| Total Complexity | 95 |
| Total Lines | 1051 |
| 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 |
||
| 33 | class UserXoopsVersion extends Files\CreateFile |
||
| 34 | { |
||
| 35 | /** |
||
| 36 | * @var array |
||
| 37 | */ |
||
| 38 | private $kw = []; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @public function constructor |
||
| 42 | * @param null |
||
| 43 | */ |
||
| 44 | public function __construct() |
||
| 45 | { |
||
| 46 | parent::__construct(); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @static function getInstance |
||
| 51 | * @param null |
||
| 52 | * @return UserXoopsVersion |
||
| 53 | */ |
||
| 54 | public static function getInstance() |
||
| 55 | { |
||
| 56 | static $instance = false; |
||
| 57 | if (!$instance) { |
||
| 58 | $instance = new self(); |
||
| 59 | } |
||
| 60 | |||
| 61 | return $instance; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @public function write |
||
| 66 | * @param $module |
||
| 67 | * @param mixed $table |
||
| 68 | * @param mixed $tables |
||
| 69 | * @param $filename |
||
| 70 | */ |
||
| 71 | public function write($module, $table, $tables, $filename) |
||
| 72 | { |
||
| 73 | $this->setModule($module); |
||
| 74 | $this->setTable($table); |
||
| 75 | $this->setTables($tables); |
||
| 76 | $this->setFileName($filename); |
||
| 77 | foreach (array_keys($tables) as $t) { |
||
| 78 | $tableName = $tables[$t]->getVar('table_name'); |
||
| 79 | $this->setKeywords($tableName); |
||
| 80 | } |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @public function setKeywords |
||
| 85 | * @param mixed $keywords |
||
| 86 | */ |
||
| 87 | public function setKeywords($keywords) |
||
| 88 | { |
||
| 89 | if (is_array($keywords)) { |
||
| 90 | $this->kw = $keywords; |
||
| 91 | } else { |
||
| 92 | $this->kw[] = $keywords; |
||
| 93 | } |
||
| 94 | } |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @public function getKeywords |
||
| 98 | * @param null |
||
| 99 | * @return array |
||
| 100 | */ |
||
| 101 | public function getKeywords() |
||
| 102 | { |
||
| 103 | return $this->kw; |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @private function getXoopsVersionHeader |
||
| 108 | * @param $module |
||
| 109 | * @param $language |
||
| 110 | * |
||
| 111 | * @return string |
||
| 112 | */ |
||
| 113 | private function getXoopsVersionHeader($module, $language) |
||
| 114 | { |
||
| 115 | $xCodeVHeader = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 116 | $uCodeVHeader = UserXoopsCode::getInstance(); |
||
| 117 | $date = date('Y/m/d'); |
||
| 118 | $ret = $this->getSimpleString(''); |
||
| 119 | $ret .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine(); |
||
| 120 | $ret .= $xCodeVHeader->getXcEqualsOperator('$dirname ', 'basename(__DIR__)'); |
||
| 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/{$module->getVar('mod_image')}'", |
||
| 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 | 'onUpdate' => "'include/update.php'", |
||
| 168 | ]; |
||
| 169 | |||
| 170 | $ret .= $uCodeVHeader->getUserModVersion(1, $descriptions); |
||
| 171 | |||
| 172 | return $ret; |
||
| 173 | } |
||
| 174 | |||
| 175 | /** |
||
| 176 | * @private function getXoopsVersionMySQL |
||
| 177 | * @param $moduleDirname |
||
| 178 | * @param $table |
||
| 179 | * @param $tables |
||
| 180 | * @return string |
||
| 181 | */ |
||
| 182 | private function getXoopsVersionMySQL($moduleDirname, $table, $tables) |
||
| 183 | { |
||
| 184 | $uCodeVMySQL = UserXoopsCode::getInstance(); |
||
| 185 | $tableName = $table->getVar('table_name'); |
||
| 186 | $n = 1; |
||
| 187 | $ret = ''; |
||
| 188 | if (!empty($tableName)) { |
||
| 189 | $ret .= $this->getDashComment('Mysql'); |
||
| 190 | $ret .= $uCodeVMySQL->getUserModVersion(2, "'sql/mysql.sql'", 'sqlfile', "'mysql'"); |
||
| 191 | $ret .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Tables'); |
||
| 192 | |||
| 193 | foreach (array_keys($tables) as $t) { |
||
| 194 | $ret .= $uCodeVMySQL->getUserModVersion(2, "'{$moduleDirname}_{$tables[$t]->getVar('table_name')}'", 'tables', $n); |
||
| 195 | ++$n; |
||
| 196 | } |
||
| 197 | unset($n); |
||
| 198 | } |
||
| 199 | |||
| 200 | return $ret; |
||
| 201 | } |
||
| 202 | |||
| 203 | /** |
||
| 204 | * @private function getXoopsVersionSearch |
||
| 205 | * @param $moduleDirname |
||
| 206 | * |
||
| 207 | * @return string |
||
| 208 | */ |
||
| 209 | private function getXoopsVersionSearch($moduleDirname) |
||
| 210 | { |
||
| 211 | $uCodeVSearch = UserXoopsCode::getInstance(); |
||
| 212 | $ret = $this->getDashComment('Search'); |
||
| 213 | $ret .= $uCodeVSearch->getUserModVersion(1, 1, 'hasSearch'); |
||
| 214 | $ret .= $uCodeVSearch->getUserModVersion(2, "'include/search.inc.php'", 'search', "'file'"); |
||
| 215 | $ret .= $uCodeVSearch->getUserModVersion(2, "'{$moduleDirname}_search'", 'search', "'func'"); |
||
| 216 | |||
| 217 | return $ret; |
||
| 218 | } |
||
| 219 | |||
| 220 | /** |
||
| 221 | * @private function getXoopsVersionComments |
||
| 222 | * @param $moduleDirname |
||
| 223 | * |
||
| 224 | * @return string |
||
| 225 | */ |
||
| 226 | private function getXoopsVersionComments($moduleDirname) |
||
| 227 | { |
||
| 228 | $uCodeVComments = UserXoopsCode::getInstance(); |
||
| 229 | $ret = $this->getDashComment('Comments'); |
||
| 230 | $ret .= $uCodeVComments->getUserModVersion(2, "'comments.php'", 'comments', "'pageName'"); |
||
| 231 | $ret .= $uCodeVComments->getUserModVersion(2, "'com_id'", 'comments', "'itemName'"); |
||
| 232 | $ret .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Comment callback functions'); |
||
| 233 | $ret .= $uCodeVComments->getUserModVersion(2, "'include/comment_functions.php'", 'comments', "'callbackFile'"); |
||
| 234 | $descriptions = ['approve' => "'{$moduleDirname}CommentsApprove'", 'update' => "'{$moduleDirname}CommentsUpdate'"]; |
||
| 235 | $ret .= $uCodeVComments->getUserModVersion(3, $descriptions, 'comments', "'callback'"); |
||
| 236 | |||
| 237 | return $ret; |
||
| 238 | } |
||
| 239 | |||
| 240 | /** |
||
| 241 | * @private function getXoopsVersionTemplatesAdmin |
||
| 242 | * @param $moduleDirname |
||
| 243 | * @param $tables |
||
| 244 | * |
||
| 245 | * @return string |
||
| 246 | */ |
||
| 247 | private function getXoopsVersionTemplatesAdmin($moduleDirname, $tables) |
||
| 248 | { |
||
| 249 | $ret = $this->getDashComment('Templates'); |
||
| 250 | $ret .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Admin'); |
||
| 251 | |||
| 252 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'about', '', true); |
||
| 253 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', '', true); |
||
| 254 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', '', true); |
||
| 255 | $tablePermissions = []; |
||
| 256 | foreach (array_keys($tables) as $t) { |
||
| 257 | $tableName = $tables[$t]->getVar('table_name'); |
||
| 258 | $tablePermissions[] = $tables[$t]->getVar('table_permissions'); |
||
| 259 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, '', true); |
||
| 260 | } |
||
| 261 | if (in_array(1, $tablePermissions)) { |
||
| 262 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'permissions', '', true); |
||
| 263 | } |
||
| 264 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', '', true); |
||
| 265 | |||
| 266 | return $ret; |
||
| 267 | } |
||
| 268 | |||
| 269 | /** |
||
| 270 | * @private function getXoopsVersionTemplatesLine |
||
| 271 | * @param $moduleDirname |
||
| 272 | * @param $type |
||
| 273 | * @param string $extra |
||
| 274 | * @param bool $isAdmin |
||
| 275 | * @return string |
||
| 276 | */ |
||
| 277 | private function getXoopsVersionTemplatesLine($moduleDirname, $type, $extra = '', $isAdmin = false) |
||
| 294 | } |
||
| 295 | |||
| 296 | /** |
||
| 297 | * @private function getXoopsVersionTemplatesUser |
||
| 298 | * @param $moduleDirname |
||
| 299 | * @param $tables |
||
| 300 | * @return string |
||
| 301 | */ |
||
| 302 | private function getXoopsVersionTemplatesUser($moduleDirname, $tables) |
||
| 303 | { |
||
| 304 | $ret = Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('User'); |
||
| 305 | |||
| 306 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', ''); |
||
| 307 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', ''); |
||
| 308 | $tableBroken = []; |
||
| 309 | $tablePdf = []; |
||
| 310 | $tablePrint = []; |
||
| 311 | $tableRate = []; |
||
| 312 | $tableRss = []; |
||
| 313 | $tableSearch = []; |
||
| 314 | $tableSingle = []; |
||
| 315 | $tableSubmit = []; |
||
| 316 | foreach (array_keys($tables) as $t) { |
||
| 317 | $tableName = $tables[$t]->getVar('table_name'); |
||
| 318 | $tableBroken[] = $tables[$t]->getVar('table_broken'); |
||
| 319 | $tablePdf[] = $tables[$t]->getVar('table_pdf'); |
||
| 320 | $tablePrint[] = $tables[$t]->getVar('table_print'); |
||
| 321 | $tableRate[] = $tables[$t]->getVar('table_rate'); |
||
| 322 | $tableRss[] = $tables[$t]->getVar('table_rss'); |
||
| 323 | $tableSearch[] = $tables[$t]->getVar('table_search'); |
||
| 324 | $tableSingle[] = $tables[$t]->getVar('table_single'); |
||
| 325 | $tableSubmit[] = $tables[$t]->getVar('table_submit'); |
||
| 326 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, ''); |
||
| 327 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, 'list'); |
||
| 328 | } |
||
| 329 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'breadcrumbs', ''); |
||
| 330 | if (in_array(1, $tableBroken)) { |
||
| 331 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'broken', ''); |
||
| 332 | } |
||
| 333 | if (in_array(1, $tablePdf)) { |
||
| 334 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'pdf', ''); |
||
| 335 | } |
||
| 336 | if (in_array(1, $tablePrint)) { |
||
| 337 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'print', ''); |
||
| 338 | } |
||
| 339 | if (in_array(1, $tableRate)) { |
||
| 340 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'rate', ''); |
||
| 341 | } |
||
| 342 | if (in_array(1, $tableRss)) { |
||
| 343 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'rss', ''); |
||
| 344 | } |
||
| 345 | if (in_array(1, $tableSearch)) { |
||
| 346 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'search', ''); |
||
| 347 | } |
||
| 348 | if (in_array(1, $tableSingle)) { |
||
| 349 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'single', ''); |
||
| 350 | } |
||
| 351 | if (in_array(1, $tableSubmit)) { |
||
| 352 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'submit', ''); |
||
| 353 | } |
||
| 354 | $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', ''); |
||
| 355 | |||
| 356 | return $ret; |
||
| 357 | } |
||
| 358 | |||
| 359 | /** |
||
| 360 | * @private function getXoopsVersionSubmenu |
||
| 361 | * @param $language |
||
| 362 | * @param $tables |
||
| 363 | * @return string |
||
| 364 | */ |
||
| 365 | private function getXoopsVersionSubmenu($language, $tables) |
||
| 366 | { |
||
| 367 | $phpCodeVSubmenu = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 368 | $uCodeVSubmenu = UserXoopsCode::getInstance(); |
||
| 369 | $ret = $this->getDashComment('Submenu'); |
||
| 370 | $i = 1; |
||
| 371 | $tableSubmit = []; |
||
| 372 | foreach (array_keys($tables) as $t) { |
||
| 373 | $tableName = $tables[$t]->getVar('table_name'); |
||
| 374 | $tableSubmit[] = $tables[$t]->getVar('table_submit'); |
||
| 375 | if (1 == $tables[$t]->getVar('table_submenu')) { |
||
| 376 | $ret .= $phpCodeVSubmenu->getPhpCodeCommentLine('Sub', $tableName); |
||
| 377 | $tname = ['name' => "{$language}SMNAME{$i}", 'url' => "'{$tableName}.php'"]; |
||
| 378 | $ret .= $uCodeVSubmenu->getUserModVersion(3, $tname, 'sub', $i); |
||
| 379 | } |
||
| 380 | ++$i; |
||
| 381 | } |
||
| 382 | if (in_array(1, $tableSubmit)) { |
||
| 383 | $ret .= $phpCodeVSubmenu->getPhpCodeCommentLine('Sub', 'Submit'); |
||
| 384 | $submit = ['name' => "{$language}SMNAME{$i}", 'url' => "'submit.php'"]; |
||
| 385 | $ret .= $uCodeVSubmenu->getUserModVersion(3, $submit, 'sub', $i); |
||
| 386 | } |
||
| 387 | unset($i); |
||
| 388 | |||
| 389 | return $ret; |
||
| 390 | } |
||
| 391 | |||
| 392 | /** |
||
| 393 | * @private function getXoopsVersionBlocks |
||
| 394 | * @param $moduleDirname |
||
| 395 | * @param $tables |
||
| 396 | * @param $language |
||
| 397 | * @return string |
||
| 398 | */ |
||
| 399 | private function getXoopsVersionBlocks($moduleDirname, $tables, $language) |
||
| 400 | { |
||
| 401 | $ret = $this->getDashComment('Blocks'); |
||
| 402 | $ret .= $this->getSimpleString('$b = 1;'); |
||
| 403 | $tableCategory = []; |
||
| 404 | foreach (array_keys($tables) as $i) { |
||
| 405 | $tableName = $tables[$i]->getVar('table_name'); |
||
| 406 | $tableFieldName = $tables[$i]->getVar('table_fieldname'); |
||
| 407 | $tableSoleName = $tables[$i]->getVar('table_solename'); |
||
| 408 | $stuTableSoleName = mb_strtoupper($tableSoleName); |
||
| 409 | $tableCategory[] = $tables[$i]->getVar('table_category'); |
||
| 410 | if (in_array(1, $tableCategory)) { |
||
| 411 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $tableFieldName); |
||
| 412 | } else { |
||
| 413 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'LAST', $language, 'last'); |
||
| 414 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'NEW', $language, 'new'); |
||
| 415 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'HITS', $language, 'hits'); |
||
| 416 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'TOP', $language, 'top'); |
||
| 417 | $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'RANDOM', $language, 'random'); |
||
| 418 | } |
||
| 419 | } |
||
| 420 | $ret .= $this->getSimpleString('unset($b);'); |
||
| 421 | |||
| 422 | return $ret; |
||
| 423 | } |
||
| 424 | |||
| 425 | /** |
||
| 426 | * @private function getXoopsVersionTypeBlocks |
||
| 427 | * @param $moduleDirname |
||
| 428 | * @param $tableName |
||
| 429 | * @param $stuTableSoleName |
||
| 430 | * @param $language |
||
| 431 | * @param $type |
||
| 432 | * @return string |
||
| 433 | */ |
||
| 434 | private function getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $type) |
||
| 435 | { |
||
| 436 | $phpCodeVTBlocks = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 437 | $uCodeVTBlocks = UserXoopsCode::getInstance(); |
||
| 438 | $stuTableName = mb_strtoupper($tableName); |
||
| 439 | $ucfTableName = ucfirst($tableName); |
||
| 440 | $ret = $phpCodeVTBlocks->getPhpCodeCommentLine($ucfTableName); |
||
| 441 | $blocks = [ |
||
| 442 | 'file' => "'{$tableName}.php'", |
||
| 443 | 'name' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}", |
||
| 444 | 'description' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}_DESC", |
||
| 445 | 'show_func' => "'b_{$moduleDirname}_{$tableName}_show'", |
||
| 446 | 'edit_func' => "'b_{$moduleDirname}_{$tableName}_edit'", |
||
| 447 | 'template' => "'{$moduleDirname}_block_{$tableName}.tpl'", |
||
| 448 | 'options' => "'{$type}|5|25|0'", |
||
| 449 | ]; |
||
| 450 | $ret .= $uCodeVTBlocks->getUserModVersion(3, $blocks, 'blocks', '$b'); |
||
| 451 | $ret .= $this->getSimpleString('++$b;'); |
||
| 452 | |||
| 453 | return $ret; |
||
| 454 | } |
||
| 455 | |||
| 456 | /** |
||
| 457 | * @private function getXoopsVersionConfig |
||
| 458 | * @param $module |
||
| 459 | * @param $tables |
||
| 460 | * @param $language |
||
| 461 | * |
||
| 462 | * @return string |
||
| 463 | */ |
||
| 464 | private function getXoopsVersionConfig($module, $tables, $language) |
||
| 465 | { |
||
| 466 | $phpCodeVConfig = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 467 | $xCodeVConfig = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 468 | $uCodeVConfig = UserXoopsCode::getInstance(); |
||
| 469 | $moduleDirname = $module->getVar('mod_dirname'); |
||
| 470 | $ret = $this->getDashComment('Config'); |
||
| 471 | $ret .= $this->getSimpleString('$c = 1;'); |
||
| 472 | |||
| 473 | $table_permissions = 0; |
||
| 474 | $table_admin = 0; |
||
| 475 | $table_user = 0; |
||
| 476 | $table_tag = 0; |
||
| 477 | $field_images = 0; |
||
| 478 | foreach ($tables as $table) { |
||
| 479 | $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
||
| 480 | foreach (array_keys($fields) as $f) { |
||
| 481 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 482 | switch ($fieldElement) { |
||
| 483 | case '3': |
||
| 484 | case '4': |
||
| 485 | case 3: |
||
| 486 | case 4: |
||
| 487 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 488 | $rpFieldName = $this->getRightString($fieldName); |
||
| 489 | $ucfFieldName = ucfirst($rpFieldName); |
||
| 490 | $stuFieldName = mb_strtoupper($rpFieldName); |
||
| 491 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Editor', $rpFieldName); |
||
| 492 | $ret .= $xCodeVConfig->getXcLoad('xoopseditorhandler'); |
||
| 493 | $ret .= $xCodeVConfig->getXcEqualsOperator('$editorHandler' . $ucfFieldName, 'XoopsEditorHandler::getInstance()'); |
||
| 494 | $editor = [ |
||
| 495 | 'name' => "'editor_{$rpFieldName}'", |
||
| 496 | 'title' => "'{$language}EDITOR_{$stuFieldName}'", |
||
| 497 | 'description' => "'{$language}EDITOR_{$stuFieldName}_DESC'", |
||
| 498 | 'formtype' => "'select'", |
||
| 499 | 'valuetype' => "'text'", |
||
| 500 | 'default' => "'dhtml'", |
||
| 501 | 'options' => 'array_flip($editorHandler' . $ucfFieldName . '->getList())', |
||
| 502 | ]; |
||
| 503 | $ret .= $uCodeVConfig->getUserModVersion(3, $editor, 'config', '$c'); |
||
| 504 | $ret .= $this->getSimpleString('++$c;'); |
||
| 505 | break; |
||
| 506 | case '10': |
||
| 507 | case '11': |
||
| 508 | case '12': |
||
| 509 | case '13': |
||
| 510 | case '14': |
||
| 511 | case 10: |
||
| 512 | case 11: |
||
| 513 | case 12: |
||
| 514 | case 13: |
||
| 515 | case 14: |
||
| 516 | $field_images = 1; |
||
| 517 | break; |
||
| 518 | case 'else': |
||
| 519 | default: |
||
| 520 | break; |
||
| 521 | } |
||
| 522 | } |
||
| 523 | if (1 == $table->getVar('table_permissions')) { |
||
| 524 | $table_permissions = 1; |
||
| 525 | } |
||
| 526 | if (1 == $table->getVar('table_admin')) { |
||
| 527 | $table_admin = 1; |
||
| 528 | } |
||
| 529 | if (1 == $table->getVar('table_user')) { |
||
| 530 | $table_user = 1; |
||
| 531 | } |
||
| 532 | if (1 == $table->getVar('table_tag')) { |
||
| 533 | $table_tag = 1; |
||
| 534 | } |
||
| 535 | } |
||
| 536 | |||
| 537 | if (1 === $table_permissions) { |
||
| 538 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Get groups'); |
||
| 539 | $ret .= $xCodeVConfig->getXcEqualsOperator('$memberHandler ', "xoops_getHandler('member')", '', false); |
||
| 540 | $ret .= $xCodeVConfig->getXcEqualsOperator('$xoopsGroups ', '$memberHandler->getGroupList()'); |
||
| 541 | $group = $xCodeVConfig->getXcEqualsOperator('$groups[$group] ', '$key', null, false, "\t"); |
||
| 542 | $ret .= $phpCodeVConfig->getPhpCodeForeach('xoopsGroups', false, 'key', 'group', $group); |
||
| 543 | $groups = [ |
||
| 544 | 'name' => "'groups'", |
||
| 545 | 'title' => "'{$language}GROUPS'", |
||
| 546 | 'description' => "'{$language}GROUPS_DESC'", |
||
| 547 | 'formtype' => "'select_multi'", |
||
| 548 | 'valuetype' => "'array'", |
||
| 549 | 'default' => '$groups', |
||
| 550 | 'options' => '$groups', |
||
| 551 | ]; |
||
| 552 | $ret .= $uCodeVConfig->getUserModVersion(3, $groups, 'config', '$c'); |
||
| 553 | $ret .= $this->getSimpleString('++$c;'); |
||
| 554 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Get Admin groups'); |
||
| 555 | $ret .= $xCodeVConfig->getXcEqualsOperator('$criteria ', 'new \CriteriaCompo()'); |
||
| 556 | $ret .= $this->getSimpleString("\$criteria->add( new \Criteria( 'group_type', 'Admin' ) );"); |
||
| 557 | $ret .= $xCodeVConfig->getXcEqualsOperator('$memberHandler ', "xoops_getHandler('member')", '', false); |
||
| 558 | $ret .= $xCodeVConfig->getXcEqualsOperator('$adminXoopsGroups ', '$memberHandler->getGroupList($criteria)'); |
||
| 559 | $adminGroup = $xCodeVConfig->getXcEqualsOperator('$adminGroups[$adminGroup] ', '$key', null, false, "\t"); |
||
| 560 | $ret .= $phpCodeVConfig->getPhpCodeForeach('adminXoopsGroups', false, 'key', 'adminGroup', $adminGroup); |
||
| 561 | $adminGroups = [ |
||
| 562 | 'name' => "'admin_groups'", |
||
| 563 | 'title' => "'{$language}GROUPS'", |
||
| 564 | 'description' => "'{$language}GROUPS_DESC'", |
||
| 565 | 'formtype' => "'select_multi'", |
||
| 566 | 'valuetype' => "'array'", |
||
| 567 | 'default' => '$adminGroups', |
||
| 568 | 'options' => '$adminGroups', |
||
| 569 | ]; |
||
| 570 | $ret .= $uCodeVConfig->getUserModVersion(3, $adminGroups, 'config', '$c'); |
||
| 571 | $ret .= $this->getSimpleString('++$c;'); |
||
| 572 | } |
||
| 573 | $keyword = implode(', ', $this->getKeywords()); |
||
| 574 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Keywords'); |
||
| 575 | $arrayKeyword = [ |
||
| 576 | 'name' => "'keywords'", |
||
| 577 | 'title' => "'{$language}KEYWORDS'", |
||
| 578 | 'description' => "'{$language}KEYWORDS_DESC'", |
||
| 579 | 'formtype' => "'textbox'", |
||
| 580 | 'valuetype' => "'text'", |
||
| 581 | 'default' => "'{$moduleDirname}, {$keyword}'", |
||
| 582 | ]; |
||
| 583 | $ret .= $uCodeVConfig->getUserModVersion(3, $arrayKeyword, 'config', '$c'); |
||
| 584 | $ret .= $this->getSimpleString('++$c;'); |
||
| 585 | unset($this->keywords); |
||
|
|
|||
| 586 | |||
| 587 | if (1 === $field_images) { |
||
| 588 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Uploads : maxsize of image'); |
||
| 589 | $maxsize = [ |
||
| 590 | 'name' => "'maxsize'", |
||
| 591 | 'title' => "'{$language}MAXSIZE'", |
||
| 592 | 'description' => "'{$language}MAXSIZE_DESC'", |
||
| 593 | 'formtype' => "'textbox'", |
||
| 594 | 'valuetype' => "'int'", |
||
| 595 | 'default' => '5000000', |
||
| 596 | ]; |
||
| 597 | $ret .= $uCodeVConfig->getUserModVersion(3, $maxsize, 'config', '$c'); |
||
| 598 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Uploads : mimetypes of image'); |
||
| 599 | $ret .= $this->getSimpleString('++$c;'); |
||
| 600 | $mimetypes = [ |
||
| 601 | 'name' => "'mimetypes'", |
||
| 602 | 'title' => "'{$language}MIMETYPES'", |
||
| 603 | 'description' => "'{$language}MIMETYPES_DESC'", |
||
| 604 | 'formtype' => "'select_multi'", |
||
| 605 | 'valuetype' => "'array'", |
||
| 606 | 'default' => "array('image/gif', 'image/jpeg', 'image/png')", |
||
| 607 | 'options' => "array('bmp' => 'image/bmp','gif' => 'image/gif','pjpeg' => 'image/pjpeg', 'jpeg' => 'image/jpeg','jpg' => 'image/jpg','jpe' => 'image/jpe', 'png' => 'image/png')", |
||
| 608 | ]; |
||
| 609 | $ret .= $uCodeVConfig->getUserModVersion(3, $mimetypes, 'config', '$c'); |
||
| 610 | $ret .= $this->getSimpleString('++$c;'); |
||
| 611 | } |
||
| 612 | if (1 === $table_admin) { |
||
| 613 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Admin pager'); |
||
| 614 | $adminPager = [ |
||
| 615 | 'name' => "'adminpager'", |
||
| 616 | 'title' => "'{$language}ADMIN_PAGER'", |
||
| 617 | 'description' => "'{$language}ADMIN_PAGER_DESC'", |
||
| 618 | 'formtype' => "'textbox'", |
||
| 619 | 'valuetype' => "'int'", |
||
| 620 | 'default' => '10', |
||
| 621 | ]; |
||
| 622 | $ret .= $uCodeVConfig->getUserModVersion(3, $adminPager, 'config', '$c'); |
||
| 623 | $ret .= $this->getSimpleString('++$c;'); |
||
| 624 | } |
||
| 625 | if (1 === $table_user) { |
||
| 626 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('User pager'); |
||
| 627 | $userPager = [ |
||
| 628 | 'name' => "'userpager'", |
||
| 629 | 'title' => "'{$language}USER_PAGER'", |
||
| 630 | 'description' => "'{$language}USER_PAGER_DESC'", |
||
| 631 | 'formtype' => "'textbox'", |
||
| 632 | 'valuetype' => "'int'", |
||
| 633 | 'default' => '10', |
||
| 634 | ]; |
||
| 635 | $ret .= $uCodeVConfig->getUserModVersion(3, $userPager, 'config', '$c'); |
||
| 636 | $ret .= $this->getSimpleString('++$c;'); |
||
| 637 | } |
||
| 638 | if (1 === $table_tag) { |
||
| 639 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Use tag'); |
||
| 640 | $useTag = [ |
||
| 641 | 'name' => "'usetag'", |
||
| 642 | 'title' => "'{$language}USE_TAG'", |
||
| 643 | 'description' => "'{$language}USE_TAG_DESC'", |
||
| 644 | 'formtype' => "'yesno'", |
||
| 645 | 'valuetype' => "'int'", |
||
| 646 | 'default' => '0', |
||
| 647 | ]; |
||
| 648 | $ret .= $uCodeVConfig->getUserModVersion(3, $useTag, 'config', '$c'); |
||
| 649 | $ret .= $this->getSimpleString('++$c;'); |
||
| 650 | } |
||
| 651 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Number column'); |
||
| 652 | $numbCol = [ |
||
| 653 | 'name' => "'numb_col'", |
||
| 654 | 'title' => "'{$language}NUMB_COL'", |
||
| 655 | 'description' => "'{$language}NUMB_COL_DESC'", |
||
| 656 | 'formtype' => "'select'", |
||
| 657 | 'valuetype' => "'int'", |
||
| 658 | 'default' => '1', |
||
| 659 | 'options' => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')", |
||
| 660 | ]; |
||
| 661 | $ret .= $uCodeVConfig->getUserModVersion(3, $numbCol, 'config', '$c'); |
||
| 662 | $ret .= $this->getSimpleString('++$c;'); |
||
| 663 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Divide by'); |
||
| 664 | $divideby = [ |
||
| 665 | 'name' => "'divideby'", |
||
| 666 | 'title' => "'{$language}DIVIDEBY'", |
||
| 667 | 'description' => "'{$language}DIVIDEBY_DESC'", |
||
| 668 | 'formtype' => "'select'", |
||
| 669 | 'valuetype' => "'int'", |
||
| 670 | 'default' => '1', |
||
| 671 | 'options' => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')", |
||
| 672 | ]; |
||
| 673 | $ret .= $uCodeVConfig->getUserModVersion(3, $divideby, 'config', '$c'); |
||
| 674 | $ret .= $this->getSimpleString('++$c;'); |
||
| 675 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Table type'); |
||
| 676 | $tableType = [ |
||
| 677 | 'name' => "'table_type'", |
||
| 678 | 'title' => "'{$language}TABLE_TYPE'", |
||
| 679 | 'description' => "'{$language}DIVIDEBY_DESC'", |
||
| 680 | 'formtype' => "'select'", |
||
| 681 | 'valuetype' => "'int'", |
||
| 682 | 'default' => "'bordered'", |
||
| 683 | 'options' => "array('bordered' => 'bordered', 'striped' => 'striped', 'hover' => 'hover', 'condensed' => 'condensed')", |
||
| 684 | ]; |
||
| 685 | $ret .= $uCodeVConfig->getUserModVersion(3, $tableType, 'config', '$c'); |
||
| 686 | $ret .= $this->getSimpleString('++$c;'); |
||
| 687 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Panel by'); |
||
| 688 | $panelType = [ |
||
| 689 | 'name' => "'panel_type'", |
||
| 690 | 'title' => "'{$language}PANEL_TYPE'", |
||
| 691 | 'description' => "'{$language}PANEL_TYPE_DESC'", |
||
| 692 | 'formtype' => "'select'", |
||
| 693 | 'valuetype' => "'text'", |
||
| 694 | 'default' => "'default'", |
||
| 695 | 'options' => "array('default' => 'default', 'primary' => 'primary', 'success' => 'success', 'info' => 'info', 'warning' => 'warning', 'danger' => 'danger')", |
||
| 696 | ]; |
||
| 697 | $ret .= $uCodeVConfig->getUserModVersion(3, $panelType, 'config', '$c'); |
||
| 698 | $ret .= $this->getSimpleString('++$c;'); |
||
| 699 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Advertise'); |
||
| 700 | $advertise = [ |
||
| 701 | 'name' => "'advertise'", |
||
| 702 | 'title' => "'{$language}ADVERTISE'", |
||
| 703 | 'description' => "'{$language}ADVERTISE_DESC'", |
||
| 704 | 'formtype' => "'textarea'", |
||
| 705 | 'valuetype' => "'text'", |
||
| 706 | 'default' => "''", |
||
| 707 | ]; |
||
| 708 | $ret .= $uCodeVConfig->getUserModVersion(3, $advertise, 'config', '$c'); |
||
| 709 | $ret .= $this->getSimpleString('++$c;'); |
||
| 710 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Bookmarks'); |
||
| 711 | $bookmarks = [ |
||
| 712 | 'name' => "'bookmarks'", |
||
| 713 | 'title' => "'{$language}BOOKMARKS'", |
||
| 714 | 'description' => "'{$language}BOOKMARKS_DESC'", |
||
| 715 | 'formtype' => "'yesno'", |
||
| 716 | 'valuetype' => "'int'", |
||
| 717 | 'default' => '0', |
||
| 718 | ]; |
||
| 719 | $ret .= $uCodeVConfig->getUserModVersion(3, $bookmarks, 'config', '$c'); |
||
| 720 | $ret .= $this->getSimpleString('++$c;'); |
||
| 721 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Facebook Comments'); |
||
| 722 | $facebookComments = [ |
||
| 723 | 'name' => "'facebook_comments'", |
||
| 724 | 'title' => "'{$language}FACEBOOK_COMMENTS'", |
||
| 725 | 'description' => "'{$language}FACEBOOK_COMMENTS_DESC'", |
||
| 726 | 'formtype' => "'yesno'", |
||
| 727 | 'valuetype' => "'int'", |
||
| 728 | 'default' => '0', |
||
| 729 | ]; |
||
| 730 | $ret .= $uCodeVConfig->getUserModVersion(3, $facebookComments, 'config', '$c'); |
||
| 731 | $ret .= $this->getSimpleString('++$c;'); |
||
| 732 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Disqus Comments'); |
||
| 733 | $disqusComments = [ |
||
| 734 | 'name' => "'disqus_comments'", |
||
| 735 | 'title' => "'{$language}DISQUS_COMMENTS'", |
||
| 736 | 'description' => "'{$language}DISQUS_COMMENTS_DESC'", |
||
| 737 | 'formtype' => "'yesno'", |
||
| 738 | 'valuetype' => "'int'", |
||
| 739 | 'default' => '0', |
||
| 740 | ]; |
||
| 741 | $ret .= $uCodeVConfig->getUserModVersion(3, $disqusComments, 'config', '$c'); |
||
| 742 | $ret .= $this->getSimpleString('++$c;'); |
||
| 743 | $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Maintained by'); |
||
| 744 | $maintainedby = [ |
||
| 745 | 'name' => "'maintainedby'", |
||
| 746 | 'title' => "'{$language}MAINTAINEDBY'", |
||
| 747 | 'description' => "'{$language}MAINTAINEDBY_DESC'", |
||
| 748 | 'formtype' => "'textbox'", |
||
| 749 | 'valuetype' => "'text'", |
||
| 750 | 'default' => "'{$module->getVar('mod_support_url')}'", |
||
| 751 | ]; |
||
| 752 | $ret .= $uCodeVConfig->getUserModVersion(3, $maintainedby, 'config', '$c'); |
||
| 753 | $ret .= $this->getSimpleString('unset($c);'); |
||
| 754 | |||
| 755 | return $ret; |
||
| 756 | } |
||
| 757 | |||
| 758 | /** |
||
| 759 | * @private function getNotificationsType |
||
| 760 | * @param $language |
||
| 761 | * @param $type |
||
| 762 | * @param $tableName |
||
| 763 | * @param $notifyFile |
||
| 764 | * @param $item |
||
| 765 | * @param $typeOfNotify |
||
| 766 | * |
||
| 767 | * @return string |
||
| 768 | */ |
||
| 769 | private function getNotificationsType($language, $type, $tableName, $notifyFile, $item, $typeOfNotify) |
||
| 770 | { |
||
| 771 | $phpCodeNType = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 772 | $uCodeNType = UserXoopsCode::getInstance(); |
||
| 773 | $stuTableName = mb_strtoupper($tableName); |
||
| 774 | $stuTypeOfNotify = mb_strtoupper($typeOfNotify); |
||
| 775 | $notifyFile = explode(', ', $notifyFile); |
||
| 776 | $notifyFile = implode(', ', $notifyFile); |
||
| 777 | $ret = ''; |
||
| 778 | switch ($type) { |
||
| 779 | case 'category': |
||
| 780 | $ret .= $phpCodeNType->getPhpCodeCommentLine('Category Notify'); |
||
| 781 | $category = [ |
||
| 782 | 'name' => "'category'", |
||
| 783 | 'title' => "'{$language}{$stuTableName}_NOTIFY'", |
||
| 784 | 'description' => "'{$language}{$stuTableName}_NOTIFY_DESC'", |
||
| 785 | 'subscribe_from' => "array('index.php',{$notifyFile})", |
||
| 786 | 'item_name' => "'{$item}'", |
||
| 787 | "'allow_bookmark'" => '1', |
||
| 788 | ]; |
||
| 789 | $ret .= $uCodeNType->getUserModVersion(3, $category, 'notification', "'{$type}'"); |
||
| 790 | break; |
||
| 791 | case 'event': |
||
| 792 | $ret .= $phpCodeNType->getPhpCodeCommentLine('Event Notify'); |
||
| 793 | $event = [ |
||
| 794 | 'name' => "'{$typeOfNotify}'", |
||
| 795 | 'category' => "'{$tableName}'", |
||
| 796 | 'admin_only' => '1', |
||
| 797 | "'title'" => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY'", |
||
| 798 | 'caption' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_CAPTION'", |
||
| 799 | 'description' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_DESC'", |
||
| 800 | 'mail_template' => "'{$tableName}_{$typeOfNotify}_notify'", |
||
| 801 | 'mail_subject' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_SUBJECT'", |
||
| 802 | ]; |
||
| 803 | $ret .= $uCodeNType->getUserModVersion(3, $event, 'notification', "'{$type}'"); |
||
| 804 | break; |
||
| 805 | } |
||
| 806 | |||
| 807 | return $ret; |
||
| 808 | } |
||
| 809 | |||
| 810 | /** |
||
| 811 | * @private function getXoopsVersionNotifications |
||
| 812 | * @param $module |
||
| 813 | * @param $language |
||
| 814 | * @return string |
||
| 815 | */ |
||
| 816 | private function getXoopsVersionNotifications($module, $language) |
||
| 817 | { |
||
| 818 | $uCodeVN = UserXoopsCode::getInstance(); |
||
| 819 | $moduleDirname = $module->getVar('mod_dirname'); |
||
| 820 | $ret = $this->getDashComment('Notifications'); |
||
| 821 | $ret .= $uCodeVN->getUserModVersion(1, 1, 'hasNotification'); |
||
| 822 | $notifications = ["'lookup_file'" => "'include/notification.inc.php'", "'lookup_func'" => "'{$moduleDirname}_notify_iteminfo'"]; |
||
| 823 | $ret .= $uCodeVN->getUserModVersion(2, $notifications, 'notification'); |
||
| 824 | |||
| 825 | $notifyFiles = []; |
||
| 826 | $single = 'single'; |
||
| 827 | $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
||
| 828 | $tableCategory = []; |
||
| 829 | $tableBroken = []; |
||
| 830 | $tableSubmit = []; |
||
| 831 | $tableId = null; |
||
| 832 | $tableMid = null; |
||
| 833 | foreach (array_keys($tables) as $t) { |
||
| 834 | $tableId = $tables[$t]->getVar('table_id'); |
||
| 835 | $tableMid = $tables[$t]->getVar('table_mid'); |
||
| 836 | $tableName = $tables[$t]->getVar('table_name'); |
||
| 837 | $tableSoleName = $tables[$t]->getVar('table_solename'); |
||
| 838 | $tableCategory[] = $tables[$t]->getVar('table_category'); |
||
| 839 | $tableBroken[] = $tables[$t]->getVar('table_broken'); |
||
| 840 | $tableSubmit[] = $tables[$t]->getVar('table_submit'); |
||
| 841 | if (1 == $tables[$t]->getVar('table_notifications')) { |
||
| 842 | if ($t <= count($tableName)) { |
||
| 843 | $notifyFiles[] = $tables[$t]->getVar('table_name'); |
||
| 844 | } |
||
| 845 | } |
||
| 846 | if (1 == $tables[$t]->getVar('table_single')) { |
||
| 847 | $single = $tableName; |
||
| 848 | } |
||
| 849 | } |
||
| 850 | $fields = $this->getTableFields($tableMid, $tableId); |
||
| 851 | $fieldId = null; |
||
| 852 | $fieldParent = null; |
||
| 853 | foreach (array_keys($fields) as $f) { |
||
| 854 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 855 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 856 | if (0 == $f) { |
||
| 857 | $fieldId = $fieldName; |
||
| 858 | } |
||
| 859 | if ($fieldElement > 15) { |
||
| 860 | $fieldParent = $fieldName; |
||
| 861 | } |
||
| 862 | } |
||
| 863 | |||
| 864 | $num = 1; |
||
| 865 | $ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', 'global', $notifyFiles, $num); |
||
| 866 | ++$num; |
||
| 867 | $ret .= $this->getXoopsVersionNotificationCategory($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1', $num); |
||
| 868 | ++$num; |
||
| 869 | $ret .= $this->getXoopsVersionNotificationTableName($language, 'category', $tableSoleName, $tableSoleName, $single, $fieldId, 1, $num); |
||
| 870 | unset($num); |
||
| 871 | $num = 1; |
||
| 872 | if (in_array(1, $tableCategory)) { |
||
| 873 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'global', 0, 'global', 'newcategory', 'global_newcategory_notify', $num); |
||
| 874 | ++$num; |
||
| 875 | } |
||
| 876 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_modify', 'global', 1, 'global', $tableSoleName . 'modify', 'global_' . $tableSoleName . 'modify_notify', $num); |
||
| 877 | if (in_array(1, $tableBroken)) { |
||
| 878 | ++$num; |
||
| 879 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_broken', 'global', 1, 'global', $tableSoleName . 'broken', 'global_' . $tableSoleName . 'broken_notify', $num); |
||
| 880 | } |
||
| 881 | if (in_array(1, $tableSubmit)) { |
||
| 882 | ++$num; |
||
| 883 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_submit', 'global', 1, 'global', $tableSoleName . 'submit', 'global_' . $tableSoleName . 'submit_notify', $num); |
||
| 884 | } |
||
| 885 | ++$num; |
||
| 886 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_' . $tableSoleName, 'global', 0, 'global', 'new' . $tableSoleName, 'global_new' . $tableSoleName . '_notify', $num); |
||
| 887 | if (in_array(1, $tableCategory)) { |
||
| 888 | ++$num; |
||
| 889 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_submit', 'category', 1, 'category', $tableSoleName . 'submit', 'category_' . $tableSoleName . 'submit_notify', $num); |
||
| 890 | ++$num; |
||
| 891 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_' . $tableSoleName, 'category', 0, 'category', 'new' . $tableSoleName, 'category_new' . $tableSoleName . '_notify', $num); |
||
| 892 | } |
||
| 893 | ++$num; |
||
| 894 | $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'approve', $tableSoleName, 1, $tableSoleName, 'approve', $tableSoleName . '_approve_notify', $num); |
||
| 895 | unset($num); |
||
| 896 | |||
| 897 | return $ret; |
||
| 898 | } |
||
| 899 | |||
| 900 | /** |
||
| 901 | * @private function getXoopsVersionNotificationGlobal |
||
| 902 | * @param $language |
||
| 903 | * @param $type |
||
| 904 | * @param $name |
||
| 905 | * @param $title |
||
| 906 | * @param $from |
||
| 907 | * |
||
| 908 | * @param $num |
||
| 909 | * @return string |
||
| 910 | */ |
||
| 911 | private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from, $num) |
||
| 927 | } |
||
| 928 | |||
| 929 | /** |
||
| 930 | * @private function getXoopsVersionNotificationCategory |
||
| 931 | * @param $language |
||
| 932 | * @param $type |
||
| 933 | * @param $name |
||
| 934 | * @param $title |
||
| 935 | * @param $file |
||
| 936 | * @param $item |
||
| 937 | * @param $allow |
||
| 938 | * @param $num |
||
| 939 | * @return string |
||
| 940 | */ |
||
| 941 | private function getXoopsVersionNotificationCategory($language, $type, $name, $title, $file, $item, $allow, $num) |
||
| 959 | } |
||
| 960 | |||
| 961 | /** |
||
| 962 | * @private function getXoopsVersionNotificationTableName |
||
| 963 | * @param $language |
||
| 964 | * @param $type |
||
| 965 | * @param $name |
||
| 966 | * @param $title |
||
| 967 | * @param $file |
||
| 968 | * @param $item |
||
| 969 | * @param $allow |
||
| 970 | * |
||
| 971 | * @param $num |
||
| 972 | * @return string |
||
| 973 | */ |
||
| 974 | private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $file, $item, $allow, $num) |
||
| 975 | { |
||
| 976 | $phpCodeVNTN = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 977 | $uCodeVNTN = UserXoopsCode::getInstance(); |
||
| 978 | $stuTitle = mb_strtoupper($title); |
||
| 979 | $ucfTitle = ucfirst($title); |
||
| 980 | $ret = $phpCodeVNTN->getPhpCodeCommentLine($ucfTitle . ' Notify'); |
||
| 981 | $table = [ |
||
| 982 | 'name' => "'{$name}'", |
||
| 983 | 'title' => "{$language}{$stuTitle}_NOTIFY", |
||
| 984 | 'description' => "{$language}{$stuTitle}_NOTIFY_DESC", |
||
| 985 | 'subscribe_from' => "'{$file}.php'", |
||
| 986 | 'item_name' => "'{$item}'", |
||
| 987 | 'allow_bookmark' => (string)$allow, |
||
| 988 | ]; |
||
| 989 | $ret .= $uCodeVNTN->getUserModVersion(4, $table, 'notification', "'{$type}'", $num); |
||
| 990 | |||
| 991 | return $ret; |
||
| 992 | } |
||
| 993 | |||
| 994 | /** |
||
| 995 | * @private function getXoopsVersionNotifications |
||
| 996 | * @param $language |
||
| 997 | * @param $type |
||
| 998 | * @param $name |
||
| 999 | * @param $category |
||
| 1000 | * @param $admin |
||
| 1001 | * @param $title |
||
| 1002 | * @param $table |
||
| 1003 | * @param $mail |
||
| 1004 | * |
||
| 1005 | * @param $num |
||
| 1006 | * @return string |
||
| 1007 | */ |
||
| 1008 | private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin, $title, $table, $mail, $num) |
||
| 1029 | } |
||
| 1030 | |||
| 1031 | /** |
||
| 1032 | * @public function render |
||
| 1033 | * @param null |
||
| 1034 | * @return bool|string |
||
| 1035 | */ |
||
| 1036 | public function render() |
||
| 1084 | } |
||
| 1085 | } |
||
| 1086 |