示例#1
0
 /**
  * @param null $obj
  */
 public function __construct($obj = null)
 {
     $xoops = Xoops::getInstance();
     parent::__construct('', 'xlanguage_form', $xoops->getEnv('PHP_SELF'), 'post', true, 'horizontal');
     // language name
     $xlanguage_select = new Xoops\Form\Select(_AM_XLANGUAGE_NAME, 'xlanguage_name', $obj->getVar('xlanguage_name'));
     $xlanguage_select->addOptionArray(XoopsLists::getLocaleList());
     $this->addElement($xlanguage_select, true);
     // language description
     $this->addElement(new Xoops\Form\Text(_AM_XLANGUAGE_DESCRIPTION, 'xlanguage_description', 5, 30, $obj->getVar('xlanguage_description')), true);
     // language charset
     $autoload = XoopsLoad::loadConfig('xlanguage');
     $charset_select = new Xoops\Form\Select(_AM_XLANGUAGE_CHARSET, 'xlanguage_charset', $obj->getVar('xlanguage_charset'));
     $charset_select->addOptionArray($autoload['charset']);
     $this->addElement($charset_select);
     // language code
     $this->addElement(new Xoops\Form\Text(_AM_XLANGUAGE_CODE, 'xlanguage_code', 5, 10, $obj->getVar('xlanguage_code')), true);
     // language weight
     $this->addElement(new Xoops\Form\Text(_AM_XLANGUAGE_WEIGHT, 'xlanguage_weight', 1, 4, $obj->getVar('xlanguage_weight')));
     // language image
     $image_option_tray = new Xoops\Form\ElementTray(_AM_XLANGUAGE_IMAGE, '');
     $image_array = XoopsLists::getImgListAsArray(\XoopsBaseConfig::get('root-path') . '/media/xoops/images/flags/' . \Xoops\Module\Helper::getHelper('xlanguage')->getConfig('theme') . '/');
     $image_select = new Xoops\Form\Select('', 'xlanguage_image', $obj->getVar('xlanguage_image'));
     $image_select->addOptionArray($image_array);
     $image_select->setExtra("onchange='showImgSelected(\"image\", \"xlanguage_image\", \"/media/xoops/images/flags/" . \Xoops\Module\Helper::getHelper('xlanguage')->getConfig('theme') . "/\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'");
     $image_tray = new Xoops\Form\ElementTray('', ' ');
     $image_tray->addElement($image_select);
     $image_tray->addElement(new Xoops\Form\Label('', "<div style='padding: 8px;'><img style='width:24px; height:24px; ' src='" . \XoopsBaseConfig::get('url') . "/media/xoops/images/flags/" . \Xoops\Module\Helper::getHelper('xlanguage')->getConfig('theme') . "/" . $obj->getVar("xlanguage_image") . "' name='image' id='image' alt='' /></div>"));
     $image_option_tray->addElement($image_tray);
     $this->addElement($image_option_tray);
     $this->addElement(new Xoops\Form\Hidden('xlanguage_id', $obj->getVar('xlanguage_id')));
     /**
      * Buttons
      */
     $button_tray = new Xoops\Form\ElementTray('', '');
     $button_tray->addElement(new Xoops\Form\Hidden('op', 'save'));
     $button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
     $button->setClass('btn btn-success');
     $button_tray->addElement($button);
     $button_2 = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
     $button_2->setClass('btn btn-warning');
     $button_tray->addElement($button_2);
     switch (basename($xoops->getEnv('PHP_SELF'), '.php')) {
         case 'xoops_xlanguage':
             $button_3 = new Xoops\Form\Button('', 'button', XoopsLocale::A_CLOSE, 'button');
             $button_3->setExtra('onclick="tinyMCEPopup.close();"');
             $button_3->setClass('btn btn-danger');
             $button_tray->addElement($button_3);
             break;
         case 'index':
         default:
             $button_3 = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
             $button_3->setExtra("onclick='javascript:history.go(-1);'");
             $button_3->setClass('btn btn-danger');
             $button_tray->addElement($button_3);
             break;
     }
     $this->addElement($button_tray);
 }
示例#2
0
 /**
  * Get an instance to a module helper for a module directory
  *
  * @param string $dirname module direcory
  *
  * @return bool|Xoops\Module\Helper\HelperAbstract
  */
 public static function getHelper($dirname = 'system')
 {
     // if this is a 2.6 system turn everything over to the core
     if (class_exists('Xoops', false)) {
         return \Xoops\Module\Helper::getHelper($dirname);
     }
     // otherwise get a GenericHelper instance for dirname
     $dirname = strtolower($dirname);
     if (xoops_isActiveModule($dirname)) {
         return GenericHelper::getInstance($dirname);
     }
     // not an active installed module
     return false;
 }
示例#3
0
 /**
  * Get an instance of a module helper for the module identified by $dirname
  *
  * @param string $dirname module directory
  *
  * @return \Xmf\Module\Helper|\Xoops\Module\Helper|false a Helper object of false on error
  */
 public static function getHelper($dirname = 'system')
 {
     static $instance = array();
     $dirname = strtolower($dirname);
     if (!isset($instance[$dirname])) {
         $instance[$dirname] = false;
         // if this is a 2.6 system turn everything over to the core
         if (class_exists('Xoops', false)) {
             $instance[$dirname] = \Xoops\Module\Helper::getHelper($dirname);
         } else {
             // otherwise get a GenericHelper instance for dirname
             if (xoops_isActiveModule($dirname)) {
                 $instance[$dirname] = new static($dirname);
             }
         }
     }
     return $instance[$dirname];
 }
示例#4
0
/**
 * 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       2010-2014 XOOPS Project (http://xoops.org)
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package         xlanguage
 * @since           2.6.0
 * @author          Laurent JEN (Aka DuGris)
 * @version         $Id$
 *
 * @param $options
 *
 * @return array
 */
function b_xlanguage_select_show($options)
{
    $xoops = \Xoops::getInstance();
    $helper = \Xoops\Module\Helper::getHelper('xlanguage');
    $xlanguage = $xoops->registry()->get('XLANGUAGE');
    $lang_tag = $xoops->registry()->get('XLANGUAGE_LANG_TAG');
    $options[3] = $helper->getConfig('theme');
    $block = array();
    $helper->getHandlerLanguage()->loadConfig();
    if (!is_array($helper->getHandlerLanguage()->cached_config) || count($helper->getHandlerLanguage()->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($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];
    if ($options[0] === 'jquery') {
        $xoops = \Xoops::getInstance();
        $xoops->theme()->addBaseScriptAssets('@jqueryui');
    }
    $block['selected'] = $xlanguage['lang'];
    if ($options[0] === 'images' || $options[0] === 'text') {
        $query_string = htmlspecialchars(implode('&', $QUERY_STRING_new));
        $query_string .= empty($query_string) ? '' : '&amp;';
    } 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'] = $helper->getHandlerLanguage()->cached_config;
    return $block;
}
示例#5
0
 /**
  * @return mixed|string
  */
 public function renderlist()
 {
     $xoops = Xoops::getInstance();
     $xoops->tpl()->assign('theme', \Xoops\Module\Helper::getHelper('xlanguage')->getConfig('theme'));
     $xoops->tpl()->assign('languages', $this->getAllLanguage(false));
     return $xoops->tpl()->fetch('admin:xlanguage/xlanguage_admin_list.tpl');
 }
示例#6
0
 /**
  * Get Module Helper
  *
  * @param string $dirname dirname of module
  *
  * @return bool|Xoops\Module\Helper\HelperAbstract
  */
 public static function getModuleHelper($dirname)
 {
     return \Xoops\Module\Helper::getHelper($dirname);
 }
示例#7
0
 * 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       2010-2014 XOOPS Project (http://xoops.org)
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package         xlanguage
 * @since           2.6.0
 * @author          Laurent JEN (Aka DuGris)
 * @version         $Id$
 */
$xoops = \Xoops::getInstance();
$helper = \Xoops\Module\Helper::getHelper('xlanguage');
$xlanguage = array();
if (XoopsLoad::fileExists($hnd_file = \XoopsBaseConfig::get('root-path') . '/modules/xlanguage/include/vars.php')) {
    include_once $hnd_file;
}
if (XoopsLoad::fileExists($hnd_file = \XoopsBaseConfig::get('root-path') . '/modules/xlanguage/include/functions.php')) {
    include_once $hnd_file;
}
$cookie_var = $xoops->registry()->get('XLANGUAGE_LANG_TAG');
$xlanguage['action'] = false;
if (!empty($_GET[$xoops->registry()->get('XLANGUAGE_LANG_TAG')])) {
    $cookie_path = '/';
    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];