Total Complexity | 103 |
Total Lines | 1236 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
33 | class UserXoopsVersion extends Files\CreateFile |
||
34 | { |
||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private $kw = []; |
||
39 | |||
40 | /** |
||
41 | * @var mixed |
||
42 | */ |
||
43 | private $uxc = null; |
||
44 | |||
45 | /** |
||
46 | * @var mixed |
||
47 | */ |
||
48 | private $xc = null; |
||
49 | |||
50 | /** |
||
51 | * @var mixed |
||
52 | */ |
||
53 | private $pc = null; |
||
54 | |||
55 | /** |
||
56 | * @public function constructor |
||
57 | * @param null |
||
58 | */ |
||
59 | public function __construct() |
||
60 | { |
||
61 | parent::__construct(); |
||
62 | $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
||
63 | $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||
64 | $this->uxc = Modulebuilder\Files\User\UserXoopsCode::getInstance(); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @static function getInstance |
||
69 | * @param null |
||
70 | * @return UserXoopsVersion |
||
71 | */ |
||
72 | public static function getInstance() |
||
73 | { |
||
74 | static $instance = false; |
||
75 | if (!$instance) { |
||
76 | $instance = new self(); |
||
77 | } |
||
78 | |||
79 | return $instance; |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @public function write |
||
84 | * @param $module |
||
85 | * @param mixed $table |
||
86 | * @param mixed $tables |
||
87 | * @param $filename |
||
88 | */ |
||
89 | public function write($module, $table, $tables, $filename) |
||
90 | { |
||
91 | $this->setModule($module); |
||
92 | $this->setTable($table); |
||
93 | $this->setTables($tables); |
||
94 | $this->setFileName($filename); |
||
95 | foreach (\array_keys($tables) as $t) { |
||
96 | $tableName = $tables[$t]->getVar('table_name'); |
||
97 | $this->setKeywords($tableName); |
||
98 | } |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * @public function setKeywords |
||
103 | * @param mixed $keywords |
||
104 | */ |
||
105 | public function setKeywords($keywords) |
||
106 | { |
||
107 | if (\is_array($keywords)) { |
||
108 | $this->kw = $keywords; |
||
109 | } else { |
||
110 | $this->kw[] = $keywords; |
||
111 | } |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @public function getKeywords |
||
116 | * @param null |
||
117 | * @return array |
||
118 | */ |
||
119 | public function getKeywords() |
||
120 | { |
||
121 | return $this->kw; |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * @private function getXoopsVersionHeader |
||
126 | * @param $module |
||
127 | * @param $language |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | private function getXoopsVersionHeader($module, $language) |
||
132 | { |
||
133 | $date = date('Y/m/d'); |
||
134 | $ret = $this->getSimpleString(''); |
||
135 | $ret .= Modulebuilder\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine(); |
||
136 | $ret .= $this->xc->getXcEqualsOperator('$moduleDirName ', '\basename(__DIR__)'); |
||
137 | $ret .= $this->xc->getXcEqualsOperator('$moduleDirNameUpper', '\mb_strtoupper($moduleDirName)'); |
||
138 | $ret .= $this->getDashComment('Informations'); |
||
139 | $ha = (1 == $module->getVar('mod_admin')) ? 1 : 0; |
||
140 | $hm = (1 == $module->getVar('mod_user')) ? 1 : 0; |
||
141 | |||
142 | $descriptions = [ |
||
143 | 'name' => "{$language}NAME", |
||
144 | 'version' => "'" . (string)$module->getVar('mod_version') . "'", |
||
145 | 'description' => "{$language}DESC", |
||
146 | 'author' => "'{$module->getVar('mod_author')}'", |
||
147 | 'author_mail' => "'{$module->getVar('mod_author_mail')}'", |
||
148 | 'author_website_url' => "'{$module->getVar('mod_author_website_url')}'", |
||
149 | 'author_website_name' => "'{$module->getVar('mod_author_website_name')}'", |
||
150 | 'credits' => "'{$module->getVar('mod_credits')}'", |
||
151 | 'license' => "'{$module->getVar('mod_license')}'", |
||
152 | 'license_url' => "'https://www.gnu.org/licenses/gpl-3.0.en.html'", |
||
153 | 'help' => "'page=help'", |
||
154 | 'release_info' => "'{$module->getVar('mod_release_info')}'", |
||
155 | 'release_file' => "\XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_release_file')}'", |
||
156 | 'release_date' => "'{$date}'", |
||
157 | 'manual' => "'{$module->getVar('mod_manual')}'", |
||
158 | 'manual_file' => "\XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_manual_file')}'", |
||
159 | 'min_php' => "'{$module->getVar('mod_min_php')}'", |
||
160 | 'min_xoops' => "'{$module->getVar('mod_min_xoops')}'", |
||
161 | 'min_admin' => "'{$module->getVar('mod_min_admin')}'", |
||
162 | 'min_db' => "['mysql' => '{$module->getVar('mod_min_mysql')}', 'mysqli' => '{$module->getVar('mod_min_mysql')}']", |
||
163 | 'image' => "'assets/images/logoModule.png'", |
||
164 | 'dirname' => '\basename(__DIR__)', |
||
165 | 'dirmoduleadmin' => "'Frameworks/moduleclasses/moduleadmin'", |
||
166 | 'sysicons16' => "'../../Frameworks/moduleclasses/icons/16'", |
||
167 | 'sysicons32' => "'../../Frameworks/moduleclasses/icons/32'", |
||
168 | 'modicons16' => "'assets/icons/16'", |
||
169 | 'modicons32' => "'assets/icons/32'", |
||
170 | 'demo_site_url' => "'{$module->getVar('mod_demo_site_url')}'", |
||
171 | 'demo_site_name' => "'{$module->getVar('mod_demo_site_name')}'", |
||
172 | 'support_url' => "'{$module->getVar('mod_support_url')}'", |
||
173 | 'support_name' => "'{$module->getVar('mod_support_name')}'", |
||
174 | 'module_website_url' => "'{$module->getVar('mod_website_url')}'", |
||
175 | 'module_website_name' => "'{$module->getVar('mod_website_name')}'", |
||
176 | 'release' => "'{$module->getVar('mod_release')}'", |
||
177 | 'module_status' => "'{$module->getVar('mod_status')}'", |
||
178 | 'system_menu' => '1', |
||
179 | 'hasAdmin' => $ha, |
||
180 | 'hasMain' => $hm, |
||
181 | 'adminindex' => "'admin/index.php'", |
||
182 | 'adminmenu' => "'admin/menu.php'", |
||
183 | 'onInstall' => "'include/install.php'", |
||
184 | 'onUninstall' => "'include/uninstall.php'", |
||
185 | 'onUpdate' => "'include/update.php'", |
||
186 | ]; |
||
187 | |||
188 | $ret .= $this->uxc->getUserModVersionArray(0, $descriptions); |
||
189 | |||
190 | return $ret; |
||
191 | } |
||
192 | |||
193 | /** |
||
194 | * @private function getXoopsVersionMySQL |
||
195 | * @param $moduleDirname |
||
196 | * @param $table |
||
197 | * @param $tables |
||
198 | * @return string |
||
199 | */ |
||
200 | private function getXoopsVersionMySQL($moduleDirname, $table, $tables) |
||
201 | { |
||
202 | $tableName = $table->getVar('table_name'); |
||
203 | $n = 1; |
||
204 | $ret = ''; |
||
205 | $items = []; |
||
206 | $tableRate = 0; |
||
207 | if (!empty($tableName)) { |
||
208 | $ret .= $this->getDashComment('Mysql'); |
||
209 | $description = "'sql/mysql.sql'"; |
||
210 | $ret .= $this->uxc->getUserModVersionText(2, $description, 'sqlfile', "'mysql'"); |
||
211 | $ret .= Modulebuilder\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Tables'); |
||
212 | |||
213 | foreach (\array_keys($tables) as $t) { |
||
214 | $items[] = "'{$moduleDirname}_{$tables[$t]->getVar('table_name')}'"; |
||
215 | if (1 === (int)$tables[$t]->getVar('table_rate')) { |
||
216 | $tableRate = 1; |
||
217 | } |
||
218 | ++$n; |
||
219 | } |
||
220 | if (1 === $tableRate) { |
||
221 | $items[] = "'{$moduleDirname}_ratings'"; |
||
222 | ++$n; |
||
223 | } |
||
224 | $ret .= $this->uxc->getUserModVersionArray(11, $items, 'tables', $n); |
||
225 | unset($n); |
||
226 | } |
||
227 | |||
228 | return $ret; |
||
229 | } |
||
230 | |||
231 | /** |
||
232 | * @private function getXoopsVersionSearch |
||
233 | * @param $moduleDirname |
||
234 | * |
||
235 | * @return string |
||
236 | */ |
||
237 | private function getXoopsVersionSearch($moduleDirname) |
||
245 | } |
||
246 | |||
247 | /** |
||
248 | * @private function getXoopsVersionComments |
||
249 | * @param $moduleDirname |
||
250 | * |
||
251 | * @param $tables |
||
252 | * @return string |
||
253 | */ |
||
254 | private function getXoopsVersionComments($moduleDirname, $tables) |
||
255 | { |
||
256 | $tableName = ''; |
||
257 | $fieldId = ''; |
||
258 | foreach (\array_keys($tables) as $t) { |
||
259 | if (1 == $tables[$t]->getVar('table_comments')) { |
||
260 | $tableName = $tables[$t]->getVar('table_name'); |
||
261 | $fields = $this->getTableFields($tables[$t]->getVar('table_mid'), $tables[$t]->getVar('table_id')); |
||
262 | foreach (\array_keys($fields) as $f) { |
||
263 | $fieldName = $fields[$f]->getVar('field_name'); |
||
264 | if (0 == $f) { |
||
265 | $fieldId = $fieldName; |
||
266 | } |
||
267 | } |
||
268 | } |
||
269 | } |
||
270 | $ret = $this->getDashComment('Comments'); |
||
271 | $ret .= $this->uxc->getUserModVersionText(1, "1", 'hasComments'); |
||
272 | $ret .= $this->uxc->getUserModVersionText(2, "'{$tableName}.php'", 'comments', "'pageName'"); |
||
273 | $ret .= $this->uxc->getUserModVersionText(2, "'{$fieldId}'", 'comments', "'itemName'"); |
||
274 | $ret .= Modulebuilder\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Comment callback functions'); |
||
275 | $ret .= $this->uxc->getUserModVersionText(2, "'include/comment_functions.php'", 'comments', "'callbackFile'"); |
||
276 | $descriptions = ['approve' => "'{$moduleDirname}CommentsApprove'", 'update' => "'{$moduleDirname}CommentsUpdate'"]; |
||
277 | $ret .= $this->uxc->getUserModVersionArray(2, $descriptions, 'comments', "'callback'"); |
||
278 | |||
279 | return $ret; |
||
280 | } |
||
281 | |||
282 | /** |
||
283 | * @private function getXoopsVersionTemplatesAdminUser |
||
284 | * @param $moduleDirname |
||
285 | * @param $tables |
||
286 | * |
||
287 | * @param $admin |
||
288 | * @param $user |
||
289 | * @return string |
||
290 | */ |
||
291 | private function getXoopsVersionTemplatesAdminUser($moduleDirname, $tables, $admin, $user) |
||
382 | } |
||
383 | |||
384 | /** |
||
385 | * @private function getXoopsVersionTemplatesLine |
||
386 | * @param $moduleDirname |
||
387 | * @param $type |
||
388 | * @param string $extra |
||
389 | * @param bool $isAdmin |
||
390 | * @return string |
||
391 | */ |
||
392 | private function getXoopsVersionTemplatesLine($moduleDirname, $type, $extra = '', $isAdmin = false) |
||
408 | } |
||
409 | |||
410 | /** |
||
411 | * @private function getXoopsVersionSubmenu |
||
412 | * @param $language |
||
413 | * @param $tables |
||
414 | * @return string |
||
415 | */ |
||
416 | private function getXoopsVersionSubmenu($language, $tables) |
||
473 | } |
||
474 | |||
475 | /** |
||
476 | * @private function getXoopsVersionBlocks |
||
477 | * @param $moduleDirname |
||
478 | * @param $tables |
||
479 | * @param $language |
||
480 | * @return string |
||
481 | */ |
||
482 | private function getXoopsVersionBlocks($moduleDirname, $tables, $language) |
||
483 | { |
||
484 | $ret = $this->getDashComment('Default Blocks'); |
||
485 | foreach (\array_keys($tables) as $i) { |
||
486 | $tableName = $tables[$i]->getVar('table_name'); |
||
487 | if (0 == $tables[$i]->getVar('table_category') && 1 == $tables[$i]->getVar('table_blocks')) { |
||
488 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'LAST', $language, 'last'); |
||
489 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'NEW', $language, 'new'); |
||
490 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'HITS', $language, 'hits'); |
||
491 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'TOP', $language, 'top'); |
||
492 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'RANDOM', $language, 'random'); |
||
493 | } |
||
494 | } |
||
495 | $ret .= $this->getDashComment('Spotlight Blocks'); |
||
496 | foreach (\array_keys($tables) as $i) { |
||
497 | $tableName = $tables[$i]->getVar('table_name'); |
||
498 | if (0 == $tables[$i]->getVar('table_category') && 1 == $tables[$i]->getVar('table_blocks')) { |
||
499 | $ret .= $this->getXoopsVersionSpotlightBlocks($moduleDirname, $tableName, '', $language, 'spotlight'); |
||
500 | } |
||
501 | } |
||
502 | |||
503 | return $ret; |
||
504 | } |
||
505 | |||
506 | /** |
||
507 | * @private function getXoopsVersionTypeBlocks |
||
508 | * @param $moduleDirname |
||
509 | * @param $tableName |
||
510 | * @param $stuTableSoleName |
||
511 | * @param $language |
||
512 | * @param $type |
||
513 | * @return string |
||
514 | */ |
||
515 | private function getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $type) |
||
516 | { |
||
517 | $stuTableName = \mb_strtoupper($tableName); |
||
518 | $ucfTableName = \ucfirst($tableName); |
||
519 | $ret = $this->pc->getPhpCodeCommentLine($ucfTableName . ' ' . $type); |
||
520 | $blocks = [ |
||
521 | 'file' => "'{$tableName}.php'", |
||
522 | 'name' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}", |
||
523 | 'description' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}_DESC", |
||
524 | 'show_func' => "'b_{$moduleDirname}_{$tableName}_show'", |
||
525 | 'edit_func' => "'b_{$moduleDirname}_{$tableName}_edit'", |
||
526 | 'template' => "'{$moduleDirname}_block_{$tableName}.tpl'", |
||
527 | 'options' => "'{$type}|5|25|0'", |
||
528 | ]; |
||
529 | $ret .= $this->uxc->getUserModVersionArray(2, $blocks, 'blocks'); |
||
530 | |||
531 | return $ret; |
||
532 | } |
||
533 | |||
534 | /** |
||
535 | * @private function getXoopsVersionTypeBlocks |
||
536 | * @param $moduleDirname |
||
537 | * @param $tableName |
||
538 | * @param $stuTableSoleName |
||
539 | * @param $language |
||
540 | * @param $type |
||
541 | * @return string |
||
542 | */ |
||
543 | private function getXoopsVersionSpotlightBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $type) |
||
544 | { |
||
545 | $stuTableName = \mb_strtoupper($tableName); |
||
546 | $ucfTableName = \ucfirst($tableName); |
||
547 | $ret = $this->pc->getPhpCodeCommentLine($ucfTableName . ' ' . $type); |
||
548 | $blocks = [ |
||
549 | 'file' => "'{$tableName}_spotlight.php'", |
||
550 | 'name' => "{$language}{$stuTableName}_BLOCK_SPOTLIGHT", |
||
551 | 'description' => "{$language}{$stuTableName}_BLOCK_SPOTLIGHT_DESC", |
||
552 | 'show_func' => "'b_{$moduleDirname}_{$tableName}_spotlight_show'", |
||
553 | 'edit_func' => "'b_{$moduleDirname}_{$tableName}_spotlight_edit'", |
||
554 | 'template' => "'{$moduleDirname}_block_{$tableName}_spotlight.tpl'", |
||
555 | 'options' => "'{$type}|5|25|0'", |
||
556 | ]; |
||
557 | $ret .= $this->uxc->getUserModVersionArray(2, $blocks, 'blocks'); |
||
558 | |||
559 | return $ret; |
||
560 | } |
||
561 | |||
562 | /** |
||
563 | * @private function getXoopsVersionConfig |
||
564 | * @param $module |
||
565 | * @param $tables |
||
566 | * @param $language |
||
567 | * |
||
568 | * @return string |
||
569 | */ |
||
570 | private function getXoopsVersionConfig($module, $tables, $language) |
||
1002 | } |
||
1003 | |||
1004 | /** |
||
1005 | * @private function getXoopsVersionNotifications |
||
1006 | * @param $module |
||
1007 | * @param $language |
||
1008 | * @return string |
||
1009 | */ |
||
1010 | private function getXoopsVersionNotifications($module, $language) |
||
1011 | { |
||
1012 | $moduleDirname = $module->getVar('mod_dirname'); |
||
1013 | $ret = $this->getDashComment('Notifications'); |
||
1014 | $ret .= $this->uxc->getUserModVersionText(1, 1, 'hasNotification'); |
||
1015 | $notifications = ['lookup_file' => "'include/notification.inc.php'", 'lookup_func' => "'{$moduleDirname}_notify_iteminfo'"]; |
||
1016 | $ret .= $this->uxc->getUserModVersionArray(1, $notifications, 'notification'); |
||
1017 | |||
1018 | $notifyFiles = []; |
||
1019 | $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
||
1020 | $tableCategory = []; |
||
1021 | $tableBroken = []; |
||
1022 | $tableComments = []; |
||
1023 | $tableSubmit = []; |
||
1024 | $tableId = null; |
||
1025 | $tableMid = null; |
||
1026 | $notifyCategory = ''; |
||
1027 | $notifyEventGlobal = $this->pc->getPhpCodeCommentLine('Global events notification'); |
||
1028 | $notifyEventTable = $this->pc->getPhpCodeCommentLine('Event notifications for items'); |
||
1029 | |||
1030 | //global events |
||
1031 | $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_new', 'global', 0, 'global_new', 'global_new_notify'); |
||
1032 | $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_modify', 'global', 0, 'global_modify', 'global_modify_notify'); |
||
1033 | $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_delete', 'global', 0, 'global_delete', 'global_delete_notify'); |
||
1034 | $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_approve', 'global', 1, 'global_approve', 'global_approve_notify'); |
||
1035 | foreach (\array_keys($tables) as $t) { |
||
1036 | $tableBroken[] = $tables[$t]->getVar('table_broken'); |
||
1037 | $tableComments[] = $tables[$t]->getVar('table_comments'); |
||
1038 | } |
||
1039 | if (\in_array(1, $tableBroken)) { |
||
1040 | $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_broken', 'global', 1, 'global_broken', 'global_broken_notify'); |
||
1041 | } |
||
1042 | if (\in_array(1, $tableComments)) { |
||
1043 | $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_comment', 'global', 0, 'global_comment', 'global_comment_notify'); |
||
1044 | } |
||
1045 | |||
1046 | foreach (\array_keys($tables) as $t) { |
||
1047 | $tableId = $tables[$t]->getVar('table_id'); |
||
1048 | $tableMid = $tables[$t]->getVar('table_mid'); |
||
1049 | $tableName = $tables[$t]->getVar('table_name'); |
||
1050 | $tableSoleName = $tables[$t]->getVar('table_solename'); |
||
1051 | $tableCategory[] = $tables[$t]->getVar('table_category'); |
||
1052 | $tableSubmit[] = $tables[$t]->getVar('table_submit'); |
||
1053 | $fields = $this->getTableFields($tableMid, $tableId); |
||
1054 | $fieldId = 0; |
||
1055 | foreach (\array_keys($fields) as $f) { |
||
1056 | $fieldName = $fields[$f]->getVar('field_name'); |
||
1057 | if (0 == $f) { |
||
1058 | $fieldId = $fieldName; |
||
1059 | } |
||
1060 | } |
||
1061 | if (1 == $tables[$t]->getVar('table_notifications')) { |
||
1062 | $notifyFiles[] = $tableName; |
||
1063 | $notifyCategory .= $this->getXoopsVersionNotificationTableName($language, 'category', $tableName, $tableSoleName, $tableName, $fieldId, 1); |
||
1064 | //$notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_new', $tableName, 0, $tableSoleName, $tableSoleName . '_new_notify'); |
||
1065 | $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_modify', $tableName, 0, $tableSoleName . '_modify', $tableSoleName . '_modify_notify'); |
||
1066 | $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_delete', $tableName, 0, $tableSoleName . '_delete', $tableSoleName . '_delete_notify'); |
||
1067 | $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_approve', $tableName, 0, $tableSoleName . '_approve', $tableSoleName . '_approve_notify'); |
||
1068 | if (1 == $tables[$t]->getVar('table_broken')) { |
||
1069 | $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_broken', $tableName, 0, $tableSoleName . '_broken', $tableSoleName . '_broken_notify'); |
||
1070 | } |
||
1071 | /*event will be added by xoops |
||
1072 | if (1 == $tables[$t]->getVar('table_comments')) { |
||
1073 | $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_comment', $tableName, 0, $tableSoleName . '_comment', $tableSoleName . '_comment_notify'); |
||
1074 | }*/ |
||
1075 | } |
||
1076 | } |
||
1077 | $ret .= $this->pc->getPhpCodeCommentLine('Categories of notification'); |
||
1078 | $ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', 'global', $notifyFiles); |
||
1079 | |||
1080 | //$ret .= $this->getXoopsVersionNotificationCategory($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1'); |
||
1081 | |||
1082 | $ret .= $notifyCategory . $notifyEventGlobal . $notifyEventTable; |
||
1083 | |||
1084 | |||
1085 | return $ret; |
||
1086 | } |
||
1087 | |||
1088 | /** |
||
1089 | * @private function getXoopsVersionNotificationGlobal |
||
1090 | * @param $language |
||
1091 | * @param $type |
||
1092 | * @param $name |
||
1093 | * @param $title |
||
1094 | * @param $from |
||
1095 | * |
||
1096 | * @return string |
||
1097 | */ |
||
1098 | private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from) |
||
1099 | { |
||
1100 | $title = \mb_strtoupper($title); |
||
1101 | $implodeFrom = \implode(".php', '", $from); |
||
1102 | $ret = $this->pc->getPhpCodeCommentLine('Global Notify'); |
||
1103 | $global = [ |
||
1104 | 'name' => "'{$name}'", |
||
1105 | 'title' => "{$language}NOTIFY_{$title}", |
||
1106 | 'description' => "''", |
||
1107 | 'subscribe_from' => "['index.php', '{$implodeFrom}.php']", |
||
1108 | ]; |
||
1109 | $ret .= $this->uxc->getUserModVersionArray(3, $global, 'notification', "'{$type}'"); |
||
1110 | |||
1111 | return $ret; |
||
1112 | } |
||
1113 | |||
1114 | |||
1115 | /** |
||
1116 | * @private function getXoopsVersionNotificationTableName |
||
1117 | * @param $language |
||
1118 | * @param $type |
||
1119 | * @param $name |
||
1120 | * @param $title |
||
1121 | * @param $file |
||
1122 | * @param $item |
||
1123 | * @param $allow |
||
1124 | * |
||
1125 | * @return string |
||
1126 | */ |
||
1127 | private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $file, $item, $allow) |
||
1128 | { |
||
1129 | $stuTitle = \mb_strtoupper($title); |
||
1130 | $ucfTitle = \ucfirst($title); |
||
1131 | $ret = $this->pc->getPhpCodeCommentLine($ucfTitle . ' Notify'); |
||
1132 | $table = [ |
||
1133 | 'name' => "'{$name}'", |
||
1134 | 'title' => "{$language}NOTIFY_{$stuTitle}", |
||
1135 | 'description' => "''", |
||
1136 | 'subscribe_from' => "'{$file}.php'", |
||
1137 | 'item_name' => "'{$item}'", |
||
1138 | 'allow_bookmark' => (string)$allow, |
||
1139 | ]; |
||
1140 | $ret .= $this->uxc->getUserModVersionArray(3, $table, 'notification', "'{$type}'"); |
||
1141 | |||
1142 | return $ret; |
||
1143 | } |
||
1144 | |||
1145 | /** |
||
1146 | * @private function getXoopsVersionNotifications |
||
1147 | * @param $language |
||
1148 | * @param $type |
||
1149 | * @param $name |
||
1150 | * @param $category |
||
1151 | * @param $admin |
||
1152 | * @param $title |
||
1153 | * @param $mail |
||
1154 | * |
||
1155 | * @return string |
||
1156 | */ |
||
1157 | private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin, $title, $mail) |
||
1158 | { |
||
1159 | $title = \mb_strtoupper($title); |
||
1160 | $ucfTitle = \ucfirst($title); |
||
1161 | $ret = $this->pc->getPhpCodeCommentLine($ucfTitle . ' Notify'); |
||
1162 | $event = [ |
||
1163 | 'name' => "'{$name}'", |
||
1164 | 'category' => "'{$category}'", |
||
1165 | 'admin_only' => (string)$admin, |
||
1166 | 'title' => "{$language}NOTIFY_{$title}", |
||
1167 | 'caption' => "{$language}NOTIFY_{$title}_CAPTION", |
||
1168 | 'description' => "''", |
||
1169 | 'mail_template' => "'{$mail}'", |
||
1170 | 'mail_subject' => "{$language}NOTIFY_{$title}_SUBJECT", |
||
1171 | ]; |
||
1172 | $ret .= $this->uxc->getUserModVersionArray(3, $event, 'notification', "'{$type}'"); |
||
1173 | |||
1174 | return $ret; |
||
1175 | } |
||
1176 | |||
1177 | /** |
||
1178 | * @private function getXoopsVersionNotifications |
||
1179 | * @param $moduleDirname |
||
1180 | * @param string $t |
||
1181 | * @return string |
||
1182 | */ |
||
1183 | private function getXoopsVersionSelectSizeMB($moduleDirname, $t = '') |
||
1184 | { |
||
1185 | $ucModuleDirname = \mb_strtoupper($moduleDirname); |
||
1186 | |||
1187 | $ret = $this->pc->getPhpCodeCommentLine('create increment steps for file size'); |
||
1188 | $ret .= $this->pc->getPhpCodeIncludeDir("__DIR__ . '/include/xoops_version.inc.php'", '',true,true); |
||
1189 | $ret .= $this->xc->getXcEqualsOperator('$iniPostMaxSize ', "{$moduleDirname}ReturnBytes(\ini_get('post_max_size'))"); |
||
1190 | $ret .= $this->xc->getXcEqualsOperator('$iniUploadMaxFileSize', "{$moduleDirname}ReturnBytes(\ini_get('upload_max_filesize'))"); |
||
1191 | $ret .= $this->xc->getXcEqualsOperator('$maxSize ', "min(\$iniPostMaxSize, \$iniUploadMaxFileSize)"); |
||
1192 | $cond = $this->xc->getXcEqualsOperator('$increment', '500', null, $t . "\t"); |
||
1193 | $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' > ', '10000 * 1048576', $cond, false, $t); |
||
1194 | $cond = $this->xc->getXcEqualsOperator('$increment', '200', null, $t . "\t"); |
||
1195 | $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '10000 * 1048576', $cond, false, $t); |
||
1196 | $cond = $this->xc->getXcEqualsOperator('$increment', '100', null, $t . "\t"); |
||
1197 | $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '5000 * 1048576', $cond, false, $t); |
||
1198 | $cond = $this->xc->getXcEqualsOperator('$increment', '50', null, $t . "\t"); |
||
1199 | $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '2500 * 1048576', $cond, false, $t); |
||
1200 | $cond = $this->xc->getXcEqualsOperator('$increment', '10', null, $t . "\t"); |
||
1201 | $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '1000 * 1048576', $cond, false, $t); |
||
1202 | $cond = $this->xc->getXcEqualsOperator('$increment', '5', null, $t . "\t"); |
||
1203 | $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '500 * 1048576', $cond, false, $t); |
||
1204 | $cond = $this->xc->getXcEqualsOperator('$increment', '2', null, $t . "\t"); |
||
1205 | $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '100 * 1048576', $cond, false, $t); |
||
1206 | $cond = $this->xc->getXcEqualsOperator('$increment', '1', null, $t . "\t"); |
||
1207 | $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '50 * 1048576', $cond, false, $t); |
||
1208 | $cond = $this->xc->getXcEqualsOperator('$increment', '0.5', null, $t . "\t"); |
||
1209 | $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '25 * 1048576', $cond, false, $t); |
||
1210 | $ret .= $this->xc->getXcEqualsOperator('$optionMaxsize', '[]'); |
||
1211 | $ret .= $this->xc->getXcEqualsOperator('$i', '$increment'); |
||
1212 | $while = $this->xc->getXcEqualsOperator("\$optionMaxsize[\$i . ' ' . _MI_{$ucModuleDirname}_SIZE_MB]", '$i * 1048576', null, $t . "\t"); |
||
1213 | $while .= $this->xc->getXcEqualsOperator('$i', '$increment', '+',$t . "\t"); |
||
1214 | $ret .= $this->pc->getPhpCodeWhile('i * 1048576', $while, '$maxSize', '<='); |
||
1215 | |||
1216 | return $ret; |
||
1217 | } |
||
1218 | |||
1219 | /** |
||
1220 | * @public function render |
||
1221 | * @param null |
||
1222 | * @return bool|string |
||
1223 | */ |
||
1224 | public function render() |
||
1269 | } |
||
1270 | } |
||
1271 |