Ignore:
Timestamp:
May 25, 2010, 10:54:53 PM (11 years ago)
Author:
teymour
Message:

Ajout de la liste des députés

Location:
cpc/trunk/project/apps/frontend
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/apps/frontend/config/routing.yml

    r1198 r1201  
    126126  url: /deputes/rechercher/
    127127  param: {module: parlementaire, action: list}
     128list_parlementaires_json:
     129  url: /deputes/json
     130  param: {module: api, action: listParlementaires, type: json}
     131list_parlementaires_xml:
     132  url: /deputes/xml
     133  param: {module: api, action: listParlementaires, type: xml}
     134list_parlementaires_csv:
     135  url: /deputes/csv
     136  param: {module: api, action: listParlementaires, type: csv}
    128137list_parlementaires_alpha:
    129138  url: /deputes/:search
  • cpc/trunk/project/apps/frontend/modules/api/actions/actions.class.php

    r1200 r1201  
    6767  }
    6868
     69  public function executeListParlementaires(sfWebRequest $request)
     70  {
     71    $deputes = doctrine::getTable('Parlementaire')->createQuery('p')->execute();
     72    $this->res = array('deputes' => array());
     73    $this->champs = array();
     74    $this->breakline = 'depute';
     75    sfLoader::loadHelpers('Url');
     76    foreach($deputes as $dep) {
     77      $depute = array();
     78      $depute['id'] = $dep->id;
     79      $this->champs['id'] = 1;
     80      $depute['nom'] = $dep->nom;
     81      $this->champs['nom'] = 1;
     82      if ($dep->fin_mandat)
     83        $depute['ancien_depute'] = 1;
     84      else if ($request->getParameter('type') == 'csv')
     85        $depute['ancien_depute'] = 0;
     86      $this->champs['ancien_depute'] = 1;
     87      $depute['mandat_debut'] = $dep->debut_mandat;
     88      $this->champs['mandat_debut'] = 1;
     89      if ($request->getParameter('type') == 'csv' && $dep->fin_mandat)
     90        $depute['mandat_fin'] = $dep->fin_mandat;
     91      $this->champs['mandat_fin'] = 1;
     92      $depute['api_url'] = 'http://'.$_SERVER['HTTP_HOST'].url_for('api/parlementaire?type='.$request->getParameter('type').'&slug='.$dep->slug);
     93      $this->champs['api_url'] = 1;
     94      $this->res['deputes'][] = array('depute' => $depute);
     95    }
     96    $this->templatize($request, 'nosdeputes.fr_deputes');
     97  }
    6998  public function executeParlementaire(sfWebRequest $request)
    7099  {
     
    81110    $this->res['depute']['nom_circo'] = $depute->nom_circo;
    82111    $this->res['depute']['num_circo'] = $depute->num_circo;
    83     $this->res['depute']['debut_mandat'] = $depute->debut_mandat;
     112    $this->res['depute']['mandat_debut'] = $depute->debut_mandat;
    84113    if ($depute->fin_mandat)
    85       $this->res['depute']['fin_mandat'] = $depute->fin_mandat;
     114      $this->res['depute']['mandat_fin'] = $depute->fin_mandat;
    86115    $this->res['depute']['groupe'] = $depute->getGroupe();
    87116    $this->res['depute']['groupe_sigle'] = $depute->groupe_acronyme;
Note: See TracChangeset for help on using the changeset viewer.