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/ViewPost.php | 178 +++++++++++++------------- 1 file changed, 89 insertions(+), 89 deletions(-) (limited to 'demos/blog/protected/Pages/Posts/ViewPost.php') diff --git a/demos/blog/protected/Pages/Posts/ViewPost.php b/demos/blog/protected/Pages/Posts/ViewPost.php index 662dc659..5831ba93 100644 --- a/demos/blog/protected/Pages/Posts/ViewPost.php +++ b/demos/blog/protected/Pages/Posts/ViewPost.php @@ -1,90 +1,90 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * ViewPost class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class ViewPost extends BlogPage -{ - private $_post=null; - - public function onInit($param) - { - parent::onInit($param); - $id=TPropertyValue::ensureInteger($this->Request['id']); - $this->_post=$this->DataAccess->queryPostByID($id); - if($this->_post===null) - throw new BlogException(500,'post_id_invalid',$id); - // if post is not published, only the author and admin can view it - if($this->_post->Status!==PostRecord::STATUS_PUBLISHED && $this->_post->Status!==PostRecord::STATUS_STICKY && !$this->User->IsAdmin && $this->User->ID!==$this->_post->AuthorID) - throw new BlogException(500,'post_view_disallowed',$id); - $this->Title=htmlentities($this->_post->Title,ENT_QUOTES,'UTF-8'); - } - - public function getCanEditPost() - { - $user=$this->getUser(); - return $user->getIsAdmin() || $user->getID()===$this->_post->AuthorID; - } - - public function getCurrentPost() - { - return $this->_post; - } - - public function onLoad($param) - { - parent::onLoad($param); - $this->Status->Visible=$this->_post->Status!==PostRecord::STATUS_PUBLISHED && $this->_post->Status!==PostRecord::STATUS_STICKY; - $this->CategoryList->DataSource=$this->DataAccess->queryCategoriesByPostID($this->_post->ID); - $this->CategoryList->dataBind(); - $this->CommentList->DataSource=$this->DataAccess->queryCommentsByPostID($this->_post->ID); - $this->CommentList->dataBind(); - } - - public function submitCommentButtonClicked($sender,$param) - { - if($this->IsValid) - { - $commentRecord=new CommentRecord; - $commentRecord->PostID=$this->CurrentPost->ID; - $commentRecord->AuthorName=$this->CommentAuthor->SafeText; - $commentRecord->AuthorEmail=$this->CommentEmail->Text; - $commentRecord->AuthorWebsite=$this->CommentWebsite->SafeText; - $commentRecord->AuthorIP=$this->Request->UserHostAddress; - $commentRecord->Content=$this->CommentContent->SafeText; - $commentRecord->CreateTime=time(); - $commentRecord->Status=0; - $this->DataAccess->insertComment($commentRecord); - $this->Response->reload(); - } - } - - public function deleteButtonClicked($sender,$param) - { - $this->DataAccess->deletePost($this->CurrentPost->ID); - $this->gotoDefaultPage(); - } - - public function repeaterItemCommand($sender,$param) - { - $id=TPropertyValue::ensureInteger($param->CommandParameter); - $this->DataAccess->deleteComment($id); - $this->Response->reload(); - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * ViewPost class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class ViewPost extends BlogPage +{ + private $_post=null; + + public function onInit($param) + { + parent::onInit($param); + $id=TPropertyValue::ensureInteger($this->Request['id']); + $this->_post=$this->DataAccess->queryPostByID($id); + if($this->_post===null) + throw new BlogException(500,'post_id_invalid',$id); + // if post is not published, only the author and admin can view it + if($this->_post->Status!==PostRecord::STATUS_PUBLISHED && $this->_post->Status!==PostRecord::STATUS_STICKY && !$this->User->IsAdmin && $this->User->ID!==$this->_post->AuthorID) + throw new BlogException(500,'post_view_disallowed',$id); + $this->Title=htmlentities($this->_post->Title,ENT_QUOTES,'UTF-8'); + } + + public function getCanEditPost() + { + $user=$this->getUser(); + return $user->getIsAdmin() || $user->getID()===$this->_post->AuthorID; + } + + public function getCurrentPost() + { + return $this->_post; + } + + public function onLoad($param) + { + parent::onLoad($param); + $this->Status->Visible=$this->_post->Status!==PostRecord::STATUS_PUBLISHED && $this->_post->Status!==PostRecord::STATUS_STICKY; + $this->CategoryList->DataSource=$this->DataAccess->queryCategoriesByPostID($this->_post->ID); + $this->CategoryList->dataBind(); + $this->CommentList->DataSource=$this->DataAccess->queryCommentsByPostID($this->_post->ID); + $this->CommentList->dataBind(); + } + + public function submitCommentButtonClicked($sender,$param) + { + if($this->IsValid) + { + $commentRecord=new CommentRecord; + $commentRecord->PostID=$this->CurrentPost->ID; + $commentRecord->AuthorName=$this->CommentAuthor->SafeText; + $commentRecord->AuthorEmail=$this->CommentEmail->Text; + $commentRecord->AuthorWebsite=$this->CommentWebsite->SafeText; + $commentRecord->AuthorIP=$this->Request->UserHostAddress; + $commentRecord->Content=$this->CommentContent->SafeText; + $commentRecord->CreateTime=time(); + $commentRecord->Status=0; + $this->DataAccess->insertComment($commentRecord); + $this->Response->reload(); + } + } + + public function deleteButtonClicked($sender,$param) + { + $this->DataAccess->deletePost($this->CurrentPost->ID); + $this->gotoDefaultPage(); + } + + public function repeaterItemCommand($sender,$param) + { + $id=TPropertyValue::ensureInteger($param->CommandParameter); + $this->DataAccess->deleteComment($id); + $this->Response->reload(); + } +} + ?> \ No newline at end of file -- cgit v1.2.3