Public function _ list ($ attr) { $ Tag = $ this-> parseXmlAttr ($ attr, 'list '); $ Id = $ tag ['id']; // table id $ Datasource = $ tag ['datasource ']; // name of the data source VoList displayed in the list $ Pk = empty ($ tag ['PK'])? 'Id': $ tag ['PK']; // primary key name. The default value is id. $ Style = $ tag ['style']; // style name $ Name =! Empty ($ tag ['name'])? $ Tag ['name']: 'vo'; // vo object name $ Action = $ tag ['action'] = 'true '? True: false; // whether to display the function $ Key =! Empty ($ tag ['key'])? True: false; $ Sort = $ tag ['sort '] = 'false '? False: true; $ Checkbox = $ tag ['checkbox']; // whether to display checkbox If (isset ($ tag ['actionlist']) { $ Actionlist = explode (',', trim ($ tag ['actionlist']); // specify the function list } If (substr ($ tag ['show '], 0, 1) =' $ '){ $ Show = $ this-> tpl-> get (substr ($ tag ['show '], 1 )); } Else { $ Show = $ tag ['show']; } $ Show = explode (',', $ show); // The field list is displayed in the list. // Calculate the number of columns in the table $ ColNum = count ($ show ); If (! Empty ($ checkbox) $ colNum ++; If (! Empty ($ action) $ colNum ++; If (! Empty ($ key) $ colNum ++; // Display start $ ParseStr = "<! -- Think system list component start --> n "; $ ParseStr. = '<table id = "'. $ id. '" class = "'. $ style. '" cellpadding = 0 cellspacing = 0> '; $ ParseStr. = '<tr> <td height = "5" colspan = "'. $ colNum. '"class =" topTd "> </td> </tr> '; $ ParseStr. = '<tr class = "row"> '; // Fields to be displayed in the list $ Fields = array (); Foreach ($ show as $ val ){ $ Fields [] = explode (':', $ val ); } If (! Empty ($ checkbox) & 'true' = strtolower ($ checkbox) {// if you specify to display the checkbox column $ ParseStr. = '<th width = "8"> <input type = "checkbox" id = "check" onclick = "CheckAll (''. $ id. '')"> </th> '; } If (! Empty ($ key )){ $ ParseStr. = '<th width = "12"> No </th> '; } Foreach ($ fields as $ field) {// display the specified field $ Property = explode ('|', $ field [0]); $ Showname = explode ('|', $ field [1]); If (isset ($ showname [1]) { $ ParseStr. = '<th width = "'. $ showname [1]. '"> '; } Else { $ ParseStr. = '<th> '; } $ Showname [2] = isset ($ showname [2])? $ Showname [2]: $ showname [0]; If ($ sort ){ $ ParseStr. = '<a xhref = "javascript: sortBy (''. $ property [0]. '', '{$ sort }',''. ACTION_NAME. '')" title = "according '. $ showname [2]. '{$ sortType} "> '. $ showname [0]. '<eq name = "order" value = "'. $ property [0]. '"> </eq> </a> </th> '; } Else { $ ParseStr. = $ showname [0]. '</th> '; } } If (! Empty ($ action) {// if you specify to display the operation function column $ ParseStr. = '<th> Operation </th> '; } $ ParseStr. = '</tr> '; $ ParseStr. = '<volist name = "'. $ datasource. '"id = "'. $ name. '"> <tr class =" row "'; // you can move the cell line color with the mouse. The specific method is defined in js. If (! Empty ($ checkbox )){ $ ParseStr. = 'onmouseover = "over (event)" onmouseout = "out (event)" onclick = "change (event )"'; } $ ParseStr. = '> '; If (! Empty ($ checkbox) {// If you need to display the checkbox, the checkbox is displayed at the beginning of each line. $ ParseStr. = '<td> <input type = "checkbox" name = "key" value = "{$ '. $ name. '. '. $ pk. '} "> </td> '; } If (! Empty ($ key )){ $ ParseStr. = '<td >{$ I} </td> '; } Foreach ($ fields as $ field ){ // Display the defined list fields $ ParseStr. = '<td> '; If (! Empty ($ field [2]) { // The List Field link function is implemented by the JS function. $ Href = explode ('|', $ field [2]); If (count ($ href)> 1 ){ // Specify the field value passed by the link // Supports passing multiple fields $ Array = explode ('^', $ href [1]); If (count ($ array)> 1 ){ Foreach ($ array as $ ){ $ Temp [] = ''{$ '. $ name.'. '. $ a.' | addslashes }''; } $ ParseStr. = '<a xhref = "javascript:'. $ href [0]. '('. implode (',', $ temp). ')"> '; } Else { $ ParseStr. = '<a xhref = "javascript :'. $ href [0]. '(' {$ '. $ name. '. '. $ href [1]. '| addslashes}') "> '; } } Else { // If no default serial number is specified $ ParseStr. = '<a xhref = "javascript :'. $ field [2]. '(' {$ '. $ name. '. '. $ pk. '| addslashes}') "> '; } } If (strpos ($ field [0], '^ ')){ $ Property = explode ('^', $ field [0]); Foreach ($ property as $ p ){ $ Unit = explode ('|', $ p ); If (count ($ unit)> 1 ){ $ ParseStr. = '{$'. $ name. '.'. $ unit [0]. '|'. $ unit [1]. '}'; } Else { $ ParseStr. = '{$'. $ name. '.'. $ p .'}'; } } } Else { $ Property = explode ('|', $ field [0]); If (count ($ property)> 1 ){ // Convert -- Yes. Multiple parameters are passed. $ Property [1] = str_replace ('--', $ property [1]); $ ParseStr. = '{$'. $ name. '.'. $ property [0]. '|'. $ property [1]. '}'; } Else { $ ParseStr. = '{$'. $ name. '.'. $ field [0]. '}'; } } If (! Empty ($ field [2]) { $ ParseStr. = '</a> '; } $ ParseStr. = '</td> '; } If (! Empty ($ action) {// Display operation If (! Empty ($ actionlist [0]) {// display the specified function item $ ParseStr. = '<td> '; Foreach ($ actionlist as $ val ){ // Apply javascript If (strpos ($ val ,':')){ $ A = explode (':', $ val ); If (count ($ a)> 2 ){ $ ParseStr. = '<a xhref = "javascript :'. $ a [0]. '(' {$ '. $ name. '. '. $ a [2]. '}') "> '. $ a [1]. '</a> & nbsp ;'; } Else { $ ParseStr. = '<a xhref = "javascript :'. $ a [0]. '(' {$ '. $ name. '. '. $ pk. '}') "> '. $ a [1]. '</a> & nbsp ;'; } } Else { // Apply the php function $ Array = explode ('|', $ val ); If (count ($ array)> 2 ){ $ ParseStr. = '<a xhref = "javascript :'. $ array [1]. '(' {$ '. $ name. '. '. $ array [0]. '}') "> '. $ array [2]. '</a> & nbsp ;'; } Else { // Convert -- Yes. Multiple parameters are passed. $ Val = str_replace ('--', $ val ); $ ParseStr. = '{$'. $ name. '.'. $ val. '} & nbsp ;'; } } } $ ParseStr. = '</td> '; // Echo $ parseStr; // Exit (); } } $ ParseStr. = '</tr> </volist> <tr> <td height = "5" colspan = "'. $ colNum. '"class =" bottomTd "> </td> </tr> </table> '; $ ParseStr. = "n <! -- Think system list component ended --> n "; Return $ parseStr; } |