From: <du...@us...> - 2012-10-25 13:38:25
|
Revision: 10234 http://sourceforge.net/p/xoops/svn/10234 Author: dugris Date: 2012-10-25 13:38:21 +0000 (Thu, 25 Oct 2012) Log Message: ----------- xlanguage 4.00 alpha (Xoops multi-Language Management) System extensions for xoops 2.6.x Added Paths: ----------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/ 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/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/blocks/index.html 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/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/index.html 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/css/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css/block.css XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css/moduladmin.css XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/docs/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/docs/changelog.txt XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/docs/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/icons/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/icons/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/icons/logo_large.png XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/icons/logo_small.png XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/images/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/images/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/images/xlanguage_logo.png XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/ 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/index.html 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/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/language/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/language/english/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/language/english/admin.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/language/english/blocks.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/language/english/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/language/english/modinfo.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/language/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/media/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/media/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/media/jquery/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/media/jquery/jquery.language/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/media/jquery/jquery.language/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/media/jquery/jquery.language/jquery.language.css XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/media/jquery/jquery.language/jquery.language.js XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/preloads/ 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/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/sql/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/sql/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/sql/mysql.sql XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/admin/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/admin/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/admin/xlanguage_admin_list.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/blocks/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/blocks/xlanguage_block.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/blocks/xlanguage_block_bootstrap.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/blocks/xlanguage_block_images.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/blocks/xlanguage_block_jquery.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/blocks/xlanguage_block_select.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/blocks/xlanguage_block_text.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/templates/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/xoops_version.php Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/about.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,30 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @version $Id$ + */ + +include dirname(__FILE__) . '/header.php'; + +$xoops->header(); +$xoops->theme->addStylesheet('modules/xcontact/css/moduladmin.css'); + +$admin_page = new XoopsModuleAdmin(); + +$admin_page->renderNavigation('about.php'); +$admin_page->renderAbout(); +$xoops->footer(); +?> \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/about.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/footer.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,22 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @version $Id$ + */ + +$admin_page->renderIndex(); +$xoops->footer(); +?> \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/footer.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/header.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,46 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @version $Id$ + */ + +include_once dirname(dirname(dirname(dirname(__FILE__)))) . '/include/cp_header.php'; + +$op = ''; +if ( isset( $_POST ) ){ + foreach ( $_POST as $k => $v ) { + ${$k} = $v; + } +} +if ( isset( $_GET ) ){ + foreach ( $_GET as $k => $v ) { + ${$k} = $v; + } +} + +XoopsLoad::load('system', 'system'); + +$xoops = Xoops::getInstance(); +$system = System::getInstance(); + +$xlanguage_handler = $xoops->getModuleHandler('xlanguage', 'xlanguage'); +$xlanguage_handler->loadConfig(); + +$xoops->header(); +$xoops->theme->addStylesheet('modules/xlanguage/css/moduladmin.css'); + +$admin_page = new XoopsModuleAdmin(); +?> \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/header.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/index.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,105 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @version $Id$ + */ + +include dirname(__FILE__) . '/header.php'; + +$xoops->header(); + +switch ( $op ) { + + case 'save': + if ( !$GLOBALS['xoopsSecurity']->check() ) { + redirect_header('index.php', 5, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); + } + + $xlanguage_id = $system->CleanVars($_POST, 'xlanguage_id', 0, 'int'); + if( isset($xlanguage_id) && $xlanguage_id > 0 ){ + $lang = $xlanguage_handler->get($xlanguage_id); + } else { + $lang = $xlanguage_handler->create(); + } + $lang->CleanVarsForDB(); + + if ($xlanguage_handler->insert($lang)) { + $xlanguage_handler->createConfig(); + redirect_header('index.php', 5, _AM_XLANGUAGE_SAVED); + } + break; + + case 'add': + $lang = $xlanguage_handler->create(); + $admin_page->addInfoBox(_MI_XLANGUAGE_ADD_LANG); + $admin_page->addInfoBoxLine($lang->getForm()); + break; + + 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) ) { + $admin_page->addInfoBox(_MI_XLANGUAGE_MODIFY); + $admin_page->addInfoBoxLine($lang->getForm()); + } else { + redirect_header('index.php', 5); + } + } else { + redirect_header('index.php', 5); + } + break; + + 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) ) { + $delete = $system->CleanVars( $_POST, 'ok', 0, 'int' ); + if ($delete == 1) { + if ( !$GLOBALS['xoopsSecurity']->check() ) { + redirect_header('index.php', 5, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); + } + $xlanguage_handler->delete($lang); + $xlanguage_handler->createConfig(); + redirect_header('index.php', 5, _AM_XLANGUAGE_DELETED); + } 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><br /><br />", $lang->getVar('xlanguage_name'))); + $confirm = '<div class="confirm">' . ob_get_contents() . '</div>'; + ob_end_clean(); + $admin_page->addInfoBox(_MI_XLANGUAGE_DELETE); + $admin_page->addInfoBoxLine($confirm); + } + } else { + redirect_header('index.php', 5); + } + } else { + redirect_header('index.php', 5); + } + break; + + case 'createconfig': + $xlanguage_handler->createConfig(); + redirect_header( 'index.php', 5, _AM_XLANGUAGE_CREATED ); + break; + + case 'default': + default: + $admin_page->addInfoBox(_AM_XLANGUAGE_LANGLIST); + $admin_page->addInfoBoxLine($xlanguage_handler->renderlist()); + break; +} +include dirname(__FILE__) . '/footer.php'; +?> Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/index.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/menu.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,39 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @version $Id$ + */ + +$cpt = 0; +$adminmenu[$cpt]['title'] = _MI_XLANGUAGE_INDEX; +$adminmenu[$cpt]['link'] = 'admin/index.php'; +$adminmenu[$cpt]['icon'] = 'home.png'; + +$cpt++; +$adminmenu[$cpt]['title'] = _MI_XLANGUAGE_ADD_LANG; +$adminmenu[$cpt]['link'] = 'admin/index.php?op=add'; +$adminmenu[$cpt]['icon'] = 'add.png'; + +$cpt++; +$adminmenu[$cpt]['title'] = _MI_XLANGUAGE_CREATE_CONFIG; +$adminmenu[$cpt]['link'] = 'admin/index.php?op=createconfig'; +$adminmenu[$cpt]['icon'] = 'administration.png'; + +$cpt++; +$adminmenu[$cpt]['title'] = _MI_XLANGUAGE_ABOUT; +$adminmenu[$cpt]['link'] = 'admin/about.php'; +$adminmenu[$cpt]['icon'] = 'about.png'; +?> \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/admin/menu.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/api.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,84 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @version $Id$ + */ + +global $xoops, $xlanguage; +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; + +$xlanguage['action'] = false; +if (!empty($_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]; +} elseif (!empty($_COOKIE[$cookie_var])) { + $xlanguage['lang'] = $_COOKIE[$cookie_var]; +} elseif ($lang = xlanguage_detectLang()) { + $xlanguage['lang'] = $lang; +} else { + $xlanguage['lang'] = $xoops->getConfig('language'); +} + +$xlanguage_handler = $xoops->getModuleHandler('xlanguage', 'xlanguage'); +$xlanguage_handler->loadConfig(); + +$lang = $xlanguage_handler->getByName($xlanguage['lang']); + +if ( is_array($lang) && strcasecmp($lang['xlanguage_name'], $xoops->getConfig('language')) ) { + $xoops->setConfig('language', $lang['xlanguage_name']); + if ( $lang['xlanguage_charset'] ) { + $xlanguage['charset'] = $lang['xlanguage_charset']; + } + if ( $lang['xlanguage_code'] ) { + $xlanguage['code'] = $lang['xlanguage_code']; + } +} +unset($lang); + +$GLOBALS['xlanguage_handler'] = $xlanguage_handler; + +if ( $xlanguage['action'] ) { + //if(CONV_REQUEST && (!empty($_GET)||!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}) ) { + ${$HV} = xlanguage_convert_encoding(${$HV}, $out_charset, $in_charset); + } + $GLOBALS['HTTP' . $HV . '_VARS'] = ${$HV}; + } + } + ob_start('xlanguage_encoding'); +} else { + ob_start('xlanguage_ml'); +} + +/* + * hardcoded scripts for language switching in theme html files + * + * see include/vars.php + */ + + +?> \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/api.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/blocks ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/blocks/index.html =================================================================== Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/blocks/xlanguage_blocks.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,86 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @version $Id$ + */ + + +function b_xlanguage_select_show($options) +{ + global $xlanguage; + $xoops = Xoops::getInstance(); + + $options[3] = $xoops->getModuleConfig('theme', 'xlanguage'); + + $block = array(); + $xlanguage_handler = $xoops->getModuleHandler('xlanguage', 'xlanguage'); + $xlanguage_handler->loadConfig(); + + 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); + } + } + + $block['display'] = $options[0]; + $block['delimitor'] = $options[1]; + $block['number'] = $options[2]; + + $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 . '='; + $block['languages'] = $xlanguage_handler->cached_config; + + return $block; +} + +function b_xlanguage_select_edit($options) +{ + $block_form = new XoopsFormElementTray(' ', '<br />'); + + $tmp = new XoopsFormSelect(_MB_XLANGUAGE_DISPLAY_METHOD . ' : ', 'options[0]', $options[0]); + $tmp->addOption('images', _MB_XLANGUAGE_DISPLAY_FLAGLIST); + $tmp->addOption('text', _MB_XLANGUAGE_DISPLAY_TEXTLIST); + $tmp->addOption('select', _MB_XLANGUAGE_DISPLAY_SELECT); + $tmp->addOption('jquery', _MB_XLANGUAGE_DISPLAY_JQUERY); + $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] )); + + return $block_form->render(); +} +?> \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/blocks/xlanguage_blocks.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/index.html =================================================================== Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/xlanguage.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,216 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +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); + } + + function Xlanguage() + { + $this->__construct(); + } + + function toArray() + { + global $xoops; + $ret = parent::toArray(); + $ret['xlanguage_image'] = XOOPS_URL . '/media/xoops/images/flags/' . $xoops->getModuleConfig('theme', 'xlanguage') . '/' . $this->getVar('xlanguage_image'); + return $ret; + } + + 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) { + $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 ) { + $value = $system->CleanVars($_POST, $k, $v, 'int'); + $this->setVar( $k, $value ); + } elseif ( $this->vars[$k]['data_type'] == XOBJ_DTYPE_ARRAY ) { + $value = $system->CleanVars($_POST, $k, $v, 'array'); + $this->setVar( $k, $value ); + } else { + $value = $system->CleanVars($_POST, $k, $v, 'string'); + $this->setVar( $k, $value ); + } + } + } + } + + function getForm() + { + global $xoops; + + $xlanguage_form = new XoopsThemeForm('', 'langform', $xoops->getEnv('PHP_SELF'), 'post', true); + + // language name + $xlanguage_select = new XoopsFormSelect(_AM_XLANGUAGE_NAME, 'xlanguage_name', $this->getVar('xlanguage_name')); + $xlanguage_select->addOptionArray(XoopsLists::getLangList()); + $xlanguage_form->addElement($xlanguage_select, true); + + // language description + $xlanguage_form->addElement(new XoopsFormText(_AM_XLANGUAGE_DESCRIPTION, 'xlanguage_description', 5, 10, $this->getVar('xlanguage_description') ), true); + + // language charset + $autoload = XoopsLoad::loadConfig( 'xlanguage' ); + $charset_select = new XoopsFormSelect(_AM_XLANGUAGE_CHARSET, 'xlanguage_charset', $this->getVar('xlanguage_charset')); + $charset_select->addOptionArray($autoload['charset']); + $xlanguage_form->addElement($charset_select); + + // language code + $xlanguage_form->addElement(new XoopsFormText(_AM_XLANGUAGE_CODE, 'xlanguage_code', 5, 10, $this->getVar('xlanguage_code') ), true); + + // language weight + $xlanguage_form->addElement(new XoopsFormText(_AM_XLANGUAGE_WEIGHT, 'xlanguage_weight', 5, 10, $this->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->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->getVar("xlanguage_image") . "' name='image' id='image' alt='' /></div>")); + $image_option_tray->addElement($image_tray); + $xlanguage_form->addElement($image_option_tray); + + $xlanguage_form->addElement(new XoopsFormHidden('xlanguage_id', $this->getVar('xlanguage_id') )); + + $button_tray = new XoopsFormElementTray('', ''); + $button_tray->addElement(new XoopsFormHidden('op', 'save')); + $button_tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); + $button_tray->addElement(new XoopsFormButton('', 'reset', _RESET, 'reset')); + $cancel_send = new XoopsFormButton('', 'cancel', _CANCEL, 'button'); + $cancel_send->setExtra("onclick='javascript:history.go(-1);'"); + $button_tray->addElement($cancel_send); + + $xlanguage_form->addElement($button_tray); + + ob_start(); + $xlanguage_form->render(); + $ret = ob_get_contents(); + ob_end_clean(); + + return $ret; + } +} + +class XlanguageXlanguageHandler extends XoopsPersistableObjectHandler +{ + + function __construct(&$db) + { + parent::__construct($db, 'xlanguage', 'Xlanguage', 'xlanguage_id', 'xlanguage_name'); + } + + function loadConfig() + { + $this->configPath = XOOPS_VAR_PATH . '/configs/'; + $this->configFile = XLANGUAGE_CONFIG_FILE; + $this->configFileExt = '.php'; + $this->cached_config = $this->loadFileConfig(); + } + + function loadFileConfig() + { + $cached_config = $this->readConfig(); + if (empty($cached_config)) { + $cached_config = $this->createConfig(); + } + return $cached_config; + } + + function readConfig() + { + $path_file = $this->configPath . $this->configFile . $this->configFileExt; + XoopsLoad::load('XoopsFile'); + $file = XoopsFile::getHandler('file', $path_file); + return eval(@$file->read()); + } + + function createConfig() + { + $cached_config = array(); + foreach ( $this->getAllLanguage( false ) as $key => $language ) { + $cached_config[$language['xlanguage_name']] = $language; + } + $this->writeConfig($cached_config); + return $cached_config; + } + + function writeConfig($data) + { + $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) . ";"); + } + + function getByName($name = null) + { + global $xoops; + $lang = empty($name) ? $xoops->getConfig('language') : strtolower($name); + + $file_config = XLANGUAGE_CONFIG_FILE; + if ( !file_exists($file_config) || !isset($this->cached_config)) { + $this->loadConfig(); + } + + if ( isset($this->cached_config[$name]) ) { + return $this->cached_config[$name]; + } + return null; + } + + + function getAllLanguage( $asobject = true ) + { + $criteria = new CriteriaCompo(); + $criteria->setSort( 'xlanguage_weight' ); + $criteria->setOrder( 'asc' ); + + return parent::getAll($criteria, null, $asobject, true); + } + + function renderlist() + { + global $xoops; + $xoops->tpl->assign('theme', $xoops->getModuleConfig('theme', 'xlanguage') ); + $xoops->tpl->assign('languages', $this->getAllLanguage(false) ); + return $xoops->tpl->fetch('db:xlanguage_admin_list.html'); + } +} +?> \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/class/xlanguage.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css/block.css =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css/block.css (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css/block.css 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,55 @@ +#xo-language { + background: transparent; + color: #999999; + margin: 0; + padding: 0 15px; +} + +.text { + padding-top: 10px !important; + line-height: 18px; +} + +.text a { + color: #999999; +} + +.text a:active, .text a:hover { + color: #ffffff; +} + +.images { + padding-top: 7px !important; +} +img.flag { + width: 32px; + max-width: 32px; + filter: alpha(opacity=1000); + -moz-opacity: 1; + opacity: 1; + -khtml-opacity: 1; +} + +img.flag:hover { + filter: alpha(opacity=50); + -moz-opacity: 0.5; + opacity: 0.5; + -khtml-opacity: 0.5; +} + +.select { + padding-top: 6px !important; +} + +.jquery { + padding-top: 6px !important; + padding-bottom: 6px !important; +} + +.bootstrap { +} + +.ico-language { + background-image: url('../icons/logo_small.png'); + background-position: 0 0; +} Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css/index.html =================================================================== Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css/moduladmin.css =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css/moduladmin.css (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/css/moduladmin.css 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,19 @@ +.xo-moduleadmin-icon { + width: 100%!important; + max-width:39%; +} +.xo-moduleadmin-box { + width: 60% !important; +} + +.errorMsg,.confirmMsg, .resultMsg { padding: .8em; text-align:center; margin-bottom: 1em; border: 2px solid #ddd;} +.errorMsg { background-color: #FBE3E4; color: #D12F19; border-color: #FBC2C4; } +.confirmMsg { background-color: #FFF6BF; color: #817134; border-color: #FFD324; } +.resultMsg { background-color: #E6EFC2; color: #529214; border-color: #C6D880; } +.errorMsg a { background-color: transparent; color: #D12F19; } +.confirmMsg a { background-color: transparent; color: #817134; } +.successMsg a { background-color: transparent; color: #529214; } + +img.flag { + width:24px; +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/docs ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/docs/changelog.txt =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/docs/changelog.txt (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/docs/changelog.txt 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,26 @@ += CHANGES = + +<b>xlanguage 4.00</b> +- rewrite for Xoops 2.6.x Laurent JEN (aka DuGris) + +<b>xlanguage 3.02</b> +- xolanguage plugin added (see www.dugris.info) +- italian translation added (thanks to Lupin) + +<b>xlanguage 2.04</b> +- capable for different language cache, reported by suico @ xoops.org + +<b>xlanguage 2.03</b> +- "input" parse improvement, reported by irmtfan @ xoops.org + +<b>xlanguage 2.02</b> +- Thanks domifara @ dev.xoops.org + +<b>xlanguage 2.01</b> + +Credits: +1 - Adi Chiributa - web...@ar..., language handler +2 - wjue - http://www.wjue.org, ziling BIG5-GB2312 conversion +3 - GIJOE - http://www.peak.ne.jp, easiest multilanguage hack +4 - D.J.(phppp) - http://www.xoopsforge.com +5 - trabis - Xoops Module Developer \ No newline at end of file Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/docs/index.html =================================================================== Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/icons ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/icons/index.html =================================================================== Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/icons/logo_large.png =================================================================== (Binary files differ) Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/icons/logo_large.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/icons/logo_small.png =================================================================== (Binary files differ) Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/icons/logo_small.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/images ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/images/index.html =================================================================== Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/images/xlanguage_logo.png =================================================================== (Binary files differ) Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/images/xlanguage_logo.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/autoload.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,50 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +return array ( + 'charset' => array( + 'big5' => 'big5', + 'euc-kr' => 'euc-kr', + 'iso-8859-1' => 'iso-8859-1', + 'iso-8859-2' => 'iso-8859-2', + 'iso-8859-3' => 'iso-8859-3', + 'iso-8859-4' => 'iso-8859-4', + 'iso-8859-5' => 'iso-8859-5', + 'iso-8859-6' => 'iso-8859-6', + 'iso-8859-7' => 'iso-8859-7', + 'iso-8859-8' => 'iso-8859-8', + 'koi8-r' => 'koi8-r', + 'shift-jis' => 'shift-jis', + 'x-euc' => 'x-euc', + 'utf-8' => 'utf-8', + 'windows-1250' => 'windows-1250', + 'windows-1251' => 'windows-1251', + 'windows-1252' => 'windows-1252', + 'windows-1253' => 'windows-1253', + 'windows-1254' => 'windows-1254', + 'windows-1255' => 'windows-1255', + 'windows-1256' => 'windows-1256', + 'windows-1257' => 'windows-1257', + 'windows-1258' => 'windows-1258', + 'windows-874' => 'windows-874' + ), +); +?> \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/autoload.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/functions.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,225 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @version $Id$ + */ + +function xlanguage_convert_encoding($value, $out_charset, $in_charset) +{ + if ( is_array($value) ) { + foreach ( $value as $key => $val ) { + $value[$key] = xlanguage_convert_encoding($val, $out_charset, $in_charset); + } + } else { + $value = xlanguage_convert_item($value, $out_charset, $in_charset); + } + return $value; +} + +function xlanguage_convert_item($value, $out_charset, $in_charset) +{ + 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) ) { + return $converted_value; + } + if ( XOOPS_USE_MULTIBYTES && function_exists('mb_convert_encoding') ) { + $converted_value = @mb_convert_encoding($value, $out_charset, $in_charset); + } elseif ( function_exists('iconv') ) { + $converted_value = @iconv($in_charset, $out_charset, $value); + } + $value = empty($converted_value) ? $value : $converted_value; + + return $value; +} + +/** + * 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 + */ +function xlanguage_lang_detect($str = '', $envType = '') +{ + foreach ( $GLOBALS['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 ) { + $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' ) + break; + } + } + return $lang; +} + +function xlanguage_detectLang() +{ + global $available_languages,$_SERVER; + + if ( !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) { + $HTTP_ACCEPT_LANGUAGE = $_SERVER['HTTP_ACCEPT_LANGUAGE']; + } + + if ( !empty($_SERVER['HTTP_USER_AGENT']) ) { + $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; + } + + $lang = ''; + $xoops_lang =''; + // 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE + // variable + 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) ) { + break; + } + } + } + // 2. try to findout user's language by checking its HTTP_USER_AGENT variable + 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]; + } + return $xoops_lang; +} + +function xlanguage_encoding($output) +{ + global $xlanguage; + $output = xlanguage_ml($output); + // escape XML doc + if ( preg_match("/^\<\?[\s]?xml[\s]+version=([\"'])[^\>]+\\1[\s]+encoding=([\"'])[^\>]+\\2[\s]?\?\>/i", $output) ) { + return $output; + } + $in_charset = $xlanguage['charset_base']; + $out_charset = $xlanguage['charset']; + + return $output = xlanguage_convert_encoding($output, $out_charset, $in_charset); +} + +function xlanguage_ml($s) +{ + global $xoops, $xlanguage_langs; + 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 ) { + $xlanguage_langs[$_lang] = $langs[$_lang]['xlanguage_code']; + } + unset($langs); + } + if ( empty($xlanguage_langs) || count($xlanguage_langs) ==0) { + return $s; + } + + // escape brackets inside of <code>...</code> + $patterns[] = "/(\<code>.*\<\/code>)/isU"; + + // escape brackets inside of <input type='...' value='...'> + $patterns[] = '/(\<input\b(?![^\>]*\btype=([\'"]?)(submit|image|reset|button))[^\>]*\>)/isU'; + + // escape brackets inside of <textarea></textarea> + $patterns[] = "/(\<textarea\b[^>]*>[^\<]*\<\/textarea>)/isU"; + + $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 ) . ')).)*' ; + + $patterns = array(); + $replaces = array(); + /* */ + 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 ) { + 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 ( count($replaces)>0 ) { + $s = preg_replace( $patterns , $replaces , $s ) ; + } + + return $s ; +} + +function xlanguage_ml_escape_bracket( $matches ) +{ + global $xlanguage_langs; + $ret = $matches[1]; + 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) ) { + 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 + } + + $block = b_xlanguage_select_show($options); + $xoops->theme->addStylesheet('modules/xlanguage/css/block.css'); + $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); + return true; +} +?> \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/functions.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/index.html =================================================================== Added: 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 (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/vars.php 2012-10-25 13:38:21 UTC (rev 10234) @@ -0,0 +1,120 @@ +<?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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package xlanguage + * @since 2.6.0 + * @author Laurent JEN (Aka DuGris) + * @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>'); +} + +/* + * 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 + */ + +/** + * All the supported languages have to be listed in the array below. + * 1. The key must be the "official" ISO 639 language code and, if required, + * the dialect code. It can also contains some informations about the + * charset (see the Russian case). + * 2. The first of the values associated to the key is used in a regular + * expression to find some keywords corresponding to the language inside two + * environment variables. + * These values contains: + * - the "official" ISO language code and, if required, the dialect code + * also ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French + * dialects, 'zh[-_]tw' for Chinese traditional...); + * - the '|' character (it means 'OR'); + * - the full language name. + * 3. The second values associated to the key is the name of the file to load + * 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 Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/include/vars.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/xlanguage/index.html ===============... [truncated message content] |