blob: 326e3c98203346803ba9359b0799eac81c5ab93c (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<?php
/**
* EditCategory class file
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link https://github.com/pradosoft/prado
* @copyright Copyright © 2006-2015 The PRADO Group
* @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
*/
/**
* EditCategory class
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link https://github.com/pradosoft/prado
* @copyright Copyright © 2006-2015 The PRADO Group
* @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
*/
class EditCategory extends BlogPage
{
private $_category;
public function onInit($param)
{
parent::onInit($param);
$id=TPropertyValue::ensureInteger($this->Request['id']);
$this->_category=$this->DataAccess->queryCategoryByID($id);
if($this->_category===null)
throw new BlogException(500,'category_id_invalid',$id);
}
public function onLoad($param)
{
parent::onLoad($param);
if(!$this->IsPostBack)
{
$this->CategoryName->Text=$this->_category->Name;
$this->CategoryDescription->Text=$this->_category->Description;
}
}
public function saveButtonClicked($sender,$param)
{
if($this->IsValid)
{
$this->_category->Name=$this->CategoryName->Text;
$this->_category->Description=$this->CategoryDescription->Text;
$this->DataAccess->updateCategory($this->_category);
$this->gotoPage('Posts.ListPost',array('cat'=>$this->_category->ID));
}
}
public function checkCategoryName($sender,$param)
{
$name=$this->CategoryName->Text;
$param->IsValid=$this->DataAccess->queryCategoryByName($name)===null;
}
}
|