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


PHP URLSegmentFilter::setAllowMultibyte方法代码示例

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


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

示例1: generateURLSegment

 /**
  * Generates a unique URLSegment from the title.
  *
  * @param int $increment
  *
  * @return string
  */
 public function generateURLSegment($increment = null)
 {
     $filter = new URLSegmentFilter();
     // Setting this to on. Because of the UI flow, it would be quite a lot of work
     // to support turning this off. (ie. the add by title flow would not work).
     // If this becomes a problem we can approach it then.
     // @see https://github.com/silverstripe/silverstripe-blog/issues/376
     $filter->setAllowMultibyte(true);
     $this->owner->URLSegment = $filter->filter($this->owner->Title);
     if (is_int($increment)) {
         $this->owner->URLSegment .= '-' . $increment;
     }
     // Postgres use '' instead of 0 as an emtpy blog ID
     // Without this all the tests fail
     if (!$this->owner->BlogID) {
         $this->owner->BlogID = 0;
     }
     $duplicate = DataList::create($this->owner->ClassName)->filter(array('URLSegment' => $this->owner->URLSegment, 'BlogID' => $this->owner->BlogID));
     if ($this->owner->ID) {
         $duplicate = $duplicate->exclude('ID', $this->owner->ID);
     }
     if ($duplicate->count() > 0) {
         if (is_int($increment)) {
             $increment += 1;
         } else {
             $increment = 0;
         }
         $this->owner->generateURLSegment((int) $increment);
     }
     return $this->owner->URLSegment;
 }
开发者ID:javabrett,项目名称:silverstripe-blog,代码行数:38,代码来源:URLSegmentExtension.php

示例2: URLSegmentFilter

	function testRetainsNonAsciiUrlsWithAllowMultiByteOption() {
		$f = new URLSegmentFilter();
		$f->setAllowMultibyte(true);
		$this->assertEquals(
			'brötchen', 
			$f->filter('Brötchen')
		);
	}
开发者ID:redema,项目名称:sapphire,代码行数:8,代码来源:URLSegmentFilterTest.php

示例3: testRemovesBadCharactersWithMultibyteAllowed

 public function testRemovesBadCharactersWithMultibyteAllowed()
 {
     $filter = new URLSegmentFilter();
     $filter->setAllowMultibyte(true);
     $this->assertEquals('url-with-bad-characters', $filter->filter('url?-with/-bad#-characters='));
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:6,代码来源:URLSegmentFilterTest.php

示例4: testReplacesForwardSlashesWithAllowMultiByteOption

 public function testReplacesForwardSlashesWithAllowMultiByteOption()
 {
     $f = new URLSegmentFilter();
     $f->setAllowMultibyte(true);
     $this->assertEquals(urlencode('this-that'), $f->filter('this/that'));
 }
开发者ID:steiha,项目名称:silverstripe-framework,代码行数:6,代码来源:URLSegmentFilterTest.php


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