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


PHP Collator::create方法代码示例

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


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

示例1: getRemainingViews

 /**
  * Returns the remaining locales sorted by language name
  *
  * @return array
  */
 public function getRemainingViews()
 {
     $remainingViews = parent::getRemainingViews();
     usort($remainingViews, function (ChoiceView $choiceView1, ChoiceView $choiceView2) {
         return \Collator::create(null)->compare($choiceView1->label, $choiceView2->label);
     });
     return $remainingViews;
 }
开发者ID:Sententiaregum,项目名称:LocaleBundle,代码行数:13,代码来源:LocaleChoiceList.php

示例2: testNotIsPrefix

 /**
  * Opposite of testIsPrefix
  *
  * @dataProvider notPrefixDataProvider
  */
 function testNotIsPrefix($lang, $base, $extended)
 {
     $cp = Collator::create($lang);
     $cp->setStrength(Collator::PRIMARY);
     $baseBin = $cp->getSortKey($base);
     // Remove sortkey terminator
     $baseBin = rtrim($baseBin, "");
     $extendedBin = $cp->getSortKey($extended);
     $this->assertStringStartsNotWith($baseBin, $extendedBin, "{$base} is a prefix of {$extended}");
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:15,代码来源:CollationTest.php

示例3: __construct

 public function __construct($locale)
 {
     if (!extension_loaded('intl')) {
         throw new MWException('An ICU collation was requested, ' . 'but the intl extension is not available.');
     }
     $this->locale = $locale;
     // Drop everything after the '@' in locale's name
     $localeParts = explode('@', $locale);
     $this->digitTransformLanguage = Language::factory($locale === 'root' ? 'en' : $localeParts[0]);
     $this->mainCollator = Collator::create($locale);
     if (!$this->mainCollator) {
         throw new MWException("Invalid ICU locale specified for collation: {$locale}");
     }
     $this->primaryCollator = Collator::create($locale);
     $this->primaryCollator->setStrength(Collator::PRIMARY);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:16,代码来源:IcuCollation.php

示例4: __construct

 public function __construct($name, $title = null, $source = null, $value = "", $form = null)
 {
     if (!is_array($source)) {
         // Get a list of countries from Zend
         $source = Zend_Locale::getTranslationList('territory', $this->locale(), 2);
         // We want them ordered by display name, not country code
         // PHP 5.3 has an extension that sorts UTF-8 strings correctly
         if (class_exists('Collator') && ($collator = Collator::create($this->locale()))) {
             $collator->asort($source);
         } else {
             asort($source);
         }
         // We don't want "unknown country" as an option
         unset($source['ZZ']);
     }
     parent::__construct($name, $title === null ? $name : $title, $source, $value, $form);
 }
开发者ID:normann,项目名称:sapphire,代码行数:17,代码来源:CountryDropdownField.php

示例5: setSource

 public function setSource($source)
 {
     if ($source) {
         return parent::setSource($source);
     }
     // map empty source to country list
     // Get a list of countries from Zend
     $source = Zend_Locale::getTranslationList('territory', $this->locale(), 2);
     // We want them ordered by display name, not country code
     // PHP 5.3 has an extension that sorts UTF-8 strings correctly
     if (class_exists('Collator') && ($collator = Collator::create($this->locale()))) {
         $collator->asort($source);
     } else {
         // Otherwise just put up with them being weirdly ordered for now
         asort($source);
     }
     // We don't want "unknown country" as an option
     unset($source['ZZ']);
     return parent::setSource($source);
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:20,代码来源:CountryDropdownField.php

示例6: __construct

 public function __construct($name, $title = null, $source = null, $value = "", $form = null)
 {
     if (!is_array($source)) {
         // Get a list of countries from Zend
         $source = Zend_Locale::getTranslationList('territory', $this->locale(), 2);
         // We want them ordered by display name, not country code
         // PHP 5.3 has an extension that sorts UTF-8 strings correctly
         if (class_exists('Collator') && ($collator = Collator::create($this->locale()))) {
             $collator->asort($source);
         } else {
             asort($source);
         }
         // We don't want "unknown country" as an option
         unset($source['ZZ']);
         // We don't want a number of countries which have ceased to exist
         unset($source['SU']);
         // Soviet Union
         unset($source['BQ']);
         // British Antarctic Territory
         unset($source['CT']);
         // Canton and Enderbury Islands
         unset($source['NQ']);
         // Dronning Maud Land
         unset($source['FX']);
         // France, Metropolitan
         unset($source['FQ']);
         // French Southern and Antarctic Territories
         unset($source['NT']);
         // Iraq-Saudi-Arabia Neutral Zone
         unset($source['PZ']);
         // Panama Canal Zone
         unset($source['CS']);
         // Serbia and Montenegro
     }
     parent::__construct($name, $title === null ? $name : $title, $source, $value, $form);
 }
开发者ID:stadtwald,项目名称:silverstripe-framework,代码行数:36,代码来源:CountryDropdownField.php

示例7: buildSort

 /**
  * @param string $path
  * @param array  $pages
  * @param string $order_by
  * @param array  $manual
  *
  * @throws \RuntimeException
  * @internal
  */
 protected function buildSort($path, array $pages, $order_by = 'default', $manual = null)
 {
     $list = [];
     $header_default = null;
     $header_query = null;
     $sort_flags = SORT_NATURAL | SORT_FLAG_CASE;
     // do this header query work only once
     if (strpos($order_by, 'header.') === 0) {
         $header_query = explode('|', str_replace('header.', '', $order_by));
         if (isset($header_query[1])) {
             $header_default = $header_query[1];
         }
     }
     foreach ($pages as $key => $info) {
         $child = isset($this->instances[$key]) ? $this->instances[$key] : null;
         if (!$child) {
             throw new \RuntimeException("Page does not exist: {$key}");
         }
         switch ($order_by) {
             case 'title':
                 $list[$key] = $child->title();
                 break;
             case 'date':
                 $list[$key] = $child->date();
                 $sort_flags = SORT_REGULAR;
                 break;
             case 'modified':
                 $list[$key] = $child->modified();
                 $sort_flags = SORT_REGULAR;
                 break;
             case 'slug':
                 $list[$key] = $child->slug();
                 break;
             case 'basename':
                 $list[$key] = basename($key);
                 break;
             case is_string($header_query[0]):
                 $child_header = new Header((array) $child->header());
                 $header_value = $child_header->get($header_query[0]);
                 if ($header_value) {
                     $list[$key] = $header_value;
                 } else {
                     $list[$key] = $header_default ?: $key;
                 }
                 $sort_flags = SORT_REGULAR;
                 break;
             case 'manual':
             case 'default':
             default:
                 $list[$key] = $key;
                 $sort_flags = SORT_REGULAR;
         }
     }
     // handle special case when order_by is random
     if ($order_by == 'random') {
         $list = $this->arrayShuffle($list);
     } else {
         // else just sort the list according to specified key
         if (extension_loaded('intl')) {
             $locale = setlocale(LC_COLLATE, 0);
             //`setlocale` with a 0 param returns the current locale set
             $col = \Collator::create($locale);
             if ($col) {
                 $col->asort($list, $sort_flags);
             } else {
                 asort($list, $sort_flags);
             }
         } else {
             asort($list, $sort_flags);
         }
     }
     // Move manually ordered items into the beginning of the list. Order of the unlisted items does not change.
     if (is_array($manual) && !empty($manual)) {
         $new_list = [];
         $i = count($manual);
         foreach ($list as $key => $dummy) {
             $info = $pages[$key];
             $order = array_search($info['slug'], $manual);
             if ($order === false) {
                 $order = $i++;
             }
             $new_list[$key] = (int) $order;
         }
         $list = $new_list;
         // Apply manual ordering to the list.
         asort($list);
     }
     foreach ($list as $key => $sort) {
         $info = $pages[$key];
         $this->sort[$path][$order_by][$key] = $info;
     }
//.........这里部分代码省略.........
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:101,代码来源:Pages.php

示例8: __construct

 function __construct($locale)
 {
     if (!extension_loaded('intl')) {
         throw new MWException('An ICU collation was requested, ' . 'but the intl extension is not available.');
     }
     $this->locale = $locale;
     $this->mainCollator = Collator::create($locale);
     if (!$this->mainCollator) {
         throw new MWException("Invalid ICU locale specified for collation: {$locale}");
     }
     $this->primaryCollator = Collator::create($locale);
     $this->primaryCollator->setStrength(Collator::PRIMARY);
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:13,代码来源:Collation.php

示例9: __construct

 public function __construct($locale)
 {
     if (!extension_loaded('intl')) {
         throw new MWException('An ICU collation was requested, ' . 'but the intl extension is not available.');
     }
     $this->locale = $locale;
     // Drop everything after the '@' in locale's name
     $localeParts = explode('@', $locale);
     $this->digitTransformLanguage = Language::factory($locale === 'root' ? 'en' : $localeParts[0]);
     $this->mainCollator = Collator::create($locale);
     if (!$this->mainCollator) {
         throw new MWException("Invalid ICU locale specified for collation: {$locale}");
     }
     $this->primaryCollator = Collator::create($locale);
     $this->primaryCollator->setStrength(Collator::PRIMARY);
     // If the special suffix for numeric collation is present, turn on numeric collation.
     if (substr($locale, -5, 5) === '-u-kn') {
         $this->useNumericCollation = true;
         // Strip off the special suffix so it doesn't trip up fetchFirstLetterData().
         $this->locale = substr($this->locale, 0, -5);
         $this->mainCollator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
         $this->primaryCollator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:24,代码来源:IcuCollation.php

示例10: ut_coll_create

function ut_coll_create($locale)
{
    return $GLOBALS['oo-mode'] ? Collator::create($locale) : collator_create($locale);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:4,代码来源:1810.php

示例11: array

<?php

use Karwana\Penelope\Types\Country;
$countries = array();
foreach (Country::getCodes() as $code) {
    $countries[$code] = Country::getName($code, __locale());
}
// Sort by country name using Unicode Collation Algorithm rules.
$collator = \Collator::create('root');
uasort($countries, function ($a, $b) use($collator) {
    return $collator->compare($a, $b);
});
if ($property->getSchema()->isMultiValue()) {
    foreach ((array) $property->getValue() as $value) {
        ?>
<select name="<?php 
        __(_e($property->getName()));
        ?>
[]">
	<option value=""><?php 
        __(_m('option_none'));
        ?>
</option>
<?php 
        foreach ($countries as $code => $name) {
            ?>
	<option value="<?php 
            __($code);
            ?>
"<?php 
            if (0 === strcasecmp($value, $code)) {
开发者ID:karwana,项目名称:penelope,代码行数:31,代码来源:country_input.php


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