Provides various official and user-released code examples for your reference.
TagLib/TagLibFront. class. php
/**
* @ Author Meik
* @ Homepage http://www.xuzc.cn
* @ Filename TagLibFront. class. php
* @ Encoding UTF-8
* @ Datetime 2011-6-27 14:59:38
* @ Version 1.0
* @ Description
*/
Class TagLibFront extends TagLib {
Protected $ tags = array (
'LIST' => array ('attr' => 'table, where, order, limit, relation, field, result, page, purl, purlvars ', 'close' => 1 ),
);
// Retrieve the list of data that can be associated (invalid field filtering) can be paging
Public function _ list ($ attr, $ content ){
$ Tag = $ this-> parseXmlAttr ($ attr, 'LIST ');
$ Result =! Empty ($ tag ['result'])? $ Tag ['result']: 'data ';
If (! Empty ($ tag ['table']) {
$ Model = 'd ("'. $ tag ['table'].'") ';
} Else {
Return '';
}
$ Key =! Empty ($ tag ['key'])? $ Tag ['key']: 'I ';
$ Mod = isset ($ tag ['mod'])? $ Tag ['mod']: '2 ';
// Concatenate SQL query statements
$ ParseStr =' If ($ tag ['where']! = Null & $ tag ['where'] = '$ where '){
$ ParseStr. = $ tag ['where']! = Null? '$ Map ='. $ tag ["where"]. ';': '';
} Else {
$ ParseStr. = $ tag ['where']! = Null? '$ Map = array ('. trim (str_replace ("=", "=>", $ tag ["where"]), ','). ');':'';
}
If ($ tag ["page"]) {
$ ParseStr. = '$'. $ result. '_ count ='. $ model;
$ ParseStr. = $ tag ['where']! = Null? '-> Where ($ map )':'';
$ ParseStr. = '-> cache (true)-> count ('. $ model. '-> getPk ());';
$ ParseStr. = 'import ("ORG. util. page "); $ '. $ result. '_ p = new Page ($ '. $ result. '_ count ,'. $ tag ["page"]. ');';
If ($ tag ['purlvars']! = Null ){
$ ParseStr. = '$ '. $ result. '_ page = $ '. $ result. '_ p-> show ("'. $ tag ['purl']. '",'. $ tag ['purlvars']. ');';
} Else {
$ ParseStr. = '$ '. $ result. '_ page = $ '. $ result. '_ p-> show ("'. $ tag ['purl']. '");';
}
}
$ ParseStr. = '$'. $ result. '_ result ='. $ model;
$ ParseStr. = $ tag ['relation']! = Null? '-> Relation (array ('. trim ($ tag ["relation"], ','). ')': '';
$ ParseStr. = $ tag ['where']! = Null? '-> Where ($ map )':'';
$ ParseStr. = $ tag ['field']! = Null? '-> Field ("'. trim ($ tag [" field "], ','). '")': '';
$ ParseStr. = $ tag ['order']! = Null? '-> Order ("'. trim ($ tag [" order "], ','). '")': '';
If ($ tag ["page"]) {
$ ParseStr. = $ tag ['page']! = Null? '-> Limit ("$'. $ result. '_ p-> firstRow, $'. $ result. '_ p-> listRows ")':'';
} Else {
$ ParseStr. = $ tag ['limit']! = Null? '-> Limit ("'. trim ($ tag [" limit "], ','). '")': '';
}
$ ParseStr. = '-> select ();?> ';
$ ParseStr. =' $ ParseStr. = 'foreach ($ '. $ result.' _ result as $ key => $ '. $ result.') {?> ';
$ ParseStr. =' ';
$ ParseStr. = $ content;
$ ParseStr. =' ';
Return $ parseStr;
}
}
Usage: any template file
$data[id]))}">·{$data.bt}
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB