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
<?php
class Smarty_Internal_Compile_Qclass extends Smarty_Internal_CompileBase{
    
    public $required_attributes = array('item');
    public $optional_attributes = array('name', 'key', 'classid', 't_len', 'order', 'limit', 'cid', 'recom');//输入
    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'];
        $name = $_attr['name'];
        
        $name=str_replace('\'','',$name);        //一个模板文件同时调用多个qclass时,用以区别
        $name=$name?$name:'list';$name='$'.$name;
        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);
        }
        
        $OutputStr='global $db,$db_config,$config;$paramer='.ArrayToString($_attr,true).';'.$name.'=array();
        $ParamerArr = GetSmarty($paramer,$_GET);
        $paramer = $ParamerArr[arr];
        $Purl =  $ParamerArr[purl];
        global $ModuleName;
        if(!$Purl["m"]){
            $Purl["m"]=$ModuleName;
        }
 
        $where=1;
        include(PLUS_PATH.\'/ask.cache.php\');
 
        //没有传输问答类别ID 则默认取第一个
        /*if(!$paramer[classid])
        {
            $paramer[classid] = $ask_index[0];
        }*/
        //按统计排序获取相关数据
        if(is_array($ask_type[$paramer[classid]]) && !empty($ask_type[$paramer[classid]]))
        { 
            $Count = $ask_type[$paramer[classid]]; 
        }else{
            $aList = $db->select_all("q_class","`pid` IN (".@implode(\',\',$ask_index).")","id");
            foreach($aList as $v){
                $aid[] =$v[id]; 
            } 
            $Count = $aid; 
        }
        if(is_array($Count)){ 
            if($_COOKIE[\'uid\']){$atn=$db->DB_select_once("attention","`uid`=\'".$_COOKIE[\'uid\']."\' and `type`=\'2\'","`ids`");} 
            $ids=@explode(\',\',$atn[\'ids\']);
            foreach($Count as $value){
                $QclassInfo=array();
                if(in_array($value,$ids)){
                    $QclassInfo[\'isatn\']=\'1\';
                }
                $QclassInfo[\'id\'] = $value;
                $QclassInfo[\'name\'] = $ask_name[$value];
                $QclassInfo[\'pic\'] = $ask_pic[$value];
                $QclassInfo[\'atnnum\'] = $ask_atnnum[$value];
                $QclassInfo[\'qusnum\'] = $ask_qusnum[$value];
                $QclassInfo[\'intro\'] = strip_tags($ask_intro[$value]);
                $QclassInfo[\'list\'] = $QusList[$value];                
                '.$name.'[] = $QclassInfo;
            }
            
        }
        ';
        //自定义标签 END
        //global $DiyTagOutputStr;
       // $DiyTagOutputStr[]=$OutputStr;
        return SmartyOutputStr($this,$compiler,$_attr,'qclass',$name,$OutputStr,$name);
    }
}
class Smarty_Internal_Compile_Qclasselse extends Smarty_Internal_CompileBase{
    public function compile($args, $compiler, $parameter){
        $_attr = $this->getAttributes($compiler, $args);
 
        list($openTag, $nocache, $item, $key) = $this->closeTag($compiler, array('qclass'));
        $this->openTag($compiler, 'qclasselse', array('qclasselse', $nocache, $item, $key));
 
        return "<?php }\nif (!\$_smarty_tpl->tpl_vars[$item]->_loop) {\n?>";
    }
}
class Smarty_Internal_Compile_Qclassclose 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('qclass', 'qclassclose'));
 
        return "<?php } ?>";
    }
}