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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 |
||
| 28 | class UserXoopsVersion extends TDMCreateFile |
||
|
|
|||
| 29 | { |
||
| 30 | /* |
||
| 31 | * @var mixed |
||
| 32 | */ |
||
| 33 | private $phpcode = null; |
||
| 34 | |||
| 35 | /* |
||
| 36 | * @var mixed |
||
| 37 | */ |
||
| 38 | private $xoopscode = null; |
||
| 39 | |||
| 40 | /* |
||
| 41 | * @var mixed |
||
| 42 | */ |
||
| 43 | private $usercode = null; |
||
| 44 | |||
| 45 | /* |
||
| 46 | * @var array |
||
| 47 | */ |
||
| 48 | private $keywords = array(); |
||
| 49 | |||
| 50 | /* |
||
| 51 | * @public function constructor |
||
| 52 | * @param null |
||
| 53 | */ |
||
| 54 | /** |
||
| 55 | * |
||
| 56 | */ |
||
| 57 | public function __construct() |
||
| 64 | |||
| 65 | /* |
||
| 66 | * @static function &getInstance |
||
| 67 | * @param null |
||
| 68 | */ |
||
| 69 | /** |
||
| 70 | * @return UserXoopsVersion |
||
| 71 | */ |
||
| 72 | public static function &getInstance() |
||
| 81 | |||
| 82 | /* |
||
| 83 | * @public function write |
||
| 84 | * @param $module |
||
| 85 | * @param mixed $table |
||
| 86 | * @param mixed $tables |
||
| 87 | * @param $filename |
||
| 88 | */ |
||
| 89 | /** |
||
| 90 | * @param $module |
||
| 91 | * @param $table |
||
| 92 | * @param $tables |
||
| 93 | * @param $filename |
||
| 94 | */ |
||
| 95 | public function write($module, $table, $tables, $filename) |
||
| 106 | |||
| 107 | /* |
||
| 108 | * @public function setKeywords |
||
| 109 | * @param mixed $keywords |
||
| 110 | */ |
||
| 111 | /** |
||
| 112 | * @param $keywords |
||
| 113 | */ |
||
| 114 | public function setKeywords($keywords) |
||
| 122 | |||
| 123 | /* |
||
| 124 | * @public function getKeywords |
||
| 125 | * @param null |
||
| 126 | */ |
||
| 127 | /** |
||
| 128 | * @return array |
||
| 129 | */ |
||
| 130 | public function getKeywords() |
||
| 134 | |||
| 135 | /* |
||
| 136 | * @private function getXoopsVersionHeader |
||
| 137 | * @param $module |
||
| 138 | * @param $language |
||
| 139 | * |
||
| 140 | * @return string |
||
| 141 | */ |
||
| 142 | private function getXoopsVersionHeader($module, $language) |
||
| 171 | |||
| 172 | /* |
||
| 173 | * @private function getXoopsVersionMySQL |
||
| 174 | * @param $moduleDirname |
||
| 175 | * @param $table |
||
| 176 | */ |
||
| 177 | /** |
||
| 178 | * @param $moduleDirname |
||
| 179 | * @param $table |
||
| 180 | * |
||
| 181 | * @return string |
||
| 182 | */ |
||
| 183 | private function getXoopsVersionMySQL($moduleDirname, $table, $tables) |
||
| 202 | |||
| 203 | /* |
||
| 204 | * @private function getXoopsVersionSearch |
||
| 205 | * @param $moduleDirname |
||
| 206 | */ |
||
| 207 | /** |
||
| 208 | * @param $moduleDirname |
||
| 209 | * |
||
| 210 | * @return string |
||
| 211 | */ |
||
| 212 | private function getXoopsVersionSearch($moduleDirname) |
||
| 221 | |||
| 222 | /* |
||
| 223 | * @private function getXoopsVersionComments |
||
| 224 | * @param $moduleDirname |
||
| 225 | */ |
||
| 226 | /** |
||
| 227 | * @param $moduleDirname |
||
| 228 | * |
||
| 229 | * @return string |
||
| 230 | */ |
||
| 231 | private function getXoopsVersionComments($moduleDirname) |
||
| 243 | |||
| 244 | /* |
||
| 245 | * @private function getXoopsVersionTemplatesAdmin |
||
| 246 | * @param $moduleDirname |
||
| 247 | */ |
||
| 248 | /** |
||
| 249 | * @param $moduleDirname |
||
| 250 | * @param $tables |
||
| 251 | * |
||
| 252 | * @return string |
||
| 253 | */ |
||
| 254 | private function getXoopsVersionTemplatesAdmin($moduleDirname, $tables) |
||
| 255 | { |
||
| 256 | $ret = $this->getHeaderComment('Templates'); |
||
| 257 | $ret .= $this->getCommentLine('Admin'); |
||
| 258 | |||
| 259 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'about', '', true); |
||
| 260 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', '', true); |
||
| 261 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', '', true); |
||
| 262 | $tablePermissions = array(); |
||
| 263 | foreach (array_keys($tables) as $t) { |
||
| 264 | $tableName = $tables[$t]->getVar('table_name'); |
||
| 265 | $tablePermissions[] = $tables[$t]->getVar('table_permissions'); |
||
| 266 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, '', true); |
||
| 267 | } |
||
| 268 | if (in_array(1, $tablePermissions)) { |
||
| 269 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'permissions', '', true); |
||
| 270 | } |
||
| 271 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', '', true); |
||
| 272 | |||
| 273 | return $ret; |
||
| 274 | } |
||
| 275 | |||
| 276 | /* |
||
| 277 | * @private function getXoopsVersionTemplatesLine |
||
| 278 | * @param $moduleDirname |
||
| 279 | */ |
||
| 280 | /** |
||
| 281 | * @param $moduleDirname |
||
| 282 | * |
||
| 283 | * @return string |
||
| 284 | */ |
||
| 285 | private function getXoopsVersionTemplatesLine($moduleDirname, $type, $extra = '', $isAdmin = false) |
||
| 302 | |||
| 303 | /* |
||
| 304 | * @private function getXoopsVersionTemplatesUser |
||
| 305 | * @param $moduleDirname |
||
| 306 | */ |
||
| 307 | /** |
||
| 308 | * @param $moduleDirname |
||
| 309 | * |
||
| 310 | * @return string |
||
| 311 | */ |
||
| 312 | private function getXoopsVersionTemplatesUser($moduleDirname, $tables) |
||
| 368 | |||
| 369 | /* |
||
| 370 | * @private function getXoopsVersionSubmenu |
||
| 371 | * @param $language |
||
| 372 | */ |
||
| 373 | /** |
||
| 374 | * @param $language |
||
| 375 | * |
||
| 376 | * @return string |
||
| 377 | */ |
||
| 378 | private function getXoopsVersionSubmenu($language, $tables) |
||
| 402 | |||
| 403 | /* |
||
| 404 | * @private function getXoopsVersionBlocks |
||
| 405 | * @param $moduleDirname |
||
| 406 | * @param $language |
||
| 407 | */ |
||
| 408 | /** |
||
| 409 | * @param $moduleDirname |
||
| 410 | * @param $language |
||
| 411 | * |
||
| 412 | * @return string |
||
| 413 | */ |
||
| 414 | private function getXoopsVersionBlocks($moduleDirname, $tables, $language) |
||
| 439 | |||
| 440 | /* |
||
| 441 | * @private function getXoopsVersionTypeBlocks |
||
| 442 | * @param $moduleDirname |
||
| 443 | * @param $language |
||
| 444 | */ |
||
| 445 | /** |
||
| 446 | * @param $moduleDirname |
||
| 447 | * @param $language |
||
| 448 | * |
||
| 449 | * @return string |
||
| 450 | */ |
||
| 451 | private function getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $type) |
||
| 464 | |||
| 465 | /* |
||
| 466 | * @private function getXoopsVersionConfig |
||
| 467 | * @param $moduleDirname |
||
| 468 | * @param $language |
||
| 469 | */ |
||
| 470 | /** |
||
| 471 | * @param $module |
||
| 472 | * @param $table |
||
| 473 | * @param $language |
||
| 474 | * |
||
| 475 | * @return string |
||
| 476 | */ |
||
| 477 | private function getXoopsVersionConfig($module, $table, $language) |
||
| 478 | { |
||
| 479 | $moduleDirname = $module->getVar('mod_dirname'); |
||
| 480 | $ret = $this->getHeaderComment('Config'); |
||
| 481 | $ret .= $this->getSimpleString('$c = 1;'); |
||
| 482 | $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
||
| 483 | $fieldName = array(); |
||
| 484 | $fieldElement = array(); |
||
| 485 | foreach (array_keys($fields) as $f) { |
||
| 486 | $fieldName[] = $fields[$f]->getVar('field_name'); |
||
| 487 | $fieldElement[] = $fields[$f]->getVar('field_element'); |
||
| 488 | } |
||
| 489 | if (in_array(4, $fieldElement)) { |
||
| 490 | $rpFieldName = $this->getRightString($fieldName); |
||
| 491 | $ucfFieldName = ucfirst($rpFieldName); |
||
| 492 | $ret .= $this->getCommentLine('Editor', $rpFieldName); |
||
| 493 | $ret .= $this->xoopscode->getXoopsCodeLoad('xoopseditorhandler'); |
||
| 494 | $ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$editorHandler ', 'XoopsEditorHandler::getInstance()'); |
||
| 495 | $editor = array('name' => "'{$moduleDirname}_editor_{$rpFieldName}'", 'title' => "'{$language}EDITOR_{$ucfFieldName}'", 'description' => "'{$language}EDITOR_{$ucfFieldName}_DESC'", |
||
| 496 | 'formtype' => "'select'", 'valuetype' => "'text'", 'default' => "'dhtml'", 'options' => 'array_flip($editorHandler->getList())', ); |
||
| 497 | $ret .= $this->usercode->getUserModVersion(3, $editor, 'config', '$c'); |
||
| 498 | $ret .= $this->getSimpleString('++$c;'); |
||
| 499 | } |
||
| 500 | if (1 == $table->getVar('table_permissions')) { |
||
| 501 | $ret .= $this->getCommentLine('Get groups'); |
||
| 502 | $ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$memberHandler ', "xoops_gethandler('member')", true); |
||
| 503 | $ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$xoopsGroups ', '$memberHandler->getGroupList()'); |
||
| 504 | $group = $this->xoopscode->getXoopsCodeEqualsOperator('$groups[$group] ', '$key'); |
||
| 505 | $ret .= $this->phpcode->getPhpCodeForeach('xoopsGroups', false, 'key', 'group', $group); |
||
| 506 | $groups = array('name' => "'groups'", 'title' => "'{$language}GROUPS'", 'description' => "'{$language}GROUPS_DESC'", |
||
| 507 | 'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => '$groups', 'options' => '$groups', ); |
||
| 508 | $ret .= $this->usercode->getUserModVersion(3, $groups, 'config', '$c'); |
||
| 509 | $ret .= $this->getSimpleString('++$c;'); |
||
| 510 | $ret .= $this->getCommentLine('Get Admin groups'); |
||
| 511 | $ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$criteria ', 'new CriteriaCompo()'); |
||
| 512 | $ret .= $this->getSimpleString("\$criteria->add( new Criteria( 'group_type', 'Admin' ) );"); |
||
| 513 | $ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$memberHandler ', "xoops_gethandler('member')", true); |
||
| 514 | $ret .= $this->xoopscode->getXoopsCodeEqualsOperator('$adminXoopsGroups ', '$memberHandler->getGroupList($criteria)'); |
||
| 515 | $adminGroup = $this->xoopscode->getXoopsCodeEqualsOperator('$adminGroups[$adminGroup] ', '$key'); |
||
| 516 | $ret .= $this->phpcode->getPhpCodeForeach('adminXoopsGroups', false, 'key', 'adminGroup', $adminGroup); |
||
| 517 | $adminGroups = array('name' => "'admin_groups'", 'title' => "'{$language}GROUPS'", 'description' => "'{$language}GROUPS_DESC'", |
||
| 518 | 'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => '$adminGroups', 'options' => '$adminGroups', ); |
||
| 519 | $ret .= $this->usercode->getUserModVersion(3, $adminGroups, 'config', '$c'); |
||
| 520 | $ret .= $this->getSimpleString('++$c;'); |
||
| 521 | } |
||
| 522 | $keyword = implode(', ', $this->getKeywords()); |
||
| 523 | $ret .= $this->getCommentLine('Keywords'); |
||
| 524 | $arrayKeyword = array('name' => "'keywords'", 'title' => "'{$language}KEYWORDS'", 'description' => "'{$language}KEYWORDS_DESC'", |
||
| 525 | 'formtype' => "'textbox'", 'valuetype' => "'text'", 'default' => "'{$moduleDirname}, {$keyword}'", ); |
||
| 526 | $ret .= $this->usercode->getUserModVersion(3, $arrayKeyword, 'config', '$c'); |
||
| 527 | $ret .= $this->getSimpleString('++$c;'); |
||
| 528 | unset($this->keywords); |
||
| 529 | if (is_object($table)) { |
||
| 530 | if (in_array(array(10, 11, 12, 13, 14), $fieldElement)) { |
||
| 531 | $ret .= $this->getCommentLine('Uploads : maxsize of image'); |
||
| 532 | $maxsize = array('name' => "'maxsize'", 'title' => "'{$language}MAXSIZE'", 'description' => "'{$language}MAXSIZE_DESC'", |
||
| 533 | 'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '5000000', ); |
||
| 534 | $ret .= $this->usercode->getUserModVersion(3, $maxsize, 'config', '$c'); |
||
| 535 | $ret .= $this->getCommentLine('Uploads : mimetypes of image'); |
||
| 536 | $ret .= $this->getSimpleString('++$c;'); |
||
| 537 | $mimetypes = array('name' => "'mimetypes'", 'title' => "'{$language}MIMETYPES'", 'description' => "'{$language}MIMETYPES_DESC'", |
||
| 538 | 'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => "array('image/gif', 'image/jpeg', 'image/png')", 'options' => "array('bmp' => 'image/bmp','gif' => 'image/gif','pjpeg' => 'image/pjpeg', |
||
| 539 | 'jpeg' => 'image/jpeg','jpg' => 'image/jpg','jpe' => 'image/jpe', |
||
| 540 | 'png' => 'image/png')", ); |
||
| 541 | $ret .= $this->usercode->getUserModVersion(3, $mimetypes, 'config', '$c'); |
||
| 542 | $ret .= $this->getSimpleString('++$c;'); |
||
| 543 | } |
||
| 544 | if (1 == $table->getVar('table_admin')) { |
||
| 545 | $ret .= $this->getCommentLine('Admin pager'); |
||
| 546 | $adminPager = array('name' => "'adminpager'", 'title' => "'{$language}ADMIN_PAGER'", 'description' => "'{$language}ADMIN_PAGER_DESC'", |
||
| 547 | 'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '10', ); |
||
| 548 | $ret .= $this->usercode->getUserModVersion(3, $adminPager, 'config', '$c'); |
||
| 549 | $ret .= $this->getSimpleString('++$c;'); |
||
| 550 | } |
||
| 551 | if (1 == $table->getVar('table_user')) { |
||
| 552 | $ret .= $this->getCommentLine('User pager'); |
||
| 553 | $userPager = array('name' => "'userpager'", 'title' => "'{$language}USER_PAGER'", 'description' => "'{$language}USER_PAGER_DESC'", |
||
| 554 | 'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '10', ); |
||
| 555 | $ret .= $this->usercode->getUserModVersion(3, $userPager, 'config', '$c'); |
||
| 556 | $ret .= $this->getSimpleString('++$c;'); |
||
| 557 | } |
||
| 558 | if (1 == $table->getVar('table_tag')) { |
||
| 559 | $ret .= $this->getCommentLine('Use tag'); |
||
| 560 | $useTag = array('name' => "'usetag'", 'title' => "'{$language}USE_TAG'", 'description' => "'{$language}USE_TAG_DESC'", |
||
| 561 | 'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0', ); |
||
| 562 | $ret .= $this->usercode->getUserModVersion(3, $useTag, 'config', '$c'); |
||
| 563 | $ret .= $this->getSimpleString('++$c;'); |
||
| 564 | } |
||
| 565 | } |
||
| 566 | $ret .= $this->getCommentLine('Number column'); |
||
| 567 | $numbCol = array('name' => "'numb_col'", 'title' => "'{$language}NUMB_COL'", 'description' => "'{$language}NUMB_COL_DESC'", |
||
| 568 | 'formtype' => "'select'", 'valuetype' => "'int'", 'default' => '1', 'options' => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')", ); |
||
| 569 | $ret .= $this->usercode->getUserModVersion(3, $numbCol, 'config', '$c'); |
||
| 570 | $ret .= $this->getSimpleString('++$c;'); |
||
| 571 | $ret .= $this->getCommentLine('Divide by'); |
||
| 572 | $divideby = array('name' => "'divideby'", 'title' => "'{$language}DIVIDEBY'", 'description' => "'{$language}DIVIDEBY_DESC'", |
||
| 573 | 'formtype' => "'select'", 'valuetype' => "'int'", 'default' => '1', 'options' => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')", ); |
||
| 574 | $ret .= $this->usercode->getUserModVersion(3, $divideby, 'config', '$c'); |
||
| 575 | $ret .= $this->getSimpleString('++$c;'); |
||
| 576 | $ret .= $this->getCommentLine('Table type'); |
||
| 577 | $tableType = array('name' => "'table_type'", 'title' => "'{$language}DIVIDEBY'", 'description' => "'{$language}DIVIDEBY_DESC'", |
||
| 578 | 'formtype' => "'select'", 'valuetype' => "'int'", 'default' => "'bordered'", 'options' => "array('bordered' => 'bordered', 'striped' => 'striped', 'hover' => 'hover', 'condensed' => 'condensed')", ); |
||
| 579 | $ret .= $this->usercode->getUserModVersion(3, $tableType, 'config', '$c'); |
||
| 580 | $ret .= $this->getSimpleString('++$c;'); |
||
| 581 | $ret .= $this->getCommentLine('Panel by'); |
||
| 582 | $panelType = array('name' => "'panel_type'", 'title' => "'{$language}PANEL_TYPE'", 'description' => "'{$language}PANEL_TYPE_DESC'", |
||
| 583 | 'formtype' => "'select'", 'valuetype' => "'text'", 'default' => "'default'", 'options' => "array('default' => 'default', 'primary' => 'primary', 'success' => 'success', 'info' => 'info', 'warning' => 'warning', 'danger' => 'danger')", ); |
||
| 584 | $ret .= $this->usercode->getUserModVersion(3, $panelType, 'config', '$c'); |
||
| 585 | $ret .= $this->getSimpleString('++$c;'); |
||
| 586 | $ret .= $this->getCommentLine('Panel by'); |
||
| 587 | $advertise = array('name' => "'advertise'", 'title' => "'{$language}ADVERTISE'", 'description' => "'{$language}ADVERTISE_DESC'", |
||
| 588 | 'formtype' => "'textarea'", 'valuetype' => "'text'", 'default' => "''", ); |
||
| 589 | $ret .= $this->usercode->getUserModVersion(3, $advertise, 'config', '$c'); |
||
| 590 | $ret .= $this->getSimpleString('++$c;'); |
||
| 591 | $ret .= $this->getCommentLine('Panel by'); |
||
| 592 | $bookmarks = array('name' => "'bookmarks'", 'title' => "'{$language}BOOKMARKS'", 'description' => "'{$language}BOOKMARKS_DESC'", |
||
| 593 | 'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0', ); |
||
| 594 | $ret .= $this->usercode->getUserModVersion(3, $bookmarks, 'config', '$c'); |
||
| 595 | $ret .= $this->getSimpleString('++$c;'); |
||
| 596 | $ret .= $this->getCommentLine('Facebook Comments'); |
||
| 597 | $facebookComments = array('name' => "'facebook_comments'", 'title' => "'{$language}FACEBOOK_COMMENTS'", 'description' => "'{$language}FACEBOOK_COMMENTS_DESC'", |
||
| 598 | 'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0', ); |
||
| 599 | $ret .= $this->usercode->getUserModVersion(3, $facebookComments, 'config', '$c'); |
||
| 600 | $ret .= $this->getSimpleString('++$c;'); |
||
| 601 | $ret .= $this->getCommentLine('Disqus Comments'); |
||
| 602 | $disqusComments = array('name' => "'disqus_comments'", 'title' => "'{$language}DISQUS_COMMENTS'", 'description' => "'{$language}DISQUS_COMMENTS_DESC'", |
||
| 603 | 'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0', ); |
||
| 604 | $ret .= $this->usercode->getUserModVersion(3, $disqusComments, 'config', '$c'); |
||
| 605 | $ret .= $this->getSimpleString('++$c;'); |
||
| 606 | $ret .= $this->getCommentLine('Maintained by'); |
||
| 607 | $maintainedby = array('name' => "'maintainedby'", 'title' => "'{$language}MAINTAINEDBY'", 'description' => "'{$language}MAINTAINEDBY_DESC'", |
||
| 608 | 'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => "'{$module->getVar('mod_support_url')}'", ); |
||
| 609 | $ret .= $this->usercode->getUserModVersion(3, $maintainedby, 'config', '$c'); |
||
| 610 | $ret .= $this->getSimpleString('unset($c);'); |
||
| 611 | |||
| 612 | return $ret; |
||
| 613 | } |
||
| 614 | |||
| 615 | /* |
||
| 616 | * @private function getNotificationsType |
||
| 617 | * @param $language |
||
| 618 | * @param $type |
||
| 619 | * @param $tableName |
||
| 620 | * @param $item |
||
| 621 | * @param $typeOfNotify |
||
| 622 | */ |
||
| 623 | /** |
||
| 624 | * @param $language |
||
| 625 | * @param $type |
||
| 626 | * @param $tableName |
||
| 627 | * @param $notifyFile |
||
| 628 | * @param $item |
||
| 629 | * @param $typeOfNotify |
||
| 630 | * |
||
| 631 | * @return string |
||
| 632 | */ |
||
| 633 | private function getNotificationsType($language, $type = 'category', $tableName, $notifyFile, $item, $typeOfNotify) |
||
| 658 | |||
| 659 | /* |
||
| 660 | * @private function getXoopsVersionNotifications |
||
| 661 | * @param $moduleDirname |
||
| 662 | * @param $language |
||
| 663 | */ |
||
| 664 | /** |
||
| 665 | * @param $moduleDirname |
||
| 666 | * @param $language |
||
| 667 | * |
||
| 668 | * @return string |
||
| 669 | */ |
||
| 670 | private function getXoopsVersionNotifications($module, $language) |
||
| 671 | { |
||
| 672 | $moduleDirname = $module->getVar('mod_dirname'); |
||
| 673 | $ret = $this->getHeaderComment('Notifications'); |
||
| 674 | $ret .= $this->usercode->getUserModVersion(1, 1, 'hasNotification'); |
||
| 675 | $notifications = array("'lookup_file'" => "'include/notification.inc.php'", "'lookup_func'" => "'{$moduleDirname}_notify_iteminfo'"); |
||
| 676 | $ret .= $this->usercode->getUserModVersion(2, $notifications, 'notification'); |
||
| 677 | |||
| 678 | $notifyFiles = array(); |
||
| 679 | $single = 'single'; |
||
| 680 | $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
||
| 681 | $tableCategory = array(); |
||
| 682 | $tableBroken = array(); |
||
| 683 | $tableSubmit = array(); |
||
| 684 | $tableId = null; |
||
| 685 | $tableMid = null; |
||
| 686 | foreach (array_keys($tables) as $t) { |
||
| 687 | $tableId = $tables[$t]->getVar('table_id'); |
||
| 688 | $tableMid = $tables[$t]->getVar('table_mid'); |
||
| 689 | $tableName = $tables[$t]->getVar('table_name'); |
||
| 690 | $tableCategory[] = $tables[$t]->getVar('table_category'); |
||
| 691 | $tableBroken[] = $tables[$t]->getVar('table_broken'); |
||
| 692 | $tableSubmit[] = $tables[$t]->getVar('table_submit'); |
||
| 693 | if (1 == $tables[$t]->getVar('table_notifications')) { |
||
| 694 | if ($t <= count($tableName)) { |
||
| 695 | $notifyFiles[] = $tables[$t]->getVar('table_name'); |
||
| 696 | } |
||
| 697 | } |
||
| 698 | if (1 == $tables[$t]->getVar('table_single')) { |
||
| 699 | $single = $tableName; |
||
| 700 | } |
||
| 701 | } |
||
| 702 | $fields = $this->getTableFields($tableMid, $tableId); |
||
| 703 | $fieldId = null; |
||
| 704 | $fieldParent = null; |
||
| 705 | foreach (array_keys($fields) as $f) { |
||
| 706 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 707 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 708 | if (0 == $f) { |
||
| 709 | $fieldId = $fieldName; |
||
| 710 | } |
||
| 711 | if ($fieldElement > 15) { |
||
| 712 | $fieldParent = $fieldName; |
||
| 713 | } |
||
| 714 | } |
||
| 715 | |||
| 716 | $num = 1; |
||
| 717 | $ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', 'global', $notifyFiles, $num); |
||
| 718 | ++$num; |
||
| 719 | $ret .= $this->getXoopsVersionNotificationCategory($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1', $num); |
||
| 720 | ++$num; |
||
| 721 | $ret .= $this->getXoopsVersionNotificationTableName($language, 'category', 'file', 'file', $single, $fieldId, 1, $num); |
||
| 722 | unset($num); |
||
| 723 | $num = 1; |
||
| 724 | if (in_array(1, $tableCategory)) { |
||
| 725 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'global', 0, 'global', 'newcategory', 'global_newcategory_notify', $num); |
||
| 726 | ++$num; |
||
| 727 | } |
||
| 728 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_modify', 'global', 1, 'global', 'filemodify', 'global_filemodify_notify', $num); |
||
| 729 | if (in_array(1, $tableBroken)) { |
||
| 730 | ++$num; |
||
| 731 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_broken', 'global', 1, 'global', 'filebroken', 'global_filebroken_notify', $num); |
||
| 732 | } |
||
| 733 | if (in_array(1, $tableSubmit)) { |
||
| 734 | ++$num; |
||
| 735 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_submit', 'global', 1, 'global', 'filesubmit', 'global_filesubmit_notify', $num); |
||
| 736 | } |
||
| 737 | ++$num; |
||
| 738 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_file', 'global', 0, 'global', 'newfile', 'global_newfile_notify', $num); |
||
| 739 | if (in_array(1, $tableCategory)) { |
||
| 740 | ++$num; |
||
| 741 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'file_submit', 'category', 1, 'category', 'filesubmit', 'category_filesubmit_notify', $num); |
||
| 742 | ++$num; |
||
| 743 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_file', 'category', 0, 'category', 'newfile', 'category_newfile_notify', $num); |
||
| 744 | } |
||
| 745 | ++$num; |
||
| 746 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'approve', 'file', 1, 'file', 'approve', 'file_approve_notify', $num); |
||
| 747 | unset($num); |
||
| 748 | |||
| 749 | return $ret; |
||
| 750 | } |
||
| 751 | |||
| 752 | /* |
||
| 753 | * @private function getXoopsVersionNotificationGlobal |
||
| 754 | */ |
||
| 755 | /** |
||
| 756 | * @param $language |
||
| 757 | * @param $type |
||
| 758 | * @param $name |
||
| 759 | * @param $title |
||
| 760 | * @param $from |
||
| 761 | * |
||
| 762 | * @return string |
||
| 763 | */ |
||
| 764 | private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from, $num) |
||
| 775 | |||
| 776 | /* |
||
| 777 | * @private function getXoopsVersionNotificationCategory |
||
| 778 | */ |
||
| 779 | /** |
||
| 780 | * @param $language |
||
| 781 | * @param $type |
||
| 782 | * @param $name |
||
| 783 | * @param $title |
||
| 784 | * @param $from |
||
| 785 | * |
||
| 786 | * @return string |
||
| 787 | */ |
||
| 788 | private function getXoopsVersionNotificationCategory($language, $type, $name, $title, $file, $item, $allow, $num) |
||
| 789 | { |
||
| 790 | $title = strtoupper($title); |
||
| 791 | $impFile = implode(".php', '", $file); |
||
| 792 | $ret = $this->getCommentLine('Category Notify'); |
||
| 793 | $global = array('name' => "'{$name}'", 'title' => "{$language}{$title}_NOTIFY", 'description' => "{$language}{$title}_NOTIFY_DESC", |
||
| 794 | 'subscribe_from' => "array('{$impFile}.php')", 'item_name' => "'{$item}'", 'allow_bookmark' => "{$allow}", ); |
||
| 795 | $ret .= $this->usercode->getUserModVersion(4, $global, 'notification', "'{$type}'", $num); |
||
| 796 | |||
| 797 | return $ret; |
||
| 798 | } |
||
| 799 | |||
| 800 | /* |
||
| 801 | * @private function getXoopsVersionNotificationTableName |
||
| 802 | */ |
||
| 803 | /** |
||
| 804 | * @param $language |
||
| 805 | * @param $type |
||
| 806 | * @param $name |
||
| 807 | * @param $title |
||
| 808 | * @param $file |
||
| 809 | * @param $item |
||
| 810 | * @param $allow |
||
| 811 | * |
||
| 812 | * @return string |
||
| 813 | */ |
||
| 814 | private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $file, $item = 'cid', $allow = 1, $num) |
||
| 815 | { |
||
| 816 | $stuTitle = strtoupper($title); |
||
| 817 | $ucfTitle = ucfirst($title); |
||
| 818 | $ret = $this->getCommentLine($ucfTitle.' Notify'); |
||
| 819 | $table = array('name' => "'{$name}'", 'title' => "{$language}{$stuTitle}_NOTIFY", 'description' => "{$language}{$stuTitle}_NOTIFY_DESC", |
||
| 820 | 'subscribe_from' => "'{$file}.php'", 'item_name' => "'{$item}'", 'allow_bookmark' => "{$allow}", ); |
||
| 821 | $ret .= $this->usercode->getUserModVersion(4, $table, 'notification', "'{$type}'", $num); |
||
| 822 | |||
| 823 | return $ret; |
||
| 824 | } |
||
| 825 | |||
| 826 | /* |
||
| 827 | * @private function getXoopsVersionNotifications |
||
| 828 | */ |
||
| 829 | /** |
||
| 830 | * @param $language |
||
| 831 | * @param $type |
||
| 832 | * @param $name |
||
| 833 | * @param $title |
||
| 834 | * @param $from |
||
| 835 | * @param $item |
||
| 836 | * @param $mail |
||
| 837 | * |
||
| 838 | * @return string |
||
| 839 | */ |
||
| 840 | private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin = 1, $title, $table, $mail, $num) |
||
| 853 | |||
| 854 | /* |
||
| 855 | * @public function render |
||
| 856 | * @param null |
||
| 857 | */ |
||
| 858 | /** |
||
| 859 | * @return bool|string |
||
| 860 | */ |
||
| 861 | public function render() |
||
| 910 | } |
||
| 911 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.