XoopsModules25x /
about
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Article module for XOOPS |
||
| 4 | * |
||
| 5 | * You may not change or alter any portion of this comment or credits |
||
| 6 | * of supporting developers from this source code or any supporting source code |
||
| 7 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 8 | * This program is distributed in the hope that it will be useful, |
||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 11 | * |
||
| 12 | * @copyright XOOPS Project (http://xoops.org) |
||
| 13 | * @license http://www.fsf.org/copyleft/gpl.html GNU public license |
||
| 14 | * @package article |
||
| 15 | * @since 1.0 |
||
| 16 | * @author Taiwen Jiang <[email protected]> |
||
| 17 | */ |
||
| 18 | |||
| 19 | defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
||
| 20 | |||
| 21 | include __DIR__ . '/vars.php'; |
||
| 22 | define($GLOBALS['artdirname'] . '_FUNCTIONS_RENDER_LOADED', true); |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Function to get template file of a specified style of a specified page |
||
| 26 | * |
||
| 27 | * @var string $page page name |
||
| 28 | * @var string $style template style |
||
| 29 | * |
||
| 30 | * @return string template file name, using default style if style is invalid |
||
| 31 | */ |
||
| 32 | function about_getTemplate($page = 'index', $style = null) |
||
| 33 | { |
||
| 34 | global $xoops; |
||
| 35 | |||
| 36 | $template_dir = $xoops->path("modules/{$GLOBALS['artdirname']}/templates/"); |
||
| 37 | $style = empty($style) ? '' : '_' . $style; |
||
| 38 | $file_name = "{$GLOBALS['artdirname']}_{$page}{$style}.tpl"; |
||
| 39 | if (file_exists($template_dir . $file_name)) { |
||
| 40 | return $file_name; |
||
| 41 | } |
||
| 42 | // Couldn't find file, try to see if the "default" style for this page exists |
||
| 43 | if (!empty($style)) { |
||
| 44 | $style = ''; |
||
| 45 | $file_name = "{$GLOBALS['artdirname']}_{$page}{$style}.tpl"; |
||
| 46 | if (file_exists($template_dir . $file_name)) { |
||
| 47 | return $file_name; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | // Couldn't find a suitable template for this page |
||
| 51 | return null; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Function to get a list of template files of a page, indexed by file name |
||
| 56 | * |
||
| 57 | * @var string $page page name |
||
| 58 | * @param bool|boolean $refresh recreate the data |
||
| 59 | * @return array |
||
| 60 | * |
||
| 61 | */ |
||
| 62 | function &about_getTemplateList($page = 'index', $refresh = false) |
||
| 63 | { |
||
| 64 | $TplFiles = about_getTplPageList($page, $refresh); |
||
| 65 | $template = array(); |
||
| 66 | if (is_array($TplFiles) && count($TplFiles) > 0) { |
||
| 67 | foreach (array_keys($TplFiles) as $temp) { |
||
| 68 | $template[$temp] = $temp; |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | return $template; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Function to get CSS file URL of a style |
||
| 77 | * |
||
| 78 | * The hardcoded path is not desirable for theme switch, however, we have to keabout it before getting a good solution for cache |
||
| 79 | * |
||
| 80 | * @var string $style |
||
| 81 | * |
||
| 82 | * @return string file URL, false if not found |
||
| 83 | */ |
||
| 84 | function about_getCss($style = 'default') |
||
| 85 | { |
||
| 86 | global $xoops; |
||
| 87 | |||
| 88 | if (is_readable($xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . strtolower($style) . '.css'))) { |
||
| 89 | return $xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style_' . strtolower($style) . '.css', true); |
||
| 90 | } |
||
| 91 | |||
| 92 | return $xoops->path('modules/' . $GLOBALS['artdirname'] . '/assets/css/style.css', true); |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Function to module header for a page with specified style |
||
| 97 | * |
||
| 98 | * @var string $style |
||
| 99 | * |
||
| 100 | * @return string |
||
| 101 | */ |
||
| 102 | function about_getModuleHeader($style = 'default') |
||
| 103 | { |
||
| 104 | $xoops_module_header = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . about_getCss($style) . "\">"; |
||
| 105 | |||
| 106 | return $xoops_module_header; |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Function to get a list of template files of a page, indexed by style |
||
| 111 | * |
||
| 112 | * @var string $page page name |
||
| 113 | * |
||
| 114 | * @param bool $refresh |
||
| 115 | * @return array |
||
| 116 | */ |
||
| 117 | function &about_getTplPageList($page = '', $refresh = true) |
||
| 118 | { |
||
| 119 | $list = null; |
||
|
0 ignored issues
–
show
|
|||
| 120 | |||
| 121 | $cache_file = empty($page) ? 'template-list' : 'template-page'; |
||
| 122 | /* |
||
| 123 | load_functions("cache"); |
||
| 124 | $list = mod_loadCacheFile($cache_file, $GLOBALS["artdirname"]); |
||
| 125 | */ |
||
| 126 | |||
| 127 | xoops_load('xoopscache'); |
||
| 128 | $key = $GLOBALS['artdirname'] . "_{$cache_file}"; |
||
| 129 | $list = XoopsCache::read($key); |
||
| 130 | |||
| 131 | if (!is_array($list) || $refresh) { |
||
| 132 | $list = about_template_lookup(!empty($page)); |
||
| 133 | } |
||
| 134 | |||
| 135 | $ret = empty($page) ? $list : @$list[$page]; |
||
| 136 | |||
| 137 | return $ret; |
||
| 138 | } |
||
| 139 | |||
| 140 | /** |
||
| 141 | * @param bool $index_by_page |
||
| 142 | * @return array |
||
| 143 | */ |
||
| 144 | function &about_template_lookup($index_by_page = false) |
||
| 145 | { |
||
| 146 | include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
| 147 | |||
| 148 | $files = XoopsLists::getHtmlListAsArray(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['artdirname'] . '/templates/'); |
||
| 149 | $list = array(); |
||
| 150 | foreach ($files as $file => $name) { |
||
| 151 | // The valid file name must be: art_article_mytpl.html OR art_category-1_your-trial.html |
||
| 152 | if (preg_match('/^' . $GLOBALS['artdirname'] . "_([^_]*)(_(.*))?\.(tpl|xotpl)$/i", $name, $matches)) { |
||
| 153 | if (empty($matches[1])) { |
||
| 154 | continue; |
||
| 155 | } |
||
| 156 | if (empty($matches[3])) { |
||
| 157 | $matches[3] = 'default'; |
||
| 158 | } |
||
| 159 | if (empty($index_by_page)) { |
||
| 160 | $list[] = array('file' => $name, 'description' => $matches[3]); |
||
| 161 | } else { |
||
| 162 | $list[$matches[1]][$matches[3]] = $name; |
||
| 163 | } |
||
| 164 | } |
||
| 165 | } |
||
| 166 | |||
| 167 | $cache_file = empty($index_by_page) ? 'template-list' : 'template-page'; |
||
| 168 | xoops_load('xoopscache'); |
||
| 169 | $key = $GLOBALS['artdirname'] . "_{$cache_file}"; |
||
| 170 | XoopsCache::write($key, $list); |
||
| 171 | |||
| 172 | //load_functions("cache"); |
||
| 173 | //mod_createCacheFile($list, $cache_file, $GLOBALS["artdirname"]); |
||
| 174 | return $list; |
||
| 175 | } |
||
| 176 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.