|
1
|
|
|
<?php namespace XoopsModules\Tdmcreate\Files\User; |
|
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: user_index.php 12258 2014-01-02 09:33:29Z timgno $ |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class UserIndex. |
|
30
|
|
|
*/ |
|
31
|
|
|
class UserIndex 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 UserIndex |
|
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 $table |
|
61
|
|
|
* @param string $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 getTemplateHeaderFile |
|
72
|
|
|
* @param $moduleDirname |
|
73
|
|
|
* |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
|
|
private function getTemplateHeaderFile($moduleDirname) |
|
77
|
|
|
{ |
|
78
|
|
|
$pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
|
79
|
|
|
$xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
|
80
|
|
|
$uc = UserXoopsCode::getInstance(); |
|
81
|
|
|
$cc = Tdmcreate\Files\Classes\ClassXoopsCode::getInstance(); |
|
|
|
|
|
|
82
|
|
|
$ret = $this->getInclude(); |
|
83
|
|
|
$ret .= $uc->getUserTplMain($moduleDirname); |
|
84
|
|
|
$ret .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'header', true); |
|
85
|
|
|
$ret .= $pc->getPhpCodeCommentLine('Define Stylesheet'); |
|
86
|
|
|
$ret .= $xc->getXcAddStylesheet(); |
|
87
|
|
|
$ret .= $pc->getPhpCodeArray('keywords', null, false, ''); |
|
88
|
|
|
|
|
89
|
|
|
return $ret; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @private function getBodyCategoriesIndex |
|
94
|
|
|
* @param $moduleDirname |
|
95
|
|
|
* @param $tableMid |
|
96
|
|
|
* @param $tableId |
|
97
|
|
|
* @param $tableName |
|
98
|
|
|
* @param $tableSoleName |
|
99
|
|
|
* @param $tableFieldname |
|
100
|
|
|
* @return string |
|
101
|
|
|
*/ |
|
102
|
|
|
private function getBodyCategoriesIndex($moduleDirname, $tableMid, $tableId, $tableName, $tableSoleName, $tableFieldname) |
|
103
|
|
|
{ |
|
104
|
|
|
$ucfTableName = ucfirst($tableName); |
|
|
|
|
|
|
105
|
|
|
// Fields |
|
106
|
|
|
$fields = $this->getTableFields($tableMid, $tableId); |
|
107
|
|
|
$fieldParentId = []; |
|
108
|
|
|
foreach (array_keys($fields) as $f) { |
|
109
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
110
|
|
|
if (0 == $f) { |
|
111
|
|
|
$fieldId = $fieldName; // fieldMain = fields parameters main field |
|
|
|
|
|
|
112
|
|
|
} |
|
113
|
|
|
$fieldParentId[] = $fields[$f]->getVar('field_parent'); |
|
114
|
|
|
if (1 == $fields[$f]->getVar('field_main')) { |
|
115
|
|
|
$fieldMain = $fieldName; // fieldMain = fields parameters main field |
|
|
|
|
|
|
116
|
|
|
} |
|
117
|
|
|
if (1 == $fields[$f]->getVar('field_parent')) { |
|
118
|
|
|
$fieldParent = $fieldName; // fieldMain = fields parameters main field |
|
|
|
|
|
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
$ret = ''; |
|
122
|
|
|
$pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
|
123
|
|
|
$xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
|
124
|
|
|
$cc = Tdmcreate\Files\Classes\ClassXoopsCode::getInstance(); |
|
|
|
|
|
|
125
|
|
|
if (in_array(1, $fieldParentId)) { |
|
126
|
|
|
$ret .= $xc->getXcObjHandlerCount($tableName); |
|
127
|
|
|
$ret .= $pc->getPhpCodeCommentLine('If there are ', $tableName); |
|
128
|
|
|
$ret .= $this->getSimpleString('$count = 1;'); |
|
129
|
|
|
|
|
130
|
|
|
$contentIf = $xc->getXcObjHandlerAll($tableName, '', 0, 0, "\t"); |
|
131
|
|
|
$contentIf .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/tree', true, false, 'include', "\t"); |
|
132
|
|
|
//$contentIf .= $cc->getClassXoopsObjectTree('mytree', $tableName, $fieldId, $fieldParent, "\t"); |
|
133
|
|
|
$contentIf .= $pc->getPhpCodeArray($tableName, "\t"); |
|
134
|
|
|
$foreach = $xc->getXcGetValues($tableName, $tableSoleName . 'Values', $tableFieldname, false, "\t"); |
|
135
|
|
|
$foreach .= $pc->getPhpCodeArray('acount', ["'count'", '$count']); |
|
136
|
|
|
$foreach .= $pc->getPhpCodeArrayType($tableName, 'merge', $tableSoleName . 'Values', '$acount'); |
|
137
|
|
|
$foreach .= $this->getSimpleString('++$count;', "\t\t"); |
|
138
|
|
|
$contentIf .= $pc->getPhpCodeForeach("{$tableName}All", true, false, $tableFieldname, $foreach, "\t"); |
|
139
|
|
|
$contentIf .= $xc->getXcTplAssign($tableName, '$' . $tableName, true, "\t"); |
|
140
|
|
|
$contentIf .= $pc->getPhpCodeUnset($tableName, "\t"); |
|
141
|
|
|
$getConfig = $xc->getXcGetConfig($moduleDirname, 'numb_col'); |
|
142
|
|
|
$contentIf .= $xc->getXcTplAssign('numb_col', $getConfig, true, "\t"); |
|
143
|
|
|
$ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contentIf, false); |
|
144
|
|
|
$ret .= $pc->getPhpCodeUnset('count'); |
|
145
|
|
|
} |
|
146
|
|
|
unset($fieldParentId); |
|
147
|
|
|
|
|
148
|
|
|
return $ret; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* @private function getBodyPagesIndex |
|
153
|
|
|
* @param $moduleDirname |
|
154
|
|
|
* @param $tableName |
|
155
|
|
|
* @param $tableSoleName |
|
156
|
|
|
* @param $tableFieldname |
|
157
|
|
|
* @param $language |
|
158
|
|
|
* @return string |
|
159
|
|
|
*/ |
|
160
|
|
|
private function getBodyPagesIndex($moduleDirname, $tableName, $tableSoleName, $tableFieldname, $language) |
|
|
|
|
|
|
161
|
|
|
{ |
|
162
|
|
|
$pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
|
163
|
|
|
$xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
|
164
|
|
|
$stuModuleDirname = mb_strtoupper($moduleDirname); |
|
|
|
|
|
|
165
|
|
|
$ucfTableName = ucfirst($tableName); |
|
|
|
|
|
|
166
|
|
|
$stuModuleDirname = mb_strtoupper($moduleDirname); |
|
167
|
|
|
$ucfTableName = ucfirst($tableName); |
|
168
|
|
|
$ret = $pc->getPhpCodeCommentLine(); |
|
169
|
|
|
$ret .= $xc->getXcTplAssign('xoops_icons32_url', 'XOOPS_ICONS32_URL'); |
|
170
|
|
|
$ret .= $xc->getXcTplAssign("{$moduleDirname}_url", "{$stuModuleDirname}_URL"); |
|
171
|
|
|
$ret .= $pc->getPhpCodeCommentLine(); |
|
172
|
|
|
$ret .= $xc->getXcObjHandlerCount($tableName); |
|
173
|
|
|
$ret .= $this->getSimpleString('$count = 1;'); |
|
174
|
|
|
$condIf = $xc->getXcXoopsRequest('start', 'start', '0', 'Int', false, "\t"); |
|
175
|
|
|
$userpager = $xc->getXcGetConfig($moduleDirname, 'userpager'); |
|
176
|
|
|
$condIf .= $xc->getXcXoopsRequest('limit', 'limit', $userpager, 'Int', false, "\t"); |
|
177
|
|
|
$condIf .= $xc->getXcObjHandlerAll($tableName, '', '$start', '$limit', "\t"); |
|
178
|
|
|
$condIf .= $pc->getPhpCodeCommentLine('Get All', $ucfTableName, "\t"); |
|
179
|
|
|
$condIf .= $pc->getPhpCodeArray($tableName, null, false, "\t"); |
|
180
|
|
|
$foreach = $xc->getXcGetValues($tableName, $tableSoleName, 'i', false, "\t"); |
|
181
|
|
|
$foreach .= $pc->getPhpCodeArray('acount', ["'count'", '$count']); |
|
182
|
|
|
$foreach .= $pc->getPhpCodeArrayType($tableName, 'merge', $tableSoleName, '$acount'); |
|
183
|
|
|
$table = $this->getTable(); |
|
184
|
|
|
// Fields |
|
185
|
|
|
$fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
|
186
|
|
|
foreach (array_keys($fields) as $f) { |
|
187
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
188
|
|
|
if (1 == $fields[$f]->getVar('field_main')) { |
|
189
|
|
|
$fieldMain = $fieldName; // fieldMain = fields parameters main field |
|
190
|
|
|
} |
|
191
|
|
|
} |
|
192
|
|
|
$foreach .= $xc->getXcGetVar('keywords[]', "{$tableName}All[\$i]", $fieldMain, false, "\t\t"); |
|
|
|
|
|
|
193
|
|
|
$foreach .= $this->getSimpleString('++$count;', "\t\t"); |
|
194
|
|
|
$condIf .= $pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, "\t"); |
|
195
|
|
|
$condIf .= $xc->getXcTplAssign($tableName, '$' . $tableName, true, "\t"); |
|
196
|
|
|
$condIf .= $pc->getPhpCodeUnset($tableName, "\t"); |
|
197
|
|
|
$condIf .= $xc->getXcPageNav($tableName, "\t"); |
|
198
|
|
|
$thereare = $pc->getPhpCodeSprintf("{$language}INDEX_THEREARE", "\${$tableName}Count"); |
|
199
|
|
|
$condIf .= $xc->getXcTplAssign('lang_thereare', $thereare, true, "\t"); |
|
200
|
|
|
$divideby = $xc->getXcGetConfig($moduleDirname, 'divideby'); |
|
201
|
|
|
$condIf .= $xc->getXcTplAssign('divideby', $divideby, true, "\t"); |
|
202
|
|
|
|
|
203
|
|
|
$ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $condIf); |
|
204
|
|
|
$ret .= $pc->getPhpCodeUnset('count'); |
|
205
|
|
|
$tableType = $xc->getXcGetConfig($moduleDirname, 'table_type'); |
|
206
|
|
|
$ret .= $xc->getXcTplAssign('table_type', $tableType); |
|
207
|
|
|
|
|
208
|
|
|
return $ret; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* @private function getUserPagesFooter |
|
213
|
|
|
* @param $moduleDirname |
|
214
|
|
|
* @param $language |
|
215
|
|
|
* @return string |
|
216
|
|
|
*/ |
|
217
|
|
|
private function getUserIndexFooter($moduleDirname, $language) |
|
218
|
|
|
{ |
|
219
|
|
|
$pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
|
220
|
|
|
$xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
|
221
|
|
|
$uc = UserXoopsCode::getInstance(); |
|
222
|
|
|
$stuModuleDirname = mb_strtoupper($moduleDirname); |
|
223
|
|
|
$ret = $pc->getPhpCodeCommentLine('Breadcrumbs'); |
|
224
|
|
|
$ret .= $uc->getUserBreadcrumbs($language); |
|
225
|
|
|
$ret .= $pc->getPhpCodeCommentLine('Keywords'); |
|
226
|
|
|
$ret .= $uc->getUserMetaKeywords($moduleDirname); |
|
227
|
|
|
$ret .= $pc->getPhpCodeUnset('keywords'); |
|
228
|
|
|
$ret .= $pc->getPhpCodeCommentLine('Description'); |
|
229
|
|
|
$ret .= $uc->getUserMetaDesc($moduleDirname, $language); |
|
230
|
|
|
$ret .= $xc->getXcTplAssign('xoops_mpageurl', "{$stuModuleDirname}_URL.'/index.php'"); |
|
231
|
|
|
$ret .= $xc->getXcTplAssign('xoops_icons32_url', 'XOOPS_ICONS32_URL'); |
|
232
|
|
|
$ret .= $xc->getXcTplAssign("{$moduleDirname}_upload_url", "{$stuModuleDirname}_UPLOAD_URL"); |
|
233
|
|
|
$ret .= $this->getInclude('footer'); |
|
234
|
|
|
|
|
235
|
|
|
return $ret; |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
/** |
|
239
|
|
|
* @public function render |
|
240
|
|
|
* @param null |
|
241
|
|
|
* @return bool|string |
|
242
|
|
|
*/ |
|
243
|
|
|
public function render() |
|
244
|
|
|
{ |
|
245
|
|
|
$module = $this->getModule(); |
|
246
|
|
|
$table = $this->getTable(); |
|
|
|
|
|
|
247
|
|
|
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
|
248
|
|
|
$filename = $this->getFileName(); |
|
249
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
250
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA'); |
|
251
|
|
|
$content = $this->getHeaderFilesComments($module, $filename); |
|
252
|
|
|
$content .= $this->getTemplateHeaderFile($moduleDirname); |
|
253
|
|
|
foreach (array_keys($tables) as $t) { |
|
254
|
|
|
$tableId = $tables[$t]->getVar('table_id'); |
|
255
|
|
|
$tableMid = $tables[$t]->getVar('table_mid'); |
|
256
|
|
|
$tableName = $tables[$t]->getVar('table_name'); |
|
257
|
|
|
$tableSoleName = $tables[$t]->getVar('table_solename'); |
|
258
|
|
|
$tableCategory[] = $tables[$t]->getVar('table_category'); |
|
259
|
|
|
$tableFieldname = $tables[$t]->getVar('table_fieldname'); |
|
260
|
|
|
$tableIndex[] = $tables[$t]->getVar('table_index'); |
|
261
|
|
|
if (in_array(1, $tableCategory, true) && in_array(1, $tableIndex)) { |
|
|
|
|
|
|
262
|
|
|
$content .= $this->getBodyCategoriesIndex($moduleDirname, $tableMid, $tableId, $tableName, $tableSoleName, $tableFieldname); |
|
263
|
|
|
} |
|
264
|
|
|
if (in_array(0, $tableCategory, true) && in_array(1, $tableIndex)) { |
|
265
|
|
|
$content .= $this->getBodyPagesIndex($moduleDirname, $tableName, $tableSoleName, $tableFieldname, $language); |
|
266
|
|
|
} |
|
267
|
|
|
} |
|
268
|
|
|
$content .= $this->getUserIndexFooter($moduleDirname, $language); |
|
269
|
|
|
|
|
270
|
|
|
$this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
271
|
|
|
|
|
272
|
|
|
return $this->renderFile(); |
|
273
|
|
|
} |
|
274
|
|
|
} |
|
275
|
|
|
|