本文整理汇总了PHP中ZLanguage::languageMap方法的典型用法代码示例。如果您正苦于以下问题:PHP ZLanguage::languageMap方法的具体用法?PHP ZLanguage::languageMap怎么用?PHP ZLanguage::languageMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZLanguage
的用法示例。
在下文中一共展示了ZLanguage::languageMap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_html_select_languages
/**
* Zikula_View function to display a drop down list of languages
*
* Available parameters:
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
* - name: Name for the control
* - id: ID for the control
* - selected: Selected value
* - installed: if set only show languages existing in languages folder
* - all: show dummy entry '_ALL' on top of the list with empty value
*
* Example
* {html_select_languages name=language selected=en}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @deprecated smarty_function_html_select_locales()
* @return string The value of the last status message posted, or void if no status message exists.
*/
function smarty_function_html_select_languages($params, Zikula_View $view)
{
if (!isset($params['name']) || empty($params['name'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('html_select_languages', 'name')));
return false;
}
require_once $view->_get_plugin_filepath('function', 'html_options');
$params['output'] = array();
$params['values'] = array();
if (isset($params['all']) && $params['all']) {
$params['values'][] = '';
$params['output'][] = DataUtil::formatForDisplay(__('All'));
unset($params['all']);
}
if (isset($params['installed']) && $params['installed']) {
$languagelist = ZLanguage::getInstalledLanguageNames();
unset($params['installed']);
} else {
$languagelist = ZLanguage::languageMap();
}
$params['output'] = array_merge($params['output'], DataUtil::formatForDisplay(array_values($languagelist)));
$params['values'] = array_merge($params['values'], DataUtil::formatForDisplay(array_keys($languagelist)));
$assign = isset($params['assign']) ? $params['assign'] : null;
unset($params['assign']);
$html_result = smarty_function_html_options($params, $view);
if (!empty($assign)) {
$view->assign($assign, $html_result);
} else {
return $html_result;
}
}
示例2: load
/**
* Load event handler.
*
* @param Zikula_Form_View $view Reference to Zikula_Form_View object.
* @param array &$params Parameters passed from the Smarty plugin function.
*
* @return void
*/
public function load(Zikula_Form_View $view, &$params)
{
if ($this->mandatory) {
$this->addItem('---', null);
}
if ($this->addAllOption) {
$this->addItem(DataUtil::formatForDisplay(__('All')), '');
}
if ($this->onlyInstalledLanguages) {
$langList = ZLanguage::getInstalledLanguageNames();
foreach ($langList as $code => $name) {
$this->addItem($name, $code);
}
} else {
$langList = ZLanguage::languageMap();
foreach ($langList as $code => $name) {
$this->addItem($name, $code);
}
}
parent::load($view, $params);
}
示例3: getAddLanguageSelectData
public function getAddLanguageSelectData($all = false)
{
$languages_map = \ZLanguage::languageMap();
if ($all) {
return $languages_map;
} else {
return array_diff_key($languages_map, $this->installed);
}
}
示例4: isValidLanguage
/**
* Checks if string field value is a valid language code.
*
* @param string $fieldName The name of the property to be checked
* @param boolean $onlyInstalled Whether to accept only installed languages (default false)
* @return boolean result of this check
*/
public function isValidLanguage($fieldName, $onlyInstalled = false)
{
$languageMap = ZLanguage::languageMap();
$result = in_array($this->entity[$fieldName], array_keys($languageMap));
if (!$result || !$onlyInstalled) {
return $result;
}
$available = ZLanguage::getInstalledLanguages();
return in_array($this->entity[$fieldName], $available);
}