123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- namespace app\models;
- use Yii;
- /**
- * This is the model class for table "{{%content_model}}".
- *
- * @property int $model_id ID
- * @property string $name 名称
- * @property string $table_name 对应表
- * @property string $description 描述
- * @property string|null $settings 配置信息
- * @property int $enable_search 是否开启全站搜索
- * @property string $default_theme 风格
- * @property string $category_template 栏目聚合页模板
- * @property string $list_template 列表页模板
- * @property string $show_template 详细页模板
- * @property string $wap_default_theme WAP风格
- * @property string $wap_category_template WAP栏目聚合页模板
- * @property string $wap_list_template WAP列表页模板
- * @property string $wap_show_template WAP详细页模板
- * @property int $items 信息数
- * @property int $type 模块类型 1:内容模型 2:会员模型
- * @property int $is_system 系统模块
- * @property int $disabled 禁用 1
- * @property int $create_time 添加时间
- * @property int $list_order 排序
- */
- class ContentModel extends \app\common\models\EActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%content_model}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['name', 'table_name','type'], 'required'],
- [['settings'], 'string'],
- [['enable_search', 'items', 'type', 'for_cms', 'is_system', 'disabled', 'create_time', 'list_order'], 'integer'],
- [['name', 'default_theme', 'category_template', 'list_template', 'show_template', 'wap_default_theme', 'wap_category_template', 'wap_list_template', 'wap_show_template'], 'string', 'max' => 30],
- [['table_name'], 'string', 'max' => 20],
- [['description'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'model_id' => Yii::t('attr','content_model.model_id'),
- 'name' => Yii::t('attr','content_model.name'),
- 'table_name' => Yii::t('attr','content_model.table_name'),
- 'description' => Yii::t('attr','content_model.description'),
- 'settings' => Yii::t('attr','content_model.settings'),
- 'enable_search' => Yii::t('attr','content_model.enable_search'),
- 'default_theme' => Yii::t('attr','content_model.default_theme'),
- 'category_template' => Yii::t('attr','content_model.category_template'),
- 'list_template' => Yii::t('attr','content_model.list_template'),
- 'show_template' =>Yii::t('attr','content_model.show_template'),
- 'wap_default_theme' => Yii::t('attr','content_model.wap_default_theme'),
- 'wap_category_template' => Yii::t('attr','content_model.wap_category_template'),
- 'wap_list_template' => Yii::t('attr','content_model.wap_list_template'),
- 'wap_show_template' => Yii::t('attr','content_model.wap_show_template'),
- 'items' => Yii::t('attr','content_model.items'),
- 'type' => Yii::t('attr','content_model.type'),
- 'for_cms' => Yii::t('attr','content_model.for_cms'),
- 'is_system' => Yii::t('attr','content_model.is_system'),
- 'disabled' => Yii::t('attr','content_model.disabled'),
- 'create_time' => Yii::t('attr','content_model.create_time'),
- 'list_order' =>Yii::t('attr','content_model.list_order'),
- ];
- }
- //类型
- public static function typeOptions($k=null)
- {
- $options = array('1'=>'内容模型','2'=>'用户模型');
- if(is_numeric($k))return $options[$k];
- return $options;
- }
- //模型选项
- public static function userModelOptions($k=null)
- {
- $options = [];
- $resultList = ContentModel::find()->where("disabled=0 and type=2")->all();
- if(is_array($resultList))foreach($resultList as $result)
- {
- $options[$result->model_id] = $result->name;
- }
- if($k>0)return $options[$k];
- return $options;
- }
- //内容模型选项
- public static function modelOptions($k=null)
- {
- $options = [];
- $resultList = ContentModel::find()->where("disabled=0 and type=1")->all();
- if(is_array($resultList))foreach($resultList as $result)
- {
- $options[$result->model_id] = $result->name;
- }
- if($k>0)return $options[$k];
- return $options;
- }
- }
|