Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
 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);
     }
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
 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);
     }
 }
Esempio n. 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.');
     }
 }
Esempio n. 8
0
 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;
 }