Total Complexity | 87 |
Total Lines | 1216 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like UserXoopsVersion often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use UserXoopsVersion, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
32 | class UserXoopsVersion extends Files\CreateFile |
||
33 | { |
||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | private $kw = []; |
||
38 | |||
39 | /** |
||
40 | * @public function constructor |
||
41 | * @param null |
||
42 | */ |
||
43 | public function __construct() |
||
44 | { |
||
45 | parent::__construct(); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @static function getInstance |
||
50 | * @param null |
||
51 | * @return UserXoopsVersion |
||
52 | */ |
||
53 | public static function getInstance() |
||
54 | { |
||
55 | static $instance = false; |
||
56 | if (!$instance) { |
||
57 | $instance = new self(); |
||
58 | } |
||
59 | |||
60 | return $instance; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @public function write |
||
65 | * @param $module |
||
66 | * @param mixed $table |
||
67 | * @param mixed $tables |
||
68 | * @param $filename |
||
69 | */ |
||
70 | public function write($module, $table, $tables, $filename) |
||
71 | { |
||
72 | $this->setModule($module); |
||
73 | $this->setTable($table); |
||
74 | $this->setTables($tables); |
||
75 | $this->setFileName($filename); |
||
76 | foreach (array_keys($tables) as $t) { |
||
77 | $tableName = $tables[$t]->getVar('table_name'); |
||
78 | $this->setKeywords($tableName); |
||
79 | } |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @public function setKeywords |
||
84 | * @param mixed $keywords |
||
85 | */ |
||
86 | public function setKeywords($keywords) |
||
87 | { |
||
88 | if (is_array($keywords)) { |
||
89 | $this->kw = $keywords; |
||
90 | } else { |
||
91 | $this->kw[] = $keywords; |
||
92 | } |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @public function getKeywords |
||
97 | * @param null |
||
98 | * @return array |
||
99 | */ |
||
100 | public function getKeywords() |
||
101 | { |
||
102 | return $this->kw; |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * @private function getXoopsVersionHeader |
||
107 | * @param $module |
||
108 | * @param $language |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | private function getXoopsVersionHeader($module, $language) |
||
113 | { |
||
114 | $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||
115 | $uxc = UserXoopsCode::getInstance(); |
||
116 | $date = date('Y/m/d'); |
||
117 | $ret = $this->getSimpleString(''); |
||
118 | $ret .= Modulebuilder\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine(); |
||
119 | $ret .= $xc->getXcEqualsOperator('$moduleDirName ', 'basename(__DIR__)'); |
||
120 | $ret .= $xc->getXcEqualsOperator('$moduleDirNameUpper', 'mb_strtoupper($moduleDirName)'); |
||
121 | $ret .= $this->getDashComment('Informations'); |
||
122 | $ha = (1 == $module->getVar('mod_admin')) ? 1 : 0; |
||
123 | $hm = (1 == $module->getVar('mod_user')) ? 1 : 0; |
||
124 | |||
125 | $descriptions = [ |
||
126 | 'name' => "{$language}NAME", |
||
127 | 'version' => (string)$module->getVar('mod_version'), |
||
128 | 'description' => "{$language}DESC", |
||
129 | 'author' => "'{$module->getVar('mod_author')}'", |
||
130 | 'author_mail' => "'{$module->getVar('mod_author_mail')}'", |
||
131 | 'author_website_url' => "'{$module->getVar('mod_author_website_url')}'", |
||
132 | 'author_website_name' => "'{$module->getVar('mod_author_website_name')}'", |
||
133 | 'credits' => "'{$module->getVar('mod_credits')}'", |
||
134 | 'license' => "'{$module->getVar('mod_license')}'", |
||
135 | 'license_url' => "'http://www.gnu.org/licenses/gpl-3.0.en.html'", |
||
136 | 'help' => "'page=help'", |
||
137 | 'release_info' => "'{$module->getVar('mod_release_info')}'", |
||
138 | 'release_file' => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_release_file')}'", |
||
139 | 'release_date' => "'{$date}'", |
||
140 | 'manual' => "'{$module->getVar('mod_manual')}'", |
||
141 | 'manual_file' => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_manual_file')}'", |
||
142 | 'min_php' => "'{$module->getVar('mod_min_php')}'", |
||
143 | 'min_xoops' => "'{$module->getVar('mod_min_xoops')}'", |
||
144 | 'min_admin' => "'{$module->getVar('mod_min_admin')}'", |
||
145 | 'min_db' => "array('mysql' => '{$module->getVar('mod_min_mysql')}', 'mysqli' => '{$module->getVar('mod_min_mysql')}')", |
||
146 | 'image' => "'assets/images/logoModule.png'", |
||
147 | 'dirname' => 'basename(__DIR__)', |
||
148 | 'dirmoduleadmin' => "'Frameworks/moduleclasses/moduleadmin'", |
||
149 | 'sysicons16' => "'../../Frameworks/moduleclasses/icons/16'", |
||
150 | 'sysicons32' => "'../../Frameworks/moduleclasses/icons/32'", |
||
151 | 'modicons16' => "'assets/icons/16'", |
||
152 | 'modicons32' => "'assets/icons/32'", |
||
153 | 'demo_site_url' => "'{$module->getVar('mod_demo_site_url')}'", |
||
154 | 'demo_site_name' => "'{$module->getVar('mod_demo_site_name')}'", |
||
155 | 'support_url' => "'{$module->getVar('mod_support_url')}'", |
||
156 | 'support_name' => "'{$module->getVar('mod_support_name')}'", |
||
157 | 'module_website_url' => "'{$module->getVar('mod_website_url')}'", |
||
158 | 'module_website_name' => "'{$module->getVar('mod_website_name')}'", |
||
159 | 'release' => "'{$module->getVar('mod_release')}'", |
||
160 | 'module_status' => "'{$module->getVar('mod_status')}'", |
||
161 | 'system_menu' => '1', |
||
162 | 'hasAdmin' => $ha, |
||
163 | 'hasMain' => $hm, |
||
164 | 'adminindex' => "'admin/index.php'", |
||
165 | 'adminmenu' => "'admin/menu.php'", |
||
166 | 'onInstall' => "'include/install.php'", |
||
167 | 'onUninstall' => "'include/uninstall.php'", |
||
168 | 'onUpdate' => "'include/update.php'", |
||
169 | ]; |
||
170 | |||
171 | $ret .= $uxc->getUserModVersionArray(0, $descriptions); |
||
172 | |||
173 | return $ret; |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | * @private function getXoopsVersionMySQL |
||
178 | * @param $moduleDirname |
||
179 | * @param $table |
||
180 | * @param $tables |
||
181 | * @return string |
||
182 | */ |
||
183 | private function getXoopsVersionMySQL($moduleDirname, $table, $tables) |
||
184 | { |
||
185 | $uxc = UserXoopsCode::getInstance(); |
||
186 | $tableName = $table->getVar('table_name'); |
||
187 | $n = 1; |
||
188 | $ret = ''; |
||
189 | $items = []; |
||
190 | if (!empty($tableName)) { |
||
191 | $ret .= $this->getDashComment('Mysql'); |
||
192 | $description = "'sql/mysql.sql'"; |
||
193 | $ret .= $uxc->getUserModVersionText(2, $description, 'sqlfile', "'mysql'"); |
||
194 | $ret .= Modulebuilder\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Tables'); |
||
195 | |||
196 | foreach (array_keys($tables) as $t) { |
||
197 | $items[] = "'{$moduleDirname}_{$tables[$t]->getVar('table_name')}'"; |
||
198 | ++$n; |
||
199 | } |
||
200 | $ret .= $uxc->getUserModVersionArray(11, $items, 'tables', $n); |
||
201 | unset($n); |
||
202 | } |
||
203 | |||
204 | return $ret; |
||
205 | } |
||
206 | |||
207 | /** |
||
208 | * @private function getXoopsVersionSearch |
||
209 | * @param $moduleDirname |
||
210 | * |
||
211 | * @return string |
||
212 | */ |
||
213 | private function getXoopsVersionSearch($moduleDirname) |
||
222 | } |
||
223 | |||
224 | /** |
||
225 | * @private function getXoopsVersionComments |
||
226 | * @param $moduleDirname |
||
227 | * |
||
228 | * @return string |
||
229 | */ |
||
230 | private function getXoopsVersionComments($moduleDirname) |
||
231 | { |
||
232 | $uxc = UserXoopsCode::getInstance(); |
||
233 | $ret = $this->getDashComment('Comments'); |
||
234 | $ret .= $uxc->getUserModVersionText(2, "'comments.php'", 'comments', "'pageName'"); |
||
235 | $ret .= $uxc->getUserModVersionText(2, "'com_id'", 'comments', "'itemName'"); |
||
236 | $ret .= Modulebuilder\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Comment callback functions'); |
||
237 | $ret .= $uxc->getUserModVersionText(2, "'include/comment_functions.php'", 'comments', "'callbackFile'"); |
||
238 | $descriptions = ['approve' => "'{$moduleDirname}CommentsApprove'", 'update' => "'{$moduleDirname}CommentsUpdate'"]; |
||
239 | $ret .= $uxc->getUserModVersionArray(2, $descriptions, 'comments', "'callback'"); |
||
240 | |||
241 | return $ret; |
||
242 | } |
||
243 | |||
244 | /** |
||
245 | * @private function getXoopsVersionTemplatesAdminUser |
||
246 | * @param $moduleDirname |
||
247 | * @param $tables |
||
248 | * |
||
249 | * @param $admin |
||
250 | * @param $user |
||
251 | * @return string |
||
252 | */ |
||
253 | private function getXoopsVersionTemplatesAdminUser($moduleDirname, $tables, $admin, $user) |
||
332 | } |
||
333 | |||
334 | /** |
||
335 | * @private function getXoopsVersionTemplatesLine |
||
336 | * @param $moduleDirname |
||
337 | * @param $type |
||
338 | * @param string $extra |
||
339 | * @param bool $isAdmin |
||
340 | * @return string |
||
341 | */ |
||
342 | private function getXoopsVersionTemplatesLine($moduleDirname, $type, $extra = '', $isAdmin = false) |
||
343 | { |
||
344 | $ret = ''; |
||
345 | $desc = "'description' => ''"; |
||
346 | $arrayFile = "['file' =>"; |
||
347 | if ($isAdmin) { |
||
348 | $ret .= "{$arrayFile} '{$moduleDirname}_admin_{$type}.tpl', {$desc}, 'type' => 'admin']"; |
||
349 | } else { |
||
350 | if ('' !== $extra) { |
||
351 | $ret .= "{$arrayFile} '{$moduleDirname}_{$type}_{$extra}.tpl', {$desc}]"; |
||
352 | } else { |
||
353 | $ret .= "{$arrayFile} '{$moduleDirname}_{$type}.tpl', {$desc}]"; |
||
354 | } |
||
355 | } |
||
356 | |||
357 | return $ret; |
||
358 | } |
||
359 | |||
360 | /** |
||
361 | * @private function getXoopsVersionSubmenu |
||
362 | * @param $language |
||
363 | * @param $tables |
||
364 | * @return string |
||
365 | */ |
||
366 | private function getXoopsVersionSubmenu($language, $tables) |
||
367 | { |
||
368 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||
369 | $uxc = UserXoopsCode::getInstance(); |
||
370 | |||
371 | $ret = $this->getDashComment('Menu'); |
||
372 | $xModule = $pc->getPhpCodeGlobals('xoopsModule'); |
||
373 | $cond = 'isset(' . $xModule . ') && is_object(' . $xModule . ')'; |
||
374 | $one = $pc->getPhpCodeGlobals('xoopsModule') . "->getVar('dirname')"; |
||
375 | $ret .= $pc->getPhpCodeTernaryOperator('currdirname ', $cond, $one, "'system'"); |
||
376 | |||
377 | $i = 1; |
||
378 | $descriptions = [ |
||
379 | 'name' => "{$language}SMNAME{$i}", |
||
380 | 'url' => "'index.php'", |
||
381 | ]; |
||
382 | $contentIf = $uxc->getUserModVersionArray(2, $descriptions, 'sub', '','', "\t"); |
||
|
|||
383 | |||
384 | $tableSearch = []; |
||
385 | foreach (array_keys($tables) as $t) { |
||
386 | $tableName = $tables[$t]->getVar('table_name'); |
||
387 | $tableSearch[] = $tables[$t]->getVar('table_search'); |
||
388 | if (1 == $tables[$t]->getVar('table_submenu')) { |
||
389 | $contentIf .= $pc->getPhpCodeCommentLine('Sub', $tableName, "\t"); |
||
390 | $descriptions = [ |
||
391 | 'name' => "{$language}SMNAME{$i}", |
||
392 | 'url' => "'{$tableName}.php'", |
||
393 | ]; |
||
394 | $contentIf .= $uxc->getUserModVersionArray(2, $descriptions, 'sub', '','', "\t"); |
||
395 | unset($item); |
||
396 | } |
||
397 | ++$i; |
||
398 | if (1 == $tables[$t]->getVar('table_submit')) { |
||
399 | $contentIf .= $pc->getPhpCodeCommentLine('Sub', 'Submit', "\t"); |
||
400 | $descriptions = [ |
||
401 | 'name' => "{$language}SMNAME{$i}", |
||
402 | 'url' => "'{$tableName}.php?op=new'", |
||
403 | ]; |
||
404 | $contentIf .= $uxc->getUserModVersionArray(2, $descriptions, 'sub', '','', "\t"); |
||
405 | ++$i; |
||
406 | } |
||
407 | } |
||
408 | |||
409 | //TODO: after finalizing creation of search.php by User/UserSearch.php this sub menu item can be activated |
||
410 | /* |
||
411 | if (in_array(1, $tableSearch)) { |
||
412 | $contentIf .= $cpc->getPhpCodeCommentLine('Sub', 'Search', "\t"); |
||
413 | $descriptions = [ |
||
414 | 'name' => "{$language}SMNAME{$i}", |
||
415 | 'url' => "'search.php'", |
||
416 | ]; |
||
417 | $contentIf .= $uxc->getUserModVersionArray(2, $descriptions, 'sub', '','', "\t"); |
||
418 | } |
||
419 | */ |
||
420 | unset($i); |
||
421 | |||
422 | $ret .= $pc->getPhpCodeConditions('$moduleDirName', ' == ', '$currdirname', $contentIf); |
||
423 | |||
424 | return $ret; |
||
425 | } |
||
426 | |||
427 | /** |
||
428 | * @private function getXoopsVersionBlocks |
||
429 | * @param $moduleDirname |
||
430 | * @param $tables |
||
431 | * @param $language |
||
432 | * @return string |
||
433 | */ |
||
434 | private function getXoopsVersionBlocks($moduleDirname, $tables, $language) |
||
435 | { |
||
436 | $ret = $this->getDashComment('Blocks'); |
||
437 | $tableCategory = []; |
||
438 | foreach (array_keys($tables) as $i) { |
||
439 | $tableName = $tables[$i]->getVar('table_name'); |
||
440 | $tableCategory[] = $tables[$i]->getVar('table_category'); |
||
441 | if (0 == $tables[$i]->getVar('table_category')) { |
||
442 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'LAST', $language, 'last'); |
||
443 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'NEW', $language, 'new'); |
||
444 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'HITS', $language, 'hits'); |
||
445 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'TOP', $language, 'top'); |
||
446 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'RANDOM', $language, 'random'); |
||
447 | } |
||
448 | } |
||
449 | |||
450 | return $ret; |
||
451 | } |
||
452 | |||
453 | /** |
||
454 | * @private function getXoopsVersionTypeBlocks |
||
455 | * @param $moduleDirname |
||
456 | * @param $tableName |
||
457 | * @param $stuTableSoleName |
||
458 | * @param $language |
||
459 | * @param $type |
||
460 | * @return string |
||
461 | */ |
||
462 | private function getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $type) |
||
463 | { |
||
464 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||
465 | $uxc = UserXoopsCode::getInstance(); |
||
466 | $stuTableName = mb_strtoupper($tableName); |
||
467 | $ucfTableName = ucfirst($tableName); |
||
468 | $ret = $pc->getPhpCodeCommentLine($ucfTableName . ' ' . $type); |
||
469 | $blocks = [ |
||
470 | 'file' => "'{$tableName}.php'", |
||
471 | 'name' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}", |
||
472 | 'description' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}_DESC", |
||
473 | 'show_func' => "'b_{$moduleDirname}_{$tableName}_show'", |
||
474 | 'edit_func' => "'b_{$moduleDirname}_{$tableName}_edit'", |
||
475 | 'template' => "'{$moduleDirname}_block_{$tableName}.tpl'", |
||
476 | 'options' => "'{$type}|5|25|0'", |
||
477 | ]; |
||
478 | $ret .= $uxc->getUserModVersionArray(2, $blocks, 'blocks'); |
||
479 | |||
480 | return $ret; |
||
481 | } |
||
482 | |||
483 | /** |
||
484 | * @private function getXoopsVersionConfig |
||
485 | * @param $module |
||
486 | * @param $tables |
||
487 | * @param $language |
||
488 | * |
||
489 | * @return string |
||
490 | */ |
||
491 | private function getXoopsVersionConfig($module, $tables, $language) |
||
492 | { |
||
493 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||
494 | $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||
495 | $uxc = UserXoopsCode::getInstance(); |
||
496 | $moduleDirname = $module->getVar('mod_dirname'); |
||
497 | $ret = $this->getDashComment('Config'); |
||
498 | |||
499 | $table_editors = 0; |
||
500 | $table_permissions = 0; |
||
501 | $table_admin = 0; |
||
502 | $table_user = 0; |
||
503 | $table_tag = 0; |
||
504 | $table_uploadimage = 0; |
||
505 | $table_uploadfile = 0; |
||
506 | foreach ($tables as $table) { |
||
507 | $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
||
508 | $stuTablename = mb_strtoupper($table->getVar('table_name')); |
||
509 | foreach (array_keys($fields) as $f) { |
||
510 | $fieldElement = (int)$fields[$f]->getVar('field_element'); |
||
511 | switch ($fieldElement) { |
||
512 | case 3: |
||
513 | $table_editors = 1; |
||
514 | break; |
||
515 | case 4: |
||
516 | $table_editors = 1; |
||
517 | break; |
||
518 | case 10: |
||
519 | case 11: |
||
520 | case 12: |
||
521 | case 13: |
||
522 | $table_uploadimage = 1; |
||
523 | break; |
||
524 | case 14: |
||
525 | $table_uploadfile = 1; |
||
526 | break; |
||
527 | case 'else': |
||
528 | default: |
||
529 | break; |
||
530 | } |
||
531 | } |
||
532 | if (1 == $table->getVar('table_permissions')) { |
||
533 | $table_permissions = 1; |
||
534 | } |
||
535 | if (1 == $table->getVar('table_admin')) { |
||
536 | $table_admin = 1; |
||
537 | } |
||
538 | if (1 == $table->getVar('table_user')) { |
||
539 | $table_user = 1; |
||
540 | } |
||
541 | if (1 == $table->getVar('table_tag')) { |
||
542 | $table_tag = 1; |
||
543 | } |
||
544 | } |
||
545 | if (1 === $table_editors) { |
||
546 | $fieldName = $fields[$f]->getVar('field_name'); |
||
547 | $rpFieldName = $this->getRightString($fieldName); |
||
548 | $ucfFieldName = ucfirst($rpFieldName); |
||
549 | $stuFieldName = mb_strtoupper($rpFieldName); |
||
550 | $ret .= $pc->getPhpCodeCommentLine('Editor', ''); |
||
551 | $ret .= $xc->getXcXoopsLoad('xoopseditorhandler'); |
||
552 | $ret .= $xc->getXcEqualsOperator('$editorHandler', 'XoopsEditorHandler::getInstance()'); |
||
553 | $editor = [ |
||
554 | 'name' => "'editor_default'", |
||
555 | 'title' => "'{$language}EDITOR_DEFAULT'", |
||
556 | 'description' => "'{$language}EDITOR_DEFAULT_DESC'", |
||
557 | 'formtype' => "'select'", |
||
558 | 'valuetype' => "'text'", |
||
559 | 'default' => "'dhtml'", |
||
560 | 'options' => 'array_flip($editorHandler->getList())', |
||
561 | ]; |
||
562 | $ret .= $uxc->getUserModVersionArray(2, $editor, 'config'); |
||
563 | $ret .= $pc->getPhpCodeCommentLine('Editor : max characters admin area'); |
||
564 | $maxsize_image = [ |
||
565 | 'name' => "'editor_maxchar'", |
||
566 | 'title' => "'{$language}EDITOR_MAXCHAR'", |
||
567 | 'description' => "'{$language}EDITOR_MAXCHAR_DESC'", |
||
568 | 'formtype' => "'textbox'", |
||
569 | 'valuetype' => "'int'", |
||
570 | 'default' => '50', |
||
571 | ]; |
||
572 | $ret .= $uxc->getUserModVersionArray(2, $maxsize_image, 'config'); |
||
573 | } |
||
574 | if (1 === $table_permissions) { |
||
575 | $ret .= $pc->getPhpCodeCommentLine('Get groups'); |
||
576 | $ret .= $xc->getXcXoopsHandler('member'); |
||
577 | $ret .= $xc->getXcEqualsOperator('$xoopsGroups ', '$memberHandler->getGroupList()'); |
||
578 | $ret .= $xc->getXcEqualsOperator('$groups', '[]'); |
||
579 | $group = $xc->getXcEqualsOperator('$groups[$group] ', '$key', null, "\t"); |
||
580 | $ret .= $pc->getPhpCodeForeach('xoopsGroups', false, 'key', 'group', $group); |
||
581 | $ret .= $pc->getPhpCodeCommentLine('General access groups'); |
||
582 | $groups = [ |
||
583 | 'name' => "'groups'", |
||
584 | 'title' => "'{$language}GROUPS'", |
||
585 | 'description' => "'{$language}GROUPS_DESC'", |
||
586 | 'formtype' => "'select_multi'", |
||
587 | 'valuetype' => "'array'", |
||
588 | 'default' => '$groups', |
||
589 | 'options' => '$groups', |
||
590 | ]; |
||
591 | $ret .= $uxc->getUserModVersionArray(2, $groups, 'config'); |
||
592 | $ret .= $pc->getPhpCodeCommentLine('Upload groups'); |
||
593 | $uplgroups = [ |
||
594 | 'name' => "'upload_groups'", |
||
595 | 'title' => "'{$language}UPLOAD_GROUPS'", |
||
596 | 'description' => "'{$language}UPLOAD_GROUPS_DESC'", |
||
597 | 'formtype' => "'select_multi'", |
||
598 | 'valuetype' => "'array'", |
||
599 | 'default' => '$groups', |
||
600 | 'options' => '$groups', |
||
601 | ]; |
||
602 | $ret .= $uxc->getUserModVersionArray(2, $uplgroups, 'config'); |
||
603 | |||
604 | $ret .= $pc->getPhpCodeCommentLine('Get Admin groups'); |
||
605 | $ret .= $xc->getXcCriteriaCompo('crGroups'); |
||
606 | $crit = $xc->getXcCriteria('', "'group_type'", "'Admin'", '', true); |
||
607 | $ret .= $xc->getXcCriteriaAdd('crGroups', $crit, '', "\n"); |
||
608 | $ret .= $xc->getXcXoopsHandler('member'); |
||
609 | $ret .= $xc->getXcEqualsOperator('$adminXoopsGroups ', '$memberHandler->getGroupList($crGroups)'); |
||
610 | $ret .= $xc->getXcEqualsOperator('$adminGroups', '[]'); |
||
611 | $adminGroup = $xc->getXcEqualsOperator('$adminGroups[$adminGroup] ', '$key', null, "\t"); |
||
612 | $ret .= $pc->getPhpCodeForeach('adminXoopsGroups', false, 'key', 'adminGroup', $adminGroup); |
||
613 | $adminGroups = [ |
||
614 | 'name' => "'admin_groups'", |
||
615 | 'title' => "'{$language}ADMIN_GROUPS'", |
||
616 | 'description' => "'{$language}ADMIN_GROUPS_DESC'", |
||
617 | 'formtype' => "'select_multi'", |
||
618 | 'valuetype' => "'array'", |
||
619 | 'default' => '$adminGroups', |
||
620 | 'options' => '$adminGroups', |
||
621 | ]; |
||
622 | $ret .= $uxc->getUserModVersionArray(2, $adminGroups, 'config'); |
||
623 | $ret .= $pc->getPhpCodeUnset('crGroups'); |
||
624 | } |
||
625 | $keyword = implode(', ', $this->getKeywords()); |
||
626 | $ret .= $pc->getPhpCodeCommentLine('Keywords'); |
||
627 | $arrayKeyword = [ |
||
628 | 'name' => "'keywords'", |
||
629 | 'title' => "'{$language}KEYWORDS'", |
||
630 | 'description' => "'{$language}KEYWORDS_DESC'", |
||
631 | 'formtype' => "'textbox'", |
||
632 | 'valuetype' => "'text'", |
||
633 | 'default' => "'{$moduleDirname}, {$keyword}'", |
||
634 | ]; |
||
635 | $ret .= $uxc->getUserModVersionArray(2, $arrayKeyword, 'config'); |
||
636 | unset($this->keywords); |
||
637 | |||
638 | if (1 === $table_uploadimage || 1 === $table_uploadfile) { |
||
639 | $ret .= $this->getXoopsVersionSelectSizeMB($moduleDirname); |
||
640 | } |
||
641 | if (1 === $table_uploadimage) { |
||
642 | $ret .= $pc->getPhpCodeCommentLine('Uploads : maxsize of image'); |
||
643 | $maxsize_image = [ |
||
644 | 'name' => "'maxsize_image'", |
||
645 | 'title' => "'{$language}MAXSIZE_IMAGE'", |
||
646 | 'description' => "'{$language}MAXSIZE_IMAGE_DESC'", |
||
647 | 'formtype' => "'select'", |
||
648 | 'valuetype' => "'int'", |
||
649 | 'default' => '3145728', |
||
650 | 'options' => '$optionMaxsize', |
||
651 | ]; |
||
652 | $ret .= $uxc->getUserModVersionArray(2, $maxsize_image, 'config'); |
||
653 | $ret .= $pc->getPhpCodeCommentLine('Uploads : mimetypes of image'); |
||
654 | $mimetypes_image = [ |
||
655 | 'name' => "'mimetypes_image'", |
||
656 | 'title' => "'{$language}MIMETYPES_IMAGE'", |
||
657 | 'description' => "'{$language}MIMETYPES_IMAGE_DESC'", |
||
658 | 'formtype' => "'select_multi'", |
||
659 | 'valuetype' => "'array'", |
||
660 | 'default' => "['image/gif', 'image/jpeg', 'image/png']", |
||
661 | 'options' => "['bmp' => 'image/bmp','gif' => 'image/gif','pjpeg' => 'image/pjpeg', 'jpeg' => 'image/jpeg','jpg' => 'image/jpg','jpe' => 'image/jpe', 'png' => 'image/png']", |
||
662 | ]; |
||
663 | $ret .= $uxc->getUserModVersionArray(2, $mimetypes_image, 'config'); |
||
664 | $maxwidth_image = [ |
||
665 | 'name' => "'maxwidth_image'", |
||
666 | 'title' => "'{$language}MAXWIDTH_IMAGE'", |
||
667 | 'description' => "'{$language}MAXWIDTH_IMAGE_DESC'", |
||
668 | 'formtype' => "'textbox'", |
||
669 | 'valuetype' => "'int'", |
||
670 | 'default' => '8000', |
||
671 | ]; |
||
672 | $ret .= $uxc->getUserModVersionArray(2, $maxwidth_image, 'config'); |
||
673 | $maxheight_image = [ |
||
674 | 'name' => "'maxheight_image'", |
||
675 | 'title' => "'{$language}MAXHEIGHT_IMAGE'", |
||
676 | 'description' => "'{$language}MAXHEIGHT_IMAGE_DESC'", |
||
677 | 'formtype' => "'textbox'", |
||
678 | 'valuetype' => "'int'", |
||
679 | 'default' => '8000', |
||
680 | ]; |
||
681 | $ret .= $uxc->getUserModVersionArray(2, $maxheight_image, 'config'); |
||
682 | } |
||
683 | if (1 === $table_uploadfile) { |
||
684 | $ret .= $pc->getPhpCodeCommentLine('Uploads : maxsize of file'); |
||
685 | $maxsize_file = [ |
||
686 | 'name' => "'maxsize_file'", |
||
687 | 'title' => "'{$language}MAXSIZE_FILE'", |
||
688 | 'description' => "'{$language}MAXSIZE_FILE_DESC'", |
||
689 | 'formtype' => "'select'", |
||
690 | 'valuetype' => "'int'", |
||
691 | 'default' => '3145728', |
||
692 | 'options' => '$optionMaxsize', |
||
693 | ]; |
||
694 | $ret .= $uxc->getUserModVersionArray(2, $maxsize_file, 'config'); |
||
695 | $ret .= $pc->getPhpCodeCommentLine('Uploads : mimetypes of file'); |
||
696 | $mimetypes_file = [ |
||
697 | 'name' => "'mimetypes_file'", |
||
698 | 'title' => "'{$language}MIMETYPES_FILE'", |
||
699 | 'description' => "'{$language}MIMETYPES_FILE_DESC'", |
||
700 | 'formtype' => "'select_multi'", |
||
701 | 'valuetype' => "'array'", |
||
702 | 'default' => "['application/pdf', 'application/zip', 'text/comma-separated-values', 'text/plain', 'image/gif', 'image/jpeg', 'image/png']", |
||
703 | 'options' => "['gif' => 'image/gif','pjpeg' => 'image/pjpeg', 'jpeg' => 'image/jpeg','jpg' => 'image/jpg','jpe' => 'image/jpe', 'png' => 'image/png', 'pdf' => 'application/pdf','zip' => 'application/zip','csv' => 'text/comma-separated-values', 'txt' => 'text/plain', 'xml' => 'application/xml', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']", |
||
704 | ]; |
||
705 | $ret .= $uxc->getUserModVersionArray(2, $mimetypes_file, 'config'); |
||
706 | } |
||
707 | if (1 === $table_admin) { |
||
708 | $ret .= $pc->getPhpCodeCommentLine('Admin pager'); |
||
709 | $adminPager = [ |
||
710 | 'name' => "'adminpager'", |
||
711 | 'title' => "'{$language}ADMIN_PAGER'", |
||
712 | 'description' => "'{$language}ADMIN_PAGER_DESC'", |
||
713 | 'formtype' => "'textbox'", |
||
714 | 'valuetype' => "'int'", |
||
715 | 'default' => '10', |
||
716 | ]; |
||
717 | $ret .= $uxc->getUserModVersionArray(2, $adminPager, 'config'); |
||
718 | } |
||
719 | if (1 === $table_user) { |
||
720 | $ret .= $pc->getPhpCodeCommentLine('User pager'); |
||
721 | $userPager = [ |
||
722 | 'name' => "'userpager'", |
||
723 | 'title' => "'{$language}USER_PAGER'", |
||
724 | 'description' => "'{$language}USER_PAGER_DESC'", |
||
725 | 'formtype' => "'textbox'", |
||
726 | 'valuetype' => "'int'", |
||
727 | 'default' => '10', |
||
728 | ]; |
||
729 | $ret .= $uxc->getUserModVersionArray(2, $userPager, 'config'); |
||
730 | } |
||
731 | if (1 === $table_tag) { |
||
732 | $ret .= $pc->getPhpCodeCommentLine('Use tag'); |
||
733 | $useTag = [ |
||
734 | 'name' => "'usetag'", |
||
735 | 'title' => "'{$language}USE_TAG'", |
||
736 | 'description' => "'{$language}USE_TAG_DESC'", |
||
737 | 'formtype' => "'yesno'", |
||
738 | 'valuetype' => "'int'", |
||
739 | 'default' => '0', |
||
740 | ]; |
||
741 | $ret .= $uxc->getUserModVersionArray(2, $useTag, 'config'); |
||
742 | } |
||
743 | $ret .= $pc->getPhpCodeCommentLine('Number column'); |
||
744 | $numbCol = [ |
||
745 | 'name' => "'numb_col'", |
||
746 | 'title' => "'{$language}NUMB_COL'", |
||
747 | 'description' => "'{$language}NUMB_COL_DESC'", |
||
748 | 'formtype' => "'select'", |
||
749 | 'valuetype' => "'int'", |
||
750 | 'default' => '1', |
||
751 | 'options' => "[1 => '1', 2 => '2', 3 => '3', 4 => '4']", |
||
752 | ]; |
||
753 | $ret .= $uxc->getUserModVersionArray(2, $numbCol, 'config'); |
||
754 | |||
755 | $ret .= $pc->getPhpCodeCommentLine('Divide by'); |
||
756 | $divideby = [ |
||
757 | 'name' => "'divideby'", |
||
758 | 'title' => "'{$language}DIVIDEBY'", |
||
759 | 'description' => "'{$language}DIVIDEBY_DESC'", |
||
760 | 'formtype' => "'select'", |
||
761 | 'valuetype' => "'int'", |
||
762 | 'default' => '1', |
||
763 | 'options' => "[1 => '1', 2 => '2', 3 => '3', 4 => '4']", |
||
764 | ]; |
||
765 | $ret .= $uxc->getUserModVersionArray(2, $divideby, 'config'); |
||
766 | |||
767 | $ret .= $pc->getPhpCodeCommentLine('Table type'); |
||
768 | $tableType = [ |
||
769 | 'name' => "'table_type'", |
||
770 | 'title' => "'{$language}TABLE_TYPE'", |
||
771 | 'description' => "'{$language}DIVIDEBY_DESC'", |
||
772 | 'formtype' => "'select'", |
||
773 | 'valuetype' => "'int'", |
||
774 | 'default' => "'bordered'", |
||
775 | 'options' => "['bordered' => 'bordered', 'striped' => 'striped', 'hover' => 'hover', 'condensed' => 'condensed']", |
||
776 | ]; |
||
777 | $ret .= $uxc->getUserModVersionArray(2, $tableType, 'config'); |
||
778 | |||
779 | $ret .= $pc->getPhpCodeCommentLine('Panel by'); |
||
780 | $panelType = [ |
||
781 | 'name' => "'panel_type'", |
||
782 | 'title' => "'{$language}PANEL_TYPE'", |
||
783 | 'description' => "'{$language}PANEL_TYPE_DESC'", |
||
784 | 'formtype' => "'select'", |
||
785 | 'valuetype' => "'text'", |
||
786 | 'default' => "'default'", |
||
787 | 'options' => "['default' => 'default', 'primary' => 'primary', 'success' => 'success', 'info' => 'info', 'warning' => 'warning', 'danger' => 'danger']", |
||
788 | ]; |
||
789 | $ret .= $uxc->getUserModVersionArray(2, $panelType, 'config'); |
||
790 | |||
791 | $ret .= $pc->getPhpCodeCommentLine('Advertise'); |
||
792 | $advertise = [ |
||
793 | 'name' => "'advertise'", |
||
794 | 'title' => "'{$language}ADVERTISE'", |
||
795 | 'description' => "'{$language}ADVERTISE_DESC'", |
||
796 | 'formtype' => "'textarea'", |
||
797 | 'valuetype' => "'text'", |
||
798 | 'default' => "''", |
||
799 | ]; |
||
800 | $ret .= $uxc->getUserModVersionArray(2, $advertise, 'config'); |
||
801 | |||
802 | $ret .= $pc->getPhpCodeCommentLine('Bookmarks'); |
||
803 | $bookmarks = [ |
||
804 | 'name' => "'bookmarks'", |
||
805 | 'title' => "'{$language}BOOKMARKS'", |
||
806 | 'description' => "'{$language}BOOKMARKS_DESC'", |
||
807 | 'formtype' => "'yesno'", |
||
808 | 'valuetype' => "'int'", |
||
809 | 'default' => '0', |
||
810 | ]; |
||
811 | $ret .= $uxc->getUserModVersionArray(2, $bookmarks, 'config'); |
||
812 | |||
813 | /* |
||
814 | * removed, as there are no system templates in xoops core for fb or disqus comments |
||
815 | * modulebuilder currently is also not creatings tpl files for this |
||
816 | $ret .= $pc->getPhpCodeCommentLine('Facebook Comments'); |
||
817 | $facebookComments = [ |
||
818 | 'name' => "'facebook_comments'", |
||
819 | 'title' => "'{$language}FACEBOOK_COMMENTS'", |
||
820 | 'description' => "'{$language}FACEBOOK_COMMENTS_DESC'", |
||
821 | 'formtype' => "'yesno'", |
||
822 | 'valuetype' => "'int'", |
||
823 | 'default' => '0', |
||
824 | ]; |
||
825 | $ret .= $uxc->getUserModVersion(3, $facebookComments, 'config', '$c'); |
||
826 | $ret .= $this->getSimpleString('++$c;'); |
||
827 | $ret .= $pc->getPhpCodeCommentLine('Disqus Comments'); |
||
828 | $disqusComments = [ |
||
829 | 'name' => "'disqus_comments'", |
||
830 | 'title' => "'{$language}DISQUS_COMMENTS'", |
||
831 | 'description' => "'{$language}DISQUS_COMMENTS_DESC'", |
||
832 | 'formtype' => "'yesno'", |
||
833 | 'valuetype' => "'int'", |
||
834 | 'default' => '0', |
||
835 | ]; |
||
836 | $ret .= $uxc->getUserModVersion(3, $disqusComments, 'config', '$c'); |
||
837 | $ret .= $this->getSimpleString('++$c;'); |
||
838 | */ |
||
839 | |||
840 | $ret .= $pc->getPhpCodeCommentLine('Make Sample button visible?'); |
||
841 | $maintainedby = [ |
||
842 | 'name' => "'displaySampleButton'", |
||
843 | 'title' => "'CO_' . \$moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON'", |
||
844 | 'description' => "'CO_' . \$moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC'", |
||
845 | 'formtype' => "'yesno'", |
||
846 | 'valuetype' => "'int'", |
||
847 | 'default' => '1', |
||
848 | ]; |
||
849 | $ret .= $uxc->getUserModVersionArray(2, $maintainedby, 'config'); |
||
850 | |||
851 | $ret .= $pc->getPhpCodeCommentLine('Maintained by'); |
||
852 | $maintainedby = [ |
||
853 | 'name' => "'maintainedby'", |
||
854 | 'title' => "'{$language}MAINTAINEDBY'", |
||
855 | 'description' => "'{$language}MAINTAINEDBY_DESC'", |
||
856 | 'formtype' => "'textbox'", |
||
857 | 'valuetype' => "'text'", |
||
858 | 'default' => "'{$module->getVar('mod_support_url')}'", |
||
859 | ]; |
||
860 | $ret .= $uxc->getUserModVersionArray(2, $maintainedby, 'config'); |
||
861 | |||
862 | return $ret; |
||
863 | } |
||
864 | |||
865 | /** |
||
866 | * @private function getNotificationsType |
||
867 | * @param $language |
||
868 | * @param $type |
||
869 | * @param $tableName |
||
870 | * @param $notifyFile |
||
871 | * @param $item |
||
872 | * @param $typeOfNotify |
||
873 | * |
||
874 | * @return string |
||
875 | */ |
||
876 | private function getNotificationsType($language, $type, $tableName, $notifyFile, $item, $typeOfNotify) |
||
915 | } |
||
916 | |||
917 | /** |
||
918 | * @private function getXoopsVersionNotifications |
||
919 | * @param $module |
||
920 | * @param $language |
||
921 | * @return string |
||
922 | */ |
||
923 | private function getXoopsVersionNotifications($module, $language) |
||
924 | { |
||
925 | $uxc = UserXoopsCode::getInstance(); |
||
926 | $moduleDirname = $module->getVar('mod_dirname'); |
||
927 | $ret = $this->getDashComment('Notifications'); |
||
928 | $ret .= $uxc->getUserModVersionText(1, 1, 'hasNotification'); |
||
929 | $notifications = ['lookup_file' => "'include/notification.inc.php'", 'lookup_func' => "'{$moduleDirname}_notify_iteminfo'"]; |
||
930 | $ret .= $uxc->getUserModVersionArray(1, $notifications, 'notification'); |
||
931 | |||
932 | $notifyFiles = []; |
||
933 | $single = 'single'; |
||
934 | $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
||
935 | $tableCategory = []; |
||
936 | $tableBroken = []; |
||
937 | $tableSubmit = []; |
||
938 | $tableId = null; |
||
939 | $tableMid = null; |
||
940 | $tableSoleName = ''; |
||
941 | $notifyCategory = ''; |
||
942 | $notifyEvent =''; |
||
943 | |||
944 | //global events |
||
945 | $notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_new', 'global', 0, 'global_new', 'global_' . 'new_notify'); |
||
946 | $notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_modify', 'global', 0, 'global_modify', 'global_' . 'modify_notify'); |
||
947 | $notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_delete', 'global', 0, 'global_delete', 'global_' . 'delete_notify'); |
||
948 | $notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_approve', 'global', 0, 'global_approve', 'global_' . 'approve_notify'); |
||
949 | $notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_broken', 'global', 0, 'global_broken', 'global_' . 'broken_notify'); |
||
950 | |||
951 | foreach (array_keys($tables) as $t) { |
||
952 | $tableId = $tables[$t]->getVar('table_id'); |
||
953 | $tableMid = $tables[$t]->getVar('table_mid'); |
||
954 | $tableName = $tables[$t]->getVar('table_name'); |
||
955 | $tableSoleName = $tables[$t]->getVar('table_solename'); |
||
956 | $tableCategory[] = $tables[$t]->getVar('table_category'); |
||
957 | $tableBroken[] = $tables[$t]->getVar('table_broken'); |
||
958 | $tableSubmit[] = $tables[$t]->getVar('table_submit'); |
||
959 | $fields = $this->getTableFields($tableMid, $tableId); |
||
960 | $fieldId = null; |
||
961 | $fieldParent = null; |
||
962 | foreach (array_keys($fields) as $f) { |
||
963 | $fieldName = $fields[$f]->getVar('field_name'); |
||
964 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
965 | if (0 == $f) { |
||
966 | $fieldId = $fieldName; |
||
967 | } |
||
968 | if ($fieldElement > 16) { |
||
969 | $fieldParent = $fieldName; |
||
970 | } |
||
971 | } |
||
972 | if (1 == $tables[$t]->getVar('table_single')) { |
||
973 | $single = $tableName; |
||
974 | } |
||
975 | if (1 == $tables[$t]->getVar('table_notifications')) { |
||
976 | $notifyFiles[] = $tableName; |
||
977 | $notifyCategory .= $this->getXoopsVersionNotificationTableName($language, 'category', $tableName, $tableSoleName, $single, $fieldId, 1); |
||
978 | $notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_new', $tableName, 0, $tableSoleName, $tableSoleName . '_new_notify'); |
||
979 | $notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_modify', $tableName, 0, $tableSoleName, $tableSoleName . '_modify_notify'); |
||
980 | $notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_delete', $tableName, 0, $tableSoleName, $tableSoleName . '_delete_notify'); |
||
981 | $notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_approve', $tableName, 0, $tableSoleName, $tableSoleName . '_approve_notify'); |
||
982 | } |
||
983 | if (1 == $tables[$t]->getVar('table_broken')) { |
||
984 | $notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_broken', $tableName, 0, $tableSoleName . '_broken', $tableSoleName . '_broken_notify'); |
||
985 | } |
||
986 | } |
||
987 | |||
988 | |||
989 | |||
990 | $ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', 'global', $notifyFiles); |
||
991 | |||
992 | //$ret .= $this->getXoopsVersionNotificationCategory($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1'); |
||
993 | |||
994 | $ret .= $notifyCategory . $notifyEvent; |
||
995 | |||
996 | /* |
||
997 | $num = 1; |
||
998 | if (in_array(1, $tableCategory)) { |
||
999 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'global', 0, 'global_new_category', 'global_newcategory_notify'); |
||
1000 | ++$num; |
||
1001 | } |
||
1002 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'modify', 'global', 1, 'global_modify', 'global_' . 'modify_notify'); |
||
1003 | if (in_array(1, $tableBroken)) { |
||
1004 | ++$num; |
||
1005 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'broken', 'global', 1, 'global_broken', 'global_' . 'broken_notify'); |
||
1006 | } |
||
1007 | if (in_array(1, $tableSubmit)) { |
||
1008 | ++$num; |
||
1009 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'submit', 'global', 1, 'global_submit', 'global_' . 'submit_notify'); |
||
1010 | } |
||
1011 | ++$num; |
||
1012 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_' . $tableSoleName, 'global', 0, 'global_new', 'global_new' . $tableSoleName . '_notify'); |
||
1013 | if (in_array(1, $tableCategory)) { |
||
1014 | ++$num; |
||
1015 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'submit', 'category', 1, 'category_submit', 'category_' . $tableSoleName . 'submit_notify'); |
||
1016 | ++$num; |
||
1017 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'category', 0, 'category', 'category_new' . $tableSoleName . '_notify'); |
||
1018 | } |
||
1019 | ++$num; |
||
1020 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'approve', $tableSoleName, 1, $tableSoleName, $tableSoleName . '_approve_notify'); |
||
1021 | unset($num); |
||
1022 | */ |
||
1023 | |||
1024 | return $ret; |
||
1025 | } |
||
1026 | |||
1027 | /** |
||
1028 | * @private function getXoopsVersionNotificationGlobal |
||
1029 | * @param $language |
||
1030 | * @param $type |
||
1031 | * @param $name |
||
1032 | * @param $title |
||
1033 | * @param $from |
||
1034 | * |
||
1035 | * @param $num |
||
1036 | * @return string |
||
1037 | */ |
||
1038 | private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from) |
||
1039 | { |
||
1040 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||
1041 | $uxc = UserXoopsCode::getInstance(); |
||
1042 | $title = mb_strtoupper($title); |
||
1043 | $implodeFrom = implode(".php', '", $from); |
||
1044 | $ret = $pc->getPhpCodeCommentLine('Global Notify'); |
||
1045 | $global = [ |
||
1046 | 'name' => "'{$name}'", |
||
1047 | 'title' => "{$language}{$title}_NOTIFY", |
||
1048 | 'description' => "{$language}{$title}_NOTIFY_DESC", |
||
1049 | 'subscribe_from' => "['index.php', '{$implodeFrom}.php']", |
||
1050 | ]; |
||
1051 | $ret .= $uxc->getUserModVersionArray(3, $global, 'notification', "'{$type}'"); |
||
1052 | |||
1053 | return $ret; |
||
1054 | } |
||
1055 | |||
1056 | /** |
||
1057 | * @private function getXoopsVersionNotificationCategory |
||
1058 | * @param $language |
||
1059 | * @param $type |
||
1060 | * @param $name |
||
1061 | * @param $title |
||
1062 | * @param $file |
||
1063 | * @param $item |
||
1064 | * @param $allow |
||
1065 | * @param $num |
||
1066 | * @return string |
||
1067 | */ |
||
1068 | private function getXoopsVersionNotificationCategory($language, $type, $name, $title, $file, $item, $allow) |
||
1086 | } |
||
1087 | |||
1088 | /** |
||
1089 | * @private function getXoopsVersionNotificationTableName |
||
1090 | * @param $language |
||
1091 | * @param $type |
||
1092 | * @param $name |
||
1093 | * @param $title |
||
1094 | * @param $file |
||
1095 | * @param $item |
||
1096 | * @param $allow |
||
1097 | * |
||
1098 | * @param $num |
||
1099 | * @return string |
||
1100 | */ |
||
1101 | private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $file, $item, $allow) |
||
1102 | { |
||
1103 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||
1104 | $uxc = UserXoopsCode::getInstance(); |
||
1105 | $stuTitle = mb_strtoupper($title); |
||
1106 | $ucfTitle = ucfirst($title); |
||
1107 | $ret = $pc->getPhpCodeCommentLine($ucfTitle . ' Notify'); |
||
1108 | $table = [ |
||
1109 | 'name' => "'{$name}'", |
||
1110 | 'title' => "{$language}{$stuTitle}_NOTIFY", |
||
1111 | 'description' => "''", |
||
1112 | 'subscribe_from' => "'{$file}.php'", |
||
1113 | 'item_name' => "'{$item}'", |
||
1114 | 'allow_bookmark' => (string)$allow, |
||
1115 | ]; |
||
1116 | $ret .= $uxc->getUserModVersionArray(3, $table, 'notification', "'{$type}'"); |
||
1117 | |||
1118 | return $ret; |
||
1119 | } |
||
1120 | |||
1121 | /** |
||
1122 | * @private function getXoopsVersionNotifications |
||
1123 | * @param $language |
||
1124 | * @param $type |
||
1125 | * @param $name |
||
1126 | * @param $category |
||
1127 | * @param $admin |
||
1128 | * @param $title |
||
1129 | * @param $mail |
||
1130 | * |
||
1131 | * @param $num |
||
1132 | * @return string |
||
1133 | */ |
||
1134 | private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin, $title, $mail) |
||
1135 | { |
||
1136 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||
1137 | $uxc = UserXoopsCode::getInstance(); |
||
1138 | $title = mb_strtoupper($title); |
||
1139 | $ucfTitle = ucfirst($title); |
||
1140 | $ret = $pc->getPhpCodeCommentLine($ucfTitle . ' Notify'); |
||
1141 | $event = [ |
||
1142 | 'name' => "'{$name}'", |
||
1143 | 'category' => "'{$category}'", |
||
1144 | 'admin_only' => (string)$admin, |
||
1145 | 'title' => "{$language}{$title}_NOTIFY", |
||
1146 | 'caption' => "{$language}{$title}_NOTIFY_CAPTION", |
||
1147 | 'description' => "''", |
||
1148 | 'mail_template' => "'{$mail}'", |
||
1149 | 'mail_subject' => "{$language}{$title}_NOTIFY_SUBJECT", |
||
1150 | ]; |
||
1151 | $ret .= $uxc->getUserModVersionArray(3, $event, 'notification', "'{$type}'"); |
||
1152 | |||
1153 | return $ret; |
||
1154 | } |
||
1155 | |||
1156 | /** |
||
1157 | * @private function getXoopsVersionNotifications |
||
1158 | * @param $moduleDirname |
||
1159 | * @param string $t |
||
1160 | * @return string |
||
1161 | */ |
||
1162 | private function getXoopsVersionSelectSizeMB($moduleDirname, $t = '') |
||
1163 | { |
||
1164 | $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||
1165 | $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||
1166 | $ucModuleDirname = mb_strtoupper($moduleDirname); |
||
1167 | |||
1168 | $ret = $pc->getPhpCodeCommentLine('create increment steps for file size'); |
||
1169 | $ret .= $pc->getPhpCodeIncludeDir("__DIR__ . '/include/xoops_version.inc.php'", '',true,true); |
||
1170 | $ret .= $xc->getXcEqualsOperator('$iniPostMaxSize ', "{$moduleDirname}ReturnBytes(ini_get('post_max_size'))"); |
||
1171 | $ret .= $xc->getXcEqualsOperator('$iniUploadMaxFileSize', "{$moduleDirname}ReturnBytes(ini_get('upload_max_filesize'))"); |
||
1172 | $ret .= $xc->getXcEqualsOperator('$maxSize ', "min(\$iniPostMaxSize, \$iniUploadMaxFileSize)"); |
||
1173 | $cond = $xc->getXcEqualsOperator('$increment', '500', null, $t . "\t"); |
||
1174 | $ret .= $pc->getPhpCodeConditions('$maxSize', ' > ', '10000 * 1048576', $cond, false, $t); |
||
1175 | $cond = $xc->getXcEqualsOperator('$increment', '200', null, $t . "\t"); |
||
1176 | $ret .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '10000 * 1048576', $cond, false, $t); |
||
1177 | $cond = $xc->getXcEqualsOperator('$increment', '100', null, $t . "\t"); |
||
1178 | $ret .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '5000 * 1048576', $cond, false, $t); |
||
1179 | $cond = $xc->getXcEqualsOperator('$increment', '50', null, $t . "\t"); |
||
1180 | $ret .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '2500 * 1048576', $cond, false, $t); |
||
1181 | $cond = $xc->getXcEqualsOperator('$increment', '10', null, $t . "\t"); |
||
1182 | $ret .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '1000 * 1048576', $cond, false, $t); |
||
1183 | $cond = $xc->getXcEqualsOperator('$increment', '5', null, $t . "\t"); |
||
1184 | $ret .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '500 * 1048576', $cond, false, $t); |
||
1185 | $cond = $xc->getXcEqualsOperator('$increment', '2', null, $t . "\t"); |
||
1186 | $ret .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '100 * 1048576', $cond, false, $t); |
||
1187 | $cond = $xc->getXcEqualsOperator('$increment', '1', null, $t . "\t"); |
||
1188 | $ret .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '50 * 1048576', $cond, false, $t); |
||
1189 | $cond = $xc->getXcEqualsOperator('$increment', '0.5', null, $t . "\t"); |
||
1190 | $ret .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '25 * 1048576', $cond, false, $t); |
||
1191 | $ret .= $xc->getXcEqualsOperator('$optionMaxsize', '[]'); |
||
1192 | $ret .= $xc->getXcEqualsOperator('$i', '$increment'); |
||
1193 | $while = $xc->getXcEqualsOperator("\$optionMaxsize[\$i . ' ' . _MI_{$ucModuleDirname}_SIZE_MB]", '$i * 1048576', null, $t . "\t"); |
||
1194 | $while .= $xc->getXcEqualsOperator('$i', '$increment', '+',$t . "\t"); |
||
1195 | $ret .= $pc->getPhpCodeWhile('i * 1048576', $while, '$maxSize', ' <= '); |
||
1196 | |||
1197 | return $ret; |
||
1198 | } |
||
1199 | |||
1200 | /** |
||
1201 | * @public function render |
||
1202 | * @param null |
||
1203 | * @return bool|string |
||
1204 | */ |
||
1205 | public function render() |
||
1248 | } |
||
1249 | } |
||
1250 |