From 75f28186a995aa930f6db9f05ec7b63bbd2cd284 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 30 May 2006 03:30:14 +0000 Subject: Merge from 3.0 branch till 1103 --- demos/blog/protected/Pages/Posts/EditCategory.php | 43 ++++++++++++++++------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'demos/blog/protected/Pages/Posts/EditCategory.php') diff --git a/demos/blog/protected/Pages/Posts/EditCategory.php b/demos/blog/protected/Pages/Posts/EditCategory.php index fd2d0707..920d2d80 100644 --- a/demos/blog/protected/Pages/Posts/EditCategory.php +++ b/demos/blog/protected/Pages/Posts/EditCategory.php @@ -1,14 +1,33 @@ + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Revision: $ $Date: $ + */ +/** + * EditCategory class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ class EditCategory extends BlogPage { - public function getCurrentCategory() + private $_category; + + public function onInit($param) { + parent::onInit($param); $id=TPropertyValue::ensureInteger($this->Request['id']); - if(($cat=$this->DataAccess->queryCategoryByID($id))!==null) - return $cat; - else - throw new BlogException('xxx'); + $this->_category=$this->DataAccess->queryCategoryByID($id); + if($this->_category===null) + throw new BlogException(500,'category_id_invalid',$id); } public function onLoad($param) @@ -16,9 +35,8 @@ class EditCategory extends BlogPage parent::onLoad($param); if(!$this->IsPostBack) { - $catRecord=$this->getCurrentCategory(); - $this->CategoryName->Text=$catRecord->Name; - $this->CategoryDescription->Text=$catRecord->Description; + $this->CategoryName->Text=$this->_category->Name; + $this->CategoryDescription->Text=$this->_category->Description; } } @@ -26,11 +44,10 @@ class EditCategory extends BlogPage { 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)); + $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)); } } -- cgit v1.2.3