Channeltype.php 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  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. use app\admin\logic\FieldLogic;
  17. use think\template\taglib\Eyou;
  18. class Channeltype extends Base
  19. {
  20. // 系统默认的模型ID,不可删除
  21. private $channeltype_system_id = [];
  22. // 系统内置不可用的模型标识,防止与home分组的控制器重名覆盖,导致网站报错
  23. private $channeltype_system_nid = ['base','index','lists','search','tags','view','left','right','top','bottom','ajax'];
  24. // 数据库对象
  25. public $channeltype_db;
  26. public function _initialize() {
  27. parent::_initialize();
  28. $eyou = new Eyou('');
  29. $this->channeltype_system_nid = array_merge($this->channeltype_system_nid, array_keys($eyou->getTags()));
  30. $this->channeltype_db = Db::name('channeltype');
  31. $this->channeltype_system_id = $this->channeltype_db->where([
  32. 'ifsystem' => 1,
  33. ])->column('id');
  34. }
  35. public function index()
  36. {
  37. // model('Channeltype')->setChanneltypeStatus(); // 根据前端模板自动开启系统模型
  38. $list = array();
  39. $param = input('param.');
  40. $condition = array();
  41. // 应用搜索条件
  42. foreach (['keywords'] as $key) {
  43. if (isset($param[$key]) && $param[$key] !== '') {
  44. if ($key == 'keywords') {
  45. $condition['a.title'] = array('LIKE', "%{$param[$key]}%");
  46. } else {
  47. $condition['a.'.$key] = array('eq', $param[$key]);
  48. }
  49. }
  50. }
  51. $count = $this->channeltype_db->alias('a')->where($condition)->count('id');// 查询满足要求的总记录数
  52. $pageObj = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
  53. $list = $this->channeltype_db->alias('a')
  54. ->where($condition)
  55. ->order('ifsystem desc, id asc')
  56. ->limit($pageObj->firstRow.','.$pageObj->listRows)
  57. ->select();
  58. $pageStr = $pageObj->show();// 分页显示输出
  59. $this->assign('pageStr',$pageStr);// 赋值分页输出
  60. $this->assign('list',$list);// 赋值数据集
  61. $this->assign('pageObj',$pageObj);// 赋值分页对象
  62. return $this->fetch();
  63. }
  64. /**
  65. * 新增
  66. */
  67. public function add()
  68. {
  69. if (IS_POST) {
  70. $post = input('post.');
  71. if (!empty($post)) {
  72. $post['title'] = trim($post['title']);
  73. if (empty($post['title'])) {
  74. $this->error('模型名称不能为空!');
  75. }
  76. $post['nid'] = trim($post['nid']);
  77. if (empty($post['nid'])) {
  78. $this->error('模型标识不能为空!');
  79. } else {
  80. if (!preg_match('/^([a-z]+)([a-z0-9]*)$/i', $post['nid'])) {
  81. $this->error('模型标识必须以小写字母开头!');
  82. } else if (in_array($post['nid'], $this->channeltype_system_nid)) {
  83. $this->error('系统禁用当前模型标识,请更改!');
  84. }
  85. }
  86. $post['nid'] = strtolower($post['nid']);
  87. $nid = $post['nid'];
  88. $post['ctl_name'] = ucwords($nid);
  89. $post['table'] = $nid;
  90. if($this->channeltype_db->where(['nid'=>$nid])->count('id') > 0){
  91. $this->error('该模型标识已存在,请检查', url('Channeltype/index'));
  92. }
  93. // 创建文件以及数据表
  94. $this->create_sql_file($post);
  95. $nowData = array(
  96. 'ntitle' => $post['title'],
  97. 'nid' => $nid,
  98. 'add_time' => getTime(),
  99. 'update_time' => getTime(),
  100. );
  101. $data = array_merge($post, $nowData);
  102. $insertId = $this->channeltype_db->insertGetId($data);
  103. $_POST['id'] = $insertId;
  104. if ($insertId) {
  105. // 复制模型字段基础数据
  106. $fieldLogic = new FieldLogic;
  107. $fieldLogic->synArchivesTableColumns($insertId);
  108. try {
  109. /*追加到快速入口列表*/
  110. $this->syn_custom_quickmenu($data, $insertId);
  111. /*end*/
  112. schemaTable($post['table'].'_content');
  113. } catch (\Exception $e) {}
  114. delFile(CACHE_PATH, true);
  115. extra_cache('admin_channeltype_list_logic', NULL);
  116. adminLog('新增模型:'.$post['title']);
  117. $this->success("操作成功", url('Channeltype/index'));
  118. }
  119. }
  120. $this->error("操作失败");
  121. }
  122. return $this->fetch();
  123. }
  124. /**
  125. * 同步自定义模型的快捷导航
  126. */
  127. private function syn_custom_quickmenu($data = [], $insertId)
  128. {
  129. $saveData = [
  130. [
  131. 'title' => $data['title'],
  132. 'laytext' => $data['title'].'列表',
  133. 'type' => 1,
  134. 'controller' => 'Custom',
  135. 'action' => 'index',
  136. 'vars' => 'channel='.$insertId,
  137. 'sort_order' => 100,
  138. 'groups' => 1,
  139. 'add_time' => getTime(),
  140. 'update_time' => getTime(),
  141. ],
  142. [
  143. 'title' => $data['title'],
  144. 'laytext' => $data['title'].'列表',
  145. 'type' => 2,
  146. 'controller' => 'Custom',
  147. 'action' => 'index',
  148. 'vars' => 'channel='.$insertId,
  149. 'sort_order' => 100,
  150. 'groups' => 1,
  151. 'add_time' => getTime(),
  152. 'update_time' => getTime(),
  153. ],
  154. ];
  155. model('Quickentry')->saveAll($saveData);
  156. }
  157. /**
  158. * 编辑
  159. */
  160. public function edit()
  161. {
  162. $id = input('id/d');
  163. if (IS_POST) {
  164. $post = input('post.');
  165. if(!empty($post['id'])){
  166. $post['title'] = trim($post['title']);
  167. if (in_array($post['id'], $this->channeltype_system_id)) {
  168. unset($post['title']);
  169. } else {
  170. if (empty($post['title'])) {
  171. $this->error('模型名称不能为空!');
  172. }
  173. $map = array(
  174. 'id' => ['NEQ', $post['id']],
  175. 'nid' => strtolower($post['nid']),
  176. );
  177. if($this->channeltype_db->where($map)->count('id') > 0){
  178. $this->error('该模型标识已存在,请检查', url('Channeltype/index'));
  179. }
  180. }
  181. $nowData = array(
  182. 'update_time' => getTime(),
  183. );
  184. unset($post['nid']);
  185. $data = array_merge($post, $nowData);
  186. $r = $this->channeltype_db
  187. ->where(['id'=>$post['id']])
  188. ->cache(true,null,"channeltype")
  189. ->update($data);
  190. if ($r) {
  191. /*留言模型 - 同步邮箱模板的开启与关闭*/
  192. if (8 == $post['id']) {
  193. Db::name('smtp_tpl')->where([
  194. 'send_scene' => 1,
  195. ])->update([
  196. 'is_open' => intval($post['smtp_is_open']),
  197. 'update_time' => getTime(),
  198. ]);
  199. /*留言间隔时间 - 多语言*/
  200. $channel_guestbook_interval = intval($post['channel_guestbook_interval']);
  201. if (is_language()) {
  202. $langRow = \think\Db::name('language')->order('id asc')
  203. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  204. ->select();
  205. foreach ($langRow as $key => $val) {
  206. tpSetting('channel_guestbook', ['channel_guestbook_interval'=>$channel_guestbook_interval], $val['mark']);
  207. }
  208. } else {
  209. tpSetting('channel_guestbook',['channel_guestbook_interval'=>$channel_guestbook_interval]);
  210. }
  211. /*--end*/
  212. }
  213. /*end*/
  214. extra_cache('admin_channeltype_list_logic', NULL);
  215. adminLog('编辑模型:'.$data['title']);
  216. $this->success("操作成功", url('Channeltype/index'));
  217. }
  218. }
  219. $this->error("操作失败");
  220. }
  221. $assign_data = array();
  222. $info = $this->channeltype_db->field('a.*')
  223. ->alias('a')
  224. ->where(array('a.id'=>$id))
  225. ->find();
  226. if (empty($info)) {
  227. $this->error('数据不存在,请联系管理员!');
  228. exit;
  229. }
  230. $assign_data['field'] = $info;
  231. /*留言模型*/
  232. $smtpTplRow = [];
  233. if (8 == $id) {
  234. /*邮箱提醒*/
  235. $smtpTplRow = Db::name('smtp_tpl')->field('is_open')
  236. ->where([
  237. 'send_scene' => 1,
  238. 'lang' => $this->main_lang,
  239. ])->find();
  240. /*end*/
  241. /*间隔时间*/
  242. $channel_guestbook_interval = tpSetting('channel_guestbook.channel_guestbook_interval');
  243. $assign_data['channel_guestbook_interval'] = is_numeric($channel_guestbook_interval) ? intval($channel_guestbook_interval) : 60;
  244. /*end*/
  245. }
  246. $assign_data['smtpTplRow'] = $smtpTplRow;
  247. /*end*/
  248. $this->assign($assign_data);
  249. return $this->fetch();
  250. }
  251. /**
  252. * 删除
  253. */
  254. public function del()
  255. {
  256. $id_arr = input('del_id/a');
  257. $id_arr = eyIntval($id_arr);
  258. if(IS_POST){
  259. if(!empty($id_arr)){
  260. foreach ($id_arr as $key => $val) {
  261. if (array_key_exists($val, $this->channeltype_system_id)) {
  262. $this->error('系统内置模型,禁止删除!');
  263. }
  264. }
  265. $result = $this->channeltype_db->field('id,title,nid')->where("id",'IN',$id_arr)->select();
  266. $title_list = get_arr_column($result, 'title');
  267. $r = $this->channeltype_db->where("id",'IN',$id_arr)->delete();
  268. if ($r) {
  269. // 删除栏目
  270. $arctype = Db::name('arctype')->where("channeltype",'IN',$id_arr)
  271. ->whereOr("current_channel", 'IN', $id_arr)
  272. ->delete();
  273. // 删除文章
  274. $archives = Db::name('archives')->where("channel",'IN',$id_arr)->delete();
  275. // 删除自定义字段
  276. $channelfield = Db::name('channelfield')->where("channel_id",'IN',$id_arr)->delete();
  277. // 删除文件
  278. foreach ($result as $key => $value) {
  279. $nid = $value['nid'];
  280. try {
  281. /*删除快速入口的相关数据*/
  282. Db::name('quickentry')->where([
  283. 'groups' => 1,
  284. 'controller' => 'Custom',
  285. 'action' => 'index',
  286. 'vars' => 'channel='.$value['id'],
  287. ])->delete();
  288. /*end*/
  289. // 删除相关数据表
  290. Db::execute('DROP TABLE '.PREFIX.$nid.'_content');
  291. } catch (\Exception $e) {}
  292. $filelist_path = 'data/model/custom_model_path/'.$nid.'.filelist.txt';
  293. $fileStr = file_get_contents($filelist_path);
  294. $filelist = explode("\n\r", $fileStr);
  295. foreach ($filelist as $k1 => $v1) {
  296. $v1 = trim($v1);
  297. if (!empty($v1)) {
  298. @unlink($v1);
  299. }
  300. }
  301. @unlink($filelist_path);
  302. delFile('application/admin/template/'.$nid, true);
  303. }
  304. delFile(CACHE_PATH, true);
  305. extra_cache('admin_channeltype_list_logic', NULL);
  306. adminLog('删除模型:'.implode(',', $title_list));
  307. $this->success('删除成功');
  308. }
  309. $this->error('删除失败');
  310. }
  311. $this->error('参数有误');
  312. }
  313. $this->error('非法访问');
  314. }
  315. // 解析sql语句
  316. private function sql_split($sql, $tablepre) {
  317. if ($tablepre != "ey_")
  318. $sql = str_replace("`ey_", '`'.$tablepre, $sql);
  319. $sql = preg_replace("/TYPE=(InnoDB|MyISAM|MEMORY)( DEFAULT CHARSET=[^; ]+)?/", "ENGINE=\\1 DEFAULT CHARSET=utf8", $sql);
  320. $sql = str_replace("\r", "\n", $sql);
  321. $ret = array();
  322. $num = 0;
  323. $queriesarray = explode(";\n", trim($sql));
  324. unset($sql);
  325. foreach ($queriesarray as $query) {
  326. $ret[$num] = '';
  327. $queries = explode("\n", trim($query));
  328. $queries = array_filter($queries);
  329. foreach ($queries as $query) {
  330. $str1 = substr($query, 0, 1);
  331. if ($str1 != '#' && $str1 != '-')
  332. $ret[$num] .= $query;
  333. }
  334. $num++;
  335. }
  336. return $ret;
  337. }
  338. // 创建文件以及数据表
  339. private function create_sql_file($post) {
  340. $demopath = 'data/model/';
  341. $fileArr = []; // 生成的相关文件记录
  342. $filelist = getDirFile($demopath);
  343. foreach ($filelist as $key => $file) {
  344. if (stristr($file, 'custom_model_path')) {
  345. unset($filelist[$key]);
  346. continue;
  347. }
  348. $src = $demopath.$file;
  349. $dst = $file;
  350. $dst = str_replace('CustomModel', $post['ctl_name'], $dst);
  351. $dst = str_replace('custommodel', $post['nid'], $dst);
  352. /*记录相关文件*/
  353. if (!stristr($dst, 'custom_model_path')) {
  354. array_push($fileArr, $dst);
  355. }
  356. /*--end*/
  357. if(tp_mkdir(dirname($dst))) {
  358. $fileContent = @file_get_contents($src);
  359. $fileContent = str_replace('CustomModel', $post['ctl_name'], $fileContent);
  360. $fileContent = str_replace('custommodel', strtolower($post['nid']), $fileContent);
  361. $fileContent = str_replace('CUSTOMMODEL', strtoupper($post['nid']), $fileContent);
  362. $view_suffix = config('template.view_suffix');
  363. if (stristr($file, 'lists_custommodel.'.$view_suffix)) {
  364. $replace = <<<EOF
  365. <section class="article-list">
  366. {eyou:list pagesize="10" titlelen="38"}
  367. <article>
  368. {eyou:notempty name="\$field.is_litpic"}
  369. <a href="{\$field.arcurl}" title="{\$field.title}" style="float: left; margin-right: 10px"> <img src="{\$field.litpic}" alt="{\$field.title}" height="100" /> </a>
  370. {/eyou:notempty}
  371. <h2><a href="{\$field.arcurl}" class="">{\$field.title}</a><span>{\$field.click}°C</span></h2>
  372. <div class="excerpt">
  373. <p>{\$field.seo_description}</p>
  374. </div>
  375. <div class="meta">
  376. <span class="item"><time>{\$field.add_time|MyDate='Y-m-d',###}</time></span>
  377. <span class="item">{\$field.typename}</span>
  378. </div>
  379. </article>
  380. {/eyou:list}
  381. </section>
  382. <section class="list-pager">
  383. {eyou:pagelist listitem='index,pre,pageno,next,end' listsize='2' /}
  384. <div class="clear"></div>
  385. </section>
  386. EOF;
  387. $fileContent = str_replace("<!-- #list# -->", $replace, $fileContent);
  388. }
  389. $puts = @file_put_contents($dst, $fileContent);
  390. if (!$puts) {
  391. $this->error('创建自定义模型生成相关文件失败,请检查站点目录权限!');
  392. }
  393. }
  394. }
  395. @file_put_contents($demopath.'custom_model_path/'.$post['nid'].'.filelist.txt', implode("\n\r", $fileArr));
  396. // 创建自定义模型附加表
  397. $table = 'ey_'.$post['table'].'_content';
  398. $tableSql = <<<EOF
  399. CREATE TABLE `{$table}` (
  400. `id` int(10) NOT NULL AUTO_INCREMENT,
  401. `aid` int(10) DEFAULT '0' COMMENT '文档ID',
  402. `add_time` int(11) DEFAULT '0' COMMENT '新增时间',
  403. `update_time` int(11) DEFAULT '0' COMMENT '更新时间',
  404. PRIMARY KEY (`id`),
  405. KEY `aid` (`aid`) USING BTREE
  406. ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='附加表';
  407. EOF;
  408. $sqlFormat = $this->sql_split($tableSql, PREFIX);
  409. // 执行SQL语句
  410. try {
  411. $counts = count($sqlFormat);
  412. for ($i = 0; $i < $counts; $i++) {
  413. $sql = trim($sqlFormat[$i]);
  414. if (stristr($sql, 'CREATE TABLE')) {
  415. Db::execute($sql);
  416. } else {
  417. if(trim($sql) == '')
  418. continue;
  419. Db::execute($sql);
  420. }
  421. }
  422. } catch (\Exception $e) {
  423. $this->error('数据库表创建失败,请检查'.$table.'表是否存在并删除,不行就请求技术支持!');
  424. }
  425. }
  426. /**
  427. * 检测模板并启用与禁用
  428. */
  429. public function ajax_show()
  430. {
  431. if (IS_POST) {
  432. $id = input('id/d');
  433. $status = input('status/d', 0);
  434. if(!empty($id)){
  435. $row = Db::name('channeltype')->where([
  436. 'id' => $id,
  437. ])->find();
  438. $nofileArr = [];
  439. /*检测模板是否存在*/
  440. $tplplan = 'template/pc';
  441. $planPath = realpath($tplplan);
  442. if (!file_exists($planPath)) {
  443. $this->success('操作成功', null, ['confirm'=>0]);
  444. }
  445. $view_suffix = config('template.view_suffix');
  446. // 检测列表模板是否存在
  447. $lists_filename = 'lists_'.$row['nid'].'.'.$view_suffix;
  448. if (!file_exists($planPath.DS.$lists_filename)) {
  449. $filename = ROOT_DIR.DS.$tplplan.DS.$lists_filename;
  450. $nofileArr[] = [
  451. 'type' => 'lists',
  452. 'title' => '列表模板:',
  453. 'file' => str_replace('\\', '/', $filename),
  454. ];
  455. }
  456. // 检测文档模板是否存在
  457. if (!in_array($row['nid'], ['single','guestbook'])) {
  458. $view_filename = 'view_'.$row['nid'].'.'.$view_suffix;
  459. if (!file_exists($planPath.DS.$view_filename)) {
  460. $filename = ROOT_DIR.DS.$tplplan.DS.$view_filename;
  461. $nofileArr[] = [
  462. 'type' => 'view',
  463. 'title' => '文档模板:',
  464. 'file' => str_replace('\\', '/', $filename),
  465. ];
  466. }
  467. }
  468. /*--end*/
  469. if (empty($status) || (1 == $status && empty($nofileArr))) {
  470. $r = Db::name('channeltype')->where([
  471. 'id' => $id,
  472. ])
  473. ->cache(true,null,"channeltype")
  474. ->update([
  475. 'status' => $status,
  476. 'update_time' => getTime(),
  477. ]);
  478. if($r){
  479. delFile(CACHE_PATH, true);
  480. adminLog('编辑【'.$row['title'].'】的状态为:'.(!empty($status)?'启用':'禁用'));
  481. $this->success('操作成功', null, ['confirm'=>0]);
  482. }else{
  483. $this->error('操作失败', null, ['confirm'=>0]);
  484. }
  485. } else {
  486. $tpltype = [];
  487. $msg = "该模型缺少以下模板,系统将自动创建一个简单模板文件:<br/>";
  488. foreach ($nofileArr as $key => $val) {
  489. $msg .= '<font color="red">'.$val['title'].$val['file']."</font><br/>";
  490. $tpltype[] = $val['type'];
  491. }
  492. delFile(CACHE_PATH, true);
  493. $this->success($msg, null, ['confirm'=>1,'tpltype'=>base64_encode(json_encode($tpltype))]);
  494. }
  495. } else {
  496. $this->error('参数有误');
  497. }
  498. }
  499. $this->error('非法访问');
  500. }
  501. /**
  502. * 启用并创建模板
  503. */
  504. public function ajax_check_tpl()
  505. {
  506. if (IS_POST) {
  507. $id = input('id/d');
  508. $status = input('status/d');
  509. if(!empty($id)){
  510. $row = Db::name('channeltype')->where([
  511. 'id' => $id,
  512. ])->find();
  513. $r = Db::name('channeltype')->where([
  514. 'id' => $id,
  515. ])
  516. ->cache(true,null,"channeltype")
  517. ->update([
  518. 'status' => $status,
  519. 'update_time' => getTime(),
  520. ]);
  521. if($r){
  522. $tpltype = input('post.tpltype/s');
  523. $tpltype = json_decode(base64_decode($tpltype), true);
  524. if (!empty($tpltype)) {
  525. $view_suffix = config('template.view_suffix');
  526. $themeStyleArr = ['pc','mobile'];
  527. foreach ($themeStyleArr as $k1 => $theme) {
  528. $tplplan = "template/{$theme}";
  529. $planPath = realpath($tplplan);
  530. if (file_exists($planPath)) {
  531. foreach ($tpltype as $k2 => $val) {
  532. $source = realpath("data/model/template/{$theme}/{$val}_custommodel.{$view_suffix}");
  533. $dest = ROOT_PATH."template/{$theme}/{$val}_{$row['nid']}.{$view_suffix}";
  534. if (!file_exists($dest)) {
  535. $content = file_get_contents($source);
  536. if ('lists' == $val) {
  537. if ('download' == $row['nid'])
  538. {
  539. $replace = <<<EOF
  540. <section class="article-list">
  541. {eyou:list pagesize="10" titlelen="38"}
  542. <article>
  543. {eyou:notempty name="\$field.is_litpic"}
  544. <a href="{\$field.arcurl}" title="{\$field.title}" style="float: left; margin-right: 10px"> <img src="{\$field.litpic}" alt="{\$field.title}" height="100" /> </a>
  545. {/eyou:notempty}
  546. <h2><a href="{\$field.arcurl}" class="">{\$field.title}</a><span>{\$field.click}°C</span></h2>
  547. <div class="excerpt">
  548. <p>{\$field.seo_description}</p>
  549. </div>
  550. <div class="meta">
  551. <span class="item"><time>{\$field.add_time|MyDate='Y-m-d',###}</time></span>
  552. <span class="item">{\$field.typename}</span>
  553. {eyou:arcview aid='\$field.aid' id='view'}
  554. {eyou:volist name="\$view.file_list" id='vo'}
  555. <span class="item"><a class="btn" href="{\$vo.downurl}" title="{\$vo.title}">下载包({\$i})</a></span>
  556. {/eyou:volist}
  557. {/eyou:arcview}
  558. </div>
  559. </article>
  560. {/eyou:list}
  561. </section>
  562. <section class="list-pager">
  563. {eyou:pagelist listitem='index,pre,pageno,next,end' listsize='2' /}
  564. <div class="clear"></div>
  565. </section>
  566. EOF;
  567. $content = str_replace("<!-- #download# -->", $replace, $content);
  568. }
  569. else if ('single' == $row['nid'])
  570. {
  571. $replace = <<<EOF
  572. <article class="content">
  573. <h1>{\$eyou.field.title}</h1>
  574. <div class="post">
  575. {\$eyou.field.content}
  576. </div>
  577. </article>
  578. EOF;
  579. $content = str_replace("<!-- #single# -->", $replace, $content);
  580. }
  581. else if ('guestbook' == $row['nid'])
  582. {
  583. $replace = <<<EOF
  584. <article class="content">
  585. <h1>{\$eyou.field.title}</h1>
  586. <div class="post">
  587. <div class="md_block">
  588. <div style=" color: #ff0000">
  589. 制作易优留言表单,主要有三个步骤:<br>1,后台>开启留言模型,建立栏目并选择留言模型。<br>2,打开根目录>template>pc>lists_guestbook.htm模板文件,按照易优表单标签制作,<a href="http://www.eyoucms.com/doc/label/arc/502.html" target="_blank">点击这里查看教程</a><br>3,还有疑问可以加易优交流群(群号:<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=917f9a4cfe50fd94600c55eb75d9c6014a1842089b0479bc616fb79a1d85ae0b">704301718</a>)
  590. </div>
  591. </div>
  592. </div>
  593. </article>
  594. <section class="pager"></section>
  595. EOF;
  596. $content = str_replace("<!-- #guestbook# -->", $replace, $content);
  597. } else {
  598. $replace = <<<EOF
  599. <section class="article-list">
  600. {eyou:list pagesize="10" titlelen="38"}
  601. <article>
  602. {eyou:notempty name="\$field.is_litpic"}
  603. <a href="{\$field.arcurl}" title="{\$field.title}" style="float: left; margin-right: 10px"> <img src="{\$field.litpic}" alt="{\$field.title}" height="100" /> </a>
  604. {/eyou:notempty}
  605. <h2><a href="{\$field.arcurl}" class="">{\$field.title}</a><span>{\$field.click}°C</span></h2>
  606. <div class="excerpt">
  607. <p>{\$field.seo_description}</p>
  608. </div>
  609. <div class="meta">
  610. <span class="item"><time>{\$field.add_time|MyDate='Y-m-d',###}</time></span>
  611. <span class="item">{\$field.typename}</span>
  612. </div>
  613. </article>
  614. {/eyou:list}
  615. </section>
  616. <section class="list-pager">
  617. {eyou:pagelist listitem='index,pre,pageno,next,end' listsize='2' /}
  618. <div class="clear"></div>
  619. </section>
  620. EOF;
  621. $content = str_replace("<!-- #list# -->", $replace, $content);
  622. }
  623. }
  624. else if ('view' == $val)
  625. { // 内置模型设有内容字段
  626. if (1 == $row['ifsystem'])
  627. {
  628. $replace = <<<EOF
  629. <div class="md_block">
  630. {\$eyou.field.content}
  631. </div>
  632. EOF;
  633. $content = str_replace('<!-- #content# -->', $replace, $content);
  634. }
  635. if ('product' == $row['nid'])
  636. {
  637. $replace = <<<EOF
  638. <div class="md_block">
  639. <!--购物车组件start-->
  640. {eyou:sppurchase id='field'}
  641. <div class="ey-price"><span>¥{\$field.users_price}</span> </div>
  642. <div class="ey-number">
  643. <label>数量</label>
  644. <div class="btn-input">
  645. <button class="layui-btn" {\$field.ReduceQuantity}>-</button>
  646. <input type="text" class="layui-input" {\$field.UpdateQuantity}>
  647. <button class="layui-btn" {\$field.IncreaseQuantity}>+</button>
  648. </div>
  649. </div>
  650. <div class="ey-buyaction">
  651. <a class="ey-joinin" href="JavaScript:void(0);" {\$field.ShopAddCart}>加入购物车</a>
  652. <a class="ey-joinbuy" href="JavaScript:void(0);" {\$field.BuyNow}>立即购买</a>
  653. </div>
  654. {\$field.hidden}
  655. {/eyou:sppurchase}
  656. <!--购物车组件end-->
  657. </div>
  658. <div class="md_block">
  659. <fieldset>
  660. <legend>图片集:</legend>
  661. <div class="pic">
  662. <div class="wrap">
  663. {eyou:volist name="\$eyou.field.image_list"}
  664. <img src="{\$field.image_url}" alt="{\$eyou.field.title}" />
  665. {/eyou:volist}
  666. </div>
  667. </div>
  668. </fieldset>
  669. </div>
  670. <div class="md_block">
  671. <fieldset>
  672. <legend>产品属性:</legend>
  673. {eyou:attribute type='auto'}
  674. {\$attr.name}:{\$attr.value}<br/>
  675. {/eyou:attribute}
  676. </fieldset>
  677. </div>
  678. EOF;
  679. $content = str_replace('<!-- #product# -->', $replace, $content);
  680. } else if ('images' == $row['nid']) {
  681. $replace = <<<EOF
  682. <div class="md_block">
  683. <fieldset>
  684. <legend>图片集:</legend>
  685. <div class="pic">
  686. <div class="wrap">
  687. {eyou:volist name="\$eyou.field.image_list"}
  688. <img src="{\$field.image_url}" alt="{\$eyou.field.title}" />
  689. {/eyou:volist}
  690. </div>
  691. </div>
  692. </fieldset>
  693. </div>
  694. EOF;
  695. $content = str_replace('<!-- #images# -->', $replace, $content);
  696. } else if ('download' == $row['nid']) {
  697. $replace = <<<EOF
  698. <div class="md_block">
  699. <fieldset>
  700. <legend>下载地址:</legend>
  701. {eyou:volist name="\$eyou.field.file_list" id="field"}
  702. <a class="btn" href="{\$field.downurl}" title="{\$field.title}">下载包({\$i})</a>
  703. {/eyou:volist}
  704. </fieldset>
  705. </div>
  706. EOF;
  707. $content = str_replace('<!-- #download# -->', $replace, $content);
  708. }
  709. }
  710. @file_put_contents($dest, $content);
  711. }
  712. }
  713. }
  714. }
  715. }
  716. extra_cache('admin_channeltype_list_logic', NULL);
  717. adminLog('编辑【'.$row['title'].'】的状态为:'.(!empty($status)?'启用':'禁用'));
  718. $this->success('操作成功');
  719. }else{
  720. $this->error('操作失败');
  721. }
  722. } else {
  723. $this->error('参数有误');
  724. }
  725. }
  726. $this->error('非法访问');
  727. }
  728. }