|
1
|
|
|
<?php namespace XoopsModules\Tdmcreate\Files\Templates\Admin; |
|
2
|
|
|
|
|
3
|
|
|
use XoopsModules\Tdmcreate; |
|
4
|
|
|
use XoopsModules\Tdmcreate\Files; |
|
5
|
|
|
|
|
6
|
|
|
/* |
|
7
|
|
|
You may not change or alter any portion of this comment or credits |
|
8
|
|
|
of supporting developers from this source code or any supporting source code |
|
9
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
10
|
|
|
|
|
11
|
|
|
This program is distributed in the hope that it will be useful, |
|
12
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
*/ |
|
15
|
|
|
/** |
|
16
|
|
|
* tdmcreate module. |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
19
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
20
|
|
|
* |
|
21
|
|
|
* @since 2.5.0 |
|
22
|
|
|
* |
|
23
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
24
|
|
|
* |
|
25
|
|
|
* @version $Id: TemplatesAdminPages.php 12258 2014-01-02 09:33:29Z timgno $ |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class TemplatesAdminPages. |
|
30
|
|
|
*/ |
|
31
|
|
|
class TemplatesAdminPages extends Files\CreateFile |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @public function constructor |
|
35
|
|
|
* @param null |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
|
|
parent::__construct(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @static function getInstance |
|
44
|
|
|
* @param null |
|
45
|
|
|
* @return TemplatesAdminPages |
|
46
|
|
|
*/ |
|
47
|
|
|
public static function getInstance() |
|
48
|
|
|
{ |
|
49
|
|
|
static $instance = false; |
|
50
|
|
|
if (!$instance) { |
|
51
|
|
|
$instance = new self(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
return $instance; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @public function write |
|
59
|
|
|
* @param string $module |
|
60
|
|
|
* @param string $table |
|
61
|
|
|
* @param $filename |
|
62
|
|
|
*/ |
|
63
|
|
|
public function write($module, $table, $filename) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->setModule($module); |
|
66
|
|
|
$this->setTable($table); |
|
67
|
|
|
$this->setFileName($filename); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @private function getTemplatesAdminPagesHeader |
|
72
|
|
|
* @param string $moduleDirname |
|
73
|
|
|
* @return string |
|
74
|
|
|
*/ |
|
75
|
|
|
private function getTemplatesAdminPagesHeader($moduleDirname) |
|
76
|
|
|
{ |
|
77
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
78
|
|
|
$ret = $hc->getHtmlComment('Header') . PHP_EOL; |
|
79
|
|
|
$ret .= $hc->getSmartyIncludeFile($moduleDirname, 'header', true); |
|
80
|
|
|
|
|
81
|
|
|
return $ret; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @private function getTemplatesAdminPagesTableThead |
|
86
|
|
|
* @param $tableSoleName |
|
87
|
|
|
* @param $tableAutoincrement |
|
88
|
|
|
* @param string $fields |
|
89
|
|
|
* @param string $language |
|
90
|
|
|
* @return string |
|
91
|
|
|
*/ |
|
92
|
|
|
private function getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincrement, $fields, $language) |
|
93
|
|
|
{ |
|
94
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
95
|
|
|
$th = ''; |
|
96
|
|
|
$langHeadId = mb_strtoupper($tableSoleName) . '_ID'; |
|
97
|
|
|
if (1 == $tableAutoincrement) { |
|
98
|
|
|
$lang = $hc->getSmartyConst($language, $langHeadId); |
|
99
|
|
|
$th .= $hc->getHtmlTag('th', ['class' => 'center'], $lang, false, false, "\t\t\t"); |
|
|
|
|
|
|
100
|
|
|
} |
|
101
|
|
|
foreach (array_keys($fields) as $f) { |
|
|
|
|
|
|
102
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
103
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
|
104
|
|
|
$langFieldName = mb_strtoupper($tableSoleName) . '_' . mb_strtoupper($rpFieldName); |
|
105
|
|
|
if (1 == $fields[$f]->getVar('field_inlist')) { |
|
106
|
|
|
$lang = $hc->getSmartyConst($language, $langFieldName); |
|
107
|
|
|
$th .= $hc->getHtmlTag('th', ['class' => 'center'], $lang, false, false, "\t\t\t"); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$lang = $hc->getSmartyConst($language, 'FORM_ACTION'); |
|
112
|
|
|
$th .= $hc->getHtmlTag('th', ['class' => 'center width5'], $lang, false, false, "\t\t\t"); |
|
113
|
|
|
$tr = $hc->getHtmlTag('tr', ['class' => 'head'], $th) . PHP_EOL; |
|
114
|
|
|
$ret = $hc->getHtmlTag('thead', [], $tr); |
|
115
|
|
|
|
|
116
|
|
|
return $ret; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @private function getTemplatesAdminPagesTableTBody |
|
121
|
|
|
* @param string $moduleDirname |
|
122
|
|
|
* @param string $tableName |
|
123
|
|
|
* @param $tableSoleName |
|
124
|
|
|
* @param $tableAutoincrement |
|
125
|
|
|
* @param string $fields |
|
126
|
|
|
* @return string |
|
127
|
|
|
* @internal param string $language |
|
128
|
|
|
*/ |
|
129
|
|
|
private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields) |
|
130
|
|
|
{ |
|
131
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
132
|
|
|
$td = ''; |
|
133
|
|
|
if (1 == $tableAutoincrement) { |
|
134
|
|
|
$double = $hc->getSmartyDoubleVar($tableSoleName, 'id'); |
|
135
|
|
|
$td .= $hc->getHtmlTableData($double, 'center'); |
|
136
|
|
|
} |
|
137
|
|
|
foreach (array_keys($fields) as $f) { |
|
|
|
|
|
|
138
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
139
|
|
|
$fieldElement = $fields[$f]->getVar('field_element'); |
|
140
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
|
141
|
|
|
if (0 == $f) { |
|
142
|
|
|
$fieldId = $fieldName; |
|
143
|
|
|
} |
|
144
|
|
|
if (1 == $fields[$f]->getVar('field_inlist')) { |
|
145
|
|
|
switch ($fieldElement) { |
|
146
|
|
|
case 9: |
|
147
|
|
|
// This is to be reviewed, as it was initially to style = "backgroung-color: #" |
|
148
|
|
|
// Now with HTML5 is not supported inline style in the parameters of the HTML tag |
|
149
|
|
|
// Old code was <span style="background-color: #<{\$list.{$rpFieldName}}>;">... |
|
150
|
|
|
$double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
151
|
|
|
$span = $hc->getHtmlTag('span', [], $double); |
|
152
|
|
|
$td .= $hc->getHtmlTag('td', ['class' => 'center'], $span); |
|
153
|
|
|
/*$ret .= <<<EOT |
|
154
|
|
|
<td class="center"><span style="background-color: #<{\$list.{$rpFieldName}}>;"> </span></td>\n |
|
155
|
|
|
EOT;*/ |
|
156
|
|
|
break; |
|
157
|
|
|
case 10: |
|
158
|
|
|
$src = $hc->getSmartyNoSimbol('xoModuleIcons32'); |
|
159
|
|
|
$src .= $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
160
|
|
|
$img = $hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, false); |
|
|
|
|
|
|
161
|
|
|
$td .= $hc->getHtmlTag('td', ['class' => 'center'], "\n\t" . $img); |
|
162
|
|
|
break; |
|
163
|
|
|
case 13: |
|
164
|
|
|
$single = $hc->getSmartySingleVar($moduleDirname . '_upload_url'); |
|
165
|
|
|
$double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
166
|
|
|
$img = $hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName, 'style' => 'max-width:100px'], '', true, false); |
|
167
|
|
|
$td .= $hc->getHtmlTag('td', ['class' => 'center'], $img, false, false, "\t\t"); |
|
|
|
|
|
|
168
|
|
|
break; |
|
169
|
|
|
default: |
|
170
|
|
|
if (0 != $f) { |
|
171
|
|
|
$double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
172
|
|
|
$td .= $hc->getHtmlTag('td', ['class' => 'center'], $double); |
|
173
|
|
|
} |
|
174
|
|
|
break; |
|
175
|
|
|
} |
|
176
|
|
|
} |
|
177
|
|
|
} |
|
178
|
|
|
$lang = $hc->getSmartyConst('', '_EDIT'); |
|
179
|
|
|
$double = $hc->getSmartyDoubleVar($tableSoleName, 'id'); |
|
180
|
|
|
$src = $hc->getSmartyNoSimbol('xoModuleIcons16 edit.png'); |
|
181
|
|
|
$img = $hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, false); |
|
182
|
|
|
$anchor = $hc->getHtmlTag('a', ['href' => $tableName . ".php?op=edit&{$fieldId}=" . $double, 'title' => $lang], "\n\t" . $img); |
|
|
|
|
|
|
183
|
|
|
$lang = $hc->getSmartyConst('', '_DELETE'); |
|
184
|
|
|
$double = $hc->getSmartyDoubleVar($tableSoleName, 'id'); |
|
185
|
|
|
$src = $hc->getSmartyNoSimbol('xoModuleIcons16 delete.png'); |
|
186
|
|
|
$img = $hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, false); |
|
187
|
|
|
$anchor .= $hc->getHtmlTag('a', ['href' => $tableName . ".php?op=delete&{$fieldId}=" . $double, 'title' => $lang], "\n\t" . $img); |
|
188
|
|
|
$td .= $hc->getHtmlTag('td', ['class' => 'center width5'], "\n" . $anchor); |
|
189
|
|
|
$cycle = $hc->getSmartyNoSimbol('cycle values=\'odd, even\''); |
|
190
|
|
|
$tr = $hc->getHtmlTag('tr', ['class' => $cycle], $td); |
|
191
|
|
|
$foreach = $hc->getSmartyForeach($tableSoleName, $tableName . '_list', $tr); |
|
192
|
|
|
$tbody = $hc->getHtmlTag('tbody', [], $foreach); |
|
193
|
|
|
|
|
194
|
|
|
return $hc->getSmartyConditions($tableName . '_count', '', '', $tbody); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* @private function getTemplatesAdminPagesTable |
|
199
|
|
|
* @param string $moduleDirname |
|
200
|
|
|
* @param string $tableName |
|
201
|
|
|
* @param $tableSoleName |
|
202
|
|
|
* @param $tableAutoincrement |
|
203
|
|
|
* @param string $fields |
|
204
|
|
|
* @param string $language |
|
205
|
|
|
* @return string |
|
206
|
|
|
*/ |
|
207
|
|
|
private function getTemplatesAdminPagesTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language) |
|
208
|
|
|
{ |
|
209
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
210
|
|
|
$tbody = $this->getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincrement, $fields, $language); |
|
211
|
|
|
$tbody .= $this->getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields); |
|
212
|
|
|
|
|
213
|
|
|
return $hc->getHtmlTable($tbody, 'table table-bordered'); |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
/** |
|
217
|
|
|
* @private function getTemplatesAdminPages |
|
218
|
|
|
* @param string $moduleDirname |
|
219
|
|
|
* @param string $tableName |
|
220
|
|
|
* @param $tableSoleName |
|
221
|
|
|
* @param $tableAutoincrement |
|
222
|
|
|
* @param string $fields |
|
223
|
|
|
* @param string $language |
|
224
|
|
|
* @return string |
|
225
|
|
|
*/ |
|
226
|
|
|
private function getTemplatesAdminPages($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language) |
|
227
|
|
|
{ |
|
228
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
229
|
|
|
$htmlTable = $this->getTemplatesAdminPagesTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language); |
|
230
|
|
|
$htmlTable .= $hc->getHtmlTag('div', ['class' => 'clear'], ' '); |
|
231
|
|
|
$single = $hc->getSmartySingleVar('pagenav'); |
|
232
|
|
|
$div = $hc->getHtmlTag('div', ['class' => 'xo-pagenav floatright'], $single); |
|
233
|
|
|
$div .= $hc->getHtmlTag('div', ['class' => 'clear spacer'], ''); |
|
234
|
|
|
$htmlTable .= $hc->getSmartyConditions('pagenav', '', '', $div); |
|
235
|
|
|
$ifList = $hc->getSmartyConditions($tableName . '_list', '', '', $htmlTable); |
|
236
|
|
|
$single = $hc->getSmartySingleVar('form'); |
|
237
|
|
|
$divComm = $hc->getHtmlComment('Display navigation'); |
|
|
|
|
|
|
238
|
|
|
//$divComm .= $hc->getHtmlTag('div', array('class' => 'errorMsg'), $single); |
|
239
|
|
|
$ifList .= $hc->getSmartyConditions('form', '', '', $single); |
|
240
|
|
|
$single = $hc->getSmartySingleVar('error'); |
|
241
|
|
|
$strong = $hc->getHtmlTag('strong', [], $single); |
|
242
|
|
|
$div = $hc->getHtmlTag('div', ['class' => 'errorMsg'], $strong); |
|
243
|
|
|
$ifList .= $hc->getSmartyConditions('error', '', '', $div); |
|
244
|
|
|
|
|
245
|
|
|
return $ifList; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* @private function getTemplatesAdminPagesFooter |
|
250
|
|
|
* @param string $moduleDirname |
|
251
|
|
|
* @return string |
|
252
|
|
|
*/ |
|
253
|
|
|
private function getTemplatesAdminPagesFooter($moduleDirname) |
|
254
|
|
|
{ |
|
255
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
256
|
|
|
$ret = $hc->getHtmlTag('br', [], '', true); |
|
257
|
|
|
$ret .= $hc->getHtmlComment('Footer'); |
|
258
|
|
|
$ret .= $hc->getSmartyIncludeFile($moduleDirname, 'footer', true); |
|
259
|
|
|
|
|
260
|
|
|
return $ret; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* @public function render |
|
265
|
|
|
* @param null |
|
266
|
|
|
* @return bool|string |
|
267
|
|
|
*/ |
|
268
|
|
|
public function render() |
|
269
|
|
|
{ |
|
270
|
|
|
$module = $this->getModule(); |
|
271
|
|
|
$table = $this->getTable(); |
|
272
|
|
|
$filename = $this->getFileName(); |
|
273
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
274
|
|
|
$language = $this->getLanguage($moduleDirname, 'AM'); |
|
275
|
|
|
$fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'), 'field_order'); |
|
276
|
|
|
$content = $this->getTemplatesAdminPagesHeader($moduleDirname); |
|
277
|
|
|
$content .= $this->getTemplatesAdminPages($moduleDirname, $table->getVar('table_name'), $table->getVar('table_solename'), $table->getVar('table_autoincrement'), $fields, $language); |
|
|
|
|
|
|
278
|
|
|
$content .= $this->getTemplatesAdminPagesFooter($moduleDirname); |
|
279
|
|
|
|
|
280
|
|
|
$this->create($moduleDirname, 'templates/admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
281
|
|
|
|
|
282
|
|
|
return $this->renderFile(); |
|
283
|
|
|
} |
|
284
|
|
|
} |
|
285
|
|
|
|