|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
You may not change or alter any portion of this comment or credits |
|
5
|
|
|
of supporting developers from this source code or any supporting source code |
|
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
|
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
/** |
|
13
|
|
|
* tdmcreate module. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
|
16
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
17
|
|
|
* |
|
18
|
|
|
* @since 2.5.0 |
|
19
|
|
|
* |
|
20
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
21
|
|
|
* |
|
22
|
|
|
* @version $Id: templates_index.php 12258 2014-01-02 09:33:29Z timgno $ |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class TemplatesUserIndex. |
|
27
|
|
|
*/ |
|
28
|
|
|
class TemplatesUserIndex extends TDMCreateFile |
|
|
|
|
|
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @public function constructor |
|
32
|
|
|
* @param null |
|
33
|
|
|
*/ |
|
34
|
|
|
|
|
35
|
|
|
public function __construct() |
|
36
|
|
|
{ |
|
37
|
|
|
parent::__construct(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @static function getInstance |
|
42
|
|
|
* @param null |
|
43
|
|
|
* @return TemplatesUserIndex |
|
44
|
|
|
*/ |
|
45
|
|
|
public static function getInstance() |
|
46
|
|
|
{ |
|
47
|
|
|
static $instance = false; |
|
48
|
|
|
if (!$instance) { |
|
49
|
|
|
$instance = new self(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return $instance; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @public function write |
|
57
|
|
|
* @param $module |
|
58
|
|
|
* @param $table |
|
59
|
|
|
* @param $tables |
|
60
|
|
|
* @param $filename |
|
61
|
|
|
*/ |
|
62
|
|
|
public function write($module, $table, $tables, $filename) |
|
63
|
|
|
{ |
|
64
|
|
|
$this->setModule($module); |
|
65
|
|
|
$this->setTable($table); |
|
66
|
|
|
$this->setTables($tables); |
|
67
|
|
|
$this->setFileName($filename); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @public function getTemplateUserIndexHeader |
|
72
|
|
|
* @param $moduleDirname |
|
73
|
|
|
* @return bool|string |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getTemplateUserIndexHeader($moduleDirname) |
|
76
|
|
|
{ |
|
77
|
|
|
$hc = TDMCreateSmartyCode::getInstance(); |
|
78
|
|
|
|
|
79
|
|
|
return $hc->getSmartyIncludeFile($moduleDirname, 'header').PHP_EOL; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @private function getTemplatesUserIndexTable |
|
84
|
|
|
* @param $moduleDirname |
|
85
|
|
|
* @param $tableName |
|
86
|
|
|
* @param $tableSolename |
|
87
|
|
|
* @param $language |
|
88
|
|
|
* @return string |
|
89
|
|
|
*/ |
|
90
|
|
|
private function getTemplatesUserIndexTable($moduleDirname, $tableName, $tableSolename, $language) |
|
|
|
|
|
|
91
|
|
|
{ |
|
92
|
|
|
$hc = TDMCreateHtmlSmartyCodes::getInstance(); |
|
93
|
|
|
$single = $hc->getSmartySingleVar('table_type'); |
|
94
|
|
|
$table = $this->getTemplatesUserIndexTableThead($tableName, $language); |
|
95
|
|
|
$table .= $this->getTemplatesUserIndexTableTBody($moduleDirname, $tableName, $tableSolename, $language); |
|
96
|
|
|
|
|
97
|
|
|
return $hc->getHtmlTable($table, 'table table-'.$single).PHP_EOL; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @private function getTemplatesUserIndexThead |
|
102
|
|
|
* @param string $language |
|
103
|
|
|
* @param $tableName |
|
104
|
|
|
* @return string |
|
105
|
|
|
*/ |
|
106
|
|
|
private function getTemplatesUserIndexTableThead($tableName, $language) |
|
107
|
|
|
{ |
|
108
|
|
|
$hc = TDMCreateHtmlSmartyCodes::getInstance(); |
|
109
|
|
|
$stuTableName = strtoupper($tableName); |
|
110
|
|
|
$lang = $hc->getSmartyConst($language, $stuTableName); |
|
111
|
|
|
$col = $hc->getSmartySingleVar('numb_col'); |
|
112
|
|
|
$th = $hc->getHtmlTableHead($lang, '', $col).PHP_EOL; |
|
113
|
|
|
$tr = $hc->getHtmlTableRow($th, 'head').PHP_EOL; |
|
114
|
|
|
|
|
115
|
|
|
return $hc->getHtmlTableThead($tr).PHP_EOL; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @private function getTemplatesUserIndexTbody |
|
120
|
|
|
* @param $moduleDirname |
|
121
|
|
|
* @param $tableName |
|
122
|
|
|
* @param $tableSolename |
|
123
|
|
|
* @param $language |
|
124
|
|
|
* @return string |
|
125
|
|
|
*/ |
|
126
|
|
|
private function getTemplatesUserIndexTableTBody($moduleDirname, $tableName, $tableSolename, $language) |
|
|
|
|
|
|
127
|
|
|
{ |
|
128
|
|
|
$hc = TDMCreateHtmlSmartyCodes::getInstance(); |
|
129
|
|
|
$type = $hc->getSmartySingleVar('panel_type'); |
|
130
|
|
|
$include = $hc->getSmartyIncludeFileListForeach($moduleDirname, $tableName, $tableSolename); |
|
131
|
|
|
$div = $hc->getHtmlDiv($include, 'panel panel-'.$type); |
|
132
|
|
|
$cont = $hc->getHtmlTableData($div).PHP_EOL; |
|
133
|
|
|
$html = $hc->getHtmlEmpty('</tr><tr>').PHP_EOL; |
|
134
|
|
|
$cont .= $hc->getSmartyConditions($tableSolename.'.count', ' is div by ', '$divideby', $html).PHP_EOL; |
|
135
|
|
|
$foreach = $hc->getSmartyForeach($tableSolename, $tableName, $cont).PHP_EOL; |
|
136
|
|
|
$tr = $hc->getHtmlTableRow($foreach).PHP_EOL; |
|
137
|
|
|
|
|
138
|
|
|
return $hc->getHtmlTableTbody($tr).PHP_EOL; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @private function getTemplatesUserIndexTfoot |
|
143
|
|
|
* @return string |
|
144
|
|
|
*/ |
|
145
|
|
|
private function getTemplatesUserIndexTableTfoot() |
|
|
|
|
|
|
146
|
|
|
{ |
|
147
|
|
|
$hc = TDMCreateHtmlCode::getInstance(); |
|
148
|
|
|
$td = $hc->getHtmlTableData(' ').PHP_EOL; |
|
149
|
|
|
$tr = $hc->getHtmlTableRow($td).PHP_EOL; |
|
150
|
|
|
|
|
151
|
|
|
return $hc->getHtmlTableTfoot($tr).PHP_EOL; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @public function getTemplatesUserIndexBodyDefault |
|
156
|
|
|
* @param $module |
|
157
|
|
|
* @param $table |
|
158
|
|
|
* @param $language |
|
159
|
|
|
* @return bool|string |
|
160
|
|
|
*/ |
|
161
|
|
|
public function getTemplatesUserIndexBodyDefault($module, $table, $language) |
|
162
|
|
|
{ |
|
163
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
164
|
|
|
$tableName = $table->getVar('table_name'); |
|
165
|
|
|
$ret = <<<EOT |
|
166
|
|
|
<{if count(\${$tableName}) == 0}> |
|
167
|
|
|
<table class="table table-<{\$table_type}>"> |
|
168
|
|
|
<thead> |
|
169
|
|
|
<tr class="center"> |
|
170
|
|
|
<th><{\$smarty.const.{$language}TITLE}> - <{\$smarty.const.{$language}DESC}></th> |
|
171
|
|
|
</tr> |
|
172
|
|
|
</thead> |
|
173
|
|
|
<tbody> |
|
174
|
|
|
<tr class="center"> |
|
175
|
|
|
<td class="bold pad5"> |
|
176
|
|
|
<ul class="menu text-center"> |
|
177
|
|
|
<li><a href="<{\${$moduleDirname}_url}>"><{\$smarty.const.{$language}INDEX}></a></li>\n |
|
178
|
|
|
EOT; |
|
179
|
|
|
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
|
180
|
|
|
foreach (array_keys($tables) as $i) { |
|
181
|
|
|
$tableName = $tables[$i]->getVar('table_name'); |
|
182
|
|
|
$stuTableName = strtoupper($tableName); |
|
183
|
|
|
$ret .= <<<EOT |
|
184
|
|
|
<li><a href="<{\${$moduleDirname}_url}>/{$tableName}.php"><{\$smarty.const.{$language}{$stuTableName}}></a></li>\n |
|
185
|
|
|
EOT; |
|
186
|
|
|
} |
|
187
|
|
|
$ret .= <<<EOT |
|
188
|
|
|
</ul> |
|
189
|
|
|
<div class="justify pad5"><{\$smarty.const.{$language}INDEX_DESC}></div> |
|
190
|
|
|
</td> |
|
191
|
|
|
</tr> |
|
192
|
|
|
</tbody> |
|
193
|
|
|
<tfoot> |
|
194
|
|
|
<{if \$adv != ''}> |
|
195
|
|
|
<tr class="center"><td class="center bold pad5"><{\$adv}></td></tr> |
|
196
|
|
|
<{else}> |
|
197
|
|
|
<tr class="center"><td class="center bold pad5"> </td></tr> |
|
198
|
|
|
<{/if}> |
|
199
|
|
|
</tfoot> |
|
200
|
|
|
</table> |
|
201
|
|
|
<{/if}>\n |
|
202
|
|
|
EOT; |
|
203
|
|
|
|
|
204
|
|
|
return $ret; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* @public function getTemplateUserIndexCategories |
|
209
|
|
|
* @param $moduleDirname |
|
210
|
|
|
* @param $tableName |
|
211
|
|
|
* @param $tableSoleName |
|
212
|
|
|
* @param $language |
|
213
|
|
|
* @return bool|string |
|
214
|
|
|
*/ |
|
215
|
|
|
public function getTemplateUserIndexCategories($moduleDirname, $tableName, $tableSoleName, $language) |
|
216
|
|
|
{ |
|
217
|
|
|
$stuTableName = strtoupper($tableName); |
|
218
|
|
|
$ret = <<<EOT |
|
219
|
|
|
<{if count(\${$tableName}) > 0}> |
|
220
|
|
|
<div class="table-responsive"> |
|
221
|
|
|
<table class="table table-<{\$table_type}>"> |
|
222
|
|
|
<thead> |
|
223
|
|
|
<tr> |
|
224
|
|
|
<th colspan="<{\$numb_col}>"><{\$smarty.const.{$language}{$stuTableName}}></th> |
|
225
|
|
|
</tr> |
|
226
|
|
|
</thead> |
|
227
|
|
|
<tbody> |
|
228
|
|
|
<tr> |
|
229
|
|
|
<{foreach item={$tableSoleName} from=\${$tableName}}> |
|
230
|
|
|
<td> |
|
231
|
|
|
<{include file="db:{$moduleDirname}_{$tableName}_list.tpl" {$tableSoleName}=\${$tableSoleName}}> |
|
232
|
|
|
</td> |
|
233
|
|
|
<{if \${$tableSoleName}.count is div by \$numb_col}> |
|
234
|
|
|
</tr><tr> |
|
235
|
|
|
<{/if}> |
|
236
|
|
|
<{/foreach}> |
|
237
|
|
|
</tr> |
|
238
|
|
|
</tbody> |
|
239
|
|
|
<tfoot> |
|
240
|
|
|
<tr> |
|
241
|
|
|
<td colspan="<{\$numb_col}>" class="{$tableSoleName}-thereare"><{\$lang_thereare}></td> |
|
242
|
|
|
</tr> |
|
243
|
|
|
</tfoot> |
|
244
|
|
|
</table> |
|
245
|
|
|
</div> |
|
246
|
|
|
<{/if}>\n |
|
247
|
|
|
EOT; |
|
248
|
|
|
$hc = TDMCreateHtmlSmartyCodes::getInstance(); |
|
249
|
|
|
$single = $hc->getSmartySingleVar('table_type'); |
|
250
|
|
|
$table = $this->getTemplatesUserIndexTableThead($tableName, $language); |
|
251
|
|
|
$table .= $this->getTemplatesUserIndexTableTBody($moduleDirname, $tableName, $tableSoleName, $language); |
|
252
|
|
|
$table .= $hc->getHtmlTable($table, 'table table-'.$single).PHP_EOL; |
|
253
|
|
|
$div = $hc->getHtmlDiv($table, 'table-responsive').PHP_EOL; |
|
|
|
|
|
|
254
|
|
|
|
|
255
|
|
|
return $ret/*$hc->getSmartyConditions($tableName, ' > ', '0', $div, false, true)*/.PHP_EOL; |
|
|
|
|
|
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* @public function getTemplateUserIndexTable |
|
260
|
|
|
* @param $moduleDirname |
|
261
|
|
|
* @param $tableName |
|
262
|
|
|
* @param $tableSoleName |
|
263
|
|
|
* @param $language |
|
264
|
|
|
* @return bool|string |
|
265
|
|
|
*/ |
|
266
|
|
|
public function getTemplateUserIndexTable($moduleDirname, $tableName, $tableSoleName, $language) |
|
267
|
|
|
{ |
|
268
|
|
|
$ret = <<<EOT |
|
269
|
|
|
<{if count(\${$tableName}) > 0}> |
|
270
|
|
|
<!-- Start Show new {$tableName} in index --> |
|
271
|
|
|
<div class="{$moduleDirname}-linetitle"><{\$smarty.const.{$language}INDEX_LATEST_LIST}></div> |
|
272
|
|
|
<table class="table table-<{\$table_type}>"> |
|
273
|
|
|
<tr> |
|
274
|
|
|
<!-- Start new link loop --> |
|
275
|
|
|
<{section name=i loop=\${$tableName}}> |
|
276
|
|
|
<td class="col_width<{\$numb_col}> top center"> |
|
277
|
|
|
<{include file="db:{$moduleDirname}_{$tableName}_list.tpl" {$tableSoleName}=\${$tableName}[i]}> |
|
278
|
|
|
</td> |
|
279
|
|
|
<{if \${$tableName}[i].count is div by \$divideby}> |
|
280
|
|
|
</tr><tr> |
|
281
|
|
|
<{/if}> |
|
282
|
|
|
<{/section}> |
|
283
|
|
|
<!-- End new link loop --> |
|
284
|
|
|
</tr> |
|
285
|
|
|
</table> |
|
286
|
|
|
<!-- End Show new files in index --> |
|
287
|
|
|
<{/if}>\n |
|
288
|
|
|
EOT; |
|
289
|
|
|
|
|
290
|
|
|
return $ret; |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
/** |
|
294
|
|
|
* @public function getTemplateUserIndexFooter |
|
295
|
|
|
* @param $moduleDirname |
|
296
|
|
|
* @return bool|string |
|
297
|
|
|
*/ |
|
298
|
|
|
public function getTemplateUserIndexFooter($moduleDirname) |
|
299
|
|
|
{ |
|
300
|
|
|
$hc = TDMCreateSmartyCode::getInstance(); |
|
301
|
|
|
|
|
302
|
|
|
return $hc->getSmartyIncludeFile($moduleDirname, 'footer'); |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
/** |
|
306
|
|
|
* @public function render |
|
307
|
|
|
* @param null |
|
308
|
|
|
* @return bool|string |
|
309
|
|
|
*/ |
|
310
|
|
|
public function render() |
|
311
|
|
|
{ |
|
312
|
|
|
$module = $this->getModule(); |
|
313
|
|
|
$table = $this->getTable(); |
|
314
|
|
|
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
|
315
|
|
|
$filename = $this->getFileName(); |
|
316
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
317
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA'); |
|
318
|
|
|
$content = $this->getTemplateUserIndexHeader($moduleDirname); |
|
319
|
|
|
$content .= $this->getTemplatesUserIndexBodyDefault($module, $table, $language); |
|
320
|
|
|
foreach (array_keys($tables) as $t) { |
|
321
|
|
|
$tableName = $tables[$t]->getVar('table_name'); |
|
322
|
|
|
$tableSoleName = $tables[$t]->getVar('table_solename'); |
|
323
|
|
|
$tableCategory[] = $tables[$t]->getVar('table_category'); |
|
|
|
|
|
|
324
|
|
|
$tableFieldname = $tables[$t]->getVar('table_fieldname'); |
|
|
|
|
|
|
325
|
|
|
$tableIndex[] = $tables[$t]->getVar('table_index'); |
|
|
|
|
|
|
326
|
|
|
if (in_array(1, $tableCategory) && in_array(1, $tableIndex)) { |
|
|
|
|
|
|
327
|
|
|
$content .= $this->getTemplateUserIndexCategories($moduleDirname, $tableName, $tableSoleName, $language); |
|
328
|
|
|
} |
|
329
|
|
|
if (in_array(0, $tableCategory) && in_array(1, $tableIndex)) { |
|
330
|
|
|
$content .= $this->getTemplateUserIndexTable($moduleDirname, $tableName, $tableSoleName, $language); |
|
331
|
|
|
} |
|
332
|
|
|
} |
|
333
|
|
|
$content .= $this->getTemplateUserIndexFooter($moduleDirname); |
|
334
|
|
|
$tdmcfile = TDMCreateFile::getInstance(); |
|
335
|
|
|
$tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
336
|
|
|
|
|
337
|
|
|
return $tdmcfile->renderFile(); |
|
338
|
|
|
} |
|
339
|
|
|
} |
|
340
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.