From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- demos/blog/protected/Pages/Posts/EditPost.php | 154 +++++++++++++------------- 1 file changed, 77 insertions(+), 77 deletions(-) (limited to 'demos/blog/protected/Pages/Posts/EditPost.php') diff --git a/demos/blog/protected/Pages/Posts/EditPost.php b/demos/blog/protected/Pages/Posts/EditPost.php index 8d754b30..3ba6f069 100644 --- a/demos/blog/protected/Pages/Posts/EditPost.php +++ b/demos/blog/protected/Pages/Posts/EditPost.php @@ -1,78 +1,78 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * EditPost class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class EditPost extends BlogPage -{ - private $_postRecord=null; - - public function onInit($param) - { - parent::onInit($param); - $id=TPropertyValue::ensureInteger($this->Request['id']); - $this->_postRecord=$this->DataAccess->queryPostByID($id); - if($this->_postRecord===null) - throw new BlogException(500,'post_id_invalid',$id); - // only the author and admin can edit the post - if(!$this->User->IsAdmin && $this->User->ID!==$this->_postRecord->AuthorID) - throw new BlogException(500,'post_edit_disallowed',$id); - } - - public function onLoad($param) - { - parent::onLoad($param); - if(!$this->IsPostBack) - { - $postRecord=$this->_postRecord; - $this->Title->Text=$postRecord->Title; - $this->Content->Text=$postRecord->Content; - $this->DraftMode->Checked=$postRecord->Status===PostRecord::STATUS_DRAFT; - $this->Categories->DataSource=$this->DataAccess->queryCategories(); - $this->Categories->dataBind(); - $cats=$this->DataAccess->queryCategoriesByPostID($postRecord->ID); - $catIDs=array(); - foreach($cats as $cat) - $catIDs[]=$cat->ID; - $this->Categories->SelectedValues=$catIDs; - } - } - - public function saveButtonClicked($sender,$param) - { - if($this->IsValid) - { - $postRecord=$this->_postRecord; - $postRecord->Title=$this->Title->SafeText; - $postRecord->Content=$this->Content->SafeText; - if($this->DraftMode->Checked) - $postRecord->Status=PostRecord::STATUS_DRAFT; - else if(!$this->User->IsAdmin && TPropertyValue::ensureBoolean($this->Application->Parameters['PostApproval'])) - $postRecord->Status=PostRecord::STATUS_PENDING; - else - $postRecord->Status=PostRecord::STATUS_PUBLISHED; - $postRecord->ModifyTime=time(); - $cats=array(); - foreach($this->Categories->SelectedValues as $value) - $cats[]=TPropertyValue::ensureInteger($value); - $this->DataAccess->updatePost($postRecord,$cats); - $this->gotoPage('Posts.ViewPost',array('id'=>$postRecord->ID)); - } - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * EditPost class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class EditPost extends BlogPage +{ + private $_postRecord=null; + + public function onInit($param) + { + parent::onInit($param); + $id=TPropertyValue::ensureInteger($this->Request['id']); + $this->_postRecord=$this->DataAccess->queryPostByID($id); + if($this->_postRecord===null) + throw new BlogException(500,'post_id_invalid',$id); + // only the author and admin can edit the post + if(!$this->User->IsAdmin && $this->User->ID!==$this->_postRecord->AuthorID) + throw new BlogException(500,'post_edit_disallowed',$id); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $postRecord=$this->_postRecord; + $this->Title->Text=$postRecord->Title; + $this->Content->Text=$postRecord->Content; + $this->DraftMode->Checked=$postRecord->Status===PostRecord::STATUS_DRAFT; + $this->Categories->DataSource=$this->DataAccess->queryCategories(); + $this->Categories->dataBind(); + $cats=$this->DataAccess->queryCategoriesByPostID($postRecord->ID); + $catIDs=array(); + foreach($cats as $cat) + $catIDs[]=$cat->ID; + $this->Categories->SelectedValues=$catIDs; + } + } + + public function saveButtonClicked($sender,$param) + { + if($this->IsValid) + { + $postRecord=$this->_postRecord; + $postRecord->Title=$this->Title->SafeText; + $postRecord->Content=$this->Content->SafeText; + if($this->DraftMode->Checked) + $postRecord->Status=PostRecord::STATUS_DRAFT; + else if(!$this->User->IsAdmin && TPropertyValue::ensureBoolean($this->Application->Parameters['PostApproval'])) + $postRecord->Status=PostRecord::STATUS_PENDING; + else + $postRecord->Status=PostRecord::STATUS_PUBLISHED; + $postRecord->ModifyTime=time(); + $cats=array(); + foreach($this->Categories->SelectedValues as $value) + $cats[]=TPropertyValue::ensureInteger($value); + $this->DataAccess->updatePost($postRecord,$cats); + $this->gotoPage('Posts.ViewPost',array('id'=>$postRecord->ID)); + } + } +} + ?> \ No newline at end of file -- cgit v1.2.3