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; }
/** * Get a list of localized timezone names * * @return array */ public static function getList() { $xoops = \Xoops::getInstance(); $locale = \Xoops\Locale::getCurrent(); $key = ['system', 'lists', 'timezone', $locale]; //$xoops->cache()->delete($key); $timeZones = $xoops->cache()->cacheRead($key, function () { $timeZones = array(); $territories = Territory::getContinentsAndCountries(); $maxLen = 0; $utcDtz = new \DateTimeZone('UTC'); foreach ($territories as $byContinent) { $continent = $byContinent['name']; foreach ($byContinent['children'] as $cCode => $cName) { $allZones = $utcDtz->listIdentifiers(\DateTimeZone::PER_COUNTRY, $cCode); foreach ($allZones as $zone) { $maxLen = max(strlen($zone), $maxLen); $name = Calendar::getTimezoneExemplarCity($zone); if (!isset($timeZones[$zone]) && !empty($name)) { $timeZones[$zone] = $continent . '/' . $name; } } } } \XoopsLocale::asort($timeZones); $default = array('UTC' => Calendar::getTimezoneNameNoLocationSpecific(new \DateTimeZone('GMT'))); $timeZones = array_merge($default, $timeZones); return $timeZones; }); return $timeZones; }
/** * gets list of locales * * @param boolean $showInCodeLanguage true to show a code's name in the language the code represents * * @return array */ public static function getList($showInCodeLanguage = false) { $locales = Data::getAvailableLocales(); $languages = array(); foreach ($locales as $locale) { $key = \Xoops\Locale::normalizeLocale($locale); $languages[$key] = Language::getName($locale, $showInCodeLanguage ? $locale : null); } \XoopsLocale::asort($languages); return $languages; }
/** * @dataProvider formatTimestampElapsedProvider */ public function test_formatTimestampElapsed($locale, $timezone, $format, $op, $interval, $expected) { $instance = $this->myClass; \Xoops\Locale::setTimeZone(new \DateTimeZone($timezone)); \Xoops\Locale::setCurrent($locale); $dateTime = new \DateTime(); $interval = new \DateInterval($interval); if ($op === 'add') { $dateTime->add($interval); } elseif ($op === 'sub') { $dateTime->sub($interval); } $value = $instance::formatTimestamp($dateTime, $format); $this->assertSame($expected, $value); }
/** * 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); }
/** * @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_translate($params, &$smarty) { $key = isset($params['key']) ? $params['key'] : ''; $dirname = isset($params['dirname']) ? $params['dirname'] : 'xoops'; return \Xoops\Locale::translate($key, $dirname); }
/** * 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; }
/** * @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); }
/** * @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', $obj->getVar('content_create'))); //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 */ $buttonTray = new Xoops\Form\ElementTray('', ''); $buttonTray->addElement(new Xoops\Form\Hidden('op', 'save')); $buttonSubmit = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'); $buttonSubmit->setClass('btn btn-success'); $buttonTray->addElement($buttonSubmit); $buttonReset = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset'); $buttonReset->setClass('btn btn-warning'); $buttonTray->addElement($buttonReset); $buttonCancel = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button'); $buttonCancel->setExtra("onclick='javascript:history.go(-1);'"); $buttonCancel->setClass('btn btn-danger'); $buttonTray->addElement($buttonCancel); $this->addElement($buttonTray); }
/** * @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'); $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 = \Xoops\Core\Text\Sanitizer::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 = \Xoops\Core\Text\Sanitizer::getInstance(); $ele = new Xoops\Form\Password($title, $obj[$i]->getVar('conf_name'), 32, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; case 'color': $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $ele = new Xoops\Form\ColorPicker($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; case 'hidden': $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; case 'textbox': default: $myts = \Xoops\Core\Text\Sanitizer::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')); } }
/** * Perform any localization required for date picker used in Form\DateSelect * * @return void */ public static function localizeDatePicker() { $delimiter = '-'; $locale = Locale::normalizeLocale(Locale::getCurrent(), $delimiter, false); if ('zh_Hant' === Locale::getCurrent()) { $locale = 'zh-TW'; } if ($locale === 'zh') { $locale = 'zh-CN'; } list($language) = explode($delimiter, $locale); $xoops = \Xoops::getInstance(); $locales = array($locale, $language); foreach ($locales as $name) { $i18nScript = 'media/jquery/ui/i18n/datepicker-' . $name . '.js'; if (file_exists($xoops->path($i18nScript))) { $xoops->theme()->addBaseScriptAssets($i18nScript); return; } } }
/** * @return string */ public static function getTimezone() { return \Xoops\Locale::getTimeZone()->getName(); }
/** * 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 /> '; $confop_msgs .= SystemLocale::S_CONFIG_OPTION_ADDED; $confop_msgs .= ' '; $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); } }
/** * @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_translate($params, &$smarty) { $key = isset($params['key']) ? $params['key'] : ''; $dirname = isset($params['dirname']) ? $params['dirname'] : 'xoops'; return \Xoops\Core\Text\Sanitizer::getInstance()->escapeForJavascript(\Xoops\Locale::translate($key, $dirname)); }
/** * @covers Xoops\Core\Request::getDateTime */ public function testGetDateTime() { $varname = 'datetimetest'; \Xoops\Locale::setTimeZone(new \DateTimeZone('UTC')); \Xoops\Locale::setCurrent('en_US'); $exampleDate = '12/14/2015'; $exampleTime = '12:10 AM'; $_REQUEST[$varname] = $exampleDate; $actual = Request::getDateTime($varname); $this->assertInstanceOf('\\DateTime', $actual); $this->assertEquals($exampleDate, $actual->format('m/d/Y')); $_REQUEST[$varname] = ['date' => $exampleDate, 'time' => $exampleTime]; $actual = Request::getDateTime($varname); $this->assertInstanceOf('\\DateTime', $actual); $this->assertEquals($exampleDate, $actual->format('m/d/Y')); $this->assertEquals($exampleTime, $actual->format('h:i A')); }
<?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();