Esempio n. 1
0
 public function renderDefault($q, $page = 1)
 {
     try {
         $ids = array();
         foreach (fulltext::index()->find($q) as $hit) {
             $ids[] = $hit->getDocument()->id;
         }
         $this->template->paginator = new Paginator();
         $this->template->paginator->setItemCount(count($ids));
         $this->template->paginator->setItemsPerPage(Environment::getVariable('itemsPerPage', 30));
         $this->template->paginator->setPage($page);
         $this->template->products = mapper::products()->findByIds(array_slice($ids, $this->template->paginator->getOffset(), $this->template->paginator->getLength()));
         $this->template->title = __('Search results for ``%s"', $q);
         $this->template->q = $q;
         Environment::getSession(SESSION_SEARCH_NS)->last = $q;
         searchlog::log($q);
     } catch (Exception $e) {
         $this->template->products = array();
     }
 }
Esempio n. 2
0
 public function renderSearchStats()
 {
     $this->template->title = __('Search statistics');
     searchlog::init(SEARCHLOG_DIR);
     $this->template->stats = searchlog::stats();
 }
Esempio n. 3
0
 /**
  * Initialize
  * @var string
  */
 public static function init($dir)
 {
     parent::init($dir);
     self::$stats = metatable::open($dir . DIRECTORY_SEPARATOR . '.stats', metatable::READWRITE | metatable::AUTOCLOSE);
 }