/**
  * Update info on presented channels
  *
  * @return int
  */
 public function actionUpdateInfo()
 {
     $searchModel = new ChannelSearch();
     $dataProvider = $searchModel->search([]);
     $result = Channel::updateChannelsInfo($dataProvider);
     return $result;
 }
Beispiel #2
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);
 }
Beispiel #3
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);
     }
 }
Beispiel #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Channel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Beispiel #5
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);
     }
 }
Beispiel #6
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);
 }
Beispiel #7
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);
     }
 }
Beispiel #8
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);
     }
 }
 /**
  * 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.');
     }
 }
Beispiel #10
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;
 }
Beispiel #11
0
 public static function getRootChannels()
 {
     return Channel::getRootChannels();
 }
Beispiel #12
0
 public static function createChannelCache()
 {
     self::createCacheFile();
     $content = '<?php' . self::$newLine;
     $dataList = Channel::_getChannelArrayTree(0, 0);
     foreach ($dataList as $row) {
         $id = $row['id'];
         $parentIds = Channel::getParentIds($id);
         $childrenIds = Channel::getChildrenIds($id);
         $leafIds = Channel::getLeafIds($id);
         $content .= '$cachedChannels[\'' . $row['id'] . '\']=[' . self::$newLine;
         $content .= self::getCacheItem('id', $row, 'int');
         $content .= self::getCacheItem('parent_id', $row, 'int');
         $content .= self::getCacheItemValue('parent_ids', implode(',', $parentIds));
         $content .= self::getCacheItemValue('child_ids', implode(',', $childrenIds));
         $content .= self::getCacheItemValue('leaf_ids', implode(',', $leafIds));
         $content .= self::getCacheItem('name', $row);
         $content .= self::getCacheItem('name_alias', $row);
         $content .= self::getCacheItem('name_url', $row);
         $content .= self::getCacheItem('redirect_url', $row);
         $content .= self::getCacheItem('level', $row, 'int');
         $content .= self::getCacheItem('is_leaf', $row, 'bool');
         $content .= self::getCacheItem('is_nav', $row, 'bool');
         $content .= self::getCacheItem('sort_num', $row, 'int');
         $content .= self::getCacheItem('table', $row);
         $content .= self::getCacheItem('channel_tpl', $row);
         $content .= self::getCacheItem('list_tpl', $row);
         $content .= self::getCacheItem('detail_tpl', $row);
         $content .= self::getCacheItem('page_size', $row, 'int');
         $content .= self::getCacheItem('seo_title', $row);
         $content .= self::getCacheItem('seo_keywords', $row);
         $content .= self::getCacheItem('seo_description', $row);
         $content .= "];" . self::$newLine;
     }
     self::writeFile('cachedChannels.php', $content);
 }
Beispiel #13
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChannels()
 {
     return $this->hasMany(Channel::className(), ['app_id' => 'id']);
 }