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