diff --git a/extend/seven/taglib/Xs.php b/extend/seven/taglib/Xs.php new file mode 100644 index 00000000..833ada58 --- /dev/null +++ b/extend/seven/taglib/Xs.php @@ -0,0 +1,123 @@ + + * @Since: 2018/2/1 19:33 + */ + +namespace seven\taglib; + + +use think\template\TagLib; +use think\Db; + + +class Xs extends Taglib +{ + + protected $tags = [ + 'nav' => ['attr' => 'name,showlevel', 'close'=> 0], + 'posts' => ['attr' => 'name,ids,cid,field,limit,order,where,ispage,pagesize,type,key', 'close' => 0], + 'ad' => ['attr' => 'id', 'close' => 0], + ]; + + public function tagAd($tag) + { + if (isset($tag['id']) && !empty($tag['id'])) { + $id = intval($tag['id']); + $parseStr = '"; + return $parseStr; + } + return; + } + + public function tagNav($tag) + { + $name = isset($tag['name']) ? $tag['name'] : '' ; //导航ID + $class = isset($tag['class']) ? $tag['class'] : ''; //导航css + $extend = isset($tag['extend']) ? $tag['extend'] : ''; //导航附加属性 + $name = preg_replace('/(\w+)/i','${1}',$name); + $class = str_replace('"', "'", $class); + $extend = str_replace('"', "'", $extend); + $navwrapattr= 'id:'.$name.';class:'.$class.';extend:'.$extend.';'; + + $itemclass = isset($tag['itemclass']) ? $tag['itemclass'] : ''; //菜单项css + $itemextend = isset($tag['itemextend']) ? $tag['itemextend'] : ''; //菜单项附加属性 + $itemclass = str_replace('"', "'", $itemclass); + $itemextend = str_replace('"', "'", $itemextend); + + $childwrap = isset($tag['childwrap']) ? $tag['childwrap'] : ''; //子菜单项的外围标签 + $childclass = isset($tag['childclass']) ? $tag['childclass'] : ''; //子菜单项的外围标签css + $childextend = isset($tag['childextend']) ? $tag['childextend'] : ''; //子菜单项的外围附加属性 + $childwrap = preg_replace('/(\w+)/i','${1}',$childwrap); + $childextend = str_replace('"', "'", $childextend); + $childclass = str_replace('"', "'", $childclass); + $childwrapattr = 'wrap:'.$childwrap.';class:'.$childclass.';extend:'.$childextend.';'; + + $itemtpl = ''; + if($itemclass!='' && $itemextend!='') + $itemtpl = "