public function actions() { $chnid = LuLu::getGetValue('chnid'); $channel = $this->getChannel($chnid); $table = CommonUtility::getCachedTable($channel['table']); return DefineTable::getBackActions($table); }
public function actionIndex($type) { $query = FragmentCategory::find()->where(['type' => $type]); $locals = LuLu::getPagedRows($query, ['order' => 'id desc']); $locals['type'] = $type; return $this->render('index', $locals); }
public function actionIndex($fraid) { $query = Fragment2Data::find()->where(['fragment_id' => $fraid]); $locals = LuLu::getPagedRows($query, ['order' => 'id desc']); $locals['currentFragment'] = Fragment::findOne($fraid); return $this->render('index', $locals); }
public function actions() { $chnid = LuLu::getGetValue('chnid', ''); $channel = $this->getChannel($chnid); $table = DefineTable::findOne(['id' => $channel['table']]); $ret = $table->getFrontActions(); return $ret; }
public static function exist($path) { if (is_array($path)) { $path = self::buildPath($path); } LuLu::info($path); return file_exists($path); }
public function getChannel($chnid) { if (!isset($this->channels[$chnid])) { LuLu::info('channel id:' . $chnid . ' does not exist'); throw new InvalidParamException('channel id:' . $chnid . ' does not exist'); } return $this->channels[$chnid]; }
public function actionIndex($type, $catid = 0) { $query = Fragment::find()->where(['type' => $type]); if ($catid > 0) { $query->andWhere(['category_id' => $catid]); } $locals = LuLu::getPagedRows($query, ['order' => 'id desc']); $locals['type'] = $type; return $this->render('index', $locals); }
public function actionIndex($catid, $pid = 0) { $query = Dict::find()->where(['parent_id' => $pid, 'category_id' => $catid]); $locals = LuLu::getPagedRows($query, ['order' => 'sort_num asc']); $locals['pid'] = $pid; $locals['parent'] = $this->findModel($pid); $locals['parents'] = Dict::getParents($pid); $locals['category'] = DictCategory::findOne($catid); return $this->render('index', $locals); }
public static function getChannelLink($id, $options = []) { $cachedChannels = LuLu::getAppParam('cachedChannels'); $channel = $cachedChannels[$id]; if (isset($options['title'])) { $title = $options['title']; unset($options['title']); } else { $title = $channel['name']; } $url = self::getChannelUrl($id); return Html::a($title, $url, $options); }
public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post())) { if ($model->checkExist()) { LuLu::setFalsh('warning', $model->variable . ':已经存在'); return $this->refresh(); } $model->save(); CacheUtility::createVariableCache(); return $this->redirect(['index']); } else { return $this->render('update', ['model' => $model]); } }
private function checkName($value) { LuLu::info($value, __METHOD__); $ret = []; $level = ['一', '二', '三', '四', '五', '六', '七', '八', '九']; $items = explode("\r\n", $value); for ($i = 0; $i < 9; $i++) { if (isset($items[$i]) && !empty($items[$i])) { $ret[] = $items[$i]; } else { $ret[] = $level[$i] . '级属性'; } } return implode("\r\n", $ret); }
public function run($chnid) { $currentChannel = $this->getChannel($chnid); $query = DataSource::buildContentQuery($currentChannel['table'], [], 'channel_id=' . $chnid); $locals = LuLu::getPagedRows($query); $locals['chnid'] = $chnid; $locals['currentChannel'] = $currentChannel; $locals['currentModel'] = $currentChannel['table']; $view = LuLu::getView(); $view->setTitle(empty($currentChannel['seo_title']) ? $currentChannel['name'] : $currentChannel['seo_title']); $view->setMetaTag('keywords', $currentChannel['seo_keywords']); $view->setMetaTag('description', $currentChannel['seo_description']); $listTpl = $this->getTpl($chnid, 'list_tpl'); return $this->render($listTpl, $locals); }
public function getTpl($chnId, $tplType) { $ret = TFileHelper::buildPath(['model_default', str_replace('_tpl', '_default', $tplType)]); $cachedChannels = LuLu::getAppParam('cachedChannels'); if (isset($cachedChannels[$chnId])) { $channelModel = $cachedChannels[$chnId]; $table = $channelModel['table']; $tplName = $channelModel[$tplType]; $tplPath = CommonUtility::getThemePath(['content', $table, $tplName]); if (TFileHelper::exist($tplPath)) { $ret = TFileHelper::buildPath([$table, $tplName]); } else { LuLu::info($tplPath . ' does not exist', __METHOD__); } } return $ret; }
public function run($chnid = 0, $id) { $currentChannel = $this->getChannel($chnid); $this->currentTableName = $currentChannel['table']; $this->updateViews($id); $model = $this->findModel($id); $locals = []; $locals['model'] = $model; $locals['chnid'] = $chnid; $locals['currentChannel'] = $currentChannel; $locals['currentModel'] = $currentChannel['table']; $view = LuLu::getView(); $view->setTitle($model['title']); $view->setMetaTag('keywords', $model['title']); $view->setMetaTag('description', $model['summary']); $detailTpl = $this->getTpl($chnid, 'detail_tpl'); return $this->render($detailTpl, $locals); }
public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post())) { if ($model->checkExist()) { LuLu::setFalsh('warning', $model->id . ':已经存在'); return $this->refresh(); } if ($model->oldAttributes['id'] !== $model->id) { Dict::updateAll(['category_id' => $model->id], ['category_id' => $model->oldAttributes['id']]); } $model->save(); return $this->redirect(['index', 'id' => $model->id]); } else { $locals = []; $locals['model'] = $model; return $this->render('update', $locals); } }
public function actionCreate($tb) { $model = new DefineTableField(); $model->table = $tb; if ($model->load($_POST) && $model->save()) { $fieldName = $model->name_en; $dataType = $model->getFieldType(); $isNull = $model->is_null; $sql = SqlData::getAddFieldSql($tb, $fieldName, $dataType, $isNull); LuLu::execute($sql); CacheUtility::createFieldCache(); return $this->redirect(['index', 'tb' => $tb]); } else { $locals = []; $locals['table'] = $tb; $locals['model'] = $model; return $this->render('create', $locals); } }
public function actionIndex($fraid) { $query = Fragment3Data::find()->where(['fragment_id' => $fraid]); $locals = LuLu::getPagedRows($query, ['order' => 'id desc']); $ret = []; foreach ($locals['rows'] as $row) { $id = $row['id']; $ret[$id] = ['id' => $row['id'], 'channel_id' => $row['channel_id'], 'content_id' => $row['content_id'], 'sort_num' => $row['sort_num']]; $item = DataSource::getContentByChannel($row['channel_id'], ['where' => 'id=' . $row['content_id']]); if ($item == null || empty($item)) { $ret[$id]['title'] = '没有此数据'; } else { $ret[$id]['title'] = $item[0]['title']; } } $locals['rows'] = $ret; $locals['currentFragment'] = Fragment::findOne($fraid); return $this->render('index', $locals); }
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); }
public function run($chnid = 0) { $currentChannel = $this->getChannel($chnid); $childChannels = $this->getChildChannels($chnid); $dataList = []; foreach ($childChannels as $channel) { $dataList[$channel['id']] = DataSource::getContentByChannel($channel['id'], ['limit' => 5]); } $locals = []; $locals['dataList'] = $dataList; $locals['chnid'] = $chnid; $locals['currentChannel'] = $currentChannel; $locals['currentModel'] = $currentChannel['table']; $view = LuLu::getView(); $view->setTitle(empty($currentChannel['seo_title']) ? $currentChannel['name'] : $currentChannel['seo_title']); $view->setMetaTag('keywords', $currentChannel['seo_keywords']); $view->setMetaTag('description', $currentChannel['seo_description']); $channelTpl = $this->getTpl($chnid, 'channel_tpl'); return $this->render($channelTpl, $locals); }
public function actionDetail($id) { $view = LuLu::getView(); $model = $this->findModel($id); $view->setTitle(empty($model['seo_title']) ? $model['title'] : $model['seo_title']); $view->setMetaTag('keywords', $model['seo_keywords']); $view->setMetaTag('description', $model['seo_description']); $view->addBreadcrumb('页面', ['page/index']); $category = PageCategory::findOne($model->category_id); if ($category !== null) { $view->addBreadcrumb($category['name'], ['page/index', 'catid' => $category['id']]); } $view->addBreadcrumb($model['title']); $locals = []; $locals['model'] = $model; $locals['catid'] = $model->category_id; $locals['currentCategory'] = $category; $detailTpl = $this->getDetailTpl($model['tpl']); return $this->render($detailTpl, $locals); }
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'] = CommonUtility::getTables(); $locals['channelTpls'] = $this->getTpl('channel_'); $locals['listTpls'] = $this->getTpl('list_'); $locals['detailTpls'] = $this->getTpl('detail_'); return $this->render('update', $locals); } }
public static function getContentByChannel($channelIds, $other = []) { $tableName = ''; $where = ''; $cachedChannels = LuLu::getAppParam('cachedChannels'); if (intval($channelIds) > 0) { $channel = $cachedChannels[$channelIds]; $tableName = $channel['table']; if (empty($tableName)) { return []; } if ($channel['is_leaf']) { $where = 'channel_id=' . $channelIds; } else { $leafIds = $channel['leaf_ids']; if ($leafIds == '') { return []; } $where = 'channel_id in(' . $leafIds . ')'; } } else { $channelIdArray = explode(',', $channelIds); $tableName = $channel[$channelIdArray[0]]; if (empty($tableName)) { return []; } $leafIds = ''; foreach ($channelIdArray as $id) { $leafIds .= $cachedChannels[$id]['leaf_ids'] . ','; } $leafIdsArray = explode(',', rtrim($leafIds, ',')); $leafIdsArray = array_unique($leafIdsArray); $leafIds = implode(',', $leafIdsArray); $where = 'channel_id in(' . $leafIds . ')'; } $query = self::buildContentQuery($tableName, $other, $where); return $query->all(); }
private function setSeo() { $view = LuLu::getView(); $title = CommonUtility::getCachedConfigValue('seo_title'); if (empty($title)) { $title = '首页——' . CommonUtility::getCachedConfigValue('seo_name'); } $view->setTitle($title); $view->registerMetaTag(['name' => 'keywords', 'content' => CommonUtility::getCachedConfigValue('seo_keywords')]); $view->registerMetaTag(['name' => 'description', 'content' => CommonUtility::getCachedConfigValue('seo_description')]); }
<li><a href="2014-06/30/content_32807283.htm">湖北大冶液化气站发生爆燃 已造成8人受伤</a></li> <li><a href="2014-06/30/content_32807212.htm">甘肃计划生育工作者不到岗长期在外打工被通报</a></li> <li><a href="shehui/2014-06/30/content_32807637.htm">河南村民修下水道挖出三尊元末明初汉白玉雕像(图)</a></li> <li><a href="shehui/2014-06/30/content_32808640.htm">昆明街头一女子被泼汽油烧死 被施暴者痛斥为小三</a></li> </ul> </div> <div class="tbox border"> <div class="ad"> <img alt="" src="<?php echo LuLu::getThemeUrl(); ?> /images/ad2.png"> </div> </div> </div> </div> <div class="clear"></div> <div class="container column"> <div class="bigTitle"> <h2> <a href="">时政社会</a>
public static function getChannelArrayTree() { $cachedChannels = LuLu::getAppParam('cachedChannels'); return $cachedChannels; }
?> " /> <title>管理中心——LuLu CMS</title> <?php $this->head(); ?> </head> <body style="margin: 0px; padding-top: 51px;" scroll="no"> <?php $this->beginBody(); ?> <?php NavBar::begin(['brandLabel' => 'LuLu CMS', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]); $menuItems = [['label' => '首页', 'url' => ['admin/index']], ['label' => '设置', 'url' => ['admin/sys']], ['label' => '分类', 'url' => ['admin/taxonomy']], ['label' => '内容', 'url' => ['admin/content']], ['label' => '模板', 'url' => ['admin/tpl']]]; $menuItems[] = ['label' => '退出 (' . Yii::$app->user->identity->username . ')', 'url' => ['/admin/logout'], 'linkOptions' => ['data-method' => 'post']]; $menuItems[] = '<li><a href="' . LuLu::getBaseUrl() . '/index.php" target="_blank">前台</a></li>'; echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]); NavBar::end(); ?> <table id="containerTable" class="table border" style="height: 95%; padding: 0px; margin: 0px;"> <tr> <td class="leftMenu" style="vertical-align: top; pading: 0px; margin: 0px;"> <?php echo $content; ?> </td> <td class="mainContent" style="vertical-align: top; padding: 0px; margin: 0px;"> <iframe id="mainFrame" name="mainFrame" width="100%" frameborder="0" scrolling="yes" src="<?php
public function getTpl($chnId, $tplName) { $ret = TFileHelper::buildPath(['model_default', $tplName], false); $cachedChannels = LuLu::getAppParam('cachedChannels'); if (isset($cachedChannels[$chnId])) { $backend = \Yii::getAlias('@backend'); $channelModel = $cachedChannels[$chnId]; $table = $channelModel['table']; $tplPath = TFileHelper::buildPath([$backend, 'views', 'content', $table, $tplName . '.php'], false); if (TFileHelper::exist($tplPath)) { $ret = TFileHelper::buildPath([$table, $tplName], false); } else { LuLu::info($tplPath . ' does not exist in backend', __METHOD__); } } return $ret; }
public static function getCachedVariableValue($id) { $cached = LuLu::getAppParam('cachedVariables'); $dataType = $cached[$id]['data_type']; //$dataType = ['0' => '字符串', '1' => '数字', '2' => '布尔型', '3' => '日期', '4' => '数组', '5' => 'JSON']; $value = $cached[$id]['value']; if ($dataType === 0) { return $value; } if ($dataType === 1) { return intval($value); } if ($dataType === 2) { $value = strtolower($value); if ($value == 'true' || $value == '1') { return true; } return false; } if ($dataType === 3) { return $value; } if ($dataType === 4) { return $value; } if ($dataType === 5) { return $value; } return $value; }
public function actionDelete($tb) { $model = $this->findModel($tb); $model->delete(); DefineTableField::deleteAll(['table' => $tb]); $sql = SqlData::getDropTableSql($tb); LuLu::execute($sql); CacheUtility::createTableCache(); CacheUtility::createFieldCache(); return $this->redirect(['index']); }
public function afterValidate() { $errors = $this->getErrors(); if (!empty($errors)) { LuLu::info($this, 'validate error:'); } }