store_plate.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /**
  3. * 关联版式
  4. *
  5. *
  6. *
  7. ***/
  8. defined('InShopNC') or exit ('Access Invalid!');
  9. class store_plateControl extends BaseSellerControl {
  10. public function __construct() {
  11. parent::__construct();
  12. }
  13. public function indexOp() {
  14. $this->plate_listOp();
  15. }
  16. /**
  17. * 关联版式列表
  18. */
  19. public function plate_listOp() {
  20. // 版式列表
  21. $where = array();
  22. $where['store_id'] = $_SESSION['store_id'];
  23. if (trim($_GET['p_name']) != '') {
  24. $where['plate_name'] = array('like', '%'.trim($_GET['p_name']).'%');
  25. }
  26. if (in_array($_GET['p_position'], array('0','1'))) {
  27. $where['plate_position'] = $_GET['p_position'];
  28. }
  29. $store_plate = Model('store_plate');
  30. $plate_list = $store_plate->getStorePlateList($where, '*', 10);
  31. Tpl::output('show_page', $store_plate->showpage(2));
  32. Tpl::output('plate_list', $plate_list);
  33. Tpl::output('position', array(0=> '底部', 1 => '顶部'));
  34. $this->profile_menu('plate_list', 'plate_list');
  35. Tpl::showpage('store_plate.list');
  36. }
  37. /**
  38. * 关联版式添加
  39. */
  40. public function plate_addOp() {
  41. if (chksubmit()) {
  42. // 验证表单
  43. $obj_validate = new Validator();
  44. $obj_validate->validateparam = array(
  45. array("input" => $_POST["p_name"], "require" => "true", "message" => '请填写版式名称'),
  46. array("input" => $_POST["p_content"], "require" => "true", "message" => '请填写版式内容')
  47. );
  48. $error = $obj_validate->validate();
  49. if ($error != '') {
  50. showDialog(L('error') . $error, urlShop('store_plate', 'index'));
  51. }
  52. $insert = array();
  53. $insert['plate_name'] = $_POST['p_name'];
  54. $insert['plate_position'] = $_POST['p_position'];
  55. $insert['plate_content'] = $_POST['p_content'];
  56. $insert['store_id'] = $_SESSION['store_id'];
  57. $result = Model('store_plate')->addStorePlate($insert);
  58. if ($result) {
  59. showDialog(L('nc_common_op_succ'), urlShop('store_plate', 'index'),'succ');
  60. } else {
  61. showDialog(L('nc_common_op_fail'), urlShop('store_plate', 'index'));
  62. }
  63. }
  64. // 是否能使用编辑器
  65. if(checkPlatformStore()){ // 平台店铺可以使用编辑器
  66. $editor_multimedia = true;
  67. } else { // 三方店铺需要
  68. $editor_multimedia = false;
  69. if ($this->store_grade['sg_function'] == 'editor_multimedia') {
  70. $editor_multimedia = true;
  71. }
  72. }
  73. Tpl::output('editor_multimedia', $editor_multimedia);
  74. $this->profile_menu('plate_add', 'plate_add');
  75. Tpl::showpage('store_plate.add');
  76. }
  77. /**
  78. * 关联版式编辑
  79. */
  80. public function plate_editOp() {
  81. if (chksubmit()) {
  82. $plate_id = intval($_POST['p_id']);
  83. if ($plate_id <= 0) {
  84. showMessage(L('wrong_argument'), '', '', 'error');
  85. }
  86. // 验证表单
  87. $obj_validate = new Validator();
  88. $obj_validate->validateparam = array(
  89. array("input" => $_POST["p_name"], "require" => "true", "message" => '请填写版式名称'),
  90. array("input" => $_POST["p_content"], "require" => "true", "message" => '请填写版式内容')
  91. );
  92. $error = $obj_validate->validate();
  93. if ($error != '') {
  94. showDialog(L('error') . $error, urlShop('store_plate', 'index'));
  95. }
  96. $update = array();
  97. $update['plate_name'] = $_POST['p_name'];
  98. $update['plate_position'] = $_POST['p_position'];
  99. $update['plate_content'] = $_POST['p_content'];
  100. $where = array();
  101. $where['plate_id'] = $plate_id;
  102. $where['store_id'] = $_SESSION['store_id'];
  103. $result = Model('store_plate')->editStorePlate($update, $where);
  104. if ($result) {
  105. showDialog(L('nc_common_op_succ'), urlShop('store_plate', 'index'),'succ');
  106. } else {
  107. showDialog(L('nc_common_op_fail'), urlShop('store_plate', 'index'));
  108. }
  109. }
  110. $plate_id = intval($_GET['p_id']);
  111. if ($plate_id <= 0) {
  112. showMessage(L('wrong_argument'), '', '', 'error');
  113. }
  114. $plate_info = Model('store_plate')->getStorePlateInfo(array('plate_id' => $plate_id, 'store_id' => $_SESSION['store_id']));
  115. Tpl::output('plate_info', $plate_info);
  116. $this->profile_menu('plate_edit', 'plate_edit');
  117. Tpl::showpage('store_plate.add');
  118. }
  119. /**
  120. * 删除关联版式
  121. */
  122. public function drop_plateOp() {
  123. $plate_id = $_GET['p_id'];
  124. if (!preg_match('/^[\d,]+$/i', $plate_id)) {
  125. showDialog(L('wrong_argument'), '', 'error');
  126. }
  127. $plateid_array = explode(',', $plate_id);
  128. $return = Model('store_plate')->delStorePlate(array('plate_id' => array('in', $plateid_array), 'store_id' => $_SESSION['store_id']));
  129. if ($return) {
  130. showDialog(L('nc_common_del_succ'), 'reload', 'succ');
  131. } else {
  132. showDialog(L('nc_common_del_fail'), '', 'error');
  133. }
  134. }
  135. /**
  136. * 用户中心右边,小导航
  137. *
  138. * @param string $menu_type 导航类型
  139. * @param string $menu_key 当前导航的menu_key
  140. * @param array $array 附加菜单
  141. * @return
  142. */
  143. private function profile_menu($menu_type,$menu_key='',$array=array()) {
  144. $menu_array = array();
  145. switch ($menu_type) {
  146. case 'plate_list':
  147. $menu_array = array(
  148. array('menu_key' => 'plate_list', 'menu_name' => '版式列表', 'menu_url' => urlShop('store_plate', 'plate_list'))
  149. );
  150. break;
  151. case 'plate_add':
  152. $menu_array = array(
  153. array('menu_key' => 'plate_list', 'menu_name' => '版式列表', 'menu_url' => urlShop('store_plate', 'plate_list')),
  154. array('menu_key' => 'plate_add', 'menu_name' => '添加版式', 'menu_url' => urlShop('store_plate', 'plate_add'))
  155. );
  156. break;
  157. case 'plate_edit':
  158. $menu_array = array(
  159. array('menu_key' => 'plate_list', 'menu_name' => '版式列表', 'menu_url' => urlShop('store_plate', 'plate_list')),
  160. array('menu_key' => 'plate_add', 'menu_name' => '添加版式', 'menu_url' => urlShop('store_plate', 'plate_add')),
  161. array('menu_key' => 'plate_edit', 'menu_name' => '编辑版式', 'menu_url' => urlShop('store_plate', 'plate_edit'))
  162. );
  163. break;
  164. }
  165. if(!empty($array)) {
  166. $menu_array[] = $array;
  167. }
  168. Tpl::output('member_menu',$menu_array);
  169. Tpl::output('menu_key',$menu_key);
  170. }
  171. }