Ejemplo n.º 1
0
 public function actions()
 {
     $chnid = LuLu::getGetValue('chnid');
     $channel = $this->getChannel($chnid);
     $table = CommonUtility::getCachedTable($channel['table']);
     return DefineTable::getBackActions($table);
 }
Ejemplo n.º 2
0
 public function actions()
 {
     $chnid = LuLu::getGetValue('chnid', '');
     $channel = $this->getChannel($chnid);
     $table = DefineTable::findOne(['id' => $channel['table']]);
     $ret = $table->getFrontActions();
     return $ret;
 }
Ejemplo n.º 3
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->is_default) {
             DefineTable::updateAll(['is_default' => 0]);
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 public function search($params)
 {
     $query = DefineTable::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->addCondition($query, 'lable');
     $this->addCondition($query, 'lable', true);
     $this->addCondition($query, 'name');
     $this->addCondition($query, 'name', true);
     $this->addCondition($query, 'description');
     $this->addCondition($query, 'description', true);
     $this->addCondition($query, 'note');
     $this->addCondition($query, 'note', true);
     return $dataProvider;
 }
Ejemplo n.º 5
0
 public static function createFieldCache()
 {
     self::createCacheFile();
     $content = '<?php' . self::$newLine;
     $tables = DefineTable::findAll();
     foreach ($tables as $table) {
         $tableName = $table['table_name'];
         $dataList = DefineTableField::findAll(['table' => $tableName]);
         foreach ($dataList as $row) {
             $content .= '$cachedFields[\'' . $tableName . '\'][\'' . $row['field_name'] . '\']=[' . self::$newLine;
             $content .= self::getCacheItem('id', $row, 'int');
             $content .= self::getCacheItem('table', $row);
             $content .= self::getCacheItem('field_name', $row);
             $content .= self::getCacheItem('name', $row);
             $content .= self::getCacheItem('type', $row);
             $content .= self::getCacheItem('length', $row, 'int');
             $content .= self::getCacheItem('is_null', $row, 'bool');
             $content .= self::getCacheItem('is_main', $row, 'bool');
             $content .= self::getCacheItem('is_sys', $row, 'bool');
             $content .= self::getCacheItem('sort_num', $row, 'int');
             $content .= self::getCacheItem('note', $row);
             $content .= self::getCacheItem('front_status', $row, 'bool');
             $content .= self::getCacheItem('front_fun_add', $row);
             $content .= self::getCacheItem('front_fun_update', $row);
             $content .= self::getCacheItem('front_fun_show', $row);
             $content .= self::getCacheItem('front_form_type', $row);
             $content .= self::getCacheItem('front_form_option', $row);
             $content .= self::getCacheItem('front_form_default', $row);
             $content .= self::getCacheItem('front_form_source', $row);
             $content .= self::getCacheItem('front_form_html', $row);
             $content .= self::getCacheItem('front_note', $row);
             $content .= self::getCacheItem('back_status', $row, 'bool');
             $content .= self::getCacheItem('back_fun_add', $row);
             $content .= self::getCacheItem('back_fun_update', $row);
             $content .= self::getCacheItem('back_fun_show', $row);
             $content .= self::getCacheItem('back_form_type', $row);
             $content .= self::getCacheItem('back_form_option', $row);
             $content .= self::getCacheItem('back_form_default', $row);
             $content .= self::getCacheItem('back_form_source', $row);
             $content .= self::getCacheItem('back_form_html', $row);
             $content .= self::getCacheItem('back_note', $row);
             $content .= "];" . self::$newLine;
         }
     }
     self::writeFile('cachedFields.php', $content);
 }
Ejemplo n.º 6
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load($_POST)) {
         $parentIds = Channel::getParentIds($model['parent_id']);
         if (in_array($model['id'], $parentIds)) {
             LuLu::setErrorMessage('不能设置父节点为当前节点的子节点');
             return $this->redirect(['update', 'id' => $id]);
         }
         $model->save();
         CacheUtility::createChannelCache();
         return $this->redirect(['index']);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['tableList'] = DefineTable::getAllTables();
         $locals['channelTpls'] = $this->getTpl('channel_');
         $locals['listTpls'] = $this->getTpl('list_');
         $locals['detailTpls'] = $this->getTpl('detail_');
         return $this->render('update', $locals);
     }
 }
Ejemplo n.º 7
0
 public static function getActions($table, $type = 'back')
 {
     $ret = [];
     $tableName = $table['table_name'];
     $ret['index'] = DefineTable::getActionItem($table, $type, 'index', 'IndexAction');
     $ret['create'] = DefineTable::getActionItem($table, $type, 'create', 'CreateAction');
     $ret['update'] = DefineTable::getActionItem($table, $type, 'update', 'UpdateAction');
     $ret['delete'] = DefineTable::getActionItem($table, $type, 'delete', 'DeleteAction');
     $ret['other'] = DefineTable::getActionItem($table, $type, 'other', 'OtherAction');
     if ($type == 'front') {
         $ret['channel'] = DefineTable::getActionItem($table, $type, 'channel', 'ChannelAction');
         $ret['list'] = DefineTable::getActionItem($table, $type, 'list', 'ListAction');
         $ret['detail'] = DefineTable::getActionItem($table, $type, 'detail', 'DetailAction');
         $ret['search'] = DefineTable::getActionItem($table, $type, 'search', 'SearchAction');
     }
     if (!empty($table[$type . '_action_custom'])) {
         $customActions = TStringHelper::parse2Array($table[$type . '_action_custom']);
         if (!empty($customActions)) {
             foreach ($customActions as $id => $action) {
                 $ret[$id] = $type . 'end\\actions\\content\\' . $tableName . '\\' . $action;
             }
         }
     }
     return $ret;
 }
Ejemplo n.º 8
0
 protected function findModel($tb)
 {
     if (($model = DefineTable::findOne($tb)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }