Exemple #1
0
 public function index(Khcn_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 = Default_Model_Functions::convert_vi_to_en(substr(trim($item->getTitle()), 0, 255), false);
     $description = Default_Model_Functions::convert_vi_to_en(substr(trim(strip_tags($item->getDescription())), 0, 255), false);
     // Ignore if no title and no description
     if (!$title && !$description) {
         return false;
     }
     // Check if already indexed
     $table = Khcn_Api::_()->getDbTable('search', 'default');
     $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->save();
 }