15/12/2011 1:41pm

PHP | Problem -


	public function augmentValidURLSegment() {

if (self::locale_filter_enabled()) {
self::disable_locale_filter();
$reEnableFilter = true;
}
$IDFilter = ($this->owner->ID) ? "AND \"SiteTree\".\"ID\" <> {$this->owner->ID}" : null;
$parentFilter = null;

if(SiteTree::nested_urls()) {
if($this->owner->ParentID) {
$parentFilter = " AND \"SiteTree\".\"ParentID\" = {$this->owner->ParentID}";
} else {
$parentFilter = ' AND "SiteTree"."ParentID" = 0';
}
}

$localeFilter = null;
if(Translatable::is_enabled()) {
$localeFilter = ' AND "SiteTree"."Locale" = \'' . Translatable::get_current_locale() . '\'';
}

$existingPage = DataObject::get_one(
'SiteTree',
"\"URLSegment\" = '{$this->owner->URLSegment}' $IDFilter $parentFilter $localeFilter",
false // disable get_one cache, as this otherwise may pick up results from when locale_filter was on
);
if ($reEnableFilter) {
self::enable_locale_filter();
}
return !$existingPage;
}


Post Comment