| Conditions | 7 |
| Paths | 8 |
| Total Lines | 56 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 68 | function xoops_module_install_lexikon(\XoopsModule $module) |
||
| 69 | { |
||
| 70 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 71 | |||
| 72 | $helper = Helper::getInstance(); |
||
| 73 | $utility = new Utility(); |
||
| 74 | $configurator = new Configurator(); |
||
| 75 | |||
| 76 | // Load language files |
||
| 77 | $helper->loadLanguage('admin'); |
||
| 78 | $helper->loadLanguage('modinfo'); |
||
| 79 | |||
| 80 | // default Permission Settings ---------------------- |
||
| 81 | $moduleId = $module->getVar('mid'); |
||
| 82 | |||
| 83 | //$moduleName = $module->getVar('name'); |
||
| 84 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 85 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 86 | // access rights ------------------------------------------ |
||
| 87 | $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
|
|
|||
| 88 | $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 89 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
||
| 90 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
||
| 91 | $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
||
| 92 | |||
| 93 | // --- CREATE FOLDERS --------------- |
||
| 94 | if (count($configurator->uploadFolders) > 0) { |
||
| 95 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
||
| 96 | foreach (array_keys($configurator->uploadFolders) as $i) { |
||
| 97 | $utility::createFolder($configurator->uploadFolders[$i]); |
||
| 98 | } |
||
| 99 | } |
||
| 100 | // --- COPY blank.png FILES --------------- |
||
| 101 | if (count($configurator->copyBlankFiles) > 0) { |
||
| 102 | $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
||
| 103 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
||
| 104 | $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
||
| 105 | $utility::copyFile($file, $dest); |
||
| 106 | } |
||
| 107 | } |
||
| 108 | |||
| 109 | // --- COPY test folder files --------------- |
||
| 110 | if (count($configurator->copyTestFolders) > 0) { |
||
| 111 | // $file = \dirname(__DIR__) . '/testdata/images/'; |
||
| 112 | foreach (array_keys($configurator->copyTestFolders) as $i) { |
||
| 113 | $src = $configurator->copyTestFolders[$i][0]; |
||
| 114 | $dest = $configurator->copyTestFolders[$i][1]; |
||
| 115 | $utility::rcopy($src, $dest); |
||
| 116 | } |
||
| 117 | } |
||
| 118 | |||
| 119 | //delete .html entries from the tpl table |
||
| 120 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
||
| 121 | $GLOBALS['xoopsDB']->queryF($sql); |
||
| 122 | |||
| 123 | return true; |
||
| 124 | } |
||
| 125 |