'cmsps_editos', 'primary' => 'id_edito', 'multilang' => TRUE, 'multilang_shop' => TRUE, 'fields' => array( 'active' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), // Lang fields 'title' => array('type' => self::TYPE_STRING, 'lang' => TRUE, 'validate' => 'isGenericName', 'required' => TRUE), 'slug' => array('type' => self::TYPE_STRING, 'lang' => TRUE, 'validate' => 'isGenericName'), 'intro' => array('type' => self::TYPE_HTML, 'lang' => TRUE, 'validate' => 'isCleanHtml'), 'content' => array('type' => self::TYPE_HTML, 'lang' => TRUE, 'validate' => 'isCleanHtml'), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => TRUE, 'validate' => 'isGenericName'), 'meta_desc' => array('type' => self::TYPE_STRING, 'lang' => TRUE, 'validate' => 'isGenericName'), 'date_add' => array('type' => self::TYPE_DATE), 'date_upd' => array('type' => self::TYPE_DATE) ), ); public function __construct($id = NULL, $id_lang = NULL, $id_shop = NULL) { parent::__construct($id, $id_lang, $id_shop); } public static function getLast($id_lang) { $collection_post = new Collection('CmsPsEdito', $id_lang); $collection_post->where('active', '=', 1); $collection_post->orderby('date_add', 'DESC'); $collection_post->setPageSize(1); $edito = $collection_post->getFirst(); return $edito; } public static function getAllEditos($id_lang, $limit = 10, $num_page, $total = FALSE, $order_by = 'date_add') { $collection_post = new Collection('CmsPsEdito', $id_lang); $collection_post->where('active', '=', 1); $collection_post->orderBy($order_by, 'DESC'); $collection_post->setPageSize($limit); $collection_post->setPageNumber($num_page); if($total) { return $collection_post->count(); } return $articles = $collection_post->getResults(); } public static function search($query, $limit, $id_lang) { $keywords = explode(' ', $query); $result = array(); $query_posts = ' SELECT p.`id_edito` FROM `'._DB_PREFIX_.'cmsps_editos` p LEFT JOIN `'._DB_PREFIX_.'cmsps_editos_lang` pl ON(p.`id_edito` = pl.`id_edito`) WHERE p.`active` = 1 '; foreach ($keywords as $key => $keyword) { $query_posts.= 'AND ( pl.`title` LIKE "%'.pSql($keyword).'%" OR pl.`content` LIKE "%'.pSql($keyword).'%" )'; } $query_posts.= ' ORDER BY p.`date_add` DESC LIMIT '.(int)$limit ; $ids = Db::getInstance()->executeS($query_posts); if ($ids) { foreach ($ids as $key => $id) { $result[] = new CmsPsEdito($id['id_edito'], $id_lang); } } return $result; } }