Changeset 2628 for cpc/trunk/project
- Timestamp:
- Feb 2, 2012, 1:17:58 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpc/trunk/project/apps/frontend/modules/api/actions/actions.class.php
r2597 r2628 111 111 sfProjectConfiguration::getActive()->loadHelpers(array('Url')); 112 112 foreach($deputes as $dep) { 113 if ($request->getParameter('current') == true) { 114 $depute = $this->getParlementaireArray($dep); 115 if ($request->getParameter('format') == 'csv') 116 foreach(array_keys($depute) as $key) 117 if (!isset($this->champs[$key])) 118 $this->champs[$key] = 1; 119 } else { 120 $depute = array(); 121 $depute['id'] = $dep->id; 122 $depute['nom'] = $dep->nom; 123 if ($dep->fin_mandat && $dep->fin_mandat >= $dep->debut_mandat) 124 $depute['ancien_depute'] = 1; 125 else if ($request->getParameter('format') == 'csv') 126 $depute['ancien_depute'] = 0; 127 $depute['mandat_debut'] = $dep->debut_mandat; 128 if ($request->getParameter('format') == 'csv' || $dep->fin_mandat) 129 $depute['mandat_fin'] = $dep->fin_mandat; 130 $this->champs['id'] = 1; 131 $this->champs['nom'] = 1; 132 $this->champs['ancien_depute'] = 1; 133 $this->champs['mandat_debut'] = 1; 134 $this->champs['mandat_fin'] = 1; 135 } 113 $depute = $this->getParlementaireArray($dep, $request->getParameter('format'), ($request->getParameter('current') == true ? 1 : 2)); 114 if ($request->getParameter('format') == 'csv') 115 foreach(array_keys($depute) as $key) 116 if (!isset($this->champs[$key])) 117 $this->champs[$key] = 1; 136 118 $depute['api_url'] = 'http://'.$_SERVER['HTTP_HOST'].url_for('api/parlementaire?format='.$request->getParameter('format').'&slug='.$dep->slug); 137 119 $this->champs['api_url'] = 1; … … 148 130 $this->forward404Unless($depute); 149 131 $this->res = array(); 150 $this->res['depute'] = $this->getParlementaireArray($depute );132 $this->res['depute'] = $this->getParlementaireArray($depute, $request->getParameter('format')); 151 133 $this->multi = array(); 152 134 $this->multi['responsabilite'] = 1; … … 163 145 164 146 165 public static function getParlementaireArray($parl ) {147 public static function getParlementaireArray($parl, $format, $light = 0) { 166 148 $res = array(); 167 149 if (!$parl) … … 180 162 if ($parl->fin_mandat) 181 163 $res['mandat_fin'] = $parl->fin_mandat; 182 $groupe = $parl->getGroupe(); 183 if (is_object($groupe)) 184 $res['groupe'] = self::array2hash($groupe, 'groupe_politique'); 164 else if ($format == 'csv' && $light != 1) 165 $res['mandat_fin'] = ""; 166 if ($parl->fin_mandat && $parl->fin_mandat >= $parl->debut_mandat) 167 $res['ancien_depute'] = 1; 168 else if ($format == 'csv' && $light != 1) 169 $res['ancien_depute'] = 0; 170 if (!$light) { 171 $groupe = $parl->getGroupe(); 172 if (is_object($groupe)) 173 $res['groupe'] = self::array2hash($groupe, 'groupe_politique'); 174 else if ($format == 'csv') 175 $res['groupe'] = ""; 176 } 185 177 $res['groupe_sigle'] = $parl->groupe_acronyme; 186 $res['responsabilites'] = self::array2hash($parl->getResponsabilites(), 'responsabilite'); 187 $res['responsabilites_extra_parlementaires'] = self::array2hash($parl->getExtras(), 'responsabilite'); 188 $res['groupes_parlementaires'] = self::array2hash($parl->getGroupes(), 'responsabilite'); 189 $res['sites_web'] = self::array2hash(unserialize($parl->sites_web), 'site'); 190 $res['url_an'] = $parl->url_an; 191 $res['emails'] = self::array2hash(unserialize($parl->mails), 'email'); 192 $res['adresses'] = self::array2hash(unserialize($parl->adresses), 'adresse'); 193 $res['anciens_mandats'] = self::array2hash(unserialize($parl->anciens_mandats), 'mandat'); 194 $res['autres_mandats'] = self::array2hash(unserialize($parl->autres_mandats), 'mandat'); 195 $res['anciens_autres_mandats'] = self::array2hash(unserialize($parl->anciens_autres_mandats), 'mandat'); 178 if (!$light) { 179 $res['responsabilites'] = self::array2hash($parl->getResponsabilites(), 'responsabilite'); 180 $res['responsabilites_extra_parlementaires'] = self::array2hash($parl->getExtras(), 'responsabilite'); 181 $res['groupes_parlementaires'] = self::array2hash($parl->getGroupes(), 'responsabilite'); 182 } 183 if ($light != 2) { 184 $res['sites_web'] = self::array2hash(unserialize($parl->sites_web), 'site'); 185 $res['emails'] = self::array2hash(unserialize($parl->mails), 'email'); 186 $res['adresses'] = self::array2hash(unserialize($parl->adresses), 'adresse'); 187 $res['anciens_mandats'] = self::array2hash(unserialize($parl->anciens_mandats), 'mandat'); 188 $res['autres_mandats'] = self::array2hash(unserialize($parl->autres_mandats), 'mandat'); 189 $res['anciens_autres_mandats'] = self::array2hash(unserialize($parl->anciens_autres_mandats), 'mandat'); 190 } 196 191 $res['profession'] = $parl->profession; 197 192 $res['place_en_hemicycle'] = $parl->place_hemicycle; 193 $res['url_an'] = $parl->url_an; 198 194 $res['slug'] = $parl->getSlug(); 199 195 return $res;
Note: See TracChangeset
for help on using the changeset viewer.