當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。