Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/categories/categories_event_handler.php
Show First 20 Lines • Show All 1363 Lines • ▼ Show 20 Line(s) | |||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnClearClipboard($event) | function OnClearClipboard($event) | ||||
{ | { | ||||
$this->Application->RemoveVar('clipboard'); | $this->Application->RemoveVar('clipboard'); | ||||
} | } | ||||
/** | /** | ||||
* Validates category data. | |||||
* | |||||
* @param kEvent $event Event. | |||||
* | |||||
* @return void | |||||
*/ | |||||
protected function OnBeforeItemValidate(kEvent $event) | |||||
{ | |||||
parent::OnBeforeItemValidate($event); | |||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | |||||
$friendly_url = $object->GetDBField('FriendlyURL'); | |||||
if ( strlen($friendly_url) && $friendly_url != $object->GetOriginalField('FriendlyURL') ) { | |||||
$sql = 'SELECT CategoryId | |||||
FROM %s | |||||
WHERE NamedParentPath = ' . $this->Conn->qstr('Content/' . $friendly_url); | |||||
$duplicate_id = $this->Conn->GetOne(sprintf($sql, $object->TableName)); | |||||
if ( $duplicate_id === false && $object->IsTempTable() ) { | |||||
$duplicate_id = $this->Conn->GetOne(sprintf( | |||||
$sql, | |||||
$this->Application->GetLiveName($object->TableName) | |||||
)); | |||||
} | |||||
if ( $duplicate_id !== false ) { | |||||
$object->SetError('FriendlyURL', 'unique'); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* Sets correct status for new categories created on front-end | * Sets correct status for new categories created on front-end | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBeforeItemCreate(kEvent $event) | protected function OnBeforeItemCreate(kEvent $event) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1811 Lines • Show Last 20 Lines |