blob: fd2d0707a39d10a2226d070c265b03152f2354b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<?php
class EditCategory extends BlogPage
{
public function getCurrentCategory()
{
$id=TPropertyValue::ensureInteger($this->Request['id']);
if(($cat=$this->DataAccess->queryCategoryByID($id))!==null)
return $cat;
else
throw new BlogException('xxx');
}
public function onLoad($param)
{
parent::onLoad($param);
if(!$this->IsPostBack)
{
$catRecord=$this->getCurrentCategory();
$this->CategoryName->Text=$catRecord->Name;
$this->CategoryDescription->Text=$catRecord->Description;
}
}
public function saveButtonClicked($sender,$param)
{
if($this->IsValid)
{
$categoryRecord=$this->getCurrentCategory();
$categoryRecord->Name=$this->CategoryName->Text;
$categoryRecord->Description=$this->CategoryDescription->Text;
$this->DataAccess->updateCategory($categoryRecord);
$this->gotoPage('Posts.ListPost',array('cat'=>$categoryRecord->ID));
}
}
public function checkCategoryName($sender,$param)
{
$name=$this->CategoryName->Text;
$param->IsValid=$this->DataAccess->queryCategoryByName($name)===null;
}
}
?>
|