55 lines
1.8 KiB
PHP
Raw Normal View History

2015-07-29 17:53:14 +02:00
<?php
class CmsPsEdito extends ObjectModel {
public $id_edito;
public $date_add;
public $date_upd;
public $active;
public $title;
public $slug;
public $intro;
public $content;
public $meta_title;
public $meta_desc;
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => '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);
}
2015-07-30 15:08:21 +02:00
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;
}
2015-07-29 17:53:14 +02:00
}