Ejemplo n.º 1
0
 public function keywordAction()
 {
     // Action parameters
     $search = $this->getRequest()->getParam("search");
     // A bit of filtering
     $search = substr($search, 0, 50);
     // Get all the items; if we are an admin, we also get the hidden one
     $data = new Data();
     $sourcesTable = new Sources();
     $sources = $sourcesTable->getSources();
     $items = array();
     foreach ($sources as $source) {
         $s = SourceModel::newInstance($source['service'], $source);
         $index = $s->getSearchIndex();
         $prefix = $s->getServicePrefix();
         $id = $s->getID();
         if ($index != '') {
             $r = $data->search($id, $prefix, $index, $search, $this->_admin);
             if ($r) {
                 $items = array_merge($items, $r);
             }
         }
     }
     // Sort the result of the search
     $sorter = new Stuffpress_SortItems();
     $sorter->sort($items, 1);
     // Prepare the common elements
     $this->common();
     // Add specifics entries
     $this->view->search = $search;
     $this->view->items = $items;
     $this->view->models = $this->getModels();
     // Set page title
     $title = $this->_properties->getProperty('title');
     $subtitle = $this->_properties->getProperty('subtitle');
     $separator = $title ? "|" : "";
     $this->view->headTitle("{$title} {$separator} Search results for {$search}");
     // Add specific styles and javascripts
     $this->view->headScript()->appendFile('js/controllers/timeline.js');
     $this->view->headLink()->appendStylesheet('style/lightbox.css');
     // Render the index
     $this->render('index');
 }
Ejemplo n.º 2
0
 public function searchAction()
 {
     // Action parameters
     $search = $this->getRequest()->getParam("search");
     $output = $this->getRequest()->getParam("output");
     // A bit of filtering
     $search = substr($search, 0, 50);
     // Get all the items; if we are an admin, we also get the hidden one
     $data = new Data();
     $sourcesTable = new Sources();
     $sources = $sourcesTable->getSources();
     $items = array();
     foreach ($sources as $source) {
         $s = SourceModel::newInstance($source['service'], $source);
         $index = $s->getSearchIndex();
         $prefix = $s->getServicePrefix();
         $id = $s->getID();
         if ($index != '') {
             $r = $data->search($id, $prefix, $index, $search, $this->_admin);
             if ($r) {
                 $items = array_merge($items, $r);
             }
         }
     }
     // Sort the result of the search
     $sorter = new Stuffpress_SortItems();
     $sorter->sort($items, 1);
     // Set page title
     $title = $this->_properties->getProperty('title');
     $subtitle = $this->_properties->getProperty('subtitle');
     $separator = $title ? "|" : "";
     $page_title = "{$title} {$separator} Search results for {$search}";
     $this->view->headTitle($page_title);
     // If rss, we stop here
     //		if ($output == "rss") {
     //			$key = "search_$search";
     //			$this->generateRss($key, $items, $page_title);
     //		}
     // Prepare the common elements
     $this->common();
     // Add specifics entries
     $this->view->search = $search;
     $this->view->items = $items;
     $this->view->models = $this->getModels();
     // Add specific styles and javascripts
     $this->view->headScript()->appendFile('js/controllers/timeline.js');
     $this->view->headLink()->appendStylesheet('style/lightbox.css');
     // Set link to RSS of page
     //		$host 		= trim(Zend_Registry::get("host"), '/');
     //		$rss_link   = "http://$host/search/" . urlencode($search) . "?output=rss";
     //		$this->view->headLink()->appendAlternate($rss_link, "application/rss+xml", "RSS Stream");
     // Render the index
     $this->render('index');
 }