Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Custom.php 49KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  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. // --存储数据
  300. $newData = array(
  301. 'typeid'=> empty($post['typeid']) ? 0 : $post['typeid'],
  302. 'channel' => $this->channeltype,
  303. 'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
  304. 'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
  305. 'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
  306. 'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
  307. 'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
  308. 'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
  309. 'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
  310. 'editor_remote_img_local'=> empty($post['editor_remote_img_local']) ? 0 : $post['editor_remote_img_local'],
  311. 'editor_img_clear_link' => empty($post['editor_img_clear_link']) ? 0 : $post['editor_img_clear_link'],
  312. 'is_jump' => $is_jump,
  313. 'is_litpic' => $is_litpic,
  314. 'jumplinks' => $jumplinks,
  315. 'origin' => empty($post['origin']) ? '网络' : $post['origin'],
  316. 'seo_keywords' => $seo_keywords,
  317. 'seo_description' => $seo_description,
  318. 'admin_id' => session('admin_info.admin_id'),
  319. 'lang' => $this->admin_lang,
  320. 'sort_order' => 100,
  321. 'crossed_price' => empty($post['crossed_price']) ? 0 : floatval($post['crossed_price']),
  322. 'add_time' => strtotime($post['add_time']),
  323. 'update_time' => strtotime($post['add_time']),
  324. 'product_id' => (int)$post['product_id'], //增加
  325. 'lunwen_id' => (int)$post['lunwen_id'], //增加
  326. 'level_group_id' => (int)$post['level_group_id'],
  327. 'level_id' => (int)$post['level_group_name'],
  328. 'level' => (int)$sort_order,
  329. 'product_tag_id' => (int)$post['product_tag_id'],
  330. 'area_tag_id' => (int)$post['area_tag_id'],
  331. );
  332. $data = array_merge($post, $newData);
  333. $aid = $this->archives_db->insertGetId($data);
  334. $_POST['aid'] = $aid;
  335. if ($aid) {
  336. // ---------后置操作
  337. model('Custom')->afterSave($aid, $data, 'add', $this->table);
  338. // 添加查询执行语句到mysql缓存表
  339. model('SqlCacheTable')->InsertSqlCacheTable();
  340. // ---------end
  341. adminLog('新增数据:'.$data['title']);
  342. //新增序列号 (论文期刊和论文模板)
  343. //只考虑新增场景 其他的用api修复
  344. if((int)$newData['typeid'] === 116 || (int)$newData['typeid'] === 123 || (int)$newData['typeid'] === 127 || (int)$newData['typeid'] === 128){
  345. $last = Db::name('seo_number')->where([
  346. "type" => 4,
  347. "tid" => (int)$post['typeid'],
  348. 'topid' => 0,
  349. 'parentid' => 0,
  350. 'area_id' => 0,
  351. ])->order('number desc')->find();
  352. if(empty($last['number'])){
  353. $num = 1;
  354. }else{
  355. $num = (int)$last['number'] + 1;
  356. }
  357. $in_data = [
  358. "type" => 4, //产品类型
  359. "aid" => $aid, //实际的ID
  360. "tid" => (int)$post['typeid'], //属于哪个栏目的
  361. 'is_del' => 0,
  362. 'is_kan' => 0, // 0正常 1审核
  363. 'status' => 1,
  364. 'area_id' => 0,
  365. 'topid' => 0,
  366. 'parentid' => 0,
  367. 'number' => $num
  368. ];
  369. Db::name('seo_number')->insert($in_data);
  370. }else if((int)$newData['typeid'] === 126 || (int)$newData['typeid'] === 825 || (int)$newData['typeid'] === 826){
  371. //资料文档
  372. $last = Db::name('seo_number')->where([
  373. "type" => 5,
  374. "tid" => (int)$post['typeid'],
  375. 'topid' => 0,
  376. 'parentid' => 0,
  377. 'area_id' => (int)$post['province_id'], //如果是0的话 后续也不能改
  378. ])->order('number desc')->find();
  379. if(empty($last['number'])){
  380. $num = 1;
  381. }else{
  382. $num = (int)$last['number'] + 1;
  383. }
  384. $in_data = [
  385. "type" => 5, //产品类型
  386. "aid" => $aid, //实际的ID
  387. "tid" => (int)$post['typeid'], //属于哪个栏目的
  388. 'is_del' => 0,
  389. 'is_kan' => 0, // 0正常 1审核
  390. 'status' => 1,
  391. 'area_id' => (int)$post['province_id'],
  392. 'topid' => 0,
  393. 'parentid' => 0,
  394. 'number' => $num
  395. ];
  396. Db::name('seo_number')->insert($in_data);
  397. }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){
  398. //案例 申报 职称相关问题 常见问题汇总 历年真题题库 答辩问题汇总 防骗指南 职称补贴
  399. $last = Db::name('seo_number')->where([
  400. "type" => 2,
  401. "tid" => (int)$post['typeid'],
  402. 'topid' => 0,
  403. 'parentid' => 0,
  404. 'area_id' => 0,
  405. ])->order('number desc')->find();
  406. if(empty($last['number'])){
  407. $num = 1;
  408. }else{
  409. $num = (int)$last['number'] + 1;
  410. }
  411. $in_data = [
  412. "type" => 2, //文章类型
  413. "aid" => $aid, //实际的ID
  414. "tid" => (int)$post['typeid'], //属于哪个栏目的
  415. 'is_del' => 0,
  416. 'is_kan' => 0, // 0正常 1审核
  417. 'status' => 1,
  418. 'area_id' => 0,
  419. 'topid' => 0,
  420. 'parentid' => 0,
  421. 'number' => $num
  422. ];
  423. Db::name('seo_number')->insert($in_data);
  424. }else if((int)$newData['typeid'] === 115 || (int)$newData['typeid'] === 117 || (int)$newData['typeid'] === 111){
  425. //政策资讯 //评审攻略 //常见问题
  426. $where6 = [
  427. "type" => 2,
  428. "tid" => (int)$post['typeid'],
  429. 'topid' => 0,
  430. 'parentid' => 0,
  431. 'area_id' => (int)$post['province_id'], //如果是0的话 后续也不能改
  432. 'city_id' => (int)$post['city_id'], //如果是0的话 后续也不能改
  433. ];
  434. /*if((int)$post['city_id'] > 0){
  435. $where6['city_id'] = (int)$post['city_id'];
  436. }*/
  437. //攻略和政策资讯
  438. $last = Db::name('seo_number')->where($where6)->order('number desc')->find();
  439. if(empty($last['number'])){
  440. $num = 1;
  441. }else{
  442. $num = (int)$last['number'] + 1;
  443. }
  444. $in_data = [
  445. "type" => 2, //产品类型
  446. "aid" => $aid, //实际的ID
  447. "tid" => (int)$post['typeid'], //属于哪个栏目的
  448. 'is_del' => 0,
  449. 'is_kan' => 0, // 0正常 1审核
  450. 'status' => 1,
  451. 'area_id' => (int)$post['province_id'],
  452. 'city_id' => (int)$post['city_id'],
  453. 'topid' => 0,
  454. 'parentid' => 0,
  455. 'number' => $num
  456. ];
  457. Db::name('seo_number')->insert($in_data);
  458. }else if((int)$newData['typeid'] === 1231 || (int)$newData['typeid'] === 1233 || (int)$newData['typeid'] === 1234){
  459. //新闻资讯 //业绩材料 //一键测评
  460. $where6 = [
  461. "type" => 2,
  462. "tid" => (int)$post['typeid'],
  463. 'topid' => 0,
  464. 'parentid' => 0,
  465. 'area_id' => 0, //(int)$post['province_id'] //如果是0的话 后续也不能改
  466. 'city_id' => 0, //(int)$post['city_id'] //如果是0的话 后续也不能改
  467. ];
  468. /*if((int)$post['city_id'] > 0){
  469. $where6['city_id'] = (int)$post['city_id'];
  470. }*/
  471. //攻略和政策资讯
  472. $last = Db::name('seo_number')->where($where6)->order('number desc')->find();
  473. if(empty($last['number'])){
  474. $num = 1;
  475. }else{
  476. $num = (int)$last['number'] + 1;
  477. }
  478. $in_data = [
  479. "type" => 2, //产品类型
  480. "aid" => $aid, //实际的ID
  481. "tid" => (int)$post['typeid'], //属于哪个栏目的
  482. 'is_del' => 0,
  483. 'is_kan' => 0, // 0正常 1审核
  484. 'status' => 1,
  485. 'area_id' => 0, //(int)$post['province_id']
  486. 'city_id' => 0, //(int)$post['city_id']
  487. 'topid' => 0,
  488. 'parentid' => 0,
  489. 'number' => $num
  490. ];
  491. Db::name('seo_number')->insert($in_data);
  492. }else if((int)$newData['typeid'] === 1232){
  493. //评审政策
  494. //按区域
  495. $where6 = [
  496. "type" => 2,
  497. "tid" => (int)$post['typeid'],
  498. 'topid' => 0,
  499. 'parentid' => 0,
  500. 'area_id' => (int)$post['area_tag_id'], //(int)$post['province_id'] //如果是0的话 后续也不能改
  501. 'city_id' => 0, //(int)$post['city_id'] //如果是0的话 后续也不能改
  502. ];
  503. /*if((int)$post['city_id'] > 0){
  504. $where6['city_id'] = (int)$post['city_id'];
  505. }*/
  506. //攻略和政策资讯
  507. $last = Db::name('seo_number')->where($where6)->order('number desc')->find();
  508. if(empty($last['number'])){
  509. $num = 1;
  510. }else{
  511. $num = (int)$last['number'] + 1;
  512. }
  513. $in_data = [
  514. "type" => 2, //产品类型
  515. "aid" => $aid, //实际的ID
  516. "tid" => (int)$post['typeid'], //属于哪个栏目的
  517. 'is_del' => 0,
  518. 'is_kan' => 0, // 0正常 1审核
  519. 'status' => 1,
  520. 'area_id' => (int)$post['area_tag_id'], //(int)$post['province_id']
  521. 'city_id' => 0, //(int)$post['city_id']
  522. 'topid' => 0,
  523. 'parentid' => 0,
  524. 'number' => $num
  525. ];
  526. Db::name('seo_number')->insert($in_data);
  527. }else{
  528. //其他
  529. }
  530. // 生成静态页面代码
  531. $successData = [
  532. 'aid' => $aid,
  533. 'tid' => $post['typeid'],
  534. ];
  535. $this->success("操作成功!", null, $successData);
  536. }
  537. $this->error("操作失败!");
  538. }
  539. $typeid = input('param.typeid/d', 0);
  540. $assign_data['typeid'] = $typeid; // 栏目ID
  541. //列出产品
  542. $list = Db::name('arctype_cat')
  543. ->where('parent_id','=',$typeid)
  544. ->where('type','=','产品')
  545. ->where('is_del','=',0)
  546. ->order('id asc')
  547. ->select();
  548. //var_dump($list);
  549. $this->assign('pro_list',$list);
  550. //列出职称级别
  551. $level_group_list = Db::name('arctype')
  552. ->field('id,parent_id,typename')
  553. ->where('parent_id','=',53)
  554. ->where('is_del','=',0)
  555. ->order('id asc')
  556. ->select();
  557. //var_dump($list);
  558. $this->assign('level_group_list',$level_group_list);
  559. //列出
  560. $level_group_name = Db::name('archives')
  561. ->field('aid,typeid,title')
  562. ->where('typeid','=',$level_group_list[0]['id'])
  563. ->where('is_del','=',0)
  564. ->order('sort_order asc,aid asc')
  565. ->select();
  566. $this->assign('level_group_name',$level_group_name);
  567. $product_id = input('param.product_id/d', 0);
  568. //var_dump($product_id);
  569. $assign_data['product_id'] = $product_id; //关联产品ID 默认都是0
  570. //var_dump($typeid);
  571. if((int)$typeid === 126 || (int)$typeid === 825 || (int)$typeid === 826){
  572. //列出职称标签
  573. $product_tag = Db::name('archives')
  574. ->field('aid,typeid,title')
  575. ->where('typeid','=',58)
  576. ->where('is_del','=',0)
  577. ->order('sort_order asc,aid asc')
  578. ->select();
  579. }else{
  580. //列出职称标签
  581. $cat = Db::name('arctype')->where(['parent_id'=>369,'article_id'=>$typeid])->find();
  582. if(empty($cat)){
  583. $cat_id = 371;
  584. }else{
  585. $cat_id = $cat['id'];
  586. }
  587. $product_tag = Db::name('archives')
  588. ->field('aid,typeid,title')
  589. ->where('typeid','=',$cat_id)
  590. ->where('is_del','=',0)
  591. ->order('sort_order asc,aid asc')
  592. ->select();
  593. }
  594. $this->assign('product_tag',$product_tag);
  595. //调用区域信息
  596. $product_area = Db::name('citysite')->where(['level'=>1])->select();
  597. $this->assign('product_area_data',$product_area);
  598. // 栏目信息
  599. $arctypeInfo = Db::name('arctype')->find($typeid);
  600. $topid = $arctypeInfo['topid'];
  601. $assign_data['topid'] = $topid;
  602. //查询区域id
  603. $catid = $arctypeInfo['area_id'];
  604. if((int)$catid === 0){
  605. $catid = input('param.catid/d', 0);
  606. }
  607. $assign_data['catid'] = $catid;
  608. //var_dump($catid);
  609. /*允许发布文档列表的栏目*/ //加入区域
  610. $arctype_html = allow_release_arctype($typeid, array($this->channeltype),true,[],false,$catid);
  611. $assign_data['arctype_html'] = $arctype_html;
  612. /*--end*/
  613. // 阅读权限
  614. $arcrank_list = get_arcrank_list();
  615. $assign_data['arcrank_list'] = $arcrank_list;
  616. /*获取可显示的系统字段*/
  617. $condition['ifcontrol'] = 0;
  618. $condition['channel_id'] = $this->channeltype;
  619. $channelfield_row = Db::name('channelfield')->where($condition)->field('name,ifeditable')->getAllWithIndex('name');
  620. $assign_data['channelfield_row'] = $channelfield_row;
  621. /*--end*/
  622. /*模板列表*/
  623. $archivesLogic = new \app\admin\logic\ArchivesLogic;
  624. $templateList = $archivesLogic->getTemplateList($this->nid);
  625. $this->assign('templateList', $templateList);
  626. /*--end*/
  627. /*默认模板文件*/
  628. $tempview = 'view_'.$this->nid.'.'.config('template.view_suffix');
  629. !empty($arctypeInfo['tempview']) && $tempview = $arctypeInfo['tempview'];
  630. $this->assign('tempview', $tempview);
  631. /*--end*/
  632. // 文档默认浏览量
  633. $globalConfig = tpCache('global');
  634. if (isset($globalConfig['other_arcclick']) && 0 <= $globalConfig['other_arcclick']) {
  635. $arcclick_arr = explode("|", $globalConfig['other_arcclick']);
  636. if (count($arcclick_arr) > 1) {
  637. $assign_data['rand_arcclick'] = mt_rand($arcclick_arr[0], $arcclick_arr[1]);
  638. } else {
  639. $assign_data['rand_arcclick'] = intval($arcclick_arr[0]);
  640. }
  641. }else{
  642. $arcclick_config['other_arcclick'] = '500|1000';
  643. tpCache('other', $arcclick_config);
  644. $assign_data['rand_arcclick'] = mt_rand(500, 1000);
  645. }
  646. // URL模式
  647. $tpcache = config('tpcache');
  648. $assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
  649. /*文档属性*/
  650. $assign_data['archives_flags'] = model('ArchivesFlag')->getList();
  651. $channelRow = Db::name('channeltype')->where('id', $this->channeltype)->find();
  652. $assign_data['channelRow'] = $channelRow;
  653. // 来源列表
  654. $system_originlist = tpSetting('system.system_originlist');
  655. $system_originlist = json_decode($system_originlist, true);
  656. $system_originlist = !empty($system_originlist) ? $system_originlist : [];
  657. $assign_data['system_originlist_0'] = !empty($system_originlist) ? $system_originlist[0] : "";
  658. $assign_data['system_originlist_str'] = implode(PHP_EOL, $system_originlist);
  659. // 多站点,当用站点域名访问后台,发布文档自动选择当前所属区域
  660. model('Citysite')->auto_location_select($assign_data);
  661. $this->assign($assign_data);
  662. return $this->fetch();
  663. }
  664. /**
  665. * 编辑
  666. */
  667. public function edit()
  668. {
  669. $admin_info = session('admin_info');
  670. $auth_role_info = $admin_info['auth_role_info'];
  671. $this->assign('auth_role_info', $auth_role_info);
  672. $this->assign('admin_info', $admin_info);
  673. if (IS_POST) {
  674. $post = input('post.');
  675. model('Archives')->editor_auto_210607($post);
  676. $post['aid'] = intval($post['aid']);
  677. $typeid = input('post.typeid/d', 0);
  678. /* 处理TAG标签 */
  679. if (!empty($post['tags_new'])) {
  680. $post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
  681. unset($post['tags_new']);
  682. }
  683. $post['tags'] = explode(',', $post['tags']);
  684. $post['tags'] = array_unique($post['tags']);
  685. $post['tags'] = implode(',', $post['tags']);
  686. /* END */
  687. /*获取第一个html类型的内容,作为文档的内容来截取SEO描述*/
  688. $contentField = Db::name('channelfield')->where([
  689. 'channel_id' => $this->channeltype,
  690. 'dtype' => 'htmltext',
  691. ])->getField('name');
  692. $content = empty($post['addonFieldExt'][$contentField]) ? '' : htmlspecialchars_decode($post['addonFieldExt'][$contentField]);
  693. /*--end*/
  694. // 根据标题自动提取相关的关键字
  695. $seo_keywords = $post['seo_keywords'];
  696. if (!empty($seo_keywords)) {
  697. $seo_keywords = str_replace(',', ',', $seo_keywords);
  698. } else {
  699. // $seo_keywords = get_split_word($post['title'], $content);
  700. }
  701. // 自动获取内容第一张图片作为封面图
  702. $is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
  703. $litpic = '';
  704. if ($is_remote == 1) {
  705. $litpic = $post['litpic_remote'];
  706. } else {
  707. $litpic = $post['litpic_local'];
  708. }
  709. if (empty($litpic)) {
  710. $litpic = get_html_first_imgurl($content);
  711. }
  712. $post['litpic'] = $litpic;
  713. /*是否有封面图*/
  714. if (empty($post['litpic'])) {
  715. $is_litpic = 0; // 无封面图
  716. } else {
  717. $is_litpic = !empty($post['is_litpic']) ? $post['is_litpic'] : 0; // 有封面图
  718. }
  719. // 勾选后SEO描述将随正文内容更新
  720. $basic_update_seo_description = empty($post['basic_update_seo_description']) ? 0 : 1;
  721. if (is_language()) {
  722. $langRow = \think\Db::name('language')->order('id asc')
  723. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  724. ->select();
  725. foreach ($langRow as $key => $val) {
  726. tpCache('basic', ['basic_update_seo_description'=>$basic_update_seo_description], $val['mark']);
  727. }
  728. } else {
  729. tpCache('basic', ['basic_update_seo_description'=>$basic_update_seo_description]);
  730. }
  731. /*--end*/
  732. // SEO描述
  733. $seo_description = '';
  734. if (!empty($basic_update_seo_description) || empty($post['seo_description'])) {
  735. $seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
  736. } else {
  737. $seo_description = $post['seo_description'];
  738. }
  739. // --外部链接
  740. $jumplinks = '';
  741. $is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
  742. if (intval($is_jump) > 0) {
  743. $jumplinks = $post['jumplinks'];
  744. }
  745. // 模板文件,如果文档模板名与栏目指定的一致,默认就为空。让它跟随栏目的指定而变
  746. if ($post['type_tempview'] == $post['tempview']) {
  747. unset($post['type_tempview']);
  748. unset($post['tempview']);
  749. }
  750. // 同步栏目切换模型之后的文档模型
  751. $channel = Db::name('arctype')->where(['id'=>$typeid])->getField('current_channel');
  752. //处理自定义文件名,仅由字母数字下划线和短横杆组成,大写强制转换为小写
  753. $htmlfilename = trim($post['htmlfilename']);
  754. if (!empty($htmlfilename)) {
  755. $htmlfilename = preg_replace("/[^\x{4e00}-\x{9fa5}\w\-]+/u", "-", $htmlfilename);
  756. // $htmlfilename = strtolower($htmlfilename);
  757. //判断是否存在相同的自定义文件名
  758. $map = [
  759. 'aid' => ['NEQ', $post['aid']],
  760. 'htmlfilename' => $htmlfilename,
  761. 'lang' => $this->admin_lang,
  762. ];
  763. if (!empty($post['typeid'])) {
  764. $map['typeid'] = array('eq', $post['typeid']);
  765. }
  766. $filenameCount = Db::name('archives')->where($map)->count();
  767. if (!empty($filenameCount)) {
  768. $this->error("同栏目下,自定义文件名已存在!");
  769. } else if (preg_match('/^(\d+)$/i', $htmlfilename)) {
  770. $this->error("自定义文件名不能纯数字,会与文档ID冲突!");
  771. }
  772. } else {
  773. // 处理外贸链接
  774. if (is_dir('./weapp/Waimao/')) {
  775. $waimaoLogic = new \weapp\Waimao\logic\WaimaoLogic;
  776. $waimaoLogic->get_new_htmlfilename($htmlfilename, $post, 'edit', $this->globalConfig);
  777. }
  778. }
  779. $post['htmlfilename'] = $htmlfilename;
  780. //做未通过审核文档不允许修改文档状态操作
  781. if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
  782. $old_archives_arcrank = Db::name('archives')->where(['aid' => $post['aid']])->getField("arcrank");
  783. if ($old_archives_arcrank < 0) {
  784. unset($post['arcrank']);
  785. }
  786. }
  787. // 副栏目
  788. if (isset($post['stypeid'])) {
  789. $post['stypeid'] = preg_replace('/([^\d\,\,]+)/i', ',', $post['stypeid']);
  790. $post['stypeid'] = str_replace(',', ',', $post['stypeid']);
  791. $post['stypeid'] = trim($post['stypeid'], ',');
  792. $post['stypeid'] = str_replace(",{$typeid},", ',', ",{$post['stypeid']},");
  793. $post['stypeid'] = trim($post['stypeid'], ',');
  794. }
  795. //查询排序 等级
  796. $sort_order = Db::name('archives')->where('aid','=',(int)$post['level_group_name'])->value('sort_order');
  797. // --存储数据
  798. $newData = array(
  799. 'typeid'=> $typeid,
  800. 'channel' => $channel,
  801. 'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
  802. 'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
  803. 'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
  804. 'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
  805. 'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
  806. 'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
  807. 'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
  808. 'editor_remote_img_local'=> empty($post['editor_remote_img_local']) ? 0 : $post['editor_remote_img_local'],
  809. 'editor_img_clear_link' => empty($post['editor_img_clear_link']) ? 0 : $post['editor_img_clear_link'],
  810. 'is_jump' => $is_jump,
  811. 'is_litpic' => $is_litpic,
  812. 'jumplinks' => $jumplinks,
  813. 'seo_keywords' => $seo_keywords,
  814. 'seo_description' => $seo_description,
  815. 'crossed_price' => empty($post['crossed_price']) ? 0 : floatval($post['crossed_price']),
  816. 'add_time' => strtotime($post['add_time']),
  817. 'update_time' => getTime(),
  818. 'product_id' => (int)$post['product_id'], //增加
  819. 'lunwen_id' => (int)$post['lunwen_id'], //增加
  820. 'level_group_id' => (int)$post['level_group_id'],
  821. 'level_id' => (int)$post['level_group_name'],
  822. 'level' => (int)$sort_order,
  823. 'product_tag_id' => (int)$post['product_tag_id'],
  824. 'area_tag_id' => (int)$post['area_tag_id'],
  825. );
  826. $data = array_merge($post, $newData);
  827. if((int)$typeid === 126 || (int)$typeid === 825 || (int)$typeid === 826){
  828. //资料文档的时候
  829. //不更新 区域信息
  830. unset($data['province_id']);
  831. unset($data['city_id']);
  832. unset($data['area_id']);
  833. }
  834. if((int)$typeid === 117 || (int)$typeid === 115 || (int)$typeid === 111){
  835. //评审攻略和政策资讯 增加常见问题
  836. //不更新 区域信息
  837. unset($data['province_id']);
  838. unset($data['city_id']);
  839. unset($data['area_id']);
  840. }
  841. $arctype_par = Db::name('arctype')->field('id,parent_id')->where('id','=',$typeid)->find();
  842. if((int)$arctype_par['parent_id'] === 369){
  843. //文章标签
  844. //不更新 区域信息
  845. unset($data['province_id']);
  846. unset($data['city_id']);
  847. unset($data['area_id']);
  848. }
  849. $r = Db::name('archives')->where([
  850. 'aid' => $data['aid'],
  851. 'lang' => $this->admin_lang,
  852. ])->update($data);
  853. if ($r) {
  854. // ---------后置操作
  855. model('Custom')->afterSave($data['aid'], $data, 'edit', $this->table);
  856. // ---------end
  857. adminLog('编辑文章:'.$data['title']);
  858. $numinfo = [
  859. 'is_del' => $data['is_del'],
  860. 'is_kan' => $data['arcrank'],
  861. 'status' => $data['status'],
  862. ];
  863. //文档aid 对应 序列号aid
  864. Db::name('seo_number')->where('aid','=',$data['aid'])->update($numinfo);
  865. // 生成静态页面代码
  866. $successData = [
  867. 'aid' => $data['aid'],
  868. 'tid' => $typeid,
  869. ];
  870. $this->success("操作成功!", null, $successData);
  871. }
  872. $this->error("操作失败!");
  873. }
  874. $assign_data = array();
  875. $id = input('id/d');
  876. $info = model('Custom')->getInfo($id, null, false);
  877. if (empty($info)) {
  878. $this->error('数据不存在,请联系管理员!');
  879. exit;
  880. }
  881. /*兼容采集没有归属栏目的文档*/
  882. if (empty($info['channel'])) {
  883. $channelRow = Db::name('channeltype')->field('id as channel')
  884. ->where('id',$this->channeltype)
  885. ->find();
  886. $info = array_merge($info, $channelRow);
  887. }
  888. /*--end*/
  889. $typeid = $info['typeid'];
  890. $assign_data['typeid'] = $typeid;
  891. //查找产品
  892. $list = Db::name('arctype_cat')
  893. ->where('parent_id','=',$typeid)
  894. ->where('type','=','产品')
  895. ->where('is_del','=',0)
  896. ->order('id asc')
  897. ->select();
  898. //var_dump($list);
  899. $this->assign('pro_list',$list);
  900. //列出职称级别
  901. $level_group_list = Db::name('arctype')
  902. ->field('id,parent_id,typename')
  903. ->where('parent_id','=',53)
  904. ->where('is_del','=',0)
  905. ->order('id asc')
  906. ->select();
  907. //var_dump($list);
  908. $this->assign('level_group_list',$level_group_list);
  909. //列出
  910. if((int)$info['level_group_id'] === 0){
  911. $level_group_id = $level_group_list[0]['id'];
  912. }else{
  913. $level_group_id = (int)$info['level_group_id'];
  914. }
  915. $level_group_name = Db::name('archives')
  916. ->field('aid,typeid,title')
  917. ->where('typeid','=',$level_group_id)
  918. ->where('is_del','=',0)
  919. ->order('sort_order asc,aid asc')
  920. ->select();
  921. $this->assign('level_group_name',$level_group_name);
  922. if((int)$typeid === 126 || (int)$typeid === 825 || (int)$typeid === 826){
  923. //列出职称标签
  924. $product_tag = Db::name('archives')
  925. ->field('aid,typeid,title')
  926. ->where('typeid','=',58)
  927. ->where('is_del','=',0)
  928. ->order('sort_order asc,aid asc')
  929. ->select();
  930. }else{
  931. //列出职称标签
  932. $cat = Db::name('arctype')->where(['parent_id'=>369,'article_id'=>$typeid])->find();
  933. if(empty($cat)){
  934. $cat_id = 371;
  935. }else{
  936. $cat_id = $cat['id'];
  937. }
  938. $product_tag = Db::name('archives')
  939. ->field('aid,typeid,title')
  940. ->where('typeid','=',$cat_id)
  941. ->where('is_del','=',0)
  942. ->order('sort_order asc,aid asc')
  943. ->select();
  944. }
  945. $this->assign('product_tag',$product_tag);
  946. //调用区域信息
  947. $product_area = Db::name('citysite')->where(['level'=>1])->select();
  948. $this->assign('product_area_data',$product_area);
  949. // 副栏目
  950. $stypeid_arr = [];
  951. if (!empty($info['stypeid'])) {
  952. $info['stypeid'] = trim($info['stypeid'], ',');
  953. $stypeid_arr = Db::name('arctype')->field('id,typename')->where(['id'=>['IN', $info['stypeid']],'is_del'=>0])->select();
  954. }
  955. $assign_data['stypeid_arr'] = $stypeid_arr;
  956. // 栏目信息
  957. $arctypeInfo = Db::name('arctype')->find($typeid);
  958. $topid = $arctypeInfo['topid'];
  959. $assign_data['topid'] = $topid;
  960. $info['channel'] = $arctypeInfo['current_channel'];
  961. if (is_http_url($info['litpic'])) {
  962. $info['is_remote'] = 1;
  963. $info['litpic_remote'] = handle_subdir_pic($info['litpic']);
  964. } else {
  965. $info['is_remote'] = 0;
  966. $info['litpic_local'] = handle_subdir_pic($info['litpic']);
  967. }
  968. // SEO描述
  969. // if (!empty($info['seo_description'])) {
  970. // $info['seo_description'] = @msubstr(checkStrHtml($info['seo_description']), 0, config('global.arc_seo_description_length'), false);
  971. // }
  972. $assign_data['field'] = $info;
  973. /*允许发布文档列表的栏目,文档所在模型以栏目所在模型为主,兼容切换模型之后的数据编辑*/
  974. $arctype_html = allow_release_arctype($typeid, array($info['channel']));
  975. $assign_data['arctype_html'] = $arctype_html;
  976. /*--end*/
  977. /*获取可显示的系统字段*/
  978. $condition['ifcontrol'] = 0;
  979. $condition['channel_id'] = $this->channeltype;
  980. $channelfield_row = Db::name('channelfield')->where($condition)->field('name,ifeditable')->getAllWithIndex('name');
  981. $assign_data['channelfield_row'] = $channelfield_row;
  982. /*--end*/
  983. // 阅读权限
  984. $arcrank_list = get_arcrank_list();
  985. $assign_data['arcrank_list'] = $arcrank_list;
  986. /*模板列表*/
  987. $archivesLogic = new \app\admin\logic\ArchivesLogic;
  988. $templateList = $archivesLogic->getTemplateList($this->nid);
  989. $this->assign('templateList', $templateList);
  990. /*--end*/
  991. /*默认模板文件*/
  992. $tempview = $info['tempview'];
  993. empty($tempview) && $tempview = $arctypeInfo['tempview'];
  994. $this->assign('tempview', $tempview);
  995. /*--end*/
  996. // URL模式
  997. $tpcache = config('tpcache');
  998. $assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
  999. /*文档属性*/
  1000. $assign_data['archives_flags'] = model('ArchivesFlag')->getList();
  1001. $channelRow = Db::name('channeltype')->where('id', $this->channeltype)->find();
  1002. $assign_data['channelRow'] = $channelRow;
  1003. // 来源列表
  1004. $system_originlist = tpSetting('system.system_originlist');
  1005. $system_originlist = json_decode($system_originlist, true);
  1006. $system_originlist = !empty($system_originlist) ? $system_originlist : [];
  1007. $assign_data['system_originlist_str'] = implode(PHP_EOL, $system_originlist);
  1008. $this->assign($assign_data);
  1009. return $this->fetch();
  1010. }
  1011. /**
  1012. * 删除
  1013. */
  1014. public function del()
  1015. {
  1016. $archivesLogic = new \app\admin\logic\ArchivesLogic;
  1017. $archivesLogic->del([], 0, 'custom');
  1018. }
  1019. //帮助
  1020. public function help()
  1021. {
  1022. $system_originlist = tpSetting('system.system_originlist');
  1023. $system_originlist = json_decode($system_originlist, true);
  1024. $system_originlist = !empty($system_originlist) ? $system_originlist : [];
  1025. $assign_data['system_originlist_str'] = implode(PHP_EOL, $system_originlist);
  1026. $this->channeltype = input('param.channel/d', 0);
  1027. $assign_data['channel'] = $this->channeltype ;
  1028. $this->assign($assign_data);
  1029. return $this->fetch();
  1030. }
  1031. }