From: <tr...@us...> - 2012-12-02 17:33:01
|
Revision: 10301 http://sourceforge.net/p/xoops/svn/10301 Author: trabis Date: 2012-12-02 17:32:55 +0000 (Sun, 02 Dec 2012) Log Message: ----------- Updating/fixing xlanguage for 2.6 Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/about.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/footer.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/header.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/index.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/menu.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/api.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/blocks/xlanguage_blocks.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/form/language.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/xlanguage.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/autoload.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/functions.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/vars.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/preloads/core.php Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/about.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/about.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/about.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -19,6 +19,7 @@ include dirname(__FILE__) . '/header.php'; +$xoops = Xoops::getInstance(); $xoops->header(); $xoops->theme->addStylesheet('modules/xcontact/css/moduladmin.css'); @@ -26,5 +27,4 @@ $admin_page->renderNavigation('about.php'); $admin_page->renderAbout(); -$xoops->footer(); -?> \ No newline at end of file +$xoops->footer(); \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/footer.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/footer.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/footer.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -17,6 +17,6 @@ * @version $Id$ */ +$xoops = Xoops::getInstance(); $admin_page->renderIndex(); -$xoops->footer(); -?> \ No newline at end of file +$xoops->footer(); \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/header.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/header.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/header.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -1,7 +1,6 @@ <?php /** * Xlanguage extension module - * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. @@ -20,13 +19,13 @@ include_once dirname(dirname(dirname(dirname(__FILE__)))) . '/include/cp_header.php'; $op = ''; -if ( isset( $_POST ) ){ - foreach ( $_POST as $k => $v ) { +if (isset($_POST)) { + foreach ($_POST as $k => $v) { ${$k} = $v; } } -if ( isset( $_GET ) ){ - foreach ( $_GET as $k => $v ) { +if (isset($_GET)) { + foreach ($_GET as $k => $v) { ${$k} = $v; } } @@ -42,5 +41,4 @@ $xoops->header(); $xoops->theme->addStylesheet('modules/xlanguage/css/moduladmin.css'); -$admin_page = new XoopsModuleAdmin(); -?> \ No newline at end of file +$admin_page = new XoopsModuleAdmin(); \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/index.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/index.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/index.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -19,24 +19,25 @@ include dirname(__FILE__) . '/header.php'; +$xoops = Xoops::getInstance(); $xoops->header(); -switch ( $op ) { +switch ( $op ) { case 'save': - if ( !$GLOBALS['xoopsSecurity']->check() ) { - $xoops->redirect('index.php', 5, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); + if ( !$xoops->security->check() ) { + $xoops->redirect('index.php', 5, implode(',', $xoops->security->getErrors())); } $xlanguage_id = $system->CleanVars($_POST, 'xlanguage_id', 0, 'int'); - if( isset($xlanguage_id) && $xlanguage_id > 0 ){ + if( isset($xlanguage_id) && $xlanguage_id > 0 ){ $lang = $xlanguage_handler->get($xlanguage_id); - } else { + } else { $lang = $xlanguage_handler->create(); } $lang->CleanVarsForDB(); - if ($xlanguage_handler->insert($lang)) { + if ($xlanguage_handler->insert($lang)) { $xlanguage_handler->createConfig(); $xoops->redirect('index.php', 5, _AM_XLANGUAGE_SAVED); } @@ -51,15 +52,15 @@ case 'edit': $xlanguage_id = $system->CleanVars($_REQUEST, 'xlanguage_id', 0, 'int'); - if( isset($xlanguage_id) && $xlanguage_id > 0 ){ - if ($lang = $xlanguage_handler->get($xlanguage_id) ) { + if( isset($xlanguage_id) && $xlanguage_id > 0 ){ + if ($lang = $xlanguage_handler->get($xlanguage_id) ) { $form = $xoops->getModuleForm($lang, 'language', 'xlanguage'); $admin_page->addInfoBox(_MI_XLANGUAGE_MODIFY); $admin_page->addInfoBoxLine( $form->render() ); - } else { - $xoops->redirect('index.php', 5); + } else { + $xoops->redirect('index.php', 5); } - } else { + } else { $xoops->redirect('index.php', 5); } break; @@ -67,16 +68,16 @@ case 'del': $xlanguage_id = $system->CleanVars($_REQUEST, 'xlanguage_id', 0, 'int'); if( isset($xlanguage_id) && $xlanguage_id > 0 ){ - if ($lang = $xlanguage_handler->get($xlanguage_id) ) { + if ($lang = $xlanguage_handler->get($xlanguage_id) ) { $delete = $system->CleanVars( $_POST, 'ok', 0, 'int' ); - if ($delete == 1) { - if ( !$GLOBALS['xoopsSecurity']->check() ) { + if ($delete == 1) { + if ( !$xoops->security->check() ) { $xoops->redirect('index.php', 5, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } $xlanguage_handler->delete($lang); $xlanguage_handler->createConfig(); $xoops->redirect('index.php', 5, _AM_XLANGUAGE_DELETED); - } else { + } else { ob_start(); $xoops->confirm(array('ok' => 1, 'xlanguage_id' => $xlanguage_id, 'op' => 'del'), $_SERVER['REQUEST_URI'], sprintf(_AM_XLANGUAGE_DELETE_CFM . "<br /><b><span style='color : Red'> %s </span></b><br /><br />", $lang->getVar('xlanguage_name'))); $confirm = '<div class="confirm">' . ob_get_contents() . '</div>'; @@ -84,10 +85,10 @@ $admin_page->addInfoBox(_MI_XLANGUAGE_DELETE); $admin_page->addInfoBoxLine($confirm); } - } else { + } else { $xoops->redirect('index.php', 5); } - } else { + } else { $xoops->redirect('index.php', 5); } break; @@ -104,4 +105,3 @@ break; } include dirname(__FILE__) . '/footer.php'; -?> Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/menu.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/menu.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/menu.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -35,5 +35,4 @@ $cpt++; $adminmenu[$cpt]['title'] = _MI_XLANGUAGE_ABOUT; $adminmenu[$cpt]['link'] = 'admin/about.php'; -$adminmenu[$cpt]['icon'] = 'about.png'; -?> \ No newline at end of file +$adminmenu[$cpt]['icon'] = 'about.png'; \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/api.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/api.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/api.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -1,7 +1,6 @@ <?php /** * Xlanguage extension module - * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. @@ -17,17 +16,19 @@ * @version $Id$ */ -global $xoops, $xlanguage; +$xoops = Xoops::getInstance(); +$xlanguage = array(); + include_once XOOPS_ROOT_PATH . '/modules/xlanguage/include/vars.php'; include_once XOOPS_ROOT_PATH . '/modules/xlanguage/include/functions.php'; -$cookie_var = XLANGUAGE_LANG_TAG; +$cookie_var = $xoops->registry->get('XLANGUAGE_LANG_TAG'); $xlanguage['action'] = false; -if (!empty($_GET[XLANGUAGE_LANG_TAG])) { +if (!empty($_GET[$xoops->registry->get('XLANGUAGE_LANG_TAG')])) { $cookie_path = '/'; - setcookie($cookie_var, $_GET[XLANGUAGE_LANG_TAG], time()+3600*24*30, $cookie_path, '', 0); - $xlanguage['lang'] = $_GET[XLANGUAGE_LANG_TAG]; + setcookie($cookie_var, $_GET[$xoops->registry->get('XLANGUAGE_LANG_TAG')], time() + 3600 * 24 * 30, $cookie_path, '', 0); + $xlanguage['lang'] = $_GET[$xoops->registry->get('XLANGUAGE_LANG_TAG')]; } elseif (!empty($_COOKIE[$cookie_var])) { $xlanguage['lang'] = $_COOKIE[$cookie_var]; } elseif ($lang = xlanguage_detectLang()) { @@ -41,29 +42,29 @@ $lang = $xlanguage_handler->getByName($xlanguage['lang']); -if ( is_array($lang) && strcasecmp($lang['xlanguage_name'], $xoops->getConfig('language')) ) { +if (is_array($lang) && strcasecmp($lang['xlanguage_name'], $xoops->getConfig('language'))) { $xoops->setConfig('language', $lang['xlanguage_name']); - if ( $lang['xlanguage_charset'] ) { + if ($lang['xlanguage_charset']) { $xlanguage['charset'] = $lang['xlanguage_charset']; } - if ( $lang['xlanguage_code'] ) { + if ($lang['xlanguage_code']) { $xlanguage['code'] = $lang['xlanguage_code']; } } unset($lang); -$GLOBALS['xlanguage_handler'] = $xlanguage_handler; +$xoops->registry->set('XLANGUAGE_HANDLER', $xlanguage_handler); -if ( $xlanguage['action'] ) { +if ($xlanguage['action']) { //if(CONV_REQUEST && (!empty($_GET)||!empty($_POST))){ - if ( !empty($_POST) ) { + if (!empty($_POST)) { $in_charset = $xlanguage['charset']; $out_charset = $xlanguage['charset_base']; //$CONV_REQUEST_array=array('_GET', '_POST'); - $CONV_REQUEST_array=array('_POST'); - foreach ( $CONV_REQUEST_array as $HV ) { - if ( !empty(${$HV}) ) { + $CONV_REQUEST_array = array('_POST'); + foreach ($CONV_REQUEST_array as $HV) { + if (!empty(${$HV})) { ${$HV} = xlanguage_convert_encoding(${$HV}, $out_charset, $in_charset); } $GLOBALS['HTTP' . $HV . '_VARS'] = ${$HV}; @@ -74,11 +75,4 @@ ob_start('xlanguage_ml'); } -/* - * hardcoded scripts for language switching in theme html files - * - * see include/vars.php - */ - - -?> \ No newline at end of file +$xoops->registry->set('XLANGUAGE', $xlanguage); \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/blocks/xlanguage_blocks.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/blocks/xlanguage_blocks.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/blocks/xlanguage_blocks.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -1,7 +1,6 @@ <?php /** * Xlanguage extension module - * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. @@ -17,57 +16,57 @@ * @version $Id$ */ - function b_xlanguage_select_show($options) -{ - global $xlanguage; - $xoops = Xoops::getInstance(); +{ + $xoops = Xoops::getInstance(); + $xlanguage = $xoops->registry->get('XLANGUAGE'); + $lang_tag = $xoops->registry->get('XLANGUAGE_LANG_TAG'); - $options[3] = $xoops->getModuleConfig('theme', 'xlanguage'); + $options[3] = $xoops->getModuleConfig('theme', 'xlanguage'); $block = array(); - $xlanguage_handler = $xoops->getModuleHandler('xlanguage', 'xlanguage'); - $xlanguage_handler->loadConfig(); + $xlanguage_handler = $xoops->getModuleHandler('xlanguage', 'xlanguage'); + $xlanguage_handler->loadConfig(); - if ( !is_array($xlanguage_handler->cached_config) || count($xlanguage_handler->cached_config)<1 ) { - return $block; + if (!is_array($xlanguage_handler->cached_config) || count($xlanguage_handler->cached_config) < 1) { + return $block; } - $QUERY_STRING_array = array_filter(explode('&',$xoops->getEnv('QUERY_STRING'))); - $QUERY_STRING_new = array(); - foreach ( $QUERY_STRING_array as $QUERY ) { - if ( substr($QUERY, 0, (strlen(XLANGUAGE_LANG_TAG)+1)) != XLANGUAGE_LANG_TAG . '=' ) { - $vals = explode('=', $QUERY); - foreach ( array_keys($vals) as $key ) { - if ( preg_match('/^a-z0-9$/i', $vals[$key]) ) { - $vals[$key] = urlencode($vals[$key]); - } - } - $QUERY_STRING_new[] = implode('=', $vals); - } - } + $QUERY_STRING_array = array_filter(explode('&', $xoops->getEnv('QUERY_STRING'))); + $QUERY_STRING_new = array(); + foreach ($QUERY_STRING_array as $QUERY) { + if (substr($QUERY, 0, (strlen($lang_tag) + 1)) != $lang_tag . '=') { + $vals = explode('=', $QUERY); + foreach (array_keys($vals) as $key) { + if (preg_match('/^a-z0-9$/i', $vals[$key])) { + $vals[$key] = urlencode($vals[$key]); + } + } + $QUERY_STRING_new[] = implode('=', $vals); + } + } - $block['display'] = $options[0]; - $block['delimitor'] = $options[1]; - $block['number'] = $options[2]; + $block['display'] = $options[0]; + $block['delimitor'] = $options[1]; + $block['number'] = $options[2]; - $block['selected'] = $xlanguage['lang']; + $block['selected'] = $xlanguage['lang']; - if ( $options[0] == 'images' || $options[0] == 'text' ) { - $query_string = htmlSpecialChars(implode('&', $QUERY_STRING_new)); - $query_string .= empty($query_string) ? '' : '&'; - } else { - $query_string = implode('&', array_map('htmlspecialchars', $QUERY_STRING_new)); - $query_string .= empty($query_string) ? '' : '&'; - } - $block['url'] = $xoops->getEnv('PHP_SELF') . '?' . $query_string . XLANGUAGE_LANG_TAG . '='; + if ($options[0] == 'images' || $options[0] == 'text') { + $query_string = htmlSpecialChars(implode('&', $QUERY_STRING_new)); + $query_string .= empty($query_string) ? '' : '&'; + } else { + $query_string = implode('&', array_map('htmlspecialchars', $QUERY_STRING_new)); + $query_string .= empty($query_string) ? '' : '&'; + } + $block['url'] = $xoops->getEnv('PHP_SELF') . '?' . $query_string . $lang_tag . '='; $block['languages'] = $xlanguage_handler->cached_config; - return $block; + return $block; } function b_xlanguage_select_edit($options) -{ +{ $block_form = new XoopsFormElementTray(' ', '<br />'); $tmp = new XoopsFormSelect(_MB_XLANGUAGE_DISPLAY_METHOD . ' : ', 'options[0]', $options[0]); @@ -78,9 +77,8 @@ $tmp->addOption('bootstrap', _MB_XLANGUAGE_DISPLAY_BOOTSTRAP); $block_form->addElement($tmp); - $block_form->addElement(new XoopsFormText(_MB_XLANGUAGE_IMAGE_SEPARATOR . ' (' . _MB_XLANGUAGE_OPTIONAL . ') : ', 'options[1]', 5, 5, $options[1] )); - $block_form->addElement(new XoopsFormText(_MB_XLANGUAGE_IMAGE_PERROW . ' (' . _MB_XLANGUAGE_OPTIONAL . ') : ', 'options[2]', 2, 2, $options[2] )); + $block_form->addElement(new XoopsFormText(_MB_XLANGUAGE_IMAGE_SEPARATOR . ' (' . _MB_XLANGUAGE_OPTIONAL . ') : ', 'options[1]', 5, 5, $options[1])); + $block_form->addElement(new XoopsFormText(_MB_XLANGUAGE_IMAGE_PERROW . ' (' . _MB_XLANGUAGE_OPTIONAL . ') : ', 'options[2]', 2, 2, $options[2])); - return $block_form->render(); -} -?> \ No newline at end of file + return $block_form->render(); +} \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/form/language.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/form/language.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/form/language.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -1,7 +1,6 @@ <?php /** * Xlanguage module - * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. @@ -31,48 +30,48 @@ /** * Maintenance Form + * * @return void */ public function LanguageForm() - { + { $xoops = Xoops::getInstance(); parent::__construct('', 'xlanguage_form', $xoops->getEnv('PHP_SELF'), 'post', true, 'horizontal'); // language name - $xlanguage_select = new XoopsFormSelect(_AM_XLANGUAGE_NAME, 'xlanguage_name', $this->xoopsObject->getVar('xlanguage_name')); + $xlanguage_select = new XoopsFormSelect(_AM_XLANGUAGE_NAME, 'xlanguage_name', $this->xoopsObject->getVar('xlanguage_name')); $xlanguage_select->addOptionArray(XoopsLists::getLangList()); $this->addElement($xlanguage_select, true); // language description - $this->addElement(new XoopsFormText(_AM_XLANGUAGE_DESCRIPTION, 'xlanguage_description', 5, 10, $this->xoopsObject->getVar('xlanguage_description') ), true); + $this->addElement(new XoopsFormText(_AM_XLANGUAGE_DESCRIPTION, 'xlanguage_description', 5, 10, $this->xoopsObject->getVar('xlanguage_description')), true); // language charset - $autoload = XoopsLoad::loadConfig( 'xlanguage' ); + $autoload = XoopsLoad::loadConfig('xlanguage'); $charset_select = new XoopsFormSelect(_AM_XLANGUAGE_CHARSET, 'xlanguage_charset', $this->xoopsObject->getVar('xlanguage_charset')); $charset_select->addOptionArray($autoload['charset']); $this->addElement($charset_select); // language code - $this->addElement(new XoopsFormText(_AM_XLANGUAGE_CODE, 'xlanguage_code', 5, 10, $this->xoopsObject->getVar('xlanguage_code') ), true); + $this->addElement(new XoopsFormText(_AM_XLANGUAGE_CODE, 'xlanguage_code', 5, 10, $this->xoopsObject->getVar('xlanguage_code')), true); // language weight - $this->addElement(new XoopsFormText(_AM_XLANGUAGE_WEIGHT, 'xlanguage_weight', 5, 10, $this->xoopsObject->getVar('xlanguage_weight') )); + $this->addElement(new XoopsFormText(_AM_XLANGUAGE_WEIGHT, 'xlanguage_weight', 5, 10, $this->xoopsObject->getVar('xlanguage_weight'))); - // language image $image_option_tray = new XoopsFormElementTray(_AM_XLANGUAGE_IMAGE, ''); $image_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/media/xoops/images/flags/' . $xoops->getModuleConfig('theme', 'xlanguage') . '/'); - $image_select = new XoopsFormSelect('', 'xlanguage_image', $this->xoopsObject->getVar('xlanguage_image')); + $image_select = new XoopsFormSelect('', 'xlanguage_image', $this->xoopsObject->getVar('xlanguage_image')); $image_select->addOptionArray($image_array); $image_select->setExtra("onchange='showImgSelected(\"image\", \"xlanguage_image\", \"/media/xoops/images/flags/" . $xoops->getModuleConfig('theme', 'xlanguage') . "/\", \"\", \"" . XOOPS_URL . "\")'"); $image_tray = new XoopsFormElementTray('', ' '); $image_tray->addElement($image_select); - $image_tray->addElement(new XoopsFormLabel('', "<div style='padding: 8px;'><img style='width:24px; height:24px; ' src='" . XOOPS_URL . "/media/xoops/images/flags/" . $xoops->getModuleConfig('theme', 'xlanguage') . "/" . $this->xoopsObject->getVar("xlanguage_image") . "' name='image' id='image' alt='' /></div>")); + $image_tray->addElement(new XoopsFormLabel('', "<div style='padding: 8px;'><img style='width:24px; height:24px; ' src='" . XOOPS_URL . "/media/xoops/images/flags/" . $xoops->getModuleConfig('theme', 'xlanguage') . "/" . $this->xoopsObject->getVar("xlanguage_image") . "' name='image' id='image' alt='' /></div>")); $image_option_tray->addElement($image_tray); $this->addElement($image_option_tray); - $this->addElement(new XoopsFormHidden('xlanguage_id', $this->xoopsObject->getVar('xlanguage_id') )); + $this->addElement(new XoopsFormHidden('xlanguage_id', $this->xoopsObject->getVar('xlanguage_id'))); $button_tray = new XoopsFormElementTray('', ''); $button_tray->addElement(new XoopsFormHidden('op', 'save')); @@ -86,7 +85,7 @@ } public function render() - { + { $this->LanguageForm(); ob_start(); parent::render(); @@ -94,5 +93,4 @@ ob_end_clean(); return $ret; } -} -?> \ No newline at end of file +} \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/xlanguage.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/xlanguage.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/xlanguage.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -1,7 +1,6 @@ <?php /** * Xlanguage extension module - * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. @@ -22,26 +21,21 @@ include_once XOOPS_ROOT_PATH . '/modules/xlanguage/include/vars.php'; class Xlanguage extends XoopsObject -{ +{ public function __construct() - { - $this->initVar('xlanguage_id' , XOBJ_DTYPE_INT , 0 , false, 10); - $this->initVar('xlanguage_name' , XOBJ_DTYPE_TXTBOX , '' , false); - $this->initVar('xlanguage_description' , XOBJ_DTYPE_TXTBOX , '' , false); - $this->initVar('xlanguage_code' , XOBJ_DTYPE_TXTBOX , '' , false); - $this->initVar('xlanguage_charset' , XOBJ_DTYPE_TXTBOX , '' , false); - $this->initVar('xlanguage_image' , XOBJ_DTYPE_TXTBOX , 'english.png' , false); - $this->initVar('xlanguage_weight' , XOBJ_DTYPE_INT , 1 , false, 10); - } - - public function Xlanguage() { - $this->__construct(); + $this->initVar('xlanguage_id', XOBJ_DTYPE_INT, 0, false, 10); + $this->initVar('xlanguage_name', XOBJ_DTYPE_TXTBOX, '', false); + $this->initVar('xlanguage_description', XOBJ_DTYPE_TXTBOX, '', false); + $this->initVar('xlanguage_code', XOBJ_DTYPE_TXTBOX, '', false); + $this->initVar('xlanguage_charset', XOBJ_DTYPE_TXTBOX, '', false); + $this->initVar('xlanguage_image', XOBJ_DTYPE_TXTBOX, 'english.png', false); + $this->initVar('xlanguage_weight', XOBJ_DTYPE_INT, 1, false, 10); } public function toArray() - { - global $xoops; + { + $xoops = Xoops::getInstance(); $ret = parent::toArray(); $ret['xlanguage_image'] = XOOPS_URL . '/media/xoops/images/flags/' . $xoops->getModuleConfig('theme', 'xlanguage') . '/' . $this->getVar('xlanguage_image'); return $ret; @@ -50,20 +44,20 @@ public function CleanVarsForDB() { global $system; - foreach ( $this->getValues() as $k => $v ) { - if ( $k != 'dohtml' ) { - if ( $this->vars[$k]['data_type'] == XOBJ_DTYPE_STIME || $this->vars[$k]['data_type'] == XOBJ_DTYPE_MTIME || $this->vars[$k]['data_type'] == XOBJ_DTYPE_LTIME) { + foreach ($this->getValues() as $k => $v) { + if ($k != 'dohtml') { + if ($this->vars[$k]['data_type'] == XOBJ_DTYPE_STIME || $this->vars[$k]['data_type'] == XOBJ_DTYPE_MTIME || $this->vars[$k]['data_type'] == XOBJ_DTYPE_LTIME) { $value = $system->CleanVars($_POST[$k], 'date', date('Y-m-d'), 'date') + $system->CleanVars($_POST[$k], 'time', date('u'), 'int'); - $this->setVar( $k, isset( $_POST[$k] ) ? $value : $v ); - } elseif ( $this->vars[$k]['data_type'] == XOBJ_DTYPE_INT ) { + $this->setVar($k, isset($_POST[$k]) ? $value : $v); + } elseif ($this->vars[$k]['data_type'] == XOBJ_DTYPE_INT) { $value = $system->CleanVars($_POST, $k, $v, 'int'); - $this->setVar( $k, $value ); - } elseif ( $this->vars[$k]['data_type'] == XOBJ_DTYPE_ARRAY ) { + $this->setVar($k, $value); + } elseif ($this->vars[$k]['data_type'] == XOBJ_DTYPE_ARRAY) { $value = $system->CleanVars($_POST, $k, $v, 'array'); - $this->setVar( $k, $value ); + $this->setVar($k, $value); } else { $value = $system->CleanVars($_POST, $k, $v, 'string'); - $this->setVar( $k, $value ); + $this->setVar($k, $value); } } } @@ -72,7 +66,6 @@ class XlanguageXlanguageHandler extends XoopsPersistableObjectHandler { - public function __construct(&$db) { parent::__construct($db, 'xlanguage', 'Xlanguage', 'xlanguage_id', 'xlanguage_name'); @@ -80,14 +73,15 @@ public function loadConfig() { + $xoops = Xoops::getInstance(); $this->configPath = XOOPS_VAR_PATH . '/configs/xlanguage/'; - $this->configFile = XLANGUAGE_CONFIG_FILE; + $this->configFile = $xoops->registry->get('XLANGUAGE_CONFIG_FILE'); $this->configFileExt = '.php'; $this->cached_config = $this->loadFileConfig(); } public function loadFileConfig() - { + { $cached_config = $this->readConfig(); if (empty($cached_config)) { $cached_config = $this->createConfig(); @@ -106,7 +100,7 @@ public function createConfig() { $cached_config = array(); - foreach ( $this->getAllLanguage( false ) as $key => $language ) { + foreach ($this->getAllLanguage(false) as $key => $language) { $cached_config[$language['xlanguage_name']] = $language; } $this->writeConfig($cached_config); @@ -115,28 +109,28 @@ public function writeConfig($data) { - if ($this->CreatePath($this->configPath) ) { + if ($this->CreatePath($this->configPath)) { $path_file = $this->configPath . $this->configFile . $this->configFileExt; XoopsLoad::load('XoopsFile'); $file = XoopsFile::getHandler('file', $path_file); - return $file->write( "return " . var_export($data, true) . ";"); + return $file->write("return " . var_export($data, true) . ";"); } } - private function CreatePath( $pathname, $pathout = XOOPS_ROOT_PATH ) + private function CreatePath($pathname, $pathout = XOOPS_ROOT_PATH) { $xoops = Xoops::getInstance(); - $pathname = substr( $pathname, strlen(XOOPS_ROOT_PATH) ); - $pathname = str_replace( DIRECTORY_SEPARATOR, '/', $pathname ); + $pathname = substr($pathname, strlen(XOOPS_ROOT_PATH)); + $pathname = str_replace(DIRECTORY_SEPARATOR, '/', $pathname); $dest = $pathout; - $paths = explode( '/', $pathname ); + $paths = explode('/', $pathname); - foreach ( $paths as $path ) { - if ( !empty( $path ) ) { + foreach ($paths as $path) { + if (!empty($path)) { $dest = $dest . '/' . $path; - if ( !is_dir( $dest ) ) { - if ( !mkdir( $dest , 0755 ) ) { + if (!is_dir($dest)) { + if (!mkdir($dest, 0755)) { return false; } else { $this->WriteIndex($xoops->path('uploads'), 'index.html', $dest); @@ -147,54 +141,51 @@ return true; } - private function WriteIndex( $folder_in, $source_file, $folder_out ) + private function WriteIndex($folder_in, $source_file, $folder_out) { - if ( !is_dir($folder_out) ) { - if ( !$this->CreatePath($folder_out) ) { + if (!is_dir($folder_out)) { + if (!$this->CreatePath($folder_out)) { return false; } } // Simple copy for a file - if ( is_file($folder_in . '/' . $source_file) ) { - return copy($folder_in . '/' . $source_file, $folder_out . '/' . basename($source_file) ); + if (is_file($folder_in . '/' . $source_file)) { + return copy($folder_in . '/' . $source_file, $folder_out . '/' . basename($source_file)); } return false; } - public function getByName($name = null) { - global $xoops; - $lang = empty($name) ? $xoops->getConfig('language') : strtolower($name); + $xoops = Xoops::getInstance(); + $name = empty($name) ? $xoops->getConfig('language') : strtolower($name); - $file_config = XLANGUAGE_CONFIG_FILE; - if ( !file_exists($file_config) || !isset($this->cached_config)) { + $file_config = $xoops->registry->get('XLANGUAGE_CONFIG_FILE'); + if (!file_exists($file_config) || !isset($this->cached_config)) { $this->loadConfig(); } - if ( isset($this->cached_config[$name]) ) { + if (isset($this->cached_config[$name])) { return $this->cached_config[$name]; } return null; } - - public function getAllLanguage( $asobject = true ) + public function getAllLanguage($asobject = true) { $criteria = new CriteriaCompo(); - $criteria->setSort( 'xlanguage_weight' ); - $criteria->setOrder( 'asc' ); + $criteria->setSort('xlanguage_weight'); + $criteria->setOrder('asc'); return parent::getAll($criteria, null, $asobject, true); } public function renderlist() { - global $xoops; - $xoops->tpl->assign('theme', $xoops->getModuleConfig('theme', 'xlanguage') ); - $xoops->tpl->assign('languages', $this->getAllLanguage(false) ); + $xoops = Xoops::getInstance(); + $xoops->tpl->assign('theme', $xoops->getModuleConfig('theme', 'xlanguage')); + $xoops->tpl->assign('languages', $this->getAllLanguage(false)); return $xoops->tpl->fetch('admin:xlanguage|xlanguage_admin_list.html'); } -} -?> \ No newline at end of file +} \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/autoload.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/autoload.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/autoload.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -46,5 +46,4 @@ 'windows-1258' => 'windows-1258', 'windows-874' => 'windows-874' ), -); -?> \ No newline at end of file +); \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/functions.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/functions.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/functions.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -1,7 +1,6 @@ <?php /** * Xlanguage extension module - * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. @@ -17,10 +16,17 @@ * @version $Id$ */ +/** + * @param string|array $value + * @param string $out_charset + * @param string $in_charset + * + * @return array|string + */ function xlanguage_convert_encoding($value, $out_charset, $in_charset) { - if ( is_array($value) ) { - foreach ( $value as $key => $val ) { + if (is_array($value)) { + foreach ($value as $key => $val) { $value[$key] = xlanguage_convert_encoding($val, $out_charset, $in_charset); } } else { @@ -29,18 +35,26 @@ return $value; } +/** + * @param string $value + * @param string $out_charset + * @param string $in_charset + * + * @return string + */ function xlanguage_convert_item($value, $out_charset, $in_charset) { - if ( strtolower($in_charset) == strtolower($out_charset) ) { + $xoops = Xoops::getInstance(); + if (strtolower($in_charset) == strtolower($out_charset)) { return $value; } - $xconv_handler = @xoops_getmodulehandler('xconv', 'xconv', true); - if ( is_object($xconv_handler) && $converted_value = @$xconv_handler->convert_encoding($value, $out_charset, $in_charset) ) { + $xconv_handler = $xoops->getModuleHandler('xconv', 'xconv', true); + if (is_object($xconv_handler) && $converted_value = @$xconv_handler->convert_encoding($value, $out_charset, $in_charset)) { return $converted_value; } - if ( XOOPS_USE_MULTIBYTES && function_exists('mb_convert_encoding') ) { + if (XOOPS_USE_MULTIBYTES && function_exists('mb_convert_encoding')) { $converted_value = @mb_convert_encoding($value, $out_charset, $in_charset); - } elseif ( function_exists('iconv') ) { + } elseif (function_exists('iconv')) { $converted_value = @iconv($in_charset, $out_charset, $value); } $value = empty($converted_value) ? $value : $converted_value; @@ -52,74 +66,84 @@ * Analyzes some PHP environment variables to find the most probable language * that should be used * - * @param string $ string to analyze - * @param integer $ type of the PHP environment variable which value is $str - * @global array the list of available translations - * @global string the retained translation keyword - * @access private + * @param string $str string to analyze + * @param integer $envType type of the PHP environment variable which value is $str + * + * @return int|string */ -function xlanguage_lang_detect($str = '', $envType = '') +function xlanguage_lang_detect($str = '', $envType = 0) { - foreach ( $GLOBALS['available_languages'] AS $key => $value ) { + $xoops = Xoops::getInstance(); + $lang = 'en'; + foreach ($xoops->registry->get('XLANGUAGE_AVAILABLE_LANGUAGES') as $key => $value) { // $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable, // 2 for the 'HTTP_USER_AGENT' one $expr = $value[0]; - if ( strpos($expr, '[-_]') === FALSE ) { + if (strpos($expr, '[-_]') === FALSE) { $expr = str_replace('|', '([-_][[:alpha:]]{2,3})?|', $expr); } - if ( ($envType == 1 && preg_match('^(' . $expr . ')(;q=[0-9]\\.[0-9])?$^', $str) ) || ($envType == 2 && preg_match('(\(|\[|;[[:space:]])(' . $expr . ')(;|\]|\))', $str))) { - $lang = $key; - //if ( $lang != 'en' ) + if (($envType == 1 && preg_match('^(' . $expr . ')(;q=[0-9]\\.[0-9])?$^', $str)) || ($envType == 2 && preg_match('(\(|\[|;[[:space:]])(' . $expr . ')(;|\]|\))', $str))) { + $lang = $key; break; } } return $lang; } +/** + * @return string + */ function xlanguage_detectLang() { - global $available_languages,$_SERVER; + $xoops = Xoops::getInstance(); - if ( !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) { + if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $HTTP_ACCEPT_LANGUAGE = $_SERVER['HTTP_ACCEPT_LANGUAGE']; } - if ( !empty($_SERVER['HTTP_USER_AGENT']) ) { + if (!empty($_SERVER['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; } $lang = ''; - $xoops_lang =''; + $xoops_lang = ''; // 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE // variable - if ( empty($lang) && !empty($HTTP_ACCEPT_LANGUAGE) ) { + if (empty($lang) && !empty($HTTP_ACCEPT_LANGUAGE)) { $accepted = explode(',', $HTTP_ACCEPT_LANGUAGE); $acceptedCnt = count($accepted); reset($accepted); for ($i = 0; $i < $acceptedCnt; $i++) { $lang = xlanguage_lang_detect($accepted[$i], 1); - if ( strncasecmp($lang,'en',2) ) { + if (strncasecmp($lang, 'en', 2)) { break; } } } // 2. try to findout user's language by checking its HTTP_USER_AGENT variable - if ( empty($lang) && !empty($HTTP_USER_AGENT) ) { + if (empty($lang) && !empty($HTTP_USER_AGENT)) { $lang = xlanguage_lang_detect($HTTP_USER_AGENT, 2); } // 3. If we catch a valid language, configure it - if ( !empty($lang) ) { - $xoops_lang = $available_languages[$lang][1]; + if (!empty($lang)) { + $available = $xoops->registry->get('XLANGUAGE_AVAILABLE_LANGUAGES'); + $xoops_lang = $available[$lang][1]; } return $xoops_lang; } +/** + * @param string $output + * + * @return array|mixed|string + */ function xlanguage_encoding($output) { - global $xlanguage; + $xoops = Xoops::getInstance(); + $xlanguage = $xoops->registry->get('XLANGUAGE'); $output = xlanguage_ml($output); // escape XML doc - if ( preg_match("/^\<\?[\s]?xml[\s]+version=([\"'])[^\>]+\\1[\s]+encoding=([\"'])[^\>]+\\2[\s]?\?\>/i", $output) ) { + if (preg_match("/^\<\?[\s]?xml[\s]+version=([\"'])[^\>]+\\1[\s]+encoding=([\"'])[^\>]+\\2[\s]?\?\>/i", $output)) { return $output; } $in_charset = $xlanguage['charset_base']; @@ -128,22 +152,32 @@ return $output = xlanguage_convert_encoding($output, $out_charset, $in_charset); } +/** + * @param string $s + * + * @return mixed + */ function xlanguage_ml($s) { - global $xoops, $xlanguage_langs; - if ( !is_object($xoops) ) { - $xoops = Xoops::getInstance(); + static $xlanguage_langs; + + $xoops = Xoops::getInstance(); + $xlanguage_handler = $xoops->registry->get('XLANGUAGE_HANDLER'); + + if (!is_object($xoops)) { + $xoops = Xoops::getInstance(); } $xoopsConfigLanguage = $xoops->getConfig('language'); - if ( !isset($xlanguage_langs) ) { - $langs = $GLOBALS['xlanguage_handler']->cached_config; - foreach ( array_keys($langs) as $_lang ) { + if (!isset($xlanguage_langs)) { + $langs = $xlanguage_handler->cached_config; + foreach (array_keys($langs) as $_lang) { $xlanguage_langs[$_lang] = $langs[$_lang]['xlanguage_code']; } unset($langs); } - if ( empty($xlanguage_langs) || count($xlanguage_langs) ==0) { + $xoops->registry->set('XLANGUAGE_LANGS', $xlanguage_langs); + if (empty($xlanguage_langs) || count($xlanguage_langs) == 0) { return $s; } @@ -156,70 +190,75 @@ // escape brackets inside of <textarea></textarea> $patterns[] = "/(\<textarea\b[^>]*>[^\<]*\<\/textarea>)/isU"; - $s = preg_replace_callback( $patterns , 'xlanguage_ml_escape_bracket' , $s ) ; + $s = preg_replace_callback($patterns, 'xlanguage_ml_escape_bracket', $s); // create the pattern between language tags - $pqhtmltags = explode( ',' , preg_quote( XLANGUAGE_TAGS_RESERVED , '/' ) ) ; - $mid_pattern = '(?:(?!(' . implode( '|' , $pqhtmltags ) . ')).)*' ; + $pqhtmltags = explode(',', preg_quote($xoops->registry->get('XLANGUAGE_TAGS_RESERVED'), '/')); + $mid_pattern = '(?:(?!(' . implode('|', $pqhtmltags) . ')).)*'; $patterns = array(); $replaces = array(); /* */ - if ( isset($xlanguage_langs[$xoopsConfigLanguage]) ) { + if (isset($xlanguage_langs[$xoopsConfigLanguage])) { $lang = $xlanguage_langs[$xoopsConfigLanguage]; $patterns[] = '/(\[([^\]]*\|)?' . preg_quote($lang) . '(\|[^\]]*)?\])(' . $mid_pattern . ')(\[\/([^\]]*\|)?' . preg_quote($lang) . '(\|[^\]]*)?\])/isU'; $replaces[] = '$4'; } /* */ - foreach ( array_keys($xlanguage_langs) as $_lang ) { - if ( $_lang == $xoopsConfigLanguage ) { + foreach (array_keys($xlanguage_langs) as $_lang) { + if ($_lang == $xoopsConfigLanguage) { continue; } $name = $xlanguage_langs[$_lang]; $patterns[] = '/(\[([^\]]*\|)?' . preg_quote($name) . '(\|[^\]]*)?\])(' . $mid_pattern . ')(\[\/([^\]]*\|)?' . preg_quote($name) . '(\|[^\]]*)?(\]\<br[\s]?[\/]?\>|\]))/isU'; $replaces[] = ''; } - if ( !empty($xoopsConfigLanguage) ) { - $s = preg_replace( '/\[[\/]?[\|]?' . preg_quote($xoopsConfigLanguage) . '[\|]?\](\<br \/\>)?/i' , '' , $s ) ; + if (!empty($xoopsConfigLanguage)) { + $s = preg_replace('/\[[\/]?[\|]?' . preg_quote($xoopsConfigLanguage) . '[\|]?\](\<br \/\>)?/i', '', $s); } - if ( count($replaces)>0 ) { - $s = preg_replace( $patterns , $replaces , $s ) ; + if (count($replaces) > 0) { + $s = preg_replace($patterns, $replaces, $s); } - return $s ; + return $s; } -function xlanguage_ml_escape_bracket( $matches ) +/** + * @param array $matches + * + * @return mixed + */ +function xlanguage_ml_escape_bracket($matches) { - global $xlanguage_langs; + $xoops = Xoops::getInstance(); + $xlanguage_langs = $xoops->registry->get('XLANGUAGE_LANGS'); + $ret = $matches[1]; - if ( !empty($xlanguage_langs) ) { - $pattern = '/(\[([\/])?(' . implode('|',array_map('preg_quote', array_values($xlanguage_langs))) . ')([\|\]]))/isU'; + if (!empty($xlanguage_langs)) { + $pattern = '/(\[([\/])?(' . implode('|', array_map('preg_quote', array_values($xlanguage_langs))) . ')([\|\]]))/isU'; $ret = preg_replace($pattern, '[\\2\\3\\4', $ret); } return $ret; } - function xlanguage_select_show($options = null) { - global $xoops; - if ( !constant(XLANGUAGE_THEME_ENABLE) ) { + $xoops = Xoops::getInstance(); + if (!$xoops->registry->get('XLANGUAGE_THEME_ENABLE')) { + define('XLANGUAGE_SWITCH_CODE', false); return false; } - include_once XOOPS_ROOT_PATH . '/modules/xlanguage/blocks/xlanguage_blocks.php'; - if ( empty($options) ) { - $options[0] = 'images'; // display style: image, text, select - $options[1] = ' '; // delimitor - $options[2] = 5; // items per line + if (empty($options)) { + $options[0] = 'images'; // display style: image, text, select + $options[1] = ' '; // delimitor + $options[2] = 5; // items per line } $block = b_xlanguage_select_show($options); $xoops->theme->addStylesheet('modules/xlanguage/css/block.css'); - $xoops->tpl->assign('block', $block ); + $xoops->tpl->assign('block', $block); $xlanguage_switch_code = "<div id='xo-language' class='" . $options[0] . "'>" . $xoops->tpl->fetch('db:xlanguage_block.html') . "</div>"; - define('XLANGUAGE_SWITCH_CODE', $xlanguage_switch_code); + define('XLANGUAGE_SWITCH_CODE',$xlanguage_switch_code); return true; -} -?> \ No newline at end of file +} \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/vars.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/vars.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/vars.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -1,7 +1,6 @@ <?php /** * Xlanguage extension module - * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. @@ -17,34 +16,13 @@ * @version $Id$ */ -if ( !defined('XLANGUAGE_CONFIG_FILE') ) { - define('XLANGUAGE_CONFIG_FILE', 'xlanguage'); -} -if ( !defined('XLANGUAGE_LANG_TAG') ) { - define('XLANGUAGE_LANG_TAG', 'lang'); -} -if ( !defined('XLANGUAGE_TAGS_RESERVED') ) { - define('XLANGUAGE_TAGS_RESERVED', '</head>,</body>'); -} +$xoops = Xoops::getInstance(); +$xoops->registry->set('XLANGUAGE_CONFIG_FILE', 'xlanguage'); +$xoops->registry->set('XLANGUAGE_LANG_TAG', 'lang'); +$xoops->registry->set('XLANGUAGE_TAGS_RESERVED', '</head>,</body>'); +$xoops->registry->set('XLANGUAGE_THEME_ENABLE', true); +$xoops->registry->set('XLANGUAGE_THEME_OPTIONS', 'bootstrap| |5'); // display mode, delimitor, number per line -/* - * hardcoded scripts for language switching in theme html files - * - * To use it: - * 1 set '$xlanguage_theme_enable = true;' - * 2 config options "$options = array('images', ' ', 5); // display mode, delimitor, number per line"; Options for display mode: image - flag; text - text; dropdown - dropdown selection box with text - * 3 insert "<{$smarty.const.XLANGUAGE_SWITCH_CODE}>" into your theme html anywhere you would like to see it present - */ - -if ( !defined('XLANGUAGE_THEME_ENABLE') ) { - define('XLANGUAGE_THEME_ENABLE', 'true'); -} - -if ( !defined('XLANGUAGE_THEME_OPTIONS') ) { - define('XLANGUAGE_THEME_OPTIONS', 'bootstrap| |5' ); // display mode, delimitor, number per line -} - - /** * phpMyAdmin Language Loading File */ @@ -67,54 +45,33 @@ * without the '.php' extension. * 4. The last values associated to the key is the language code as defined by * the RFC1766. - * * Beware that the sorting order (first values associated to keys by * alphabetical reverse order in the array) is important: 'zh-tw' (chinese * traditional) must be detected before 'zh' (chinese simplified) for * example. - * * When there are more than one charset for a language, we put the -utf-8 * first. */ -$GLOBALS['available_languages'] = array( - 'ar' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic'), - 'bg' => array('bg|bulgarian', 'bulgarian'), - 'ca' => array('ca|catalan', 'catalan'), - 'cs' => array('cs|czech', 'czech'), - 'da' => array('da|danish', 'danish'), - 'de' => array('de([-_][[:alpha:]]{2})?|german', 'german'), - 'el' => array('el|greek', 'greek'), - 'en' => array('en([-_][[:alpha:]]{2})?|english', 'english'), - 'es' => array('es([-_][[:alpha:]]{2})?|spanish', 'spanish'), - 'et' => array('et|estonian', 'estonian'), - 'fi' => array('fi|finnish', 'finnish'), - 'fr' => array('fr([-_][[:alpha:]]{2})?|french', 'french'), - 'gl' => array('gl|galician', 'galician'), - 'he' => array('he|hebrew', 'hebrew'), - 'hr' => array('hr|croatian', 'croatian'), - 'hu' => array('hu|hungarian', 'hungarian'), - 'id' => array('id|indonesian', 'indonesian'), - 'it' => array('it|italian', 'italian'), - 'ja' => array('ja|japanese', 'japanese'), - 'ko' => array('ko|korean', 'koreano'), - 'ka' => array('ka|georgian', 'georgian'), - 'lt' => array('lt|lithuanian', 'lithuanian'), - 'lv' => array('lv|latvian', 'latvian'), - 'nl' => array('nl([-_][[:alpha:]]{2})?|dutch', 'dutch'), - 'no' => array('no|norwegian', 'norwegian'), - 'pl' => array('pl|polish', 'polish'), - 'pt-br' => array('pt[-_]br|brazilian portuguese', 'portuguesebr'), - 'pt' => array('pt([-_][[:alpha:]]{2})?|portuguese', 'portuguese'), - 'ro' => array('ro|romanian', 'romanian'), - 'ru' => array('ru|russian', 'russian'), - 'sk' => array('sk|slovak', 'slovak'), - 'sq' => array('sq|albanian', 'albanian'), - 'sr' => array('sr|serbian', 'serbian'), - 'sv' => array('sv|swedish', 'swedish'), - 'th' => array('th|thai', 'thai'), - 'tr' => array('tr|turkish', 'turkish'), - 'uk' => array('uk|ukrainian', 'ukrainian'), - 'zh-tw' => array('zh[-_]tw|chinese traditional', 'tchinese'), - 'zh-cn' => array('zh[-_]cn|chinese simplified', 'schinese'), - ); -?> \ No newline at end of file +$xoops->registry->set('XLANGUAGE_AVAILABLE_LANGUAGES', array( + 'ar' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic'), 'bg' => array('bg|bulgarian', 'bulgarian'), + 'ca' => array('ca|catalan', 'catalan'), 'cs' => array('cs|czech', 'czech'), + 'da' => array('da|danish', 'danish'), 'de' => array('de([-_][[:alpha:]]{2})?|german', 'german'), + 'el' => array('el|greek', 'greek'), 'en' => array('en([-_][[:alpha:]]{2})?|english', 'english'), + 'es' => array('es([-_][[:alpha:]]{2})?|spanish', 'spanish'), 'et' => array('et|estonian', 'estonian'), + 'fi' => array('fi|finnish', 'finnish'), 'fr' => array('fr([-_][[:alpha:]]{2})?|french', 'french'), + 'gl' => array('gl|galician', 'galician'), 'he' => array('he|hebrew', 'hebrew'), + 'hr' => array('hr|croatian', 'croatian'), 'hu' => array('hu|hungarian', 'hungarian'), + 'id' => array('id|indonesian', 'indonesian'), 'it' => array('it|italian', 'italian'), + 'ja' => array('ja|japanese', 'japanese'), 'ko' => array('ko|korean', 'koreano'), + 'ka' => array('ka|georgian', 'georgian'), 'lt' => array('lt|lithuanian', 'lithuanian'), + 'lv' => array('lv|latvian', 'latvian'), 'nl' => array('nl([-_][[:alpha:]]{2})?|dutch', 'dutch'), + 'no' => array('no|norwegian', 'norwegian'), 'pl' => array('pl|polish', 'polish'), + 'pt-br' => array('pt[-_]br|brazilian portuguese', 'portuguesebr'), + 'pt' => array('pt([-_][[:alpha:]]{2})?|portuguese', 'portuguese'), 'ro' => array('ro|romanian', 'romanian'), + 'ru' => array('ru|russian', 'russian'), 'sk' => array('sk|slovak', 'slovak'), + 'sq' => array('sq|albanian', 'albanian'), 'sr' => array('sr|serbian', 'serbian'), + 'sv' => array('sv|swedish', 'swedish'), 'th' => array('th|thai', 'thai'), + 'tr' => array('tr|turkish', 'turkish'), 'uk' => array('uk|ukrainian', 'ukrainian'), + 'zh-tw' => array('zh[-_]tw|chinese traditional', 'tchinese'), + 'zh-cn' => array('zh[-_]cn|chinese simplified', 'schinese'), + )); \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/preloads/core.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/preloads/core.php 2012-12-02 16:23:25 UTC (rev 10300) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/preloads/core.php 2012-12-02 17:32:55 UTC (rev 10301) @@ -1,7 +1,6 @@ <?php /** * Xlanguage extension module - * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. @@ -19,7 +18,6 @@ defined('XOOPS_ROOT_PATH') or die('Restricted access'); - /** * Xlanguage core preloads * @@ -28,29 +26,26 @@ * @author trabis <lus...@gm...> */ class XlanguageCorePreload extends XoopsPreloadItem -{ - static public function eventCoreLanguageCommon($args) - { - if (XlanguageCorePreload::isActive()) { - include_once dirname(dirname(__FILE__)) . '/api.php'; - } +{ + /** + * @param array $args + */ + static public function eventCoreHeaderStart($args) + { + include_once dirname(dirname(__FILE__)) . '/api.php'; + include_once dirname(dirname(__FILE__)) . '/include/vars.php'; + include_once dirname(dirname(__FILE__)) . '/include/functions.php'; } - static public function eventCoreHeaderCommon($args) - { + /** + * @param array $args + */ + static public function eventCoreHeaderEnd($args) + { + $xoops = Xoops::getInstance(); + include_once dirname(dirname(__FILE__)) . '/api.php'; include_once dirname(dirname(__FILE__)) . '/include/vars.php'; include_once dirname(dirname(__FILE__)) . '/include/functions.php'; - if (XlanguageCorePreload::isActive() && defined('XLANGUAGE_THEME_ENABLE') && constant('XLANGUAGE_THEME_ENABLE') ) { - xlanguage_select_show( explode('|', XLANGUAGE_THEME_OPTIONS) ); - } + xlanguage_select_show(explode('|', $xoops->registry->get('XLANGUAGE_THEME_OPTIONS'))); } - - static private function isActive() - { - global $xoops; - $module_handler = $xoops->getHandlerModule(); - $module = $module_handler->getByDirname('xlanguage'); - return ($module && $module->getVar('isactive')) ? true : false; - } -} -?> +} \ No newline at end of file |