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/Admin/AdminMenu.php | 46 ++-- demos/blog/protected/Pages/Admin/ConfigMan.php | 152 ++++++------ demos/blog/protected/Pages/Admin/PostMan.php | 144 +++++------ demos/blog/protected/Pages/Admin/UserMan.php | 148 ++++++------ demos/blog/protected/Pages/ErrorReport.php | 56 ++--- demos/blog/protected/Pages/Posts/EditCategory.php | 120 ++++----- demos/blog/protected/Pages/Posts/EditPost.php | 154 ++++++------ demos/blog/protected/Pages/Posts/ListPost.php | 282 +++++++++++----------- demos/blog/protected/Pages/Posts/MyPost.php | 100 ++++---- demos/blog/protected/Pages/Posts/NewCategory.php | 80 +++--- demos/blog/protected/Pages/Posts/NewPost.php | 112 ++++----- demos/blog/protected/Pages/Posts/ViewPost.php | 178 +++++++------- demos/blog/protected/Pages/SearchPost.php | 134 +++++----- demos/blog/protected/Pages/Users/EditUser.php | 136 +++++------ demos/blog/protected/Pages/Users/NewUser.php | 114 ++++----- demos/blog/protected/Pages/Users/ViewUser.php | 82 +++---- 16 files changed, 1019 insertions(+), 1019 deletions(-) (limited to 'demos/blog/protected/Pages') diff --git a/demos/blog/protected/Pages/Admin/AdminMenu.php b/demos/blog/protected/Pages/Admin/AdminMenu.php index a631d5b5..4687a5ce 100644 --- a/demos/blog/protected/Pages/Admin/AdminMenu.php +++ b/demos/blog/protected/Pages/Admin/AdminMenu.php @@ -1,24 +1,24 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * AdminMenu class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class AdminMenu extends TTemplateControl -{ -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * AdminMenu class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class AdminMenu extends TTemplateControl +{ +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/Admin/ConfigMan.php b/demos/blog/protected/Pages/Admin/ConfigMan.php index 61516c27..c60a04e8 100644 --- a/demos/blog/protected/Pages/Admin/ConfigMan.php +++ b/demos/blog/protected/Pages/Admin/ConfigMan.php @@ -1,77 +1,77 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * ConfigMan class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class ConfigMan extends BlogPage -{ - const CONFIG_FILE='Application.Data.Settings'; - - public function onLoad($param) - { - parent::onLoad($param); - if(!$this->IsPostBack) - { - $parameters=$this->Application->Parameters; - $this->SiteTitle->Text=$parameters['SiteTitle']; - $this->SiteSubtitle->Text=$parameters['SiteSubtitle']; - $this->SiteOwner->Text=$parameters['SiteOwner']; - $this->AdminEmail->Text=$parameters['AdminEmail']; - $this->MultipleUser->Checked=TPropertyValue::ensureBoolean($parameters['MultipleUser']); - $this->AccountApproval->Checked=TPropertyValue::ensureBoolean($parameters['AccountApproval']); - $this->PostPerPage->Text=$parameters['PostPerPage']; - $this->RecentComments->Text=$parameters['RecentComments']; - $this->PostApproval->Checked=TPropertyValue::ensureBoolean($parameters['PostApproval']); - $themes=$this->Service->ThemeManager->AvailableThemes; - $this->ThemeName->DataSource=$themes; - $this->ThemeName->dataBind(); - $this->ThemeName->SelectedValue=array_search($parameters['ThemeName'],$themes); - } - } - - public function saveButtonClicked($sender,$param) - { - $dom=new TXmlDocument; - $dom->Encoding='utf-8'; - $dom->TagName='parameters'; - $elements=$dom->Elements; - $elements[]=$this->createParameter('SiteTitle',$this->SiteTitle->Text); - $elements[]=$this->createParameter('SiteSubtitle',$this->SiteSubtitle->Text); - $elements[]=$this->createParameter('SiteOwner',$this->SiteOwner->Text); - $elements[]=$this->createParameter('AdminEmail',$this->AdminEmail->Text); - $elements[]=$this->createParameter('MultipleUser',$this->MultipleUser->Checked); - $elements[]=$this->createParameter('AccountApproval',$this->AccountApproval->Checked); - $elements[]=$this->createParameter('PostPerPage',$this->PostPerPage->Text); - $elements[]=$this->createParameter('RecentComments',$this->RecentComments->Text); - $elements[]=$this->createParameter('PostApproval',$this->PostApproval->Checked); - $themeName=$this->ThemeName->SelectedItem->Text; - $elements[]=$this->createParameter('ThemeName',$themeName); - $dom->saveToFile(Prado::getPathOfNamespace(self::CONFIG_FILE,'.xml')); - if($themeName!==$this->Theme->Name) - $this->Response->reload(); - } - - private function createParameter($id,$value) - { - $element=new TXmlElement('parameter'); - $element->Attributes['id']=$id; - $element->Attributes['value']=TPropertyValue::ensureString($value); - return $element; - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * ConfigMan class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class ConfigMan extends BlogPage +{ + const CONFIG_FILE='Application.Data.Settings'; + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $parameters=$this->Application->Parameters; + $this->SiteTitle->Text=$parameters['SiteTitle']; + $this->SiteSubtitle->Text=$parameters['SiteSubtitle']; + $this->SiteOwner->Text=$parameters['SiteOwner']; + $this->AdminEmail->Text=$parameters['AdminEmail']; + $this->MultipleUser->Checked=TPropertyValue::ensureBoolean($parameters['MultipleUser']); + $this->AccountApproval->Checked=TPropertyValue::ensureBoolean($parameters['AccountApproval']); + $this->PostPerPage->Text=$parameters['PostPerPage']; + $this->RecentComments->Text=$parameters['RecentComments']; + $this->PostApproval->Checked=TPropertyValue::ensureBoolean($parameters['PostApproval']); + $themes=$this->Service->ThemeManager->AvailableThemes; + $this->ThemeName->DataSource=$themes; + $this->ThemeName->dataBind(); + $this->ThemeName->SelectedValue=array_search($parameters['ThemeName'],$themes); + } + } + + public function saveButtonClicked($sender,$param) + { + $dom=new TXmlDocument; + $dom->Encoding='utf-8'; + $dom->TagName='parameters'; + $elements=$dom->Elements; + $elements[]=$this->createParameter('SiteTitle',$this->SiteTitle->Text); + $elements[]=$this->createParameter('SiteSubtitle',$this->SiteSubtitle->Text); + $elements[]=$this->createParameter('SiteOwner',$this->SiteOwner->Text); + $elements[]=$this->createParameter('AdminEmail',$this->AdminEmail->Text); + $elements[]=$this->createParameter('MultipleUser',$this->MultipleUser->Checked); + $elements[]=$this->createParameter('AccountApproval',$this->AccountApproval->Checked); + $elements[]=$this->createParameter('PostPerPage',$this->PostPerPage->Text); + $elements[]=$this->createParameter('RecentComments',$this->RecentComments->Text); + $elements[]=$this->createParameter('PostApproval',$this->PostApproval->Checked); + $themeName=$this->ThemeName->SelectedItem->Text; + $elements[]=$this->createParameter('ThemeName',$themeName); + $dom->saveToFile(Prado::getPathOfNamespace(self::CONFIG_FILE,'.xml')); + if($themeName!==$this->Theme->Name) + $this->Response->reload(); + } + + private function createParameter($id,$value) + { + $element=new TXmlElement('parameter'); + $element->Attributes['id']=$id; + $element->Attributes['value']=TPropertyValue::ensureString($value); + return $element; + } +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/Admin/PostMan.php b/demos/blog/protected/Pages/Admin/PostMan.php index bf6597b1..c2ceb73f 100644 --- a/demos/blog/protected/Pages/Admin/PostMan.php +++ b/demos/blog/protected/Pages/Admin/PostMan.php @@ -1,73 +1,73 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * PostMan class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class PostMan extends BlogPage -{ - protected function bindData() - { - $offset=$this->PostGrid->CurrentPageIndex*$this->PostGrid->PageSize; - $limit=$this->PostGrid->PageSize; - $this->PostGrid->DataSource=$this->DataAccess->queryPosts('','','ORDER BY a.status DESC, modify_time DESC',"LIMIT $offset,$limit"); - $this->PostGrid->VirtualItemCount=$this->DataAccess->queryPostCount('',''); - $this->PostGrid->dataBind(); - } - - public function onLoad($param) - { - parent::onLoad($param); - if(!$this->IsPostBack) - $this->bindData(); - } - - public function changePage($sender,$param) - { - $this->PostGrid->CurrentPageIndex=$param->NewPageIndex; - $this->bindData(); - } - - public function pagerCreated($sender,$param) - { - $param->Pager->Controls->insertAt(0,'Page: '); - } - - public function editItem($sender,$param) - { - $this->PostGrid->EditItemIndex=$param->Item->ItemIndex; - $this->bindData(); - } - - public function saveItem($sender,$param) - { - $item=$param->Item; - $postID=$this->PostGrid->DataKeys[$item->ItemIndex]; - $postRecord=$this->DataAccess->queryPostByID($postID); - $postRecord->Status=TPropertyValue::ensureInteger($item->Cells[2]->PostStatus->SelectedValue); - $this->DataAccess->updatePost($postRecord); - $this->PostGrid->EditItemIndex=-1; - $this->bindData(); - } - - public function cancelItem($sender,$param) - { - $this->PostGrid->EditItemIndex=-1; - $this->bindData(); - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * PostMan class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class PostMan extends BlogPage +{ + protected function bindData() + { + $offset=$this->PostGrid->CurrentPageIndex*$this->PostGrid->PageSize; + $limit=$this->PostGrid->PageSize; + $this->PostGrid->DataSource=$this->DataAccess->queryPosts('','','ORDER BY a.status DESC, modify_time DESC',"LIMIT $offset,$limit"); + $this->PostGrid->VirtualItemCount=$this->DataAccess->queryPostCount('',''); + $this->PostGrid->dataBind(); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + $this->bindData(); + } + + public function changePage($sender,$param) + { + $this->PostGrid->CurrentPageIndex=$param->NewPageIndex; + $this->bindData(); + } + + public function pagerCreated($sender,$param) + { + $param->Pager->Controls->insertAt(0,'Page: '); + } + + public function editItem($sender,$param) + { + $this->PostGrid->EditItemIndex=$param->Item->ItemIndex; + $this->bindData(); + } + + public function saveItem($sender,$param) + { + $item=$param->Item; + $postID=$this->PostGrid->DataKeys[$item->ItemIndex]; + $postRecord=$this->DataAccess->queryPostByID($postID); + $postRecord->Status=TPropertyValue::ensureInteger($item->Cells[2]->PostStatus->SelectedValue); + $this->DataAccess->updatePost($postRecord); + $this->PostGrid->EditItemIndex=-1; + $this->bindData(); + } + + public function cancelItem($sender,$param) + { + $this->PostGrid->EditItemIndex=-1; + $this->bindData(); + } +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/Admin/UserMan.php b/demos/blog/protected/Pages/Admin/UserMan.php index 5901c334..231f6c84 100644 --- a/demos/blog/protected/Pages/Admin/UserMan.php +++ b/demos/blog/protected/Pages/Admin/UserMan.php @@ -1,75 +1,75 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * UserMan class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class UserMan extends BlogPage -{ - protected function bindData() - { - $author=$this->User->ID; - $offset=$this->UserGrid->CurrentPageIndex*$this->UserGrid->PageSize; - $limit=$this->UserGrid->PageSize; - $this->UserGrid->DataSource=$this->DataAccess->queryUsers('','ORDER BY status DESC, name ASC',"LIMIT $offset,$limit"); - $this->UserGrid->VirtualItemCount=$this->DataAccess->queryUserCount(''); - $this->UserGrid->dataBind(); - } - - public function onLoad($param) - { - parent::onLoad($param); - if(!$this->IsPostBack) - $this->bindData(); - } - - public function changePage($sender,$param) - { - $this->UserGrid->CurrentPageIndex=$param->NewPageIndex; - $this->bindData(); - } - - public function pagerCreated($sender,$param) - { - $param->Pager->Controls->insertAt(0,'Page: '); - } - - public function editItem($sender,$param) - { - $this->UserGrid->EditItemIndex=$param->Item->ItemIndex; - $this->bindData(); - } - - public function saveItem($sender,$param) - { - $item=$param->Item; - $userID=$this->UserGrid->DataKeys[$item->ItemIndex]; - $userRecord=$this->DataAccess->queryUserByID($userID); - $userRecord->Role=TPropertyValue::ensureInteger($item->Cells[1]->UserRole->SelectedValue); - $userRecord->Status=TPropertyValue::ensureInteger($item->Cells[2]->UserStatus->SelectedValue); - $this->DataAccess->updateUser($userRecord); - $this->UserGrid->EditItemIndex=-1; - $this->bindData(); - } - - public function cancelItem($sender,$param) - { - $this->UserGrid->EditItemIndex=-1; - $this->bindData(); - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * UserMan class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class UserMan extends BlogPage +{ + protected function bindData() + { + $author=$this->User->ID; + $offset=$this->UserGrid->CurrentPageIndex*$this->UserGrid->PageSize; + $limit=$this->UserGrid->PageSize; + $this->UserGrid->DataSource=$this->DataAccess->queryUsers('','ORDER BY status DESC, name ASC',"LIMIT $offset,$limit"); + $this->UserGrid->VirtualItemCount=$this->DataAccess->queryUserCount(''); + $this->UserGrid->dataBind(); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + $this->bindData(); + } + + public function changePage($sender,$param) + { + $this->UserGrid->CurrentPageIndex=$param->NewPageIndex; + $this->bindData(); + } + + public function pagerCreated($sender,$param) + { + $param->Pager->Controls->insertAt(0,'Page: '); + } + + public function editItem($sender,$param) + { + $this->UserGrid->EditItemIndex=$param->Item->ItemIndex; + $this->bindData(); + } + + public function saveItem($sender,$param) + { + $item=$param->Item; + $userID=$this->UserGrid->DataKeys[$item->ItemIndex]; + $userRecord=$this->DataAccess->queryUserByID($userID); + $userRecord->Role=TPropertyValue::ensureInteger($item->Cells[1]->UserRole->SelectedValue); + $userRecord->Status=TPropertyValue::ensureInteger($item->Cells[2]->UserStatus->SelectedValue); + $this->DataAccess->updateUser($userRecord); + $this->UserGrid->EditItemIndex=-1; + $this->bindData(); + } + + public function cancelItem($sender,$param) + { + $this->UserGrid->EditItemIndex=-1; + $this->bindData(); + } +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/ErrorReport.php b/demos/blog/protected/Pages/ErrorReport.php index 50d4a047..2b086f5f 100644 --- a/demos/blog/protected/Pages/ErrorReport.php +++ b/demos/blog/protected/Pages/ErrorReport.php @@ -1,29 +1,29 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * ErrorReport class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class ErrorReport extends BlogPage -{ - public function onLoad($param) - { - parent::onLoad($param); - $this->ErrorMessage->Text=$this->Application->SecurityManager->validateData(urldecode($this->Request['msg'])); - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * ErrorReport class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class ErrorReport extends BlogPage +{ + public function onLoad($param) + { + parent::onLoad($param); + $this->ErrorMessage->Text=$this->Application->SecurityManager->validateData(urldecode($this->Request['msg'])); + } +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/Posts/EditCategory.php b/demos/blog/protected/Pages/Posts/EditCategory.php index 76013264..d60418be 100644 --- a/demos/blog/protected/Pages/Posts/EditCategory.php +++ b/demos/blog/protected/Pages/Posts/EditCategory.php @@ -1,61 +1,61 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * EditCategory class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -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; - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * EditCategory class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +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; + } +} + ?> \ No newline at end of file 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 diff --git a/demos/blog/protected/Pages/Posts/ListPost.php b/demos/blog/protected/Pages/Posts/ListPost.php index 0e0a044c..7ff9dac9 100644 --- a/demos/blog/protected/Pages/Posts/ListPost.php +++ b/demos/blog/protected/Pages/Posts/ListPost.php @@ -1,142 +1,142 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * ListPost class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class ListPost extends BlogPage -{ - private $_posts; - private $_category; - - public function onInit($param) - { - parent::onInit($param); - $this->_posts=$this->DataAccess->queryPosts( - $this->getPostFilter(), - $this->getCategoryFilter(), - 'ORDER BY a.status DESC, create_time DESC', - 'LIMIT '.$this->getPageOffset().','.$this->getPageSize()); - if($this->Request['cat']!==null) - { - $catID=TPropertyValue::ensureInteger($this->Request['cat']); - $this->_category=$this->DataAccess->queryCategoryByID($catID); - $this->CategoryPanel->Visible=true; - } - $this->Title=$this->Application->Parameters['SiteTitle']; - } - - private function getPageOffset() - { - if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0) - $offset=0; - return $offset; - } - - private function getPageSize() - { - if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0) - $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']); - return $limit; - } - - private function getTimeFilter() - { - if(($time=TPropertyValue::ensureInteger($this->Request['time']))>0) - { - $year=(integer)($time/100); - $month=$time%100; - $startTime=mktime(0,0,0,$month,1,$year); - if(++$month>12) - { - $month=1; - $year++; - } - $endTime=mktime(0,0,0,$month,1,$year); - return "create_time>=$startTime AND create_time<$endTime"; - } - else - return ''; - } - - private function getPostFilter() - { - $filter='(a.status=0 OR a.status=3)'; - if(($timeFilter=$this->getTimeFilter())!=='') - return "$filter AND $timeFilter"; - else - return $filter; - } - - private function getCategoryFilter() - { - if(($catID=$this->Request['cat'])!==null) - { - $catID=TPropertyValue::ensureInteger($catID); - return "category_id=$catID"; - } - else - return ''; - } - - private function formUrl($newOffset) - { - $gets=array(); - $gets['offset']=$newOffset; - if($this->Request['limit']!==null) - $gets['limit']=$this->Request['limit']; - if($this->Request['time']!==null) - $gets['time']=$this->Request['time']; - if($this->Request['cat']!==null) - $gets['cat']=$this->Request['cat']; - return $this->Service->constructUrl('Posts.ListPost',$gets); - } - - public function getCategory() - { - return $this->_category; - } - - public function onLoad($param) - { - parent::onLoad($param); - $this->PostList->DataSource=$this->_posts; - $this->PostList->dataBind(); - if($this->getPageOffset()>0) - { - if(($offset=$this->getPageOffset()-$this->getPageSize())<0) - $offset=0; - $this->PrevPage->NavigateUrl=$this->formUrl($offset); - $this->PrevPage->Visible=true; - } - if(count($this->_posts)===$this->getPageSize()) - { - $this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize()); - $this->NextPage->Visible=true; - } - } - - public function deleteButtonClicked($sender,$param) - { - if($this->User->IsAdmin) - { - $this->DataAccess->deleteCategory($this->Category->ID); - $this->gotoDefaultPage(); - } - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * ListPost class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class ListPost extends BlogPage +{ + private $_posts; + private $_category; + + public function onInit($param) + { + parent::onInit($param); + $this->_posts=$this->DataAccess->queryPosts( + $this->getPostFilter(), + $this->getCategoryFilter(), + 'ORDER BY a.status DESC, create_time DESC', + 'LIMIT '.$this->getPageOffset().','.$this->getPageSize()); + if($this->Request['cat']!==null) + { + $catID=TPropertyValue::ensureInteger($this->Request['cat']); + $this->_category=$this->DataAccess->queryCategoryByID($catID); + $this->CategoryPanel->Visible=true; + } + $this->Title=$this->Application->Parameters['SiteTitle']; + } + + private function getPageOffset() + { + if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0) + $offset=0; + return $offset; + } + + private function getPageSize() + { + if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0) + $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']); + return $limit; + } + + private function getTimeFilter() + { + if(($time=TPropertyValue::ensureInteger($this->Request['time']))>0) + { + $year=(integer)($time/100); + $month=$time%100; + $startTime=mktime(0,0,0,$month,1,$year); + if(++$month>12) + { + $month=1; + $year++; + } + $endTime=mktime(0,0,0,$month,1,$year); + return "create_time>=$startTime AND create_time<$endTime"; + } + else + return ''; + } + + private function getPostFilter() + { + $filter='(a.status=0 OR a.status=3)'; + if(($timeFilter=$this->getTimeFilter())!=='') + return "$filter AND $timeFilter"; + else + return $filter; + } + + private function getCategoryFilter() + { + if(($catID=$this->Request['cat'])!==null) + { + $catID=TPropertyValue::ensureInteger($catID); + return "category_id=$catID"; + } + else + return ''; + } + + private function formUrl($newOffset) + { + $gets=array(); + $gets['offset']=$newOffset; + if($this->Request['limit']!==null) + $gets['limit']=$this->Request['limit']; + if($this->Request['time']!==null) + $gets['time']=$this->Request['time']; + if($this->Request['cat']!==null) + $gets['cat']=$this->Request['cat']; + return $this->Service->constructUrl('Posts.ListPost',$gets); + } + + public function getCategory() + { + return $this->_category; + } + + public function onLoad($param) + { + parent::onLoad($param); + $this->PostList->DataSource=$this->_posts; + $this->PostList->dataBind(); + if($this->getPageOffset()>0) + { + if(($offset=$this->getPageOffset()-$this->getPageSize())<0) + $offset=0; + $this->PrevPage->NavigateUrl=$this->formUrl($offset); + $this->PrevPage->Visible=true; + } + if(count($this->_posts)===$this->getPageSize()) + { + $this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize()); + $this->NextPage->Visible=true; + } + } + + public function deleteButtonClicked($sender,$param) + { + if($this->User->IsAdmin) + { + $this->DataAccess->deleteCategory($this->Category->ID); + $this->gotoDefaultPage(); + } + } +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/Posts/MyPost.php b/demos/blog/protected/Pages/Posts/MyPost.php index fd65cc57..7d0be020 100644 --- a/demos/blog/protected/Pages/Posts/MyPost.php +++ b/demos/blog/protected/Pages/Posts/MyPost.php @@ -1,51 +1,51 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * MyPost class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class MyPost extends BlogPage -{ - protected function bindData() - { - $author=$this->User->ID; - $offset=$this->PostGrid->CurrentPageIndex*$this->PostGrid->PageSize; - $limit=$this->PostGrid->PageSize; - $this->PostGrid->DataSource=$this->DataAccess->queryPosts("author_id=$author",'','ORDER BY a.status DESC, create_time DESC',"LIMIT $offset,$limit"); - $this->PostGrid->VirtualItemCount=$this->DataAccess->queryPostCount("author_id=$author",''); - $this->PostGrid->dataBind(); - } - - public function onLoad($param) - { - parent::onLoad($param); - if(!$this->IsPostBack) - $this->bindData(); - } - - public function changePage($sender,$param) - { - $this->PostGrid->CurrentPageIndex=$param->NewPageIndex; - $this->bindData(); - } - - public function pagerCreated($sender,$param) - { - $param->Pager->Controls->insertAt(0,'Page: '); - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * MyPost class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class MyPost extends BlogPage +{ + protected function bindData() + { + $author=$this->User->ID; + $offset=$this->PostGrid->CurrentPageIndex*$this->PostGrid->PageSize; + $limit=$this->PostGrid->PageSize; + $this->PostGrid->DataSource=$this->DataAccess->queryPosts("author_id=$author",'','ORDER BY a.status DESC, create_time DESC',"LIMIT $offset,$limit"); + $this->PostGrid->VirtualItemCount=$this->DataAccess->queryPostCount("author_id=$author",''); + $this->PostGrid->dataBind(); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + $this->bindData(); + } + + public function changePage($sender,$param) + { + $this->PostGrid->CurrentPageIndex=$param->NewPageIndex; + $this->bindData(); + } + + public function pagerCreated($sender,$param) + { + $param->Pager->Controls->insertAt(0,'Page: '); + } +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/Posts/NewCategory.php b/demos/blog/protected/Pages/Posts/NewCategory.php index 5df0c85b..b5bf26e9 100644 --- a/demos/blog/protected/Pages/Posts/NewCategory.php +++ b/demos/blog/protected/Pages/Posts/NewCategory.php @@ -1,41 +1,41 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * NewCategory class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class NewCategory extends BlogPage -{ - public function saveButtonClicked($sender,$param) - { - if($this->IsValid) - { - $categoryRecord=new CategoryRecord; - $categoryRecord->Name=$this->CategoryName->Text; - $categoryRecord->Description=$this->CategoryDescription->Text; - $this->DataAccess->insertCategory($categoryRecord); - $this->gotoPage('Posts.ListPost',array('cat'=>$categoryRecord->ID)); - } - } - - public function checkCategoryName($sender,$param) - { - $name=$this->CategoryName->Text; - $param->IsValid=$this->DataAccess->queryCategoryByName($name)===null; - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * NewCategory class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class NewCategory extends BlogPage +{ + public function saveButtonClicked($sender,$param) + { + if($this->IsValid) + { + $categoryRecord=new CategoryRecord; + $categoryRecord->Name=$this->CategoryName->Text; + $categoryRecord->Description=$this->CategoryDescription->Text; + $this->DataAccess->insertCategory($categoryRecord); + $this->gotoPage('Posts.ListPost',array('cat'=>$categoryRecord->ID)); + } + } + + public function checkCategoryName($sender,$param) + { + $name=$this->CategoryName->Text; + $param->IsValid=$this->DataAccess->queryCategoryByName($name)===null; + } +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/Posts/NewPost.php b/demos/blog/protected/Pages/Posts/NewPost.php index 2f894cd5..45b1a794 100644 --- a/demos/blog/protected/Pages/Posts/NewPost.php +++ b/demos/blog/protected/Pages/Posts/NewPost.php @@ -1,57 +1,57 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * NewPost class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class NewPost extends BlogPage -{ - public function onLoad($param) - { - parent::onLoad($param); - if(!$this->IsPostBack) - { - $this->Categories->DataSource=$this->DataAccess->queryCategories(); - $this->Categories->dataBind(); - } - } - - public function saveButtonClicked($sender,$param) - { - if($this->IsValid) - { - $postRecord=new 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->CreateTime=time(); - $postRecord->ModifyTime=$postRecord->CreateTime; - $postRecord->AuthorID=$this->User->ID; - $cats=array(); - foreach($this->Categories->SelectedValues as $value) - $cats[]=TPropertyValue::ensureInteger($value); - $this->DataAccess->insertPost($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$ + */ + +/** + * NewPost class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class NewPost extends BlogPage +{ + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->Categories->DataSource=$this->DataAccess->queryCategories(); + $this->Categories->dataBind(); + } + } + + public function saveButtonClicked($sender,$param) + { + if($this->IsValid) + { + $postRecord=new 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->CreateTime=time(); + $postRecord->ModifyTime=$postRecord->CreateTime; + $postRecord->AuthorID=$this->User->ID; + $cats=array(); + foreach($this->Categories->SelectedValues as $value) + $cats[]=TPropertyValue::ensureInteger($value); + $this->DataAccess->insertPost($postRecord,$cats); + $this->gotoPage('Posts.ViewPost',array('id'=>$postRecord->ID)); + } + } +} + ?> \ No newline at end of file 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 diff --git a/demos/blog/protected/Pages/SearchPost.php b/demos/blog/protected/Pages/SearchPost.php index dc483f9a..437435f9 100644 --- a/demos/blog/protected/Pages/SearchPost.php +++ b/demos/blog/protected/Pages/SearchPost.php @@ -1,68 +1,68 @@ -_posts=$this->DataAccess->queryPostsSearch( - $this->getPostKeywords(), - 'ORDER BY create_time DESC', - 'LIMIT '.$this->getPageOffset().','.$this->getPageSize()); - } - - private function getPostKeywords() - { - return explode(' ',$this->Request['keyword']); - } - - private function getPageOffset() - { - if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0) - $offset=0; - return $offset; - } - - private function getPageSize() - { - if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0) - $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']); - return $limit; - } - - private function formUrl($newOffset) - { - $gets=array(); - $gets['offset']=$newOffset; - if($this->Request['limit']!==null) - $gets['limit']=$this->Request['limit']; - if($this->Request['time']!==null) - $gets['time']=$this->Request['time']; - if($this->Request['cat']!==null) - $gets['cat']=$this->Request['cat']; - return $this->Service->constructUrl('Posts.ListPost',$gets); - } - - public function onLoad($param) - { - parent::onLoad($param); - $this->PostList->DataSource=$this->_posts; - $this->PostList->dataBind(); - if($this->getPageOffset()>0) - { - if(($offset=$this->getPageOffset()-$this->getPageSize())<0) - $offset=0; - $this->PrevPage->NavigateUrl=$this->formUrl($offset); - $this->PrevPage->Visible=true; - } - if(count($this->_posts)===$this->getPageSize()) - { - $this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize()); - $this->NextPage->Visible=true; - } - } -} - +_posts=$this->DataAccess->queryPostsSearch( + $this->getPostKeywords(), + 'ORDER BY create_time DESC', + 'LIMIT '.$this->getPageOffset().','.$this->getPageSize()); + } + + private function getPostKeywords() + { + return explode(' ',$this->Request['keyword']); + } + + private function getPageOffset() + { + if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0) + $offset=0; + return $offset; + } + + private function getPageSize() + { + if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0) + $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']); + return $limit; + } + + private function formUrl($newOffset) + { + $gets=array(); + $gets['offset']=$newOffset; + if($this->Request['limit']!==null) + $gets['limit']=$this->Request['limit']; + if($this->Request['time']!==null) + $gets['time']=$this->Request['time']; + if($this->Request['cat']!==null) + $gets['cat']=$this->Request['cat']; + return $this->Service->constructUrl('Posts.ListPost',$gets); + } + + public function onLoad($param) + { + parent::onLoad($param); + $this->PostList->DataSource=$this->_posts; + $this->PostList->dataBind(); + if($this->getPageOffset()>0) + { + if(($offset=$this->getPageOffset()-$this->getPageSize())<0) + $offset=0; + $this->PrevPage->NavigateUrl=$this->formUrl($offset); + $this->PrevPage->Visible=true; + } + if(count($this->_posts)===$this->getPageSize()) + { + $this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize()); + $this->NextPage->Visible=true; + } + } +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/Users/EditUser.php b/demos/blog/protected/Pages/Users/EditUser.php index c574ca6b..8d5cb090 100644 --- a/demos/blog/protected/Pages/Users/EditUser.php +++ b/demos/blog/protected/Pages/Users/EditUser.php @@ -1,69 +1,69 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * EditUser class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class EditUser extends BlogPage -{ - private $_userRecord=null; - - public function onInit($param) - { - parent::onInit($param); - if(($id=$this->Request['id'])!==null) - { - $id=TPropertyValue::ensureInteger($id); - if(!$this->User->IsAdmin && $this->User->ID!==$id) - throw new BlogException(500,'profile_edit_disallowed',$id); - } - else - $id=$this->User->ID; - if(($this->_userRecord=$this->DataAccess->queryUserByID($id))===null) - throw new BlogException(500,'profile_id_invalid',$id); - } - - public function onLoad($param) - { - parent::onLoad($param); - if(!$this->IsPostBack) - { - $userRecord=$this->_userRecord; - $this->Username->Text=$userRecord->Name; - $this->FullName->Text=$userRecord->FullName; - $this->Email->Text=$userRecord->Email; - $this->Website->Text=$userRecord->Website; - } - } - - public function saveButtonClicked($sender,$param) - { - if($this->IsValid) - { - $userRecord=$this->_userRecord; - if($this->Password->Text!=='') - $userRecord->Password=md5($this->Password->Text); - $userRecord->FullName=$this->FullName->Text; - $userRecord->Email=$this->Email->Text; - $userRecord->Website=$this->Website->Text; - $this->DataAccess->updateUser($userRecord); - $authManager=$this->Application->getModule('auth'); - $this->gotoPage('Users.ViewUser',array('id'=>$userRecord->ID)); - } - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * EditUser class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class EditUser extends BlogPage +{ + private $_userRecord=null; + + public function onInit($param) + { + parent::onInit($param); + if(($id=$this->Request['id'])!==null) + { + $id=TPropertyValue::ensureInteger($id); + if(!$this->User->IsAdmin && $this->User->ID!==$id) + throw new BlogException(500,'profile_edit_disallowed',$id); + } + else + $id=$this->User->ID; + if(($this->_userRecord=$this->DataAccess->queryUserByID($id))===null) + throw new BlogException(500,'profile_id_invalid',$id); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $userRecord=$this->_userRecord; + $this->Username->Text=$userRecord->Name; + $this->FullName->Text=$userRecord->FullName; + $this->Email->Text=$userRecord->Email; + $this->Website->Text=$userRecord->Website; + } + } + + public function saveButtonClicked($sender,$param) + { + if($this->IsValid) + { + $userRecord=$this->_userRecord; + if($this->Password->Text!=='') + $userRecord->Password=md5($this->Password->Text); + $userRecord->FullName=$this->FullName->Text; + $userRecord->Email=$this->Email->Text; + $userRecord->Website=$this->Website->Text; + $this->DataAccess->updateUser($userRecord); + $authManager=$this->Application->getModule('auth'); + $this->gotoPage('Users.ViewUser',array('id'=>$userRecord->ID)); + } + } +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/Users/NewUser.php b/demos/blog/protected/Pages/Users/NewUser.php index 40e79910..50f9f123 100644 --- a/demos/blog/protected/Pages/Users/NewUser.php +++ b/demos/blog/protected/Pages/Users/NewUser.php @@ -1,58 +1,58 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * NewUser class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class NewUser extends BlogPage -{ - public function onInit($param) - { - if(!$this->User->IsAdmin && !TPropertyValue::ensureBoolean($this->Application->Parameters['MultipleUser'])) - throw new BlogException(500,'newuser_registration_disallowed'); - } - - public function checkUsername($sender,$param) - { - $username=strtolower($this->Username->Text); - $param->IsValid=$this->DataAccess->queryUserByName($username)===null; - } - - public function createUser($sender,$param) - { - if($this->IsValid) - { - $userRecord=new UserRecord; - $userRecord->Name=strtolower($this->Username->Text); - $userRecord->FullName=$this->FullName->Text; - $userRecord->Role=0; - $userRecord->Password=md5($this->Password->Text); - $userRecord->Email=$this->Email->Text; - $userRecord->CreateTime=time(); - $userRecord->Website=$this->Website->Text; - if(TPropertyValue::ensureBoolean($this->Application->Parameters['AccountApproval'])) - $userRecord->Status=UserRecord::STATUS_PENDING; - else - $userRecord->Status=UserRecord::STATUS_NORMAL; - $this->DataAccess->insertUser($userRecord); - $authManager=$this->Application->getModule('auth'); - $authManager->login($this->Username->Text,$this->Password->Text); - $this->gotoDefaultPage(); - } - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * NewUser class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class NewUser extends BlogPage +{ + public function onInit($param) + { + if(!$this->User->IsAdmin && !TPropertyValue::ensureBoolean($this->Application->Parameters['MultipleUser'])) + throw new BlogException(500,'newuser_registration_disallowed'); + } + + public function checkUsername($sender,$param) + { + $username=strtolower($this->Username->Text); + $param->IsValid=$this->DataAccess->queryUserByName($username)===null; + } + + public function createUser($sender,$param) + { + if($this->IsValid) + { + $userRecord=new UserRecord; + $userRecord->Name=strtolower($this->Username->Text); + $userRecord->FullName=$this->FullName->Text; + $userRecord->Role=0; + $userRecord->Password=md5($this->Password->Text); + $userRecord->Email=$this->Email->Text; + $userRecord->CreateTime=time(); + $userRecord->Website=$this->Website->Text; + if(TPropertyValue::ensureBoolean($this->Application->Parameters['AccountApproval'])) + $userRecord->Status=UserRecord::STATUS_PENDING; + else + $userRecord->Status=UserRecord::STATUS_NORMAL; + $this->DataAccess->insertUser($userRecord); + $authManager=$this->Application->getModule('auth'); + $authManager->login($this->Username->Text,$this->Password->Text); + $this->gotoDefaultPage(); + } + } +} + ?> \ No newline at end of file diff --git a/demos/blog/protected/Pages/Users/ViewUser.php b/demos/blog/protected/Pages/Users/ViewUser.php index 75bd711a..86c27592 100644 --- a/demos/blog/protected/Pages/Users/ViewUser.php +++ b/demos/blog/protected/Pages/Users/ViewUser.php @@ -1,42 +1,42 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - */ - -/** - * ViewUser class - * - * @author Qiang Xue - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2006 PradoSoft - * @license http://www.pradosoft.com/license/ - */ -class ViewUser extends BlogPage -{ - private $_userRecord=null; - - public function onInit($param) - { - parent::onInit($param); - if(($id=$this->Request['id'])!==null) - $id=TPropertyValue::ensureInteger($id); - else - $id=$this->User->ID; - if(($this->_userRecord=$this->DataAccess->queryUserByID($id))===null) - throw new BlogException(500,'profile_id_invalid',$id); - $this->_userRecord->Email=strtr(strtoupper($this->_userRecord->Email),array('@'=>' at ','.'=>' dot ')); - } - - public function getProfile() - { - return $this->_userRecord; - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + */ + +/** + * ViewUser class + * + * @author Qiang Xue + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2006 PradoSoft + * @license http://www.pradosoft.com/license/ + */ +class ViewUser extends BlogPage +{ + private $_userRecord=null; + + public function onInit($param) + { + parent::onInit($param); + if(($id=$this->Request['id'])!==null) + $id=TPropertyValue::ensureInteger($id); + else + $id=$this->User->ID; + if(($this->_userRecord=$this->DataAccess->queryUserByID($id))===null) + throw new BlogException(500,'profile_id_invalid',$id); + $this->_userRecord->Email=strtr(strtoupper($this->_userRecord->Email),array('@'=>' at ','.'=>' dot ')); + } + + public function getProfile() + { + return $this->_userRecord; + } +} + ?> \ No newline at end of file -- cgit v1.2.3