private function getDetailTpl($tpl) { $tplPath = CommonUtility::getThemePath(['page', $tpl]); if (TFileHelper::exist($tplPath)) { return $tpl; } return 'detail_default'; }
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 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 getFiles($dir = null, $prefix = null, $isBack = null) { $root = ''; if ($isBack === null) { $root = \Yii::getAlias('@webroot'); } else { if ($isBack) { $root = \Yii::getAlias('@backend'); } else { $root = \Yii::getAlias('@frontend'); } } if ($dir !== null) { if (is_string($dir)) { $pathArray = [$root, $dir]; } else { if (is_array($dir)) { $pathArray = array_merge([$root], $dir); } } } else { $pathArray = [$root]; } return TFileHelper::getFiles($pathArray, $prefix); }
private static function writeFile($fileName, $content) { $rootData = \Yii::getAlias('@data'); TFileHelper::writeFile([$rootData, 'cache', $fileName], $content); }
public static function createChannelCache() { $newLine = "\r\n"; $content = '<?php' . $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'] . ']=[' . $newLine; $content .= self::getCacheItem('id', $row, 'int'); $content .= self::getCacheItem('parent_id', $row, 'int'); $content .= self::getCacheItemValue('parent_ids', implode(',', $parentIds)); $content .= self::getCacheItemValue('children_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, true); $content .= self::getCacheItem('is_leaf', $row, true); $content .= self::getCacheItem('is_nav', $row, true); $content .= self::getCacheItem('sort_num', $row, true); $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, true); $content .= "];" . $newLine; } $rootData = \Yii::getAlias('@data'); TFileHelper::writeFile([$rootData, 'cache', 'cachedChannels.php'], $content); return $content; }