人人商城

material-post.ctrl.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. load()->func('file');
  8. load()->model('material');
  9. load()->model('account');
  10. $dos = array('news', 'tomedia', 'addnews', 'upload_material', 'upload_news');
  11. $do = in_array($do, $dos) ? $do : 'news';
  12. permission_check_account_user('platform_material');
  13. $_W['page']['title'] = '新增素材-微信素材';
  14. if ($do == 'tomedia') {
  15. iajax('0', tomedia($_GPC['url']), '');
  16. }
  17. if ($do == 'news') {
  18. $type = trim($_GPC['type']);
  19. $newsid = intval($_GPC['newsid']);
  20. $upload_limit = material_upload_limit();
  21. if (empty($newsid)) {
  22. if ($type == 'reply') {
  23. $reply_news_id = intval($_GPC['reply_news_id']);
  24. $news = pdo_get('news_reply', array(
  25. 'id' => $reply_news_id
  26. ));
  27. $news_list = pdo_getall('news_reply', array(
  28. 'parent_id' => $news['id']
  29. ), array(), '', ' displayorder ASC');
  30. $news_list = array_merge(array(
  31. $news
  32. ), $news_list);
  33. if (!empty($news_list)) {
  34. foreach ($news_list as $key => &$row_news) {
  35. $row_news = array(
  36. 'uniacid' => $_W['uniacid'],
  37. 'thumb_url' => $row_news['thumb'],
  38. 'title' => $row_news['title'],
  39. 'author' => $row_news['author'],
  40. 'digest' => $row_news['description'],
  41. 'content' => $row_news['content'],
  42. 'url' => $row_news['url'],
  43. 'displayorder' => $key,
  44. 'show_cover_pic' => intval($row_news['incontent']),
  45. 'content_source_url' => $row_news['content_source_url']
  46. );
  47. }
  48. unset($row_news);
  49. }
  50. }
  51. } else {
  52. $attachment = material_get($newsid);
  53. if (is_error($attachment)){
  54. itoast('图文素材不存在,或已删除', url('platform/material'), 'warning');
  55. }
  56. $news_list = $attachment['news'];
  57. }
  58. if (!empty($_GPC['new_type'])) {
  59. $new_type = trim($_GPC['new_type']);
  60. if (!in_array($new_type, array('reply', 'link'))) {
  61. $new_type = 'reply';
  62. }
  63. }
  64. if (!empty($news_list)) {
  65. foreach ($news_list as $key => $row_news) {
  66. if (empty($row_news['author']) && empty($row_news['content'])) {
  67. $new_type = 'link';
  68. } else {
  69. $new_type = 'reply';
  70. }
  71. }
  72. }
  73. template('platform/material-post');
  74. }
  75. if ($do == 'addnews') {
  76. $is_sendto_wechat = trim($_GPC['target']) == 'wechat' ? true : false;
  77. $attach_id = intval($_GPC['attach_id']);
  78. if (empty($_GPC['news'])) {
  79. iajax(- 1, '提交内容参数有误');
  80. }
  81. $attach_id = material_news_set($_GPC['news'], $attach_id);
  82. if (is_error($attach_id)) {
  83. iajax(-1, $attach_id['message']);
  84. }
  85. if (!empty($_GPC['news_rid'])) {
  86. pdo_update('news_reply', array('media_id' => $attach_id), array('id' => intval($_GPC['news_rid'])));
  87. }
  88. if ($is_sendto_wechat) {
  89. $result = material_local_news_upload($attach_id);
  90. }
  91. if (is_error($result)){
  92. iajax(-1, '提交微信素材失败');
  93. }else{
  94. iajax(0, '编辑图文素材成功');
  95. }
  96. }
  97. if ($do == 'upload_material') {
  98. $material_id = intval($_GPC['material_id']);
  99. $result = material_local_upload($material_id);
  100. if (is_error($result)) {
  101. iajax(1, $result['message']);
  102. }
  103. iajax(0, json_encode($result));
  104. }
  105. if ($do == 'upload_news') {
  106. $material_id = intval($_GPC['material_id']);
  107. $result = material_local_news_upload($material_id);
  108. if (is_error($result)){
  109. iajax(-1, $result['message']);
  110. } else {
  111. iajax(0, '转换成功');
  112. }
  113. }