当前位置: 首页>>代码示例>>PHP>>正文


PHP opToolkit::getCultureChoices方法代码示例

本文整理汇总了PHP中opToolkit::getCultureChoices方法的典型用法代码示例。如果您正苦于以下问题:PHP opToolkit::getCultureChoices方法的具体用法?PHP opToolkit::getCultureChoices怎么用?PHP opToolkit::getCultureChoices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opToolkit的用法示例。


在下文中一共展示了opToolkit::getCultureChoices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: configure

 public function configure()
 {
     $this->user = sfContext::getInstance()->getUser();
     $languages = sfConfig::get('op_supported_languages');
     $opt_languages = $this->getOption('languages', array());
     $languages = array_unique(array_merge($languages, $opt_languages));
     $choices = opToolkit::getCultureChoices($languages);
     $this->setDefaults(array('culture' => $this->user->getCulture()));
     $this->setWidgets(array('culture' => new sfWidgetFormChoice(array('choices' => $choices)), 'next_uri' => new opWidgetFormInputHiddenNextUri()));
     $this->setValidators(array('culture' => new sfValidatorChoice(array('choices' => array_keys($choices))), 'next_uri' => new opValidatorNextUri()));
     $this->widgetSchema->setLabels(array('culture' => 'Languages'));
     $this->widgetSchema->setNameFormat('language[%s]');
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:13,代码来源:opLanguageSelecterForm.class.php

示例2: generateWidget

 public static function generateWidget($field, $choices = array())
 {
     $field = self::arrayKeyCamelize($field);
     $params = self::generateWidgetParams($field, $choices);
     if (in_array($field['FormType'], self::$choicesType)) {
         if ($field['FormType'] === 'select') {
             if (!$field['IsRequired']) {
                 $params['choices'] = array('' => sfContext::getInstance()->getI18N()->__('Please Select')) + $params['choices'];
             }
         } else {
             $params['expanded'] = true;
         }
     }
     switch ($field['FormType']) {
         case 'checkbox':
             $params['multiple'] = true;
             $obj = new sfWidgetFormChoice($params);
             break;
         case 'select':
             $obj = new sfWidgetFormChoice($params);
             break;
         case 'radio':
             $obj = new sfWidgetFormChoice($params);
             break;
         case 'textarea':
             $obj = new sfWidgetFormTextarea($params);
             break;
         case 'rich_textarea':
             $obj = new opWidgetFormRichTextarea($params);
             break;
         case 'password':
             $obj = new sfWidgetFormInputPassword($params);
             break;
         case 'date':
             unset($params['choices']);
             $params['culture'] = sfContext::getInstance()->getUser()->getCulture();
             $params['month_format'] = 'number';
             if (!$field['IsRequired']) {
                 $params['can_be_empty'] = true;
             }
             $obj = new opWidgetFormDate($params);
             break;
         case 'increased_input':
             $obj = new opWidgetFormInputIncreased($params);
             break;
         case 'language_select':
             $languages = sfConfig::get('op_supported_languages');
             $choices = opToolkit::getCultureChoices($languages);
             $obj = new sfWidgetFormChoice(array('choices' => $choices));
             break;
         case 'country_select':
             $info = sfCultureInfo::getInstance(sfContext::getInstance()->getUser()->getCulture());
             $obj = new sfWidgetFormChoice(array('choices' => $info->getCountries()));
             break;
         case 'region_select':
             $list = sfYaml::load(sfConfig::get('sf_lib_dir') . '/config/config/regions.yml');
             $type = $field['ValueType'];
             if ('string' !== $type && isset($list[$type])) {
                 $list = $list[$type];
                 $list = array_combine($list, $list);
             } else {
                 foreach ($list as $k => $v) {
                     if ($v) {
                         $list[$k] = array_combine($v, $v);
                     }
                 }
             }
             $list = opToolkit::arrayMapRecursive(array(sfContext::getInstance()->getI18N(), '__'), $list);
             $obj = new sfWidgetFormChoice(array('choices' => $list));
             break;
         default:
             $obj = new sfWidgetFormInput($params);
     }
     return $obj;
 }
开发者ID:phenom,项目名称:OpenPNE3,代码行数:75,代码来源:opFormItemGenerator.class.php


注:本文中的opToolkit::getCultureChoices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。