Example #1
0
 /**
  * Hook for node listing - fetches comment count
  *
  * @param Zoo_Content_Interface $item
  *
  * @return void
  *
  */
 public function nodeList(&$item)
 {
     // Count comments per node
     $counts = Zoo::getService('content')->countChildren($item->id, 'comment');
     $count = isset($counts[$item->id]) ? $counts[$item->id] : 0;
     if ($count > 0) {
         $this->view->url = $item->url();
         $this->view->count = $count;
         /**
          * Render HTML
          */
         $item->hooks['comments'] = $this->render('nodelist', 'Comments');
     }
 }
Example #2
0
 /**
  * Build Apache_Solr_Document from Zoo_Content_Interface object
  *
  * @param Zoo_Content_Interface $item
  * @return Apache_Solr_Document
  */
 protected function _build(Zoo_Content_Interface $item)
 {
     // (Re-)Index document
     $document = new Apache_Solr_Document();
     $document->nid = $item->id;
     $document->title = $item->title;
     list($content) = Zoo::getService('content')->getRenderedContent($item->id, 'Display');
     $document->contents = strip_tags($content);
     $document->link = $item->url();
     $document->type = $item->type;
     $document->uid = $item->uid;
     // Index wants a W3C canonical timestamp in GMT _WITH_ Z at the end
     $date = new Zend_Date($item->published, Zend_Date::TIMESTAMP);
     $date->setTimezone('gmt');
     $document->published = str_replace("+00:00", "Z", $date->get(Zend_Date::W3C));
     return $document;
 }
Example #3
0
 /**
  * Add node to index
  *
  * @param Zoo_Content_Interface $item
  */
 protected function _build(Zoo_Content_Interface $item)
 {
     // Delete existing document, if exists
     $hits = $this->index->find('nid:' . $item->id);
     foreach ($hits as $hit) {
         $this->index->delete($hit->id);
     }
     // (Re-)Index document
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::text('nid', $item->id));
     $doc->addField(Zend_Search_Lucene_Field::unIndexed('link', $item->url()));
     $doc->addField(Zend_Search_Lucene_Field::unStored('title', $item->title));
     $doc->addField(Zend_Search_Lucene_Field::unStored('type', $item->type));
     $doc->addField(Zend_Search_Lucene_Field::unStored('published', $item->published));
     $doc->addField(Zend_Search_Lucene_Field::unStored('uid', $item->uid));
     list($content) = Zoo::getService('content')->getRenderedContent($item->id, 'Display');
     $doc->addField(Zend_Search_Lucene_Field::unStored('contents', strip_tags($content)));
     return $doc;
 }
Example #4
0
 /**
  * Transform a node into a page
  * @param $node
  * @return Zend_Navigation_Page_Uri
  */
 function nodeToPage(Zoo_Content_Interface $node, $active = false)
 {
     return new Zend_Navigation_Page_Uri(array('uri' => $node->url(), 'title' => $node->title, 'label' => $node->title, 'id' => 'node_' . $node->id, 'resource' => 'content.node', 'privilege' => 'index.' . $node->type, 'active' => $active));
 }