[ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 3 class SearchPost extends BlogPage 4 { 5 private $_posts; 6 7 public function onInit($param) 8 { 9 parent::onInit($param); 10 $this->_posts=$this->DataAccess->queryPosts( 11 $this->getPostFilter(), 12 '', 13 'ORDER BY create_time DESC', 14 'LIMIT '.$this->getPageOffset().','.$this->getPageSize()); 15 } 16 17 private function getPostFilter() 18 { 19 $filter='a.status=0'; 20 $keywords=explode(' ',$this->Request['keyword']); 21 foreach($keywords as $keyword) 22 { 23 if(($keyword=$this->DataAccess->escapeString(trim($keyword)))!=='') 24 $filter.=" AND (content LIKE '%$keyword%' OR title LIKE '%$keyword%')"; 25 } 26 return $filter; 27 } 28 29 private function getPageOffset() 30 { 31 if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0) 32 $offset=0; 33 return $offset; 34 } 35 36 private function getPageSize() 37 { 38 if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0) 39 $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']); 40 return $limit; 41 } 42 43 private function formUrl($newOffset) 44 { 45 $gets=array(); 46 $gets['offset']=$newOffset; 47 if($this->Request['limit']!==null) 48 $gets['limit']=$this->Request['limit']; 49 if($this->Request['time']!==null) 50 $gets['time']=$this->Request['time']; 51 if($this->Request['cat']!==null) 52 $gets['cat']=$this->Request['cat']; 53 return $this->Service->constructUrl('Posts.ListPost',$gets); 54 } 55 56 public function onLoad($param) 57 { 58 parent::onLoad($param); 59 $this->PostList->DataSource=$this->_posts; 60 $this->PostList->dataBind(); 61 if($this->getPageOffset()>0) 62 { 63 if(($offset=$this->getPageOffset()-$this->getPageSize())<0) 64 $offset=0; 65 $this->PrevPage->NavigateUrl=$this->formUrl($offset); 66 $this->PrevPage->Visible=true; 67 } 68 if(count($this->_posts)===$this->getPageSize()) 69 { 70 $this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize()); 71 $this->NextPage->Visible=true; 72 } 73 } 74 } 75 76 ?>
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 |