Passed
Pull Request — master (#8)
by Michael
11:33
created
class/Common/TestdataButtons.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 use Xmf\{
26
-    Module\Admin,
27
-    Request,
28
-    Yaml
26
+	Module\Admin,
27
+	Request,
28
+	Yaml
29 29
 };
30 30
 use XoopsModules\Myiframe\{
31
-    Helper
31
+	Helper
32 32
 };
33 33
 
34 34
 /** @var Helper $helper */
@@ -40,64 +40,64 @@  discard block
 block discarded – undo
40 40
  */
41 41
 class TestdataButtons
42 42
 {
43
-    /** Button status constants */
44
-    private const SHOW_BUTTONS = 1;
45
-    private const HIDE_BUTTONS = 0;
43
+	/** Button status constants */
44
+	private const SHOW_BUTTONS = 1;
45
+	private const HIDE_BUTTONS = 0;
46 46
 
47
-    /**
48
-     * Load the test button configuration
49
-     *
50
-     * @param \Xmf\Module\Admin $adminObject
51
-     *
52
-     * @return void
53
-     */
54
-    public static function loadButtonConfig(Admin $adminObject): void
55
-    {
56
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
57
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
58
-        $helper              = Helper::getInstance();
59
-        $yamlFile            = $helper->path('/config/admin.yml');
60
-        $config             = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps
61
-        $displaySampleButton = $config['displaySampleButton'];
47
+	/**
48
+	 * Load the test button configuration
49
+	 *
50
+	 * @param \Xmf\Module\Admin $adminObject
51
+	 *
52
+	 * @return void
53
+	 */
54
+	public static function loadButtonConfig(Admin $adminObject): void
55
+	{
56
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
57
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
58
+		$helper              = Helper::getInstance();
59
+		$yamlFile            = $helper->path('/config/admin.yml');
60
+		$config             = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps
61
+		$displaySampleButton = $config['displaySampleButton'];
62 62
 
63
-        if (self::SHOW_BUTTONS == $displaySampleButton) {
64
-            \xoops_loadLanguage('admin/modulesadmin', 'system');
65
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add');
66
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add');
67
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert');
68
-            //    $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add');
69
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
70
-        } else {
71
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
72
-            // $displaySampleButton = $config['displaySampleButton'];
73
-        }
74
-    }
63
+		if (self::SHOW_BUTTONS == $displaySampleButton) {
64
+			\xoops_loadLanguage('admin/modulesadmin', 'system');
65
+			$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add');
66
+			$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add');
67
+			$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert');
68
+			//    $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add');
69
+			$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
70
+		} else {
71
+			$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
72
+			// $displaySampleButton = $config['displaySampleButton'];
73
+		}
74
+	}
75 75
 
76
-    /**
77
-     * Hide the test buttons
78
-     *
79
-     * @return void
80
-     */
81
-    public static function hideButtons(): void
82
-    {
83
-        $yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
84
-        $app                        = [];
85
-        $app['displaySampleButton'] = 0;
86
-        Yaml::save($app, $yamlFile);
87
-        \redirect_header('index.php', 0, '');
88
-    }
76
+	/**
77
+	 * Hide the test buttons
78
+	 *
79
+	 * @return void
80
+	 */
81
+	public static function hideButtons(): void
82
+	{
83
+		$yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
84
+		$app                        = [];
85
+		$app['displaySampleButton'] = 0;
86
+		Yaml::save($app, $yamlFile);
87
+		\redirect_header('index.php', 0, '');
88
+	}
89 89
 
90
-    /**
91
-     * Show the test buttons
92
-     *
93
-     * @return void
94
-     */
95
-    public static function showButtons(): void
96
-    {
97
-        $yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
98
-        $app                        = [];
99
-        $app['displaySampleButton'] = 1;
100
-        Yaml::save($app, $yamlFile);
101
-        \redirect_header('index.php', 0, '');
102
-    }
90
+	/**
91
+	 * Show the test buttons
92
+	 *
93
+	 * @return void
94
+	 */
95
+	public static function showButtons(): void
96
+	{
97
+		$yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
98
+		$app                        = [];
99
+		$app['displaySampleButton'] = 1;
100
+		Yaml::save($app, $yamlFile);
101
+		\redirect_header('index.php', 0, '');
102
+	}
103 103
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 
63 63
         if (self::SHOW_BUTTONS == $displaySampleButton) {
64 64
             \xoops_loadLanguage('admin/modulesadmin', 'system');
65
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add');
66
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add');
67
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert');
65
+            $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add');
66
+            $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add');
67
+            $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert');
68 68
             //    $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add');
69
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
69
+            $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
70 70
         } else {
71
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
71
+            $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
72 72
             // $displaySampleButton = $config['displaySampleButton'];
73 73
         }
74 74
     }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public static function hideButtons(): void
82 82
     {
83
-        $yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
83
+        $yamlFile                   = \dirname(__DIR__, 2).'/config/admin.yml';
84 84
         $app                        = [];
85 85
         $app['displaySampleButton'] = 0;
86 86
         Yaml::save($app, $yamlFile);
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public static function showButtons(): void
96 96
     {
97
-        $yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
97
+        $yamlFile                   = \dirname(__DIR__, 2).'/config/admin.yml';
98 98
         $app                        = [];
99 99
         $app['displaySampleButton'] = 1;
100 100
         Yaml::save($app, $yamlFile);
Please login to merge, or discard this patch.
class/Common/ServerStats.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -19,60 +19,60 @@
 block discarded – undo
19 19
  */
20 20
 trait ServerStats
21 21
 {
22
-    /**
23
-     * serverStats()
24
-     *
25
-     * @return string
26
-     */
27
-    public static function getServerStats()
28
-    {
29
-        //mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
30
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
31
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
32
-        \xoops_loadLanguage('common', $moduleDirName);
33
-        $html = '';
34
-        //        $sql   = 'SELECT metavalue';
35
-        //        $sql   .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta');
36
-        //        $sql   .= " WHERE metakey='version' LIMIT 1";
37
-        //        $query = $GLOBALS['xoopsDB']->query($sql);
38
-        //        list($meta) = $GLOBALS['xoopsDB']->fetchRow($query);
39
-        $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . \constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n";
40
-        $html .= "<div style='padding: 8px;'>\n";
41
-        //        $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n";
42
-        //        $html .= "<br>\n";
43
-        //        $html .= "<br>\n";
44
-        $html .= '<div>' . \constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n";
45
-        $html .= "<ul>\n";
22
+	/**
23
+	 * serverStats()
24
+	 *
25
+	 * @return string
26
+	 */
27
+	public static function getServerStats()
28
+	{
29
+		//mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
30
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
31
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
32
+		\xoops_loadLanguage('common', $moduleDirName);
33
+		$html = '';
34
+		//        $sql   = 'SELECT metavalue';
35
+		//        $sql   .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta');
36
+		//        $sql   .= " WHERE metakey='version' LIMIT 1";
37
+		//        $query = $GLOBALS['xoopsDB']->query($sql);
38
+		//        list($meta) = $GLOBALS['xoopsDB']->fetchRow($query);
39
+		$html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . \constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n";
40
+		$html .= "<div style='padding: 8px;'>\n";
41
+		//        $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n";
42
+		//        $html .= "<br>\n";
43
+		//        $html .= "<br>\n";
44
+		$html .= '<div>' . \constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n";
45
+		$html .= "<ul>\n";
46 46
 
47
-        $gdlib = \function_exists('gd_info') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>';
48
-        $html  .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
49
-        if (\function_exists('gd_info')) {
50
-            if (true === ($gdlib = gd_info())) {
51
-                $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>';
52
-            }
53
-        }
54
-        //
55
-        //    $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF');
56
-        //    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode;
57
-        //
58
-        //    $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>';
59
-        //    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals;
60
-        //
61
-        $downloads = \ini_get('file_uploads') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>';
62
-        $html      .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads;
47
+		$gdlib = \function_exists('gd_info') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>';
48
+		$html  .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
49
+		if (\function_exists('gd_info')) {
50
+			if (true === ($gdlib = gd_info())) {
51
+				$html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>';
52
+			}
53
+		}
54
+		//
55
+		//    $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF');
56
+		//    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode;
57
+		//
58
+		//    $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>';
59
+		//    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals;
60
+		//
61
+		$downloads = \ini_get('file_uploads') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>';
62
+		$html      .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads;
63 63
 
64
-        $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . \ini_get('upload_max_filesize') . "</span></b>\n";
65
-        $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . \ini_get('post_max_size') . "</span></b>\n";
66
-        $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . \ini_get('memory_limit') . "</span></b>\n";
67
-        $html .= "</ul>\n";
68
-        $html .= "<ul>\n";
69
-        $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n";
70
-        $html .= "</ul>\n";
71
-        $html .= "<br>\n";
72
-        $html .= \constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n";
73
-        $html .= '</div>';
74
-        $html .= '</fieldset><br>';
64
+		$html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . \ini_get('upload_max_filesize') . "</span></b>\n";
65
+		$html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . \ini_get('post_max_size') . "</span></b>\n";
66
+		$html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . \ini_get('memory_limit') . "</span></b>\n";
67
+		$html .= "</ul>\n";
68
+		$html .= "<ul>\n";
69
+		$html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n";
70
+		$html .= "</ul>\n";
71
+		$html .= "<br>\n";
72
+		$html .= \constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n";
73
+		$html .= '</div>';
74
+		$html .= '</fieldset><br>';
75 75
 
76
-        return $html;
77
-    }
76
+		return $html;
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,19 +36,19 @@  discard block
 block discarded – undo
36 36
         //        $sql   .= " WHERE metakey='version' LIMIT 1";
37 37
         //        $query = $GLOBALS['xoopsDB']->query($sql);
38 38
         //        list($meta) = $GLOBALS['xoopsDB']->fetchRow($query);
39
-        $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . \constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n";
39
+        $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>".\constant('CO_'.$moduleDirNameUpper.'_IMAGEINFO')."</legend>\n";
40 40
         $html .= "<div style='padding: 8px;'>\n";
41 41
         //        $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n";
42 42
         //        $html .= "<br>\n";
43 43
         //        $html .= "<br>\n";
44
-        $html .= '<div>' . \constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n";
44
+        $html .= '<div>'.\constant('CO_'.$moduleDirNameUpper.'_SPHPINI')."</div>\n";
45 45
         $html .= "<ul>\n";
46 46
 
47
-        $gdlib = \function_exists('gd_info') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>';
48
-        $html  .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
47
+        $gdlib = \function_exists('gd_info') ? '<span style="color: green;">'.\constant('CO_'.$moduleDirNameUpper.'_GDON').'</span>' : '<span style="color: red;">'.\constant('CO_'.$moduleDirNameUpper.'_GDOFF').'</span>';
48
+        $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_GDLIBSTATUS').$gdlib;
49 49
         if (\function_exists('gd_info')) {
50 50
             if (true === ($gdlib = gd_info())) {
51
-                $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>';
51
+                $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_GDLIBVERSION').'<b>'.$gdlib['GD Version'].'</b>';
52 52
             }
53 53
         }
54 54
         //
@@ -58,18 +58,18 @@  discard block
 block discarded – undo
58 58
         //    $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>';
59 59
         //    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals;
60 60
         //
61
-        $downloads = \ini_get('file_uploads') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>';
62
-        $html      .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads;
61
+        $downloads = \ini_get('file_uploads') ? '<span style="color: green;">'.\constant('CO_'.$moduleDirNameUpper.'_ON').'</span>' : '<span style="color: red;">'.\constant('CO_'.$moduleDirNameUpper.'_OFF').'</span>';
62
+        $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_SERVERUPLOADSTATUS').$downloads;
63 63
 
64
-        $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . \ini_get('upload_max_filesize') . "</span></b>\n";
65
-        $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . \ini_get('post_max_size') . "</span></b>\n";
66
-        $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . \ini_get('memory_limit') . "</span></b>\n";
64
+        $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_MAXUPLOADSIZE').' <b><span style="color: blue;">'.\ini_get('upload_max_filesize')."</span></b>\n";
65
+        $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_MAXPOSTSIZE').' <b><span style="color: blue;">'.\ini_get('post_max_size')."</span></b>\n";
66
+        $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_MEMORYLIMIT').' <b><span style="color: blue;">'.\ini_get('memory_limit')."</span></b>\n";
67 67
         $html .= "</ul>\n";
68 68
         $html .= "<ul>\n";
69
-        $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n";
69
+        $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_SERVERPATH').' <b>'.XOOPS_ROOT_PATH."</b>\n";
70 70
         $html .= "</ul>\n";
71 71
         $html .= "<br>\n";
72
-        $html .= \constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n";
72
+        $html .= \constant('CO_'.$moduleDirNameUpper.'_UPLOADPATHDSC')."\n";
73 73
         $html .= '</div>';
74 74
         $html .= '</fieldset><br>';
75 75
 
Please login to merge, or discard this patch.
class/Common/FilesManagement.php 2 patches
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -19,225 +19,225 @@
 block discarded – undo
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 $file
44
-     * @param $folder
45
-     */
46
-    public static function copyFile(string $file, string $folder): bool
47
-    {
48
-        return \copy($file, $folder);
49
-    }
50
-
51
-    /**
52
-     * @param $src
53
-     * @param $dst
54
-     */
55
-    public static function recurseCopy($src, $dst): void
56
-    {
57
-        $dir = \opendir($src);
58
-        //        @mkdir($dst);
59
-        if (!@\mkdir($dst) && !\is_dir($dst)) {
60
-            throw new \RuntimeException('The directory ' . $dst . ' could not be created.');
61
-        }
62
-        while (false !== ($file = \readdir($dir))) {
63
-            if (('.' !== $file) && ('..' !== $file)) {
64
-                if (\is_dir($src . '/' . $file)) {
65
-                    self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
66
-                } else {
67
-                    \copy($src . '/' . $file, $dst . '/' . $file);
68
-                }
69
-            }
70
-        }
71
-        \closedir($dir);
72
-    }
73
-
74
-    /**
75
-     * Remove files and (sub)directories
76
-     *
77
-     * @param string $src source directory to delete
78
-     *
79
-     * @return bool true on success
80
-     * @uses \Xmf\Module\Helper::isUserAdmin()
81
-     *
82
-     * @uses \Xmf\Module\Helper::getHelper()
83
-     */
84
-    public static function deleteDirectory($src)
85
-    {
86
-        // Only continue if user is a 'global' Admin
87
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
88
-            return false;
89
-        }
90
-
91
-        $success = true;
92
-        // remove old files
93
-        $dirInfo = new \SplFileInfo($src);
94
-        // validate is a directory
95
-        if ($dirInfo->isDir()) {
96
-            $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']);
97
-            foreach ($fileList as $k => $v) {
98
-                $fileInfo = new \SplFileInfo("{$src}/{$v}");
99
-                if ($fileInfo->isDir()) {
100
-                    // recursively handle subdirectories
101
-                    if (!$success = self::deleteDirectory($fileInfo->getRealPath())) {
102
-                        break;
103
-                    }
104
-                } elseif (!($success = \unlink($fileInfo->getRealPath()))) {
105
-                    break;
106
-                }
107
-            }
108
-            // now delete this (sub)directory if all the files are gone
109
-            if ($success) {
110
-                $success = \rmdir($dirInfo->getRealPath());
111
-            }
112
-        } else {
113
-            // input is not a valid directory
114
-            $success = false;
115
-        }
116
-
117
-        return $success;
118
-    }
119
-
120
-    /**
121
-     * Recursively remove directory
122
-     *
123
-     * @todo currently won't remove directories with hidden files, should it?
124
-     *
125
-     * @param string $src directory to remove (delete)
126
-     *
127
-     * @return bool true on success
128
-     */
129
-    public static function rrmdir($src)
130
-    {
131
-        // Only continue if user is a 'global' Admin
132
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
133
-            return false;
134
-        }
135
-
136
-        // If source is not a directory stop processing
137
-        if (!\is_dir($src)) {
138
-            return false;
139
-        }
140
-
141
-        $success = true;
142
-
143
-        // Open the source directory to read in files
144
-        $iterator = new \DirectoryIterator($src);
145
-        foreach ($iterator as $fObj) {
146
-            if ($fObj->isFile()) {
147
-                $filename = $fObj->getPathname();
148
-                $fObj     = null; // clear this iterator object to close the file
149
-                if (!\unlink($filename)) {
150
-                    return false; // couldn't delete the file
151
-                }
152
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
153
-                // Try recursively on directory
154
-                self::rrmdir($fObj->getPathname());
155
-            }
156
-        }
157
-        $iterator = null;   // clear iterator Obj to close file/directory
158
-
159
-        return \rmdir($src); // remove the directory & return results
160
-    }
161
-
162
-    /**
163
-     * Recursively move files from one directory to another
164
-     *
165
-     * @param string $src  - Source of files being moved
166
-     * @param string $dest - Destination of files being moved
167
-     *
168
-     * @return bool true on success
169
-     */
170
-    public static function rmove($src, $dest)
171
-    {
172
-        // Only continue if user is a 'global' Admin
173
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
174
-            return false;
175
-        }
176
-
177
-        // If source is not a directory stop processing
178
-        if (!\is_dir($src)) {
179
-            return false;
180
-        }
181
-
182
-        // If the destination directory does not exist and could not be created stop processing
183
-        if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) {
184
-            return false;
185
-        }
186
-
187
-        // Open the source directory to read in files
188
-        $iterator = new \DirectoryIterator($src);
189
-        foreach ($iterator as $fObj) {
190
-            if ($fObj->isFile()) {
191
-                \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
192
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
193
-                // Try recursively on directory
194
-                self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
195
-                //                rmdir($fObj->getPath()); // now delete the directory
196
-            }
197
-        }
198
-        $iterator = null;   // clear iterator Obj to close file/directory
199
-
200
-        return \rmdir($src); // remove the directory & return results
201
-    }
202
-
203
-    /**
204
-     * Recursively copy directories and files from one directory to another
205
-     *
206
-     * @param string $src  - Source of files being moved
207
-     * @param string $dest - Destination of files being moved
208
-     *
209
-     * @return bool true on success
210
-     * @uses \Xmf\Module\Helper::isUserAdmin()
211
-     *
212
-     * @uses \Xmf\Module\Helper::getHelper()
213
-     */
214
-    public static function rcopy($src, $dest)
215
-    {
216
-        // Only continue if user is a 'global' Admin
217
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
218
-            return false;
219
-        }
220
-
221
-        // If source is not a directory stop processing
222
-        if (!\is_dir($src)) {
223
-            return false;
224
-        }
225
-
226
-        // If the destination directory does not exist and could not be created stop processing
227
-        if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) {
228
-            return false;
229
-        }
230
-
231
-        // Open the source directory to read in files
232
-        $iterator = new \DirectoryIterator($src);
233
-        foreach ($iterator as $fObj) {
234
-            if ($fObj->isFile()) {
235
-                \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
236
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
237
-                self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
238
-            }
239
-        }
240
-
241
-        return true;
242
-    }
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 $file
44
+	 * @param $folder
45
+	 */
46
+	public static function copyFile(string $file, string $folder): bool
47
+	{
48
+		return \copy($file, $folder);
49
+	}
50
+
51
+	/**
52
+	 * @param $src
53
+	 * @param $dst
54
+	 */
55
+	public static function recurseCopy($src, $dst): void
56
+	{
57
+		$dir = \opendir($src);
58
+		//        @mkdir($dst);
59
+		if (!@\mkdir($dst) && !\is_dir($dst)) {
60
+			throw new \RuntimeException('The directory ' . $dst . ' could not be created.');
61
+		}
62
+		while (false !== ($file = \readdir($dir))) {
63
+			if (('.' !== $file) && ('..' !== $file)) {
64
+				if (\is_dir($src . '/' . $file)) {
65
+					self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
66
+				} else {
67
+					\copy($src . '/' . $file, $dst . '/' . $file);
68
+				}
69
+			}
70
+		}
71
+		\closedir($dir);
72
+	}
73
+
74
+	/**
75
+	 * Remove files and (sub)directories
76
+	 *
77
+	 * @param string $src source directory to delete
78
+	 *
79
+	 * @return bool true on success
80
+	 * @uses \Xmf\Module\Helper::isUserAdmin()
81
+	 *
82
+	 * @uses \Xmf\Module\Helper::getHelper()
83
+	 */
84
+	public static function deleteDirectory($src)
85
+	{
86
+		// Only continue if user is a 'global' Admin
87
+		if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
88
+			return false;
89
+		}
90
+
91
+		$success = true;
92
+		// remove old files
93
+		$dirInfo = new \SplFileInfo($src);
94
+		// validate is a directory
95
+		if ($dirInfo->isDir()) {
96
+			$fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']);
97
+			foreach ($fileList as $k => $v) {
98
+				$fileInfo = new \SplFileInfo("{$src}/{$v}");
99
+				if ($fileInfo->isDir()) {
100
+					// recursively handle subdirectories
101
+					if (!$success = self::deleteDirectory($fileInfo->getRealPath())) {
102
+						break;
103
+					}
104
+				} elseif (!($success = \unlink($fileInfo->getRealPath()))) {
105
+					break;
106
+				}
107
+			}
108
+			// now delete this (sub)directory if all the files are gone
109
+			if ($success) {
110
+				$success = \rmdir($dirInfo->getRealPath());
111
+			}
112
+		} else {
113
+			// input is not a valid directory
114
+			$success = false;
115
+		}
116
+
117
+		return $success;
118
+	}
119
+
120
+	/**
121
+	 * Recursively remove directory
122
+	 *
123
+	 * @todo currently won't remove directories with hidden files, should it?
124
+	 *
125
+	 * @param string $src directory to remove (delete)
126
+	 *
127
+	 * @return bool true on success
128
+	 */
129
+	public static function rrmdir($src)
130
+	{
131
+		// Only continue if user is a 'global' Admin
132
+		if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
133
+			return false;
134
+		}
135
+
136
+		// If source is not a directory stop processing
137
+		if (!\is_dir($src)) {
138
+			return false;
139
+		}
140
+
141
+		$success = true;
142
+
143
+		// Open the source directory to read in files
144
+		$iterator = new \DirectoryIterator($src);
145
+		foreach ($iterator as $fObj) {
146
+			if ($fObj->isFile()) {
147
+				$filename = $fObj->getPathname();
148
+				$fObj     = null; // clear this iterator object to close the file
149
+				if (!\unlink($filename)) {
150
+					return false; // couldn't delete the file
151
+				}
152
+			} elseif (!$fObj->isDot() && $fObj->isDir()) {
153
+				// Try recursively on directory
154
+				self::rrmdir($fObj->getPathname());
155
+			}
156
+		}
157
+		$iterator = null;   // clear iterator Obj to close file/directory
158
+
159
+		return \rmdir($src); // remove the directory & return results
160
+	}
161
+
162
+	/**
163
+	 * Recursively move files from one directory to another
164
+	 *
165
+	 * @param string $src  - Source of files being moved
166
+	 * @param string $dest - Destination of files being moved
167
+	 *
168
+	 * @return bool true on success
169
+	 */
170
+	public static function rmove($src, $dest)
171
+	{
172
+		// Only continue if user is a 'global' Admin
173
+		if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
174
+			return false;
175
+		}
176
+
177
+		// If source is not a directory stop processing
178
+		if (!\is_dir($src)) {
179
+			return false;
180
+		}
181
+
182
+		// If the destination directory does not exist and could not be created stop processing
183
+		if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) {
184
+			return false;
185
+		}
186
+
187
+		// Open the source directory to read in files
188
+		$iterator = new \DirectoryIterator($src);
189
+		foreach ($iterator as $fObj) {
190
+			if ($fObj->isFile()) {
191
+				\rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
192
+			} elseif (!$fObj->isDot() && $fObj->isDir()) {
193
+				// Try recursively on directory
194
+				self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
195
+				//                rmdir($fObj->getPath()); // now delete the directory
196
+			}
197
+		}
198
+		$iterator = null;   // clear iterator Obj to close file/directory
199
+
200
+		return \rmdir($src); // remove the directory & return results
201
+	}
202
+
203
+	/**
204
+	 * Recursively copy directories and files from one directory to another
205
+	 *
206
+	 * @param string $src  - Source of files being moved
207
+	 * @param string $dest - Destination of files being moved
208
+	 *
209
+	 * @return bool true on success
210
+	 * @uses \Xmf\Module\Helper::isUserAdmin()
211
+	 *
212
+	 * @uses \Xmf\Module\Helper::getHelper()
213
+	 */
214
+	public static function rcopy($src, $dest)
215
+	{
216
+		// Only continue if user is a 'global' Admin
217
+		if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
218
+			return false;
219
+		}
220
+
221
+		// If source is not a directory stop processing
222
+		if (!\is_dir($src)) {
223
+			return false;
224
+		}
225
+
226
+		// If the destination directory does not exist and could not be created stop processing
227
+		if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) {
228
+			return false;
229
+		}
230
+
231
+		// Open the source directory to read in files
232
+		$iterator = new \DirectoryIterator($src);
233
+		foreach ($iterator as $fObj) {
234
+			if ($fObj->isFile()) {
235
+				\copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
236
+			} elseif (!$fObj->isDot() && $fObj->isDir()) {
237
+				self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
238
+			}
239
+		}
240
+
241
+		return true;
242
+	}
243 243
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
                     throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder));
33 33
                 }
34 34
 
35
-                file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
35
+                file_put_contents($folder.'/index.html', '<script>history.go(-1);</script>');
36 36
             }
37 37
         } catch (\Throwable $e) {
38 38
             echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
         $dir = \opendir($src);
58 58
         //        @mkdir($dst);
59 59
         if (!@\mkdir($dst) && !\is_dir($dst)) {
60
-            throw new \RuntimeException('The directory ' . $dst . ' could not be created.');
60
+            throw new \RuntimeException('The directory '.$dst.' could not be created.');
61 61
         }
62 62
         while (false !== ($file = \readdir($dir))) {
63 63
             if (('.' !== $file) && ('..' !== $file)) {
64
-                if (\is_dir($src . '/' . $file)) {
65
-                    self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
64
+                if (\is_dir($src.'/'.$file)) {
65
+                    self::recurseCopy($src.'/'.$file, $dst.'/'.$file);
66 66
                 } else {
67
-                    \copy($src . '/' . $file, $dst . '/' . $file);
67
+                    \copy($src.'/'.$file, $dst.'/'.$file);
68 68
                 }
69 69
             }
70 70
         }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                 self::rrmdir($fObj->getPathname());
155 155
             }
156 156
         }
157
-        $iterator = null;   // clear iterator Obj to close file/directory
157
+        $iterator = null; // clear iterator Obj to close file/directory
158 158
 
159 159
         return \rmdir($src); // remove the directory & return results
160 160
     }
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
         $iterator = new \DirectoryIterator($src);
189 189
         foreach ($iterator as $fObj) {
190 190
             if ($fObj->isFile()) {
191
-                \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
191
+                \rename($fObj->getPathname(), "{$dest}/".$fObj->getFilename());
192 192
             } elseif (!$fObj->isDot() && $fObj->isDir()) {
193 193
                 // Try recursively on directory
194
-                self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
194
+                self::rmove($fObj->getPathname(), "{$dest}/".$fObj->getFilename());
195 195
                 //                rmdir($fObj->getPath()); // now delete the directory
196 196
             }
197 197
         }
198
-        $iterator = null;   // clear iterator Obj to close file/directory
198
+        $iterator = null; // clear iterator Obj to close file/directory
199 199
 
200 200
         return \rmdir($src); // remove the directory & return results
201 201
     }
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
         $iterator = new \DirectoryIterator($src);
233 233
         foreach ($iterator as $fObj) {
234 234
             if ($fObj->isFile()) {
235
-                \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
235
+                \copy($fObj->getPathname(), "{$dest}/".$fObj->getFilename());
236 236
             } elseif (!$fObj->isDot() && $fObj->isDir()) {
237
-                self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
237
+                self::rcopy($fObj->getPathname(), "{$dest}/".$fObj->getFilename());
238 238
             }
239 239
         }
240 240
 
Please login to merge, or discard this patch.
class/Common/Configurator.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -24,41 +24,41 @@
 block discarded – undo
24 24
  */
25 25
 class Configurator
26 26
 {
27
-    public $name;
28
-    public $paths           = [];
29
-    public $uploadFolders   = [];
30
-    public $copyBlankFiles  = [];
31
-    public $copyTestFolders = [];
32
-    public $templateFolders = [];
33
-    public $oldFiles        = [];
34
-    public $oldFolders      = [];
35
-    public $renameTables    = [];
36
-    public $renameColumns   = [];
37
-    public $moduleStats     = [];
38
-    public $modCopyright;
39
-    public $icons;
27
+	public $name;
28
+	public $paths           = [];
29
+	public $uploadFolders   = [];
30
+	public $copyBlankFiles  = [];
31
+	public $copyTestFolders = [];
32
+	public $templateFolders = [];
33
+	public $oldFiles        = [];
34
+	public $oldFolders      = [];
35
+	public $renameTables    = [];
36
+	public $renameColumns   = [];
37
+	public $moduleStats     = [];
38
+	public $modCopyright;
39
+	public $icons;
40 40
 
41
-    /**
42
-     * Configurator constructor.
43
-     */
44
-    public function __construct()
45
-    {
46
-        $config = require \dirname(__DIR__, 2) . '/config/config.php';
41
+	/**
42
+	 * Configurator constructor.
43
+	 */
44
+	public function __construct()
45
+	{
46
+		$config = require \dirname(__DIR__, 2) . '/config/config.php';
47 47
 
48
-        $this->name            = $config->name;
49
-        $this->paths           = $config->paths;
50
-        $this->uploadFolders   = $config->uploadFolders;
51
-        $this->copyBlankFiles  = $config->copyBlankFiles;
52
-        $this->copyTestFolders = $config->copyTestFolders;
53
-        $this->templateFolders = $config->templateFolders;
54
-        $this->oldFiles        = $config->oldFiles;
55
-        $this->oldFolders      = $config->oldFolders;
56
-        $this->renameTables    = $config->renameTables;
57
-        $this->renameColumns   = $config->renameColumns;
58
-        $this->moduleStats     = $config->moduleStats;
59
-        $this->modCopyright    = $config->modCopyright;
48
+		$this->name            = $config->name;
49
+		$this->paths           = $config->paths;
50
+		$this->uploadFolders   = $config->uploadFolders;
51
+		$this->copyBlankFiles  = $config->copyBlankFiles;
52
+		$this->copyTestFolders = $config->copyTestFolders;
53
+		$this->templateFolders = $config->templateFolders;
54
+		$this->oldFiles        = $config->oldFiles;
55
+		$this->oldFolders      = $config->oldFolders;
56
+		$this->renameTables    = $config->renameTables;
57
+		$this->renameColumns   = $config->renameColumns;
58
+		$this->moduleStats     = $config->moduleStats;
59
+		$this->modCopyright    = $config->modCopyright;
60 60
 
61
-        $this->icons = require \dirname(__DIR__, 2) . '/config/icons.php';
62
-        $this->paths = require \dirname(__DIR__, 2) . '/config/paths.php';
63
-    }
61
+		$this->icons = require \dirname(__DIR__, 2) . '/config/icons.php';
62
+		$this->paths = require \dirname(__DIR__, 2) . '/config/paths.php';
63
+	}
64 64
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function __construct()
45 45
     {
46
-        $config = require \dirname(__DIR__, 2) . '/config/config.php';
46
+        $config = require \dirname(__DIR__, 2).'/config/config.php';
47 47
 
48 48
         $this->name            = $config->name;
49 49
         $this->paths           = $config->paths;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $this->moduleStats     = $config->moduleStats;
59 59
         $this->modCopyright    = $config->modCopyright;
60 60
 
61
-        $this->icons = require \dirname(__DIR__, 2) . '/config/icons.php';
62
-        $this->paths = require \dirname(__DIR__, 2) . '/config/paths.php';
61
+        $this->icons = require \dirname(__DIR__, 2).'/config/icons.php';
62
+        $this->paths = require \dirname(__DIR__, 2).'/config/paths.php';
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
class/Common/Blocksadmin.php 2 patches
Indentation   +556 added lines, -556 removed lines patch added patch discarded remove patch
@@ -26,72 +26,72 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class Blocksadmin
28 28
 {
29
-    /**
30
-     * @var \XoopsMySQLDatabase|null
31
-     */
32
-    public $db;
33
-    /**
34
-     * @var \Xmf\Module\Helper
35
-     */
36
-    public $helper;
37
-    /**
38
-     * @var string
39
-     */
40
-    public $moduleDirName;
41
-    /**
42
-     * @var string
43
-     */
44
-    public $moduleDirNameUpper;
45
-
46
-    /**
47
-     * Blocksadmin constructor.
48
-     */
49
-    public function __construct(?\XoopsDatabase $db, \Xmf\Module\Helper $helper)
50
-    {
51
-        if (null === $db) {
52
-            $db = \XoopsDatabaseFactory::getDatabaseConnection();
53
-        }
54
-        $this->db                 = $db;
55
-        $this->helper             = $helper;
56
-        $this->moduleDirName      = \basename(\dirname(__DIR__, 2));
57
-        $this->moduleDirNameUpper = \mb_strtoupper($this->moduleDirName);
58
-        \xoops_loadLanguage('admin', 'system');
59
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
60
-        \xoops_loadLanguage('admin/groups', 'system');
61
-        \xoops_loadLanguage('common', $this->moduleDirName);
62
-        \xoops_loadLanguage('blocksadmin', $this->moduleDirName);
63
-    }
64
-
65
-    /**
66
-     * @return void
67
-     */
68
-    public function listBlocks(): void
69
-    {
70
-        global $xoopsModule, $pathIcon16;
71
-        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
72
-        //        xoops_loadLanguage('admin', 'system');
73
-        //        xoops_loadLanguage('admin/blocksadmin', 'system');
74
-        //        xoops_loadLanguage('admin/groups', 'system');
75
-        //        xoops_loadLanguage('common', $moduleDirName);
76
-        //        xoops_loadLanguage('blocks', $moduleDirName);
77
-
78
-        /** @var \XoopsModuleHandler $moduleHandler */
79
-        $moduleHandler = \xoops_getHandler('module');
80
-        /** @var \XoopsMemberHandler $memberHandler */
81
-        $memberHandler = \xoops_getHandler('member');
82
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
83
-        $grouppermHandler = \xoops_getHandler('groupperm');
84
-        $groups           = $memberHandler->getGroups();
85
-        $criteria         = new \CriteriaCompo(new \Criteria('hasmain', '1'));
86
-        $criteria->add(new \Criteria('isactive', '1'));
87
-        $moduleList     = $moduleHandler->getList($criteria);
88
-        $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
89
-        $moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
90
-        \ksort($moduleList);
91
-        echo "<h4 style='text-align:left;'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
92
-        echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>";
93
-        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
94
-        echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
29
+	/**
30
+	 * @var \XoopsMySQLDatabase|null
31
+	 */
32
+	public $db;
33
+	/**
34
+	 * @var \Xmf\Module\Helper
35
+	 */
36
+	public $helper;
37
+	/**
38
+	 * @var string
39
+	 */
40
+	public $moduleDirName;
41
+	/**
42
+	 * @var string
43
+	 */
44
+	public $moduleDirNameUpper;
45
+
46
+	/**
47
+	 * Blocksadmin constructor.
48
+	 */
49
+	public function __construct(?\XoopsDatabase $db, \Xmf\Module\Helper $helper)
50
+	{
51
+		if (null === $db) {
52
+			$db = \XoopsDatabaseFactory::getDatabaseConnection();
53
+		}
54
+		$this->db                 = $db;
55
+		$this->helper             = $helper;
56
+		$this->moduleDirName      = \basename(\dirname(__DIR__, 2));
57
+		$this->moduleDirNameUpper = \mb_strtoupper($this->moduleDirName);
58
+		\xoops_loadLanguage('admin', 'system');
59
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
60
+		\xoops_loadLanguage('admin/groups', 'system');
61
+		\xoops_loadLanguage('common', $this->moduleDirName);
62
+		\xoops_loadLanguage('blocksadmin', $this->moduleDirName);
63
+	}
64
+
65
+	/**
66
+	 * @return void
67
+	 */
68
+	public function listBlocks(): void
69
+	{
70
+		global $xoopsModule, $pathIcon16;
71
+		require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
72
+		//        xoops_loadLanguage('admin', 'system');
73
+		//        xoops_loadLanguage('admin/blocksadmin', 'system');
74
+		//        xoops_loadLanguage('admin/groups', 'system');
75
+		//        xoops_loadLanguage('common', $moduleDirName);
76
+		//        xoops_loadLanguage('blocks', $moduleDirName);
77
+
78
+		/** @var \XoopsModuleHandler $moduleHandler */
79
+		$moduleHandler = \xoops_getHandler('module');
80
+		/** @var \XoopsMemberHandler $memberHandler */
81
+		$memberHandler = \xoops_getHandler('member');
82
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
83
+		$grouppermHandler = \xoops_getHandler('groupperm');
84
+		$groups           = $memberHandler->getGroups();
85
+		$criteria         = new \CriteriaCompo(new \Criteria('hasmain', '1'));
86
+		$criteria->add(new \Criteria('isactive', '1'));
87
+		$moduleList     = $moduleHandler->getList($criteria);
88
+		$moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
89
+		$moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
90
+		\ksort($moduleList);
91
+		echo "<h4 style='text-align:left;'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
92
+		echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>";
93
+		echo $GLOBALS['xoopsSecurity']->getTokenHTML();
94
+		echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
95 95
         <tr valign='middle'><th align='center'>" . \_AM_SYSTEM_BLOCKS_TITLE . "</th><th align='center' nowrap='nowrap'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'SIDE') . '<br>' . _LEFT . '-' . _CENTER . '-' . _RIGHT . "</th>
96 96
         <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT') . "</th>
97 97
         <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE') . "</th><th align='center'>" . \_AM_SYSTEM_BLOCKS_VISIBLEIN . "</th>
@@ -99,82 +99,82 @@  discard block
 block discarded – undo
99 99
         <th align='center'>" . \_AM_SYSTEM_BLOCKS_BCACHETIME . "</th>
100 100
         <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'ACTION') . '</th>
101 101
         </tr>';
102
-        $blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
103
-        $blockCount = \count($blockArray);
104
-        $class      = 'even';
105
-        $cachetimes = [
106
-            0       => _NOCACHE,
107
-            30      => \sprintf(_SECONDS, 30),
108
-            60      => _MINUTE,
109
-            300     => \sprintf(_MINUTES, 5),
110
-            1800    => \sprintf(_MINUTES, 30),
111
-            3600    => _HOUR,
112
-            18000   => \sprintf(_HOURS, 5),
113
-            86400   => _DAY,
114
-            259200  => \sprintf(_DAYS, 3),
115
-            604800  => _WEEK,
116
-            2592000 => _MONTH,
117
-        ];
118
-        foreach ($blockArray as $i) {
119
-            $groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
120
-            $sql               = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
121
-            $result            = $this->db->query($sql);
122
-            $modules           = [];
123
-            if (!$result instanceof \mysqli_result) {
124
-                \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR);
125
-            }
126
-            while (false !== ($row = $this->db->fetchArray($result))) {
127
-                $modules[] = (int)$row['module_id'];
128
-            }
129
-
130
-            $cachetimeOptions = '';
131
-            foreach ($cachetimes as $cachetime => $cachetimeName) {
132
-                if ($i->getVar('bcachetime') == $cachetime) {
133
-                    $cachetimeOptions .= "<option value='$cachetime' selected='selected'>$cachetimeName</option>\n";
134
-                } else {
135
-                    $cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n";
136
-                }
137
-            }
138
-
139
-            $ssel7 = '';
140
-            $ssel6 = $ssel7;
141
-            $ssel5 = $ssel6;
142
-            $ssel4 = $ssel5;
143
-            $ssel3 = $ssel4;
144
-            $ssel2 = $ssel3;
145
-            $ssel1 = $ssel2;
146
-            $ssel0 = $ssel1;
147
-            $sel1  = $ssel0;
148
-            $sel0  = $sel1;
149
-            if (1 === $i->getVar('visible')) {
150
-                $sel1 = ' checked';
151
-            } else {
152
-                $sel0 = ' checked';
153
-            }
154
-            if (\XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) {
155
-                $ssel0 = ' checked';
156
-            } elseif (\XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) {
157
-                $ssel1 = ' checked';
158
-            } elseif (\XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) {
159
-                $ssel2 = ' checked';
160
-            } elseif (\XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) {
161
-                $ssel4 = ' checked';
162
-            } elseif (\XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) {
163
-                $ssel3 = ' checked';
164
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) {
165
-                $ssel5 = ' checked';
166
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) {
167
-                $ssel6 = ' checked';
168
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) {
169
-                $ssel7 = ' checked';
170
-            }
171
-            if ('' === $i->getVar('title')) {
172
-                $title = '&nbsp;';
173
-            } else {
174
-                $title = $i->getVar('title');
175
-            }
176
-            $name = $i->getVar('name');
177
-            echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" . $i->getVar('bid') . "]' value='" . $title . "'></td>
102
+		$blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
103
+		$blockCount = \count($blockArray);
104
+		$class      = 'even';
105
+		$cachetimes = [
106
+			0       => _NOCACHE,
107
+			30      => \sprintf(_SECONDS, 30),
108
+			60      => _MINUTE,
109
+			300     => \sprintf(_MINUTES, 5),
110
+			1800    => \sprintf(_MINUTES, 30),
111
+			3600    => _HOUR,
112
+			18000   => \sprintf(_HOURS, 5),
113
+			86400   => _DAY,
114
+			259200  => \sprintf(_DAYS, 3),
115
+			604800  => _WEEK,
116
+			2592000 => _MONTH,
117
+		];
118
+		foreach ($blockArray as $i) {
119
+			$groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
120
+			$sql               = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
121
+			$result            = $this->db->query($sql);
122
+			$modules           = [];
123
+			if (!$result instanceof \mysqli_result) {
124
+				\trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR);
125
+			}
126
+			while (false !== ($row = $this->db->fetchArray($result))) {
127
+				$modules[] = (int)$row['module_id'];
128
+			}
129
+
130
+			$cachetimeOptions = '';
131
+			foreach ($cachetimes as $cachetime => $cachetimeName) {
132
+				if ($i->getVar('bcachetime') == $cachetime) {
133
+					$cachetimeOptions .= "<option value='$cachetime' selected='selected'>$cachetimeName</option>\n";
134
+				} else {
135
+					$cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n";
136
+				}
137
+			}
138
+
139
+			$ssel7 = '';
140
+			$ssel6 = $ssel7;
141
+			$ssel5 = $ssel6;
142
+			$ssel4 = $ssel5;
143
+			$ssel3 = $ssel4;
144
+			$ssel2 = $ssel3;
145
+			$ssel1 = $ssel2;
146
+			$ssel0 = $ssel1;
147
+			$sel1  = $ssel0;
148
+			$sel0  = $sel1;
149
+			if (1 === $i->getVar('visible')) {
150
+				$sel1 = ' checked';
151
+			} else {
152
+				$sel0 = ' checked';
153
+			}
154
+			if (\XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) {
155
+				$ssel0 = ' checked';
156
+			} elseif (\XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) {
157
+				$ssel1 = ' checked';
158
+			} elseif (\XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) {
159
+				$ssel2 = ' checked';
160
+			} elseif (\XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) {
161
+				$ssel4 = ' checked';
162
+			} elseif (\XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) {
163
+				$ssel3 = ' checked';
164
+			} elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) {
165
+				$ssel5 = ' checked';
166
+			} elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) {
167
+				$ssel6 = ' checked';
168
+			} elseif (\XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) {
169
+				$ssel7 = ' checked';
170
+			}
171
+			if ('' === $i->getVar('title')) {
172
+				$title = '&nbsp;';
173
+			} else {
174
+				$title = $i->getVar('title');
175
+			}
176
+			$name = $i->getVar('name');
177
+			echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" . $i->getVar('bid') . "]' value='" . $title . "'></td>
178 178
             <td class='$class' align='center' nowrap='nowrap'><div align='center' >
179 179
                     <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_LEFT . "'$ssel2>
180 180
                     <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_CENTER . "'$ssel3>
@@ -193,39 +193,39 @@  discard block
 block discarded – undo
193 193
                 <td class='$class' align='center'><input type='text' name='weight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "' size='5' maxlength='5'></td>
194 194
                 <td class='$class' align='center' nowrap><input type='radio' name='visible[" . $i->getVar('bid') . "]' value='1'$sel1>" . _YES . "&nbsp;<input type='radio' name='visible[" . $i->getVar('bid') . "]' value='0'$sel0>" . _NO . '</td>';
195 195
 
196
-            echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
197
-            foreach ($moduleList as $k => $v) {
198
-                echo "<option value='$k'" . (\in_array($k, $modules) ? " selected='selected'" : '') . ">$v</option>";
199
-            }
200
-            echo '</select></td>';
196
+			echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
197
+			foreach ($moduleList as $k => $v) {
198
+				echo "<option value='$k'" . (\in_array($k, $modules) ? " selected='selected'" : '') . ">$v</option>";
199
+			}
200
+			echo '</select></td>';
201 201
 
202
-            echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
203
-            foreach ($groups as $grp) {
204
-                echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
205
-            }
206
-            echo '</select></td>';
202
+			echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
203
+			foreach ($groups as $grp) {
204
+				echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
205
+			}
206
+			echo '</select></td>';
207 207
 
208
-            // Cache lifetime
209
-            echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select>
208
+			// Cache lifetime
209
+			echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select>
210 210
                                     </td>';
211 211
 
212
-            // Actions
212
+			// Actions
213 213
 
214
-            echo "<td class='$class' align='center'>
214
+			echo "<td class='$class' align='center'>
215 215
                 <a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'></a> 
216 216
                 <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'></a>";
217
-            //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
218
-            //                echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
219
-            //                     </a>";
220
-            //            }
221
-
222
-            //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
223
-            if (!\in_array($i->getVar('block_type'), ['M', 'S'])) {
224
-                echo "&nbsp;
217
+			//            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
218
+			//                echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
219
+			//                     </a>";
220
+			//            }
221
+
222
+			//            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
223
+			if (!\in_array($i->getVar('block_type'), ['M', 'S'])) {
224
+				echo "&nbsp;
225 225
                 <a href='blocksadmin.php?op=delete&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
226 226
                      </a>";
227
-            }
228
-            echo "
227
+			}
228
+			echo "
229 229
             <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'>
230 230
             <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'>
231 231
             <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'>
@@ -235,394 +235,394 @@  discard block
 block discarded – undo
235 235
             <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'>
236 236
             </td></tr>
237 237
             ";
238
-            $class = ('even' === $class) ? 'odd' : 'even';
239
-        }
240
-        echo "<tr><td class='foot' align='center' colspan='8'> <input type='hidden' name='op' value='order'>" . $GLOBALS['xoopsSecurity']->getTokenHTML() . "<input type='submit' name='submit' value='" . _SUBMIT . "'></td></tr></table></form><br><br>";
241
-    }
242
-
243
-    public function deleteBlock(int $bid): void
244
-    {
245
-        //        \xoops_cp_header();
246
-
247
-        \xoops_loadLanguage('admin', 'system');
248
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
249
-        \xoops_loadLanguage('admin/groups', 'system');
250
-
251
-        $myblock = new \XoopsBlock($bid);
252
-
253
-        $sql = \sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), $bid);
254
-        $this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
255
-        $sql = \sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
256
-        $this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
257
-
258
-        $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
259
-    }
260
-
261
-    public function cloneBlock(int $bid): void
262
-    {
263
-        //require __DIR__ . '/admin_header.php';
264
-        //        \xoops_cp_header();
265
-
266
-        \xoops_loadLanguage('admin', 'system');
267
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
268
-        \xoops_loadLanguage('admin/groups', 'system');
269
-
270
-        $myblock = new \XoopsBlock($bid);
271
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
272
-        $result  = $this->db->query($sql);
273
-        $modules = [];
274
-        if ($result instanceof \mysqli_result) {
275
-            while (false !== ($row = $this->db->fetchArray($result))) {
276
-                $modules[] = (int)$row['module_id'];
277
-            }
278
-        }
279
-        $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
280
-        $block    = [
281
-            'title'      => $myblock->getVar('title') . ' Clone',
282
-            'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
283
-            'name'       => $myblock->getVar('name'),
284
-            'side'       => $myblock->getVar('side'),
285
-            'weight'     => $myblock->getVar('weight'),
286
-            'visible'    => $myblock->getVar('visible'),
287
-            'content'    => $myblock->getVar('content', 'N'),
288
-            'modules'    => $modules,
289
-            'is_custom'  => $isCustom,
290
-            'ctype'      => $myblock->getVar('c_type'),
291
-            'bcachetime' => $myblock->getVar('bcachetime'),
292
-            'op'         => 'clone_ok',
293
-            'bid'        => $myblock->getVar('bid'),
294
-            'edit_form'  => $myblock->getOptions(),
295
-            'template'   => $myblock->getVar('template'),
296
-            'options'    => $myblock->getVar('options'),
297
-        ];
298
-        echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
299
-        //        $form = new Blockform();
300
-        //        $form->render();
301
-
302
-        echo $this->render($block);
303
-        //        xoops_cp_footer();
304
-        //        require_once __DIR__ . '/admin_footer.php';
305
-        //        exit();
306
-    }
307
-
308
-    public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
309
-    {
310
-        \xoops_loadLanguage('admin', 'system');
311
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
312
-        \xoops_loadLanguage('admin/groups', 'system');
313
-
314
-        $block = new \XoopsBlock($bid);
315
-        $clone = $block->xoopsClone();
316
-        if (empty($bmodule)) {
317
-            //            \xoops_cp_header();
318
-            \xoops_error(\sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
319
-            \xoops_cp_footer();
320
-            exit();
321
-        }
322
-        $clone->setVar('side', $bside);
323
-        $clone->setVar('weight', $bweight);
324
-        $clone->setVar('visible', $bvisible);
325
-        //$clone->setVar('content', $_POST['bcontent']);
326
-        $clone->setVar('title', Request::getString('btitle', '', 'POST'));
327
-        $clone->setVar('bcachetime', $bcachetime);
328
-        if (\is_array($options) && (\count($options) > 0)) {
329
-            $options = \implode('|', $options);
330
-            $clone->setVar('options', $options);
331
-        }
332
-        $clone->setVar('bid', 0);
333
-        if (\in_array($block->getVar('block_type'), ['C', 'E'])) {
334
-            $clone->setVar('block_type', 'E');
335
-        } else {
336
-            $clone->setVar('block_type', 'D');
337
-        }
338
-        //        $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105
339
-        if ($clone->store()) {
340
-            $newid = $clone->id();  //get the id of the cloned block
341
-        }
342
-        if (!$newid) {
343
-            //            \xoops_cp_header();
344
-            $clone->getHtmlErrors();
345
-            \xoops_cp_footer();
346
-            exit();
347
-        }
348
-        if ('' !== $clone->getVar('template')) {
349
-            /** @var \XoopsTplfileHandler $tplfileHandler */
350
-            $tplfileHandler = \xoops_getHandler('tplfile');
351
-            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string)$bid);
352
-            if (\count($btemplate) > 0) {
353
-                $tplclone = $btemplate[0]->xoopsClone();
354
-                $tplclone->setVar('tpl_id', 0);
355
-                $tplclone->setVar('tpl_refid', $newid);
356
-                $tplfileHandler->insert($tplclone);
357
-            }
358
-        }
359
-
360
-        foreach ($bmodule as $bmid) {
361
-            $sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
362
-            $this->db->query($sql);
363
-        }
364
-        //$groups = &$GLOBALS['xoopsUser']->getGroups();
365
-        foreach ($groups as $iValue) {
366
-            $sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
367
-            $this->db->query($sql);
368
-        }
369
-        $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
370
-    }
371
-
372
-    public function setOrder(string $bid, string $title, string $weight, string $visible, string $side, string $bcachetime, ?array $bmodule = null): void
373
-    {
374
-        $myblock = new \XoopsBlock($bid);
375
-        $myblock->setVar('title', $title);
376
-        $myblock->setVar('weight', $weight);
377
-        $myblock->setVar('visible', $visible);
378
-        $myblock->setVar('side', $side);
379
-        $myblock->setVar('bcachetime', $bcachetime);
380
-        $myblock->store();
381
-        //        /** @var \XoopsBlockHandler $blockHandler */
382
-        //        $blockHandler = \xoops_getHandler('block');
383
-        //        return $blockHandler->insert($myblock);
384
-    }
385
-
386
-    public function editBlock(int $bid): void
387
-    {
388
-        //        require_once \dirname(__DIR__,2) . '/admin/admin_header.php';
389
-        //        \xoops_cp_header();
390
-        \xoops_loadLanguage('admin', 'system');
391
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
392
-        \xoops_loadLanguage('admin/groups', 'system');
393
-        //        mpu_adm_menu();
394
-        $myblock = new \XoopsBlock($bid);
395
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
396
-        $result  = $this->db->query($sql);
397
-        $modules = [];
398
-        if ($result instanceof \mysqli_result) {
399
-            while (false !== ($row = $this->db->fetchArray($result))) {
400
-                $modules[] = (int)$row['module_id'];
401
-            }
402
-        }
403
-        $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
404
-        $block    = [
405
-            'title'      => $myblock->getVar('title'),
406
-            'form_title' => \_AM_SYSTEM_BLOCKS_EDITBLOCK,
407
-            //        'name'       => $myblock->getVar('name'),
408
-            'side'       => $myblock->getVar('side'),
409
-            'weight'     => $myblock->getVar('weight'),
410
-            'visible'    => $myblock->getVar('visible'),
411
-            'content'    => $myblock->getVar('content', 'N'),
412
-            'modules'    => $modules,
413
-            'is_custom'  => $isCustom,
414
-            'ctype'      => $myblock->getVar('c_type'),
415
-            'bcachetime' => $myblock->getVar('bcachetime'),
416
-            'op'         => 'edit_ok',
417
-            'bid'        => $myblock->getVar('bid'),
418
-            'edit_form'  => $myblock->getOptions(),
419
-            'template'   => $myblock->getVar('template'),
420
-            'options'    => $myblock->getVar('options'),
421
-        ];
422
-        echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
423
-
424
-        echo $this->render($block);
425
-    }
426
-
427
-    public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
428
-    {
429
-        $myblock = new \XoopsBlock($bid);
430
-        $myblock->setVar('title', $btitle);
431
-        $myblock->setVar('weight', $bweight);
432
-        $myblock->setVar('visible', $bvisible);
433
-        $myblock->setVar('side', $bside);
434
-        $myblock->setVar('bcachetime', $bcachetime);
435
-        //update block options
436
-        if (isset($options)) {
437
-            $optionsCount = \count($options);
438
-            if ($optionsCount > 0) {
439
-                //Convert array values to comma-separated
440
-                foreach ($options as $i => $iValue) {
441
-                    if (\is_array($iValue)) {
442
-                        $options[$i] = \implode(',', $iValue);
443
-                    }
444
-                }
445
-                $options = \implode('|', $options);
446
-                $myblock->setVar('options', $options);
447
-            }
448
-        }
449
-        $myblock->store();
450
-        //        /** @var \XoopsBlockHandler $blockHandler */
451
-        //        $blockHandler = \xoops_getHandler('block');
452
-        //        $blockHandler->insert($myblock);
453
-
454
-        if (!empty($bmodule) && \count($bmodule) > 0) {
455
-            $sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
456
-            $this->db->query($sql);
457
-            if (\in_array(0, $bmodule)) {
458
-                $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, 0);
459
-                $this->db->query($sql);
460
-            } else {
461
-                foreach ($bmodule as $bmid) {
462
-                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int)$bmid);
463
-                    $this->db->query($sql);
464
-                }
465
-            }
466
-        }
467
-        $sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid);
468
-        $this->db->query($sql);
469
-        if (!empty($groups)) {
470
-            foreach ($groups as $grp) {
471
-                $sql = \sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid);
472
-                $this->db->query($sql);
473
-            }
474
-        }
475
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
476
-    }
477
-
478
-    public function orderBlock(
479
-        array $bid, array $oldtitle, array $oldside, array $oldweight, array $oldvisible, array $oldgroups, array $oldbcachetime, array $oldbmodule, array $title, array $weight, array $visible, array $side, array $bcachetime, array $groups, array $bmodule
480
-    ): void {
481
-        if (!$GLOBALS['xoopsSecurity']->check()) {
482
-            \redirect_header($_SERVER['SCRIPT_NAME'], 3, \implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
483
-        }
484
-        foreach (\array_keys($bid) as $i) {
485
-            if ($oldtitle[$i] !== $title[$i]
486
-                || $oldweight[$i] !== $weight[$i]
487
-                || $oldvisible[$i] !== $visible[$i]
488
-                || $oldside[$i] !== $side[$i]
489
-                || $oldbcachetime[$i] !== $bcachetime[$i]
490
-                || $oldbmodule[$i] !== $bmodule[$i]) {
491
-                $this->setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
492
-            }
493
-            if (!empty($bmodule[$i]) && \count($bmodule[$i]) > 0) {
494
-                $sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid[$i]);
495
-                $this->db->query($sql);
496
-                if (\in_array(0, $bmodule[$i], true)) {
497
-                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], 0);
498
-                    $this->db->query($sql);
499
-                } else {
500
-                    foreach ($bmodule[$i] as $bmid) {
501
-                        $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid);
502
-                        $this->db->query($sql);
503
-                    }
504
-                }
505
-            }
506
-            $sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid[$i]);
507
-            $this->db->query($sql);
508
-            if (!empty($groups[$i])) {
509
-                foreach ($groups[$i] as $grp) {
510
-                    $sql = \sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid[$i]);
511
-                    $this->db->query($sql);
512
-                }
513
-            }
514
-        }
515
-
516
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
517
-    }
518
-
519
-    public function render(?array $block = null)
520
-    {
521
-        \xoops_load('XoopsFormLoader');
522
-        \xoops_loadLanguage('common', $this->moduleDirNameUpper);
523
-
524
-        $form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true);
525
-        if (isset($block['name'])) {
526
-            $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_NAME, $block['name']));
527
-        }
528
-        $sideSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']);
529
-        $sideSelect->addOptionArray([
530
-                                        0 => \_AM_SYSTEM_BLOCKS_SBLEFT,
531
-                                        1 => \_AM_SYSTEM_BLOCKS_SBRIGHT,
532
-                                        3 => \_AM_SYSTEM_BLOCKS_CBLEFT,
533
-                                        4 => \_AM_SYSTEM_BLOCKS_CBRIGHT,
534
-                                        5 => \_AM_SYSTEM_BLOCKS_CBCENTER,
535
-                                        7 => \_AM_SYSTEM_BLOCKS_CBBOTTOMLEFT,
536
-                                        8 => \_AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT,
537
-                                        9 => \_AM_SYSTEM_BLOCKS_CBBOTTOM,
538
-                                    ]);
539
-        $form->addElement($sideSelect);
540
-        $form->addElement(new \XoopsFormText(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
541
-        $form->addElement(new \XoopsFormRadioYN(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
542
-        $modSelect = new \XoopsFormSelect(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
543
-        /** @var \XoopsModuleHandler $moduleHandler */
544
-        $moduleHandler = \xoops_getHandler('module');
545
-        $criteria      = new \CriteriaCompo(new \Criteria('hasmain', '1'));
546
-        $criteria->add(new \Criteria('isactive', '1'));
547
-        $moduleList     = $moduleHandler->getList($criteria);
548
-        $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
549
-        $moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
550
-        \ksort($moduleList);
551
-        $modSelect->addOptionArray($moduleList);
552
-        $form->addElement($modSelect);
553
-        $form->addElement(new \XoopsFormText(\_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false);
554
-        if ($block['is_custom']) {
555
-            $textarea = new \XoopsFormDhtmlTextArea(\_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);
556
-            $textarea->setDescription('<span style="font-size:x-small;font-weight:bold;">' . \_AM_SYSTEM_BLOCKS_USEFULTAGS . '</span><br><span style="font-size:x-small;font-weight:normal;">' . \sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . '</span>');
557
-            $form->addElement($textarea, true);
558
-            $ctypeSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
559
-            $ctypeSelect->addOptionArray([
560
-                                             'H' => \_AM_SYSTEM_BLOCKS_HTML,
561
-                                             'P' => \_AM_SYSTEM_BLOCKS_PHP,
562
-                                             'S' => \_AM_SYSTEM_BLOCKS_AFWSMILE,
563
-                                             'T' => \_AM_SYSTEM_BLOCKS_AFNOSMILE,
564
-                                         ]);
565
-            $form->addElement($ctypeSelect);
566
-        } else {
567
-            if ('' !== $block['template']) {
568
-                /** @var \XoopsTplfileHandler $tplfileHandler */
569
-                $tplfileHandler = \xoops_getHandler('tplfile');
570
-                $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
571
-                if (\count($btemplate) > 0) {
572
-                    $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate[0]->getVar('tpl_id') . '">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
573
-                } else {
574
-                    $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);
575
-                    if (\count($btemplate2) > 0) {
576
-                        $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" target="_blank">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
577
-                    }
578
-                }
579
-            }
580
-            if (false !== $block['edit_form']) {
581
-                $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form']));
582
-            }
583
-        }
584
-        $cache_select = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']);
585
-        $cache_select->addOptionArray([
586
-                                          0       => _NOCACHE,
587
-                                          30      => \sprintf(_SECONDS, 30),
588
-                                          60      => _MINUTE,
589
-                                          300     => \sprintf(_MINUTES, 5),
590
-                                          1800    => \sprintf(_MINUTES, 30),
591
-                                          3600    => _HOUR,
592
-                                          18000   => \sprintf(_HOURS, 5),
593
-                                          86400   => _DAY,
594
-                                          259200  => \sprintf(_DAYS, 3),
595
-                                          604800  => _WEEK,
596
-                                          2592000 => _MONTH,
597
-                                      ]);
598
-        $form->addElement($cache_select);
599
-
600
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
601
-        $grouppermHandler = \xoops_getHandler('groupperm');
602
-        $groups           = $grouppermHandler->getGroupIds('block_read', $block['bid']);
603
-
604
-        $form->addElement(new \XoopsFormSelectGroup(\_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true));
605
-
606
-        if (isset($block['bid'])) {
607
-            $form->addElement(new \XoopsFormHidden('bid', $block['bid']));
608
-        }
609
-        $form->addElement(new \XoopsFormHidden('op', $block['op']));
610
-        $form->addElement(new \XoopsFormHidden('fct', 'blocksadmin'));
611
-        $buttonTray = new \XoopsFormElementTray('', '&nbsp;');
612
-        if ($block['is_custom']) {
613
-            $buttonTray->addElement(new \XoopsFormButton('', 'previewblock', _PREVIEW, 'submit'));
614
-        }
615
-
616
-        //Submit buttons
617
-        $buttonTray   = new \XoopsFormElementTray('', '');
618
-        $submitButton = new \XoopsFormButton('', 'submitblock', _SUBMIT, 'submit');
619
-        $buttonTray->addElement($submitButton);
620
-
621
-        $cancelButton = new \XoopsFormButton('', '', _CANCEL, 'button');
622
-        $cancelButton->setExtra('onclick="history.go(-1)"');
623
-        $buttonTray->addElement($cancelButton);
624
-
625
-        $form->addElement($buttonTray);
626
-        $form->display();
627
-    }
238
+			$class = ('even' === $class) ? 'odd' : 'even';
239
+		}
240
+		echo "<tr><td class='foot' align='center' colspan='8'> <input type='hidden' name='op' value='order'>" . $GLOBALS['xoopsSecurity']->getTokenHTML() . "<input type='submit' name='submit' value='" . _SUBMIT . "'></td></tr></table></form><br><br>";
241
+	}
242
+
243
+	public function deleteBlock(int $bid): void
244
+	{
245
+		//        \xoops_cp_header();
246
+
247
+		\xoops_loadLanguage('admin', 'system');
248
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
249
+		\xoops_loadLanguage('admin/groups', 'system');
250
+
251
+		$myblock = new \XoopsBlock($bid);
252
+
253
+		$sql = \sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), $bid);
254
+		$this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
255
+		$sql = \sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
256
+		$this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
257
+
258
+		$this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
259
+	}
260
+
261
+	public function cloneBlock(int $bid): void
262
+	{
263
+		//require __DIR__ . '/admin_header.php';
264
+		//        \xoops_cp_header();
265
+
266
+		\xoops_loadLanguage('admin', 'system');
267
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
268
+		\xoops_loadLanguage('admin/groups', 'system');
269
+
270
+		$myblock = new \XoopsBlock($bid);
271
+		$sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
272
+		$result  = $this->db->query($sql);
273
+		$modules = [];
274
+		if ($result instanceof \mysqli_result) {
275
+			while (false !== ($row = $this->db->fetchArray($result))) {
276
+				$modules[] = (int)$row['module_id'];
277
+			}
278
+		}
279
+		$isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
280
+		$block    = [
281
+			'title'      => $myblock->getVar('title') . ' Clone',
282
+			'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
283
+			'name'       => $myblock->getVar('name'),
284
+			'side'       => $myblock->getVar('side'),
285
+			'weight'     => $myblock->getVar('weight'),
286
+			'visible'    => $myblock->getVar('visible'),
287
+			'content'    => $myblock->getVar('content', 'N'),
288
+			'modules'    => $modules,
289
+			'is_custom'  => $isCustom,
290
+			'ctype'      => $myblock->getVar('c_type'),
291
+			'bcachetime' => $myblock->getVar('bcachetime'),
292
+			'op'         => 'clone_ok',
293
+			'bid'        => $myblock->getVar('bid'),
294
+			'edit_form'  => $myblock->getOptions(),
295
+			'template'   => $myblock->getVar('template'),
296
+			'options'    => $myblock->getVar('options'),
297
+		];
298
+		echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
299
+		//        $form = new Blockform();
300
+		//        $form->render();
301
+
302
+		echo $this->render($block);
303
+		//        xoops_cp_footer();
304
+		//        require_once __DIR__ . '/admin_footer.php';
305
+		//        exit();
306
+	}
307
+
308
+	public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
309
+	{
310
+		\xoops_loadLanguage('admin', 'system');
311
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
312
+		\xoops_loadLanguage('admin/groups', 'system');
313
+
314
+		$block = new \XoopsBlock($bid);
315
+		$clone = $block->xoopsClone();
316
+		if (empty($bmodule)) {
317
+			//            \xoops_cp_header();
318
+			\xoops_error(\sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
319
+			\xoops_cp_footer();
320
+			exit();
321
+		}
322
+		$clone->setVar('side', $bside);
323
+		$clone->setVar('weight', $bweight);
324
+		$clone->setVar('visible', $bvisible);
325
+		//$clone->setVar('content', $_POST['bcontent']);
326
+		$clone->setVar('title', Request::getString('btitle', '', 'POST'));
327
+		$clone->setVar('bcachetime', $bcachetime);
328
+		if (\is_array($options) && (\count($options) > 0)) {
329
+			$options = \implode('|', $options);
330
+			$clone->setVar('options', $options);
331
+		}
332
+		$clone->setVar('bid', 0);
333
+		if (\in_array($block->getVar('block_type'), ['C', 'E'])) {
334
+			$clone->setVar('block_type', 'E');
335
+		} else {
336
+			$clone->setVar('block_type', 'D');
337
+		}
338
+		//        $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105
339
+		if ($clone->store()) {
340
+			$newid = $clone->id();  //get the id of the cloned block
341
+		}
342
+		if (!$newid) {
343
+			//            \xoops_cp_header();
344
+			$clone->getHtmlErrors();
345
+			\xoops_cp_footer();
346
+			exit();
347
+		}
348
+		if ('' !== $clone->getVar('template')) {
349
+			/** @var \XoopsTplfileHandler $tplfileHandler */
350
+			$tplfileHandler = \xoops_getHandler('tplfile');
351
+			$btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string)$bid);
352
+			if (\count($btemplate) > 0) {
353
+				$tplclone = $btemplate[0]->xoopsClone();
354
+				$tplclone->setVar('tpl_id', 0);
355
+				$tplclone->setVar('tpl_refid', $newid);
356
+				$tplfileHandler->insert($tplclone);
357
+			}
358
+		}
359
+
360
+		foreach ($bmodule as $bmid) {
361
+			$sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
362
+			$this->db->query($sql);
363
+		}
364
+		//$groups = &$GLOBALS['xoopsUser']->getGroups();
365
+		foreach ($groups as $iValue) {
366
+			$sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
367
+			$this->db->query($sql);
368
+		}
369
+		$this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
370
+	}
371
+
372
+	public function setOrder(string $bid, string $title, string $weight, string $visible, string $side, string $bcachetime, ?array $bmodule = null): void
373
+	{
374
+		$myblock = new \XoopsBlock($bid);
375
+		$myblock->setVar('title', $title);
376
+		$myblock->setVar('weight', $weight);
377
+		$myblock->setVar('visible', $visible);
378
+		$myblock->setVar('side', $side);
379
+		$myblock->setVar('bcachetime', $bcachetime);
380
+		$myblock->store();
381
+		//        /** @var \XoopsBlockHandler $blockHandler */
382
+		//        $blockHandler = \xoops_getHandler('block');
383
+		//        return $blockHandler->insert($myblock);
384
+	}
385
+
386
+	public function editBlock(int $bid): void
387
+	{
388
+		//        require_once \dirname(__DIR__,2) . '/admin/admin_header.php';
389
+		//        \xoops_cp_header();
390
+		\xoops_loadLanguage('admin', 'system');
391
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
392
+		\xoops_loadLanguage('admin/groups', 'system');
393
+		//        mpu_adm_menu();
394
+		$myblock = new \XoopsBlock($bid);
395
+		$sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
396
+		$result  = $this->db->query($sql);
397
+		$modules = [];
398
+		if ($result instanceof \mysqli_result) {
399
+			while (false !== ($row = $this->db->fetchArray($result))) {
400
+				$modules[] = (int)$row['module_id'];
401
+			}
402
+		}
403
+		$isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
404
+		$block    = [
405
+			'title'      => $myblock->getVar('title'),
406
+			'form_title' => \_AM_SYSTEM_BLOCKS_EDITBLOCK,
407
+			//        'name'       => $myblock->getVar('name'),
408
+			'side'       => $myblock->getVar('side'),
409
+			'weight'     => $myblock->getVar('weight'),
410
+			'visible'    => $myblock->getVar('visible'),
411
+			'content'    => $myblock->getVar('content', 'N'),
412
+			'modules'    => $modules,
413
+			'is_custom'  => $isCustom,
414
+			'ctype'      => $myblock->getVar('c_type'),
415
+			'bcachetime' => $myblock->getVar('bcachetime'),
416
+			'op'         => 'edit_ok',
417
+			'bid'        => $myblock->getVar('bid'),
418
+			'edit_form'  => $myblock->getOptions(),
419
+			'template'   => $myblock->getVar('template'),
420
+			'options'    => $myblock->getVar('options'),
421
+		];
422
+		echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
423
+
424
+		echo $this->render($block);
425
+	}
426
+
427
+	public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
428
+	{
429
+		$myblock = new \XoopsBlock($bid);
430
+		$myblock->setVar('title', $btitle);
431
+		$myblock->setVar('weight', $bweight);
432
+		$myblock->setVar('visible', $bvisible);
433
+		$myblock->setVar('side', $bside);
434
+		$myblock->setVar('bcachetime', $bcachetime);
435
+		//update block options
436
+		if (isset($options)) {
437
+			$optionsCount = \count($options);
438
+			if ($optionsCount > 0) {
439
+				//Convert array values to comma-separated
440
+				foreach ($options as $i => $iValue) {
441
+					if (\is_array($iValue)) {
442
+						$options[$i] = \implode(',', $iValue);
443
+					}
444
+				}
445
+				$options = \implode('|', $options);
446
+				$myblock->setVar('options', $options);
447
+			}
448
+		}
449
+		$myblock->store();
450
+		//        /** @var \XoopsBlockHandler $blockHandler */
451
+		//        $blockHandler = \xoops_getHandler('block');
452
+		//        $blockHandler->insert($myblock);
453
+
454
+		if (!empty($bmodule) && \count($bmodule) > 0) {
455
+			$sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
456
+			$this->db->query($sql);
457
+			if (\in_array(0, $bmodule)) {
458
+				$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, 0);
459
+				$this->db->query($sql);
460
+			} else {
461
+				foreach ($bmodule as $bmid) {
462
+					$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int)$bmid);
463
+					$this->db->query($sql);
464
+				}
465
+			}
466
+		}
467
+		$sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid);
468
+		$this->db->query($sql);
469
+		if (!empty($groups)) {
470
+			foreach ($groups as $grp) {
471
+				$sql = \sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid);
472
+				$this->db->query($sql);
473
+			}
474
+		}
475
+		$this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
476
+	}
477
+
478
+	public function orderBlock(
479
+		array $bid, array $oldtitle, array $oldside, array $oldweight, array $oldvisible, array $oldgroups, array $oldbcachetime, array $oldbmodule, array $title, array $weight, array $visible, array $side, array $bcachetime, array $groups, array $bmodule
480
+	): void {
481
+		if (!$GLOBALS['xoopsSecurity']->check()) {
482
+			\redirect_header($_SERVER['SCRIPT_NAME'], 3, \implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
483
+		}
484
+		foreach (\array_keys($bid) as $i) {
485
+			if ($oldtitle[$i] !== $title[$i]
486
+				|| $oldweight[$i] !== $weight[$i]
487
+				|| $oldvisible[$i] !== $visible[$i]
488
+				|| $oldside[$i] !== $side[$i]
489
+				|| $oldbcachetime[$i] !== $bcachetime[$i]
490
+				|| $oldbmodule[$i] !== $bmodule[$i]) {
491
+				$this->setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
492
+			}
493
+			if (!empty($bmodule[$i]) && \count($bmodule[$i]) > 0) {
494
+				$sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid[$i]);
495
+				$this->db->query($sql);
496
+				if (\in_array(0, $bmodule[$i], true)) {
497
+					$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], 0);
498
+					$this->db->query($sql);
499
+				} else {
500
+					foreach ($bmodule[$i] as $bmid) {
501
+						$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid);
502
+						$this->db->query($sql);
503
+					}
504
+				}
505
+			}
506
+			$sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid[$i]);
507
+			$this->db->query($sql);
508
+			if (!empty($groups[$i])) {
509
+				foreach ($groups[$i] as $grp) {
510
+					$sql = \sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid[$i]);
511
+					$this->db->query($sql);
512
+				}
513
+			}
514
+		}
515
+
516
+		$this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
517
+	}
518
+
519
+	public function render(?array $block = null)
520
+	{
521
+		\xoops_load('XoopsFormLoader');
522
+		\xoops_loadLanguage('common', $this->moduleDirNameUpper);
523
+
524
+		$form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true);
525
+		if (isset($block['name'])) {
526
+			$form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_NAME, $block['name']));
527
+		}
528
+		$sideSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']);
529
+		$sideSelect->addOptionArray([
530
+										0 => \_AM_SYSTEM_BLOCKS_SBLEFT,
531
+										1 => \_AM_SYSTEM_BLOCKS_SBRIGHT,
532
+										3 => \_AM_SYSTEM_BLOCKS_CBLEFT,
533
+										4 => \_AM_SYSTEM_BLOCKS_CBRIGHT,
534
+										5 => \_AM_SYSTEM_BLOCKS_CBCENTER,
535
+										7 => \_AM_SYSTEM_BLOCKS_CBBOTTOMLEFT,
536
+										8 => \_AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT,
537
+										9 => \_AM_SYSTEM_BLOCKS_CBBOTTOM,
538
+									]);
539
+		$form->addElement($sideSelect);
540
+		$form->addElement(new \XoopsFormText(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
541
+		$form->addElement(new \XoopsFormRadioYN(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
542
+		$modSelect = new \XoopsFormSelect(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
543
+		/** @var \XoopsModuleHandler $moduleHandler */
544
+		$moduleHandler = \xoops_getHandler('module');
545
+		$criteria      = new \CriteriaCompo(new \Criteria('hasmain', '1'));
546
+		$criteria->add(new \Criteria('isactive', '1'));
547
+		$moduleList     = $moduleHandler->getList($criteria);
548
+		$moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
549
+		$moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
550
+		\ksort($moduleList);
551
+		$modSelect->addOptionArray($moduleList);
552
+		$form->addElement($modSelect);
553
+		$form->addElement(new \XoopsFormText(\_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false);
554
+		if ($block['is_custom']) {
555
+			$textarea = new \XoopsFormDhtmlTextArea(\_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);
556
+			$textarea->setDescription('<span style="font-size:x-small;font-weight:bold;">' . \_AM_SYSTEM_BLOCKS_USEFULTAGS . '</span><br><span style="font-size:x-small;font-weight:normal;">' . \sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . '</span>');
557
+			$form->addElement($textarea, true);
558
+			$ctypeSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
559
+			$ctypeSelect->addOptionArray([
560
+											 'H' => \_AM_SYSTEM_BLOCKS_HTML,
561
+											 'P' => \_AM_SYSTEM_BLOCKS_PHP,
562
+											 'S' => \_AM_SYSTEM_BLOCKS_AFWSMILE,
563
+											 'T' => \_AM_SYSTEM_BLOCKS_AFNOSMILE,
564
+										 ]);
565
+			$form->addElement($ctypeSelect);
566
+		} else {
567
+			if ('' !== $block['template']) {
568
+				/** @var \XoopsTplfileHandler $tplfileHandler */
569
+				$tplfileHandler = \xoops_getHandler('tplfile');
570
+				$btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
571
+				if (\count($btemplate) > 0) {
572
+					$form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate[0]->getVar('tpl_id') . '">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
573
+				} else {
574
+					$btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);
575
+					if (\count($btemplate2) > 0) {
576
+						$form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" target="_blank">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
577
+					}
578
+				}
579
+			}
580
+			if (false !== $block['edit_form']) {
581
+				$form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form']));
582
+			}
583
+		}
584
+		$cache_select = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']);
585
+		$cache_select->addOptionArray([
586
+										  0       => _NOCACHE,
587
+										  30      => \sprintf(_SECONDS, 30),
588
+										  60      => _MINUTE,
589
+										  300     => \sprintf(_MINUTES, 5),
590
+										  1800    => \sprintf(_MINUTES, 30),
591
+										  3600    => _HOUR,
592
+										  18000   => \sprintf(_HOURS, 5),
593
+										  86400   => _DAY,
594
+										  259200  => \sprintf(_DAYS, 3),
595
+										  604800  => _WEEK,
596
+										  2592000 => _MONTH,
597
+									  ]);
598
+		$form->addElement($cache_select);
599
+
600
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
601
+		$grouppermHandler = \xoops_getHandler('groupperm');
602
+		$groups           = $grouppermHandler->getGroupIds('block_read', $block['bid']);
603
+
604
+		$form->addElement(new \XoopsFormSelectGroup(\_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true));
605
+
606
+		if (isset($block['bid'])) {
607
+			$form->addElement(new \XoopsFormHidden('bid', $block['bid']));
608
+		}
609
+		$form->addElement(new \XoopsFormHidden('op', $block['op']));
610
+		$form->addElement(new \XoopsFormHidden('fct', 'blocksadmin'));
611
+		$buttonTray = new \XoopsFormElementTray('', '&nbsp;');
612
+		if ($block['is_custom']) {
613
+			$buttonTray->addElement(new \XoopsFormButton('', 'previewblock', _PREVIEW, 'submit'));
614
+		}
615
+
616
+		//Submit buttons
617
+		$buttonTray   = new \XoopsFormElementTray('', '');
618
+		$submitButton = new \XoopsFormButton('', 'submitblock', _SUBMIT, 'submit');
619
+		$buttonTray->addElement($submitButton);
620
+
621
+		$cancelButton = new \XoopsFormButton('', '', _CANCEL, 'button');
622
+		$cancelButton->setExtra('onclick="history.go(-1)"');
623
+		$buttonTray->addElement($cancelButton);
624
+
625
+		$form->addElement($buttonTray);
626
+		$form->display();
627
+	}
628 628
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     public function listBlocks(): void
69 69
     {
70 70
         global $xoopsModule, $pathIcon16;
71
-        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
71
+        require_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
72 72
         //        xoops_loadLanguage('admin', 'system');
73 73
         //        xoops_loadLanguage('admin/blocksadmin', 'system');
74 74
         //        xoops_loadLanguage('admin/groups', 'system');
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
         $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
89 89
         $moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
90 90
         \ksort($moduleList);
91
-        echo "<h4 style='text-align:left;'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
92
-        echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>";
91
+        echo "<h4 style='text-align:left;'>".\constant('CO_'.$this->moduleDirNameUpper.'_'.'BADMIN').'</h4>';
92
+        echo "<form action='".$_SERVER['SCRIPT_NAME']."' name='blockadmin' method='post'>";
93 93
         echo $GLOBALS['xoopsSecurity']->getTokenHTML();
94 94
         echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
95
-        <tr valign='middle'><th align='center'>" . \_AM_SYSTEM_BLOCKS_TITLE . "</th><th align='center' nowrap='nowrap'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'SIDE') . '<br>' . _LEFT . '-' . _CENTER . '-' . _RIGHT . "</th>
96
-        <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT') . "</th>
97
-        <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE') . "</th><th align='center'>" . \_AM_SYSTEM_BLOCKS_VISIBLEIN . "</th>
98
-        <th align='center'>" . \_AM_SYSTEM_ADGS . "</th>
99
-        <th align='center'>" . \_AM_SYSTEM_BLOCKS_BCACHETIME . "</th>
100
-        <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'ACTION') . '</th>
95
+        <tr valign='middle'><th align='center'>" . \_AM_SYSTEM_BLOCKS_TITLE."</th><th align='center' nowrap='nowrap'>".\constant('CO_'.$this->moduleDirNameUpper.'_'.'SIDE').'<br>'._LEFT.'-'._CENTER.'-'._RIGHT."</th>
96
+        <th align='center'>" . \constant('CO_'.$this->moduleDirNameUpper.'_'.'WEIGHT')."</th>
97
+        <th align='center'>" . \constant('CO_'.$this->moduleDirNameUpper.'_'.'VISIBLE')."</th><th align='center'>".\_AM_SYSTEM_BLOCKS_VISIBLEIN."</th>
98
+        <th align='center'>" . \_AM_SYSTEM_ADGS."</th>
99
+        <th align='center'>" . \_AM_SYSTEM_BLOCKS_BCACHETIME."</th>
100
+        <th align='center'>" . \constant('CO_'.$this->moduleDirNameUpper.'_'.'ACTION').'</th>
101 101
         </tr>';
102 102
         $blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
103 103
         $blockCount = \count($blockArray);
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
         ];
118 118
         foreach ($blockArray as $i) {
119 119
             $groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
120
-            $sql               = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
120
+            $sql               = 'SELECT module_id FROM '.$this->db->prefix('block_module_link').' WHERE block_id='.$i->getVar('bid');
121 121
             $result            = $this->db->query($sql);
122 122
             $modules           = [];
123 123
             if (!$result instanceof \mysqli_result) {
124
-                \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR);
124
+                \trigger_error("Query Failed! SQL: $sql Error: ".$this->db->error(), \E_USER_ERROR);
125 125
             }
126 126
             while (false !== ($row = $this->db->fetchArray($result))) {
127
-                $modules[] = (int)$row['module_id'];
127
+                $modules[] = (int) $row['module_id'];
128 128
             }
129 129
 
130 130
             $cachetimeOptions = '';
@@ -174,46 +174,46 @@  discard block
 block discarded – undo
174 174
                 $title = $i->getVar('title');
175 175
             }
176 176
             $name = $i->getVar('name');
177
-            echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" . $i->getVar('bid') . "]' value='" . $title . "'></td>
177
+            echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[".$i->getVar('bid')."]' value='".$title."'></td>
178 178
             <td class='$class' align='center' nowrap='nowrap'><div align='center' >
179
-                    <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_LEFT . "'$ssel2>
180
-                    <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_CENTER . "'$ssel3>
181
-                    <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_RIGHT . "'$ssel4>
179
+                    <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_LEFT."'$ssel2>
180
+                    <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_CENTER."'$ssel3>
181
+                    <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_RIGHT."'$ssel4>
182 182
                     </div>
183 183
                     <div>
184
-                        <span style='float:right;'><input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_SIDEBLOCK_RIGHT . "'$ssel1></span>
185
-                    <div align='left'><input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_SIDEBLOCK_LEFT . "'$ssel0></div>
184
+                        <span style='float:right;'><input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_SIDEBLOCK_RIGHT."'$ssel1></span>
185
+                    <div align='left'><input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_SIDEBLOCK_LEFT."'$ssel0></div>
186 186
                     </div>
187 187
                     <div align='center'>
188
-                    <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_BOTTOMLEFT . "'$ssel5>
189
-                        <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_BOTTOM . "'$ssel7>
190
-                    <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_BOTTOMRIGHT . "'$ssel6>
188
+                    <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_BOTTOMLEFT."'$ssel5>
189
+                        <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_BOTTOM."'$ssel7>
190
+                    <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_BOTTOMRIGHT."'$ssel6>
191 191
                     </div>
192 192
                 </td>
193
-                <td class='$class' align='center'><input type='text' name='weight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "' size='5' maxlength='5'></td>
194
-                <td class='$class' align='center' nowrap><input type='radio' name='visible[" . $i->getVar('bid') . "]' value='1'$sel1>" . _YES . "&nbsp;<input type='radio' name='visible[" . $i->getVar('bid') . "]' value='0'$sel0>" . _NO . '</td>';
193
+                <td class='$class' align='center'><input type='text' name='weight[".$i->getVar('bid')."]' value='".$i->getVar('weight')."' size='5' maxlength='5'></td>
194
+                <td class='$class' align='center' nowrap><input type='radio' name='visible[".$i->getVar('bid')."]' value='1'$sel1>"._YES."&nbsp;<input type='radio' name='visible[".$i->getVar('bid')."]' value='0'$sel0>"._NO.'</td>';
195 195
 
196
-            echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
196
+            echo "<td class='$class' align='center'><select size='5' name='bmodule[".$i->getVar('bid')."][]' id='bmodule[".$i->getVar('bid')."][]' multiple='multiple'>";
197 197
             foreach ($moduleList as $k => $v) {
198
-                echo "<option value='$k'" . (\in_array($k, $modules) ? " selected='selected'" : '') . ">$v</option>";
198
+                echo "<option value='$k'".(\in_array($k, $modules) ? " selected='selected'" : '').">$v</option>";
199 199
             }
200 200
             echo '</select></td>';
201 201
 
202
-            echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
202
+            echo "<td class='$class' align='center'><select size='5' name='groups[".$i->getVar('bid')."][]' id='groups[".$i->getVar('bid')."][]' multiple='multiple'>";
203 203
             foreach ($groups as $grp) {
204
-                echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
204
+                echo "<option value='".$grp->getVar('groupid')."' ".(\in_array($grp->getVar('groupid'), $groupsPermissions) ? " selected='selected'" : '').'>'.$grp->getVar('name').'</option>';
205 205
             }
206 206
             echo '</select></td>';
207 207
 
208 208
             // Cache lifetime
209
-            echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select>
209
+            echo '<td class="'.$class.'" align="center"> <select name="bcachetime['.$i->getVar('bid').']" size="1">'.$cachetimeOptions.'</select>
210 210
                                     </td>';
211 211
 
212 212
             // Actions
213 213
 
214 214
             echo "<td class='$class' align='center'>
215
-                <a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'></a> 
216
-                <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'></a>";
215
+                <a href='blocksadmin.php?op=edit&amp;bid=".$i->getVar('bid')."'><img src=".$pathIcon16.'/edit.png'." alt='"._EDIT."' title='"._EDIT."'></a> 
216
+                <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid')."'><img src=".$pathIcon16.'/editcopy.png'." alt='"._CLONE."' title='"._CLONE."'></a>";
217 217
             //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
218 218
             //                echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
219 219
             //                     </a>";
@@ -222,22 +222,22 @@  discard block
 block discarded – undo
222 222
             //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
223 223
             if (!\in_array($i->getVar('block_type'), ['M', 'S'])) {
224 224
                 echo "&nbsp;
225
-                <a href='blocksadmin.php?op=delete&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
225
+                <a href='blocksadmin.php?op=delete&amp;bid=" . $i->getVar('bid')."'><img src=".$pathIcon16.'/delete.png'." alt='"._DELETE."' title='"._DELETE."'>
226 226
                      </a>";
227 227
             }
228 228
             echo "
229
-            <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'>
230
-            <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'>
231
-            <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'>
232
-            <input type='hidden' name='oldvisible[" . $i->getVar('bid') . "]' value='" . $i->getVar('visible') . "'>
233
-            <input type='hidden' name='oldgroups[" . $i->getVar('groups') . "]' value='" . $i->getVar('groups') . "'>
234
-            <input type='hidden' name='oldbcachetime[" . $i->getVar('bid') . "]' value='" . $i->getVar('bcachetime') . "'>
235
-            <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'>
229
+            <input type='hidden' name='oldtitle[" . $i->getVar('bid')."]' value='".$i->getVar('title')."'>
230
+            <input type='hidden' name='oldside[" . $i->getVar('bid')."]' value='".$i->getVar('side')."'>
231
+            <input type='hidden' name='oldweight[" . $i->getVar('bid')."]' value='".$i->getVar('weight')."'>
232
+            <input type='hidden' name='oldvisible[" . $i->getVar('bid')."]' value='".$i->getVar('visible')."'>
233
+            <input type='hidden' name='oldgroups[" . $i->getVar('groups')."]' value='".$i->getVar('groups')."'>
234
+            <input type='hidden' name='oldbcachetime[" . $i->getVar('bid')."]' value='".$i->getVar('bcachetime')."'>
235
+            <input type='hidden' name='bid[" . $i->getVar('bid')."]' value='".$i->getVar('bid')."'>
236 236
             </td></tr>
237 237
             ";
238 238
             $class = ('even' === $class) ? 'odd' : 'even';
239 239
         }
240
-        echo "<tr><td class='foot' align='center' colspan='8'> <input type='hidden' name='op' value='order'>" . $GLOBALS['xoopsSecurity']->getTokenHTML() . "<input type='submit' name='submit' value='" . _SUBMIT . "'></td></tr></table></form><br><br>";
240
+        echo "<tr><td class='foot' align='center' colspan='8'> <input type='hidden' name='op' value='order'>".$GLOBALS['xoopsSecurity']->getTokenHTML()."<input type='submit' name='submit' value='"._SUBMIT."'></td></tr></table></form><br><br>";
241 241
     }
242 242
 
243 243
     public function deleteBlock(int $bid): void
@@ -268,18 +268,18 @@  discard block
 block discarded – undo
268 268
         \xoops_loadLanguage('admin/groups', 'system');
269 269
 
270 270
         $myblock = new \XoopsBlock($bid);
271
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
271
+        $sql     = 'SELECT module_id FROM '.$this->db->prefix('block_module_link').' WHERE block_id='.$bid;
272 272
         $result  = $this->db->query($sql);
273 273
         $modules = [];
274 274
         if ($result instanceof \mysqli_result) {
275 275
             while (false !== ($row = $this->db->fetchArray($result))) {
276
-                $modules[] = (int)$row['module_id'];
276
+                $modules[] = (int) $row['module_id'];
277 277
             }
278 278
         }
279 279
         $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
280 280
         $block    = [
281
-            'title'      => $myblock->getVar('title') . ' Clone',
282
-            'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
281
+            'title'      => $myblock->getVar('title').' Clone',
282
+            'form_title' => \constant('CO_'.$this->moduleDirNameUpper.'_'.'BLOCKS_CLONEBLOCK'),
283 283
             'name'       => $myblock->getVar('name'),
284 284
             'side'       => $myblock->getVar('side'),
285 285
             'weight'     => $myblock->getVar('weight'),
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             'template'   => $myblock->getVar('template'),
296 296
             'options'    => $myblock->getVar('options'),
297 297
         ];
298
-        echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
298
+        echo '<a href="blocksadmin.php">'.\constant('CO_'.$this->moduleDirNameUpper.'_'.'BADMIN').'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'.\_AM_SYSTEM_BLOCKS_CLONEBLOCK.'<br><br>';
299 299
         //        $form = new Blockform();
300 300
         //        $form->render();
301 301
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         }
338 338
         //        $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105
339 339
         if ($clone->store()) {
340
-            $newid = $clone->id();  //get the id of the cloned block
340
+            $newid = $clone->id(); //get the id of the cloned block
341 341
         }
342 342
         if (!$newid) {
343 343
             //            \xoops_cp_header();
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
         if ('' !== $clone->getVar('template')) {
349 349
             /** @var \XoopsTplfileHandler $tplfileHandler */
350 350
             $tplfileHandler = \xoops_getHandler('tplfile');
351
-            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string)$bid);
351
+            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string) $bid);
352 352
             if (\count($btemplate) > 0) {
353 353
                 $tplclone = $btemplate[0]->xoopsClone();
354 354
                 $tplclone->setVar('tpl_id', 0);
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
         }
359 359
 
360 360
         foreach ($bmodule as $bmid) {
361
-            $sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
361
+            $sql = 'INSERT INTO '.$this->db->prefix('block_module_link').' (block_id, module_id) VALUES ('.$newid.', '.$bmid.')';
362 362
             $this->db->query($sql);
363 363
         }
364 364
         //$groups = &$GLOBALS['xoopsUser']->getGroups();
365 365
         foreach ($groups as $iValue) {
366
-            $sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
366
+            $sql = 'INSERT INTO '.$this->db->prefix('group_permission').' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ('.$iValue.', '.$newid.", 1, 'block_read')";
367 367
             $this->db->query($sql);
368 368
         }
369 369
         $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
@@ -392,12 +392,12 @@  discard block
 block discarded – undo
392 392
         \xoops_loadLanguage('admin/groups', 'system');
393 393
         //        mpu_adm_menu();
394 394
         $myblock = new \XoopsBlock($bid);
395
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
395
+        $sql     = 'SELECT module_id FROM '.$this->db->prefix('block_module_link').' WHERE block_id='.$bid;
396 396
         $result  = $this->db->query($sql);
397 397
         $modules = [];
398 398
         if ($result instanceof \mysqli_result) {
399 399
             while (false !== ($row = $this->db->fetchArray($result))) {
400
-                $modules[] = (int)$row['module_id'];
400
+                $modules[] = (int) $row['module_id'];
401 401
             }
402 402
         }
403 403
         $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
             'template'   => $myblock->getVar('template'),
420 420
             'options'    => $myblock->getVar('options'),
421 421
         ];
422
-        echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
422
+        echo '<a href="blocksadmin.php">'.\constant('CO_'.$this->moduleDirNameUpper.'_'.'BADMIN').'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'.\_AM_SYSTEM_BLOCKS_EDITBLOCK.'<br><br>';
423 423
 
424 424
         echo $this->render($block);
425 425
     }
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
                 $this->db->query($sql);
460 460
             } else {
461 461
                 foreach ($bmodule as $bmid) {
462
-                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int)$bmid);
462
+                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int) $bmid);
463 463
                     $this->db->query($sql);
464 464
                 }
465 465
             }
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
                 $this->db->query($sql);
473 473
             }
474 474
         }
475
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
475
+        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_'.$this->moduleDirNameUpper.'_'.'UPDATE_SUCCESS'));
476 476
     }
477 477
 
478 478
     public function orderBlock(
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
                     $this->db->query($sql);
499 499
                 } else {
500 500
                     foreach ($bmodule[$i] as $bmid) {
501
-                        $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid);
501
+                        $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int) $bmid);
502 502
                         $this->db->query($sql);
503 503
                     }
504 504
                 }
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
             }
514 514
         }
515 515
 
516
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
516
+        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_'.$this->moduleDirNameUpper.'_'.'UPDATE_SUCCESS'));
517 517
     }
518 518
 
519 519
     public function render(?array $block = null)
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
                                         9 => \_AM_SYSTEM_BLOCKS_CBBOTTOM,
538 538
                                     ]);
539 539
         $form->addElement($sideSelect);
540
-        $form->addElement(new \XoopsFormText(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
541
-        $form->addElement(new \XoopsFormRadioYN(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
542
-        $modSelect = new \XoopsFormSelect(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
540
+        $form->addElement(new \XoopsFormText(\constant('CO_'.$this->moduleDirNameUpper.'_'.'WEIGHT'), 'bweight', 2, 5, $block['weight']));
541
+        $form->addElement(new \XoopsFormRadioYN(\constant('CO_'.$this->moduleDirNameUpper.'_'.'VISIBLE'), 'bvisible', $block['visible']));
542
+        $modSelect = new \XoopsFormSelect(\constant('CO_'.$this->moduleDirNameUpper.'_'.'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
543 543
         /** @var \XoopsModuleHandler $moduleHandler */
544 544
         $moduleHandler = \xoops_getHandler('module');
545 545
         $criteria      = new \CriteriaCompo(new \Criteria('hasmain', '1'));
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
         $form->addElement(new \XoopsFormText(\_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false);
554 554
         if ($block['is_custom']) {
555 555
             $textarea = new \XoopsFormDhtmlTextArea(\_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);
556
-            $textarea->setDescription('<span style="font-size:x-small;font-weight:bold;">' . \_AM_SYSTEM_BLOCKS_USEFULTAGS . '</span><br><span style="font-size:x-small;font-weight:normal;">' . \sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . '</span>');
556
+            $textarea->setDescription('<span style="font-size:x-small;font-weight:bold;">'.\_AM_SYSTEM_BLOCKS_USEFULTAGS.'</span><br><span style="font-size:x-small;font-weight:normal;">'.\sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL.'/').'</span>');
557 557
             $form->addElement($textarea, true);
558 558
             $ctypeSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
559 559
             $ctypeSelect->addOptionArray([
@@ -569,11 +569,11 @@  discard block
 block discarded – undo
569 569
                 $tplfileHandler = \xoops_getHandler('tplfile');
570 570
                 $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
571 571
                 if (\count($btemplate) > 0) {
572
-                    $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate[0]->getVar('tpl_id') . '">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
572
+                    $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="'.XOOPS_URL.'/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id='.$btemplate[0]->getVar('tpl_id').'">'.\_AM_SYSTEM_BLOCKS_EDITTPL.'</a>'));
573 573
                 } else {
574 574
                     $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);
575 575
                     if (\count($btemplate2) > 0) {
576
-                        $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" target="_blank">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
576
+                        $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="'.XOOPS_URL.'/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id='.$btemplate2[0]->getVar('tpl_id').'" target="_blank">'.\_AM_SYSTEM_BLOCKS_EDITTPL.'</a>'));
577 577
                     }
578 578
                 }
579 579
             }
Please login to merge, or discard this patch.
class/Common/SysUtility.php 2 patches
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -30,216 +30,216 @@
 block discarded – undo
30 30
  */
31 31
 class SysUtility
32 32
 {
33
-    use VersionChecks;
34
-
35
-    //checkVerXoops, checkVerPhp Traits
36
-
37
-    use ServerStats;
38
-
39
-    // getServerStats Trait
40
-
41
-    use FilesManagement;
42
-
43
-    // Files Management Trait
44
-
45
-    /**
46
-     * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags
47
-     * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags
48
-     * www.cakephp.org
49
-     *
50
-     * @param string $text         String to truncate.
51
-     * @param int    $length       Length of returned string, including ellipsis.
52
-     * @param string $ending       Ending to be appended to the trimmed string.
53
-     * @param bool   $exact        If false, $text will not be cut mid-word
54
-     * @param bool   $considerHtml If true, HTML tags would be handled correctly
55
-     *
56
-     * @return string Trimmed string.
57
-     */
58
-    public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
59
-    {
60
-        if ($considerHtml) {
61
-            // if the plain text is shorter than the maximum length, return the whole text
62
-            if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
63
-                return $text;
64
-            }
65
-            // splits all html-tags to scanable lines
66
-            \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
67
-            $total_length = mb_strlen($ending);
68
-            $open_tags    = [];
69
-            $truncate     = '';
70
-            foreach ($lines as $line_matchings) {
71
-                // if there is any html-tag in this line, handle it and add it (uncounted) to the output
72
-                if (!empty($line_matchings[1])) {
73
-                    // if it's an "empty element" with or without xhtml-conform closing slash
74
-                    if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {
75
-                        // do nothing
76
-                        // if tag is a closing tag
77
-                    } elseif (\preg_match('/^<\s*\/(\S+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
78
-                        // delete tag from $open_tags list
79
-                        $pos = \array_search($tag_matchings[1], $open_tags, true);
80
-                        if (false !== $pos) {
81
-                            unset($open_tags[$pos]);
82
-                        }
83
-                        // if tag is an opening tag
84
-                    } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) {
85
-                        // add tag to the beginning of $open_tags list
86
-                        \array_unshift($open_tags, \mb_strtolower($tag_matchings[1]));
87
-                    }
88
-                    // add html-tag to $truncate'd text
89
-                    $truncate .= $line_matchings[1];
90
-                }
91
-                // calculate the length of the plain text part of the line; handle entities as one character
92
-                $content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
93
-                if ($total_length + $content_length > $length) {
94
-                    // the number of characters which are left
95
-                    $left            = $length - $total_length;
96
-                    $entities_length = 0;
97
-                    // search for html entities
98
-                    if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
99
-                        // calculate the real length of all entities in the legal range
100
-                        foreach ($entities[0] as $entity) {
101
-                            if ($left >= $entity[1] + 1 - $entities_length) {
102
-                                $left--;
103
-                                $entities_length += mb_strlen($entity[0]);
104
-                            } else {
105
-                                // no more characters left
106
-                                break;
107
-                            }
108
-                        }
109
-                    }
110
-                    $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length);
111
-                    // maximum lenght is reached, so get off the loop
112
-                    break;
113
-                }
114
-                $truncate     .= $line_matchings[2];
115
-                $total_length += $content_length;
116
-
117
-                // if the maximum length is reached, get off the loop
118
-                if ($total_length >= $length) {
119
-                    break;
120
-                }
121
-            }
122
-        } else {
123
-            if (mb_strlen($text) <= $length) {
124
-                return $text;
125
-            }
126
-            $truncate = mb_substr($text, 0, $length - mb_strlen($ending));
127
-        }
128
-        // if the words shouldn't be cut in the middle...
129
-        if (!$exact) {
130
-            // ...search the last occurance of a space...
131
-            $spacepos = mb_strrpos($truncate, ' ');
132
-            if (isset($spacepos)) {
133
-                // ...and cut the text in this position
134
-                $truncate = mb_substr($truncate, 0, $spacepos);
135
-            }
136
-        }
137
-        // add the defined ending to the text
138
-        $truncate .= $ending;
139
-        if ($considerHtml) {
140
-            // close all unclosed html-tags
141
-            foreach ($open_tags as $tag) {
142
-                $truncate .= '</' . $tag . '>';
143
-            }
144
-        }
145
-
146
-        return $truncate;
147
-    }
148
-
149
-    /**
150
-     * @param \Xmf\Module\Helper $helper
151
-     * @param array|null         $options
152
-     * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor
153
-     */
154
-    public static function getEditor($helper = null, $options = null)
155
-    {
156
-        /** @var Helper $helper */
157
-        if (null === $options) {
158
-            $options           = [];
159
-            $options['name']   = 'Editor';
160
-            $options['value']  = 'Editor';
161
-            $options['rows']   = 10;
162
-            $options['cols']   = '100%';
163
-            $options['width']  = '100%';
164
-            $options['height'] = '400px';
165
-        }
166
-
167
-        if (null === $helper) {
168
-            $helper = Helper::getInstance();
169
-        }
170
-
171
-        $isAdmin = $helper->isUserAdmin();
172
-
173
-        if (\class_exists('XoopsFormEditor')) {
174
-            if ($isAdmin) {
175
-                $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea');
176
-            } else {
177
-                $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea');
178
-            }
179
-        } else {
180
-            $descEditor = new \XoopsFormDhtmlTextArea(\ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%');
181
-        }
182
-
183
-        //        $form->addElement($descEditor);
184
-
185
-        return $descEditor;
186
-    }
187
-
188
-    /**
189
-     * @param $fieldname
190
-     * @param $table
191
-     */
192
-    public static function fieldExists(string $fieldname, string $table): bool
193
-    {
194
-        global $xoopsDB;
195
-        $result = $xoopsDB->queryF("SHOW COLUMNS FROM   $table LIKE '$fieldname'");
196
-
197
-        return ($xoopsDB->getRowsNum($result) > 0);
198
-    }
199
-
200
-    /**
201
-     * @param array|string $tableName
202
-     * @param int          $id_field
203
-     * @param int          $id
204
-     *
205
-     * @return mixed
206
-     */
207
-    public static function cloneRecord($tableName, $id_field, $id)
208
-    {
209
-        $new_id = false;
210
-        $table  = $GLOBALS['xoopsDB']->prefix($tableName);
211
-        // copy content of the record you wish to clone
212
-        $sql    = "SELECT * FROM $table WHERE $idField='" . $id . "' ";
213
-        $result = $GLOBALS['xoopsDB']->query($sql);
214
-        if ($result instanceof \mysqli_result) {
215
-            $tempTable = $GLOBALS['xoopsDB']->fetchArray($result, \MYSQLI_ASSOC);
216
-        }
217
-        if (!$tempTable) {
218
-            \trigger_error($GLOBALS['xoopsDB']->error());
219
-        }
220
-        // set the auto-incremented id's value to blank.
221
-        unset($tempTable[$id_field]);
222
-        // insert cloned copy of the original  record
223
-        $sql    = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", \array_values($tempTable)) . "')";
224
-        $result = $GLOBALS['xoopsDB']->queryF($sql);
225
-        if (!$result) {
226
-            \trigger_error($GLOBALS['xoopsDB']->error());
227
-        }
228
-        // Return the new id
229
-        $new_id = $GLOBALS['xoopsDB']->getInsertId();
230
-
231
-        return $new_id;
232
-    }
233
-
234
-    /**
235
-     * @param string $tablename
236
-     *
237
-     * @return bool
238
-     */
239
-    public static function tableExists($tablename)
240
-    {
241
-        $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'");
242
-
243
-        return $GLOBALS['xoopsDB']->getRowsNum($result) > 0;
244
-    }
33
+	use VersionChecks;
34
+
35
+	//checkVerXoops, checkVerPhp Traits
36
+
37
+	use ServerStats;
38
+
39
+	// getServerStats Trait
40
+
41
+	use FilesManagement;
42
+
43
+	// Files Management Trait
44
+
45
+	/**
46
+	 * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags
47
+	 * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags
48
+	 * www.cakephp.org
49
+	 *
50
+	 * @param string $text         String to truncate.
51
+	 * @param int    $length       Length of returned string, including ellipsis.
52
+	 * @param string $ending       Ending to be appended to the trimmed string.
53
+	 * @param bool   $exact        If false, $text will not be cut mid-word
54
+	 * @param bool   $considerHtml If true, HTML tags would be handled correctly
55
+	 *
56
+	 * @return string Trimmed string.
57
+	 */
58
+	public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
59
+	{
60
+		if ($considerHtml) {
61
+			// if the plain text is shorter than the maximum length, return the whole text
62
+			if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
63
+				return $text;
64
+			}
65
+			// splits all html-tags to scanable lines
66
+			\preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
67
+			$total_length = mb_strlen($ending);
68
+			$open_tags    = [];
69
+			$truncate     = '';
70
+			foreach ($lines as $line_matchings) {
71
+				// if there is any html-tag in this line, handle it and add it (uncounted) to the output
72
+				if (!empty($line_matchings[1])) {
73
+					// if it's an "empty element" with or without xhtml-conform closing slash
74
+					if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {
75
+						// do nothing
76
+						// if tag is a closing tag
77
+					} elseif (\preg_match('/^<\s*\/(\S+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
78
+						// delete tag from $open_tags list
79
+						$pos = \array_search($tag_matchings[1], $open_tags, true);
80
+						if (false !== $pos) {
81
+							unset($open_tags[$pos]);
82
+						}
83
+						// if tag is an opening tag
84
+					} elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) {
85
+						// add tag to the beginning of $open_tags list
86
+						\array_unshift($open_tags, \mb_strtolower($tag_matchings[1]));
87
+					}
88
+					// add html-tag to $truncate'd text
89
+					$truncate .= $line_matchings[1];
90
+				}
91
+				// calculate the length of the plain text part of the line; handle entities as one character
92
+				$content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
93
+				if ($total_length + $content_length > $length) {
94
+					// the number of characters which are left
95
+					$left            = $length - $total_length;
96
+					$entities_length = 0;
97
+					// search for html entities
98
+					if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
99
+						// calculate the real length of all entities in the legal range
100
+						foreach ($entities[0] as $entity) {
101
+							if ($left >= $entity[1] + 1 - $entities_length) {
102
+								$left--;
103
+								$entities_length += mb_strlen($entity[0]);
104
+							} else {
105
+								// no more characters left
106
+								break;
107
+							}
108
+						}
109
+					}
110
+					$truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length);
111
+					// maximum lenght is reached, so get off the loop
112
+					break;
113
+				}
114
+				$truncate     .= $line_matchings[2];
115
+				$total_length += $content_length;
116
+
117
+				// if the maximum length is reached, get off the loop
118
+				if ($total_length >= $length) {
119
+					break;
120
+				}
121
+			}
122
+		} else {
123
+			if (mb_strlen($text) <= $length) {
124
+				return $text;
125
+			}
126
+			$truncate = mb_substr($text, 0, $length - mb_strlen($ending));
127
+		}
128
+		// if the words shouldn't be cut in the middle...
129
+		if (!$exact) {
130
+			// ...search the last occurance of a space...
131
+			$spacepos = mb_strrpos($truncate, ' ');
132
+			if (isset($spacepos)) {
133
+				// ...and cut the text in this position
134
+				$truncate = mb_substr($truncate, 0, $spacepos);
135
+			}
136
+		}
137
+		// add the defined ending to the text
138
+		$truncate .= $ending;
139
+		if ($considerHtml) {
140
+			// close all unclosed html-tags
141
+			foreach ($open_tags as $tag) {
142
+				$truncate .= '</' . $tag . '>';
143
+			}
144
+		}
145
+
146
+		return $truncate;
147
+	}
148
+
149
+	/**
150
+	 * @param \Xmf\Module\Helper $helper
151
+	 * @param array|null         $options
152
+	 * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor
153
+	 */
154
+	public static function getEditor($helper = null, $options = null)
155
+	{
156
+		/** @var Helper $helper */
157
+		if (null === $options) {
158
+			$options           = [];
159
+			$options['name']   = 'Editor';
160
+			$options['value']  = 'Editor';
161
+			$options['rows']   = 10;
162
+			$options['cols']   = '100%';
163
+			$options['width']  = '100%';
164
+			$options['height'] = '400px';
165
+		}
166
+
167
+		if (null === $helper) {
168
+			$helper = Helper::getInstance();
169
+		}
170
+
171
+		$isAdmin = $helper->isUserAdmin();
172
+
173
+		if (\class_exists('XoopsFormEditor')) {
174
+			if ($isAdmin) {
175
+				$descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea');
176
+			} else {
177
+				$descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea');
178
+			}
179
+		} else {
180
+			$descEditor = new \XoopsFormDhtmlTextArea(\ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%');
181
+		}
182
+
183
+		//        $form->addElement($descEditor);
184
+
185
+		return $descEditor;
186
+	}
187
+
188
+	/**
189
+	 * @param $fieldname
190
+	 * @param $table
191
+	 */
192
+	public static function fieldExists(string $fieldname, string $table): bool
193
+	{
194
+		global $xoopsDB;
195
+		$result = $xoopsDB->queryF("SHOW COLUMNS FROM   $table LIKE '$fieldname'");
196
+
197
+		return ($xoopsDB->getRowsNum($result) > 0);
198
+	}
199
+
200
+	/**
201
+	 * @param array|string $tableName
202
+	 * @param int          $id_field
203
+	 * @param int          $id
204
+	 *
205
+	 * @return mixed
206
+	 */
207
+	public static function cloneRecord($tableName, $id_field, $id)
208
+	{
209
+		$new_id = false;
210
+		$table  = $GLOBALS['xoopsDB']->prefix($tableName);
211
+		// copy content of the record you wish to clone
212
+		$sql    = "SELECT * FROM $table WHERE $idField='" . $id . "' ";
213
+		$result = $GLOBALS['xoopsDB']->query($sql);
214
+		if ($result instanceof \mysqli_result) {
215
+			$tempTable = $GLOBALS['xoopsDB']->fetchArray($result, \MYSQLI_ASSOC);
216
+		}
217
+		if (!$tempTable) {
218
+			\trigger_error($GLOBALS['xoopsDB']->error());
219
+		}
220
+		// set the auto-incremented id's value to blank.
221
+		unset($tempTable[$id_field]);
222
+		// insert cloned copy of the original  record
223
+		$sql    = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", \array_values($tempTable)) . "')";
224
+		$result = $GLOBALS['xoopsDB']->queryF($sql);
225
+		if (!$result) {
226
+			\trigger_error($GLOBALS['xoopsDB']->error());
227
+		}
228
+		// Return the new id
229
+		$new_id = $GLOBALS['xoopsDB']->getInsertId();
230
+
231
+		return $new_id;
232
+	}
233
+
234
+	/**
235
+	 * @param string $tablename
236
+	 *
237
+	 * @return bool
238
+	 */
239
+	public static function tableExists($tablename)
240
+	{
241
+		$result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'");
242
+
243
+		return $GLOBALS['xoopsDB']->getRowsNum($result) > 0;
244
+	}
245 245
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
     {
60 60
         if ($considerHtml) {
61 61
             // if the plain text is shorter than the maximum length, return the whole text
62
-            if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
62
+            if (mb_strlen(\preg_replace('/<.*?'.'>/', '', $text)) <= $length) {
63 63
                 return $text;
64 64
             }
65 65
             // splits all html-tags to scanable lines
66
-            \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
66
+            \preg_match_all('/(<.+?'.'>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
67 67
             $total_length = mb_strlen($ending);
68 68
             $open_tags    = [];
69 69
             $truncate     = '';
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
                             unset($open_tags[$pos]);
82 82
                         }
83 83
                         // if tag is an opening tag
84
-                    } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) {
84
+                    } elseif (\preg_match('/^<\s*([^\s>!]+).*?'.'>$/s', $line_matchings[1], $tag_matchings)) {
85 85
                         // add tag to the beginning of $open_tags list
86 86
                         \array_unshift($open_tags, \mb_strtolower($tag_matchings[1]));
87 87
                     }
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
                 }
91 91
                 // calculate the length of the plain text part of the line; handle entities as one character
92 92
                 $content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
93
-                if ($total_length + $content_length > $length) {
93
+                if ($total_length+$content_length > $length) {
94 94
                     // the number of characters which are left
95
-                    $left            = $length - $total_length;
95
+                    $left            = $length-$total_length;
96 96
                     $entities_length = 0;
97 97
                     // search for html entities
98 98
                     if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
99 99
                         // calculate the real length of all entities in the legal range
100 100
                         foreach ($entities[0] as $entity) {
101
-                            if ($left >= $entity[1] + 1 - $entities_length) {
101
+                            if ($left >= $entity[1]+1-$entities_length) {
102 102
                                 $left--;
103 103
                                 $entities_length += mb_strlen($entity[0]);
104 104
                             } else {
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                             }
108 108
                         }
109 109
                     }
110
-                    $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length);
110
+                    $truncate .= mb_substr($line_matchings[2], 0, $left+$entities_length);
111 111
                     // maximum lenght is reached, so get off the loop
112 112
                     break;
113 113
                 }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             if (mb_strlen($text) <= $length) {
124 124
                 return $text;
125 125
             }
126
-            $truncate = mb_substr($text, 0, $length - mb_strlen($ending));
126
+            $truncate = mb_substr($text, 0, $length-mb_strlen($ending));
127 127
         }
128 128
         // if the words shouldn't be cut in the middle...
129 129
         if (!$exact) {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         if ($considerHtml) {
140 140
             // close all unclosed html-tags
141 141
             foreach ($open_tags as $tag) {
142
-                $truncate .= '</' . $tag . '>';
142
+                $truncate .= '</'.$tag.'>';
143 143
             }
144 144
         }
145 145
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         $new_id = false;
210 210
         $table  = $GLOBALS['xoopsDB']->prefix($tableName);
211 211
         // copy content of the record you wish to clone
212
-        $sql    = "SELECT * FROM $table WHERE $idField='" . $id . "' ";
212
+        $sql    = "SELECT * FROM $table WHERE $idField='".$id."' ";
213 213
         $result = $GLOBALS['xoopsDB']->query($sql);
214 214
         if ($result instanceof \mysqli_result) {
215 215
             $tempTable = $GLOBALS['xoopsDB']->fetchArray($result, \MYSQLI_ASSOC);
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
         // set the auto-incremented id's value to blank.
221 221
         unset($tempTable[$id_field]);
222 222
         // insert cloned copy of the original  record
223
-        $sql    = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", \array_values($tempTable)) . "')";
223
+        $sql    = "INSERT INTO $table (".\implode(', ', \array_keys($tempTable)).") VALUES ('".\implode("', '", \array_values($tempTable))."')";
224 224
         $result = $GLOBALS['xoopsDB']->queryF($sql);
225 225
         if (!$result) {
226 226
             \trigger_error($GLOBALS['xoopsDB']->error());
Please login to merge, or discard this patch.
class/MyiframeBaseHandler.php 2 patches
Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -15,214 +15,214 @@
 block discarded – undo
15 15
  */
16 16
 class MyiframeBaseHandler extends \XoopsObjectHandler
17 17
 {
18
-    /**
19
-     * @param bool $isNew
20
-     * @return myiframe
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 myiframe|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 \XoopsModules\Myiframe\Criteria $criteria
154
-     * @param bool                            $id_as_key
155
-     * @return array
156
-     */
157
-    public function &getObjects(\Criteria $criteria = null, $id_as_key = false)
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
-        if ($result instanceof \mysqli_result) {
172
-            while (false !== ($myrow = $this->db->fetchArray($result))) {
173
-                if (!$id_as_key) {
174
-                    $ret[] = new MyiframeBase($myrow);
175
-                } else {
176
-                    $ret[$myrow['frame_frameid']] = new MyiframeBase($myrow);
177
-                }
178
-            }
179
-        }
180
-
181
-        return $ret;
182
-    }
183
-
184
-    /**
185
-     * @param \XoopsModules\Myiframe\CriteriaCompo $criteria
186
-     * @return int
187
-     */
188
-    public function getCount(\CriteriaCompo $criteria = null)
189
-    {
190
-        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('myiframe');
191
-        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
192
-            $sql .= ' ' . $criteria->renderWhere();
193
-        }
194
-        $result = $this->db->query($sql);
195
-        if (!$result) {
196
-            return 0;
197
-        }
198
-        [$count] = $this->db->fetchRow($result);
199
-
200
-        return $count;
201
-    }
202
-
203
-    /**
204
-     * @param \XoopsModules\Myiframe\CriteriaCompo $criteria
205
-     * @return bool
206
-     */
207
-    public function deleteAll(\CriteriaCompo $criteria = null)
208
-    {
209
-        $sql = 'DELETE FROM ' . $this->db->prefix('myiframe');
210
-        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
211
-            $sql .= ' ' . $criteria->renderWhere();
212
-        }
213
-        if (!$result = $this->db->query($sql)) {
214
-            return false;
215
-        }
216
-
217
-        return true;
218
-    }
219
-
220
-    /**
221
-     * @param $frame_id
222
-     */
223
-    public function updatehits($frame_id): void
224
-    {
225
-        $sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int)$frame_id);
226
-        $this->db->queryF($sql);
227
-    }
18
+	/**
19
+	 * @param bool $isNew
20
+	 * @return myiframe
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 myiframe|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 \XoopsModules\Myiframe\Criteria $criteria
154
+	 * @param bool                            $id_as_key
155
+	 * @return array
156
+	 */
157
+	public function &getObjects(\Criteria $criteria = null, $id_as_key = false)
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
+		if ($result instanceof \mysqli_result) {
172
+			while (false !== ($myrow = $this->db->fetchArray($result))) {
173
+				if (!$id_as_key) {
174
+					$ret[] = new MyiframeBase($myrow);
175
+				} else {
176
+					$ret[$myrow['frame_frameid']] = new MyiframeBase($myrow);
177
+				}
178
+			}
179
+		}
180
+
181
+		return $ret;
182
+	}
183
+
184
+	/**
185
+	 * @param \XoopsModules\Myiframe\CriteriaCompo $criteria
186
+	 * @return int
187
+	 */
188
+	public function getCount(\CriteriaCompo $criteria = null)
189
+	{
190
+		$sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('myiframe');
191
+		if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
192
+			$sql .= ' ' . $criteria->renderWhere();
193
+		}
194
+		$result = $this->db->query($sql);
195
+		if (!$result) {
196
+			return 0;
197
+		}
198
+		[$count] = $this->db->fetchRow($result);
199
+
200
+		return $count;
201
+	}
202
+
203
+	/**
204
+	 * @param \XoopsModules\Myiframe\CriteriaCompo $criteria
205
+	 * @return bool
206
+	 */
207
+	public function deleteAll(\CriteriaCompo $criteria = null)
208
+	{
209
+		$sql = 'DELETE FROM ' . $this->db->prefix('myiframe');
210
+		if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
211
+			$sql .= ' ' . $criteria->renderWhere();
212
+		}
213
+		if (!$result = $this->db->query($sql)) {
214
+			return false;
215
+		}
216
+
217
+		return true;
218
+	}
219
+
220
+	/**
221
+	 * @param $frame_id
222
+	 */
223
+	public function updatehits($frame_id): void
224
+	{
225
+		$sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int)$frame_id);
226
+		$this->db->queryF($sql);
227
+	}
228 228
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * Copyright (c) Hervé Thouzard of Instant Zero (https://www.instant-zero.com)
9 9
  * ****************************************************************************
10 10
  */
11
-require_once XOOPS_ROOT_PATH . '/kernel/object.php';
11
+require_once XOOPS_ROOT_PATH.'/kernel/object.php';
12 12
 
13 13
 /**
14 14
  * Class MyiframeBaseHandler
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public function get($id)
37 37
     {
38 38
         $ret = null;
39
-        $sql = 'SELECT * FROM ' . $this->db->prefix('myiframe') . '  WHERE frame_frameid=' . (int)$id;
39
+        $sql = 'SELECT * FROM '.$this->db->prefix('myiframe').'  WHERE frame_frameid='.(int) $id;
40 40
         if (!$result = $this->db->query($sql)) {
41 41
             return $ret;
42 42
         }
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
     {
159 159
         $ret   = [];
160 160
         $limit = $start = 0;
161
-        $sql   = 'SELECT * FROM ' . $this->db->prefix('myiframe');
161
+        $sql   = 'SELECT * FROM '.$this->db->prefix('myiframe');
162 162
         if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
163
-            $sql .= ' ' . $criteria->renderWhere();
163
+            $sql .= ' '.$criteria->renderWhere();
164 164
             if ('' !== $criteria->getSort()) {
165
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
165
+                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
166 166
             }
167 167
             $limit = $criteria->getLimit();
168 168
             $start = $criteria->getStart();
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function getCount(\CriteriaCompo $criteria = null)
189 189
     {
190
-        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('myiframe');
190
+        $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('myiframe');
191 191
         if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
192
-            $sql .= ' ' . $criteria->renderWhere();
192
+            $sql .= ' '.$criteria->renderWhere();
193 193
         }
194 194
         $result = $this->db->query($sql);
195 195
         if (!$result) {
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
      */
207 207
     public function deleteAll(\CriteriaCompo $criteria = null)
208 208
     {
209
-        $sql = 'DELETE FROM ' . $this->db->prefix('myiframe');
209
+        $sql = 'DELETE FROM '.$this->db->prefix('myiframe');
210 210
         if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
211
-            $sql .= ' ' . $criteria->renderWhere();
211
+            $sql .= ' '.$criteria->renderWhere();
212 212
         }
213 213
         if (!$result = $this->db->query($sql)) {
214 214
             return false;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      */
223 223
     public function updatehits($frame_id): void
224 224
     {
225
-        $sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int)$frame_id);
225
+        $sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int) $frame_id);
226 226
         $this->db->queryF($sql);
227 227
     }
228 228
 }
Please login to merge, or discard this patch.
class/MyiframeBase.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -15,50 +15,50 @@
 block discarded – undo
15 15
  */
16 16
 class MyiframeBase extends \XoopsObject
17 17
 {
18
-    //    /** @var \XoopsMySQLDatabase */
19
-    public $db;
18
+	//    /** @var \XoopsMySQLDatabase */
19
+	public $db;
20 20
 
21
-    /**
22
-     * myiframe constructor.
23
-     * @param null $id
24
-     */
25
-    public function __construct($id = null)
26
-    {
27
-        $this->db = \XoopsDatabaseFactory::getDatabaseConnection();
28
-        $this->initVar('frame_frameid', \XOBJ_DTYPE_INT, null, false, 10);
29
-        $this->initVar('frame_created', \XOBJ_DTYPE_INT, null, false, 10);
30
-        $this->initVar('frame_uid', \XOBJ_DTYPE_INT, null, false, 10);
31
-        $this->initVar('frame_description', \XOBJ_DTYPE_TXTBOX, null, false, 255);
32
-        $this->initVar('frame_width', \XOBJ_DTYPE_TXTBOX, null, false, 15);
33
-        $this->initVar('frame_height', \XOBJ_DTYPE_TXTBOX, null, false, 15);
34
-        $this->initVar('frame_align', \XOBJ_DTYPE_INT, null, false, 10);
35
-        $this->initVar('frame_frameborder', \XOBJ_DTYPE_INT, null, false, 10);
36
-        $this->initVar('frame_marginwidth', \XOBJ_DTYPE_INT, null, false, 10);
37
-        $this->initVar('frame_marginheight', \XOBJ_DTYPE_INT, null, false, 10);
38
-        $this->initVar('frame_scrolling', \XOBJ_DTYPE_INT, null, false, 10);
39
-        $this->initVar('frame_hits', \XOBJ_DTYPE_INT, null, false, 10);
40
-        $this->initVar('frame_url', \XOBJ_DTYPE_TXTBOX, null, false, 255);
41
-        if (!empty($id)) {
42
-            if (\is_array($id)) {
43
-                $this->assignVars($id);
44
-            } else {
45
-                $this->load((int)$id);
46
-            }
47
-        } else {
48
-            $this->setNew();
49
-        }
50
-    }
21
+	/**
22
+	 * myiframe constructor.
23
+	 * @param null $id
24
+	 */
25
+	public function __construct($id = null)
26
+	{
27
+		$this->db = \XoopsDatabaseFactory::getDatabaseConnection();
28
+		$this->initVar('frame_frameid', \XOBJ_DTYPE_INT, null, false, 10);
29
+		$this->initVar('frame_created', \XOBJ_DTYPE_INT, null, false, 10);
30
+		$this->initVar('frame_uid', \XOBJ_DTYPE_INT, null, false, 10);
31
+		$this->initVar('frame_description', \XOBJ_DTYPE_TXTBOX, null, false, 255);
32
+		$this->initVar('frame_width', \XOBJ_DTYPE_TXTBOX, null, false, 15);
33
+		$this->initVar('frame_height', \XOBJ_DTYPE_TXTBOX, null, false, 15);
34
+		$this->initVar('frame_align', \XOBJ_DTYPE_INT, null, false, 10);
35
+		$this->initVar('frame_frameborder', \XOBJ_DTYPE_INT, null, false, 10);
36
+		$this->initVar('frame_marginwidth', \XOBJ_DTYPE_INT, null, false, 10);
37
+		$this->initVar('frame_marginheight', \XOBJ_DTYPE_INT, null, false, 10);
38
+		$this->initVar('frame_scrolling', \XOBJ_DTYPE_INT, null, false, 10);
39
+		$this->initVar('frame_hits', \XOBJ_DTYPE_INT, null, false, 10);
40
+		$this->initVar('frame_url', \XOBJ_DTYPE_TXTBOX, null, false, 255);
41
+		if (!empty($id)) {
42
+			if (\is_array($id)) {
43
+				$this->assignVars($id);
44
+			} else {
45
+				$this->load((int)$id);
46
+			}
47
+		} else {
48
+			$this->setNew();
49
+		}
50
+	}
51 51
 
52
-    /**
53
-     * @param $id
54
-     */
55
-    public function load($id): void
56
-    {
57
-        $sql   = 'SELECT * FROM ' . $this->db->prefix('myiframe') . ' WHERE frame_frameid=' . (int)$id;
58
-        $myrow = $this->db->fetchArray($this->db->query($sql));
59
-        $this->assignVars($myrow);
60
-        if (!$myrow) {
61
-            $this->setNew();
62
-        }
63
-    }
52
+	/**
53
+	 * @param $id
54
+	 */
55
+	public function load($id): void
56
+	{
57
+		$sql   = 'SELECT * FROM ' . $this->db->prefix('myiframe') . ' WHERE frame_frameid=' . (int)$id;
58
+		$myrow = $this->db->fetchArray($this->db->query($sql));
59
+		$this->assignVars($myrow);
60
+		if (!$myrow) {
61
+			$this->setNew();
62
+		}
63
+	}
64 64
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * Copyright (c) Hervé Thouzard of Instant Zero (https://www.instant-zero.com)
9 9
  * ****************************************************************************
10 10
  */
11
-require_once XOOPS_ROOT_PATH . '/kernel/object.php';
11
+require_once XOOPS_ROOT_PATH.'/kernel/object.php';
12 12
 
13 13
 /**
14 14
  * Class Myiframe
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             if (\is_array($id)) {
43 43
                 $this->assignVars($id);
44 44
             } else {
45
-                $this->load((int)$id);
45
+                $this->load((int) $id);
46 46
             }
47 47
         } else {
48 48
             $this->setNew();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function load($id): void
56 56
     {
57
-        $sql   = 'SELECT * FROM ' . $this->db->prefix('myiframe') . ' WHERE frame_frameid=' . (int)$id;
57
+        $sql   = 'SELECT * FROM '.$this->db->prefix('myiframe').' WHERE frame_frameid='.(int) $id;
58 58
         $myrow = $this->db->fetchArray($this->db->query($sql));
59 59
         $this->assignVars($myrow);
60 60
         if (!$myrow) {
Please login to merge, or discard this patch.
xoops_version.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -14,113 +14,113 @@
 block discarded – undo
14 14
 $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
15 15
 
16 16
 $modversion = [
17
-    'version'             => '1.67.0',
18
-    'module_status'       => 'Beta 1',
19
-    'release_date'        => '2022/01/26',
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.3',
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'      => '05/07/2017',
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 1',
19
+	'release_date'        => '2022/01/26',
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.3',
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'      => '05/07/2017',
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']);
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']);
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
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined.');
10 10
 
11
-require_once __DIR__ . '/preloads/autoloader.php';
11
+require_once __DIR__.'/preloads/autoloader.php';
12 12
 
13 13
 $moduleDirName      = \basename(__DIR__);
14 14
 $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 
73 73
 if (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $modversion['dirname'] && $xoopsModule->getVar('isactive')) {
74 74
     $i = 0;
75
-    require_once XOOPS_ROOT_PATH . '/modules/myiframe/include/functions.php';
75
+    require_once XOOPS_ROOT_PATH.'/modules/myiframe/include/functions.php';
76 76
     $myts = \MyTextSanitizer::getInstance();
77 77
     if (myiframe_getmoduleoption('showinmenu')) {
78
-        $sql    = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' ORDER BY frame_description';
78
+        $sql    = 'SELECT * FROM '.$GLOBALS['xoopsDB']->prefix('myiframe').' ORDER BY frame_description';
79 79
         $result = $GLOBALS['xoopsDB']->query($sql);
80 80
         while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
81 81
             if ('' !== xoops_trim($myrow['frame_description'])) {
82 82
                 $modversion['sub'][$i]['name'] = htmlspecialchars($myrow['frame_description']);
83
-                $modversion['sub'][$i]['url']  = 'index.php?iframeid=' . (int)$myrow['frame_frameid'];
83
+                $modversion['sub'][$i]['url']  = 'index.php?iframeid='.(int) $myrow['frame_frameid'];
84 84
                 $i++;
85 85
             }
86 86
         }
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 // Make Sample button visible?
108 108
 $modversion['config'][] = [
109 109
     'name'        => 'displaySampleButton',
110
-    'title'       => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON',
111
-    'description' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC',
110
+    'title'       => 'CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLE_BUTTON',
111
+    'description' => 'CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLE_BUTTON_DESC',
112 112
     'formtype'    => 'yesno',
113 113
     'valuetype'   => 'int',
114 114
     'default'     => 1,
Please login to merge, or discard this patch.