1- <?php
2-
3- /*
4- Copyright (c) 2005, 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-
32- class listform_tpl_generator {
33-
34- function buildHTML ($ listDef ,$ module = '' ) {
35-
36- global $ app ;
37-
38- $ lang = array ();
39- $ html = '<form name="myform" action=" ' .$ listDef ["file " ].'" method="POST">
40- <div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
41- <table width="100%" border="0" cellspacing="0" cellpadding="4">
42- <tr>
43- ' ;
44-
45- $ lang ["list_head_txt " ] = $ listDef ["name " ];
46- foreach ($ listDef ["item " ] as $ field ) {
47- $ key = $ field ["field " ];
48- $ html .= " <td class= \"tblHead \"><tmpl_var name= \"" .$ key ."_txt \"></td> \r\n" ;
49- $ lang [$ key ."_txt " ] = $ key ;
50- }
51-
52- $ html .= ' <td class="tblHead"> </td>
53- </tr>
54- <tr>
55- ' ;
56-
57- foreach ($ listDef ["item " ] as $ field ) {
58- $ key = $ field ["field " ];
59- if ($ field ["formtype " ] == 'SELECT ' ) {
60- $ html .= " <td class= \"frmText11 \"><select name= \"" .$ listDef ["search_prefix " ].$ key ."\" onChange= \"document.myform.submit(); \">{tmpl_var name=' " .$ listDef ["search_prefix " ].$ key ."'}</select></td> \r\n" ;
61- } else {
62- $ html .= " <td class= \"frmText11 \"><input type= \"text \" name= \"" .$ listDef ["search_prefix " ].$ key ."\" value= \"{tmpl_var name=' " .$ listDef ["search_prefix " ].$ key ."'} \" class= \"text \" /></td> \r\n" ;
63- }
64- }
65-
66- $ html .= ' <td class="frmText11" align="right"><input name="Filter" type="submit" id="Filter" value="{tmpl_var name="filter_txt"}"></td>
67- </tr>
68- <tmpl_loop name="records">
69- <tr bgcolor="{tmpl_var name="bgcolor"}">
70- ' ;
71-
72- foreach ($ listDef ["item " ] as $ field ) {
73- $ key = $ field ["field " ];
74- $ html .= " <td class= \"frmText11 \"><a href= \"" .$ listDef ["edit_file " ]."?id={tmpl_var name='id'} \" class= \"frmText11 \">{tmpl_var name= \"" .$ key ."\"}</a></td> \r\n" ;
75- }
76-
77- $ html .= " <td class= \"frmText11 \" align= \"right \">[<a href= \"javascript: del_record(' " .$ listDef ["delete_file " ]."?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}'); \" class= \"frmText11 \">{tmpl_var name='delete_txt'}</a>]</td>
78- </tr>
79- </tmpl_loop>
80- " ;
81- $ html .= '
82- <tr>
83- <td colspan=" ' .(count ($ listDef ["item " ])+1 ).'" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td>
84- </tr>
85- </table>
86- </form> ' ;
87-
88- if ($ module == '' ) {
89- $ filename = 'templates/ ' .$ listDef ["name " ].'_list.htm ' ;
90- } else {
91- $ filename = '../ ' .$ module .'/templates/ ' .$ listDef ["name " ].'_list.htm ' ;
92- }
93-
94-
95- // speichere Template
96- if (!$ handle = fopen ($ filename , 'w ' )) {
97- print "Cannot open file ( $ filename) " ;
98- exit ;
99- }
100-
101- if (!fwrite ($ handle , $ html )) {
102- print "Cannot write to file ( $ filename) " ;
103- exit ;
104- }
105- fclose ($ handle );
106-
107- $ lang ["page_txt " ] = 'Page ' ;
108- $ lang ["page_of_txt " ] = 'of ' ;
109- $ lang ["page_next_txt " ] = 'Next ' ;
110- $ lang ["page_back_txt " ] = 'Back ' ;
111- $ lang ["delete_txt " ] = 'Delete ' ;
112- $ lang ["filter_txt " ] = 'Filter ' ;
113-
114- // speichere language Datei
115- $ this ->lng_add ($ lang ,$ listDef ,$ module );
116- }
117-
118- function lng_add ($ lang ,$ listDef ,$ module = '' ) {
119- global $ go_api , $ go_info ,$ conf ;
120-
121- if ($ module == '' ) {
122- $ lng_file = "lib/lang/ " .$ conf ["language " ]."_ " .$ listDef ['name ' ]."_list.lng " ;
123- } else {
124- $ lng_file = '../ ' .$ module ."/lib/lang/en_ " .$ listDef ['name ' ]."_list.lng " ;
125- }
126-
127- if (is_file ($ lng_file )) {
128- include_once ($ lng_file );
129- } else {
130- $ wb = array ();
131- }
132-
133- $ wb_out = array_merge ($ wb ,$ lang );
134-
135- if (is_array ($ wb_out )) {
136- $ fp = fopen ($ lng_file , "w " );
137- fwrite ($ fp ,"<?php \r\n" );
138- foreach ($ wb_out as $ key => $ val ) {
139- $ new_line = '$wb[" ' .$ key .'"] = ' ."' $ val'; \r\n" ;
140- fwrite ($ fp ,$ new_line );
141-
142- }
143- fwrite ($ fp ,"?> " );
144- fclose ($ fp );
145- }
146- }
147- }
148-
1+ <?php
2+
3+ /*
4+ Copyright (c) 2005, 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+
32+ class listform_tpl_generator {
33+
34+ function buildHTML ($ listDef ,$ module = '' ) {
35+
36+ global $ app ;
37+
38+ if ($ module == '' ) $ module = $ _SESSION ["s " ]["module " ]["name " ];
39+
40+ $ lang = array ();
41+ $ html = '<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
42+ <input type="button" value="{tmpl_var name="add_new_record_txt"}" class="button" onClick=" ' ."loadContent(' " .$ module ."/ " .$ listDef ["edit_file " ]."'); " .'" /><div class="buttonEnding"></div><br /><br />
43+ <table width="100%" border="0" cellspacing="0" cellpadding="4" class="listTable">
44+ <tr>
45+ ' ;
46+
47+ $ lang ["list_head_txt " ] = $ listDef ["name " ];
48+ foreach ($ listDef ["item " ] as $ field ) {
49+ $ key = $ field ["field " ];
50+ $ html .= " <td class= \"tblHead \"><tmpl_var name= \"" .$ key ."_txt \"></td> \r\n" ;
51+ $ lang [$ key ."_txt " ] = $ key ;
52+ }
53+
54+ $ html .= ' <td class="tblHead"> </td>
55+ </tr>
56+ <tr>
57+ ' ;
58+
59+ foreach ($ listDef ["item " ] as $ field ) {
60+ $ key = $ field ["field " ];
61+ if ($ field ["formtype " ] == 'SELECT ' ) {
62+ $ html .= " <td class= \"frmText11 \"><select name= \"" .$ listDef ["search_prefix " ].$ key ."\" onChange= \"submitForm('pageForm',' " .$ module ."/ " .$ listDef ["file " ]."'); \">{tmpl_var name=' " .$ listDef ["search_prefix " ].$ key ."'}</select></td> \r\n" ;
63+ } else {
64+ $ html .= " <td class= \"frmText11 \"><input type= \"text \" name= \"" .$ listDef ["search_prefix " ].$ key ."\" value= \"{tmpl_var name=' " .$ listDef ["search_prefix " ].$ key ."'} \" class= \"text \" /></td> \r\n" ;
65+ }
66+ }
67+
68+ $ html .= ' <td class="frmText11" align="right"><input name="Filter" type="button" id="Filter" value="{tmpl_var name="filter_txt"}" class="button" onClick=" ' ."submitForm('pageForm',' " .$ module ."/ " .$ listDef ["file " ]."'); " .'"><div class="buttonEnding"></div></td>
69+ </tr>
70+ <tmpl_loop name="records">
71+ <tr bgcolor="{tmpl_var name="bgcolor"}">
72+ ' ;
73+
74+ foreach ($ listDef ["item " ] as $ field ) {
75+ $ key = $ field ["field " ];
76+ $ html .= " <td class= \"frmText11 \"><a href= \"# \" onClick= \"loadContent(' " .$ module ."/ " .$ listDef ["edit_file " ]."?id={tmpl_var name='id'}'); \" class= \"frmText11 \">{tmpl_var name= \"" .$ key ."\"}</a></td> \r\n" ;
77+ }
78+
79+ $ html .= " <td class= \"frmText11 \" align= \"right \">[<a href= \"javascript: del_record(' " .$ module ."/ " .$ listDef ["delete_file " ]."?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}'); \" class= \"frmText11 \">{tmpl_var name='delete_txt'}</a>]</td>
80+ </tr>
81+ </tmpl_loop>
82+ " ;
83+ $ html .= '
84+ <tr>
85+ <td colspan=" ' .(count ($ listDef ["item " ])+1 ).'" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td>
86+ </tr>
87+ </table> ' ;
88+
89+ if ($ module == '' ) {
90+ $ filename = 'templates/ ' .$ listDef ["name " ].'_list.htm ' ;
91+ } else {
92+ $ filename = '../ ' .$ module .'/templates/ ' .$ listDef ["name " ].'_list.htm ' ;
93+ }
94+
95+
96+ // speichere Template
97+ if (!$ handle = fopen ($ filename , 'w ' )) {
98+ print "Cannot open file ( $ filename) " ;
99+ exit ;
100+ }
101+
102+ if (!fwrite ($ handle , $ html )) {
103+ print "Cannot write to file ( $ filename) " ;
104+ exit ;
105+ }
106+ fclose ($ handle );
107+
108+ $ lang ["page_txt " ] = 'Page ' ;
109+ $ lang ["page_of_txt " ] = 'of ' ;
110+ $ lang ["page_next_txt " ] = 'Next ' ;
111+ $ lang ["page_back_txt " ] = 'Back ' ;
112+ $ lang ["delete_txt " ] = 'Delete ' ;
113+ $ lang ["filter_txt " ] = 'Filter ' ;
114+
115+ // speichere language Datei
116+ $ this ->lng_add ($ lang ,$ listDef ,$ module );
117+ }
118+
119+ function lng_add ($ lang ,$ listDef ,$ module = '' ) {
120+ global $ go_api , $ go_info ,$ conf ;
121+
122+ if ($ module == '' ) {
123+ $ lng_file = "lib/lang/ " .$ conf ["language " ]."_ " .$ listDef ['name ' ]."_list.lng " ;
124+ } else {
125+ $ lng_file = '../ ' .$ module ."/lib/lang/en_ " .$ listDef ['name ' ]."_list.lng " ;
126+ }
127+
128+ if (is_file ($ lng_file )) {
129+ include_once ($ lng_file );
130+ } else {
131+ $ wb = array ();
132+ }
133+
134+ $ wb_out = array_merge ($ lang ,$ wb );
135+
136+ if (is_array ($ wb_out )) {
137+ $ fp = fopen ($ lng_file , "w " );
138+ fwrite ($ fp ,"<?php \r\n" );
139+ foreach ($ wb_out as $ key => $ val ) {
140+ $ new_line = '$wb[" ' .$ key .'"] = ' ."' $ val'; \r\n" ;
141+ fwrite ($ fp ,$ new_line );
142+
143+ }
144+ fwrite ($ fp ,"?> " );
145+ fclose ($ fp );
146+ }
147+ }
148+ }
149+
149150?>
0 commit comments