Passed
Pull Request — master (#2)
by Michael
07:10 queued 03:28
created
class/Artists.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -12,150 +12,150 @@
 block discarded – undo
12 12
  */
13 13
 class Artists extends \XoopsObject
14 14
 {
15
-    public $aid;
16
-    public $cids;
17
-    public $sids;
18
-    public $name;
19
-    public $albums;
20
-    public $songs;
21
-    public $hits;
22
-    public $rank;
23
-    public $votes;
24
-    public $created;
25
-    public $updated;
26
-
27
-    /**
28
-     * Artists constructor.
29
-     * @param null $fid
30
-     */
31
-    public function __construct($fid = null)
32
-    {
33
-        $this->initVar('aid', \XOBJ_DTYPE_INT, 0, false);
34
-        $this->initVar('cids', \XOBJ_DTYPE_ARRAY, [], false);
35
-        $this->initVar('sids', \XOBJ_DTYPE_ARRAY, [], false);
36
-        $this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
37
-        $this->initVar('albums', \XOBJ_DTYPE_INT, 0, false);
38
-        $this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
39
-        $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
40
-        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
41
-        $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
42
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
43
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
44
-    }
45
-
46
-    /**
47
-     * @param bool $as_array
48
-     * @return array|string
49
-     */
50
-    public function getForm($as_array = false)
51
-    {
52
-        return FormController::getFormArtists($this, $as_array);
53
-    }
54
-
55
-    /**
56
-     * @param bool $extra
57
-     * @return array
58
-     */
59
-    public function toArray($extra = false): array
60
-    {
61
-        $ret  = parent::toArray();
62
-        $form = $this->getForm(true);
63
-        foreach ($form as $key => $element) {
64
-            $ret['form'][$key] = $element->render();
65
-        }
66
-        foreach (['created', 'updated'] as $key) {
67
-            if ($this->getVar($key) > 0) {
68
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
69
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
70
-            }
71
-        }
72
-
73
-        $ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
74
-        $ret['url']  = $this->getURL(true);
75
-
76
-        \xoops_loadLanguage('enum', 'songlist');
77
-        if (!empty($ret['singer'])) {
78
-            $ret['singer'] = \constant($ret['singer']);
79
-        }
80
-
81
-        if (!$extra) {
82
-            return $ret;
83
-        }
84
-
85
-        if (0 != \count($this->getVar('cids'))) {
86
-            $categoriesHandler = Helper::getInstance()->getHandler('Category');
87
-            foreach ($this->getVar('cids') as $aid) {
88
-                $category = $categoriesHandler->get($aid);
89
-                if (\is_object($category)) {
90
-                    $ret['categories_array'][$aid] = $category->toArray(false);
91
-                }
92
-            }
93
-        }
94
-
95
-        if (\is_array($this->getVar('aids')) && 0 != \count($this->getVar('aids'))) {
96
-            $artistsHandler = Helper::getInstance()->getHandler('Artists');
97
-            foreach ($this->getVar('aids') as $aid) {
98
-                $artist = $artistsHandler->get($aid);
99
-                if (\is_object($artist)) {
100
-                    $ret['artists_array'][$aid] = $artist->toArray(false);
101
-                }
102
-            }
103
-        }
104
-
105
-        if (0 != \count($this->getVar('sids'))) {
106
-            $songsHandler = Helper::getInstance()->getHandler('Songs');
107
-            $criteria     = new \Criteria('aids', '%"' . $this->getVar('aid') . '"%', 'LIKE');
108
-            $criteria->setSort('songid');
109
-            $criteria->setOrder('ASC');
110
-            foreach ($songsHandler->getObjects($criteria, true) as $sid => $song) {
111
-                if (\is_object($song)) {
112
-                    $ret['songs_array'][$sid] = $song->toArray(false);
113
-                }
114
-            }
115
-        }
116
-
117
-        return $ret;
118
-    }
119
-
120
-    /**
121
-     * @return string
122
-     */
123
-    public function getURL(): string
124
-    {
125
-        global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
126
-        if ($GLOBALS['songlistModuleConfig']['htaccess']) {
127
-            if (0 != $id) {
128
-                $artistHandler = Helper::getInstance()->getHandler('Artists');
129
-                $artist        = $artistHandler->get($id);
130
-                if (\is_object($artist) && !$artist->isNew()) {
131
-                    return XOOPS_URL
132
-                           . '/'
133
-                           . $GLOBALS['songlistModuleConfig']['baseofurl']
134
-                           . '/artists/'
135
-                           . \urlencode(\str_replace([' ', \chr(9)], '-', $artist->getVar('name')))
136
-                           . '/'
137
-                           . $start
138
-                           . '-'
139
-                           . $id
140
-                           . '-'
141
-                           . $op
142
-                           . '-'
143
-                           . $fct
144
-                           . '-'
145
-                           . $gid
146
-                           . '-'
147
-                           . $cid
148
-                           . '/'
149
-                           . \urlencode($value)
150
-                           . $GLOBALS['songlistModuleConfig']['endofurl'];
151
-                }
152
-
153
-                return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/artists/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '-' . $vcid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
154
-            }
155
-
156
-            return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/artists/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '-' . $vcid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
157
-        }
158
-
159
-        return XOOPS_URL . '/modules/songlist/artists.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid . '&start=' . $start;
160
-    }
15
+	public $aid;
16
+	public $cids;
17
+	public $sids;
18
+	public $name;
19
+	public $albums;
20
+	public $songs;
21
+	public $hits;
22
+	public $rank;
23
+	public $votes;
24
+	public $created;
25
+	public $updated;
26
+
27
+	/**
28
+	 * Artists constructor.
29
+	 * @param null $fid
30
+	 */
31
+	public function __construct($fid = null)
32
+	{
33
+		$this->initVar('aid', \XOBJ_DTYPE_INT, 0, false);
34
+		$this->initVar('cids', \XOBJ_DTYPE_ARRAY, [], false);
35
+		$this->initVar('sids', \XOBJ_DTYPE_ARRAY, [], false);
36
+		$this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
37
+		$this->initVar('albums', \XOBJ_DTYPE_INT, 0, false);
38
+		$this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
39
+		$this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
40
+		$this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
41
+		$this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
42
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
43
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
44
+	}
45
+
46
+	/**
47
+	 * @param bool $as_array
48
+	 * @return array|string
49
+	 */
50
+	public function getForm($as_array = false)
51
+	{
52
+		return FormController::getFormArtists($this, $as_array);
53
+	}
54
+
55
+	/**
56
+	 * @param bool $extra
57
+	 * @return array
58
+	 */
59
+	public function toArray($extra = false): array
60
+	{
61
+		$ret  = parent::toArray();
62
+		$form = $this->getForm(true);
63
+		foreach ($form as $key => $element) {
64
+			$ret['form'][$key] = $element->render();
65
+		}
66
+		foreach (['created', 'updated'] as $key) {
67
+			if ($this->getVar($key) > 0) {
68
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
69
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
70
+			}
71
+		}
72
+
73
+		$ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
74
+		$ret['url']  = $this->getURL(true);
75
+
76
+		\xoops_loadLanguage('enum', 'songlist');
77
+		if (!empty($ret['singer'])) {
78
+			$ret['singer'] = \constant($ret['singer']);
79
+		}
80
+
81
+		if (!$extra) {
82
+			return $ret;
83
+		}
84
+
85
+		if (0 != \count($this->getVar('cids'))) {
86
+			$categoriesHandler = Helper::getInstance()->getHandler('Category');
87
+			foreach ($this->getVar('cids') as $aid) {
88
+				$category = $categoriesHandler->get($aid);
89
+				if (\is_object($category)) {
90
+					$ret['categories_array'][$aid] = $category->toArray(false);
91
+				}
92
+			}
93
+		}
94
+
95
+		if (\is_array($this->getVar('aids')) && 0 != \count($this->getVar('aids'))) {
96
+			$artistsHandler = Helper::getInstance()->getHandler('Artists');
97
+			foreach ($this->getVar('aids') as $aid) {
98
+				$artist = $artistsHandler->get($aid);
99
+				if (\is_object($artist)) {
100
+					$ret['artists_array'][$aid] = $artist->toArray(false);
101
+				}
102
+			}
103
+		}
104
+
105
+		if (0 != \count($this->getVar('sids'))) {
106
+			$songsHandler = Helper::getInstance()->getHandler('Songs');
107
+			$criteria     = new \Criteria('aids', '%"' . $this->getVar('aid') . '"%', 'LIKE');
108
+			$criteria->setSort('songid');
109
+			$criteria->setOrder('ASC');
110
+			foreach ($songsHandler->getObjects($criteria, true) as $sid => $song) {
111
+				if (\is_object($song)) {
112
+					$ret['songs_array'][$sid] = $song->toArray(false);
113
+				}
114
+			}
115
+		}
116
+
117
+		return $ret;
118
+	}
119
+
120
+	/**
121
+	 * @return string
122
+	 */
123
+	public function getURL(): string
124
+	{
125
+		global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
126
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
127
+			if (0 != $id) {
128
+				$artistHandler = Helper::getInstance()->getHandler('Artists');
129
+				$artist        = $artistHandler->get($id);
130
+				if (\is_object($artist) && !$artist->isNew()) {
131
+					return XOOPS_URL
132
+						   . '/'
133
+						   . $GLOBALS['songlistModuleConfig']['baseofurl']
134
+						   . '/artists/'
135
+						   . \urlencode(\str_replace([' ', \chr(9)], '-', $artist->getVar('name')))
136
+						   . '/'
137
+						   . $start
138
+						   . '-'
139
+						   . $id
140
+						   . '-'
141
+						   . $op
142
+						   . '-'
143
+						   . $fct
144
+						   . '-'
145
+						   . $gid
146
+						   . '-'
147
+						   . $cid
148
+						   . '/'
149
+						   . \urlencode($value)
150
+						   . $GLOBALS['songlistModuleConfig']['endofurl'];
151
+				}
152
+
153
+				return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/artists/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '-' . $vcid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
154
+			}
155
+
156
+			return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/artists/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '-' . $vcid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
157
+		}
158
+
159
+		return XOOPS_URL . '/modules/songlist/artists.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid . '&start=' . $start;
160
+	}
161 161
 }
Please login to merge, or discard this patch.
class/Genre.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -12,94 +12,94 @@
 block discarded – undo
12 12
  */
13 13
 class Genre extends \XoopsObject
14 14
 {
15
-    public $gid;
16
-    public $name;
17
-    public $artists;
18
-    public $albums;
19
-    public $songs;
20
-    public $hits;
21
-    public $rank;
22
-    public $votes;
23
-    public $created;
24
-    public $updated;
15
+	public $gid;
16
+	public $name;
17
+	public $artists;
18
+	public $albums;
19
+	public $songs;
20
+	public $hits;
21
+	public $rank;
22
+	public $votes;
23
+	public $created;
24
+	public $updated;
25 25
 
26
-    /**
27
-     * Genre constructor.
28
-     * @param null $fid
29
-     */
30
-    public function __construct($fid = null)
31
-    {
32
-        $this->initVar('gid', \XOBJ_DTYPE_INT, 0, false);
33
-        $this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
34
-        $this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
35
-        $this->initVar('albums', \XOBJ_DTYPE_INT, 0, false);
36
-        $this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
37
-        $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
38
-        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
39
-        $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
40
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
41
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
42
-    }
26
+	/**
27
+	 * Genre constructor.
28
+	 * @param null $fid
29
+	 */
30
+	public function __construct($fid = null)
31
+	{
32
+		$this->initVar('gid', \XOBJ_DTYPE_INT, 0, false);
33
+		$this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
34
+		$this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
35
+		$this->initVar('albums', \XOBJ_DTYPE_INT, 0, false);
36
+		$this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
37
+		$this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
38
+		$this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
39
+		$this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
40
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
41
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
42
+	}
43 43
 
44
-    /**
45
-     * @param bool $as_array
46
-     * @return array|string
47
-     */
48
-    public function getForm($as_array = false)
49
-    {
50
-        return FormController::getFormGenre($this, $as_array);
51
-    }
44
+	/**
45
+	 * @param bool $as_array
46
+	 * @return array|string
47
+	 */
48
+	public function getForm($as_array = false)
49
+	{
50
+		return FormController::getFormGenre($this, $as_array);
51
+	}
52 52
 
53
-    /**
54
-     * @return array
55
-     */
56
-    public function toArray(): array
57
-    {
58
-        $ret  = parent::toArray();
59
-        $form = $this->getForm(true);
60
-        foreach ($form as $key => $element) {
61
-            $ret['form'][$key] = $element->render();
62
-        }
63
-        foreach (['created', 'updated'] as $key) {
64
-            if ($this->getVar($key) > 0) {
65
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
66
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
67
-            }
68
-        }
69
-        $ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
53
+	/**
54
+	 * @return array
55
+	 */
56
+	public function toArray(): array
57
+	{
58
+		$ret  = parent::toArray();
59
+		$form = $this->getForm(true);
60
+		foreach ($form as $key => $element) {
61
+			$ret['form'][$key] = $element->render();
62
+		}
63
+		foreach (['created', 'updated'] as $key) {
64
+			if ($this->getVar($key) > 0) {
65
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
66
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
67
+			}
68
+		}
69
+		$ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
70 70
 
71
-        return $ret;
72
-    }
71
+		return $ret;
72
+	}
73 73
 
74
-    /**
75
-     * @return string
76
-     */
77
-    public function getURL(): string
78
-    {
79
-        global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
80
-        if ($GLOBALS['songlistModuleConfig']['htaccess']) {
81
-            return XOOPS_URL
82
-                   . '/'
83
-                   . $GLOBALS['songlistModuleConfig']['baseurl']
84
-                   . '/'
85
-                   . $file
86
-                   . '/'
87
-                   . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('name')))
88
-                   . '/'
89
-                   . $op
90
-                   . '-'
91
-                   . $fct
92
-                   . '-'
93
-                   . $this->getVar('gid')
94
-                   . '-'
95
-                   . \urlencode($value)
96
-                   . '-'
97
-                   . $gid
98
-                   . '-'
99
-                   . $cid
100
-                   . $GLOBALS['songlistModuleConfig']['endofurl'];
101
-        }
74
+	/**
75
+	 * @return string
76
+	 */
77
+	public function getURL(): string
78
+	{
79
+		global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
80
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
81
+			return XOOPS_URL
82
+				   . '/'
83
+				   . $GLOBALS['songlistModuleConfig']['baseurl']
84
+				   . '/'
85
+				   . $file
86
+				   . '/'
87
+				   . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('name')))
88
+				   . '/'
89
+				   . $op
90
+				   . '-'
91
+				   . $fct
92
+				   . '-'
93
+				   . $this->getVar('gid')
94
+				   . '-'
95
+				   . \urlencode($value)
96
+				   . '-'
97
+				   . $gid
98
+				   . '-'
99
+				   . $cid
100
+				   . $GLOBALS['songlistModuleConfig']['endofurl'];
101
+		}
102 102
 
103
-        return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $this->getVar('gid') . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&cid=' . $cid;
104
-    }
103
+		return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $this->getVar('gid') . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&cid=' . $cid;
104
+	}
105 105
 }
Please login to merge, or discard this patch.
class/Requests.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -15,68 +15,68 @@
 block discarded – undo
15 15
  */
16 16
 class Requests extends XoopsObject
17 17
 {
18
-    public $rid;
19
-    public $aid;
20
-    public $artist;
21
-    public $album;
22
-    public $title;
23
-    public $lyrics;
24
-    public $uid;
25
-    public $name;
26
-    public $email;
27
-    public $songid;
28
-    public $sid;
29
-    public $created;
30
-    public $updated;
18
+	public $rid;
19
+	public $aid;
20
+	public $artist;
21
+	public $album;
22
+	public $title;
23
+	public $lyrics;
24
+	public $uid;
25
+	public $name;
26
+	public $email;
27
+	public $songid;
28
+	public $sid;
29
+	public $created;
30
+	public $updated;
31 31
 
32
-    /**
33
-     * Requests constructor.
34
-     * @param null $fid
35
-     */
36
-    public function __construct($fid = null)
37
-    {
38
-        $this->initVar('rid', \XOBJ_DTYPE_INT, 0, false);
39
-        $this->initVar('aid', \XOBJ_DTYPE_INT, 0, false);
40
-        $this->initVar('artist', \XOBJ_DTYPE_TXTBOX, null, false, 128);
41
-        $this->initVar('album', \XOBJ_DTYPE_TXTBOX, null, false, 128);
42
-        $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
43
-        $this->initVar('lyrics', \XOBJ_DTYPE_OTHER, null, false);
44
-        $this->initVar('uid', \XOBJ_DTYPE_INT, 0, false);
45
-        $this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
46
-        $this->initVar('email', \XOBJ_DTYPE_TXTBOX, null, false, 255);
47
-        $this->initVar('songid', \XOBJ_DTYPE_TXTBOX, null, false, 32);
48
-        $this->initVar('sid', \XOBJ_DTYPE_INT, 0, false);
49
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
50
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
51
-    }
32
+	/**
33
+	 * Requests constructor.
34
+	 * @param null $fid
35
+	 */
36
+	public function __construct($fid = null)
37
+	{
38
+		$this->initVar('rid', \XOBJ_DTYPE_INT, 0, false);
39
+		$this->initVar('aid', \XOBJ_DTYPE_INT, 0, false);
40
+		$this->initVar('artist', \XOBJ_DTYPE_TXTBOX, null, false, 128);
41
+		$this->initVar('album', \XOBJ_DTYPE_TXTBOX, null, false, 128);
42
+		$this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
43
+		$this->initVar('lyrics', \XOBJ_DTYPE_OTHER, null, false);
44
+		$this->initVar('uid', \XOBJ_DTYPE_INT, 0, false);
45
+		$this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
46
+		$this->initVar('email', \XOBJ_DTYPE_TXTBOX, null, false, 255);
47
+		$this->initVar('songid', \XOBJ_DTYPE_TXTBOX, null, false, 32);
48
+		$this->initVar('sid', \XOBJ_DTYPE_INT, 0, false);
49
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
50
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
51
+	}
52 52
 
53
-    /**
54
-     * @param bool $as_array
55
-     * @return array|string
56
-     */
57
-    public function getForm($as_array = false)
58
-    {
59
-        return FormController::getFormRequests($this, $as_array);
60
-    }
53
+	/**
54
+	 * @param bool $as_array
55
+	 * @return array|string
56
+	 */
57
+	public function getForm($as_array = false)
58
+	{
59
+		return FormController::getFormRequests($this, $as_array);
60
+	}
61 61
 
62
-    /**
63
-     * @return array
64
-     */
65
-    public function toArray(): array
66
-    {
67
-        $ret            = parent::toArray();
68
-        $form           = $this->getForm(true);
69
-        $form['songid'] = new XoopsFormText('', $this->getVar('rid') . '[songid]', 11, 32);
70
-        foreach ($form as $key => $element) {
71
-            $ret['form'][$key] = $element->render();
72
-        }
73
-        foreach (['created', 'updated'] as $key) {
74
-            if ($this->getVar($key) > 0) {
75
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
76
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
77
-            }
78
-        }
62
+	/**
63
+	 * @return array
64
+	 */
65
+	public function toArray(): array
66
+	{
67
+		$ret            = parent::toArray();
68
+		$form           = $this->getForm(true);
69
+		$form['songid'] = new XoopsFormText('', $this->getVar('rid') . '[songid]', 11, 32);
70
+		foreach ($form as $key => $element) {
71
+			$ret['form'][$key] = $element->render();
72
+		}
73
+		foreach (['created', 'updated'] as $key) {
74
+			if ($this->getVar($key) > 0) {
75
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
76
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
77
+			}
78
+		}
79 79
 
80
-        return $ret;
81
-    }
80
+		return $ret;
81
+	}
82 82
 }
Please login to merge, or discard this patch.
class/Category.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -9,110 +9,110 @@
 block discarded – undo
9 9
  */
10 10
 class Category extends \XoopsObject
11 11
 {
12
-    public $cid;
13
-    public $pid;
14
-    public $weight;
15
-    public $name;
16
-    public $description;
17
-    public $image;
18
-    public $path;
19
-    public $artists;
20
-    public $albums;
21
-    public $songs;
22
-    public $hits;
23
-    public $rank;
24
-    public $votes;
25
-    public $created;
26
-    public $updated;
12
+	public $cid;
13
+	public $pid;
14
+	public $weight;
15
+	public $name;
16
+	public $description;
17
+	public $image;
18
+	public $path;
19
+	public $artists;
20
+	public $albums;
21
+	public $songs;
22
+	public $hits;
23
+	public $rank;
24
+	public $votes;
25
+	public $created;
26
+	public $updated;
27 27
 
28
-    /**
29
-     * Category constructor.
30
-     * @param null $fid
31
-     */
32
-    public function __construct($fid = null)
33
-    {
34
-        $this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
35
-        $this->initVar('pid', \XOBJ_DTYPE_INT, 0, false);
36
-        $this->initVar('weight', \XOBJ_DTYPE_INT, 1, false);
37
-        $this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
38
-        $this->initVar('description', \XOBJ_DTYPE_OTHER, null, false);
39
-        $this->initVar('image', \XOBJ_DTYPE_TXTBOX, null, false, 128);
40
-        $this->initVar('path', \XOBJ_DTYPE_TXTBOX, null, false, 128);
41
-        $this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
42
-        $this->initVar('albums', \XOBJ_DTYPE_INT, 0, false);
43
-        $this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
44
-        $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
45
-        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
46
-        $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
47
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
48
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
49
-    }
28
+	/**
29
+	 * Category constructor.
30
+	 * @param null $fid
31
+	 */
32
+	public function __construct($fid = null)
33
+	{
34
+		$this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
35
+		$this->initVar('pid', \XOBJ_DTYPE_INT, 0, false);
36
+		$this->initVar('weight', \XOBJ_DTYPE_INT, 1, false);
37
+		$this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
38
+		$this->initVar('description', \XOBJ_DTYPE_OTHER, null, false);
39
+		$this->initVar('image', \XOBJ_DTYPE_TXTBOX, null, false, 128);
40
+		$this->initVar('path', \XOBJ_DTYPE_TXTBOX, null, false, 128);
41
+		$this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
42
+		$this->initVar('albums', \XOBJ_DTYPE_INT, 0, false);
43
+		$this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
44
+		$this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
45
+		$this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
46
+		$this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
47
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
48
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
49
+	}
50 50
 
51
-    /**
52
-     * @param bool $as_array
53
-     * @return array|string
54
-     */
55
-    public function getForm($as_array = false)
56
-    {
57
-        return FormController::getFormCategory($this, $as_array);
58
-    }
51
+	/**
52
+	 * @param bool $as_array
53
+	 * @return array|string
54
+	 */
55
+	public function getForm($as_array = false)
56
+	{
57
+		return FormController::getFormCategory($this, $as_array);
58
+	}
59 59
 
60
-    /**
61
-     * @return array
62
-     */
63
-    public function toArray(): array
64
-    {
65
-        $ret  = parent::toArray();
66
-        $form = $this->getForm(true);
67
-        foreach ($form as $key => $element) {
68
-            $ret['form'][$key] = $element->render();
69
-        }
70
-        foreach (['created', 'updated'] as $key) {
71
-            if ($this->getVar($key) > 0) {
72
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
73
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
74
-            }
75
-        }
76
-        $ret['picture']  = $this->getImage('image', false);
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
-        $ret['url']      = $this->getURL();
79
-        $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
80
-        if ($categoryHandler->getCount(new \Criteria('pid', $this->getVar('cid')))) {
81
-            foreach ($categoryHandler->getObjects(new \Criteria('pid', $this->getVar('cid')), true) as $cid => $cat) {
82
-                $ret['subcategories'][$cid] = $cat->toArray();
83
-            }
84
-        }
60
+	/**
61
+	 * @return array
62
+	 */
63
+	public function toArray(): array
64
+	{
65
+		$ret  = parent::toArray();
66
+		$form = $this->getForm(true);
67
+		foreach ($form as $key => $element) {
68
+			$ret['form'][$key] = $element->render();
69
+		}
70
+		foreach (['created', 'updated'] as $key) {
71
+			if ($this->getVar($key) > 0) {
72
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
73
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
74
+			}
75
+		}
76
+		$ret['picture']  = $this->getImage('image', false);
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
+		$ret['url']      = $this->getURL();
79
+		$categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
80
+		if ($categoryHandler->getCount(new \Criteria('pid', $this->getVar('cid')))) {
81
+			foreach ($categoryHandler->getObjects(new \Criteria('pid', $this->getVar('cid')), true) as $cid => $cat) {
82
+				$ret['subcategories'][$cid] = $cat->toArray();
83
+			}
84
+		}
85 85
 
86
-        return $ret;
87
-    }
86
+		return $ret;
87
+	}
88 88
 
89
-    /**
90
-     * @param string $field
91
-     * @param bool   $local
92
-     * @return bool|string
93
-     */
94
-    public function getImage($field = 'image', $local = false)
95
-    {
96
-        if ('' == $this->getVar($field)) {
97
-            return false;
98
-        }
99
-        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
100
-            return false;
101
-        }
102
-        if (!$local) {
103
-            return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
104
-        }
89
+	/**
90
+	 * @param string $field
91
+	 * @param bool   $local
92
+	 * @return bool|string
93
+	 */
94
+	public function getImage($field = 'image', $local = false)
95
+	{
96
+		if ('' == $this->getVar($field)) {
97
+			return false;
98
+		}
99
+		if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
100
+			return false;
101
+		}
102
+		if (!$local) {
103
+			return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
104
+		}
105 105
 
106
-        return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
107
-    }
106
+		return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
107
+	}
108 108
 
109
-    /**
110
-     * @return string
111
-     */
112
-    public function getURL(): string
113
-    {
114
-        global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
109
+	/**
110
+	 * @return string
111
+	 */
112
+	public function getURL(): string
113
+	{
114
+		global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
115 115
 
116
-        return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=category&fct=set&id=' . $this->getVar('cid') . '&value=' . \urlencode($file ?? '') . '&gid=' . $gid . '&cid=' . $cid;
117
-    }
116
+		return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=category&fct=set&id=' . $this->getVar('cid') . '&value=' . \urlencode($file ?? '') . '&gid=' . $gid . '&cid=' . $cid;
117
+	}
118 118
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
             $ret['form'][$key] = $element->render();
69 69
         }
70 70
         foreach (['created', 'updated'] as $key) {
71
-            if ($this->getVar($key) > 0) {
71
+            if ($this->getVar($key)>0) {
72 72
                 $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
73 73
                 $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
74 74
             }
75 75
         }
76 76
         $ret['picture']  = $this->getImage('image', false);
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
         $ret['url']      = $this->getURL();
79 79
         $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
80 80
         if ($categoryHandler->getCount(new \Criteria('pid', $this->getVar('cid')))) {
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getImage($field = 'image', $local = false)
95 95
     {
96
-        if ('' == $this->getVar($field)) {
96
+        if (''==$this->getVar($field)) {
97 97
             return false;
98 98
         }
99
-        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
99
+        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path').$this->getVar($field)))) {
100 100
             return false;
101 101
         }
102 102
         if (!$local) {
103
-            return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
103
+            return XOOPS_URL.'/'.\str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
104 104
         }
105 105
 
106
-        return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
106
+        return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
107 107
     }
108 108
 
109 109
     /**
@@ -113,6 +113,6 @@  discard block
 block discarded – undo
113 113
     {
114 114
         global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
115 115
 
116
-        return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=category&fct=set&id=' . $this->getVar('cid') . '&value=' . \urlencode($file ?? '') . '&gid=' . $gid . '&cid=' . $cid;
116
+        return XOOPS_URL.'/modules/songlist/'.$file.'.php?op=category&fct=set&id='.$this->getVar('cid').'&value='.\urlencode($file ?? '').'&gid='.$gid.'&cid='.$cid;
117 117
     }
118 118
 }
Please login to merge, or discard this patch.
class/Songs.php 2 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -16,186 +16,186 @@
 block discarded – undo
16 16
  */
17 17
 class Songs extends XoopsObject
18 18
 {
19
-    public $sid;
20
-    public $cid;
21
-    public $gids;
22
-    public $vcid;
23
-    public $aids;
24
-    public $abid;
25
-    public $songid;
26
-    public $traxid;
27
-    public $title;
28
-    public $lyrics;
29
-    public $hits;
30
-    public $rank;
31
-    public $votes;
32
-    public $tags;
33
-    public $mp3;
34
-    public $created;
35
-    public $updated;
36
-
37
-    /**
38
-     * Songs constructor.
39
-     * @param null $fid
40
-     */
41
-    public function __construct($fid = null)
42
-    {
43
-        $this->initVar('sid', \XOBJ_DTYPE_INT, 0, false);
44
-        $this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
45
-        $this->initVar('gids', \XOBJ_DTYPE_ARRAY, 0, false);
46
-        $this->initVar('vcid', \XOBJ_DTYPE_INT, 0, false);
47
-        $this->initVar('aids', \XOBJ_DTYPE_ARRAY, [], false);
48
-        $this->initVar('abid', \XOBJ_DTYPE_INT, 0, false);
49
-        $this->initVar('songid', \XOBJ_DTYPE_TXTBOX, null, false, 32);
50
-        $this->initVar('traxid', \XOBJ_DTYPE_TXTBOX, null, false, 32);
51
-        $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
52
-        $this->initVar('lyrics', \XOBJ_DTYPE_OTHER, null, false);
53
-        $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
54
-        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
55
-        $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
56
-        $this->initVar('tags', \XOBJ_DTYPE_TXTBOX, null, false, 255);
57
-        $this->initVar('mp3', \XOBJ_DTYPE_OTHER, null, false, 500);
58
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
59
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
60
-    }
61
-
62
-    /**
63
-     * @param bool $as_array
64
-     * @return array|string
65
-     */
66
-    public function getForm($as_array = false)
67
-    {
68
-        return FormController::getFormSongs($this, $as_array);
69
-    }
70
-
71
-    /**
72
-     * @param bool $extra
73
-     * @return array
74
-     */
75
-    public function toArray($extra = true): array
76
-    {
77
-        $ret = parent::toArray();
78
-
79
-        $GLOBALS['myts'] = MyTextSanitizer::getInstance();
80
-
81
-        $ret['lyrics'] = $GLOBALS['myts']->displayTarea($this->getVar('lyrics'), true, true, true, true, true);
82
-
83
-        $form = $this->getForm(true);
84
-        foreach ($form as $key => $element) {
85
-            $ret['form'][$key] = $element->render();
86
-        }
87
-        foreach (['created', 'updated'] as $key) {
88
-            if ($this->getVar($key) > 0) {
89
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
90
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
91
-            }
92
-        }
93
-
94
-        $ret['url'] = $this->getURL();
95
-
96
-        $ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
97
-
98
-        if (!empty($ret['mp3'])) {
99
-            $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='
100
-                          . $ret['mp3']
101
-                          . "\" quality='high' menu='false' wmode='transparent' pluginspage='https://www.macromedia.com/go/getflashplayer' src='"
102
-                          . XOOPS_URL
103
-                          . "/images/form/player.swf'  width=290 height=24 type='application/x-shockwave-flash'></embed>";
104
-        }
105
-
106
-        $helper = Helper::getInstance();
107
-        if (1 == $helper->getConfig('tags')
108
-            && \class_exists(\XoopsModules\Tag\Tagbar::class)
109
-            && \xoops_isActiveModule('tag')) {
110
-            $tagbarObj     = new \XoopsModules\Tag\Tagbar();
111
-            $ret['tagbar'] = $tagbarObj->getTagbar($this->getVar('sid'), $this->getVar('cid'));
112
-        }
113
-
114
-        $extrasHandler     = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Extras');
115
-        $fieldHandler      = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Field');
116
-        $visibilityHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Visibility');
117
-
118
-        $extras = $extrasHandler->get($this->getVar('sid'));
119
-        if ($extras) {
120
-            if (\is_object($GLOBALS['xoopsUser'])) {
121
-                $fields_id = $visibilityHandler->getVisibleFields([], $GLOBALS['xoopsUser']->getGroups());
122
-            } elseif (!\is_object($GLOBALS['xoopsUser'])) {
123
-                $fields_id = $visibilityHandler->getVisibleFields([], []);
124
-            }
125
-
126
-            if (\count($fields_id) > 0) {
127
-                $criteria = new Criteria('field_id', '(' . \implode(',', $fields_id) . ')', 'IN');
128
-                $criteria->setSort('field_weight');
129
-                $fields = $fieldHandler->getObjects($criteria, true);
130
-                foreach ($fields as $id => $field) {
131
-                    if (\in_array($this->getVar('cid'), $field->getVar('cids'), true)) {
132
-                        $ret['fields'][$id]['title'] = $field->getVar('field_title');
133
-                        if (\is_object($GLOBALS['xoopsUser'])) {
134
-                            $ret['fields'][$id]['value'] = htmlspecialchars_decode($field->getOutputValue($GLOBALS['xoopsUser'], $extras));
135
-                        } elseif (!\is_object($GLOBALS['xoopsUser'])) {
136
-                            $ret['fields'][$id]['value'] = htmlspecialchars_decode($extras->getVar($field->getVar('field_name')));
137
-                        }
138
-                    }
139
-                }
140
-            }
141
-        }
142
-
143
-        if (!$extra) {
144
-            return $ret;
145
-        }
146
-
147
-        if (0 != $this->getVar('cid')) {
148
-            $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
149
-            $category        = $categoryHandler->get($this->getVar('cid'));
150
-            $ret['category'] = $category->toArray(false);
151
-        }
152
-
153
-        if (0 != \count($this->getVar('gids'))) {
154
-            $i            = 0;
155
-            $genreHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Genre');
156
-            $ret['genre'] = '';
157
-            $genres       = $genreHandler->getObjects(new Criteria('gid', '(' . \implode(',', $this->getVar('gids')) . ')', 'IN'), true);
158
-            foreach ($genres as $gid => $genre) {
159
-                $ret['genre_array'][$gid] = $genre->toArray(false);
160
-                ++$i;
161
-                $ret['genre'] .= $genre->getVar('name') . ($i < \count($genres) ? ', ' : '');
162
-            }
163
-        }
164
-        if (0 != $this->getVar('vcid')) {
165
-            $voiceHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Voice');
166
-            $voice        = $voiceHandler->get($this->getVar('vcid'));
167
-            $ret['voice'] = $voice->toArray(false);
168
-        }
169
-
170
-        if (0 != \count($this->getVar('aids'))) {
171
-            $artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
172
-            foreach ($this->getVar('aids') as $aid) {
173
-                $artist                     = $artistsHandler->get($aid);
174
-                $ret['artists_array'][$aid] = $artist->toArray(false);
175
-            }
176
-        }
177
-
178
-        if (0 != $this->getVar('abid')) {
179
-            $albumsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
180
-            $albums        = $albumsHandler->get($this->getVar('abid'));
181
-            if (null !== $albums) {
182
-                $ret['albums'] = $albums->toArray(false);
183
-            }
184
-        }
185
-
186
-        return $ret;
187
-    }
188
-
189
-    /**
190
-     * @return string
191
-     */
192
-    public function getURL(): string
193
-    {
194
-        global $file, $op, $fct, $id, $value, $vcid, $gid, $cid, $start, $limit;
195
-        if ($GLOBALS['songlistModuleConfig']['htaccess']) {
196
-            return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/index/' . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('title'))) . '/item-item-' . $this->getVar('sid') . $GLOBALS['songlistModuleConfig']['endofurl'];
197
-        }
198
-
199
-        return XOOPS_URL . '/modules/songlist/index.php?op=item&fct=item&id=' . $this->getVar('sid') . '&value=' . \urlencode($value ?? '') . '&vcid=' . $vcid . '&gid=' . $gid . '&cid=' . $cid;
200
-    }
19
+	public $sid;
20
+	public $cid;
21
+	public $gids;
22
+	public $vcid;
23
+	public $aids;
24
+	public $abid;
25
+	public $songid;
26
+	public $traxid;
27
+	public $title;
28
+	public $lyrics;
29
+	public $hits;
30
+	public $rank;
31
+	public $votes;
32
+	public $tags;
33
+	public $mp3;
34
+	public $created;
35
+	public $updated;
36
+
37
+	/**
38
+	 * Songs constructor.
39
+	 * @param null $fid
40
+	 */
41
+	public function __construct($fid = null)
42
+	{
43
+		$this->initVar('sid', \XOBJ_DTYPE_INT, 0, false);
44
+		$this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
45
+		$this->initVar('gids', \XOBJ_DTYPE_ARRAY, 0, false);
46
+		$this->initVar('vcid', \XOBJ_DTYPE_INT, 0, false);
47
+		$this->initVar('aids', \XOBJ_DTYPE_ARRAY, [], false);
48
+		$this->initVar('abid', \XOBJ_DTYPE_INT, 0, false);
49
+		$this->initVar('songid', \XOBJ_DTYPE_TXTBOX, null, false, 32);
50
+		$this->initVar('traxid', \XOBJ_DTYPE_TXTBOX, null, false, 32);
51
+		$this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
52
+		$this->initVar('lyrics', \XOBJ_DTYPE_OTHER, null, false);
53
+		$this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
54
+		$this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
55
+		$this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
56
+		$this->initVar('tags', \XOBJ_DTYPE_TXTBOX, null, false, 255);
57
+		$this->initVar('mp3', \XOBJ_DTYPE_OTHER, null, false, 500);
58
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
59
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
60
+	}
61
+
62
+	/**
63
+	 * @param bool $as_array
64
+	 * @return array|string
65
+	 */
66
+	public function getForm($as_array = false)
67
+	{
68
+		return FormController::getFormSongs($this, $as_array);
69
+	}
70
+
71
+	/**
72
+	 * @param bool $extra
73
+	 * @return array
74
+	 */
75
+	public function toArray($extra = true): array
76
+	{
77
+		$ret = parent::toArray();
78
+
79
+		$GLOBALS['myts'] = MyTextSanitizer::getInstance();
80
+
81
+		$ret['lyrics'] = $GLOBALS['myts']->displayTarea($this->getVar('lyrics'), true, true, true, true, true);
82
+
83
+		$form = $this->getForm(true);
84
+		foreach ($form as $key => $element) {
85
+			$ret['form'][$key] = $element->render();
86
+		}
87
+		foreach (['created', 'updated'] as $key) {
88
+			if ($this->getVar($key) > 0) {
89
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
90
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
91
+			}
92
+		}
93
+
94
+		$ret['url'] = $this->getURL();
95
+
96
+		$ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
97
+
98
+		if (!empty($ret['mp3'])) {
99
+			$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='
100
+						  . $ret['mp3']
101
+						  . "\" quality='high' menu='false' wmode='transparent' pluginspage='https://www.macromedia.com/go/getflashplayer' src='"
102
+						  . XOOPS_URL
103
+						  . "/images/form/player.swf'  width=290 height=24 type='application/x-shockwave-flash'></embed>";
104
+		}
105
+
106
+		$helper = Helper::getInstance();
107
+		if (1 == $helper->getConfig('tags')
108
+			&& \class_exists(\XoopsModules\Tag\Tagbar::class)
109
+			&& \xoops_isActiveModule('tag')) {
110
+			$tagbarObj     = new \XoopsModules\Tag\Tagbar();
111
+			$ret['tagbar'] = $tagbarObj->getTagbar($this->getVar('sid'), $this->getVar('cid'));
112
+		}
113
+
114
+		$extrasHandler     = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Extras');
115
+		$fieldHandler      = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Field');
116
+		$visibilityHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Visibility');
117
+
118
+		$extras = $extrasHandler->get($this->getVar('sid'));
119
+		if ($extras) {
120
+			if (\is_object($GLOBALS['xoopsUser'])) {
121
+				$fields_id = $visibilityHandler->getVisibleFields([], $GLOBALS['xoopsUser']->getGroups());
122
+			} elseif (!\is_object($GLOBALS['xoopsUser'])) {
123
+				$fields_id = $visibilityHandler->getVisibleFields([], []);
124
+			}
125
+
126
+			if (\count($fields_id) > 0) {
127
+				$criteria = new Criteria('field_id', '(' . \implode(',', $fields_id) . ')', 'IN');
128
+				$criteria->setSort('field_weight');
129
+				$fields = $fieldHandler->getObjects($criteria, true);
130
+				foreach ($fields as $id => $field) {
131
+					if (\in_array($this->getVar('cid'), $field->getVar('cids'), true)) {
132
+						$ret['fields'][$id]['title'] = $field->getVar('field_title');
133
+						if (\is_object($GLOBALS['xoopsUser'])) {
134
+							$ret['fields'][$id]['value'] = htmlspecialchars_decode($field->getOutputValue($GLOBALS['xoopsUser'], $extras));
135
+						} elseif (!\is_object($GLOBALS['xoopsUser'])) {
136
+							$ret['fields'][$id]['value'] = htmlspecialchars_decode($extras->getVar($field->getVar('field_name')));
137
+						}
138
+					}
139
+				}
140
+			}
141
+		}
142
+
143
+		if (!$extra) {
144
+			return $ret;
145
+		}
146
+
147
+		if (0 != $this->getVar('cid')) {
148
+			$categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
149
+			$category        = $categoryHandler->get($this->getVar('cid'));
150
+			$ret['category'] = $category->toArray(false);
151
+		}
152
+
153
+		if (0 != \count($this->getVar('gids'))) {
154
+			$i            = 0;
155
+			$genreHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Genre');
156
+			$ret['genre'] = '';
157
+			$genres       = $genreHandler->getObjects(new Criteria('gid', '(' . \implode(',', $this->getVar('gids')) . ')', 'IN'), true);
158
+			foreach ($genres as $gid => $genre) {
159
+				$ret['genre_array'][$gid] = $genre->toArray(false);
160
+				++$i;
161
+				$ret['genre'] .= $genre->getVar('name') . ($i < \count($genres) ? ', ' : '');
162
+			}
163
+		}
164
+		if (0 != $this->getVar('vcid')) {
165
+			$voiceHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Voice');
166
+			$voice        = $voiceHandler->get($this->getVar('vcid'));
167
+			$ret['voice'] = $voice->toArray(false);
168
+		}
169
+
170
+		if (0 != \count($this->getVar('aids'))) {
171
+			$artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
172
+			foreach ($this->getVar('aids') as $aid) {
173
+				$artist                     = $artistsHandler->get($aid);
174
+				$ret['artists_array'][$aid] = $artist->toArray(false);
175
+			}
176
+		}
177
+
178
+		if (0 != $this->getVar('abid')) {
179
+			$albumsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
180
+			$albums        = $albumsHandler->get($this->getVar('abid'));
181
+			if (null !== $albums) {
182
+				$ret['albums'] = $albums->toArray(false);
183
+			}
184
+		}
185
+
186
+		return $ret;
187
+	}
188
+
189
+	/**
190
+	 * @return string
191
+	 */
192
+	public function getURL(): string
193
+	{
194
+		global $file, $op, $fct, $id, $value, $vcid, $gid, $cid, $start, $limit;
195
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
196
+			return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/index/' . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('title'))) . '/item-item-' . $this->getVar('sid') . $GLOBALS['songlistModuleConfig']['endofurl'];
197
+		}
198
+
199
+		return XOOPS_URL . '/modules/songlist/index.php?op=item&fct=item&id=' . $this->getVar('sid') . '&value=' . \urlencode($value ?? '') . '&vcid=' . $vcid . '&gid=' . $gid . '&cid=' . $cid;
200
+	}
201 201
 }
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
 
11 11
 // require_once \dirname(__DIR__) . '/include/songlist.form.php';
12 12
 use  XoopsModules\Songlist\Form\FormController;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             $ret['form'][$key] = $element->render();
86 86
         }
87 87
         foreach (['created', 'updated'] as $key) {
88
-            if ($this->getVar($key) > 0) {
88
+            if ($this->getVar($key)>0) {
89 89
                 $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
90 90
                 $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
91 91
             }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
         $ret['url'] = $this->getURL();
95 95
 
96
-        $ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
96
+        $ret['rank'] = \number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2).\_MI_SONGLIST_OFTEN;
97 97
 
98 98
         if (!empty($ret['mp3'])) {
99 99
             $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='
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         }
105 105
 
106 106
         $helper = Helper::getInstance();
107
-        if (1 == $helper->getConfig('tags')
107
+        if (1==$helper->getConfig('tags')
108 108
             && \class_exists(\XoopsModules\Tag\Tagbar::class)
109 109
             && \xoops_isActiveModule('tag')) {
110 110
             $tagbarObj     = new \XoopsModules\Tag\Tagbar();
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
                 $fields_id = $visibilityHandler->getVisibleFields([], []);
124 124
             }
125 125
 
126
-            if (\count($fields_id) > 0) {
127
-                $criteria = new Criteria('field_id', '(' . \implode(',', $fields_id) . ')', 'IN');
126
+            if (\count($fields_id)>0) {
127
+                $criteria = new Criteria('field_id', '('.\implode(',', $fields_id).')', 'IN');
128 128
                 $criteria->setSort('field_weight');
129 129
                 $fields = $fieldHandler->getObjects($criteria, true);
130 130
                 foreach ($fields as $id => $field) {
@@ -144,30 +144,30 @@  discard block
 block discarded – undo
144 144
             return $ret;
145 145
         }
146 146
 
147
-        if (0 != $this->getVar('cid')) {
147
+        if (0!=$this->getVar('cid')) {
148 148
             $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
149 149
             $category        = $categoryHandler->get($this->getVar('cid'));
150 150
             $ret['category'] = $category->toArray(false);
151 151
         }
152 152
 
153
-        if (0 != \count($this->getVar('gids'))) {
153
+        if (0!=\count($this->getVar('gids'))) {
154 154
             $i            = 0;
155 155
             $genreHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Genre');
156 156
             $ret['genre'] = '';
157
-            $genres       = $genreHandler->getObjects(new Criteria('gid', '(' . \implode(',', $this->getVar('gids')) . ')', 'IN'), true);
157
+            $genres       = $genreHandler->getObjects(new Criteria('gid', '('.\implode(',', $this->getVar('gids')).')', 'IN'), true);
158 158
             foreach ($genres as $gid => $genre) {
159 159
                 $ret['genre_array'][$gid] = $genre->toArray(false);
160 160
                 ++$i;
161
-                $ret['genre'] .= $genre->getVar('name') . ($i < \count($genres) ? ', ' : '');
161
+                $ret['genre'] .= $genre->getVar('name').($i<\count($genres) ? ', ' : '');
162 162
             }
163 163
         }
164
-        if (0 != $this->getVar('vcid')) {
164
+        if (0!=$this->getVar('vcid')) {
165 165
             $voiceHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Voice');
166 166
             $voice        = $voiceHandler->get($this->getVar('vcid'));
167 167
             $ret['voice'] = $voice->toArray(false);
168 168
         }
169 169
 
170
-        if (0 != \count($this->getVar('aids'))) {
170
+        if (0!=\count($this->getVar('aids'))) {
171 171
             $artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
172 172
             foreach ($this->getVar('aids') as $aid) {
173 173
                 $artist                     = $artistsHandler->get($aid);
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
             }
176 176
         }
177 177
 
178
-        if (0 != $this->getVar('abid')) {
178
+        if (0!=$this->getVar('abid')) {
179 179
             $albumsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
180 180
             $albums        = $albumsHandler->get($this->getVar('abid'));
181
-            if (null !== $albums) {
181
+            if (null!==$albums) {
182 182
                 $ret['albums'] = $albums->toArray(false);
183 183
             }
184 184
         }
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
     {
194 194
         global $file, $op, $fct, $id, $value, $vcid, $gid, $cid, $start, $limit;
195 195
         if ($GLOBALS['songlistModuleConfig']['htaccess']) {
196
-            return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/index/' . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('title'))) . '/item-item-' . $this->getVar('sid') . $GLOBALS['songlistModuleConfig']['endofurl'];
196
+            return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/index/'.\urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('title'))).'/item-item-'.$this->getVar('sid').$GLOBALS['songlistModuleConfig']['endofurl'];
197 197
         }
198 198
 
199
-        return XOOPS_URL . '/modules/songlist/index.php?op=item&fct=item&id=' . $this->getVar('sid') . '&value=' . \urlencode($value ?? '') . '&vcid=' . $vcid . '&gid=' . $gid . '&cid=' . $cid;
199
+        return XOOPS_URL.'/modules/songlist/index.php?op=item&fct=item&id='.$this->getVar('sid').'&value='.\urlencode($value ?? '').'&vcid='.$vcid.'&gid='.$gid.'&cid='.$cid;
200 200
     }
201 201
 }
Please login to merge, or discard this patch.
class/Albums.php 1 patch
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -12,169 +12,169 @@
 block discarded – undo
12 12
  */
13 13
 class Albums extends \XoopsObject
14 14
 {
15
-    public $abid;
16
-    public $cid;
17
-    public $aids;
18
-    public $sids;
19
-    public $title;
20
-    public $image;
21
-    public $path;
22
-    public $artists;
23
-    public $songs;
24
-    public $hits;
25
-    public $rank;
26
-    public $votes;
27
-    public $created;
28
-    public $updated;
29
-
30
-    /**
31
-     * Albums constructor.
32
-     * @param null $fid
33
-     */
34
-    public function __construct($fid = null)
35
-    {
36
-        $this->initVar('abid', \XOBJ_DTYPE_INT, 0, false);
37
-        $this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
38
-        $this->initVar('aids', \XOBJ_DTYPE_ARRAY, [], false);
39
-        $this->initVar('sids', \XOBJ_DTYPE_ARRAY, [], false);
40
-        $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
41
-        $this->initVar('image', \XOBJ_DTYPE_TXTBOX, null, false, 255);
42
-        $this->initVar('path', \XOBJ_DTYPE_TXTBOX, null, false, 255);
43
-        $this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
44
-        $this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
45
-        $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
46
-        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
47
-        $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
48
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
49
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
50
-    }
51
-
52
-    /**
53
-     * @param bool $as_array
54
-     * @return array|string
55
-     */
56
-    public function getForm($as_array = false)
57
-    {
58
-        return FormController::getFormAlbums($this, $as_array);
59
-    }
60
-
61
-    /**
62
-     * @param bool $extra
63
-     * @return array
64
-     */
65
-    public function toArray($extra = true): array
66
-    {
67
-        $ret  = parent::toArray();
68
-        $form = $this->getForm(true);
69
-        foreach ($form as $key => $element) {
70
-            $ret['form'][$key] = $element->render();
71
-        }
72
-        foreach (['created', 'updated'] as $key) {
73
-            if ($this->getVar($key) > 0) {
74
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
75
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
76
-            }
77
-        }
78
-        $ret['picture'] = $this->getImage('image', false);
79
-        $ret['rank']    = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
80
-        $ret['url']     = $this->getURL(true);
81
-
82
-        if (!$extra) {
83
-            return $ret;
84
-        }
85
-
86
-        if (0 != $this->getVar('cid')) {
87
-            $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
88
-            $category        = $categoryHandler->get($this->getVar('cid'));
89
-            if (\is_object($category)) {
90
-                $ret['category'] = $category->toArray(false);
91
-            }
92
-        }
93
-
94
-        if (0 != \count($this->getVar('aids'))) {
95
-            $artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
96
-            foreach ($this->getVar('aids') as $aid) {
97
-                $artist = $artistsHandler->get($aid);
98
-                if (\is_object($artist)) {
99
-                    $ret['artists_array'][$aid] = $artist->toArray(false);
100
-                }
101
-            }
102
-        }
103
-
104
-        if (0 != \count($this->getVar('sids'))) {
105
-            $songsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Songs');
106
-            $criteria     = new \Criteria('sid', '(' . \implode(',', $this->getVar('sids')) . ')', 'IN');
107
-            $criteria->setSort('traxid');
108
-            $criteria->setOrder('ASC');
109
-            foreach ($songsHandler->getObjects($criteria, true) as $sid => $song) {
110
-                if (\is_object($song)) {
111
-                    $ret['songs_array'][$sid] = $song->toArray(false);
112
-                }
113
-            }
114
-        }
115
-
116
-        return $ret;
117
-    }
118
-
119
-    /**
120
-     * @param string $field
121
-     * @param bool   $local
122
-     * @return bool|string
123
-     */
124
-    public function getImage($field = 'image', $local = false)
125
-    {
126
-        if ('' == $this->getVar($field)) {
127
-            return false;
128
-        }
129
-        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
130
-            return false;
131
-        }
132
-        if (!$local) {
133
-            return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
134
-        }
135
-
136
-        return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
137
-    }
138
-
139
-    /**
140
-     * @return string
141
-     */
142
-    public function getURL(): string
143
-    {
144
-        global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
145
-        if ($GLOBALS['songlistModuleConfig']['htaccess']) {
146
-            if (0 != $id) {
147
-                $artistHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
148
-                $artist        = $artistHandler->get($id);
149
-                if (\is_object($artist) && !$artist->isNew()) {
150
-                    return XOOPS_URL
151
-                           . '/'
152
-                           . $GLOBALS['songlistModuleConfig']['baseofurl']
153
-                           . '/albums/'
154
-                           . \urlencode(\str_replace([' ', \chr(9)], '-', $artist->getVar('title')))
155
-                           . '/'
156
-                           . $start
157
-                           . '-'
158
-                           . $id
159
-                           . '-'
160
-                           . $op
161
-                           . '-'
162
-                           . $fct
163
-                           . '-'
164
-                           . $gid
165
-                           . '-'
166
-                           . $cid
167
-                           . '/'
168
-                           . \urlencode($value)
169
-                           . $GLOBALS['songlistModuleConfig']['endofurl'];
170
-                }
171
-
172
-                return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
173
-            }
174
-
175
-            return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
176
-        }
177
-
178
-        return XOOPS_URL . '/modules/songlist/albums.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid . '&start=' . $start;
179
-    }
15
+	public $abid;
16
+	public $cid;
17
+	public $aids;
18
+	public $sids;
19
+	public $title;
20
+	public $image;
21
+	public $path;
22
+	public $artists;
23
+	public $songs;
24
+	public $hits;
25
+	public $rank;
26
+	public $votes;
27
+	public $created;
28
+	public $updated;
29
+
30
+	/**
31
+	 * Albums constructor.
32
+	 * @param null $fid
33
+	 */
34
+	public function __construct($fid = null)
35
+	{
36
+		$this->initVar('abid', \XOBJ_DTYPE_INT, 0, false);
37
+		$this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
38
+		$this->initVar('aids', \XOBJ_DTYPE_ARRAY, [], false);
39
+		$this->initVar('sids', \XOBJ_DTYPE_ARRAY, [], false);
40
+		$this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
41
+		$this->initVar('image', \XOBJ_DTYPE_TXTBOX, null, false, 255);
42
+		$this->initVar('path', \XOBJ_DTYPE_TXTBOX, null, false, 255);
43
+		$this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
44
+		$this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
45
+		$this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
46
+		$this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
47
+		$this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
48
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
49
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
50
+	}
51
+
52
+	/**
53
+	 * @param bool $as_array
54
+	 * @return array|string
55
+	 */
56
+	public function getForm($as_array = false)
57
+	{
58
+		return FormController::getFormAlbums($this, $as_array);
59
+	}
60
+
61
+	/**
62
+	 * @param bool $extra
63
+	 * @return array
64
+	 */
65
+	public function toArray($extra = true): array
66
+	{
67
+		$ret  = parent::toArray();
68
+		$form = $this->getForm(true);
69
+		foreach ($form as $key => $element) {
70
+			$ret['form'][$key] = $element->render();
71
+		}
72
+		foreach (['created', 'updated'] as $key) {
73
+			if ($this->getVar($key) > 0) {
74
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
75
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
76
+			}
77
+		}
78
+		$ret['picture'] = $this->getImage('image', false);
79
+		$ret['rank']    = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
80
+		$ret['url']     = $this->getURL(true);
81
+
82
+		if (!$extra) {
83
+			return $ret;
84
+		}
85
+
86
+		if (0 != $this->getVar('cid')) {
87
+			$categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
88
+			$category        = $categoryHandler->get($this->getVar('cid'));
89
+			if (\is_object($category)) {
90
+				$ret['category'] = $category->toArray(false);
91
+			}
92
+		}
93
+
94
+		if (0 != \count($this->getVar('aids'))) {
95
+			$artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
96
+			foreach ($this->getVar('aids') as $aid) {
97
+				$artist = $artistsHandler->get($aid);
98
+				if (\is_object($artist)) {
99
+					$ret['artists_array'][$aid] = $artist->toArray(false);
100
+				}
101
+			}
102
+		}
103
+
104
+		if (0 != \count($this->getVar('sids'))) {
105
+			$songsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Songs');
106
+			$criteria     = new \Criteria('sid', '(' . \implode(',', $this->getVar('sids')) . ')', 'IN');
107
+			$criteria->setSort('traxid');
108
+			$criteria->setOrder('ASC');
109
+			foreach ($songsHandler->getObjects($criteria, true) as $sid => $song) {
110
+				if (\is_object($song)) {
111
+					$ret['songs_array'][$sid] = $song->toArray(false);
112
+				}
113
+			}
114
+		}
115
+
116
+		return $ret;
117
+	}
118
+
119
+	/**
120
+	 * @param string $field
121
+	 * @param bool   $local
122
+	 * @return bool|string
123
+	 */
124
+	public function getImage($field = 'image', $local = false)
125
+	{
126
+		if ('' == $this->getVar($field)) {
127
+			return false;
128
+		}
129
+		if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
130
+			return false;
131
+		}
132
+		if (!$local) {
133
+			return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
134
+		}
135
+
136
+		return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
137
+	}
138
+
139
+	/**
140
+	 * @return string
141
+	 */
142
+	public function getURL(): string
143
+	{
144
+		global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
145
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
146
+			if (0 != $id) {
147
+				$artistHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
148
+				$artist        = $artistHandler->get($id);
149
+				if (\is_object($artist) && !$artist->isNew()) {
150
+					return XOOPS_URL
151
+						   . '/'
152
+						   . $GLOBALS['songlistModuleConfig']['baseofurl']
153
+						   . '/albums/'
154
+						   . \urlencode(\str_replace([' ', \chr(9)], '-', $artist->getVar('title')))
155
+						   . '/'
156
+						   . $start
157
+						   . '-'
158
+						   . $id
159
+						   . '-'
160
+						   . $op
161
+						   . '-'
162
+						   . $fct
163
+						   . '-'
164
+						   . $gid
165
+						   . '-'
166
+						   . $cid
167
+						   . '/'
168
+						   . \urlencode($value)
169
+						   . $GLOBALS['songlistModuleConfig']['endofurl'];
170
+				}
171
+
172
+				return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
173
+			}
174
+
175
+			return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
176
+		}
177
+
178
+		return XOOPS_URL . '/modules/songlist/albums.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid . '&start=' . $start;
179
+	}
180 180
 }
Please login to merge, or discard this patch.