コード例 #1
0
 /**
  * Update info on presented channels
  *
  * @return int
  */
 public function actionUpdateInfo()
 {
     $searchModel = new ChannelSearch();
     $dataProvider = $searchModel->search([]);
     $result = Channel::updateChannelsInfo($dataProvider);
     return $result;
 }
コード例 #2
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);
 }
コード例 #3
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);
     }
 }
コード例 #4
0
ファイル: ChannelSearch.php プロジェクト: aldegtyarev/fantasy
 /**
  * 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;
 }
コード例 #5
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);
     }
 }
コード例 #6
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);
 }
コード例 #7
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);
     }
 }
コード例 #8
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);
     }
 }
コード例 #9
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.');
     }
 }
コード例 #10
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;
 }
コード例 #11
0
ファイル: CommonUtility.php プロジェクト: hucongyang/lulucms2
 public static function getRootChannels()
 {
     return Channel::getRootChannels();
 }
コード例 #12
0
ファイル: CacheUtility.php プロジェクト: dw250100785/lulucms
 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);
 }
コード例 #13
0
ファイル: App.php プロジェクト: xuguoliangjj/datacenter
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChannels()
 {
     return $this->hasMany(Channel::className(), ['app_id' => 'id']);
 }