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