@@ -35,18 +35,20 @@ |
||
| 35 | 35 | $postRecord=new PostRecord; |
| 36 | 36 | $postRecord->Title=$this->Title->SafeText; |
| 37 | 37 | $postRecord->Content=$this->Content->SafeText; |
| 38 | - if($this->DraftMode->Checked) |
|
| 39 | - $postRecord->Status=PostRecord::STATUS_DRAFT; |
|
| 40 | - else if(!$this->User->IsAdmin && TPropertyValue::ensureBoolean($this->Application->Parameters['PostApproval'])) |
|
| 41 | - $postRecord->Status=PostRecord::STATUS_PENDING; |
|
| 42 | - else |
|
| 43 | - $postRecord->Status=PostRecord::STATUS_PUBLISHED; |
|
| 38 | + if($this->DraftMode->Checked) { |
|
| 39 | + $postRecord->Status=PostRecord::STATUS_DRAFT; |
|
| 40 | + } else if(!$this->User->IsAdmin && TPropertyValue::ensureBoolean($this->Application->Parameters['PostApproval'])) { |
|
| 41 | + $postRecord->Status=PostRecord::STATUS_PENDING; |
|
| 42 | + } else { |
|
| 43 | + $postRecord->Status=PostRecord::STATUS_PUBLISHED; |
|
| 44 | + } |
|
| 44 | 45 | $postRecord->CreateTime=time(); |
| 45 | 46 | $postRecord->ModifyTime=$postRecord->CreateTime; |
| 46 | 47 | $postRecord->AuthorID=$this->User->ID; |
| 47 | 48 | $cats=array(); |
| 48 | - foreach($this->Categories->SelectedValues as $value) |
|
| 49 | - $cats[]=TPropertyValue::ensureInteger($value); |
|
| 49 | + foreach($this->Categories->SelectedValues as $value) { |
|
| 50 | + $cats[]=TPropertyValue::ensureInteger($value); |
|
| 51 | + } |
|
| 50 | 52 | $this->DataAccess->insertPost($postRecord,$cats); |
| 51 | 53 | $this->gotoPage('Posts.ViewPost',array('id'=>$postRecord->ID)); |
| 52 | 54 | } |
@@ -40,15 +40,17 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | private function getPageOffset() |
| 42 | 42 | { |
| 43 | - if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0) |
|
| 44 | - $offset=0; |
|
| 43 | + if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0) { |
|
| 44 | + $offset=0; |
|
| 45 | + } |
|
| 45 | 46 | return $offset; |
| 46 | 47 | } |
| 47 | 48 | |
| 48 | 49 | private function getPageSize() |
| 49 | 50 | { |
| 50 | - if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0) |
|
| 51 | - $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']); |
|
| 51 | + if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0) { |
|
| 52 | + $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']); |
|
| 53 | + } |
|
| 52 | 54 | return $limit; |
| 53 | 55 | } |
| 54 | 56 | |
@@ -66,18 +68,19 @@ discard block |
||
| 66 | 68 | } |
| 67 | 69 | $endTime=mktime(0,0,0,$month,1,$year); |
| 68 | 70 | return "create_time>=$startTime AND create_time<$endTime"; |
| 71 | + } else { |
|
| 72 | + return ''; |
|
| 69 | 73 | } |
| 70 | - else |
|
| 71 | - return ''; |
|
| 72 | 74 | } |
| 73 | 75 | |
| 74 | 76 | private function getPostFilter() |
| 75 | 77 | { |
| 76 | 78 | $filter='(a.status=0 OR a.status=3)'; |
| 77 | - if(($timeFilter=$this->getTimeFilter())!=='') |
|
| 78 | - return "$filter AND $timeFilter"; |
|
| 79 | - else |
|
| 80 | - return $filter; |
|
| 79 | + if(($timeFilter=$this->getTimeFilter())!=='') { |
|
| 80 | + return "$filter AND $timeFilter"; |
|
| 81 | + } else { |
|
| 82 | + return $filter; |
|
| 83 | + } |
|
| 81 | 84 | } |
| 82 | 85 | |
| 83 | 86 | private function getCategoryFilter() |
@@ -86,21 +89,24 @@ discard block |
||
| 86 | 89 | { |
| 87 | 90 | $catID=TPropertyValue::ensureInteger($catID); |
| 88 | 91 | return "category_id=$catID"; |
| 92 | + } else { |
|
| 93 | + return ''; |
|
| 89 | 94 | } |
| 90 | - else |
|
| 91 | - return ''; |
|
| 92 | 95 | } |
| 93 | 96 | |
| 94 | 97 | private function formUrl($newOffset) |
| 95 | 98 | { |
| 96 | 99 | $gets=array(); |
| 97 | 100 | $gets['offset']=$newOffset; |
| 98 | - if($this->Request['limit']!==null) |
|
| 99 | - $gets['limit']=$this->Request['limit']; |
|
| 100 | - if($this->Request['time']!==null) |
|
| 101 | - $gets['time']=$this->Request['time']; |
|
| 102 | - if($this->Request['cat']!==null) |
|
| 103 | - $gets['cat']=$this->Request['cat']; |
|
| 101 | + if($this->Request['limit']!==null) { |
|
| 102 | + $gets['limit']=$this->Request['limit']; |
|
| 103 | + } |
|
| 104 | + if($this->Request['time']!==null) { |
|
| 105 | + $gets['time']=$this->Request['time']; |
|
| 106 | + } |
|
| 107 | + if($this->Request['cat']!==null) { |
|
| 108 | + $gets['cat']=$this->Request['cat']; |
|
| 109 | + } |
|
| 104 | 110 | return $this->Service->constructUrl('Posts.ListPost',$gets); |
| 105 | 111 | } |
| 106 | 112 | |
@@ -116,8 +122,9 @@ discard block |
||
| 116 | 122 | $this->PostList->dataBind(); |
| 117 | 123 | if($this->getPageOffset()>0) |
| 118 | 124 | { |
| 119 | - if(($offset=$this->getPageOffset()-$this->getPageSize())<0) |
|
| 120 | - $offset=0; |
|
| 125 | + if(($offset=$this->getPageOffset()-$this->getPageSize())<0) { |
|
| 126 | + $offset=0; |
|
| 127 | + } |
|
| 121 | 128 | $this->PrevPage->NavigateUrl=$this->formUrl($offset); |
| 122 | 129 | $this->PrevPage->Visible=true; |
| 123 | 130 | } |
@@ -60,8 +60,9 @@ |
||
| 60 | 60 | $themeName=$this->ThemeName->SelectedItem->Text; |
| 61 | 61 | $elements[]=$this->createParameter('ThemeName',$themeName); |
| 62 | 62 | $dom->saveToFile(Prado::getPathOfNamespace(self::CONFIG_FILE,'.xml')); |
| 63 | - if($themeName!==$this->Theme->Name) |
|
| 64 | - $this->Response->reload(); |
|
| 63 | + if($themeName!==$this->Theme->Name) { |
|
| 64 | + $this->Response->reload(); |
|
| 65 | + } |
|
| 65 | 66 | } |
| 66 | 67 | |
| 67 | 68 | private function createParameter($id,$value) |
@@ -30,8 +30,9 @@ |
||
| 30 | 30 | public function onLoad($param) |
| 31 | 31 | { |
| 32 | 32 | parent::onLoad($param); |
| 33 | - if(!$this->IsPostBack) |
|
| 34 | - $this->bindData(); |
|
| 33 | + if(!$this->IsPostBack) { |
|
| 34 | + $this->bindData(); |
|
| 35 | + } |
|
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | public function changePage($sender,$param) |
@@ -23,8 +23,9 @@ |
||
| 23 | 23 | public function onInit($param) |
| 24 | 24 | { |
| 25 | 25 | parent::onInit($param); |
| 26 | - if(!$this->Page->IsPostBack && ($keyword=$this->Request['keyword'])!==null) |
|
| 27 | - $this->Keyword->Text=$keyword; |
|
| 26 | + if(!$this->Page->IsPostBack && ($keyword=$this->Request['keyword'])!==null) { |
|
| 27 | + $this->Keyword->Text=$keyword; |
|
| 28 | + } |
|
| 28 | 29 | } |
| 29 | 30 | |
| 30 | 31 | public function search($sender,$param) |
@@ -30,8 +30,10 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $currentTime=time(); |
| 32 | 32 | $startTime=$this->Application->getModule('data')->queryEarliestPostTime(); |
| 33 | - if(empty($startTime)) // if no posts |
|
| 33 | + if(empty($startTime)) { |
|
| 34 | + // if no posts |
|
| 34 | 35 | $startTime=$currentTime; |
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // obtain the timestamp for the initial month |
| 37 | 39 | $date=getdate($startTime); |
@@ -44,8 +46,9 @@ discard block |
||
| 44 | 46 | $timestamps=array(); |
| 45 | 47 | while(true) |
| 46 | 48 | { |
| 47 | - if(($timestamp=mktime(0,0,0,$month,1,$year))<$startTime) |
|
| 48 | - break; |
|
| 49 | + if(($timestamp=mktime(0,0,0,$month,1,$year))<$startTime) { |
|
| 50 | + break; |
|
| 51 | + } |
|
| 49 | 52 | $timestamps[]=$timestamp; |
| 50 | 53 | if(--$month===0) |
| 51 | 54 | { |
@@ -28,8 +28,9 @@ |
||
| 28 | 28 | foreach($comments as $comment) |
| 29 | 29 | { |
| 30 | 30 | $comment->ID=$this->Service->constructUrl('Posts.ViewPost',array('id'=>$comment->PostID)).'#c'.$comment->ID; |
| 31 | - if(strlen($comment->Content)>40) |
|
| 32 | - $comment->Content=substr($comment->Content,0,40).' ...'; |
|
| 31 | + if(strlen($comment->Content)>40) { |
|
| 32 | + $comment->Content=substr($comment->Content,0,40).' ...'; |
|
| 33 | + } |
|
| 33 | 34 | } |
| 34 | 35 | $this->CommentList->DataSource=$comments; |
| 35 | 36 | $this->CommentList->dataBind(); |
@@ -23,14 +23,16 @@ |
||
| 23 | 23 | public function validateUser($sender,$param) |
| 24 | 24 | { |
| 25 | 25 | $authManager=$this->Application->getModule('auth'); |
| 26 | - if(!$authManager->login(strtolower($this->Username->Text),$this->Password->Text)) |
|
| 27 | - $param->IsValid=false; |
|
| 26 | + if(!$authManager->login(strtolower($this->Username->Text),$this->Password->Text)) { |
|
| 27 | + $param->IsValid=false; |
|
| 28 | + } |
|
| 28 | 29 | } |
| 29 | 30 | |
| 30 | 31 | public function loginButtonClicked($sender,$param) |
| 31 | 32 | { |
| 32 | - if($this->Page->IsValid) |
|
| 33 | - $this->Response->reload(); |
|
| 33 | + if($this->Page->IsValid) { |
|
| 34 | + $this->Response->reload(); |
|
| 35 | + } |
|
| 34 | 36 | //$this->Response->redirect($this->Application->getModule('auth')->getReturnUrl()); |
| 35 | 37 | } |
| 36 | 38 | } |
@@ -36,9 +36,9 @@ |
||
| 36 | 36 | Prado::log($message,TLogger::ERROR,'BlogApplication'); |
| 37 | 37 | $message=urldecode($this->getApplication()->getSecurityManager()->hashData($message)); |
| 38 | 38 | $this->Response->redirect($this->Service->constructUrl('ErrorReport',array('msg'=>$message),false)); |
| 39 | + } else { |
|
| 40 | + parent::handleExternalError($statusCode,$exception); |
|
| 39 | 41 | } |
| 40 | - else |
|
| 41 | - parent::handleExternalError($statusCode,$exception); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |