1- <?php
2-
3- /*
4- Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5- All rights reserved.
6-
7- Redistribution and use in source and binary forms, with or without modification,
8- are permitted provided that the following conditions are met:
9-
10- * Redistributions of source code must retain the above copyright notice,
11- this list of conditions and the following disclaimer.
12- * Redistributions in binary form must reproduce the above copyright notice,
13- this list of conditions and the following disclaimer in the documentation
14- and/or other materials provided with the distribution.
15- * Neither the name of ISPConfig nor the names of its contributors
16- may be used to endorse or promote products derived from this software without
17- specific prior written permission.
18-
19- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22- IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29- */
30-
31- class listform_tpl_generator {
32-
33- function buildHTML ($ listDef ,$ module = '' ) {
34-
35- global $ app ;
36-
37- if ($ module == '' ) $ module = $ _SESSION ["s " ]["module " ]["name " ];
38-
39- $ lang = array ();
40- $ html = '<h2><tmpl_var name="list_head_txt"></h2>
41-
42- <div class="panel panel_list_ ' .$ listDef ["name " ].'">
43-
44- <div class="pnl_toolsarea">
45- <fieldset><legend>Tools </legend>
46- <div class="buttons">
47- <button class="iconstxt icoAdd" type="button" onClick=" ' ."loadContent(' " .$ module ."/ " .$ listDef ["edit_file " ]."'); " .'">
48- <span>{tmpl_var name="add_new_record_txt"}</span>
49- </button>
50- </div>
51- </fieldset>
52- </div>
53-
54- <div class="pnl_listarea">
55- <fieldset><legend><tmpl_var name="list_head_txt"></legend>
56- <table class="list">
57- <thead>
58- <tr>
59- ' ;
60-
61- $ lang ["list_head_txt " ] = $ listDef ["name " ];
62- foreach ($ listDef ["item " ] as $ field ) {
63- $ key = $ field ["field " ];
64- $ html .= " <th class= \"tbl_col_ " .$ key ."\" scope= \"col \"><tmpl_var name= \"" .$ key ."_txt \"></th> \r\n" ;
65- $ lang [$ key ."_txt " ] = $ key ;
66- }
67-
68- $ html .= ' <th class="tbl_col_buttons" scope="col"> </th>
69- </tr>
70- <tr>
71- ' ;
72-
73- foreach ($ listDef ["item " ] as $ field ) {
74- $ key = $ field ["field " ];
75- if ($ field ["formtype " ] == 'SELECT ' ) {
76- $ html .= " <td class= \"tbl_col_ " .$ key ."\"><select name= \"" .$ listDef ["search_prefix " ].$ key ."\" onChange= \"submitForm('pageForm',' " .$ module ."/ " .$ listDef ["file " ]."'); \">{tmpl_var name=' " .$ listDef ["search_prefix " ].$ key ."'}</select></td> \r\n" ;
77- } else {
78- $ html .= " <td class= \"tbl_col_ " .$ key ."\"><input type= \"text \" name= \"" .$ listDef ["search_prefix " ].$ key ."\" value= \"{tmpl_var name=' " .$ listDef ["search_prefix " ].$ key ."'} \" /></td> \r\n" ;
79- }
80- }
81-
82- $ html .= ' <td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick=" ' ."submitForm('pageForm',' " .$ module ."/ " .$ listDef ["file " ]."'); " .'"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
83- </tr>
84- </thead>
85- <tbody>
86- <tmpl_loop name="records">
87- <tr class="tbl_row_<tmpl_if name= \'__EVEN__ \'}even<tmpl_else>uneven</tmpl_if>">
88- ' ;
89-
90- foreach ($ listDef ["item " ] as $ field ) {
91- $ key = $ field ["field " ];
92- $ html .= " <td class= \"tbl_col_ " .$ key ."\"><a href= \"# \" onClick= \"loadContent(' " .$ module ."/ " .$ listDef ["edit_file " ]."?id={tmpl_var name='id'}'); \">{tmpl_var name= \"" .$ key ."\"}</a></td> \r\n" ;
93- }
94-
95- $ html .= " <td class= \"tbl_col_buttons \">
96- <div class= \"buttons icons16 \">
97- <a class= \"icons16 icoDelete \" href= \"javascript: del_record(' " .$ module ."/ " .$ listDef ["delete_file " ]."?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}'); \"><span>{tmpl_var name='delete_txt'}</span></a>
98- </div>
99- </td>
100- </tr>
101- </tmpl_loop>
102- </tbody> " ;
103- $ html .= '
104- <tfoot>
105- <tr>
106- <td class="tbl_footer tbl_paging" colspan=" ' .(count ($ listDef ["item " ])+1 ).'"><tmpl_var name="paging"></td>
107- </tr>
108- </tfoot>
109- </table>
110- </fieldset>
111- </div>
112-
113- </div>
114- ' ;
115-
116- if ($ module == '' ) {
117- $ filename = 'templates/ ' .$ listDef ["name " ].'_list.htm ' ;
118- } else {
119- $ filename = '../ ' .$ module .'/templates/ ' .$ listDef ["name " ].'_list.htm ' ;
120- }
121-
122-
123- // save template
124- if (!$ handle = fopen ($ filename , 'w ' )) {
125- print "Cannot open file ( $ filename) " ;
126- exit ;
127- }
128-
129- if (!fwrite ($ handle , $ html )) {
130- print "Cannot write to file ( $ filename) " ;
131- exit ;
132- }
133- fclose ($ handle );
134-
135- }
136-
137- }
138-
1+ <?php
2+
3+ /*
4+ Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5+ All rights reserved.
6+
7+ Redistribution and use in source and binary forms, with or without modification,
8+ are permitted provided that the following conditions are met:
9+
10+ * Redistributions of source code must retain the above copyright notice,
11+ this list of conditions and the following disclaimer.
12+ * Redistributions in binary form must reproduce the above copyright notice,
13+ this list of conditions and the following disclaimer in the documentation
14+ and/or other materials provided with the distribution.
15+ * Neither the name of ISPConfig nor the names of its contributors
16+ may be used to endorse or promote products derived from this software without
17+ specific prior written permission.
18+
19+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+ IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+ */
30+
31+ class listform_tpl_generator {
32+
33+ function buildHTML ($ listDef ,$ module = '' ) {
34+
35+ global $ app ;
36+
37+ if ($ module == '' ) $ module = $ _SESSION ["s " ]["module " ]["name " ];
38+
39+ $ lang = array ();
40+ $ html = '<h2><tmpl_var name="list_head_txt"></h2>
41+
42+ <div class="panel panel_list_ ' .$ listDef ["name " ].'">
43+
44+ <div class="pnl_toolsarea">
45+ <fieldset><legend>{tmpl_var name="toolsarea_head_txt"} </legend>
46+ <div class="buttons">
47+ <button class="iconstxt icoAdd" type="button" onClick=" ' ."loadContent(' " .$ module ."/ " .$ listDef ["edit_file " ]."'); " .'">
48+ <span>{tmpl_var name="add_new_record_txt"}</span>
49+ </button>
50+ </div>
51+ </fieldset>
52+ </div>
53+
54+ <div class="pnl_listarea">
55+ <fieldset><legend><tmpl_var name="list_head_txt"></legend>
56+ <table class="list">
57+ <thead>
58+ <tr>
59+ ' ;
60+
61+ $ lang ["list_head_txt " ] = $ listDef ["name " ];
62+ foreach ($ listDef ["item " ] as $ field ) {
63+ $ key = $ field ["field " ];
64+ $ html .= " <th class= \"tbl_col_ " .$ key ."\" scope= \"col \"><tmpl_var name= \"" .$ key ."_txt \"></th> \r\n" ;
65+ $ lang [$ key ."_txt " ] = $ key ;
66+ }
67+
68+ $ html .= ' <th class="tbl_col_buttons" scope="col"> </th>
69+ </tr>
70+ <tr>
71+ ' ;
72+
73+ foreach ($ listDef ["item " ] as $ field ) {
74+ $ key = $ field ["field " ];
75+ if ($ field ["formtype " ] == 'SELECT ' ) {
76+ $ html .= " <td class= \"tbl_col_ " .$ key ."\"><select name= \"" .$ listDef ["search_prefix " ].$ key ."\" onChange= \"submitForm('pageForm',' " .$ module ."/ " .$ listDef ["file " ]."'); \">{tmpl_var name=' " .$ listDef ["search_prefix " ].$ key ."'}</select></td> \r\n" ;
77+ } else {
78+ $ html .= " <td class= \"tbl_col_ " .$ key ."\"><input type= \"text \" name= \"" .$ listDef ["search_prefix " ].$ key ."\" value= \"{tmpl_var name=' " .$ listDef ["search_prefix " ].$ key ."'} \" /></td> \r\n" ;
79+ }
80+ }
81+
82+ $ html .= ' <td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick=" ' ."submitForm('pageForm',' " .$ module ."/ " .$ listDef ["file " ]."'); " .'"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
83+ </tr>
84+ </thead>
85+ <tbody>
86+ <tmpl_loop name="records">
87+ <tr class="tbl_row_<tmpl_if name= \'__EVEN__ \'}even<tmpl_else>uneven</tmpl_if>">
88+ ' ;
89+
90+ foreach ($ listDef ["item " ] as $ field ) {
91+ $ key = $ field ["field " ];
92+ $ html .= " <td class= \"tbl_col_ " .$ key ."\"><a href= \"# \" onClick= \"loadContent(' " .$ module ."/ " .$ listDef ["edit_file " ]."?id={tmpl_var name='id'}'); \">{tmpl_var name= \"" .$ key ."\"}</a></td> \r\n" ;
93+ }
94+
95+ $ html .= " <td class= \"tbl_col_buttons \">
96+ <div class= \"buttons icons16 \">
97+ <a class= \"icons16 icoDelete \" href= \"javascript: del_record(' " .$ module ."/ " .$ listDef ["delete_file " ]."?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}'); \"><span>{tmpl_var name='delete_txt'}</span></a>
98+ </div>
99+ </td>
100+ </tr>
101+ </tmpl_loop>
102+ </tbody> " ;
103+ $ html .= '
104+ <tfoot>
105+ <tr>
106+ <td class="tbl_footer tbl_paging" colspan=" ' .(count ($ listDef ["item " ])+1 ).'"><tmpl_var name="paging"></td>
107+ </tr>
108+ </tfoot>
109+ </table>
110+ </fieldset>
111+ </div>
112+
113+ </div>
114+ ' ;
115+
116+ if ($ module == '' ) {
117+ $ filename = 'templates/ ' .$ listDef ["name " ].'_list.htm ' ;
118+ } else {
119+ $ filename = '../ ' .$ module .'/templates/ ' .$ listDef ["name " ].'_list.htm ' ;
120+ }
121+
122+
123+ // save template
124+ if (!$ handle = fopen ($ filename , 'w ' )) {
125+ print "Cannot open file ( $ filename) " ;
126+ exit ;
127+ }
128+
129+ if (!fwrite ($ handle , $ html )) {
130+ print "Cannot write to file ( $ filename) " ;
131+ exit ;
132+ }
133+ fclose ($ handle );
134+
135+ }
136+
137+ }
138+
139139?>
0 commit comments