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 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 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(); }
public static function getChannelArrayTree() { $cachedChannels = LuLu::getAppParam('cachedChannels'); return $cachedChannels; }
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 static function getDicts($category, $pid) { $ret = []; $cached = LuLu::getAppParam('cachedDicts'); $dicts = $cached[$category]; if ($pid === 0) { foreach ($dicts as $id => $dict) { if ($dict['parent_id'] === 0) { $ret[$id] = $dict; } } } else { $dict = $dicts[$pid]; $childIds = explode(',', $dict['child_ids']); foreach ($childIds as $childId) { $ret[$childId] = $dicts[$childId]; } } return $ret; }
public static function getAllTables() { return LuLu::getAppParam('cachedTables'); }
public static function getTables($tableName = null) { $cached = LuLu::getAppParam('cachedTables'); if ($tableName != null) { return $cached[$tableName]; } return $cached; }