| Total Complexity | 57 |
| Total Lines | 427 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like Modules 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 Modules, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 33 | class Modules extends \XoopsObject |
||
| 34 | { |
||
| 35 | /** |
||
| 36 | * Options. |
||
| 37 | */ |
||
| 38 | public $options = [ |
||
| 39 | 'admin', |
||
| 40 | 'user', |
||
| 41 | 'blocks', |
||
| 42 | 'search', |
||
| 43 | 'comments', |
||
| 44 | 'notifications', |
||
| 45 | 'permissions', |
||
| 46 | //'inroot_copy', |
||
| 47 | ]; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @public function constructor class |
||
| 51 | * @param null |
||
| 52 | */ |
||
| 53 | public function __construct() |
||
| 54 | { |
||
| 55 | $helper = Tdmcreate\Helper::getInstance(); |
||
| 56 | $setId = \Xmf\Request::getInt('set_id'); |
||
| 57 | $settings = $helper->getHandler('Settings')->get($setId); |
||
| 58 | |||
| 59 | $this->initVar('mod_id', XOBJ_DTYPE_INT); |
||
| 60 | $this->initVar('mod_name', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_name')); |
||
| 61 | $this->initVar('mod_dirname', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_dirname')); |
||
| 62 | $this->initVar('mod_version', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_version')); |
||
| 63 | $this->initVar('mod_since', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_since')); |
||
| 64 | $this->initVar('mod_min_php', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_min_php')); |
||
| 65 | $this->initVar('mod_min_xoops', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_min_xoops')); |
||
| 66 | $this->initVar('mod_min_admin', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_min_admin')); |
||
| 67 | $this->initVar('mod_min_mysql', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_min_mysql')); |
||
| 68 | $this->initVar('mod_description', XOBJ_DTYPE_TXTAREA, $settings->getVar('set_description')); |
||
| 69 | $this->initVar('mod_author', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_author')); |
||
| 70 | $this->initVar('mod_author_mail', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_author_mail')); |
||
| 71 | $this->initVar('mod_author_website_url', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_author_website_url')); |
||
| 72 | $this->initVar('mod_author_website_name', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_author_website_name')); |
||
| 73 | $this->initVar('mod_credits', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_credits')); |
||
| 74 | $this->initVar('mod_license', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_license')); |
||
| 75 | $this->initVar('mod_release_info', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_release_info')); |
||
| 76 | $this->initVar('mod_release_file', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_release_file')); |
||
| 77 | $this->initVar('mod_manual', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_manual')); |
||
| 78 | $this->initVar('mod_manual_file', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_manual_file')); |
||
| 79 | $this->initVar('mod_image', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_image')); |
||
| 80 | $this->initVar('mod_demo_site_url', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_demo_site_url')); |
||
| 81 | $this->initVar('mod_demo_site_name', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_demo_site_name')); |
||
| 82 | $this->initVar('mod_support_url', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_support_url')); |
||
| 83 | $this->initVar('mod_support_name', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_support_name')); |
||
| 84 | $this->initVar('mod_website_url', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_website_url')); |
||
| 85 | $this->initVar('mod_website_name', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_website_name')); |
||
| 86 | $this->initVar('mod_release', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_release')); |
||
| 87 | $this->initVar('mod_status', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_status')); |
||
| 88 | $this->initVar('mod_admin', XOBJ_DTYPE_INT, $settings->getVar('set_admin')); |
||
| 89 | $this->initVar('mod_user', XOBJ_DTYPE_INT, $settings->getVar('set_user')); |
||
| 90 | $this->initVar('mod_blocks', XOBJ_DTYPE_INT, $settings->getVar('set_blocks')); |
||
| 91 | $this->initVar('mod_search', XOBJ_DTYPE_INT, $settings->getVar('set_search')); |
||
| 92 | $this->initVar('mod_comments', XOBJ_DTYPE_INT, $settings->getVar('set_comments')); |
||
| 93 | $this->initVar('mod_notifications', XOBJ_DTYPE_INT, $settings->getVar('set_notifications')); |
||
| 94 | $this->initVar('mod_permissions', XOBJ_DTYPE_INT, $settings->getVar('set_permissions')); |
||
| 95 | //$this->initVar('mod_inroot_copy', XOBJ_DTYPE_INT, $settings->getVar('set_inroot_copy')); |
||
| 96 | $this->initVar('mod_donations', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_donations')); |
||
| 97 | $this->initVar('mod_subversion', XOBJ_DTYPE_TXTBOX, $settings->getVar('set_subversion')); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @param string $method |
||
| 102 | * @param array $args |
||
| 103 | * |
||
| 104 | * @return mixed |
||
| 105 | */ |
||
| 106 | public function __call($method, $args) |
||
| 107 | { |
||
| 108 | $arg = isset($args[0]) ? $args[0] : null; |
||
| 109 | |||
| 110 | return $this->getVar($method, $arg); |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @static function getInstance |
||
| 115 | * @param null |
||
| 116 | * @return Modules |
||
| 117 | */ |
||
| 118 | public static function getInstance() |
||
| 119 | { |
||
| 120 | static $instance = false; |
||
| 121 | if (!$instance) { |
||
| 122 | $instance = new self(); |
||
| 123 | } |
||
| 124 | |||
| 125 | return $instance; |
||
| 126 | } |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @public function getFormModules |
||
| 130 | * @param mixed $action |
||
| 131 | * |
||
| 132 | * @return \XoopsThemeForm |
||
| 133 | */ |
||
| 134 | public function getFormModules($action = false) |
||
| 135 | { |
||
| 136 | $helper = Tdmcreate\Helper::getInstance(); |
||
| 137 | if (false === $action) { |
||
| 138 | $action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'); |
||
| 139 | } |
||
| 140 | $set = []; |
||
| 141 | $settings = $helper->getHandler('Settings')->getAllSettings(0, 0, 'set_type'); |
||
|
|
|||
| 142 | foreach ($settings as $setting) { |
||
| 143 | $set['name'] = $setting->getVar('set_name'); |
||
| 144 | $set['dirname'] = $setting->getVar('set_dirname'); |
||
| 145 | $set['version'] = $setting->getVar('set_version'); |
||
| 146 | $set['since'] = $setting->getVar('set_since'); |
||
| 147 | $set['min_php'] = $setting->getVar('set_min_php'); |
||
| 148 | $set['min_xoops'] = $setting->getVar('set_min_xoops'); |
||
| 149 | $set['min_admin'] = $setting->getVar('set_min_admin'); |
||
| 150 | $set['min_mysql'] = $setting->getVar('set_min_mysql'); |
||
| 151 | $set['description'] = $setting->getVar('set_description'); |
||
| 152 | $set['author'] = $setting->getVar('set_author'); |
||
| 153 | $set['license'] = $setting->getVar('set_license'); |
||
| 154 | $set['admin'] = $setting->getVar('set_admin'); |
||
| 155 | $set['user'] = $setting->getVar('set_user'); |
||
| 156 | $set['blocks'] = $setting->getVar('set_blocks'); |
||
| 157 | $set['search'] = $setting->getVar('set_search'); |
||
| 158 | $set['comments'] = $setting->getVar('set_comments'); |
||
| 159 | $set['notifications'] = $setting->getVar('set_notifications'); |
||
| 160 | $set['permissions'] = $setting->getVar('set_permissions'); |
||
| 161 | //$set['inroot'] = $setting->getVar('set_inroot_copy'); |
||
| 162 | $set['image'] = $setting->getVar('set_image'); |
||
| 163 | $set['author_mail'] = $setting->getVar('set_author_mail'); |
||
| 164 | $set['author_website_url'] = $setting->getVar('set_author_website_url'); |
||
| 165 | $set['author_website_name'] = $setting->getVar('set_author_website_name'); |
||
| 166 | $set['credits'] = $setting->getVar('set_credits'); |
||
| 167 | $set['release_info'] = $setting->getVar('set_release_info'); |
||
| 168 | $set['release_file'] = $setting->getVar('set_release_file'); |
||
| 169 | $set['manual'] = $setting->getVar('set_manual'); |
||
| 170 | $set['manual_file'] = $setting->getVar('set_manual_file'); |
||
| 171 | $set['demo_site_url'] = $setting->getVar('set_demo_site_url'); |
||
| 172 | $set['demo_site_name'] = $setting->getVar('set_demo_site_name'); |
||
| 173 | $set['support_url'] = $setting->getVar('set_support_url'); |
||
| 174 | $set['support_name'] = $setting->getVar('set_support_name'); |
||
| 175 | $set['website_url'] = $setting->getVar('set_website_url'); |
||
| 176 | $set['website_name'] = $setting->getVar('set_website_name'); |
||
| 177 | $set['release'] = $setting->getVar('set_release'); |
||
| 178 | $set['status'] = $setting->getVar('set_status'); |
||
| 179 | $set['donations'] = $setting->getVar('set_donations'); |
||
| 180 | $set['subversion'] = $setting->getVar('set_subversion'); |
||
| 181 | } |
||
| 182 | |||
| 183 | $isNew = $this->isNew(); |
||
| 184 | $title = $isNew ? sprintf(_AM_TDMCREATE_MODULE_NEW) : sprintf(_AM_TDMCREATE_MODULE_EDIT); |
||
| 185 | |||
| 186 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
| 187 | |||
| 188 | $form = new \XoopsThemeForm($title, 'moduleform', $action, 'post', true); |
||
| 189 | $form->setExtra('enctype="multipart/form-data"'); |
||
| 190 | |||
| 191 | $modName = $isNew ? $set['name'] : $this->getVar('mod_name'); |
||
| 192 | $modName = new \XoopsFormText(_AM_TDMCREATE_MODULE_NAME, 'mod_name', 50, 255, $modName); |
||
| 193 | $modName->setDescription(_AM_TDMCREATE_MODULE_NAME_DESC); |
||
| 194 | $form->addElement($modName, true); |
||
| 195 | |||
| 196 | $modDirname = $isNew ? $set['dirname'] : $this->getVar('mod_dirname'); |
||
| 197 | $modDirname = new \XoopsFormText(_AM_TDMCREATE_MODULE_DIRNAME, 'mod_dirname', 25, 255, $modDirname); |
||
| 198 | $modDirname->setDescription(_AM_TDMCREATE_MODULE_DIRNAME_DESC); |
||
| 199 | $form->addElement($modDirname, true); |
||
| 200 | |||
| 201 | $modVersion = $isNew ? $set['version'] : $this->getVar('mod_version'); |
||
| 202 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_VERSION, 'mod_version', 10, 25, $modVersion), true); |
||
| 203 | |||
| 204 | $modSince = $isNew ? $set['since'] : $this->getVar('mod_since'); |
||
| 205 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_SINCE, 'mod_since', 10, 25, $modSince), true); |
||
| 206 | |||
| 207 | $modMinPhp = $isNew ? $set['min_php'] : $this->getVar('mod_min_php'); |
||
| 208 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_MIN_PHP, 'mod_min_php', 10, 25, $modMinPhp), true); |
||
| 209 | |||
| 210 | $modMinXoops = $isNew ? $set['min_xoops'] : $this->getVar('mod_min_xoops'); |
||
| 211 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_MIN_XOOPS, 'mod_min_xoops', 10, 25, $modMinXoops), true); |
||
| 212 | |||
| 213 | $modMinAdmin = $isNew ? $set['min_admin'] : $this->getVar('mod_min_admin'); |
||
| 214 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_MIN_ADMIN, 'mod_min_admin', 10, 25, $modMinAdmin), true); |
||
| 215 | |||
| 216 | $modMinMysql = $isNew ? $set['min_mysql'] : $this->getVar('mod_min_mysql'); |
||
| 217 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_MIN_MYSQL, 'mod_min_mysql', 10, 25, $modMinMysql), true); |
||
| 218 | // Name description |
||
| 219 | $editorConfigs = []; |
||
| 220 | $editorConfigs['name'] = 'mod_description'; |
||
| 221 | $editorConfigs['value'] = $isNew ? $set['description'] : $this->getVar('mod_description', 'e'); |
||
| 222 | $editorConfigs['rows'] = 5; |
||
| 223 | $editorConfigs['cols'] = 100; |
||
| 224 | $editorConfigs['width'] = '50%'; |
||
| 225 | $editorConfigs['height'] = '100px'; |
||
| 226 | $editorConfigs['editor'] = $helper->getConfig('tdmcreate_editor'); |
||
| 227 | $form->addElement(new \XoopsFormEditor(_AM_TDMCREATE_MODULE_DESCRIPTION, 'mod_description', $editorConfigs), true); |
||
| 228 | // Author |
||
| 229 | $modAuthor = $isNew ? $set['author'] : $this->getVar('mod_author'); |
||
| 230 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR, 'mod_author', 50, 255, $modAuthor), true); |
||
| 231 | $modLicense = $isNew ? $set['license'] : $this->getVar('mod_license'); |
||
| 232 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_LICENSE, 'mod_license', 50, 255, $modLicense), true); |
||
| 233 | |||
| 234 | $optionsTray = new \XoopsFormElementTray(_OPTIONS, '<br>'); |
||
| 235 | $optionsTray->setDescription(_AM_TDMCREATE_OPTIONS_DESC); |
||
| 236 | // Check All Modules Options |
||
| 237 | $checkAllOptions = new \XoopsFormCheckBox('', 'modulebox', 1); |
||
| 238 | $checkAllOptions->addOption('allbox', _AM_TDMCREATE_MODULE_ALL); |
||
| 239 | $checkAllOptions->setExtra(' onclick="xoopsCheckAll(\'moduleform\', \'modulebox\');" '); |
||
| 240 | $checkAllOptions->setClass('xo-checkall'); |
||
| 241 | $optionsTray->addElement($checkAllOptions); |
||
| 242 | // Options |
||
| 243 | $checkbox = new \XoopsFormCheckbox(' ', 'module_option', $this->getOptionsModules(), '<br>'); |
||
| 244 | foreach ($this->options as $option) { |
||
| 245 | $checkbox->addOption($option, self::getDefinedLanguage('_AM_TDMCREATE_MODULE_' . mb_strtoupper($option))); |
||
| 246 | } |
||
| 247 | $optionsTray->addElement($checkbox); |
||
| 248 | |||
| 249 | $form->addElement($optionsTray); |
||
| 250 | |||
| 251 | $modImage = $this->getVar('mod_image'); |
||
| 252 | $modImage = $modImage ?: $set['image']; |
||
| 253 | |||
| 254 | $uploadDirectory = 'uploads/' . $GLOBALS['xoopsModule']->dirname() . '/images/modules'; |
||
| 255 | $imgtray = new \XoopsFormElementTray(_AM_TDMCREATE_MODULE_IMAGE, '<br>'); |
||
| 256 | $imgpath = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, './' . mb_strtolower($uploadDirectory) . '/'); |
||
| 257 | $imageselect = new \XoopsFormSelect($imgpath, 'mod_image', $modImage); |
||
| 258 | $modImageArray = \XoopsLists::getImgListAsArray(TDMC_UPLOAD_IMGMOD_PATH); |
||
| 259 | foreach ($modImageArray as $image) { |
||
| 260 | $imageselect->addOption($image, $image); |
||
| 261 | } |
||
| 262 | $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"mod_image\", \"" . $uploadDirectory . '", "", "' . XOOPS_URL . "\")'"); |
||
| 263 | $imgtray->addElement($imageselect); |
||
| 264 | $imgtray->addElement(new \XoopsFormLabel('', "<br><img src='" . TDMC_UPLOAD_IMGMOD_URL . '/' . $modImage . "' id='image3' alt='' /><br>")); |
||
| 265 | |||
| 266 | $fileseltray = new \XoopsFormElementTray('', '<br>'); |
||
| 267 | $fileseltray->addElement(new \XoopsFormFile(_AM_TDMCREATE_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxsize_image'))); |
||
| 268 | $fileseltray->addElement(new \XoopsFormLabel('')); |
||
| 269 | $imgtray->addElement($fileseltray); |
||
| 270 | $form->addElement($imgtray); |
||
| 271 | //---------- START LOGO GENERATOR ----------------- |
||
| 272 | $tables_img = $this->getVar('table_image') ?: 'about.png'; |
||
| 273 | $iconsdir = '/Frameworks/moduleclasses/icons/32'; |
||
| 274 | if (is_dir(XOOPS_ROOT_PATH . $iconsdir)) { |
||
| 275 | $uploadDirectory = $iconsdir; |
||
| 276 | $imgpath = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, ".{$iconsdir}/"); |
||
| 277 | } else { |
||
| 278 | $uploadDirectory = '/uploads/' . $GLOBALS['xoopsModule']->dirname() . '/images/tables'; |
||
| 279 | $imgpath = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, './uploads/' . $GLOBALS['xoopsModule']->dirname() . '/images/tables'); |
||
| 280 | } |
||
| 281 | $createLogoTray = new \XoopsFormElementTray(_AM_TDMCREATE_MODULE_CREATENEWLOGO, '<br>'); |
||
| 282 | $iconSelect = new \XoopsFormSelect($imgpath, 'tables_img', $tables_img, 8); |
||
| 283 | $tablesImagesArray = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadDirectory); |
||
| 284 | foreach ($tablesImagesArray as $image) { |
||
| 285 | $iconSelect->addOption($image, $image); |
||
| 286 | } |
||
| 287 | $iconSelect->setExtra(" onchange='showImgSelected2(\"image4\", \"tables_img\", \"" . $uploadDirectory . '", "", "' . XOOPS_URL . "\")' "); |
||
| 288 | $createLogoTray->addElement($iconSelect); |
||
| 289 | $createLogoTray->addElement(new \XoopsFormLabel('', "<br><img src='" . XOOPS_URL . '/' . $uploadDirectory . '/' . $tables_img . "' id='image4' alt='' />")); |
||
| 290 | // Create preview and submit buttons |
||
| 291 | $buttonLogoGenerator4 = new \XoopsFormButton('', 'button4', _AM_TDMCREATE_MODULE_CREATENEWLOGO, 'button'); |
||
| 292 | $buttonLogoGenerator4->setExtra(" onclick='createNewModuleLogo(\"" . TDMC_URL . "\")' "); |
||
| 293 | $createLogoTray->addElement($buttonLogoGenerator4); |
||
| 294 | |||
| 295 | $form->addElement($createLogoTray); |
||
| 296 | //------------ END LOGO GENERATOR -------------------- |
||
| 297 | |||
| 298 | $modAuthorMail = $isNew ? $set['author_mail'] : $this->getVar('mod_author_mail'); |
||
| 299 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR_MAIL, 'mod_author_mail', 50, 255, $modAuthorMail)); |
||
| 300 | |||
| 301 | $modAuthorWebsiteUrl = $isNew ? $set['author_website_url'] : $this->getVar('mod_author_website_url'); |
||
| 302 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR_WEBSITE_URL, 'mod_author_website_url', 50, 255, $modAuthorWebsiteUrl)); |
||
| 303 | |||
| 304 | $modAuthorWebsiteName = $isNew ? $set['author_website_name'] : $this->getVar('mod_author_website_name'); |
||
| 305 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR_WEBSITE_NAME, 'mod_author_website_name', 50, 255, $modAuthorWebsiteName)); |
||
| 306 | |||
| 307 | $modCredits = $isNew ? $set['credits'] : $this->getVar('mod_credits'); |
||
| 308 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_CREDITS, 'mod_credits', 50, 255, $modCredits)); |
||
| 309 | |||
| 310 | $modReleaseInfo = $isNew ? $set['release_info'] : $this->getVar('mod_release_info'); |
||
| 311 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_RELEASE_INFO, 'mod_release_info', 50, 255, $modReleaseInfo)); |
||
| 312 | |||
| 313 | $modReleaseFile = $isNew ? $set['release_file'] : $this->getVar('mod_release_file'); |
||
| 314 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_RELEASE_FILE, 'mod_release_file', 50, 255, $modReleaseFile)); |
||
| 315 | |||
| 316 | $modManual = $isNew ? $set['manual'] : $this->getVar('mod_manual'); |
||
| 317 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_MANUAL, 'mod_manual', 50, 255, $modManual)); |
||
| 318 | |||
| 319 | $modManualFile = $isNew ? $set['manual_file'] : $this->getVar('mod_manual_file'); |
||
| 320 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_MANUAL_FILE, 'mod_manual_file', 50, 255, $modManualFile)); |
||
| 321 | |||
| 322 | $modDemoSiteUrl = $isNew ? $set['demo_site_url'] : $this->getVar('mod_demo_site_url'); |
||
| 323 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_DEMO_SITE_URL, 'mod_demo_site_url', 50, 255, $modDemoSiteUrl)); |
||
| 324 | |||
| 325 | $modDemoSiteName = $isNew ? $set['demo_site_name'] : $this->getVar('mod_demo_site_name'); |
||
| 326 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_DEMO_SITE_NAME, 'mod_demo_site_name', 50, 255, $modDemoSiteName)); |
||
| 327 | |||
| 328 | $modSupportUrl = $isNew ? $set['support_url'] : $this->getVar('mod_support_url'); |
||
| 329 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_SUPPORT_URL, 'mod_support_url', 50, 255, $modSupportUrl)); |
||
| 330 | |||
| 331 | $modSupportName = $isNew ? $set['support_name'] : $this->getVar('mod_support_name'); |
||
| 332 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_SUPPORT_NAME, 'mod_support_name', 50, 255, $modSupportName)); |
||
| 333 | |||
| 334 | $modWebsiteUrl = $isNew ? $set['website_url'] : $this->getVar('mod_website_url'); |
||
| 335 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_WEBSITE_URL, 'mod_website_url', 50, 255, $modWebsiteUrl)); |
||
| 336 | |||
| 337 | $modWebsiteName = $isNew ? $set['website_name'] : $this->getVar('mod_website_name'); |
||
| 338 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_WEBSITE_NAME, 'mod_website_name', 50, 255, $modWebsiteName)); |
||
| 339 | |||
| 340 | $modRelease = $isNew ? $set['release'] : $this->getVar('mod_release'); |
||
| 341 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_RELEASE, 'mod_release', 50, 255, $modRelease)); |
||
| 342 | |||
| 343 | $modStatus = $isNew ? $set['status'] : $this->getVar('mod_status'); |
||
| 344 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_STATUS, 'mod_status', 50, 255, $modStatus)); |
||
| 345 | |||
| 346 | $modDonations = $isNew ? $set['donations'] : $this->getVar('mod_donations'); |
||
| 347 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_PAYPAL_BUTTON, 'mod_donations', 50, 255, $modDonations)); |
||
| 348 | |||
| 349 | $modSubversion = $isNew ? $set['subversion'] : $this->getVar('mod_subversion'); |
||
| 350 | $form->addElement(new \XoopsFormText(_AM_TDMCREATE_MODULE_SUBVERSION, 'mod_subversion', 50, 255, $modSubversion)); |
||
| 351 | |||
| 352 | $buttonTray = new \XoopsFormElementTray(_REQUIRED . ' <sup class="red bold">*</sup>', ''); |
||
| 353 | $buttonTray->addElement(new \XoopsFormHidden('op', 'save')); |
||
| 354 | $buttonTray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||
| 355 | $form->addElement($buttonTray); |
||
| 356 | |||
| 357 | return $form; |
||
| 358 | } |
||
| 359 | |||
| 360 | /** |
||
| 361 | * @private static function createLogo |
||
| 362 | * @param mixed $logoIcon |
||
| 363 | * @param string $moduleDirname |
||
| 364 | * |
||
| 365 | * @return bool|string |
||
| 366 | */ |
||
| 367 | private static function createLogo($logoIcon, $moduleDirname) |
||
| 368 | { |
||
| 369 | if (!extension_loaded('gd')) { |
||
| 370 | return false; |
||
| 371 | } |
||
| 372 | $requiredFunctions = ['imagecreatefrompng', 'imagefttext', 'imagecopy', 'imagepng', 'imagedestroy', 'imagecolorallocate']; |
||
| 373 | foreach ($requiredFunctions as $func) { |
||
| 374 | if (!function_exists($func)) { |
||
| 375 | return false; |
||
| 376 | } |
||
| 377 | } |
||
| 378 | |||
| 379 | if (!file_exists($imageBase = TDMC_IMAGES_LOGOS_PATH . '/empty.png') |
||
| 380 | || !file_exists($font = TDMC_FONTS_PATH . '/VeraBd.ttf') |
||
| 381 | || !file_exists($iconFile = XOOPS_ICONS32_PATH . '/' . basename($logoIcon))) { |
||
| 382 | return false; |
||
| 383 | } |
||
| 384 | $imageModule = imagecreatefrompng($imageBase); |
||
| 385 | $imageIcon = imagecreatefrompng($iconFile); |
||
| 386 | // Write text |
||
| 387 | $textColor = imagecolorallocate($imageModule, 0, 0, 0); |
||
| 388 | $spaceBorder = (92 - mb_strlen($moduleDirname) * 7.5) / 2; |
||
| 389 | imagefttext($imageModule, 8.5, 0, $spaceBorder, 45, $textColor, $font, ucfirst($moduleDirname), []); |
||
| 390 | imagecopy($imageModule, $imageIcon, 29, 2, 0, 0, 32, 32); |
||
| 391 | $logoImg = '/' . 'logoModule.png'; |
||
| 392 | imagepng($imageModule, TDMC_UPLOAD_IMGMOD_PATH . $logoImg); |
||
| 393 | imagedestroy($imageModule); |
||
| 394 | imagedestroy($imageIcon); |
||
| 395 | |||
| 396 | return TDMC_UPLOAD_IMGMOD_URL . $logoImg; |
||
| 397 | } |
||
| 398 | |||
| 399 | /** |
||
| 400 | * Get Values. |
||
| 401 | * |
||
| 402 | * @param null $keys |
||
| 403 | * @param null $format |
||
| 404 | * @param null $maxDepth |
||
| 405 | * |
||
| 406 | * @return array |
||
| 407 | */ |
||
| 408 | public function getValuesModules($keys = null, $format = null, $maxDepth = null) |
||
| 427 | } |
||
| 428 | |||
| 429 | /** |
||
| 430 | * Get getOptionsModules. |
||
| 431 | * |
||
| 432 | * @return array |
||
| 433 | */ |
||
| 434 | private function getOptionsModules() |
||
| 444 | } |
||
| 445 | |||
| 446 | /** |
||
| 447 | * Get Defined Language. |
||
| 448 | * |
||
| 449 | * @param $lang |
||
| 450 | * |
||
| 451 | * @return string |
||
| 452 | */ |
||
| 453 | private static function getDefinedLanguage($lang) |
||
| 460 | } |
||
| 461 | } |
||
| 462 |