本文整理汇总了PHP中DataType::model方法的典型用法代码示例。如果您正苦于以下问题:PHP DataType::model方法的具体用法?PHP DataType::model怎么用?PHP DataType::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataType
的用法示例。
在下文中一共展示了DataType::model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$page_id = $this->page_id;
$controller = Yii::app()->getController();
$model = new ModuleFields();
if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
$role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
if ($role_id < 2) {
// доступно для пользователей первой роли (например, «Реактиву»)
$model = $this->create_item($page_id, $model);
$this->update_order($page_id);
}
$this->update_values($page_id);
$data_type_drop_down_list = DataType::model()->getDropDownList();
unset($data_type_drop_down_list[5]);
unset($data_type_drop_down_list[6]);
$this->render('module_fields', array('model' => $model, 'data_type_drop_down_list' => $data_type_drop_down_list, 'page_id' => $page_id));
} else {
$controller->redirect(Yii::app()->request->scriptUrl);
}
}
示例2: actionSettings
public function actionSettings($page_id = null, $id = null)
{
$role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
if ($role_id < 2 && !is_null($page_id) && Pages::model()->existsPage($page_id)) {
$mpage_id = ModulesInPages::model()->getLink((int) $page_id, $this->module->id);
if ($mpage_id == 5) {
$mpage_id = 4;
}
if ($mpage_id == 54) {
$mpage_id = 4;
}
if ($mpage_id == 56) {
$mpage_id = 4;
}
if ($mpage_id == 58) {
$mpage_id = 4;
}
if (!is_null($id) && ModuleList3Params::model()->existsItem($mpage_id, $id)) {
$model = ModuleList3Params::model()->findByPk($id);
if (isset($_POST['ModuleList3Params'])) {
$model->attributes = $_POST['ModuleList3Params'];
if ($model->save()) {
Yii::app()->user->setFlash('message', '<p style="color:green;">Сохранено</p>');
$this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/params/settings&page_id=' . $page_id . '&id=' . $id);
} else {
Yii::app()->user->setFlash('message', '<p style="color:red;">Ошибка</p>');
}
}
$model = ModuleList3Params::model()->getItem($id);
$data_type_drop_down_list = DataType::model()->getDropDownList();
$this->render('settings', array('model' => $model, 'data_type_drop_down_list' => $data_type_drop_down_list, 'page_id' => $page_id, 'id' => $id));
} else {
$this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module->id);
}
} else {
$this->redirect(Yii::app()->request->scriptUrl);
}
}
示例3: actionSettings
public function actionSettings($page_id = null, $id = null)
{
$role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
if ($role_id < 2 && !is_null($page_id) && Pages::model()->existsPage($page_id)) {
$mpage_id = ModulesInPages::model()->getLink((int) $page_id, $this->module->id);
if (!is_null($id) && ModuleList4Params::model()->existsItem($mpage_id, $id)) {
$model = ModuleList4Params::model()->findByPk($id);
if (isset($_POST['ModuleList4Params'])) {
$model->attributes = $_POST['ModuleList4Params'];
$model->settings = array();
foreach ($model->defaultSettings['list4'] as $code => $setting) {
switch ($setting['type']) {
case 'checkbox':
$sValue = isset($_POST['ModuleList4Params']['settings'][$code]) ? true : false;
$model->settings = array_merge($model->settings, array($code => $sValue));
break;
case 'string':
if (isset($_POST['ModuleList4Params']['settings'][$code])) {
$sValue = trim($_POST['ModuleList4Params']['settings'][$code]);
} else {
$sValue = $setting['value'];
}
$model->settings = array_merge($model->settings, array($code => $sValue));
break;
default:
break;
}
}
if (!is_null($model->settings)) {
$model->settings = serialize($model->settings);
}
if ($model->save()) {
Yii::app()->user->setFlash('message', '<p style="color:green;">Сохранено</p>');
$this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/params/settings&page_id=' . $page_id . '&id=' . $id);
} else {
Yii::app()->user->setFlash('message', '<p style="color:red;">Ошибка</p>');
}
}
$model = ModuleList4Params::model()->getItem($id);
$data_type_drop_down_list = DataType::model()->getDropDownList();
$module_settings = ModuleList4Settings::model()->getItem($mpage_id);
$this->pageTitle = $module_settings->title . ' — Настройки параметра «' . $model->title . '»';
$this->render('settings', array('model' => $model, 'data_type_drop_down_list' => $data_type_drop_down_list, 'page_id' => $page_id, 'id' => $id));
} else {
$this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module->id);
}
} else {
$this->redirect(Yii::app()->request->scriptUrl);
}
}