本文整理汇总了PHP中ZLanguage::getInstalledLanguageNames方法的典型用法代码示例。如果您正苦于以下问题:PHP ZLanguage::getInstalledLanguageNames方法的具体用法?PHP ZLanguage::getInstalledLanguageNames怎么用?PHP ZLanguage::getInstalledLanguageNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZLanguage
的用法示例。
在下文中一共展示了ZLanguage::getInstalledLanguageNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: modify
/**
* modify block settings
*/
public function modify($blockinfo)
{
// get variable values from database
$vars = BlockUtil::varsFromContent($blockinfo['content']);
// installed languages
$languages = ZLanguage::getInstalledLanguageNames();
// set default values - block
if (!isset($vars['block_template'])) {
$vars['block_template'] = 'marquee.tpl';
}
if (!isset($vars['block_title']) || !is_array($vars['block_title'])) {
$vars['block_title'] = array();
}
foreach (array_keys($languages) as $lang) {
if (!array_key_exists($lang, $vars['block_title'])) {
$vars['block_title'][$lang] = '';
}
}
if (!isset($vars['block_wrap'])) {
$vars['block_wrap'] = true;
}
// set default values - content
if (!isset($vars['marquee_content']) || !is_array($vars['marquee_content'])) {
$vars['marquee_content'] = array();
}
foreach (array_keys($languages) as $lang) {
if (!array_key_exists($lang, $vars['marquee_content'])) {
$vars['marquee_content'][$lang] = '';
}
}
if (!isset($vars['marquee_content_editor'])) {
$vars['marquee_content_editor'] = true;
}
if (!isset($vars['marquee_duration'])) {
$vars['marquee_duration'] = 15000;
}
if (!isset($vars['marquee_gap'])) {
$vars['marquee_gap'] = 200;
}
if (!isset($vars['marquee_delayBeforeStart'])) {
$vars['marquee_delayBeforeStart'] = 0;
}
if (!isset($vars['marquee_direction'])) {
$vars['marquee_direction'] = 'left';
}
if (!isset($vars['marquee_duplicated'])) {
$vars['marquee_duplicated'] = true;
}
if (!isset($vars['marquee_pauseOnHover'])) {
$vars['marquee_pauseOnHover'] = true;
}
if (!isset($vars['marquee_pauseOnCycle'])) {
$vars['marquee_pauseOnCycle'] = false;
}
$this->view->assign('vars', $vars);
$this->view->assign('bid', $blockinfo['bid']);
$this->view->assign('languages', $languages);
return $this->view->fetch('blocks/marquee_modify.tpl');
}
示例3: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('title', 'text')->add('urltitle', 'text', array('required' => false, 'label' => __('PermaLink URL title')))->add($builder->create('metadescription', 'textarea', array('required' => false))->addModelTransformer(new NullToEmptyTransformer()))->add($builder->create('metakeywords', 'textarea', array('required' => false))->addModelTransformer(new NullToEmptyTransformer()))->add('content')->add('displaywrapper', 'checkbox', array('required' => false, 'label' => __('Display additional information')))->add('displaytitle', 'checkbox', array('required' => false, 'label' => __('Display page title')))->add('displaycreated', 'checkbox', array('required' => false, 'label' => __('Display page creation date')))->add('displayupdated', 'checkbox', array('required' => false, 'label' => __('Display page update date')))->add('displaytextinfo', 'checkbox', array('required' => false, 'label' => __('Display page text statistics')))->add('displayprint', 'checkbox', array('required' => false, 'label' => __('Display page print link')))->add($builder->create('language', 'choice', array('choices' => \ZLanguage::getInstalledLanguageNames(), 'required' => false, 'placeholder' => __('All')))->addModelTransformer(new NullToEmptyTransformer()))->add('obj_status', 'checkbox', array('required' => false, 'label' => __('Page is active')))->add('save', 'submit', array('label' => 'Create Page'));
$entityCategoryRegistries = \CategoryRegistryUtil::getRegisteredModuleCategories('ZikulaPagesModule', 'PageEntity', 'id');
foreach ($entityCategoryRegistries as $registryId => $parentCategoryId) {
$builder->add('categories', new CategoryType($registryId, $parentCategoryId), array('multiple' => true));
}
}
示例4: 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);
}
示例5: smarty_function_html_select_locales
/**
* 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_locales name=locale selected=en}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string The value of the last status message posted, or void if no status message exists.
*/
function smarty_function_html_select_locales($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_locales', 'name')));
return false;
}
require_once $view->_get_plugin_filepath('function', 'html_options');
$values = $output = array();
if (isset($params['all']) && $params['all']) {
$values[] = '';
$output[] = DataUtil::formatForDisplay(__('All'));
}
$installed = ZLanguage::getInstalledLanguageNames();
$output = array_merge($output, DataUtil::formatForDisplay(array_values($installed)));
$values = array_merge($values, DataUtil::formatForDisplay(array_keys($installed)));
$html_result = smarty_function_html_options(array('output' => $output, 'values' => $values, 'selected' => isset($params['selected']) ? $params['selected'] : null, 'id' => isset($params['id']) ? $params['id'] : null, 'name' => $params['name']), $view);
if (isset($params['assign']) && !empty($params['assign'])) {
$view->assign($params['assign'], $html_result);
} else {
return $html_result;
}
}
示例6: getSelectorData_Language
/**
* Return the dropdown data for the language selector.
*
* @param boolean $includeAll Whether or not to include the 'All' choice.
*
* @return The string representation for the selected value.
*/
public static function getSelectorData_Language($includeAll = true)
{
$langlist = array();
$dropdown = array();
if ($includeAll) {
$dropdown[] = array('id' => '', 'name' => __('All'));
}
$langlist = ZLanguage::getInstalledLanguageNames();
asort($langlist);
foreach ($langlist as $k => $v) {
$dropdown[] = array('id' => $k, 'name' => $v);
}
return $dropdown;
}
示例7: _upg_selectlanguage
/**
* Generate the language selector page.
*
* This function generate the language selector page.
*
* @return void
*/
function _upg_selectlanguage()
{
_upg_header();
$validupgrade = true;
if (!$GLOBALS['ZConfig']['System']['installed']) {
$validupgrade = false;
echo '<h2>' . __('FATAL ERROR!') . "</h2>\n";
echo '<p class="z-errormsg">' . __("Zikula does not appear to be installed.") . "</p>\n";
}
if (!$validupgrade) {
_upg_footer();
System::shutdown();
}
$curlang = ZLanguage::getLanguageCode();
echo '<form class="z-form" action="upgrade.php" method="get" enctype="application/x-www-form-urlencoded">' . "\n";
echo '<fieldset><legend>' . __('Please select your language') . '</legend>' . "\n";
echo '<input type="hidden" name="action" value="upgradeinit" />' . "\n";
echo '<div class="z-formrow"><label for="lang">' . __('Choose a language') . '</label>' . "\n";
echo '<select id="lang" name="lang">' . "\n";
$langs = ZLanguage::getInstalledLanguageNames();
foreach ($langs as $lang => $name) {
$selected = $lang == $curlang ? ' selected="selected"' : '';
echo '<option value="' . $lang . '" label="' . $name . '"' . $selected . '>' . $name . "</option>\n";
}
echo '</select></div></fieldset>' . "\n";
echo '<div class="z-buttons z-center"><input type="submit" value="' . __('Submit') . '" /></div>' . "\n";
echo '</form>' . "\n";
_upg_footer();
}
示例8: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('locale', 'choice', array('label' => __('Select your default language'), 'label_attr' => array('class' => 'col-sm-3'), 'choices' => \ZLanguage::getInstalledLanguageNames(), 'data' => \ZLanguage::getLanguageCode()));
}
示例9: changeLangAction
/**
* @Route("/lang")
*
* Display the form that allows the user to change the language displayed to him on the site.
*
* @return Response symfony response object if a form is to be displayed
*
* @throws AccessDeniedException Thrown if the user isn't logged in
*/
public function changeLangAction()
{
if (!UserUtil::isLoggedIn()) {
throw new AccessDeniedException();
}
// Assign the languages
return new Response($this->view->assign('languages', \ZLanguage::getInstalledLanguageNames())->assign('usrlang', \ZLanguage::getLanguageCode())->fetch('User/changelang.tpl'));
}
示例10: modify
/**
* block configuration
*/
public function modify($blockinfo)
{
$vars = BlockUtil::varsFromContent($blockinfo['content']);
// set some default vars
$vars['isnew'] = empty($vars);
$vars['menutree_content'] = isset($vars['menutree_content']) ? $vars['menutree_content'] : array();
$vars['menutree_tpl'] = isset($vars['menutree_tpl']) ? $vars['menutree_tpl'] : '';
$vars['menutree_stylesheet'] = isset($vars['menutree_stylesheet']) ? $vars['menutree_stylesheet'] : '';
$vars['menutree_linkclass'] = isset($vars['menutree_linkclass']) ? $vars['menutree_linkclass'] : false;
$vars['menutree_linkclasses'] = isset($vars['menutree_linkclasses']) ? $vars['menutree_linkclasses'] : array();
$vars['menutree_titles'] = isset($vars['menutree_titles']) ? $vars['menutree_titles'] : array();
$vars['menutree_editlinks'] = isset($vars['menutree_editlinks']) ? $vars['menutree_editlinks'] : false;
$vars['menutree_stripbaseurl'] = isset($vars['menutree_stripbaseurl']) ? $vars['menutree_stripbaseurl'] : true;
$vars['menutree_maxdepth'] = isset($vars['menutree_maxdepth']) ? $vars['menutree_maxdepth'] : 0;
$vars['oldlanguages'] = isset($vars['oldlanguages']) ? $vars['oldlanguages'] : array();
$vars['olddefaultanguage'] = isset($vars['olddefaultanguage']) ? $vars['olddefaultanguage'] :'';
// get list of languages
$vars['languages'] = ZLanguage::getInstalledLanguageNames();
$userlanguage = ZLanguage::getLanguageCode();
// get default langs
$vars['defaultanguage'] = !empty($blockinfo['language']) ? $blockinfo['language'] : $userlanguage;
// rebuild langs array - default lang has to be first
if (isset($vars['languages']) && count($vars['languages']) > 1) {
$deflang[$vars['defaultanguage']] = $vars['languages'][$vars['defaultanguage']];
unset($vars['languages'][$vars['defaultanguage']]);
$vars['languages'] = array_merge($deflang,$vars['languages']);
$vars['multilingual'] = true;
} else {
$vars['multilingual'] = false;
}
$langs = array('list' => array_keys($vars['languages']),
'flat' => false);
// check if there is allredy content
if (empty($vars['menutree_content'])) {
// no content - get list of menus to allow import
$vars['menutree_menus'] = $this->_get_current_menus($blockinfo['bid']);
} else {
// are there new langs not present in current menu?
// check if there are new languages not present in current menu
// if so - need to set reference lang to copy initial menu items data
if (count(array_diff($vars['languages'],$vars['oldlanguages'])) > 1) {
// fisrt try current default lang
if (in_array($vars['defaultanguage'],$vars['oldlanguages'])) {
$langs['ref'] = $vars['defaultanguage'];
// or user lang
} elseif (in_array($userlanguage,$vars['oldlanguages'])) {
$langs['ref'] = $userlanguage;
// or old default lang
} elseif (in_array($vars['olddefaultanguage'],$vars['languages'])) {
$langs['ref'] = $vars['olddefaultanguage'];
// it must be any language present in old and new lang list
} else {
$langs['ref'] = current(array_intersect($vars['languages'], $vars['oldlanguages']));
}
}
}
// decode tree array
$tree = new Blocks_MenutreeTree();
$tree->setOption('id', 'adm-menutree'.$blockinfo['bid']);
$tree->setOption('sortable', true);
if (isset($langs)) {
$tree->setOption('langs', $langs['list']);
}
$tree->setOption('stripbaseurl', $vars['menutree_stripbaseurl']);
$tree->setOption('maxDepth', $vars['menutree_maxdepth']);
$tree->loadArrayData($vars['menutree_content']);
$vars['menutree_content'] = $tree->getHTML();
// get all templates and stylesheets.
$vars['tpls'] = Blocks_MenutreeUtil::getTemplates();
$vars['styles'] = Blocks_MenutreeUtil::getStylesheets();
$someThemes = $this->__('Only in some themes');
$vars['somethemes'] = isset($vars['tpls'][$someThemes]) || isset($vars['styles'][$someThemes]) ? true : false;
// template to use
if (empty($vars['menutree_tpl']) || !$this->view->template_exists($vars['menutree_tpl'])) {
$vars['menutree_tpl'] = 'menutree/blocks_block_menutree_default.tpl';
}
// prepare block titles array
foreach (array_keys($vars['languages']) as $lang) {
if (!array_key_exists($lang, $vars['menutree_titles'])) {
$vars['menutree_titles'][$lang] = '';
}
}
// for permissions settings get first supported permlevels
$vars['permlevels'] = $this->_permlevels();
// check if saved permlevels are correct
$vars['menutree_titlesperms'] = !empty($vars['menutree_titlesperms']) ? $vars['menutree_titlesperms'] : 'ACCESS_EDIT';
//.........这里部分代码省略.........
示例11: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('bid', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\HiddenType')->add('bkey', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\HiddenType')->add('blocktype', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\HiddenType')->add($builder->create('title', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType', ['required' => false])->addModelTransformer(new NullToEmptyTransformer()))->add($builder->create('description', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType', ['required' => false])->addModelTransformer(new NullToEmptyTransformer()))->add($builder->create('language', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType', ['choices' => \ZLanguage::getInstalledLanguageNames(), 'required' => false, 'placeholder' => $this->translator->__('All')])->addModelTransformer(new NullToEmptyTransformer()))->add('positions', 'Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType', ['class' => 'Zikula\\BlocksModule\\Entity\\BlockPositionEntity', 'choice_label' => 'name', 'multiple' => true, 'required' => false])->add('filters', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\CollectionType', ['entry_type' => 'Zikula\\BlocksModule\\Form\\Type\\BlockFilterType', 'allow_add' => true, 'allow_delete' => true, 'label' => 'Custom filters', 'required' => false])->add('save', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\SubmitType')->add('cancel', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\SubmitType');
}
示例12: setDefaultOptions
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('choices' => \ZLanguage::getInstalledLanguageNames(), 'label' => __('Locale'), 'required' => false, 'placeholder' => __('All')));
}
示例13: changeLangAction
/**
* Display the form that allows the user to change the language displayed to him on the site.
*
* @return string The rendered template.
*/
public function changeLangAction()
{
if (!UserUtil::isLoggedIn()) {
throw new Zikula_Exception_Forbidden();
}
// Assign the languages
return $this->response($this->view->assign('languages', ZLanguage::getInstalledLanguageNames())->assign('usrlang', ZLanguage::getLanguageCode())->fetch('users_user_changelang.tpl'));
}
示例14: modify
/**
* modify block settings
*/
public function modify($blockinfo)
{
// get variable values from database
$vars = BlockUtil::varsFromContent($blockinfo['content']);
// installed languages
$languages = ZLanguage::getInstalledLanguageNames();
// Javascript plugin data
$plugindir = 'javascript/jquery-plugins/Nivo-Slider';
$pluginthemes = FileUtil::getFiles($plugindir . '/themes', false, true, null, 'd');
// set default values - block
if (!isset($vars['block_template'])) {
$vars['block_template'] = 'slider.tpl';
}
if (!isset($vars['block_title']) || !is_array($vars['block_title'])) {
$vars['block_title'] = array();
}
foreach (array_keys($languages) as $lang) {
if (!array_key_exists($lang, $vars['block_title'])) {
$vars['block_title'][$lang] = '';
}
}
if (!isset($vars['block_wrap'])) {
$vars['block_wrap'] = true;
}
// set default values - content
if (!isset($vars['slider_content']) || !is_array($vars['slider_content'])) {
$vars['slider_content'] = array();
}
foreach (array_keys($languages) as $lang) {
if (!array_key_exists($lang, $vars['slider_content'])) {
$vars['slider_content'][$lang] = '';
}
}
if (!isset($vars['slider_htmlcaption']) || !is_array($vars['slider_htmlcaption'])) {
$vars['slider_htmlcaption'] = array();
}
foreach (array_keys($languages) as $lang) {
if (!array_key_exists($lang, $vars['slider_htmlcaption'])) {
$vars['slider_htmlcaption'][$lang] = '';
}
}
if (!isset($vars['slider_content_editor'])) {
$vars['slider_content_editor'] = true;
}
if (!isset($vars['slider_theme'])) {
$vars['slider_theme'] = 'default';
}
if (!isset($vars['slider_effect'])) {
$vars['slider_effect'] = 'random';
}
if (!isset($vars['slider_slices'])) {
$vars['slider_slices'] = 15;
}
if (!isset($vars['slider_boxCols'])) {
$vars['slider_boxCols'] = 8;
}
if (!isset($vars['slider_boxRows'])) {
$vars['slider_boxRows'] = 4;
}
if (!isset($vars['slider_animSpeed'])) {
$vars['slider_animSpeed'] = 500;
}
if (!isset($vars['slider_pauseTime'])) {
$vars['slider_pauseTime'] = 3000;
}
if (!isset($vars['slider_startSlide'])) {
$vars['slider_startSlide'] = 0;
}
if (!isset($vars['slider_directionNav'])) {
$vars['slider_directionNav'] = true;
}
if (!isset($vars['slider_controlNav'])) {
$vars['slider_controlNav'] = true;
}
if (!isset($vars['slider_controlNavThumbs'])) {
$vars['slider_controlNavThumbs'] = false;
}
if (!isset($vars['slider_pauseOnHover'])) {
$vars['slider_pauseOnHover'] = true;
}
if (!isset($vars['slider_manualAdvance'])) {
$vars['slider_manualAdvance'] = false;
}
if (!isset($vars['slider_randomStart'])) {
$vars['slider_randomStart'] = false;
}
$this->view->assign('vars', $vars);
$this->view->assign('bid', $blockinfo['bid']);
$this->view->assign('languages', $languages);
$this->view->assign('plugindir', $plugindir);
$this->view->assign('pluginthemes', $pluginthemes);
$this->view->assign('plugineffects', array('sliceDown', 'sliceDownLeft', 'sliceUp', 'sliceUpLeft', 'sliceUpDown', 'sliceUpDownLeft', 'fold', 'fade', 'random', 'slideInRight', 'slideInLeft', 'boxRandom', 'boxRain', 'boxRainReverse', 'boxRainGrow', 'boxRainGrowReverse'));
return $this->view->fetch('blocks/slider_modify.tpl');
}
示例15: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('sort-field', 'hidden')->add('sort-direction', 'hidden')->add('position', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType', ['choices' => $options['positionChoices'], 'required' => false, 'placeholder' => $options['translator']->__('All'), 'attr' => ['class' => 'input-sm']])->add('module', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType', ['choices' => $options['moduleChoices'], 'required' => false, 'placeholder' => $options['translator']->__('All'), 'attr' => ['class' => 'input-sm']])->add('language', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType', ['choices' => \ZLanguage::getInstalledLanguageNames(), 'required' => false, 'placeholder' => $options['translator']->__('All'), 'attr' => ['class' => 'input-sm']])->add('active', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType', ['choices' => [BlockApi::BLOCK_ACTIVE => $options['translator']->__('Active'), BlockApi::BLOCK_INACTIVE => $options['translator']->__('Inactive')], 'required' => false, 'placeholder' => $options['translator']->__('All'), 'attr' => ['class' => 'input-sm']])->add('filterButton', 'submit', ['icon' => 'fa-filter fa-lg', 'label' => __('Filter'), 'attr' => ['class' => "btn btn-default btn-sm"]]);
}