本文整理汇总了PHP中XoopsLocale类的典型用法代码示例。如果您正苦于以下问题:PHP XoopsLocale类的具体用法?PHP XoopsLocale怎么用?PHP XoopsLocale使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XoopsLocale类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* render
*
* @return string rendered form element
*/
public function render()
{
static $included = false;
$xoops = \Xoops::getInstance();
$ele_value = (string) $this->getValue(false);
$display_value = $ele_value;
if (0 < (int) $ele_value) {
$display_value = date(\XoopsLocale::getFormatShortDate(), $ele_value);
}
if ($this->getSize() > $this->getMaxcols()) {
$maxcols = $this->getMaxcols();
} else {
$maxcols = $this->getSize();
}
$this->addAttribute('class', 'span' . $maxcols);
$dlist = $this->isDatalist();
if (!empty($dlist)) {
$this->addAttribute('list', 'list_' . $this->getName());
}
$attributes = $this->renderAttributeString();
$xoops->theme()->addBaseStylesheetAssets('@jqueryuicss');
$xoops->theme()->addBaseScriptAssets('@jqueryui');
// TODO - select and apply script by locale, example:
// $i18nScript = 'media/jquery/ui/i18n/datepicker-es.js';
// $xoops->theme()->addBaseScriptAssets($i18nScript);
$xoops->theme()->addScript('', '', ' $(function() { $( "#' . $this->getAttribute('id') . '" ).datepicker({' . 'showOn: "button", buttonImageOnly: false, ' . 'buttonImage: "' . $xoops->url('media/xoops/images/icons/calendar.png') . '", ' . 'buttonImageOnly: false, buttonText: "' . \XoopsLocale::A_SELECT . '" }); }); ');
return '<input ' . $attributes . 'value="' . $display_value . '" ' . $this->getExtra() . ' >';
}
示例2: getList
/**
* 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;
}
示例3: __construct
/**
* Constructor
*
* @return XoopsMailerLocal
*/
public function __construct()
{
parent::__construct();
// It is supposed no need to change the charset
$this->charSet = strtolower(XoopsLocale::getCharset());
// You MUST specify the language code value so that the file exists: XOOPS_ROOT_PAT/class/mail/phpmailer/language/lang-["your-language-code"].php
$this->multimailer->SetLanguage("en");
}
示例4: publisher_search
/**
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package Publisher
* @since 1.0
* @author trabis <lusopoemas@gmail.com>
* @version $Id$
*/
function publisher_search($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = "", $extra = "")
{
$publisher = Publisher::getInstance();
$ret = array();
if ($queryarray == '' || count($queryarray) == 0) {
$hightlight_key = '';
} else {
$keywords = implode('+', $queryarray);
$hightlight_key = "&keywords=" . $keywords;
}
$itemsObjs = $publisher->getItemHandler()->getItemsFromSearch($queryarray, $andor, $limit, $offset, $userid, $categories, $sortby, $searchin, $extra);
$withCategoryPath = $publisher->getConfig('search_cat_path');
$usersIds = array();
/* @var $obj PublisherItem */
foreach ($itemsObjs as $obj) {
$item['image'] = "images/item_icon.gif";
$item['link'] = $obj->getItemUrl();
$item['link'] .= !empty($hightlight_key) && strpos($item['link'], '.php?') === false ? "?" . ltrim($hightlight_key, '&') : $hightlight_key;
if ($withCategoryPath) {
$item['title'] = $obj->getCategoryPath(false) . " > " . $obj->title();
} else {
$item['title'] = $obj->title();
}
$item['time'] = $obj->getVar('datesub');
//must go has unix timestamp
$item['uid'] = $obj->getVar('uid');
//"Fulltext search/highlight
$text = $obj->body();
$sanitized_text = "";
$text_i = strtolower($text);
$queryarray = is_array($queryarray) ? $queryarray : array($queryarray);
//@todo look into xoopslocal
foreach ($queryarray as $query) {
$pos = strpos($text_i, strtolower($query));
//xoops_local("strpos", $text_i, strtolower($query));
$start = max($pos - 100, 0);
$length = strlen($query) + 200;
//xoops_local("strlen", $query) + 200;
$context = $obj->highlight(XoopsLocale::substr($text, $start, $length, " [...]"), $query);
$sanitized_text .= "<p>[...] " . $context . "</p>";
}
//End of highlight
$item['text'] = $sanitized_text;
$item['author'] = $obj->getVar('author_alias');
$item['datesub'] = $obj->datesub($publisher->getConfig('format_date'));
$usersIds[$obj->getVar('uid')] = $obj->getVar('uid');
$ret[] = $item;
unset($item, $sanitized_text);
}
$usersNames = XoopsUserUtility::getUnameFromIds($usersIds, $publisher->getConfig('format_realname'), true);
foreach ($ret as $key => $item) {
if ($item["author"] == '') {
$ret[$key]["author"] = @$usersNames[$item["uid"]];
}
}
unset($usersNames, $usersIds);
return $ret;
}
示例5: getExtensionList
/**
* Return all extensions
*
* @return array
*/
public function getExtensionList()
{
// Get main instance
$xoops = Xoops::getInstance();
$module_handler = $xoops->getHandlerModule();
$moduleperm_handler = $xoops->getHandlerGroupperm();
$ret = array();
$i = 0;
foreach ($this->modulesList as $file) {
$file = trim($file);
if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $file . '/xoops_version.php')) {
clearstatcache();
/* @var $module XoopsModule */
$module = $module_handler->create();
$module->loadInfoAsVar($file);
if ($module->getInfo('extension')) {
if (in_array($file, $this->modulesDirnames)) {
$module->setInfo('install', true);
$extension = $module_handler->getByDirname($module->getInfo('dirname'));
$module->setInfo('mid', $extension->getVar('mid'));
$module->setInfo('update', XoopsLocale::formatTimestamp($extension->getVar('last_update'), 's'));
$module->setInfo('hasconfig', $module->getVar('hasconfig'));
if (round($module->getInfo('version'), 2) != $extension->getVar('version')) {
$module->setInfo('warning_update', true);
}
$groups = array();
if (is_object($xoops->user)) {
$groups = $xoops->user->getGroups();
}
$sadmin = $moduleperm_handler->checkRight('module_admin', $module->getInfo('mid'), $groups);
if ($sadmin && ($module->getVar('hasnotification') || is_array($module->getInfo('config')) || is_array($module->getInfo('comments')))) {
$module->setInfo('link_pref', \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $module->getInfo('mid'));
}
} else {
$module->setInfo('install', false);
}
$module->setInfo('version', round($module->getInfo('version'), 2));
if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_small.png')) {
$module->setInfo('logo_small', \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_small.png');
} else {
$module->setInfo('logo_small', \XoopsBaseConfig::get('url') . '/media/xoops/images/icons/16/default.png');
}
if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_large.png')) {
$module->setInfo('logo_large', \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_large.png');
} else {
$module->setInfo('logo_large', \XoopsBaseConfig::get('url') . '/media/xoops/images/icons/32/default.png');
}
$module->setInfo('link_admin', \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/' . $module->getInfo('adminindex'));
$module->setInfo('options', $module->getAdminMenu());
$ret[] = $module;
unset($module);
++$i;
}
}
}
return $ret;
}
示例6: decode
/**
* @return string
*/
public static function decode($url, $width, $height)
{
$config = parent::loadConfig(__DIR__);
if (empty($url) || empty($config['link'])) {
return $url;
}
$charset = !empty($config['charset']) ? $config['charset'] : "UTF-8";
$ret = "<a href='" . sprintf($config['link'], urlencode(XoopsLocale::convert_encoding($url, $charset))) . "' rel='external' title=''>{$text}</a>";
return $ret;
}
示例7: loadLanguage
/**
* @param string $name
*/
public function loadLanguage($name)
{
$helper = Menus::getInstance();
$language = XoopsLocale::getLegacyLanguage();
$path = $helper->path("decorators/{$name}/language");
if (!($ret = XoopsLoad::loadFile("{$path}/{$language}/decorator.php"))) {
$ret = XoopsLoad::loadFile("{$path}/english/decorator.php");
}
return $ret;
}
示例8: getList
/**
* 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;
}
示例9: getValues
public function getValues($keys = null, $format = null, $maxDepth = null)
{
$page = Page::getInstance();
$ret = parent::getValues($keys, $format, $maxDepth);
$ret['rating'] = number_format($this->getVar('content_rating'), 1);
// these next two lines are rather silly
$ret['content_authorid'] = $this->getVar('content_author');
$ret['content_author'] = XoopsUser::getUnameFromId($this->getVar('content_author'), true);
$ret['content_date'] = XoopsLocale::formatTimestamp($this->getVar('content_create'), $page->getConfig('page_dateformat'));
$ret['content_time'] = XoopsLocale::formatTimestamp($this->getVar('content_create'), $page->getConfig('page_timeformat'));
$ret['content_rating'] = number_format($this->getVar('content_rating'), 2);
return $ret;
}
示例10: execute
function execute()
{
$xoops = Xoops::getInstance();
// use HTMLPurifier inside Protector
//require_once $xoops->path('lib/HTMLPurifier/HTMLPurifier.auto.php');
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache', 'SerializerPath', \XoopsBaseConfig::get('lib-path'));
$config->set('Core', 'Encoding', XoopsLocale::getCharset());
//$config->set('HTML', 'Doctype', 'HTML 4.01 Transitional');
$this->purifier = new HTMLPurifier($config);
$this->method = 'purify';
$_POST = $this->purify_recursive($_POST);
}
示例11: getList
/**
* gets list of image file names in a directory
*
* @param string $path filesystem path
* @param string $prefix prefix added to file names
*
* @return array
*/
public static function getList($path = null, $prefix = '')
{
$fileList = array();
if (is_dir($path) && ($handle = opendir($path))) {
while (false !== ($file = readdir($handle))) {
if (preg_match('/\\.(gif|jpg|jpeg|png|swf)$/i', $file)) {
$file = $prefix . $file;
$fileList[$file] = $file;
}
}
closedir($handle);
\XoopsLocale::asort($fileList);
reset($fileList);
}
return $fileList;
}
示例12: __construct
public function __construct()
{
parent::__construct();
// SMARTY_PLUGINS_DIR is initialized into parent
$xoops = Xoops::getInstance();
$xoops->preload()->triggerEvent('core.template.construct.start', array($this));
$this->left_delimiter = '<{';
$this->right_delimiter = '}>';
$this->setTemplateDir(\XoopsBaseConfig::get('themes-path'));
$this->setCacheDir(\XoopsBaseConfig::get('smarty-cache'));
$this->setCompileDir(\XoopsBaseConfig::get('smarty-compile'));
$this->compile_check = $xoops->getConfig('theme_fromfile') == 1;
$this->setPluginsDir(\XoopsBaseConfig::get('smarty-xoops-plugins'));
$this->addPluginsDir(SMARTY_PLUGINS_DIR);
$this->setCompileId();
$this->assign(array('xoops_url' => \XoopsBaseConfig::get('url'), 'xoops_rootpath' => \XoopsBaseConfig::get('root-path'), 'xoops_langcode' => XoopsLocale::getLangCode(), 'xoops_charset' => XoopsLocale::getCharset(), 'xoops_version' => \Xoops::VERSION, 'xoops_upload_url' => \XoopsBaseConfig::get('uploads-url')));
}
示例13: test__construct
public function test__construct()
{
$xoops = \Xoops::getInstance();
$this->assertSame('{', $this->object->left_delimiter);
$this->assertSame('}', $this->object->right_delimiter);
$this->assertTrue(in_array(\XoopsBaseConfig::get('themes-path') . DIRECTORY_SEPARATOR, $this->object->getTemplateDir()));
$this->assertSame(\XoopsBaseConfig::get('var-path') . '/caches/smarty_cache' . DIRECTORY_SEPARATOR, $this->object->getCacheDir());
$this->assertSame(\XoopsBaseConfig::get('var-path') . '/caches/smarty_compile' . DIRECTORY_SEPARATOR, $this->object->getCompileDir());
$this->assertSame($xoops->getConfig('theme_fromfile') == 1, $this->object->compile_check);
$this->assertSame(array(\XoopsBaseConfig::get('lib-path') . '/smarty/xoops_plugins' . DIRECTORY_SEPARATOR, SMARTY_DIR . 'plugins' . DS), $this->object->plugins_dir);
$this->assertSame(\XoopsBaseConfig::get('url'), $this->object->getTemplateVars('xoops_url'));
$this->assertSame(\XoopsBaseConfig::get('root-path'), $this->object->getTemplateVars('xoops_rootpath'));
$this->assertSame(\XoopsLocale::getLangCode(), $this->object->getTemplateVars('xoops_langcode'));
$this->assertSame(\XoopsLocale::getCharset(), $this->object->getTemplateVars('xoops_charset'));
$this->assertSame(\Xoops::VERSION, $this->object->getTemplateVars('xoops_version'));
$this->assertSame(\XoopsBaseConfig::get('uploads-url'), $this->object->getTemplateVars('xoops_upload_url'));
}
示例14: xlanguage_convert_item
/**
* @param string $value
* @param string $out_charset
* @param string $in_charset
*
* @return string
*/
function xlanguage_convert_item($value, $out_charset, $in_charset)
{
$xoops = Xoops::getInstance();
if (strtolower($in_charset) == strtolower($out_charset)) {
return $value;
}
$xconv_handler = $xoops->getModuleHandler('xconv', 'xconv', true);
if (is_object($xconv_handler) && ($converted_value = @$xconv_handler->convert_encoding($value, $out_charset, $in_charset))) {
return $converted_value;
}
if (XoopsLocale::isMultiByte() && 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;
}
示例15: loadLanguage
/**
* @param string $name Name of language file to be loaded, without extension
* @param mixed $domain string: Module dirname; global language file will be loaded if $domain is set to 'global' or not specified
* array: example; array('Frameworks/moduleclasses/moduleadmin')
* @param string $language Language to be loaded, current language content will be loaded if not specified
*
* @return boolean
*/
public static function loadLanguage($name, $domain = '', $language = null)
{
if (empty($name)) {
return false;
}
$language = empty($language) ? XoopsLocale::getLegacyLanguage() : $language;
// expanded domain to multiple categories, e.g. module:system, framework:filter, etc.
if (empty($domain) || 'global' == $domain) {
$path = '';
} else {
$path = is_array($domain) ? array_shift($domain) : "modules/{$domain}";
}
$xoops = Xoops::getInstance();
$fullPath = $xoops->path("{$path}/language/{$language}/{$name}.php");
if (!($ret = XoopsLoad::loadFile($fullPath))) {
$fullPath2 = $xoops->path("{$path}/language/english/{$name}.php");
$ret = XoopsLoad::loadFile($fullPath2);
}
return $ret;
}