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 PagesItem. |
31
|
|
|
*/ |
32
|
|
|
class PagesItem extends Files\CreateFile |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @var mixed |
36
|
|
|
*/ |
37
|
|
|
private $hc = null; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var mixed |
41
|
|
|
*/ |
42
|
|
|
private $sc = null; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @public function constructor |
46
|
|
|
* @param null |
47
|
|
|
*/ |
48
|
|
|
public function __construct() |
49
|
|
|
{ |
50
|
|
|
parent::__construct(); |
51
|
|
|
$this->hc = Modulebuilder\Files\CreateHtmlCode::getInstance(); |
52
|
|
|
$this->sc = Modulebuilder\Files\CreateSmartyCode::getInstance(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @static function getInstance |
57
|
|
|
* @param null |
58
|
|
|
* @return PagesItem |
59
|
|
|
*/ |
60
|
|
|
public static function getInstance() |
61
|
|
|
{ |
62
|
|
|
static $instance = false; |
63
|
|
|
if (!$instance) { |
64
|
|
|
$instance = new self(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return $instance; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @public function write |
72
|
|
|
* @param $module |
73
|
|
|
* @param $table |
74
|
|
|
* @param string $filename |
75
|
|
|
* @param $tables |
76
|
|
|
*/ |
77
|
|
|
public function write($module, $table, $tables, $filename) |
78
|
|
|
{ |
79
|
|
|
$this->setModule($module); |
80
|
|
|
$this->setTable($table); |
81
|
|
|
$this->setTables($tables); |
82
|
|
|
$this->setFileName($filename); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @private function getTemplatesUserPagesItemPanel |
87
|
|
|
* @param string $moduleDirname |
88
|
|
|
* @param $tableId |
89
|
|
|
* @param $tableMid |
90
|
|
|
* @param $tableName |
91
|
|
|
* @param $tableSoleName |
92
|
|
|
* @param $language |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableRate, $language) |
96
|
|
|
{ |
97
|
|
|
$fields = $this->getTableFields($tableMid, $tableId); |
98
|
|
|
$ret = ''; |
99
|
|
|
$retNumb = ''; |
100
|
|
|
$fieldId = ''; |
101
|
|
|
$ccFieldId = ''; |
102
|
|
|
$keyDouble = ''; |
103
|
|
|
foreach (array_keys($fields) as $f) { |
104
|
|
|
if (0 == $f) { |
105
|
|
|
$fieldId = $fields[$f]->getVar('field_name'); |
106
|
|
|
$ccFieldId = $this->getCamelCase($fieldId, false, true); |
107
|
|
|
$keyDouble = $this->sc->getSmartyDoubleVar($tableSoleName, $fieldId); |
108
|
|
|
} |
109
|
|
|
$fieldElement = $fields[$f]->getVar('field_element'); |
110
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
111
|
|
|
if (1 == $fields[$f]->getVar('field_thead')) { |
112
|
|
|
switch ($fieldElement) { |
113
|
|
|
default: |
114
|
|
|
//case 2: |
115
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
116
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
117
|
|
|
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
118
|
|
|
$retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); |
119
|
|
|
break; |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
$ret .= $this->hc->getHtmlI('', '', $ccFieldId . '_' . $keyDouble); |
125
|
|
|
$ret .= $this->hc->getHtmlDiv($retNumb, 'panel-heading'); |
126
|
|
|
$retElem = ''; |
127
|
|
|
foreach (array_keys($fields) as $f) { |
128
|
|
|
$fieldElement = $fields[$f]->getVar('field_element'); |
129
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
130
|
|
|
if (1 == $fields[$f]->getVar('field_tbody')) { |
131
|
|
|
switch ($fieldElement) { |
132
|
|
|
default: |
133
|
|
|
//case 3: |
134
|
|
|
//case 4: |
135
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
136
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
137
|
|
|
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
138
|
|
|
$retElem .= $this->hc->getHtmlSpan($doubleVar, 'col-sm-9 justify', "\t"); |
139
|
|
|
break; |
140
|
|
|
case 10: |
141
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
142
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
143
|
|
|
$singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url'); |
144
|
|
|
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
145
|
|
|
$img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); |
146
|
|
|
$retElem .= $this->hc->getHtmlSpan($img, 'col-sm-3', "\t"); |
147
|
|
|
unset($img); |
148
|
|
|
break; |
149
|
|
|
case 13: |
150
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
151
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
152
|
|
|
$singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); |
153
|
|
|
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
154
|
|
|
$img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); |
155
|
|
|
$retElem .= $this->hc->getHtmlSpan($img, 'col-sm-3',"\t"); |
156
|
|
|
unset($img); |
157
|
|
|
break; |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
$ret .= $this->hc->getHtmlDiv($retElem, 'panel-body'); |
163
|
|
|
|
164
|
|
|
$retFoot = ''; |
165
|
|
|
foreach (array_keys($fields) as $f) { |
166
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
167
|
|
|
if (1 == $fields[$f]->getVar('field_tfoot')) { |
168
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
169
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
170
|
|
|
$langConst = mb_strtoupper($tableSoleName) . '_' . mb_strtoupper($rpFieldName); |
171
|
|
|
$lang = $this->sc->getSmartyConst($language, $langConst); |
172
|
|
|
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
173
|
|
|
$retFoot .= $this->hc->getHtmlSpan($lang . ': ' . $doubleVar, 'block-pie justify',"\t"); |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
$anchors = ''; |
179
|
|
|
$lang = $this->sc->getSmartyConst($language, mb_strtoupper($tableName) . '_LIST'); |
180
|
|
|
$contIf = $this->hc->getHtmlAnchor($tableName . ".php?op=list&#{$ccFieldId}_" . $keyDouble, $lang, $lang, '', 'btn btn-success right', '', "\t\t\t", "\n"); |
181
|
|
|
$lang = $this->sc->getSmartyConst($language, 'DETAILS'); |
182
|
|
|
$contElse = $this->hc->getHtmlAnchor($tableName . ".php?op=show&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-success right', '', "\t\t\t", "\n"); |
183
|
|
|
$anchors .= $this->sc->getSmartyConditions('showItem', '', '', $contIf, $contElse, '', '', "\t\t"); |
184
|
|
|
$lang = $this->sc->getSmartyConst('', '_EDIT'); |
185
|
|
|
$contIf = $this->hc->getHtmlAnchor($tableName . ".php?op=edit&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-primary right', '', "\t\t\t", "\n"); |
186
|
|
|
$lang = $this->sc->getSmartyConst('', '_DELETE'); |
187
|
|
|
$contIf .= $this->hc->getHtmlAnchor($tableName . ".php?op=delete&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-danger right', '', "\t\t\t", "\n"); |
188
|
|
|
$anchors .= $this->sc->getSmartyConditions('permEdit', '', '', $contIf, false, '', '', "\t\t"); |
189
|
|
|
$lang = $this->sc->getSmartyConst($language, 'BROKEN'); |
190
|
|
|
$anchors .= $this->hc->getHtmlAnchor($tableName . ".php?op=broken&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-warning right', '', "\t\t", "\n"); |
191
|
|
|
$retFoot .= $this->hc->getHtmlDiv($anchors, 'col-sm-12 right',"\t", "\n"); |
192
|
|
|
$ret .= $this->hc->getHtmlDiv($retFoot, 'panel-foot'); |
193
|
|
|
if ($tableRate) { |
194
|
|
|
$rate = $this->sc->getSmartyIncludeFile($moduleDirname, 'rate', false, false, "\t", "\n", 'item=$' . $tableSoleName); |
195
|
|
|
$ret .= $this->sc->getSmartyConditions('rating', '', '', $rate, false); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
return $ret; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @public function render |
203
|
|
|
* @param null |
204
|
|
|
* @return bool|string |
205
|
|
|
*/ |
206
|
|
|
public function render() |
207
|
|
|
{ |
208
|
|
|
$module = $this->getModule(); |
209
|
|
|
$table = $this->getTable(); |
210
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
211
|
|
|
$filename = $this->getFileName(); |
212
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA'); |
213
|
|
|
$content = ''; |
214
|
|
|
$tableId = $table->getVar('table_id'); |
215
|
|
|
$tableMid = $table->getVar('table_mid'); |
216
|
|
|
$tableName = $table->getVar('table_name'); |
217
|
|
|
$tableSoleName = $table->getVar('table_solename'); |
218
|
|
|
$tableRate = $table->getVar('table_rate'); |
219
|
|
|
$tableCategory[] = $table->getVar('table_category'); |
|
|
|
|
220
|
|
|
if (in_array(0, $tableCategory)) { |
221
|
|
|
$content .= $this->getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableRate, $language); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
$this->create($moduleDirname, 'templates', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED); |
225
|
|
|
|
226
|
|
|
return $this->renderFile(); |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
|