Changeset 1467


Ignore:
Timestamp:
Sep 28, 2010, 4:08:02 PM (10 years ago)
Author:
teymour
Message:

Migration des urls de recherche vers solr

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

Legend:

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

    r1463 r1467  
    109109  url: /id/:id
    110110  param: {module: parlementaire, action: id}
    111 depute_id_type:
    112   url: /id/:id/:type
     111depute_id_format:
     112  url: /id/:id/:format
    113113  param: {module: parlementaire, action: id}
    114114parlementaire_id:
    115115  url: /parlementaire/id/:id
    116116  param: {module: parlementaire, action: id}
    117 parlementaire_id_type:
    118   url: /parlementaire/id/:id/:type
     117parlementaire_id_format:
     118  url: /parlementaire/id/:id/:format
    119119  param: {module: parlementaire, action: id}
    120120# Liste de tous les parlementaires ou par catégorie
     
    126126  param: {module: parlementaire, action: tag}
    127127list_parlementaires_search:
    128   url: /deputes/rechercher/:search
    129   param: {module: parlementaire, action: list}
    130 list_parlementaires_search_empty:
    131   url: /deputes/rechercher/
    132   param: {module: parlementaire, action: list}
     128  url: /deputes/rechercher/:query
     129  param: {module: solr, action: redirect, object_name: Parlementaire}
    133130list_parlementaires_json:
    134131  url: /deputes/json
    135   param: {module: api, action: listParlementaires, type: json}
     132  param: {module: api, action: listParlementaires, format: json}
    136133list_parlementaires_xml:
    137134  url: /deputes/xml
    138   param: {module: api, action: listParlementaires, type: xml}
     135  param: {module: api, action: listParlementaires, format: xml}
    139136list_parlementaires_csv:
    140137  url: /deputes/csv
    141   param: {module: api, action: listParlementaires, type: csv}
     138  param: {module: api, action: listParlementaires, format: csv}
    142139list_parlementaires_alpha:
    143   url: /deputes/:search
    144   param: {module: parlementaire, action: list}
     140  url: /deputes/:query
     141  param: {module: solr, action: redirect, object_name: Parlementaire}
    145142list_parlementaires:
    146143  url: /deputes
     
    238235
    239236# Recherche lexicale d'interventions ou d'amendements
    240 search:
    241   url: /rechercher
    242   param: {module: search, action: index}
    243237search_interventions_mots_rss:
    244   url: /rechercher/interventions/:search/rss
    245   param: {module: intervention, action: search, rss: 1}
     238  url: /rechercher/interventions/:query/rss
     239  param: {module: solr, action: redirect, object_name: Intervention, format: rss}
    246240search_interventions_mots:
    247   url: /rechercher/interventions/:search
    248   param: {module: intervention, action: search}
     241  url: /rechercher/interventions/:query
     242  param: {module: solr, action: redirect, object_name: Intervention}
    249243search_interventions:
    250244  url: /rechercher/interventions/
    251   param: {module: intervention, action: search}
     245  param: {module: solr, action: redirect, object_name: Intervention}
    252246search_amendements_mots_rss:
    253   url: /rechercher/amendements/:search/rss
    254   param: {module: amendement, action: search, rss: 1}
     247  url: /rechercher/amendements/:query/rss
     248  param: {module: solr, action: redirect, object_name: Amendement, format: rss}
    255249search_amendements_mots:
    256   url: /rechercher/amendements/:search
    257   param: {module: amendement, action: search}
     250  url: /rechercher/amendements/:query
     251  param: {module: solr, action: redirect, object_name: Amendement, action: search}
    258252search_amendements:
    259253  url: /rechercher/amendements/
    260   param: {module: amendement, action: search}
     254  param: {module: solr, action: redirect, object_name: Amendement}
    261255search_questions_ecrites_mots_rss:
    262   url: /rechercher/questions/:search/rss
    263   param: {module: questions, action: search, rss: 1}
     256  url: /rechercher/questions/:query/rss
     257  param: {module: solr, action: redirect, object_name: QuestionEcrite, format: rss}
    264258search_questions_ecrites_mots:
    265   url: /rechercher/questions/:search
    266   param: {module: questions, action: search}
     259  url: /rechercher/questions/:query
     260  param: {module: solr, action: redirect, object_name: QuestionEcrite}
    267261search_questions_ecrites:
    268262  url: /rechercher/questions/
    269   param: {module: questions, action: search}
     263  param: {module: solr, action: redirect, object_name: QuestionEcrite}
    270264
    271265
     
    295289  param: {module: parlementaire, action: top}
    296290api_synthese:
    297   url: /synthese/:date/:type
     291  url: /synthese/:date/:format
    298292  param: {module: api, action: top}
    299293
    300294api_document:
    301   url: /api/document/:class/:id/:type
     295  url: /api/document/:class/:id/:format
    302296  param: {module: api, action: document}
    303297
     
    410404parlementaire_api_xml:
    411405  url: /:slug/xml
    412   param: {module: api, action: parlementaire, type: xml}
     406  param: {module: api, action: parlementaire, format: xml}
    413407parlementaire_api_json:
    414408  url: /:slug/json
    415   param: {module: api, action: parlementaire, type: json}
     409  param: {module: api, action: parlementaire, format: json}
    416410parlementaire_api_csv:
    417411  url: /:slug/csv
    418   param: {module: api, action: parlementaire, type: csv}
     412  param: {module: api, action: parlementaire, format: csv}
    419413parlementaire_interventions:
    420414  url: /:slug/interventions/:type
    421   param: {module: intervention, action: parlementaire}
     415  param: {module: intervention, action: parlementaire, type: all}
    422416parlementaire_interventions_organisme:
    423417  url: /:slug/organisme/:orga/interventions/
     
    434428parlementaire_rss_commentaires:
    435429  url: /:slug/commentaires/rss
    436   param: {module: commentaire, action: list, rss: 1}
     430  param: {module: solr, action: redirect, object_name: Commentaire, format: rss}
    437431parlementaire_commentaires:
    438432  url: /:slug/commentaires
  • cpc/trunk/project/apps/frontend/modules/api/actions/actions.class.php

    r1449 r1467  
    1818  {
    1919    $class = $request->getParameter('class');
    20     $type = $request->getParameter('type');
     20    $format = $request->getParameter('format');
    2121    $id = $request->getParameter('id');
    2222    $this->forward404Unless($class);
    2323    $o = doctrine::getTable($class)->find($id);
    2424    if ($class == 'Parlementaire') {
    25       return $this->redirect('api/parlementaire?slug='.$o->slug.'&type='.$type);
     25      return $this->redirect('api/parlementaire?slug='.$o->slug.'&format='.$format);
    2626    }
    2727    $slug = $class.'_'.$id;
     
    105105      if ($dep->fin_mandat)
    106106        $depute['ancien_depute'] = 1;
    107       else if ($request->getParameter('type') == 'csv')
     107      else if ($request->getParameter('format') == 'csv')
    108108        $depute['ancien_depute'] = 0;
    109109      $this->champs['ancien_depute'] = 1;
    110110      $depute['mandat_debut'] = $dep->debut_mandat;
    111111      $this->champs['mandat_debut'] = 1;
    112       if ($request->getParameter('type') == 'csv' || $dep->fin_mandat)
     112      if ($request->getParameter('format') == 'csv' || $dep->fin_mandat)
    113113        $depute['mandat_fin'] = $dep->fin_mandat;
    114114      $this->champs['mandat_fin'] = 1;
    115       $depute['api_url'] = 'http://'.$_SERVER['HTTP_HOST'].url_for('api/parlementaire?type='.$request->getParameter('type').'&slug='.$dep->slug);
     115      $depute['api_url'] = 'http://'.$_SERVER['HTTP_HOST'].url_for('api/parlementaire?format='.$request->getParameter('format').'&slug='.$dep->slug);
    116116      $this->champs['api_url'] = 1;
    117117      $this->res['deputes'][] = array('depute' => $depute);
     
    161161  private function templatize($request, $filename) {
    162162    $this->setLayout(false);
    163     switch($request->getParameter('type')) {
     163    switch($request->getParameter('format')) {
    164164      case 'json':
    165165        $this->setTemplate('json');
  • cpc/trunk/project/apps/frontend/modules/solr/actions/actions.class.php

    r1448 r1467  
    7373    $date = $request->getParameter('date');
    7474    $from = $request->getParameter('from');
    75     $type = $request->getParameter('type');
     75    $format = $request->getParameter('format');
    7676
    7777    $this->tags = 0;
    78     if ($type) {
     78    if ($format) {
    7979      sfConfig::set('sf_web_debug', false);
    8080      $this->tags = $request->getParameter('tags');
    81       $this->type = $type;
    82     }
    83 
    84     if ($type == 'rss') {
     81      $this->format = $format;
     82    }
     83
     84    if ($format == 'rss') {
    8585      $this->setTemplate('rss');
    8686      $this->feed = new sfRssFeed();
     
    9191    }
    9292
    93     if ($type == 'json') {
     93    if ($format == 'json') {
    9494      $this->getResponse()->setContentType('text/plain; charset=utf-8');
    9595      $this->setTemplate('json');
     
    9797    }
    9898
    99     if ($type == 'xml') {
     99    if ($format == 'xml') {
    100100      $this->getResponse()->setContentType('text/xml; charset=utf-8');
    101101      $this->setTemplate('xml');
     
    103103    }
    104104
    105     if ($type == 'csv') {
     105    if ($format == 'csv') {
    106106      //      $this->getResponse()->setContentType('application/csv; charset=utf-8');
    107107      $this->getResponse()->setContentType('text/plain; charset=utf-8');
     
    200200    }
    201201  }
     202  public function executeRedirect(sfWebRequest $request)
     203  {
     204    $add = '';
     205    if ($p = $request->getParameter('format')) {
     206      $add .= '&format='.$p;
     207    }
     208    if ($p = $request->getParameter('object_name')) {
     209      $add .= '&object_name='.$p;
     210    }
     211    if ($p = $request->getParameter('slug')) {
     212      $add .= '&tag=parlementaire='.preg_replace('/\-/', '+', $p);
     213    }
     214    return $this->redirect('solr/search?query='.$request->getParameter('query').$add);
     215  }
    202216}
  • cpc/trunk/project/apps/frontend/modules/solr/templates/csvSuccess.php

    r1462 r1467  
    99  echo ";";
    1010  echo $record['object']->id;
    11   echo url_for('@api_document?type='.$type.'&class='.get_class($record['object']).'&id='.$record['object']->id)."\n";
     11  echo url_for('@api_document?format='.$format.'&class='.get_class($record['object']).'&id='.$record['object']->id)."\n";
    1212  echo ";\n";
    1313}
  • cpc/trunk/project/apps/frontend/modules/solr/templates/jsonSuccess.php

    r1461 r1467  
    1010  echo "[document_type:\"".get_class($record['object'])."\",";
    1111  echo "document_id:".$record['object']->id.",";
    12   echo "document_url:\"".sfConfig::get('app_baseurl').url_for('@api_document?type='.$type.'&class='.get_class($record['object']).'&id='.$record['object']->id)."\"]";
     12  echo "document_url:\"".sfConfig::get('app_baseurl').url_for('@api_document?format='.$format.'&class='.get_class($record['object']).'&id='.$record['object']->id)."\"]";
    1313}
    1414?> }}<?php return;
  • cpc/trunk/project/apps/frontend/modules/solr/templates/xmlSuccess.php

    r1448 r1467  
    1111  echo "<document_type>".get_class($record['object'])."</document_type>";
    1212  echo "<document_id>".$record['object']->id."</document_id>";
    13   echo "<document_url>".sfConfig::get('app_base_url').url_for('@api_document?type='.$type.'&class='.get_class($record['object']).'&id='.$record['object']->id)."</document_url>";
     13  echo "<document_url>".sfConfig::get('app_base_url').url_for('@api_document?format='.$format.'&class='.get_class($record['object']).'&id='.$record['object']->id)."</document_url>";
    1414  echo "</result>\n";
    1515}
Note: See TracChangeset for help on using the changeset viewer.