|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
You may not change or alter any portion of this comment or credits |
|
5
|
|
|
of supporting developers from this source code or any supporting source code |
|
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
|
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
/** |
|
13
|
|
|
* tdmcreate module. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
|
16
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
17
|
|
|
* |
|
18
|
|
|
* @since 2.5.0 |
|
19
|
|
|
* |
|
20
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
21
|
|
|
* |
|
22
|
|
|
* @version $Id: UserXoopsVersion.php 12258 2014-01-02 09:33:29Z timgno $ |
|
23
|
|
|
*/ |
|
24
|
|
|
defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Class UserXoopsVersion. |
|
28
|
|
|
*/ |
|
29
|
|
|
class UserXoopsVersion extends TDMCreateFile |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
/* |
|
32
|
|
|
* @var mixed |
|
33
|
|
|
*/ |
|
34
|
|
|
private $phpcode = null; |
|
35
|
|
|
|
|
36
|
|
|
/* |
|
37
|
|
|
* @var mixed |
|
38
|
|
|
*/ |
|
39
|
|
|
private $xoopscode = null; |
|
40
|
|
|
|
|
41
|
|
|
/* |
|
42
|
|
|
* @var mixed |
|
43
|
|
|
*/ |
|
44
|
|
|
private $usercode = null; |
|
45
|
|
|
|
|
46
|
|
|
/* |
|
47
|
|
|
* @var array |
|
48
|
|
|
*/ |
|
49
|
|
|
private $keywords = array(); |
|
50
|
|
|
|
|
51
|
|
|
/* |
|
52
|
|
|
* @public function constructor |
|
53
|
|
|
* @param null |
|
54
|
|
|
*/ |
|
55
|
|
|
/** |
|
56
|
|
|
* |
|
57
|
|
|
*/ |
|
58
|
|
|
public function __construct() |
|
59
|
|
|
{ |
|
60
|
|
|
parent::__construct(); |
|
61
|
|
|
$this->phpcode = TDMCreatePhpCode::getInstance(); |
|
62
|
|
|
$this->xoopscode = TDMCreateXoopsCode::getInstance(); |
|
63
|
|
|
$this->usercode = UserXoopsCode::getInstance(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/* |
|
67
|
|
|
* @static function &getInstance |
|
68
|
|
|
* @param null |
|
69
|
|
|
*/ |
|
70
|
|
|
/** |
|
71
|
|
|
* @return UserXoopsVersion |
|
72
|
|
|
*/ |
|
73
|
|
|
public static function &getInstance() |
|
74
|
|
|
{ |
|
75
|
|
|
static $instance = false; |
|
76
|
|
|
if (!$instance) { |
|
77
|
|
|
$instance = new self(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return $instance; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/* |
|
84
|
|
|
* @public function write |
|
85
|
|
|
* @param $module |
|
86
|
|
|
* @param mixed $table |
|
87
|
|
|
* @param mixed $tables |
|
88
|
|
|
* @param $filename |
|
89
|
|
|
*/ |
|
90
|
|
|
/** |
|
91
|
|
|
* @param $module |
|
92
|
|
|
* @param $table |
|
93
|
|
|
* @param $tables |
|
94
|
|
|
* @param $filename |
|
95
|
|
|
*/ |
|
96
|
|
|
public function write($module, $table, $tables, $filename) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->setModule($module); |
|
99
|
|
|
$this->setTable($table); |
|
100
|
|
|
$this->setTables($tables); |
|
101
|
|
|
$this->setFileName($filename); |
|
102
|
|
|
foreach (array_keys($tables) as $t) { |
|
103
|
|
|
$tableName = $tables[$t]->getVar('table_name'); |
|
104
|
|
|
$this->setKeywords($tableName); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/* |
|
109
|
|
|
* @public function setKeywords |
|
110
|
|
|
* @param mixed $keywords |
|
111
|
|
|
*/ |
|
112
|
|
|
/** |
|
113
|
|
|
* @param $keywords |
|
114
|
|
|
*/ |
|
115
|
|
|
public function setKeywords($keywords) |
|
116
|
|
|
{ |
|
117
|
|
|
if (is_array($keywords)) { |
|
118
|
|
|
$this->keywords = $keywords; |
|
119
|
|
|
} else { |
|
120
|
|
|
$this->keywords[] = $keywords; |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/* |
|
125
|
|
|
* @public function getKeywords |
|
126
|
|
|
* @param null |
|
127
|
|
|
*/ |
|
128
|
|
|
/** |
|
129
|
|
|
* @return array |
|
130
|
|
|
*/ |
|
131
|
|
|
public function getKeywords() |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->keywords; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/* |
|
137
|
|
|
* @private function getXoopsVersionHeader |
|
138
|
|
|
* @param $module |
|
139
|
|
|
* @param $language |
|
140
|
|
|
* |
|
141
|
|
|
* @return string |
|
142
|
|
|
*/ |
|
143
|
|
|
private function getXoopsVersionHeader($module, $language) |
|
144
|
|
|
{ |
|
145
|
|
|
$date = date(_DBDATESTRING); |
|
146
|
|
|
$ret = $this->getSimpleString("defined('XOOPS_ROOT_PATH') || die('Restricted access');"); |
|
147
|
|
|
$ret .= $this->getCommentLine(); |
|
148
|
|
|
$ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$dirname ', 'basename(__DIR__)'); |
|
149
|
|
|
$ret .= $this->getHeaderComment('Informations'); |
|
150
|
|
|
$ha = (1 == $module->getVar('mod_admin')) ? 1 : 0; |
|
151
|
|
|
$hm = (1 == $module->getVar('mod_user')) ? 1 : 0; |
|
152
|
|
|
|
|
153
|
|
|
$descriptions = array('name' => "{$language}NAME", 'version' => "{$module->getVar('mod_version')}", 'description' => "{$language}DESC", |
|
154
|
|
|
'author' => "'{$module->getVar('mod_author')}'", 'author_mail' => "'{$module->getVar('mod_author_mail')}'", 'author_website_url' => "'{$module->getVar('mod_author_website_url')}'", |
|
155
|
|
|
'author_website_name' => "'{$module->getVar('mod_author_website_name')}'",'credits' => "'{$module->getVar('mod_credits')}'",'license' => "'{$module->getVar('mod_license')}'", |
|
156
|
|
|
'license_url' => "'www.gnu.org/licenses/gpl-2.0.html/'", 'help' => "'page=help'", 'release_info' => "'{$module->getVar('mod_release_info')}'", |
|
157
|
|
|
'release_file' => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_release_file')}'", 'release_date' => "'{$date}'", |
|
158
|
|
|
'manual' => "'{$module->getVar('mod_manual')}'", 'manual_file' => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_manual_file')}'", |
|
159
|
|
|
'min_php' => "'{$module->getVar('mod_min_php')}'", 'min_xoops' => "'{$module->getVar('mod_min_xoops')}'", 'min_admin' => "'{$module->getVar('mod_min_admin')}'", |
|
160
|
|
|
'min_db' => "array('mysql' => '{$module->getVar('mod_min_mysql')}', 'mysqli' => '{$module->getVar('mod_min_mysql')}')", 'image' => "'assets/images/{$module->getVar('mod_image')}'", |
|
161
|
|
|
'dirname' => 'basename(__DIR__)', 'dirmoduleadmin' => "'Frameworks/moduleclasses/moduleadmin'", 'sysicons16' => "'../../Frameworks/moduleclasses/icons/16'", |
|
162
|
|
|
'sysicons32' => "'../../Frameworks/moduleclasses/icons/32'", 'modicons16' => "'assets/icons/16'", 'modicons32' => "'assets/icons/32'", |
|
163
|
|
|
'demo_site_url' => "'{$module->getVar('mod_demo_site_url')}'", 'demo_site_name' => "'{$module->getVar('mod_demo_site_name')}'", 'support_url' => "'{$module->getVar('mod_support_url')}'", |
|
164
|
|
|
'support_name' => "'{$module->getVar('mod_support_name')}'", 'module_website_url' => "'{$module->getVar('mod_website_url')}'", 'module_website_name' => "'{$module->getVar('mod_website_name')}'", 'release' => "'{$module->getVar('mod_release')}'", 'module_status' => "'{$module->getVar('mod_status')}'", |
|
165
|
|
|
'system_menu' => '1', 'hasAdmin' => $ha, 'hasMain' => $hm, 'adminindex' => "'admin/index.php'", 'adminmenu' => "'admin/menu.php'", |
|
166
|
|
|
'onInstall' => "'include/install.php'", 'onUpdate' => "'include/update.php'", ); |
|
167
|
|
|
|
|
168
|
|
|
$ret .= $this->usercode->getUserModVersion(1, $descriptions); |
|
169
|
|
|
|
|
170
|
|
|
return $ret; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/* |
|
174
|
|
|
* @private function getXoopsVersionMySQL |
|
175
|
|
|
* @param $moduleDirname |
|
176
|
|
|
* @param $table |
|
177
|
|
|
*/ |
|
178
|
|
|
/** |
|
179
|
|
|
* @param $moduleDirname |
|
180
|
|
|
* @param $table |
|
181
|
|
|
* |
|
182
|
|
|
* @return string |
|
183
|
|
|
*/ |
|
184
|
|
|
private function getXoopsVersionMySQL($moduleDirname, $table, $tables) |
|
185
|
|
|
{ |
|
186
|
|
|
$tableName = $table->getVar('table_name'); |
|
187
|
|
|
$n = 1; |
|
188
|
|
|
$ret = ''; |
|
189
|
|
|
if (!empty($tableName)) { |
|
190
|
|
|
$ret .= $this->getHeaderComment('Mysql'); |
|
191
|
|
|
$ret .= $this->usercode->getUserModVersion(2, "'sql/mysql.sql'", 'sqlfile', "'mysql'"); |
|
192
|
|
|
$ret .= $this->getCommentLine('Tables'); |
|
193
|
|
|
|
|
194
|
|
|
foreach (array_keys($tables) as $t) { |
|
195
|
|
|
$ret .= $this->usercode->getUserModVersion(2, "'{$moduleDirname}_{$tables[$t]->getVar('table_name')}'", 'tables', $n); |
|
196
|
|
|
++$n; |
|
197
|
|
|
} |
|
198
|
|
|
unset($n); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
return $ret; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/* |
|
205
|
|
|
* @private function getXoopsVersionSearch |
|
206
|
|
|
* @param $moduleDirname |
|
207
|
|
|
*/ |
|
208
|
|
|
/** |
|
209
|
|
|
* @param $moduleDirname |
|
210
|
|
|
* |
|
211
|
|
|
* @return string |
|
212
|
|
|
*/ |
|
213
|
|
|
private function getXoopsVersionSearch($moduleDirname) |
|
214
|
|
|
{ |
|
215
|
|
|
$ret = $this->getHeaderComment('Search'); |
|
216
|
|
|
$ret .= $this->usercode->getUserModVersion(1, 1, 'hasSearch'); |
|
217
|
|
|
$ret .= $this->usercode->getUserModVersion(2, "'include/search.inc.php'", 'search', "'file'"); |
|
218
|
|
|
$ret .= $this->usercode->getUserModVersion(2, "'{$moduleDirname}_search'", 'search', "'func'"); |
|
219
|
|
|
|
|
220
|
|
|
return $ret; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/* |
|
224
|
|
|
* @private function getXoopsVersionComments |
|
225
|
|
|
* @param $moduleDirname |
|
226
|
|
|
*/ |
|
227
|
|
|
/** |
|
228
|
|
|
* @param $moduleDirname |
|
229
|
|
|
* |
|
230
|
|
|
* @return string |
|
231
|
|
|
*/ |
|
232
|
|
|
private function getXoopsVersionComments($moduleDirname) |
|
233
|
|
|
{ |
|
234
|
|
|
$ret = $this->getHeaderComment('Comments'); |
|
235
|
|
|
$ret .= $this->usercode->getUserModVersion(2, "'comments.php'", 'comments', "'pageName'"); |
|
236
|
|
|
$ret .= $this->usercode->getUserModVersion(2, "'com_id'", 'comments', "'itemName'"); |
|
237
|
|
|
$ret .= $this->getCommentLine('Comment callback functions'); |
|
238
|
|
|
$ret .= $this->usercode->getUserModVersion(2, "'include/comment_functions.php'", 'comments', "'callbackFile'"); |
|
239
|
|
|
$descriptions = array('approve' => "'{$moduleDirname}CommentsApprove'", 'update' => "'{$moduleDirname}CommentsUpdate'"); |
|
240
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $descriptions, 'comments', "'callback'"); |
|
241
|
|
|
|
|
242
|
|
|
return $ret; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
/* |
|
246
|
|
|
* @private function getXoopsVersionTemplatesAdmin |
|
247
|
|
|
* @param $moduleDirname |
|
248
|
|
|
*/ |
|
249
|
|
|
/** |
|
250
|
|
|
* @param $moduleDirname |
|
251
|
|
|
* @param $tables |
|
252
|
|
|
* |
|
253
|
|
|
* @return string |
|
254
|
|
|
*/ |
|
255
|
|
|
private function getXoopsVersionTemplatesAdmin($moduleDirname, $tables) |
|
256
|
|
|
{ |
|
257
|
|
|
$ret = $this->getHeaderComment('Templates'); |
|
258
|
|
|
$ret .= $this->getCommentLine('Admin'); |
|
259
|
|
|
|
|
260
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'about', false, true); |
|
261
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', false, true); |
|
262
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', false, true); |
|
263
|
|
|
$tablePermissions = array(); |
|
264
|
|
View Code Duplication |
foreach (array_keys($tables) as $t) { |
|
|
|
|
|
|
265
|
|
|
$tableName = $tables[$t]->getVar('table_name'); |
|
266
|
|
|
$tablePermissions[] = $tables[$t]->getVar('table_permissions'); |
|
267
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, false, true); |
|
268
|
|
|
} |
|
269
|
|
|
if (in_array(1, $tablePermissions)) { |
|
270
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'permissions', false, true); |
|
271
|
|
|
} |
|
272
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', false, true); |
|
273
|
|
|
|
|
274
|
|
|
return $ret; |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
/* |
|
278
|
|
|
* @private function getXoopsVersionTemplatesLine |
|
279
|
|
|
* @param $moduleDirname |
|
280
|
|
|
*/ |
|
281
|
|
|
/** |
|
282
|
|
|
* @param $moduleDirname |
|
283
|
|
|
* |
|
284
|
|
|
* @return string |
|
285
|
|
|
*/ |
|
286
|
|
|
private function getXoopsVersionTemplatesLine($moduleDirname, $type, $extra = false, $isAdmin = false) |
|
287
|
|
|
{ |
|
288
|
|
|
$ret = ''; |
|
289
|
|
|
$desc = "'description' => ''"; |
|
290
|
|
|
$arrayFile = "array('file' =>"; |
|
291
|
|
|
if ($isAdmin) { |
|
292
|
|
|
$ret .= $this->usercode->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_admin_{$type}.tpl', {$desc}, 'type' => 'admin')", 'templates', ''); |
|
293
|
|
|
} else { |
|
294
|
|
|
if ($extra === false) { |
|
295
|
|
|
$ret .= $this->usercode->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_{$type}.tpl', {$desc})", 'templates', ''); |
|
296
|
|
|
} else { |
|
297
|
|
|
$ret .= $this->usercode->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_{$type}_{$extra}.tpl', {$desc})", 'templates', ''); |
|
298
|
|
|
} |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
return $ret; |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
/* |
|
305
|
|
|
* @private function getXoopsVersionTemplatesUser |
|
306
|
|
|
* @param $moduleDirname |
|
307
|
|
|
*/ |
|
308
|
|
|
/** |
|
309
|
|
|
* @param $moduleDirname |
|
310
|
|
|
* |
|
311
|
|
|
* @return string |
|
312
|
|
|
*/ |
|
313
|
|
|
private function getXoopsVersionTemplatesUser($moduleDirname, $tables) |
|
314
|
|
|
{ |
|
315
|
|
|
$table = $this->getTable(); |
|
316
|
|
|
$ret = $this->getCommentLine('User'); |
|
317
|
|
|
|
|
318
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header'); |
|
319
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index'); |
|
320
|
|
|
foreach (array_keys($tables) as $t) { |
|
321
|
|
|
$tableName = $tables[$t]->getVar('table_name'); |
|
322
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName); |
|
323
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, 'list'); |
|
|
|
|
|
|
324
|
|
|
} |
|
325
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'breadcrumbs'); |
|
326
|
|
|
if (1 == $table->getVar('table_broken')) { |
|
327
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'broken'); |
|
328
|
|
|
} |
|
329
|
|
|
if (1 == $table->getVar('table_pdf')) { |
|
330
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'pdf'); |
|
331
|
|
|
} |
|
332
|
|
|
if (1 == $table->getVar('table_print')) { |
|
333
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'print'); |
|
334
|
|
|
} |
|
335
|
|
|
if (1 == $table->getVar('table_rate')) { |
|
336
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'rate'); |
|
337
|
|
|
} |
|
338
|
|
|
if (1 == $table->getVar('table_rss')) { |
|
339
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'rss'); |
|
340
|
|
|
} |
|
341
|
|
|
if (1 == $table->getVar('table_search')) { |
|
342
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'search'); |
|
343
|
|
|
} |
|
344
|
|
|
if (1 == $table->getVar('table_single')) { |
|
345
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'single'); |
|
346
|
|
|
} |
|
347
|
|
|
if (1 == $table->getVar('table_submit')) { |
|
348
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'submit'); |
|
349
|
|
|
} |
|
350
|
|
|
$ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer'); |
|
351
|
|
|
|
|
352
|
|
|
return $ret; |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
/* |
|
356
|
|
|
* @private function getXoopsVersionSubmenu |
|
357
|
|
|
* @param $language |
|
358
|
|
|
*/ |
|
359
|
|
|
/** |
|
360
|
|
|
* @param $language |
|
361
|
|
|
* |
|
362
|
|
|
* @return string |
|
363
|
|
|
*/ |
|
364
|
|
|
private function getXoopsVersionSubmenu($language, $tables) |
|
365
|
|
|
{ |
|
366
|
|
|
$ret = $this->getHeaderComment('Submenu'); |
|
367
|
|
|
$i = 1; |
|
368
|
|
|
$tableSubmit = array(); |
|
369
|
|
|
foreach (array_keys($tables) as $t) { |
|
370
|
|
|
$tableName = $tables[$t]->getVar('table_name'); |
|
371
|
|
|
$tableSubmit[] = $tables[$t]->getVar('table_submit'); |
|
372
|
|
|
if (1 == $tables[$t]->getVar('table_submenu')) { |
|
373
|
|
|
$ret .= $this->getCommentLine('Sub', $tableName); |
|
374
|
|
|
$tname = array('name' => "{$language}SMNAME{$i}", 'url' => "'{$tableName}.php'"); |
|
375
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $tname, 'sub', $i); |
|
376
|
|
|
} |
|
377
|
|
|
++$i; |
|
378
|
|
|
} |
|
379
|
|
|
if (in_array(1, $tableSubmit)) { |
|
380
|
|
|
$ret .= $this->getCommentLine('Sub', 'Submit'); |
|
381
|
|
|
$submit = array('name' => "{$language}SMNAME{$i}", 'url' => "'submit.php'"); |
|
382
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $submit, 'sub', $i); |
|
383
|
|
|
} |
|
384
|
|
|
unset($i); |
|
385
|
|
|
|
|
386
|
|
|
return $ret; |
|
387
|
|
|
} |
|
388
|
|
|
|
|
389
|
|
|
/* |
|
390
|
|
|
* @private function getXoopsVersionBlocks |
|
391
|
|
|
* @param $moduleDirname |
|
392
|
|
|
* @param $language |
|
393
|
|
|
*/ |
|
394
|
|
|
/** |
|
395
|
|
|
* @param $moduleDirname |
|
396
|
|
|
* @param $language |
|
397
|
|
|
* |
|
398
|
|
|
* @return string |
|
399
|
|
|
*/ |
|
400
|
|
|
private function getXoopsVersionBlocks($moduleDirname, $table, $tables, $language) |
|
|
|
|
|
|
401
|
|
|
{ |
|
402
|
|
|
$ret = $this->getHeaderComment('Blocks'); |
|
403
|
|
|
$ret .= $this->getSimpleString('$b = 1;'); |
|
404
|
|
|
foreach (array_keys($tables) as $i) { |
|
405
|
|
|
$tableName = $tables[$i]->getVar('table_name'); |
|
406
|
|
|
$tableFieldName = $tables[$i]->getVar('table_fieldname'); |
|
407
|
|
|
if (1 == $tables[$i]->getVar('table_category')) { |
|
408
|
|
|
$ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, $language, $tableFieldName); |
|
409
|
|
|
} else { |
|
410
|
|
|
$ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, $language, 'last'); |
|
411
|
|
|
$ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, $language, 'new'); |
|
412
|
|
|
$ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, $language, 'hits'); |
|
413
|
|
|
$ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, $language, 'top'); |
|
414
|
|
|
$ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, $language, 'random'); |
|
415
|
|
|
} |
|
416
|
|
|
} |
|
417
|
|
|
$ret .= $this->getSimpleString('unset($b);'); |
|
418
|
|
|
|
|
419
|
|
|
return $ret; |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
/* |
|
423
|
|
|
* @private function getXoopsVersionTypeBlocks |
|
424
|
|
|
* @param $moduleDirname |
|
425
|
|
|
* @param $language |
|
426
|
|
|
*/ |
|
427
|
|
|
/** |
|
428
|
|
|
* @param $moduleDirname |
|
429
|
|
|
* @param $language |
|
430
|
|
|
* |
|
431
|
|
|
* @return string |
|
432
|
|
|
*/ |
|
433
|
|
|
private function getXoopsVersionTypeBlocks($moduleDirname, $tableName, $language, $type) |
|
434
|
|
|
{ |
|
435
|
|
|
$stuTableName = strtoupper($tableName); |
|
436
|
|
|
$stuType = strtoupper($type); |
|
437
|
|
|
$ucfType = ucfirst($type); |
|
438
|
|
|
$ret = $this->getCommentLine("{$ucfType}"); |
|
439
|
|
|
$blocks = array('file' => "'{$tableName}.php'", 'name' => "{$language}{$stuTableName}_BLOCK_{$stuType}", 'description' => "{$language}{$stuTableName}_BLOCK_{$stuType}_DESC", |
|
440
|
|
|
'show_func' => "'b_{$moduleDirname}_{$tableName}_show'", 'edit_func' => "'b_{$moduleDirname}_{$tableName}_edit'", |
|
441
|
|
|
'template' => "'{$moduleDirname}_block_{$tableName}.tpl'", 'options' => "'{$type}|5|25|0'", ); |
|
442
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $blocks, 'blocks', '$b'); |
|
443
|
|
|
$ret .= $this->getSimpleString('++$b;'); |
|
444
|
|
|
|
|
445
|
|
|
return $ret; |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
/* |
|
449
|
|
|
* @private function getXoopsVersionConfig |
|
450
|
|
|
* @param $moduleDirname |
|
451
|
|
|
* @param $language |
|
452
|
|
|
*/ |
|
453
|
|
|
/** |
|
454
|
|
|
* @param $module |
|
455
|
|
|
* @param $table |
|
456
|
|
|
* @param $language |
|
457
|
|
|
* |
|
458
|
|
|
* @return string |
|
459
|
|
|
*/ |
|
460
|
|
|
private function getXoopsVersionConfig($module, $table, $language) |
|
461
|
|
|
{ |
|
462
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
463
|
|
|
$ret = $this->getHeaderComment('Config'); |
|
464
|
|
|
$ret .= $this->getSimpleString('$c = 1;'); |
|
465
|
|
|
$fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
|
466
|
|
|
$fieldName = array(); |
|
467
|
|
|
$fieldElement = array(); |
|
468
|
|
|
foreach (array_keys($fields) as $f) { |
|
469
|
|
|
$fieldName[] = $fields[$f]->getVar('field_name'); |
|
470
|
|
|
$fieldElement[] = $fields[$f]->getVar('field_element'); |
|
471
|
|
|
} |
|
472
|
|
|
if (in_array(4, $fieldElement)) { |
|
473
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
|
474
|
|
|
$ucfFieldName = ucfirst($rpFieldName); |
|
475
|
|
|
$ret .= $this->getCommentLine('Editor', $rpFieldName); |
|
476
|
|
|
$ret .= $this->xoopscode->getXoopsCodeLoad('xoopseditorhandler'); |
|
477
|
|
|
$ret .= $this->xoopscode->getXoopsCodeEqualsOperator('editorHandler ', 'XoopsEditorHandler::getInstance()'); |
|
478
|
|
|
$editor = array('name' => "'{$moduleDirname}_editor_{$rpFieldName}'", 'title' => "'{$language}EDITOR_{$ucfFieldName}'", 'description' => "'{$language}EDITOR_{$ucfFieldName}_DESC'", |
|
479
|
|
|
'formtype' => "'select'", 'valuetype' => "'text'", 'default' => "'dhtml'", 'options' => 'array_flip($editorHandler->getList())', ); |
|
480
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $editor, 'config', '$c'); |
|
481
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
482
|
|
|
} |
|
483
|
|
|
if (1 == $table->getVar('table_permissions')) { |
|
484
|
|
|
$ret .= $this->getCommentLine('Get groups'); |
|
485
|
|
|
$ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$memberHandler ', "xoops_gethandler('member')", true); |
|
486
|
|
|
$ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$xoopsGroups ', '$memberHandler->getGroupList()'); |
|
487
|
|
|
$group = $this->xoopscode->getXoopsCodeEqualsOperator('$groups[$group] ', '$key'); |
|
488
|
|
|
$ret .= $this->phpcode->getPhpCodeForeach('xoopsGroups', false, 'key', 'group', $group); |
|
489
|
|
|
$groups = array('name' => "'groups'", 'title' => "'{$language}GROUPS'", 'description' => "'{$language}GROUPS_DESC'", |
|
490
|
|
|
'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => '$groups', 'options' => '$groups', ); |
|
491
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $groups, 'config', '$c'); |
|
492
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
493
|
|
|
$ret .= $this->getCommentLine('Get Admin groups'); |
|
494
|
|
|
$ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$criteria ', 'new CriteriaCompo()'); |
|
495
|
|
|
$ret .= $this->getSimpleString("\$criteria->add( new Criteria( 'group_type', 'Admin' ) );"); |
|
496
|
|
|
$ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$memberHandler ', "xoops_gethandler('member')", true); |
|
497
|
|
|
$ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$adminXoopsGroups ', '$memberHandler->getGroupList($criteria)'); |
|
498
|
|
|
$adminGroup = $this->xoopscode->getXoopsCodeEqualsOperator('$adminGroups[$adminGroup] ', '$key'); |
|
499
|
|
|
$ret .= $this->phpcode->getPhpCodeForeach('adminXoopsGroups', false, 'key', 'adminGroup', $adminGroup); |
|
500
|
|
|
$adminGroups = array('name' => "'admin_groups'", 'title' => "'{$language}GROUPS'", 'description' => "'{$language}GROUPS_DESC'", |
|
501
|
|
|
'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => '$adminGroups', 'options' => '$adminGroups', ); |
|
502
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $adminGroups, 'config', '$c'); |
|
503
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
504
|
|
|
} |
|
505
|
|
|
$keyword = implode(', ', $this->getKeywords()); |
|
506
|
|
|
$ret .= $this->getCommentLine('Keywords'); |
|
507
|
|
|
$arrayKeyword = array('name' => "'keywords'", 'title' => "'{$language}KEYWORDS'", 'description' => "'{$language}KEYWORDS_DESC'", |
|
508
|
|
|
'formtype' => "'textbox'", 'valuetype' => "'text'", 'default' => "'{$moduleDirname}, {$keyword}'", ); |
|
509
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $arrayKeyword, 'config', '$c'); |
|
510
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
511
|
|
|
unset($this->keywords); |
|
512
|
|
|
if (is_object($table)) { |
|
513
|
|
|
if (in_array(array(10, 11, 12, 13, 14), $fieldElement)) { |
|
514
|
|
|
$ret .= $this->getCommentLine('Uploads : maxsize of image'); |
|
515
|
|
|
$maxsize = array('name' => "'maxsize'", 'title' => "'{$language}MAXSIZE'", 'description' => "'{$language}MAXSIZE_DESC'", |
|
516
|
|
|
'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '5000000', ); |
|
517
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $maxsize, 'config', '$c'); |
|
518
|
|
|
$ret .= $this->getCommentLine('Uploads : mimetypes of image'); |
|
519
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
520
|
|
|
$mimetypes = array('name' => "'mimetypes'", 'title' => "'{$language}MIMETYPES'", 'description' => "'{$language}MIMETYPES_DESC'", |
|
521
|
|
|
'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => "array('image/gif', 'image/jpeg', 'image/png')", 'options' => "array('bmp' => 'image/bmp','gif' => 'image/gif','pjpeg' => 'image/pjpeg', |
|
522
|
|
|
'jpeg' => 'image/jpeg','jpg' => 'image/jpg','jpe' => 'image/jpe', |
|
523
|
|
|
'png' => 'image/png')", ); |
|
524
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $mimetypes, 'config', '$c'); |
|
525
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
526
|
|
|
} |
|
527
|
|
View Code Duplication |
if (1 == $table->getVar('table_admin')) { |
|
|
|
|
|
|
528
|
|
|
$ret .= $this->getCommentLine('Admin pager'); |
|
529
|
|
|
$adminPager = array('name' => "'adminpager'", 'title' => "'{$language}ADMIN_PAGER'", 'description' => "'{$language}ADMIN_PAGER_DESC'", |
|
530
|
|
|
'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '10', ); |
|
531
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $adminPager, 'config', '$c'); |
|
532
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
533
|
|
|
} |
|
534
|
|
View Code Duplication |
if (1 == $table->getVar('table_user')) { |
|
|
|
|
|
|
535
|
|
|
$ret .= $this->getCommentLine('User pager'); |
|
536
|
|
|
$userPager = array('name' => "'userpager'", 'title' => "'{$language}USER_PAGER'", 'description' => "'{$language}USER_PAGER_DESC'", |
|
537
|
|
|
'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '10', ); |
|
538
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $userPager, 'config', '$c'); |
|
539
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
540
|
|
|
} |
|
541
|
|
View Code Duplication |
if (1 == $table->getVar('table_tag')) { |
|
|
|
|
|
|
542
|
|
|
$ret .= $this->getCommentLine('Use tag'); |
|
543
|
|
|
$useTag = array('name' => "'usetag'", 'title' => "'{$language}USE_TAG'", 'description' => "'{$language}USE_TAG_DESC'", |
|
544
|
|
|
'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0', ); |
|
545
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $useTag, 'config', '$c'); |
|
546
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
547
|
|
|
} |
|
548
|
|
|
} |
|
549
|
|
|
$ret .= $this->getCommentLine('Number column'); |
|
550
|
|
|
$numbCol = array('name' => "'numb_col'", 'title' => "'{$language}NUMB_COL'", 'description' => "'{$language}NUMB_COL_DESC'", |
|
551
|
|
|
'formtype' => "'select'", 'valuetype' => "'int'", 'default' => '1', 'options' => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')", ); |
|
552
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $numbCol, 'config', '$c'); |
|
553
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
554
|
|
|
$ret .= $this->getCommentLine('Divide by'); |
|
555
|
|
|
$divideby = array('name' => "'divideby'", 'title' => "'{$language}DIVIDEBY'", 'description' => "'{$language}DIVIDEBY_DESC'", |
|
556
|
|
|
'formtype' => "'select'", 'valuetype' => "'int'", 'default' => '1', 'options' => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')", ); |
|
557
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $divideby, 'config', '$c'); |
|
558
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
559
|
|
|
$ret .= $this->getCommentLine('Table type'); |
|
560
|
|
|
$tableType = array('name' => "'table_type'", 'title' => "'{$language}DIVIDEBY'", 'description' => "'{$language}DIVIDEBY_DESC'", |
|
561
|
|
|
'formtype' => "'select'", 'valuetype' => "'int'", 'default' => "'bordered'", 'options' => "array('bordered' => 'bordered', 'striped' => 'striped', 'hover' => 'hover', 'condensed' => 'condensed')", ); |
|
562
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $tableType, 'config', '$c'); |
|
563
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
564
|
|
|
$ret .= $this->getCommentLine('Panel by'); |
|
565
|
|
|
$panelType = array('name' => "'panel_type'", 'title' => "'{$language}PANEL_TYPE'", 'description' => "'{$language}PANEL_TYPE_DESC'", |
|
566
|
|
|
'formtype' => "'select'", 'valuetype' => "'text'", 'default' => "'default'", 'options' => "array('default' => 'default', 'primary' => 'primary', 'success' => 'success', 'info' => 'info', 'warning' => 'warning', 'danger' => 'danger')", ); |
|
567
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $panelType, 'config', '$c'); |
|
568
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
569
|
|
|
$ret .= $this->getCommentLine('Panel by'); |
|
570
|
|
|
$advertise = array('name' => "'advertise'", 'title' => "'{$language}ADVERTISE'", 'description' => "'{$language}ADVERTISE_DESC'", |
|
571
|
|
|
'formtype' => "'textarea'", 'valuetype' => "'text'", 'default' => "''", ); |
|
572
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $advertise, 'config', '$c'); |
|
573
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
574
|
|
|
$ret .= $this->getCommentLine('Panel by'); |
|
575
|
|
|
$bookmarks = array('name' => "'bookmarks'", 'title' => "'{$language}BOOKMARKS'", 'description' => "'{$language}BOOKMARKS_DESC'", |
|
576
|
|
|
'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0', ); |
|
577
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $bookmarks, 'config', '$c'); |
|
578
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
579
|
|
|
$ret .= $this->getCommentLine('Facebook Comments'); |
|
580
|
|
|
$facebookComments = array('name' => "'facebook_comments'", 'title' => "'{$language}FACEBOOK_COMMENTS'", 'description' => "'{$language}FACEBOOK_COMMENTS_DESC'", |
|
581
|
|
|
'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0', ); |
|
582
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $facebookComments, 'config', '$c'); |
|
583
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
584
|
|
|
$ret .= $this->getCommentLine('Disqus Comments'); |
|
585
|
|
|
$disqusComments = array('name' => "'disqus_comments'", 'title' => "'{$language}DISQUS_COMMENTS'", 'description' => "'{$language}DISQUS_COMMENTS_DESC'", |
|
586
|
|
|
'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0', ); |
|
587
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $disqusComments, 'config', '$c'); |
|
588
|
|
|
$ret .= $this->getSimpleString('++$c;'); |
|
589
|
|
|
$ret .= $this->getCommentLine('Maintained by'); |
|
590
|
|
|
$maintainedby = array('name' => "'maintainedby'", 'title' => "'{$language}MAINTAINEDBY'", 'description' => "'{$language}MAINTAINEDBY_DESC'", |
|
591
|
|
|
'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => "'{$module->getVar('mod_support_url')}'", ); |
|
592
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $maintainedby, 'config', '$c'); |
|
593
|
|
|
$ret .= $this->getSimpleString('unset($c);'); |
|
594
|
|
|
|
|
595
|
|
|
return $ret; |
|
596
|
|
|
} |
|
597
|
|
|
|
|
598
|
|
|
/* |
|
599
|
|
|
* @private function getNotificationsType |
|
600
|
|
|
* @param $language |
|
601
|
|
|
* @param $type |
|
602
|
|
|
* @param $tableName |
|
603
|
|
|
* @param $item |
|
604
|
|
|
* @param $typeOfNotify |
|
605
|
|
|
*/ |
|
606
|
|
|
/** |
|
607
|
|
|
* @param $language |
|
608
|
|
|
* @param $type |
|
609
|
|
|
* @param $tableName |
|
610
|
|
|
* @param $notifyFile |
|
611
|
|
|
* @param $item |
|
612
|
|
|
* @param $typeOfNotify |
|
613
|
|
|
* |
|
614
|
|
|
* @return string |
|
615
|
|
|
*/ |
|
616
|
|
|
private function getNotificationsType($language, $type = 'category', $tableName, $notifyFile, $item, $typeOfNotify) |
|
|
|
|
|
|
617
|
|
|
{ |
|
618
|
|
|
$stuTableName = strtoupper($tableName); |
|
619
|
|
|
$stuTypeOfNotify = strtoupper($typeOfNotify); |
|
620
|
|
|
$notifyFile = explode(', ', $notifyFile); |
|
621
|
|
|
$notifyFile = implode(', ', $notifyFile); |
|
622
|
|
|
$ret = ''; |
|
623
|
|
|
switch ($type) { |
|
624
|
|
|
case 'category': |
|
625
|
|
|
$ret .= $this->getCommentLine('Category Notify'); |
|
626
|
|
|
$category = array('name' => "'category'", 'title' => "'{$language}{$stuTableName}_NOTIFY'", 'description' => "'{$language}{$stuTableName}_NOTIFY_DESC'", |
|
627
|
|
|
'subscribe_from' => "array('index.php',{$notifyFile})", 'item_name' => "'{$item}'", "'allow_bookmark'" => '1', ); |
|
628
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $category, 'notification', "'{$type}'"); |
|
629
|
|
|
break; |
|
630
|
|
|
case 'event': |
|
631
|
|
|
$ret .= $this->getCommentLine('Event Notify'); |
|
632
|
|
|
$event = array('name' => "'{$typeOfNotify}'", 'category' => "'{$tableName}'", 'admin_only' => '1', "'title'" => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY'", |
|
633
|
|
|
'caption' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_CAPTION'", 'description' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_DESC'", |
|
634
|
|
|
'mail_template' => "'{$tableName}_{$typeOfNotify}_notify'", 'mail_subject' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_SUBJECT'", ); |
|
635
|
|
|
$ret .= $this->usercode->getUserModVersion(3, $event, 'notification', "'{$type}'"); |
|
636
|
|
|
break; |
|
637
|
|
|
} |
|
638
|
|
|
|
|
639
|
|
|
return $ret; |
|
640
|
|
|
} |
|
641
|
|
|
|
|
642
|
|
|
/* |
|
643
|
|
|
* @private function getXoopsVersionNotifications |
|
644
|
|
|
* @param $moduleDirname |
|
645
|
|
|
* @param $language |
|
646
|
|
|
*/ |
|
647
|
|
|
/** |
|
648
|
|
|
* @param $moduleDirname |
|
649
|
|
|
* @param $language |
|
650
|
|
|
* |
|
651
|
|
|
* @return string |
|
652
|
|
|
*/ |
|
653
|
|
|
private function getXoopsVersionNotifications($module, $language) |
|
654
|
|
|
{ |
|
655
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
656
|
|
|
$ret = $this->getHeaderComment('Notifications'); |
|
657
|
|
|
$ret .= $this->usercode->getUserModVersion(1, 1, 'hasNotification'); |
|
658
|
|
|
$notifications = array("'lookup_file'" => "'include/notification.inc.php'", "'lookup_func'" => "'{$moduleDirname}_notify_iteminfo'"); |
|
659
|
|
|
$ret .= $this->usercode->getUserModVersion(2, $notifications, 'notification'); |
|
660
|
|
|
|
|
661
|
|
|
$notifyFiles = array(); |
|
662
|
|
|
$single = 'single'; |
|
663
|
|
|
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
|
664
|
|
|
$tableCategory = array(); |
|
665
|
|
|
$tableBroken = array(); |
|
666
|
|
|
$tableSubmit = array(); |
|
667
|
|
|
foreach (array_keys($tables) as $t) { |
|
668
|
|
|
$tableId = $tables[$t]->getVar('table_id'); |
|
669
|
|
|
$tableMid = $tables[$t]->getVar('table_mid'); |
|
670
|
|
|
$tableName = $tables[$t]->getVar('table_name'); |
|
671
|
|
|
$tableCategory[] = $tables[$t]->getVar('table_category'); |
|
672
|
|
|
$tableBroken[] = $tables[$t]->getVar('table_broken'); |
|
673
|
|
|
$tableSubmit[] = $tables[$t]->getVar('table_submit'); |
|
674
|
|
|
if (1 == $tables[$t]->getVar('table_notifications')) { |
|
675
|
|
|
if ($t <= count($tableName)) { |
|
676
|
|
|
$notifyFiles[] = $tables[$t]->getVar('table_name'); |
|
677
|
|
|
} |
|
678
|
|
|
} |
|
679
|
|
|
if (1 == $tables[$t]->getVar('table_single')) { |
|
680
|
|
|
$single = $tableName; |
|
681
|
|
|
} |
|
682
|
|
|
} |
|
683
|
|
|
$fields = $this->getTableFields($tableMid, $tableId); |
|
|
|
|
|
|
684
|
|
|
$fieldParent = null; |
|
685
|
|
|
foreach (array_keys($fields) as $f) { |
|
686
|
|
|
$fieldMid = $fields[$f]->getVar('field_mid'); |
|
|
|
|
|
|
687
|
|
|
$fieldTid = $fields[$f]->getVar('field_tid'); |
|
|
|
|
|
|
688
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
689
|
|
|
$fieldElement = $fields[$f]->getVar('field_element'); |
|
690
|
|
|
if (0 == $f) { |
|
691
|
|
|
$fieldId = $fieldName; |
|
692
|
|
|
} |
|
693
|
|
|
if ($fieldElement > 15) { |
|
694
|
|
|
$fieldParent = $fieldName; |
|
695
|
|
|
} |
|
696
|
|
|
} |
|
697
|
|
|
|
|
698
|
|
|
$num = 1; |
|
699
|
|
|
$ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', 'global', $notifyFiles, $num); |
|
700
|
|
|
++$num; |
|
701
|
|
|
$ret .= $this->getXoopsVersionNotificationCategory($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1', $num); |
|
702
|
|
|
++$num; |
|
703
|
|
|
$ret .= $this->getXoopsVersionNotificationTableName($language, 'category', 'file', 'file', $single, $fieldId, 1, $num); |
|
|
|
|
|
|
704
|
|
|
unset($num); |
|
705
|
|
|
$num = 1; |
|
706
|
|
|
if (in_array(1, $tableCategory)) { |
|
707
|
|
|
++$num; |
|
708
|
|
|
$ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'global', 0, 'global', 'newcategory', 'global_newcategory_notify', $num); |
|
709
|
|
|
} |
|
710
|
|
|
$ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_modify', 'global', 1, 'global', 'filemodify', 'global_filemodify_notify', $num); |
|
711
|
|
|
if (in_array(1, $tableBroken)) { |
|
712
|
|
|
++$num; |
|
713
|
|
|
$ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_broken', 'global', 1, 'global', 'filebroken', 'global_filebroken_notify', $num); |
|
714
|
|
|
} |
|
715
|
|
|
if (in_array(1, $tableSubmit)) { |
|
716
|
|
|
++$num; |
|
717
|
|
|
$ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_submit', 'global', 1, 'global', 'filesubmit', 'global_filesubmit_notify', $num); |
|
718
|
|
|
} |
|
719
|
|
|
++$num; |
|
720
|
|
|
$ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_file', 'global', 0, 'global', 'newfile', 'global_newfile_notify', $num); |
|
721
|
|
|
if (in_array(1, $tableCategory)) { |
|
722
|
|
|
++$num; |
|
723
|
|
|
$ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_submit', 'category', 1, 'category', 'filesubmit', 'category_filesubmit_notify', $num); |
|
724
|
|
|
++$num; |
|
725
|
|
|
$ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_file', 'category', 0, 'category', 'newfile', 'category_newfile_notify', $num); |
|
726
|
|
|
} |
|
727
|
|
|
++$num; |
|
728
|
|
|
$ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'approve', 'file', 1, 'file', 'approve', 'file_approve_notify', $num); |
|
729
|
|
|
unset($num); |
|
730
|
|
|
|
|
731
|
|
|
return $ret; |
|
732
|
|
|
} |
|
733
|
|
|
|
|
734
|
|
|
/* |
|
735
|
|
|
* @private function getXoopsVersionNotificationGlobal |
|
736
|
|
|
*/ |
|
737
|
|
|
/** |
|
738
|
|
|
* @param $language |
|
739
|
|
|
* @param $type |
|
740
|
|
|
* @param $name |
|
741
|
|
|
* @param $title |
|
742
|
|
|
* @param $from |
|
743
|
|
|
* |
|
744
|
|
|
* @return string |
|
745
|
|
|
*/ |
|
746
|
|
|
private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from, $num) |
|
747
|
|
|
{ |
|
748
|
|
|
$title = strtoupper($title); |
|
749
|
|
|
$implodeFrom = implode(".php', '", $from); |
|
750
|
|
|
$ret = $this->getCommentLine('Global Notify'); |
|
751
|
|
|
$global = array('name' => "'{$name}'", 'title' => "{$language}{$title}_NOTIFY", 'description' => "{$language}{$title}_NOTIFY_DESC", |
|
752
|
|
|
'subscribe_from' => "array('index.php', '{$implodeFrom}.php')", ); |
|
753
|
|
|
$ret .= $this->usercode->getUserModVersion(4, $global, 'notification', "'{$type}'", $num); |
|
754
|
|
|
|
|
755
|
|
|
return $ret; |
|
756
|
|
|
} |
|
757
|
|
|
|
|
758
|
|
|
/* |
|
759
|
|
|
* @private function getXoopsVersionNotificationCategory |
|
760
|
|
|
*/ |
|
761
|
|
|
/** |
|
762
|
|
|
* @param $language |
|
763
|
|
|
* @param $type |
|
764
|
|
|
* @param $name |
|
765
|
|
|
* @param $title |
|
766
|
|
|
* @param $from |
|
767
|
|
|
* |
|
768
|
|
|
* @return string |
|
769
|
|
|
*/ |
|
770
|
|
View Code Duplication |
private function getXoopsVersionNotificationCategory($language, $type, $name, $title, $from, $item, $allow, $num) |
|
|
|
|
|
|
771
|
|
|
{ |
|
772
|
|
|
$title = strtoupper($title);//{$from} |
|
773
|
|
|
$implodeFrom = implode(".php', '", $from); |
|
774
|
|
|
$ret = $this->getCommentLine('Category Notify'); |
|
775
|
|
|
$global = array('name' => "'{$name}'", 'title' => "{$language}{$title}_NOTIFY", 'description' => "{$language}{$title}_NOTIFY_DESC", |
|
776
|
|
|
'subscribe_from' => "array('{$implodeFrom}.php')", 'item_name' => "'{$item}'", 'allow_bookmark' => "{$allow}", ); |
|
777
|
|
|
$ret .= $this->usercode->getUserModVersion(4, $global, 'notification', "'{$type}'", $num); |
|
778
|
|
|
|
|
779
|
|
|
return $ret; |
|
780
|
|
|
} |
|
781
|
|
|
|
|
782
|
|
|
/* |
|
783
|
|
|
* @private function getXoopsVersionNotificationTableName |
|
784
|
|
|
*/ |
|
785
|
|
|
/** |
|
786
|
|
|
* @param $language |
|
787
|
|
|
* @param $type |
|
788
|
|
|
* @param $name |
|
789
|
|
|
* @param $title |
|
790
|
|
|
* @param $from |
|
791
|
|
|
* @param $item |
|
792
|
|
|
* @param $allow |
|
793
|
|
|
* |
|
794
|
|
|
* @return string |
|
795
|
|
|
*/ |
|
796
|
|
View Code Duplication |
private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $from, $item = 'cid', $allow = 1, $num) |
|
|
|
|
|
|
797
|
|
|
{ |
|
798
|
|
|
$stuTitle = strtoupper($title); |
|
799
|
|
|
$ucfTitle = ucfirst($title); |
|
800
|
|
|
$ret = $this->getCommentLine($ucfTitle.' Notify'); |
|
801
|
|
|
$global = array('name' => "'{$name}'", 'title' => "{$language}{$stuTitle}_NOTIFY", 'description' => "{$language}{$stuTitle}_NOTIFY_DESC", |
|
802
|
|
|
'subscribe_from' => "'{$from}.php'", 'item_name' => "'{$item}'", 'allow_bookmark' => "{$allow}", ); |
|
803
|
|
|
$ret .= $this->usercode->getUserModVersion(4, $global, 'notification', "'{$type}'", $num); |
|
804
|
|
|
|
|
805
|
|
|
return $ret; |
|
806
|
|
|
} |
|
807
|
|
|
|
|
808
|
|
|
/* |
|
809
|
|
|
* @private function getXoopsVersionNotifications |
|
810
|
|
|
*/ |
|
811
|
|
|
/** |
|
812
|
|
|
* @param $language |
|
813
|
|
|
* @param $type |
|
814
|
|
|
* @param $name |
|
815
|
|
|
* @param $title |
|
816
|
|
|
* @param $from |
|
817
|
|
|
* @param $item |
|
818
|
|
|
* @param $mail |
|
819
|
|
|
* |
|
820
|
|
|
* @return string |
|
821
|
|
|
*/ |
|
822
|
|
|
private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin = 1, $title, $table, $mail, $num) |
|
823
|
|
|
{ |
|
824
|
|
|
$title = strtoupper($title); |
|
825
|
|
|
$table = strtoupper($table); |
|
826
|
|
|
$ucfTitle = ucfirst($title); |
|
827
|
|
|
$ret = $this->getCommentLine($ucfTitle.' Notify'); |
|
828
|
|
|
$event = array('name' => "'{$name}'", 'category' => "'{$category}'", 'admin_only' => "{$admin}", 'title' => "{$language}{$title}_{$table}_NOTIFY", |
|
829
|
|
|
'caption' => "{$language}{$title}_{$table}_NOTIFY_CAPTION", 'description' => "{$language}{$title}_{$table}_NOTIFY_DESC", |
|
830
|
|
|
'mail_template' => "'{$mail}'", 'mail_subject' => "{$language}{$title}_{$table}_NOTIFY_SUBJECT", ); |
|
831
|
|
|
$ret .= $this->usercode->getUserModVersion(4, $event, 'notification', "'{$type}'", $num); |
|
832
|
|
|
|
|
833
|
|
|
return $ret; |
|
834
|
|
|
} |
|
835
|
|
|
|
|
836
|
|
|
/* |
|
837
|
|
|
* @public function render |
|
838
|
|
|
* @param null |
|
839
|
|
|
*/ |
|
840
|
|
|
/** |
|
841
|
|
|
* @return bool|string |
|
842
|
|
|
*/ |
|
843
|
|
|
public function render() |
|
844
|
|
|
{ |
|
845
|
|
|
$module = $this->getModule(); |
|
846
|
|
|
$table = $this->getTable(); |
|
847
|
|
|
$tables = $this->getTables(); |
|
848
|
|
|
$filename = $this->getFileName(); |
|
849
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
850
|
|
|
$language = $this->getLanguage($moduleDirname, 'MI'); |
|
851
|
|
|
$content = $this->getHeaderFilesComments($module, $filename); |
|
852
|
|
|
$content .= $this->getXoopsVersionHeader($module, $language); |
|
853
|
|
|
if (1 == $module->getVar('mod_admin')) { |
|
854
|
|
|
$content .= $this->getXoopsVersionTemplatesAdmin($moduleDirname, $tables); |
|
855
|
|
|
} |
|
856
|
|
|
if (1 == $module->getVar('mod_user')) { |
|
857
|
|
|
$content .= $this->getXoopsVersionTemplatesUser($moduleDirname, $tables); |
|
858
|
|
|
} |
|
859
|
|
|
$content .= $this->getXoopsVersionMySQL($moduleDirname, $table, $tables); |
|
860
|
|
|
$tableSearch = array(); |
|
861
|
|
|
$tableComments = array(); |
|
862
|
|
|
$tableSubmenu = array(); |
|
863
|
|
|
$tableBlocks = array(); |
|
864
|
|
|
$tableNotifications = array(); |
|
865
|
|
|
foreach (array_keys($tables) as $t) { |
|
866
|
|
|
$tableSearch[] = $tables[$t]->getVar('table_search'); |
|
867
|
|
|
$tableComments[] = $tables[$t]->getVar('table_comments'); |
|
868
|
|
|
$tableSubmenu[] = $tables[$t]->getVar('table_submenu'); |
|
869
|
|
|
$tableBlocks[] = $tables[$t]->getVar('table_blocks'); |
|
870
|
|
|
$tableNotifications[] = $tables[$t]->getVar('table_notifications'); |
|
871
|
|
|
} |
|
872
|
|
|
if (in_array(1, $tableSearch)) { |
|
873
|
|
|
$content .= $this->getXoopsVersionSearch($moduleDirname); |
|
874
|
|
|
} |
|
875
|
|
|
if (in_array(1, $tableComments)) { |
|
876
|
|
|
$content .= $this->getXoopsVersionComments($moduleDirname); |
|
877
|
|
|
} |
|
878
|
|
|
if (in_array(1, $tableSubmenu)) { |
|
879
|
|
|
$content .= $this->getXoopsVersionSubmenu($language, $tables); |
|
880
|
|
|
} |
|
881
|
|
|
if (in_array(1, $tableBlocks)) { |
|
882
|
|
|
$content .= $this->getXoopsVersionBlocks($moduleDirname, $table, $tables, $language); |
|
883
|
|
|
} |
|
884
|
|
|
$content .= $this->getXoopsVersionConfig($module, $table, $language); |
|
885
|
|
|
if (in_array(1, $tableNotifications)) { |
|
886
|
|
|
$content .= $this->getXoopsVersionNotifications($module, $language, $filename); |
|
|
|
|
|
|
887
|
|
|
} |
|
888
|
|
|
$this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
889
|
|
|
|
|
890
|
|
|
return $this->renderFile(); |
|
891
|
|
|
} |
|
892
|
|
|
} |
|
893
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.