slide.ctrl.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. $do = !empty($do) ? $do : 'display';
  8. $do = in_array($do, array('display', 'post', 'delete')) ? $do : 'display';
  9. permission_check_account_user('platform_site');
  10. if ($do == 'display' && $_W['isajax'] && $_W['ispost']) {
  11. $pindex = max(1, intval($_GPC['page']));
  12. $psize = 10;
  13. $condition = '';
  14. $params = array();
  15. $multiid = intval($_GPC['multiid']);
  16. if ($multiid > 0) {
  17. $condition .= " AND multiid = {$multiid}";
  18. }
  19. if (!empty($_GPC['keyword'])) {
  20. $condition .= " AND title LIKE '%{$_GPC['keyword']}%'";
  21. }
  22. $list = pdo_fetchall("SELECT * FROM ".tablename('site_slide')." WHERE uniacid = '{$_W['uniacid']}' $condition ORDER BY displayorder DESC, uniacid DESC LIMIT ".($pindex - 1) * $psize.','.$psize, $params);
  23. $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('site_slide') . " WHERE uniacid = '{$_W['uniacid']}' $condition");
  24. $pager = pagination($total, $pindex, $psize);
  25. iajax(0, $list, '');
  26. }
  27. if ($do == 'post' && $_W['isajax'] && $_W['ispost']) {
  28. $multiid = intval($_GPC['multiid']);
  29. if (empty($_GPC['slide'])) {
  30. pdo_delete('site_slide', array('uniacid' => $_W['uniacid'], 'multiid' => $multiid));
  31. } else {
  32. foreach ($_GPC['slide'] as $key => $val) {
  33. if (empty($val['thumb'])){
  34. iajax(-1, '幻灯图片不可为空', '');
  35. }
  36. }
  37. pdo_delete('site_slide', array('uniacid' => $_W['uniacid'], 'multiid' => $multiid));
  38. foreach ($_GPC['slide'] as $value) {
  39. $data = array(
  40. 'uniacid' => $_W['uniacid'],
  41. 'multiid' => $multiid,
  42. 'title' => $value['title'],
  43. 'url' => $value['url'],
  44. 'thumb' => $value['thumb'],
  45. 'displayorder' => intval($value['displayorder']),
  46. );
  47. pdo_insert('site_slide', $data);
  48. }
  49. }
  50. iajax(0, '幻灯片保存成功!', '');
  51. }