summaryrefslogtreecommitdiff
path: root/demos/blog/protected/Pages/Posts/ViewPost.php
diff options
context:
space:
mode:
authorctrlaltca <>2012-07-12 11:21:01 +0000
committerctrlaltca <>2012-07-12 11:21:01 +0000
commit903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch)
treee08bf04f0823650a231227ac3499121270172a23 /demos/blog/protected/Pages/Posts/ViewPost.php
parent3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff)
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'demos/blog/protected/Pages/Posts/ViewPost.php')
-rw-r--r--demos/blog/protected/Pages/Posts/ViewPost.php178
1 files changed, 89 insertions, 89 deletions
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 @@
-<?php
-/**
- * ViewPost class file
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * ViewPost class
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 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();
- }
-}
-
+<?php
+/**
+ * ViewPost class file
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * ViewPost class
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 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