暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Custom.php 51KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海口快推科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 小虎哥 <1105415366@qq.com>
  11. * Date: 2018-4-3
  12. */
  13. namespace app\admin\controller;
  14. use think\Page;
  15. use think\Db;
  16. class Custom extends Base
  17. {
  18. // 模型标识
  19. public $nid = '';
  20. // 模型ID
  21. public $channeltype = 0;
  22. // 模型附加表
  23. public $table = '';
  24. /*
  25. * 初始化操作
  26. */
  27. public function _initialize()
  28. {
  29. parent::_initialize();
  30. $this->archives_db = Db::name('archives');
  31. $this->channeltype = input('param.channel/d', 0);
  32. $channeltypeRow = Db::name('channeltype')->field('nid,table')->where(['id'=>['eq',$this->channeltype]])->find();
  33. if (empty($this->channeltype) || empty($channeltypeRow)) {
  34. $this->error('自定义模型ID丢失,打开失败!');
  35. }
  36. $this->nid = $channeltypeRow['nid'];
  37. $this->table = $channeltypeRow['table'];
  38. $this->assign('nid', $this->nid);
  39. $this->assign('table', $this->table);
  40. $this->assign('channeltype', $this->channeltype);
  41. // 返回页面
  42. $paramTypeid = input('param.typeid/d', 0);
  43. $this->callback_url = url('Custom/index', ['lang' => $this->admin_lang, 'channel'=>$this->channeltype, 'typeid' => $paramTypeid]);
  44. $this->assign('callback_url', $this->callback_url);
  45. }
  46. //列表
  47. public function index()
  48. {
  49. $assign_data = $condition = [];
  50. // 获取到所有GET参数
  51. $param = input('param.');
  52. $typeid = input('typeid/d', 0);
  53. // 搜索、筛选查询条件处理
  54. foreach (['keywords', 'typeid', 'flag', 'is_release','province_id','city_id','area_id'] as $key) {
  55. if ($key == 'typeid' && empty($param['typeid'])) {
  56. $typeids = Db::name('arctype')->where('current_channel', $this->channeltype)->column('id');
  57. $condition['a.typeid'] = array('IN', $typeids);
  58. }
  59. if (isset($param[$key]) && $param[$key] !== '') {
  60. if ($key == 'keywords') {
  61. $keywords = $param[$key];
  62. $condition['a.title'] = array('LIKE', "%{$param[$key]}%");
  63. } else if ($key == 'typeid') {
  64. $typeid = $param[$key];
  65. $hasRow = model('Arctype')->getHasChildren($typeid);
  66. $typeids = get_arr_column($hasRow, 'id');
  67. // 权限控制 by 小虎哥
  68. $admin_info = session('admin_info');
  69. if (0 < intval($admin_info['role_id'])) {
  70. $auth_role_info = $admin_info['auth_role_info'];
  71. if (!empty($typeid) && !empty($auth_role_info) && !empty($auth_role_info['permission']['arctype'])) {
  72. $typeids = array_intersect($typeids, $auth_role_info['permission']['arctype']);
  73. }
  74. }
  75. $condition['a.typeid'] = array('IN', $typeids);
  76. } else if ($key == 'flag') {
  77. if ('is_release' == $param[$key]) {
  78. $condition['a.users_id'] = array('gt', 0);
  79. } else {
  80. $FlagNew = $param[$key];
  81. $condition['a.'.$param[$key]] = array('eq', 1);
  82. }
  83. } else if (in_array($key, ['province_id','city_id','area_id'])) {
  84. if (!empty($param['area_id'])) {
  85. $condition['a.area_id'] = $param['area_id'];
  86. } else if (!empty($param['city_id'])) {
  87. $condition['a.city_id'] = $param['city_id'];
  88. } else if (!empty($param['province_id'])) {
  89. $condition['a.province_id'] = $param['province_id'];
  90. }
  91. } else {
  92. $condition['a.'.$key] = array('eq', $param[$key]);
  93. }
  94. }
  95. }
  96. // 权限控制 by 小虎哥
  97. $admin_info = session('admin_info');
  98. if (0 < intval($admin_info['role_id'])) {
  99. $auth_role_info = $admin_info['auth_role_info'];
  100. if (!empty($auth_role_info) && isset($auth_role_info['only_oneself']) && 1 == $auth_role_info['only_oneself']) {
  101. $condition['a.admin_id'] = $admin_info['admin_id'];
  102. }
  103. }
  104. // 时间检索条件
  105. $begin = strtotime(input('add_time_begin'));
  106. $end = strtotime(input('add_time_end'));
  107. if ($begin > 0 && $end > 0) {
  108. $condition['a.add_time'] = array('between', "$begin, $end");
  109. } else if ($begin > 0) {
  110. $condition['a.add_time'] = array('egt', $begin);
  111. } else if ($end > 0) {
  112. $condition['a.add_time'] = array('elt', $end);
  113. }
  114. // 必要条件
  115. $condition['a.channel'] = array('eq', $this->channeltype);
  116. $condition['a.lang'] = array('eq', $this->admin_lang);
  117. $condition['a.is_del'] = array('eq', 0);
  118. $conditionNew = "(a.users_id = 0 OR (a.users_id > 0 AND a.arcrank >= 0))";
  119. // 自定义排序
  120. $orderby = input('param.orderby/s');
  121. $orderway = input('param.orderway/s');
  122. if (!empty($orderby) && !empty($orderway)) {
  123. $orderby = "a.{$orderby} {$orderway}, a.aid desc";
  124. } else {
  125. $orderby = "a.aid desc";
  126. }
  127. // 数据查询,搜索出主键ID的值
  128. $SqlQuery = $this->archives_db->alias('a')->where($condition)->where($conditionNew)->fetchSql()->count('aid');
  129. $count = Db::name('sql_cache_table')->where(['sql_md5'=>md5($SqlQuery)])->getField('sql_result');
  130. $count = ($count < 0) ? 0 : $count;
  131. if (empty($count)) {
  132. $count = $this->archives_db->alias('a')->where($condition)->where($conditionNew)->count('aid');
  133. /*添加查询执行语句到mysql缓存表*/
  134. $SqlCacheTable = [
  135. 'sql_name' => '|' . $this->table . '|' . $this->channeltype . '|',
  136. 'sql_result' => $count,
  137. 'sql_md5' => md5($SqlQuery),
  138. 'sql_query' => $SqlQuery,
  139. 'add_time' => getTime(),
  140. 'update_time' => getTime(),
  141. ];
  142. if (!empty($FlagNew)) $SqlCacheTable['sql_name'] = $SqlCacheTable['sql_name'] . $FlagNew . '|';
  143. if (!empty($typeid)) $SqlCacheTable['sql_name'] = $SqlCacheTable['sql_name'] . $typeid . '|';
  144. if (!empty($keywords)) $SqlCacheTable['sql_name'] = '|custom|keywords|';
  145. Db::name('sql_cache_table')->insertGetId($SqlCacheTable);
  146. /*END*/
  147. }
  148. $Page = new Page($count, config('paginate.list_rows'));
  149. $list = [];
  150. if (!empty($count)) {
  151. $limit = $count > config('paginate.list_rows') ? $Page->firstRow.','.$Page->listRows : $count;
  152. $list = $this->archives_db
  153. ->field("a.aid")
  154. ->alias('a')
  155. ->where($condition)
  156. ->where($conditionNew)
  157. ->order($orderby)
  158. ->limit($limit)
  159. ->getAllWithIndex('aid');
  160. if (!empty($list)) {
  161. $aids = array_keys($list);
  162. $fields = "b.*, a.*, a.aid as aid";
  163. $row = $this->archives_db
  164. ->field($fields)
  165. ->alias('a')
  166. ->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
  167. ->where('a.aid', 'in', $aids)
  168. ->getAllWithIndex('aid');
  169. foreach ($list as $key => $val) {
  170. $row[$val['aid']]['arcurl'] = get_arcurl($row[$val['aid']]);
  171. $row[$val['aid']]['litpic'] = handle_subdir_pic($row[$val['aid']]['litpic']);
  172. $list[$key] = $row[$val['aid']];
  173. }
  174. }
  175. }
  176. $show = $Page->show();
  177. $assign_data['page'] = $show;
  178. $assign_data['list'] = $list;
  179. $assign_data['pager'] = $Page;
  180. $assign_data['typeid'] = $typeid;
  181. $assign_data['tab'] = input('param.tab/d', 3);// 选项卡
  182. $assign_data['archives_flags'] = model('ArchivesFlag')->getList();// 文档属性
  183. $assign_data['arctype_info'] = $typeid > 0 ? Db::name('arctype')->field('typename')->find($typeid) : [];// 当前栏目信息
  184. $this->assign($assign_data);
  185. return $this->fetch();
  186. }
  187. /**
  188. * 添加
  189. */
  190. public function add()
  191. {
  192. $admin_info = session('admin_info');
  193. $auth_role_info = $admin_info['auth_role_info'];
  194. $this->assign('auth_role_info', $auth_role_info);
  195. $this->assign('admin_info', $admin_info);
  196. if (IS_POST) {
  197. $post = input('post.');
  198. model('Archives')->editor_auto_210607($post);
  199. /* 处理TAG标签 */
  200. if (!empty($post['tags_new'])) {
  201. $post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
  202. unset($post['tags_new']);
  203. }
  204. $post['tags'] = explode(',', $post['tags']);
  205. $post['tags'] = array_unique($post['tags']);
  206. $post['tags'] = implode(',', $post['tags']);
  207. /* END */
  208. /*获取第一个html类型的内容,作为文档的内容来截取SEO描述*/
  209. $contentField = Db::name('channelfield')->where([
  210. 'channel_id' => $this->channeltype,
  211. 'dtype' => 'htmltext',
  212. ])->getField('name');
  213. $content = empty($post['addonFieldExt'][$contentField]) ? '' : htmlspecialchars_decode($post['addonFieldExt'][$contentField]);
  214. /*--end*/
  215. // 根据标题自动提取相关的关键字
  216. $seo_keywords = $post['seo_keywords'];
  217. if (!empty($seo_keywords)) {
  218. $seo_keywords = str_replace(',', ',', $seo_keywords);
  219. } else {
  220. // $seo_keywords = get_split_word($post['title'], $content);
  221. }
  222. // 自动获取内容第一张图片作为封面图
  223. $is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
  224. $litpic = '';
  225. if ($is_remote == 1) {
  226. $litpic = $post['litpic_remote'];
  227. } else {
  228. $litpic = $post['litpic_local'];
  229. }
  230. if (empty($litpic)) {
  231. $litpic = get_html_first_imgurl($content);
  232. }
  233. $post['litpic'] = $litpic;
  234. /*是否有封面图*/
  235. if (empty($post['litpic'])) {
  236. $is_litpic = 0; // 无封面图
  237. } else {
  238. $is_litpic = 1; // 有封面图
  239. }
  240. // SEO描述
  241. $seo_description = '';
  242. if (empty($post['seo_description']) && !empty($content)) {
  243. $seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
  244. } else {
  245. $seo_description = $post['seo_description'];
  246. }
  247. // 外部链接跳转
  248. $jumplinks = '';
  249. $is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
  250. if (intval($is_jump) > 0) {
  251. $jumplinks = $post['jumplinks'];
  252. }
  253. // 模板文件,如果文档模板名与栏目指定的一致,默认就为空。让它跟随栏目的指定而变
  254. if ($post['type_tempview'] == $post['tempview']) {
  255. unset($post['type_tempview']);
  256. unset($post['tempview']);
  257. }
  258. //处理自定义文件名,仅由字母数字下划线和短横杆组成,大写强制转换为小写
  259. $htmlfilename = trim($post['htmlfilename']);
  260. if (!empty($htmlfilename)) {
  261. $htmlfilename = preg_replace("/[^\x{4e00}-\x{9fa5}\w\-]+/u", "-", $htmlfilename);
  262. // $htmlfilename = strtolower($htmlfilename);
  263. //判断是否存在相同的自定义文件名
  264. $map = [
  265. 'htmlfilename' => $htmlfilename,
  266. 'lang' => $this->admin_lang,
  267. ];
  268. if (!empty($post['typeid'])) {
  269. $map['typeid'] = array('eq', $post['typeid']);
  270. }
  271. $filenameCount = Db::name('archives')->where($map)->count();
  272. if (!empty($filenameCount)) {
  273. $this->error("同栏目下,自定义文件名已存在!");
  274. } else if (preg_match('/^(\d+)$/i', $htmlfilename)) {
  275. $this->error("自定义文件名不能纯数字,会与文档ID冲突!");
  276. }
  277. } else {
  278. // 处理外贸链接
  279. if (is_dir('./weapp/Waimao/')) {
  280. $waimaoLogic = new \weapp\Waimao\logic\WaimaoLogic;
  281. $waimaoLogic->get_new_htmlfilename($htmlfilename, $post, 'add', $this->globalConfig);
  282. }
  283. }
  284. $post['htmlfilename'] = $htmlfilename;
  285. //做自动通过审核判断
  286. if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
  287. $post['arcrank'] = -1;
  288. }
  289. // 副栏目
  290. if (isset($post['stypeid'])) {
  291. $post['stypeid'] = preg_replace('/([^\d\,\,]+)/i', ',', $post['stypeid']);
  292. $post['stypeid'] = str_replace(',', ',', $post['stypeid']);
  293. $post['stypeid'] = trim($post['stypeid'], ',');
  294. $post['stypeid'] = str_replace(",{$post['typeid']},", ',', ",{$post['stypeid']},");
  295. $post['stypeid'] = trim($post['stypeid'], ',');
  296. }
  297. //查询排序 等级
  298. $sort_order = Db::name('archives')->where('aid','=',(int)$post['level_group_name'])->value('sort_order');
  299. //var_dump($post['addonFieldExt']);die;
  300. //获取文档文件后缀
  301. if(!empty($post['addonFieldExt']['down_eyou_remote'])){
  302. $file = explode('.',$post['addonFieldExt']['down_eyou_remote']);
  303. $ext = end($file);
  304. }else{
  305. $ext = '';
  306. }
  307. if(!empty($post['addonFieldExt']['down_eyou_local'])){
  308. $file = explode('.',$post['addonFieldExt']['down_eyou_local']);
  309. $ext = end($file);
  310. }else{
  311. $ext = '';
  312. }
  313. // --存储数据
  314. $newData = array(
  315. 'typeid'=> empty($post['typeid']) ? 0 : $post['typeid'],
  316. 'channel' => $this->channeltype,
  317. 'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
  318. 'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
  319. 'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
  320. 'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
  321. 'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
  322. 'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
  323. 'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
  324. 'editor_remote_img_local'=> empty($post['editor_remote_img_local']) ? 0 : $post['editor_remote_img_local'],
  325. 'editor_img_clear_link' => empty($post['editor_img_clear_link']) ? 0 : $post['editor_img_clear_link'],
  326. 'is_jump' => $is_jump,
  327. 'is_litpic' => $is_litpic,
  328. 'jumplinks' => $jumplinks,
  329. 'origin' => empty($post['origin']) ? '网络' : $post['origin'],
  330. 'seo_keywords' => $seo_keywords,
  331. 'seo_description' => $seo_description,
  332. 'admin_id' => session('admin_info.admin_id'),
  333. 'lang' => $this->admin_lang,
  334. 'sort_order' => 100,
  335. 'crossed_price' => empty($post['crossed_price']) ? 0 : floatval($post['crossed_price']),
  336. 'add_time' => strtotime($post['add_time']),
  337. 'update_time' => strtotime($post['add_time']),
  338. 'product_id' => (int)$post['product_id'], //增加
  339. 'lunwen_id' => (int)$post['lunwen_id'], //增加
  340. 'level_group_id' => (int)$post['level_group_id'],
  341. 'level_id' => (int)$post['level_group_name'],
  342. 'level' => (int)$sort_order,
  343. 'product_tag_id' => (int)$post['product_tag_id'],
  344. 'area_tag_id' => (int)$post['area_tag_id'],
  345. 'ext' => $ext
  346. );
  347. $data = array_merge($post, $newData);
  348. $aid = $this->archives_db->insertGetId($data);
  349. $_POST['aid'] = $aid;
  350. if ($aid) {
  351. // ---------后置操作
  352. model('Custom')->afterSave($aid, $data, 'add', $this->table);
  353. // 添加查询执行语句到mysql缓存表
  354. model('SqlCacheTable')->InsertSqlCacheTable();
  355. // ---------end
  356. adminLog('新增数据:'.$data['title']);
  357. //新增序列号 (论文期刊和论文模板)
  358. //只考虑新增场景 其他的用api修复
  359. if((int)$newData['typeid'] === 116 || (int)$newData['typeid'] === 123 || (int)$newData['typeid'] === 127 || (int)$newData['typeid'] === 128){
  360. $last = Db::name('seo_number')->where([
  361. "type" => 4,
  362. "tid" => (int)$post['typeid'],
  363. 'topid' => 0,
  364. 'parentid' => 0,
  365. 'area_id' => 0,
  366. ])->order('number desc')->find();
  367. if(empty($last['number'])){
  368. $num = 1;
  369. }else{
  370. $num = (int)$last['number'] + 1;
  371. }
  372. $in_data = [
  373. "type" => 4, //产品类型
  374. "aid" => $aid, //实际的ID
  375. "tid" => (int)$post['typeid'], //属于哪个栏目的
  376. 'is_del' => 0,
  377. 'is_kan' => 0, // 0正常 1审核
  378. 'status' => 1,
  379. 'area_id' => 0,
  380. 'topid' => 0,
  381. 'parentid' => 0,
  382. 'number' => $num
  383. ];
  384. Db::name('seo_number')->insert($in_data);
  385. }else if((int)$newData['typeid'] === 126 || (int)$newData['typeid'] === 825 || (int)$newData['typeid'] === 826){
  386. //资料文档
  387. $last = Db::name('seo_number')->where([
  388. "type" => 5,
  389. "tid" => (int)$post['typeid'],
  390. 'topid' => 0,
  391. 'parentid' => 0,
  392. 'area_id' => (int)$post['province_id'], //如果是0的话 后续也不能改
  393. ])->order('number desc')->find();
  394. if(empty($last['number'])){
  395. $num = 1;
  396. }else{
  397. $num = (int)$last['number'] + 1;
  398. }
  399. $in_data = [
  400. "type" => 5, //产品类型
  401. "aid" => $aid, //实际的ID
  402. "tid" => (int)$post['typeid'], //属于哪个栏目的
  403. 'is_del' => 0,
  404. 'is_kan' => 0, // 0正常 1审核
  405. 'status' => 1,
  406. 'area_id' => (int)$post['province_id'],
  407. 'topid' => 0,
  408. 'parentid' => 0,
  409. 'number' => $num
  410. ];
  411. Db::name('seo_number')->insert($in_data);
  412. }else if((int)$newData['typeid'] === 120 || (int)$newData['typeid'] === 118 || (int)$newData['typeid'] === 122 || (int)$newData['typeid'] === 11100000 || (int)$newData['typeid'] === 133 || (int)$newData['typeid'] === 132 || (int)$newData['typeid'] === 131 || (int)$newData['typeid'] === 306){
  413. //案例 申报 职称相关问题 常见问题汇总 历年真题题库 答辩问题汇总 防骗指南 职称补贴
  414. $last = Db::name('seo_number')->where([
  415. "type" => 2,
  416. "tid" => (int)$post['typeid'],
  417. 'topid' => 0,
  418. 'parentid' => 0,
  419. 'area_id' => 0,
  420. ])->order('number desc')->find();
  421. if(empty($last['number'])){
  422. $num = 1;
  423. }else{
  424. $num = (int)$last['number'] + 1;
  425. }
  426. $in_data = [
  427. "type" => 2, //文章类型
  428. "aid" => $aid, //实际的ID
  429. "tid" => (int)$post['typeid'], //属于哪个栏目的
  430. 'is_del' => 0,
  431. 'is_kan' => 0, // 0正常 1审核
  432. 'status' => 1,
  433. 'area_id' => 0,
  434. 'topid' => 0,
  435. 'parentid' => 0,
  436. 'number' => $num
  437. ];
  438. Db::name('seo_number')->insert($in_data);
  439. }else if((int)$newData['typeid'] === 115 || (int)$newData['typeid'] === 117 || (int)$newData['typeid'] === 111){
  440. //政策资讯 //评审攻略 //常见问题
  441. $where6 = [
  442. "type" => 2,
  443. "tid" => (int)$post['typeid'],
  444. 'topid' => 0,
  445. 'parentid' => 0,
  446. 'area_id' => (int)$post['province_id'], //如果是0的话 后续也不能改
  447. 'city_id' => (int)$post['city_id'], //如果是0的话 后续也不能改
  448. ];
  449. /*if((int)$post['city_id'] > 0){
  450. $where6['city_id'] = (int)$post['city_id'];
  451. }*/
  452. //攻略和政策资讯
  453. $last = Db::name('seo_number')->where($where6)->order('number desc')->find();
  454. if(empty($last['number'])){
  455. $num = 1;
  456. }else{
  457. $num = (int)$last['number'] + 1;
  458. }
  459. $in_data = [
  460. "type" => 2, //产品类型
  461. "aid" => $aid, //实际的ID
  462. "tid" => (int)$post['typeid'], //属于哪个栏目的
  463. 'is_del' => 0,
  464. 'is_kan' => 0, // 0正常 1审核
  465. 'status' => 1,
  466. 'area_id' => (int)$post['province_id'],
  467. 'city_id' => (int)$post['city_id'],
  468. 'topid' => 0,
  469. 'parentid' => 0,
  470. 'number' => $num
  471. ];
  472. Db::name('seo_number')->insert($in_data);
  473. }else if((int)$newData['typeid'] === 1231 || (int)$newData['typeid'] === 1233 || (int)$newData['typeid'] === 1234){
  474. //新闻资讯 //业绩材料 //一键测评
  475. $where6 = [
  476. "type" => 2,
  477. "tid" => (int)$post['typeid'],
  478. 'topid' => 0,
  479. 'parentid' => 0,
  480. 'area_id' => 0, //(int)$post['province_id'] //如果是0的话 后续也不能改
  481. 'city_id' => 0, //(int)$post['city_id'] //如果是0的话 后续也不能改
  482. ];
  483. /*if((int)$post['city_id'] > 0){
  484. $where6['city_id'] = (int)$post['city_id'];
  485. }*/
  486. //攻略和政策资讯
  487. $last = Db::name('seo_number')->where($where6)->order('number desc')->find();
  488. if(empty($last['number'])){
  489. $num = 1;
  490. }else{
  491. $num = (int)$last['number'] + 1;
  492. }
  493. $in_data = [
  494. "type" => 2, //产品类型
  495. "aid" => $aid, //实际的ID
  496. "tid" => (int)$post['typeid'], //属于哪个栏目的
  497. 'is_del' => 0,
  498. 'is_kan' => 0, // 0正常 1审核
  499. 'status' => 1,
  500. 'area_id' => 0, //(int)$post['province_id']
  501. 'city_id' => 0, //(int)$post['city_id']
  502. 'topid' => 0,
  503. 'parentid' => 0,
  504. 'number' => $num
  505. ];
  506. Db::name('seo_number')->insert($in_data);
  507. }else if((int)$newData['typeid'] === 1232){
  508. //评审政策
  509. //按区域
  510. $where6 = [
  511. "type" => 2,
  512. "tid" => (int)$post['typeid'],
  513. 'topid' => 0,
  514. 'parentid' => 0,
  515. 'area_id' => (int)$post['area_tag_id'], //(int)$post['province_id'] //如果是0的话 后续也不能改
  516. 'city_id' => 0, //(int)$post['city_id'] //如果是0的话 后续也不能改
  517. ];
  518. /*if((int)$post['city_id'] > 0){
  519. $where6['city_id'] = (int)$post['city_id'];
  520. }*/
  521. //攻略和政策资讯
  522. $last = Db::name('seo_number')->where($where6)->order('number desc')->find();
  523. if(empty($last['number'])){
  524. $num = 1;
  525. }else{
  526. $num = (int)$last['number'] + 1;
  527. }
  528. $in_data = [
  529. "type" => 2, //产品类型
  530. "aid" => $aid, //实际的ID
  531. "tid" => (int)$post['typeid'], //属于哪个栏目的
  532. 'is_del' => 0,
  533. 'is_kan' => 0, // 0正常 1审核
  534. 'status' => 1,
  535. 'area_id' => (int)$post['area_tag_id'], //(int)$post['province_id']
  536. 'city_id' => 0, //(int)$post['city_id']
  537. 'topid' => 0,
  538. 'parentid' => 0,
  539. 'number' => $num
  540. ];
  541. Db::name('seo_number')->insert($in_data);
  542. }else{
  543. //其他
  544. }
  545. // 生成静态页面代码
  546. $successData = [
  547. 'aid' => $aid,
  548. 'tid' => $post['typeid'],
  549. ];
  550. $this->success("操作成功!", null, $successData);
  551. }
  552. $this->error("操作失败!");
  553. }
  554. $typeid = input('param.typeid/d', 0);
  555. $assign_data['typeid'] = $typeid; // 栏目ID
  556. //列出产品
  557. $list = Db::name('arctype_cat')
  558. ->where('parent_id','=',$typeid)
  559. ->where('type','=','产品')
  560. ->where('is_del','=',0)
  561. ->order('id asc')
  562. ->select();
  563. //var_dump($list);
  564. $this->assign('pro_list',$list);
  565. //列出职称级别
  566. $level_group_list = Db::name('arctype')
  567. ->field('id,parent_id,typename')
  568. ->where('parent_id','=',53)
  569. ->where('is_del','=',0)
  570. ->order('id asc')
  571. ->select();
  572. //var_dump($list);
  573. $this->assign('level_group_list',$level_group_list);
  574. //列出
  575. $level_group_name = Db::name('archives')
  576. ->field('aid,typeid,title')
  577. ->where('typeid','=',$level_group_list[0]['id'])
  578. ->where('is_del','=',0)
  579. ->order('sort_order asc,aid asc')
  580. ->select();
  581. $this->assign('level_group_name',$level_group_name);
  582. $product_id = input('param.product_id/d', 0);
  583. //var_dump($product_id);
  584. $assign_data['product_id'] = $product_id; //关联产品ID 默认都是0
  585. //var_dump($typeid);
  586. if((int)$typeid === 126 || (int)$typeid === 825 || (int)$typeid === 826){
  587. //列出职称标签
  588. $product_tag = Db::name('archives')
  589. ->field('aid,typeid,title')
  590. ->where('typeid','=',58)
  591. ->where('is_del','=',0)
  592. ->order('sort_order asc,aid asc')
  593. ->select();
  594. }else{
  595. //列出职称标签
  596. $cat = Db::name('arctype')->where(['parent_id'=>369,'article_id'=>$typeid])->find();
  597. if(empty($cat)){
  598. $cat_id = 371;
  599. }else{
  600. $cat_id = $cat['id'];
  601. }
  602. $product_tag = Db::name('archives')
  603. ->field('aid,typeid,title')
  604. ->where('typeid','=',$cat_id)
  605. ->where('is_del','=',0)
  606. ->order('sort_order asc,aid asc')
  607. ->select();
  608. }
  609. $this->assign('product_tag',$product_tag);
  610. //调用区域信息
  611. $product_area = Db::name('citysite')->where(['level'=>1])->select();
  612. $this->assign('product_area_data',$product_area);
  613. // 栏目信息
  614. $arctypeInfo = Db::name('arctype')->find($typeid);
  615. $topid = $arctypeInfo['topid'];
  616. $assign_data['topid'] = $topid;
  617. //查询区域id
  618. $catid = $arctypeInfo['area_id'];
  619. if((int)$catid === 0){
  620. $catid = input('param.catid/d', 0);
  621. }
  622. $assign_data['catid'] = $catid;
  623. //var_dump($catid);
  624. /*允许发布文档列表的栏目*/ //加入区域
  625. $arctype_html = allow_release_arctype($typeid, array($this->channeltype),true,[],false,$catid);
  626. $assign_data['arctype_html'] = $arctype_html;
  627. /*--end*/
  628. // 阅读权限
  629. $arcrank_list = get_arcrank_list();
  630. $assign_data['arcrank_list'] = $arcrank_list;
  631. /*获取可显示的系统字段*/
  632. $condition['ifcontrol'] = 0;
  633. $condition['channel_id'] = $this->channeltype;
  634. $channelfield_row = Db::name('channelfield')->where($condition)->field('name,ifeditable')->getAllWithIndex('name');
  635. $assign_data['channelfield_row'] = $channelfield_row;
  636. /*--end*/
  637. /*模板列表*/
  638. $archivesLogic = new \app\admin\logic\ArchivesLogic;
  639. $templateList = $archivesLogic->getTemplateList($this->nid);
  640. $this->assign('templateList', $templateList);
  641. /*--end*/
  642. /*默认模板文件*/
  643. $tempview = 'view_'.$this->nid.'.'.config('template.view_suffix');
  644. !empty($arctypeInfo['tempview']) && $tempview = $arctypeInfo['tempview'];
  645. $this->assign('tempview', $tempview);
  646. /*--end*/
  647. // 文档默认浏览量
  648. $globalConfig = tpCache('global');
  649. if (isset($globalConfig['other_arcclick']) && 0 <= $globalConfig['other_arcclick']) {
  650. $arcclick_arr = explode("|", $globalConfig['other_arcclick']);
  651. if (count($arcclick_arr) > 1) {
  652. $assign_data['rand_arcclick'] = mt_rand($arcclick_arr[0], $arcclick_arr[1]);
  653. } else {
  654. $assign_data['rand_arcclick'] = intval($arcclick_arr[0]);
  655. }
  656. }else{
  657. $arcclick_config['other_arcclick'] = '500|1000';
  658. tpCache('other', $arcclick_config);
  659. $assign_data['rand_arcclick'] = mt_rand(500, 1000);
  660. }
  661. // URL模式
  662. $tpcache = config('tpcache');
  663. $assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
  664. /*文档属性*/
  665. $assign_data['archives_flags'] = model('ArchivesFlag')->getList();
  666. $channelRow = Db::name('channeltype')->where('id', $this->channeltype)->find();
  667. $assign_data['channelRow'] = $channelRow;
  668. // 来源列表
  669. $system_originlist = tpSetting('system.system_originlist');
  670. $system_originlist = json_decode($system_originlist, true);
  671. $system_originlist = !empty($system_originlist) ? $system_originlist : [];
  672. $assign_data['system_originlist_0'] = !empty($system_originlist) ? $system_originlist[0] : "";
  673. $assign_data['system_originlist_str'] = implode(PHP_EOL, $system_originlist);
  674. // 多站点,当用站点域名访问后台,发布文档自动选择当前所属区域
  675. model('Citysite')->auto_location_select($assign_data);
  676. $this->assign($assign_data);
  677. return $this->fetch();
  678. }
  679. /**
  680. * 编辑
  681. */
  682. public function edit()
  683. {
  684. $admin_info = session('admin_info');
  685. $auth_role_info = $admin_info['auth_role_info'];
  686. $this->assign('auth_role_info', $auth_role_info);
  687. $this->assign('admin_info', $admin_info);
  688. if (IS_POST) {
  689. $post = input('post.');
  690. model('Archives')->editor_auto_210607($post);
  691. $post['aid'] = intval($post['aid']);
  692. $typeid = input('post.typeid/d', 0);
  693. /* 处理TAG标签 */
  694. if (!empty($post['tags_new'])) {
  695. $post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
  696. unset($post['tags_new']);
  697. }
  698. $post['tags'] = explode(',', $post['tags']);
  699. $post['tags'] = array_unique($post['tags']);
  700. $post['tags'] = implode(',', $post['tags']);
  701. /* END */
  702. /*获取第一个html类型的内容,作为文档的内容来截取SEO描述*/
  703. $contentField = Db::name('channelfield')->where([
  704. 'channel_id' => $this->channeltype,
  705. 'dtype' => 'htmltext',
  706. ])->getField('name');
  707. $content = empty($post['addonFieldExt'][$contentField]) ? '' : htmlspecialchars_decode($post['addonFieldExt'][$contentField]);
  708. /*--end*/
  709. // 根据标题自动提取相关的关键字
  710. $seo_keywords = $post['seo_keywords'];
  711. if (!empty($seo_keywords)) {
  712. $seo_keywords = str_replace(',', ',', $seo_keywords);
  713. } else {
  714. // $seo_keywords = get_split_word($post['title'], $content);
  715. }
  716. // 自动获取内容第一张图片作为封面图
  717. $is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
  718. $litpic = '';
  719. if ($is_remote == 1) {
  720. $litpic = $post['litpic_remote'];
  721. } else {
  722. $litpic = $post['litpic_local'];
  723. }
  724. if (empty($litpic)) {
  725. $litpic = get_html_first_imgurl($content);
  726. }
  727. $post['litpic'] = $litpic;
  728. /*是否有封面图*/
  729. if (empty($post['litpic'])) {
  730. $is_litpic = 0; // 无封面图
  731. } else {
  732. $is_litpic = !empty($post['is_litpic']) ? $post['is_litpic'] : 0; // 有封面图
  733. }
  734. // 勾选后SEO描述将随正文内容更新
  735. $basic_update_seo_description = empty($post['basic_update_seo_description']) ? 0 : 1;
  736. if (is_language()) {
  737. $langRow = \think\Db::name('language')->order('id asc')
  738. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  739. ->select();
  740. foreach ($langRow as $key => $val) {
  741. tpCache('basic', ['basic_update_seo_description'=>$basic_update_seo_description], $val['mark']);
  742. }
  743. } else {
  744. tpCache('basic', ['basic_update_seo_description'=>$basic_update_seo_description]);
  745. }
  746. /*--end*/
  747. // SEO描述
  748. $seo_description = '';
  749. if (!empty($basic_update_seo_description) || empty($post['seo_description'])) {
  750. $seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
  751. } else {
  752. $seo_description = $post['seo_description'];
  753. }
  754. // --外部链接
  755. $jumplinks = '';
  756. $is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
  757. if (intval($is_jump) > 0) {
  758. $jumplinks = $post['jumplinks'];
  759. }
  760. // 模板文件,如果文档模板名与栏目指定的一致,默认就为空。让它跟随栏目的指定而变
  761. if ($post['type_tempview'] == $post['tempview']) {
  762. unset($post['type_tempview']);
  763. unset($post['tempview']);
  764. }
  765. // 同步栏目切换模型之后的文档模型
  766. $channel = Db::name('arctype')->where(['id'=>$typeid])->getField('current_channel');
  767. //处理自定义文件名,仅由字母数字下划线和短横杆组成,大写强制转换为小写
  768. $htmlfilename = trim($post['htmlfilename']);
  769. if (!empty($htmlfilename)) {
  770. $htmlfilename = preg_replace("/[^\x{4e00}-\x{9fa5}\w\-]+/u", "-", $htmlfilename);
  771. // $htmlfilename = strtolower($htmlfilename);
  772. //判断是否存在相同的自定义文件名
  773. $map = [
  774. 'aid' => ['NEQ', $post['aid']],
  775. 'htmlfilename' => $htmlfilename,
  776. 'lang' => $this->admin_lang,
  777. ];
  778. if (!empty($post['typeid'])) {
  779. $map['typeid'] = array('eq', $post['typeid']);
  780. }
  781. $filenameCount = Db::name('archives')->where($map)->count();
  782. if (!empty($filenameCount)) {
  783. $this->error("同栏目下,自定义文件名已存在!");
  784. } else if (preg_match('/^(\d+)$/i', $htmlfilename)) {
  785. $this->error("自定义文件名不能纯数字,会与文档ID冲突!");
  786. }
  787. } else {
  788. // 处理外贸链接
  789. if (is_dir('./weapp/Waimao/')) {
  790. $waimaoLogic = new \weapp\Waimao\logic\WaimaoLogic;
  791. $waimaoLogic->get_new_htmlfilename($htmlfilename, $post, 'edit', $this->globalConfig);
  792. }
  793. }
  794. $post['htmlfilename'] = $htmlfilename;
  795. //做未通过审核文档不允许修改文档状态操作
  796. if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
  797. $old_archives_arcrank = Db::name('archives')->where(['aid' => $post['aid']])->getField("arcrank");
  798. if ($old_archives_arcrank < 0) {
  799. unset($post['arcrank']);
  800. }
  801. }
  802. // 副栏目
  803. if (isset($post['stypeid'])) {
  804. $post['stypeid'] = preg_replace('/([^\d\,\,]+)/i', ',', $post['stypeid']);
  805. $post['stypeid'] = str_replace(',', ',', $post['stypeid']);
  806. $post['stypeid'] = trim($post['stypeid'], ',');
  807. $post['stypeid'] = str_replace(",{$typeid},", ',', ",{$post['stypeid']},");
  808. $post['stypeid'] = trim($post['stypeid'], ',');
  809. }
  810. //查询排序 等级
  811. $sort_order = Db::name('archives')->where('aid','=',(int)$post['level_group_name'])->value('sort_order');
  812. //获取文档文件后缀
  813. if(!empty($post['addonFieldExt']['down_eyou_remote'])){
  814. $file = explode('.',$post['addonFieldExt']['down_eyou_remote']);
  815. $ext = end($file);
  816. }else{
  817. $ext = '';
  818. }
  819. if(!empty($post['addonFieldExt']['down_eyou_local'])){
  820. $file = explode('.',$post['addonFieldExt']['down_eyou_local']);
  821. $ext = end($file);
  822. }else{
  823. $ext = '';
  824. }
  825. // --存储数据
  826. $newData = array(
  827. 'typeid'=> $typeid,
  828. 'channel' => $channel,
  829. 'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
  830. 'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
  831. 'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
  832. 'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
  833. 'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
  834. 'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
  835. 'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
  836. 'editor_remote_img_local'=> empty($post['editor_remote_img_local']) ? 0 : $post['editor_remote_img_local'],
  837. 'editor_img_clear_link' => empty($post['editor_img_clear_link']) ? 0 : $post['editor_img_clear_link'],
  838. 'is_jump' => $is_jump,
  839. 'is_litpic' => $is_litpic,
  840. 'jumplinks' => $jumplinks,
  841. 'seo_keywords' => $seo_keywords,
  842. 'seo_description' => $seo_description,
  843. 'crossed_price' => empty($post['crossed_price']) ? 0 : floatval($post['crossed_price']),
  844. 'add_time' => strtotime($post['add_time']),
  845. 'update_time' => getTime(),
  846. 'product_id' => (int)$post['product_id'], //增加
  847. 'lunwen_id' => (int)$post['lunwen_id'], //增加
  848. 'level_group_id' => (int)$post['level_group_id'],
  849. 'level_id' => (int)$post['level_group_name'],
  850. 'level' => (int)$sort_order,
  851. 'product_tag_id' => (int)$post['product_tag_id'],
  852. 'area_tag_id' => (int)$post['area_tag_id'],
  853. 'ext' => $ext
  854. );
  855. $data = array_merge($post, $newData);
  856. if((int)$typeid === 126 || (int)$typeid === 825 || (int)$typeid === 826){
  857. //资料文档的时候
  858. //不更新 区域信息
  859. unset($data['province_id']);
  860. unset($data['city_id']);
  861. unset($data['area_id']);
  862. }
  863. if((int)$typeid === 117 || (int)$typeid === 115 || (int)$typeid === 111){
  864. //评审攻略和政策资讯 增加常见问题
  865. //不更新 区域信息
  866. unset($data['province_id']);
  867. unset($data['city_id']);
  868. unset($data['area_id']);
  869. }
  870. $arctype_par = Db::name('arctype')->field('id,parent_id')->where('id','=',$typeid)->find();
  871. if((int)$arctype_par['parent_id'] === 369){
  872. //文章标签
  873. //不更新 区域信息
  874. unset($data['province_id']);
  875. unset($data['city_id']);
  876. unset($data['area_id']);
  877. }
  878. //var_dump($post['addonFieldExt']);die;
  879. $r = Db::name('archives')->where([
  880. 'aid' => $data['aid'],
  881. 'lang' => $this->admin_lang,
  882. ])->update($data);
  883. if ($r) {
  884. // ---------后置操作
  885. model('Custom')->afterSave($data['aid'], $data, 'edit', $this->table);
  886. // ---------end
  887. adminLog('编辑文章:'.$data['title']);
  888. $numinfo = [
  889. //'is_del' => $data['is_del'],
  890. 'is_kan' => $data['arcrank'],
  891. //'status' => $data['status'],
  892. ];
  893. //文档aid 对应 序列号aid
  894. Db::name('seo_number')->where('aid','=',$data['aid'])->update($numinfo);
  895. // 生成静态页面代码
  896. $successData = [
  897. 'aid' => $data['aid'],
  898. 'tid' => $typeid,
  899. ];
  900. $this->success("操作成功!", null, $successData);
  901. }
  902. $this->error("操作失败!");
  903. }
  904. $assign_data = array();
  905. $id = input('id/d');
  906. $info = model('Custom')->getInfo($id, null, false);
  907. if (empty($info)) {
  908. $this->error('数据不存在,请联系管理员!');
  909. exit;
  910. }
  911. /*兼容采集没有归属栏目的文档*/
  912. if (empty($info['channel'])) {
  913. $channelRow = Db::name('channeltype')->field('id as channel')
  914. ->where('id',$this->channeltype)
  915. ->find();
  916. $info = array_merge($info, $channelRow);
  917. }
  918. /*--end*/
  919. $typeid = $info['typeid'];
  920. $assign_data['typeid'] = $typeid;
  921. //查找产品
  922. $list = Db::name('arctype_cat')
  923. ->where('parent_id','=',$typeid)
  924. ->where('type','=','产品')
  925. ->where('is_del','=',0)
  926. ->order('id asc')
  927. ->select();
  928. //var_dump($list);
  929. $this->assign('pro_list',$list);
  930. //列出职称级别
  931. $level_group_list = Db::name('arctype')
  932. ->field('id,parent_id,typename')
  933. ->where('parent_id','=',53)
  934. ->where('is_del','=',0)
  935. ->order('id asc')
  936. ->select();
  937. //var_dump($list);
  938. $this->assign('level_group_list',$level_group_list);
  939. //列出
  940. if((int)$info['level_group_id'] === 0){
  941. $level_group_id = $level_group_list[0]['id'];
  942. }else{
  943. $level_group_id = (int)$info['level_group_id'];
  944. }
  945. $level_group_name = Db::name('archives')
  946. ->field('aid,typeid,title')
  947. ->where('typeid','=',$level_group_id)
  948. ->where('is_del','=',0)
  949. ->order('sort_order asc,aid asc')
  950. ->select();
  951. $this->assign('level_group_name',$level_group_name);
  952. if((int)$typeid === 126 || (int)$typeid === 825 || (int)$typeid === 826){
  953. //列出职称标签
  954. $product_tag = Db::name('archives')
  955. ->field('aid,typeid,title')
  956. ->where('typeid','=',58)
  957. ->where('is_del','=',0)
  958. ->order('sort_order asc,aid asc')
  959. ->select();
  960. }else{
  961. //列出职称标签
  962. $cat = Db::name('arctype')->where(['parent_id'=>369,'article_id'=>$typeid])->find();
  963. if(empty($cat)){
  964. $cat_id = 371;
  965. }else{
  966. $cat_id = $cat['id'];
  967. }
  968. $product_tag = Db::name('archives')
  969. ->field('aid,typeid,title')
  970. ->where('typeid','=',$cat_id)
  971. ->where('is_del','=',0)
  972. ->order('sort_order asc,aid asc')
  973. ->select();
  974. }
  975. $this->assign('product_tag',$product_tag);
  976. //调用区域信息
  977. $product_area = Db::name('citysite')->where(['level'=>1])->select();
  978. $this->assign('product_area_data',$product_area);
  979. // 副栏目
  980. $stypeid_arr = [];
  981. if (!empty($info['stypeid'])) {
  982. $info['stypeid'] = trim($info['stypeid'], ',');
  983. $stypeid_arr = Db::name('arctype')->field('id,typename')->where(['id'=>['IN', $info['stypeid']],'is_del'=>0])->select();
  984. }
  985. $assign_data['stypeid_arr'] = $stypeid_arr;
  986. // 栏目信息
  987. $arctypeInfo = Db::name('arctype')->find($typeid);
  988. $topid = $arctypeInfo['topid'];
  989. $assign_data['topid'] = $topid;
  990. $info['channel'] = $arctypeInfo['current_channel'];
  991. if (is_http_url($info['litpic'])) {
  992. $info['is_remote'] = 1;
  993. $info['litpic_remote'] = handle_subdir_pic($info['litpic']);
  994. } else {
  995. $info['is_remote'] = 0;
  996. $info['litpic_local'] = handle_subdir_pic($info['litpic']);
  997. }
  998. // SEO描述
  999. // if (!empty($info['seo_description'])) {
  1000. // $info['seo_description'] = @msubstr(checkStrHtml($info['seo_description']), 0, config('global.arc_seo_description_length'), false);
  1001. // }
  1002. $assign_data['field'] = $info;
  1003. /*允许发布文档列表的栏目,文档所在模型以栏目所在模型为主,兼容切换模型之后的数据编辑*/
  1004. $arctype_html = allow_release_arctype($typeid, array($info['channel']));
  1005. $assign_data['arctype_html'] = $arctype_html;
  1006. /*--end*/
  1007. /*获取可显示的系统字段*/
  1008. $condition['ifcontrol'] = 0;
  1009. $condition['channel_id'] = $this->channeltype;
  1010. $channelfield_row = Db::name('channelfield')->where($condition)->field('name,ifeditable')->getAllWithIndex('name');
  1011. $assign_data['channelfield_row'] = $channelfield_row;
  1012. /*--end*/
  1013. // 阅读权限
  1014. $arcrank_list = get_arcrank_list();
  1015. $assign_data['arcrank_list'] = $arcrank_list;
  1016. /*模板列表*/
  1017. $archivesLogic = new \app\admin\logic\ArchivesLogic;
  1018. $templateList = $archivesLogic->getTemplateList($this->nid);
  1019. $this->assign('templateList', $templateList);
  1020. /*--end*/
  1021. /*默认模板文件*/
  1022. $tempview = $info['tempview'];
  1023. empty($tempview) && $tempview = $arctypeInfo['tempview'];
  1024. $this->assign('tempview', $tempview);
  1025. /*--end*/
  1026. // URL模式
  1027. $tpcache = config('tpcache');
  1028. $assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
  1029. /*文档属性*/
  1030. $assign_data['archives_flags'] = model('ArchivesFlag')->getList();
  1031. $channelRow = Db::name('channeltype')->where('id', $this->channeltype)->find();
  1032. $assign_data['channelRow'] = $channelRow;
  1033. // 来源列表
  1034. $system_originlist = tpSetting('system.system_originlist');
  1035. $system_originlist = json_decode($system_originlist, true);
  1036. $system_originlist = !empty($system_originlist) ? $system_originlist : [];
  1037. $assign_data['system_originlist_str'] = implode(PHP_EOL, $system_originlist);
  1038. $this->assign($assign_data);
  1039. return $this->fetch();
  1040. }
  1041. /**
  1042. * 删除
  1043. */
  1044. public function del()
  1045. {
  1046. $archivesLogic = new \app\admin\logic\ArchivesLogic;
  1047. $archivesLogic->del([], 0, 'custom');
  1048. }
  1049. //帮助
  1050. public function help()
  1051. {
  1052. $system_originlist = tpSetting('system.system_originlist');
  1053. $system_originlist = json_decode($system_originlist, true);
  1054. $system_originlist = !empty($system_originlist) ? $system_originlist : [];
  1055. $assign_data['system_originlist_str'] = implode(PHP_EOL, $system_originlist);
  1056. $this->channeltype = input('param.channel/d', 0);
  1057. $assign_data['channel'] = $this->channeltype ;
  1058. $this->assign($assign_data);
  1059. return $this->fetch();
  1060. }
  1061. }