PageRenderTime 27ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/xlanguage/admin/index.php

https://gitlab.com/BaseX/BaseX
PHP | 214 lines | 173 code | 13 blank | 28 comment | 23 complexity | 1dc713545c6fc24910c2a0ee172e5625 MD5 | raw file
  1. <?php
  2. // $Id: index.php,v 1.3 2004/10/05 19:06:29 phppp Exp $
  3. // ------------------------------------------------------------------------ //
  4. // Xlanguage: eXtensible Language Management For Xoops //
  5. // Copyright (c) 2004 Xoops China Community //
  6. // <http://www.xoops.org.cn/> //
  7. // ------------------------------------------------------------------------ //
  8. // This program is free software; you can redistribute it and/or modify //
  9. // it under the terms of the GNU General Public License as published by //
  10. // the Free Software Foundation; either version 2 of the License, or //
  11. // (at your option) any later version. //
  12. // //
  13. // You may not change or alter any portion of this comment or credits //
  14. // of supporting developers from this source code or any supporting //
  15. // source code which is considered copyrighted (c) material of the //
  16. // original comment or credit authors. //
  17. // //
  18. // This program is distributed in the hope that it will be useful, //
  19. // but WITHOUT ANY WARRANTY; without even the implied warranty of //
  20. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
  21. // GNU General Public License for more details. //
  22. // //
  23. // You should have received a copy of the GNU General Public License //
  24. // along with this program; if not, write to the Free Software //
  25. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
  26. // ------------------------------------------------------------------------ //
  27. // Author: D.J.(phppp) php_pp@hotmail.com //
  28. // URL: http://www.xoops.org.cn //
  29. // ------------------------------------------------------------------------- //
  30. include '../../../include/cp_header.php';
  31. include_once(XOOPS_ROOT_PATH.'/modules/xlanguage/include/vars.php');
  32. include_once(XOOPS_ROOT_PATH.'/modules/xlanguage/include/functions.php');
  33. $op = "";
  34. if ( isset( $_POST ) ){
  35. foreach ( $_POST as $k => $v ) {
  36. ${$k} = $v;
  37. }
  38. }
  39. if ( isset( $_GET ) ){
  40. foreach ( $_GET as $k => $v ) {
  41. ${$k} = $v;
  42. }
  43. }
  44. define("XLANG_CONFIG_LINK","<a href='index.php' target='_self'>"._AM_XLANG_CONFIG."</a>");
  45. $xlanguage_handler =& xoops_getmodulehandler('language', 'xlanguage');
  46. $xlanguage_handler->loadConfig();
  47. switch ( $op )
  48. {
  49. case "del":
  50. if (!isset($_POST['ok']) || $_POST['ok'] != 1 ){
  51. xoops_cp_header();
  52. echo "<h4>" . XLANG_CONFIG_LINK . "</h4>";
  53. xoops_confirm( array( 'op' => 'del', 'type' => $_GET['type'], 'lang_id' => intval( $_GET['lang_id'] ), 'ok' => 1 ), 'index.php', _AM_XLANG_DELETE_CFM );
  54. }else{
  55. if(isset($type)&&$type=='ext') $isBase = false;
  56. else $isBase = true;
  57. $lang =& $xlanguage_handler->get($lang_id, $isBase);
  58. $xlanguage_handler->delete($lang);
  59. redirect_header("index.php",2,_AM_XLANG_DELETED);
  60. }
  61. break;
  62. case "save":
  63. if(isset($type)&&$type=='ext') $isBase = false;
  64. else $isBase = true;
  65. if(isset($lang_id)&&$lang_id>0){
  66. $lang =& $xlanguage_handler->get($lang_id, $isBase);
  67. }else{
  68. $lang =& $xlanguage_handler->create(true, $isBase);
  69. }
  70. $lang_name = preg_replace("/[^a-zA-Z0-9\_\-]/", "", $lang_name);
  71. $lang->setVar('lang_name',$lang_name);
  72. $lang->setVar('lang_desc',$lang_desc);
  73. $lang->setVar('lang_code',$lang_code);
  74. $lang->setVar('lang_charset',$lang_charset);
  75. $lang->setVar('lang_image',$lang_image);
  76. if(!$isBase){
  77. $lang->setVar('lang_base',$lang_base);
  78. }
  79. $lang->setVar('weight',$weight);
  80. $xlanguage_handler->insert($lang);
  81. redirect_header("index.php",2,_AM_XLANG_SAVED);
  82. break;
  83. case "edit":
  84. xoops_cp_header();
  85. echo "<h4>" . XLANG_CONFIG_LINK . "</h4>";
  86. echo "<br />";
  87. echo "<h4>" . _AM_XLANG_EDITLANG . "</h4>";
  88. if(isset($type)&&$type=='ext') $isBase = false;
  89. else $isBase = true;
  90. if(isset($lang_id)&&$lang_id>0){
  91. $lang =& $xlanguage_handler->get($lang_id, $isBase);
  92. }elseif(isset($lang_name)){
  93. $lang =& $xlanguage_handler->getByName($lang_name, $isBase);
  94. }else{
  95. $lang =& $xlanguage_handler->create(true, $isBase);
  96. }
  97. $lang_name = $lang->getVar('lang_name');
  98. $lang_desc = $lang->getVar('lang_desc');
  99. $lang_code = $lang->getVar('lang_code');
  100. $lang_charset = $lang->getVar('lang_charset');
  101. $lang_image = $lang->getVar('lang_image');
  102. $weight = $lang->getVar('weight');
  103. if(!$isBase){
  104. $lang_base = $lang->getVar('lang_base');
  105. }
  106. include "langform.inc.php";
  107. break;
  108. case "add":
  109. xoops_cp_header();
  110. echo "<h4>" . XLANG_CONFIG_LINK . "</h4>";
  111. echo "<br />";
  112. echo "<h4>" . _AM_XLANG_ADDLANG . "</h4>";
  113. if(isset($type)&&$type=='ext') $isBase = false;
  114. else $isBase = true;
  115. $lang_name = '';
  116. $lang_desc = '';
  117. $lang_code = '';
  118. $lang_charset = '';
  119. $lang_image = '';
  120. $weight = 1;
  121. $lang_base = '';
  122. include "langform.inc.php";
  123. break;
  124. case 'createconfig':
  125. xlanguage_createConfig();
  126. redirect_header( 'index.php', 1, _AM_XLANG_CREATED );
  127. exit();
  128. break;
  129. case "default":
  130. default:
  131. xoops_cp_header();
  132. echo "<h4>" . XLANG_CONFIG_LINK . "</h4>";
  133. languageList();
  134. $configfile_status = (@is_readable(XLANGUAGE_CONFIG_FILE))?_AM_XLANG_CONFIGOK:_AM_XLANG_CONFIGNOTOK;
  135. echo"<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\">";
  136. echo " - <b><a href='index.php?op=add&amp;type=base'>" . _AM_XLANG_ADDBASE . "</a></b><br /><br />\n";
  137. echo " - <b><a href='index.php?op=add&amp;type=ext'>" . _AM_XLANG_ADDEXT . "</a></b><br /><br />\n";
  138. echo " - <b>".$configfile_status."</b>: ".XLANGUAGE_CONFIG_FILE." (<a href='index.php?op=createconfig' title='"._AM_XLANG_CREATECONFIG."'>" . _AM_XLANG_CREATECONFIG . "</a>)<br /><br />\n";
  139. echo " - <b><a href='about.php'>" . _AM_XLANG_ABOUT . "</a></b>";
  140. echo"</td></tr></table>";
  141. break;
  142. }
  143. xoops_cp_footer();
  144. function languageList()
  145. {
  146. global $xlanguage_handler;
  147. $lang_list =& $xlanguage_handler->getAllList();
  148. if ( is_array($lang_list)&&count( $lang_list ) > 0 ){
  149. echo"<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\">";
  150. echo "<div style='text-align: center;'><b>" . _AM_XLANG_LANGLIST . "</b><br />";
  151. echo "<table width='100%' border='1'><tr class='bg2'><td align='center'>" . _AM_XLANG_DESC . "</td><td align='center'>" . _AM_XLANG_NAME . "</td><td align='center'>" . _AM_XLANG_CHARSET . "</td><td align='center'>" . _AM_XLANG_CODE . "</td><td align='center'>" . _AM_XLANG_IMAGE . "</td><td align='center'>" . _AM_XLANG_WEIGHT . "</td><td align='center'>" . _AM_XLANG_BASE . "</td><td align='center'>" . _EDIT . "</td><td align='center'>" . _DELETE . "</td></tr>\n";
  152. foreach( array_keys($lang_list) as $lang_name ) {
  153. $lang =& $lang_list[$lang_name];
  154. $isOrphan = true;
  155. if(isset($lang['base'])){
  156. echo "<tr>\n";
  157. echo "<td>" . $lang['base'] -> getVar('lang_desc') . "</td>\n";
  158. echo "<td><b>" . $lang['base'] -> getVar('lang_name') . "</b></td>\n";
  159. echo "<td><b>" . $lang['base'] -> getVar('lang_charset') . "</b></td>\n";
  160. echo "<td>" . $lang['base'] -> getVar('lang_code') . "</td>\n";
  161. if(is_readable(XOOPS_ROOT_PATH.'/modules/xlanguage/images/'.$lang['base'] -> getVar('lang_image'))){
  162. $lang_image = $lang['base'] -> getVar('lang_image');
  163. }else{
  164. $lang_image = 'noflag.gif';
  165. }
  166. echo "<td><img src='" . XOOPS_URL.'/modules/xlanguage/images/'.$lang_image . "' alt='".$lang['base'] -> getVar('lang_desc')."' /></td>\n";
  167. echo "<td>" . $lang['base'] -> getVar('weight') . "</td>\n";
  168. echo "<td>&#216;</td>\n";
  169. echo "<td><a href='index.php?op=edit&amp;type=base&amp;lang_id=" . $lang['base'] -> getVar('lang_id') . "'>" . _EDIT . "</a></td>\n";
  170. echo "<td><a href='index.php?op=del&amp;type=base&amp;lang_id=" . $lang['base'] -> getVar('lang_id') . "'>" . _DELETE ."</td>\n";
  171. echo "</tr>\n";
  172. $isOrphan = false;
  173. }
  174. if(!isset($lang['ext'])||count($lang['ext'])<1) continue;
  175. foreach($lang['ext'] as $ext){
  176. echo "<tr>\n";
  177. echo "<td>" . $ext -> getVar('lang_desc') . "</td>\n";
  178. echo "<td>" . $ext -> getVar('lang_name') . "</td>\n";
  179. echo "<td><b>" . $ext -> getVar('lang_charset') . "</b></td>\n";
  180. echo "<td>" . $ext -> getVar('lang_code') . "</td>\n";
  181. if(is_readable(XOOPS_ROOT_PATH.'/modules/xlanguage/images/'.$ext -> getVar('lang_image'))){
  182. $lang_image = $ext -> getVar('lang_image');
  183. }else{
  184. $lang_image = 'noflag.gif';
  185. }
  186. echo "<td><img src='" . XOOPS_URL.'/modules/xlanguage/images/'.$lang_image . "' alt='".$ext -> getVar('lang_desc')."' /></td>\n";
  187. echo "<td>" . $ext -> getVar('weight') . "</td>\n";
  188. $lang_base = ($isOrphan)?"<font color='red'>".$ext -> getVar('lang_base')."</font>":$ext -> getVar('lang_base');
  189. echo "<td><b>" . $lang_base . "</b></td>\n";
  190. echo "<td><a href='index.php?op=edit&amp;type=ext&amp;lang_id=" . $ext -> getVar('lang_id') . "'>" . _EDIT . "</a></td>\n";
  191. echo "<td><a href='index.php?op=del&amp;type=ext&amp;lang_id=" . $ext -> getVar('lang_id') . "'>" . _DELETE ."</td>\n";
  192. echo "</tr>\n";
  193. }
  194. echo "<tr><td colspan='9' height='2px'></td></tr>\n";
  195. }
  196. echo "</table></div>\n";
  197. echo"</td></tr></table>";
  198. echo "<br />";
  199. }
  200. }
  201. ?>