本文整理汇总了PHP中ZLanguage::setLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP ZLanguage::setLocale方法的具体用法?PHP ZLanguage::setLocale怎么用?PHP ZLanguage::setLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZLanguage
的用法示例。
在下文中一共展示了ZLanguage::setLocale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isNecessary
public function isNecessary()
{
if (version_compare(ZIKULACORE_CURRENT_INSTALLED_VERSION, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION, '<')) {
throw new AbortStageException(__f('The current installed version of Zikula is reporting (%1$s). You must upgrade to version (%2$s) before you can use this upgrade.', array(ZIKULACORE_CURRENT_INSTALLED_VERSION, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION)));
}
// make sure selected language is installed
if (!in_array(\ZLanguage::getLanguageCode(), \ZLanguage::getInstalledLanguages())) {
\System::setVar('language_i18n', 'en');
\System::setVar('language', 'eng');
\System::setVar('locale', 'en');
\ZLanguage::setLocale('en');
}
return true;
}
示例2: newBlockPositions
protected function newBlockPositions()
{
$positions = ModUtil::apiFunc('Blocks', 'user', 'getallpositions');
// create the search block position if doesn't exists
if (!isset($positions['search'])) {
$searchpid = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'search', 'description' => $this->__('Search block')));
} else {
$searchpid = $positions['search']['pid'];
}
// restores the search block if not present
$dbtable = DBUtil::getTables();
$blockscolumn = $dbtable['blocks_column'];
$searchblocks = DBUtil::selectObjectArray('blocks', "$blockscolumn[bkey] = 'Search'");
if (empty($searchblocks)) {
$block = array('bkey' => 'Search', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '', 'mid' => ModUtil::getIdFromName('Search'), 'title' => $this->__('Search box'), 'description' => '', 'positions' => array($searchpid));
$block['bid'] = ModUtil::apiFunc('Blocks', 'admin', 'create', $block);
ModUtil::apiFunc('Blocks', 'admin', 'update', $block);
} else {
// assign the block to the search position
$blockplacement = array('bid' => $searchblocks[0]['bid'], 'pid' => $searchpid);
DBUtil::insertObject($blockplacement, 'block_placements');
}
// create new block positions if they don't exist
if (!isset($positions['header'])) {
$header = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'header', 'description' => $this->__('Header block')));
}
if (!isset($positions['footer'])) {
$footer = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'footer', 'description' => $this->__('Footer block')));
}
if (!isset($positions['bottomnav'])) {
$bottomnav = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'bottomnav', 'description' => $this->__('Bottom navigation block')));
}
if (!isset($positions['topnav'])) {
$topnav = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'topnav', 'description' => $this->__('Top navigation block')));
// Build content for the top navigation menu
$languages = ZLanguage::getInstalledLanguages();
$saveLanguage = ZLanguage::getLanguageCode();
foreach ($languages as $lang) {
ZLanguage::setLocale($lang);
ZLanguage::bindCoreDomain();
$topnavcontent = array();
$topnavcontent['displaymodules'] = '0';
$topnavcontent['stylesheet'] = 'extmenu.css';
$topnavcontent['template'] = 'blocks_block_extmenu_topnav.tpl';
$topnavcontent['blocktitles'][$lang] = $this->__('Top navigation');
$topnavcontent['links'][$lang][] = array('name' => $this->__('Home'), 'url' => '{homepage}', 'title' => $this->__("Go to the site's home page"), 'level' => 0, 'parentid' => null, 'image' => '', 'active' => '1');
$topnavcontent['links'][$lang][] = array('name' => $this->__('My Account'), 'url' => '{Users}', 'title' => $this->__('Go to your account panel'), 'level' => 0, 'parentid' => null, 'image' => '', 'active' => '1');
$topnavcontent['links'][$lang][] = array('name' => $this->__('Site search'), 'url' => '{Search}', 'title' => $this->__('Search this site'), 'level' => 0, 'parentid' => null, 'image' => '', 'active' => '1');
}
ZLanguage::setLocale($saveLanguage);
$topnavcontent = serialize($topnavcontent);
$topnavblock = array('bkey' => 'Extmenu', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '', 'mid' => ModUtil::getIdFromName('Blocks'), 'title' => $this->__('Top navigation'), 'description' => '', 'content' => $topnavcontent, 'positions' => array($topnav));
$topnavblock['bid'] = ModUtil::apiFunc('Blocks', 'admin', 'create', $topnavblock);
ModUtil::apiFunc('Blocks', 'admin', 'update', $topnavblock);
}
}
示例3: smarty_function_selector_category
/**
* Category selector.
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string
*/
function smarty_function_selector_category($params, Zikula_View $view)
{
$categoryRegistryModule = isset($params['categoryRegistryModule']) ? $params['categoryRegistryModule'] : '';
$categoryRegistryTable = isset($params['categoryRegistryTable']) ? $params['categoryRegistryTable'] : '';
$categoryRegistryProperty = isset($params['categoryRegistryProperty']) ? $params['categoryRegistryProperty'] : '';
$category = isset($params['category']) ? $params['category'] : 0;
$path = isset($params['path']) ? $params['path'] : '';
$pathfield = isset($params['pathfield']) ? $params['pathfield'] : 'path';
$field = isset($params['field']) ? $params['field'] : 'id';
$fieldIsAttribute = isset($params['fieldIsAttribute']) ? $params['fieldIsAttribute'] : null;
$selectedValue = isset($params['selectedValue']) ? $params['selectedValue'] : 0;
$defaultValue = isset($params['defaultValue']) ? $params['defaultValue'] : 0;
$defaultText = isset($params['defaultText']) ? $params['defaultText'] : '';
$allValue = isset($params['allValue']) ? $params['allValue'] : 0;
$allText = isset($params['allText']) ? $params['allText'] : '';
$name = isset($params['name']) ? $params['name'] : 'defaultselectorname';
$submit = isset($params['submit']) ? $params['submit'] : false;
$recurse = isset($params['recurse']) ? $params['recurse'] : true;
$relative = isset($params['relative']) ? $params['relative'] : true;
$includeRoot = isset($params['includeRoot']) ? $params['includeRoot'] : false;
$includeLeaf = isset($params['includeLeaf']) ? $params['includeLeaf'] : true;
$all = isset($params['all']) ? $params['all'] : false;
$displayPath = isset($params['displayPath']) ? $params['displayPath'] : false;
$attributes = isset($params['attributes']) ? $params['attributes'] : null;
$assign = isset($params['assign']) ? $params['assign'] : null;
$editLink = isset($params['editLink']) ? $params['editLink'] : true;
$multipleSize = isset($params['multipleSize']) ? $params['multipleSize'] : 1;
$sortField = isset($params['sortField']) ? $params['sortField'] : 'sort_value';
$doReplaceRootCat = isset($params['doReplaceRootCat']) ? $params['doReplaceRootCat'] : null;
$cssClass = isset($params['cssClass']) ? $params['cssClass'] : '';
if (isset($params['lang'])) {
$lang = $params['lang'];
$oldLocale = ZLanguage::getLocale();
ZLanguage::setLocale($lang);
} else {
$lang = ZLanguage::getLanguageCode();
}
if (!$category && !$path && $categoryRegistryModule && $categoryRegistryTable && $categoryRegistryProperty) {
$category = CategoryRegistryUtil::getRegisteredModuleCategory($categoryRegistryModule, $categoryRegistryTable, $categoryRegistryProperty);
}
// if we don't have a category-id we see if we can get a category by path
if (!$category && $path) {
$category = CategoryUtil::getCategoryByPath($path, $pathfield);
} elseif (is_numeric($category)) {
// check if we have a numeric category
$category = CategoryUtil::getCategoryByID($category);
} elseif (is_string($category) && strpos($category, '/') === 0) {
// check if we have a string/path category
$category = CategoryUtil::getCategoryByPath($category, $pathfield);
}
static $catCache;
if (!$catCache) {
$catCache = array();
}
$cacheKey = "{$category['id']}||{$recurse}|{$relative}|{$includeRoot}|{$includeLeaf}|{$all}|||{$attributes}|{$sortField}";
if (!isset($catCache[$cacheKey])) {
$catCache[$cacheKey] = CategoryUtil::getSubCategoriesForCategory($category, $recurse, $relative, $includeRoot, $includeLeaf, $all, '', '', $attributes, $sortField);
}
$html = CategoryUtil::getSelector_Categories($catCache[$cacheKey], $field, $selectedValue, $name, $defaultValue, $defaultText, $allValue, $allText, $submit, $displayPath, $doReplaceRootCat, $multipleSize, $fieldIsAttribute, $cssClass, $lang);
if ($editLink && !empty($category) && SecurityUtil::checkPermission('ZikulaCategoriesModule::', "{$category['id']}::", ACCESS_EDIT)) {
$url = DataUtil::formatForDisplay(ModUtil::url('ZikulaCategoriesModule', 'user', 'edit', array('dr' => $category['id'])));
$html .= " <a href=\"{$url}\"><img src=\"" . System::getBaseUrl() . "images/icons/extrasmall/xedit.png\" title=\"" . __('Edit sub-category') . '" alt="' . __('Edit sub-category') . '" /></a>';
}
if (isset($params['lang'])) {
// Reset language again.
ZLanguage::setLocale($oldLocale);
}
if ($assign) {
$view->assign($assign, $html);
} else {
return $html;
}
}
示例4: time
<?php
//1. Init zikula engine
$time = time();
include 'lib/bootstrap.php';
$core->init();
ModUtil::load('IWmain', 'admin');
$langcode = ModUtil::getVar('ZConfig', 'language_i18n');
ZLanguage::setLocale($langcode);
ZLanguage::bindCoreDomain();
$dom = ZLanguage::getModuleDomain('IWmain');
//2. Checking cron password
$passwordActive = ModUtil::getVar('IWmain','cronPasswordActive');
if ($passwordActive) {
$passwordString = ModUtil::getVar('IWmain','cronPasswordString');
$passwordSended = FormUtil::getPassedValue('password',null,'GET');
if ($passwordString !== $passwordSended) {
print __("You can't execute iwcron", $dom);
cronShutdown();
}
}
//3. Cron actions
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$lastCronSuccessfull = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => -100,
'name' => 'lastCronSuccessfull',
'module' => 'IWmain_cron',
'sv' => $sv));
$dateTimeFrom = (int)$lastCronSuccessfull;
示例5: getAvailableLanguages
public function getAvailableLanguages($translate)
{
$savedLanguage = ZLanguage::getLanguageCode();
$langlist = ZLanguage::getInstalledLanguages();
$list = array();
foreach ($langlist as $code) {
$img = file_exists("images/flags/flag-$code.png");
if ($translate == 2) {
// configuration requires to translate each item in the list into the language of the country being shown
ZLanguage::setLocale($code);
$langname = ZLanguage::getLanguageName($code);
ZLanguage::setLocale($savedLanguage);
} else {
$langname = ZLanguage::getLanguageName($code);
}
$list[] = array('code' => $code,
'name' => $langname,
'flag' => $img ? "images/flags/flag-$code.png" : '');
}
usort($list, '_blocks_thelangblock_sort');
return $list;
}