Passed
Pull Request — master (#2)
by Michael
07:48 queued 04:06
created
class/Category.php 2 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -9,94 +9,94 @@
 block discarded – undo
9 9
  */
10 10
 class Category extends \XoopsObject
11 11
 {
12
-    /**
13
-     * Category constructor.
14
-     * @param null $fid
15
-     */
16
-    public function __construct($fid = null)
17
-    {
18
-        $this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
19
-        $this->initVar('pid', \XOBJ_DTYPE_INT, 0, false);
20
-        $this->initVar('weight', \XOBJ_DTYPE_INT, 1, false);
21
-        $this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
22
-        $this->initVar('description', \XOBJ_DTYPE_OTHER, null, false);
23
-        $this->initVar('image', \XOBJ_DTYPE_TXTBOX, null, false, 128);
24
-        $this->initVar('path', \XOBJ_DTYPE_TXTBOX, null, false, 128);
25
-        $this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
26
-        $this->initVar('albums', \XOBJ_DTYPE_INT, 0, false);
27
-        $this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
28
-        $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
29
-        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
30
-        $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
31
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
32
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
33
-    }
12
+	/**
13
+	 * Category constructor.
14
+	 * @param null $fid
15
+	 */
16
+	public function __construct($fid = null)
17
+	{
18
+		$this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
19
+		$this->initVar('pid', \XOBJ_DTYPE_INT, 0, false);
20
+		$this->initVar('weight', \XOBJ_DTYPE_INT, 1, false);
21
+		$this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
22
+		$this->initVar('description', \XOBJ_DTYPE_OTHER, null, false);
23
+		$this->initVar('image', \XOBJ_DTYPE_TXTBOX, null, false, 128);
24
+		$this->initVar('path', \XOBJ_DTYPE_TXTBOX, null, false, 128);
25
+		$this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
26
+		$this->initVar('albums', \XOBJ_DTYPE_INT, 0, false);
27
+		$this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
28
+		$this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
29
+		$this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
30
+		$this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
31
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
32
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
33
+	}
34 34
 
35
-    /**
36
-     * @param bool $as_array
37
-     * @return array|string
38
-     */
39
-    public function getForm($as_array = false)
40
-    {
41
-        return FormController::getFormCategory($this, $as_array);
42
-    }
35
+	/**
36
+	 * @param bool $as_array
37
+	 * @return array|string
38
+	 */
39
+	public function getForm($as_array = false)
40
+	{
41
+		return FormController::getFormCategory($this, $as_array);
42
+	}
43 43
 
44
-    /**
45
-     * @return array
46
-     */
47
-    public function toArray(): array
48
-    {
49
-        $ret  = parent::toArray();
50
-        $form = $this->getForm(true);
51
-        foreach ($form as $key => $element) {
52
-            $ret['form'][$key] = $element->render();
53
-        }
54
-        foreach (['created', 'updated'] as $key) {
55
-            if ($this->getVar($key) > 0) {
56
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
57
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
58
-            }
59
-        }
60
-        $ret['picture']  = $this->getImage('image', false);
61
-        $ret['rank']     = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
62
-        $ret['url']      = $this->getURL();
63
-        $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
64
-        if ($categoryHandler->getCount(new \Criteria('pid', $this->getVar('cid')))) {
65
-            foreach ($categoryHandler->getObjects(new \Criteria('pid', $this->getVar('cid')), true) as $cid => $cat) {
66
-                $ret['subcategories'][$cid] = $cat->toArray();
67
-            }
68
-        }
44
+	/**
45
+	 * @return array
46
+	 */
47
+	public function toArray(): array
48
+	{
49
+		$ret  = parent::toArray();
50
+		$form = $this->getForm(true);
51
+		foreach ($form as $key => $element) {
52
+			$ret['form'][$key] = $element->render();
53
+		}
54
+		foreach (['created', 'updated'] as $key) {
55
+			if ($this->getVar($key) > 0) {
56
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
57
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
58
+			}
59
+		}
60
+		$ret['picture']  = $this->getImage('image', false);
61
+		$ret['rank']     = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
62
+		$ret['url']      = $this->getURL();
63
+		$categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
64
+		if ($categoryHandler->getCount(new \Criteria('pid', $this->getVar('cid')))) {
65
+			foreach ($categoryHandler->getObjects(new \Criteria('pid', $this->getVar('cid')), true) as $cid => $cat) {
66
+				$ret['subcategories'][$cid] = $cat->toArray();
67
+			}
68
+		}
69 69
 
70
-        return $ret;
71
-    }
70
+		return $ret;
71
+	}
72 72
 
73
-    /**
74
-     * @param string $field
75
-     * @param bool   $local
76
-     * @return bool|string
77
-     */
78
-    public function getImage($field = 'image', $local = false)
79
-    {
80
-        if ('' == $this->getVar($field)) {
81
-            return false;
82
-        }
83
-        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
84
-            return false;
85
-        }
86
-        if (!$local) {
87
-            return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
88
-        }
73
+	/**
74
+	 * @param string $field
75
+	 * @param bool   $local
76
+	 * @return bool|string
77
+	 */
78
+	public function getImage($field = 'image', $local = false)
79
+	{
80
+		if ('' == $this->getVar($field)) {
81
+			return false;
82
+		}
83
+		if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
84
+			return false;
85
+		}
86
+		if (!$local) {
87
+			return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
88
+		}
89 89
 
90
-        return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
91
-    }
90
+		return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
91
+	}
92 92
 
93
-    /**
94
-     * @return string
95
-     */
96
-    public function getURL(): string
97
-    {
98
-        global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
93
+	/**
94
+	 * @return string
95
+	 */
96
+	public function getURL(): string
97
+	{
98
+		global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
99 99
 
100
-        return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=category&fct=set&id=' . $this->getVar('cid') . '&value=' . \urlencode($file??'') . '&gid=' . $gid . '&cid=' . $cid;
101
-    }
100
+		return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=category&fct=set&id=' . $this->getVar('cid') . '&value=' . \urlencode($file??'') . '&gid=' . $gid . '&cid=' . $cid;
101
+	}
102 102
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
             $ret['form'][$key] = $element->render();
53 53
         }
54 54
         foreach (['created', 'updated'] as $key) {
55
-            if ($this->getVar($key) > 0) {
55
+            if ($this->getVar($key)>0) {
56 56
                 $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
57 57
                 $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
58 58
             }
59 59
         }
60 60
         $ret['picture']  = $this->getImage('image', false);
61
-        $ret['rank']     = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
61
+        $ret['rank']     = \number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2).\_MI_SONGLIST_OFTEN;
62 62
         $ret['url']      = $this->getURL();
63 63
         $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
64 64
         if ($categoryHandler->getCount(new \Criteria('pid', $this->getVar('cid')))) {
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function getImage($field = 'image', $local = false)
79 79
     {
80
-        if ('' == $this->getVar($field)) {
80
+        if (''==$this->getVar($field)) {
81 81
             return false;
82 82
         }
83
-        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
83
+        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path').$this->getVar($field)))) {
84 84
             return false;
85 85
         }
86 86
         if (!$local) {
87
-            return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
87
+            return XOOPS_URL.'/'.\str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
88 88
         }
89 89
 
90
-        return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
90
+        return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
91 91
     }
92 92
 
93 93
     /**
@@ -97,6 +97,6 @@  discard block
 block discarded – undo
97 97
     {
98 98
         global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
99 99
 
100
-        return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=category&fct=set&id=' . $this->getVar('cid') . '&value=' . \urlencode($file??'') . '&gid=' . $gid . '&cid=' . $cid;
100
+        return XOOPS_URL.'/modules/songlist/'.$file.'.php?op=category&fct=set&id='.$this->getVar('cid').'&value='.\urlencode($file ?? '').'&gid='.$gid.'&cid='.$cid;
101 101
     }
102 102
 }
Please login to merge, or discard this patch.
class/Songs.php 2 patches
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -15,169 +15,169 @@
 block discarded – undo
15 15
  */
16 16
 class Songs extends XoopsObject
17 17
 {
18
-    /**
19
-     * Songs constructor.
20
-     * @param null $fid
21
-     */
22
-    public function __construct($fid = null)
23
-    {
24
-        $this->initVar('sid', \XOBJ_DTYPE_INT, 0, false);
25
-        $this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
26
-        $this->initVar('gids', \XOBJ_DTYPE_ARRAY, 0, false);
27
-        $this->initVar('vcid', \XOBJ_DTYPE_INT, 0, false);
28
-        $this->initVar('aids', \XOBJ_DTYPE_ARRAY, [], false);
29
-        $this->initVar('abid', \XOBJ_DTYPE_INT, 0, false);
30
-        $this->initVar('songid', \XOBJ_DTYPE_TXTBOX, null, false, 32);
31
-        $this->initVar('traxid', \XOBJ_DTYPE_TXTBOX, null, false, 32);
32
-        $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
33
-        $this->initVar('lyrics', \XOBJ_DTYPE_OTHER, null, false);
34
-        $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
35
-        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
36
-        $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
37
-        $this->initVar('tags', \XOBJ_DTYPE_TXTBOX, null, false, 255);
38
-        $this->initVar('mp3', \XOBJ_DTYPE_OTHER, null, false, 500);
39
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
40
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
41
-    }
42
-
43
-    /**
44
-     * @param bool $as_array
45
-     * @return array|string
46
-     */
47
-    public function getForm($as_array = false)
48
-    {
49
-        return FormController::getFormSongs($this, $as_array);
50
-    }
51
-
52
-    /**
53
-     * @param bool $extra
54
-     * @return array
55
-     */
56
-    public function toArray($extra = true): array
57
-    {
58
-        $ret = parent::toArray();
59
-
60
-        $GLOBALS['myts'] = MyTextSanitizer::getInstance();
61
-
62
-        $ret['lyrics'] = $GLOBALS['myts']->displayTarea($this->getVar('lyrics'), true, true, true, true, true);
63
-
64
-        $form = $this->getForm(true);
65
-        foreach ($form as $key => $element) {
66
-            $ret['form'][$key] = $element->render();
67
-        }
68
-        foreach (['created', 'updated'] as $key) {
69
-            if ($this->getVar($key) > 0) {
70
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
71
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
72
-            }
73
-        }
74
-
75
-        $ret['url'] = $this->getURL();
76
-
77
-        $ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
78
-
79
-        if (!empty($ret['mp3'])) {
80
-            $ret['mp3'] = '<embed flashvars="playerID=1&amp;bg=0xf8f8f8&amp;leftbg=0x3786b3&amp;lefticon=0x78bee3&amp;rightbg=0x3786b3&amp;rightbghover=0x78bee3&amp;righticon=0x78bee3&amp;righticonhover=0x3786b3&amp;text=0x666666&amp;slider=0x3786b3&amp;track=0xcccccc&amp;border=0x666666&amp;loader=0x78bee3&amp;loop=no&amp;soundFile='
81
-                          . $ret['mp3']
82
-                          . "\" quality='high' menu='false' wmode='transparent' pluginspage='https://www.macromedia.com/go/getflashplayer' src='"
83
-                          . XOOPS_URL
84
-                          . "/images/form/player.swf'  width=290 height=24 type='application/x-shockwave-flash'></embed>";
85
-        }
86
-
87
-        $helper = Helper::getInstance();
88
-        if (1 == $helper->getConfig('tags')
89
-            && \class_exists(\XoopsModules\Tag\Tagbar::class)
90
-            && \xoops_isActiveModule('tag')) {
91
-            $tagbarObj     = new \XoopsModules\Tag\Tagbar();
92
-            $ret['tagbar'] = $tagbarObj->getTagbar($this->getVar('sid'), $this->getVar('cid'));
93
-        }
94
-
95
-        $extrasHandler     = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Extras');
96
-        $fieldHandler      = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Field');
97
-        $visibilityHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Visibility');
98
-
99
-        $extras = $extrasHandler->get($this->getVar('sid'));
100
-        if ($extras) {
101
-            if (\is_object($GLOBALS['xoopsUser'])) {
102
-                $fields_id = $visibilityHandler->getVisibleFields([], $GLOBALS['xoopsUser']->getGroups());
103
-            } elseif (!\is_object($GLOBALS['xoopsUser'])) {
104
-                $fields_id = $visibilityHandler->getVisibleFields([], []);
105
-            }
106
-
107
-            if (\count($fields_id) > 0) {
108
-                $criteria = new Criteria('field_id', '(' . \implode(',', $fields_id) . ')', 'IN');
109
-                $criteria->setSort('field_weight');
110
-                $fields = $fieldHandler->getObjects($criteria, true);
111
-                foreach ($fields as $id => $field) {
112
-                    if (\in_array($this->getVar('cid'), $field->getVar('cids'), true)) {
113
-                        $ret['fields'][$id]['title'] = $field->getVar('field_title');
114
-                        if (\is_object($GLOBALS['xoopsUser'])) {
115
-                            $ret['fields'][$id]['value'] = htmlspecialchars_decode($field->getOutputValue($GLOBALS['xoopsUser'], $extras));
116
-                        } elseif (!\is_object($GLOBALS['xoopsUser'])) {
117
-                            $ret['fields'][$id]['value'] = htmlspecialchars_decode($extras->getVar($field->getVar('field_name')));
118
-                        }
119
-                    }
120
-                }
121
-            }
122
-        }
123
-
124
-        if (!$extra) {
125
-            return $ret;
126
-        }
127
-
128
-        if (0 != $this->getVar('cid')) {
129
-            $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
130
-            $category        = $categoryHandler->get($this->getVar('cid'));
131
-            $ret['category'] = $category->toArray(false);
132
-        }
133
-
134
-        if (0 != \count($this->getVar('gids'))) {
135
-            $i            = 0;
136
-            $genreHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Genre');
137
-            $ret['genre'] = '';
138
-            $genres       = $genreHandler->getObjects(new Criteria('gid', '(' . \implode(',', $this->getVar('gids')) . ')', 'IN'), true);
139
-            foreach ($genres as $gid => $genre) {
140
-                $ret['genre_array'][$gid] = $genre->toArray(false);
141
-                ++$i;
142
-                $ret['genre'] .= $genre->getVar('name') . ($i < \count($genres) ? ', ' : '');
143
-            }
144
-        }
145
-        if (0 != $this->getVar('vcid')) {
146
-            $voiceHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Voice');
147
-            $voice        = $voiceHandler->get($this->getVar('vcid'));
148
-            $ret['voice'] = $voice->toArray(false);
149
-        }
150
-
151
-        if (0 != \count($this->getVar('aids'))) {
152
-            $artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
153
-            foreach ($this->getVar('aids') as $aid) {
154
-                $artist                     = $artistsHandler->get($aid);
155
-                $ret['artists_array'][$aid] = $artist->toArray(false);
156
-            }
157
-        }
158
-
159
-        if (0 != $this->getVar('abid')) {
160
-            $albumsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
161
-            $albums        = $albumsHandler->get($this->getVar('abid'));
162
-            if (null !== $albums) {
163
-                $ret['albums'] = $albums->toArray(false);
164
-            }
165
-
166
-        }
167
-
168
-        return $ret;
169
-    }
170
-
171
-    /**
172
-     * @return string
173
-     */
174
-    public function getURL(): string
175
-    {
176
-        global $file, $op, $fct, $id, $value, $vcid, $gid, $cid, $start, $limit;
177
-        if ($GLOBALS['songlistModuleConfig']['htaccess']) {
178
-            return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/index/' . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('title'))) . '/item-item-' . $this->getVar('sid') . $GLOBALS['songlistModuleConfig']['endofurl'];
179
-        }
180
-
181
-        return XOOPS_URL . '/modules/songlist/index.php?op=item&fct=item&id=' . $this->getVar('sid') . '&value=' . \urlencode($value ?? '') . '&vcid=' . $vcid . '&gid=' . $gid . '&cid=' . $cid;
182
-    }
18
+	/**
19
+	 * Songs constructor.
20
+	 * @param null $fid
21
+	 */
22
+	public function __construct($fid = null)
23
+	{
24
+		$this->initVar('sid', \XOBJ_DTYPE_INT, 0, false);
25
+		$this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
26
+		$this->initVar('gids', \XOBJ_DTYPE_ARRAY, 0, false);
27
+		$this->initVar('vcid', \XOBJ_DTYPE_INT, 0, false);
28
+		$this->initVar('aids', \XOBJ_DTYPE_ARRAY, [], false);
29
+		$this->initVar('abid', \XOBJ_DTYPE_INT, 0, false);
30
+		$this->initVar('songid', \XOBJ_DTYPE_TXTBOX, null, false, 32);
31
+		$this->initVar('traxid', \XOBJ_DTYPE_TXTBOX, null, false, 32);
32
+		$this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
33
+		$this->initVar('lyrics', \XOBJ_DTYPE_OTHER, null, false);
34
+		$this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
35
+		$this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
36
+		$this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
37
+		$this->initVar('tags', \XOBJ_DTYPE_TXTBOX, null, false, 255);
38
+		$this->initVar('mp3', \XOBJ_DTYPE_OTHER, null, false, 500);
39
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
40
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
41
+	}
42
+
43
+	/**
44
+	 * @param bool $as_array
45
+	 * @return array|string
46
+	 */
47
+	public function getForm($as_array = false)
48
+	{
49
+		return FormController::getFormSongs($this, $as_array);
50
+	}
51
+
52
+	/**
53
+	 * @param bool $extra
54
+	 * @return array
55
+	 */
56
+	public function toArray($extra = true): array
57
+	{
58
+		$ret = parent::toArray();
59
+
60
+		$GLOBALS['myts'] = MyTextSanitizer::getInstance();
61
+
62
+		$ret['lyrics'] = $GLOBALS['myts']->displayTarea($this->getVar('lyrics'), true, true, true, true, true);
63
+
64
+		$form = $this->getForm(true);
65
+		foreach ($form as $key => $element) {
66
+			$ret['form'][$key] = $element->render();
67
+		}
68
+		foreach (['created', 'updated'] as $key) {
69
+			if ($this->getVar($key) > 0) {
70
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
71
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
72
+			}
73
+		}
74
+
75
+		$ret['url'] = $this->getURL();
76
+
77
+		$ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
78
+
79
+		if (!empty($ret['mp3'])) {
80
+			$ret['mp3'] = '<embed flashvars="playerID=1&amp;bg=0xf8f8f8&amp;leftbg=0x3786b3&amp;lefticon=0x78bee3&amp;rightbg=0x3786b3&amp;rightbghover=0x78bee3&amp;righticon=0x78bee3&amp;righticonhover=0x3786b3&amp;text=0x666666&amp;slider=0x3786b3&amp;track=0xcccccc&amp;border=0x666666&amp;loader=0x78bee3&amp;loop=no&amp;soundFile='
81
+						  . $ret['mp3']
82
+						  . "\" quality='high' menu='false' wmode='transparent' pluginspage='https://www.macromedia.com/go/getflashplayer' src='"
83
+						  . XOOPS_URL
84
+						  . "/images/form/player.swf'  width=290 height=24 type='application/x-shockwave-flash'></embed>";
85
+		}
86
+
87
+		$helper = Helper::getInstance();
88
+		if (1 == $helper->getConfig('tags')
89
+			&& \class_exists(\XoopsModules\Tag\Tagbar::class)
90
+			&& \xoops_isActiveModule('tag')) {
91
+			$tagbarObj     = new \XoopsModules\Tag\Tagbar();
92
+			$ret['tagbar'] = $tagbarObj->getTagbar($this->getVar('sid'), $this->getVar('cid'));
93
+		}
94
+
95
+		$extrasHandler     = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Extras');
96
+		$fieldHandler      = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Field');
97
+		$visibilityHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Visibility');
98
+
99
+		$extras = $extrasHandler->get($this->getVar('sid'));
100
+		if ($extras) {
101
+			if (\is_object($GLOBALS['xoopsUser'])) {
102
+				$fields_id = $visibilityHandler->getVisibleFields([], $GLOBALS['xoopsUser']->getGroups());
103
+			} elseif (!\is_object($GLOBALS['xoopsUser'])) {
104
+				$fields_id = $visibilityHandler->getVisibleFields([], []);
105
+			}
106
+
107
+			if (\count($fields_id) > 0) {
108
+				$criteria = new Criteria('field_id', '(' . \implode(',', $fields_id) . ')', 'IN');
109
+				$criteria->setSort('field_weight');
110
+				$fields = $fieldHandler->getObjects($criteria, true);
111
+				foreach ($fields as $id => $field) {
112
+					if (\in_array($this->getVar('cid'), $field->getVar('cids'), true)) {
113
+						$ret['fields'][$id]['title'] = $field->getVar('field_title');
114
+						if (\is_object($GLOBALS['xoopsUser'])) {
115
+							$ret['fields'][$id]['value'] = htmlspecialchars_decode($field->getOutputValue($GLOBALS['xoopsUser'], $extras));
116
+						} elseif (!\is_object($GLOBALS['xoopsUser'])) {
117
+							$ret['fields'][$id]['value'] = htmlspecialchars_decode($extras->getVar($field->getVar('field_name')));
118
+						}
119
+					}
120
+				}
121
+			}
122
+		}
123
+
124
+		if (!$extra) {
125
+			return $ret;
126
+		}
127
+
128
+		if (0 != $this->getVar('cid')) {
129
+			$categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
130
+			$category        = $categoryHandler->get($this->getVar('cid'));
131
+			$ret['category'] = $category->toArray(false);
132
+		}
133
+
134
+		if (0 != \count($this->getVar('gids'))) {
135
+			$i            = 0;
136
+			$genreHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Genre');
137
+			$ret['genre'] = '';
138
+			$genres       = $genreHandler->getObjects(new Criteria('gid', '(' . \implode(',', $this->getVar('gids')) . ')', 'IN'), true);
139
+			foreach ($genres as $gid => $genre) {
140
+				$ret['genre_array'][$gid] = $genre->toArray(false);
141
+				++$i;
142
+				$ret['genre'] .= $genre->getVar('name') . ($i < \count($genres) ? ', ' : '');
143
+			}
144
+		}
145
+		if (0 != $this->getVar('vcid')) {
146
+			$voiceHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Voice');
147
+			$voice        = $voiceHandler->get($this->getVar('vcid'));
148
+			$ret['voice'] = $voice->toArray(false);
149
+		}
150
+
151
+		if (0 != \count($this->getVar('aids'))) {
152
+			$artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
153
+			foreach ($this->getVar('aids') as $aid) {
154
+				$artist                     = $artistsHandler->get($aid);
155
+				$ret['artists_array'][$aid] = $artist->toArray(false);
156
+			}
157
+		}
158
+
159
+		if (0 != $this->getVar('abid')) {
160
+			$albumsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
161
+			$albums        = $albumsHandler->get($this->getVar('abid'));
162
+			if (null !== $albums) {
163
+				$ret['albums'] = $albums->toArray(false);
164
+			}
165
+
166
+		}
167
+
168
+		return $ret;
169
+	}
170
+
171
+	/**
172
+	 * @return string
173
+	 */
174
+	public function getURL(): string
175
+	{
176
+		global $file, $op, $fct, $id, $value, $vcid, $gid, $cid, $start, $limit;
177
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
178
+			return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/index/' . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('title'))) . '/item-item-' . $this->getVar('sid') . $GLOBALS['songlistModuleConfig']['endofurl'];
179
+		}
180
+
181
+		return XOOPS_URL . '/modules/songlist/index.php?op=item&fct=item&id=' . $this->getVar('sid') . '&value=' . \urlencode($value ?? '') . '&vcid=' . $vcid . '&gid=' . $gid . '&cid=' . $cid;
182
+	}
183 183
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use MyTextSanitizer;
7 7
 use XoopsObject;
8 8
 
9
-require_once \dirname(__DIR__) . '/include/songlist.object.php';
9
+require_once \dirname(__DIR__).'/include/songlist.object.php';
10 10
 // require_once \dirname(__DIR__) . '/include/songlist.form.php';
11 11
 use  XoopsModules\Songlist\Form\FormController;
12 12
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             $ret['form'][$key] = $element->render();
67 67
         }
68 68
         foreach (['created', 'updated'] as $key) {
69
-            if ($this->getVar($key) > 0) {
69
+            if ($this->getVar($key)>0) {
70 70
                 $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
71 71
                 $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
72 72
             }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
         $ret['url'] = $this->getURL();
76 76
 
77
-        $ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
77
+        $ret['rank'] = \number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2).\_MI_SONGLIST_OFTEN;
78 78
 
79 79
         if (!empty($ret['mp3'])) {
80 80
             $ret['mp3'] = '<embed flashvars="playerID=1&amp;bg=0xf8f8f8&amp;leftbg=0x3786b3&amp;lefticon=0x78bee3&amp;rightbg=0x3786b3&amp;rightbghover=0x78bee3&amp;righticon=0x78bee3&amp;righticonhover=0x3786b3&amp;text=0x666666&amp;slider=0x3786b3&amp;track=0xcccccc&amp;border=0x666666&amp;loader=0x78bee3&amp;loop=no&amp;soundFile='
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         }
86 86
 
87 87
         $helper = Helper::getInstance();
88
-        if (1 == $helper->getConfig('tags')
88
+        if (1==$helper->getConfig('tags')
89 89
             && \class_exists(\XoopsModules\Tag\Tagbar::class)
90 90
             && \xoops_isActiveModule('tag')) {
91 91
             $tagbarObj     = new \XoopsModules\Tag\Tagbar();
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
                 $fields_id = $visibilityHandler->getVisibleFields([], []);
105 105
             }
106 106
 
107
-            if (\count($fields_id) > 0) {
108
-                $criteria = new Criteria('field_id', '(' . \implode(',', $fields_id) . ')', 'IN');
107
+            if (\count($fields_id)>0) {
108
+                $criteria = new Criteria('field_id', '('.\implode(',', $fields_id).')', 'IN');
109 109
                 $criteria->setSort('field_weight');
110 110
                 $fields = $fieldHandler->getObjects($criteria, true);
111 111
                 foreach ($fields as $id => $field) {
@@ -125,30 +125,30 @@  discard block
 block discarded – undo
125 125
             return $ret;
126 126
         }
127 127
 
128
-        if (0 != $this->getVar('cid')) {
128
+        if (0!=$this->getVar('cid')) {
129 129
             $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
130 130
             $category        = $categoryHandler->get($this->getVar('cid'));
131 131
             $ret['category'] = $category->toArray(false);
132 132
         }
133 133
 
134
-        if (0 != \count($this->getVar('gids'))) {
134
+        if (0!=\count($this->getVar('gids'))) {
135 135
             $i            = 0;
136 136
             $genreHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Genre');
137 137
             $ret['genre'] = '';
138
-            $genres       = $genreHandler->getObjects(new Criteria('gid', '(' . \implode(',', $this->getVar('gids')) . ')', 'IN'), true);
138
+            $genres       = $genreHandler->getObjects(new Criteria('gid', '('.\implode(',', $this->getVar('gids')).')', 'IN'), true);
139 139
             foreach ($genres as $gid => $genre) {
140 140
                 $ret['genre_array'][$gid] = $genre->toArray(false);
141 141
                 ++$i;
142
-                $ret['genre'] .= $genre->getVar('name') . ($i < \count($genres) ? ', ' : '');
142
+                $ret['genre'] .= $genre->getVar('name').($i<\count($genres) ? ', ' : '');
143 143
             }
144 144
         }
145
-        if (0 != $this->getVar('vcid')) {
145
+        if (0!=$this->getVar('vcid')) {
146 146
             $voiceHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Voice');
147 147
             $voice        = $voiceHandler->get($this->getVar('vcid'));
148 148
             $ret['voice'] = $voice->toArray(false);
149 149
         }
150 150
 
151
-        if (0 != \count($this->getVar('aids'))) {
151
+        if (0!=\count($this->getVar('aids'))) {
152 152
             $artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
153 153
             foreach ($this->getVar('aids') as $aid) {
154 154
                 $artist                     = $artistsHandler->get($aid);
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
             }
157 157
         }
158 158
 
159
-        if (0 != $this->getVar('abid')) {
159
+        if (0!=$this->getVar('abid')) {
160 160
             $albumsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
161 161
             $albums        = $albumsHandler->get($this->getVar('abid'));
162
-            if (null !== $albums) {
162
+            if (null!==$albums) {
163 163
                 $ret['albums'] = $albums->toArray(false);
164 164
             }
165 165
 
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
     {
176 176
         global $file, $op, $fct, $id, $value, $vcid, $gid, $cid, $start, $limit;
177 177
         if ($GLOBALS['songlistModuleConfig']['htaccess']) {
178
-            return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/index/' . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('title'))) . '/item-item-' . $this->getVar('sid') . $GLOBALS['songlistModuleConfig']['endofurl'];
178
+            return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/index/'.\urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('title'))).'/item-item-'.$this->getVar('sid').$GLOBALS['songlistModuleConfig']['endofurl'];
179 179
         }
180 180
 
181
-        return XOOPS_URL . '/modules/songlist/index.php?op=item&fct=item&id=' . $this->getVar('sid') . '&value=' . \urlencode($value ?? '') . '&vcid=' . $vcid . '&gid=' . $gid . '&cid=' . $cid;
181
+        return XOOPS_URL.'/modules/songlist/index.php?op=item&fct=item&id='.$this->getVar('sid').'&value='.\urlencode($value ?? '').'&vcid='.$vcid.'&gid='.$gid.'&cid='.$cid;
182 182
     }
183 183
 }
Please login to merge, or discard this patch.
class/VisibilityHandler.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -27,81 +27,81 @@
 block discarded – undo
27 27
  */
28 28
 class VisibilityHandler extends XoopsPersistableObjectHandler
29 29
 {
30
-    /**
31
-     * VisibilityHandler constructor.
32
-     * @param \XoopsDatabase $db
33
-     */
34
-    public function __construct(XoopsDatabase $db)
35
-    {
36
-        parent::__construct($db, 'songlist_visibility', Visibility::class, 'field_id');
37
-    }
30
+	/**
31
+	 * VisibilityHandler constructor.
32
+	 * @param \XoopsDatabase $db
33
+	 */
34
+	public function __construct(XoopsDatabase $db)
35
+	{
36
+		parent::__construct($db, 'songlist_visibility', Visibility::class, 'field_id');
37
+	}
38 38
 
39
-    /**
40
-     * get all objects matching a condition
41
-     *
42
-     * @param \CriteriaElement|null $criteria {@link \CriteriaElement} to match
43
-     * @param null                  $fields
44
-     * @param bool                  $asObject
45
-     * @param bool                  $id_as_key
46
-     * @return array of objects/array <a href='psi_element://XoopsObject'>XoopsObject</a>
47
-     * @internal param array $fields variables to fetch
48
-     * @internal param bool $asObject flag indicating as object, otherwise as array
49
-     * @internal param bool $id_as_key use the ID as key for the array
50
-     */
51
-    public function &getAll(CriteriaElement $criteria = null, $fields = null, $asObject = true, $id_as_key = true): array //getAll($criteria = null)
52
-    {
53
-        $limit            = null;
54
-        $GLOBALS['start'] = null;
55
-        $sql              = "SELECT * FROM `{$this->table}`";
56
-        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
57
-            $sql     .= ' ' . $criteria->renderWhere();
58
-            $groupby = $criteria->getGroupby();
59
-            if ($groupby) {
60
-                $sql .= ' ' . $groupby;
61
-            }
62
-            $sort = $criteria->getSort();
63
-            if ($sort) {
64
-                $sql      .= " ORDER BY {$sort} " . $criteria->getOrder();
65
-                $orderSet = true;
66
-            }
67
-            $limit            = $criteria->getLimit();
68
-            $GLOBALS['start'] = $criteria->getStart();
69
-        }
70
-        if (empty($orderSet)) {
71
-            $sql .= " ORDER BY `{$this->keyName}` DESC";
72
-        }
73
-        $result = $this->db->query($sql, $limit, $GLOBALS['start']);
74
-        $ret    = [];
75
-        while (false !== ($row = $this->db->fetchArray($result))) {
76
-            $ret[$row['field_id']][] = $row;
77
-        }
39
+	/**
40
+	 * get all objects matching a condition
41
+	 *
42
+	 * @param \CriteriaElement|null $criteria {@link \CriteriaElement} to match
43
+	 * @param null                  $fields
44
+	 * @param bool                  $asObject
45
+	 * @param bool                  $id_as_key
46
+	 * @return array of objects/array <a href='psi_element://XoopsObject'>XoopsObject</a>
47
+	 * @internal param array $fields variables to fetch
48
+	 * @internal param bool $asObject flag indicating as object, otherwise as array
49
+	 * @internal param bool $id_as_key use the ID as key for the array
50
+	 */
51
+	public function &getAll(CriteriaElement $criteria = null, $fields = null, $asObject = true, $id_as_key = true): array //getAll($criteria = null)
52
+	{
53
+		$limit            = null;
54
+		$GLOBALS['start'] = null;
55
+		$sql              = "SELECT * FROM `{$this->table}`";
56
+		if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
57
+			$sql     .= ' ' . $criteria->renderWhere();
58
+			$groupby = $criteria->getGroupby();
59
+			if ($groupby) {
60
+				$sql .= ' ' . $groupby;
61
+			}
62
+			$sort = $criteria->getSort();
63
+			if ($sort) {
64
+				$sql      .= " ORDER BY {$sort} " . $criteria->getOrder();
65
+				$orderSet = true;
66
+			}
67
+			$limit            = $criteria->getLimit();
68
+			$GLOBALS['start'] = $criteria->getStart();
69
+		}
70
+		if (empty($orderSet)) {
71
+			$sql .= " ORDER BY `{$this->keyName}` DESC";
72
+		}
73
+		$result = $this->db->query($sql, $limit, $GLOBALS['start']);
74
+		$ret    = [];
75
+		while (false !== ($row = $this->db->fetchArray($result))) {
76
+			$ret[$row['field_id']][] = $row;
77
+		}
78 78
 
79
-        return $ret;
80
-    }
79
+		return $ret;
80
+	}
81 81
 
82
-    /**
83
-     * Get fields visible to the $user_groups on a $profile_groups profile
84
-     *
85
-     * @param array $profile_groups groups of the user to be accessed
86
-     * @param array $user_groups    groups of the visitor, default as $GLOBALS['xoopsUser']
87
-     *
88
-     * @return array
89
-     */
90
-    public function getVisibleFields($profile_groups, $user_groups = []): array
91
-    {
92
-        $profile_groups[] = '0';
93
-        $user_groups[]    = '0';
94
-        $profile_groups[] = $user_groups[] = 0;
95
-        $sql              = "SELECT field_id FROM {$this->table} WHERE profile_group IN (" . \implode(',', $profile_groups) . ')';
96
-        $sql              .= ' AND user_group IN (' . \implode(',', $user_groups) . ')';
97
-        $field_ids        = [];
98
-        $result           = $this->db->query($sql);
99
-        if ($result) {
100
-            while ([$field_id] = $this->db->fetchRow($result)) {
101
-                $field_ids[] = $field_id;
102
-            }
103
-        }
82
+	/**
83
+	 * Get fields visible to the $user_groups on a $profile_groups profile
84
+	 *
85
+	 * @param array $profile_groups groups of the user to be accessed
86
+	 * @param array $user_groups    groups of the visitor, default as $GLOBALS['xoopsUser']
87
+	 *
88
+	 * @return array
89
+	 */
90
+	public function getVisibleFields($profile_groups, $user_groups = []): array
91
+	{
92
+		$profile_groups[] = '0';
93
+		$user_groups[]    = '0';
94
+		$profile_groups[] = $user_groups[] = 0;
95
+		$sql              = "SELECT field_id FROM {$this->table} WHERE profile_group IN (" . \implode(',', $profile_groups) . ')';
96
+		$sql              .= ' AND user_group IN (' . \implode(',', $user_groups) . ')';
97
+		$field_ids        = [];
98
+		$result           = $this->db->query($sql);
99
+		if ($result) {
100
+			while ([$field_id] = $this->db->fetchRow($result)) {
101
+				$field_ids[] = $field_id;
102
+			}
103
+		}
104 104
 
105
-        return $field_ids;
106
-    }
105
+		return $field_ids;
106
+	}
107 107
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
         $GLOBALS['start'] = null;
55 55
         $sql              = "SELECT * FROM `{$this->table}`";
56 56
         if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
57
-            $sql     .= ' ' . $criteria->renderWhere();
57
+            $sql     .= ' '.$criteria->renderWhere();
58 58
             $groupby = $criteria->getGroupby();
59 59
             if ($groupby) {
60
-                $sql .= ' ' . $groupby;
60
+                $sql .= ' '.$groupby;
61 61
             }
62 62
             $sort = $criteria->getSort();
63 63
             if ($sort) {
64
-                $sql      .= " ORDER BY {$sort} " . $criteria->getOrder();
64
+                $sql .= " ORDER BY {$sort} ".$criteria->getOrder();
65 65
                 $orderSet = true;
66 66
             }
67 67
             $limit            = $criteria->getLimit();
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         }
73 73
         $result = $this->db->query($sql, $limit, $GLOBALS['start']);
74 74
         $ret    = [];
75
-        while (false !== ($row = $this->db->fetchArray($result))) {
75
+        while (false!==($row = $this->db->fetchArray($result))) {
76 76
             $ret[$row['field_id']][] = $row;
77 77
         }
78 78
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
         $profile_groups[] = '0';
93 93
         $user_groups[]    = '0';
94 94
         $profile_groups[] = $user_groups[] = 0;
95
-        $sql              = "SELECT field_id FROM {$this->table} WHERE profile_group IN (" . \implode(',', $profile_groups) . ')';
96
-        $sql              .= ' AND user_group IN (' . \implode(',', $user_groups) . ')';
95
+        $sql              = "SELECT field_id FROM {$this->table} WHERE profile_group IN (".\implode(',', $profile_groups).')';
96
+        $sql .= ' AND user_group IN ('.\implode(',', $user_groups).')';
97 97
         $field_ids        = [];
98 98
         $result           = $this->db->query($sql);
99 99
         if ($result) {
Please login to merge, or discard this patch.
class/VotesHandler.php 2 patches
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -17,140 +17,140 @@
 block discarded – undo
17 17
  */
18 18
 class VotesHandler extends XoopsPersistableObjectHandler
19 19
 {
20
-    /**
21
-     * VotesHandler constructor.
22
-     * @param \XoopsDatabase $db
23
-     */
24
-    public function __construct(XoopsDatabase $db)
25
-    {
26
-        parent::__construct($db, 'songlist_votes', Votes::class, 'vid', 'ip');
27
-    }
28
-
29
-    /**
30
-     * @return array
31
-     */
32
-    public function filterFields(): array
33
-    {
34
-        return ['vid', 'sid', 'uid', 'ip', 'netaddy', 'rank'];
35
-    }
36
-
37
-    /**
38
-     * @param string $filter
39
-     * @return \CriteriaCompo
40
-     */
41
-    public function getFilterCriteria($filter): CriteriaCompo
42
-    {
43
-        $parts    = \explode('|', $filter);
44
-        $criteria = new CriteriaCompo();
45
-        foreach ($parts as $part) {
46
-            $var = \explode(',', $part);
47
-            if (!empty($var[1]) && !\is_numeric($var[0])) {
48
-                $object = $this->create();
49
-                if (\XOBJ_DTYPE_TXTBOX == $object->vars[$var[0]]['data_type']
50
-                    || \XOBJ_DTYPE_TXTAREA == $object->vars[$var[0]]['data_type']) {
51
-                    $criteria->add(new Criteria('`' . $var[0] . '`', '%' . $var[1] . '%', ($var[2] ?? 'LIKE')));
52
-                } elseif (in_array($object->vars[$var[0]]['data_type'], [XOBJ_DTYPE_INT, XOBJ_DTYPE_DECIMAL, XOBJ_DTYPE_FLOAT])) {
53
-                    $criteria->add(new Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '=')));
54
-                } elseif (\XOBJ_DTYPE_ENUM == $object->vars[$var[0]]['data_type']) {
55
-                    $criteria->add(new Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '=')));
56
-                } elseif (\XOBJ_DTYPE_ARRAY == $object->vars[$var[0]]['data_type']) {
57
-                    $criteria->add(new Criteria('`' . $var[0] . '`', '%"' . $var[1] . '";%', ($var[2] ?? 'LIKE')));
58
-                }
59
-            } elseif (!empty($var[1]) && \is_numeric($var[0])) {
60
-                $criteria->add(new Criteria($var[0], $var[1]));
61
-            }
62
-        }
63
-
64
-        return $criteria;
65
-    }
66
-
67
-    /**
68
-     * @param string $filter
69
-     * @param string $field
70
-     * @param string $sort
71
-     * @param string $op
72
-     * @param string $fct
73
-     * @return string
74
-     */
75
-    public function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list'): string
76
-    {
77
-        $ele = Utility::getFilterElement($filter, $field, $sort, $op, $fct);
78
-        if (\is_object($ele)) {
79
-            return $ele->render();
80
-        }
81
-
82
-        return '&nbsp;';
83
-    }
84
-
85
-    /**
86
-     * @param bool $force
87
-     * @return mixed
88
-     */
89
-    public function insert(XoopsObject $obj, $force = true)
90
-    {
91
-        if ($obj->isNew()) {
92
-            $obj->setVar('created', \time());
93
-        } else {
94
-            $obj->setVar('updated', \time());
95
-        }
96
-
97
-        return parent::insert($obj, $force);
98
-    }
99
-
100
-    /**
101
-     * @param int $sid
102
-     * @param string$value
103
-     * @return bool
104
-     */
105
-    public function addVote($sid, $value): bool
106
-    {
107
-        $criteria = new CriteriaCompo(new Criteria('sid', $sid));
108
-
109
-        $ip = Utility::getIPData(false);
110
-        if ($ip['uid'] > 0) {
111
-            $criteria->add(new Criteria('uid', $ip['uid']));
112
-        } else {
113
-            $criteria->add(new Criteria('ip', $ip['ip']));
114
-            $criteria->add(new Criteria('netaddy', $ip['network-addy']));
115
-        }
116
-
117
-        if (0 == $this->getCount($criteria) && $sid > 0 && $value > 0) {
118
-            $vote = $this->create();
119
-            $vote->setVar('sid', $sid);
120
-            $vote->setVar('uid', $ip['uid']);
121
-            $vote->setVar('ip', $ip['ip']);
122
-            $vote->setVar('netaddy', $ip['network-addy']);
123
-            $vote->setVar('rank', $value);
124
-            if ($this->insert($vote)) {
125
-                $songsHandler    = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Songs');
126
-                $albumsHandler   = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
127
-                $artistsHandler  = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
128
-                $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
129
-                $genreHandler    = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Genre');
130
-                $voiceHandler    = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Voice');
131
-
132
-                $song  = $songsHandler->get($sid);
133
-                $sql   = [];
134
-                $sql[] = 'UPDATE `' . $songsHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $songsHandler->keyName . '` = ' . $sid;
135
-                $sql[] = 'UPDATE `' . $categoryHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $categoryHandler->keyName . '` = ' . $song->getVar($categoryHandler->keyName);
136
-                $sql[] = 'UPDATE `' . $genreHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $genreHandler->keyName . '` = ' . $song->getVar($genreHandler->keyName);
137
-                $sql[] = 'UPDATE `' . $voiceHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $voiceHandler->keyName . '` = ' . $song->getVar($voiceHandler->keyName);
138
-                $sql[] = 'UPDATE `' . $albumsHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $albumsHandler->keyName . '` = ' . $song->getVar($albumsHandler->keyName);
139
-                foreach ($song->getVar('aids') as $aid) {
140
-                    $sql[] = 'UPDATE `' . $artistsHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $artistsHandler->keyName . '` = ' . $aid;
141
-                }
142
-                foreach ($sql as $question) {
143
-                    $GLOBALS['xoopsDB']->queryF($question);
144
-                }
145
-                \redirect_header($_POST['uri'], 10, \_MD_SONGLIST_MSG_VOTED_FINISHED);
146
-                exit(0);
147
-            }
148
-            \redirect_header($_POST['uri'], 10, \_MD_SONGLIST_MSG_VOTED_ALREADY);
149
-            exit(0);
150
-        }
151
-        \redirect_header($_POST['uri'], 10, \_MD_SONGLIST_MSG_VOTED_SOMETHINGWRONG);
152
-        exit(0);
153
-
154
-        return false;
155
-    }
20
+	/**
21
+	 * VotesHandler constructor.
22
+	 * @param \XoopsDatabase $db
23
+	 */
24
+	public function __construct(XoopsDatabase $db)
25
+	{
26
+		parent::__construct($db, 'songlist_votes', Votes::class, 'vid', 'ip');
27
+	}
28
+
29
+	/**
30
+	 * @return array
31
+	 */
32
+	public function filterFields(): array
33
+	{
34
+		return ['vid', 'sid', 'uid', 'ip', 'netaddy', 'rank'];
35
+	}
36
+
37
+	/**
38
+	 * @param string $filter
39
+	 * @return \CriteriaCompo
40
+	 */
41
+	public function getFilterCriteria($filter): CriteriaCompo
42
+	{
43
+		$parts    = \explode('|', $filter);
44
+		$criteria = new CriteriaCompo();
45
+		foreach ($parts as $part) {
46
+			$var = \explode(',', $part);
47
+			if (!empty($var[1]) && !\is_numeric($var[0])) {
48
+				$object = $this->create();
49
+				if (\XOBJ_DTYPE_TXTBOX == $object->vars[$var[0]]['data_type']
50
+					|| \XOBJ_DTYPE_TXTAREA == $object->vars[$var[0]]['data_type']) {
51
+					$criteria->add(new Criteria('`' . $var[0] . '`', '%' . $var[1] . '%', ($var[2] ?? 'LIKE')));
52
+				} elseif (in_array($object->vars[$var[0]]['data_type'], [XOBJ_DTYPE_INT, XOBJ_DTYPE_DECIMAL, XOBJ_DTYPE_FLOAT])) {
53
+					$criteria->add(new Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '=')));
54
+				} elseif (\XOBJ_DTYPE_ENUM == $object->vars[$var[0]]['data_type']) {
55
+					$criteria->add(new Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '=')));
56
+				} elseif (\XOBJ_DTYPE_ARRAY == $object->vars[$var[0]]['data_type']) {
57
+					$criteria->add(new Criteria('`' . $var[0] . '`', '%"' . $var[1] . '";%', ($var[2] ?? 'LIKE')));
58
+				}
59
+			} elseif (!empty($var[1]) && \is_numeric($var[0])) {
60
+				$criteria->add(new Criteria($var[0], $var[1]));
61
+			}
62
+		}
63
+
64
+		return $criteria;
65
+	}
66
+
67
+	/**
68
+	 * @param string $filter
69
+	 * @param string $field
70
+	 * @param string $sort
71
+	 * @param string $op
72
+	 * @param string $fct
73
+	 * @return string
74
+	 */
75
+	public function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list'): string
76
+	{
77
+		$ele = Utility::getFilterElement($filter, $field, $sort, $op, $fct);
78
+		if (\is_object($ele)) {
79
+			return $ele->render();
80
+		}
81
+
82
+		return '&nbsp;';
83
+	}
84
+
85
+	/**
86
+	 * @param bool $force
87
+	 * @return mixed
88
+	 */
89
+	public function insert(XoopsObject $obj, $force = true)
90
+	{
91
+		if ($obj->isNew()) {
92
+			$obj->setVar('created', \time());
93
+		} else {
94
+			$obj->setVar('updated', \time());
95
+		}
96
+
97
+		return parent::insert($obj, $force);
98
+	}
99
+
100
+	/**
101
+	 * @param int $sid
102
+	 * @param string$value
103
+	 * @return bool
104
+	 */
105
+	public function addVote($sid, $value): bool
106
+	{
107
+		$criteria = new CriteriaCompo(new Criteria('sid', $sid));
108
+
109
+		$ip = Utility::getIPData(false);
110
+		if ($ip['uid'] > 0) {
111
+			$criteria->add(new Criteria('uid', $ip['uid']));
112
+		} else {
113
+			$criteria->add(new Criteria('ip', $ip['ip']));
114
+			$criteria->add(new Criteria('netaddy', $ip['network-addy']));
115
+		}
116
+
117
+		if (0 == $this->getCount($criteria) && $sid > 0 && $value > 0) {
118
+			$vote = $this->create();
119
+			$vote->setVar('sid', $sid);
120
+			$vote->setVar('uid', $ip['uid']);
121
+			$vote->setVar('ip', $ip['ip']);
122
+			$vote->setVar('netaddy', $ip['network-addy']);
123
+			$vote->setVar('rank', $value);
124
+			if ($this->insert($vote)) {
125
+				$songsHandler    = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Songs');
126
+				$albumsHandler   = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
127
+				$artistsHandler  = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
128
+				$categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
129
+				$genreHandler    = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Genre');
130
+				$voiceHandler    = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Voice');
131
+
132
+				$song  = $songsHandler->get($sid);
133
+				$sql   = [];
134
+				$sql[] = 'UPDATE `' . $songsHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $songsHandler->keyName . '` = ' . $sid;
135
+				$sql[] = 'UPDATE `' . $categoryHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $categoryHandler->keyName . '` = ' . $song->getVar($categoryHandler->keyName);
136
+				$sql[] = 'UPDATE `' . $genreHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $genreHandler->keyName . '` = ' . $song->getVar($genreHandler->keyName);
137
+				$sql[] = 'UPDATE `' . $voiceHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $voiceHandler->keyName . '` = ' . $song->getVar($voiceHandler->keyName);
138
+				$sql[] = 'UPDATE `' . $albumsHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $albumsHandler->keyName . '` = ' . $song->getVar($albumsHandler->keyName);
139
+				foreach ($song->getVar('aids') as $aid) {
140
+					$sql[] = 'UPDATE `' . $artistsHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $artistsHandler->keyName . '` = ' . $aid;
141
+				}
142
+				foreach ($sql as $question) {
143
+					$GLOBALS['xoopsDB']->queryF($question);
144
+				}
145
+				\redirect_header($_POST['uri'], 10, \_MD_SONGLIST_MSG_VOTED_FINISHED);
146
+				exit(0);
147
+			}
148
+			\redirect_header($_POST['uri'], 10, \_MD_SONGLIST_MSG_VOTED_ALREADY);
149
+			exit(0);
150
+		}
151
+		\redirect_header($_POST['uri'], 10, \_MD_SONGLIST_MSG_VOTED_SOMETHINGWRONG);
152
+		exit(0);
153
+
154
+		return false;
155
+	}
156 156
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use XoopsObject;
9 9
 use XoopsPersistableObjectHandler;
10 10
 
11
-require_once \dirname(__DIR__) . '/include/songlist.object.php';
11
+require_once \dirname(__DIR__).'/include/songlist.object.php';
12 12
 // require_once \dirname(__DIR__) . '/include/songlist.form.php';
13 13
 use  XoopsModules\Songlist\Form\FormController;
14 14
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
             $var = \explode(',', $part);
47 47
             if (!empty($var[1]) && !\is_numeric($var[0])) {
48 48
                 $object = $this->create();
49
-                if (\XOBJ_DTYPE_TXTBOX == $object->vars[$var[0]]['data_type']
50
-                    || \XOBJ_DTYPE_TXTAREA == $object->vars[$var[0]]['data_type']) {
51
-                    $criteria->add(new Criteria('`' . $var[0] . '`', '%' . $var[1] . '%', ($var[2] ?? 'LIKE')));
49
+                if (\XOBJ_DTYPE_TXTBOX==$object->vars[$var[0]]['data_type']
50
+                    || \XOBJ_DTYPE_TXTAREA==$object->vars[$var[0]]['data_type']) {
51
+                    $criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', ($var[2] ?? 'LIKE')));
52 52
                 } elseif (in_array($object->vars[$var[0]]['data_type'], [XOBJ_DTYPE_INT, XOBJ_DTYPE_DECIMAL, XOBJ_DTYPE_FLOAT])) {
53
-                    $criteria->add(new Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '=')));
54
-                } elseif (\XOBJ_DTYPE_ENUM == $object->vars[$var[0]]['data_type']) {
55
-                    $criteria->add(new Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '=')));
56
-                } elseif (\XOBJ_DTYPE_ARRAY == $object->vars[$var[0]]['data_type']) {
57
-                    $criteria->add(new Criteria('`' . $var[0] . '`', '%"' . $var[1] . '";%', ($var[2] ?? 'LIKE')));
53
+                    $criteria->add(new Criteria('`'.$var[0].'`', $var[1], ($var[2] ?? '=')));
54
+                } elseif (\XOBJ_DTYPE_ENUM==$object->vars[$var[0]]['data_type']) {
55
+                    $criteria->add(new Criteria('`'.$var[0].'`', $var[1], ($var[2] ?? '=')));
56
+                } elseif (\XOBJ_DTYPE_ARRAY==$object->vars[$var[0]]['data_type']) {
57
+                    $criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', ($var[2] ?? 'LIKE')));
58 58
                 }
59 59
             } elseif (!empty($var[1]) && \is_numeric($var[0])) {
60 60
                 $criteria->add(new Criteria($var[0], $var[1]));
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
         $criteria = new CriteriaCompo(new Criteria('sid', $sid));
108 108
 
109 109
         $ip = Utility::getIPData(false);
110
-        if ($ip['uid'] > 0) {
110
+        if ($ip['uid']>0) {
111 111
             $criteria->add(new Criteria('uid', $ip['uid']));
112 112
         } else {
113 113
             $criteria->add(new Criteria('ip', $ip['ip']));
114 114
             $criteria->add(new Criteria('netaddy', $ip['network-addy']));
115 115
         }
116 116
 
117
-        if (0 == $this->getCount($criteria) && $sid > 0 && $value > 0) {
117
+        if (0==$this->getCount($criteria) && $sid>0 && $value>0) {
118 118
             $vote = $this->create();
119 119
             $vote->setVar('sid', $sid);
120 120
             $vote->setVar('uid', $ip['uid']);
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 
132 132
                 $song  = $songsHandler->get($sid);
133 133
                 $sql   = [];
134
-                $sql[] = 'UPDATE `' . $songsHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $songsHandler->keyName . '` = ' . $sid;
135
-                $sql[] = 'UPDATE `' . $categoryHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $categoryHandler->keyName . '` = ' . $song->getVar($categoryHandler->keyName);
136
-                $sql[] = 'UPDATE `' . $genreHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $genreHandler->keyName . '` = ' . $song->getVar($genreHandler->keyName);
137
-                $sql[] = 'UPDATE `' . $voiceHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $voiceHandler->keyName . '` = ' . $song->getVar($voiceHandler->keyName);
138
-                $sql[] = 'UPDATE `' . $albumsHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $albumsHandler->keyName . '` = ' . $song->getVar($albumsHandler->keyName);
134
+                $sql[] = 'UPDATE `'.$songsHandler->table.'` SET `rank` = `rank` + '.$value.', `votes` = `votes` + 1 WHERE `'.$songsHandler->keyName.'` = '.$sid;
135
+                $sql[] = 'UPDATE `'.$categoryHandler->table.'` SET `rank` = `rank` + '.$value.', `votes` = `votes` + 1 WHERE `'.$categoryHandler->keyName.'` = '.$song->getVar($categoryHandler->keyName);
136
+                $sql[] = 'UPDATE `'.$genreHandler->table.'` SET `rank` = `rank` + '.$value.', `votes` = `votes` + 1 WHERE `'.$genreHandler->keyName.'` = '.$song->getVar($genreHandler->keyName);
137
+                $sql[] = 'UPDATE `'.$voiceHandler->table.'` SET `rank` = `rank` + '.$value.', `votes` = `votes` + 1 WHERE `'.$voiceHandler->keyName.'` = '.$song->getVar($voiceHandler->keyName);
138
+                $sql[] = 'UPDATE `'.$albumsHandler->table.'` SET `rank` = `rank` + '.$value.', `votes` = `votes` + 1 WHERE `'.$albumsHandler->keyName.'` = '.$song->getVar($albumsHandler->keyName);
139 139
                 foreach ($song->getVar('aids') as $aid) {
140
-                    $sql[] = 'UPDATE `' . $artistsHandler->table . '` SET `rank` = `rank` + ' . $value . ', `votes` = `votes` + 1 WHERE `' . $artistsHandler->keyName . '` = ' . $aid;
140
+                    $sql[] = 'UPDATE `'.$artistsHandler->table.'` SET `rank` = `rank` + '.$value.', `votes` = `votes` + 1 WHERE `'.$artistsHandler->keyName.'` = '.$aid;
141 141
                 }
142 142
                 foreach ($sql as $question) {
143 143
                     $GLOBALS['xoopsDB']->queryF($question);
Please login to merge, or discard this patch.
class/Albums.php 2 patches
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -11,154 +11,154 @@
 block discarded – undo
11 11
  */
12 12
 class Albums extends \XoopsObject
13 13
 {
14
-    /**
15
-     * Albums constructor.
16
-     * @param null $fid
17
-     */
18
-    public function __construct($fid = null)
19
-    {
20
-        $this->initVar('abid', \XOBJ_DTYPE_INT, 0, false);
21
-        $this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
22
-        $this->initVar('aids', \XOBJ_DTYPE_ARRAY, [], false);
23
-        $this->initVar('sids', \XOBJ_DTYPE_ARRAY, [], false);
24
-        $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
25
-        $this->initVar('image', \XOBJ_DTYPE_TXTBOX, null, false, 255);
26
-        $this->initVar('path', \XOBJ_DTYPE_TXTBOX, null, false, 255);
27
-        $this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
28
-        $this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
29
-        $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
30
-        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
31
-        $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
32
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
33
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
34
-    }
35
-
36
-    /**
37
-     * @param bool $as_array
38
-     * @return array|string
39
-     */
40
-    public function getForm($as_array = false)
41
-    {
42
-        return FormController::getFormAlbums($this, $as_array);
43
-    }
44
-
45
-    /**
46
-     * @param bool $extra
47
-     * @return array
48
-     */
49
-    public function toArray($extra = true): array
50
-    {
51
-        $ret  = parent::toArray();
52
-        $form = $this->getForm(true);
53
-        foreach ($form as $key => $element) {
54
-            $ret['form'][$key] = $element->render();
55
-        }
56
-        foreach (['created', 'updated'] as $key) {
57
-            if ($this->getVar($key) > 0) {
58
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
59
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
60
-            }
61
-        }
62
-        $ret['picture'] = $this->getImage('image', false);
63
-        $ret['rank']    = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
64
-        $ret['url']     = $this->getURL(true);
65
-
66
-        if (!$extra) {
67
-            return $ret;
68
-        }
69
-
70
-        if (0 != $this->getVar('cid')) {
71
-            $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
72
-            $category        = $categoryHandler->get($this->getVar('cid'));
73
-            if (\is_object($category)) {
74
-                $ret['category'] = $category->toArray(false);
75
-            }
76
-        }
77
-
78
-        if (0 != \count($this->getVar('aids'))) {
79
-            $artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
80
-            foreach ($this->getVar('aids') as $aid) {
81
-                $artist = $artistsHandler->get($aid);
82
-                if (\is_object($artist)) {
83
-                    $ret['artists_array'][$aid] = $artist->toArray(false);
84
-                }
85
-            }
86
-        }
87
-
88
-        if (0 != \count($this->getVar('sids'))) {
89
-            $songsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Songs');
90
-            $criteria     = new \Criteria('sid', '(' . \implode(',', $this->getVar('sids')) . ')', 'IN');
91
-            $criteria->setSort('traxid');
92
-            $criteria->setOrder('ASC');
93
-            foreach ($songsHandler->getObjects($criteria, true) as $sid => $song) {
94
-                if (\is_object($song)) {
95
-                    $ret['songs_array'][$sid] = $song->toArray(false);
96
-                }
97
-            }
98
-        }
99
-
100
-        return $ret;
101
-    }
102
-
103
-    /**
104
-     * @param string $field
105
-     * @param bool   $local
106
-     * @return bool|string
107
-     */
108
-    public function getImage($field = 'image', $local = false)
109
-    {
110
-        if ('' == $this->getVar($field)) {
111
-            return false;
112
-        }
113
-        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
114
-            return false;
115
-        }
116
-        if (!$local) {
117
-            return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
118
-        }
119
-
120
-        return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
121
-    }
122
-
123
-    /**
124
-     * @return string
125
-     */
126
-    public function getURL(): string
127
-    {
128
-        global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
129
-        if ($GLOBALS['songlistModuleConfig']['htaccess']) {
130
-            if (0 != $id) {
131
-                $artistHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
132
-                $artist        = $artistHandler->get($id);
133
-                if (\is_object($artist) && !$artist->isNew()) {
134
-                    return XOOPS_URL
135
-                           . '/'
136
-                           . $GLOBALS['songlistModuleConfig']['baseofurl']
137
-                           . '/albums/'
138
-                           . \urlencode(\str_replace([' ', \chr(9)], '-', $artist->getVar('title')))
139
-                           . '/'
140
-                           . $start
141
-                           . '-'
142
-                           . $id
143
-                           . '-'
144
-                           . $op
145
-                           . '-'
146
-                           . $fct
147
-                           . '-'
148
-                           . $gid
149
-                           . '-'
150
-                           . $cid
151
-                           . '/'
152
-                           . \urlencode($value)
153
-                           . $GLOBALS['songlistModuleConfig']['endofurl'];
154
-                }
155
-
156
-                return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
157
-            }
158
-
159
-            return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
160
-        }
161
-
162
-        return XOOPS_URL . '/modules/songlist/albums.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid . '&start=' . $start;
163
-    }
14
+	/**
15
+	 * Albums constructor.
16
+	 * @param null $fid
17
+	 */
18
+	public function __construct($fid = null)
19
+	{
20
+		$this->initVar('abid', \XOBJ_DTYPE_INT, 0, false);
21
+		$this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
22
+		$this->initVar('aids', \XOBJ_DTYPE_ARRAY, [], false);
23
+		$this->initVar('sids', \XOBJ_DTYPE_ARRAY, [], false);
24
+		$this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
25
+		$this->initVar('image', \XOBJ_DTYPE_TXTBOX, null, false, 255);
26
+		$this->initVar('path', \XOBJ_DTYPE_TXTBOX, null, false, 255);
27
+		$this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
28
+		$this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
29
+		$this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
30
+		$this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
31
+		$this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
32
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
33
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
34
+	}
35
+
36
+	/**
37
+	 * @param bool $as_array
38
+	 * @return array|string
39
+	 */
40
+	public function getForm($as_array = false)
41
+	{
42
+		return FormController::getFormAlbums($this, $as_array);
43
+	}
44
+
45
+	/**
46
+	 * @param bool $extra
47
+	 * @return array
48
+	 */
49
+	public function toArray($extra = true): array
50
+	{
51
+		$ret  = parent::toArray();
52
+		$form = $this->getForm(true);
53
+		foreach ($form as $key => $element) {
54
+			$ret['form'][$key] = $element->render();
55
+		}
56
+		foreach (['created', 'updated'] as $key) {
57
+			if ($this->getVar($key) > 0) {
58
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
59
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
60
+			}
61
+		}
62
+		$ret['picture'] = $this->getImage('image', false);
63
+		$ret['rank']    = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
64
+		$ret['url']     = $this->getURL(true);
65
+
66
+		if (!$extra) {
67
+			return $ret;
68
+		}
69
+
70
+		if (0 != $this->getVar('cid')) {
71
+			$categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
72
+			$category        = $categoryHandler->get($this->getVar('cid'));
73
+			if (\is_object($category)) {
74
+				$ret['category'] = $category->toArray(false);
75
+			}
76
+		}
77
+
78
+		if (0 != \count($this->getVar('aids'))) {
79
+			$artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
80
+			foreach ($this->getVar('aids') as $aid) {
81
+				$artist = $artistsHandler->get($aid);
82
+				if (\is_object($artist)) {
83
+					$ret['artists_array'][$aid] = $artist->toArray(false);
84
+				}
85
+			}
86
+		}
87
+
88
+		if (0 != \count($this->getVar('sids'))) {
89
+			$songsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Songs');
90
+			$criteria     = new \Criteria('sid', '(' . \implode(',', $this->getVar('sids')) . ')', 'IN');
91
+			$criteria->setSort('traxid');
92
+			$criteria->setOrder('ASC');
93
+			foreach ($songsHandler->getObjects($criteria, true) as $sid => $song) {
94
+				if (\is_object($song)) {
95
+					$ret['songs_array'][$sid] = $song->toArray(false);
96
+				}
97
+			}
98
+		}
99
+
100
+		return $ret;
101
+	}
102
+
103
+	/**
104
+	 * @param string $field
105
+	 * @param bool   $local
106
+	 * @return bool|string
107
+	 */
108
+	public function getImage($field = 'image', $local = false)
109
+	{
110
+		if ('' == $this->getVar($field)) {
111
+			return false;
112
+		}
113
+		if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
114
+			return false;
115
+		}
116
+		if (!$local) {
117
+			return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
118
+		}
119
+
120
+		return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
121
+	}
122
+
123
+	/**
124
+	 * @return string
125
+	 */
126
+	public function getURL(): string
127
+	{
128
+		global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
129
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
130
+			if (0 != $id) {
131
+				$artistHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
132
+				$artist        = $artistHandler->get($id);
133
+				if (\is_object($artist) && !$artist->isNew()) {
134
+					return XOOPS_URL
135
+						   . '/'
136
+						   . $GLOBALS['songlistModuleConfig']['baseofurl']
137
+						   . '/albums/'
138
+						   . \urlencode(\str_replace([' ', \chr(9)], '-', $artist->getVar('title')))
139
+						   . '/'
140
+						   . $start
141
+						   . '-'
142
+						   . $id
143
+						   . '-'
144
+						   . $op
145
+						   . '-'
146
+						   . $fct
147
+						   . '-'
148
+						   . $gid
149
+						   . '-'
150
+						   . $cid
151
+						   . '/'
152
+						   . \urlencode($value)
153
+						   . $GLOBALS['songlistModuleConfig']['endofurl'];
154
+				}
155
+
156
+				return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
157
+			}
158
+
159
+			return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
160
+		}
161
+
162
+		return XOOPS_URL . '/modules/songlist/albums.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid . '&start=' . $start;
163
+	}
164 164
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace XoopsModules\Songlist;
4 4
 
5
-require_once \dirname(__DIR__) . '/include/songlist.object.php';
5
+require_once \dirname(__DIR__).'/include/songlist.object.php';
6 6
 // require_once \dirname(__DIR__) . '/include/songlist.form.php';
7 7
 use  XoopsModules\Songlist\Form\FormController;
8 8
 
@@ -54,20 +54,20 @@  discard block
 block discarded – undo
54 54
             $ret['form'][$key] = $element->render();
55 55
         }
56 56
         foreach (['created', 'updated'] as $key) {
57
-            if ($this->getVar($key) > 0) {
57
+            if ($this->getVar($key)>0) {
58 58
                 $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
59 59
                 $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
60 60
             }
61 61
         }
62 62
         $ret['picture'] = $this->getImage('image', false);
63
-        $ret['rank']    = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
63
+        $ret['rank']    = \number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2).\_MI_SONGLIST_OFTEN;
64 64
         $ret['url']     = $this->getURL(true);
65 65
 
66 66
         if (!$extra) {
67 67
             return $ret;
68 68
         }
69 69
 
70
-        if (0 != $this->getVar('cid')) {
70
+        if (0!=$this->getVar('cid')) {
71 71
             $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
72 72
             $category        = $categoryHandler->get($this->getVar('cid'));
73 73
             if (\is_object($category)) {
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             }
76 76
         }
77 77
 
78
-        if (0 != \count($this->getVar('aids'))) {
78
+        if (0!=\count($this->getVar('aids'))) {
79 79
             $artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
80 80
             foreach ($this->getVar('aids') as $aid) {
81 81
                 $artist = $artistsHandler->get($aid);
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
             }
86 86
         }
87 87
 
88
-        if (0 != \count($this->getVar('sids'))) {
88
+        if (0!=\count($this->getVar('sids'))) {
89 89
             $songsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Songs');
90
-            $criteria     = new \Criteria('sid', '(' . \implode(',', $this->getVar('sids')) . ')', 'IN');
90
+            $criteria     = new \Criteria('sid', '('.\implode(',', $this->getVar('sids')).')', 'IN');
91 91
             $criteria->setSort('traxid');
92 92
             $criteria->setOrder('ASC');
93 93
             foreach ($songsHandler->getObjects($criteria, true) as $sid => $song) {
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public function getImage($field = 'image', $local = false)
109 109
     {
110
-        if ('' == $this->getVar($field)) {
110
+        if (''==$this->getVar($field)) {
111 111
             return false;
112 112
         }
113
-        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
113
+        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path').$this->getVar($field)))) {
114 114
             return false;
115 115
         }
116 116
         if (!$local) {
117
-            return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
117
+            return XOOPS_URL.'/'.\str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
118 118
         }
119 119
 
120
-        return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
120
+        return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
121 121
     }
122 122
 
123 123
     /**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     {
128 128
         global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
129 129
         if ($GLOBALS['songlistModuleConfig']['htaccess']) {
130
-            if (0 != $id) {
130
+            if (0!=$id) {
131 131
                 $artistHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
132 132
                 $artist        = $artistHandler->get($id);
133 133
                 if (\is_object($artist) && !$artist->isNew()) {
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
                            . $GLOBALS['songlistModuleConfig']['endofurl'];
154 154
                 }
155 155
 
156
-                return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
156
+                return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/albums/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.\urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
157 157
             }
158 158
 
159
-            return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
159
+            return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/albums/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.\urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
160 160
         }
161 161
 
162
-        return XOOPS_URL . '/modules/songlist/albums.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid . '&start=' . $start;
162
+        return XOOPS_URL.'/modules/songlist/albums.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.\urlencode($value ?? '').'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
163 163
     }
164 164
 }
Please login to merge, or discard this patch.
xoops_version.php 2 patches
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $configHandler             = xoops_getHandler('config');
13 13
 $GLOBALS['songlistModule'] = $moduleHandler->getByDirname('songlist');
14 14
 if (is_object($GLOBALS['songlistModule'])) {
15
-    $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid'));
15
+	$GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid'));
16 16
 }
17 17
 
18 18
 $modversion['version']             = '2.0.0';
@@ -52,18 +52,18 @@  discard block
 block discarded – undo
52 52
 
53 53
 // ------------------- Tables ------------------ //
54 54
 $modversion['tables'] = [
55
-    $moduleDirName . '_' . 'albums',
56
-    $moduleDirName . '_' . 'artists',
57
-    $moduleDirName . '_' . 'category',
58
-    $moduleDirName . '_' . 'extra',
59
-    $moduleDirName . '_' . 'field',
60
-    $moduleDirName . '_' . 'genre',
61
-    $moduleDirName . '_' . 'voice',
62
-    $moduleDirName . '_' . 'requests',
63
-    $moduleDirName . '_' . 'songs',
64
-    $moduleDirName . '_' . 'utf8map',
65
-    $moduleDirName . '_' . 'visibility',
66
-    $moduleDirName . '_' . 'votes',
55
+	$moduleDirName . '_' . 'albums',
56
+	$moduleDirName . '_' . 'artists',
57
+	$moduleDirName . '_' . 'category',
58
+	$moduleDirName . '_' . 'extra',
59
+	$moduleDirName . '_' . 'field',
60
+	$moduleDirName . '_' . 'genre',
61
+	$moduleDirName . '_' . 'voice',
62
+	$moduleDirName . '_' . 'requests',
63
+	$moduleDirName . '_' . 'songs',
64
+	$moduleDirName . '_' . 'utf8map',
65
+	$moduleDirName . '_' . 'visibility',
66
+	$moduleDirName . '_' . 'votes',
67 67
 ];
68 68
 
69 69
 // Admin things
@@ -95,52 +95,52 @@  discard block
 block discarded – undo
95 95
 
96 96
 // ------------------- Help files ------------------- //
97 97
 $modversion['helpsection'] = [
98
-    ['name' => _MI_SONGLIST_OVERVIEW, 'link' => 'page=help'],
99
-    ['name' => _MI_SONGLIST_DISCLAIMER, 'link' => 'page=disclaimer'],
100
-    ['name' => _MI_SONGLIST_LICENSE, 'link' => 'page=license'],
101
-    ['name' => _MI_SONGLIST_SUPPORT, 'link' => 'page=support'],
98
+	['name' => _MI_SONGLIST_OVERVIEW, 'link' => 'page=help'],
99
+	['name' => _MI_SONGLIST_DISCLAIMER, 'link' => 'page=disclaimer'],
100
+	['name' => _MI_SONGLIST_LICENSE, 'link' => 'page=license'],
101
+	['name' => _MI_SONGLIST_SUPPORT, 'link' => 'page=support'],
102 102
 ];
103 103
 
104 104
 // ------------------- Templates ------------------- //
105 105
 $modversion['templates'] = [
106
-    ['file' => 'songlist_albums_index.tpl', 'description' => ''],
107
-    ['file' => 'songlist_albums_item.tpl', 'description' => ''],
108
-    ['file' => 'songlist_albums_list.tpl', 'description' => ''],
109
-    ['file' => 'songlist_alpha_browse.tpl', 'description' => ''],
110
-    ['file' => 'songlist_artists_index.tpl', 'description' => ''],
111
-    ['file' => 'songlist_artists_item.tpl', 'description' => ''],
112
-    ['file' => 'songlist_artists_list.tpl', 'description' => ''],
113
-    ['file' => 'songlist_category_item.tpl', 'description' => ''],
114
-    ['file' => 'songlist_category_list.tpl', 'description' => ''],
115
-    ['file' => 'songlist_cpanel_albums_edit.tpl', 'description' => ''],
116
-    ['file' => 'songlist_cpanel_albums_list.tpl', 'description' => ''],
117
-    ['file' => 'songlist_cpanel_artists_edit.tpl', 'description' => ''],
118
-    ['file' => 'songlist_cpanel_artists_list.tpl', 'description' => ''],
119
-    ['file' => 'songlist_cpanel_category_edit.tpl', 'description' => ''],
120
-    ['file' => 'songlist_cpanel_category_list.tpl', 'description' => ''],
121
-    ['file' => 'songlist_cpanel_fieldlist.tpl', 'description' => ''],
122
-    ['file' => 'songlist_cpanel_genre_edit.tpl', 'description' => ''],
123
-    ['file' => 'songlist_cpanel_genre_list.tpl', 'description' => ''],
124
-    ['file' => 'songlist_cpanel_import_actiona.tpl', 'description' => ''],
125
-    ['file' => 'songlist_cpanel_import_actionb.tpl', 'description' => ''],
126
-    ['file' => 'songlist_cpanel_requests_edit.tpl', 'description' => ''],
127
-    ['file' => 'songlist_cpanel_requests_list.tpl', 'description' => ''],
128
-    ['file' => 'songlist_cpanel_songs_edit.tpl', 'description' => ''],
129
-    ['file' => 'songlist_cpanel_songs_list.tpl', 'description' => ''],
130
-    ['file' => 'songlist_cpanel_utf8map_edit.tpl', 'description' => ''],
131
-    ['file' => 'songlist_cpanel_utf8map_list.tpl', 'description' => ''],
132
-    ['file' => 'songlist_cpanel_visibility.tpl', 'description' => ''],
133
-    ['file' => 'songlist_cpanel_voice_edit.tpl', 'description' => ''],
134
-    ['file' => 'songlist_cpanel_voice_list.tpl', 'description' => ''],
135
-    ['file' => 'songlist_cpanel_votes_edit.tpl', 'description' => ''],
136
-    ['file' => 'songlist_cpanel_votes_list.tpl', 'description' => ''],
137
-    ['file' => 'songlist_requests_index.tpl', 'description' => ''],
138
-    ['file' => 'songlist_search_index.tpl', 'description' => ''],
139
-    ['file' => 'songlist_search_results.tpl', 'description' => ''],
140
-    ['file' => 'songlist_search_search.tpl', 'description' => ''],
141
-    ['file' => 'songlist_songs_index.tpl', 'description' => ''],
142
-    ['file' => 'songlist_songs_item.tpl', 'description' => ''],
143
-    ['file' => 'songlist_songs_list.tpl', 'description' => ''],
106
+	['file' => 'songlist_albums_index.tpl', 'description' => ''],
107
+	['file' => 'songlist_albums_item.tpl', 'description' => ''],
108
+	['file' => 'songlist_albums_list.tpl', 'description' => ''],
109
+	['file' => 'songlist_alpha_browse.tpl', 'description' => ''],
110
+	['file' => 'songlist_artists_index.tpl', 'description' => ''],
111
+	['file' => 'songlist_artists_item.tpl', 'description' => ''],
112
+	['file' => 'songlist_artists_list.tpl', 'description' => ''],
113
+	['file' => 'songlist_category_item.tpl', 'description' => ''],
114
+	['file' => 'songlist_category_list.tpl', 'description' => ''],
115
+	['file' => 'songlist_cpanel_albums_edit.tpl', 'description' => ''],
116
+	['file' => 'songlist_cpanel_albums_list.tpl', 'description' => ''],
117
+	['file' => 'songlist_cpanel_artists_edit.tpl', 'description' => ''],
118
+	['file' => 'songlist_cpanel_artists_list.tpl', 'description' => ''],
119
+	['file' => 'songlist_cpanel_category_edit.tpl', 'description' => ''],
120
+	['file' => 'songlist_cpanel_category_list.tpl', 'description' => ''],
121
+	['file' => 'songlist_cpanel_fieldlist.tpl', 'description' => ''],
122
+	['file' => 'songlist_cpanel_genre_edit.tpl', 'description' => ''],
123
+	['file' => 'songlist_cpanel_genre_list.tpl', 'description' => ''],
124
+	['file' => 'songlist_cpanel_import_actiona.tpl', 'description' => ''],
125
+	['file' => 'songlist_cpanel_import_actionb.tpl', 'description' => ''],
126
+	['file' => 'songlist_cpanel_requests_edit.tpl', 'description' => ''],
127
+	['file' => 'songlist_cpanel_requests_list.tpl', 'description' => ''],
128
+	['file' => 'songlist_cpanel_songs_edit.tpl', 'description' => ''],
129
+	['file' => 'songlist_cpanel_songs_list.tpl', 'description' => ''],
130
+	['file' => 'songlist_cpanel_utf8map_edit.tpl', 'description' => ''],
131
+	['file' => 'songlist_cpanel_utf8map_list.tpl', 'description' => ''],
132
+	['file' => 'songlist_cpanel_visibility.tpl', 'description' => ''],
133
+	['file' => 'songlist_cpanel_voice_edit.tpl', 'description' => ''],
134
+	['file' => 'songlist_cpanel_voice_list.tpl', 'description' => ''],
135
+	['file' => 'songlist_cpanel_votes_edit.tpl', 'description' => ''],
136
+	['file' => 'songlist_cpanel_votes_list.tpl', 'description' => ''],
137
+	['file' => 'songlist_requests_index.tpl', 'description' => ''],
138
+	['file' => 'songlist_search_index.tpl', 'description' => ''],
139
+	['file' => 'songlist_search_results.tpl', 'description' => ''],
140
+	['file' => 'songlist_search_search.tpl', 'description' => ''],
141
+	['file' => 'songlist_songs_index.tpl', 'description' => ''],
142
+	['file' => 'songlist_songs_item.tpl', 'description' => ''],
143
+	['file' => 'songlist_songs_list.tpl', 'description' => ''],
144 144
 ];
145 145
 
146 146
 // Submenus
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
 $modversion['sub'][$i]['url']  = 'artists.php';
150 150
 ++$i;
151 151
 if (isset($GLOBALS['songlistModuleConfig']['album'])) {
152
-    if ($GLOBALS['songlistModuleConfig']['album']) {
153
-        $modversion['sub'][$i]['name'] = _MI_SONGLIST_MENU_ALBUMS;
154
-        $modversion['sub'][$i]['url']  = 'albums.php';
155
-        ++$i;
156
-    }
152
+	if ($GLOBALS['songlistModuleConfig']['album']) {
153
+		$modversion['sub'][$i]['name'] = _MI_SONGLIST_MENU_ALBUMS;
154
+		$modversion['sub'][$i]['url']  = 'albums.php';
155
+		++$i;
156
+	}
157 157
 }
158 158
 $modversion['sub'][$i]['name'] = _MI_SONGLIST_MENU_SEARCH;
159 159
 $modversion['sub'][$i]['url']  = 'search.php';
@@ -165,90 +165,90 @@  discard block
 block discarded – undo
165 165
 $i = 0;
166 166
 // ------------------- Blocks ------------------- //
167 167
 $modversion['blocks'][$i] = [
168
-    'file'        => 'songlist_popular_artist.php',
169
-    'name'        => _MI_SONGLIST_BLOCK_TOP_ARTIST,
170
-    'description' => 'Shows top artist',
171
-    'show_func'   => 'b_songlist_popular_artist_show',
172
-    'options'     => '',
173
-    'edit_func'   => 'b_songlist_popular_artist_edit',
174
-    'template'    => 'songlist_popular_artist.tpl',
168
+	'file'        => 'songlist_popular_artist.php',
169
+	'name'        => _MI_SONGLIST_BLOCK_TOP_ARTIST,
170
+	'description' => 'Shows top artist',
171
+	'show_func'   => 'b_songlist_popular_artist_show',
172
+	'options'     => '',
173
+	'edit_func'   => 'b_songlist_popular_artist_edit',
174
+	'template'    => 'songlist_popular_artist.tpl',
175 175
 ];
176 176
 
177 177
 ++$i;
178 178
 $modversion['blocks'][$i] = [
179
-    'file'        => 'songlist_popular_artists.php',
180
-    'name'        => _MI_SONGLIST_BLOCK_POPULAR_ARTISTS,
181
-    'description' => 'Shows popular artists',
182
-    'show_func'   => 'b_songlist_popular_artists_show',
183
-    'options'     => '6',
184
-    'edit_func'   => 'b_songlist_popular_artists_edit',
185
-    'template'    => 'songlist_popular_artists.tpl',
179
+	'file'        => 'songlist_popular_artists.php',
180
+	'name'        => _MI_SONGLIST_BLOCK_POPULAR_ARTISTS,
181
+	'description' => 'Shows popular artists',
182
+	'show_func'   => 'b_songlist_popular_artists_show',
183
+	'options'     => '6',
184
+	'edit_func'   => 'b_songlist_popular_artists_edit',
185
+	'template'    => 'songlist_popular_artists.tpl',
186 186
 ];
187 187
 
188 188
 ++$i;
189 189
 $modversion['blocks'][$i] = [
190
-    'file'        => 'songlist_popular_album.php',
191
-    'name'        => _MI_SONGLIST_BLOCK_TOP_ALBUM,
192
-    'description' => 'Shows top album',
193
-    'show_func'   => 'b_songlist_popular_album_show',
194
-    'options'     => '',
195
-    'edit_func'   => 'b_songlist_popular_album_edit',
196
-    'template'    => 'songlist_popular_album.tpl',
190
+	'file'        => 'songlist_popular_album.php',
191
+	'name'        => _MI_SONGLIST_BLOCK_TOP_ALBUM,
192
+	'description' => 'Shows top album',
193
+	'show_func'   => 'b_songlist_popular_album_show',
194
+	'options'     => '',
195
+	'edit_func'   => 'b_songlist_popular_album_edit',
196
+	'template'    => 'songlist_popular_album.tpl',
197 197
 ];
198 198
 
199 199
 ++$i;
200 200
 $modversion['blocks'][$i] = [
201
-    'file'        => 'songlist_popular_albums.php',
202
-    'name'        => _MI_SONGLIST_BLOCK_POPULAR_ALBUMS,
203
-    'description' => 'Shows popular albums',
204
-    'show_func'   => 'b_songlist_popular_albums_show',
205
-    'options'     => '6',
206
-    'edit_func'   => 'b_songlist_popular_albums_edit',
207
-    'template'    => 'songlist_popular_albums.tpl',
201
+	'file'        => 'songlist_popular_albums.php',
202
+	'name'        => _MI_SONGLIST_BLOCK_POPULAR_ALBUMS,
203
+	'description' => 'Shows popular albums',
204
+	'show_func'   => 'b_songlist_popular_albums_show',
205
+	'options'     => '6',
206
+	'edit_func'   => 'b_songlist_popular_albums_edit',
207
+	'template'    => 'songlist_popular_albums.tpl',
208 208
 ];
209 209
 
210 210
 ++$i;
211 211
 $modversion['blocks'][$i] = [
212
-    'file'        => 'songlist_popular_genre.php',
213
-    'name'        => _MI_SONGLIST_BLOCK_TOP_GENRE,
214
-    'description' => 'Shows top genre',
215
-    'show_func'   => 'b_songlist_popular_genre_show',
216
-    'options'     => '',
217
-    'edit_func'   => 'b_songlist_popular_genre_edit',
218
-    'template'    => 'songlist_popular_genre.tpl',
212
+	'file'        => 'songlist_popular_genre.php',
213
+	'name'        => _MI_SONGLIST_BLOCK_TOP_GENRE,
214
+	'description' => 'Shows top genre',
215
+	'show_func'   => 'b_songlist_popular_genre_show',
216
+	'options'     => '',
217
+	'edit_func'   => 'b_songlist_popular_genre_edit',
218
+	'template'    => 'songlist_popular_genre.tpl',
219 219
 ];
220 220
 
221 221
 ++$i;
222 222
 $modversion['blocks'][$i] = [
223
-    'file'        => 'songlist_popular_genres.php',
224
-    'name'        => _MI_SONGLIST_BLOCK_POPULAR_GENRES,
225
-    'description' => 'Shows popular genres',
226
-    'show_func'   => 'b_songlist_popular_genres_show',
227
-    'options'     => '6',
228
-    'edit_func'   => 'b_songlist_popular_genres_edit',
229
-    'template'    => 'songlist_popular_genres.tpl',
223
+	'file'        => 'songlist_popular_genres.php',
224
+	'name'        => _MI_SONGLIST_BLOCK_POPULAR_GENRES,
225
+	'description' => 'Shows popular genres',
226
+	'show_func'   => 'b_songlist_popular_genres_show',
227
+	'options'     => '6',
228
+	'edit_func'   => 'b_songlist_popular_genres_edit',
229
+	'template'    => 'songlist_popular_genres.tpl',
230 230
 ];
231 231
 
232 232
 ++$i;
233 233
 $modversion['blocks'][$i] = [
234
-    'file'        => 'songlist_popular_song.php',
235
-    'name'        => _MI_SONGLIST_BLOCK_TOP_SONG,
236
-    'description' => 'Shows top song',
237
-    'show_func'   => 'b_songlist_popular_song_show',
238
-    'options'     => '',
239
-    'edit_func'   => 'b_songlist_popular_song_edit',
240
-    'template'    => 'songlist_popular_song.tpl',
234
+	'file'        => 'songlist_popular_song.php',
235
+	'name'        => _MI_SONGLIST_BLOCK_TOP_SONG,
236
+	'description' => 'Shows top song',
237
+	'show_func'   => 'b_songlist_popular_song_show',
238
+	'options'     => '',
239
+	'edit_func'   => 'b_songlist_popular_song_edit',
240
+	'template'    => 'songlist_popular_song.tpl',
241 241
 ];
242 242
 
243 243
 ++$i;
244 244
 $modversion['blocks'][$i] = [
245
-    'file'        => 'songlist_popular_songs.php',
246
-    'name'        => _MI_SONGLIST_BLOCK_POPULAR_SONGS,
247
-    'description' => 'Shows popular songs',
248
-    'show_func'   => 'b_songlist_popular_songs_show',
249
-    'options'     => '6',
250
-    'edit_func'   => 'b_songlist_popular_songs_edit',
251
-    'template'    => 'songlist_popular_songs.tpl',
245
+	'file'        => 'songlist_popular_songs.php',
246
+	'name'        => _MI_SONGLIST_BLOCK_POPULAR_SONGS,
247
+	'description' => 'Shows popular songs',
248
+	'show_func'   => 'b_songlist_popular_songs_show',
249
+	'options'     => '6',
250
+	'edit_func'   => 'b_songlist_popular_songs_edit',
251
+	'template'    => 'songlist_popular_songs.tpl',
252 252
 ];
253 253
 
254 254
 // default admin editor
@@ -257,127 +257,127 @@  discard block
 block discarded – undo
257 257
 $editorList    = array_flip($editorHandler->getList());
258 258
 
259 259
 $modversion['config'][] = [
260
-    'name'        => 'editor',
261
-    'title'       => '_MI_SONGLIST_EDITORS',
262
-    'description' => '_MI_SONGLIST_EDITORS_DESC',
263
-    'formtype'    => 'select',
264
-    'valuetype'   => 'text',
265
-    'default'     => 'tinymce',
266
-    'options'     => $editorList,
260
+	'name'        => 'editor',
261
+	'title'       => '_MI_SONGLIST_EDITORS',
262
+	'description' => '_MI_SONGLIST_EDITORS_DESC',
263
+	'formtype'    => 'select',
264
+	'valuetype'   => 'text',
265
+	'default'     => 'tinymce',
266
+	'options'     => $editorList,
267 267
 ];
268 268
 
269 269
 $modversion['config'][] = [
270
-    'name'        => 'salt',
271
-    'title'       => '_MI_SONGLIST_SALT',
272
-    'description' => '_MI_SONGLIST_SALT_DESC',
273
-    'formtype'    => 'text',
274
-    'valuetype'   => 'text',
275
-    'default'     => (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
276
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
277
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
278
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
279
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
280
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
281
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
282
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
283
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
284
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
285
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
286
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
287
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
288
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : ''),
289
-
290
-    'options' => [],
270
+	'name'        => 'salt',
271
+	'title'       => '_MI_SONGLIST_SALT',
272
+	'description' => '_MI_SONGLIST_SALT_DESC',
273
+	'formtype'    => 'text',
274
+	'valuetype'   => 'text',
275
+	'default'     => (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
276
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
277
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
278
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
279
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
280
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
281
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
282
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
283
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
284
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
285
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
286
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
287
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
288
+					 . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : ''),
289
+
290
+	'options' => [],
291 291
 ];
292 292
 
293 293
 $modversion['config'][] = [
294
-    'name'        => 'cols',
295
-    'title'       => '_MI_SONGLIST_COLS',
296
-    'description' => '_MI_SONGLIST_COLS_DESC',
297
-    'formtype'    => 'text',
298
-    'valuetype'   => 'int',
299
-    'default'     => 4,
300
-    'options'     => [],
294
+	'name'        => 'cols',
295
+	'title'       => '_MI_SONGLIST_COLS',
296
+	'description' => '_MI_SONGLIST_COLS_DESC',
297
+	'formtype'    => 'text',
298
+	'valuetype'   => 'int',
299
+	'default'     => 4,
300
+	'options'     => [],
301 301
 ];
302 302
 
303 303
 $modversion['config'][] = [
304
-    'name'        => 'rows',
305
-    'title'       => '_MI_SONGLIST_ROWS',
306
-    'description' => '_MI_SONGLIST_ROWS_DESC',
307
-    'formtype'    => 'text',
308
-    'valuetype'   => 'int',
309
-    'default'     => 4,
310
-    'options'     => [],
304
+	'name'        => 'rows',
305
+	'title'       => '_MI_SONGLIST_ROWS',
306
+	'description' => '_MI_SONGLIST_ROWS_DESC',
307
+	'formtype'    => 'text',
308
+	'valuetype'   => 'int',
309
+	'default'     => 4,
310
+	'options'     => [],
311 311
 ];
312 312
 
313 313
 $modversion['config'][] = [
314
-    'name'        => 'email',
315
-    'title'       => '_MI_SONGLIST_EMAIL',
316
-    'description' => '_MI_SONGLIST_EMAIL_DESC',
317
-    'formtype'    => 'textarea',
318
-    'valuetype'   => 'text',
319
-    'default'     => $GLOBALS['xoopsConfig']['adminmail'],
320
-    'options'     => [],
314
+	'name'        => 'email',
315
+	'title'       => '_MI_SONGLIST_EMAIL',
316
+	'description' => '_MI_SONGLIST_EMAIL_DESC',
317
+	'formtype'    => 'textarea',
318
+	'valuetype'   => 'text',
319
+	'default'     => $GLOBALS['xoopsConfig']['adminmail'],
320
+	'options'     => [],
321 321
 ];
322 322
 
323 323
 $modversion['config'][] = [
324
-    'name'        => 'mp3_filesize',
325
-    'title'       => '_MI_SONGLIST_MP3FILESIZE',
326
-    'description' => '_MI_SONGLIST_MP3FILESIZE_DESC',
327
-    'formtype'    => 'textbox',
328
-    'valuetype'   => 'int',
329
-    'default'     => '195035100',
324
+	'name'        => 'mp3_filesize',
325
+	'title'       => '_MI_SONGLIST_MP3FILESIZE',
326
+	'description' => '_MI_SONGLIST_MP3FILESIZE_DESC',
327
+	'formtype'    => 'textbox',
328
+	'valuetype'   => 'int',
329
+	'default'     => '195035100',
330 330
 ];
331 331
 
332 332
 $modversion['config'][] = [
333
-    'name'        => 'mp3_mimetype',
334
-    'title'       => '_MI_SONGLIST_MP3MIMETYPE',
335
-    'description' => '_MI_SONGLIST_MP3MIMETYPE_DESC',
336
-    'formtype'    => 'textarea',
337
-    'valuetype'   => 'text',
338
-    'default'     => 'audio/mpeg|audio/x-mpeg|audio/mp3|audio/x-mp3|audio/mpeg3|audio/x-mpeg3|audio/mpg|audio/x-mpg|audio/x-mpegaudio',
333
+	'name'        => 'mp3_mimetype',
334
+	'title'       => '_MI_SONGLIST_MP3MIMETYPE',
335
+	'description' => '_MI_SONGLIST_MP3MIMETYPE_DESC',
336
+	'formtype'    => 'textarea',
337
+	'valuetype'   => 'text',
338
+	'default'     => 'audio/mpeg|audio/x-mpeg|audio/mp3|audio/x-mp3|audio/mpeg3|audio/x-mpeg3|audio/mpg|audio/x-mpg|audio/x-mpegaudio',
339 339
 ];
340 340
 
341 341
 $modversion['config'][] = [
342
-    'name'        => 'mp3_extensions',
343
-    'title'       => '_MI_SONGLIST_MP3EXTENSIONS',
344
-    'description' => '_MI_SONGLIST_MP3EXTENSIONS_DESC',
345
-    'formtype'    => 'textarea',
346
-    'valuetype'   => 'text',
347
-    'default'     => 'mp3',
342
+	'name'        => 'mp3_extensions',
343
+	'title'       => '_MI_SONGLIST_MP3EXTENSIONS',
344
+	'description' => '_MI_SONGLIST_MP3EXTENSIONS_DESC',
345
+	'formtype'    => 'textarea',
346
+	'valuetype'   => 'text',
347
+	'default'     => 'mp3',
348 348
 ];
349 349
 
350 350
 $modversion['config'][] = [
351
-    'name'        => 'filesize_upload',
352
-    'title'       => '_MI_SONGLIST_FILESIZEUPLD',
353
-    'description' => '_MI_SONGLIST_FILESIZEUPLD_DESC',
354
-    'formtype'    => 'textbox',
355
-    'valuetype'   => 'int',
356
-    'default'     => '1950351',
351
+	'name'        => 'filesize_upload',
352
+	'title'       => '_MI_SONGLIST_FILESIZEUPLD',
353
+	'description' => '_MI_SONGLIST_FILESIZEUPLD_DESC',
354
+	'formtype'    => 'textbox',
355
+	'valuetype'   => 'int',
356
+	'default'     => '1950351',
357 357
 ];
358 358
 
359 359
 $modversion['config'][] = [
360
-    'name'        => 'allowed_mimetype',
361
-    'title'       => '_MI_SONGLIST_ALLOWEDMIMETYPE',
362
-    'description' => '_MI_SONGLIST_ALLOWEDMIMETYPE_DESC',
363
-    'formtype'    => 'textarea',
364
-    'valuetype'   => 'text',
365
-    'default'     => 'image/gif|image/pjpeg|image/jpeg|image/x-png|image/png',
360
+	'name'        => 'allowed_mimetype',
361
+	'title'       => '_MI_SONGLIST_ALLOWEDMIMETYPE',
362
+	'description' => '_MI_SONGLIST_ALLOWEDMIMETYPE_DESC',
363
+	'formtype'    => 'textarea',
364
+	'valuetype'   => 'text',
365
+	'default'     => 'image/gif|image/pjpeg|image/jpeg|image/x-png|image/png',
366 366
 ];
367 367
 
368 368
 $modversion['config'][] = [
369
-    'name'        => 'allowed_extensions',
370
-    'title'       => '_MI_SONGLIST_ALLOWEDEXTENSIONS',
371
-    'description' => '_MI_SONGLIST_ALLOWEDEXTENSIONS_DESC',
372
-    'formtype'    => 'textarea',
373
-    'valuetype'   => 'text',
374
-    'default'     => 'gif|pjpeg|jpeg|jpg|png',
369
+	'name'        => 'allowed_extensions',
370
+	'title'       => '_MI_SONGLIST_ALLOWEDEXTENSIONS',
371
+	'description' => '_MI_SONGLIST_ALLOWEDEXTENSIONS_DESC',
372
+	'formtype'    => 'textarea',
373
+	'valuetype'   => 'text',
374
+	'default'     => 'gif|pjpeg|jpeg|jpg|png',
375 375
 ];
376 376
 
377 377
 $modversion['config'][] = [
378
-    'name'        => 'upload_areas',
379
-    'title'       => '_MI_SONGLIST_UPLOADAREAS',
380
-    'description' => '_MI_SONGLIST_UPLOADAREAS_DESC',
378
+	'name'        => 'upload_areas',
379
+	'title'       => '_MI_SONGLIST_UPLOADAREAS',
380
+	'description' => '_MI_SONGLIST_UPLOADAREAS_DESC',
381 381
 //    'formtype'    => 'select',
382 382
 //    'valuetype'   => 'text',
383 383
 //    'default'     => 'uploads' . DS . 'songlist' . DS,
@@ -385,45 +385,45 @@  discard block
 block discarded – undo
385 385
 //        'uploads' . DS                   => 'uploads' . DS,
386 386
 //        'uploads' . DS . 'songlist' . DS => 'uploads' . DS . 'songlist' . DS,
387 387
 //],
388
-    'formtype'    => 'textbox',
389
-    'valuetype'   => 'text',
390
-    'default'     => '/uploads/songlist/',
388
+	'formtype'    => 'textbox',
389
+	'valuetype'   => 'text',
390
+	'default'     => '/uploads/songlist/',
391 391
 ];
392 392
 
393 393
 $modversion['config'][] = [
394
-    'name'        => 'album',
395
-    'title'       => '_MI_SONGLIST_ALBUM',
396
-    'description' => '_MI_SONGLIST_ALBUM_DESC',
397
-    'formtype'    => 'yesno',
398
-    'valuetype'   => 'int',
399
-    'default'     => '0',
394
+	'name'        => 'album',
395
+	'title'       => '_MI_SONGLIST_ALBUM',
396
+	'description' => '_MI_SONGLIST_ALBUM_DESC',
397
+	'formtype'    => 'yesno',
398
+	'valuetype'   => 'int',
399
+	'default'     => '0',
400 400
 ];
401 401
 
402 402
 $modversion['config'][] = [
403
-    'name'        => 'genre',
404
-    'title'       => '_MI_SONGLIST_GENRE',
405
-    'description' => '_MI_SONGLIST_GENRE_DESC',
406
-    'formtype'    => 'yesno',
407
-    'valuetype'   => 'int',
408
-    'default'     => '0',
403
+	'name'        => 'genre',
404
+	'title'       => '_MI_SONGLIST_GENRE',
405
+	'description' => '_MI_SONGLIST_GENRE_DESC',
406
+	'formtype'    => 'yesno',
407
+	'valuetype'   => 'int',
408
+	'default'     => '0',
409 409
 ];
410 410
 
411 411
 $modversion['config'][] = [
412
-    'name'        => 'voice',
413
-    'title'       => '_MI_SONGLIST_VOICE',
414
-    'description' => '_MI_SONGLIST_VOICE_DESC',
415
-    'formtype'    => 'yesno',
416
-    'valuetype'   => 'int',
417
-    'default'     => '0',
412
+	'name'        => 'voice',
413
+	'title'       => '_MI_SONGLIST_VOICE',
414
+	'description' => '_MI_SONGLIST_VOICE_DESC',
415
+	'formtype'    => 'yesno',
416
+	'valuetype'   => 'int',
417
+	'default'     => '0',
418 418
 ];
419 419
 
420 420
 $modversion['config'][] = [
421
-    'name'        => 'lyrics',
422
-    'title'       => '_MI_SONGLIST_LYRICS',
423
-    'description' => '_MI_SONGLIST_LYRICS_DESC',
424
-    'formtype'    => 'yesno',
425
-    'valuetype'   => 'int',
426
-    'default'     => '0',
421
+	'name'        => 'lyrics',
422
+	'title'       => '_MI_SONGLIST_LYRICS',
423
+	'description' => '_MI_SONGLIST_LYRICS_DESC',
424
+	'formtype'    => 'yesno',
425
+	'valuetype'   => 'int',
426
+	'default'     => '0',
427 427
 ];
428 428
 
429 429
 /*
@@ -438,110 +438,110 @@  discard block
 block discarded – undo
438 438
 */
439 439
 
440 440
 $modversion['config'][] = [
441
-    'name'        => 'htaccess',
442
-    'title'       => '_MI_SONGLIST_HTACCESS',
443
-    'description' => '_MI_SONGLIST_HTACCESS_DESC',
444
-    'formtype'    => 'yesno',
445
-    'valuetype'   => 'int',
446
-    'default'     => '0',
441
+	'name'        => 'htaccess',
442
+	'title'       => '_MI_SONGLIST_HTACCESS',
443
+	'description' => '_MI_SONGLIST_HTACCESS_DESC',
444
+	'formtype'    => 'yesno',
445
+	'valuetype'   => 'int',
446
+	'default'     => '0',
447 447
 ];
448 448
 
449 449
 $modversion['config'][] = [
450
-    'name'        => 'baseofurl',
451
-    'title'       => '_MI_SONGLIST_HTACCESS_BASEOFURL',
452
-    'description' => '_MI_SONGLIST_HTACCESS_BASEOFURL_DESC',
453
-    'formtype'    => 'text',
454
-    'valuetype'   => 'text',
455
-    'default'     => 'songlist',
450
+	'name'        => 'baseofurl',
451
+	'title'       => '_MI_SONGLIST_HTACCESS_BASEOFURL',
452
+	'description' => '_MI_SONGLIST_HTACCESS_BASEOFURL_DESC',
453
+	'formtype'    => 'text',
454
+	'valuetype'   => 'text',
455
+	'default'     => 'songlist',
456 456
 ];
457 457
 
458 458
 $modversion['config'][] = [
459
-    'name'        => 'endofurl',
460
-    'title'       => '_MI_SONGLIST_HTACCESS_ENDOFURL',
461
-    'description' => '_MI_SONGLIST_HTACCESS_ENDOFURL_DESC',
462
-    'formtype'    => 'text',
463
-    'valuetype'   => 'text',
464
-    'default'     => '.tpl',
459
+	'name'        => 'endofurl',
460
+	'title'       => '_MI_SONGLIST_HTACCESS_ENDOFURL',
461
+	'description' => '_MI_SONGLIST_HTACCESS_ENDOFURL_DESC',
462
+	'formtype'    => 'text',
463
+	'valuetype'   => 'text',
464
+	'default'     => '.tpl',
465 465
 ];
466 466
 
467 467
 $modversion['config'][] = [
468
-    'name'        => 'tags',
469
-    'title'       => '_MI_SONGLIST_TAGS',
470
-    'description' => '_MI_SONGLIST_TAGS_DESC',
471
-    'formtype'    => 'yesno',
472
-    'valuetype'   => 'int',
473
-    'default'     => '0',
468
+	'name'        => 'tags',
469
+	'title'       => '_MI_SONGLIST_TAGS',
470
+	'description' => '_MI_SONGLIST_TAGS_DESC',
471
+	'formtype'    => 'yesno',
472
+	'valuetype'   => 'int',
473
+	'default'     => '0',
474 474
 ];
475 475
 
476 476
 $modversion['config'][] = [
477
-    'name'        => 'force_jquery',
478
-    'title'       => '_MI_SONGLIST_FORCE_JQUERY',
479
-    'description' => '_MI_SONGLIST_FORCE_JQUERY_DESC',
480
-    'formtype'    => 'yesno',
481
-    'valuetype'   => 'int',
482
-    'default'     => true,
477
+	'name'        => 'force_jquery',
478
+	'title'       => '_MI_SONGLIST_FORCE_JQUERY',
479
+	'description' => '_MI_SONGLIST_FORCE_JQUERY_DESC',
480
+	'formtype'    => 'yesno',
481
+	'valuetype'   => 'int',
482
+	'default'     => true,
483 483
 ];
484 484
 
485 485
 $modversion['config'][] = [
486
-    'name'        => 'memory_admin',
487
-    'title'       => '_MI_SONGLIST_MEMORY_ADMIN',
488
-    'description' => '_MI_SONGLIST_MEMORY_ADMIN_DESC',
489
-    'formtype'    => 'text',
490
-    'valuetype'   => 'int',
491
-    'default'     => 128,
492
-    'options'     => [],
486
+	'name'        => 'memory_admin',
487
+	'title'       => '_MI_SONGLIST_MEMORY_ADMIN',
488
+	'description' => '_MI_SONGLIST_MEMORY_ADMIN_DESC',
489
+	'formtype'    => 'text',
490
+	'valuetype'   => 'int',
491
+	'default'     => 128,
492
+	'options'     => [],
493 493
 ];
494 494
 
495 495
 $modversion['config'][] = [
496
-    'name'        => 'memory_user',
497
-    'title'       => '_MI_SONGLIST_MEMORY_USER',
498
-    'description' => '_MI_SONGLIST_MEMORY_USER_DESC',
499
-    'formtype'    => 'text',
500
-    'valuetype'   => 'int',
501
-    'default'     => 128,
502
-    'options'     => [],
496
+	'name'        => 'memory_user',
497
+	'title'       => '_MI_SONGLIST_MEMORY_USER',
498
+	'description' => '_MI_SONGLIST_MEMORY_USER_DESC',
499
+	'formtype'    => 'text',
500
+	'valuetype'   => 'int',
501
+	'default'     => 128,
502
+	'options'     => [],
503 503
 ];
504 504
 
505 505
 $modversion['config'][] = [
506
-    'name'        => 'time_admin',
507
-    'title'       => '_MI_SONGLIST_TIME_ADMIN',
508
-    'description' => '_MI_SONGLIST_TIME_ADMIN_DESC',
509
-    'formtype'    => 'text',
510
-    'valuetype'   => 'int',
511
-    'default'     => 360,
512
-    'options'     => [],
506
+	'name'        => 'time_admin',
507
+	'title'       => '_MI_SONGLIST_TIME_ADMIN',
508
+	'description' => '_MI_SONGLIST_TIME_ADMIN_DESC',
509
+	'formtype'    => 'text',
510
+	'valuetype'   => 'int',
511
+	'default'     => 360,
512
+	'options'     => [],
513 513
 ];
514 514
 
515 515
 $modversion['config'][] = [
516
-    'name'        => 'time_user',
517
-    'title'       => '_MI_SONGLIST_TIME_USER',
518
-    'description' => '_MI_SONGLIST_TIME_USER_DESC',
519
-    'formtype'    => 'text',
520
-    'valuetype'   => 'int',
521
-    'default'     => 360,
522
-    'options'     => [],
516
+	'name'        => 'time_user',
517
+	'title'       => '_MI_SONGLIST_TIME_USER',
518
+	'description' => '_MI_SONGLIST_TIME_USER_DESC',
519
+	'formtype'    => 'text',
520
+	'valuetype'   => 'int',
521
+	'default'     => 360,
522
+	'options'     => [],
523 523
 ];
524 524
 
525 525
 /**
526 526
  * Make Sample button visible?
527 527
  */
528 528
 $modversion['config'][] = [
529
-    'name'        => 'displaySampleButton',
530
-    'title'       => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON',
531
-    'description' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC',
532
-    'formtype'    => 'yesno',
533
-    'valuetype'   => 'int',
534
-    'default'     => 1,
529
+	'name'        => 'displaySampleButton',
530
+	'title'       => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON',
531
+	'description' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC',
532
+	'formtype'    => 'yesno',
533
+	'valuetype'   => 'int',
534
+	'default'     => 1,
535 535
 ];
536 536
 
537 537
 /**
538 538
  * Show Developer Tools?
539 539
  */
540 540
 $modversion['config'][] = [
541
-    'name'        => 'displayDeveloperTools',
542
-    'title'       => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS',
543
-    'description' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC',
544
-    'formtype'    => 'yesno',
545
-    'valuetype'   => 'int',
546
-    'default'     => 0,
541
+	'name'        => 'displayDeveloperTools',
542
+	'title'       => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS',
543
+	'description' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC',
544
+	'formtype'    => 'yesno',
545
+	'valuetype'   => 'int',
546
+	'default'     => 0,
547 547
 ];
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php declare(strict_types=1);
2 2
 
3
-require_once __DIR__ . '/preloads/autoloader.php';
3
+require_once __DIR__.'/preloads/autoloader.php';
4 4
 
5 5
 error_reporting(E_ALL);
6 6
 $moduleDirName      = basename(__DIR__);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 $modversion['releasedate']         = 'Thursday, 03rd July, 2022';
30 30
 $modversion['website']             = 'www.chronolabs.coop';
31 31
 $modversion['release_info']        = 'Stable 2012/08/16';
32
-$modversion['release_file']        = XOOPS_URL . '/modules/songlist/docs/changelog.txt';
32
+$modversion['release_file']        = XOOPS_URL.'/modules/songlist/docs/changelog.txt';
33 33
 $modversion['author_realname']     = 'Wishcraft';
34 34
 $modversion['author_website_url']  = 'https://www.chronolabs.coop';
35 35
 $modversion['author_website_name'] = 'Chronolabs';
@@ -52,18 +52,18 @@  discard block
 block discarded – undo
52 52
 
53 53
 // ------------------- Tables ------------------ //
54 54
 $modversion['tables'] = [
55
-    $moduleDirName . '_' . 'albums',
56
-    $moduleDirName . '_' . 'artists',
57
-    $moduleDirName . '_' . 'category',
58
-    $moduleDirName . '_' . 'extra',
59
-    $moduleDirName . '_' . 'field',
60
-    $moduleDirName . '_' . 'genre',
61
-    $moduleDirName . '_' . 'voice',
62
-    $moduleDirName . '_' . 'requests',
63
-    $moduleDirName . '_' . 'songs',
64
-    $moduleDirName . '_' . 'utf8map',
65
-    $moduleDirName . '_' . 'visibility',
66
-    $moduleDirName . '_' . 'votes',
55
+    $moduleDirName.'_'.'albums',
56
+    $moduleDirName.'_'.'artists',
57
+    $moduleDirName.'_'.'category',
58
+    $moduleDirName.'_'.'extra',
59
+    $moduleDirName.'_'.'field',
60
+    $moduleDirName.'_'.'genre',
61
+    $moduleDirName.'_'.'voice',
62
+    $moduleDirName.'_'.'requests',
63
+    $moduleDirName.'_'.'songs',
64
+    $moduleDirName.'_'.'utf8map',
65
+    $moduleDirName.'_'.'visibility',
66
+    $moduleDirName.'_'.'votes',
67 67
 ];
68 68
 
69 69
 // Admin things
@@ -272,20 +272,20 @@  discard block
 block discarded – undo
272 272
     'description' => '_MI_SONGLIST_SALT_DESC',
273 273
     'formtype'    => 'text',
274 274
     'valuetype'   => 'text',
275
-    'default'     => (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
276
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
277
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
278
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
279
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
280
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
281
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
282
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
283
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
284
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
285
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
286
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
287
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : '')
288
-                     . (2 != random_int(0, 4) ? chr(random_int(32, 190)) : ''),
275
+    'default'     => (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
276
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
277
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
278
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
279
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
280
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
281
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
282
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
283
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
284
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
285
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
286
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
287
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : '')
288
+                     . (2!=random_int(0, 4) ? chr(random_int(32, 190)) : ''),
289 289
 
290 290
     'options' => [],
291 291
 ];
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
  */
528 528
 $modversion['config'][] = [
529 529
     'name'        => 'displaySampleButton',
530
-    'title'       => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON',
531
-    'description' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC',
530
+    'title'       => 'CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLE_BUTTON',
531
+    'description' => 'CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLE_BUTTON_DESC',
532 532
     'formtype'    => 'yesno',
533 533
     'valuetype'   => 'int',
534 534
     'default'     => 1,
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
  */
540 540
 $modversion['config'][] = [
541 541
     'name'        => 'displayDeveloperTools',
542
-    'title'       => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS',
543
-    'description' => 'CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC',
542
+    'title'       => 'CO_'.$moduleDirNameUpper.'_'.'SHOW_DEV_TOOLS',
543
+    'description' => 'CO_'.$moduleDirNameUpper.'_'.'SHOW_DEV_TOOLS_DESC',
544 544
     'formtype'    => 'yesno',
545 545
     'valuetype'   => 'int',
546 546
     'default'     => 0,
Please login to merge, or discard this patch.
EXTRA/modules/tag/plugin/songlist.php 3 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -3,37 +3,37 @@  discard block
 block discarded – undo
3 3
 
4 4
 function songlist_tag_iteminfo(&$items)
5 5
 {
6
-    if (empty($items) || !is_array($items)) {
7
-        return false;
8
-    }
6
+	if (empty($items) || !is_array($items)) {
7
+		return false;
8
+	}
9 9
     
10
-    $items_id = array();
11
-    foreach (array_keys($items) as $cat_id) {
12
-        // Some handling here to build the link upon catid
13
-        // catid is not used in songlist, so just skip it
14
-        foreach (array_keys($items[$cat_id]) as $item_id) {
15
-            // In songlist, the item_id is "topic_id"
16
-            $items_id[] = intval($item_id);
17
-        }
18
-    }
19
-    $item_handler =& xoops_getmodulehandler('songs', 'songlist');
20
-    $items_obj = $item_handler->getObjects(new Criteria("sid", "(" . implode(", ", $items_id) . ")", "IN"), true);
21
-    $myts = MyTextSanitizer::getInstance();
22
-    foreach (array_keys($items) as $cat_id) {
23
-        foreach (array_keys($items[$cat_id]) as $item_id) {
24
-            $item_obj =& $items_obj[$item_id];
25
-            if (is_object($item_obj))
10
+	$items_id = array();
11
+	foreach (array_keys($items) as $cat_id) {
12
+		// Some handling here to build the link upon catid
13
+		// catid is not used in songlist, so just skip it
14
+		foreach (array_keys($items[$cat_id]) as $item_id) {
15
+			// In songlist, the item_id is "topic_id"
16
+			$items_id[] = intval($item_id);
17
+		}
18
+	}
19
+	$item_handler =& xoops_getmodulehandler('songs', 'songlist');
20
+	$items_obj = $item_handler->getObjects(new Criteria("sid", "(" . implode(", ", $items_id) . ")", "IN"), true);
21
+	$myts = MyTextSanitizer::getInstance();
22
+	foreach (array_keys($items) as $cat_id) {
23
+		foreach (array_keys($items[$cat_id]) as $item_id) {
24
+			$item_obj =& $items_obj[$item_id];
25
+			if (is_object($item_obj))
26 26
 			$items[$cat_id][$item_id] = array(
27
-                "title"     => $item_obj->getVar("title"),
28
-                "uid"       => $item_obj->getVar("uid"),
29
-                "link"      => 'index.php?op=item&fct=item&id='.$item_obj->getVar("sid").'&cid='.$item_obj->getVar("cid"),
30
-                "time"      => $item_obj->getVar("date"),
31
-                "tags"      => tag_parse_tag($item_obj->getVar("tags", "n")),
32
-                "content"   => $myts->displayTarea($item_obj->getVar("lyrics"),true,true,true,true,true,true)
33
-                );
34
-        }
35
-    }
36
-    unset($items_obj);    
27
+				"title"     => $item_obj->getVar("title"),
28
+				"uid"       => $item_obj->getVar("uid"),
29
+				"link"      => 'index.php?op=item&fct=item&id='.$item_obj->getVar("sid").'&cid='.$item_obj->getVar("cid"),
30
+				"time"      => $item_obj->getVar("date"),
31
+				"tags"      => tag_parse_tag($item_obj->getVar("tags", "n")),
32
+				"content"   => $myts->displayTarea($item_obj->getVar("lyrics"),true,true,true,true,true,true)
33
+				);
34
+		}
35
+	}
36
+	unset($items_obj);    
37 37
 }
38 38
 
39 39
 /**
@@ -44,33 +44,33 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function songlist_tag_synchronization($mid)
46 46
 {
47
-    $item_handler =& xoops_getmodulehandler('songs', 'songlist');
48
-    $link_handler =& xoops_getmodulehandler("link", "tag");
47
+	$item_handler =& xoops_getmodulehandler('songs', 'songlist');
48
+	$link_handler =& xoops_getmodulehandler("link", "tag");
49 49
         
50
-    /* clear tag-item links */
51
-    if (version_compare( mysql_get_server_info(), "4.1.0", "ge" )):
52
-    $sql =  "    DELETE FROM {$link_handler->table}" .
53
-            "    WHERE " .
54
-            "        tag_modid = {$mid}" .
55
-            "        AND " .
56
-            "        ( tag_itemid NOT IN " .
57
-            "            ( SELECT DISTINCT {$item_handler->keyName} " .
58
-            "                FROM {$item_handler->table} " .
59
-            "                WHERE {$item_handler->table}.approved > 0" .
60
-            "            ) " .
61
-            "        )";
62
-    else:
63
-    $sql =  "    DELETE {$link_handler->table} FROM {$link_handler->table}" .
64
-            "    LEFT JOIN {$item_handler->table} AS aa ON {$link_handler->table}.tag_itemid = aa.{$item_handler->keyName} " .
65
-            "    WHERE " .
66
-            "        tag_modid = {$mid}" .
67
-            "        AND " .
68
-            "        ( aa.{$item_handler->keyName} IS NULL" .
69
-            "            OR aa.approved < 1" .
70
-            "        )";
71
-    endif;
72
-    if (!$result = $link_handler->db->queryF($sql)) {
73
-        //xoops_error($link_handler->db->error());
74
-    }
50
+	/* clear tag-item links */
51
+	if (version_compare( mysql_get_server_info(), "4.1.0", "ge" )):
52
+	$sql =  "    DELETE FROM {$link_handler->table}" .
53
+			"    WHERE " .
54
+			"        tag_modid = {$mid}" .
55
+			"        AND " .
56
+			"        ( tag_itemid NOT IN " .
57
+			"            ( SELECT DISTINCT {$item_handler->keyName} " .
58
+			"                FROM {$item_handler->table} " .
59
+			"                WHERE {$item_handler->table}.approved > 0" .
60
+			"            ) " .
61
+			"        )";
62
+	else:
63
+	$sql =  "    DELETE {$link_handler->table} FROM {$link_handler->table}" .
64
+			"    LEFT JOIN {$item_handler->table} AS aa ON {$link_handler->table}.tag_itemid = aa.{$item_handler->keyName} " .
65
+			"    WHERE " .
66
+			"        tag_modid = {$mid}" .
67
+			"        AND " .
68
+			"        ( aa.{$item_handler->keyName} IS NULL" .
69
+			"            OR aa.approved < 1" .
70
+			"        )";
71
+	endif;
72
+	if (!$result = $link_handler->db->queryF($sql)) {
73
+		//xoops_error($link_handler->db->error());
74
+	}
75 75
 }
76 76
 ?>
77 77
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
             $items_id[] = intval($item_id);
17 17
         }
18 18
     }
19
-    $item_handler =& xoops_getmodulehandler('songs', 'songlist');
20
-    $items_obj = $item_handler->getObjects(new Criteria("sid", "(" . implode(", ", $items_id) . ")", "IN"), true);
19
+    $item_handler = & xoops_getmodulehandler('songs', 'songlist');
20
+    $items_obj = $item_handler->getObjects(new Criteria("sid", "(".implode(", ", $items_id).")", "IN"), true);
21 21
     $myts = MyTextSanitizer::getInstance();
22 22
     foreach (array_keys($items) as $cat_id) {
23 23
         foreach (array_keys($items[$cat_id]) as $item_id) {
24
-            $item_obj =& $items_obj[$item_id];
24
+            $item_obj = & $items_obj[$item_id];
25 25
             if (is_object($item_obj))
26 26
 			$items[$cat_id][$item_id] = array(
27 27
                 "title"     => $item_obj->getVar("title"),
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
                 "link"      => 'index.php?op=item&fct=item&id='.$item_obj->getVar("sid").'&cid='.$item_obj->getVar("cid"),
30 30
                 "time"      => $item_obj->getVar("date"),
31 31
                 "tags"      => tag_parse_tag($item_obj->getVar("tags", "n")),
32
-                "content"   => $myts->displayTarea($item_obj->getVar("lyrics"),true,true,true,true,true,true)
32
+                "content"   => $myts->displayTarea($item_obj->getVar("lyrics"), true, true, true, true, true, true)
33 33
                 );
34 34
         }
35 35
     }
@@ -44,29 +44,29 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function songlist_tag_synchronization($mid)
46 46
 {
47
-    $item_handler =& xoops_getmodulehandler('songs', 'songlist');
48
-    $link_handler =& xoops_getmodulehandler("link", "tag");
47
+    $item_handler = & xoops_getmodulehandler('songs', 'songlist');
48
+    $link_handler = & xoops_getmodulehandler("link", "tag");
49 49
         
50 50
     /* clear tag-item links */
51
-    if (version_compare( mysql_get_server_info(), "4.1.0", "ge" )):
52
-    $sql =  "    DELETE FROM {$link_handler->table}" .
53
-            "    WHERE " .
54
-            "        tag_modid = {$mid}" .
55
-            "        AND " .
56
-            "        ( tag_itemid NOT IN " .
57
-            "            ( SELECT DISTINCT {$item_handler->keyName} " .
58
-            "                FROM {$item_handler->table} " .
59
-            "                WHERE {$item_handler->table}.approved > 0" .
60
-            "            ) " .
51
+    if (version_compare(mysql_get_server_info(), "4.1.0", "ge")):
52
+    $sql = "    DELETE FROM {$link_handler->table}".
53
+            "    WHERE ".
54
+            "        tag_modid = {$mid}".
55
+            "        AND ".
56
+            "        ( tag_itemid NOT IN ".
57
+            "            ( SELECT DISTINCT {$item_handler->keyName} ".
58
+            "                FROM {$item_handler->table} ".
59
+            "                WHERE {$item_handler->table}.approved > 0".
60
+            "            ) ".
61 61
             "        )";
62 62
     else:
63
-    $sql =  "    DELETE {$link_handler->table} FROM {$link_handler->table}" .
64
-            "    LEFT JOIN {$item_handler->table} AS aa ON {$link_handler->table}.tag_itemid = aa.{$item_handler->keyName} " .
65
-            "    WHERE " .
66
-            "        tag_modid = {$mid}" .
67
-            "        AND " .
68
-            "        ( aa.{$item_handler->keyName} IS NULL" .
69
-            "            OR aa.approved < 1" .
63
+    $sql = "    DELETE {$link_handler->table} FROM {$link_handler->table}".
64
+            "    LEFT JOIN {$item_handler->table} AS aa ON {$link_handler->table}.tag_itemid = aa.{$item_handler->keyName} ".
65
+            "    WHERE ".
66
+            "        tag_modid = {$mid}".
67
+            "        AND ".
68
+            "        ( aa.{$item_handler->keyName} IS NULL".
69
+            "            OR aa.approved < 1".
70 70
             "        )";
71 71
     endif;
72 72
     if (!$result = $link_handler->db->queryF($sql)) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
     foreach (array_keys($items) as $cat_id) {
23 23
         foreach (array_keys($items[$cat_id]) as $item_id) {
24 24
             $item_obj =& $items_obj[$item_id];
25
-            if (is_object($item_obj))
26
-			$items[$cat_id][$item_id] = array(
25
+            if (is_object($item_obj)) {
26
+            			$items[$cat_id][$item_id] = array(
27 27
                 "title"     => $item_obj->getVar("title"),
28 28
                 "uid"       => $item_obj->getVar("uid"),
29 29
                 "link"      => 'index.php?op=item&fct=item&id='.$item_obj->getVar("sid").'&cid='.$item_obj->getVar("cid"),
@@ -31,6 +31,7 @@  discard block
 block discarded – undo
31 31
                 "tags"      => tag_parse_tag($item_obj->getVar("tags", "n")),
32 32
                 "content"   => $myts->displayTarea($item_obj->getVar("lyrics"),true,true,true,true,true,true)
33 33
                 );
34
+            }
34 35
         }
35 36
     }
36 37
     unset($items_obj);    
@@ -59,7 +60,8 @@  discard block
 block discarded – undo
59 60
             "                WHERE {$item_handler->table}.approved > 0" .
60 61
             "            ) " .
61 62
             "        )";
62
-    else:
63
+    else {
64
+    	:
63 65
     $sql =  "    DELETE {$link_handler->table} FROM {$link_handler->table}" .
64 66
             "    LEFT JOIN {$item_handler->table} AS aa ON {$link_handler->table}.tag_itemid = aa.{$item_handler->keyName} " .
65 67
             "    WHERE " .
@@ -68,6 +70,7 @@  discard block
 block discarded – undo
68 70
             "        ( aa.{$item_handler->keyName} IS NULL" .
69 71
             "            OR aa.approved < 1" .
70 72
             "        )";
73
+    }
71 74
     endif;
72 75
     if (!$result = $link_handler->db->queryF($sql)) {
73 76
         //xoops_error($link_handler->db->error());
Please login to merge, or discard this patch.
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.