[ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 /** 3 * ListPost class file 4 * 5 * @author Qiang Xue <qiang.xue@gmail.com> 6 * @link http://www.pradosoft.com/ 7 * @copyright Copyright © 2006 PradoSoft 8 * @license http://www.pradosoft.com/license/ 9 * @version $Id: ListPost.php 1397 2006-09-07 07:55:53Z wei $ 10 */ 11 12 /** 13 * ListPost class 14 * 15 * @author Qiang Xue <qiang.xue@gmail.com> 16 * @link http://www.pradosoft.com/ 17 * @copyright Copyright © 2006 PradoSoft 18 * @license http://www.pradosoft.com/license/ 19 */ 20 class ListPost extends BlogPage 21 { 22 private $_posts; 23 private $_category; 24 25 public function onInit($param) 26 { 27 parent::onInit($param); 28 $this->_posts=$this->DataAccess->queryPosts( 29 $this->getPostFilter(), 30 $this->getCategoryFilter(), 31 'ORDER BY a.status DESC, create_time DESC', 32 'LIMIT '.$this->getPageOffset().','.$this->getPageSize()); 33 if($this->Request['cat']!==null) 34 { 35 $catID=TPropertyValue::ensureInteger($this->Request['cat']); 36 $this->_category=$this->DataAccess->queryCategoryByID($catID); 37 $this->CategoryPanel->Visible=true; 38 } 39 $this->Title=$this->Application->Parameters['SiteTitle']; 40 } 41 42 private function getPageOffset() 43 { 44 if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0) 45 $offset=0; 46 return $offset; 47 } 48 49 private function getPageSize() 50 { 51 if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0) 52 $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']); 53 return $limit; 54 } 55 56 private function getTimeFilter() 57 { 58 if(($time=TPropertyValue::ensureInteger($this->Request['time']))>0) 59 { 60 $year=(integer)($time/100); 61 $month=$time%100; 62 $startTime=mktime(0,0,0,$month,1,$year); 63 if(++$month>12) 64 { 65 $month=1; 66 $year++; 67 } 68 $endTime=mktime(0,0,0,$month,1,$year); 69 return "create_time>=$startTime AND create_time<$endTime"; 70 } 71 else 72 return ''; 73 } 74 75 private function getPostFilter() 76 { 77 $filter='(a.status=0 OR a.status=3)'; 78 if(($timeFilter=$this->getTimeFilter())!=='') 79 return "$filter AND $timeFilter"; 80 else 81 return $filter; 82 } 83 84 private function getCategoryFilter() 85 { 86 if(($catID=$this->Request['cat'])!==null) 87 { 88 $catID=TPropertyValue::ensureInteger($catID); 89 return "category_id=$catID"; 90 } 91 else 92 return ''; 93 } 94 95 private function formUrl($newOffset) 96 { 97 $gets=array(); 98 $gets['offset']=$newOffset; 99 if($this->Request['limit']!==null) 100 $gets['limit']=$this->Request['limit']; 101 if($this->Request['time']!==null) 102 $gets['time']=$this->Request['time']; 103 if($this->Request['cat']!==null) 104 $gets['cat']=$this->Request['cat']; 105 return $this->Service->constructUrl('Posts.ListPost',$gets); 106 } 107 108 public function getCategory() 109 { 110 return $this->_category; 111 } 112 113 public function onLoad($param) 114 { 115 parent::onLoad($param); 116 $this->PostList->DataSource=$this->_posts; 117 $this->PostList->dataBind(); 118 if($this->getPageOffset()>0) 119 { 120 if(($offset=$this->getPageOffset()-$this->getPageSize())<0) 121 $offset=0; 122 $this->PrevPage->NavigateUrl=$this->formUrl($offset); 123 $this->PrevPage->Visible=true; 124 } 125 if(count($this->_posts)===$this->getPageSize()) 126 { 127 $this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize()); 128 $this->NextPage->Visible=true; 129 } 130 } 131 132 public function deleteButtonClicked($sender,$param) 133 { 134 if($this->User->IsAdmin) 135 { 136 $this->DataAccess->deleteCategory($this->Category->ID); 137 $this->gotoDefaultPage(); 138 } 139 } 140 } 141 142 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 21:07:04 2007 | par Balluche grâce à PHPXref 0.7 |