Changeset 1447


Ignore:
Timestamp:
Sep 27, 2010, 12:17:10 AM (10 years ago)
Author:
teymour
Message:

Ajout des tags dans l'API

Location:
cpc/trunk/project/apps/frontend/modules/solr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/apps/frontend/modules/solr/actions/actions.class.php

    r1446 r1447  
    7575    $type = $request->getParameter('type');
    7676
     77    $this->tags = 0;
    7778    if ($type) {
    7879      sfConfig::set('sf_web_debug', false);
     80      $this->tags = $request->getParameter('tags');
    7981    }
    8082
     
    101103
    102104    if ($type == 'csv') {
    103       $this->getResponse()->setContentType('application/csv; charset=utf-8');
     105      //      $this->getResponse()->setContentType('application/csv; charset=utf-8');
     106      $this->getResponse()->setContentType('text/plain; charset=utf-8');
    104107      $this->setTemplate('csv');
    105108      $this->setLayout(false);
  • cpc/trunk/project/apps/frontend/modules/solr/templates/csvSuccess.php

    r1446 r1447  
     1<?php if (!$tags) :?>
    12type document;document id;url vers document;resultats <?php echo $results['start'] + 1; ?> à <?php echo $results['end'] - 1; ?> sur <?php echo $results['numFound']; ?>
    23
     
    1011  echo ";\n";
    1112}
    12 
     13return;
     14endif;
     15?>
     16tag type;tag nom;nb
     17<?php
     18foreach(array_keys($facet) as $k)
     19  if (isset($facet[$k]['values']) && count($facet[$k]['values']))
     20    foreach($facet[$k]['values'] as $value => $nb)
     21     if ($nb)
     22       echo "$k:$value:$nb\n";
  • cpc/trunk/project/apps/frontend/modules/solr/templates/jsonSuccess.php

    r1446 r1447  
    1 {
    2   "start": <?php echo $results['start'] + 1; ?>,
    3     "end" : <?php echo $results['end'] - 1; ?>,
    4       "last_result" : <?php echo $results['numFound'];  ?>,
    5         "results" : {
    6 <?php
     1<?php if (!$tags) : ?>
     2{ "start": <?php echo $results['start'] + 1; ?>, "end" : <?php echo $results['end'] - 1; ?>, "last_result" : <?php echo $results['numFound'];  ?>, "results" : {<?php
    73            $nb = 0;
    84foreach ($results['docs'] as $record)
     
    1612  echo "document_url:\"\"]";
    1713}
    18           ?> }}
    19 
     14?> }}<?php return;
     15endif;
     16?>
     17{
     18<?php
     19    $cpt = 0;
     20foreach(array_keys($facet) as $k)
     21  if (isset($facet[$k]['values']) && count($facet[$k]['values']))
     22    foreach($facet[$k]['values'] as $value => $nb)
     23      if ($nb) {
     24        if ($cpt)
     25          echo ",";
     26        else
     27          $cpt = 1;
     28        echo "[\"tag_type\":\"$k\";\"tag_nom\":\"$value\",\"nb\":$nb]\n";
     29      }
     30  ?>}
  • cpc/trunk/project/apps/frontend/modules/solr/templates/xmlSuccess.php

    r1446 r1447  
     1<?php if (!$tags) : ?>
    12<search>
    23<start><?php echo $results['start'] + 1; ?></start>
     
    1415}
    1516?></results></search>
     17<? return ; endif; ?>
     18<search>
     19<tags>
     20<?php
     21foreach(array_keys($facet) as $k)
     22  if (isset($facet[$k]['values']) && count($facet[$k]['values']))
     23    foreach($facet[$k]['values'] as $value => $nb)
     24     if ($nb)
     25       echo "<tag><type>$k</type><nom>$value</nom><nb>$nb</nb></tag>\n";
    1626
     27?></tags>
     28</search>
Note: See TracChangeset for help on using the changeset viewer.