Muy.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <?php
  2. namespace app\common\taglib;
  3. use think\template\TagLib;
  4. use think\Db;
  5. class Muy extends Taglib
  6. {
  7. // 标签定义
  8. protected $tags = [
  9. // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次
  10. 'siteseo' => ['attr' => 'name','close'=>0],//网站相关tdk信息调用
  11. 'matter' => ['attr' => 'key,tab,limit,operate,order,sql,father','level'=>3,'close'=>1],//文章的相关调用
  12. 'hnav' => ['attr' => 'all,hid,order,limit,sonlimit,class','level'=>3,'close'=>1],//导航调用
  13. 'myad' => ['attr' => 'id,name','close'=>0],//网站广告的调用
  14. 'links' => ['attr' => 'order,limit','close'=>1],//友情链接
  15. 'feed' => ['attr' => 'uid,feid,limit,order','close'=>1],//留言
  16. 'section' => ['attr' => 'comid,matid,order,compid,limit,uid','level'=>3,'close'=>1],//评论调用标签
  17. 'typ' => ['attr' => 'id,mid,limit,order','close'=>1],//分类调用
  18. 'tags' => ['attr' => 'matid,catid,operate,limit,order','close'=>1],//tag调用key调用
  19. 'maturl' => ['attr' => 'cateid,contid','close'=>0],//文章链接快捷填写
  20. 'urlsu' => ['attr' => 'id','close'=>0],//会员中心链接快捷填写
  21. 'ppt' => ['attr' => 'tab,operate,slide,top,limit,order','close'=>1],//幻灯片调用
  22. 'cuf' => ['attr' => 'temp,id','close'=>0],//单页调用标签
  23. ];
  24. /*
  25. *系统TDK信息调用
  26. *$seot 获取前台填写值
  27. *$parse db结果
  28. */
  29. public function tagSiteseo($tag)
  30. {
  31. $seot = isset($tag['name']) ? $tag['name'] : 'title';
  32. $pass = ['title','descri','keyword','ftitle','record','copyright','statistics','logo','ico','adminqq','adminemail'];
  33. if(!in_array($seot,$pass)){//超出调用范围 结束
  34. return;
  35. }
  36. $parse = Db::name('system')->where('id',1)->value($seot);
  37. return $parse;
  38. }
  39. /*
  40. *文章的相关调用
  41. *tab 栏目id 表名
  42. *limit 调用指定数量
  43. *father true查子孙数据 false只查自身 默认查子孙
  44. *operate 操作类型 (0栏目最新 1栏目推荐)[tab=栏目id] (2表最新 3表推荐)[tab=表名,无需表前缀]
  45. 4 查询所有表信息 注意:limit="页码,显示数量" 或 limit="数量" ; 默认关闭分页
  46. *order 排序
  47. *pag 分页
  48. *key 特殊项 可为空
  49. */
  50. public function tagMatter($tag,$content)
  51. {
  52. $tab = !empty($tag['tab']) ? $tag['tab'] : '1';
  53. $limit = isset($tag['limit']) ? $tag['limit'] : '10';
  54. $muyuop = isset($tag['operate']) ? $tag['operate'] : '0';
  55. $order = empty($tag['order']) ? 'create_time desc' : $tag['order'];
  56. $pag = isset($tag['pag']) ? $tag['pag'] : 'false';
  57. $father = isset($tag['father']) ? $tag['father'] : 'true';
  58. $keyis = isset($tag['key']) ? $tag['key'] : '';
  59. $sql = empty($tag['sql']) ? '' : '->'.$tag['sql'];//附加条件 例如:whereTime('create_time', 'week')本周的内容
  60. $whereCe = "select()";
  61. $limits = "->limit('".$limit."')";
  62. if($pag == "true"){//判断是否开启分页
  63. $whereCe = 'paginate("'.$limit.'")';
  64. $limits = "";
  65. }
  66. if(!in_array($muyuop,array("0","1","2","3","4"))){//不在类型内 结束
  67. return;
  68. }
  69. $where = '->where(["a.delete_time"=>NULL])';//给定默认查询条件
  70. if($muyuop == '0' || $muyuop == '2'){//根据操作类型改写排序
  71. $order = 'create_time desc';
  72. }elseif($muyuop == '1' || $muyuop == '3'){
  73. $where = '->where(["a.delete_time"=>NULL,"a.top"=>1])';//根据操作类型改写查询条件
  74. }
  75. $echo = '$_LI';//根据操作类型改变变量名方便不同分页互不干扰
  76. if($muyuop == 1){
  77. $echo = '$_LIT';
  78. }elseif($muyuop == 2){
  79. $echo = '$_LIS';
  80. }elseif($muyuop == 3){
  81. $echo = '$_LIST';
  82. }
  83. if($muyuop == '2' || $muyuop == '3' || $muyuop == '4'){
  84. $father ="true";
  85. }
  86. if(!empty($keyis)){
  87. $echo = '$_'.$keyis;
  88. }
  89. $lmwer = "";//定义一个空变量
  90. $parse = '<?php ';
  91. if($muyuop == '0' || $muyuop == '1'){//根据操作类型处理数据
  92. if("$" == substr($tab, 0, 1)){//如果是变量
  93. $tab = $this->autoBuildVar($tab);//解析
  94. $parse .= '$_TAB = '.$tab.';';
  95. $parse .= 'if(is_numeric($_TAB)){ $_TABS = muyname($_TAB,'.$father.'); $_TAB = $_TABS["tablename"]; $_MID = $_TABS["mid"]; $_FTB = $_TABS["ftabname"]; };';//判断变量是数字 获取需要的值
  96. $lmwer = '->where("a.mid","in","$_MID")';//增加查询条件 查询顶级栏目以及子栏目数据
  97. }else{
  98. $parse .= '$_TAB = "'.$tab.'";';
  99. $parse .= 'if(is_numeric($_TAB)){ $_TABS = muyname($_TAB,'.$father.'); $_TAB = $_TABS["tablename"]; $_MID = $_TABS["mid"]; $_FTB = $_TABS["ftabname"]; };';
  100. $lmwer = '->where("a.mid","in",$_MID)';
  101. }
  102. }elseif($muyuop == '2' || $muyuop == '3'){
  103. $parse .= '$_TAB = "'.$tab.'";';
  104. $parse .= '$_FTB = "'.$tab.'_data";';
  105. }
  106. if($muyuop == 4){
  107. $parse .= '$_ALLMAT = setallmat("'.$limit.'","'.$order.'");';
  108. $parse .= ''.$echo.' = $_ALLMAT["allmats"];';
  109. }else{
  110. $parse .= 'if(!empty($_FTB) && !empty($_TAB)) : '.$echo.' = Db::name($_TAB)
  111. ->alias("a")
  112. ->fieldRaw("a.*,b.likes,b.browse,comment_t,c.title as catitle,d.name,d.photo,d.email,d.intro,d.home_count,e.title as tytitle,f.grade,f.suffer,f.title as assettitle")
  113. ->join("$_FTB b","find_in_set(b.aid,a.id)")
  114. ->leftjoin("category c","find_in_set(c.id,a.mid)")
  115. ->leftjoin("member d","find_in_set(d.id,a.uid)")
  116. ->leftjoin("member_asset f","find_in_set(f.memberid,d.id)")
  117. ->leftjoin("type e","find_in_set(e.id,a.type)")
  118. '.$where.'
  119. '.$lmwer.'
  120. '.$sql.'
  121. ->where(["a.status"=>0])
  122. ->orderRaw("'.$order.'")
  123. '.$limits.'
  124. ->'.$whereCe.';';//拼装Db查询
  125. $parse .= 'else: ';
  126. $parse .= ''.$echo.' = array();';
  127. $parse .= 'endif;';
  128. }
  129. $parse .= '$_NUM = 0;';
  130. $parse .= 'foreach('.$echo.' as $mat):';
  131. $parse .= '$_PRICE = ["1"=>"免费","2"=>"付费"];';
  132. $parse .= '$mat["price"] = $_PRICE[$mat["price"]];';
  133. $parse .= '$mat["matnu"] = $_NUM++;';
  134. $parse .= 'extract($mat); ?>';//处理$mat
  135. $parse .= $content;
  136. $parse .= '<?php endforeach; ?>';
  137. return $parse;
  138. }
  139. /*
  140. *栏目导航调用
  141. *hid 调用指定id栏目信息
  142. *order 栏目排序
  143. *limit 栏目数量
  144. */
  145. public function tagHnav($tag,$content){
  146. $all = isset($tag['all']) ? $tag['all'] : 'false';
  147. $id = isset($tag['hid']) ? $tag['hid'] : '';
  148. $order = isset($tag['order']) ? $tag['order'] : 'id asc';
  149. $limit = !empty($tag['limit']) ? $tag['limit'] : '';
  150. $calss = isset($tag['class']) ? $tag['class'] : '' ;
  151. $sonlimit = !empty($tag['sonlimit']) ? $tag['sonlimit'] : '';
  152. $parse = '<?php ';
  153. if($all == 'false'){
  154. if($id){
  155. if("$" == substr($id, 0, 1)){
  156. $id = $this->autoBuildVar($id);
  157. $parse .= '$_CID = '.$id.';';
  158. $parse .= '$_NAVS = hnavs("'.$limit.'","'.$sonlimit.'","'.$order.'","$_CID");';
  159. }else{
  160. $parse .= '$_NAVS = hnavs("'.$limit.'","'.$sonlimit.'","'.$order.'","'.$id.'");';
  161. }
  162. }
  163. }else{
  164. $parse .= '$_NAVS = hnavs("'.$limit.'","'.$sonlimit.'","'.$order.'");';
  165. }
  166. $parse .= 'foreach($_NAVS as $key=>$va):';
  167. $parse .= '$navclass = thisclass($va["id"],"'.$calss.'");';
  168. $parse .= 'extract($va);?>';//处理$va
  169. $parse .= $content;
  170. $parse .= '<?php endforeach; ?>';
  171. return $parse;
  172. }
  173. /*
  174. *广告调用标签 myad
  175. *id 调用指定id广告 必填
  176. */
  177. public function tagMyad($tag)
  178. {
  179. $id = $tag['id']; // 必填 需要调用的广告ID
  180. $adname = isset($tag['name']) ? $tag['name'] : 'title';//调用广告$id的内容
  181. if(empty($id)){
  182. return;
  183. }
  184. $adinfo = Db::name("advertising")->find($id);
  185. if(empty($adinfo)){
  186. return;
  187. }
  188. if($adinfo["status"] == 0){
  189. return;
  190. }
  191. if($adinfo['outtime'] != null || !empty($adinfo['outtime'])){
  192. if($adinfo["adset"] == 1){
  193. if($adinfo['outtime'] <= time()){
  194. Db::name("advertising")->where("id",$id)->update(["status"=>0]);
  195. return;
  196. }
  197. }
  198. }
  199. $parse = Db::name("advertising")->where(["id"=>$id])->value($adname);
  200. if($adinfo['outtime'] != null || !empty($adinfo['outtime'])){
  201. if($adinfo['outtime'] <= time()){
  202. $parse = Db::name("advertising")->where("id",$id)->value("outext");
  203. }
  204. }
  205. return $parse;
  206. }
  207. /*
  208. *友情链接调用
  209. */
  210. public function tagLinks($tag,$content)
  211. {
  212. $order = empty($tag['order']) ? 'orders asc' : $tag['order'];
  213. $limit = empty($tag['limit']) ? '20' : $tag['limit'];
  214. $parse = '<?php ';
  215. $parse .= '$__LIST__ = Db::name("links")
  216. ->where("status",1)
  217. ->limit("'. $limit .'")
  218. ->orderRaw("'. $order .'")
  219. ->select();';
  220. $parse .= 'foreach($__LIST__ as $ls):';
  221. $parse .= 'extract($ls);?>';//处理$ls
  222. $parse .= $content;
  223. $parse .= '<?php endforeach; ?>';
  224. return $parse;
  225. }
  226. /*
  227. *留言调用
  228. *uid 会员的所有评论
  229. *limit 调用数量 默认15条
  230. *order 排序方式
  231. *id 调用指定id单条评论
  232. */
  233. public function tagFeed($tag,$content)
  234. {
  235. $uid = isset($tag['uid']) ? $tag['uid'] : '';
  236. $limit = empty($tag['limit']) ? '15' : $tag['limit'];
  237. $order = isset($tag['order']) ? $tag['order'] : 'a.id desc';
  238. $id = isset($tag['feid']) ? $tag['feid'] : '';
  239. $where = "";
  240. $parse = '<?php ';
  241. if($uid){
  242. if("$" == substr($uid, 0, 1)){
  243. $uid = $this->autoBuildVar($uid);
  244. $parse .= '$_UID = '.$uid.';';
  245. $where = '->where(["a.uid"=>$_UID])';
  246. }else{
  247. $where = '->where(["a.uid"=>'.$uid.'])';
  248. }
  249. }
  250. if($id){
  251. if("$" == substr($uid, 0, 1)){
  252. $id = $this->autoBuildVar($id);
  253. $parse .= '$_ID = '.$id.';';
  254. $where = '->where(["a.id"=>$_ID])';
  255. }else{
  256. $where = '->where(["a.id"=>'.$id.'])';
  257. }
  258. }
  259. if(!empty($id) && !empty($uid)){
  260. if("$" == substr($uid, 0, 1) || "$" == substr($id, 0, 1)){
  261. $uid = $this->autoBuildVar($uid);
  262. $parse .= '$_UID = '.$uid.';';
  263. $id = $this->autoBuildVar($id);
  264. $parse .= '$_ID = '.$id.';';
  265. $where = '->where(["a.uid"=>$_UID,"a.id"=>$_ID])';
  266. }else{
  267. $where = '->where(["a.uid"=>'.$uid.',"a.id"=>'.$id.'])';
  268. }
  269. }
  270. $parse .= '$_LY = Db::name("feedback")
  271. ->alias("a")
  272. ->leftjoin("member b","find_in_set(b.id,a.uid)")
  273. ->leftjoin("member_asset c","find_in_set(c.memberid,b.id)")
  274. '.$where.'
  275. ->limit("'.$limit.'")
  276. ->fieldRaw("a.*,b.name,b.photo,b.email,c.*")
  277. ->orderRaw("'.$order.'")
  278. ->select();';
  279. $parse .= 'foreach($_LY as $feed):';
  280. $parse .= 'extract($feed);?>';//处理$feed
  281. $parse .= $content;
  282. $parse .= '<?php endforeach; ?>';
  283. return $parse;
  284. }
  285. /*
  286. *评论调用标签
  287. *comid 调用指定id单条评论
  288. *limit 调用指定数量评论 默认10
  289. *matid 调用指定文章的评论
  290. *order 排序
  291. *uid 调用指定会员的评论
  292. *compid 调用上级评论的回复评论
  293. */
  294. public function tagSection($tag,$content){
  295. $id = isset($tag['comid']) ? $tag['comid'] : '';
  296. $arid = empty($tag['matid']) ? '':$tag['matid'];
  297. $uid = empty($tag['uid']) ? '':$tag['uid'];
  298. $pid = empty($tag['compid']) ? '':$tag['compid'];
  299. $limit = empty($tag['limit']) ? '10' : $tag['limit'];
  300. $order = empty($tag['order']) ? 'id desc' : $tag['order'];
  301. $where = '->where(["a.pid"=>0,"a.status"=>1';
  302. $catup = 'paginate("'.$limit.'")->toArray()';
  303. $vname = '$_PIST';
  304. $limit = '';
  305. $parse = '<?php ';
  306. if($id){
  307. if("$" == substr($id, 0, 1)){
  308. $id = $this->autoBuildVar($id);
  309. $parse .= '$_COMID = '.$id.';';
  310. $where .= ',"a.id"=>$_COMID';
  311. $vname = '$_ZPIST';
  312. $catup = 'select()->toArray()';
  313. $limit = '->limit('.$limit.')';
  314. }else{
  315. $where .= ',"a.id"=>'.$id.'';
  316. $vname = '$_ZPIST';
  317. $catup = 'select()->toArray()';
  318. $limit = '->limit('.$limit.')';
  319. }
  320. }
  321. if($arid){
  322. if("$" == substr($arid, 0, 1)){
  323. $arid = $this->autoBuildVar($arid);
  324. $parse .= '$_MATID = '.$arid.';';
  325. $where .= ',"a.aid"=>$_MATID';
  326. }else{
  327. $where .= ',"a.aid"=>'.$arid.'';
  328. }
  329. }
  330. if($pid){
  331. if("$" == substr($pid, 0, 1)){
  332. $pid = $this->autoBuildVar($pid);
  333. $parse .= '$_COMPID = '.$pid.';';
  334. $vname = '$_ZPIST';
  335. $where .= ',"a.pid"=>$_COMPID';
  336. $catup = 'select()->toArray()';
  337. $limit = '->limit('.$limit.')';
  338. }else{
  339. $where .= ',"a.pid"=>'.$pid.'';
  340. $vname = '$_ZPIST';
  341. $catup = 'select()->toArray()';
  342. $limit = '->limit('.$limit.')';
  343. }
  344. }
  345. if($uid){
  346. if("$" == substr($uid, 0, 1)){
  347. $uid = $this->autoBuildVar($uid);
  348. $parse .= '$_UID = '.$uid.';';
  349. $where .= ',"a.uid"=>$_UID';
  350. }else{
  351. $where .= ',"a.uid"=>'.$uid.'';
  352. }
  353. }
  354. $wheres = $where.'])';
  355. $parse .= ''.$vname.' = Db::name("comment")
  356. ->alias("a")
  357. ->fieldRaw("a.*,c.*,d.grade,d.suffer,d.title as assettitle")
  358. ->join("comment_data c","find_in_set(a.id,c.cid)")
  359. ->leftjoin("member_asset d","find_in_set(d.memberid,a.uid)")
  360. '.$wheres.'
  361. '.$limit.'
  362. ->orderRaw("'.$order.'")
  363. ->'.$catup.';';
  364. $parse .= 'if(isset('.$vname.'["data"])) : '.$vname.' = alldigui('.$vname.'["data"]);';
  365. $parse .= 'else: ';
  366. $parse .= ''.$vname.' = alldigui('.$vname.');';
  367. $parse .= 'endif;';
  368. $parse .= '$_NUM = 0;';
  369. $parse .= 'foreach('.$vname.' as $com):';
  370. $parse .= '$com["comnu"] = $_NUM++;';
  371. $parse .= '$MATINFO = matsection($com["aid"]);';
  372. $parse .= '$com["matitle"] = $MATINFO["title"];';
  373. $parse .= 'extract($com);?>';//处理$com
  374. $parse .= $content;
  375. $parse .= '<?php endforeach; ?>';
  376. return $parse;
  377. }
  378. /*
  379. *分类调用标签 示例{muy:typ name="type" }{$type.type_name}{/muy:typ}
  380. *name 默认 type
  381. *id 调用指定id分类信息
  382. *mid 调用指定栏目下分类
  383. *limit 分类调用数量
  384. *order 分类排序方式
  385. */
  386. public function tagTyp($tag,$content){
  387. $id = isset($tag['id']) ? $tag['id'] : '';
  388. $mid = isset($tag['caid']) ? $this->autoBuildVar($tag['caid']) : '';
  389. $order = isset($tag['order']) ? $tag['order'] : 'id asc';
  390. $limit = !empty($tag['limit']) ? $tag['limit'] : '10';
  391. $where = '->where("status",1)';
  392. $parse = '<?php ';
  393. if($id){
  394. if("$" == substr($id, 0, 1)){
  395. $id = $this->autoBuildVar($id);
  396. $parse .= '$_TYID = '.$id.';';
  397. $where = '->where(["status"=>1,"id"=>$_TYID])';
  398. }else{
  399. $where = '->where(["status"=>1,"id"=>'.$id.'])';
  400. }
  401. } //处理单id和栏目id以变量方式传入
  402. if($mid){
  403. if("$" == substr($mid, 0, 1)){
  404. $mid = $this->autoBuildVar($mid);
  405. $parse .= '$_CAID = '.$mid.';';
  406. $where .= '->where("mid",$_CAID)';
  407. }else{
  408. $where .= '->where("mid",'.$mid.')';
  409. }
  410. }
  411. $parse .= '$__LIST__ = Db::name("type")
  412. '.$where.'
  413. ->limit("'.$limit.'")
  414. ->orderRaw("'.$order.'")
  415. ->select();';
  416. $parse .= '$_NUM = 0;';
  417. $parse .= 'foreach($__LIST__ as $ts):';
  418. $parse .= '$ts["tynu"] = $_NUM++;';
  419. $parse .= 'extract($ts);?>';//处理$ts
  420. $parse .= $content;
  421. $parse .= '<?php endforeach; ?>';
  422. return $parse;
  423. }
  424. /*
  425. *tag和key的调用
  426. *matid 调用指定id文章的tag或key
  427. *catid 调用指定栏目下的tag或key
  428. *limit 限制调用数量
  429. *operate 0调用关键词 1调用tags
  430. *order 排序
  431. */
  432. public function tagTags($tag,$content){
  433. $id = empty($tag['matid']) ? '' :$tag['matid'];
  434. $mid = empty($tag['catid']) ? '' :$tag['catid'];
  435. $operate = isset($tag['operate']) ? $tag['operate'] : '0' ;
  436. $limit = empty($tag['limit']) ? '10' : $tag['limit'];
  437. $order = empty($tag['order']) ? 'create_time asc' : $tag['order'];
  438. $field = "keyword";
  439. if(!empty($id) && !empty($mid)){
  440. return;
  441. }
  442. if($operate == 1){
  443. $field = "tag";
  444. }
  445. $parse = '<?php ';
  446. $parse .= '$_LIST = tagkey('.$limit.',"'.$field.'","'.$order.'");';
  447. if(!empty($id)){
  448. if("$" == substr($id, 0, 1)){
  449. $id = $this->autoBuildVar($id);
  450. $parse .= '$_MATID = '.$id.';';
  451. $parse .= '$_LIST = tagkey('.$limit.',"'.$field.'","'.$order.'","",$_MATID);';
  452. }else{
  453. $parse .= '$_LIST = tagkey('.$limit.',"'.$field.'","'.$order.'","",'.$id.');';
  454. }
  455. }
  456. if(!empty($mid)){
  457. if("$" == substr($mid, 0, 1)){
  458. $mid = $this->autoBuildVar($mid);
  459. $parse .= '$_CATID = '.$mid.';';
  460. $parse .= '$_LIST = tagkey('.$limit.',"'.$field.'","'.$order.'",$_CATID);';
  461. }else{
  462. $parse .= '$_LIST = tagkey('.$limit.',"'.$field.'","'.$order.'",'.$mid.');';
  463. }
  464. }
  465. $parse .= 'foreach($_LIST as $'.$field.'):?>';
  466. $parse .= $content;
  467. $parse .= '<?php endforeach; ?>';
  468. return $parse;
  469. }
  470. /*
  471. *内容相关url便捷书写
  472. *cateid 栏目id
  473. *
  474. *contid 内容id
  475. */
  476. public function tagMaturl($tag){
  477. $cateid = isset($tag['cateid']) ? $tag['cateid'] : '';
  478. $contid = isset($tag['contid']) ? $tag['contid'] : '';
  479. if(!empty($cateid) && !empty($contid)){
  480. return;
  481. }
  482. if($cateid){
  483. if("$" == substr($cateid, 0, 1)){
  484. $parse = '<?php ';
  485. $cateid = $this->autoBuildVar($cateid);
  486. $parse .= '$_CATID = '.$cateid.';';
  487. $parse .= '$_CKURL = Db::name("category")->find($_CATID);';
  488. $parse .= ' ?>';
  489. $parse .= '{$_CKURL["href"]}';
  490. return $parse;
  491. }else{
  492. $checkurl = Db::name('category')->find($cateid);
  493. $parse = $checkurl['href'];
  494. if($checkurl['patternlist'] == 1){
  495. $parse = '/matlist_'.$cateid.'.html';
  496. }
  497. return $parse;
  498. }
  499. }elseif($contid){
  500. if("$" == substr($contid, 0, 1)){
  501. $parse = '<?php ';
  502. $contid = $this->autoBuildVar($contid);
  503. $parse .= '$_CONTID = '.$contid.';';
  504. $parse .= '$_MURL = selectmatinfo($_CONTID);';
  505. $parse .= ' ?>';
  506. $parse .= '{$_MURL}';
  507. return $parse;
  508. }else{
  509. $parse = selectmatinfo($contid);
  510. return $parse;
  511. }
  512. }
  513. return;
  514. }
  515. /*
  516. *会员中心url快捷书写
  517. *urlsu
  518. *uid:会员id
  519. *书写格式:{muy:urlsu id='*'}
  520. */
  521. public function tagUrlsu($tag){
  522. $id=isset($tag['uid']) ? $this->autoBuildVar($tag['uid']) : '';
  523. if($id){
  524. $parse = '<?php ';
  525. $parse .= '$_D = '.$id.';';
  526. $parse .= ' ?>';
  527. $parse .= '{:url("index/user/my_home",["uid"=>$_D])}';
  528. return $parse;
  529. }
  530. }
  531. /**
  532. * 幻灯片调用标签
  533. * tab 调用栏目/模型下文章图为幻灯;必须结合operate操作方法1/2使用 operate=0 无需填写tab
  534. *
  535. * slide 是否限制幻灯属性 true/false;
  536. *
  537. * top 是否限制置顶属性 填写置顶级别 目前暂时1级;
  538. *
  539. * operate 操作类型 0所有不限制(默认项 无需指定) 1根据栏目id操作 2根据模型标识操作;
  540. *
  541. * limit 限制调用数量,默认限制10条;
  542. *
  543. * order 数据排序方式 默认'create_time asc';
  544. */
  545. public function tagPpt($tag,$content){
  546. $limit = empty($tag['limit']) && !is_numeric($tag['limit']) ? '10' : intval($tag['limit']);
  547. $tab = isset($tag['tab']) ? $tag['tab'] : '';
  548. $operate = isset($tag['operate']) && is_numeric($tag['operate']) ? intval($tag['operate']) : '0';
  549. $slide = isset($tag['slide']) && $tag['slide'] == 'true' ? $tag['slide'] : 'false';
  550. $top = isset($tag['top']) && !is_numeric($tag['top']) ? intval($tag['top']) : '0';
  551. $order = isset($tag['order']) ? $tag['order'] : 'create_time asc';
  552. $parse ='<?php ';
  553. $parse .= '$_LIST = getppt('.$limit.',"'.$order.'",'.$operate.',"'.$slide.'",'.$top.');';
  554. if(!empty($tab)){
  555. if("$" == substr($tab, 0, 1)){
  556. $tab = $this->autoBuildVar($tab);
  557. $parse .= '$_TAB = '.$tab.';';
  558. $parse .= '$_LIST = getppt('.$limit.',"'.$order.'",'.$operate.',"'.$slide.'",'.$top.',"$_TAB");';
  559. }else{
  560. $parse .= '$_LIST = getppt('.$limit.',"'.$order.'",'.$operate.',"'.$slide.'",'.$top.',"'.$tab.'");';
  561. }
  562. }
  563. $parse .= 'foreach($_LIST as $ppt):';
  564. $parse .= 'extract($ppt);?>';//处理$ppt
  565. $parse .= $content;
  566. $parse .= '<?php endforeach; ?>';
  567. return $parse;
  568. }
  569. /*
  570. *单页文件调用
  571. *
  572. *
  573. **/
  574. public function tagCuf($tag){
  575. $id = isset($tag['id']) ? $tag['id'] : '';
  576. $temp = isset($tag['temp']) ? $tag['temp'] : '';
  577. if(!empty($id)){
  578. if("$" == substr($id, 0, 1)){
  579. $parse ='<?php ';
  580. $id = $this->autoBuildVar($id);
  581. $parse .= '$_CUFID = '.$id.';';
  582. $parse .= ' ?>';
  583. $parse .= '{:url("index/matters/artsctform",["formid"=>$_CUFID])}';
  584. return $parse;
  585. }else{
  586. $parse = '{:url("index/matters/artsctform",["formid"=>'.$id.'])}';
  587. return $parse;
  588. }
  589. return;
  590. }
  591. if(!empty($temp)){
  592. if("$" == substr($temp, 0, 1)){
  593. $parse ='<?php ';
  594. $temp = $this->autoBuildVar($temp);
  595. $parse .= '$_CUFT = '.$temp.';';
  596. $parse .= ' ?>';
  597. $parse .= '{:url("index/matters/artsctform",["t"=>$_CUFT])}';
  598. return $parse;
  599. }else{
  600. $parse = '{:url("index/matters/artsctform",["t"=>"'.$temp.'"])}';
  601. return $parse;
  602. }
  603. return;
  604. }
  605. return;
  606. }
  607. }