Authored by whb

添加分页

@@ -131,7 +131,11 @@ class Controller_Admin_Activity extends Controller_Admin_Base @@ -131,7 +131,11 @@ class Controller_Admin_Activity extends Controller_Admin_Base
131 */ 131 */
132 public function plantopicAction() 132 public function plantopicAction()
133 { 133 {
134 - $this->_view['topics'] = Facade_Activity::getActivityTopic(); 134 + $limit = 15;
  135 + $total = Facade_Activity::getActivityTopicTotal();
  136 + $pagination = new Lib_Helper_Pagination($total, $limit);
  137 + $this->_view['topics'] = Facade_Activity::getActivityTopicList($pagination->getOffset(), $limit);
  138 + $this->_view['pagination'] = $pagination->getPagination();
135 } 139 }
136 140
137 /** 141 /**
@@ -15,7 +15,7 @@ class Controller_Admin_News extends Controller_Admin_Base @@ -15,7 +15,7 @@ class Controller_Admin_News extends Controller_Admin_Base
15 $total = Facade_News::getTotal($conditions); 15 $total = Facade_News::getTotal($conditions);
16 $pagination = new Lib_Helper_Pagination($total,$limit); 16 $pagination = new Lib_Helper_Pagination($total,$limit);
17 $pagination->setParames($url_args); 17 $pagination->setParames($url_args);
18 - $list = Facade_News::getList($conditions, $pagination->getOffset(),$limit); 18 + $list = Facade_News::getList($conditions, $pagination->getOffset(), $limit);
19 foreach ($list as $k => $v) 19 foreach ($list as $k => $v)
20 { 20 {
21 $list[$k]['content'] = str_replace(array("\n","\r","\t"),'', Util_StringHelper::substr_cn(strip_tags($v['content']),30)); 21 $list[$k]['content'] = str_replace(array("\n","\r","\t"),'', Util_StringHelper::substr_cn(strip_tags($v['content']),30));
@@ -155,6 +155,28 @@ class Facade_Activity @@ -155,6 +155,28 @@ class Facade_Activity
155 } 155 }
156 156
157 /** 157 /**
  158 + * 获取活动主题列表
  159 + *
  160 + * @param int $offset
  161 + * @param int $limit
  162 + * @return array
  163 + */
  164 + public static function getActivityTopicList($offset, $limit)
  165 + {
  166 + return self::service()->getActivityTopicList($offset, $limit);
  167 + }
  168 +
  169 + /**
  170 + * 获取活动主题总数
  171 + *
  172 + * @return int
  173 + */
  174 + public static function getActivityTopicTotal()
  175 + {
  176 + return self::service()->getActivityTopicTotal();
  177 + }
  178 +
  179 + /**
158 * 增加活动主题 180 * 增加活动主题
159 * 181 *
160 * @param int $title 182 * @param int $title
@@ -224,7 +224,30 @@ class Service_Activity extends Lib_Service @@ -224,7 +224,30 @@ class Service_Activity extends Lib_Service
224 { 224 {
225 return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getActivityTopic'); 225 return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getActivityTopic');
226 } 226 }
227 - 227 +
  228 + /**
  229 + * 获取活动主题列表
  230 + *
  231 + * @param int $offset
  232 + * @param int $limit
  233 + * @return array
  234 + */
  235 + public function getActivityTopicList($offset, $limit)
  236 + {
  237 + return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getActivityTopicList',
  238 + array('offset'=> intval($offset), 'limit'=> intval($limit)));
  239 + }
  240 +
  241 + /**
  242 + * 获取活动主题总数
  243 + *
  244 + * @return int
  245 + */
  246 + public function getActivityTopicTotal()
  247 + {
  248 + return self::service(self::ROUTER)->tag(self::$_tag)->fetchOne('getActivityTopicTotal');
  249 + }
  250 +
228 /** 251 /**
229 * 删除活动主题 252 * 删除活动主题
230 * 253 *
@@ -33,6 +33,12 @@ @@ -33,6 +33,12 @@
33 <select id="getActivityTopic"> 33 <select id="getActivityTopic">
34 SELECT * FROM tbl_activity_topic ORDER BY start_time DESC 34 SELECT * FROM tbl_activity_topic ORDER BY start_time DESC
35 </select> 35 </select>
  36 + <select id="getActivityTopicList">
  37 + SELECT * FROM tbl_activity_topic ORDER BY start_time DESC LIMIT :offset, :limit
  38 + </select>
  39 + <select id="getActivityTopicTotal">
  40 + SELECT COUNT(*) FROM tbl_activity_topic
  41 + </select>
36 <select id="setActivityTopic"> 42 <select id="setActivityTopic">
37 INSERT INTO tbl_activity_topic(title, place,start_time, end_time,create_time)VALUES(:title, :place, :start_time,:end_time, UNIX_TIMESTAMP()) 43 INSERT INTO tbl_activity_topic(title, place,start_time, end_time,create_time)VALUES(:title, :place, :start_time,:end_time, UNIX_TIMESTAMP())
38 </select> 44 </select>
@@ -31,6 +31,10 @@ @@ -31,6 +31,10 @@
31 </tr> 31 </tr>
32 <?php endforeach;?> 32 <?php endforeach;?>
33 </table> 33 </table>
  34 +<?php $this->_component('Common_Pagination',array(
  35 + 'pagination' => $this->view->pagination,'show_count' =>true,
  36 + ));?>
  37 +
34 <div id="form_pan" admin="" style="display:none;"> 38 <div id="form_pan" admin="" style="display:none;">
35 <table class="table table-bordered"> 39 <table class="table table-bordered">
36 <tbody> 40 <tbody>