本文整理匯總了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;
}
示例2: URLSegmentFilter
function testRetainsNonAsciiUrlsWithAllowMultiByteOption() {
$f = new URLSegmentFilter();
$f->setAllowMultibyte(true);
$this->assertEquals(
'brötchen',
$f->filter('Brötchen')
);
}
示例3: testRemovesBadCharactersWithMultibyteAllowed
public function testRemovesBadCharactersWithMultibyteAllowed()
{
$filter = new URLSegmentFilter();
$filter->setAllowMultibyte(true);
$this->assertEquals('url-with-bad-characters', $filter->filter('url?-with/-bad#-characters='));
}
示例4: testReplacesForwardSlashesWithAllowMultiByteOption
public function testReplacesForwardSlashesWithAllowMultiByteOption()
{
$f = new URLSegmentFilter();
$f->setAllowMultibyte(true);
$this->assertEquals(urlencode('this-that'), $f->filter('this/that'));
}