15/12/2011 1:39pm

PHP | Problem -


	public function validURLSegment() {

if(self::nested_urls() && $parent = $this->Parent()) {
if($controller = ModelAsController::controller_for($parent)) {
if($controller instanceof Controller && $controller->hasAction($this->URLSegment)) return false;
}
}

if(!self::nested_urls() || !$this->ParentID) {
if(class_exists($this->URLSegment) && is_subclass_of($this->URLSegment, 'RequestHandler')) return false;
}

$IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null;
$parentFilter = null;

if(self::nested_urls()) {
if($this->ParentID) {
$parentFilter = " AND \"SiteTree\".\"ParentID\" = $this->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->URLSegment' $IDFilter $parentFilter $localeFilter"
);
if ($existingPage) {
return false;
}

$values = $this->extend('augmentValidURLSegment');
if (count($values) && !min($values)) {
return false;
}

return true;
}


Post Comment