人人商城

material.ctrl.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. $type = trim($_GPC['type']);
  8. $pageindex = max(1, intval($_GPC['page']));
  9. $pagesize = 4;
  10. if($type == 'image') {
  11. $pagesize = 50;
  12. }
  13. $condition = array('uniacid' => $_W['uniacid'], 'type' => $type, 'model' => 'perm');
  14. if ($type == 'news') {
  15. $newsmodel = trim($_GPC['newsmodel']);
  16. if (empty($newsmodel) || !in_array($newsmodel, array('wx', 'local'))) {
  17. $condition['model'] = 'perm';
  18. } else {
  19. $condition['model'] = $newsmodel == 'local' ? 'local' : 'perm';
  20. }
  21. }
  22. $material_list = pdo_getslice('wechat_attachment', $condition, array($pageindex, $pagesize), $total, array(), 'id', 'createtime DESC');
  23. if(!empty($material_list)) {
  24. foreach($material_list as &$row) {
  25. if($type == 'video') {
  26. $row['tag'] = iunserializer($row['tag']);
  27. $row['attach'] = tomedia($row['attachment'], true);
  28. } elseif($type == 'news') {
  29. $row['items'] = pdo_getall('wechat_news', array('uniacid' => $_W['uniacid'], 'attach_id' => $row['id']));
  30. if(!empty($row['items'])) {
  31. foreach($row['items'] as &$li) {
  32. $li['thumb_url'] = tomedia($li['thumb_url']);
  33. }
  34. unset($li);
  35. }
  36. } elseif($type == 'image') {
  37. $row['attach'] = tomedia($row['attachment'], true);
  38. $row['url'] = "url({$row['attach']})";
  39. } elseif($type == 'voice') {
  40. $row['attach'] = tomedia($row['attachment'], true);
  41. }
  42. $row['createtime_cn'] = date('Y-m-d H:i', $row['createtime']);
  43. }
  44. unset($row);
  45. }
  46. $result = array(
  47. 'items' => $material_list,
  48. 'pager' => pagination($total, $pageindex, $pagesize, '', array('before' => '2', 'after' => '3', 'ajaxcallback'=>'null')),
  49. );
  50. iajax(0, $result);