当前位置: 首页>>代码示例>>PHP>>正文


PHP DataType::model方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:arduanov,项目名称:eco,代码行数:21,代码来源:Module_fields.php

示例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);
     }
 }
开发者ID:arduanov,项目名称:eco,代码行数:38,代码来源:ParamsController.php

示例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);
     }
 }
开发者ID:arduanov,项目名称:eco,代码行数:50,代码来源:ParamsController.php


注:本文中的DataType::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。