Index.class.php 4.5 KB

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