chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
class Smarty_Internal_Compile_Key extends Smarty_Internal_CompileBase{
    public $required_attributes = array('item');
    public $optional_attributes = array('name', 'key', 'limit', 'recom', 'type', 'iswap', 'order', 'len', 'tuijian');
    public $shorttag_order = array('from', 'item', 'key', 'name');
    public function compile($args, $compiler, $parameter){
        $_attr = $this->getAttributes($compiler, $args);
 
        $from = $_attr['from'];
        $item = $_attr['item'];
        if (!strncmp("\$_smarty_tpl->tpl_vars[$item]", $from, strlen($item) + 24)) {
            $compiler->trigger_template_error("item variable {$item} may not be the same variable as at 'from'", $compiler->lex->taglineno);
        }
 
        //自定义标签 START
        $OutputStr='global $config;$paramer='.ArrayToString($_attr,true).';$list=array();
        
        $ParamerArr = GetSmarty($paramer,$_GET,$_smarty_tpl);
        $paramer = $ParamerArr[arr];
        //是否推荐
        if($paramer[recom]){
            $tuijian = 1;
        }
        //类别
        if($paramer[type]){
            $type = $paramer[type];
        }
        //查询条数
        if($paramer[limit]){
            $limit=$paramer[limit];
        }else{
            $limit=5;
        }
        include PLUS_PATH."/keyword.cache.php";
        if($paramer[iswap]){
            $wap = "/wap";
        }else{
            $index =1;
        }
        if(is_array($keyword)){
            if($paramer[iswap]){
                $i=0;
                foreach($keyword as $k=>$v){
                    if($tuijian && $v[tuijian]!=1){
                        continue;
                    }
                    if($type && $v[type]!=$type){
                        continue;
                    }
 
                    $i++;
                    if($v[type]=="1"){
                        $v[url] = Url("wap",array("c"=>"once","keyword"=>$v[\'key_name\']));
                        $v[type_name]=\'店铺招聘\';
                    }elseif($v[\'type\']=="13"){
                        $v[\'url\'] = Url("wap",array("c"=>"tiny","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'普工简历\';
                    }elseif($v[type]=="3"){
                        $v[url] = Url("wap",array("c"=>"job","keyword"=>$v[\'key_name\']));
                        $v[type_name]=\'职位\';
                    }elseif($v[\'type\']=="4"){
                        $v[\'url\'] = Url("wap",array("c"=>"company","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'公司\';
                    }elseif($v[\'type\']=="5"){
                        $v[\'url\'] = Url("wap",array("c"=>"resume","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'人才\';
                    }
                    $v[\'key_title\']=$v[\'key_name\'];
                    if($v[\'color\']){
                        $v[\'key_name\']="<font color=\'".$v[\'color\']."\'>".$v[\'key_name\']."</font>";
                    }
                    $list[] = $v;
                    if($i==$limit){
                        break;
                    }
                }
            }else{
                $i=0;
                foreach($keyword as $k=>$v){
                    if($tuijian && $v[\'tuijian\']!=1){
                        continue;
                    }
                    if($type && $v[\'type\']!=$type){
                        continue;
                    }
                    $i++;
                    if($v[\'type\']=="1"){
                        $v[\'url\'] = Url("once",array("keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'店铺招聘\';
                    }elseif($v[\'type\']=="2"){
                        $v[\'url\'] = Url("part",array("keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'兼职\';
                    }elseif($v[\'type\']=="13"){
                        $v[\'url\'] = Url("tiny",array("keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'普工简历\';
                    }elseif($v[\'type\']=="3"){
                        $v[\'url\'] = Url("job",array("c"=>"search","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'职位\';
                    }elseif($v[\'type\']=="4"){
                        $v[\'url\'] = Url("company",array("keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'公司\';
                    }elseif($v[\'type\']=="5"){
                        $v[\'url\'] = Url("resume",array("c"=>"search","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'人才\';
                    }elseif($v[\'type\']=="6"){
                        $v[\'url\'] = Url("lietou",array("c"=>"service","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'猎头\';
                    }elseif($v[\'type\']=="7"){
                        $v[\'url\'] = Url("lietou",array("c"=>"post","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'猎头职位\';
                    }else if($v[\'type\']=="9"){
                        $v[\'url\'] = Url("train",array("c"=>"subject","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'培训课程\';
                    }else if($v[\'type\']=="10"){
                        $v[\'url\'] = Url("train",array("c"=>"agency","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'培训机构\';
                    }else if($v[\'type\']=="11"){
                        $v[\'url\'] = Url("train",array("c"=>"teacher","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'培训师\';
                    }else if($v[\'type\']=="12"){
                        $v[\'url\'] = Url("ask",array("c"=>"search","keyword"=>$v[\'key_name\']));
                        $v[\'type_name\']=\'问答\';
                    }
                    $v[\'key_title\']=$v[\'key_name\'];
                    if($v[\'color\']){
                        $v[\'key_name\']="<font color=\'".$v[\'color\']."\'>".$v[\'key_name\']."</font>";
                    }
 
                    $list[] = $v;
                    if($i==$limit){
                        break;
                    }
                }
            }
        }';
 
        return SmartyOutputStr($this,$compiler,$_attr,'key','$list',$OutputStr,'$list');
    }
}
class Smarty_Internal_Compile_Keyelse extends Smarty_Internal_CompileBase{
    public function compile($args, $compiler, $parameter){
        $_attr = $this->getAttributes($compiler, $args);
 
        list($openTag, $nocache, $item, $key) = $this->closeTag($compiler, array('key'));
        $this->openTag($compiler, 'keyelse', array('keyelse', $nocache, $item, $key));
 
        return "<?php }\nif (!\$_smarty_tpl->tpl_vars[$item]->_loop) {\n?>";
    }
}
class Smarty_Internal_Compile_Keyclose extends Smarty_Internal_CompileBase{
    public function compile($args, $compiler, $parameter){
        $_attr = $this->getAttributes($compiler, $args);
        if ($compiler->nocache) {
            $compiler->tag_nocache = true;
        }
 
        list($openTag, $compiler->nocache, $item, $key) = $this->closeTag($compiler, array('key', 'keyelse'));
 
        return "<?php } ?>";
    }
}