@@ -14,113 +14,113 @@ |
||
14 | 14 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
15 | 15 | |
16 | 16 | $modversion = [ |
17 | - 'version' => '1.67.0', |
|
18 | - 'module_status' => 'Beta 2', |
|
19 | - 'release_date' => '2022/03/28', |
|
20 | - 'name' => _MI_MYIFRAME_NAME, |
|
21 | - 'description' => _MI_MYIFRAME_DESC, |
|
22 | - 'credits' => '', |
|
23 | - 'author' => 'Instant Zero - https://xoops.instant-zero.com', |
|
24 | - 'help' => 'page=help', |
|
25 | - 'license' => 'GPL see LICENSE', |
|
26 | - 'official' => 0, |
|
27 | - 'image' => 'assets/images/logoModule.png', |
|
28 | - 'dirname' => basename(__DIR__), |
|
29 | - 'min_php' => '7.4', |
|
30 | - 'min_db' => ['mysql' => '5.5'], |
|
31 | - 'min_xoops' => '2.5.10', |
|
32 | - 'min_admin' => '1.2', |
|
33 | - 'module_website_url' => 'www.xoops.org', |
|
34 | - 'module_website_name' => 'XOOPS', |
|
35 | - 'module_release' => '03/28/2022', |
|
36 | - 'system_menu' => 1, |
|
37 | - //sql tables |
|
38 | - 'sqlfile' => ['mysql' => 'sql/mysql.sql'], |
|
39 | - 'tables' => [ |
|
40 | - 'myiframe', |
|
41 | - ], |
|
42 | - // Admin |
|
43 | - 'hasAdmin' => 1, |
|
44 | - 'adminindex' => 'admin/index.php', |
|
45 | - 'adminmenu' => 'admin/menu.php', |
|
46 | - // Menu |
|
47 | - 'hasMain' => 1, |
|
17 | + 'version' => '1.67.0', |
|
18 | + 'module_status' => 'Beta 2', |
|
19 | + 'release_date' => '2022/03/28', |
|
20 | + 'name' => _MI_MYIFRAME_NAME, |
|
21 | + 'description' => _MI_MYIFRAME_DESC, |
|
22 | + 'credits' => '', |
|
23 | + 'author' => 'Instant Zero - https://xoops.instant-zero.com', |
|
24 | + 'help' => 'page=help', |
|
25 | + 'license' => 'GPL see LICENSE', |
|
26 | + 'official' => 0, |
|
27 | + 'image' => 'assets/images/logoModule.png', |
|
28 | + 'dirname' => basename(__DIR__), |
|
29 | + 'min_php' => '7.4', |
|
30 | + 'min_db' => ['mysql' => '5.5'], |
|
31 | + 'min_xoops' => '2.5.10', |
|
32 | + 'min_admin' => '1.2', |
|
33 | + 'module_website_url' => 'www.xoops.org', |
|
34 | + 'module_website_name' => 'XOOPS', |
|
35 | + 'module_release' => '03/28/2022', |
|
36 | + 'system_menu' => 1, |
|
37 | + //sql tables |
|
38 | + 'sqlfile' => ['mysql' => 'sql/mysql.sql'], |
|
39 | + 'tables' => [ |
|
40 | + 'myiframe', |
|
41 | + ], |
|
42 | + // Admin |
|
43 | + 'hasAdmin' => 1, |
|
44 | + 'adminindex' => 'admin/index.php', |
|
45 | + 'adminmenu' => 'admin/menu.php', |
|
46 | + // Menu |
|
47 | + 'hasMain' => 1, |
|
48 | 48 | ]; |
49 | 49 | // ------------------- Help files ------------------- // |
50 | 50 | $modversion['helpsection'] = [ |
51 | - ['name' => _MI_MYIFRAME_OVERVIEW, 'link' => 'page=help'], |
|
52 | - ['name' => _MI_MYIFRAME_DISCLAIMER, 'link' => 'page=disclaimer'], |
|
53 | - ['name' => _MI_MYIFRAME_LICENSE, 'link' => 'page=license'], |
|
54 | - ['name' => _MI_MYIFRAME_SUPPORT, 'link' => 'page=support'], |
|
51 | + ['name' => _MI_MYIFRAME_OVERVIEW, 'link' => 'page=help'], |
|
52 | + ['name' => _MI_MYIFRAME_DISCLAIMER, 'link' => 'page=disclaimer'], |
|
53 | + ['name' => _MI_MYIFRAME_LICENSE, 'link' => 'page=license'], |
|
54 | + ['name' => _MI_MYIFRAME_SUPPORT, 'link' => 'page=support'], |
|
55 | 55 | ]; |
56 | 56 | // ------------------- Templates ------------------- // |
57 | 57 | $modversion['templates'] = [ |
58 | - ['file' => 'myiframe.tpl', 'description' => 'Default template'], |
|
58 | + ['file' => 'myiframe.tpl', 'description' => 'Default template'], |
|
59 | 59 | ]; |
60 | 60 | |
61 | 61 | //Blocks |
62 | 62 | $modversion['blocks'][] = [ |
63 | - 'file' => 'myiframe_iframe.php', |
|
64 | - 'name' => _MI_MYIFRAME_BNAME1, |
|
65 | - 'description' => 'Shows an iframe in a block', |
|
66 | - 'show_func' => 'b_myiframe_iframe_show', |
|
67 | - 'edit_func' => 'b_myiframe_iframe_edit', |
|
68 | - 'options' => '0', |
|
69 | - 'template' => 'myiframe_block_show.tpl', |
|
63 | + 'file' => 'myiframe_iframe.php', |
|
64 | + 'name' => _MI_MYIFRAME_BNAME1, |
|
65 | + 'description' => 'Shows an iframe in a block', |
|
66 | + 'show_func' => 'b_myiframe_iframe_show', |
|
67 | + 'edit_func' => 'b_myiframe_iframe_edit', |
|
68 | + 'options' => '0', |
|
69 | + 'template' => 'myiframe_block_show.tpl', |
|
70 | 70 | ]; |
71 | 71 | global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
72 | 72 | |
73 | 73 | if (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $modversion['dirname'] && $xoopsModule->getVar('isactive')) { |
74 | - $i = 0; |
|
75 | - require_once XOOPS_ROOT_PATH . '/modules/myiframe/include/functions.php'; |
|
76 | - $myts = \MyTextSanitizer::getInstance(); |
|
77 | - if (myiframe_getmoduleoption('showinmenu')) { |
|
78 | - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' ORDER BY frame_description'; |
|
79 | - $result = $GLOBALS['xoopsDB']->query($sql); |
|
80 | - while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
81 | - if ('' !== xoops_trim($myrow['frame_description'])) { |
|
82 | - $modversion['sub'][$i]['name'] = htmlspecialchars($myrow['frame_description'], ENT_QUOTES | ENT_HTML5); |
|
83 | - $modversion['sub'][$i]['url'] = 'index.php?iframeid=' . (int)$myrow['frame_frameid']; |
|
84 | - $i++; |
|
85 | - } |
|
86 | - } |
|
87 | - } |
|
74 | + $i = 0; |
|
75 | + require_once XOOPS_ROOT_PATH . '/modules/myiframe/include/functions.php'; |
|
76 | + $myts = \MyTextSanitizer::getInstance(); |
|
77 | + if (myiframe_getmoduleoption('showinmenu')) { |
|
78 | + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' ORDER BY frame_description'; |
|
79 | + $result = $GLOBALS['xoopsDB']->query($sql); |
|
80 | + while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
81 | + if ('' !== xoops_trim($myrow['frame_description'])) { |
|
82 | + $modversion['sub'][$i]['name'] = htmlspecialchars($myrow['frame_description'], ENT_QUOTES | ENT_HTML5); |
|
83 | + $modversion['sub'][$i]['url'] = 'index.php?iframeid=' . (int)$myrow['frame_frameid']; |
|
84 | + $i++; |
|
85 | + } |
|
86 | + } |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | // Options |
90 | 90 | $modversion['config'][] = [ |
91 | - 'name' => 'showinmenu', |
|
92 | - 'title' => '_MI_MYIFRAME_OPT0', |
|
93 | - 'description' => '_MI_MYIFRAME_OPT0_DSC', |
|
94 | - 'formtype' => 'yesno', |
|
95 | - 'valuetype' => 'int', |
|
96 | - 'default' => 0, |
|
91 | + 'name' => 'showinmenu', |
|
92 | + 'title' => '_MI_MYIFRAME_OPT0', |
|
93 | + 'description' => '_MI_MYIFRAME_OPT0_DSC', |
|
94 | + 'formtype' => 'yesno', |
|
95 | + 'valuetype' => 'int', |
|
96 | + 'default' => 0, |
|
97 | 97 | ]; |
98 | 98 | $modversion['config'][] = [ |
99 | - 'name' => 'showlist', |
|
100 | - 'title' => '_MI_MYIFRAME_OPT1', |
|
101 | - 'description' => '_MI_MYIFRAME_OPT1_DSC', |
|
102 | - 'formtype' => 'yesno', |
|
103 | - 'valuetype' => 'int', |
|
104 | - 'default' => 1, |
|
99 | + 'name' => 'showlist', |
|
100 | + 'title' => '_MI_MYIFRAME_OPT1', |
|
101 | + 'description' => '_MI_MYIFRAME_OPT1_DSC', |
|
102 | + 'formtype' => 'yesno', |
|
103 | + 'valuetype' => 'int', |
|
104 | + 'default' => 1, |
|
105 | 105 | ]; |
106 | 106 | |
107 | 107 | // Make Sample button visible? |
108 | 108 | $modversion['config'][] = [ |
109 | - 'name' => 'displaySampleButton', |
|
110 | - 'title' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON', |
|
111 | - 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC', |
|
112 | - 'formtype' => 'yesno', |
|
113 | - 'valuetype' => 'int', |
|
114 | - 'default' => 1, |
|
109 | + 'name' => 'displaySampleButton', |
|
110 | + 'title' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON', |
|
111 | + 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC', |
|
112 | + 'formtype' => 'yesno', |
|
113 | + 'valuetype' => 'int', |
|
114 | + 'default' => 1, |
|
115 | 115 | ]; |
116 | 116 | // Maintained by |
117 | 117 | $modversion['config'][] = [ |
118 | - 'name' => 'maintainedby', |
|
119 | - 'title' => '\_MI_MYMODULE_MAINTAINEDBY', |
|
120 | - 'description' => '\_MI_MYMODULE_MAINTAINEDBY_DESC', |
|
121 | - 'formtype' => 'textbox', |
|
122 | - 'valuetype' => 'text', |
|
123 | - 'default' => 'https://xoops.org/modules/newbb', |
|
118 | + 'name' => 'maintainedby', |
|
119 | + 'title' => '\_MI_MYMODULE_MAINTAINEDBY', |
|
120 | + 'description' => '\_MI_MYMODULE_MAINTAINEDBY_DESC', |
|
121 | + 'formtype' => 'textbox', |
|
122 | + 'valuetype' => 'text', |
|
123 | + 'default' => 'https://xoops.org/modules/newbb', |
|
124 | 124 | ]; |
125 | 125 | |
126 | 126 | // Search |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | use Xmf\Module\Admin; |
22 | 22 | use XoopsModules\Myiframe\{ |
23 | - Helper |
|
23 | + Helper |
|
24 | 24 | }; |
25 | 25 | |
26 | 26 | /** @var Admin $adminObject */ |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | |
16 | 16 | // Verify if the table is up to date |
17 | 17 | if (!myiframe_FieldExists('frame_frameid', $GLOBALS['xoopsDB']->prefix('myiframe'))) { |
18 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `frameid` `frame_frameid` INT( 8 ) NOT NULL AUTO_INCREMENT'); |
|
19 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `created` `frame_created` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); |
|
20 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `uid` `frame_uid` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'"); |
|
21 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `longdesc` `frame_description` VARCHAR( 255 ) NOT NULL'); |
|
22 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `width` `frame_width` VARCHAR( 15 ) NOT NULL'); |
|
23 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `height` `frame_height` VARCHAR( 15 ) NOT NULL'); |
|
24 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `align` `frame_align` SMALLINT( 2 ) NOT NULL DEFAULT '0'"); |
|
25 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `frameborder` `frame_frameborder` SMALLINT( 3 ) NOT NULL DEFAULT '0'"); |
|
26 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `marginwidth` `frame_marginwidth` SMALLINT( 3 ) NOT NULL DEFAULT '0'"); |
|
27 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `marginheight` `frame_marginheight` SMALLINT( 3 ) NOT NULL DEFAULT '0'"); |
|
28 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `scrolling` `frame_scrolling` SMALLINT( 1 ) NOT NULL DEFAULT '0'"); |
|
29 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `hits` `frame_hits` INT( 8 ) UNSIGNED NOT NULL DEFAULT '0'"); |
|
30 | - $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `url` `frame_url` VARCHAR( 255 ) NOT NULL'); |
|
31 | - header('Location : ' . XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=myiframe'); |
|
18 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `frameid` `frame_frameid` INT( 8 ) NOT NULL AUTO_INCREMENT'); |
|
19 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `created` `frame_created` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); |
|
20 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `uid` `frame_uid` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'"); |
|
21 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `longdesc` `frame_description` VARCHAR( 255 ) NOT NULL'); |
|
22 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `width` `frame_width` VARCHAR( 15 ) NOT NULL'); |
|
23 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `height` `frame_height` VARCHAR( 15 ) NOT NULL'); |
|
24 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `align` `frame_align` SMALLINT( 2 ) NOT NULL DEFAULT '0'"); |
|
25 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `frameborder` `frame_frameborder` SMALLINT( 3 ) NOT NULL DEFAULT '0'"); |
|
26 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `marginwidth` `frame_marginwidth` SMALLINT( 3 ) NOT NULL DEFAULT '0'"); |
|
27 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `marginheight` `frame_marginheight` SMALLINT( 3 ) NOT NULL DEFAULT '0'"); |
|
28 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `scrolling` `frame_scrolling` SMALLINT( 1 ) NOT NULL DEFAULT '0'"); |
|
29 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `hits` `frame_hits` INT( 8 ) UNSIGNED NOT NULL DEFAULT '0'"); |
|
30 | + $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `url` `frame_url` VARCHAR( 255 ) NOT NULL'); |
|
31 | + header('Location : ' . XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=myiframe'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | $module_id = $xoopsModule->getVar('mid'); |
@@ -53,48 +53,48 @@ discard block |
||
53 | 53 | */ |
54 | 54 | function addEditForm($frameid, $Action, $FormTitle, $longdesc, $width, $height, $align, $frameborder, $marginwidth, $marginheight, $scrolling, $url, $LabelSubmitButton): void |
55 | 55 | { |
56 | - require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
57 | - global $xoopsModule; |
|
56 | + require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
57 | + global $xoopsModule; |
|
58 | 58 | |
59 | - $sform = new \XoopsThemeForm($FormTitle, 'indexform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/manage.php'); |
|
60 | - $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_DESC, 'longdesc', 50, 255, $longdesc), false); |
|
61 | - $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_WIDTH, 'width', 10, 15, $width), false); |
|
62 | - $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_HEIGHT, 'height', 10, 15, $height), false); |
|
59 | + $sform = new \XoopsThemeForm($FormTitle, 'indexform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/manage.php'); |
|
60 | + $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_DESC, 'longdesc', 50, 255, $longdesc), false); |
|
61 | + $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_WIDTH, 'width', 10, 15, $width), false); |
|
62 | + $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_HEIGHT, 'height', 10, 15, $height), false); |
|
63 | 63 | |
64 | - $selalign = new \XoopsFormSelect(_AM_MYIFRAME_ALIGN, 'align', $align); |
|
65 | - $selalign->addOption(1, _AM_MYIFRAME_ALIGN_TOP); |
|
66 | - $selalign->addOption(2, _AM_MYIFRAME_ALIGN_MIDDLE); |
|
67 | - $selalign->addOption(3, _AM_MYIFRAME_ALIGN_BOTTOM); |
|
68 | - $selalign->addOption(4, _AM_MYIFRAME_ALIGN_LEFT); |
|
69 | - $selalign->addOption(5, _AM_MYIFRAME_ALIGN_RIGHT); |
|
70 | - $selalign->setValue($align); |
|
71 | - $sform->addElement($selalign); |
|
64 | + $selalign = new \XoopsFormSelect(_AM_MYIFRAME_ALIGN, 'align', $align); |
|
65 | + $selalign->addOption(1, _AM_MYIFRAME_ALIGN_TOP); |
|
66 | + $selalign->addOption(2, _AM_MYIFRAME_ALIGN_MIDDLE); |
|
67 | + $selalign->addOption(3, _AM_MYIFRAME_ALIGN_BOTTOM); |
|
68 | + $selalign->addOption(4, _AM_MYIFRAME_ALIGN_LEFT); |
|
69 | + $selalign->addOption(5, _AM_MYIFRAME_ALIGN_RIGHT); |
|
70 | + $selalign->setValue($align); |
|
71 | + $sform->addElement($selalign); |
|
72 | 72 | |
73 | - $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_FRAMEBORDER, 'frameborder', 3, 3, $frameborder), false); |
|
74 | - $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_MARGINWIDTH, 'marginwidth', 3, 3, $marginwidth), false); |
|
75 | - $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_MARGINHEIGHT, 'marginheight', 3, 3, $marginheight), false); |
|
73 | + $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_FRAMEBORDER, 'frameborder', 3, 3, $frameborder), false); |
|
74 | + $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_MARGINWIDTH, 'marginwidth', 3, 3, $marginwidth), false); |
|
75 | + $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_MARGINHEIGHT, 'marginheight', 3, 3, $marginheight), false); |
|
76 | 76 | |
77 | - $selscroll = new \XoopsFormSelect(_AM_MYIFRAME_SCROLLING, 'scrolling', $scrolling); |
|
78 | - $selscroll->addOption(1, _YES); |
|
79 | - $selscroll->addOption(2, _NO); |
|
80 | - $selscroll->addOption(3, _AM_MYIFRAME_AUTO); |
|
81 | - $selscroll->setValue($scrolling); |
|
82 | - $sform->addElement($selscroll); |
|
77 | + $selscroll = new \XoopsFormSelect(_AM_MYIFRAME_SCROLLING, 'scrolling', $scrolling); |
|
78 | + $selscroll->addOption(1, _YES); |
|
79 | + $selscroll->addOption(2, _NO); |
|
80 | + $selscroll->addOption(3, _AM_MYIFRAME_AUTO); |
|
81 | + $selscroll->setValue($scrolling); |
|
82 | + $sform->addElement($selscroll); |
|
83 | 83 | |
84 | - $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_URL, 'url', 50, 255, $url), true); |
|
85 | - $sform->addElement(new \XoopsFormHidden('op', $Action), false); |
|
86 | - if (!empty($frameid)) { |
|
87 | - $sform->addElement(new \XoopsFormHidden('frameid', $frameid), false); |
|
88 | - } |
|
84 | + $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_URL, 'url', 50, 255, $url), true); |
|
85 | + $sform->addElement(new \XoopsFormHidden('op', $Action), false); |
|
86 | + if (!empty($frameid)) { |
|
87 | + $sform->addElement(new \XoopsFormHidden('frameid', $frameid), false); |
|
88 | + } |
|
89 | 89 | |
90 | - $buttonTray = new \XoopsFormElementTray('', ''); |
|
91 | - $submit_btn = new \XoopsFormButton('', 'submit', $LabelSubmitButton, 'submit'); |
|
92 | - $buttonTray->addElement($submit_btn); |
|
93 | - $cancel_btn = new \XoopsFormButton('', 'reset', _AM_MYIFRAME_RESETBUTTON, 'reset'); |
|
94 | - $buttonTray->addElement($cancel_btn); |
|
95 | - $sform->addElement($buttonTray); |
|
96 | - $sform->display(); |
|
97 | - require_once __DIR__ . '/admin_footer.php'; |
|
90 | + $buttonTray = new \XoopsFormElementTray('', ''); |
|
91 | + $submit_btn = new \XoopsFormButton('', 'submit', $LabelSubmitButton, 'submit'); |
|
92 | + $buttonTray->addElement($submit_btn); |
|
93 | + $cancel_btn = new \XoopsFormButton('', 'reset', _AM_MYIFRAME_RESETBUTTON, 'reset'); |
|
94 | + $buttonTray->addElement($cancel_btn); |
|
95 | + $sform->addElement($buttonTray); |
|
96 | + $sform->display(); |
|
97 | + require_once __DIR__ . '/admin_footer.php'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | // ****************************************************************************************************************************************** |
@@ -104,191 +104,191 @@ discard block |
||
104 | 104 | $op = Request::getCmd('op', ''); |
105 | 105 | |
106 | 106 | switch ($op) { |
107 | - case 'verifybeforeedit': |
|
108 | - if (Request::hasVar('submit', 'POST') && '' !== $_POST['submit']) { |
|
109 | - if ('' === $_POST['longdesc']) { |
|
110 | - xoops_cp_header(); |
|
111 | - $adminObject = Admin::getInstance(); |
|
112 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
113 | - echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n"; |
|
114 | - echo '<tr><td class="odd">'; |
|
115 | - echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>'; |
|
116 | - echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 1'; |
|
117 | - echo '</td></tr></table>'; |
|
118 | - require_once __DIR__ . '/admin_footer.php'; |
|
119 | - xoops_cp_footer(); |
|
120 | - exit(); |
|
121 | - } |
|
107 | + case 'verifybeforeedit': |
|
108 | + if (Request::hasVar('submit', 'POST') && '' !== $_POST['submit']) { |
|
109 | + if ('' === $_POST['longdesc']) { |
|
110 | + xoops_cp_header(); |
|
111 | + $adminObject = Admin::getInstance(); |
|
112 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
113 | + echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n"; |
|
114 | + echo '<tr><td class="odd">'; |
|
115 | + echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>'; |
|
116 | + echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 1'; |
|
117 | + echo '</td></tr></table>'; |
|
118 | + require_once __DIR__ . '/admin_footer.php'; |
|
119 | + xoops_cp_footer(); |
|
120 | + exit(); |
|
121 | + } |
|
122 | 122 | |
123 | - $frameid = $_POST['frameid']; |
|
124 | - $frame = $iframeHandler->get($frameid); |
|
125 | - $frame->unsetNew(); |
|
126 | - $frame->setVar('frame_description', $_POST['longdesc']); |
|
127 | - $frame->setVar('frame_width', $_POST['width']); |
|
128 | - $frame->setVar('frame_height', $_POST['height']); |
|
129 | - $frame->setVar('frame_align', $_POST['align']); |
|
130 | - $frame->setVar('frame_frameborder', $_POST['frameborder']); |
|
131 | - $frame->setVar('frame_marginwidth', $_POST['marginwidth']); |
|
132 | - $frame->setVar('frame_marginheight', $_POST['marginheight']); |
|
133 | - $frame->setVar('frame_scrolling', $_POST['scrolling']); |
|
134 | - $frame->setVar('frame_url', $_POST['url']); |
|
135 | - $frame->setVar('frame_uid', $xoopsUser->getVar('uid')); |
|
136 | - $res = $iframeHandler->insert($frame); |
|
137 | - if (!$res) { |
|
138 | - redirect_header('manage.php', 1, _AM_MYIFRAME_ERROR_MODIFY_DB); |
|
139 | - } |
|
140 | - redirect_header('manage.php', 1, _AM_MYIFRAME_DBUPDATED); |
|
141 | - } |
|
142 | - break; |
|
143 | - case 'edit': |
|
144 | - xoops_cp_header(); |
|
145 | - $adminObject = Admin::getInstance(); |
|
146 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
147 | - if (Request::hasVar('frameid', 'GET')) { |
|
148 | - $frameid = Request::getInt('frameid', 0, 'GET'); |
|
149 | - $frame = $iframeHandler->get($frameid); |
|
150 | - addEditForm( |
|
151 | - $frameid, |
|
152 | - 'verifybeforeedit', |
|
153 | - _AM_MYIFRAME_CONFIG, |
|
154 | - $frame->getVar('frame_description', 'e'), |
|
155 | - $frame->getVar('frame_width', 'e'), |
|
156 | - $frame->getVar('frame_height', 'e'), |
|
157 | - $frame->getVar('frame_align', 'e'), |
|
158 | - $frame->getVar('frame_frameborder', 'e'), |
|
159 | - $frame->getVar('frame_marginwidth', 'e'), |
|
160 | - $frame->getVar('frame_marginheight', 'e'), |
|
161 | - $frame->getVar('frame_scrolling', 'e'), |
|
162 | - $frame->getVar('frame_url', 'e'), |
|
163 | - _AM_MYIFRAME_UPDATE |
|
164 | - ); |
|
165 | - } else { |
|
166 | - xoops_cp_header(); |
|
167 | - $adminObject = Admin::getInstance(); |
|
168 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
169 | - echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n"; |
|
170 | - echo '<tr><td class="odd">'; |
|
171 | - echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>'; |
|
172 | - echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 2'; |
|
173 | - echo "</td></tr></table>\n"; |
|
174 | - require_once __DIR__ . '/admin_footer.php'; |
|
175 | - xoops_cp_footer(); |
|
176 | - exit(); |
|
177 | - } |
|
178 | - break; |
|
179 | - case 'delete': |
|
180 | - if (!isset($_POST['ok'])) { |
|
181 | - xoops_cp_header(); |
|
182 | - $adminObject = Admin::getInstance(); |
|
183 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
184 | - echo '<h4>' . _AM_MYIFRAME_CONFIG . '</h4>'; |
|
185 | - xoops_confirm( |
|
186 | - [ |
|
187 | - 'op' => 'delete', |
|
188 | - 'frameid' => Request::getInt('frameid', 0, 'GET'), |
|
189 | - 'ok' => 1, |
|
190 | - ], |
|
191 | - 'manage.php', |
|
192 | - _AM_MYIFRAME_RUSUREDEL |
|
193 | - ); |
|
194 | - require_once __DIR__ . '/admin_footer.php'; |
|
195 | - } else { |
|
196 | - if (empty($_POST['frameid'])) { |
|
197 | - redirect_header('manage.php', 2, _AM_MYIFRAME_ERROR_ADD_INDEX . ' 3'); |
|
198 | - } |
|
199 | - $frameid = Request::getInt('frameid', 0, 'POST'); |
|
200 | - $critere = new \Criteria('frame_frameid', $frameid, '='); |
|
201 | - $iframeHandler->deleteAll($critere); |
|
202 | - redirect_header('manage.php', 1, _AM_MYIFRAME_DBUPDATED); |
|
203 | - } |
|
204 | - break; |
|
205 | - case 'verifytoadd': |
|
206 | - if (Request::hasVar('submit', 'POST') && '' !== $_POST['submit']) { |
|
207 | - if ('' === $_POST['url']) { |
|
208 | - xoops_cp_header(); |
|
209 | - $adminObject = Admin::getInstance(); |
|
210 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
211 | - echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n"; |
|
212 | - echo '<tr><td class="odd">'; |
|
213 | - echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>'; |
|
214 | - echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 4'; |
|
215 | - echo "</td></tr></table>\n"; |
|
216 | - require_once __DIR__ . '/admin_footer.php'; |
|
217 | - xoops_cp_footer(); |
|
218 | - $adminObject = Admin::getInstance(); |
|
219 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
220 | - exit(); |
|
221 | - } |
|
222 | - $frame = $iframeHandler->create(true); |
|
223 | - $frame->setVar('frame_description', $_POST['longdesc']); |
|
224 | - $frame->setVar('frame_width', $_POST['width']); |
|
225 | - $frame->setVar('frame_height', $_POST['height']); |
|
226 | - $frame->setVar('frame_align', $_POST['align']); |
|
227 | - $frame->setVar('frame_frameborder', $_POST['frameborder']); |
|
228 | - $frame->setVar('frame_marginwidth', $_POST['marginwidth']); |
|
229 | - $frame->setVar('frame_marginheight', $_POST['marginheight']); |
|
230 | - $frame->setVar('frame_scrolling', $_POST['scrolling']); |
|
231 | - $frame->setVar('frame_url', $_POST['url']); |
|
232 | - $frame->setVar('frame_created', time()); |
|
233 | - $frame->setVar('frame_uid', $xoopsUser->getVar('uid')); |
|
234 | - $res = $iframeHandler->insert($frame); |
|
235 | - if (!$res) { |
|
236 | - redirect_header('manage.php', 1, _AM_MYIFRAME_ERROR_ADD_INDEX . ' 5'); |
|
237 | - } |
|
238 | - redirect_header('manage.php', 1, _AM_MYIFRAME_ADDED_OK); |
|
239 | - } |
|
240 | - break; |
|
241 | - case 'addframe': |
|
242 | - xoops_cp_header(); |
|
243 | - $adminObject = Admin::getInstance(); |
|
244 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
245 | - addEditForm(0, 'verifytoadd', _AM_MYIFRAME_CONFIG, '', '100%', '', '', '0', '0', '0', 1, '', _AM_MYIFRAME_ADDBUTTON); |
|
246 | - break; |
|
247 | - case 'default': |
|
248 | - default: |
|
249 | - xoops_cp_header(); |
|
250 | - $adminObject = Admin::getInstance(); |
|
251 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
252 | - echo '<h4>' . _AM_MYIFRAME_CONFIG . "</h4><br>\n"; |
|
253 | - echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n"; |
|
254 | - echo "<tr><th align='center'>" . _AM_MYIFRAME_ID . "</th><th align='center'>" . _AM_MYIFRAME_DESC . "</th><th align='center'>" . _AM_MYIFRAME_CREATED . "</th><th align='center'>" . _AM_MYIFRAME_HITS . "</th><th align='center'>" . _AM_MYIFRAME_ACTION . "</th></tr>\n"; |
|
255 | - $critere = new \Criteria('1', '1', '='); |
|
256 | - $critere->setSort('frame_description'); |
|
257 | - $frarray = $iframeHandler->getObjects($critere); |
|
258 | - $class = 'even'; |
|
259 | - $baseurl = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/manage.php'; |
|
260 | - if (count($frarray) > 0) { |
|
261 | - /** @var Myiframe $frame */ |
|
262 | - foreach ($frarray as $frame) { |
|
263 | - $action_edit = "<a href='" . $baseurl . '?op=edit&frameid=' . $frame->getVar('frame_frameid') . "'><img src='../assets/images/edit.png' alt='" . _AM_MYIFRAME_EDIT . "'></a>"; |
|
264 | - $action_delete = "<a href='" . $baseurl . '?op=delete&frameid=' . $frame->getVar('frame_frameid') . "'><img src='../assets/images/delete.png' alt='" . _AM_MYIFRAME_DELETE . "'></a>"; |
|
265 | - if ('' === xoops_trim($frame->getVar('frame_description'))) { |
|
266 | - $liendesc = $frame->getVar('frame_url'); |
|
267 | - } else { |
|
268 | - $liendesc = "<a href='" . XOOPS_URL . '/modules/myiframe/index.php?iframeid=' . $frame->getVar('frame_frameid') . "'>" . $frame->getVar('frame_description') . '</a>'; |
|
269 | - } |
|
270 | - echo "<tr class='" |
|
271 | - . $class |
|
272 | - . "'><td align='center'>" |
|
273 | - . $frame->getVar('frame_frameid') |
|
274 | - . "</td><td align='center'>" |
|
275 | - . $liendesc |
|
276 | - . "</td><td align='center'>" |
|
277 | - . formatTimestamp($frame->getVar('frame_created')) |
|
278 | - . "</td><td align='center'>" |
|
279 | - . $frame->getVar('frame_hits') |
|
280 | - . "</td><td align='center'>" |
|
281 | - . $action_edit |
|
282 | - . ' - ' |
|
283 | - . $action_delete |
|
284 | - . "</td></tr>\n"; |
|
285 | - $class = ('even' === $class) ? 'odd' : 'even'; |
|
286 | - } |
|
287 | - } |
|
288 | - echo "<tr class='" . $class . "'><td colspan='5' align='center'><form name='faddframe' method='post' action='manage.php'><input type='hidden' name='op' value='addframe'><input type='submit' name='submit' value='" . _AM_MYIFRAME_ADD . "'></td></tr>"; |
|
289 | - echo '</table>'; |
|
290 | - require_once __DIR__ . '/admin_footer.php'; |
|
291 | - break; |
|
123 | + $frameid = $_POST['frameid']; |
|
124 | + $frame = $iframeHandler->get($frameid); |
|
125 | + $frame->unsetNew(); |
|
126 | + $frame->setVar('frame_description', $_POST['longdesc']); |
|
127 | + $frame->setVar('frame_width', $_POST['width']); |
|
128 | + $frame->setVar('frame_height', $_POST['height']); |
|
129 | + $frame->setVar('frame_align', $_POST['align']); |
|
130 | + $frame->setVar('frame_frameborder', $_POST['frameborder']); |
|
131 | + $frame->setVar('frame_marginwidth', $_POST['marginwidth']); |
|
132 | + $frame->setVar('frame_marginheight', $_POST['marginheight']); |
|
133 | + $frame->setVar('frame_scrolling', $_POST['scrolling']); |
|
134 | + $frame->setVar('frame_url', $_POST['url']); |
|
135 | + $frame->setVar('frame_uid', $xoopsUser->getVar('uid')); |
|
136 | + $res = $iframeHandler->insert($frame); |
|
137 | + if (!$res) { |
|
138 | + redirect_header('manage.php', 1, _AM_MYIFRAME_ERROR_MODIFY_DB); |
|
139 | + } |
|
140 | + redirect_header('manage.php', 1, _AM_MYIFRAME_DBUPDATED); |
|
141 | + } |
|
142 | + break; |
|
143 | + case 'edit': |
|
144 | + xoops_cp_header(); |
|
145 | + $adminObject = Admin::getInstance(); |
|
146 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
147 | + if (Request::hasVar('frameid', 'GET')) { |
|
148 | + $frameid = Request::getInt('frameid', 0, 'GET'); |
|
149 | + $frame = $iframeHandler->get($frameid); |
|
150 | + addEditForm( |
|
151 | + $frameid, |
|
152 | + 'verifybeforeedit', |
|
153 | + _AM_MYIFRAME_CONFIG, |
|
154 | + $frame->getVar('frame_description', 'e'), |
|
155 | + $frame->getVar('frame_width', 'e'), |
|
156 | + $frame->getVar('frame_height', 'e'), |
|
157 | + $frame->getVar('frame_align', 'e'), |
|
158 | + $frame->getVar('frame_frameborder', 'e'), |
|
159 | + $frame->getVar('frame_marginwidth', 'e'), |
|
160 | + $frame->getVar('frame_marginheight', 'e'), |
|
161 | + $frame->getVar('frame_scrolling', 'e'), |
|
162 | + $frame->getVar('frame_url', 'e'), |
|
163 | + _AM_MYIFRAME_UPDATE |
|
164 | + ); |
|
165 | + } else { |
|
166 | + xoops_cp_header(); |
|
167 | + $adminObject = Admin::getInstance(); |
|
168 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
169 | + echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n"; |
|
170 | + echo '<tr><td class="odd">'; |
|
171 | + echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>'; |
|
172 | + echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 2'; |
|
173 | + echo "</td></tr></table>\n"; |
|
174 | + require_once __DIR__ . '/admin_footer.php'; |
|
175 | + xoops_cp_footer(); |
|
176 | + exit(); |
|
177 | + } |
|
178 | + break; |
|
179 | + case 'delete': |
|
180 | + if (!isset($_POST['ok'])) { |
|
181 | + xoops_cp_header(); |
|
182 | + $adminObject = Admin::getInstance(); |
|
183 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
184 | + echo '<h4>' . _AM_MYIFRAME_CONFIG . '</h4>'; |
|
185 | + xoops_confirm( |
|
186 | + [ |
|
187 | + 'op' => 'delete', |
|
188 | + 'frameid' => Request::getInt('frameid', 0, 'GET'), |
|
189 | + 'ok' => 1, |
|
190 | + ], |
|
191 | + 'manage.php', |
|
192 | + _AM_MYIFRAME_RUSUREDEL |
|
193 | + ); |
|
194 | + require_once __DIR__ . '/admin_footer.php'; |
|
195 | + } else { |
|
196 | + if (empty($_POST['frameid'])) { |
|
197 | + redirect_header('manage.php', 2, _AM_MYIFRAME_ERROR_ADD_INDEX . ' 3'); |
|
198 | + } |
|
199 | + $frameid = Request::getInt('frameid', 0, 'POST'); |
|
200 | + $critere = new \Criteria('frame_frameid', $frameid, '='); |
|
201 | + $iframeHandler->deleteAll($critere); |
|
202 | + redirect_header('manage.php', 1, _AM_MYIFRAME_DBUPDATED); |
|
203 | + } |
|
204 | + break; |
|
205 | + case 'verifytoadd': |
|
206 | + if (Request::hasVar('submit', 'POST') && '' !== $_POST['submit']) { |
|
207 | + if ('' === $_POST['url']) { |
|
208 | + xoops_cp_header(); |
|
209 | + $adminObject = Admin::getInstance(); |
|
210 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
211 | + echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n"; |
|
212 | + echo '<tr><td class="odd">'; |
|
213 | + echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>'; |
|
214 | + echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 4'; |
|
215 | + echo "</td></tr></table>\n"; |
|
216 | + require_once __DIR__ . '/admin_footer.php'; |
|
217 | + xoops_cp_footer(); |
|
218 | + $adminObject = Admin::getInstance(); |
|
219 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
220 | + exit(); |
|
221 | + } |
|
222 | + $frame = $iframeHandler->create(true); |
|
223 | + $frame->setVar('frame_description', $_POST['longdesc']); |
|
224 | + $frame->setVar('frame_width', $_POST['width']); |
|
225 | + $frame->setVar('frame_height', $_POST['height']); |
|
226 | + $frame->setVar('frame_align', $_POST['align']); |
|
227 | + $frame->setVar('frame_frameborder', $_POST['frameborder']); |
|
228 | + $frame->setVar('frame_marginwidth', $_POST['marginwidth']); |
|
229 | + $frame->setVar('frame_marginheight', $_POST['marginheight']); |
|
230 | + $frame->setVar('frame_scrolling', $_POST['scrolling']); |
|
231 | + $frame->setVar('frame_url', $_POST['url']); |
|
232 | + $frame->setVar('frame_created', time()); |
|
233 | + $frame->setVar('frame_uid', $xoopsUser->getVar('uid')); |
|
234 | + $res = $iframeHandler->insert($frame); |
|
235 | + if (!$res) { |
|
236 | + redirect_header('manage.php', 1, _AM_MYIFRAME_ERROR_ADD_INDEX . ' 5'); |
|
237 | + } |
|
238 | + redirect_header('manage.php', 1, _AM_MYIFRAME_ADDED_OK); |
|
239 | + } |
|
240 | + break; |
|
241 | + case 'addframe': |
|
242 | + xoops_cp_header(); |
|
243 | + $adminObject = Admin::getInstance(); |
|
244 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
245 | + addEditForm(0, 'verifytoadd', _AM_MYIFRAME_CONFIG, '', '100%', '', '', '0', '0', '0', 1, '', _AM_MYIFRAME_ADDBUTTON); |
|
246 | + break; |
|
247 | + case 'default': |
|
248 | + default: |
|
249 | + xoops_cp_header(); |
|
250 | + $adminObject = Admin::getInstance(); |
|
251 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
252 | + echo '<h4>' . _AM_MYIFRAME_CONFIG . "</h4><br>\n"; |
|
253 | + echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n"; |
|
254 | + echo "<tr><th align='center'>" . _AM_MYIFRAME_ID . "</th><th align='center'>" . _AM_MYIFRAME_DESC . "</th><th align='center'>" . _AM_MYIFRAME_CREATED . "</th><th align='center'>" . _AM_MYIFRAME_HITS . "</th><th align='center'>" . _AM_MYIFRAME_ACTION . "</th></tr>\n"; |
|
255 | + $critere = new \Criteria('1', '1', '='); |
|
256 | + $critere->setSort('frame_description'); |
|
257 | + $frarray = $iframeHandler->getObjects($critere); |
|
258 | + $class = 'even'; |
|
259 | + $baseurl = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/manage.php'; |
|
260 | + if (count($frarray) > 0) { |
|
261 | + /** @var Myiframe $frame */ |
|
262 | + foreach ($frarray as $frame) { |
|
263 | + $action_edit = "<a href='" . $baseurl . '?op=edit&frameid=' . $frame->getVar('frame_frameid') . "'><img src='../assets/images/edit.png' alt='" . _AM_MYIFRAME_EDIT . "'></a>"; |
|
264 | + $action_delete = "<a href='" . $baseurl . '?op=delete&frameid=' . $frame->getVar('frame_frameid') . "'><img src='../assets/images/delete.png' alt='" . _AM_MYIFRAME_DELETE . "'></a>"; |
|
265 | + if ('' === xoops_trim($frame->getVar('frame_description'))) { |
|
266 | + $liendesc = $frame->getVar('frame_url'); |
|
267 | + } else { |
|
268 | + $liendesc = "<a href='" . XOOPS_URL . '/modules/myiframe/index.php?iframeid=' . $frame->getVar('frame_frameid') . "'>" . $frame->getVar('frame_description') . '</a>'; |
|
269 | + } |
|
270 | + echo "<tr class='" |
|
271 | + . $class |
|
272 | + . "'><td align='center'>" |
|
273 | + . $frame->getVar('frame_frameid') |
|
274 | + . "</td><td align='center'>" |
|
275 | + . $liendesc |
|
276 | + . "</td><td align='center'>" |
|
277 | + . formatTimestamp($frame->getVar('frame_created')) |
|
278 | + . "</td><td align='center'>" |
|
279 | + . $frame->getVar('frame_hits') |
|
280 | + . "</td><td align='center'>" |
|
281 | + . $action_edit |
|
282 | + . ' - ' |
|
283 | + . $action_delete |
|
284 | + . "</td></tr>\n"; |
|
285 | + $class = ('even' === $class) ? 'odd' : 'even'; |
|
286 | + } |
|
287 | + } |
|
288 | + echo "<tr class='" . $class . "'><td colspan='5' align='center'><form name='faddframe' method='post' action='manage.php'><input type='hidden' name='op' value='addframe'><input type='submit' name='submit' value='" . _AM_MYIFRAME_ADD . "'></td></tr>"; |
|
289 | + echo '</table>'; |
|
290 | + require_once __DIR__ . '/admin_footer.php'; |
|
291 | + break; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | xoops_cp_footer(); |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function xoops_module_pre_uninstall_myiframe(\XoopsModule $module) |
22 | 22 | { |
23 | - // Do some synchronization |
|
24 | - return true; |
|
23 | + // Do some synchronization |
|
24 | + return true; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -32,32 +32,32 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function xoops_module_uninstall_myiframe(\XoopsModule $module) |
34 | 34 | { |
35 | - // return true; |
|
35 | + // return true; |
|
36 | 36 | |
37 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
38 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
39 | - /** @var Myiframe\Helper $helper */ |
|
40 | - $helper = Myiframe\Helper::getInstance(); |
|
37 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
38 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
39 | + /** @var Myiframe\Helper $helper */ |
|
40 | + $helper = Myiframe\Helper::getInstance(); |
|
41 | 41 | |
42 | - /** @var Myiframe\Utility $utility */ |
|
43 | - $utility = new Utility(); |
|
42 | + /** @var Myiframe\Utility $utility */ |
|
43 | + $utility = new Utility(); |
|
44 | 44 | |
45 | - $success = true; |
|
46 | - $helper->loadLanguage('admin'); |
|
45 | + $success = true; |
|
46 | + $helper->loadLanguage('admin'); |
|
47 | 47 | |
48 | - // Rename uploads folder to BAK and add date to name |
|
49 | - $uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName"); |
|
50 | - $dirInfo = new \SplFileInfo($uploadDirectory); |
|
51 | - if ($dirInfo->isDir()) { |
|
52 | - // The directory exists so rename it |
|
53 | - $date = date('Y-m-d'); |
|
54 | - if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) { |
|
55 | - $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory)); |
|
56 | - $success = false; |
|
57 | - } |
|
58 | - } |
|
59 | - unset($dirInfo); |
|
60 | - /* |
|
48 | + // Rename uploads folder to BAK and add date to name |
|
49 | + $uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName"); |
|
50 | + $dirInfo = new \SplFileInfo($uploadDirectory); |
|
51 | + if ($dirInfo->isDir()) { |
|
52 | + // The directory exists so rename it |
|
53 | + $date = date('Y-m-d'); |
|
54 | + if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) { |
|
55 | + $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory)); |
|
56 | + $success = false; |
|
57 | + } |
|
58 | + } |
|
59 | + unset($dirInfo); |
|
60 | + /* |
|
61 | 61 | //------------ START ---------------- |
62 | 62 | //------------------------------------------------------------------ |
63 | 63 | // Remove xsitemap.xml from XOOPS root folder if it exists |
@@ -71,6 +71,6 @@ discard block |
||
71 | 71 | // return $success && $delOk; // use this if you're using this routine |
72 | 72 | */ |
73 | 73 | |
74 | - return $success; |
|
75 | - //------------ END ---------------- |
|
74 | + return $success; |
|
75 | + //------------ END ---------------- |
|
76 | 76 | } |
@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | //$downloadHandler = new Myiframe\DownloadHandler($db); |
39 | 39 | |
40 | 40 | if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) { |
41 | - define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); |
|
42 | - define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
43 | - define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
44 | - define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/'); |
|
45 | - define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/'); |
|
46 | - define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images'); |
|
47 | - define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/'); |
|
48 | - define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/'); |
|
49 | - define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php'); |
|
50 | - define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png'); |
|
51 | - define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
52 | - define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
53 | - define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1); |
|
41 | + define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); |
|
42 | + define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
43 | + define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
44 | + define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/'); |
|
45 | + define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/'); |
|
46 | + define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images'); |
|
47 | + define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/'); |
|
48 | + define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/'); |
|
49 | + define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php'); |
|
50 | + define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png'); |
|
51 | + define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
52 | + define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
53 | + define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $pathIcon16 = Admin::iconUrl('', '16'); |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | //$pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
60 | 60 | |
61 | 61 | $icons = [ |
62 | - 'edit' => "<img src='" . $pathIcon16 . "/edit.png' alt=" . _EDIT . "' align='middle'>", |
|
63 | - 'delete' => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>", |
|
64 | - 'clone' => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>", |
|
65 | - 'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>", |
|
66 | - 'print' => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>", |
|
67 | - 'pdf' => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>", |
|
68 | - 'add' => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>", |
|
69 | - '0' => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>", |
|
70 | - '1' => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>", |
|
62 | + 'edit' => "<img src='" . $pathIcon16 . "/edit.png' alt=" . _EDIT . "' align='middle'>", |
|
63 | + 'delete' => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>", |
|
64 | + 'clone' => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>", |
|
65 | + 'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>", |
|
66 | + 'print' => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>", |
|
67 | + 'pdf' => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>", |
|
68 | + 'add' => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>", |
|
69 | + '0' => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>", |
|
70 | + '1' => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>", |
|
71 | 71 | ]; |
72 | 72 | |
73 | 73 | $debug = false; |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | $myts = \MyTextSanitizer::getInstance(); |
77 | 77 | |
78 | 78 | if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) { |
79 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
80 | - $GLOBALS['xoopsTpl'] = new \XoopsTpl(); |
|
79 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
80 | + $GLOBALS['xoopsTpl'] = new \XoopsTpl(); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $GLOBALS['xoopsTpl']->assign('mod_url', $helper->url()); |
84 | 84 | // Local icons path |
85 | 85 | if (is_object($helper->getModule())) { |
86 | - $pathModIcon16 = $helper->getModule() |
|
87 | - ->getInfo('modicons16'); |
|
88 | - $pathModIcon32 = $helper->getModule() |
|
89 | - ->getInfo('modicons32'); |
|
86 | + $pathModIcon16 = $helper->getModule() |
|
87 | + ->getInfo('modicons16'); |
|
88 | + $pathModIcon32 = $helper->getModule() |
|
89 | + ->getInfo('modicons32'); |
|
90 | 90 | |
91 | - $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
|
92 | - $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
|
91 | + $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
|
92 | + $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
|
93 | 93 | } |
@@ -9,8 +9,8 @@ discard block |
||
9 | 9 | |
10 | 10 | use XoopsModules\Newbb; |
11 | 11 | use XoopsModules\Myiframe\{ |
12 | - Constants, |
|
13 | - Helper |
|
12 | + Constants, |
|
13 | + Helper |
|
14 | 14 | }; |
15 | 15 | |
16 | 16 | /** @var Helper $helper */ |
@@ -23,40 +23,40 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function b_myiframe_iframe_show($options) |
25 | 25 | { |
26 | - if (!class_exists(Helper::class)) { |
|
27 | - return false; |
|
28 | - } |
|
29 | - $frame = null; |
|
30 | - $helper = Helper::getInstance(); |
|
31 | - $block = []; |
|
32 | - $tblalign = [ |
|
33 | - 'top', |
|
34 | - 'middle', |
|
35 | - 'bottom', |
|
36 | - 'left', |
|
37 | - 'rigth', |
|
38 | - ]; |
|
39 | - $tblscrolling = [ |
|
40 | - 'yes', |
|
41 | - 'no', |
|
42 | - 'auto', |
|
43 | - ]; |
|
44 | - $iframeHandler = $helper->getHandler('MyiframeBase'); |
|
45 | - $frame = $iframeHandler->get($options[0]); |
|
26 | + if (!class_exists(Helper::class)) { |
|
27 | + return false; |
|
28 | + } |
|
29 | + $frame = null; |
|
30 | + $helper = Helper::getInstance(); |
|
31 | + $block = []; |
|
32 | + $tblalign = [ |
|
33 | + 'top', |
|
34 | + 'middle', |
|
35 | + 'bottom', |
|
36 | + 'left', |
|
37 | + 'rigth', |
|
38 | + ]; |
|
39 | + $tblscrolling = [ |
|
40 | + 'yes', |
|
41 | + 'no', |
|
42 | + 'auto', |
|
43 | + ]; |
|
44 | + $iframeHandler = $helper->getHandler('MyiframeBase'); |
|
45 | + $frame = $iframeHandler->get($options[0]); |
|
46 | 46 | |
47 | - if (is_object($frame)) { |
|
48 | - $block['longdesc'] = $frame->getVar('frame_description'); |
|
49 | - $block['width'] = $frame->getVar('frame_width'); |
|
50 | - $block['height'] = $frame->getVar('frame_height'); |
|
51 | - $block['align'] = $tblalign[$frame->getVar('frame_align') - 1]; |
|
52 | - $block['frameborder'] = $frame->getVar('frame_frameborder'); |
|
53 | - $block['marginwidth'] = $frame->getVar('frame_marginwidth'); |
|
54 | - $block['marginheight'] = $frame->getVar('frame_marginheight'); |
|
55 | - $block['scrolling'] = $tblscrolling[$frame->getVar('frame_scrolling') - 1]; |
|
56 | - $block['url'] = $frame->getVar('frame_url'); |
|
57 | - } |
|
47 | + if (is_object($frame)) { |
|
48 | + $block['longdesc'] = $frame->getVar('frame_description'); |
|
49 | + $block['width'] = $frame->getVar('frame_width'); |
|
50 | + $block['height'] = $frame->getVar('frame_height'); |
|
51 | + $block['align'] = $tblalign[$frame->getVar('frame_align') - 1]; |
|
52 | + $block['frameborder'] = $frame->getVar('frame_frameborder'); |
|
53 | + $block['marginwidth'] = $frame->getVar('frame_marginwidth'); |
|
54 | + $block['marginheight'] = $frame->getVar('frame_marginheight'); |
|
55 | + $block['scrolling'] = $tblscrolling[$frame->getVar('frame_scrolling') - 1]; |
|
56 | + $block['url'] = $frame->getVar('frame_url'); |
|
57 | + } |
|
58 | 58 | |
59 | - return $block; |
|
59 | + return $block; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -65,30 +65,30 @@ discard block |
||
65 | 65 | */ |
66 | 66 | function b_myiframe_iframe_edit($options) |
67 | 67 | { |
68 | - if (!class_exists(Helper::class)) { |
|
69 | - return false; |
|
70 | - } |
|
71 | - $helper = Helper::getInstance(); |
|
68 | + if (!class_exists(Helper::class)) { |
|
69 | + return false; |
|
70 | + } |
|
71 | + $helper = Helper::getInstance(); |
|
72 | 72 | |
73 | - /** @var \MyiframeBaseHandler $iframeHandler */ |
|
74 | - $iframeHandler = $helper->getHandler('MyiframeBase'); |
|
75 | - $frarray = []; |
|
76 | - $critere = new \Criteria('1', '1', '='); |
|
77 | - $critere->setSort('frame_description'); |
|
78 | - $frarray = $iframeHandler->getObjects($critere); |
|
73 | + /** @var \MyiframeBaseHandler $iframeHandler */ |
|
74 | + $iframeHandler = $helper->getHandler('MyiframeBase'); |
|
75 | + $frarray = []; |
|
76 | + $critere = new \Criteria('1', '1', '='); |
|
77 | + $critere->setSort('frame_description'); |
|
78 | + $frarray = $iframeHandler->getObjects($critere); |
|
79 | 79 | |
80 | - $form = '' . _MB_MYIFRAME_IFRAME . " <select name='options[0]'>"; |
|
81 | - /** @var Myiframe $oneframe */ |
|
82 | - foreach ($frarray as $oneframe) { |
|
83 | - $form .= "<option value='" . $oneframe->getVar('frame_frameid') . "'"; |
|
84 | - if ($options[0] == $oneframe->getVar('frame_frameid')) { |
|
85 | - $form .= " selected='selected'"; |
|
86 | - } |
|
87 | - $form .= '>' . $oneframe->getVar('frame_description') . '</option>'; |
|
88 | - } |
|
89 | - $form .= "</select>\n"; |
|
80 | + $form = '' . _MB_MYIFRAME_IFRAME . " <select name='options[0]'>"; |
|
81 | + /** @var Myiframe $oneframe */ |
|
82 | + foreach ($frarray as $oneframe) { |
|
83 | + $form .= "<option value='" . $oneframe->getVar('frame_frameid') . "'"; |
|
84 | + if ($options[0] == $oneframe->getVar('frame_frameid')) { |
|
85 | + $form .= " selected='selected'"; |
|
86 | + } |
|
87 | + $form .= '>' . $oneframe->getVar('frame_description') . '</option>'; |
|
88 | + } |
|
89 | + $form .= "</select>\n"; |
|
90 | 90 | |
91 | - return $form; |
|
91 | + return $form; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | */ |
97 | 97 | function b_myiframe_iframe_onthefly($options): void |
98 | 98 | { |
99 | - $options = explode('|', $options); |
|
100 | - $block = b_myiframe_iframe_show($options); |
|
99 | + $options = explode('|', $options); |
|
100 | + $block = b_myiframe_iframe_show($options); |
|
101 | 101 | |
102 | - $tpl = new \XoopsTpl(); |
|
103 | - $tpl->assign('block', $block); |
|
104 | - $tpl->display('db:myiframe_block_show.tpl'); |
|
102 | + $tpl = new \XoopsTpl(); |
|
103 | + $tpl->assign('block', $block); |
|
104 | + $tpl->display('db:myiframe_block_show.tpl'); |
|
105 | 105 | } |
@@ -15,215 +15,215 @@ |
||
15 | 15 | */ |
16 | 16 | class MyiframeBaseHandler extends \XoopsObjectHandler |
17 | 17 | { |
18 | - /** |
|
19 | - * @param bool $isNew |
|
20 | - * @return \XoopsModules\Myiframe\MyiframeBase |
|
21 | - */ |
|
22 | - public function create($isNew = true) |
|
23 | - { |
|
24 | - $object = new MyiframeBase(); |
|
25 | - if ($isNew) { |
|
26 | - $object->setNew(); |
|
27 | - } |
|
28 | - |
|
29 | - return $object; |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * @param int $id |
|
34 | - * @return \XoopsModules\Myiframe\MyiframeBase|null |
|
35 | - */ |
|
36 | - public function get($id) |
|
37 | - { |
|
38 | - $ret = null; |
|
39 | - $sql = 'SELECT * FROM ' . $this->db->prefix('myiframe') . ' WHERE frame_frameid=' . (int)$id; |
|
40 | - if (!$result = $this->db->query($sql)) { |
|
41 | - return $ret; |
|
42 | - } |
|
43 | - $numrows = $this->db->getRowsNum($result); |
|
44 | - if (1 == $numrows) { |
|
45 | - $object = new MyiframeBase(); |
|
46 | - $object->assignVars($this->db->fetchArray($result)); |
|
47 | - |
|
48 | - return $object; |
|
49 | - } |
|
50 | - |
|
51 | - return $ret; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * @param bool $force |
|
56 | - * @return bool |
|
57 | - */ |
|
58 | - public function insert(\XoopsObject $object, $force = false) |
|
59 | - { |
|
60 | - if (!$object instanceof MyiframeBase) { |
|
61 | - return false; |
|
62 | - } |
|
63 | - if (!$object->isDirty()) { |
|
64 | - return true; |
|
65 | - } |
|
66 | - if (!$object->cleanVars()) { |
|
67 | - foreach ($object->getErrors() as $oneerror) { |
|
68 | - \trigger_error($oneerror); |
|
69 | - } |
|
70 | - |
|
71 | - return false; |
|
72 | - } |
|
73 | - foreach ($object->cleanVars as $k => $v) { |
|
74 | - ${$k} = $v; |
|
75 | - } |
|
76 | - |
|
77 | - if ($object->isNew()) { |
|
78 | - $format = 'INSERT INTO %s (frame_created, frame_uid, frame_description, frame_width, frame_height, frame_align, frame_frameborder, frame_marginwidth, frame_marginheight, frame_scrolling, frame_hits, frame_url) VALUES (%u, %u, %s, %s, %s, %d, %d, %d, %d, %d, %u, %s)'; |
|
79 | - $sql = \sprintf( |
|
80 | - $format, |
|
81 | - $this->db->prefix('myiframe'), |
|
82 | - $frame_created, |
|
83 | - $frame_uid, |
|
84 | - $this->db->quoteString($frame_description), |
|
85 | - $this->db->quoteString($frame_width), |
|
86 | - $this->db->quoteString($frame_height), |
|
87 | - $frame_align, |
|
88 | - $frame_frameborder, |
|
89 | - $frame_marginwidth, |
|
90 | - $frame_marginheight, |
|
91 | - $frame_scrolling, |
|
92 | - $frame_hits, |
|
93 | - $this->db->quoteString($frame_url) |
|
94 | - ); |
|
95 | - $force = true; |
|
96 | - } else { |
|
97 | - $format = 'UPDATE %s SET frame_description=%s, frame_width=%s, frame_height=%s, frame_align="%d", frame_frameborder="%d", frame_marginwidth="%d", frame_marginheight="%d", frame_scrolling="%d", frame_hits="%u", frame_url=%s WHERE frame_frameid=%u'; |
|
98 | - $sql = \sprintf( |
|
99 | - $format, |
|
100 | - $this->db->prefix('myiframe'), |
|
101 | - $this->db->quoteString($frame_description), |
|
102 | - $this->db->quoteString($frame_width), |
|
103 | - $this->db->quoteString($frame_height), |
|
104 | - $frame_align, |
|
105 | - $frame_frameborder, |
|
106 | - $frame_marginwidth, |
|
107 | - $frame_marginheight, |
|
108 | - $frame_scrolling, |
|
109 | - $frame_hits, |
|
110 | - $this->db->quoteString($frame_url), |
|
111 | - $frame_frameid |
|
112 | - ); |
|
113 | - } |
|
114 | - if (false !== $force) { |
|
115 | - $result = $this->db->queryF($sql); |
|
116 | - } else { |
|
117 | - $result = $this->db->query($sql); |
|
118 | - } |
|
119 | - if (!$result) { |
|
120 | - return false; |
|
121 | - } |
|
122 | - if (empty($frame_frameid)) { |
|
123 | - $frame_frameid = $this->db->getInsertId(); |
|
124 | - } |
|
125 | - $object->assignVar('frame_frameid', $frame_frameid); |
|
126 | - |
|
127 | - return $frame_frameid; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @param bool $force |
|
132 | - * @return bool |
|
133 | - */ |
|
134 | - public function delete(\XoopsObject $object, $force = false) |
|
135 | - { |
|
136 | - if (!$object instanceof MyiframeBase) { |
|
137 | - return false; |
|
138 | - } |
|
139 | - $sql = \sprintf('DELETE FROM %s WHERE frame_frameid = "%u"', $this->db->prefix('myiframe'), $object->getVar('frame_frameid')); |
|
140 | - if (false !== $force) { |
|
141 | - $result = $this->db->queryF($sql); |
|
142 | - } else { |
|
143 | - $result = $this->db->query($sql); |
|
144 | - } |
|
145 | - if (!$result) { |
|
146 | - return false; |
|
147 | - } |
|
148 | - |
|
149 | - return true; |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * @param \Criteria|null $criteria |
|
154 | - * @param bool $id_as_key |
|
155 | - * @return array |
|
156 | - */ |
|
157 | - public function &getObjects(\Criteria $criteria = null, $id_as_key = false): array |
|
158 | - { |
|
159 | - $ret = []; |
|
160 | - $limit = $start = 0; |
|
161 | - $sql = 'SELECT * FROM ' . $this->db->prefix('myiframe'); |
|
162 | - if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) { |
|
163 | - $sql .= ' ' . $criteria->renderWhere(); |
|
164 | - if ('' !== $criteria->getSort()) { |
|
165 | - $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); |
|
166 | - } |
|
167 | - $limit = $criteria->getLimit(); |
|
168 | - $start = $criteria->getStart(); |
|
169 | - } |
|
170 | - $result = $this->db->query($sql, $limit, $start); |
|
171 | - /** @var array $myrow */ |
|
172 | - if ($result instanceof \mysqli_result) { |
|
173 | - while (false !== ($myrow = $this->db->fetchArray($result))) { |
|
174 | - if (!$id_as_key) { |
|
175 | - $ret[] = new MyiframeBase($myrow); |
|
176 | - } else { |
|
177 | - $ret[$myrow['frame_frameid']] = new MyiframeBase($myrow); |
|
178 | - } |
|
179 | - } |
|
180 | - } |
|
181 | - |
|
182 | - return $ret; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @param \CriteriaCompo|null $criteria |
|
187 | - * @return int |
|
188 | - */ |
|
189 | - public function getCount(\CriteriaCompo $criteria = null): int |
|
190 | - { |
|
191 | - $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('myiframe'); |
|
192 | - if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) { |
|
193 | - $sql .= ' ' . $criteria->renderWhere(); |
|
194 | - } |
|
195 | - $result = $this->db->query($sql); |
|
196 | - if (!$result) { |
|
197 | - return 0; |
|
198 | - } |
|
199 | - [$count] = $this->db->fetchRow($result); |
|
200 | - |
|
201 | - return $count; |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * @param \CriteriaCompo|null $criteria |
|
206 | - * @return bool |
|
207 | - */ |
|
208 | - public function deleteAll(\CriteriaCompo $criteria = null): bool |
|
209 | - { |
|
210 | - $sql = 'DELETE FROM ' . $this->db->prefix('myiframe'); |
|
211 | - if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) { |
|
212 | - $sql .= ' ' . $criteria->renderWhere(); |
|
213 | - } |
|
214 | - if (!$result = $this->db->query($sql)) { |
|
215 | - return false; |
|
216 | - } |
|
217 | - |
|
218 | - return true; |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * @param $frame_id |
|
223 | - */ |
|
224 | - public function updatehits($frame_id): void |
|
225 | - { |
|
226 | - $sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int)$frame_id); |
|
227 | - $this->db->queryF($sql); |
|
228 | - } |
|
18 | + /** |
|
19 | + * @param bool $isNew |
|
20 | + * @return \XoopsModules\Myiframe\MyiframeBase |
|
21 | + */ |
|
22 | + public function create($isNew = true) |
|
23 | + { |
|
24 | + $object = new MyiframeBase(); |
|
25 | + if ($isNew) { |
|
26 | + $object->setNew(); |
|
27 | + } |
|
28 | + |
|
29 | + return $object; |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * @param int $id |
|
34 | + * @return \XoopsModules\Myiframe\MyiframeBase|null |
|
35 | + */ |
|
36 | + public function get($id) |
|
37 | + { |
|
38 | + $ret = null; |
|
39 | + $sql = 'SELECT * FROM ' . $this->db->prefix('myiframe') . ' WHERE frame_frameid=' . (int)$id; |
|
40 | + if (!$result = $this->db->query($sql)) { |
|
41 | + return $ret; |
|
42 | + } |
|
43 | + $numrows = $this->db->getRowsNum($result); |
|
44 | + if (1 == $numrows) { |
|
45 | + $object = new MyiframeBase(); |
|
46 | + $object->assignVars($this->db->fetchArray($result)); |
|
47 | + |
|
48 | + return $object; |
|
49 | + } |
|
50 | + |
|
51 | + return $ret; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * @param bool $force |
|
56 | + * @return bool |
|
57 | + */ |
|
58 | + public function insert(\XoopsObject $object, $force = false) |
|
59 | + { |
|
60 | + if (!$object instanceof MyiframeBase) { |
|
61 | + return false; |
|
62 | + } |
|
63 | + if (!$object->isDirty()) { |
|
64 | + return true; |
|
65 | + } |
|
66 | + if (!$object->cleanVars()) { |
|
67 | + foreach ($object->getErrors() as $oneerror) { |
|
68 | + \trigger_error($oneerror); |
|
69 | + } |
|
70 | + |
|
71 | + return false; |
|
72 | + } |
|
73 | + foreach ($object->cleanVars as $k => $v) { |
|
74 | + ${$k} = $v; |
|
75 | + } |
|
76 | + |
|
77 | + if ($object->isNew()) { |
|
78 | + $format = 'INSERT INTO %s (frame_created, frame_uid, frame_description, frame_width, frame_height, frame_align, frame_frameborder, frame_marginwidth, frame_marginheight, frame_scrolling, frame_hits, frame_url) VALUES (%u, %u, %s, %s, %s, %d, %d, %d, %d, %d, %u, %s)'; |
|
79 | + $sql = \sprintf( |
|
80 | + $format, |
|
81 | + $this->db->prefix('myiframe'), |
|
82 | + $frame_created, |
|
83 | + $frame_uid, |
|
84 | + $this->db->quoteString($frame_description), |
|
85 | + $this->db->quoteString($frame_width), |
|
86 | + $this->db->quoteString($frame_height), |
|
87 | + $frame_align, |
|
88 | + $frame_frameborder, |
|
89 | + $frame_marginwidth, |
|
90 | + $frame_marginheight, |
|
91 | + $frame_scrolling, |
|
92 | + $frame_hits, |
|
93 | + $this->db->quoteString($frame_url) |
|
94 | + ); |
|
95 | + $force = true; |
|
96 | + } else { |
|
97 | + $format = 'UPDATE %s SET frame_description=%s, frame_width=%s, frame_height=%s, frame_align="%d", frame_frameborder="%d", frame_marginwidth="%d", frame_marginheight="%d", frame_scrolling="%d", frame_hits="%u", frame_url=%s WHERE frame_frameid=%u'; |
|
98 | + $sql = \sprintf( |
|
99 | + $format, |
|
100 | + $this->db->prefix('myiframe'), |
|
101 | + $this->db->quoteString($frame_description), |
|
102 | + $this->db->quoteString($frame_width), |
|
103 | + $this->db->quoteString($frame_height), |
|
104 | + $frame_align, |
|
105 | + $frame_frameborder, |
|
106 | + $frame_marginwidth, |
|
107 | + $frame_marginheight, |
|
108 | + $frame_scrolling, |
|
109 | + $frame_hits, |
|
110 | + $this->db->quoteString($frame_url), |
|
111 | + $frame_frameid |
|
112 | + ); |
|
113 | + } |
|
114 | + if (false !== $force) { |
|
115 | + $result = $this->db->queryF($sql); |
|
116 | + } else { |
|
117 | + $result = $this->db->query($sql); |
|
118 | + } |
|
119 | + if (!$result) { |
|
120 | + return false; |
|
121 | + } |
|
122 | + if (empty($frame_frameid)) { |
|
123 | + $frame_frameid = $this->db->getInsertId(); |
|
124 | + } |
|
125 | + $object->assignVar('frame_frameid', $frame_frameid); |
|
126 | + |
|
127 | + return $frame_frameid; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @param bool $force |
|
132 | + * @return bool |
|
133 | + */ |
|
134 | + public function delete(\XoopsObject $object, $force = false) |
|
135 | + { |
|
136 | + if (!$object instanceof MyiframeBase) { |
|
137 | + return false; |
|
138 | + } |
|
139 | + $sql = \sprintf('DELETE FROM %s WHERE frame_frameid = "%u"', $this->db->prefix('myiframe'), $object->getVar('frame_frameid')); |
|
140 | + if (false !== $force) { |
|
141 | + $result = $this->db->queryF($sql); |
|
142 | + } else { |
|
143 | + $result = $this->db->query($sql); |
|
144 | + } |
|
145 | + if (!$result) { |
|
146 | + return false; |
|
147 | + } |
|
148 | + |
|
149 | + return true; |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * @param \Criteria|null $criteria |
|
154 | + * @param bool $id_as_key |
|
155 | + * @return array |
|
156 | + */ |
|
157 | + public function &getObjects(\Criteria $criteria = null, $id_as_key = false): array |
|
158 | + { |
|
159 | + $ret = []; |
|
160 | + $limit = $start = 0; |
|
161 | + $sql = 'SELECT * FROM ' . $this->db->prefix('myiframe'); |
|
162 | + if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) { |
|
163 | + $sql .= ' ' . $criteria->renderWhere(); |
|
164 | + if ('' !== $criteria->getSort()) { |
|
165 | + $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); |
|
166 | + } |
|
167 | + $limit = $criteria->getLimit(); |
|
168 | + $start = $criteria->getStart(); |
|
169 | + } |
|
170 | + $result = $this->db->query($sql, $limit, $start); |
|
171 | + /** @var array $myrow */ |
|
172 | + if ($result instanceof \mysqli_result) { |
|
173 | + while (false !== ($myrow = $this->db->fetchArray($result))) { |
|
174 | + if (!$id_as_key) { |
|
175 | + $ret[] = new MyiframeBase($myrow); |
|
176 | + } else { |
|
177 | + $ret[$myrow['frame_frameid']] = new MyiframeBase($myrow); |
|
178 | + } |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + return $ret; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * @param \CriteriaCompo|null $criteria |
|
187 | + * @return int |
|
188 | + */ |
|
189 | + public function getCount(\CriteriaCompo $criteria = null): int |
|
190 | + { |
|
191 | + $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('myiframe'); |
|
192 | + if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) { |
|
193 | + $sql .= ' ' . $criteria->renderWhere(); |
|
194 | + } |
|
195 | + $result = $this->db->query($sql); |
|
196 | + if (!$result) { |
|
197 | + return 0; |
|
198 | + } |
|
199 | + [$count] = $this->db->fetchRow($result); |
|
200 | + |
|
201 | + return $count; |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * @param \CriteriaCompo|null $criteria |
|
206 | + * @return bool |
|
207 | + */ |
|
208 | + public function deleteAll(\CriteriaCompo $criteria = null): bool |
|
209 | + { |
|
210 | + $sql = 'DELETE FROM ' . $this->db->prefix('myiframe'); |
|
211 | + if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) { |
|
212 | + $sql .= ' ' . $criteria->renderWhere(); |
|
213 | + } |
|
214 | + if (!$result = $this->db->query($sql)) { |
|
215 | + return false; |
|
216 | + } |
|
217 | + |
|
218 | + return true; |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * @param $frame_id |
|
223 | + */ |
|
224 | + public function updatehits($frame_id): void |
|
225 | + { |
|
226 | + $sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int)$frame_id); |
|
227 | + $this->db->queryF($sql); |
|
228 | + } |
|
229 | 229 | } |
@@ -27,26 +27,26 @@ |
||
27 | 27 | */ |
28 | 28 | final class Constants |
29 | 29 | { |
30 | - /**#@+ |
|
30 | + /**#@+ |
|
31 | 31 | * Constant definition |
32 | 32 | */ |
33 | 33 | |
34 | - public const DISALLOW = 0; |
|
35 | - /** |
|
36 | - * no delay XOOPS redirect delay (in seconds) |
|
37 | - */ |
|
38 | - public const REDIRECT_DELAY_NONE = 0; |
|
39 | - /** |
|
40 | - * short XOOPS redirect delay (in seconds) |
|
41 | - */ |
|
42 | - public const REDIRECT_DELAY_SHORT = 1; |
|
43 | - /** |
|
44 | - * medium XOOPS redirect delay (in seconds) |
|
45 | - */ |
|
46 | - public const REDIRECT_DELAY_MEDIUM = 3; |
|
47 | - /** |
|
48 | - * long XOOPS redirect delay (in seconds) |
|
49 | - */ |
|
50 | - public const REDIRECT_DELAY_LONG = 7; |
|
51 | - /**#@-*/ |
|
34 | + public const DISALLOW = 0; |
|
35 | + /** |
|
36 | + * no delay XOOPS redirect delay (in seconds) |
|
37 | + */ |
|
38 | + public const REDIRECT_DELAY_NONE = 0; |
|
39 | + /** |
|
40 | + * short XOOPS redirect delay (in seconds) |
|
41 | + */ |
|
42 | + public const REDIRECT_DELAY_SHORT = 1; |
|
43 | + /** |
|
44 | + * medium XOOPS redirect delay (in seconds) |
|
45 | + */ |
|
46 | + public const REDIRECT_DELAY_MEDIUM = 3; |
|
47 | + /** |
|
48 | + * long XOOPS redirect delay (in seconds) |
|
49 | + */ |
|
50 | + public const REDIRECT_DELAY_LONG = 7; |
|
51 | + /**#@-*/ |
|
52 | 52 | } |
@@ -19,226 +19,226 @@ |
||
19 | 19 | */ |
20 | 20 | trait FilesManagement |
21 | 21 | { |
22 | - /** |
|
23 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
24 | - * |
|
25 | - * @param string $folder The full path of the directory to check |
|
26 | - */ |
|
27 | - public static function createFolder($folder): void |
|
28 | - { |
|
29 | - try { |
|
30 | - if (!\is_dir($folder)) { |
|
31 | - if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { |
|
32 | - throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); |
|
33 | - } |
|
34 | - |
|
35 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
36 | - } |
|
37 | - } catch (\Throwable $e) { |
|
38 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @param string $file |
|
44 | - * @param string $folder |
|
45 | - * @return bool |
|
46 | - */ |
|
47 | - public static function copyFile(string $file, string $folder): bool |
|
48 | - { |
|
49 | - return \copy($file, $folder); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @param $src |
|
54 | - * @param $dst |
|
55 | - */ |
|
56 | - public static function recurseCopy($src, $dst): void |
|
57 | - { |
|
58 | - $dir = \opendir($src); |
|
59 | - // @mkdir($dst); |
|
60 | - if (!@\mkdir($dst) && !\is_dir($dst)) { |
|
61 | - throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); |
|
62 | - } |
|
63 | - while (false !== ($file = \readdir($dir))) { |
|
64 | - if (('.' !== $file) && ('..' !== $file)) { |
|
65 | - if (\is_dir($src . '/' . $file)) { |
|
66 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
67 | - } else { |
|
68 | - \copy($src . '/' . $file, $dst . '/' . $file); |
|
69 | - } |
|
70 | - } |
|
71 | - } |
|
72 | - \closedir($dir); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Remove files and (sub)directories |
|
77 | - * |
|
78 | - * @param string $src source directory to delete |
|
79 | - * |
|
80 | - * @return bool true on success |
|
81 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
82 | - * |
|
83 | - * @uses \Xmf\Module\Helper::getHelper() |
|
84 | - */ |
|
85 | - public static function deleteDirectory($src): bool |
|
86 | - { |
|
87 | - // Only continue if user is a 'global' Admin |
|
88 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
89 | - return false; |
|
90 | - } |
|
91 | - |
|
92 | - $success = true; |
|
93 | - // remove old files |
|
94 | - $dirInfo = new \SplFileInfo($src); |
|
95 | - // validate is a directory |
|
96 | - if ($dirInfo->isDir()) { |
|
97 | - $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']); |
|
98 | - foreach ($fileList as $k => $v) { |
|
99 | - $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
|
100 | - if ($fileInfo->isDir()) { |
|
101 | - // recursively handle subdirectories |
|
102 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
103 | - break; |
|
104 | - } |
|
105 | - } elseif (!($success = \unlink($fileInfo->getRealPath()))) { |
|
106 | - break; |
|
107 | - } |
|
108 | - } |
|
109 | - // now delete this (sub)directory if all the files are gone |
|
110 | - if ($success) { |
|
111 | - $success = \rmdir($dirInfo->getRealPath()); |
|
112 | - } |
|
113 | - } else { |
|
114 | - // input is not a valid directory |
|
115 | - $success = false; |
|
116 | - } |
|
117 | - |
|
118 | - return $success; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Recursively remove directory |
|
123 | - * |
|
124 | - * @todo currently won't remove directories with hidden files, should it? |
|
125 | - * |
|
126 | - * @param string $src directory to remove (delete) |
|
127 | - * |
|
128 | - * @return bool true on success |
|
129 | - */ |
|
130 | - public static function rrmdir($src): bool |
|
131 | - { |
|
132 | - // Only continue if user is a 'global' Admin |
|
133 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
134 | - return false; |
|
135 | - } |
|
136 | - |
|
137 | - // If source is not a directory stop processing |
|
138 | - if (!\is_dir($src)) { |
|
139 | - return false; |
|
140 | - } |
|
141 | - |
|
142 | - $success = true; |
|
143 | - |
|
144 | - // Open the source directory to read in files |
|
145 | - $iterator = new \DirectoryIterator($src); |
|
146 | - foreach ($iterator as $fObj) { |
|
147 | - if ($fObj->isFile()) { |
|
148 | - $filename = $fObj->getPathname(); |
|
149 | - $fObj = null; // clear this iterator object to close the file |
|
150 | - if (!\unlink($filename)) { |
|
151 | - return false; // couldn't delete the file |
|
152 | - } |
|
153 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
154 | - // Try recursively on directory |
|
155 | - self::rrmdir($fObj->getPathname()); |
|
156 | - } |
|
157 | - } |
|
158 | - $iterator = null; // clear iterator Obj to close file/directory |
|
159 | - |
|
160 | - return \rmdir($src); // remove the directory & return results |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Recursively move files from one directory to another |
|
165 | - * |
|
166 | - * @param string $src - Source of files being moved |
|
167 | - * @param string $dest - Destination of files being moved |
|
168 | - * |
|
169 | - * @return bool true on success |
|
170 | - */ |
|
171 | - public static function rmove($src, $dest): bool |
|
172 | - { |
|
173 | - // Only continue if user is a 'global' Admin |
|
174 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
175 | - return false; |
|
176 | - } |
|
177 | - |
|
178 | - // If source is not a directory stop processing |
|
179 | - if (!\is_dir($src)) { |
|
180 | - return false; |
|
181 | - } |
|
182 | - |
|
183 | - // If the destination directory does not exist and could not be created stop processing |
|
184 | - if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { |
|
185 | - return false; |
|
186 | - } |
|
187 | - |
|
188 | - // Open the source directory to read in files |
|
189 | - $iterator = new \DirectoryIterator($src); |
|
190 | - foreach ($iterator as $fObj) { |
|
191 | - if ($fObj->isFile()) { |
|
192 | - \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
193 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
194 | - // Try recursively on directory |
|
195 | - self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
196 | - // rmdir($fObj->getPath()); // now delete the directory |
|
197 | - } |
|
198 | - } |
|
199 | - $iterator = null; // clear iterator Obj to close file/directory |
|
200 | - |
|
201 | - return \rmdir($src); // remove the directory & return results |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Recursively copy directories and files from one directory to another |
|
206 | - * |
|
207 | - * @param string $src - Source of files being moved |
|
208 | - * @param string $dest - Destination of files being moved |
|
209 | - * |
|
210 | - * @return bool true on success |
|
211 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
212 | - * |
|
213 | - * @uses \Xmf\Module\Helper::getHelper() |
|
214 | - */ |
|
215 | - public static function rcopy($src, $dest): bool |
|
216 | - { |
|
217 | - // Only continue if user is a 'global' Admin |
|
218 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
219 | - return false; |
|
220 | - } |
|
221 | - |
|
222 | - // If source is not a directory stop processing |
|
223 | - if (!\is_dir($src)) { |
|
224 | - return false; |
|
225 | - } |
|
226 | - |
|
227 | - // If the destination directory does not exist and could not be created stop processing |
|
228 | - if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { |
|
229 | - return false; |
|
230 | - } |
|
231 | - |
|
232 | - // Open the source directory to read in files |
|
233 | - $iterator = new \DirectoryIterator($src); |
|
234 | - foreach ($iterator as $fObj) { |
|
235 | - if ($fObj->isFile()) { |
|
236 | - \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
237 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
238 | - self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
239 | - } |
|
240 | - } |
|
241 | - |
|
242 | - return true; |
|
243 | - } |
|
22 | + /** |
|
23 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
24 | + * |
|
25 | + * @param string $folder The full path of the directory to check |
|
26 | + */ |
|
27 | + public static function createFolder($folder): void |
|
28 | + { |
|
29 | + try { |
|
30 | + if (!\is_dir($folder)) { |
|
31 | + if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { |
|
32 | + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); |
|
33 | + } |
|
34 | + |
|
35 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
36 | + } |
|
37 | + } catch (\Throwable $e) { |
|
38 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
39 | + } |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @param string $file |
|
44 | + * @param string $folder |
|
45 | + * @return bool |
|
46 | + */ |
|
47 | + public static function copyFile(string $file, string $folder): bool |
|
48 | + { |
|
49 | + return \copy($file, $folder); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @param $src |
|
54 | + * @param $dst |
|
55 | + */ |
|
56 | + public static function recurseCopy($src, $dst): void |
|
57 | + { |
|
58 | + $dir = \opendir($src); |
|
59 | + // @mkdir($dst); |
|
60 | + if (!@\mkdir($dst) && !\is_dir($dst)) { |
|
61 | + throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); |
|
62 | + } |
|
63 | + while (false !== ($file = \readdir($dir))) { |
|
64 | + if (('.' !== $file) && ('..' !== $file)) { |
|
65 | + if (\is_dir($src . '/' . $file)) { |
|
66 | + self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
67 | + } else { |
|
68 | + \copy($src . '/' . $file, $dst . '/' . $file); |
|
69 | + } |
|
70 | + } |
|
71 | + } |
|
72 | + \closedir($dir); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Remove files and (sub)directories |
|
77 | + * |
|
78 | + * @param string $src source directory to delete |
|
79 | + * |
|
80 | + * @return bool true on success |
|
81 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
82 | + * |
|
83 | + * @uses \Xmf\Module\Helper::getHelper() |
|
84 | + */ |
|
85 | + public static function deleteDirectory($src): bool |
|
86 | + { |
|
87 | + // Only continue if user is a 'global' Admin |
|
88 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
89 | + return false; |
|
90 | + } |
|
91 | + |
|
92 | + $success = true; |
|
93 | + // remove old files |
|
94 | + $dirInfo = new \SplFileInfo($src); |
|
95 | + // validate is a directory |
|
96 | + if ($dirInfo->isDir()) { |
|
97 | + $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']); |
|
98 | + foreach ($fileList as $k => $v) { |
|
99 | + $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
|
100 | + if ($fileInfo->isDir()) { |
|
101 | + // recursively handle subdirectories |
|
102 | + if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
103 | + break; |
|
104 | + } |
|
105 | + } elseif (!($success = \unlink($fileInfo->getRealPath()))) { |
|
106 | + break; |
|
107 | + } |
|
108 | + } |
|
109 | + // now delete this (sub)directory if all the files are gone |
|
110 | + if ($success) { |
|
111 | + $success = \rmdir($dirInfo->getRealPath()); |
|
112 | + } |
|
113 | + } else { |
|
114 | + // input is not a valid directory |
|
115 | + $success = false; |
|
116 | + } |
|
117 | + |
|
118 | + return $success; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Recursively remove directory |
|
123 | + * |
|
124 | + * @todo currently won't remove directories with hidden files, should it? |
|
125 | + * |
|
126 | + * @param string $src directory to remove (delete) |
|
127 | + * |
|
128 | + * @return bool true on success |
|
129 | + */ |
|
130 | + public static function rrmdir($src): bool |
|
131 | + { |
|
132 | + // Only continue if user is a 'global' Admin |
|
133 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
134 | + return false; |
|
135 | + } |
|
136 | + |
|
137 | + // If source is not a directory stop processing |
|
138 | + if (!\is_dir($src)) { |
|
139 | + return false; |
|
140 | + } |
|
141 | + |
|
142 | + $success = true; |
|
143 | + |
|
144 | + // Open the source directory to read in files |
|
145 | + $iterator = new \DirectoryIterator($src); |
|
146 | + foreach ($iterator as $fObj) { |
|
147 | + if ($fObj->isFile()) { |
|
148 | + $filename = $fObj->getPathname(); |
|
149 | + $fObj = null; // clear this iterator object to close the file |
|
150 | + if (!\unlink($filename)) { |
|
151 | + return false; // couldn't delete the file |
|
152 | + } |
|
153 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
154 | + // Try recursively on directory |
|
155 | + self::rrmdir($fObj->getPathname()); |
|
156 | + } |
|
157 | + } |
|
158 | + $iterator = null; // clear iterator Obj to close file/directory |
|
159 | + |
|
160 | + return \rmdir($src); // remove the directory & return results |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Recursively move files from one directory to another |
|
165 | + * |
|
166 | + * @param string $src - Source of files being moved |
|
167 | + * @param string $dest - Destination of files being moved |
|
168 | + * |
|
169 | + * @return bool true on success |
|
170 | + */ |
|
171 | + public static function rmove($src, $dest): bool |
|
172 | + { |
|
173 | + // Only continue if user is a 'global' Admin |
|
174 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
175 | + return false; |
|
176 | + } |
|
177 | + |
|
178 | + // If source is not a directory stop processing |
|
179 | + if (!\is_dir($src)) { |
|
180 | + return false; |
|
181 | + } |
|
182 | + |
|
183 | + // If the destination directory does not exist and could not be created stop processing |
|
184 | + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { |
|
185 | + return false; |
|
186 | + } |
|
187 | + |
|
188 | + // Open the source directory to read in files |
|
189 | + $iterator = new \DirectoryIterator($src); |
|
190 | + foreach ($iterator as $fObj) { |
|
191 | + if ($fObj->isFile()) { |
|
192 | + \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
193 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
194 | + // Try recursively on directory |
|
195 | + self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
196 | + // rmdir($fObj->getPath()); // now delete the directory |
|
197 | + } |
|
198 | + } |
|
199 | + $iterator = null; // clear iterator Obj to close file/directory |
|
200 | + |
|
201 | + return \rmdir($src); // remove the directory & return results |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Recursively copy directories and files from one directory to another |
|
206 | + * |
|
207 | + * @param string $src - Source of files being moved |
|
208 | + * @param string $dest - Destination of files being moved |
|
209 | + * |
|
210 | + * @return bool true on success |
|
211 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
212 | + * |
|
213 | + * @uses \Xmf\Module\Helper::getHelper() |
|
214 | + */ |
|
215 | + public static function rcopy($src, $dest): bool |
|
216 | + { |
|
217 | + // Only continue if user is a 'global' Admin |
|
218 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
219 | + return false; |
|
220 | + } |
|
221 | + |
|
222 | + // If source is not a directory stop processing |
|
223 | + if (!\is_dir($src)) { |
|
224 | + return false; |
|
225 | + } |
|
226 | + |
|
227 | + // If the destination directory does not exist and could not be created stop processing |
|
228 | + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { |
|
229 | + return false; |
|
230 | + } |
|
231 | + |
|
232 | + // Open the source directory to read in files |
|
233 | + $iterator = new \DirectoryIterator($src); |
|
234 | + foreach ($iterator as $fObj) { |
|
235 | + if ($fObj->isFile()) { |
|
236 | + \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
237 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
238 | + self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
239 | + } |
|
240 | + } |
|
241 | + |
|
242 | + return true; |
|
243 | + } |
|
244 | 244 | } |