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


PHP sfCultureInfo::getCultures方法代码示例

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


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

示例1: configure

 /**
  * Configures the current validator.
  *
  * @param array $options   An array of options
  * @param array $messages  An array of error messages
  *
  * @see sfValidatorChoice
  */
 protected function configure($options = array(), $messages = array())
 {
     parent::configure($options, $messages);
     // populate choices with all cultures
     $choices = array();
     $cultures = sfCultureInfo::getCultures(sfCultureInfo::SPECIFIC);
     foreach ($cultures as $culture) {
         // skip en_US_POSIX
         if ($culture == "en_US_POSIX") {
             continue;
         }
         try {
             $choices[] = sfCultureInfo::getInstance($culture)->getName();
         } catch (sfException $e) {
         }
     }
     sort($choices);
     $this->setOption('choices', $choices);
 }
开发者ID:psskhal,项目名称:symfony-sample,代码行数:27,代码来源:sfValidatorI18nChoiceCulture.class.php

示例2: foreach

// ->validCulture()
$t->diag('->validCulture()');
$t->is($c->validCulture('fr'), true, '->validCulture() returns true if the culture is valid');
$t->is($c->validCulture('fr_FR'), true, '->validCulture() returns true if the culture is valid');
foreach (array('xxx', 'pp', 'frFR') as $culture) {
    $t->is($c->validCulture($culture), false, '->validCulture() returns false if the culture does not exist');
}
// ::getCultures()
$t->diag('::getCultures()');
$cultures = sfCultureInfo::getCultures();
$t->is(in_array('fr', $cultures), true, '::getCultures() returns an array of all available cultures');
$t->is(in_array('fr_FR', $cultures), true, '::getCultures() returns an array of all available cultures');
$cultures = sfCultureInfo::getCultures(sfCultureInfo::NEUTRAL);
$t->is(in_array('fr', $cultures), true, '::getCultures() returns an array of all available cultures');
$t->is(in_array('fr_FR', $cultures), false, '::getCultures() returns an array of all available cultures');
$cultures = sfCultureInfo::getCultures(sfCultureInfo::SPECIFIC);
$t->is(in_array('fr', $cultures), false, '::getCultures() returns an array of all available cultures');
$t->is(in_array('fr_FR', $cultures), true, '::getCultures() returns an array of all available cultures');
// ->getParent()
$t->diag('->getParent()');
$c = sfCultureInfo::getInstance('fr_FR');
$t->isa_ok($c->getParent(), 'sfCultureInfo', '->getParent() returns a sfCultureInfo instance');
$t->is($c->getParent()->getName(), 'fr', '->getParent() returns the parent culture');
$c = sfCultureInfo::getInstance('fr');
$t->is($c->getParent()->getName(), 'en', '->getParent() returns the invariant culture if the culture is neutral');
// ->getIsNeutralCulture()
$t->diag('->getIsNeutralCulture()');
$c = sfCultureInfo::getInstance('fr_FR');
$t->is($c->getIsNeutralCulture(), false, '->getIsNeutralCulture() returns false if the culture is specific');
$c = sfCultureInfo::getInstance('fr');
$t->is($c->getIsNeutralCulture(), true, '->getIsNeutralCulture() returns true if the culture is neutral');
开发者ID:sensorsix,项目名称:app,代码行数:31,代码来源:sfCultureInfoTest.php

示例3: loadConfigForm

 public function loadConfigForm(sfEvent $event)
 {
     $form = $event->getSubject();
     $form->addSetting(null, 'rows_per_page', 'Rows Per Page');
     if (sfSympalConfig::isI18nEnabled()) {
         $cultures = sfCultureInfo::getCultures(sfCultureInfo::NEUTRAL);
         $languages = array();
         foreach ($cultures as $key => $value) {
             $formatted = format_language($value);
             if (!$formatted) {
                 $formatted = format_language($value, 'en');
             }
             if ($formatted) {
                 $languages[$value] = $formatted;
             }
         }
         asort($languages);
         $widget = new sfWidgetFormChoice(array('multiple' => true, 'choices' => $languages));
         $validator = new sfValidatorChoice(array('multiple' => true, 'choices' => array_keys($languages)));
         $form->addSetting(null, 'language_codes', 'Available Cultures', $widget, $validator);
         $languageForm = new sfFormLanguage(sfContext::getInstance()->getUser(), array('languages' => sfSympalConfig::getLanguageCodes()));
         $widgetSchema = $languageForm->getWidgetSchema();
         $validatorSchema = $languageForm->getValidatorSchema();
         $form->addSetting(null, 'default_culture', 'Default Culture', $widgetSchema['language'], $validatorSchema['language']);
     }
     $array = sfSympalFormToolkit::getThemeWidgetAndValidator();
     $form->addSetting(null, 'default_theme', 'Default Theme', $array['widget'], $array['validator']);
     $form->addSetting(null, 'default_rendering_module', 'Default Rendering Module');
     $form->addSetting(null, 'default_rendering_action', 'Default Rendering Action');
     $form->addSetting(null, 'recaptcha_public_key', 'Recaptcha Public Key');
     $form->addSetting(null, 'recaptcha_private_key', 'Recaptcha Private Key');
     $form->addSetting(null, 'breadcrumbs_separator', 'Breadcrumbs Separator');
     $form->addSetting(null, 'default_from_email_address', 'Default From Address');
     $form->addSetting(null, 'enable_markdown_editor', 'Enable Markdown Editor', 'InputCheckbox', 'Boolean');
     $form->addSetting(null, 'elastic_textareas', 'Elastic Textareas', 'InputCheckbox', 'Boolean');
     $form->addSetting(null, 'check_for_upgrades_on_dashboard', 'Check for Upgrades', 'InputCheckbox', 'Boolean');
     $form->addSetting('plugin_api', 'username', 'Username or API Key');
     $form->addSetting('plugin_api', 'password');
     $form->addSetting('page_cache', 'enabled', 'Enabled?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'super', 'Enable Super Cache?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'with_layout', 'With layout?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'lifetime', 'Lifetime');
 }
开发者ID:slemoigne,项目名称:sympal,代码行数:43,代码来源:sfSympalAdminPluginConfiguration.class.php

示例4: loadConfigForm

 /**
  * Listens to sympal.load_config_form to load the configuration form
  */
 public function loadConfigForm(sfEvent $event)
 {
     $form = $event->getSubject();
     if (sfSympalConfig::isI18nEnabled()) {
         $cultures = sfCultureInfo::getCultures(sfCultureInfo::NEUTRAL);
         $languages = array();
         foreach ($cultures as $key => $value) {
             $formatted = format_language($value);
             if (!$formatted) {
                 $formatted = format_language($value, 'en');
             }
             if ($formatted) {
                 $languages[$value] = $formatted;
             }
         }
         asort($languages);
         $widget = new sfWidgetFormChoice(array('multiple' => true, 'choices' => $languages));
         $validator = new sfValidatorChoice(array('multiple' => true, 'choices' => array_keys($languages)));
         $form->addSetting(null, 'language_codes', 'Available Cultures', $widget, $validator);
         $languageForm = new sfFormLanguage(sfContext::getInstance()->getUser(), array('languages' => sfSympalConfig::getLanguageCodes()));
         $widgetSchema = $languageForm->getWidgetSchema();
         $validatorSchema = $languageForm->getValidatorSchema();
         $form->addSetting(null, 'default_culture', 'Default Culture', $widgetSchema['language'], $validatorSchema['language']);
     }
     $form->addSetting(null, 'default_rendering_module', 'Default Rendering Module');
     $form->addSetting(null, 'default_rendering_action', 'Default Rendering Action');
     $form->addSetting(null, 'breadcrumbs_separator', 'Breadcrumbs Separator');
     $form->addSetting(null, 'elastic_textareas', 'Elastic Textareas', 'InputCheckbox', 'Boolean');
     $form->addSetting(null, 'check_for_upgrades_on_dashboard', 'Check for Upgrades', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'enabled', 'Enabled?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'super', 'Enable Super Cache?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'with_layout', 'With layout?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'lifetime', 'Lifetime');
 }
开发者ID:sympal,项目名称:sympal,代码行数:37,代码来源:sfSympalAdminPluginConfiguration.class.php

示例5: date

$context->user->culture = 'fr';
$t->is(format_date($now, 'F', 'en'), date('F j, Y g:i:s A', $now).' '.date('T', $now), 'format_date() takes a culture as its third argument');

// format_datetime()
$t->diag('format_datetime()');
$context->user->culture = 'en';
$t->is(format_datetime($now), date('F j, Y g:i:s A', $now).' '.date('T', $now), 'format_datetime() format a numerical date time according to the user culture');
$t->is(format_datetime(date('Y-m-d', $now)), date('F j, Y', $now).' 12:00:00 AM '.date('T', $now), 'format_datetime() format a string date time according to the user culture');
$t->is(format_datetime(date('Y-m-d H:i:s', $now), 'f'), date('F j, Y g:i A', $now), 'formats timestamps correctly');

$t->diag('sfDateFormat');
$df = new sfDateFormat('en_US');
$t->is($df->format('7/14/1789', 'i', 'd'), '1789-07-14', 'pre-epoch date from en_US to iso');
$t->is($df->format('7/14/1789 14:29', 'I', $df->getInputPattern('g')), '1789-07-14 14:29:00', 'pre-epoch date-time from en_US to iso with getInputPattern()');
$df = new sfDateFormat('fr');
$t->is($df->format(date('d/m/y', $now), 'i', 'd'), date('Y-m-d', $now), 'format two digit year from fr to iso');

$cultures = sfCultureInfo::getCultures();
foreach ($cultures as $culture)
{
  if (sfCultureInfo::validCulture($culture))
  {
    $df = new sfDateFormat($culture);
    $shortDate = $df->format($now, 'd');
    $t->is($df->format($shortDate, 'i', 'd'), date('Y-m-d', $now), sprintf('"%s": conversion "d" to "i"', $culture));
    $dateTime = $df->format($now, $df->getInputPattern('g'));
    $t->is($df->format($dateTime, 'I', $df->getInputPattern('g')), date('Y-m-d H:i:', $now).'00', sprintf('"%s": Conversion "g" to "I"', $culture));
  }
}
开发者ID:nationalfield,项目名称:symfony,代码行数:29,代码来源:DateHelperTest.php


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