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