本文整理汇总了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'));
}