Index.class.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. namespace Cas\Controller\Admin\Focus;
  3. use KIF\Core\Request;
  4. use Cas\Controller\Admin\Controller;
  5. use KIF\Page\Page;
  6. use Cas\Dao\Platform;
  7. use Cas\Dao\Focus;
  8. /**
  9. * "推荐相关" - "列表"[推荐相关信息]
  10. *
  11. * @author rabin
  12. * 页面: "推荐信息"列表 doPageList
  13. * 页面: 查看&修改 "推荐信息" doPageShow
  14. * 事件: 创建"推荐信息" doReqCreate
  15. * 事件: 修改"推荐信息" doReqUp
  16. * 事件: 删除"推荐信息" doReqDel  
  17. */
  18. class Index extends Controller {
  19. private $objDFocus;
  20. private $operatorData;
  21. /**
  22. *  初始化
  23. */
  24. public function __construct() {
  25. header ( "Content-Type: text/html; charset=utf-8" );
  26. $this->objDFocus = new Focus ();
  27. $this->operatorData = $this->getUser ();
  28. }
  29. /**
  30. * 默认
  31. */
  32. public function doDefault() {
  33. }
  34. /**
  35. * 页面: "推荐信息"列表
  36. * 地址:http://cas.lishuy.com/?c=Admin_Focus_Index&a=PageList
  37. */
  38. public function doPageList() {
  39. $page = Request::varGetInt ( 'page', 1 );
  40. $size = 10;
  41. $offset = ($page - 1) * $size;
  42. $limit = "{$offset},{$size}";
  43. $condition = array ();
  44. $total_num = $this->objDFocus->totals ( $condition );
  45. $url_tpl = Request::schemeDomain () . "?c=Admin_Focus_Index&a=PageList";
  46. $url_tpl .= "&page={page}";
  47. $objPage = new Page ( $total_num, $url_tpl, $page, $size );
  48. $page_html = $objPage->html ();
  49. $order = '`index` desc, id desc';
  50. $ids = $this->objDFocus->findIdsBy ( $condition, $limit, $order );
  51. $focusData = $this->objDFocus->gets ( $ids );
  52. $this->tpl = 'admin/focus/list';
  53. $title = '推荐列表';
  54. $this->setOutput('title', $title);
  55. $this->setOutput('menu_active', array('name' => 'focuslist', 'item' => 'list')); //激活菜单
  56. $this->addNavMenu('推荐设置');
  57. $this->addNavMenu($title);
  58. $platformList = array ();
  59. $objDPlatform = new Platform ();
  60. $platformList = $objDPlatform->getsAll ();
  61. $this->setOutput ( 'platformList', $platformList ); //
  62. $this->setOutput('pagePublicData', $this->getPagePublicData()); // 后台管理相关数据
  63. $this->setOutput ( 'page_html', $page_html ); // 分页Html
  64. $this->setOutput ( 'focusData', $focusData ); // 当前"推荐信息"列表数据
  65. }
  66. /**
  67. * 页面: 查看&修改 "推荐信息"
  68. * 地址:http://cas.lishuy.com/?c=Admin_Focus_Index&a=PageShow&id=nn
  69. * 参数:id "推荐信息"id
  70. */
  71. public function doPageShow() {
  72. $id = Request::g ( 'id' );
  73. $focusData = $this->objDFocus->get ( $id );
  74. $this->tpl = 'admin/focus/edit';
  75. $title = '编辑推荐信息';
  76. $this->setOutput('title', $title);
  77. $this->setOutput('menu_active', array('name' => 'focuslist', 'item' => 'list')); //激活菜单
  78. $this->addNavMenu('推荐设置');
  79. $this->addNavMenu('推荐列表', Request::schemeDomain() . '/?c=Admin_Focus_index&a=PageList');
  80. $this->addNavMenu($title);
  81. $platformList = array ();
  82. $objDPlatform = new Platform ();
  83. $platformList = $objDPlatform->getsAll ();
  84. $this->setOutput ( 'platformList', $platformList ); //
  85. $this->setOutput('pagePublicData', $this->getPagePublicData()); // 后台管理相关数据
  86. $this->setOutput ( 'focusData', $focusData ); // 当前"推荐信息"内容
  87. }
  88. /**
  89. * 事件:创建"推荐信息"
  90. * 地址:http://cas.lishuy.com/index.php?c=Admin_Focus_Index&a=ReqCreate
  91. * 参数:见方法内
  92. */
  93. public function doReqCreate() {
  94. $tableInfo = $_POST;
  95. $operator_uid = $this->operatorData ['uid'];
  96. $info = array_merge($tableInfo, array(
  97. 'operator_uid' => $operator_uid
  98. ));
  99. $tmpResult = $this->objDFocus->add ( $info );
  100. if (!$tmpResult) {
  101. $this->ajax_fail_exit('添加新推荐失败');
  102. }
  103. $this->ajax_success_exit();
  104. }
  105. /**
  106. * 事件: 修改"推荐信息"
  107. * 地址:http://cas.lishuy.com/index.php?c=Admin_Focus_Index&a=ReqUp
  108. * 参数:见方法内
  109. */
  110. public function doReqUp() {
  111. $tableInfo = $_POST;
  112. $id = $tableInfo['id'];
  113. unset($tableInfo['id']);
  114. $operator_uid = $this->operatorData ['uid'];
  115. $info = array_merge($tableInfo, array(
  116. 'operator_uid' => $operator_uid
  117. ));
  118. $tmpResult = $this->objDFocus->modify ( $info, array (
  119. 'id' => $id
  120. ) );
  121. if (!$tmpResult->isSuccess()) {
  122. $this->ajax_fail_exit($tmpResult->getData());
  123. }
  124. $this->ajax_success_exit();
  125. }
  126. /**
  127. * 事件: 删除"推荐信息"
  128. * 地址:http://cas.lishuy.com/index.php?c=Admin_Focus_Index&a=ReqDel
  129. * 参数:见方法内
  130. */
  131. public function doReqDel() {
  132. $id = Request::p ( 'id' );
  133. $this->objDFocus->delete ( array (
  134. 'id' => $id
  135. ) );
  136. // TODO 根据前端自定义返回结果或跳转
  137. header ( "Location: " . Request::schemeDomain () . "/?c=Admin_Focus_Index&a=PageList" );
  138. exit ();
  139. }
  140. public function display() {
  141. return $this->render ();
  142. }
  143. }