1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder\Files\Templates\User\Defstyle; |
4
|
|
|
|
5
|
|
|
use XoopsModules\Modulebuilder; |
6
|
|
|
use XoopsModules\Modulebuilder\Files; |
7
|
|
|
|
8
|
|
|
/* |
9
|
|
|
You may not change or alter any portion of this comment or credits |
10
|
|
|
of supporting developers from this source code or any supporting source code |
11
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
12
|
|
|
|
13
|
|
|
This program is distributed in the hope that it will be useful, |
14
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16
|
|
|
*/ |
17
|
|
|
/** |
18
|
|
|
* modulebuilder module. |
19
|
|
|
* |
20
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
21
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
22
|
|
|
* |
23
|
|
|
* @since 2.5.0 |
24
|
|
|
* |
25
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
26
|
|
|
* |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* class PagesList. |
31
|
|
|
*/ |
32
|
|
|
class PagesList extends Files\CreateFile |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @public function constructor |
36
|
|
|
* @param null |
37
|
|
|
*/ |
38
|
|
|
public function __construct() |
39
|
|
|
{ |
40
|
|
|
parent::__construct(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @static function getInstance |
45
|
|
|
* @param null |
46
|
|
|
* @return PagesList |
47
|
|
|
*/ |
48
|
|
|
public static function getInstance() |
49
|
|
|
{ |
50
|
|
|
static $instance = false; |
51
|
|
|
if (!$instance) { |
52
|
|
|
$instance = new self(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $instance; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @public function write |
60
|
|
|
* @param string $module |
61
|
|
|
* @param string $table |
62
|
|
|
* @param string $filename |
63
|
|
|
* @param $tables |
64
|
|
|
*/ |
65
|
|
|
public function write($module, $table, $tables, $filename) |
66
|
|
|
{ |
67
|
|
|
$this->setModule($module); |
68
|
|
|
$this->setTable($table); |
69
|
|
|
$this->setTables($tables); |
70
|
|
|
$this->setFileName($filename); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @private function getTemplatesUserPagesListPanel |
75
|
|
|
* @param string $moduleDirname |
76
|
|
|
* @param $tableId |
77
|
|
|
* @param $tableMid |
78
|
|
|
* @param $tableName |
79
|
|
|
* @param $tableSoleName |
80
|
|
|
* @param $language |
81
|
|
|
* @return string |
82
|
|
|
*/ |
83
|
|
|
private function getTemplatesUserPagesListPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language) |
84
|
|
|
{ |
85
|
|
|
$hc = Modulebuilder\Files\CreateHtmlCode::getInstance(); |
86
|
|
|
$sc = Modulebuilder\Files\CreateSmartyCode::getInstance(); |
87
|
|
|
$fields = $this->getTableFields($tableMid, $tableId); |
88
|
|
|
$ret = ''; |
89
|
|
|
$retNumb = ''; |
90
|
|
|
foreach (array_keys($fields) as $f) { |
91
|
|
|
$fieldElement = $fields[$f]->getVar('field_element'); |
92
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
93
|
|
|
if (1 == $fields[$f]->getVar('field_ihead')) { |
94
|
|
|
switch ($fieldElement) { |
95
|
|
|
default: |
96
|
|
|
//case 2: |
97
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
98
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
99
|
|
|
$doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
100
|
|
|
$retNumb .= $hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); |
101
|
|
|
break; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
$ret .= $hc->getHtmlDiv($retNumb, 'panel-heading'); |
107
|
|
|
$retElem = ''; |
108
|
|
|
$fieldId = ''; |
109
|
|
|
$keyDouble = ''; |
110
|
|
|
foreach (array_keys($fields) as $f) { |
111
|
|
|
if (0 == $f) { |
112
|
|
|
$fieldId = $fields[$f]->getVar('field_name'); |
113
|
|
|
$keyDouble = $sc->getSmartyDoubleVar($tableSoleName, $fieldId); |
114
|
|
|
} |
115
|
|
|
$fieldElement = $fields[$f]->getVar('field_element'); |
116
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
117
|
|
|
if (1 == $fields[$f]->getVar('field_ibody')) { |
118
|
|
|
switch ($fieldElement) { |
119
|
|
|
default: |
120
|
|
|
//case 3: |
121
|
|
|
//case 4: |
122
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
123
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
124
|
|
|
$doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
125
|
|
|
$retElem .= $hc->getHtmlSpan($doubleVar, 'col-sm-9 justify', "\t"); |
126
|
|
|
break; |
127
|
|
|
case 10: |
128
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
129
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
130
|
|
|
$singleVar = $sc->getSmartySingleVar('xoops_icons32_url'); |
131
|
|
|
$doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
132
|
|
|
$img = $hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); |
133
|
|
|
$retElem .= $hc->getHtmlSpan($img, 'col-sm-3', "\t"); |
134
|
|
|
unset($img); |
135
|
|
|
break; |
136
|
|
|
case 13: |
137
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
138
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
139
|
|
|
$singleVar = $sc->getSmartySingleVar($moduleDirname . '_upload_url'); |
140
|
|
|
$doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
141
|
|
|
$img = $hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); |
142
|
|
|
$retElem .= $hc->getHtmlSpan($img, 'col-sm-3',"\t"); |
143
|
|
|
unset($img); |
144
|
|
|
break; |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
|
151
|
|
|
$ret .= $hc->getHtmlDiv($retElem, 'panel-body'); |
152
|
|
|
$retFoot = ''; |
153
|
|
|
foreach (array_keys($fields) as $f) { |
154
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
155
|
|
|
if (1 == $fields[$f]->getVar('field_ifoot')) { |
156
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
157
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
158
|
|
|
$langConst = mb_strtoupper($tableSoleName) . '_' . mb_strtoupper($rpFieldName); |
159
|
|
|
$lang = $sc->getSmartyConst($language, $langConst); |
160
|
|
|
$doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
161
|
|
|
$retFoot .= $hc->getHtmlSpan($lang . ': ' . $doubleVar, 'block-pie justify',"\t"); |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
$lang = $sc->getSmartyConst($language, 'DETAILS'); |
166
|
|
|
$anchor = $hc->getHtmlAnchor($tableName . ".php?op=show&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-primary', '', '', ''); |
167
|
|
|
$retFoot .= $hc->getHtmlSpan($anchor, 'col-sm-12',"\t"); |
168
|
|
|
$ret .= $hc->getHtmlDiv($retFoot, 'panel-foot'); |
169
|
|
|
|
170
|
|
|
return $ret; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @private function getTemplatesUserPagesListPanel |
175
|
|
|
* @param string $moduleDirname |
176
|
|
|
* @param $tableId |
177
|
|
|
* @param $tableMid |
178
|
|
|
* @param $tableName |
179
|
|
|
* @param $tableSoleName |
180
|
|
|
* @param $language |
181
|
|
|
* @return string |
182
|
|
|
*/ |
183
|
|
|
private function getElement($moduleDirname, $tableName, $tableSoleName, $fieldElement, $fieldName, $rpFieldName) |
|
|
|
|
184
|
|
|
{ |
185
|
|
|
$hc = Modulebuilder\Files\CreateHtmlCode::getInstance(); |
186
|
|
|
$sc = Modulebuilder\Files\CreateSmartyCode::getInstance(); |
187
|
|
|
|
188
|
|
|
switch ($fieldElement) { |
189
|
|
|
default: |
190
|
|
|
$ret = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
|
|
|
191
|
|
|
case 10: |
192
|
|
|
$singleVar = $sc->getSmartySingleVar('xoops_icons32_url'); |
193
|
|
|
$doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
194
|
|
|
$ret = $hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); |
195
|
|
|
break; |
196
|
|
|
case 13: |
197
|
|
|
$singleVar = $sc->getSmartySingleVar($moduleDirname . '_upload_url'); |
198
|
|
|
$doubleVar = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
199
|
|
|
$ret = $hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); |
200
|
|
|
break; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
return $ret; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @public function render |
208
|
|
|
* @param null |
209
|
|
|
* @return bool|string |
210
|
|
|
*/ |
211
|
|
|
public function render() |
212
|
|
|
{ |
213
|
|
|
$module = $this->getModule(); |
214
|
|
|
$table = $this->getTable(); |
215
|
|
|
//$tables = $this->getTables(); |
216
|
|
|
//$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
217
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
218
|
|
|
$filename = $this->getFileName(); |
219
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA'); |
220
|
|
|
$content = ''; |
221
|
|
|
$tableId = $table->getVar('table_id'); |
222
|
|
|
$tableMid = $table->getVar('table_mid'); |
223
|
|
|
$tableName = $table->getVar('table_name'); |
224
|
|
|
$tableSoleName = $table->getVar('table_solename'); |
225
|
|
|
$tableCategory[] = $table->getVar('table_category'); |
|
|
|
|
226
|
|
|
//$tableIndex = $table->getVar('table_index'); |
227
|
|
|
if (in_array(0, $tableCategory)) { |
228
|
|
|
$content .= $this->getTemplatesUserPagesListPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
$this->create($moduleDirname, 'templates', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED); |
232
|
|
|
|
233
|
|
|
return $this->renderFile(); |
234
|
|
|
} |
235
|
|
|
} |
236
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.