XoopsModules25x /
xlanguage
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * xLanguage module (eXtensible Language Management 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 {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
||
| 14 | * @package xlanguage |
||
| 15 | * @since 2.0 |
||
| 16 | * @author D.J.(phppp) [email protected] |
||
| 17 | **/ |
||
| 18 | |||
| 19 | include_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; |
||
| 20 | include_once __DIR__ . '/admin_header.php'; |
||
| 21 | |||
| 22 | include_once(XOOPS_ROOT_PATH . '/modules/xlanguage/include/vars.php'); |
||
| 23 | include_once(XOOPS_ROOT_PATH . '/modules/xlanguage/include/functions.php'); |
||
| 24 | |||
| 25 | $op = ''; |
||
| 26 | if (isset($_POST)) { |
||
| 27 | foreach ($_POST as $k => $v) { |
||
| 28 | ${$k} = $v; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | if (isset($_GET)) { |
||
| 32 | foreach ($_GET as $k => $v) { |
||
| 33 | ${$k} = $v; |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | define('XLANG_CONFIG_LINK', "<a href='main.php' target='_self'>" . _AM_XLANG_CONFIG . '</a>'); |
||
| 38 | |||
| 39 | $xlanguageHandler = xoops_getModuleHandler('language', 'xlanguage'); |
||
| 40 | $xlanguageHandler->loadConfig(); |
||
| 41 | |||
| 42 | switch ($op) { |
||
| 43 | case 'del': |
||
| 44 | if (!isset($_POST['ok']) || $_POST['ok'] != 1) { |
||
| 45 | xoops_cp_header(); |
||
| 46 | $aboutAdmin = new ModuleAdmin(); |
||
| 47 | echo $aboutAdmin->addNavigation(basename(__FILE__)); |
||
| 48 | // echo "<h4>" . XLANG_CONFIG_LINK . "</h4>"; |
||
| 49 | xoops_confirm(array('op' => 'del', 'type' => $_GET['type'], 'lang_id' => (int)$_GET['lang_id'], 'ok' => 1), 'main.php', _AM_XLANG_DELETE_CFM); |
||
| 50 | } else { |
||
| 51 | $isBase = true; |
||
| 52 | if (isset($type) && $type === 'ext') { |
||
| 53 | $isBase = false; |
||
| 54 | } |
||
| 55 | $lang = $xlanguageHandler->get($lang_id, $isBase); |
||
| 56 | $xlanguageHandler->delete($lang); |
||
| 57 | redirect_header('main.php', 2, _AM_XLANG_DELETED); |
||
| 58 | } |
||
| 59 | break; |
||
| 60 | |||
| 61 | case 'save': |
||
| 62 | $isBase = true; |
||
| 63 | if (isset($type) && $type === 'ext') { |
||
| 64 | $isBase = false; |
||
| 65 | } |
||
| 66 | if (isset($lang_id) && $lang_id > 0) { |
||
| 67 | $lang = $xlanguageHandler->get($lang_id, $isBase); |
||
| 68 | } else { |
||
| 69 | $lang = $xlanguageHandler->create(true, $isBase); |
||
| 70 | } |
||
| 71 | $lang_name = preg_replace("/[^a-zA-Z0-9\_\-]/", '', $lang_name); |
||
| 72 | |||
| 73 | $lang->setVar('lang_name', $lang_name); |
||
| 74 | $lang->setVar('lang_desc', $lang_desc); |
||
| 75 | $lang->setVar('lang_code', $lang_code); |
||
| 76 | $lang->setVar('lang_charset', $lang_charset); |
||
| 77 | $lang->setVar('lang_image', $lang_image); |
||
| 78 | if (!$isBase) { |
||
| 79 | $lang->setVar('lang_base', $lang_base); |
||
| 80 | } |
||
| 81 | $lang->setVar('weight', $weight); |
||
| 82 | $xlanguageHandler->insert($lang); |
||
| 83 | redirect_header('main.php', 2, _AM_XLANG_SAVED); |
||
| 84 | break; |
||
| 85 | |||
| 86 | case 'edit': |
||
| 87 | xoops_cp_header(); |
||
| 88 | $aboutAdmin = new ModuleAdmin(); |
||
| 89 | echo $aboutAdmin->addNavigation(basename(__FILE__)); |
||
| 90 | // echo "<h4>" . XLANG_CONFIG_LINK . "</h4>"; |
||
| 91 | // echo "<br>"; |
||
| 92 | echo '<h4>' . _AM_XLANG_EDITLANG . '</h4>'; |
||
| 93 | $isBase = true; |
||
| 94 | if (isset($type) && $type === 'ext') { |
||
| 95 | $isBase = false; |
||
| 96 | } |
||
| 97 | if (isset($lang_id) && $lang_id > 0) { |
||
| 98 | $lang = $xlanguageHandler->get($lang_id, $isBase); |
||
| 99 | } elseif (isset($lang_name)) { |
||
| 100 | $lang = $xlanguageHandler->getByName($lang_name, $isBase); |
||
| 101 | } else { |
||
| 102 | $lang = $xlanguageHandler->create(true, $isBase); |
||
| 103 | } |
||
| 104 | $lang_name = $lang->getVar('lang_name'); |
||
| 105 | $lang_desc = $lang->getVar('lang_desc'); |
||
| 106 | $lang_code = $lang->getVar('lang_code'); |
||
| 107 | $lang_charset = $lang->getVar('lang_charset'); |
||
| 108 | $lang_image = $lang->getVar('lang_image'); |
||
| 109 | $weight = $lang->getVar('weight'); |
||
| 110 | if (!$isBase) { |
||
| 111 | $lang_base = $lang->getVar('lang_base'); |
||
| 112 | } |
||
| 113 | include __DIR__ . '/langform.inc.php'; |
||
| 114 | break; |
||
| 115 | |||
| 116 | case 'add': |
||
| 117 | xoops_cp_header(); |
||
| 118 | $aboutAdmin = new ModuleAdmin(); |
||
| 119 | // echo "<h4>" . XLANG_CONFIG_LINK . "</h4>"; |
||
| 120 | // echo "<br>"; |
||
| 121 | // echo "<h4>" . _AM_XLANG_ADDLANG . "</h4>"; |
||
| 122 | if (isset($type) && $type === 'ext') { |
||
| 123 | $isBase = false; |
||
| 124 | echo $aboutAdmin->addNavigation('main.php?op=add&type=ext'); |
||
| 125 | } else { |
||
| 126 | $isBase = true; |
||
| 127 | echo $aboutAdmin->addNavigation('main.php?op=add&type=base'); |
||
| 128 | } |
||
| 129 | $lang_name = ''; |
||
| 130 | $lang_desc = ''; |
||
| 131 | $lang_code = ''; |
||
| 132 | $lang_charset = ''; |
||
| 133 | $lang_image = ''; |
||
| 134 | $weight = 1; |
||
| 135 | $lang_base = ''; |
||
| 136 | include __DIR__ . '/langform.inc.php'; |
||
| 137 | break; |
||
| 138 | |||
| 139 | case 'createconfig': |
||
| 140 | xlanguage_createConfig(); |
||
| 141 | redirect_header('main.php', 1, _AM_XLANG_CREATED); |
||
| 142 | |||
| 143 | break; |
||
| 144 | |||
| 145 | case 'default': |
||
| 146 | default: |
||
| 147 | xoops_cp_header(); |
||
| 148 | $mainAdmin = new ModuleAdmin(); |
||
| 149 | echo $mainAdmin->addNavigation(basename(__FILE__)); |
||
| 150 | |||
| 151 | // if (TDMDownloads_checkModuleAdmin()) { |
||
| 152 | // $mainAdmin = new ModuleAdmin(); |
||
| 153 | // echo $mainAdmin->addNavigation('downloads.php'); |
||
| 154 | $mainAdmin->addItemButton(_MI_XLANGUAGE_ADMENU1, 'main.php?op=add&type=base', 'add'); |
||
| 155 | $mainAdmin->addItemButton(_MI_XLANGUAGE_ADMENU2, 'main.php?op=add&type=ext', 'insert_table_row'); |
||
| 156 | |||
| 157 | echo $mainAdmin->renderButton(); |
||
| 158 | // } |
||
| 159 | |||
| 160 | // echo "<h4>" . XLANG_CONFIG_LINK . "</h4>"; |
||
| 161 | languageList(); |
||
| 162 | $configfile_status = (@is_readable(XLANGUAGE_CONFIG_FILE)) ? _AM_XLANG_CONFIGOK : _AM_XLANG_CONFIGNOTOK; |
||
| 163 | echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\"><br>"; |
||
| 164 | // echo " - <b><a href='index.php?op=add&type=base'>" . _AM_XLANG_ADDBASE . "</a></b><br><br>\n"; |
||
| 165 | // echo " - <b><a href='index.php?op=add&type=ext'>" . _AM_XLANG_ADDEXT . "</a></b><br><br>\n"; |
||
| 166 | echo '<b>' . $configfile_status . '</b>: ' . XLANGUAGE_CONFIG_FILE . " (<a href='main.php?op=createconfig' title='" . _AM_XLANG_CREATECONFIG . "'>" . _AM_XLANG_CREATECONFIG |
||
| 167 | . "</a>)<br><br>\n"; |
||
| 168 | // echo " - <b><a href='about.php'>" . _AM_XLANG_ABOUT . "</a></b>"; |
||
| 169 | echo '</td></tr></table>'; |
||
| 170 | break; |
||
| 171 | } |
||
| 172 | xoops_cp_footer(); |
||
| 173 | |||
| 174 | function languageList() |
||
| 175 | { |
||
| 176 | global $xlanguageHandler, $xoopsModule; |
||
|
0 ignored issues
–
show
|
|||
| 177 | |||
| 178 | global $pathIcon16; |
||
| 179 | |||
| 180 | $lang_list = $xlanguageHandler->getAllList(); |
||
| 181 | if (is_array($lang_list) && count($lang_list) > 0) { |
||
| 182 | echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\">"; |
||
| 183 | echo "<div style='text-align: center;'><b><h4>" . _AM_XLANG_LANGLIST . '</h4></b><br>'; |
||
| 184 | echo "<table class='outer' width='100%' border='0' cellpadding='0' cellspacing='0' ><tr class='bg2'><th align='center'>" . _AM_XLANG_DESC . "</th><th align='center'>" . _AM_XLANG_NAME |
||
| 185 | . "</th><th align='center'>" . _AM_XLANG_CHARSET . "</th><th align='center'>" . _AM_XLANG_CODE . "</th><th align='center'>" . _AM_XLANG_IMAGE . "</th><th align='center'>" |
||
| 186 | . _AM_XLANG_WEIGHT . "</th><th align='center'>" . _AM_XLANG_BASE . "</th><th align='center'>" . _AM_XLANG_ACTION . "</th></tr>\n"; |
||
| 187 | $class = 'even'; |
||
| 188 | foreach (array_keys($lang_list) as $lang_name) { |
||
| 189 | $lang =& $lang_list[$lang_name]; |
||
| 190 | $isOrphan = true; |
||
| 191 | if (isset($lang['base'])) { |
||
| 192 | echo "<tr>\n"; |
||
| 193 | echo "<td class='$class' >" . $lang['base']->getVar('lang_desc') . "</td>\n"; |
||
| 194 | echo "<td class='$class' ><b>" . $lang['base']->getVar('lang_name') . "</b></td>\n"; |
||
| 195 | echo "<td class='$class' ><b>" . $lang['base']->getVar('lang_charset') . "</b></td>\n"; |
||
| 196 | echo "<td class='$class' >" . $lang['base']->getVar('lang_code') . "</td>\n"; |
||
| 197 | $lang_image = 'noflag.gif'; |
||
| 198 | View Code Duplication | if (is_readable(XOOPS_ROOT_PATH . '/modules/xlanguage/assets/images/' . $lang['base']->getVar('lang_image'))) { |
|
| 199 | $lang_image = $lang['base']->getVar('lang_image'); |
||
| 200 | } |
||
| 201 | echo "<td class='$class' ><img src='" . XOOPS_URL . '/modules/xlanguage/assets/images/' . $lang_image . "' alt='" . $lang['base']->getVar('lang_desc') . "' /></td>\n"; |
||
| 202 | echo "<td class='$class' >" . $lang['base']->getVar('weight') . "</td>\n"; |
||
| 203 | echo "<td class='$class' >Ø</td>\n"; |
||
| 204 | echo "<td class='$class' ><a href='main.php?op=edit&type=base&lang_id=" . $lang['base']->getVar('lang_id') . "'><img src=" . $pathIcon16 . '/edit.png title=' . _EDIT |
||
| 205 | . "></a>\n" . "<a href='main.php?op=del&type=base&lang_id=" . $lang['base']->getVar('lang_id') . "'><img src=" . $pathIcon16 . '/delete.png title=' . _DELETE . "></td>\n"; |
||
| 206 | echo "</tr>\n"; |
||
| 207 | $isOrphan = false; |
||
| 208 | $class = ($class === 'odd') ? 'even' : 'odd'; |
||
| 209 | } |
||
| 210 | if (!isset($lang['ext']) || count($lang['ext']) < 1) { |
||
| 211 | continue; |
||
| 212 | } |
||
| 213 | foreach ($lang['ext'] as $ext) { |
||
| 214 | echo "<tr>\n"; |
||
| 215 | echo "<td class='$class' >" . $ext->getVar('lang_desc') . "</td>\n"; |
||
| 216 | echo "<td class='$class' >" . $ext->getVar('lang_name') . "</td>\n"; |
||
| 217 | echo "<td class='$class' ><b>" . $ext->getVar('lang_charset') . "</b></td>\n"; |
||
| 218 | echo "<td class='$class' >" . $ext->getVar('lang_code') . "</td>\n"; |
||
| 219 | $lang_image = 'noflag.gif'; |
||
| 220 | View Code Duplication | if (is_readable(XOOPS_ROOT_PATH . '/modules/xlanguage/assets/images/' . $ext->getVar('lang_image'))) { |
|
| 221 | $lang_image = $ext->getVar('lang_image'); |
||
| 222 | } |
||
| 223 | echo "<td class='$class' ><img src='" . XOOPS_URL . '/modules/xlanguage/assets/images/' . $lang_image . "' alt='" . $ext->getVar('lang_desc') . "' /></td>\n"; |
||
| 224 | echo "<td class='$class' >" . $ext->getVar('weight') . "</td>\n"; |
||
| 225 | $lang_base = $isOrphan ? "<font color='red'>" . $ext->getVar('lang_base') . '</font>' : $ext->getVar('lang_base'); |
||
| 226 | echo "<td class='$class' ><b>" . $lang_base . "</b></td>\n"; |
||
| 227 | echo "<td class='$class' ><a href='main.php?op=edit&type=ext&lang_id=" . $ext->getVar('lang_id') . "'><img src=" . $pathIcon16 . '/edit.png title=' . _EDIT . "></a>\n" |
||
| 228 | . "<a href='main.php?op=del&type=ext&lang_id=" . $ext->getVar('lang_id') . "'><img src=" . $pathIcon16 . '/delete.png title=' . _DELETE . "></td>\n"; |
||
| 229 | echo "</tr>\n"; |
||
| 230 | } |
||
| 231 | echo "<tr><td colspan='9' ></td></tr>\n"; |
||
| 232 | $class = ($class === 'odd') ? 'even' : 'odd'; |
||
| 233 | } |
||
| 234 | |||
| 235 | echo "</table></div>\n"; |
||
| 236 | echo '</td></tr></table>'; |
||
| 237 | echo '<br>'; |
||
| 238 | } |
||
| 239 | } |
||
| 240 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state