Exemplo n.º 1
0
 public function index(Core_Model_Item_Abstract $item)
 {
     // Check if not search allowed
     if (isset($item->search) && !$item->search) {
         return false;
     }
     // Get info
     $type = $item->getType();
     $id = $item->getIdentity();
     $title = substr(trim($item->getTitle()), 0, 255);
     $description = substr(trim($item->getDescription()), 0, 255);
     $keywords = substr(trim($item->getKeywords()), 0, 255);
     $hiddenText = substr(trim($item->getHiddenSearchData()), 0, 255);
     // Ignore if no title and no description
     if (!$title && !$description) {
         return false;
     }
     // Check if already indexed
     $table = Engine_Api::_()->getDbtable('search', 'core');
     $select = $table->select()->where('type = ?', $type)->where('id = ?', $id)->limit(1);
     $row = $table->fetchRow($select);
     if (null === $row) {
         $row = $table->createRow();
         $row->type = $type;
         $row->id = $id;
     }
     $row->title = $title;
     $row->description = $description;
     $row->keywords = $keywords;
     $row->hidden = $hiddenText;
     $row->save();
 }