Passed
Pull Request — master (#2)
by Michael
07:10 queued 03:28
created
class/Common/SysUtility.php 2 patches
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -29,217 +29,217 @@
 block discarded – undo
29 29
  */
30 30
 class SysUtility
31 31
 {
32
-    use VersionChecks;
33
-
34
-    //checkVerXoops, checkVerPhp Traits
35
-
36
-    use ServerStats;
37
-
38
-    // getServerStats Trait
39
-
40
-    use FilesManagement;
41
-
42
-    // Files Management Trait
43
-
44
-    /**
45
-     * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags
46
-     * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags
47
-     * www.cakephp.org
48
-     *
49
-     * @param string $text         String to truncate.
50
-     * @param int    $length       Length of returned string, including ellipsis.
51
-     * @param string $ending       Ending to be appended to the trimmed string.
52
-     * @param bool   $exact        If false, $text will not be cut mid-word
53
-     * @param bool   $considerHtml If true, HTML tags would be handled correctly
54
-     *
55
-     * @return string Trimmed string.
56
-     */
57
-    public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true): string
58
-    {
59
-        if ($considerHtml) {
60
-            // if the plain text is shorter than the maximum length, return the whole text
61
-            if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
62
-                return $text;
63
-            }
64
-            // splits all html-tags to scanable lines
65
-            \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
66
-            $total_length = mb_strlen($ending);
67
-            $open_tags    = [];
68
-            $truncate     = '';
69
-            foreach ($lines as $line_matchings) {
70
-                // if there is any html-tag in this line, handle it and add it (uncounted) to the output
71
-                if (!empty($line_matchings[1])) {
72
-                    // if it's an "empty element" with or without xhtml-conform closing slash
73
-                    if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {
74
-                        // do nothing
75
-                        // if tag is a closing tag
76
-                    } elseif (\preg_match('/^<\s*\/(\S+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
77
-                        // delete tag from $open_tags list
78
-                        $pos = \array_search($tag_matchings[1], $open_tags, true);
79
-                        if (false !== $pos) {
80
-                            unset($open_tags[$pos]);
81
-                        }
82
-                        // if tag is an opening tag
83
-                    } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) {
84
-                        // add tag to the beginning of $open_tags list
85
-                        \array_unshift($open_tags, \mb_strtolower($tag_matchings[1]));
86
-                    }
87
-                    // add html-tag to $truncate'd text
88
-                    $truncate .= $line_matchings[1];
89
-                }
90
-                // calculate the length of the plain text part of the line; handle entities as one character
91
-                $content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
92
-                if ($total_length + $content_length > $length) {
93
-                    // the number of characters which are left
94
-                    $left            = $length - $total_length;
95
-                    $entities_length = 0;
96
-                    // search for html entities
97
-                    if (\preg_match_all('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
98
-                        // calculate the real length of all entities in the legal range
99
-                        foreach ($entities[0] as $entity) {
100
-                            if ($left >= $entity[1] + 1 - $entities_length) {
101
-                                $left--;
102
-                                $entities_length += mb_strlen($entity[0]);
103
-                            } else {
104
-                                // no more characters left
105
-                                break;
106
-                            }
107
-                        }
108
-                    }
109
-                    $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length);
110
-                    // maximum lenght is reached, so get off the loop
111
-                    break;
112
-                }
113
-                $truncate     .= $line_matchings[2];
114
-                $total_length += $content_length;
115
-
116
-                // if the maximum length is reached, get off the loop
117
-                if ($total_length >= $length) {
118
-                    break;
119
-                }
120
-            }
121
-        } else {
122
-            if (mb_strlen($text) <= $length) {
123
-                return $text;
124
-            }
125
-            $truncate = mb_substr($text, 0, $length - mb_strlen($ending));
126
-        }
127
-        // if the words shouldn't be cut in the middle...
128
-        if (!$exact) {
129
-            // ...search the last occurance of a space...
130
-            $spacepos = mb_strrpos($truncate, ' ');
131
-            if (isset($spacepos)) {
132
-                // ...and cut the text in this position
133
-                $truncate = mb_substr($truncate, 0, $spacepos);
134
-            }
135
-        }
136
-        // add the defined ending to the text
137
-        $truncate .= $ending;
138
-        if ($considerHtml) {
139
-            // close all unclosed html-tags
140
-            foreach ($open_tags as $tag) {
141
-                $truncate .= '</' . $tag . '>';
142
-            }
143
-        }
144
-
145
-        return $truncate;
146
-    }
147
-
148
-    /**
149
-     * @param \Xmf\Module\Helper $helper
150
-     * @param array|null         $options
151
-     * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor
152
-     */
153
-    public static function getEditor($helper = null, $options = null)
154
-    {
155
-        /** @var Helper $helper */
156
-        if (null === $options) {
157
-            $options           = [];
158
-            $options['name']   = 'Editor';
159
-            $options['value']  = 'Editor';
160
-            $options['rows']   = 10;
161
-            $options['cols']   = '100%';
162
-            $options['width']  = '100%';
163
-            $options['height'] = '400px';
164
-        }
165
-
166
-        if (null === $helper) {
167
-            $helper = Helper::getInstance();
168
-        }
169
-
170
-        $isAdmin = $helper->isUserAdmin();
171
-
172
-        if (\class_exists('XoopsFormEditor')) {
173
-            if ($isAdmin) {
174
-                $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea');
175
-            } else {
176
-                $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea');
177
-            }
178
-        } else {
179
-            $descEditor = new \XoopsFormDhtmlTextArea(\ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%');
180
-        }
181
-
182
-        //        $form->addElement($descEditor);
183
-
184
-        return $descEditor;
185
-    }
186
-
187
-    /**
188
-     * @param string $fieldname
189
-     * @param string $table
190
-     * @return bool
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): bool
240
-    {
241
-        $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'");
242
-
243
-        return $GLOBALS['xoopsDB']->getRowsNum($result) > 0;
244
-    }
32
+	use VersionChecks;
33
+
34
+	//checkVerXoops, checkVerPhp Traits
35
+
36
+	use ServerStats;
37
+
38
+	// getServerStats Trait
39
+
40
+	use FilesManagement;
41
+
42
+	// Files Management Trait
43
+
44
+	/**
45
+	 * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags
46
+	 * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags
47
+	 * www.cakephp.org
48
+	 *
49
+	 * @param string $text         String to truncate.
50
+	 * @param int    $length       Length of returned string, including ellipsis.
51
+	 * @param string $ending       Ending to be appended to the trimmed string.
52
+	 * @param bool   $exact        If false, $text will not be cut mid-word
53
+	 * @param bool   $considerHtml If true, HTML tags would be handled correctly
54
+	 *
55
+	 * @return string Trimmed string.
56
+	 */
57
+	public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true): string
58
+	{
59
+		if ($considerHtml) {
60
+			// if the plain text is shorter than the maximum length, return the whole text
61
+			if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
62
+				return $text;
63
+			}
64
+			// splits all html-tags to scanable lines
65
+			\preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
66
+			$total_length = mb_strlen($ending);
67
+			$open_tags    = [];
68
+			$truncate     = '';
69
+			foreach ($lines as $line_matchings) {
70
+				// if there is any html-tag in this line, handle it and add it (uncounted) to the output
71
+				if (!empty($line_matchings[1])) {
72
+					// if it's an "empty element" with or without xhtml-conform closing slash
73
+					if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {
74
+						// do nothing
75
+						// if tag is a closing tag
76
+					} elseif (\preg_match('/^<\s*\/(\S+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
77
+						// delete tag from $open_tags list
78
+						$pos = \array_search($tag_matchings[1], $open_tags, true);
79
+						if (false !== $pos) {
80
+							unset($open_tags[$pos]);
81
+						}
82
+						// if tag is an opening tag
83
+					} elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) {
84
+						// add tag to the beginning of $open_tags list
85
+						\array_unshift($open_tags, \mb_strtolower($tag_matchings[1]));
86
+					}
87
+					// add html-tag to $truncate'd text
88
+					$truncate .= $line_matchings[1];
89
+				}
90
+				// calculate the length of the plain text part of the line; handle entities as one character
91
+				$content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
92
+				if ($total_length + $content_length > $length) {
93
+					// the number of characters which are left
94
+					$left            = $length - $total_length;
95
+					$entities_length = 0;
96
+					// search for html entities
97
+					if (\preg_match_all('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
98
+						// calculate the real length of all entities in the legal range
99
+						foreach ($entities[0] as $entity) {
100
+							if ($left >= $entity[1] + 1 - $entities_length) {
101
+								$left--;
102
+								$entities_length += mb_strlen($entity[0]);
103
+							} else {
104
+								// no more characters left
105
+								break;
106
+							}
107
+						}
108
+					}
109
+					$truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length);
110
+					// maximum lenght is reached, so get off the loop
111
+					break;
112
+				}
113
+				$truncate     .= $line_matchings[2];
114
+				$total_length += $content_length;
115
+
116
+				// if the maximum length is reached, get off the loop
117
+				if ($total_length >= $length) {
118
+					break;
119
+				}
120
+			}
121
+		} else {
122
+			if (mb_strlen($text) <= $length) {
123
+				return $text;
124
+			}
125
+			$truncate = mb_substr($text, 0, $length - mb_strlen($ending));
126
+		}
127
+		// if the words shouldn't be cut in the middle...
128
+		if (!$exact) {
129
+			// ...search the last occurance of a space...
130
+			$spacepos = mb_strrpos($truncate, ' ');
131
+			if (isset($spacepos)) {
132
+				// ...and cut the text in this position
133
+				$truncate = mb_substr($truncate, 0, $spacepos);
134
+			}
135
+		}
136
+		// add the defined ending to the text
137
+		$truncate .= $ending;
138
+		if ($considerHtml) {
139
+			// close all unclosed html-tags
140
+			foreach ($open_tags as $tag) {
141
+				$truncate .= '</' . $tag . '>';
142
+			}
143
+		}
144
+
145
+		return $truncate;
146
+	}
147
+
148
+	/**
149
+	 * @param \Xmf\Module\Helper $helper
150
+	 * @param array|null         $options
151
+	 * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor
152
+	 */
153
+	public static function getEditor($helper = null, $options = null)
154
+	{
155
+		/** @var Helper $helper */
156
+		if (null === $options) {
157
+			$options           = [];
158
+			$options['name']   = 'Editor';
159
+			$options['value']  = 'Editor';
160
+			$options['rows']   = 10;
161
+			$options['cols']   = '100%';
162
+			$options['width']  = '100%';
163
+			$options['height'] = '400px';
164
+		}
165
+
166
+		if (null === $helper) {
167
+			$helper = Helper::getInstance();
168
+		}
169
+
170
+		$isAdmin = $helper->isUserAdmin();
171
+
172
+		if (\class_exists('XoopsFormEditor')) {
173
+			if ($isAdmin) {
174
+				$descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea');
175
+			} else {
176
+				$descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea');
177
+			}
178
+		} else {
179
+			$descEditor = new \XoopsFormDhtmlTextArea(\ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%');
180
+		}
181
+
182
+		//        $form->addElement($descEditor);
183
+
184
+		return $descEditor;
185
+	}
186
+
187
+	/**
188
+	 * @param string $fieldname
189
+	 * @param string $table
190
+	 * @return bool
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): bool
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   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
     {
59 59
         if ($considerHtml) {
60 60
             // if the plain text is shorter than the maximum length, return the whole text
61
-            if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
61
+            if (mb_strlen(\preg_replace('/<.*?'.'>/', '', $text))<=$length) {
62 62
                 return $text;
63 63
             }
64 64
             // splits all html-tags to scanable lines
65
-            \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
65
+            \preg_match_all('/(<.+?'.'>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
66 66
             $total_length = mb_strlen($ending);
67 67
             $open_tags    = [];
68 68
             $truncate     = '';
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
                     } elseif (\preg_match('/^<\s*\/(\S+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
77 77
                         // delete tag from $open_tags list
78 78
                         $pos = \array_search($tag_matchings[1], $open_tags, true);
79
-                        if (false !== $pos) {
79
+                        if (false!==$pos) {
80 80
                             unset($open_tags[$pos]);
81 81
                         }
82 82
                         // if tag is an opening tag
83
-                    } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) {
83
+                    } elseif (\preg_match('/^<\s*([^\s>!]+).*?'.'>$/s', $line_matchings[1], $tag_matchings)) {
84 84
                         // add tag to the beginning of $open_tags list
85 85
                         \array_unshift($open_tags, \mb_strtolower($tag_matchings[1]));
86 86
                     }
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
                 }
90 90
                 // calculate the length of the plain text part of the line; handle entities as one character
91 91
                 $content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
92
-                if ($total_length + $content_length > $length) {
92
+                if ($total_length+$content_length>$length) {
93 93
                     // the number of characters which are left
94
-                    $left            = $length - $total_length;
94
+                    $left            = $length-$total_length;
95 95
                     $entities_length = 0;
96 96
                     // search for html entities
97 97
                     if (\preg_match_all('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
98 98
                         // calculate the real length of all entities in the legal range
99 99
                         foreach ($entities[0] as $entity) {
100
-                            if ($left >= $entity[1] + 1 - $entities_length) {
100
+                            if ($left>=$entity[1]+1-$entities_length) {
101 101
                                 $left--;
102 102
                                 $entities_length += mb_strlen($entity[0]);
103 103
                             } else {
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                             }
107 107
                         }
108 108
                     }
109
-                    $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length);
109
+                    $truncate .= mb_substr($line_matchings[2], 0, $left+$entities_length);
110 110
                     // maximum lenght is reached, so get off the loop
111 111
                     break;
112 112
                 }
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
                 $total_length += $content_length;
115 115
 
116 116
                 // if the maximum length is reached, get off the loop
117
-                if ($total_length >= $length) {
117
+                if ($total_length>=$length) {
118 118
                     break;
119 119
                 }
120 120
             }
121 121
         } else {
122
-            if (mb_strlen($text) <= $length) {
122
+            if (mb_strlen($text)<=$length) {
123 123
                 return $text;
124 124
             }
125
-            $truncate = mb_substr($text, 0, $length - mb_strlen($ending));
125
+            $truncate = mb_substr($text, 0, $length-mb_strlen($ending));
126 126
         }
127 127
         // if the words shouldn't be cut in the middle...
128 128
         if (!$exact) {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         if ($considerHtml) {
139 139
             // close all unclosed html-tags
140 140
             foreach ($open_tags as $tag) {
141
-                $truncate .= '</' . $tag . '>';
141
+                $truncate .= '</'.$tag.'>';
142 142
             }
143 143
         }
144 144
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     public static function getEditor($helper = null, $options = null)
154 154
     {
155 155
         /** @var Helper $helper */
156
-        if (null === $options) {
156
+        if (null===$options) {
157 157
             $options           = [];
158 158
             $options['name']   = 'Editor';
159 159
             $options['value']  = 'Editor';
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             $options['height'] = '400px';
164 164
         }
165 165
 
166
-        if (null === $helper) {
166
+        if (null===$helper) {
167 167
             $helper = Helper::getInstance();
168 168
         }
169 169
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         global $xoopsDB;
195 195
         $result = $xoopsDB->queryF("SHOW COLUMNS FROM   $table LIKE '$fieldname'");
196 196
 
197
-        return ($xoopsDB->getRowsNum($result) > 0);
197
+        return ($xoopsDB->getRowsNum($result)>0);
198 198
     }
199 199
 
200 200
     /**
@@ -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());
@@ -240,6 +240,6 @@  discard block
 block discarded – undo
240 240
     {
241 241
         $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'");
242 242
 
243
-        return $GLOBALS['xoopsDB']->getRowsNum($result) > 0;
243
+        return $GLOBALS['xoopsDB']->getRowsNum($result)>0;
244 244
     }
245 245
 }
Please login to merge, or discard this patch.
class/Common/FilesManagement.php 2 patches
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -24,226 +24,226 @@
 block discarded – undo
24 24
  */
25 25
 trait FilesManagement
26 26
 {
27
-    /**
28
-     * Function responsible for checking if a directory exists, we can also write in and create an index.html file
29
-     *
30
-     * @param string $folder The full path of the directory to check
31
-     */
32
-    public static function createFolder($folder): void
33
-    {
34
-        try {
35
-            if (!\is_dir($folder)) {
36
-                if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) {
37
-                    throw new RuntimeException(\sprintf('Unable to create the %s directory', $folder));
38
-                }
39
-
40
-                file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
41
-            }
42
-        } catch (\Throwable $e) {
43
-            echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
44
-        }
45
-    }
46
-
47
-    /**
48
-     * @param string $file
49
-     * @param string $folder
50
-     * @return bool
51
-     */
52
-    public static function copyFile(string $file, string $folder): bool
53
-    {
54
-        return \copy($file, $folder);
55
-    }
56
-
57
-    /**
58
-     * @param $src
59
-     * @param $dst
60
-     */
61
-    public static function recurseCopy($src, $dst): void
62
-    {
63
-        $dir = \opendir($src);
64
-        //        @mkdir($dst);
65
-        if (!@\mkdir($dst) && !\is_dir($dst)) {
66
-            throw new RuntimeException('The directory ' . $dst . ' could not be created.');
67
-        }
68
-        while (false !== ($file = \readdir($dir))) {
69
-            if (('.' !== $file) && ('..' !== $file)) {
70
-                if (\is_dir($src . '/' . $file)) {
71
-                    self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
72
-                } else {
73
-                    \copy($src . '/' . $file, $dst . '/' . $file);
74
-                }
75
-            }
76
-        }
77
-        \closedir($dir);
78
-    }
79
-
80
-    /**
81
-     * Remove files and (sub)directories
82
-     *
83
-     * @param string $src source directory to delete
84
-     *
85
-     * @return bool true on success
86
-     * @uses \Xmf\Module\Helper::isUserAdmin()
87
-     *
88
-     * @uses \Xmf\Module\Helper::getHelper()
89
-     */
90
-    public static function deleteDirectory($src): bool
91
-    {
92
-        // Only continue if user is a 'global' Admin
93
-        if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
94
-            return false;
95
-        }
96
-
97
-        $success = true;
98
-        // remove old files
99
-        $dirInfo = new SplFileInfo($src);
100
-        // validate is a directory
101
-        if ($dirInfo->isDir()) {
102
-            $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']);
103
-            foreach ($fileList as $k => $v) {
104
-                $fileInfo = new SplFileInfo("{$src}/{$v}");
105
-                if ($fileInfo->isDir()) {
106
-                    // recursively handle subdirectories
107
-                    if (!$success = self::deleteDirectory($fileInfo->getRealPath())) {
108
-                        break;
109
-                    }
110
-                } elseif (!($success = \unlink($fileInfo->getRealPath()))) {
111
-                    break;
112
-                }
113
-            }
114
-            // now delete this (sub)directory if all the files are gone
115
-            if ($success) {
116
-                $success = \rmdir($dirInfo->getRealPath());
117
-            }
118
-        } else {
119
-            // input is not a valid directory
120
-            $success = false;
121
-        }
122
-
123
-        return $success;
124
-    }
125
-
126
-    /**
127
-     * Recursively remove directory
128
-     *
129
-     * @todo currently won't remove directories with hidden files, should it?
130
-     *
131
-     * @param string $src directory to remove (delete)
132
-     *
133
-     * @return bool true on success
134
-     */
135
-    public static function rrmdir($src): bool
136
-    {
137
-        // Only continue if user is a 'global' Admin
138
-        if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
139
-            return false;
140
-        }
141
-
142
-        // If source is not a directory stop processing
143
-        if (!\is_dir($src)) {
144
-            return false;
145
-        }
146
-
147
-        $success = true;
148
-
149
-        // Open the source directory to read in files
150
-        $iterator = new DirectoryIterator($src);
151
-        foreach ($iterator as $fObj) {
152
-            if ($fObj->isFile()) {
153
-                $filename = $fObj->getPathname();
154
-                $fObj     = null; // clear this iterator object to close the file
155
-                if (!\unlink($filename)) {
156
-                    return false; // couldn't delete the file
157
-                }
158
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
159
-                // Try recursively on directory
160
-                self::rrmdir($fObj->getPathname());
161
-            }
162
-        }
163
-        $iterator = null;   // clear iterator Obj to close file/directory
164
-
165
-        return \rmdir($src); // remove the directory & return results
166
-    }
167
-
168
-    /**
169
-     * Recursively move files from one directory to another
170
-     *
171
-     * @param string $src  - Source of files being moved
172
-     * @param string $dest - Destination of files being moved
173
-     *
174
-     * @return bool true on success
175
-     */
176
-    public static function rmove($src, $dest): bool
177
-    {
178
-        // Only continue if user is a 'global' Admin
179
-        if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
180
-            return false;
181
-        }
182
-
183
-        // If source is not a directory stop processing
184
-        if (!\is_dir($src)) {
185
-            return false;
186
-        }
187
-
188
-        // If the destination directory does not exist and could not be created stop processing
189
-        if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) {
190
-            return false;
191
-        }
192
-
193
-        // Open the source directory to read in files
194
-        $iterator = new DirectoryIterator($src);
195
-        foreach ($iterator as $fObj) {
196
-            if ($fObj->isFile()) {
197
-                \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
198
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
199
-                // Try recursively on directory
200
-                self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
201
-                //                rmdir($fObj->getPath()); // now delete the directory
202
-            }
203
-        }
204
-        $iterator = null;   // clear iterator Obj to close file/directory
205
-
206
-        return \rmdir($src); // remove the directory & return results
207
-    }
208
-
209
-    /**
210
-     * Recursively copy directories and files from one directory to another
211
-     *
212
-     * @param string $src  - Source of files being moved
213
-     * @param string $dest - Destination of files being moved
214
-     *
215
-     * @return bool true on success
216
-     * @uses \Xmf\Module\Helper::isUserAdmin()
217
-     *
218
-     * @uses \Xmf\Module\Helper::getHelper()
219
-     */
220
-    public static function rcopy($src, $dest): bool
221
-    {
222
-        // Only continue if user is a 'global' Admin
223
-        if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
224
-            return false;
225
-        }
226
-
227
-        // If source is not a directory stop processing
228
-        if (!\is_dir($src)) {
229
-            return false;
230
-        }
231
-
232
-        // If the destination directory does not exist and could not be created stop processing
233
-        if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) {
234
-            return false;
235
-        }
236
-
237
-        // Open the source directory to read in files
238
-        $iterator = new DirectoryIterator($src);
239
-        foreach ($iterator as $fObj) {
240
-            if ($fObj->isFile()) {
241
-                \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
242
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
243
-                self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
244
-            }
245
-        }
246
-
247
-        return true;
248
-    }
27
+	/**
28
+	 * Function responsible for checking if a directory exists, we can also write in and create an index.html file
29
+	 *
30
+	 * @param string $folder The full path of the directory to check
31
+	 */
32
+	public static function createFolder($folder): void
33
+	{
34
+		try {
35
+			if (!\is_dir($folder)) {
36
+				if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) {
37
+					throw new RuntimeException(\sprintf('Unable to create the %s directory', $folder));
38
+				}
39
+
40
+				file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
41
+			}
42
+		} catch (\Throwable $e) {
43
+			echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
44
+		}
45
+	}
46
+
47
+	/**
48
+	 * @param string $file
49
+	 * @param string $folder
50
+	 * @return bool
51
+	 */
52
+	public static function copyFile(string $file, string $folder): bool
53
+	{
54
+		return \copy($file, $folder);
55
+	}
56
+
57
+	/**
58
+	 * @param $src
59
+	 * @param $dst
60
+	 */
61
+	public static function recurseCopy($src, $dst): void
62
+	{
63
+		$dir = \opendir($src);
64
+		//        @mkdir($dst);
65
+		if (!@\mkdir($dst) && !\is_dir($dst)) {
66
+			throw new RuntimeException('The directory ' . $dst . ' could not be created.');
67
+		}
68
+		while (false !== ($file = \readdir($dir))) {
69
+			if (('.' !== $file) && ('..' !== $file)) {
70
+				if (\is_dir($src . '/' . $file)) {
71
+					self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
72
+				} else {
73
+					\copy($src . '/' . $file, $dst . '/' . $file);
74
+				}
75
+			}
76
+		}
77
+		\closedir($dir);
78
+	}
79
+
80
+	/**
81
+	 * Remove files and (sub)directories
82
+	 *
83
+	 * @param string $src source directory to delete
84
+	 *
85
+	 * @return bool true on success
86
+	 * @uses \Xmf\Module\Helper::isUserAdmin()
87
+	 *
88
+	 * @uses \Xmf\Module\Helper::getHelper()
89
+	 */
90
+	public static function deleteDirectory($src): bool
91
+	{
92
+		// Only continue if user is a 'global' Admin
93
+		if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
94
+			return false;
95
+		}
96
+
97
+		$success = true;
98
+		// remove old files
99
+		$dirInfo = new SplFileInfo($src);
100
+		// validate is a directory
101
+		if ($dirInfo->isDir()) {
102
+			$fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']);
103
+			foreach ($fileList as $k => $v) {
104
+				$fileInfo = new SplFileInfo("{$src}/{$v}");
105
+				if ($fileInfo->isDir()) {
106
+					// recursively handle subdirectories
107
+					if (!$success = self::deleteDirectory($fileInfo->getRealPath())) {
108
+						break;
109
+					}
110
+				} elseif (!($success = \unlink($fileInfo->getRealPath()))) {
111
+					break;
112
+				}
113
+			}
114
+			// now delete this (sub)directory if all the files are gone
115
+			if ($success) {
116
+				$success = \rmdir($dirInfo->getRealPath());
117
+			}
118
+		} else {
119
+			// input is not a valid directory
120
+			$success = false;
121
+		}
122
+
123
+		return $success;
124
+	}
125
+
126
+	/**
127
+	 * Recursively remove directory
128
+	 *
129
+	 * @todo currently won't remove directories with hidden files, should it?
130
+	 *
131
+	 * @param string $src directory to remove (delete)
132
+	 *
133
+	 * @return bool true on success
134
+	 */
135
+	public static function rrmdir($src): bool
136
+	{
137
+		// Only continue if user is a 'global' Admin
138
+		if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
139
+			return false;
140
+		}
141
+
142
+		// If source is not a directory stop processing
143
+		if (!\is_dir($src)) {
144
+			return false;
145
+		}
146
+
147
+		$success = true;
148
+
149
+		// Open the source directory to read in files
150
+		$iterator = new DirectoryIterator($src);
151
+		foreach ($iterator as $fObj) {
152
+			if ($fObj->isFile()) {
153
+				$filename = $fObj->getPathname();
154
+				$fObj     = null; // clear this iterator object to close the file
155
+				if (!\unlink($filename)) {
156
+					return false; // couldn't delete the file
157
+				}
158
+			} elseif (!$fObj->isDot() && $fObj->isDir()) {
159
+				// Try recursively on directory
160
+				self::rrmdir($fObj->getPathname());
161
+			}
162
+		}
163
+		$iterator = null;   // clear iterator Obj to close file/directory
164
+
165
+		return \rmdir($src); // remove the directory & return results
166
+	}
167
+
168
+	/**
169
+	 * Recursively move files from one directory to another
170
+	 *
171
+	 * @param string $src  - Source of files being moved
172
+	 * @param string $dest - Destination of files being moved
173
+	 *
174
+	 * @return bool true on success
175
+	 */
176
+	public static function rmove($src, $dest): bool
177
+	{
178
+		// Only continue if user is a 'global' Admin
179
+		if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
180
+			return false;
181
+		}
182
+
183
+		// If source is not a directory stop processing
184
+		if (!\is_dir($src)) {
185
+			return false;
186
+		}
187
+
188
+		// If the destination directory does not exist and could not be created stop processing
189
+		if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) {
190
+			return false;
191
+		}
192
+
193
+		// Open the source directory to read in files
194
+		$iterator = new DirectoryIterator($src);
195
+		foreach ($iterator as $fObj) {
196
+			if ($fObj->isFile()) {
197
+				\rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
198
+			} elseif (!$fObj->isDot() && $fObj->isDir()) {
199
+				// Try recursively on directory
200
+				self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
201
+				//                rmdir($fObj->getPath()); // now delete the directory
202
+			}
203
+		}
204
+		$iterator = null;   // clear iterator Obj to close file/directory
205
+
206
+		return \rmdir($src); // remove the directory & return results
207
+	}
208
+
209
+	/**
210
+	 * Recursively copy directories and files from one directory to another
211
+	 *
212
+	 * @param string $src  - Source of files being moved
213
+	 * @param string $dest - Destination of files being moved
214
+	 *
215
+	 * @return bool true on success
216
+	 * @uses \Xmf\Module\Helper::isUserAdmin()
217
+	 *
218
+	 * @uses \Xmf\Module\Helper::getHelper()
219
+	 */
220
+	public static function rcopy($src, $dest): bool
221
+	{
222
+		// Only continue if user is a 'global' Admin
223
+		if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
224
+			return false;
225
+		}
226
+
227
+		// If source is not a directory stop processing
228
+		if (!\is_dir($src)) {
229
+			return false;
230
+		}
231
+
232
+		// If the destination directory does not exist and could not be created stop processing
233
+		if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) {
234
+			return false;
235
+		}
236
+
237
+		// Open the source directory to read in files
238
+		$iterator = new DirectoryIterator($src);
239
+		foreach ($iterator as $fObj) {
240
+			if ($fObj->isFile()) {
241
+				\copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
242
+			} elseif (!$fObj->isDot() && $fObj->isDir()) {
243
+				self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
244
+			}
245
+		}
246
+
247
+		return true;
248
+	}
249 249
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
                     throw new RuntimeException(\sprintf('Unable to create the %s directory', $folder));
38 38
                 }
39 39
 
40
-                file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
40
+                file_put_contents($folder.'/index.html', '<script>history.go(-1);</script>');
41 41
             }
42 42
         } catch (\Throwable $e) {
43 43
             echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
         $dir = \opendir($src);
64 64
         //        @mkdir($dst);
65 65
         if (!@\mkdir($dst) && !\is_dir($dst)) {
66
-            throw new RuntimeException('The directory ' . $dst . ' could not be created.');
66
+            throw new RuntimeException('The directory '.$dst.' could not be created.');
67 67
         }
68
-        while (false !== ($file = \readdir($dir))) {
69
-            if (('.' !== $file) && ('..' !== $file)) {
70
-                if (\is_dir($src . '/' . $file)) {
71
-                    self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
68
+        while (false!==($file = \readdir($dir))) {
69
+            if (('.'!==$file) && ('..'!==$file)) {
70
+                if (\is_dir($src.'/'.$file)) {
71
+                    self::recurseCopy($src.'/'.$file, $dst.'/'.$file);
72 72
                 } else {
73
-                    \copy($src . '/' . $file, $dst . '/' . $file);
73
+                    \copy($src.'/'.$file, $dst.'/'.$file);
74 74
                 }
75 75
             }
76 76
         }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 self::rrmdir($fObj->getPathname());
161 161
             }
162 162
         }
163
-        $iterator = null;   // clear iterator Obj to close file/directory
163
+        $iterator = null; // clear iterator Obj to close file/directory
164 164
 
165 165
         return \rmdir($src); // remove the directory & return results
166 166
     }
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
         $iterator = new DirectoryIterator($src);
195 195
         foreach ($iterator as $fObj) {
196 196
             if ($fObj->isFile()) {
197
-                \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
197
+                \rename($fObj->getPathname(), "{$dest}/".$fObj->getFilename());
198 198
             } elseif (!$fObj->isDot() && $fObj->isDir()) {
199 199
                 // Try recursively on directory
200
-                self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
200
+                self::rmove($fObj->getPathname(), "{$dest}/".$fObj->getFilename());
201 201
                 //                rmdir($fObj->getPath()); // now delete the directory
202 202
             }
203 203
         }
204
-        $iterator = null;   // clear iterator Obj to close file/directory
204
+        $iterator = null; // clear iterator Obj to close file/directory
205 205
 
206 206
         return \rmdir($src); // remove the directory & return results
207 207
     }
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
         $iterator = new DirectoryIterator($src);
239 239
         foreach ($iterator as $fObj) {
240 240
             if ($fObj->isFile()) {
241
-                \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
241
+                \copy($fObj->getPathname(), "{$dest}/".$fObj->getFilename());
242 242
             } elseif (!$fObj->isDot() && $fObj->isDir()) {
243
-                self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
243
+                self::rcopy($fObj->getPathname(), "{$dest}/".$fObj->getFilename());
244 244
             }
245 245
         }
246 246
 
Please login to merge, or discard this patch.
class/Common/Cloner.php 2 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -9,101 +9,101 @@
 block discarded – undo
9 9
  */
10 10
 class Cloner
11 11
 {
12
-    // recursive cloning script
13
-    /**
14
-     * @param $path
15
-     */
16
-    public static function cloneFileFolder($path)
17
-    {
18
-        global $patKeys;
19
-        global $patValues;
12
+	// recursive cloning script
13
+	/**
14
+	 * @param $path
15
+	 */
16
+	public static function cloneFileFolder($path)
17
+	{
18
+		global $patKeys;
19
+		global $patValues;
20 20
 
21
-        $newPath = \str_replace($patKeys[0], $patValues[0], $path);
21
+		$newPath = \str_replace($patKeys[0], $patValues[0], $path);
22 22
 
23
-        if (\is_dir($path)) {
24
-            // create new dir
25
-            if (!\mkdir($newPath) && !\is_dir($newPath)) {
26
-                throw new \RuntimeException(\sprintf('Directory "%s" was not created', $newPath));
27
-            }
23
+		if (\is_dir($path)) {
24
+			// create new dir
25
+			if (!\mkdir($newPath) && !\is_dir($newPath)) {
26
+				throw new \RuntimeException(\sprintf('Directory "%s" was not created', $newPath));
27
+			}
28 28
 
29
-            // check all files in dir, and process it
30
-            $handle = \opendir($path);
31
-            if (false !== $handle) {
32
-                while (false !== ($file = \readdir($handle))) {
33
-                    if (0 !== \mb_strpos($file, '.')) {
34
-                        self::cloneFileFolder("{$path}/{$file}");
35
-                    }
36
-                }
37
-                \closedir($handle);
38
-            }
39
-        } else {
40
-            $noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf'];
41
-            if (\in_array(\mb_strtolower((string)\pathinfo($path, \PATHINFO_EXTENSION)), $noChangeExtensions, true)) {
42
-                // image
43
-                \copy($path, $newPath);
44
-            } else {
45
-                // file, read it
46
-                $content = file_get_contents($path);
47
-                $content = \str_replace($patKeys, $patValues, $content);
48
-                file_put_contents($newPath, $content);
49
-            }
50
-        }
51
-    }
29
+			// check all files in dir, and process it
30
+			$handle = \opendir($path);
31
+			if (false !== $handle) {
32
+				while (false !== ($file = \readdir($handle))) {
33
+					if (0 !== \mb_strpos($file, '.')) {
34
+						self::cloneFileFolder("{$path}/{$file}");
35
+					}
36
+				}
37
+				\closedir($handle);
38
+			}
39
+		} else {
40
+			$noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf'];
41
+			if (\in_array(\mb_strtolower((string)\pathinfo($path, \PATHINFO_EXTENSION)), $noChangeExtensions, true)) {
42
+				// image
43
+				\copy($path, $newPath);
44
+			} else {
45
+				// file, read it
46
+				$content = file_get_contents($path);
47
+				$content = \str_replace($patKeys, $patValues, $content);
48
+				file_put_contents($newPath, $content);
49
+			}
50
+		}
51
+	}
52 52
 
53
-    /**
54
-     * @param $dirname
55
-     *
56
-     * @return bool
57
-     */
58
-    public static function createLogo($dirname): bool
59
-    {
60
-        if (!\extension_loaded('gd')) {
61
-            return false;
62
-        }
63
-        $requiredFunctions = [
64
-            'imagecreatefrompng',
65
-            'imagecolorallocate',
66
-            'imagefilledrectangle',
67
-            'imagepng',
68
-            'imagedestroy',
69
-            'imagefttext',
70
-            'imagealphablending',
71
-            'imagesavealpha',
72
-        ];
73
-        foreach ($requiredFunctions as $func) {
74
-            if (!\function_exists($func)) {
75
-                return false;
76
-            }
77
-        }
78
-        //            unset($func);
53
+	/**
54
+	 * @param $dirname
55
+	 *
56
+	 * @return bool
57
+	 */
58
+	public static function createLogo($dirname): bool
59
+	{
60
+		if (!\extension_loaded('gd')) {
61
+			return false;
62
+		}
63
+		$requiredFunctions = [
64
+			'imagecreatefrompng',
65
+			'imagecolorallocate',
66
+			'imagefilledrectangle',
67
+			'imagepng',
68
+			'imagedestroy',
69
+			'imagefttext',
70
+			'imagealphablending',
71
+			'imagesavealpha',
72
+		];
73
+		foreach ($requiredFunctions as $func) {
74
+			if (!\function_exists($func)) {
75
+				return false;
76
+			}
77
+		}
78
+		//            unset($func);
79 79
 
80
-        if (!\file_exists($imageBase = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'))
81
-            || !\file_exists($font = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/VeraBd.ttf'))) {
82
-            return false;
83
-        }
80
+		if (!\file_exists($imageBase = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'))
81
+			|| !\file_exists($font = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/VeraBd.ttf'))) {
82
+			return false;
83
+		}
84 84
 
85
-        $imageModule = \imagecreatefrompng($imageBase);
86
-        // save existing alpha channel
87
-        imagealphablending($imageModule, false);
88
-        imagesavealpha($imageModule, true);
85
+		$imageModule = \imagecreatefrompng($imageBase);
86
+		// save existing alpha channel
87
+		imagealphablending($imageModule, false);
88
+		imagesavealpha($imageModule, true);
89 89
 
90
-        //Erase old text
91
-        $greyColor = \imagecolorallocate($imageModule, 237, 237, 237);
92
-        \imagefilledrectangle($imageModule, 5, 35, 85, 46, $greyColor);
90
+		//Erase old text
91
+		$greyColor = \imagecolorallocate($imageModule, 237, 237, 237);
92
+		\imagefilledrectangle($imageModule, 5, 35, 85, 46, $greyColor);
93 93
 
94
-        // Write text
95
-        $textColor     = \imagecolorallocate($imageModule, 0, 0, 0);
96
-        $spaceToBorder = (int)((80 - \mb_strlen($dirname) * 6.5) / 2);
97
-        \imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, \ucfirst($dirname), []);
94
+		// Write text
95
+		$textColor     = \imagecolorallocate($imageModule, 0, 0, 0);
96
+		$spaceToBorder = (int)((80 - \mb_strlen($dirname) * 6.5) / 2);
97
+		\imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, \ucfirst($dirname), []);
98 98
 
99
-        // Set transparency color
100
-        //$white = imagecolorallocatealpha($imageModule, 255, 255, 255, 127);
101
-        //imagefill($imageModule, 0, 0, $white);
102
-        //imagecolortransparent($imageModule, $white);
99
+		// Set transparency color
100
+		//$white = imagecolorallocatealpha($imageModule, 255, 255, 255, 127);
101
+		//imagefill($imageModule, 0, 0, $white);
102
+		//imagecolortransparent($imageModule, $white);
103 103
 
104
-        \imagepng($imageModule, $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'));
105
-        \imagedestroy($imageModule);
104
+		\imagepng($imageModule, $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'));
105
+		\imagedestroy($imageModule);
106 106
 
107
-        return true;
108
-    }
107
+		return true;
108
+	}
109 109
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
             // check all files in dir, and process it
30 30
             $handle = \opendir($path);
31
-            if (false !== $handle) {
32
-                while (false !== ($file = \readdir($handle))) {
33
-                    if (0 !== \mb_strpos($file, '.')) {
31
+            if (false!==$handle) {
32
+                while (false!==($file = \readdir($handle))) {
33
+                    if (0!==\mb_strpos($file, '.')) {
34 34
                         self::cloneFileFolder("{$path}/{$file}");
35 35
                     }
36 36
                 }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             }
39 39
         } else {
40 40
             $noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf'];
41
-            if (\in_array(\mb_strtolower((string)\pathinfo($path, \PATHINFO_EXTENSION)), $noChangeExtensions, true)) {
41
+            if (\in_array(\mb_strtolower((string) \pathinfo($path, \PATHINFO_EXTENSION)), $noChangeExtensions, true)) {
42 42
                 // image
43 43
                 \copy($path, $newPath);
44 44
             } else {
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
         }
78 78
         //            unset($func);
79 79
 
80
-        if (!\file_exists($imageBase = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'))
81
-            || !\file_exists($font = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/VeraBd.ttf'))) {
80
+        if (!\file_exists($imageBase = $GLOBALS['xoops']->path('modules/'.$dirname.'/assets/images/logoModule.png'))
81
+            || !\file_exists($font = $GLOBALS['xoops']->path('modules/'.$dirname.'/assets/images/VeraBd.ttf'))) {
82 82
             return false;
83 83
         }
84 84
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
         // Write text
95 95
         $textColor     = \imagecolorallocate($imageModule, 0, 0, 0);
96
-        $spaceToBorder = (int)((80 - \mb_strlen($dirname) * 6.5) / 2);
96
+        $spaceToBorder = (int) ((80-\mb_strlen($dirname)*6.5)/2);
97 97
         \imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, \ucfirst($dirname), []);
98 98
 
99 99
         // Set transparency color
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         //imagefill($imageModule, 0, 0, $white);
102 102
         //imagecolortransparent($imageModule, $white);
103 103
 
104
-        \imagepng($imageModule, $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'));
104
+        \imagepng($imageModule, $GLOBALS['xoops']->path('modules/'.$dirname.'/assets/images/logoModule.png'));
105 105
         \imagedestroy($imageModule);
106 106
 
107 107
         return true;
Please login to merge, or discard this patch.
class/Common/Blocksadmin.php 2 patches
Indentation   +637 added lines, -637 removed lines patch added patch discarded remove patch
@@ -25,260 +25,260 @@  discard block
 block discarded – undo
25 25
  */
26 26
 class Blocksadmin
27 27
 {
28
-    /**
29
-     * @var \XoopsMySQLDatabase|null
30
-     */
31
-    public $db;
32
-    public $helper;
33
-    public $moduleDirName;
34
-    public $moduleDirNameUpper;
35
-
36
-    /**
37
-     * Blocksadmin constructor.
38
-     */
39
-    public function __construct(?\XoopsDatabase $db, Helper $helper)
40
-    {
41
-        if (null === $db) {
42
-            $db = \XoopsDatabaseFactory::getDatabaseConnection();
43
-        }
44
-        $this->db                 = $db;
45
-        $this->helper             = $helper;
46
-        $this->moduleDirName      = \basename(\dirname(__DIR__, 2));
47
-        $this->moduleDirNameUpper = \mb_strtoupper($this->moduleDirName);
48
-        \xoops_loadLanguage('admin', 'system');
49
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
50
-        \xoops_loadLanguage('admin/groups', 'system');
51
-        \xoops_loadLanguage('common', $this->moduleDirName);
52
-        \xoops_loadLanguage('blocksadmin', $this->moduleDirName);
53
-    }
54
-
55
-    public function listBlocks(): void
56
-    {
57
-        global $xoopsModule, $pathIcon16;
58
-        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
59
-        //        xoops_loadLanguage('admin', 'system');
60
-        //        xoops_loadLanguage('admin/blocksadmin', 'system');
61
-        //        xoops_loadLanguage('admin/groups', 'system');
62
-        //        xoops_loadLanguage('common', $moduleDirName);
63
-        //        xoops_loadLanguage('blocks', $moduleDirName);
64
-
65
-        /** @var \XoopsModuleHandler $moduleHandler */
66
-        $moduleHandler = \xoops_getHandler('module');
67
-        /** @var \XoopsMemberHandler $memberHandler */
68
-        $memberHandler = \xoops_getHandler('member');
69
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
70
-        $grouppermHandler = \xoops_getHandler('groupperm');
71
-        $groups           = $memberHandler->getGroups();
72
-        $criteria         = new \CriteriaCompo(new \Criteria('hasmain', 1));
73
-        $criteria->add(new \Criteria('isactive', 1));
74
-        $moduleList     = $moduleHandler->getList($criteria);
75
-        $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
76
-        $moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
77
-        \ksort($moduleList);
78
-        echo "
28
+	/**
29
+	 * @var \XoopsMySQLDatabase|null
30
+	 */
31
+	public $db;
32
+	public $helper;
33
+	public $moduleDirName;
34
+	public $moduleDirNameUpper;
35
+
36
+	/**
37
+	 * Blocksadmin constructor.
38
+	 */
39
+	public function __construct(?\XoopsDatabase $db, Helper $helper)
40
+	{
41
+		if (null === $db) {
42
+			$db = \XoopsDatabaseFactory::getDatabaseConnection();
43
+		}
44
+		$this->db                 = $db;
45
+		$this->helper             = $helper;
46
+		$this->moduleDirName      = \basename(\dirname(__DIR__, 2));
47
+		$this->moduleDirNameUpper = \mb_strtoupper($this->moduleDirName);
48
+		\xoops_loadLanguage('admin', 'system');
49
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
50
+		\xoops_loadLanguage('admin/groups', 'system');
51
+		\xoops_loadLanguage('common', $this->moduleDirName);
52
+		\xoops_loadLanguage('blocksadmin', $this->moduleDirName);
53
+	}
54
+
55
+	public function listBlocks(): void
56
+	{
57
+		global $xoopsModule, $pathIcon16;
58
+		require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
59
+		//        xoops_loadLanguage('admin', 'system');
60
+		//        xoops_loadLanguage('admin/blocksadmin', 'system');
61
+		//        xoops_loadLanguage('admin/groups', 'system');
62
+		//        xoops_loadLanguage('common', $moduleDirName);
63
+		//        xoops_loadLanguage('blocks', $moduleDirName);
64
+
65
+		/** @var \XoopsModuleHandler $moduleHandler */
66
+		$moduleHandler = \xoops_getHandler('module');
67
+		/** @var \XoopsMemberHandler $memberHandler */
68
+		$memberHandler = \xoops_getHandler('member');
69
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
70
+		$grouppermHandler = \xoops_getHandler('groupperm');
71
+		$groups           = $memberHandler->getGroups();
72
+		$criteria         = new \CriteriaCompo(new \Criteria('hasmain', 1));
73
+		$criteria->add(new \Criteria('isactive', 1));
74
+		$moduleList     = $moduleHandler->getList($criteria);
75
+		$moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
76
+		$moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
77
+		\ksort($moduleList);
78
+		echo "
79 79
         <h4 style='text-align:left;'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
80
-        echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>";
81
-        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
82
-        echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
80
+		echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>";
81
+		echo $GLOBALS['xoopsSecurity']->getTokenHTML();
82
+		echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
83 83
         <tr valign='middle'><th align='center'>"
84
-             . \_AM_SYSTEM_BLOCKS_TITLE
85
-             . "</th><th align='center' nowrap='nowrap'>"
86
-             . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'SIDE')
87
-             . '<br>'
88
-             . _LEFT
89
-             . '-'
90
-             . _CENTER
91
-             . '-'
92
-             . _RIGHT
93
-             . "</th><th align='center'>"
94
-             . \constant(
95
-                 'CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'
96
-             )
97
-             . "</th><th align='center'>"
98
-             . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE')
99
-             . "</th><th align='center'>"
100
-             . \_AM_SYSTEM_BLOCKS_VISIBLEIN
101
-             . "</th><th align='center'>"
102
-             . \_AM_SYSTEM_ADGS
103
-             . "</th><th align='center'>"
104
-             . \_AM_SYSTEM_BLOCKS_BCACHETIME
105
-             . "</th><th align='center'>"
106
-             . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'ACTION')
107
-             . '</th></tr>
84
+			 . \_AM_SYSTEM_BLOCKS_TITLE
85
+			 . "</th><th align='center' nowrap='nowrap'>"
86
+			 . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'SIDE')
87
+			 . '<br>'
88
+			 . _LEFT
89
+			 . '-'
90
+			 . _CENTER
91
+			 . '-'
92
+			 . _RIGHT
93
+			 . "</th><th align='center'>"
94
+			 . \constant(
95
+				 'CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'
96
+			 )
97
+			 . "</th><th align='center'>"
98
+			 . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE')
99
+			 . "</th><th align='center'>"
100
+			 . \_AM_SYSTEM_BLOCKS_VISIBLEIN
101
+			 . "</th><th align='center'>"
102
+			 . \_AM_SYSTEM_ADGS
103
+			 . "</th><th align='center'>"
104
+			 . \_AM_SYSTEM_BLOCKS_BCACHETIME
105
+			 . "</th><th align='center'>"
106
+			 . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'ACTION')
107
+			 . '</th></tr>
108 108
         ';
109
-        $blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
110
-        $blockCount = \count($blockArray);
111
-        $class      = 'even';
112
-        $cachetimes = [
113
-            0       => _NOCACHE,
114
-            30      => \sprintf(_SECONDS, 30),
115
-            60      => _MINUTE,
116
-            300     => \sprintf(_MINUTES, 5),
117
-            1800    => \sprintf(_MINUTES, 30),
118
-            3600    => _HOUR,
119
-            18000   => \sprintf(_HOURS, 5),
120
-            86400   => _DAY,
121
-            259200  => \sprintf(_DAYS, 3),
122
-            604800  => _WEEK,
123
-            2592000 => _MONTH,
124
-        ];
125
-        foreach ($blockArray as $i) {
126
-            $groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
127
-            $sql               = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
128
-            $result            = $this->db->query($sql);
129
-            $modules           = [];
130
-            if (!$result instanceof \mysqli_result) {
131
-                \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR);
132
-            }
133
-            while (false !== ($row = $this->db->fetchArray($result))) {
134
-                $modules[] = (int)$row['module_id'];
135
-            }
136
-
137
-            $cachetimeOptions = '';
138
-            foreach ($cachetimes as $cachetime => $cachetimeName) {
139
-                if ($i->getVar('bcachetime') == $cachetime) {
140
-                    $cachetimeOptions .= "<option value='$cachetime' selected='selected'>$cachetimeName</option>\n";
141
-                } else {
142
-                    $cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n";
143
-                }
144
-            }
145
-
146
-            $ssel7 = '';
147
-            $ssel6 = $ssel7;
148
-            $ssel5 = $ssel6;
149
-            $ssel4 = $ssel5;
150
-            $ssel3 = $ssel4;
151
-            $ssel2 = $ssel3;
152
-            $ssel1 = $ssel2;
153
-            $ssel0 = $ssel1;
154
-            $sel1  = $ssel0;
155
-            $sel0  = $sel1;
156
-            if (1 === $i->getVar('visible')) {
157
-                $sel1 = ' checked';
158
-            } else {
159
-                $sel0 = ' checked';
160
-            }
161
-            if (\XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) {
162
-                $ssel0 = ' checked';
163
-            } elseif (\XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) {
164
-                $ssel1 = ' checked';
165
-            } elseif (\XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) {
166
-                $ssel2 = ' checked';
167
-            } elseif (\XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) {
168
-                $ssel4 = ' checked';
169
-            } elseif (\XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) {
170
-                $ssel3 = ' checked';
171
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) {
172
-                $ssel5 = ' checked';
173
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) {
174
-                $ssel6 = ' checked';
175
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) {
176
-                $ssel7 = ' checked';
177
-            }
178
-            if ('' === $i->getVar('title')) {
179
-                $title = '&nbsp;';
180
-            } else {
181
-                $title = $i->getVar('title');
182
-            }
183
-            $name = $i->getVar('name');
184
-            echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title["
185
-                 . $i->getVar('bid')
186
-                 . "]' value='"
187
-                 . $title
188
-                 . "'></td><td class='$class' align='center' nowrap='nowrap'>
109
+		$blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
110
+		$blockCount = \count($blockArray);
111
+		$class      = 'even';
112
+		$cachetimes = [
113
+			0       => _NOCACHE,
114
+			30      => \sprintf(_SECONDS, 30),
115
+			60      => _MINUTE,
116
+			300     => \sprintf(_MINUTES, 5),
117
+			1800    => \sprintf(_MINUTES, 30),
118
+			3600    => _HOUR,
119
+			18000   => \sprintf(_HOURS, 5),
120
+			86400   => _DAY,
121
+			259200  => \sprintf(_DAYS, 3),
122
+			604800  => _WEEK,
123
+			2592000 => _MONTH,
124
+		];
125
+		foreach ($blockArray as $i) {
126
+			$groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
127
+			$sql               = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
128
+			$result            = $this->db->query($sql);
129
+			$modules           = [];
130
+			if (!$result instanceof \mysqli_result) {
131
+				\trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR);
132
+			}
133
+			while (false !== ($row = $this->db->fetchArray($result))) {
134
+				$modules[] = (int)$row['module_id'];
135
+			}
136
+
137
+			$cachetimeOptions = '';
138
+			foreach ($cachetimes as $cachetime => $cachetimeName) {
139
+				if ($i->getVar('bcachetime') == $cachetime) {
140
+					$cachetimeOptions .= "<option value='$cachetime' selected='selected'>$cachetimeName</option>\n";
141
+				} else {
142
+					$cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n";
143
+				}
144
+			}
145
+
146
+			$ssel7 = '';
147
+			$ssel6 = $ssel7;
148
+			$ssel5 = $ssel6;
149
+			$ssel4 = $ssel5;
150
+			$ssel3 = $ssel4;
151
+			$ssel2 = $ssel3;
152
+			$ssel1 = $ssel2;
153
+			$ssel0 = $ssel1;
154
+			$sel1  = $ssel0;
155
+			$sel0  = $sel1;
156
+			if (1 === $i->getVar('visible')) {
157
+				$sel1 = ' checked';
158
+			} else {
159
+				$sel0 = ' checked';
160
+			}
161
+			if (\XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) {
162
+				$ssel0 = ' checked';
163
+			} elseif (\XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) {
164
+				$ssel1 = ' checked';
165
+			} elseif (\XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) {
166
+				$ssel2 = ' checked';
167
+			} elseif (\XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) {
168
+				$ssel4 = ' checked';
169
+			} elseif (\XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) {
170
+				$ssel3 = ' checked';
171
+			} elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) {
172
+				$ssel5 = ' checked';
173
+			} elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) {
174
+				$ssel6 = ' checked';
175
+			} elseif (\XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) {
176
+				$ssel7 = ' checked';
177
+			}
178
+			if ('' === $i->getVar('title')) {
179
+				$title = '&nbsp;';
180
+			} else {
181
+				$title = $i->getVar('title');
182
+			}
183
+			$name = $i->getVar('name');
184
+			echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title["
185
+				 . $i->getVar('bid')
186
+				 . "]' value='"
187
+				 . $title
188
+				 . "'></td><td class='$class' align='center' nowrap='nowrap'>
189 189
                     <div align='center' >
190 190
                     <input type='radio' name='side["
191
-                 . $i->getVar('bid')
192
-                 . "]' value='"
193
-                 . \XOOPS_CENTERBLOCK_LEFT
194
-                 . "'$ssel2>
191
+				 . $i->getVar('bid')
192
+				 . "]' value='"
193
+				 . \XOOPS_CENTERBLOCK_LEFT
194
+				 . "'$ssel2>
195 195
                         <input type='radio' name='side["
196
-                 . $i->getVar('bid')
197
-                 . "]' value='"
198
-                 . \XOOPS_CENTERBLOCK_CENTER
199
-                 . "'$ssel3>
196
+				 . $i->getVar('bid')
197
+				 . "]' value='"
198
+				 . \XOOPS_CENTERBLOCK_CENTER
199
+				 . "'$ssel3>
200 200
                     <input type='radio' name='side["
201
-                 . $i->getVar('bid')
202
-                 . "]' value='"
203
-                 . \XOOPS_CENTERBLOCK_RIGHT
204
-                 . "'$ssel4>
201
+				 . $i->getVar('bid')
202
+				 . "]' value='"
203
+				 . \XOOPS_CENTERBLOCK_RIGHT
204
+				 . "'$ssel4>
205 205
                     </div>
206 206
                     <div>
207 207
                         <span style='float:right;'><input type='radio' name='side["
208
-                 . $i->getVar('bid')
209
-                 . "]' value='"
210
-                 . \XOOPS_SIDEBLOCK_RIGHT
211
-                 . "'$ssel1></span>
208
+				 . $i->getVar('bid')
209
+				 . "]' value='"
210
+				 . \XOOPS_SIDEBLOCK_RIGHT
211
+				 . "'$ssel1></span>
212 212
                     <div align='left'><input type='radio' name='side["
213
-                 . $i->getVar('bid')
214
-                 . "]' value='"
215
-                 . \XOOPS_SIDEBLOCK_LEFT
216
-                 . "'$ssel0></div>
213
+				 . $i->getVar('bid')
214
+				 . "]' value='"
215
+				 . \XOOPS_SIDEBLOCK_LEFT
216
+				 . "'$ssel0></div>
217 217
                     </div>
218 218
                     <div align='center'>
219 219
                     <input type='radio' name='side["
220
-                 . $i->getVar('bid')
221
-                 . "]' value='"
222
-                 . \XOOPS_CENTERBLOCK_BOTTOMLEFT
223
-                 . "'$ssel5>
220
+				 . $i->getVar('bid')
221
+				 . "]' value='"
222
+				 . \XOOPS_CENTERBLOCK_BOTTOMLEFT
223
+				 . "'$ssel5>
224 224
                         <input type='radio' name='side["
225
-                 . $i->getVar('bid')
226
-                 . "]' value='"
227
-                 . \XOOPS_CENTERBLOCK_BOTTOM
228
-                 . "'$ssel7>
225
+				 . $i->getVar('bid')
226
+				 . "]' value='"
227
+				 . \XOOPS_CENTERBLOCK_BOTTOM
228
+				 . "'$ssel7>
229 229
                     <input type='radio' name='side["
230
-                 . $i->getVar('bid')
231
-                 . "]' value='"
232
-                 . \XOOPS_CENTERBLOCK_BOTTOMRIGHT
233
-                 . "'$ssel6>
230
+				 . $i->getVar('bid')
231
+				 . "]' value='"
232
+				 . \XOOPS_CENTERBLOCK_BOTTOMRIGHT
233
+				 . "'$ssel6>
234 234
                     </div>
235 235
                 </td><td class='$class' align='center'><input type='text' name='weight["
236
-                 . $i->getVar('bid')
237
-                 . "]' value='"
238
-                 . $i->getVar('weight')
239
-                 . "' size='5' maxlength='5'></td><td class='$class' align='center' nowrap><input type='radio' name='visible["
240
-                 . $i->getVar('bid')
241
-                 . "]' value='1'$sel1>"
242
-                 . _YES
243
-                 . "&nbsp;<input type='radio' name='visible["
244
-                 . $i->getVar('bid')
245
-                 . "]' value='0'$sel0>"
246
-                 . _NO
247
-                 . '</td>';
248
-
249
-            echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
250
-            foreach ($moduleList as $k => $v) {
251
-                echo "<option value='$k'" . (\in_array($k, $modules, true) ? " selected='selected'" : '') . ">$v</option>";
252
-            }
253
-            echo '</select></td>';
254
-
255
-            echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
256
-            foreach ($groups as $grp) {
257
-                echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions, true) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
258
-            }
259
-            echo '</select></td>';
260
-
261
-            // Cache lifetime
262
-            echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select>
236
+				 . $i->getVar('bid')
237
+				 . "]' value='"
238
+				 . $i->getVar('weight')
239
+				 . "' size='5' maxlength='5'></td><td class='$class' align='center' nowrap><input type='radio' name='visible["
240
+				 . $i->getVar('bid')
241
+				 . "]' value='1'$sel1>"
242
+				 . _YES
243
+				 . "&nbsp;<input type='radio' name='visible["
244
+				 . $i->getVar('bid')
245
+				 . "]' value='0'$sel0>"
246
+				 . _NO
247
+				 . '</td>';
248
+
249
+			echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
250
+			foreach ($moduleList as $k => $v) {
251
+				echo "<option value='$k'" . (\in_array($k, $modules, true) ? " selected='selected'" : '') . ">$v</option>";
252
+			}
253
+			echo '</select></td>';
254
+
255
+			echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
256
+			foreach ($groups as $grp) {
257
+				echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions, true) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
258
+			}
259
+			echo '</select></td>';
260
+
261
+			// Cache lifetime
262
+			echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select>
263 263
                                     </td>';
264 264
 
265
-            // Actions
265
+			// Actions
266 266
 
267
-            echo "<td class='$class' align='center'>
267
+			echo "<td class='$class' align='center'>
268 268
                 <a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'></a> 
269 269
                 <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'></a>";
270
-            //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
271
-            //                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 . "'>
272
-            //                     </a>";
273
-            //            }
274
-
275
-            //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
276
-            if (!\in_array($i->getVar('block_type'), ['M', 'S'], true)) {
277
-                echo "&nbsp;
270
+			//            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
271
+			//                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 . "'>
272
+			//                     </a>";
273
+			//            }
274
+
275
+			//            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
276
+			if (!\in_array($i->getVar('block_type'), ['M', 'S'], true)) {
277
+				echo "&nbsp;
278 278
                 <a href='blocksadmin.php?op=delete&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
279 279
                      </a>";
280
-            }
281
-            echo "
280
+			}
281
+			echo "
282 282
             <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'>
283 283
             <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'>
284 284
             <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'>
@@ -288,418 +288,418 @@  discard block
 block discarded – undo
288 288
             <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'>
289 289
             </td></tr>
290 290
             ";
291
-            $class = ('even' === $class) ? 'odd' : 'even';
292
-        }
293
-        echo "<tr><td class='foot' align='center' colspan='8'>
291
+			$class = ('even' === $class) ? 'odd' : 'even';
292
+		}
293
+		echo "<tr><td class='foot' align='center' colspan='8'>
294 294
         <input type='hidden' name='op' value='order'>
295 295
         " . $GLOBALS['xoopsSecurity']->getTokenHTML() . "
296 296
         <input type='submit' name='submit' value='" . _SUBMIT . "'>
297 297
         </td></tr></table>
298 298
         </form>
299 299
         <br><br>";
300
-    }
301
-
302
-    public function deleteBlock(int $bid): void
303
-    {
304
-        //        \xoops_cp_header();
305
-
306
-        \xoops_loadLanguage('admin', 'system');
307
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
308
-        \xoops_loadLanguage('admin/groups', 'system');
309
-
310
-        $myblock = new \XoopsBlock($bid);
311
-
312
-        $sql = \sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), $bid);
313
-        $this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
314
-
315
-        $sql = \sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
316
-        $this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
317
-
318
-        $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
319
-    }
320
-
321
-    public function cloneBlock(int $bid): void
322
-    {
323
-        //require __DIR__ . '/admin_header.php';
324
-        //        \xoops_cp_header();
325
-
326
-        \xoops_loadLanguage('admin', 'system');
327
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
328
-        \xoops_loadLanguage('admin/groups', 'system');
329
-
330
-        $myblock = new \XoopsBlock($bid);
331
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
332
-        $result  = $this->db->query($sql);
333
-        $modules = [];
334
-        if ($result instanceof \mysqli_result) {
335
-            while (false !== ($row = $this->db->fetchArray($result))) {
336
-                $modules[] = (int)$row['module_id'];
337
-            }
338
-        }
339
-        $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E'], true);
340
-        $block    = [
341
-            'title'      => $myblock->getVar('title') . ' Clone',
342
-            'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
343
-            'name'       => $myblock->getVar('name'),
344
-            'side'       => $myblock->getVar('side'),
345
-            'weight'     => $myblock->getVar('weight'),
346
-            'visible'    => $myblock->getVar('visible'),
347
-            'content'    => $myblock->getVar('content', 'N'),
348
-            'modules'    => $modules,
349
-            'is_custom'  => $isCustom,
350
-            'ctype'      => $myblock->getVar('c_type'),
351
-            'bcachetime' => $myblock->getVar('bcachetime'),
352
-            'op'         => 'clone_ok',
353
-            'bid'        => $myblock->getVar('bid'),
354
-            'edit_form'  => $myblock->getOptions(),
355
-            'template'   => $myblock->getVar('template'),
356
-            'options'    => $myblock->getVar('options'),
357
-        ];
358
-        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>';
359
-        //        $form = new Blockform();
360
-        //        $form->render();
361
-
362
-        echo $this->render($block);
363
-        //        xoops_cp_footer();
364
-        //        require_once __DIR__ . '/admin_footer.php';
365
-        //        exit();
366
-    }
367
-
368
-    /**
369
-     * @param null|array|string $options
370
-     */
371
-    public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
372
-    {
373
-        \xoops_loadLanguage('admin', 'system');
374
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
375
-        \xoops_loadLanguage('admin/groups', 'system');
376
-
377
-        $block = new \XoopsBlock($bid);
378
-        $clone = $block->xoopsClone();
379
-        if (empty($bmodule)) {
380
-            //            \xoops_cp_header();
381
-            \xoops_error(\sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
382
-            \xoops_cp_footer();
383
-            exit();
384
-        }
385
-        $clone->setVar('side', $bside);
386
-        $clone->setVar('weight', $bweight);
387
-        $clone->setVar('visible', $bvisible);
388
-        //$clone->setVar('content', $_POST['bcontent']);
389
-        $clone->setVar('title', Request::getString('btitle', '', 'POST'));
390
-        $clone->setVar('bcachetime', $bcachetime);
391
-        if (\is_array($options) && (\count($options) > 0)) {
392
-            $options = \implode('|', $options);
393
-            $clone->setVar('options', $options);
394
-        }
395
-        $clone->setVar('bid', 0);
396
-        if (\in_array($block->getVar('block_type'), ['C', 'E'], true)) {
397
-            $clone->setVar('block_type', 'E');
398
-        } else {
399
-            $clone->setVar('block_type', 'D');
400
-        }
401
-        //        $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105
402
-        if ($clone->store()) {
403
-            $newid = $clone->id();  //get the id of the cloned block
404
-        }
405
-        if (!$newid) {
406
-            //            \xoops_cp_header();
407
-            $clone->getHtmlErrors();
408
-            \xoops_cp_footer();
409
-            exit();
410
-        }
411
-        if ('' !== $clone->getVar('template')) {
412
-            /** @var \XoopsTplfileHandler $tplfileHandler */
413
-            $tplfileHandler = \xoops_getHandler('tplfile');
414
-            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string)$bid);
415
-            if (\count($btemplate) > 0) {
416
-                $tplclone = $btemplate[0]->xoopsClone();
417
-                $tplclone->setVar('tpl_id', 0);
418
-                $tplclone->setVar('tpl_refid', $newid);
419
-                $tplfileHandler->insert($tplclone);
420
-            }
421
-        }
422
-
423
-        foreach ($bmodule as $bmid) {
424
-            $sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
425
-            $this->db->query($sql);
426
-        }
427
-        //$groups = &$GLOBALS['xoopsUser']->getGroups();
428
-        foreach ($groups as $iValue) {
429
-            $sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
430
-            $this->db->query($sql);
431
-        }
432
-        $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
433
-    }
434
-
435
-    public function setOrder(string $bid, string $title, string $weight, string $visible, string $side, string $bcachetime, ?array $bmodule = null): void
436
-    {
437
-        $myblock = new \XoopsBlock($bid);
438
-        $myblock->setVar('title', $title);
439
-        $myblock->setVar('weight', $weight);
440
-        $myblock->setVar('visible', $visible);
441
-        $myblock->setVar('side', $side);
442
-        $myblock->setVar('bcachetime', $bcachetime);
443
-        $myblock->store();
444
-        //        /** @var \XoopsBlockHandler $blockHandler */
445
-        //        $blockHandler = \xoops_getHandler('block');
446
-        //        return $blockHandler->insert($myblock);
447
-    }
448
-
449
-    public function editBlock(int $bid): void
450
-    {
451
-        //        require_once \dirname(__DIR__,2) . '/admin/admin_header.php';
452
-        //        \xoops_cp_header();
453
-        \xoops_loadLanguage('admin', 'system');
454
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
455
-        \xoops_loadLanguage('admin/groups', 'system');
456
-        //        mpu_adm_menu();
457
-        $myblock = new \XoopsBlock($bid);
458
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
459
-        $result  = $this->db->query($sql);
460
-        $modules = [];
461
-        if ($result instanceof \mysqli_result) {
462
-            while (false !== ($row = $this->db->fetchArray($result))) {
463
-                $modules[] = (int)$row['module_id'];
464
-            }
465
-        }
466
-        $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E'], true);
467
-        $block    = [
468
-            'title'      => $myblock->getVar('title'),
469
-            'form_title' => \_AM_SYSTEM_BLOCKS_EDITBLOCK,
470
-            //        'name'       => $myblock->getVar('name'),
471
-            'side'       => $myblock->getVar('side'),
472
-            'weight'     => $myblock->getVar('weight'),
473
-            'visible'    => $myblock->getVar('visible'),
474
-            'content'    => $myblock->getVar('content', 'N'),
475
-            'modules'    => $modules,
476
-            'is_custom'  => $isCustom,
477
-            'ctype'      => $myblock->getVar('c_type'),
478
-            'bcachetime' => $myblock->getVar('bcachetime'),
479
-            'op'         => 'edit_ok',
480
-            'bid'        => $myblock->getVar('bid'),
481
-            'edit_form'  => $myblock->getOptions(),
482
-            'template'   => $myblock->getVar('template'),
483
-            'options'    => $myblock->getVar('options'),
484
-        ];
485
-        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>';
486
-
487
-        echo $this->render($block);
488
-    }
489
-
490
-    public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
491
-    {
492
-        $myblock = new \XoopsBlock($bid);
493
-        $myblock->setVar('title', $btitle);
494
-        $myblock->setVar('weight', $bweight);
495
-        $myblock->setVar('visible', $bvisible);
496
-        $myblock->setVar('side', $bside);
497
-        $myblock->setVar('bcachetime', $bcachetime);
498
-        //update block options
499
-        if (isset($options) && \is_array($options)) {
500
-            $optionsCount = \count($options);
501
-            if ($optionsCount > 0) {
502
-                //Convert array values to comma-separated
503
-                foreach ($options as $i => $iValue) {
504
-                    if (\is_array($iValue)) {
505
-                        $options[$i] = \implode(',', $iValue);
506
-                    }
507
-                }
508
-                $options = \implode('|', $options);
509
-                $myblock->setVar('options', $options);
510
-            }
511
-        }
512
-        $myblock->store();
513
-        //        /** @var \XoopsBlockHandler $blockHandler */
514
-        //        $blockHandler = \xoops_getHandler('block');
515
-        //        $blockHandler->insert($myblock);
516
-
517
-        if (!empty($bmodule) && \count($bmodule) > 0) {
518
-            $sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
519
-            $this->db->query($sql);
520
-            if (\in_array(0, $bmodule, true)) {
521
-                $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, 0);
522
-                $this->db->query($sql);
523
-            } else {
524
-                foreach ($bmodule as $bmid) {
525
-                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int)$bmid);
526
-                    $this->db->query($sql);
527
-                }
528
-            }
529
-        }
530
-        $sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid);
531
-        $this->db->query($sql);
532
-        if (!empty($groups)) {
533
-            foreach ($groups as $grp) {
534
-                $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);
535
-                $this->db->query($sql);
536
-            }
537
-        }
538
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
539
-    }
540
-
541
-    public function orderBlock(
542
-        array $bid,
543
-        array $oldtitle,
544
-        array $oldside,
545
-        array $oldweight,
546
-        array $oldvisible,
547
-        array $oldgroups,
548
-        array $oldbcachetime,
549
-        array $oldbmodule,
550
-        array $title,
551
-        array $weight,
552
-        array $visible,
553
-        array $side,
554
-        array $bcachetime,
555
-        array $groups,
556
-        array $bmodule
557
-    ): void {
558
-        if (!$GLOBALS['xoopsSecurity']->check()) {
559
-            \redirect_header($_SERVER['SCRIPT_NAME'], 3, \implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
560
-        }
561
-        foreach (\array_keys($bid) as $i) {
562
-            if ($oldtitle[$i] !== $title[$i]
563
-                || $oldweight[$i] !== $weight[$i]
564
-                || $oldvisible[$i] !== $visible[$i]
565
-                || $oldside[$i] !== $side[$i]
566
-                || $oldbcachetime[$i] !== $bcachetime[$i]
567
-                || $oldbmodule[$i] !== $bmodule[$i]) {
568
-                $this->setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
569
-            }
570
-            if (!empty($bmodule[$i]) && \count($bmodule[$i]) > 0) {
571
-                $sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid[$i]);
572
-                $this->db->query($sql);
573
-                if (\in_array(0, $bmodule[$i], true)) {
574
-                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], 0);
575
-                    $this->db->query($sql);
576
-                } else {
577
-                    foreach ($bmodule[$i] as $bmid) {
578
-                        $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid);
579
-                        $this->db->query($sql);
580
-                    }
581
-                }
582
-            }
583
-            $sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid[$i]);
584
-            $this->db->query($sql);
585
-            if (!empty($groups[$i])) {
586
-                foreach ($groups[$i] as $grp) {
587
-                    $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]);
588
-                    $this->db->query($sql);
589
-                }
590
-            }
591
-        }
592
-
593
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
594
-    }
595
-
596
-    public function render(?array $block = null): void
597
-    {
598
-        \xoops_load('XoopsFormLoader');
599
-        \xoops_loadLanguage('common', $this->moduleDirNameUpper);
600
-
601
-        $form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true);
602
-        if (isset($block['name'])) {
603
-            $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_NAME, $block['name']));
604
-        }
605
-        $sideSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']);
606
-        $sideSelect->addOptionArray([
607
-                                        0 => \_AM_SYSTEM_BLOCKS_SBLEFT,
608
-                                        1 => \_AM_SYSTEM_BLOCKS_SBRIGHT,
609
-                                        3 => \_AM_SYSTEM_BLOCKS_CBLEFT,
610
-                                        4 => \_AM_SYSTEM_BLOCKS_CBRIGHT,
611
-                                        5 => \_AM_SYSTEM_BLOCKS_CBCENTER,
612
-                                        7 => \_AM_SYSTEM_BLOCKS_CBBOTTOMLEFT,
613
-                                        8 => \_AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT,
614
-                                        9 => \_AM_SYSTEM_BLOCKS_CBBOTTOM,
615
-                                    ]);
616
-        $form->addElement($sideSelect);
617
-        $form->addElement(new \XoopsFormText(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
618
-        $form->addElement(new \XoopsFormRadioYN(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
619
-        $modSelect = new \XoopsFormSelect(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
620
-        /** @var \XoopsModuleHandler $moduleHandler */
621
-        $moduleHandler = \xoops_getHandler('module');
622
-        $criteria      = new \CriteriaCompo(new \Criteria('hasmain', 1));
623
-        $criteria->add(new \Criteria('isactive', 1));
624
-        $moduleList     = $moduleHandler->getList($criteria);
625
-        $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
626
-        $moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
627
-        \ksort($moduleList);
628
-        $modSelect->addOptionArray($moduleList);
629
-        $form->addElement($modSelect);
630
-        $form->addElement(new \XoopsFormText(\_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false);
631
-        if ($block['is_custom']) {
632
-            $textarea = new \XoopsFormDhtmlTextArea(\_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);
633
-            $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>');
634
-            $form->addElement($textarea, true);
635
-            $ctypeSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
636
-            $ctypeSelect->addOptionArray([
637
-                                             'H' => \_AM_SYSTEM_BLOCKS_HTML,
638
-                                             'P' => \_AM_SYSTEM_BLOCKS_PHP,
639
-                                             'S' => \_AM_SYSTEM_BLOCKS_AFWSMILE,
640
-                                             'T' => \_AM_SYSTEM_BLOCKS_AFNOSMILE,
641
-                                         ]);
642
-            $form->addElement($ctypeSelect);
643
-        } else {
644
-            if ('' !== $block['template']) {
645
-                /** @var \XoopsTplfileHandler $tplfileHandler */
646
-                $tplfileHandler = \xoops_getHandler('tplfile');
647
-                $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
648
-                if (\count($btemplate) > 0) {
649
-                    $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>'));
650
-                } else {
651
-                    $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);
652
-                    if (\count($btemplate2) > 0) {
653
-                        $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>'));
654
-                    }
655
-                }
656
-            }
657
-            if (false !== $block['edit_form']) {
658
-                $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form']));
659
-            }
660
-        }
661
-        $cache_select = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']);
662
-        $cache_select->addOptionArray([
663
-                                          0       => _NOCACHE,
664
-                                          30      => \sprintf(_SECONDS, 30),
665
-                                          60      => _MINUTE,
666
-                                          300     => \sprintf(_MINUTES, 5),
667
-                                          1800    => \sprintf(_MINUTES, 30),
668
-                                          3600    => _HOUR,
669
-                                          18000   => \sprintf(_HOURS, 5),
670
-                                          86400   => _DAY,
671
-                                          259200  => \sprintf(_DAYS, 3),
672
-                                          604800  => _WEEK,
673
-                                          2592000 => _MONTH,
674
-                                      ]);
675
-        $form->addElement($cache_select);
676
-
677
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
678
-        $grouppermHandler = \xoops_getHandler('groupperm');
679
-        $groups           = $grouppermHandler->getGroupIds('block_read', $block['bid']);
680
-
681
-        $form->addElement(new \XoopsFormSelectGroup(\_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true));
682
-
683
-        if (isset($block['bid'])) {
684
-            $form->addElement(new \XoopsFormHidden('bid', $block['bid']));
685
-        }
686
-        $form->addElement(new \XoopsFormHidden('op', $block['op']));
687
-        $form->addElement(new \XoopsFormHidden('fct', 'blocksadmin'));
688
-        $buttonTray = new \XoopsFormElementTray('', '&nbsp;');
689
-        if ($block['is_custom']) {
690
-            $buttonTray->addElement(new \XoopsFormButton('', 'previewblock', _PREVIEW, 'submit'));
691
-        }
692
-
693
-        //Submit buttons
694
-        $buttonTray   = new \XoopsFormElementTray('', '');
695
-        $submitButton = new \XoopsFormButton('', 'submitblock', _SUBMIT, 'submit');
696
-        $buttonTray->addElement($submitButton);
697
-
698
-        $cancelButton = new \XoopsFormButton('', '', _CANCEL, 'button');
699
-        $cancelButton->setExtra('onclick="history.go(-1)"');
700
-        $buttonTray->addElement($cancelButton);
701
-
702
-        $form->addElement($buttonTray);
703
-        $form->display();
704
-    }
300
+	}
301
+
302
+	public function deleteBlock(int $bid): void
303
+	{
304
+		//        \xoops_cp_header();
305
+
306
+		\xoops_loadLanguage('admin', 'system');
307
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
308
+		\xoops_loadLanguage('admin/groups', 'system');
309
+
310
+		$myblock = new \XoopsBlock($bid);
311
+
312
+		$sql = \sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), $bid);
313
+		$this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
314
+
315
+		$sql = \sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
316
+		$this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
317
+
318
+		$this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
319
+	}
320
+
321
+	public function cloneBlock(int $bid): void
322
+	{
323
+		//require __DIR__ . '/admin_header.php';
324
+		//        \xoops_cp_header();
325
+
326
+		\xoops_loadLanguage('admin', 'system');
327
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
328
+		\xoops_loadLanguage('admin/groups', 'system');
329
+
330
+		$myblock = new \XoopsBlock($bid);
331
+		$sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
332
+		$result  = $this->db->query($sql);
333
+		$modules = [];
334
+		if ($result instanceof \mysqli_result) {
335
+			while (false !== ($row = $this->db->fetchArray($result))) {
336
+				$modules[] = (int)$row['module_id'];
337
+			}
338
+		}
339
+		$isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E'], true);
340
+		$block    = [
341
+			'title'      => $myblock->getVar('title') . ' Clone',
342
+			'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
343
+			'name'       => $myblock->getVar('name'),
344
+			'side'       => $myblock->getVar('side'),
345
+			'weight'     => $myblock->getVar('weight'),
346
+			'visible'    => $myblock->getVar('visible'),
347
+			'content'    => $myblock->getVar('content', 'N'),
348
+			'modules'    => $modules,
349
+			'is_custom'  => $isCustom,
350
+			'ctype'      => $myblock->getVar('c_type'),
351
+			'bcachetime' => $myblock->getVar('bcachetime'),
352
+			'op'         => 'clone_ok',
353
+			'bid'        => $myblock->getVar('bid'),
354
+			'edit_form'  => $myblock->getOptions(),
355
+			'template'   => $myblock->getVar('template'),
356
+			'options'    => $myblock->getVar('options'),
357
+		];
358
+		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>';
359
+		//        $form = new Blockform();
360
+		//        $form->render();
361
+
362
+		echo $this->render($block);
363
+		//        xoops_cp_footer();
364
+		//        require_once __DIR__ . '/admin_footer.php';
365
+		//        exit();
366
+	}
367
+
368
+	/**
369
+	 * @param null|array|string $options
370
+	 */
371
+	public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
372
+	{
373
+		\xoops_loadLanguage('admin', 'system');
374
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
375
+		\xoops_loadLanguage('admin/groups', 'system');
376
+
377
+		$block = new \XoopsBlock($bid);
378
+		$clone = $block->xoopsClone();
379
+		if (empty($bmodule)) {
380
+			//            \xoops_cp_header();
381
+			\xoops_error(\sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
382
+			\xoops_cp_footer();
383
+			exit();
384
+		}
385
+		$clone->setVar('side', $bside);
386
+		$clone->setVar('weight', $bweight);
387
+		$clone->setVar('visible', $bvisible);
388
+		//$clone->setVar('content', $_POST['bcontent']);
389
+		$clone->setVar('title', Request::getString('btitle', '', 'POST'));
390
+		$clone->setVar('bcachetime', $bcachetime);
391
+		if (\is_array($options) && (\count($options) > 0)) {
392
+			$options = \implode('|', $options);
393
+			$clone->setVar('options', $options);
394
+		}
395
+		$clone->setVar('bid', 0);
396
+		if (\in_array($block->getVar('block_type'), ['C', 'E'], true)) {
397
+			$clone->setVar('block_type', 'E');
398
+		} else {
399
+			$clone->setVar('block_type', 'D');
400
+		}
401
+		//        $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105
402
+		if ($clone->store()) {
403
+			$newid = $clone->id();  //get the id of the cloned block
404
+		}
405
+		if (!$newid) {
406
+			//            \xoops_cp_header();
407
+			$clone->getHtmlErrors();
408
+			\xoops_cp_footer();
409
+			exit();
410
+		}
411
+		if ('' !== $clone->getVar('template')) {
412
+			/** @var \XoopsTplfileHandler $tplfileHandler */
413
+			$tplfileHandler = \xoops_getHandler('tplfile');
414
+			$btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string)$bid);
415
+			if (\count($btemplate) > 0) {
416
+				$tplclone = $btemplate[0]->xoopsClone();
417
+				$tplclone->setVar('tpl_id', 0);
418
+				$tplclone->setVar('tpl_refid', $newid);
419
+				$tplfileHandler->insert($tplclone);
420
+			}
421
+		}
422
+
423
+		foreach ($bmodule as $bmid) {
424
+			$sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
425
+			$this->db->query($sql);
426
+		}
427
+		//$groups = &$GLOBALS['xoopsUser']->getGroups();
428
+		foreach ($groups as $iValue) {
429
+			$sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
430
+			$this->db->query($sql);
431
+		}
432
+		$this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
433
+	}
434
+
435
+	public function setOrder(string $bid, string $title, string $weight, string $visible, string $side, string $bcachetime, ?array $bmodule = null): void
436
+	{
437
+		$myblock = new \XoopsBlock($bid);
438
+		$myblock->setVar('title', $title);
439
+		$myblock->setVar('weight', $weight);
440
+		$myblock->setVar('visible', $visible);
441
+		$myblock->setVar('side', $side);
442
+		$myblock->setVar('bcachetime', $bcachetime);
443
+		$myblock->store();
444
+		//        /** @var \XoopsBlockHandler $blockHandler */
445
+		//        $blockHandler = \xoops_getHandler('block');
446
+		//        return $blockHandler->insert($myblock);
447
+	}
448
+
449
+	public function editBlock(int $bid): void
450
+	{
451
+		//        require_once \dirname(__DIR__,2) . '/admin/admin_header.php';
452
+		//        \xoops_cp_header();
453
+		\xoops_loadLanguage('admin', 'system');
454
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
455
+		\xoops_loadLanguage('admin/groups', 'system');
456
+		//        mpu_adm_menu();
457
+		$myblock = new \XoopsBlock($bid);
458
+		$sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
459
+		$result  = $this->db->query($sql);
460
+		$modules = [];
461
+		if ($result instanceof \mysqli_result) {
462
+			while (false !== ($row = $this->db->fetchArray($result))) {
463
+				$modules[] = (int)$row['module_id'];
464
+			}
465
+		}
466
+		$isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E'], true);
467
+		$block    = [
468
+			'title'      => $myblock->getVar('title'),
469
+			'form_title' => \_AM_SYSTEM_BLOCKS_EDITBLOCK,
470
+			//        'name'       => $myblock->getVar('name'),
471
+			'side'       => $myblock->getVar('side'),
472
+			'weight'     => $myblock->getVar('weight'),
473
+			'visible'    => $myblock->getVar('visible'),
474
+			'content'    => $myblock->getVar('content', 'N'),
475
+			'modules'    => $modules,
476
+			'is_custom'  => $isCustom,
477
+			'ctype'      => $myblock->getVar('c_type'),
478
+			'bcachetime' => $myblock->getVar('bcachetime'),
479
+			'op'         => 'edit_ok',
480
+			'bid'        => $myblock->getVar('bid'),
481
+			'edit_form'  => $myblock->getOptions(),
482
+			'template'   => $myblock->getVar('template'),
483
+			'options'    => $myblock->getVar('options'),
484
+		];
485
+		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>';
486
+
487
+		echo $this->render($block);
488
+	}
489
+
490
+	public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
491
+	{
492
+		$myblock = new \XoopsBlock($bid);
493
+		$myblock->setVar('title', $btitle);
494
+		$myblock->setVar('weight', $bweight);
495
+		$myblock->setVar('visible', $bvisible);
496
+		$myblock->setVar('side', $bside);
497
+		$myblock->setVar('bcachetime', $bcachetime);
498
+		//update block options
499
+		if (isset($options) && \is_array($options)) {
500
+			$optionsCount = \count($options);
501
+			if ($optionsCount > 0) {
502
+				//Convert array values to comma-separated
503
+				foreach ($options as $i => $iValue) {
504
+					if (\is_array($iValue)) {
505
+						$options[$i] = \implode(',', $iValue);
506
+					}
507
+				}
508
+				$options = \implode('|', $options);
509
+				$myblock->setVar('options', $options);
510
+			}
511
+		}
512
+		$myblock->store();
513
+		//        /** @var \XoopsBlockHandler $blockHandler */
514
+		//        $blockHandler = \xoops_getHandler('block');
515
+		//        $blockHandler->insert($myblock);
516
+
517
+		if (!empty($bmodule) && \count($bmodule) > 0) {
518
+			$sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
519
+			$this->db->query($sql);
520
+			if (\in_array(0, $bmodule, true)) {
521
+				$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, 0);
522
+				$this->db->query($sql);
523
+			} else {
524
+				foreach ($bmodule as $bmid) {
525
+					$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int)$bmid);
526
+					$this->db->query($sql);
527
+				}
528
+			}
529
+		}
530
+		$sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid);
531
+		$this->db->query($sql);
532
+		if (!empty($groups)) {
533
+			foreach ($groups as $grp) {
534
+				$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);
535
+				$this->db->query($sql);
536
+			}
537
+		}
538
+		$this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
539
+	}
540
+
541
+	public function orderBlock(
542
+		array $bid,
543
+		array $oldtitle,
544
+		array $oldside,
545
+		array $oldweight,
546
+		array $oldvisible,
547
+		array $oldgroups,
548
+		array $oldbcachetime,
549
+		array $oldbmodule,
550
+		array $title,
551
+		array $weight,
552
+		array $visible,
553
+		array $side,
554
+		array $bcachetime,
555
+		array $groups,
556
+		array $bmodule
557
+	): void {
558
+		if (!$GLOBALS['xoopsSecurity']->check()) {
559
+			\redirect_header($_SERVER['SCRIPT_NAME'], 3, \implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
560
+		}
561
+		foreach (\array_keys($bid) as $i) {
562
+			if ($oldtitle[$i] !== $title[$i]
563
+				|| $oldweight[$i] !== $weight[$i]
564
+				|| $oldvisible[$i] !== $visible[$i]
565
+				|| $oldside[$i] !== $side[$i]
566
+				|| $oldbcachetime[$i] !== $bcachetime[$i]
567
+				|| $oldbmodule[$i] !== $bmodule[$i]) {
568
+				$this->setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
569
+			}
570
+			if (!empty($bmodule[$i]) && \count($bmodule[$i]) > 0) {
571
+				$sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid[$i]);
572
+				$this->db->query($sql);
573
+				if (\in_array(0, $bmodule[$i], true)) {
574
+					$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], 0);
575
+					$this->db->query($sql);
576
+				} else {
577
+					foreach ($bmodule[$i] as $bmid) {
578
+						$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid);
579
+						$this->db->query($sql);
580
+					}
581
+				}
582
+			}
583
+			$sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid[$i]);
584
+			$this->db->query($sql);
585
+			if (!empty($groups[$i])) {
586
+				foreach ($groups[$i] as $grp) {
587
+					$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]);
588
+					$this->db->query($sql);
589
+				}
590
+			}
591
+		}
592
+
593
+		$this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
594
+	}
595
+
596
+	public function render(?array $block = null): void
597
+	{
598
+		\xoops_load('XoopsFormLoader');
599
+		\xoops_loadLanguage('common', $this->moduleDirNameUpper);
600
+
601
+		$form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true);
602
+		if (isset($block['name'])) {
603
+			$form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_NAME, $block['name']));
604
+		}
605
+		$sideSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']);
606
+		$sideSelect->addOptionArray([
607
+										0 => \_AM_SYSTEM_BLOCKS_SBLEFT,
608
+										1 => \_AM_SYSTEM_BLOCKS_SBRIGHT,
609
+										3 => \_AM_SYSTEM_BLOCKS_CBLEFT,
610
+										4 => \_AM_SYSTEM_BLOCKS_CBRIGHT,
611
+										5 => \_AM_SYSTEM_BLOCKS_CBCENTER,
612
+										7 => \_AM_SYSTEM_BLOCKS_CBBOTTOMLEFT,
613
+										8 => \_AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT,
614
+										9 => \_AM_SYSTEM_BLOCKS_CBBOTTOM,
615
+									]);
616
+		$form->addElement($sideSelect);
617
+		$form->addElement(new \XoopsFormText(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
618
+		$form->addElement(new \XoopsFormRadioYN(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
619
+		$modSelect = new \XoopsFormSelect(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
620
+		/** @var \XoopsModuleHandler $moduleHandler */
621
+		$moduleHandler = \xoops_getHandler('module');
622
+		$criteria      = new \CriteriaCompo(new \Criteria('hasmain', 1));
623
+		$criteria->add(new \Criteria('isactive', 1));
624
+		$moduleList     = $moduleHandler->getList($criteria);
625
+		$moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
626
+		$moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
627
+		\ksort($moduleList);
628
+		$modSelect->addOptionArray($moduleList);
629
+		$form->addElement($modSelect);
630
+		$form->addElement(new \XoopsFormText(\_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false);
631
+		if ($block['is_custom']) {
632
+			$textarea = new \XoopsFormDhtmlTextArea(\_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);
633
+			$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>');
634
+			$form->addElement($textarea, true);
635
+			$ctypeSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
636
+			$ctypeSelect->addOptionArray([
637
+											 'H' => \_AM_SYSTEM_BLOCKS_HTML,
638
+											 'P' => \_AM_SYSTEM_BLOCKS_PHP,
639
+											 'S' => \_AM_SYSTEM_BLOCKS_AFWSMILE,
640
+											 'T' => \_AM_SYSTEM_BLOCKS_AFNOSMILE,
641
+										 ]);
642
+			$form->addElement($ctypeSelect);
643
+		} else {
644
+			if ('' !== $block['template']) {
645
+				/** @var \XoopsTplfileHandler $tplfileHandler */
646
+				$tplfileHandler = \xoops_getHandler('tplfile');
647
+				$btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
648
+				if (\count($btemplate) > 0) {
649
+					$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>'));
650
+				} else {
651
+					$btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);
652
+					if (\count($btemplate2) > 0) {
653
+						$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>'));
654
+					}
655
+				}
656
+			}
657
+			if (false !== $block['edit_form']) {
658
+				$form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form']));
659
+			}
660
+		}
661
+		$cache_select = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']);
662
+		$cache_select->addOptionArray([
663
+										  0       => _NOCACHE,
664
+										  30      => \sprintf(_SECONDS, 30),
665
+										  60      => _MINUTE,
666
+										  300     => \sprintf(_MINUTES, 5),
667
+										  1800    => \sprintf(_MINUTES, 30),
668
+										  3600    => _HOUR,
669
+										  18000   => \sprintf(_HOURS, 5),
670
+										  86400   => _DAY,
671
+										  259200  => \sprintf(_DAYS, 3),
672
+										  604800  => _WEEK,
673
+										  2592000 => _MONTH,
674
+									  ]);
675
+		$form->addElement($cache_select);
676
+
677
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
678
+		$grouppermHandler = \xoops_getHandler('groupperm');
679
+		$groups           = $grouppermHandler->getGroupIds('block_read', $block['bid']);
680
+
681
+		$form->addElement(new \XoopsFormSelectGroup(\_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true));
682
+
683
+		if (isset($block['bid'])) {
684
+			$form->addElement(new \XoopsFormHidden('bid', $block['bid']));
685
+		}
686
+		$form->addElement(new \XoopsFormHidden('op', $block['op']));
687
+		$form->addElement(new \XoopsFormHidden('fct', 'blocksadmin'));
688
+		$buttonTray = new \XoopsFormElementTray('', '&nbsp;');
689
+		if ($block['is_custom']) {
690
+			$buttonTray->addElement(new \XoopsFormButton('', 'previewblock', _PREVIEW, 'submit'));
691
+		}
692
+
693
+		//Submit buttons
694
+		$buttonTray   = new \XoopsFormElementTray('', '');
695
+		$submitButton = new \XoopsFormButton('', 'submitblock', _SUBMIT, 'submit');
696
+		$buttonTray->addElement($submitButton);
697
+
698
+		$cancelButton = new \XoopsFormButton('', '', _CANCEL, 'button');
699
+		$cancelButton->setExtra('onclick="history.go(-1)"');
700
+		$buttonTray->addElement($cancelButton);
701
+
702
+		$form->addElement($buttonTray);
703
+		$form->display();
704
+	}
705 705
 }
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function __construct(?\XoopsDatabase $db, Helper $helper)
40 40
     {
41
-        if (null === $db) {
41
+        if (null===$db) {
42 42
             $db = \XoopsDatabaseFactory::getDatabaseConnection();
43 43
         }
44 44
         $this->db                 = $db;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function listBlocks(): void
56 56
     {
57 57
         global $xoopsModule, $pathIcon16;
58
-        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
58
+        require_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
59 59
         //        xoops_loadLanguage('admin', 'system');
60 60
         //        xoops_loadLanguage('admin/blocksadmin', 'system');
61 61
         //        xoops_loadLanguage('admin/groups', 'system');
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
         $moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
77 77
         \ksort($moduleList);
78 78
         echo "
79
-        <h4 style='text-align:left;'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
80
-        echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>";
79
+        <h4 style='text-align:left;'>" . \constant('CO_'.$this->moduleDirNameUpper.'_'.'BADMIN').'</h4>';
80
+        echo "<form action='".$_SERVER['SCRIPT_NAME']."' name='blockadmin' method='post'>";
81 81
         echo $GLOBALS['xoopsSecurity']->getTokenHTML();
82 82
         echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
83 83
         <tr valign='middle'><th align='center'>"
84 84
              . \_AM_SYSTEM_BLOCKS_TITLE
85 85
              . "</th><th align='center' nowrap='nowrap'>"
86
-             . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'SIDE')
86
+             . \constant('CO_'.$this->moduleDirNameUpper.'_'.'SIDE')
87 87
              . '<br>'
88 88
              . _LEFT
89 89
              . '-'
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
              . _RIGHT
93 93
              . "</th><th align='center'>"
94 94
              . \constant(
95
-                 'CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'
95
+                 'CO_'.$this->moduleDirNameUpper.'_'.'WEIGHT'
96 96
              )
97 97
              . "</th><th align='center'>"
98
-             . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE')
98
+             . \constant('CO_'.$this->moduleDirNameUpper.'_'.'VISIBLE')
99 99
              . "</th><th align='center'>"
100 100
              . \_AM_SYSTEM_BLOCKS_VISIBLEIN
101 101
              . "</th><th align='center'>"
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
              . "</th><th align='center'>"
104 104
              . \_AM_SYSTEM_BLOCKS_BCACHETIME
105 105
              . "</th><th align='center'>"
106
-             . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'ACTION')
106
+             . \constant('CO_'.$this->moduleDirNameUpper.'_'.'ACTION')
107 107
              . '</th></tr>
108 108
         ';
109 109
         $blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
@@ -124,19 +124,19 @@  discard block
 block discarded – undo
124 124
         ];
125 125
         foreach ($blockArray as $i) {
126 126
             $groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
127
-            $sql               = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
127
+            $sql               = 'SELECT module_id FROM '.$this->db->prefix('block_module_link').' WHERE block_id='.$i->getVar('bid');
128 128
             $result            = $this->db->query($sql);
129 129
             $modules           = [];
130 130
             if (!$result instanceof \mysqli_result) {
131
-                \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR);
131
+                \trigger_error("Query Failed! SQL: $sql Error: ".$this->db->error(), \E_USER_ERROR);
132 132
             }
133
-            while (false !== ($row = $this->db->fetchArray($result))) {
134
-                $modules[] = (int)$row['module_id'];
133
+            while (false!==($row = $this->db->fetchArray($result))) {
134
+                $modules[] = (int) $row['module_id'];
135 135
             }
136 136
 
137 137
             $cachetimeOptions = '';
138 138
             foreach ($cachetimes as $cachetime => $cachetimeName) {
139
-                if ($i->getVar('bcachetime') == $cachetime) {
139
+                if ($i->getVar('bcachetime')==$cachetime) {
140 140
                     $cachetimeOptions .= "<option value='$cachetime' selected='selected'>$cachetimeName</option>\n";
141 141
                 } else {
142 142
                     $cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n";
@@ -153,29 +153,29 @@  discard block
 block discarded – undo
153 153
             $ssel0 = $ssel1;
154 154
             $sel1  = $ssel0;
155 155
             $sel0  = $sel1;
156
-            if (1 === $i->getVar('visible')) {
156
+            if (1===$i->getVar('visible')) {
157 157
                 $sel1 = ' checked';
158 158
             } else {
159 159
                 $sel0 = ' checked';
160 160
             }
161
-            if (\XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) {
161
+            if (\XOOPS_SIDEBLOCK_LEFT===$i->getVar('side')) {
162 162
                 $ssel0 = ' checked';
163
-            } elseif (\XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) {
163
+            } elseif (\XOOPS_SIDEBLOCK_RIGHT===$i->getVar('side')) {
164 164
                 $ssel1 = ' checked';
165
-            } elseif (\XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) {
165
+            } elseif (\XOOPS_CENTERBLOCK_LEFT===$i->getVar('side')) {
166 166
                 $ssel2 = ' checked';
167
-            } elseif (\XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) {
167
+            } elseif (\XOOPS_CENTERBLOCK_RIGHT===$i->getVar('side')) {
168 168
                 $ssel4 = ' checked';
169
-            } elseif (\XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) {
169
+            } elseif (\XOOPS_CENTERBLOCK_CENTER===$i->getVar('side')) {
170 170
                 $ssel3 = ' checked';
171
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) {
171
+            } elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT===$i->getVar('side')) {
172 172
                 $ssel5 = ' checked';
173
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) {
173
+            } elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT===$i->getVar('side')) {
174 174
                 $ssel6 = ' checked';
175
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) {
175
+            } elseif (\XOOPS_CENTERBLOCK_BOTTOM===$i->getVar('side')) {
176 176
                 $ssel7 = ' checked';
177 177
             }
178
-            if ('' === $i->getVar('title')) {
178
+            if (''===$i->getVar('title')) {
179 179
                 $title = '&nbsp;';
180 180
             } else {
181 181
                 $title = $i->getVar('title');
@@ -246,27 +246,27 @@  discard block
 block discarded – undo
246 246
                  . _NO
247 247
                  . '</td>';
248 248
 
249
-            echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
249
+            echo "<td class='$class' align='center'><select size='5' name='bmodule[".$i->getVar('bid')."][]' id='bmodule[".$i->getVar('bid')."][]' multiple='multiple'>";
250 250
             foreach ($moduleList as $k => $v) {
251
-                echo "<option value='$k'" . (\in_array($k, $modules, true) ? " selected='selected'" : '') . ">$v</option>";
251
+                echo "<option value='$k'".(\in_array($k, $modules, true) ? " selected='selected'" : '').">$v</option>";
252 252
             }
253 253
             echo '</select></td>';
254 254
 
255
-            echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
255
+            echo "<td class='$class' align='center'><select size='5' name='groups[".$i->getVar('bid')."][]' id='groups[".$i->getVar('bid')."][]' multiple='multiple'>";
256 256
             foreach ($groups as $grp) {
257
-                echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions, true) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
257
+                echo "<option value='".$grp->getVar('groupid')."' ".(\in_array($grp->getVar('groupid'), $groupsPermissions, true) ? " selected='selected'" : '').'>'.$grp->getVar('name').'</option>';
258 258
             }
259 259
             echo '</select></td>';
260 260
 
261 261
             // Cache lifetime
262
-            echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select>
262
+            echo '<td class="'.$class.'" align="center"> <select name="bcachetime['.$i->getVar('bid').']" size="1">'.$cachetimeOptions.'</select>
263 263
                                     </td>';
264 264
 
265 265
             // Actions
266 266
 
267 267
             echo "<td class='$class' align='center'>
268
-                <a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'></a> 
269
-                <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'></a>";
268
+                <a href='blocksadmin.php?op=edit&amp;bid=".$i->getVar('bid')."'><img src=".$pathIcon16.'/edit.png'." alt='"._EDIT."' title='"._EDIT."'></a> 
269
+                <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid')."'><img src=".$pathIcon16.'/editcopy.png'." alt='"._CLONE."' title='"._CLONE."'></a>";
270 270
             //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
271 271
             //                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 . "'>
272 272
             //                     </a>";
@@ -275,25 +275,25 @@  discard block
 block discarded – undo
275 275
             //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
276 276
             if (!\in_array($i->getVar('block_type'), ['M', 'S'], true)) {
277 277
                 echo "&nbsp;
278
-                <a href='blocksadmin.php?op=delete&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
278
+                <a href='blocksadmin.php?op=delete&amp;bid=" . $i->getVar('bid')."'><img src=".$pathIcon16.'/delete.png'." alt='"._DELETE."' title='"._DELETE."'>
279 279
                      </a>";
280 280
             }
281 281
             echo "
282
-            <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'>
283
-            <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'>
284
-            <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'>
285
-            <input type='hidden' name='oldvisible[" . $i->getVar('bid') . "]' value='" . $i->getVar('visible') . "'>
286
-            <input type='hidden' name='oldgroups[" . $i->getVar('groups') . "]' value='" . $i->getVar('groups') . "'>
287
-            <input type='hidden' name='oldbcachetime[" . $i->getVar('bid') . "]' value='" . $i->getVar('bcachetime') . "'>
288
-            <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'>
282
+            <input type='hidden' name='oldtitle[" . $i->getVar('bid')."]' value='".$i->getVar('title')."'>
283
+            <input type='hidden' name='oldside[" . $i->getVar('bid')."]' value='".$i->getVar('side')."'>
284
+            <input type='hidden' name='oldweight[" . $i->getVar('bid')."]' value='".$i->getVar('weight')."'>
285
+            <input type='hidden' name='oldvisible[" . $i->getVar('bid')."]' value='".$i->getVar('visible')."'>
286
+            <input type='hidden' name='oldgroups[" . $i->getVar('groups')."]' value='".$i->getVar('groups')."'>
287
+            <input type='hidden' name='oldbcachetime[" . $i->getVar('bid')."]' value='".$i->getVar('bcachetime')."'>
288
+            <input type='hidden' name='bid[" . $i->getVar('bid')."]' value='".$i->getVar('bid')."'>
289 289
             </td></tr>
290 290
             ";
291
-            $class = ('even' === $class) ? 'odd' : 'even';
291
+            $class = ('even'===$class) ? 'odd' : 'even';
292 292
         }
293 293
         echo "<tr><td class='foot' align='center' colspan='8'>
294 294
         <input type='hidden' name='op' value='order'>
295
-        " . $GLOBALS['xoopsSecurity']->getTokenHTML() . "
296
-        <input type='submit' name='submit' value='" . _SUBMIT . "'>
295
+        " . $GLOBALS['xoopsSecurity']->getTokenHTML()."
296
+        <input type='submit' name='submit' value='" . _SUBMIT."'>
297 297
         </td></tr></table>
298 298
         </form>
299 299
         <br><br>";
@@ -328,18 +328,18 @@  discard block
 block discarded – undo
328 328
         \xoops_loadLanguage('admin/groups', 'system');
329 329
 
330 330
         $myblock = new \XoopsBlock($bid);
331
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
331
+        $sql     = 'SELECT module_id FROM '.$this->db->prefix('block_module_link').' WHERE block_id='.$bid;
332 332
         $result  = $this->db->query($sql);
333 333
         $modules = [];
334 334
         if ($result instanceof \mysqli_result) {
335
-            while (false !== ($row = $this->db->fetchArray($result))) {
336
-                $modules[] = (int)$row['module_id'];
335
+            while (false!==($row = $this->db->fetchArray($result))) {
336
+                $modules[] = (int) $row['module_id'];
337 337
             }
338 338
         }
339 339
         $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E'], true);
340 340
         $block    = [
341
-            'title'      => $myblock->getVar('title') . ' Clone',
342
-            'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
341
+            'title'      => $myblock->getVar('title').' Clone',
342
+            'form_title' => \constant('CO_'.$this->moduleDirNameUpper.'_'.'BLOCKS_CLONEBLOCK'),
343 343
             'name'       => $myblock->getVar('name'),
344 344
             'side'       => $myblock->getVar('side'),
345 345
             'weight'     => $myblock->getVar('weight'),
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
             'template'   => $myblock->getVar('template'),
356 356
             'options'    => $myblock->getVar('options'),
357 357
         ];
358
-        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>';
358
+        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>';
359 359
         //        $form = new Blockform();
360 360
         //        $form->render();
361 361
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
         //$clone->setVar('content', $_POST['bcontent']);
389 389
         $clone->setVar('title', Request::getString('btitle', '', 'POST'));
390 390
         $clone->setVar('bcachetime', $bcachetime);
391
-        if (\is_array($options) && (\count($options) > 0)) {
391
+        if (\is_array($options) && (\count($options)>0)) {
392 392
             $options = \implode('|', $options);
393 393
             $clone->setVar('options', $options);
394 394
         }
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
         }
401 401
         //        $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105
402 402
         if ($clone->store()) {
403
-            $newid = $clone->id();  //get the id of the cloned block
403
+            $newid = $clone->id(); //get the id of the cloned block
404 404
         }
405 405
         if (!$newid) {
406 406
             //            \xoops_cp_header();
@@ -408,11 +408,11 @@  discard block
 block discarded – undo
408 408
             \xoops_cp_footer();
409 409
             exit();
410 410
         }
411
-        if ('' !== $clone->getVar('template')) {
411
+        if (''!==$clone->getVar('template')) {
412 412
             /** @var \XoopsTplfileHandler $tplfileHandler */
413 413
             $tplfileHandler = \xoops_getHandler('tplfile');
414
-            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string)$bid);
415
-            if (\count($btemplate) > 0) {
414
+            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string) $bid);
415
+            if (\count($btemplate)>0) {
416 416
                 $tplclone = $btemplate[0]->xoopsClone();
417 417
                 $tplclone->setVar('tpl_id', 0);
418 418
                 $tplclone->setVar('tpl_refid', $newid);
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
         }
422 422
 
423 423
         foreach ($bmodule as $bmid) {
424
-            $sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
424
+            $sql = 'INSERT INTO '.$this->db->prefix('block_module_link').' (block_id, module_id) VALUES ('.$newid.', '.$bmid.')';
425 425
             $this->db->query($sql);
426 426
         }
427 427
         //$groups = &$GLOBALS['xoopsUser']->getGroups();
428 428
         foreach ($groups as $iValue) {
429
-            $sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
429
+            $sql = 'INSERT INTO '.$this->db->prefix('group_permission').' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ('.$iValue.', '.$newid.", 1, 'block_read')";
430 430
             $this->db->query($sql);
431 431
         }
432 432
         $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
@@ -455,12 +455,12 @@  discard block
 block discarded – undo
455 455
         \xoops_loadLanguage('admin/groups', 'system');
456 456
         //        mpu_adm_menu();
457 457
         $myblock = new \XoopsBlock($bid);
458
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
458
+        $sql     = 'SELECT module_id FROM '.$this->db->prefix('block_module_link').' WHERE block_id='.$bid;
459 459
         $result  = $this->db->query($sql);
460 460
         $modules = [];
461 461
         if ($result instanceof \mysqli_result) {
462
-            while (false !== ($row = $this->db->fetchArray($result))) {
463
-                $modules[] = (int)$row['module_id'];
462
+            while (false!==($row = $this->db->fetchArray($result))) {
463
+                $modules[] = (int) $row['module_id'];
464 464
             }
465 465
         }
466 466
         $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E'], true);
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
             'template'   => $myblock->getVar('template'),
483 483
             'options'    => $myblock->getVar('options'),
484 484
         ];
485
-        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>';
485
+        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>';
486 486
 
487 487
         echo $this->render($block);
488 488
     }
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
         //update block options
499 499
         if (isset($options) && \is_array($options)) {
500 500
             $optionsCount = \count($options);
501
-            if ($optionsCount > 0) {
501
+            if ($optionsCount>0) {
502 502
                 //Convert array values to comma-separated
503 503
                 foreach ($options as $i => $iValue) {
504 504
                     if (\is_array($iValue)) {
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
         //        $blockHandler = \xoops_getHandler('block');
515 515
         //        $blockHandler->insert($myblock);
516 516
 
517
-        if (!empty($bmodule) && \count($bmodule) > 0) {
517
+        if (!empty($bmodule) && \count($bmodule)>0) {
518 518
             $sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
519 519
             $this->db->query($sql);
520 520
             if (\in_array(0, $bmodule, true)) {
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
                 $this->db->query($sql);
523 523
             } else {
524 524
                 foreach ($bmodule as $bmid) {
525
-                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int)$bmid);
525
+                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int) $bmid);
526 526
                     $this->db->query($sql);
527 527
                 }
528 528
             }
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
                 $this->db->query($sql);
536 536
             }
537 537
         }
538
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
538
+        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_'.$this->moduleDirNameUpper.'_'.'UPDATE_SUCCESS'));
539 539
     }
540 540
 
541 541
     public function orderBlock(
@@ -559,15 +559,15 @@  discard block
 block discarded – undo
559 559
             \redirect_header($_SERVER['SCRIPT_NAME'], 3, \implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
560 560
         }
561 561
         foreach (\array_keys($bid) as $i) {
562
-            if ($oldtitle[$i] !== $title[$i]
563
-                || $oldweight[$i] !== $weight[$i]
564
-                || $oldvisible[$i] !== $visible[$i]
565
-                || $oldside[$i] !== $side[$i]
566
-                || $oldbcachetime[$i] !== $bcachetime[$i]
567
-                || $oldbmodule[$i] !== $bmodule[$i]) {
562
+            if ($oldtitle[$i]!==$title[$i]
563
+                || $oldweight[$i]!==$weight[$i]
564
+                || $oldvisible[$i]!==$visible[$i]
565
+                || $oldside[$i]!==$side[$i]
566
+                || $oldbcachetime[$i]!==$bcachetime[$i]
567
+                || $oldbmodule[$i]!==$bmodule[$i]) {
568 568
                 $this->setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
569 569
             }
570
-            if (!empty($bmodule[$i]) && \count($bmodule[$i]) > 0) {
570
+            if (!empty($bmodule[$i]) && \count($bmodule[$i])>0) {
571 571
                 $sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid[$i]);
572 572
                 $this->db->query($sql);
573 573
                 if (\in_array(0, $bmodule[$i], true)) {
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
                     $this->db->query($sql);
576 576
                 } else {
577 577
                     foreach ($bmodule[$i] as $bmid) {
578
-                        $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid);
578
+                        $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int) $bmid);
579 579
                         $this->db->query($sql);
580 580
                     }
581 581
                 }
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
             }
591 591
         }
592 592
 
593
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
593
+        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_'.$this->moduleDirNameUpper.'_'.'UPDATE_SUCCESS'));
594 594
     }
595 595
 
596 596
     public function render(?array $block = null): void
@@ -614,9 +614,9 @@  discard block
 block discarded – undo
614 614
                                         9 => \_AM_SYSTEM_BLOCKS_CBBOTTOM,
615 615
                                     ]);
616 616
         $form->addElement($sideSelect);
617
-        $form->addElement(new \XoopsFormText(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
618
-        $form->addElement(new \XoopsFormRadioYN(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
619
-        $modSelect = new \XoopsFormSelect(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
617
+        $form->addElement(new \XoopsFormText(\constant('CO_'.$this->moduleDirNameUpper.'_'.'WEIGHT'), 'bweight', 2, 5, $block['weight']));
618
+        $form->addElement(new \XoopsFormRadioYN(\constant('CO_'.$this->moduleDirNameUpper.'_'.'VISIBLE'), 'bvisible', $block['visible']));
619
+        $modSelect = new \XoopsFormSelect(\constant('CO_'.$this->moduleDirNameUpper.'_'.'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
620 620
         /** @var \XoopsModuleHandler $moduleHandler */
621 621
         $moduleHandler = \xoops_getHandler('module');
622 622
         $criteria      = new \CriteriaCompo(new \Criteria('hasmain', 1));
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
         $form->addElement(new \XoopsFormText(\_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false);
631 631
         if ($block['is_custom']) {
632 632
             $textarea = new \XoopsFormDhtmlTextArea(\_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);
633
-            $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>');
633
+            $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>');
634 634
             $form->addElement($textarea, true);
635 635
             $ctypeSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
636 636
             $ctypeSelect->addOptionArray([
@@ -641,20 +641,20 @@  discard block
 block discarded – undo
641 641
                                          ]);
642 642
             $form->addElement($ctypeSelect);
643 643
         } else {
644
-            if ('' !== $block['template']) {
644
+            if (''!==$block['template']) {
645 645
                 /** @var \XoopsTplfileHandler $tplfileHandler */
646 646
                 $tplfileHandler = \xoops_getHandler('tplfile');
647 647
                 $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
648
-                if (\count($btemplate) > 0) {
649
-                    $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>'));
648
+                if (\count($btemplate)>0) {
649
+                    $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>'));
650 650
                 } else {
651 651
                     $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);
652
-                    if (\count($btemplate2) > 0) {
653
-                        $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>'));
652
+                    if (\count($btemplate2)>0) {
653
+                        $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>'));
654 654
                     }
655 655
                 }
656 656
             }
657
-            if (false !== $block['edit_form']) {
657
+            if (false!==$block['edit_form']) {
658 658
                 $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form']));
659 659
             }
660 660
         }
Please login to merge, or discard this patch.
class/Common/VersionChecks.php 2 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -19,127 +19,127 @@
 block discarded – undo
19 19
  */
20 20
 trait VersionChecks
21 21
 {
22
-    /**
23
-     * Verifies XOOPS version meets minimum requirements for this module
24
-     * @static
25
-     * @param \XoopsModule|null $module
26
-     *
27
-     * @param null|string       $requiredVer
28
-     * @return bool true if meets requirements, false if not
29
-     */
30
-    public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null): bool
31
-    {
32
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
33
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
34
-        if (null === $module) {
35
-            $module = \XoopsModule::getByDirname($moduleDirName);
36
-        }
37
-        \xoops_loadLanguage('admin', $moduleDirName);
38
-        \xoops_loadLanguage('common', $moduleDirName);
22
+	/**
23
+	 * Verifies XOOPS version meets minimum requirements for this module
24
+	 * @static
25
+	 * @param \XoopsModule|null $module
26
+	 *
27
+	 * @param null|string       $requiredVer
28
+	 * @return bool true if meets requirements, false if not
29
+	 */
30
+	public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null): bool
31
+	{
32
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
33
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
34
+		if (null === $module) {
35
+			$module = \XoopsModule::getByDirname($moduleDirName);
36
+		}
37
+		\xoops_loadLanguage('admin', $moduleDirName);
38
+		\xoops_loadLanguage('common', $moduleDirName);
39 39
 
40
-        //check for minimum XOOPS version
41
-        $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string
42
-        if (null === $requiredVer) {
43
-            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
44
-        }
45
-        $success = true;
40
+		//check for minimum XOOPS version
41
+		$currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string
42
+		if (null === $requiredVer) {
43
+			$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
44
+		}
45
+		$success = true;
46 46
 
47
-        if (\version_compare($currentVer, $requiredVer, '<')) {
48
-            $success = false;
49
-            $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
50
-        }
47
+		if (\version_compare($currentVer, $requiredVer, '<')) {
48
+			$success = false;
49
+			$module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
50
+		}
51 51
 
52
-        return $success;
53
-    }
52
+		return $success;
53
+	}
54 54
 
55
-    /**
56
-     * Verifies PHP version meets minimum requirements for this module
57
-     * @static
58
-     * @param \XoopsModule|bool|null $module
59
-     *
60
-     * @return bool true if meets requirements, false if not
61
-     */
62
-    public static function checkVerPhp(\XoopsModule $module = null): bool
63
-    {
64
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
65
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
66
-        if (null === $module) {
67
-            $module = \XoopsModule::getByDirname($moduleDirName);
68
-        }
69
-        \xoops_loadLanguage('admin', $moduleDirName);
70
-        \xoops_loadLanguage('common', $moduleDirName);
55
+	/**
56
+	 * Verifies PHP version meets minimum requirements for this module
57
+	 * @static
58
+	 * @param \XoopsModule|bool|null $module
59
+	 *
60
+	 * @return bool true if meets requirements, false if not
61
+	 */
62
+	public static function checkVerPhp(\XoopsModule $module = null): bool
63
+	{
64
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
65
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
66
+		if (null === $module) {
67
+			$module = \XoopsModule::getByDirname($moduleDirName);
68
+		}
69
+		\xoops_loadLanguage('admin', $moduleDirName);
70
+		\xoops_loadLanguage('common', $moduleDirName);
71 71
 
72
-        // check for minimum PHP version
73
-        $success = true;
72
+		// check for minimum PHP version
73
+		$success = true;
74 74
 
75
-        $verNum = \PHP_VERSION;
76
-        $reqVer = &$module->getInfo('min_php');
75
+		$verNum = \PHP_VERSION;
76
+		$reqVer = &$module->getInfo('min_php');
77 77
 
78
-        if (false !== $reqVer && '' !== $reqVer) {
79
-            if (\version_compare($verNum, $reqVer, '<')) {
80
-                $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
81
-                $success = false;
82
-            }
83
-        }
78
+		if (false !== $reqVer && '' !== $reqVer) {
79
+			if (\version_compare($verNum, $reqVer, '<')) {
80
+				$module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
81
+				$success = false;
82
+			}
83
+		}
84 84
 
85
-        return $success;
86
-    }
85
+		return $success;
86
+	}
87 87
 
88
-    /**
89
-     * compares current module version with the latest GitHub release
90
-     * @static
91
-     *
92
-     * @return string|array info about the latest module version, if newer
93
-     */
94
-    public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
95
-    {
96
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
97
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
98
-        $update             = '';
99
-        $repository         = 'XoopsModules25x/' . $moduleDirName;
100
-        //        $repository         = 'XoopsModules25x/publisher'; //for testing only
101
-        $ret             = null;
102
-        $infoReleasesUrl = "https://api.github.com/repos/$repository/releases";
103
-        if ('github' === $source) {
104
-            if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) {
105
-                \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl);
106
-                \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true);
107
-                \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized'
108
-                \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);
109
-                $curlReturn = \curl_exec($curlHandle);
110
-                if (false === $curlReturn) {
111
-                    \trigger_error(\curl_error($curlHandle));
112
-                } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) {
113
-                    \trigger_error('Repository Not Found: ' . $infoReleasesUrl);
114
-                } else {
115
-                    $file              = json_decode($curlReturn, false);
116
-                    $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default);
117
-                    $latestVersion     = $file[0]->tag_name;
118
-                    $prerelease        = $file[0]->prerelease;
119
-                    if ('master' !== $latestVersionLink) {
120
-                        $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
121
-                    }
122
-                    //"PHP-standardized" version
123
-                    $latestVersion = \mb_strtolower($latestVersion);
124
-                    if (false !== mb_strpos($latestVersion, 'final')) {
125
-                        $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion));
126
-                        $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion));
127
-                    }
128
-                    $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'));
129
-                    //"PHP-standardized" version
130
-                    $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion));
131
-                    //                    $moduleVersion = '1.0'; //for testing only
132
-                    //                    $moduleDirName = 'publisher'; //for testing only
133
-                    if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) {
134
-                        $ret   = [];
135
-                        $ret[] = $update;
136
-                        $ret[] = $latestVersionLink;
137
-                    }
138
-                }
139
-                \curl_close($curlHandle);
140
-            }
141
-        }
88
+	/**
89
+	 * compares current module version with the latest GitHub release
90
+	 * @static
91
+	 *
92
+	 * @return string|array info about the latest module version, if newer
93
+	 */
94
+	public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
95
+	{
96
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
97
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
98
+		$update             = '';
99
+		$repository         = 'XoopsModules25x/' . $moduleDirName;
100
+		//        $repository         = 'XoopsModules25x/publisher'; //for testing only
101
+		$ret             = null;
102
+		$infoReleasesUrl = "https://api.github.com/repos/$repository/releases";
103
+		if ('github' === $source) {
104
+			if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) {
105
+				\curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl);
106
+				\curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true);
107
+				\curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized'
108
+				\curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);
109
+				$curlReturn = \curl_exec($curlHandle);
110
+				if (false === $curlReturn) {
111
+					\trigger_error(\curl_error($curlHandle));
112
+				} elseif (false !== \mb_strpos($curlReturn, 'Not Found')) {
113
+					\trigger_error('Repository Not Found: ' . $infoReleasesUrl);
114
+				} else {
115
+					$file              = json_decode($curlReturn, false);
116
+					$latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default);
117
+					$latestVersion     = $file[0]->tag_name;
118
+					$prerelease        = $file[0]->prerelease;
119
+					if ('master' !== $latestVersionLink) {
120
+						$update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
121
+					}
122
+					//"PHP-standardized" version
123
+					$latestVersion = \mb_strtolower($latestVersion);
124
+					if (false !== mb_strpos($latestVersion, 'final')) {
125
+						$latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion));
126
+						$latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion));
127
+					}
128
+					$moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'));
129
+					//"PHP-standardized" version
130
+					$moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion));
131
+					//                    $moduleVersion = '1.0'; //for testing only
132
+					//                    $moduleDirName = 'publisher'; //for testing only
133
+					if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) {
134
+						$ret   = [];
135
+						$ret[] = $update;
136
+						$ret[] = $latestVersionLink;
137
+					}
138
+				}
139
+				\curl_close($curlHandle);
140
+			}
141
+		}
142 142
 
143
-        return $ret;
144
-    }
143
+		return $ret;
144
+	}
145 145
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $moduleDirName      = \basename(\dirname(__DIR__, 2));
33 33
         $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
34
-        if (null === $module) {
34
+        if (null===$module) {
35 35
             $module = \XoopsModule::getByDirname($moduleDirName);
36 36
         }
37 37
         \xoops_loadLanguage('admin', $moduleDirName);
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 
40 40
         //check for minimum XOOPS version
41 41
         $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string
42
-        if (null === $requiredVer) {
43
-            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
42
+        if (null===$requiredVer) {
43
+            $requiredVer = ''.$module->getInfo('min_xoops'); //making sure it's a string
44 44
         }
45 45
         $success = true;
46 46
 
47 47
         if (\version_compare($currentVer, $requiredVer, '<')) {
48 48
             $success = false;
49
-            $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
49
+            $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
50 50
         }
51 51
 
52 52
         return $success;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     {
64 64
         $moduleDirName      = \basename(\dirname(__DIR__, 2));
65 65
         $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
66
-        if (null === $module) {
66
+        if (null===$module) {
67 67
             $module = \XoopsModule::getByDirname($moduleDirName);
68 68
         }
69 69
         \xoops_loadLanguage('admin', $moduleDirName);
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
         $verNum = \PHP_VERSION;
76 76
         $reqVer = &$module->getInfo('min_php');
77 77
 
78
-        if (false !== $reqVer && '' !== $reqVer) {
78
+        if (false!==$reqVer && ''!==$reqVer) {
79 79
             if (\version_compare($verNum, $reqVer, '<')) {
80
-                $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
80
+                $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_PHP'), $reqVer, $verNum));
81 81
                 $success = false;
82 82
             }
83 83
         }
@@ -96,36 +96,36 @@  discard block
 block discarded – undo
96 96
         $moduleDirName      = \basename(\dirname(__DIR__, 2));
97 97
         $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
98 98
         $update             = '';
99
-        $repository         = 'XoopsModules25x/' . $moduleDirName;
99
+        $repository         = 'XoopsModules25x/'.$moduleDirName;
100 100
         //        $repository         = 'XoopsModules25x/publisher'; //for testing only
101 101
         $ret             = null;
102 102
         $infoReleasesUrl = "https://api.github.com/repos/$repository/releases";
103
-        if ('github' === $source) {
104
-            if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) {
103
+        if ('github'===$source) {
104
+            if (\function_exists('curl_init') && false!==($curlHandle = \curl_init())) {
105 105
                 \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl);
106 106
                 \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true);
107 107
                 \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized'
108 108
                 \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);
109 109
                 $curlReturn = \curl_exec($curlHandle);
110
-                if (false === $curlReturn) {
110
+                if (false===$curlReturn) {
111 111
                     \trigger_error(\curl_error($curlHandle));
112
-                } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) {
113
-                    \trigger_error('Repository Not Found: ' . $infoReleasesUrl);
112
+                } elseif (false!==\mb_strpos($curlReturn, 'Not Found')) {
113
+                    \trigger_error('Repository Not Found: '.$infoReleasesUrl);
114 114
                 } else {
115 115
                     $file              = json_decode($curlReturn, false);
116 116
                     $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default);
117 117
                     $latestVersion     = $file[0]->tag_name;
118 118
                     $prerelease        = $file[0]->prerelease;
119
-                    if ('master' !== $latestVersionLink) {
120
-                        $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
119
+                    if ('master'!==$latestVersionLink) {
120
+                        $update = \constant('CO_'.$moduleDirNameUpper.'_'.'NEW_VERSION').$latestVersion;
121 121
                     }
122 122
                     //"PHP-standardized" version
123 123
                     $latestVersion = \mb_strtolower($latestVersion);
124
-                    if (false !== mb_strpos($latestVersion, 'final')) {
124
+                    if (false!==mb_strpos($latestVersion, 'final')) {
125 125
                         $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion));
126 126
                         $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion));
127 127
                     }
128
-                    $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'));
128
+                    $moduleVersion = ($helper->getModule()->getInfo('version').'_'.$helper->getModule()->getInfo('module_status'));
129 129
                     //"PHP-standardized" version
130 130
                     $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion));
131 131
                     //                    $moduleVersion = '1.0'; //for testing only
Please login to merge, or discard this patch.
class/Common/TestdataButtons.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -29,64 +29,64 @@
 block discarded – undo
29 29
  */
30 30
 class TestdataButtons
31 31
 {
32
-    /** Button status constants */
33
-    private const SHOW_BUTTONS = 1;
34
-    private const HIDE_BUTTONS = 0;
32
+	/** Button status constants */
33
+	private const SHOW_BUTTONS = 1;
34
+	private const HIDE_BUTTONS = 0;
35 35
 
36
-    /**
37
-     * Load the test button configuration
38
-     *
39
-     * @param \Xmf\Module\Admin $adminObject
40
-     *
41
-     * @return void
42
-     */
43
-    public static function loadButtonConfig($adminObject): void
44
-    {
45
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
46
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
47
-        $helper              = Helper::getInstance();
48
-        $yamlFile            = $helper->path('/config/admin.yml');
49
-        $config             = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps
50
-        $displaySampleButton = $config['displaySampleButton'];
36
+	/**
37
+	 * Load the test button configuration
38
+	 *
39
+	 * @param \Xmf\Module\Admin $adminObject
40
+	 *
41
+	 * @return void
42
+	 */
43
+	public static function loadButtonConfig($adminObject): void
44
+	{
45
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
46
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
47
+		$helper              = Helper::getInstance();
48
+		$yamlFile            = $helper->path('/config/admin.yml');
49
+		$config             = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps
50
+		$displaySampleButton = $config['displaySampleButton'];
51 51
 
52
-        if (self::SHOW_BUTTONS == $displaySampleButton) {
53
-            \xoops_loadLanguage('admin/modulesadmin', 'system');
54
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add');
55
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add');
56
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert');
57
-            //    $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add');
58
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
59
-        } else {
60
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
61
-            // $displaySampleButton = $config['displaySampleButton'];
62
-        }
63
-    }
52
+		if (self::SHOW_BUTTONS == $displaySampleButton) {
53
+			\xoops_loadLanguage('admin/modulesadmin', 'system');
54
+			$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add');
55
+			$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add');
56
+			$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert');
57
+			//    $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add');
58
+			$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
59
+		} else {
60
+			$adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
61
+			// $displaySampleButton = $config['displaySampleButton'];
62
+		}
63
+	}
64 64
 
65
-    /**
66
-     * Hide the test buttons
67
-     *
68
-     * @return void
69
-     */
70
-    public static function hideButtons(): void
71
-    {
72
-        $yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
73
-        $app                        = [];
74
-        $app['displaySampleButton'] = self::HIDE_BUTTONS;
75
-        Yaml::save($app, $yamlFile);
76
-        \redirect_header('index.php', 0, '');
77
-    }
65
+	/**
66
+	 * Hide the test buttons
67
+	 *
68
+	 * @return void
69
+	 */
70
+	public static function hideButtons(): void
71
+	{
72
+		$yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
73
+		$app                        = [];
74
+		$app['displaySampleButton'] = self::HIDE_BUTTONS;
75
+		Yaml::save($app, $yamlFile);
76
+		\redirect_header('index.php', 0, '');
77
+	}
78 78
 
79
-    /**
80
-     * Show the test buttons
81
-     *
82
-     * @return void
83
-     */
84
-    public static function showButtons(): void
85
-    {
86
-        $yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
87
-        $app                        = [];
88
-        $app['displaySampleButton'] = self::SHOW_BUTTONS;
89
-        Yaml::save($app, $yamlFile);
90
-        \redirect_header('index.php', 0, '');
91
-    }
79
+	/**
80
+	 * Show the test buttons
81
+	 *
82
+	 * @return void
83
+	 */
84
+	public static function showButtons(): void
85
+	{
86
+		$yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
87
+		$app                        = [];
88
+		$app['displaySampleButton'] = self::SHOW_BUTTONS;
89
+		Yaml::save($app, $yamlFile);
90
+		\redirect_header('index.php', 0, '');
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
         $config             = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps
50 50
         $displaySampleButton = $config['displaySampleButton'];
51 51
 
52
-        if (self::SHOW_BUTTONS == $displaySampleButton) {
52
+        if (self::SHOW_BUTTONS==$displaySampleButton) {
53 53
             \xoops_loadLanguage('admin/modulesadmin', 'system');
54
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add');
55
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add');
56
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert');
54
+            $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add');
55
+            $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add');
56
+            $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert');
57 57
             //    $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add');
58
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
58
+            $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
59 59
         } else {
60
-            $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
60
+            $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
61 61
             // $displaySampleButton = $config['displaySampleButton'];
62 62
         }
63 63
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public static function hideButtons(): void
71 71
     {
72
-        $yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
72
+        $yamlFile                   = \dirname(__DIR__, 2).'/config/admin.yml';
73 73
         $app                        = [];
74 74
         $app['displaySampleButton'] = self::HIDE_BUTTONS;
75 75
         Yaml::save($app, $yamlFile);
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public static function showButtons(): void
85 85
     {
86
-        $yamlFile                   = \dirname(__DIR__, 2) . '/config/admin.yml';
86
+        $yamlFile                   = \dirname(__DIR__, 2).'/config/admin.yml';
87 87
         $app                        = [];
88 88
         $app['displaySampleButton'] = self::SHOW_BUTTONS;
89 89
         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(): string
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(): string
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   +13 added lines, -13 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
-            if (true == ($gdlib = gd_info())) {
51
-                $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>';
50
+            if (true==($gdlib = gd_info())) {
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/Migrate.php 2 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -25,49 +25,49 @@  discard block
 block discarded – undo
25 25
  */
26 26
 class Migrate extends \Xmf\Database\Migrate
27 27
 {
28
-    private $moduleDirName;
29
-    private $renameColumns;
30
-    private $renameTables;
28
+	private $moduleDirName;
29
+	private $renameColumns;
30
+	private $renameTables;
31 31
 
32
-    /**
33
-     * Migrate constructor.
34
-     * @throws \RuntimeException
35
-     * @throws \InvalidArgumentException
36
-     */
37
-    public function __construct()
38
-    {
39
-        $class = __NAMESPACE__ . '\\' . 'Configurator';
40
-        if (!\class_exists($class)) {
41
-            throw new \RuntimeException("Class '$class' not found");
42
-        }
43
-        $configurator       = new $class();
44
-        $this->renameTables = $configurator->renameTables;
45
-        $this->renameColumns = $configurator->renameColumns;
32
+	/**
33
+	 * Migrate constructor.
34
+	 * @throws \RuntimeException
35
+	 * @throws \InvalidArgumentException
36
+	 */
37
+	public function __construct()
38
+	{
39
+		$class = __NAMESPACE__ . '\\' . 'Configurator';
40
+		if (!\class_exists($class)) {
41
+			throw new \RuntimeException("Class '$class' not found");
42
+		}
43
+		$configurator       = new $class();
44
+		$this->renameTables = $configurator->renameTables;
45
+		$this->renameColumns = $configurator->renameColumns;
46 46
 
47
-        $this->moduleDirName = \basename(\dirname(__DIR__, 2));
48
-        parent::__construct($this->moduleDirName);
49
-    }
47
+		$this->moduleDirName = \basename(\dirname(__DIR__, 2));
48
+		parent::__construct($this->moduleDirName);
49
+	}
50 50
 
51
-    /**
52
-     * change table prefix if needed
53
-     */
54
-    private function changePrefix()
55
-    {
51
+	/**
52
+	 * change table prefix if needed
53
+	 */
54
+	private function changePrefix()
55
+	{
56 56
 //        foreach ($this->renameTables as $oldName => $newName) {
57 57
 //            if ($this->tableHandler->useTable($oldName) && !$this->tableHandler->useTable($newName)) {
58 58
 //                $this->tableHandler->renameTable($oldName, $newName);
59 59
 //            }
60 60
 //        }
61
-    }
61
+	}
62 62
 
63
-    /**
64
-     * Change integer IPv4 column to varchar IPv6 capable
65
-     *
66
-     * @param string $tableName  table to convert
67
-     * @param string $columnName column with IP address
68
-     */
69
-    private function convertIPAddresses($tableName, $columnName)
70
-    {
63
+	/**
64
+	 * Change integer IPv4 column to varchar IPv6 capable
65
+	 *
66
+	 * @param string $tableName  table to convert
67
+	 * @param string $columnName column with IP address
68
+	 */
69
+	private function convertIPAddresses($tableName, $columnName)
70
+	{
71 71
 //        if ($this->tableHandler->useTable($tableName)) {
72 72
 //            $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName);
73 73
 //            if (false !== \mb_strpos($attributes, ' int(')) {
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 //                $this->tableHandler->update($tableName, [$columnName => "INET_NTOA($columnName)"], '', false);
80 80
 //            }
81 81
 //        }
82
-    }
82
+	}
83 83
 
84
-    /**
85
-     * @deprecated (just as an example here)
86
-     * Move do* columns from newbb_posts to newbb_posts_text table
87
-     */
88
-    private function moveDoColumns()
89
-    {
84
+	/**
85
+	 * @deprecated (just as an example here)
86
+	 * Move do* columns from newbb_posts to newbb_posts_text table
87
+	 */
88
+	private function moveDoColumns()
89
+	{
90 90
 //        $tableName    = 'newbb_posts_text';
91 91
 //        $srcTableName = 'newbb_posts';
92 92
 //        if ($this->tableHandler->useTable($tableName)
@@ -100,62 +100,62 @@  discard block
 block discarded – undo
100 100
 //                $this->tableHandler->addToQueue($sql);
101 101
 //            }
102 102
 //        }
103
-    }
103
+	}
104 104
 
105
-    /**
106
-     * rename table if needed
107
-     */
108
-    private function renameTable()
109
-    {
110
-        foreach ($this->renameTables as $oldName => $newName) {
111
-            if ($this->tableHandler->useTable($oldName) && !$this->tableHandler->useTable($newName)) {
112
-                $this->tableHandler->renameTable($oldName, $newName);
113
-            }
114
-        }
115
-    }
105
+	/**
106
+	 * rename table if needed
107
+	 */
108
+	private function renameTable()
109
+	{
110
+		foreach ($this->renameTables as $oldName => $newName) {
111
+			if ($this->tableHandler->useTable($oldName) && !$this->tableHandler->useTable($newName)) {
112
+				$this->tableHandler->renameTable($oldName, $newName);
113
+			}
114
+		}
115
+	}
116 116
 
117 117
 
118
-    /**
119
-     * rename columns if needed
120
-     */
121
-    private function renameColumns()
122
-    {
123
-        foreach ($this->renameColumns as $tableName) {
124
-            if ($this->tableHandler->useTable($tableName)) {
125
-                $oldName = $tableName['from'];
126
-                $newName = $tableName['to'];
127
-                $attributes = $this->tableHandler->getColumnAttributes($tableName, $oldName);
128
-                if (false !== \strpos($attributes, ' int(')) {
129
-                    $this->tableHandler->alterColumn($tableName, $oldName, $attributes, $newName);
130
-                }
131
-            }
132
-        }
133
-    }
118
+	/**
119
+	 * rename columns if needed
120
+	 */
121
+	private function renameColumns()
122
+	{
123
+		foreach ($this->renameColumns as $tableName) {
124
+			if ($this->tableHandler->useTable($tableName)) {
125
+				$oldName = $tableName['from'];
126
+				$newName = $tableName['to'];
127
+				$attributes = $this->tableHandler->getColumnAttributes($tableName, $oldName);
128
+				if (false !== \strpos($attributes, ' int(')) {
129
+					$this->tableHandler->alterColumn($tableName, $oldName, $attributes, $newName);
130
+				}
131
+			}
132
+		}
133
+	}
134 134
 
135
-    /**
136
-     * Perform any upfront actions before synchronizing the schema
137
-     *
138
-     * Some typical uses include
139
-     *   table and column renames
140
-     *   data conversions
141
-     */
142
-    protected function preSyncActions()
143
-    {
144
-        // change 'bb' table prefix to 'newbb'
145
-        $this->changePrefix();
146
-        // columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point
147
-        $this->moveDoColumns();
148
-        // Convert IP address columns from int to readable varchar(45) for IPv6
135
+	/**
136
+	 * Perform any upfront actions before synchronizing the schema
137
+	 *
138
+	 * Some typical uses include
139
+	 *   table and column renames
140
+	 *   data conversions
141
+	 */
142
+	protected function preSyncActions()
143
+	{
144
+		// change 'bb' table prefix to 'newbb'
145
+		$this->changePrefix();
146
+		// columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point
147
+		$this->moveDoColumns();
148
+		// Convert IP address columns from int to readable varchar(45) for IPv6
149 149
 //        $this->convertIPAddresses('newbb_posts', 'poster_ip');
150 150
 //        $this->convertIPAddresses('newbb_report', 'reporter_ip');
151 151
 
152
-        // rename table
153
-        if ($this->renameTables && \is_array($this->renameTables)) {
154
-            $this->renameTable();
155
-        }
156
-        // rename column
157
-        if ($this->renameColumns && \is_array($this->renameColumns)) {
158
-            $this->renameColumns();
159
-        }
160
-    }
152
+		// rename table
153
+		if ($this->renameTables && \is_array($this->renameTables)) {
154
+			$this->renameTable();
155
+		}
156
+		// rename column
157
+		if ($this->renameColumns && \is_array($this->renameColumns)) {
158
+			$this->renameColumns();
159
+		}
160
+	}
161 161
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function __construct()
38 38
     {
39
-        $class = __NAMESPACE__ . '\\' . 'Configurator';
39
+        $class = __NAMESPACE__.'\\'.'Configurator';
40 40
         if (!\class_exists($class)) {
41 41
             throw new \RuntimeException("Class '$class' not found");
42 42
         }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                 $oldName = $tableName['from'];
126 126
                 $newName = $tableName['to'];
127 127
                 $attributes = $this->tableHandler->getColumnAttributes($tableName, $oldName);
128
-                if (false !== \strpos($attributes, ' int(')) {
128
+                if (false!==\strpos($attributes, ' int(')) {
129 129
                     $this->tableHandler->alterColumn($tableName, $oldName, $attributes, $newName);
130 130
                 }
131 131
             }
Please login to merge, or discard this patch.
class/Common/Breadcrumb.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -32,39 +32,39 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class Breadcrumb
34 34
 {
35
-    public  $dirname;
36
-    private $bread = [];
35
+	public  $dirname;
36
+	private $bread = [];
37 37
 
38
-    public function __construct()
39
-    {
40
-        $this->dirname = \basename(\dirname(__DIR__, 2));
41
-    }
38
+	public function __construct()
39
+	{
40
+		$this->dirname = \basename(\dirname(__DIR__, 2));
41
+	}
42 42
 
43
-    /**
44
-     * Add link to breadcrumb
45
-     *
46
-     * @param string $title
47
-     * @param string $link
48
-     */
49
-    public function addLink($title = '', $link = ''): void
50
-    {
51
-        $this->bread[] = [
52
-            'link'  => $link,
53
-            'title' => $title,
54
-        ];
55
-    }
43
+	/**
44
+	 * Add link to breadcrumb
45
+	 *
46
+	 * @param string $title
47
+	 * @param string $link
48
+	 */
49
+	public function addLink($title = '', $link = ''): void
50
+	{
51
+		$this->bread[] = [
52
+			'link'  => $link,
53
+			'title' => $title,
54
+		];
55
+	}
56 56
 
57
-    /**
58
-     * Render BreadCrumb
59
-     */
60
-    public function render(): void
61
-    {
62
-        /*
57
+	/**
58
+	 * Render BreadCrumb
59
+	 */
60
+	public function render(): void
61
+	{
62
+		/*
63 63
         TODO if you want to use the render code below,
64 64
         1) create ./templates/chess_common_breadcrumb.tpl)
65 65
         2) add declaration to  xoops_version.php
66 66
         */
67
-        /*
67
+		/*
68 68
         if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) {
69 69
             require $GLOBALS['xoops']->path('class/theme.php');
70 70
 
@@ -83,5 +83,5 @@  discard block
 block discarded – undo
83 83
 
84 84
         return $html;
85 85
         */
86
-    }
86
+	}
87 87
 }
Please login to merge, or discard this patch.