Example #1
0
 public function getValues($keys = null, $format = null, $maxDepth = null)
 {
     $ret = parent::getValues($keys, $format, $maxDepth);
     $ret['navigation'] = Xoops_Locale::translate('L_RELATED_NAVIGATION_OPTION' . $this->getVar('related_navigation'), 'page');
     $ret['related_links'] = Page::getInstance()->getLinkHandler()->getLinks($this->getVar('related_id'));
     return $ret;
 }
Example #2
0
 /**
  * @param array       $obj
  * @param XoopsModule $mod
  */
 public function getForm(&$obj, XoopsModule $mod)
 {
     $xoops = Xoops::getInstance();
     $helper = Userconfigs::getInstance();
     $config_handler = $helper->getHandlerConfig();
     /* @var $plugin UserconfigsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($mod->getVar('dirname'), 'userconfigs')) {
         parent::__construct('', 'pref_form', 'index.php', 'post', true);
         if ($mod->getVar('dirname') != 'system') {
             $xoops->loadLanguage('modinfo', $mod->getVar('dirname'));
             $xoops->loadLocale($mod->getVar('dirname'));
         }
         $configs = $plugin->configs();
         $configNames = array();
         foreach (array_keys($configs) as $i) {
             $configNames[$configs[$i]['name']] =& $configs[$i];
         }
         $configCats = $plugin->categories();
         if (!$configCats) {
             $configCats = array('default' => array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => ''));
         }
         if (!in_array('default', array_keys($configCats))) {
             $configCats['default'] = array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => '');
         }
         foreach (array_keys($configNames) as $name) {
             if (!isset($configNames[$name]['category'])) {
                 $configNames[$name]['category'] = 'default';
             }
         }
         $tabtray = new Xoops\Form\TabTray('', 'pref_tabtay', $xoops->getModuleConfig('jquery_theme', 'system'));
         $tabs = array();
         foreach ($configCats as $name => $info) {
             $tabs[$name] = new Xoops\Form\Tab($info['name'], 'pref_tab_' . $name);
             if (isset($info['description']) && $info['description'] != '') {
                 $tabs[$name]->addElement(new Xoops\Form\Label('', $info['description']));
             }
         }
         $count = count($obj);
         for ($i = 0; $i < $count; ++$i) {
             $title = Xoops_Locale::translate($obj[$i]->getVar('conf_title'), $mod->getVar('dirname'));
             $desc = $obj[$i]->getVar('conf_desc') != '' ? Xoops_Locale::translate($obj[$i]->getVar('conf_desc'), $mod->getVar('dirname')) : '';
             switch ($obj[$i]->getVar('conf_formtype')) {
                 case 'textarea':
                     $myts = MyTextSanitizer::getInstance();
                     if ($obj[$i]->getVar('conf_valuetype') == 'array') {
                         // this is exceptional.. only when value type is arrayneed a smarter way for this
                         $ele = $obj[$i]->getVar('conf_value') != '' ? new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars(implode('|', $obj[$i]->getConfValueForOutput())), 5, 5) : new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), '', 5, 5);
                     } else {
                         $ele = new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()), 5, 5);
                     }
                     break;
                 case 'select':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id')));
                     $opcount = count($options);
                     for ($j = 0; $j < $opcount; ++$j) {
                         $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname'));
                         $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname'));
                         $ele->addOption($optval, $optkey);
                     }
                     break;
                 case 'select_multi':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true);
                     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id')));
                     $opcount = count($options);
                     for ($j = 0; $j < $opcount; ++$j) {
                         $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname'));
                         $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname'));
                         $ele->addOption($optval, $optkey);
                     }
                     break;
                 case 'yesno':
                     $ele = new Xoops\Form\RadioYesNo($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'theme':
                 case 'theme_multi':
                     $ele = $obj[$i]->getVar('conf_formtype') != 'theme_multi' ? new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()) : new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true);
                     $dirlist = XoopsLists::getThemesList();
                     if (!empty($dirlist)) {
                         asort($dirlist);
                         $ele->addOptionArray($dirlist);
                     }
                     break;
                 case 'tplset':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $tplset_handler = $xoops->getHandlerTplSet();
                     $tplsetlist = $tplset_handler->getNameList();
                     asort($tplsetlist);
                     foreach ($tplsetlist as $key => $name) {
                         $ele->addOption($key, $name);
                     }
                     break;
                 case 'cpanel':
                     $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     /*
                                             $ele = new Xoops\Form\Select($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
                                             XoopsLoad::load("cpanel", "system");
                                             $list = XoopsSystemCpanel::getGuis();
                                             $ele->addOptionArray($list);  */
                     break;
                 case 'timezone':
                     $ele = new Xoops\Form\SelectTimeZone($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'language':
                     $ele = new Xoops\Form\SelectLanguage($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'locale':
                     $ele = new Xoops\Form\SelectLocale($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'startpage':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $module_handler = $xoops->getHandlerModule();
                     $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
                     $criteria->add(new Criteria('isactive', 1));
                     $moduleslist = $module_handler->getNameList($criteria, true);
                     $moduleslist['--'] = XoopsLocale::NONE;
                     $ele->addOptionArray($moduleslist);
                     break;
                 case 'group':
                     $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false);
                     break;
                 case 'group_multi':
                     $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true);
                     break;
                     // RMV-NOTIFY: added 'user' and 'user_multi'
                 // RMV-NOTIFY: added 'user' and 'user_multi'
                 case 'user':
                     $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false);
                     break;
                 case 'user_multi':
                     $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true);
                     break;
                 case 'module_cache':
                     $module_handler = $xoops->getHandlerModule();
                     $modules = $module_handler->getObjectsArray(new Criteria('hasmain', 1), true);
                     $currrent_val = $obj[$i]->getConfValueForOutput();
                     $cache_options = array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH);
                     if (count($modules) > 0) {
                         $ele = new Xoops\Form\ElementTray($title, '<br />');
                         foreach (array_keys($modules) as $mid) {
                             $c_val = isset($currrent_val[$mid]) ? (int) $currrent_val[$mid] : null;
                             $selform = new Xoops\Form\Select($modules[$mid]->getVar('name'), $obj[$i]->getVar('conf_name') . "[{$mid}]", $c_val);
                             $selform->addOptionArray($cache_options);
                             $ele->addElement($selform);
                             unset($selform);
                         }
                     } else {
                         $ele = new Xoops\Form\Label($title, SystemLocale::NO_MODULE_TO_CACHE);
                     }
                     break;
                 case 'site_cache':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $ele->addOptionArray(array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH));
                     break;
                 case 'password':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Password($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'color':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\ColorPicker($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'hidden':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'textbox':
                 default:
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Text($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
             }
             $hidden = new Xoops\Form\Hidden('conf_ids[]', $obj[$i]->getVar('conf_id'));
             if (isset($ele)) {
                 $ele->setDescription($desc);
                 if ($obj[$i]->getVar('conf_formtype') != 'hidden') {
                     $name = 'default';
                     if (isset($configNames[$obj[$i]->getVar('conf_name')]['category'])) {
                         $name = $configNames[$obj[$i]->getVar('conf_name')]['category'];
                     }
                     $tabs[$name]->addElement($ele);
                 } else {
                     $this->addElement($ele);
                 }
                 $this->addElement($hidden);
                 unset($ele);
                 unset($hidden);
             }
         }
         foreach (array_keys($tabs) as $name) {
             if ($tabs[$name]->getElements()) {
                 $tabtray->addElement($tabs[$name]);
             }
         }
         $this->addElement($tabtray);
         $this->addElement(new Xoops\Form\Hidden('op', 'save'));
         $this->addElement(new Xoops\Form\Hidden('mid', $mod->getVar('mid')));
         $this->addElement(new Xoops\Form\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit'));
     }
 }
Example #3
0
/**
 * @param XoopsConfigItem $config
 *
 * @return Xoops\Form\ThemeForm[]
 */
function createThemeform(XoopsConfigItem $config)
{
    $title = $config->getVar('conf_desc') == '' ? Xoops_Locale::translate($config->getVar('conf_title'), 'system') : Xoops_Locale::translate($config->getVar('conf_title'), 'system') . '<br /><br /><span>' . Xoops_Locale::translate($config->getVar('conf_desc'), 'system') . '</span>';
    $form_theme_set = new Xoops\Form\Select('', $config->getVar('conf_name'), $config->getConfValueForOutput(), 1, false);
    $dirlist = XoopsLists::getThemesList();
    if (!empty($dirlist)) {
        asort($dirlist);
        $form_theme_set->addOptionArray($dirlist);
    }
    $label_content = "";
    // read ini file for each theme
    foreach ($dirlist as $theme) {
        // set default value
        $theme_ini = array('Name' => $theme, 'Description' => '', 'Version' => '', 'Format' => '', 'Author' => '', 'Demo' => '', 'Url' => '', 'Download' => '', 'W3C' => '', 'Licence' => '', 'thumbnail' => 'screenshot.gif', 'screenshot' => 'screenshot.png');
        if ($theme == $config->getConfValueForOutput()) {
            $label_content .= "<div id='{$theme}' rel='theme' style='display:block;'>";
        } else {
            $label_content .= "<div id='{$theme}' rel='theme' style='display:none;'>";
        }
        if (file_exists(XOOPS_ROOT_PATH . "/themes/{$theme}/theme.ini")) {
            $theme_ini = parse_ini_file(XOOPS_ROOT_PATH . "/themes/{$theme}/theme.ini");
            if ($theme_ini['screenshot'] == '') {
                $theme_ini['screenshot'] = 'screenshot.png';
                $theme_ini['thumbnail'] = 'thumbnail.png';
            }
        }
        if ($theme_ini['screenshot'] != '' && file_exists(XOOPS_ROOT_PATH . "/themes/{$theme}/" . $theme_ini['screenshot'])) {
            $label_content .= "<img src='" . XOOPS_URL . "/themes/" . $theme . "/" . $theme_ini['screenshot'] . "' alt='Screenshot' />";
        } elseif ($theme_ini['thumbnail'] != '' && file_exists(XOOPS_ROOT_PATH . "/themes/{$theme}/" . $theme_ini['thumbnail'])) {
            $label_content .= "<img src='" . XOOPS_URL . "/themes/" . $theme . "/" . $theme_ini['thumbnail'] . "' alt='{$theme}' />";
        } else {
            $label_content .= THEME_NO_SCREENSHOT;
        }
        $label_content .= "</div>";
    }
    // read ini file for each theme
    $form_theme_set->setExtra("onchange='showThemeSelected(this)'");
    $form = new Xoops\Form\ThemeForm($title, 'themes', 'index.php', 'post');
    $form->addElement($form_theme_set);
    $form->addElement(new Xoops\Form\Label('', "<div id='screenshot'>" . $label_content . "</div>"));
    $form->addElement(new Xoops\Form\Hidden('conf_ids[]', $config->getVar('conf_id')));
    return array($form);
}
Example #4
0
$xoops->loadLocale('system');
echo XoopsLocale::A_DELETE;
echo '</br>';
echo XoopsLocale::A_POST;
echo '</br>';
echo SystemLocale::RECOMMEND_US;
echo '</br>';
//Translate using wrapper, no auto completion but offers support
echo Xoops_Locale::translate('A_EDIT');
echo '</br>';
//get from XoopsLocale by default
echo Xoops_Locale::translate('ADMINISTRATION_MENU');
echo '</br>';
//Not in XoopsLocale, the key is echoed
echo Xoops_Locale::translate('ADMINISTRATION_MENU', 'system');
echo '</br>';
//Displays translation
echo Xoops_Locale::translate('_CHARSET');
echo '</br>';
//Translations not present on classes are loaded from defines()
//or
echo $xoops->translate('ACTIVE');
echo '</br>';
//Example of template
$tpl = new XoopsTpl();
$tpl->display(__DIR__ . '/templates/language.tpl');
Xoops_Utils::dumpFile(__FILE__);
echo "Template file:";
echo '</br>';
Xoops_Utils::dumpFile(__DIR__ . '/templates/language.tpl');
$xoops->footer();
/**
 * @copyright       XOOPS Project (http://xoops.org)
 * @license     GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @author          trabis <*****@*****.**>
 * @version         $Id$
 */
function smarty_function_translateTheme($params, &$smarty)
{
    $key = isset($params['key']) ? $params['key'] : '';
    $dirname = isset($params['dirname']) ? $params['dirname'] : '';
    return Xoops_Locale::translateTheme($key, $dirname);
}
Example #6
0
 /**
  * Get Mailer
  *
  * @return XoopsMailer|XoopsMailerLocale
  */
 public function getMailer()
 {
     static $mailer;
     if (is_object($mailer)) {
         return $mailer;
     }
     Xoops_Locale::loadMailerLocale();
     if (class_exists('XoopsMailerLocale')) {
         $mailer = new XoopsMailerLocale();
     } else {
         $mailer = new XoopsMailer();
     }
     return $mailer;
 }
Example #7
0
<?php

if (defined('XOOPS_TU_ROOT_PATH')) {
    return;
}
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
    die("XOOP check: PHP version require 5.3.0 or more");
}
// needed for phpunit => initializing $_SERVER values
if (empty($_SERVER["HTTP_HOST"])) {
    define('IS_PHPUNIT', true);
}
if (defined('IS_PHPUNIT')) {
    require_once dirname(__FILE__) . '/common_phpunit.php';
} else {
    // Avoid check proxy to define constant XOOPS_DB_PROXY
    // because it implies a readonly database connection
    $_SERVER['REQUEST_METHOD'] = 'POST';
    define('XOOPS_XMLRPC', 0);
}
define('XOOPS_TU_ROOT_PATH', realpath(dirname(__FILE__) . '/../../htdocs'));
//temporary patch, we still need mainfile until we have a config file
$xoopsOption["nocommon"] = true;
// don't include common.php file
require_once XOOPS_TU_ROOT_PATH . '/mainfile.php';
//require_once(XOOPS_TU_ROOT_PATH . '/class/XoopsBaseConfig.php');
\XoopsBaseConfig::bootstrapTransition();
require_once XOOPS_TU_ROOT_PATH . '/xoops_lib/Xoops/Locale.php';
\Xoops_Locale::loadLocale();
Example #8
0
 /**
  * installconfigs
  *
  * @param XoopsModule $module module being installed
  *
  * @return void
  */
 public function installConfigs(XoopsModule $module)
 {
     $xoops = Xoops::getInstance();
     // now reinsert them with the new settings
     $configs = $module->getInfo('config');
     if (!is_array($configs)) {
         $configs = array();
     }
     XoopsPreload::getInstance()->triggerEvent('onModuleUpdateConfigs', array($module, &$configs));
     if (is_array($configs) && count($configs) > 0) {
         $this->trace[] = SystemLocale::MANAGING_PREFERENCES;
         $config_handler = $xoops->getHandlerConfig();
         $order = 0;
         foreach ($configs as $config) {
             // only insert ones that have been deleted previously with success
             if (!in_array($config['name'], $this->config_delng)) {
                 $confobj = $config_handler->createConfig();
                 $confobj->setVar('conf_modid', $module->getVar('mid'));
                 $confobj->setVar('conf_catid', 0);
                 $confobj->setVar('conf_name', $config['name']);
                 $confobj->setVar('conf_title', $config['title']);
                 $confobj->setVar('conf_desc', $config['description']);
                 $confobj->setVar('conf_formtype', $config['formtype']);
                 $confobj->setVar('conf_valuetype', $config['valuetype']);
                 if (isset($this->config_old[$config['name']]['value']) && $this->config_old[$config['name']]['formtype'] == $config['formtype'] && $this->config_old[$config['name']]['valuetype'] == $config['valuetype']) {
                     // preserver the old value if any
                     // form type and value type must be the same
                     $confobj->setVar('conf_value', $this->config_old[$config['name']]['value']);
                 } else {
                     $confobj->setConfValueForInput($config['default']);
                     //$confobj->setVar('conf_value', $config['default']);
                 }
                 $confobj->setVar('conf_order', $order);
                 $confop_msgs = '';
                 if (isset($config['options']) && is_array($config['options'])) {
                     foreach ($config['options'] as $key => $value) {
                         $confop = $config_handler->createConfigOption();
                         $confop->setVar('confop_name', $key);
                         $confop->setVar('confop_value', $value);
                         $confobj->setConfOptions($confop);
                         $confop_msgs .= '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
                         $confop_msgs .= SystemLocale::S_CONFIG_OPTION_ADDED;
                         $confop_msgs .= '&nbsp;';
                         $confop_msgs .= XoopsLocale::C_NAME;
                         $confop_msgs .= ' <strong>' . Xoops_Locale::translate($key, $module->getVar('dirname')) . '</strong> ';
                         $confop_msgs .= XoopsLocale::C_VALUE . ' <strong>' . $value . '</strong> ';
                         unset($confop);
                     }
                 }
                 ++$order;
                 if (false != $config_handler->insertConfig($confobj)) {
                     $this->trace[]['sub'] = sprintf(SystemLocale::SF_CONFIG_ADDED, "<strong>" . $config['name'] . "</strong>") . $confop_msgs;
                 } else {
                     $this->trace[]['sub'] = '<span class="red">' . sprintf(SystemLocale::EF_CONFIG_NOT_ADDED, "<strong>" . $config['name'] . "</strong>") . '</span>';
                 }
                 unset($confobj);
             }
         }
         unset($configs);
     }
 }
Example #9
0
 /**
  * @param PagePage_content|XoopsObject $obj
  */
 public function __construct(PagePage_content &$obj)
 {
     $helper = Page::getInstance();
     $xoops = $helper->xoops();
     $xoops->theme()->addStylesheet('modules/page/css/styles.css');
     $title = $obj->isNew() ? PageLocale::A_ADD_CONTENT : PageLocale::A_EDIT_CONTENT;
     parent::__construct($title, 'form', 'content.php', 'post', true, 'raw');
     $tabtray = new Xoops\Form\TabTray('', 'uniqueid');
     /**
      * Main
      */
     $tab1 = new Xoops\Form\Tab(PageLocale::TAB_MAIN, 'main');
     //Author
     //        if ($helper->isUserAdmin()) {
     $content_author = $obj->isNew() ? $xoops->user->getVar('uid') : $obj->getVar('content_author');
     $tab1->addElement(new Xoops\Form\SelectUser(XoopsLocale::AUTHOR, 'content_author', true, $content_author, 1, false), true);
     //        }
     //date
     $tab1->addElement(new Xoops\Form\DateTime(XoopsLocale::DATE, 'content_create', 2, $obj->getVar('content_create'), false));
     //title
     $tab1->addElement(new Xoops\Form\Text(XoopsLocale::TITLE, 'content_title', 12, 255, $obj->getVar('content_title'), ''), true);
     // editor
     $editor_configs = array();
     $editor_configs['editor'] = $helper->getConfig('page_editor');
     $editor_configs['rows'] = 12;
     $editor_configs['cols'] = 12;
     //short text
     $editor_configs['name'] = 'content_shorttext';
     $editor_configs['value'] = $obj->getVar('content_shorttext', 'e');
     $tab1->addElement(new Xoops\Form\Editor(XoopsLocale::SHORT_TEXT, 'content_shorttext', $editor_configs), true);
     //text
     $editor_configs['name'] = 'content_text';
     $editor_configs['value'] = $obj->getVar('content_text', 'e');
     $text = new Xoops\Form\Editor(XoopsLocale::TEXT, 'content_text', $editor_configs);
     $text->setDescription(PageLocale::CONTENT_TEXT_DESC);
     $tab1->addElement($text, false);
     //Weight
     $weight = new Xoops\Form\Text(XoopsLocale::WEIGHT, 'content_weight', 1, 5, $obj->getVar('content_weight'), '');
     $weight->setPattern('^\\d+$', PageLocale::E_WEIGHT);
     $tab1->addElement($weight, true);
     $tabtray->addElement($tab1);
     /**
      * Metas
      */
     $tab2 = new Xoops\Form\Tab(PageLocale::TAB_METAS, 'metas');
     //content_mkeyword
     $tab2->addElement(new Xoops\Form\TextArea(PageLocale::CONTENT_META_KEYWORDS, 'content_mkeyword', $obj->getVar('content_mkeyword'), 1, 11, PageLocale::CONTENT_META_KEYWORDS_DSC));
     //content_mdescription
     $tab2->addElement(new Xoops\Form\TextArea(PageLocale::CONTENT_META_DESCRIPTION, 'content_mdescription', $obj->getVar('content_mdescription'), 5, 11));
     $tabtray->addElement($tab2);
     /**
      * Options
      */
     $tab3 = new Xoops\Form\Tab(PageLocale::TAB_OPTIONS, 'options');
     //Options
     $content_option = $obj->getOptions();
     $checkbox = new Xoops\Form\Checkbox(XoopsLocale::OPTIONS, 'content_option', $content_option, false);
     $checkbox->setDescription(PageLocale::CONTENT_OPTIONS_DSC);
     foreach ($obj->options as $option) {
         $checkbox->addOption($option, Xoops_Locale::translate('L_CONTENT_DO' . strtoupper($option), 'page'));
     }
     $tab3->addElement($checkbox);
     //maindisplay
     $tab3->addElement(new Xoops\Form\RadioYesNo(PageLocale::Q_ON_MAIN_PAGE, 'content_maindisplay', $obj->getVar('content_maindisplay')));
     //active
     $tab3->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::ACTIVE, 'content_status', $obj->getVar('content_status')));
     $tabtray->addElement($tab3);
     /**
      * Permissions
      */
     if ($helper->isUserAdmin()) {
         $tab4 = new Xoops\Form\Tab(PageLocale::TAB_PERMISSIONS, 'permissions');
         //permissions
         $group_list = $xoops->getHandlerMember()->getGroupList();
         $full_list = array_keys($group_list);
         if (!$obj->isNew()) {
             $module_id = $helper->getModule()->getVar('mid', 'n');
             $groups_ids_view = $helper->getGrouppermHandler()->getGroupIds('page_view_item', $obj->getVar('content_id'), $module_id);
             $groups_ids_view = array_values($groups_ids_view);
             $groups_can_view_checkbox = new Xoops\Form\Checkbox(PageLocale::CONTENT_SELECT_GROUPS, 'groups_view_item[]', $groups_ids_view, false);
         } else {
             $groups_can_view_checkbox = new Xoops\Form\Checkbox(PageLocale::CONTENT_SELECT_GROUPS, 'groups_view_item[]', $full_list, false);
         }
         $groups_can_view_checkbox->addOptionArray($group_list);
         $tab4->addElement($groups_can_view_checkbox);
         $tabtray->addElement($tab4);
     }
     $this->addElement($tabtray);
     $this->addElement(new Xoops\Form\Hidden('content_id', $obj->getVar('content_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);
     $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);
     $this->addElement($button_tray);
 }
Example #10
0
 /**
  * getUserLocales()
  * Returns the user locales
  * Normally it returns an array like this:
  * 1. Forced language
  * 2. Language in $_GET['lang']
  * 3. Language in $_SESSION['lang']
  * 4. HTTP_ACCEPT_LANGUAGE
  * 5. Fallback language
  * Note: duplicate values are deleted.
  *
  * @return array with the user locales sorted by priority. Highest is best.
  */
 public static function getUserLocales()
 {
     if (empty(self::$_userLocales)) {
         // reset user_lang array
         $userLocales = array();
         // Highest priority: forced language
         //if ($this->forcedLang != NULL) {
         //    $userLocales[] = $this->forcedLang;
         //}
         // 2nd highest priority: GET parameter 'lang'
         if (isset($_GET['lang']) && is_string($_GET['lang'])) {
             $userLocales[] = $_GET['lang'];
         }
         // 3rd highest priority: SESSION parameter 'lang'
         if (isset($_SESSION['lang']) && is_string($_SESSION['lang'])) {
             $userLocales[] = $_SESSION['lang'];
         }
         // 4th highest priority: HTTP_ACCEPT_LANGUAGE
         if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
             foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $part) {
                 if (preg_match("/(.*);q=([0-1]{0,1}\\.\\d{0,4})/i", $part, $matches)) {
                     $userLocales[] = $matches[1];
                 } else {
                     $userLocales[] = $part;
                 }
             }
         }
         $userLocales[] = Xoops::getInstance()->getConfig('locale');
         // Lowest priority: fallback
         $userLocales[] = static::$_defaultLocale;
         $availableLocales = XoopsLists::getLocaleList();
         // remove not allowed characters
         foreach ($userLocales as $key => $value) {
             $value = preg_replace('/[^a-zA-Z0-9_\\-]/', '', $value);
             // only allow a-z, A-Z and 0-9
             if ($value && in_array($value, $availableLocales)) {
                 self::$_userLocales[$key] = str_replace('-', '_', $value);
             }
         }
         // remove duplicate elements
         self::$_userLocales = array_unique(self::$_userLocales);
     }
     return self::$_userLocales;
 }
Example #11
0
 /**
  * Load localization information
  * Folder structure for localization:
  * themes/themefolder/english
  *    - main.php - language definitions
  *    - style.css - localization stylesheet
  *    - script.js - localization script
  *
  * @param string $type language domain (unused?)
  *
  * @return array list of 2 arrays, one
  */
 public function getLocalizationAssets($type = "main")
 {
     $cssAssets = array();
     $jsAssets = array();
     $xoops = Xoops::getInstance();
     Xoops_Locale::loadThemeLocale($this);
     $language = XoopsLocale::getLocale();
     // Load global localization stylesheet if available
     if (XoopsLoad::fileExists($xoops->path('locale/' . $language . '/style.css'))) {
         $cssAssets[] = $xoops->path('locale/' . $language . '/style.css');
     }
     //$this->addLanguage($type);
     // Load theme localization stylesheet and scripts if available
     if (XoopsLoad::fileExists($this->path . '/locale/' . $language . '/script.js')) {
         $jsAssets[] = $this->url . '/locale/' . $language . '/script.js';
     }
     if (XoopsLoad::fileExists($this->path . '/locale/' . $language . '/style.css')) {
         $cssAssets[] = $this->path . '/locale/' . $language . '/style.css';
     }
     return array($cssAssets, $jsAssets);
 }