コード例 #1
0
ファイル: ManagerAction.php プロジェクト: bzboy/lulucms
 public function run($chnid = 0)
 {
     $channelModel = Channel::findOne($chnid);
     $dataList = DataSource::getContentByChannel($chnid);
     $locals = [];
     $locals['dataList'] = $dataList;
     $locals['currentChannel'] = $channelModel;
     $indexTpl = $this->getTpl($chnid, 'manager');
     return $this->render($indexTpl, $locals);
 }
コード例 #2
0
ファイル: UpdateAction.php プロジェクト: dw250100785/lulucms
 public function run($chnid, $id)
 {
     $channelModel = Channel::findOne($chnid);
     $model = [];
     if (true) {
         return $this->redirect(['index', 'cid' => $chnid]);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['currentChannel'] = $channelModel;
         $updateTpl = $this->getTpl($chnid, 'update');
         return $this->render($updateTpl, $locals);
     }
 }
コード例 #3
0
ファイル: CreateAction.php プロジェクト: liangdabiao/lulucms
 public function run($chnid)
 {
     $currentChannel = Channel::findOne($chnid);
     $this->currentTableName = $currentChannel['table'];
     $model = new DefaultContent($currentChannel['table']);
     $model->setIsNewRecord(true);
     if ($model->load($_POST)) {
         $this->saveContent($model, true);
         return $this->redirect(['manager', 'chnid' => $chnid]);
     } else {
         $locals = $this->initContent($model, $currentChannel);
         $tplName = $this->getTpl($chnid, 'create');
         return $this->render($tplName, $locals);
     }
 }
コード例 #4
0
ファイル: IndexAction.php プロジェクト: dw250100785/lulucms
 public function run($chnid = 0)
 {
     if ($chnid === 0) {
         $currentChannel = new Channel();
         $rows = [];
     } else {
         $currentChannel = Channel::findOne($chnid);
         $rows = DataSource::getContentByChannel($chnid);
     }
     $query = new Query();
     $query->select('*')->from($currentChannel['table'])->where(['channel_id' => $chnid]);
     $locals = LuLu::getPagedRows($query, ['order' => 'publish_time desc']);
     //$locals['rows']=$rows;
     $locals['chnid'] = $chnid;
     $locals['channelArrayTree'] = Channel::getChannelArrayTree();
     $locals['currentChannel'] = $currentChannel;
     $tplName = $this->getTpl($chnid, 'index');
     return $this->render($tplName, $locals);
 }
コード例 #5
0
ファイル: UpdateAction.php プロジェクト: dw250100785/lulucms
 public function run($chnid, $id)
 {
     $currentChannel = Channel::findOne($chnid);
     $this->currentTableName = $currentChannel['table'];
     $attValues = $this->findModel($id);
     $model = new DefaultContent($currentChannel['table']);
     $model->setIsNewRecord(false);
     $model->attributes = $attValues;
     if ($model->load($_POST)) {
         $this->saveContent($model);
         return $this->redirect(['index', 'chnid' => $chnid]);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['chnid'] = $chnid;
         $locals['currentChannel'] = $currentChannel;
         $locals['fields'] = DefineTableField::findAll(['table' => $currentChannel['table'], 'is_sys' => 0]);
         $tplName = $this->getTpl($chnid, 'update');
         return $this->render($tplName, $locals);
     }
 }
コード例 #6
0
ファイル: CreateAction.php プロジェクト: bzboy/lulucms
 public function run($chnid)
 {
     $model = [];
     $channelModel = Channel::findOne($chnid);
     $formName = 'Content';
     if ($this->hasPostValue($formName)) {
         $items = $this->getPostValue($formName);
         // $items['catalog_id']=$channelId;
         $columns = $items;
         $db = Yii::$app->db;
         $command = $db->createCommand();
         $command->insert($this->tableName, $columns);
         $command->execute();
         return $this->redirect(['manager', 'chnid' => $chnid]);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['chnid'] = $chnid;
         $createTpl = $this->getTpl($chnid, 'create');
         return $this->render($createTpl, $locals);
     }
 }
コード例 #7
0
 /**
  * Finds the Channel model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Channel the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Channel::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #8
0
ファイル: Channel.php プロジェクト: dw250100785/lulucms
 public static function getLeafIds($id)
 {
     $ret = [];
     $current = Channel::findOne(['id' => $id]);
     if ($current['is_leaf']) {
         $ret[] = $id;
         return $ret;
     }
     $children = Channel::findAll(['parent_id' => $id]);
     if (count($children) > 0) {
         foreach ($children as $child) {
             $temp = Channel::getLeafIds($child['id']);
             $ret = array_merge($ret, $temp);
         }
     }
     return $ret;
 }