Changeset 1541


Ignore:
Timestamp:
Oct 2, 2010, 11:57:16 PM (10 years ago)
Author:
teymour
Message:

Indexation de pages qui ne sont pas liée à un objet doctrine

Location:
cpc/trunk/project
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/lib/model/solr/SolrConnector.class.php

    r1405 r1541  
    8888    for ($i = 0 ; $i < count($results['response']['docs']); $i++) {
    8989      $res = $results['response']['docs'][$i];
    90       $results['response']['docs'][$i]['object'] = Doctrine::getTable($res['object_name'])->find($res['object_id']);
     90      if ($res['object_name'] == 'NonObjectPage') {
     91        $results['response']['docs'][$i]['object'] = NonObjectPage::find($res['object_id']);
     92      }else{
     93        $results['response']['docs'][$i]['object'] = Doctrine::getTable($res['object_name'])->find($res['object_id']);
     94      }
    9195      if (!$results['response']['docs'][$i]['object'])
    9296        $unset[] = $i;
  • cpc/trunk/project/lib/task/indexSolrTask.class.php

    r1456 r1541  
    2121    $this->addOption('removeAll', null, sfCommandOption::PARAMETER_OPTIONAL, 'Drop solr database (=no|yes no default)', 'no');
    2222    $this->addOption('all', null, sfCommandOption::PARAMETER_OPTIONAL, 'Reindex all the database (=no|yes no default)', 'no');
     23    $this->addOption('pages', null, sfCommandOption::PARAMETER_OPTIONAL, 'Index static pages (=no|yes no default)', 'no');
    2324
    2425    $this->file_conf = sys_get_temp_dir().DIRECTORY_SEPARATOR."reindex_slor.db";
     
    2627    if (file_exists($this->file_conf)) {
    2728      $this->state = unserialize(file_get_contents($this->file_conf));
     29    }
     30  }
     31
     32  protected function indexNonObjectPages($solr) {
     33    $array = NonObjectPage::getElements();
     34    foreach ($array as $k => $v) {
     35      $json = new stdClass();
     36      $json->id = 'NonObjectPage/'.$k;
     37      $json->object_name = 'NonObjectPage';
     38      $json->object_id = $k;
     39      $weight = $v['weight'];
     40      if (!$weight) {
     41        $weight = 1;
     42      }
     43      $json->title->content = $v['title'];
     44      $json->title->weight  = $weight * 1.2;
     45      if (isset($a['description'])) {
     46        $json->description->content = $v['description'];
     47        $json->description->weight  = $weight;
     48      }
     49      $solr->updateLuceneRecord($json);
    2850    }
    2951  }
     
    3759    if ($options['removeAll'] == 'yes') {
    3860      $solr->deleteAll();
     61    }
     62
     63    if ($options['pages'] == 'yes') {
     64      $this->indexNonObjectPages($solr);
     65      return ;
    3966    }
    4067
Note: See TracChangeset for help on using the changeset viewer.