Passed
Push — master ( ed55b2...84c1d9 )
by Michael
12:36 queued 12s
created
htdocs/modules/songlist/class/genre.php 3 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
 class SonglistGenre extends XoopsObject
11 11
 {
12 12
 
13
-    function SonglistGenre($fid = null)
14
-    {
15
-        $this->initVar('gid', XOBJ_DTYPE_INT, 0, false);
13
+	function SonglistGenre($fid = null)
14
+	{
15
+		$this->initVar('gid', XOBJ_DTYPE_INT, 0, false);
16 16
 		$this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 128);
17 17
 		$this->initVar('artists', XOBJ_DTYPE_INT, 0, false);
18 18
 		$this->initVar('albums', XOBJ_DTYPE_INT, 0, false);
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 	
48 48
 	function getURL() {
49
-    	global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
50
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
51
-    		return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $this->getVar('name'))).'/'.$op.'-'.$fct.'-'.$this->getVar('gid').'-'.urlencode($value).'-'.$gid.'-'.$cid.$GLOBALS['songlistModuleConfig']['endofurl'];
52
-    	} else {
53
-    		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$this->getVar('gid').'&value='.urlencode($value).'&gid='.$gid.'&cid='.$cid;
54
-    	}
55
-    }
49
+		global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
50
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
51
+			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $this->getVar('name'))).'/'.$op.'-'.$fct.'-'.$this->getVar('gid').'-'.urlencode($value).'-'.$gid.'-'.$cid.$GLOBALS['songlistModuleConfig']['endofurl'];
52
+		} else {
53
+			return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$this->getVar('gid').'&value='.urlencode($value).'&gid='.$gid.'&cid='.$cid;
54
+		}
55
+	}
56 56
 	
57 57
 	
58 58
 	
@@ -61,76 +61,76 @@  discard block
 block discarded – undo
61 61
 
62 62
 class SonglistGenreHandler extends XoopsPersistableObjectHandler
63 63
 {
64
-    function __construct(&$db) 
65
-    {
66
-        parent::__construct($db, "songlist_genre", 'SonglistGenre', "gid", "name");
67
-    }
64
+	function __construct(&$db) 
65
+	{
66
+		parent::__construct($db, "songlist_genre", 'SonglistGenre', "gid", "name");
67
+	}
68 68
 
69 69
 	function filterFields() {
70 70
 		return array('gid', 'name', 'artists', 'albums', 'songs', 'hits', 'rank', 'votes', 'created', 'updated');
71 71
 	}
72 72
 	
73
-    function getFilterCriteria($filter) {
74
-    	$parts = explode('|', $filter);
75
-    	$criteria = new CriteriaCompo();
76
-    	foreach($parts as $part) {
77
-    		$var = explode(',', $part);
78
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
79
-    			$object = $this->create();
80
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
81
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
82
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
83
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
84
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
85
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
86
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
73
+	function getFilterCriteria($filter) {
74
+		$parts = explode('|', $filter);
75
+		$criteria = new CriteriaCompo();
76
+		foreach($parts as $part) {
77
+			$var = explode(',', $part);
78
+			if (!empty($var[1])&&!is_numeric($var[0])) {
79
+				$object = $this->create();
80
+				if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
81
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
82
+					$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
83
+				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
84
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
85
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
86
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
87 87
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
88
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
88
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
89 89
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
90
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
90
+					$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
91 91
 				}
92
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
93
-    			$criteria->add(new Criteria($var[0], $var[1]));
94
-    		}
95
-    	}
96
-    	return $criteria;
97
-    }
92
+			} elseif (!empty($var[1])&&is_numeric($var[0])) {
93
+				$criteria->add(new Criteria($var[0], $var[1]));
94
+			}
95
+		}
96
+		return $criteria;
97
+	}
98 98
         
99
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
100
-    	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
101
-    	if (is_object($ele))
102
-    		return $ele->render();
103
-    	else 
104
-    		return ' ';
105
-    }
99
+	function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
100
+		$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
101
+		if (is_object($ele))
102
+			return $ele->render();
103
+		else 
104
+			return ' ';
105
+	}
106 106
     
107 107
 	function insert($obj, $force=true) {
108
-    	if ($obj->isNew()) {
109
-    		$obj->setVar('created', time());	
110
-    	} else {
111
-    		$obj->setVar('updated', time());
112
-    	}
113
-    	if (strlen($obj->getVar('name'))==0)
114
-    		return false;
115
-    	return parent::insert($obj, $force);
116
-    }
108
+		if ($obj->isNew()) {
109
+			$obj->setVar('created', time());	
110
+		} else {
111
+			$obj->setVar('updated', time());
112
+		}
113
+		if (strlen($obj->getVar('name'))==0)
114
+			return false;
115
+		return parent::insert($obj, $force);
116
+	}
117 117
      
118 118
 	var $_objects = array('object'=>array(), 'array'=>array());
119 119
     
120
-    function get($id, $fields = '*') {
121
-    	if (!isset($this->_objects['object'][$id])) {
122
-	    	$this->_objects['object'][$id] = parent::get($id, $fields);
123
-	    	if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
124
-		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
125
-		    	$GLOBALS['xoopsDB']->queryF($sql);
126
-	    	}
127
-    	}
128
-    	return $this->_objects['object'][$id];
129
-    }
120
+	function get($id, $fields = '*') {
121
+		if (!isset($this->_objects['object'][$id])) {
122
+			$this->_objects['object'][$id] = parent::get($id, $fields);
123
+			if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
124
+				$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
125
+				$GLOBALS['xoopsDB']->queryF($sql);
126
+			}
127
+		}
128
+		return $this->_objects['object'][$id];
129
+	}
130 130
     
131
-    function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
132
-    	$ret = parent::getObjects($criteria, $id_as_key, $as_object);
133
-    	/*if (!isset($GLOBALS['songlistAdmin'])) {
131
+	function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
132
+		$ret = parent::getObjects($criteria, $id_as_key, $as_object);
133
+		/*if (!isset($GLOBALS['songlistAdmin'])) {
134 134
 	    	$id = array();
135 135
 	    	foreach($ret as $data) {
136 136
 	    		if ($as_object==true) {
@@ -150,36 +150,36 @@  discard block
 block discarded – undo
150 150
 	    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` IN ('.implode(',', $id).')';
151 151
 	    	$GLOBALS['xoopsDB']->queryF($sql);
152 152
     	}*/
153
-    	return $ret;
154
-    }
153
+		return $ret;
154
+	}
155 155
 
156
-    function getURL() {
157
-    	global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
158
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
159
-    		return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseurl'].'/'.$file.'/'.$start.'-'.$op.'-'.$fct.'-'.$id.'-'.urlencode($value).'-'.$gid.'-'.$cid.$GLOBALS['songlistModuleConfig']['endofurl'];
160
-    	} else {
161
-    		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&cid='.$cid.'&start='.$start;
162
-    	}
163
-    }
156
+	function getURL() {
157
+		global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
158
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
159
+			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseurl'].'/'.$file.'/'.$start.'-'.$op.'-'.$fct.'-'.$id.'-'.urlencode($value).'-'.$gid.'-'.$cid.$GLOBALS['songlistModuleConfig']['endofurl'];
160
+		} else {
161
+			return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&cid='.$cid.'&start='.$start;
162
+		}
163
+	}
164 164
     
165 165
 	function getTop($limit=1) {
166
-    	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
167
-    	$results = $GLOBALS['xoopsDB']->queryF($sql);
168
-    	$ret = array();
169
-    	$i=0;
170
-    	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
171
-    		$ret[$i] = $this->create();
172
-    		$ret[$i]->assignVars($row);
173
-    		$i++;
174
-    	}
175
-    	return $ret;
176
-    }
166
+		$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
167
+		$results = $GLOBALS['xoopsDB']->queryF($sql);
168
+		$ret = array();
169
+		$i=0;
170
+		while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
171
+			$ret[$i] = $this->create();
172
+			$ret[$i]->assignVars($row);
173
+			$i++;
174
+		}
175
+		return $ret;
176
+	}
177 177
     
178
-    function delete($object, $force=true) {
179
-    	parent::delete($object, $force);
180
-    	$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `gid` = 0 WHERE `gid` = ' . $object->getVar('gid');
181
-    	return $GLOBALS['xoopsDB']->queryF($sql);	
182
-    }
178
+	function delete($object, $force=true) {
179
+		parent::delete($object, $force);
180
+		$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `gid` = 0 WHERE `gid` = ' . $object->getVar('gid');
181
+		return $GLOBALS['xoopsDB']->queryF($sql);	
182
+	}
183 183
     
184 184
 }
185 185
 ?>
186 186
\ 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
@@ -31,16 +31,16 @@  discard block
 block discarded – undo
31 31
 	function toArray() {
32 32
 		$ret = parent::toArray();
33 33
 		$form = $this->getForm(true);
34
-		foreach($form as $key => $element) {
34
+		foreach ($form as $key => $element) {
35 35
 			$ret['form'][$key] = $form[$key]->render();	
36 36
 		}
37
-		foreach(array('created', 'updated') as $key) {
37
+		foreach (array('created', 'updated') as $key) {
38 38
 			if ($this->getVar($key)>0) {
39 39
 				$ret['form'][$key] = date(_DATESTRING, $this->getVar($key)); 
40 40
 				$ret[$key] = date(_DATESTRING, $this->getVar($key));
41 41
 			}
42 42
 		}
43
-		$ret['rank'] = number_format(($this->getVar('rank')>0&&$this->getVar('votes')>0?$this->getVar('rank')/$this->getVar('votes'):0),2)._MI_SONGLIST_OFTEN;
43
+		$ret['rank'] = number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2)._MI_SONGLIST_OFTEN;
44 44
     		
45 45
 		return $ret;
46 46
 	}
@@ -73,30 +73,30 @@  discard block
 block discarded – undo
73 73
     function getFilterCriteria($filter) {
74 74
     	$parts = explode('|', $filter);
75 75
     	$criteria = new CriteriaCompo();
76
-    	foreach($parts as $part) {
76
+    	foreach ($parts as $part) {
77 77
     		$var = explode(',', $part);
78
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
78
+    		if (!empty($var[1]) && !is_numeric($var[0])) {
79 79
     			$object = $this->create();
80
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
81
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
82
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
83
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
80
+    			if ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
81
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) {
82
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2]) ? $var[2] : 'LIKE')));
83
+    			} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
84 84
     						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
85
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
86
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
87
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
88
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
89
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
90
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
85
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT) {
86
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));			
87
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM) {
88
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));    				
89
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY) {
90
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2]) ? $var[2] : 'LIKE')));    				
91 91
 				}
92
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
92
+    		} elseif (!empty($var[1]) && is_numeric($var[0])) {
93 93
     			$criteria->add(new Criteria($var[0], $var[1]));
94 94
     		}
95 95
     	}
96 96
     	return $criteria;
97 97
     }
98 98
         
99
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
99
+    function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list') {
100 100
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
101 101
     	if (is_object($ele))
102 102
     		return $ele->render();
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     		return ' ';
105 105
     }
106 106
     
107
-	function insert($obj, $force=true) {
107
+	function insert($obj, $force = true) {
108 108
     	if ($obj->isNew()) {
109 109
     		$obj->setVar('created', time());	
110 110
     	} else {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     function get($id, $fields = '*') {
121 121
     	if (!isset($this->_objects['object'][$id])) {
122 122
 	    	$this->_objects['object'][$id] = parent::get($id, $fields);
123
-	    	if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
123
+	    	if (!isset($GLOBALS['songlistAdmin']) && is_object($this->_objects['object'][$id])) {
124 124
 		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
125 125
 		    	$GLOBALS['xoopsDB']->queryF($sql);
126 126
 	    	}
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
     	}
163 163
     }
164 164
     
165
-	function getTop($limit=1) {
165
+	function getTop($limit = 1) {
166 166
     	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
167 167
     	$results = $GLOBALS['xoopsDB']->queryF($sql);
168 168
     	$ret = array();
169
-    	$i=0;
169
+    	$i = 0;
170 170
     	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
171 171
     		$ret[$i] = $this->create();
172 172
     		$ret[$i]->assignVars($row);
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
     	return $ret;
176 176
     }
177 177
     
178
-    function delete($object, $force=true) {
178
+    function delete($object, $force = true) {
179 179
     	parent::delete($object, $force);
180
-    	$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `gid` = 0 WHERE `gid` = ' . $object->getVar('gid');
180
+    	$sql = 'UPDATE '.$GLOBALS['xoopsDB']->prefix('songlist_songs').' SET `gid` = 0 WHERE `gid` = '.$object->getVar('gid');
181 181
     	return $GLOBALS['xoopsDB']->queryF($sql);	
182 182
     }
183 183
     
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -98,10 +98,11 @@  discard block
 block discarded – undo
98 98
         
99 99
     function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
100 100
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
101
-    	if (is_object($ele))
102
-    		return $ele->render();
103
-    	else 
104
-    		return ' ';
101
+    	if (is_object($ele)) {
102
+    	    		return $ele->render();
103
+    	} else {
104
+    	    		return ' ';
105
+    	}
105 106
     }
106 107
     
107 108
 	function insert($obj, $force=true) {
@@ -110,8 +111,9 @@  discard block
 block discarded – undo
110 111
     	} else {
111 112
     		$obj->setVar('updated', time());
112 113
     	}
113
-    	if (strlen($obj->getVar('name'))==0)
114
-    		return false;
114
+    	if (strlen($obj->getVar('name'))==0) {
115
+    	    		return false;
116
+    	}
115 117
     	return parent::insert($obj, $force);
116 118
     }
117 119
      
Please login to merge, or discard this patch.
htdocs/modules/songlist/class/albums.php 3 patches
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 class SonglistAlbums extends XoopsObject
11 11
 {
12 12
 
13
-    function SonglistAlbums($fid = null)
14
-    {
15
-        $this->initVar('abid', XOBJ_DTYPE_INT, 0, false);
16
-        $this->initVar('cid', XOBJ_DTYPE_INT, 0, false);
13
+	function SonglistAlbums($fid = null)
14
+	{
15
+		$this->initVar('abid', XOBJ_DTYPE_INT, 0, false);
16
+		$this->initVar('cid', XOBJ_DTYPE_INT, 0, false);
17 17
 		$this->initVar('aids', XOBJ_DTYPE_ARRAY, array(), false);
18 18
 		$this->initVar('sids', XOBJ_DTYPE_ARRAY, array(), false);
19 19
 		$this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false, 128);
@@ -46,41 +46,41 @@  discard block
 block discarded – undo
46 46
 		}
47 47
 		$ret['picture'] = $this->getImage('image', false);
48 48
 		$ret['rank'] = number_format(($this->getVar('rank')>0&&$this->getVar('votes')>0?$this->getVar('rank')/$this->getVar('votes'):0),2)._MI_SONGLIST_OFTEN;
49
-    	$ret['url'] = $this->getURL(true);
49
+		$ret['url'] = $this->getURL(true);
50 50
     	
51 51
 		if ($extra==false)
52
-    		return $ret;
52
+			return $ret;
53 53
     		
54
-    	if ($this->getVar('cid')!=0) {
55
-    		$category_handler = xoops_getmodulehandler('category', 'songlist');
56
-    		$category = $category_handler->get($this->getVar('cid'));
57
-    		if (is_object($category))
58
-    			$ret['category'] = $category->toArray(false); 	
59
-    	}
54
+		if ($this->getVar('cid')!=0) {
55
+			$category_handler = xoops_getmodulehandler('category', 'songlist');
56
+			$category = $category_handler->get($this->getVar('cid'));
57
+			if (is_object($category))
58
+				$ret['category'] = $category->toArray(false); 	
59
+		}
60 60
 
61 61
     	
62 62
 		if (count($this->getVar('aids'))!=0) {
63
-    		$artists_handler = xoops_getmodulehandler('artists', 'songlist');
64
-    		foreach($this->getVar('aids') as $aid) {
65
-    			$artist = $artists_handler->get($aid);
66
-    			if (is_object($artist)) 
67
-    				$ret['artists_array'][$aid] = $artist->toArray(false);
68
-    		} 	
69
-    	}
63
+			$artists_handler = xoops_getmodulehandler('artists', 'songlist');
64
+			foreach($this->getVar('aids') as $aid) {
65
+				$artist = $artists_handler->get($aid);
66
+				if (is_object($artist)) 
67
+					$ret['artists_array'][$aid] = $artist->toArray(false);
68
+			} 	
69
+		}
70 70
     	
71 71
 		
72 72
 		if (count($this->getVar('sids'))!=0) {
73
-    		$songs_handler = xoops_getmodulehandler('songs', 'songlist');
74
-    		$criteria = new Criteria('sid', '('.implode(',', $this->getVar('sids')).')', 'IN');
75
-    		$criteria->setSort('`traxid`');
76
-    		$criteria->setOrder('ASC');
77
-    		foreach($songs_handler->getObjects($criteria, true) as $sid=>$song) {
78
-    			if (is_object($song))
79
-    				$ret['songs_array'][$sid] = $song->toArray(false);
80
-    		} 	
81
-    	}
73
+			$songs_handler = xoops_getmodulehandler('songs', 'songlist');
74
+			$criteria = new Criteria('sid', '('.implode(',', $this->getVar('sids')).')', 'IN');
75
+			$criteria->setSort('`traxid`');
76
+			$criteria->setOrder('ASC');
77
+			foreach($songs_handler->getObjects($criteria, true) as $sid=>$song) {
78
+				if (is_object($song))
79
+					$ret['songs_array'][$sid] = $song->toArray(false);
80
+			} 	
81
+		}
82 82
     	
83
-    	return $ret;
83
+		return $ret;
84 84
 		
85 85
 	}
86 86
     
@@ -90,88 +90,88 @@  discard block
 block discarded – undo
90 90
 		if (!file_exists($GLOBALS['xoops']->path($this->getVar('path').$this->getVar($field))))
91 91
 			return false;
92 92
 		if ($local==false)
93
-    		return XOOPS_URL.'/'.str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
94
-    	else 
95
-    		return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
96
-    }
93
+			return XOOPS_URL.'/'.str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
94
+		else 
95
+			return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
96
+	}
97 97
 	
98
-    function getURL() {
99
-    	global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
100
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
101
-    	    if ($id!=0) {
102
-    			$artist_handler = xoops_getmodulehandler('albums', 'songlist');
103
-    			$artist = $artist_handler->get($id);
104
-    			if (is_object($artist)&&!$artist->isNew()) {
105
-    				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/albums/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('title'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
106
-    			} else {
107
-    				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/albums/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
108
-    			}
109
-    		} else {
110
-    			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/albums/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
111
-    		}
112
-    	} else {
113
-    		return XOOPS_URL.'/modules/songlist/albums.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
114
-    	}
115
-    }
98
+	function getURL() {
99
+		global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
100
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
101
+			if ($id!=0) {
102
+				$artist_handler = xoops_getmodulehandler('albums', 'songlist');
103
+				$artist = $artist_handler->get($id);
104
+				if (is_object($artist)&&!$artist->isNew()) {
105
+					return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/albums/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('title'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
106
+				} else {
107
+					return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/albums/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
108
+				}
109
+			} else {
110
+				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/albums/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
111
+			}
112
+		} else {
113
+			return XOOPS_URL.'/modules/songlist/albums.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
114
+		}
115
+	}
116 116
         
117 117
 }
118 118
 
119 119
 
120 120
 class SonglistAlbumsHandler extends XoopsPersistableObjectHandler
121 121
 {
122
-    function __construct(&$db) 
123
-    {
124
-        parent::__construct($db, "songlist_albums", 'SonglistAlbums', "abid", "title");
125
-    }
122
+	function __construct(&$db) 
123
+	{
124
+		parent::__construct($db, "songlist_albums", 'SonglistAlbums', "abid", "title");
125
+	}
126 126
     
127 127
 	function filterFields() {
128 128
 		return array('abid', 'cid', 'aids', 'sids', 'title', 'image', 'path', 'artists', 'songs', 'hits', 'rank', 'votes', 'created', 'updated');
129 129
 	}
130 130
 	
131
-    function getFilterCriteria($filter) {
132
-    	$parts = explode('|', $filter);
133
-    	$criteria = new CriteriaCompo();
134
-    	foreach($parts as $part) {
135
-    		$var = explode(',', $part);
136
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
137
-    			$object = $this->create();
138
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
139
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
140
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
141
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
142
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
143
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
144
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
131
+	function getFilterCriteria($filter) {
132
+		$parts = explode('|', $filter);
133
+		$criteria = new CriteriaCompo();
134
+		foreach($parts as $part) {
135
+			$var = explode(',', $part);
136
+			if (!empty($var[1])&&!is_numeric($var[0])) {
137
+				$object = $this->create();
138
+				if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
139
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
140
+					$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
141
+				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
142
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
143
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
144
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
145 145
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
146
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
146
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
147 147
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
148
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
148
+					$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
149 149
 				}
150
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
151
-    			$criteria->add(new Criteria($var[0], $var[1]));
152
-    		}
153
-    	}
154
-    	return $criteria;
155
-    }
150
+			} elseif (!empty($var[1])&&is_numeric($var[0])) {
151
+				$criteria->add(new Criteria($var[0], $var[1]));
152
+			}
153
+		}
154
+		return $criteria;
155
+	}
156 156
         
157
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
158
-    	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
159
-    	if (is_object($ele))
160
-    		return $ele->render();
161
-    	else 
162
-    		return ' ';
163
-    }
157
+	function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
158
+		$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
159
+		if (is_object($ele))
160
+			return $ele->render();
161
+		else 
162
+			return ' ';
163
+	}
164 164
     
165 165
 	function insert($obj, $force=true, $object = null) {
166
-    	if ($obj->isNew()) {
167
-    		$new = true;
168
-    		$old = $this->create();
169
-    		$obj->setVar('created', time());	
170
-    	} else {
171
-    		$new = false;
172
-    		$old = $this->get($obj->getVar('abid'));
173
-    		$obj->setVar('updated', time());
174
-    	}
166
+		if ($obj->isNew()) {
167
+			$new = true;
168
+			$old = $this->create();
169
+			$obj->setVar('created', time());	
170
+		} else {
171
+			$new = false;
172
+			$old = $this->get($obj->getVar('abid'));
173
+			$obj->setVar('updated', time());
174
+		}
175 175
 		
176 176
 		$artists_handler = xoops_getmodulehandler('artists', 'songlist');
177 177
 		$genre_handler = xoops_getmodulehandler('genre', 'songlist');
@@ -183,79 +183,79 @@  discard block
 block discarded – undo
183 183
 				if ($obj->vars['cid']['value'] != $old->vars['cid']['value']) {
184 184
 					$category = $category_handler->get($obj->vars['cid']['value']);
185 185
 					if (is_object($category)) {
186
-			    		$category->setVar('albums', $category->getVar('albums')+1);
187
-			    		$category_handler->insert($category, true, $obj);
188
-			    		if (!$old->isNew()&&$old->vars['cid']['value']>0) {
189
-				    		$category = $category_handler->get($old->vars['cid']['value']);
190
-				    		if (is_object($category)) {
191
-					    		$category->setVar('albums', $category->getVar('albums')-1);
192
-					    		$category_handler->insert($category, true, $obj);
193
-				    		}
194
-			    		}
186
+						$category->setVar('albums', $category->getVar('albums')+1);
187
+						$category_handler->insert($category, true, $obj);
188
+						if (!$old->isNew()&&$old->vars['cid']['value']>0) {
189
+							$category = $category_handler->get($old->vars['cid']['value']);
190
+							if (is_object($category)) {
191
+								$category->setVar('albums', $category->getVar('albums')-1);
192
+								$category_handler->insert($category, true, $obj);
193
+							}
194
+						}
195 195
 					}	
196 196
 				}
197 197
 			}
198 198
 		    	
199
-	    	if (count($obj->vars['aids']['value'])!=0&&$obj->vars['aids']['changed']==true) {
200
-	    		foreach($obj->vars['aids']['value'] as $aid) {
201
-	    			if (!is_array($aid, $old->getVar('aids'))&&$aid!=0) {
202
-		    			$artists = $artists_handler->get($aid);
203
-		    			if (is_object($artists)) {
204
-			    			$artists->setVar('albums', $artists->getVar('albums')+1);
205
-			    			$artists_handler->insert($artists, true, $obj);
206
-		    			}
207
-	    			}
208
-	    		}
209
-	    		if (!$old->isNew()) {
210
-		    		foreach($old->getVar('aids') as $aid) {
211
-		    			if (!is_array($aid, $obj->vars['aids']['value'])&&$aid!=0) {
212
-			    			$artists = $artists_handler->get($aid);
213
-			    			if (is_object($artists)) {
214
-				    			$artists->setVar('albums', $artists->getVar('albums')-1);
215
-				    			$artists_handler->insert($artists, true, $obj);
216
-			    			}
217
-		    			}
218
-		    		}
219
-	    		}
220
-	       	}
199
+			if (count($obj->vars['aids']['value'])!=0&&$obj->vars['aids']['changed']==true) {
200
+				foreach($obj->vars['aids']['value'] as $aid) {
201
+					if (!is_array($aid, $old->getVar('aids'))&&$aid!=0) {
202
+						$artists = $artists_handler->get($aid);
203
+						if (is_object($artists)) {
204
+							$artists->setVar('albums', $artists->getVar('albums')+1);
205
+							$artists_handler->insert($artists, true, $obj);
206
+						}
207
+					}
208
+				}
209
+				if (!$old->isNew()) {
210
+					foreach($old->getVar('aids') as $aid) {
211
+						if (!is_array($aid, $obj->vars['aids']['value'])&&$aid!=0) {
212
+							$artists = $artists_handler->get($aid);
213
+							if (is_object($artists)) {
214
+								$artists->setVar('albums', $artists->getVar('albums')-1);
215
+								$artists_handler->insert($artists, true, $obj);
216
+							}
217
+						}
218
+					}
219
+				}
220
+		   	}
221 221
 	    	
222 222
 			if ($object->vars['gid']['value']!=0&&$object->vars['gid']['changed']==true) {
223
-    			$genre = $genre_handler->get($object->vars['gid']['value']);
224
-    			if (is_object($genre)) {
225
-	    			$genre->setVar('albums', $genre->getVar('albums')+1);
226
-	    			$genre_handler->insert($genre, true, $obj);
227
-    			}
228
-	       	}
223
+				$genre = $genre_handler->get($object->vars['gid']['value']);
224
+				if (is_object($genre)) {
225
+					$genre->setVar('albums', $genre->getVar('albums')+1);
226
+					$genre_handler->insert($genre, true, $obj);
227
+				}
228
+		   	}
229 229
 			if ($object->vars['vid']['value']!=0&&$object->vars['vid']['changed']==true) {
230
-    			$voice = $voice_handler->get($object->vars['vid']['value']);
231
-    			if (is_object($voice)) {
232
-	    			$voice->setVar('albums', $voice->getVar('albums')+1);
233
-	    			$voice_handler->insert($voice, true, $obj);
234
-    			}
235
-	       	}
230
+				$voice = $voice_handler->get($object->vars['vid']['value']);
231
+				if (is_object($voice)) {
232
+					$voice->setVar('albums', $voice->getVar('albums')+1);
233
+					$voice_handler->insert($voice, true, $obj);
234
+				}
235
+		   	}
236 236
 			
237 237
 		}
238 238
 		if (strlen($obj->getVar('title'))==0)
239
-    		return false;
239
+			return false;
240 240
     	
241
-    	return parent::insert($obj, $force);
242
-    }
241
+		return parent::insert($obj, $force);
242
+	}
243 243
      
244 244
 	var $_objects = array('object'=>array(), 'array'=>array());
245 245
     
246
-    function get($id, $fields = '*') {
247
-    	if (!isset($this->_objects['object'][$id])) {
248
-	    	$this->_objects['object'][$id] = parent::get($id, $fields);
249
-	    	if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
250
-		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
251
-		    	$GLOBALS['xoopsDB']->queryF($sql);
252
-	    	}
253
-    	}
254
-    	return $this->_objects['object'][$id];
255
-    }
246
+	function get($id, $fields = '*') {
247
+		if (!isset($this->_objects['object'][$id])) {
248
+			$this->_objects['object'][$id] = parent::get($id, $fields);
249
+			if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
250
+				$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
251
+				$GLOBALS['xoopsDB']->queryF($sql);
252
+			}
253
+		}
254
+		return $this->_objects['object'][$id];
255
+	}
256 256
     
257
-    function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
258
-    	$ret = parent::getObjects($criteria, $id_as_key, $as_object);
257
+	function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
258
+		$ret = parent::getObjects($criteria, $id_as_key, $as_object);
259 259
    		/* if (!isset($GLOBALS['songlistAdmin'])) {
260 260
 	    	$id = array();
261 261
 	    	foreach($ret as $data) {
@@ -276,39 +276,39 @@  discard block
 block discarded – undo
276 276
 	    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` IN ('.implode(',', $id).')';
277 277
 	    	$GLOBALS['xoopsDB']->queryF($sql);
278 278
     	}*/
279
-    	return $ret;
280
-    }
279
+		return $ret;
280
+	}
281 281
     
282
-    function getURL() {
283
-    	global $file, $op, $fct, $id, $value, $gid, $vid, $cid, $start, $limit;
284
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
285
-    	    if ($cid!=0) {
286
-    			$artist_handler = xoops_getmodulehandler('artists', 'songlist');
287
-    			$artist = $artist_handler->get($cid);
288
-    			if (is_object($artist)&&!$artist->isNew()) {
289
-    				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
290
-    			} else {
291
-    				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
292
-    			}
293
-    		} else {
294
-    			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
295
-    		}
296
-    	} else {
297
-    		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
298
-    	}
299
-    }
282
+	function getURL() {
283
+		global $file, $op, $fct, $id, $value, $gid, $vid, $cid, $start, $limit;
284
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
285
+			if ($cid!=0) {
286
+				$artist_handler = xoops_getmodulehandler('artists', 'songlist');
287
+				$artist = $artist_handler->get($cid);
288
+				if (is_object($artist)&&!$artist->isNew()) {
289
+					return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
290
+				} else {
291
+					return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
292
+				}
293
+			} else {
294
+				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
295
+			}
296
+		} else {
297
+			return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
298
+		}
299
+	}
300 300
     
301
-    function getTop($limit=1) {
302
-    	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
303
-    	$results = $GLOBALS['xoopsDB']->queryF($sql);
304
-    	$ret = array();
305
-    	$i=0;
306
-    	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
307
-    		$ret[$i] = $this->create();
308
-    		$ret[$i]->assignVars($row);
309
-    		$i++;
310
-    	}
311
-    	return $ret;
312
-    }
301
+	function getTop($limit=1) {
302
+		$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
303
+		$results = $GLOBALS['xoopsDB']->queryF($sql);
304
+		$ret = array();
305
+		$i=0;
306
+		while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
307
+			$ret[$i] = $this->create();
308
+			$ret[$i]->assignVars($row);
309
+			$i++;
310
+		}
311
+		return $ret;
312
+	}
313 313
 }
314 314
 ?>
315 315
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 	function toArray($extra = true) {
36 36
 		$ret = parent::toArray();
37 37
 		$form = $this->getForm(true);
38
-		foreach($form as $key => $element) {
38
+		foreach ($form as $key => $element) {
39 39
 			$ret['form'][$key] = $form[$key]->render();	
40 40
 		}
41
-		foreach(array('created', 'updated') as $key) {
41
+		foreach (array('created', 'updated') as $key) {
42 42
 			if ($this->getVar($key)>0) {
43 43
 				$ret['form'][$key] = date(_DATESTRING, $this->getVar($key)); 
44 44
 				$ret[$key] = date(_DATESTRING, $this->getVar($key));
45 45
 			}
46 46
 		}
47 47
 		$ret['picture'] = $this->getImage('image', false);
48
-		$ret['rank'] = number_format(($this->getVar('rank')>0&&$this->getVar('votes')>0?$this->getVar('rank')/$this->getVar('votes'):0),2)._MI_SONGLIST_OFTEN;
48
+		$ret['rank'] = number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2)._MI_SONGLIST_OFTEN;
49 49
     	$ret['url'] = $this->getURL(true);
50 50
     	
51 51
 		if ($extra==false)
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     	
62 62
 		if (count($this->getVar('aids'))!=0) {
63 63
     		$artists_handler = xoops_getmodulehandler('artists', 'songlist');
64
-    		foreach($this->getVar('aids') as $aid) {
64
+    		foreach ($this->getVar('aids') as $aid) {
65 65
     			$artist = $artists_handler->get($aid);
66 66
     			if (is_object($artist)) 
67 67
     				$ret['artists_array'][$aid] = $artist->toArray(false);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     		$criteria = new Criteria('sid', '('.implode(',', $this->getVar('sids')).')', 'IN');
75 75
     		$criteria->setSort('`traxid`');
76 76
     		$criteria->setOrder('ASC');
77
-    		foreach($songs_handler->getObjects($criteria, true) as $sid=>$song) {
77
+    		foreach ($songs_handler->getObjects($criteria, true) as $sid=>$song) {
78 78
     			if (is_object($song))
79 79
     				$ret['songs_array'][$sid] = $song->toArray(false);
80 80
     		} 	
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     	    if ($id!=0) {
102 102
     			$artist_handler = xoops_getmodulehandler('albums', 'songlist');
103 103
     			$artist = $artist_handler->get($id);
104
-    			if (is_object($artist)&&!$artist->isNew()) {
104
+    			if (is_object($artist) && !$artist->isNew()) {
105 105
     				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/albums/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('title'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
106 106
     			} else {
107 107
     				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/albums/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
@@ -131,30 +131,30 @@  discard block
 block discarded – undo
131 131
     function getFilterCriteria($filter) {
132 132
     	$parts = explode('|', $filter);
133 133
     	$criteria = new CriteriaCompo();
134
-    	foreach($parts as $part) {
134
+    	foreach ($parts as $part) {
135 135
     		$var = explode(',', $part);
136
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
136
+    		if (!empty($var[1]) && !is_numeric($var[0])) {
137 137
     			$object = $this->create();
138
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
139
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
140
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
141
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
138
+    			if ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
139
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) {
140
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2]) ? $var[2] : 'LIKE')));
141
+    			} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
142 142
     						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
143
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
144
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
145
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
146
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
147
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
148
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
143
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT) {
144
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));			
145
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM) {
146
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));    				
147
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY) {
148
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2]) ? $var[2] : 'LIKE')));    				
149 149
 				}
150
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
150
+    		} elseif (!empty($var[1]) && is_numeric($var[0])) {
151 151
     			$criteria->add(new Criteria($var[0], $var[1]));
152 152
     		}
153 153
     	}
154 154
     	return $criteria;
155 155
     }
156 156
         
157
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
157
+    function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list') {
158 158
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
159 159
     	if (is_object($ele))
160 160
     		return $ele->render();
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     		return ' ';
163 163
     }
164 164
     
165
-	function insert($obj, $force=true, $object = null) {
165
+	function insert($obj, $force = true, $object = null) {
166 166
     	if ($obj->isNew()) {
167 167
     		$new = true;
168 168
     		$old = $this->create();
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
    	
181 181
 		if (is_a($object, 'SonglistSongs')) {
182 182
 			if ($obj->vars['cid']['changed']==true) {
183
-				if ($obj->vars['cid']['value'] != $old->vars['cid']['value']) {
183
+				if ($obj->vars['cid']['value']!=$old->vars['cid']['value']) {
184 184
 					$category = $category_handler->get($obj->vars['cid']['value']);
185 185
 					if (is_object($category)) {
186 186
 			    		$category->setVar('albums', $category->getVar('albums')+1);
187 187
 			    		$category_handler->insert($category, true, $obj);
188
-			    		if (!$old->isNew()&&$old->vars['cid']['value']>0) {
188
+			    		if (!$old->isNew() && $old->vars['cid']['value']>0) {
189 189
 				    		$category = $category_handler->get($old->vars['cid']['value']);
190 190
 				    		if (is_object($category)) {
191 191
 					    		$category->setVar('albums', $category->getVar('albums')-1);
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 				}
197 197
 			}
198 198
 		    	
199
-	    	if (count($obj->vars['aids']['value'])!=0&&$obj->vars['aids']['changed']==true) {
200
-	    		foreach($obj->vars['aids']['value'] as $aid) {
201
-	    			if (!is_array($aid, $old->getVar('aids'))&&$aid!=0) {
199
+	    	if (count($obj->vars['aids']['value'])!=0 && $obj->vars['aids']['changed']==true) {
200
+	    		foreach ($obj->vars['aids']['value'] as $aid) {
201
+	    			if (!is_array($aid, $old->getVar('aids')) && $aid!=0) {
202 202
 		    			$artists = $artists_handler->get($aid);
203 203
 		    			if (is_object($artists)) {
204 204
 			    			$artists->setVar('albums', $artists->getVar('albums')+1);
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	    			}
208 208
 	    		}
209 209
 	    		if (!$old->isNew()) {
210
-		    		foreach($old->getVar('aids') as $aid) {
211
-		    			if (!is_array($aid, $obj->vars['aids']['value'])&&$aid!=0) {
210
+		    		foreach ($old->getVar('aids') as $aid) {
211
+		    			if (!is_array($aid, $obj->vars['aids']['value']) && $aid!=0) {
212 212
 			    			$artists = $artists_handler->get($aid);
213 213
 			    			if (is_object($artists)) {
214 214
 				    			$artists->setVar('albums', $artists->getVar('albums')-1);
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
 	    		}
220 220
 	       	}
221 221
 	    	
222
-			if ($object->vars['gid']['value']!=0&&$object->vars['gid']['changed']==true) {
222
+			if ($object->vars['gid']['value']!=0 && $object->vars['gid']['changed']==true) {
223 223
     			$genre = $genre_handler->get($object->vars['gid']['value']);
224 224
     			if (is_object($genre)) {
225 225
 	    			$genre->setVar('albums', $genre->getVar('albums')+1);
226 226
 	    			$genre_handler->insert($genre, true, $obj);
227 227
     			}
228 228
 	       	}
229
-			if ($object->vars['vid']['value']!=0&&$object->vars['vid']['changed']==true) {
229
+			if ($object->vars['vid']['value']!=0 && $object->vars['vid']['changed']==true) {
230 230
     			$voice = $voice_handler->get($object->vars['vid']['value']);
231 231
     			if (is_object($voice)) {
232 232
 	    			$voice->setVar('albums', $voice->getVar('albums')+1);
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     function get($id, $fields = '*') {
247 247
     	if (!isset($this->_objects['object'][$id])) {
248 248
 	    	$this->_objects['object'][$id] = parent::get($id, $fields);
249
-	    	if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
249
+	    	if (!isset($GLOBALS['songlistAdmin']) && is_object($this->_objects['object'][$id])) {
250 250
 		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
251 251
 		    	$GLOBALS['xoopsDB']->queryF($sql);
252 252
 	    	}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     	    if ($cid!=0) {
286 286
     			$artist_handler = xoops_getmodulehandler('artists', 'songlist');
287 287
     			$artist = $artist_handler->get($cid);
288
-    			if (is_object($artist)&&!$artist->isNew()) {
288
+    			if (is_object($artist) && !$artist->isNew()) {
289 289
     				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
290 290
     			} else {
291 291
     				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
     	}
299 299
     }
300 300
     
301
-    function getTop($limit=1) {
301
+    function getTop($limit = 1) {
302 302
     	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
303 303
     	$results = $GLOBALS['xoopsDB']->queryF($sql);
304 304
     	$ret = array();
305
-    	$i=0;
305
+    	$i = 0;
306 306
     	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
307 307
     		$ret[$i] = $this->create();
308 308
     		$ret[$i]->assignVars($row);
Please login to merge, or discard this patch.
Braces   +31 added lines, -22 removed lines patch added patch discarded remove patch
@@ -48,14 +48,16 @@  discard block
 block discarded – undo
48 48
 		$ret['rank'] = number_format(($this->getVar('rank')>0&&$this->getVar('votes')>0?$this->getVar('rank')/$this->getVar('votes'):0),2)._MI_SONGLIST_OFTEN;
49 49
     	$ret['url'] = $this->getURL(true);
50 50
     	
51
-		if ($extra==false)
52
-    		return $ret;
51
+		if ($extra==false) {
52
+		    		return $ret;
53
+		}
53 54
     		
54 55
     	if ($this->getVar('cid')!=0) {
55 56
     		$category_handler = xoops_getmodulehandler('category', 'songlist');
56 57
     		$category = $category_handler->get($this->getVar('cid'));
57
-    		if (is_object($category))
58
-    			$ret['category'] = $category->toArray(false); 	
58
+    		if (is_object($category)) {
59
+    		    			$ret['category'] = $category->toArray(false);
60
+    		}
59 61
     	}
60 62
 
61 63
     	
@@ -63,8 +65,9 @@  discard block
 block discarded – undo
63 65
     		$artists_handler = xoops_getmodulehandler('artists', 'songlist');
64 66
     		foreach($this->getVar('aids') as $aid) {
65 67
     			$artist = $artists_handler->get($aid);
66
-    			if (is_object($artist)) 
67
-    				$ret['artists_array'][$aid] = $artist->toArray(false);
68
+    			if (is_object($artist)) {
69
+    			    				$ret['artists_array'][$aid] = $artist->toArray(false);
70
+    			}
68 71
     		} 	
69 72
     	}
70 73
     	
@@ -75,8 +78,9 @@  discard block
 block discarded – undo
75 78
     		$criteria->setSort('`traxid`');
76 79
     		$criteria->setOrder('ASC');
77 80
     		foreach($songs_handler->getObjects($criteria, true) as $sid=>$song) {
78
-    			if (is_object($song))
79
-    				$ret['songs_array'][$sid] = $song->toArray(false);
81
+    			if (is_object($song)) {
82
+    			    				$ret['songs_array'][$sid] = $song->toArray(false);
83
+    			}
80 84
     		} 	
81 85
     	}
82 86
     	
@@ -85,14 +89,17 @@  discard block
 block discarded – undo
85 89
 	}
86 90
     
87 91
 	function getImage($field = 'image', $local = false) {
88
-		if (strlen($this->getVar($field))==0)
89
-			return false;
90
-		if (!file_exists($GLOBALS['xoops']->path($this->getVar('path').$this->getVar($field))))
91
-			return false;
92
-		if ($local==false)
93
-    		return XOOPS_URL.'/'.str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
94
-    	else 
95
-    		return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
92
+		if (strlen($this->getVar($field))==0) {
93
+					return false;
94
+		}
95
+		if (!file_exists($GLOBALS['xoops']->path($this->getVar('path').$this->getVar($field)))) {
96
+					return false;
97
+		}
98
+		if ($local==false) {
99
+		    		return XOOPS_URL.'/'.str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
100
+		} else {
101
+    	    		return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
102
+    	}
96 103
     }
97 104
 	
98 105
     function getURL() {
@@ -156,10 +163,11 @@  discard block
 block discarded – undo
156 163
         
157 164
     function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
158 165
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
159
-    	if (is_object($ele))
160
-    		return $ele->render();
161
-    	else 
162
-    		return ' ';
166
+    	if (is_object($ele)) {
167
+    	    		return $ele->render();
168
+    	} else {
169
+    	    		return ' ';
170
+    	}
163 171
     }
164 172
     
165 173
 	function insert($obj, $force=true, $object = null) {
@@ -235,8 +243,9 @@  discard block
 block discarded – undo
235 243
 	       	}
236 244
 			
237 245
 		}
238
-		if (strlen($obj->getVar('title'))==0)
239
-    		return false;
246
+		if (strlen($obj->getVar('title'))==0) {
247
+		    		return false;
248
+		}
240 249
     	
241 250
     	return parent::insert($obj, $force);
242 251
     }
Please login to merge, or discard this patch.
htdocs/modules/songlist/class/songs.php 3 patches
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
10 10
 class SonglistSongs extends XoopsObject
11 11
 {
12 12
 
13
-    function SonglistSongs($fid = null)
14
-    {
15
-        $this->initVar('sid', XOBJ_DTYPE_INT, 0, false);
16
-        $this->initVar('cid', XOBJ_DTYPE_INT, 0, false);
17
-        $this->initVar('gids', XOBJ_DTYPE_ARRAY, 0, false);
13
+	function SonglistSongs($fid = null)
14
+	{
15
+		$this->initVar('sid', XOBJ_DTYPE_INT, 0, false);
16
+		$this->initVar('cid', XOBJ_DTYPE_INT, 0, false);
17
+		$this->initVar('gids', XOBJ_DTYPE_ARRAY, 0, false);
18 18
 		$this->initVar('vcid', XOBJ_DTYPE_INT, 0, false);
19
-        $this->initVar('aids', XOBJ_DTYPE_ARRAY, array(), false);
20
-        $this->initVar('abid', XOBJ_DTYPE_INT, 0, false);
19
+		$this->initVar('aids', XOBJ_DTYPE_ARRAY, array(), false);
20
+		$this->initVar('abid', XOBJ_DTYPE_INT, 0, false);
21 21
 		$this->initVar('songid', XOBJ_DTYPE_TXTBOX, null, false, 32);
22 22
 		$this->initVar('traxid', XOBJ_DTYPE_TXTBOX, null, false, 32);
23 23
 		$this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false, 128);
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		$this->initVar('updated', XOBJ_DTYPE_INT, 0, false);
32 32
 	}
33 33
 	
34
-    function getForm($as_array = false) {
34
+	function getForm($as_array = false) {
35 35
 		return songlist_songs_get_form($this, $as_array);
36 36
 	}
37 37
 
@@ -93,312 +93,312 @@  discard block
 block discarded – undo
93 93
 			}
94 94
 		}
95 95
 				
96
-    	if ($extra==false)
97
-    		return $ret;
96
+		if ($extra==false)
97
+			return $ret;
98 98
     		
99
-    	if ($this->getVar('cid')!=0) {
100
-    		$category_handler = xoops_getmodulehandler('category', 'songlist');
101
-    		$category = $category_handler->get($this->getVar('cid'));
102
-    		$ret['category'] = $category->toArray(false); 	
103
-    	}
99
+		if ($this->getVar('cid')!=0) {
100
+			$category_handler = xoops_getmodulehandler('category', 'songlist');
101
+			$category = $category_handler->get($this->getVar('cid'));
102
+			$ret['category'] = $category->toArray(false); 	
103
+		}
104 104
 
105
-    	if (count($this->getVar('gids'))!=0) {
106
-    		$i=0;
107
-    		$genre_handler = xoops_getmodulehandler('genre', 'songlist');
108
-    		$ret['genre'] = '';
109
-    		$genres = $genre_handler->getObjects(new Criteria('gid', '('.implode(',',$this->getVar('gids')).')', 'IN'), true);
110
-    		foreach($genres as $gid => $genre) {
111
-    			$ret['genre_array'][$gid] = $genre->toArray(false);
112
-    			$i++;
113
-    			$ret['genre'] .= $genre->getVar('name') . ($i<count($genres)?', ':'');
114
-    		}
115
-    	}
116
-    	if ($this->getVar('vcid')!=0) {
117
-    		$voice_handler = xoops_getmodulehandler('voice', 'songlist');
118
-    		$voice = $voice_handler->get($this->getVar('vcid'));
119
-    		$ret['voice'] = $voice->toArray(false); 	
120
-    	}		
105
+		if (count($this->getVar('gids'))!=0) {
106
+			$i=0;
107
+			$genre_handler = xoops_getmodulehandler('genre', 'songlist');
108
+			$ret['genre'] = '';
109
+			$genres = $genre_handler->getObjects(new Criteria('gid', '('.implode(',',$this->getVar('gids')).')', 'IN'), true);
110
+			foreach($genres as $gid => $genre) {
111
+				$ret['genre_array'][$gid] = $genre->toArray(false);
112
+				$i++;
113
+				$ret['genre'] .= $genre->getVar('name') . ($i<count($genres)?', ':'');
114
+			}
115
+		}
116
+		if ($this->getVar('vcid')!=0) {
117
+			$voice_handler = xoops_getmodulehandler('voice', 'songlist');
118
+			$voice = $voice_handler->get($this->getVar('vcid'));
119
+			$ret['voice'] = $voice->toArray(false); 	
120
+		}		
121 121
     	
122 122
 		if (count($this->getVar('aids'))!=0) {
123
-    		$artists_handler = xoops_getmodulehandler('artists', 'songlist');
124
-    		foreach($this->getVar('aids') as $aid) {
125
-    			$artist = $artists_handler->get($aid);
126
-    			$ret['artists_array'][$aid] = $artist->toArray(false);
127
-    		} 	
128
-    	}
123
+			$artists_handler = xoops_getmodulehandler('artists', 'songlist');
124
+			foreach($this->getVar('aids') as $aid) {
125
+				$artist = $artists_handler->get($aid);
126
+				$ret['artists_array'][$aid] = $artist->toArray(false);
127
+			} 	
128
+		}
129 129
     	
130 130
 		if ($this->getVar('abid')!=0) {
131
-    		$albums_handler = xoops_getmodulehandler('albums', 'songlist');
132
-    		$albums = $albums_handler->get($this->getVar('abid'));
133
-    		$ret['album'] = $albums->toArray(false); 	
134
-    	}
135
-    	return $ret;
131
+			$albums_handler = xoops_getmodulehandler('albums', 'songlist');
132
+			$albums = $albums_handler->get($this->getVar('abid'));
133
+			$ret['album'] = $albums->toArray(false); 	
134
+		}
135
+		return $ret;
136 136
 	}
137 137
 	
138 138
 	function getURL() {
139
-    	global $file, $op, $fct, $id, $value, $vcid, $gid, $cid, $start, $limit;
140
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
141
-    		return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/index/'.urlencode(str_replace(array(' ', chr(9)), '-', $this->getVar('title'))).'/item-item-'.$this->getVar('sid').$GLOBALS['songlistModuleConfig']['endofurl'];
142
-    	} else {
143
-    		return XOOPS_URL.'/modules/songlist/index.php?op=item&fct=item&id='.$this->getVar('sid').'&value='.urlencode($value).'&vcid='.$vcid.'&gid='.$gid.'&cid='.$cid;
144
-    	}
145
-    }
139
+		global $file, $op, $fct, $id, $value, $vcid, $gid, $cid, $start, $limit;
140
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
141
+			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/index/'.urlencode(str_replace(array(' ', chr(9)), '-', $this->getVar('title'))).'/item-item-'.$this->getVar('sid').$GLOBALS['songlistModuleConfig']['endofurl'];
142
+		} else {
143
+			return XOOPS_URL.'/modules/songlist/index.php?op=item&fct=item&id='.$this->getVar('sid').'&value='.urlencode($value).'&vcid='.$vcid.'&gid='.$gid.'&cid='.$cid;
144
+		}
145
+	}
146 146
 	
147 147
 }
148 148
 
149 149
 
150 150
 class SonglistSongsHandler extends XoopsPersistableObjectHandler
151 151
 {
152
-    function __construct(&$db) 
153
-    {
154
-    	$module_handler = xoops_gethandler('module');
152
+	function __construct(&$db) 
153
+	{
154
+		$module_handler = xoops_gethandler('module');
155 155
 		$config_handler = xoops_gethandler('config');
156 156
 		$GLOBALS['songlistModule'] = $module_handler->getByDirname('songlist');
157 157
 		$GLOBALS['songlistModuleConfig'] = $config_handler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); 
158 158
 			
159
-        parent::__construct($db, "songlist_songs", 'SonglistSongs', "sid", "title");
160
-    }
159
+		parent::__construct($db, "songlist_songs", 'SonglistSongs', "sid", "title");
160
+	}
161 161
 
162 162
 	function filterFields() {
163 163
 		return array('sid', 'cid', 'mp3', 'gid', 'vcid', 'aids', 'abid', 'songid', 'title', 'lyrics', 'hits', 'rank', 'votes', 'tags', 'created', 'updated');
164 164
 	}
165 165
 	
166
-    function getFilterCriteria($filter) {
167
-    	$parts = explode('|', $filter);
168
-    	$criteria = new CriteriaCompo();
169
-    	foreach($parts as $part) {
170
-    		$var = explode(',', $part);
171
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
172
-    			$object = $this->create();
173
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
174
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
175
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
176
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
177
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
178
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
179
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
166
+	function getFilterCriteria($filter) {
167
+		$parts = explode('|', $filter);
168
+		$criteria = new CriteriaCompo();
169
+		foreach($parts as $part) {
170
+			$var = explode(',', $part);
171
+			if (!empty($var[1])&&!is_numeric($var[0])) {
172
+				$object = $this->create();
173
+				if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
174
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
175
+					$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
176
+				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
177
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
178
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
179
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
180 180
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
181
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
181
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
182 182
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
183
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
183
+					$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
184 184
 				}
185
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
186
-    			$criteria->add(new Criteria($var[0], $var[1]));
187
-    		}
188
-    	}
189
-    	return $criteria;
190
-    }
185
+			} elseif (!empty($var[1])&&is_numeric($var[0])) {
186
+				$criteria->add(new Criteria($var[0], $var[1]));
187
+			}
188
+		}
189
+		return $criteria;
190
+	}
191 191
         
192
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
193
-    	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
194
-    	if (is_object($ele))
195
-    		return $ele->render();
196
-    	else 
197
-    		return '&nbsp;';
198
-    }
192
+	function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
193
+		$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
194
+		if (is_object($ele))
195
+			return $ele->render();
196
+		else 
197
+			return '&nbsp;';
198
+	}
199 199
     
200 200
 	function insert($obj, $force=true, $object = null) {
201
-    	if ($obj->isNew()) {
202
-    		$new = true;
203
-    		$old = $this->create();
204
-    		$obj->setVar('created', time());	
205
-    	} else {
206
-    		$new = false;
207
-    		$old = $this->get($obj->getVar('sid'));
208
-    		$obj->setVar('updated', time());
209
-    	}
201
+		if ($obj->isNew()) {
202
+			$new = true;
203
+			$old = $this->create();
204
+			$obj->setVar('created', time());	
205
+		} else {
206
+			$new = false;
207
+			$old = $this->get($obj->getVar('sid'));
208
+			$obj->setVar('updated', time());
209
+		}
210 210
 		
211
-    	$albums_handler = xoops_getmodulehandler('albums', 'songlist');
211
+		$albums_handler = xoops_getmodulehandler('albums', 'songlist');
212 212
 		$artists_handler = xoops_getmodulehandler('artists', 'songlist');
213 213
 		$genre_handler = xoops_getmodulehandler('genre', 'songlist');
214 214
 		$voice_handler = xoops_getmodulehandler('voice', 'songlist');		
215 215
 		$category_handler = xoops_getmodulehandler('category', 'songlist');
216 216
 
217 217
 		if ($obj->vars['gid']['changed']==true) {
218
-    		if ($new==true||($obj->vars['gid']['value']!=0)) {
219
-    			$genre = $genre_handler->get($obj->vars['gid']['value']);
220
-    			if (is_object($genre)) {
221
-	    			$genre->setVar('songs', $genre->getVar('songs')+1);
222
-	    			$genre_handler->insert($genre, true, $obj);
223
-    			}
224
-    		} 
225
-    		if (!$old->isNew()&&$old->getVar('gid')>0) {
226
-    			$genre = $genre_handler->get($old->vars['gid']['value']);
227
-    			if (is_object($genre)) {
228
-	    			$genre->setVar('songs', $genre->getVar('songs')-1);
229
-	    			$genre_handler->insert($genre, true, null);
230
-    			}
231
-    		}
232
-    	}
218
+			if ($new==true||($obj->vars['gid']['value']!=0)) {
219
+				$genre = $genre_handler->get($obj->vars['gid']['value']);
220
+				if (is_object($genre)) {
221
+					$genre->setVar('songs', $genre->getVar('songs')+1);
222
+					$genre_handler->insert($genre, true, $obj);
223
+				}
224
+			} 
225
+			if (!$old->isNew()&&$old->getVar('gid')>0) {
226
+				$genre = $genre_handler->get($old->vars['gid']['value']);
227
+				if (is_object($genre)) {
228
+					$genre->setVar('songs', $genre->getVar('songs')-1);
229
+					$genre_handler->insert($genre, true, null);
230
+				}
231
+			}
232
+		}
233 233
 
234 234
 		if ($obj->vars['vcid']['changed']==true) {
235
-    		if ($new==true||($obj->vars['vcid']['value']!=0)) {
236
-    			$voice = $voice_handler->get($obj->vars['vcid']['value']);
237
-    			if (is_object($voice)) {
238
-	    			$voice->setVar('songs', $voice->getVar('songs')+1);
239
-	    			$voice_handler->insert($voice, true, $obj);
240
-    			}
241
-    		} 
242
-    		if (!$old->isNew()&&$old->getVar('vcid')>0) {
243
-    			$voice = $voice_handler->get($old->vars['vcid']['value']);
244
-    			if (is_object($voice)) {
245
-	    			$voice->setVar('songs', $voice->getVar('songs')-1);
246
-	    			$voice_handler->insert($voice, true, null);
247
-    			}
248
-    		}
249
-    	}
235
+			if ($new==true||($obj->vars['vcid']['value']!=0)) {
236
+				$voice = $voice_handler->get($obj->vars['vcid']['value']);
237
+				if (is_object($voice)) {
238
+					$voice->setVar('songs', $voice->getVar('songs')+1);
239
+					$voice_handler->insert($voice, true, $obj);
240
+				}
241
+			} 
242
+			if (!$old->isNew()&&$old->getVar('vcid')>0) {
243
+				$voice = $voice_handler->get($old->vars['vcid']['value']);
244
+				if (is_object($voice)) {
245
+					$voice->setVar('songs', $voice->getVar('songs')-1);
246
+					$voice_handler->insert($voice, true, null);
247
+				}
248
+			}
249
+		}
250 250
     	
251 251
 		if ($obj->vars['cid']['changed']==true) {
252
-    		if ($new==true||($obj->vars['cid']['value']!=0)) {
253
-    			$category = $category_handler->get($obj->vars['cid']['value']);
254
-    			if (is_object($category)) {
255
-	    			$category->setVar('songs', $category->getVar('songs')+1);
256
-	    			$category_handler->insert($category, true, $obj);
257
-	    		    foreach($obj->getVar('aids') as $aid) {
258
-		    			$artists = $artists_handler->get($aid);
259
-		    			$cids = $artists->getVar('cids');
260
-		    			$cids[$obj->getVar('cid')] = $obj->getVar('cid');
261
-		    			if (is_object($artists)) {
262
-			    			$artists->setVar('cids', $cids);
263
-			    			$artists_handler->insert($artists, true, null);
264
-		    			}
265
-	    			}
266
-    			}
267
-    		}
252
+			if ($new==true||($obj->vars['cid']['value']!=0)) {
253
+				$category = $category_handler->get($obj->vars['cid']['value']);
254
+				if (is_object($category)) {
255
+					$category->setVar('songs', $category->getVar('songs')+1);
256
+					$category_handler->insert($category, true, $obj);
257
+					foreach($obj->getVar('aids') as $aid) {
258
+						$artists = $artists_handler->get($aid);
259
+						$cids = $artists->getVar('cids');
260
+						$cids[$obj->getVar('cid')] = $obj->getVar('cid');
261
+						if (is_object($artists)) {
262
+							$artists->setVar('cids', $cids);
263
+							$artists_handler->insert($artists, true, null);
264
+						}
265
+					}
266
+				}
267
+			}
268 268
 			if (!$old->isNew()&&$old->getVar('cid')>0) {
269 269
 				$category = $category_handler->get($old->vars['cid']['value']);
270 270
 				if (is_object($category)) {
271
-	    			$category->setVar('songs', $category->getVar('songs')-1);
272
-	    			$category_handler->insert($category, true, null);
271
+					$category->setVar('songs', $category->getVar('songs')-1);
272
+					$category_handler->insert($category, true, null);
273 273
 					foreach($obj->getVar('aids') as $aid) {
274
-		    			$artists = $artists_handler->get($aid);
275
-		    			$cids=array();
276
-		    			foreach($artists->getVar('cids') as $cid) {
277
-		    				if($cid!=$old->getVar('cid')||$cid==$obj->getVar('cid'))
278
-		    					$cids[$cid] = $cid;
279
-		    			}
280
-		    			if (is_object($artists)) {
281
-			    			$artists->setVar('cids', $cids);
282
-			    			$artists_handler->insert($artists, true, null);
283
-		    			}
284
-	    			}
274
+						$artists = $artists_handler->get($aid);
275
+						$cids=array();
276
+						foreach($artists->getVar('cids') as $cid) {
277
+							if($cid!=$old->getVar('cid')||$cid==$obj->getVar('cid'))
278
+								$cids[$cid] = $cid;
279
+						}
280
+						if (is_object($artists)) {
281
+							$artists->setVar('cids', $cids);
282
+							$artists_handler->insert($artists, true, null);
283
+						}
284
+					}
285 285
 				}
286
-    		}
287
-    	}
286
+			}
287
+		}
288 288
     	
289
-    	if ($obj->vars['aids']['changed']==true&&count($obj->vars['aids']['value'])!=0) {
290
-    		if ($new==true||count($obj->vars['aids']['value'])!=0) {
291
-    			foreach($obj->vars['aids']['value'] as $aid) {
292
-    				if (!in_array($aid, $old->vars['aids']['value'])) {
293
-		    			$artists = $artists_handler->get($aid);
294
-		    			if (is_object($artists)) {
295
-			    			$artists->setVar('songs', $artists->getVar('songs')+1);
296
-			    			$artists_handler->insert($artists, true, $obj);
297
-				    		if ($new==true||($obj->vars['vcid']['value']!=0)) {
298
-				    			$voice = $voice_handler->get($obj->vars['vcid']['value']);
299
-				    			if (is_object($voice)) {
300
-					    			$voice->setVar('artists', $voice->getVar('artists')+1);
301
-					    			$voice_handler->insert($voice, true, $obj);
302
-				    			}
303
-				    		} 
304
-		    			}
305
-    				}
306
-    			}
307
-    		}
308
-    		if (!$old->isNew()&&count($old->getVar('aids'))==0) {
309
-    			foreach($old->getVar('aids') as $aid) {
310
-    				if (!in_array($aid, $obj->vars['aids']['value'])) {
311
-	    				$artists = $artists_handler->get($aid);
312
-	    				if (is_object($artists)) {
313
-			    			$artists->setVar('songs', $artists->getVar('songs')-1);
314
-			    			$artists_handler->insert($artists, true, null);
315
-			    			if (!$old->isNew()&&$old->getVar('vcid')>0) {
316
-				    			$voice = $voice_handler->get($old->vars['vcid']['value']);
317
-				    			if (is_object($voice)) {
318
-					    			$voice->setVar('artists', $voice->getVar('artists')-1);
319
-					    			$voice_handler->insert($voice, true, null);
320
-				    			}
321
-				    		}
322
-	    				}	
323
-    				}
324
-    			}
325
-    		}
326
-    	}
289
+		if ($obj->vars['aids']['changed']==true&&count($obj->vars['aids']['value'])!=0) {
290
+			if ($new==true||count($obj->vars['aids']['value'])!=0) {
291
+				foreach($obj->vars['aids']['value'] as $aid) {
292
+					if (!in_array($aid, $old->vars['aids']['value'])) {
293
+						$artists = $artists_handler->get($aid);
294
+						if (is_object($artists)) {
295
+							$artists->setVar('songs', $artists->getVar('songs')+1);
296
+							$artists_handler->insert($artists, true, $obj);
297
+							if ($new==true||($obj->vars['vcid']['value']!=0)) {
298
+								$voice = $voice_handler->get($obj->vars['vcid']['value']);
299
+								if (is_object($voice)) {
300
+									$voice->setVar('artists', $voice->getVar('artists')+1);
301
+									$voice_handler->insert($voice, true, $obj);
302
+								}
303
+							} 
304
+						}
305
+					}
306
+				}
307
+			}
308
+			if (!$old->isNew()&&count($old->getVar('aids'))==0) {
309
+				foreach($old->getVar('aids') as $aid) {
310
+					if (!in_array($aid, $obj->vars['aids']['value'])) {
311
+						$artists = $artists_handler->get($aid);
312
+						if (is_object($artists)) {
313
+							$artists->setVar('songs', $artists->getVar('songs')-1);
314
+							$artists_handler->insert($artists, true, null);
315
+							if (!$old->isNew()&&$old->getVar('vcid')>0) {
316
+								$voice = $voice_handler->get($old->vars['vcid']['value']);
317
+								if (is_object($voice)) {
318
+									$voice->setVar('artists', $voice->getVar('artists')-1);
319
+									$voice_handler->insert($voice, true, null);
320
+								}
321
+							}
322
+						}	
323
+					}
324
+				}
325
+			}
326
+		}
327 327
     	
328
-    	if ($obj->vars['abid']['changed']==true) {
329
-    		if ($new==true||($obj->vars['abid']['value']!=0)) {
330
-    			$album = $albums_handler->get($obj->vars['abid']['value']);
331
-    			if (is_object($album)) {
332
-	    			$album->setVar('songs', $album->getVar('songs')+1);
333
-	    			$albums_handler->insert($album, true, $obj);
334
-		    		if ($new==true||($obj->vars['vcid']['value']!=0)) {
335
-		    			$voice = $voice_handler->get($obj->vars['vcid']['value']);
336
-		    			if (is_object($voice)) {
337
-			    			$voice->setVar('albums', $voice->getVar('albums')+1);
338
-			    			$voice_handler->insert($voice, true, $obj);
339
-		    			}
340
-		    		} 
341
-    			}
342
-    		}
343
-    		if (!$old->isNew()&&$old->getVar('abid')>0) {
344
-    			$album = $albums_handler->get($obj->vars['abid']['value']);
345
-    			if (is_object($album)) {
346
-	    			$album->setVar('songs', $album->getVar('songs')-1);
347
-	    			$albums_handler->insert($album, true, null);
348
-    				if (!$old->isNew()&&$old->getVar('vcid')>0) {
349
-			    		$voice = $voice_handler->get($old->vars['vcid']['value']);
350
-			    		if (is_object($voice)) {
328
+		if ($obj->vars['abid']['changed']==true) {
329
+			if ($new==true||($obj->vars['abid']['value']!=0)) {
330
+				$album = $albums_handler->get($obj->vars['abid']['value']);
331
+				if (is_object($album)) {
332
+					$album->setVar('songs', $album->getVar('songs')+1);
333
+					$albums_handler->insert($album, true, $obj);
334
+					if ($new==true||($obj->vars['vcid']['value']!=0)) {
335
+						$voice = $voice_handler->get($obj->vars['vcid']['value']);
336
+						if (is_object($voice)) {
337
+							$voice->setVar('albums', $voice->getVar('albums')+1);
338
+							$voice_handler->insert($voice, true, $obj);
339
+						}
340
+					} 
341
+				}
342
+			}
343
+			if (!$old->isNew()&&$old->getVar('abid')>0) {
344
+				$album = $albums_handler->get($obj->vars['abid']['value']);
345
+				if (is_object($album)) {
346
+					$album->setVar('songs', $album->getVar('songs')-1);
347
+					$albums_handler->insert($album, true, null);
348
+					if (!$old->isNew()&&$old->getVar('vcid')>0) {
349
+						$voice = $voice_handler->get($old->vars['vcid']['value']);
350
+						if (is_object($voice)) {
351 351
 				   			$voice->setVar('albums', $voice->getVar('albums')-1);
352 352
 				   			$voice_handler->insert($voice, true, null);
353
-			    		}
354
-			    	}
355
-    			}
356
-    		}
357
-    	}
353
+						}
354
+					}
355
+				}
356
+			}
357
+		}
358 358
     	
359
-    	if (strlen($obj->getVar('title'))==0)
360
-    		return false;
359
+		if (strlen($obj->getVar('title'))==0)
360
+			return false;
361 361
     	
362
-    	$sid = parent::insert($obj, $force);
363
-    	if ($obj->vars['abid']['value']>0) {
364
-    		$album = $albums_handler->get($obj->vars['abid']['value']);
365
-    		$arry = $album->getVar('sids');
366
-    		$arry[$sid] = $sid;
367
-    		if (is_object($album)) {
368
-	    		$album->setVar('sids', $arry);
369
-	    		$albums_handler->insert($album);
370
-    		}
371
-    	}
362
+		$sid = parent::insert($obj, $force);
363
+		if ($obj->vars['abid']['value']>0) {
364
+			$album = $albums_handler->get($obj->vars['abid']['value']);
365
+			$arry = $album->getVar('sids');
366
+			$arry[$sid] = $sid;
367
+			if (is_object($album)) {
368
+				$album->setVar('sids', $arry);
369
+				$albums_handler->insert($album);
370
+			}
371
+		}
372 372
 		if (count($obj->getVar('aids'))>0) {
373
-    		foreach($obj->getVar('aids') as $aid) {
373
+			foreach($obj->getVar('aids') as $aid) {
374 374
 				$artist = $artists_handler->get($aid);
375
-	    		$arry = $artist->getVar('sids');
376
-	    		$arry[$sid] = $sid;
377
-	    		if (is_object($artists)) {
378
-		    		$artist->setVar('sids', $arry);
379
-		    		$artists_handler->insert($artist);
380
-	    		}
381
-    		}
382
-    	}
383
-    	return $sid;
384
-    }
375
+				$arry = $artist->getVar('sids');
376
+				$arry[$sid] = $sid;
377
+				if (is_object($artists)) {
378
+					$artist->setVar('sids', $arry);
379
+					$artists_handler->insert($artist);
380
+				}
381
+			}
382
+		}
383
+		return $sid;
384
+	}
385 385
      
386 386
 	var $_objects = array('object'=>array(), 'array'=>array());
387 387
     
388
-    function get($id, $fields = '*') {
389
-    	if (!isset($this->_objects['object'][$id])) {
390
-	    	$this->_objects['object'][$id] = parent::get($id, $fields);
391
-	    	if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
392
-		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
393
-		    	$GLOBALS['xoopsDB']->queryF($sql);
394
-	    	}
395
-    	}
396
-    	return $this->_objects['object'][$id];
397
-    }
388
+	function get($id, $fields = '*') {
389
+		if (!isset($this->_objects['object'][$id])) {
390
+			$this->_objects['object'][$id] = parent::get($id, $fields);
391
+			if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
392
+				$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
393
+				$GLOBALS['xoopsDB']->queryF($sql);
394
+			}
395
+		}
396
+		return $this->_objects['object'][$id];
397
+	}
398 398
     
399
-    function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
400
-    	$ret = parent::getObjects($criteria, $id_as_key, $as_object);
401
-    	/*if (!isset($GLOBALS['songlistAdmin'])) {
399
+	function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
400
+		$ret = parent::getObjects($criteria, $id_as_key, $as_object);
401
+		/*if (!isset($GLOBALS['songlistAdmin'])) {
402 402
 	    	foreach($ret as $data) {
403 403
 	    		$id = array();
404 404
 	    		if ($as_object==true) {
@@ -418,49 +418,49 @@  discard block
 block discarded – undo
418 418
 	    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` IN ('.implode(',', $id).')';
419 419
 	    	$GLOBALS['xoopsDB']->queryF($sql);
420 420
     	}*/
421
-    	return $ret;
422
-    }   
421
+		return $ret;
422
+	}   
423 423
     
424
-    function getURL() {
425
-    	global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
426
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
427
-    	    if ($cid!=0) {
428
-    			$artist_handler = xoops_getmodulehandler('artists', 'songlist');
429
-    			$artist = $artist_handler->get($cid);
430
-    			if (is_object($artist)&&!$artist->isNew()) {
431
-    				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
432
-    			} else {
433
-    				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
434
-    			}
435
-    		} else {
436
-    			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
437
-    		}
438
-    	} else {
439
-    		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
440
-    	}
441
-    }
424
+	function getURL() {
425
+		global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
426
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
427
+			if ($cid!=0) {
428
+				$artist_handler = xoops_getmodulehandler('artists', 'songlist');
429
+				$artist = $artist_handler->get($cid);
430
+				if (is_object($artist)&&!$artist->isNew()) {
431
+					return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
432
+				} else {
433
+					return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
434
+				}
435
+			} else {
436
+				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
437
+			}
438
+		} else {
439
+			return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
440
+		}
441
+	}
442 442
 	
443 443
 
444
-    function getSearchURL() {
445
-    	global $file, $op, $fct, $id, $value, $gid, $vcid, $cid, $start, $limit;
446
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
447
-    		return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$op.'-'.$fct.'-'.$gid.'-'.(isset($_GET['cid'])?($_GET['cid']):$cid).'-'.$vcid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
448
-    	} else {
449
-    		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&value='.urlencode($value).'&cid='.$cid.'&gid='.$gid.'&vcid='.$vcid.'&start='.$start;
450
-    	}
451
-    }
444
+	function getSearchURL() {
445
+		global $file, $op, $fct, $id, $value, $gid, $vcid, $cid, $start, $limit;
446
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
447
+			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$op.'-'.$fct.'-'.$gid.'-'.(isset($_GET['cid'])?($_GET['cid']):$cid).'-'.$vcid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
448
+		} else {
449
+			return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&value='.urlencode($value).'&cid='.$cid.'&gid='.$gid.'&vcid='.$vcid.'&start='.$start;
450
+		}
451
+	}
452 452
 
453 453
 	function getTop($limit=1) {
454
-    	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
455
-    	$results = $GLOBALS['xoopsDB']->queryF($sql);
456
-    	$ret = array();
457
-    	$i=0;
458
-    	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
459
-    		$ret[$i] = $this->create();
460
-    		$ret[$i]->assignVars($row);
461
-    		$i++;
462
-    	}
463
-    	return $ret;
464
-    }
454
+		$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
455
+		$results = $GLOBALS['xoopsDB']->queryF($sql);
456
+		$ret = array();
457
+		$i=0;
458
+		while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
459
+			$ret[$i] = $this->create();
460
+			$ret[$i]->assignVars($row);
461
+			$i++;
462
+		}
463
+		return $ret;
464
+	}
465 465
 }
466 466
 ?>
467 467
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 		$ret['lyrics'] = $GLOBALS['myts']->displayTarea($this->getVar('lyrics'), true, true, true, true, true);
44 44
 		
45 45
 		$form = $this->getForm(true);
46
-		foreach($form as $key => $element) {
46
+		foreach ($form as $key => $element) {
47 47
 			$ret['form'][$key] = $form[$key]->render();	
48 48
 		}
49
-		foreach(array('created', 'updated') as $key) {
49
+		foreach (array('created', 'updated') as $key) {
50 50
 			if ($this->getVar($key)>0) {
51 51
 				$ret['form'][$key] = date(_DATESTRING, $this->getVar($key)); 
52 52
 				$ret[$key] = date(_DATESTRING, $this->getVar($key));
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 		
56 56
 		$ret['url'] = $this->getURL();
57 57
 		
58
-		$ret['rank'] = number_format(($this->getVar('rank')>0&&$this->getVar('votes')>0?$this->getVar('rank')/$this->getVar('votes'):0),2)._MI_SONGLIST_OFTEN;
58
+		$ret['rank'] = number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2)._MI_SONGLIST_OFTEN;
59 59
 		
60 60
 		if (!empty($ret['mp3'])) {
61
-			$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=".$ret['mp3']."\" quality='high' menu='false' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' src='" . XOOPS_URL . "/images/form/player.swf'  width=290 height=24 type='application/x-shockwave-flash'></embed>";
61
+			$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=".$ret['mp3']."\" quality='high' menu='false' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' src='".XOOPS_URL."/images/form/player.swf'  width=290 height=24 type='application/x-shockwave-flash'></embed>";
62 62
 		}
63 63
 		
64
-		if (file_exists($GLOBALS['xoops']->path("/modules/tag/include/tagbar.php"))&&$GLOBALS['songlistModuleConfig']['tags']) {
64
+		if (file_exists($GLOBALS['xoops']->path("/modules/tag/include/tagbar.php")) && $GLOBALS['songlistModuleConfig']['tags']) {
65 65
 			include_once XOOPS_ROOT_PATH."/modules/tag/include/tagbar.php";
66 66
 			$ret['tagbar'] = tagBar($this->getVar('sid'), $this->getVar('cid'));
67 67
 		}
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 				$fields_id = $visibility_handler->getVisibleFields(array(), array());
79 79
 	
80 80
 			if (count($fields_id)>0) {
81
-				$criteria = new Criteria('field_id', '('.implode(',',$fields_id).')', 'IN');
81
+				$criteria = new Criteria('field_id', '('.implode(',', $fields_id).')', 'IN');
82 82
 				$criteria->setSort('field_weight');
83 83
 				$fields = $field_handler->getObjects($criteria, true);
84
-				foreach($fields as $id => $field) {
84
+				foreach ($fields as $id => $field) {
85 85
 					if (in_array($this->getVar('cid'), $field->getVar('cids'))) {
86 86
 						$ret['fields'][$id]['title'] = $field->getVar('field_title');
87 87
 						if (is_object($GLOBALS['xoopsUser']))
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
     	}
104 104
 
105 105
     	if (count($this->getVar('gids'))!=0) {
106
-    		$i=0;
106
+    		$i = 0;
107 107
     		$genre_handler = xoops_getmodulehandler('genre', 'songlist');
108 108
     		$ret['genre'] = '';
109
-    		$genres = $genre_handler->getObjects(new Criteria('gid', '('.implode(',',$this->getVar('gids')).')', 'IN'), true);
110
-    		foreach($genres as $gid => $genre) {
109
+    		$genres = $genre_handler->getObjects(new Criteria('gid', '('.implode(',', $this->getVar('gids')).')', 'IN'), true);
110
+    		foreach ($genres as $gid => $genre) {
111 111
     			$ret['genre_array'][$gid] = $genre->toArray(false);
112 112
     			$i++;
113
-    			$ret['genre'] .= $genre->getVar('name') . ($i<count($genres)?', ':'');
113
+    			$ret['genre'] .= $genre->getVar('name').($i<count($genres) ? ', ' : '');
114 114
     		}
115 115
     	}
116 116
     	if ($this->getVar('vcid')!=0) {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     	
122 122
 		if (count($this->getVar('aids'))!=0) {
123 123
     		$artists_handler = xoops_getmodulehandler('artists', 'songlist');
124
-    		foreach($this->getVar('aids') as $aid) {
124
+    		foreach ($this->getVar('aids') as $aid) {
125 125
     			$artist = $artists_handler->get($aid);
126 126
     			$ret['artists_array'][$aid] = $artist->toArray(false);
127 127
     		} 	
@@ -166,30 +166,30 @@  discard block
 block discarded – undo
166 166
     function getFilterCriteria($filter) {
167 167
     	$parts = explode('|', $filter);
168 168
     	$criteria = new CriteriaCompo();
169
-    	foreach($parts as $part) {
169
+    	foreach ($parts as $part) {
170 170
     		$var = explode(',', $part);
171
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
171
+    		if (!empty($var[1]) && !is_numeric($var[0])) {
172 172
     			$object = $this->create();
173
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
174
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
175
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
176
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
173
+    			if ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
174
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) {
175
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2]) ? $var[2] : 'LIKE')));
176
+    			} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
177 177
     						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
178
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
179
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
180
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
181
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
182
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
183
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
178
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT) {
179
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));			
180
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM) {
181
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));    				
182
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY) {
183
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2]) ? $var[2] : 'LIKE')));    				
184 184
 				}
185
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
185
+    		} elseif (!empty($var[1]) && is_numeric($var[0])) {
186 186
     			$criteria->add(new Criteria($var[0], $var[1]));
187 187
     		}
188 188
     	}
189 189
     	return $criteria;
190 190
     }
191 191
         
192
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
192
+    function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list') {
193 193
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
194 194
     	if (is_object($ele))
195 195
     		return $ele->render();
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     		return '&nbsp;';
198 198
     }
199 199
     
200
-	function insert($obj, $force=true, $object = null) {
200
+	function insert($obj, $force = true, $object = null) {
201 201
     	if ($obj->isNew()) {
202 202
     		$new = true;
203 203
     		$old = $this->create();
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
 		$category_handler = xoops_getmodulehandler('category', 'songlist');
216 216
 
217 217
 		if ($obj->vars['gid']['changed']==true) {
218
-    		if ($new==true||($obj->vars['gid']['value']!=0)) {
218
+    		if ($new==true || ($obj->vars['gid']['value']!=0)) {
219 219
     			$genre = $genre_handler->get($obj->vars['gid']['value']);
220 220
     			if (is_object($genre)) {
221 221
 	    			$genre->setVar('songs', $genre->getVar('songs')+1);
222 222
 	    			$genre_handler->insert($genre, true, $obj);
223 223
     			}
224 224
     		} 
225
-    		if (!$old->isNew()&&$old->getVar('gid')>0) {
225
+    		if (!$old->isNew() && $old->getVar('gid')>0) {
226 226
     			$genre = $genre_handler->get($old->vars['gid']['value']);
227 227
     			if (is_object($genre)) {
228 228
 	    			$genre->setVar('songs', $genre->getVar('songs')-1);
@@ -232,14 +232,14 @@  discard block
 block discarded – undo
232 232
     	}
233 233
 
234 234
 		if ($obj->vars['vcid']['changed']==true) {
235
-    		if ($new==true||($obj->vars['vcid']['value']!=0)) {
235
+    		if ($new==true || ($obj->vars['vcid']['value']!=0)) {
236 236
     			$voice = $voice_handler->get($obj->vars['vcid']['value']);
237 237
     			if (is_object($voice)) {
238 238
 	    			$voice->setVar('songs', $voice->getVar('songs')+1);
239 239
 	    			$voice_handler->insert($voice, true, $obj);
240 240
     			}
241 241
     		} 
242
-    		if (!$old->isNew()&&$old->getVar('vcid')>0) {
242
+    		if (!$old->isNew() && $old->getVar('vcid')>0) {
243 243
     			$voice = $voice_handler->get($old->vars['vcid']['value']);
244 244
     			if (is_object($voice)) {
245 245
 	    			$voice->setVar('songs', $voice->getVar('songs')-1);
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
     	}
250 250
     	
251 251
 		if ($obj->vars['cid']['changed']==true) {
252
-    		if ($new==true||($obj->vars['cid']['value']!=0)) {
252
+    		if ($new==true || ($obj->vars['cid']['value']!=0)) {
253 253
     			$category = $category_handler->get($obj->vars['cid']['value']);
254 254
     			if (is_object($category)) {
255 255
 	    			$category->setVar('songs', $category->getVar('songs')+1);
256 256
 	    			$category_handler->insert($category, true, $obj);
257
-	    		    foreach($obj->getVar('aids') as $aid) {
257
+	    		    foreach ($obj->getVar('aids') as $aid) {
258 258
 		    			$artists = $artists_handler->get($aid);
259 259
 		    			$cids = $artists->getVar('cids');
260 260
 		    			$cids[$obj->getVar('cid')] = $obj->getVar('cid');
@@ -265,16 +265,16 @@  discard block
 block discarded – undo
265 265
 	    			}
266 266
     			}
267 267
     		}
268
-			if (!$old->isNew()&&$old->getVar('cid')>0) {
268
+			if (!$old->isNew() && $old->getVar('cid')>0) {
269 269
 				$category = $category_handler->get($old->vars['cid']['value']);
270 270
 				if (is_object($category)) {
271 271
 	    			$category->setVar('songs', $category->getVar('songs')-1);
272 272
 	    			$category_handler->insert($category, true, null);
273
-					foreach($obj->getVar('aids') as $aid) {
273
+					foreach ($obj->getVar('aids') as $aid) {
274 274
 		    			$artists = $artists_handler->get($aid);
275
-		    			$cids=array();
276
-		    			foreach($artists->getVar('cids') as $cid) {
277
-		    				if($cid!=$old->getVar('cid')||$cid==$obj->getVar('cid'))
275
+		    			$cids = array();
276
+		    			foreach ($artists->getVar('cids') as $cid) {
277
+		    				if ($cid!=$old->getVar('cid') || $cid==$obj->getVar('cid'))
278 278
 		    					$cids[$cid] = $cid;
279 279
 		    			}
280 280
 		    			if (is_object($artists)) {
@@ -286,15 +286,15 @@  discard block
 block discarded – undo
286 286
     		}
287 287
     	}
288 288
     	
289
-    	if ($obj->vars['aids']['changed']==true&&count($obj->vars['aids']['value'])!=0) {
290
-    		if ($new==true||count($obj->vars['aids']['value'])!=0) {
291
-    			foreach($obj->vars['aids']['value'] as $aid) {
289
+    	if ($obj->vars['aids']['changed']==true && count($obj->vars['aids']['value'])!=0) {
290
+    		if ($new==true || count($obj->vars['aids']['value'])!=0) {
291
+    			foreach ($obj->vars['aids']['value'] as $aid) {
292 292
     				if (!in_array($aid, $old->vars['aids']['value'])) {
293 293
 		    			$artists = $artists_handler->get($aid);
294 294
 		    			if (is_object($artists)) {
295 295
 			    			$artists->setVar('songs', $artists->getVar('songs')+1);
296 296
 			    			$artists_handler->insert($artists, true, $obj);
297
-				    		if ($new==true||($obj->vars['vcid']['value']!=0)) {
297
+				    		if ($new==true || ($obj->vars['vcid']['value']!=0)) {
298 298
 				    			$voice = $voice_handler->get($obj->vars['vcid']['value']);
299 299
 				    			if (is_object($voice)) {
300 300
 					    			$voice->setVar('artists', $voice->getVar('artists')+1);
@@ -305,14 +305,14 @@  discard block
 block discarded – undo
305 305
     				}
306 306
     			}
307 307
     		}
308
-    		if (!$old->isNew()&&count($old->getVar('aids'))==0) {
309
-    			foreach($old->getVar('aids') as $aid) {
308
+    		if (!$old->isNew() && count($old->getVar('aids'))==0) {
309
+    			foreach ($old->getVar('aids') as $aid) {
310 310
     				if (!in_array($aid, $obj->vars['aids']['value'])) {
311 311
 	    				$artists = $artists_handler->get($aid);
312 312
 	    				if (is_object($artists)) {
313 313
 			    			$artists->setVar('songs', $artists->getVar('songs')-1);
314 314
 			    			$artists_handler->insert($artists, true, null);
315
-			    			if (!$old->isNew()&&$old->getVar('vcid')>0) {
315
+			    			if (!$old->isNew() && $old->getVar('vcid')>0) {
316 316
 				    			$voice = $voice_handler->get($old->vars['vcid']['value']);
317 317
 				    			if (is_object($voice)) {
318 318
 					    			$voice->setVar('artists', $voice->getVar('artists')-1);
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
     	}
327 327
     	
328 328
     	if ($obj->vars['abid']['changed']==true) {
329
-    		if ($new==true||($obj->vars['abid']['value']!=0)) {
329
+    		if ($new==true || ($obj->vars['abid']['value']!=0)) {
330 330
     			$album = $albums_handler->get($obj->vars['abid']['value']);
331 331
     			if (is_object($album)) {
332 332
 	    			$album->setVar('songs', $album->getVar('songs')+1);
333 333
 	    			$albums_handler->insert($album, true, $obj);
334
-		    		if ($new==true||($obj->vars['vcid']['value']!=0)) {
334
+		    		if ($new==true || ($obj->vars['vcid']['value']!=0)) {
335 335
 		    			$voice = $voice_handler->get($obj->vars['vcid']['value']);
336 336
 		    			if (is_object($voice)) {
337 337
 			    			$voice->setVar('albums', $voice->getVar('albums')+1);
@@ -340,12 +340,12 @@  discard block
 block discarded – undo
340 340
 		    		} 
341 341
     			}
342 342
     		}
343
-    		if (!$old->isNew()&&$old->getVar('abid')>0) {
343
+    		if (!$old->isNew() && $old->getVar('abid')>0) {
344 344
     			$album = $albums_handler->get($obj->vars['abid']['value']);
345 345
     			if (is_object($album)) {
346 346
 	    			$album->setVar('songs', $album->getVar('songs')-1);
347 347
 	    			$albums_handler->insert($album, true, null);
348
-    				if (!$old->isNew()&&$old->getVar('vcid')>0) {
348
+    				if (!$old->isNew() && $old->getVar('vcid')>0) {
349 349
 			    		$voice = $voice_handler->get($old->vars['vcid']['value']);
350 350
 			    		if (is_object($voice)) {
351 351
 				   			$voice->setVar('albums', $voice->getVar('albums')-1);
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
     		}
371 371
     	}
372 372
 		if (count($obj->getVar('aids'))>0) {
373
-    		foreach($obj->getVar('aids') as $aid) {
373
+    		foreach ($obj->getVar('aids') as $aid) {
374 374
 				$artist = $artists_handler->get($aid);
375 375
 	    		$arry = $artist->getVar('sids');
376 376
 	    		$arry[$sid] = $sid;
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
     function get($id, $fields = '*') {
389 389
     	if (!isset($this->_objects['object'][$id])) {
390 390
 	    	$this->_objects['object'][$id] = parent::get($id, $fields);
391
-	    	if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
391
+	    	if (!isset($GLOBALS['songlistAdmin']) && is_object($this->_objects['object'][$id])) {
392 392
 		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
393 393
 		    	$GLOBALS['xoopsDB']->queryF($sql);
394 394
 	    	}
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
     	    if ($cid!=0) {
428 428
     			$artist_handler = xoops_getmodulehandler('artists', 'songlist');
429 429
     			$artist = $artist_handler->get($cid);
430
-    			if (is_object($artist)&&!$artist->isNew()) {
430
+    			if (is_object($artist) && !$artist->isNew()) {
431 431
     				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
432 432
     			} else {
433 433
     				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
@@ -444,17 +444,17 @@  discard block
 block discarded – undo
444 444
     function getSearchURL() {
445 445
     	global $file, $op, $fct, $id, $value, $gid, $vcid, $cid, $start, $limit;
446 446
     	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
447
-    		return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$op.'-'.$fct.'-'.$gid.'-'.(isset($_GET['cid'])?($_GET['cid']):$cid).'-'.$vcid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
447
+    		return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$op.'-'.$fct.'-'.$gid.'-'.(isset($_GET['cid']) ? ($_GET['cid']) : $cid).'-'.$vcid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
448 448
     	} else {
449 449
     		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&value='.urlencode($value).'&cid='.$cid.'&gid='.$gid.'&vcid='.$vcid.'&start='.$start;
450 450
     	}
451 451
     }
452 452
 
453
-	function getTop($limit=1) {
453
+	function getTop($limit = 1) {
454 454
     	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
455 455
     	$results = $GLOBALS['xoopsDB']->queryF($sql);
456 456
     	$ret = array();
457
-    	$i=0;
457
+    	$i = 0;
458 458
     	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
459 459
     		$ret[$i] = $this->create();
460 460
     		$ret[$i]->assignVars($row);
Please login to merge, or discard this patch.
Braces   +24 added lines, -18 removed lines patch added patch discarded remove patch
@@ -72,10 +72,11 @@  discard block
 block discarded – undo
72 72
 
73 73
 		if ($extras = $extras_handler->get($this->getVar('sid'))) {
74 74
 	
75
-			if (is_object($GLOBALS['xoopsUser']))
76
-				$fields_id = $visibility_handler->getVisibleFields(array(), $GLOBALS['xoopsUser']->getGroups());
77
-			elseif (!is_object($GLOBALS['xoopsUser']))
78
-				$fields_id = $visibility_handler->getVisibleFields(array(), array());
75
+			if (is_object($GLOBALS['xoopsUser'])) {
76
+							$fields_id = $visibility_handler->getVisibleFields(array(), $GLOBALS['xoopsUser']->getGroups());
77
+			} elseif (!is_object($GLOBALS['xoopsUser'])) {
78
+							$fields_id = $visibility_handler->getVisibleFields(array(), array());
79
+			}
79 80
 	
80 81
 			if (count($fields_id)>0) {
81 82
 				$criteria = new Criteria('field_id', '('.implode(',',$fields_id).')', 'IN');
@@ -84,17 +85,19 @@  discard block
 block discarded – undo
84 85
 				foreach($fields as $id => $field) {
85 86
 					if (in_array($this->getVar('cid'), $field->getVar('cids'))) {
86 87
 						$ret['fields'][$id]['title'] = $field->getVar('field_title');
87
-						if (is_object($GLOBALS['xoopsUser']))
88
-							$ret['fields'][$id]['value'] = htmlspecialchars_decode($field->getOutputValue($GLOBALS['xoopsUser'], $extras));
89
-						elseif (!is_object($GLOBALS['xoopsUser']))
90
-							$ret['fields'][$id]['value'] = htmlspecialchars_decode($extras->getVar($field->getVar('field_name')));			
88
+						if (is_object($GLOBALS['xoopsUser'])) {
89
+													$ret['fields'][$id]['value'] = htmlspecialchars_decode($field->getOutputValue($GLOBALS['xoopsUser'], $extras));
90
+						} elseif (!is_object($GLOBALS['xoopsUser'])) {
91
+													$ret['fields'][$id]['value'] = htmlspecialchars_decode($extras->getVar($field->getVar('field_name')));
92
+						}
91 93
 					}
92 94
 				}
93 95
 			}
94 96
 		}
95 97
 				
96
-    	if ($extra==false)
97
-    		return $ret;
98
+    	if ($extra==false) {
99
+    	    		return $ret;
100
+    	}
98 101
     		
99 102
     	if ($this->getVar('cid')!=0) {
100 103
     		$category_handler = xoops_getmodulehandler('category', 'songlist');
@@ -191,10 +194,11 @@  discard block
 block discarded – undo
191 194
         
192 195
     function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
193 196
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
194
-    	if (is_object($ele))
195
-    		return $ele->render();
196
-    	else 
197
-    		return '&nbsp;';
197
+    	if (is_object($ele)) {
198
+    	    		return $ele->render();
199
+    	} else {
200
+    	    		return '&nbsp;';
201
+    	}
198 202
     }
199 203
     
200 204
 	function insert($obj, $force=true, $object = null) {
@@ -274,8 +278,9 @@  discard block
 block discarded – undo
274 278
 		    			$artists = $artists_handler->get($aid);
275 279
 		    			$cids=array();
276 280
 		    			foreach($artists->getVar('cids') as $cid) {
277
-		    				if($cid!=$old->getVar('cid')||$cid==$obj->getVar('cid'))
278
-		    					$cids[$cid] = $cid;
281
+		    				if($cid!=$old->getVar('cid')||$cid==$obj->getVar('cid')) {
282
+		    						    					$cids[$cid] = $cid;
283
+		    				}
279 284
 		    			}
280 285
 		    			if (is_object($artists)) {
281 286
 			    			$artists->setVar('cids', $cids);
@@ -356,8 +361,9 @@  discard block
 block discarded – undo
356 361
     		}
357 362
     	}
358 363
     	
359
-    	if (strlen($obj->getVar('title'))==0)
360
-    		return false;
364
+    	if (strlen($obj->getVar('title'))==0) {
365
+    	    		return false;
366
+    	}
361 367
     	
362 368
     	$sid = parent::insert($obj, $force);
363 369
     	if ($obj->vars['abid']['value']>0) {
Please login to merge, or discard this patch.
htdocs/modules/songlist/class/field.php 3 patches
Indentation   +751 added lines, -751 removed lines patch added patch discarded remove patch
@@ -9,107 +9,107 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class SonglistField extends XoopsObject
11 11
 {
12
-    function __construct()
13
-    {
14
-        $this->initVar('field_id', XOBJ_DTYPE_INT, null);
15
-        $this->initVar('cids', XOBJ_DTYPE_ARRAY, array(0=>'0'), true);
16
-        $this->initVar('field_type', XOBJ_DTYPE_TXTBOX);
17
-        $this->initVar('field_valuetype', XOBJ_DTYPE_INT, null, true);
18
-        $this->initVar('field_name', XOBJ_DTYPE_TXTBOX, null, true);
19
-        $this->initVar('field_title', XOBJ_DTYPE_TXTBOX);
20
-        $this->initVar('field_description', XOBJ_DTYPE_TXTAREA);
21
-        $this->initVar('field_required', XOBJ_DTYPE_INT, 0); //0 = no, 1 = yes
22
-        $this->initVar('field_maxlength', XOBJ_DTYPE_INT, 0);
23
-        $this->initVar('field_weight', XOBJ_DTYPE_INT, 0);
24
-        $this->initVar('field_default', XOBJ_DTYPE_TXTAREA, "");
25
-        $this->initVar('field_notnull', XOBJ_DTYPE_INT, 1);
26
-        $this->initVar('field_edit', XOBJ_DTYPE_INT, 0);
27
-        $this->initVar('field_show', XOBJ_DTYPE_INT, 0);
28
-        $this->initVar('field_config', XOBJ_DTYPE_INT, 0);
29
-        $this->initVar('field_options', XOBJ_DTYPE_ARRAY, array() );
30
-    }
12
+	function __construct()
13
+	{
14
+		$this->initVar('field_id', XOBJ_DTYPE_INT, null);
15
+		$this->initVar('cids', XOBJ_DTYPE_ARRAY, array(0=>'0'), true);
16
+		$this->initVar('field_type', XOBJ_DTYPE_TXTBOX);
17
+		$this->initVar('field_valuetype', XOBJ_DTYPE_INT, null, true);
18
+		$this->initVar('field_name', XOBJ_DTYPE_TXTBOX, null, true);
19
+		$this->initVar('field_title', XOBJ_DTYPE_TXTBOX);
20
+		$this->initVar('field_description', XOBJ_DTYPE_TXTAREA);
21
+		$this->initVar('field_required', XOBJ_DTYPE_INT, 0); //0 = no, 1 = yes
22
+		$this->initVar('field_maxlength', XOBJ_DTYPE_INT, 0);
23
+		$this->initVar('field_weight', XOBJ_DTYPE_INT, 0);
24
+		$this->initVar('field_default', XOBJ_DTYPE_TXTAREA, "");
25
+		$this->initVar('field_notnull', XOBJ_DTYPE_INT, 1);
26
+		$this->initVar('field_edit', XOBJ_DTYPE_INT, 0);
27
+		$this->initVar('field_show', XOBJ_DTYPE_INT, 0);
28
+		$this->initVar('field_config', XOBJ_DTYPE_INT, 0);
29
+		$this->initVar('field_options', XOBJ_DTYPE_ARRAY, array() );
30
+	}
31 31
 
32 32
 
33 33
 	
34
-    function SonglistField()
35
-    {
36
-        $this->__construct();
37
-    }
38
-
39
-    /**
40
-     * Extra treatment dealing with non latin encoding
41
-     * Tricky solution
42
-     */
43
-    function setVar($key, $value, $not_gpc = false)
44
-    {
45
-        if ($key == 'field_options' && is_array($value)) {
46
-            foreach (array_keys($value) as $idx ) {
47
-                $value[$idx] = base64_encode($value[$idx]);
48
-            }
49
-        }
50
-        parent::setVar($key, $value, $not_gpc);
51
-    }
52
-
53
-    function getVar($key, $format = 's')
54
-    {
55
-        $value = parent::getVar($key, $format);
56
-        if ($key == 'field_options' && !empty($value)) {
57
-            foreach (array_keys($value) as $idx) {
58
-                $value[$idx] = base64_decode($value[$idx]);
59
-            }
60
-        }
61
-        return $value;
62
-    }
63
-
64
-    /**
65
-    * Returns a {@link XoopsFormElement} for editing the value of this field
66
-    *
67
-    * @param XoopsUser $user {@link XoopsUser} object to edit the value of
68
-    * @param ObjectsProfile $profile {@link ObjectsProfile} object to edit the value of
69
-    *
70
-    * @return XoopsFormElement
71
-    **/
72
-    function getEditElement($user, $profile)
73
-    {
74
-        $value = in_array($this->getVar('field_name'), $this->getPostVars() ) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
75
-        if (is_null($value)) {
76
-            $value = $this->getVar('field_default');
77
-        }
78
-        $caption = $this->getVar('field_title');
79
-        $caption = defined($caption) ? constant($caption) : $caption;
80
-        $name = $this->getVar('field_name', 'e');
81
-        $options = $this->getVar('field_options');
82
-        if (is_array($options)) {
83
-            //asort($options);
84
-
85
-            foreach (array_keys($options) as $key) {
86
-                $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
87
-                $optkey = defined($key) ? constant($key) : $key;
88
-                unset($options[$key]);
89
-                $options[$optkey] = $optval;
90
-            }
91
-        }
92
-        include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
93
-        switch ($this->getVar('field_type')  ) {
94
-            default:
95
-            case "autotext":
96
-                //autotext is not for editing
97
-                $element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
98
-                break;
99
-
100
-            case "textbox":
101
-                $element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
102
-                break;
103
-
104
-            case "textarea":
105
-                $element = new XoopsFormTextArea($caption, $name, $value, 4, 30);
106
-                break;
107
-
108
-            case "dhtml":
109
-                $element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30);
110
-                break;
111
-
112
-            case "editor":
34
+	function SonglistField()
35
+	{
36
+		$this->__construct();
37
+	}
38
+
39
+	/**
40
+	 * Extra treatment dealing with non latin encoding
41
+	 * Tricky solution
42
+	 */
43
+	function setVar($key, $value, $not_gpc = false)
44
+	{
45
+		if ($key == 'field_options' && is_array($value)) {
46
+			foreach (array_keys($value) as $idx ) {
47
+				$value[$idx] = base64_encode($value[$idx]);
48
+			}
49
+		}
50
+		parent::setVar($key, $value, $not_gpc);
51
+	}
52
+
53
+	function getVar($key, $format = 's')
54
+	{
55
+		$value = parent::getVar($key, $format);
56
+		if ($key == 'field_options' && !empty($value)) {
57
+			foreach (array_keys($value) as $idx) {
58
+				$value[$idx] = base64_decode($value[$idx]);
59
+			}
60
+		}
61
+		return $value;
62
+	}
63
+
64
+	/**
65
+	 * Returns a {@link XoopsFormElement} for editing the value of this field
66
+	 *
67
+	 * @param XoopsUser $user {@link XoopsUser} object to edit the value of
68
+	 * @param ObjectsProfile $profile {@link ObjectsProfile} object to edit the value of
69
+	 *
70
+	 * @return XoopsFormElement
71
+	 **/
72
+	function getEditElement($user, $profile)
73
+	{
74
+		$value = in_array($this->getVar('field_name'), $this->getPostVars() ) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
75
+		if (is_null($value)) {
76
+			$value = $this->getVar('field_default');
77
+		}
78
+		$caption = $this->getVar('field_title');
79
+		$caption = defined($caption) ? constant($caption) : $caption;
80
+		$name = $this->getVar('field_name', 'e');
81
+		$options = $this->getVar('field_options');
82
+		if (is_array($options)) {
83
+			//asort($options);
84
+
85
+			foreach (array_keys($options) as $key) {
86
+				$optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
87
+				$optkey = defined($key) ? constant($key) : $key;
88
+				unset($options[$key]);
89
+				$options[$optkey] = $optval;
90
+			}
91
+		}
92
+		include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
93
+		switch ($this->getVar('field_type')  ) {
94
+			default:
95
+			case "autotext":
96
+				//autotext is not for editing
97
+				$element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
98
+				break;
99
+
100
+			case "textbox":
101
+				$element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
102
+				break;
103
+
104
+			case "textarea":
105
+				$element = new XoopsFormTextArea($caption, $name, $value, 4, 30);
106
+				break;
107
+
108
+			case "dhtml":
109
+				$element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30);
110
+				break;
111
+
112
+			case "editor":
113 113
 
114 114
 				$editor_config['name'] = $name;
115 115
 				$editor_config['editor'] = $GLOBALS['songlistModuleConfig']['editor'];
@@ -117,437 +117,437 @@  discard block
 block discarded – undo
117 117
 				$editor_config['width'] = $GLOBALS['songlistModuleConfig']['editor_width'];
118 118
 				$editor_config['height'] = $GLOBALS['songlistModuleConfig']['editor_height'];
119 119
 				$element = new XoopsFormEditor($caption, $name, $editor_config);
120
-                break;
121
-
122
-            case "select":
123
-                $element = new XoopsFormSelect($caption, $name, $value);
124
-                // If options do not include an empty element, then add a blank option to prevent any default selection
125
-                if (!in_array('', array_keys($options))) {
126
-                    $element->addOption('', _NONE);
127
-                    //trabis
128
-                    if ($this->getVar('field_required') == 1) {
129
-                        $eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf( _FORM_ENTER, $caption);
130
-                        $eltmsg = str_replace('"', '\"', stripslashes($eltmsg));
131
-                        $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" .
132
-                            "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" .
133
-                            "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
134
-                    }
135
-                }
136
-                $element->addOptionArray($options);
137
-                break;
138
-
139
-            case "select_multi":
140
-                $element = new XoopsFormSelect($caption, $name, $value, 5, true);
141
-                $element->addOptionArray($options);
142
-                break;
143
-
144
-            case "radio":
145
-                $element = new XoopsFormRadio($caption, $name, $value);
146
-                $element->addOptionArray($options);
147
-                break;
148
-
149
-            case "checkbox":
150
-                $element = new XoopsFormCheckBox($caption, $name, $value);
151
-                $element->addOptionArray($options);
152
-                break;
153
-
154
-            case "yesno":
155
-                $element = new XoopsFormRadioYN($caption, $name, $value);
156
-                break;
157
-
158
-            case "group":
159
-                $element = new XoopsFormSelectGroup($caption, $name, true, $value);
160
-                break;
161
-
162
-            case "group_multi":
163
-                $element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
164
-                break;
165
-
166
-            case "language":
167
-                $element = new XoopsFormSelectLang($caption, $name, $value);
168
-                break;
169
-
170
-            case "date":
171
-                $element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
172
-                break;
173
-
174
-            case "longdate":
175
-                $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value) );
176
-                break;
177
-
178
-            case "datetime":
179
-                $element = new XoopsFormDatetime($caption, $name, 15, $value);
180
-                break;
181
-
182
-            case "list":
183
-                $element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
184
-                break;
185
-
186
-            case "timezone":
187
-                $element = new XoopsFormSelectTimezone($caption, $name, $value);
188
-                $element->setExtra("style='width: 280px;'");
189
-                break;
190
-
191
-            case "rank":
192
-                $element = new XoopsFormSelect($caption, $name, $value);
193
-
194
-                include_once $GLOBALS['xoops']->path('class/xoopslists.php');
195
-                $ranks = XoopsLists::getUserRankList();
196
-                $element->addOption(0, "--------------");
197
-                $element->addOptionArray($ranks);
198
-                break;
199
-
200
-            case 'theme':
201
-                $element = new XoopsFormSelect($caption, $name, $value);
202
-                $element->addOption("0", _OBJS_MF_SITEDEFAULT);
203
-                $handle = opendir(XOOPS_THEME_PATH . '/');
204
-                $dirlist = array();
205
-                while (false !== ($file = readdir($handle) ) ) {
206
-                    if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) != 'cvs' ) {
207
-                        if (file_exists(XOOPS_THEME_PATH . "/" . $file . "/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
208
-                            $dirlist[$file] = $file;
209
-                        }
210
-                    }
211
-                }
212
-                closedir($handle);
213
-                if (!empty($dirlist)) {
214
-                    asort($dirlist);
215
-                    $element->addOptionArray($dirlist);
216
-                }
217
-                break;
218
-        }
219
-        if ($this->getVar('field_description') != "") {
220
-            $element->setDescription($this->getVar('field_description') );
221
-        }
222
-        return $element;
223
-    }
224
-
225
-    /**
226
-    * Returns a {@link XoopsFormElement} for editing the value of this field
227
-    *
228
-    * @param XoopsUser $user {@link XoopsUser} object to edit the value of
229
-    * @param ObjectsProfile $profile {@link ObjectsProfile} object to edit the value of
230
-    *
231
-    * @return XoopsFormElement
232
-    **/
233
-    function getSearchElement()
234
-    {
235
-        $caption = $this->getVar('field_title');
236
-        $caption = defined($caption) ? constant($caption) : $caption;
237
-        $name = $this->getVar('field_name', 'e');
238
-        $options = $this->getVar('field_options');
239
-        if (is_array($options)) {
240
-            //asort($options);
241
-
242
-            foreach (array_keys($options) as $key) {
243
-                $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
244
-                $optkey = defined($key) ? constant($key) : $key;
245
-                unset($options[$key]);
246
-                $options[$optkey] = $optval;
247
-            }
248
-        }
249
-        include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
250
-        switch ($this->getVar('field_type')  ) {
251
-            default:
252
-            case "autotext":
253
-                //autotext is not for editing
254
-                $element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
255
-                break;
256
-
257
-            case "textbox":
258
-                $element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
259
-                break;
260
-
261
-            case "textarea":
262
-                $element = new XoopsFormTextArea($caption, $name, $value, 4, 30);
263
-                break;
264
-
265
-            case "dhtml":
266
-                $element = new XoopsFormText($caption, $name, 35, 255, $value);
267
-                break;
268
-
269
-            case "select":
270
-                $element = new XoopsFormSelect($caption, $name, $value);
271
-                // If options do not include an empty element, then add a blank option to prevent any default selection
272
-                if (!in_array('', array_keys($options))) {
273
-                    $element->addOption('', _NONE);
274
-                    //trabis
275
-                    if ($this->getVar('field_required') == 1) {
276
-                        $eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf( _FORM_ENTER, $caption);
277
-                        $eltmsg = str_replace('"', '\"', stripslashes($eltmsg));
278
-                        $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" .
279
-                            "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" .
280
-                            "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
281
-                    }
282
-                    //end
283
-                }
284
-                $element->addOptionArray($options);
285
-                break;
286
-
287
-
288
-            case "editor":
289
-
290
-                $element = new XoopsFormText($caption, $name, 35, 255, $value);
291
-                break;
292
-
293
-            case "select_multi":
294
-                $element = new XoopsFormSelect($caption, $name, $value, 5, true);
295
-                $element->addOptionArray($options);
296
-                break;
297
-
298
-            case "radio":
299
-                $element = new XoopsFormRadio($caption, $name, $value);
300
-                $element->addOptionArray($options);
301
-                break;
302
-
303
-            case "checkbox":
304
-                $element = new XoopsFormCheckBox($caption, $name, $value);
305
-                $element->addOptionArray($options);
306
-                break;
307
-
308
-            case "yesno":
309
-                $element = new XoopsFormRadioYN($caption, $name, $value);
310
-                break;
311
-
312
-            case "group":
313
-                $element = new XoopsFormSelectGroup($caption, $name, true, $value);
314
-                break;
315
-
316
-            case "group_multi":
317
-                $element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
318
-                break;
319
-
320
-            case "language":
321
-                $element = new XoopsFormSelectLang($caption, $name, $value);
322
-                break;
323
-
324
-            case "date":
325
-                $element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
326
-                break;
327
-
328
-            case "longdate":
329
-                $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value) );
330
-                break;
331
-
332
-            case "datetime":
333
-                $element = new XoopsFormDatetime($caption, $name, 15, $value);
334
-                break;
335
-
336
-            case "list":
337
-                $element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
338
-                break;
339
-
340
-            case "timezone":
341
-                $element = new XoopsFormSelectTimezone($caption, $name, $value);
342
-                $element->setExtra("style='width: 280px;'");
343
-                break;
344
-
345
-            case "rank":
346
-                $element = new XoopsFormSelect($caption, $name, $value);
347
-
348
-                include_once $GLOBALS['xoops']->path('class/xoopslists.php');
349
-                $ranks = XoopsLists::getUserRankList();
350
-                $element->addOption(0, "--------------");
351
-                $element->addOptionArray($ranks);
352
-                break;
353
-
354
-            case 'theme':
355
-                $element = new XoopsFormSelect($caption, $name, $value);
356
-                $element->addOption("0", _OBJS_MF_SITEDEFAULT);
357
-                $handle = opendir(XOOPS_THEME_PATH . '/');
358
-                $dirlist = array();
359
-                while (false !== ($file = readdir($handle) ) ) {
360
-                    if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) != 'cvs' ) {
361
-                        if (file_exists(XOOPS_THEME_PATH . "/" . $file . "/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
362
-                            $dirlist[$file] = $file;
363
-                        }
364
-                    }
365
-                }
366
-                closedir($handle);
367
-                if (!empty($dirlist)) {
368
-                    asort($dirlist);
369
-                    $element->addOptionArray($dirlist);
370
-                }
371
-                break;
372
-        }
373
-        if ($this->getVar('field_description') != "") {
374
-            $element->setDescription($this->getVar('field_description') );
375
-        }
376
-        return $element;
377
-    }
378
-
379
-    /**
380
-    * Returns a value for output of this field
381
-    *
382
-    * @param XoopsUser $user {@link XoopsUser} object to get the value of
383
-    * @param ObjectsProfile $profile object to get the value of
384
-    *
385
-    * @return mixed
386
-    **/
387
-    function getOutputValue($user, $profile)
388
-    {
389
-        if (file_exists($file = $GLOBALS['xoops']->path('modules/objects/language/' . $GLOBALS['xoopsConfig']['language'] . '/modinfo.php'))) {
390
-            include_once $file;
391
-        } else {
392
-            include_once $GLOBALS['xoops']->path('modules/objects/language/english/modinfo.php');
393
-        }
394
-
395
-        $value = in_array($this->getVar('field_name'), $this->getPostVars() ) ? $user->getVar($this->getVar('field_name') ) : $profile->getVar($this->getVar('field_name'));
396
-
397
-        switch ($this->getVar('field_type')  ) {
398
-            default:
399
-            case "textbox":
400
-                if ( $this->getVar('field_name') == 'url' && $value != '') {
401
-                     return '<a href="' . formatURL($value) . '" rel="external">' . $value . '</a>';
402
-                   } else {
403
-                     return $value;
404
-                }
405
-                break;
120
+				break;
121
+
122
+			case "select":
123
+				$element = new XoopsFormSelect($caption, $name, $value);
124
+				// If options do not include an empty element, then add a blank option to prevent any default selection
125
+				if (!in_array('', array_keys($options))) {
126
+					$element->addOption('', _NONE);
127
+					//trabis
128
+					if ($this->getVar('field_required') == 1) {
129
+						$eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf( _FORM_ENTER, $caption);
130
+						$eltmsg = str_replace('"', '\"', stripslashes($eltmsg));
131
+						$element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" .
132
+							"for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" .
133
+							"if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
134
+					}
135
+				}
136
+				$element->addOptionArray($options);
137
+				break;
138
+
139
+			case "select_multi":
140
+				$element = new XoopsFormSelect($caption, $name, $value, 5, true);
141
+				$element->addOptionArray($options);
142
+				break;
143
+
144
+			case "radio":
145
+				$element = new XoopsFormRadio($caption, $name, $value);
146
+				$element->addOptionArray($options);
147
+				break;
148
+
149
+			case "checkbox":
150
+				$element = new XoopsFormCheckBox($caption, $name, $value);
151
+				$element->addOptionArray($options);
152
+				break;
153
+
154
+			case "yesno":
155
+				$element = new XoopsFormRadioYN($caption, $name, $value);
156
+				break;
157
+
158
+			case "group":
159
+				$element = new XoopsFormSelectGroup($caption, $name, true, $value);
160
+				break;
161
+
162
+			case "group_multi":
163
+				$element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
164
+				break;
165
+
166
+			case "language":
167
+				$element = new XoopsFormSelectLang($caption, $name, $value);
168
+				break;
169
+
170
+			case "date":
171
+				$element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
172
+				break;
173
+
174
+			case "longdate":
175
+				$element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value) );
176
+				break;
177
+
178
+			case "datetime":
179
+				$element = new XoopsFormDatetime($caption, $name, 15, $value);
180
+				break;
181
+
182
+			case "list":
183
+				$element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
184
+				break;
185
+
186
+			case "timezone":
187
+				$element = new XoopsFormSelectTimezone($caption, $name, $value);
188
+				$element->setExtra("style='width: 280px;'");
189
+				break;
190
+
191
+			case "rank":
192
+				$element = new XoopsFormSelect($caption, $name, $value);
193
+
194
+				include_once $GLOBALS['xoops']->path('class/xoopslists.php');
195
+				$ranks = XoopsLists::getUserRankList();
196
+				$element->addOption(0, "--------------");
197
+				$element->addOptionArray($ranks);
198
+				break;
199
+
200
+			case 'theme':
201
+				$element = new XoopsFormSelect($caption, $name, $value);
202
+				$element->addOption("0", _OBJS_MF_SITEDEFAULT);
203
+				$handle = opendir(XOOPS_THEME_PATH . '/');
204
+				$dirlist = array();
205
+				while (false !== ($file = readdir($handle) ) ) {
206
+					if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) != 'cvs' ) {
207
+						if (file_exists(XOOPS_THEME_PATH . "/" . $file . "/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
208
+							$dirlist[$file] = $file;
209
+						}
210
+					}
211
+				}
212
+				closedir($handle);
213
+				if (!empty($dirlist)) {
214
+					asort($dirlist);
215
+					$element->addOptionArray($dirlist);
216
+				}
217
+				break;
218
+		}
219
+		if ($this->getVar('field_description') != "") {
220
+			$element->setDescription($this->getVar('field_description') );
221
+		}
222
+		return $element;
223
+	}
224
+
225
+	/**
226
+	 * Returns a {@link XoopsFormElement} for editing the value of this field
227
+	 *
228
+	 * @param XoopsUser $user {@link XoopsUser} object to edit the value of
229
+	 * @param ObjectsProfile $profile {@link ObjectsProfile} object to edit the value of
230
+	 *
231
+	 * @return XoopsFormElement
232
+	 **/
233
+	function getSearchElement()
234
+	{
235
+		$caption = $this->getVar('field_title');
236
+		$caption = defined($caption) ? constant($caption) : $caption;
237
+		$name = $this->getVar('field_name', 'e');
238
+		$options = $this->getVar('field_options');
239
+		if (is_array($options)) {
240
+			//asort($options);
241
+
242
+			foreach (array_keys($options) as $key) {
243
+				$optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
244
+				$optkey = defined($key) ? constant($key) : $key;
245
+				unset($options[$key]);
246
+				$options[$optkey] = $optval;
247
+			}
248
+		}
249
+		include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
250
+		switch ($this->getVar('field_type')  ) {
251
+			default:
252
+			case "autotext":
253
+				//autotext is not for editing
254
+				$element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
255
+				break;
256
+
257
+			case "textbox":
258
+				$element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
259
+				break;
260
+
261
+			case "textarea":
262
+				$element = new XoopsFormTextArea($caption, $name, $value, 4, 30);
263
+				break;
264
+
265
+			case "dhtml":
266
+				$element = new XoopsFormText($caption, $name, 35, 255, $value);
267
+				break;
268
+
269
+			case "select":
270
+				$element = new XoopsFormSelect($caption, $name, $value);
271
+				// If options do not include an empty element, then add a blank option to prevent any default selection
272
+				if (!in_array('', array_keys($options))) {
273
+					$element->addOption('', _NONE);
274
+					//trabis
275
+					if ($this->getVar('field_required') == 1) {
276
+						$eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf( _FORM_ENTER, $caption);
277
+						$eltmsg = str_replace('"', '\"', stripslashes($eltmsg));
278
+						$element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" .
279
+							"for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" .
280
+							"if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
281
+					}
282
+					//end
283
+				}
284
+				$element->addOptionArray($options);
285
+				break;
286
+
287
+
288
+			case "editor":
289
+
290
+				$element = new XoopsFormText($caption, $name, 35, 255, $value);
291
+				break;
292
+
293
+			case "select_multi":
294
+				$element = new XoopsFormSelect($caption, $name, $value, 5, true);
295
+				$element->addOptionArray($options);
296
+				break;
297
+
298
+			case "radio":
299
+				$element = new XoopsFormRadio($caption, $name, $value);
300
+				$element->addOptionArray($options);
301
+				break;
302
+
303
+			case "checkbox":
304
+				$element = new XoopsFormCheckBox($caption, $name, $value);
305
+				$element->addOptionArray($options);
306
+				break;
307
+
308
+			case "yesno":
309
+				$element = new XoopsFormRadioYN($caption, $name, $value);
310
+				break;
311
+
312
+			case "group":
313
+				$element = new XoopsFormSelectGroup($caption, $name, true, $value);
314
+				break;
315
+
316
+			case "group_multi":
317
+				$element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
318
+				break;
319
+
320
+			case "language":
321
+				$element = new XoopsFormSelectLang($caption, $name, $value);
322
+				break;
323
+
324
+			case "date":
325
+				$element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
326
+				break;
327
+
328
+			case "longdate":
329
+				$element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value) );
330
+				break;
331
+
332
+			case "datetime":
333
+				$element = new XoopsFormDatetime($caption, $name, 15, $value);
334
+				break;
335
+
336
+			case "list":
337
+				$element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
338
+				break;
339
+
340
+			case "timezone":
341
+				$element = new XoopsFormSelectTimezone($caption, $name, $value);
342
+				$element->setExtra("style='width: 280px;'");
343
+				break;
344
+
345
+			case "rank":
346
+				$element = new XoopsFormSelect($caption, $name, $value);
347
+
348
+				include_once $GLOBALS['xoops']->path('class/xoopslists.php');
349
+				$ranks = XoopsLists::getUserRankList();
350
+				$element->addOption(0, "--------------");
351
+				$element->addOptionArray($ranks);
352
+				break;
353
+
354
+			case 'theme':
355
+				$element = new XoopsFormSelect($caption, $name, $value);
356
+				$element->addOption("0", _OBJS_MF_SITEDEFAULT);
357
+				$handle = opendir(XOOPS_THEME_PATH . '/');
358
+				$dirlist = array();
359
+				while (false !== ($file = readdir($handle) ) ) {
360
+					if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) != 'cvs' ) {
361
+						if (file_exists(XOOPS_THEME_PATH . "/" . $file . "/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
362
+							$dirlist[$file] = $file;
363
+						}
364
+					}
365
+				}
366
+				closedir($handle);
367
+				if (!empty($dirlist)) {
368
+					asort($dirlist);
369
+					$element->addOptionArray($dirlist);
370
+				}
371
+				break;
372
+		}
373
+		if ($this->getVar('field_description') != "") {
374
+			$element->setDescription($this->getVar('field_description') );
375
+		}
376
+		return $element;
377
+	}
378
+
379
+	/**
380
+	 * Returns a value for output of this field
381
+	 *
382
+	 * @param XoopsUser $user {@link XoopsUser} object to get the value of
383
+	 * @param ObjectsProfile $profile object to get the value of
384
+	 *
385
+	 * @return mixed
386
+	 **/
387
+	function getOutputValue($user, $profile)
388
+	{
389
+		if (file_exists($file = $GLOBALS['xoops']->path('modules/objects/language/' . $GLOBALS['xoopsConfig']['language'] . '/modinfo.php'))) {
390
+			include_once $file;
391
+		} else {
392
+			include_once $GLOBALS['xoops']->path('modules/objects/language/english/modinfo.php');
393
+		}
394
+
395
+		$value = in_array($this->getVar('field_name'), $this->getPostVars() ) ? $user->getVar($this->getVar('field_name') ) : $profile->getVar($this->getVar('field_name'));
396
+
397
+		switch ($this->getVar('field_type')  ) {
398
+			default:
399
+			case "textbox":
400
+				if ( $this->getVar('field_name') == 'url' && $value != '') {
401
+					 return '<a href="' . formatURL($value) . '" rel="external">' . $value . '</a>';
402
+				   } else {
403
+					 return $value;
404
+				}
405
+				break;
406 406
 			case "editor":
407
-            case "textarea":
408
-            case "dhtml":
409
-            case 'theme':
410
-            case "language":
411
-            case "list":
412
-                return $value;
413
-                break;
414
-
415
-            case "select":
416
-            case "radio":
417
-                $options = $this->getVar('field_options');
418
-                if (isset($options[$value])) {
419
-                    $value = htmlspecialchars( defined($options[$value]) ? constant($options[$value]) : $options[$value]);
420
-                } else {
421
-                    $value = "";
422
-                }
423
-                return $value;
424
-                break;
425
-
426
-            case "select_multi":
427
-            case "checkbox":
428
-                $options = $this->getVar('field_options');
429
-                $ret = array();
430
-                if (count($options) > 0) {
431
-                    foreach (array_keys($options) as $key) {
432
-                        if (in_array($key, $value)) {
433
-                            $$ret[$key] = htmlspecialchars( defined($options[$key]) ? constant($options[$key]) : $options[$key]);
434
-                        }
435
-                    }
436
-                }
437
-                return $ret;
438
-                break;
439
-
440
-            case "group":
441
-                //change to retrieve groups and return name of group
442
-                return $value;
443
-                break;
444
-
445
-            case "group_multi":
446
-                //change to retrieve groups and return array of group names
447
-                return "";
448
-                break;
449
-
450
-            case "longdate":
451
-                //return YYYY/MM/DD format - not optimal as it is not using local date format, but how do we do that
452
-                //when we cannot convert it to a UNIX timestamp?
453
-                return str_replace("-", "/", $value);
454
-
455
-            case "date":
456
-                return formatTimestamp($value, 's');
457
-                break;
458
-
459
-            case "datetime":
460
-                if (!empty($value)) {
461
-                       return formatTimestamp($value, 'm');
462
-                   } else {
463
-                       return $value = _XFORUM_MI_DATENOTSET;
464
-                   }
465
-                break;
466
-
467
-            case "autotext":
468
-                $value = $user->getVar($this->getVar('field_name'), 'n'); //autotext can have HTML in it
469
-                $value = str_replace("{X_UID}", $user->getVar("uid"), $value);
470
-                $value = str_replace("{X_URL}", XOOPS_URL, $value );
471
-                $value = str_replace("{X_UNAME}", $user->getVar("uname"), $value);
472
-                return $value;
473
-                break;
474
-
475
-            case "rank":
476
-                $userrank = $user->rank();
477
-                $user_rankimage = "";
478
-                if (isset($userrank['image']) && $userrank['image'] != "") {
479
-                    $user_rankimage = '<img src="'.XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="' . $userrank['title'] . '" /><br />';
480
-                }
481
-                return $user_rankimage.$userrank['title'];
482
-                break;
483
-
484
-            case "yesno":
485
-                return $value ? _YES : _NO;
486
-                break;
487
-
488
-            case "timezone":
489
-                include_once $GLOBALS['xoops']->path('class/xoopslists.php');
490
-                $timezones = XoopsLists::getTimeZoneList();
491
-                $value = empty($value) ? "0" : strval($value);
492
-                return $timezones[str_replace('.0', '', $value)];
493
-                break;
494
-        }
495
-    }
496
-
497
-    /**
498
-    * Returns a value ready to be saved in the database
499
-    *
500
-    * @param mixed $value Value to format
501
-    *
502
-    * @return mixed
503
-    */
504
-    function getValueForSave($value)
505
-    {
506
-        switch ($this->getVar('field_type')) {
507
-            default:
508
-            case "textbox":
509
-            case "textarea":
510
-            case "dhtml":
511
-            case "yesno":
512
-            case "timezone":
513
-            case 'theme':
514
-            case "language":
515
-            case "list":
516
-            case "select":
517
-            case "radio":
518
-            case "select_multi":
519
-            case "checkbox":
520
-            case "group":
521
-            case "group_multi":
522
-            case "longdate":
523
-                return $value;
524
-
525
-            case "date":
526
-                if ($value != "") {
527
-                    return strtotime($value);
528
-                }
529
-                return $value;
530
-                break;
531
-
532
-            case "datetime":
533
-                if (!empty($value)) {
534
-                    return strtotime($value['date']) + intval($value['time']);
535
-                }
536
-                return $value;
537
-                break;
538
-        }
539
-    }
540
-
541
-    /**
542
-     * Get names of user variables
543
-     *
544
-     * @return array
545
-     */
546
-    function getPostVars()
547
-    {
548
-        $objects_handler = xoops_getmodulehandler('extras', 'songlist');
549
-        return $objects_handler->getPostVars();
550
-    }
407
+			case "textarea":
408
+			case "dhtml":
409
+			case 'theme':
410
+			case "language":
411
+			case "list":
412
+				return $value;
413
+				break;
414
+
415
+			case "select":
416
+			case "radio":
417
+				$options = $this->getVar('field_options');
418
+				if (isset($options[$value])) {
419
+					$value = htmlspecialchars( defined($options[$value]) ? constant($options[$value]) : $options[$value]);
420
+				} else {
421
+					$value = "";
422
+				}
423
+				return $value;
424
+				break;
425
+
426
+			case "select_multi":
427
+			case "checkbox":
428
+				$options = $this->getVar('field_options');
429
+				$ret = array();
430
+				if (count($options) > 0) {
431
+					foreach (array_keys($options) as $key) {
432
+						if (in_array($key, $value)) {
433
+							$$ret[$key] = htmlspecialchars( defined($options[$key]) ? constant($options[$key]) : $options[$key]);
434
+						}
435
+					}
436
+				}
437
+				return $ret;
438
+				break;
439
+
440
+			case "group":
441
+				//change to retrieve groups and return name of group
442
+				return $value;
443
+				break;
444
+
445
+			case "group_multi":
446
+				//change to retrieve groups and return array of group names
447
+				return "";
448
+				break;
449
+
450
+			case "longdate":
451
+				//return YYYY/MM/DD format - not optimal as it is not using local date format, but how do we do that
452
+				//when we cannot convert it to a UNIX timestamp?
453
+				return str_replace("-", "/", $value);
454
+
455
+			case "date":
456
+				return formatTimestamp($value, 's');
457
+				break;
458
+
459
+			case "datetime":
460
+				if (!empty($value)) {
461
+					   return formatTimestamp($value, 'm');
462
+				   } else {
463
+					   return $value = _XFORUM_MI_DATENOTSET;
464
+				   }
465
+				break;
466
+
467
+			case "autotext":
468
+				$value = $user->getVar($this->getVar('field_name'), 'n'); //autotext can have HTML in it
469
+				$value = str_replace("{X_UID}", $user->getVar("uid"), $value);
470
+				$value = str_replace("{X_URL}", XOOPS_URL, $value );
471
+				$value = str_replace("{X_UNAME}", $user->getVar("uname"), $value);
472
+				return $value;
473
+				break;
474
+
475
+			case "rank":
476
+				$userrank = $user->rank();
477
+				$user_rankimage = "";
478
+				if (isset($userrank['image']) && $userrank['image'] != "") {
479
+					$user_rankimage = '<img src="'.XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="' . $userrank['title'] . '" /><br />';
480
+				}
481
+				return $user_rankimage.$userrank['title'];
482
+				break;
483
+
484
+			case "yesno":
485
+				return $value ? _YES : _NO;
486
+				break;
487
+
488
+			case "timezone":
489
+				include_once $GLOBALS['xoops']->path('class/xoopslists.php');
490
+				$timezones = XoopsLists::getTimeZoneList();
491
+				$value = empty($value) ? "0" : strval($value);
492
+				return $timezones[str_replace('.0', '', $value)];
493
+				break;
494
+		}
495
+	}
496
+
497
+	/**
498
+	 * Returns a value ready to be saved in the database
499
+	 *
500
+	 * @param mixed $value Value to format
501
+	 *
502
+	 * @return mixed
503
+	 */
504
+	function getValueForSave($value)
505
+	{
506
+		switch ($this->getVar('field_type')) {
507
+			default:
508
+			case "textbox":
509
+			case "textarea":
510
+			case "dhtml":
511
+			case "yesno":
512
+			case "timezone":
513
+			case 'theme':
514
+			case "language":
515
+			case "list":
516
+			case "select":
517
+			case "radio":
518
+			case "select_multi":
519
+			case "checkbox":
520
+			case "group":
521
+			case "group_multi":
522
+			case "longdate":
523
+				return $value;
524
+
525
+			case "date":
526
+				if ($value != "") {
527
+					return strtotime($value);
528
+				}
529
+				return $value;
530
+				break;
531
+
532
+			case "datetime":
533
+				if (!empty($value)) {
534
+					return strtotime($value['date']) + intval($value['time']);
535
+				}
536
+				return $value;
537
+				break;
538
+		}
539
+	}
540
+
541
+	/**
542
+	 * Get names of user variables
543
+	 *
544
+	 * @return array
545
+	 */
546
+	function getPostVars()
547
+	{
548
+		$objects_handler = xoops_getmodulehandler('extras', 'songlist');
549
+		return $objects_handler->getPostVars();
550
+	}
551 551
 }
552 552
 
553 553
 /**
@@ -556,229 +556,229 @@  discard block
 block discarded – undo
556 556
  */
557 557
 class SonglistFieldHandler extends XoopsPersistableObjectHandler
558 558
 {
559
-    function __construct($db)
560
-    {
561
-        parent::__construct($db, 'songlist_field', "SonglistField", "field_id", 'field_title');
562
-    }
563
-
564
-    /**
565
-    * Read field information from cached storage
566
-    *
567
-    * @param bool   $force_update   read fields from database and not cached storage
568
-    *
569
-    * @return array
570
-    */
571
-    function loadFields($force_update = false)
572
-    {
573
-        static $fields = array();
574
-        if (!empty($force_update) || count($fields) == 0) {
575
-            $criteria = new Criteria('field_id', 0, "!=");
576
-            $criteria->setSort('field_weight');
577
-            if ($this->getCount($criteria)==0)
578
-            	return false;
579
-            $field_objs = $this->getObjects($criteria);
580
-            foreach (array_keys($field_objs) as $i ) {
581
-                $fields[$field_objs[$i]->getVar('field_name')] = $field_objs[$i];
582
-            }
583
-        }
584
-        return $fields;
585
-    }
586
-
587
-    /**
588
-    * save a profile field in the database
589
-    *
590
-    * @param object $obj reference to the object
591
-    * @param bool $force whether to force the query execution despite security settings
592
-    * @param bool $checkObject check if the object is dirty and clean the attributes
593
-    * @return bool FALSE if failed, TRUE if already present and unchanged or successful
594
-    */
595
-    function insert($obj, $force = false)
596
-    {
597
-        $objects_handler = xoops_getmodulehandler('extras', 'songlist');
598
-        $obj->setVar('field_name', str_replace(' ', '_', $obj->getVar('field_name')));
599
-        $obj->cleanVars();
600
-        $defaultstring = "";
601
-        switch ($obj->getVar('field_type')  ) {
602
-            case "datetime":
603
-            case "date":
604
-                $obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
605
-                $obj->setVar('field_maxlength', 10);
606
-                break;
607
-
608
-            case "longdate":
609
-                $obj->setVar('field_valuetype', XOBJ_DTYPE_MTIME);
610
-                break;
611
-
612
-            case "yesno":
613
-                $obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
614
-                $obj->setVar('field_maxlength', 1);
615
-                break;
616
-
617
-            case "textbox":
618
-                if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
619
-                    $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
620
-                }
621
-                break;
622
-
623
-            case "autotext":
624
-                if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
625
-                    $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
626
-                }
627
-                break;
628
-
629
-            case "group_multi":
630
-            case "select_multi":
631
-            case "checkbox":
632
-                $obj->setVar('field_valuetype', XOBJ_DTYPE_ARRAY);
633
-                break;
634
-
635
-            case "language":
636
-            case "timezone":
637
-            case "theme":
638
-                $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
639
-                break;
640
-
641
-            case "dhtml":
642
-            case "textarea":
643
-                $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
644
-                break;
645
-        }
646
-
647
-        if ($obj->getVar('field_valuetype') == "") {
648
-            $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
649
-        }
650
-
651
-        if (!in_array($obj->getVar('field_name'), $this->getPostVars())) {
652
-            if ($obj->isNew()) {
653
-                //add column to table
654
-                $changetype = "ADD";
655
-            } else {
656
-                //update column information
657
-                $changetype = "CHANGE `" . $obj->getVar('field_name', 'n') . "`";
658
-            }
659
-            $maxlengthstring = $obj->getVar('field_maxlength') > 0 ? "(" . $obj->getVar('field_maxlength') . ")" : "";
660
-            $notnullstring = " NOT NULL";
661
-            //set type
662
-            switch ($obj->getVar('field_valuetype')) {
663
-                default:
664
-                case XOBJ_DTYPE_ARRAY:
665
-                case XOBJ_DTYPE_UNICODE_ARRAY:
666
-                    $type = "mediumtext";
667
-                    break;
668
-                case XOBJ_DTYPE_UNICODE_EMAIL:
669
-                case XOBJ_DTYPE_UNICODE_TXTBOX:
670
-                case XOBJ_DTYPE_UNICODE_URL:
671
-                case XOBJ_DTYPE_EMAIL:
672
-                case XOBJ_DTYPE_TXTBOX:
673
-                case XOBJ_DTYPE_URL:
674
-                    $type = "varchar";
675
-                    // varchars must have a maxlength
676
-                    if (!$maxlengthstring) {
677
-                        //so set it to max if maxlength is not set - or should it fail?
678
-                        $maxlengthstring = "(255)";
679
-                        $obj->setVar('field_maxlength', 255);
680
-                    }
681
-                    //if ( $obj->getVar('field_default')  ) {
682
-                        $defaultstring = " DEFAULT " . $this->db->quote($obj->cleanVars['field_default']);
683
-                    //}
684
-                    break;
685
-
686
-                case XOBJ_DTYPE_INT:
687
-                    $type = "int";
688
-                    if ($obj->getVar('field_default') || $obj->getVar('field_default') !== '') {
689
-                        $defaultstring = " DEFAULT '" . intval($obj->cleanVars['field_default']) . "'";
690
-                        $obj->setVar('field_default', intval($obj->cleanVars['field_default']));
691
-                    }
692
-                    break;
693
-
694
-                case XOBJ_DTYPE_DECIMAL:
695
-                    $type = "decimal(14,6)";
696
-                    if ($obj->getVar('field_default') || $obj->getVar('field_default') !== '') {
697
-                        $defaultstring = " DEFAULT '" . doubleval($obj->cleanVars['field_default']) . "'";
698
-                        $obj->setVar('field_default', doubleval($obj->cleanVars['field_default']));
699
-                    }
700
-                    break;
701
-
702
-                case XOBJ_DTYPE_FLOAT:
703
-                    $type = "float(15,9)";
704
-                    if ($obj->getVar('field_default') || $obj->getVar('field_default') !== '') {
705
-                        $defaultstring = " DEFAULT '" . floatval($obj->cleanVars['field_default']) . "'";
706
-                        $obj->setVar('field_default', floatval($obj->cleanVars['field_default']));
707
-                    }
708
-                    break;
709
-
710
-                case XOBJ_DTYPE_OTHER:
711
-                case XOBJ_DTYPE_UNICODE_TXTAREA:
712
-                case XOBJ_DTYPE_TXTAREA:
713
-                    $type = "text";
714
-                    $maxlengthstring = "";
715
-                    $notnullstring = "";
716
-                    break;
717
-
718
-                case XOBJ_DTYPE_MTIME:
719
-                    $type = "date";
720
-                    $maxlengthstring = "";
721
-                    break;
722
-            }
723
-
724
-            $sql = "ALTER TABLE `" . $objects_handler->table . "` " .
725
-            $changetype . " `" . $obj->cleanVars['field_name'] . "` " . $type . $maxlengthstring . $notnullstring . $defaultstring;
726
-            if (!$this->db->query($sql)) {
727
-                return false;
728
-            }
729
-        }
730
-
731
-        //change this to also update the cached field information storage
732
-        $obj->setDirty();
733
-        if (!parent::insert($obj, $force)) {
734
-            return false;
735
-        }
736
-        return $obj->getVar('field_id');
737
-
738
-    }
739
-
740
-    /**
741
-    * delete a profile field from the database
742
-    *
743
-    * @param object $obj reference to the object to delete
744
-    * @param bool $force
745
-    * @return bool FALSE if failed.
746
-    **/
747
-    function delete($obj, $force = false)
748
-    {
749
-        $objects_handler = xoops_getmodulehandler('extras', 'songlist');
750
-        // remove column from table
751
-        $sql = "ALTER TABLE " . $objects_handler->table . " DROP `" . $obj->getVar('field_name', 'n') . "`";
752
-        if ($this->db->query($sql)) {
753
-            //change this to update the cached field information storage
754
-            if (!parent::delete($obj, $force)) {
755
-                return false;
756
-            }
757
-
758
-            if ($obj->getVar('field_show') || $obj->getVar('field_edit')) {
759
-                $module_handler = xoops_gethandler('module');
760
-                $objects_module = $module_handler->getByDirname('profile');
761
-                if (is_object($objects_module)) {
762
-                    // Remove group permissions
763
-                    $groupperm_handler = xoops_gethandler('groupperm');
764
-                    $criteria = new CriteriaCompo(new Criteria('gperm_modid', $objects_module->getVar('mid')));
765
-                    $criteria->add(new Criteria('gperm_itemid', $obj->getVar('field_id')));
766
-                    return $groupperm_handler->deleteAll($criteria);
767
-                }
768
-            }
769
-        }
770
-        return false;
771
-    }
772
-
773
-    /**
774
-     * Get array of standard variable names (song table)
775
-     *
776
-     * @return array
777
-     */
778
-    function getPostVars()
779
-    {
780
-        return array('sid', 'cid', 'gid', 'aids', 'abid', 'songid', 'traxid', 'title', 'lyrics', 'hits', 'rank', 'votes', 'tags',
559
+	function __construct($db)
560
+	{
561
+		parent::__construct($db, 'songlist_field', "SonglistField", "field_id", 'field_title');
562
+	}
563
+
564
+	/**
565
+	 * Read field information from cached storage
566
+	 *
567
+	 * @param bool   $force_update   read fields from database and not cached storage
568
+	 *
569
+	 * @return array
570
+	 */
571
+	function loadFields($force_update = false)
572
+	{
573
+		static $fields = array();
574
+		if (!empty($force_update) || count($fields) == 0) {
575
+			$criteria = new Criteria('field_id', 0, "!=");
576
+			$criteria->setSort('field_weight');
577
+			if ($this->getCount($criteria)==0)
578
+				return false;
579
+			$field_objs = $this->getObjects($criteria);
580
+			foreach (array_keys($field_objs) as $i ) {
581
+				$fields[$field_objs[$i]->getVar('field_name')] = $field_objs[$i];
582
+			}
583
+		}
584
+		return $fields;
585
+	}
586
+
587
+	/**
588
+	 * save a profile field in the database
589
+	 *
590
+	 * @param object $obj reference to the object
591
+	 * @param bool $force whether to force the query execution despite security settings
592
+	 * @param bool $checkObject check if the object is dirty and clean the attributes
593
+	 * @return bool FALSE if failed, TRUE if already present and unchanged or successful
594
+	 */
595
+	function insert($obj, $force = false)
596
+	{
597
+		$objects_handler = xoops_getmodulehandler('extras', 'songlist');
598
+		$obj->setVar('field_name', str_replace(' ', '_', $obj->getVar('field_name')));
599
+		$obj->cleanVars();
600
+		$defaultstring = "";
601
+		switch ($obj->getVar('field_type')  ) {
602
+			case "datetime":
603
+			case "date":
604
+				$obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
605
+				$obj->setVar('field_maxlength', 10);
606
+				break;
607
+
608
+			case "longdate":
609
+				$obj->setVar('field_valuetype', XOBJ_DTYPE_MTIME);
610
+				break;
611
+
612
+			case "yesno":
613
+				$obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
614
+				$obj->setVar('field_maxlength', 1);
615
+				break;
616
+
617
+			case "textbox":
618
+				if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
619
+					$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
620
+				}
621
+				break;
622
+
623
+			case "autotext":
624
+				if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
625
+					$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
626
+				}
627
+				break;
628
+
629
+			case "group_multi":
630
+			case "select_multi":
631
+			case "checkbox":
632
+				$obj->setVar('field_valuetype', XOBJ_DTYPE_ARRAY);
633
+				break;
634
+
635
+			case "language":
636
+			case "timezone":
637
+			case "theme":
638
+				$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
639
+				break;
640
+
641
+			case "dhtml":
642
+			case "textarea":
643
+				$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
644
+				break;
645
+		}
646
+
647
+		if ($obj->getVar('field_valuetype') == "") {
648
+			$obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
649
+		}
650
+
651
+		if (!in_array($obj->getVar('field_name'), $this->getPostVars())) {
652
+			if ($obj->isNew()) {
653
+				//add column to table
654
+				$changetype = "ADD";
655
+			} else {
656
+				//update column information
657
+				$changetype = "CHANGE `" . $obj->getVar('field_name', 'n') . "`";
658
+			}
659
+			$maxlengthstring = $obj->getVar('field_maxlength') > 0 ? "(" . $obj->getVar('field_maxlength') . ")" : "";
660
+			$notnullstring = " NOT NULL";
661
+			//set type
662
+			switch ($obj->getVar('field_valuetype')) {
663
+				default:
664
+				case XOBJ_DTYPE_ARRAY:
665
+				case XOBJ_DTYPE_UNICODE_ARRAY:
666
+					$type = "mediumtext";
667
+					break;
668
+				case XOBJ_DTYPE_UNICODE_EMAIL:
669
+				case XOBJ_DTYPE_UNICODE_TXTBOX:
670
+				case XOBJ_DTYPE_UNICODE_URL:
671
+				case XOBJ_DTYPE_EMAIL:
672
+				case XOBJ_DTYPE_TXTBOX:
673
+				case XOBJ_DTYPE_URL:
674
+					$type = "varchar";
675
+					// varchars must have a maxlength
676
+					if (!$maxlengthstring) {
677
+						//so set it to max if maxlength is not set - or should it fail?
678
+						$maxlengthstring = "(255)";
679
+						$obj->setVar('field_maxlength', 255);
680
+					}
681
+					//if ( $obj->getVar('field_default')  ) {
682
+						$defaultstring = " DEFAULT " . $this->db->quote($obj->cleanVars['field_default']);
683
+					//}
684
+					break;
685
+
686
+				case XOBJ_DTYPE_INT:
687
+					$type = "int";
688
+					if ($obj->getVar('field_default') || $obj->getVar('field_default') !== '') {
689
+						$defaultstring = " DEFAULT '" . intval($obj->cleanVars['field_default']) . "'";
690
+						$obj->setVar('field_default', intval($obj->cleanVars['field_default']));
691
+					}
692
+					break;
693
+
694
+				case XOBJ_DTYPE_DECIMAL:
695
+					$type = "decimal(14,6)";
696
+					if ($obj->getVar('field_default') || $obj->getVar('field_default') !== '') {
697
+						$defaultstring = " DEFAULT '" . doubleval($obj->cleanVars['field_default']) . "'";
698
+						$obj->setVar('field_default', doubleval($obj->cleanVars['field_default']));
699
+					}
700
+					break;
701
+
702
+				case XOBJ_DTYPE_FLOAT:
703
+					$type = "float(15,9)";
704
+					if ($obj->getVar('field_default') || $obj->getVar('field_default') !== '') {
705
+						$defaultstring = " DEFAULT '" . floatval($obj->cleanVars['field_default']) . "'";
706
+						$obj->setVar('field_default', floatval($obj->cleanVars['field_default']));
707
+					}
708
+					break;
709
+
710
+				case XOBJ_DTYPE_OTHER:
711
+				case XOBJ_DTYPE_UNICODE_TXTAREA:
712
+				case XOBJ_DTYPE_TXTAREA:
713
+					$type = "text";
714
+					$maxlengthstring = "";
715
+					$notnullstring = "";
716
+					break;
717
+
718
+				case XOBJ_DTYPE_MTIME:
719
+					$type = "date";
720
+					$maxlengthstring = "";
721
+					break;
722
+			}
723
+
724
+			$sql = "ALTER TABLE `" . $objects_handler->table . "` " .
725
+			$changetype . " `" . $obj->cleanVars['field_name'] . "` " . $type . $maxlengthstring . $notnullstring . $defaultstring;
726
+			if (!$this->db->query($sql)) {
727
+				return false;
728
+			}
729
+		}
730
+
731
+		//change this to also update the cached field information storage
732
+		$obj->setDirty();
733
+		if (!parent::insert($obj, $force)) {
734
+			return false;
735
+		}
736
+		return $obj->getVar('field_id');
737
+
738
+	}
739
+
740
+	/**
741
+	 * delete a profile field from the database
742
+	 *
743
+	 * @param object $obj reference to the object to delete
744
+	 * @param bool $force
745
+	 * @return bool FALSE if failed.
746
+	 **/
747
+	function delete($obj, $force = false)
748
+	{
749
+		$objects_handler = xoops_getmodulehandler('extras', 'songlist');
750
+		// remove column from table
751
+		$sql = "ALTER TABLE " . $objects_handler->table . " DROP `" . $obj->getVar('field_name', 'n') . "`";
752
+		if ($this->db->query($sql)) {
753
+			//change this to update the cached field information storage
754
+			if (!parent::delete($obj, $force)) {
755
+				return false;
756
+			}
757
+
758
+			if ($obj->getVar('field_show') || $obj->getVar('field_edit')) {
759
+				$module_handler = xoops_gethandler('module');
760
+				$objects_module = $module_handler->getByDirname('profile');
761
+				if (is_object($objects_module)) {
762
+					// Remove group permissions
763
+					$groupperm_handler = xoops_gethandler('groupperm');
764
+					$criteria = new CriteriaCompo(new Criteria('gperm_modid', $objects_module->getVar('mid')));
765
+					$criteria->add(new Criteria('gperm_itemid', $obj->getVar('field_id')));
766
+					return $groupperm_handler->deleteAll($criteria);
767
+				}
768
+			}
769
+		}
770
+		return false;
771
+	}
772
+
773
+	/**
774
+	 * Get array of standard variable names (song table)
775
+	 *
776
+	 * @return array
777
+	 */
778
+	function getPostVars()
779
+	{
780
+		return array('sid', 'cid', 'gid', 'aids', 'abid', 'songid', 'traxid', 'title', 'lyrics', 'hits', 'rank', 'votes', 'tags',
781 781
  					 'created', 'updated');
782
-    }
782
+	}
783 783
 }
784 784
 ?>
785 785
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         $this->initVar('field_edit', XOBJ_DTYPE_INT, 0);
27 27
         $this->initVar('field_show', XOBJ_DTYPE_INT, 0);
28 28
         $this->initVar('field_config', XOBJ_DTYPE_INT, 0);
29
-        $this->initVar('field_options', XOBJ_DTYPE_ARRAY, array() );
29
+        $this->initVar('field_options', XOBJ_DTYPE_ARRAY, array());
30 30
     }
31 31
 
32 32
 
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
      */
43 43
     function setVar($key, $value, $not_gpc = false)
44 44
     {
45
-        if ($key == 'field_options' && is_array($value)) {
46
-            foreach (array_keys($value) as $idx ) {
45
+        if ($key=='field_options' && is_array($value)) {
46
+            foreach (array_keys($value) as $idx) {
47 47
                 $value[$idx] = base64_encode($value[$idx]);
48 48
             }
49 49
         }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     function getVar($key, $format = 's')
54 54
     {
55 55
         $value = parent::getVar($key, $format);
56
-        if ($key == 'field_options' && !empty($value)) {
56
+        if ($key=='field_options' && !empty($value)) {
57 57
             foreach (array_keys($value) as $idx) {
58 58
                 $value[$idx] = base64_decode($value[$idx]);
59 59
             }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     **/
72 72
     function getEditElement($user, $profile)
73 73
     {
74
-        $value = in_array($this->getVar('field_name'), $this->getPostVars() ) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
74
+        $value = in_array($this->getVar('field_name'), $this->getPostVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
75 75
         if (is_null($value)) {
76 76
             $value = $this->getVar('field_default');
77 77
         }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             }
91 91
         }
92 92
         include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
93
-        switch ($this->getVar('field_type')  ) {
93
+        switch ($this->getVar('field_type')) {
94 94
             default:
95 95
             case "autotext":
96 96
                 //autotext is not for editing
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
                 if (!in_array('', array_keys($options))) {
126 126
                     $element->addOption('', _NONE);
127 127
                     //trabis
128
-                    if ($this->getVar('field_required') == 1) {
129
-                        $eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf( _FORM_ENTER, $caption);
128
+                    if ($this->getVar('field_required')==1) {
129
+                        $eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf(_FORM_ENTER, $caption);
130 130
                         $eltmsg = str_replace('"', '\"', stripslashes($eltmsg));
131
-                        $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" .
132
-                            "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" .
131
+                        $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};".
132
+                            "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }".
133 133
                             "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
134 134
                     }
135 135
                 }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                 break;
173 173
 
174 174
             case "longdate":
175
-                $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value) );
175
+                $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
176 176
                 break;
177 177
 
178 178
             case "datetime":
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
             case 'theme':
201 201
                 $element = new XoopsFormSelect($caption, $name, $value);
202 202
                 $element->addOption("0", _OBJS_MF_SITEDEFAULT);
203
-                $handle = opendir(XOOPS_THEME_PATH . '/');
203
+                $handle = opendir(XOOPS_THEME_PATH.'/');
204 204
                 $dirlist = array();
205
-                while (false !== ($file = readdir($handle) ) ) {
206
-                    if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) != 'cvs' ) {
207
-                        if (file_exists(XOOPS_THEME_PATH . "/" . $file . "/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
205
+                while (false!==($file = readdir($handle))) {
206
+                    if (is_dir(XOOPS_THEME_PATH.'/'.$file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file)!='cvs') {
207
+                        if (file_exists(XOOPS_THEME_PATH."/".$file."/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
208 208
                             $dirlist[$file] = $file;
209 209
                         }
210 210
                     }
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
                 }
217 217
                 break;
218 218
         }
219
-        if ($this->getVar('field_description') != "") {
220
-            $element->setDescription($this->getVar('field_description') );
219
+        if ($this->getVar('field_description')!="") {
220
+            $element->setDescription($this->getVar('field_description'));
221 221
         }
222 222
         return $element;
223 223
     }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             }
248 248
         }
249 249
         include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
250
-        switch ($this->getVar('field_type')  ) {
250
+        switch ($this->getVar('field_type')) {
251 251
             default:
252 252
             case "autotext":
253 253
                 //autotext is not for editing
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
                 if (!in_array('', array_keys($options))) {
273 273
                     $element->addOption('', _NONE);
274 274
                     //trabis
275
-                    if ($this->getVar('field_required') == 1) {
276
-                        $eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf( _FORM_ENTER, $caption);
275
+                    if ($this->getVar('field_required')==1) {
276
+                        $eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf(_FORM_ENTER, $caption);
277 277
                         $eltmsg = str_replace('"', '\"', stripslashes($eltmsg));
278
-                        $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" .
279
-                            "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" .
278
+                        $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};".
279
+                            "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }".
280 280
                             "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
281 281
                     }
282 282
                     //end
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
                 break;
327 327
 
328 328
             case "longdate":
329
-                $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value) );
329
+                $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
330 330
                 break;
331 331
 
332 332
             case "datetime":
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
             case 'theme':
355 355
                 $element = new XoopsFormSelect($caption, $name, $value);
356 356
                 $element->addOption("0", _OBJS_MF_SITEDEFAULT);
357
-                $handle = opendir(XOOPS_THEME_PATH . '/');
357
+                $handle = opendir(XOOPS_THEME_PATH.'/');
358 358
                 $dirlist = array();
359
-                while (false !== ($file = readdir($handle) ) ) {
360
-                    if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) != 'cvs' ) {
361
-                        if (file_exists(XOOPS_THEME_PATH . "/" . $file . "/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
359
+                while (false!==($file = readdir($handle))) {
360
+                    if (is_dir(XOOPS_THEME_PATH.'/'.$file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file)!='cvs') {
361
+                        if (file_exists(XOOPS_THEME_PATH."/".$file."/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
362 362
                             $dirlist[$file] = $file;
363 363
                         }
364 364
                     }
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
                 }
371 371
                 break;
372 372
         }
373
-        if ($this->getVar('field_description') != "") {
374
-            $element->setDescription($this->getVar('field_description') );
373
+        if ($this->getVar('field_description')!="") {
374
+            $element->setDescription($this->getVar('field_description'));
375 375
         }
376 376
         return $element;
377 377
     }
@@ -386,19 +386,19 @@  discard block
 block discarded – undo
386 386
     **/
387 387
     function getOutputValue($user, $profile)
388 388
     {
389
-        if (file_exists($file = $GLOBALS['xoops']->path('modules/objects/language/' . $GLOBALS['xoopsConfig']['language'] . '/modinfo.php'))) {
389
+        if (file_exists($file = $GLOBALS['xoops']->path('modules/objects/language/'.$GLOBALS['xoopsConfig']['language'].'/modinfo.php'))) {
390 390
             include_once $file;
391 391
         } else {
392 392
             include_once $GLOBALS['xoops']->path('modules/objects/language/english/modinfo.php');
393 393
         }
394 394
 
395
-        $value = in_array($this->getVar('field_name'), $this->getPostVars() ) ? $user->getVar($this->getVar('field_name') ) : $profile->getVar($this->getVar('field_name'));
395
+        $value = in_array($this->getVar('field_name'), $this->getPostVars()) ? $user->getVar($this->getVar('field_name')) : $profile->getVar($this->getVar('field_name'));
396 396
 
397
-        switch ($this->getVar('field_type')  ) {
397
+        switch ($this->getVar('field_type')) {
398 398
             default:
399 399
             case "textbox":
400
-                if ( $this->getVar('field_name') == 'url' && $value != '') {
401
-                     return '<a href="' . formatURL($value) . '" rel="external">' . $value . '</a>';
400
+                if ($this->getVar('field_name')=='url' && $value!='') {
401
+                     return '<a href="'.formatURL($value).'" rel="external">'.$value.'</a>';
402 402
                    } else {
403 403
                      return $value;
404 404
                 }
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
             case "radio":
417 417
                 $options = $this->getVar('field_options');
418 418
                 if (isset($options[$value])) {
419
-                    $value = htmlspecialchars( defined($options[$value]) ? constant($options[$value]) : $options[$value]);
419
+                    $value = htmlspecialchars(defined($options[$value]) ? constant($options[$value]) : $options[$value]);
420 420
                 } else {
421 421
                     $value = "";
422 422
                 }
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
             case "checkbox":
428 428
                 $options = $this->getVar('field_options');
429 429
                 $ret = array();
430
-                if (count($options) > 0) {
430
+                if (count($options)>0) {
431 431
                     foreach (array_keys($options) as $key) {
432 432
                         if (in_array($key, $value)) {
433
-                            $$ret[$key] = htmlspecialchars( defined($options[$key]) ? constant($options[$key]) : $options[$key]);
433
+                            $$ret[$key] = htmlspecialchars(defined($options[$key]) ? constant($options[$key]) : $options[$key]);
434 434
                         }
435 435
                     }
436 436
                 }
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
             case "autotext":
468 468
                 $value = $user->getVar($this->getVar('field_name'), 'n'); //autotext can have HTML in it
469 469
                 $value = str_replace("{X_UID}", $user->getVar("uid"), $value);
470
-                $value = str_replace("{X_URL}", XOOPS_URL, $value );
470
+                $value = str_replace("{X_URL}", XOOPS_URL, $value);
471 471
                 $value = str_replace("{X_UNAME}", $user->getVar("uname"), $value);
472 472
                 return $value;
473 473
                 break;
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
             case "rank":
476 476
                 $userrank = $user->rank();
477 477
                 $user_rankimage = "";
478
-                if (isset($userrank['image']) && $userrank['image'] != "") {
479
-                    $user_rankimage = '<img src="'.XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="' . $userrank['title'] . '" /><br />';
478
+                if (isset($userrank['image']) && $userrank['image']!="") {
479
+                    $user_rankimage = '<img src="'.XOOPS_UPLOAD_URL.'/'.$userrank['image'].'" alt="'.$userrank['title'].'" /><br />';
480 480
                 }
481 481
                 return $user_rankimage.$userrank['title'];
482 482
                 break;
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                 return $value;
524 524
 
525 525
             case "date":
526
-                if ($value != "") {
526
+                if ($value!="") {
527 527
                     return strtotime($value);
528 528
                 }
529 529
                 return $value;
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 
532 532
             case "datetime":
533 533
                 if (!empty($value)) {
534
-                    return strtotime($value['date']) + intval($value['time']);
534
+                    return strtotime($value['date'])+intval($value['time']);
535 535
                 }
536 536
                 return $value;
537 537
                 break;
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
     function loadFields($force_update = false)
572 572
     {
573 573
         static $fields = array();
574
-        if (!empty($force_update) || count($fields) == 0) {
574
+        if (!empty($force_update) || count($fields)==0) {
575 575
             $criteria = new Criteria('field_id', 0, "!=");
576 576
             $criteria->setSort('field_weight');
577 577
             if ($this->getCount($criteria)==0)
578 578
             	return false;
579 579
             $field_objs = $this->getObjects($criteria);
580
-            foreach (array_keys($field_objs) as $i ) {
580
+            foreach (array_keys($field_objs) as $i) {
581 581
                 $fields[$field_objs[$i]->getVar('field_name')] = $field_objs[$i];
582 582
             }
583 583
         }
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
         $obj->setVar('field_name', str_replace(' ', '_', $obj->getVar('field_name')));
599 599
         $obj->cleanVars();
600 600
         $defaultstring = "";
601
-        switch ($obj->getVar('field_type')  ) {
601
+        switch ($obj->getVar('field_type')) {
602 602
             case "datetime":
603 603
             case "date":
604 604
                 $obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
@@ -615,13 +615,13 @@  discard block
 block discarded – undo
615 615
                 break;
616 616
 
617 617
             case "textbox":
618
-                if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
618
+                if ($obj->getVar('field_valuetype')!=XOBJ_DTYPE_INT) {
619 619
                     $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
620 620
                 }
621 621
                 break;
622 622
 
623 623
             case "autotext":
624
-                if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
624
+                if ($obj->getVar('field_valuetype')!=XOBJ_DTYPE_INT) {
625 625
                     $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
626 626
                 }
627 627
                 break;
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
                 break;
645 645
         }
646 646
 
647
-        if ($obj->getVar('field_valuetype') == "") {
647
+        if ($obj->getVar('field_valuetype')=="") {
648 648
             $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
649 649
         }
650 650
 
@@ -654,9 +654,9 @@  discard block
 block discarded – undo
654 654
                 $changetype = "ADD";
655 655
             } else {
656 656
                 //update column information
657
-                $changetype = "CHANGE `" . $obj->getVar('field_name', 'n') . "`";
657
+                $changetype = "CHANGE `".$obj->getVar('field_name', 'n')."`";
658 658
             }
659
-            $maxlengthstring = $obj->getVar('field_maxlength') > 0 ? "(" . $obj->getVar('field_maxlength') . ")" : "";
659
+            $maxlengthstring = $obj->getVar('field_maxlength')>0 ? "(".$obj->getVar('field_maxlength').")" : "";
660 660
             $notnullstring = " NOT NULL";
661 661
             //set type
662 662
             switch ($obj->getVar('field_valuetype')) {
@@ -679,30 +679,30 @@  discard block
 block discarded – undo
679 679
                         $obj->setVar('field_maxlength', 255);
680 680
                     }
681 681
                     //if ( $obj->getVar('field_default')  ) {
682
-                        $defaultstring = " DEFAULT " . $this->db->quote($obj->cleanVars['field_default']);
682
+                        $defaultstring = " DEFAULT ".$this->db->quote($obj->cleanVars['field_default']);
683 683
                     //}
684 684
                     break;
685 685
 
686 686
                 case XOBJ_DTYPE_INT:
687 687
                     $type = "int";
688
-                    if ($obj->getVar('field_default') || $obj->getVar('field_default') !== '') {
689
-                        $defaultstring = " DEFAULT '" . intval($obj->cleanVars['field_default']) . "'";
688
+                    if ($obj->getVar('field_default') || $obj->getVar('field_default')!=='') {
689
+                        $defaultstring = " DEFAULT '".intval($obj->cleanVars['field_default'])."'";
690 690
                         $obj->setVar('field_default', intval($obj->cleanVars['field_default']));
691 691
                     }
692 692
                     break;
693 693
 
694 694
                 case XOBJ_DTYPE_DECIMAL:
695 695
                     $type = "decimal(14,6)";
696
-                    if ($obj->getVar('field_default') || $obj->getVar('field_default') !== '') {
697
-                        $defaultstring = " DEFAULT '" . doubleval($obj->cleanVars['field_default']) . "'";
696
+                    if ($obj->getVar('field_default') || $obj->getVar('field_default')!=='') {
697
+                        $defaultstring = " DEFAULT '".doubleval($obj->cleanVars['field_default'])."'";
698 698
                         $obj->setVar('field_default', doubleval($obj->cleanVars['field_default']));
699 699
                     }
700 700
                     break;
701 701
 
702 702
                 case XOBJ_DTYPE_FLOAT:
703 703
                     $type = "float(15,9)";
704
-                    if ($obj->getVar('field_default') || $obj->getVar('field_default') !== '') {
705
-                        $defaultstring = " DEFAULT '" . floatval($obj->cleanVars['field_default']) . "'";
704
+                    if ($obj->getVar('field_default') || $obj->getVar('field_default')!=='') {
705
+                        $defaultstring = " DEFAULT '".floatval($obj->cleanVars['field_default'])."'";
706 706
                         $obj->setVar('field_default', floatval($obj->cleanVars['field_default']));
707 707
                     }
708 708
                     break;
@@ -721,8 +721,8 @@  discard block
 block discarded – undo
721 721
                     break;
722 722
             }
723 723
 
724
-            $sql = "ALTER TABLE `" . $objects_handler->table . "` " .
725
-            $changetype . " `" . $obj->cleanVars['field_name'] . "` " . $type . $maxlengthstring . $notnullstring . $defaultstring;
724
+            $sql = "ALTER TABLE `".$objects_handler->table."` ".
725
+            $changetype." `".$obj->cleanVars['field_name']."` ".$type.$maxlengthstring.$notnullstring.$defaultstring;
726 726
             if (!$this->db->query($sql)) {
727 727
                 return false;
728 728
             }
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
     {
749 749
         $objects_handler = xoops_getmodulehandler('extras', 'songlist');
750 750
         // remove column from table
751
-        $sql = "ALTER TABLE " . $objects_handler->table . " DROP `" . $obj->getVar('field_name', 'n') . "`";
751
+        $sql = "ALTER TABLE ".$objects_handler->table." DROP `".$obj->getVar('field_name', 'n')."`";
752 752
         if ($this->db->query($sql)) {
753 753
             //change this to update the cached field information storage
754 754
             if (!parent::delete($obj, $force)) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -574,8 +574,9 @@
 block discarded – undo
574 574
         if (!empty($force_update) || count($fields) == 0) {
575 575
             $criteria = new Criteria('field_id', 0, "!=");
576 576
             $criteria->setSort('field_weight');
577
-            if ($this->getCount($criteria)==0)
578
-            	return false;
577
+            if ($this->getCount($criteria)==0) {
578
+                        	return false;
579
+            }
579 580
             $field_objs = $this->getObjects($criteria);
580 581
             foreach (array_keys($field_objs) as $i ) {
581 582
                 $fields[$field_objs[$i]->getVar('field_name')] = $field_objs[$i];
Please login to merge, or discard this patch.
htdocs/modules/songlist/class/voice.php 3 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
 class SonglistVoice extends XoopsObject
11 11
 {
12 12
 
13
-    function SonglistVoice($fid = null)
14
-    {
15
-        $this->initVar('vcid', XOBJ_DTYPE_INT, 0, false);
13
+	function SonglistVoice($fid = null)
14
+	{
15
+		$this->initVar('vcid', XOBJ_DTYPE_INT, 0, false);
16 16
 		$this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 128);
17 17
 		$this->initVar('artists', XOBJ_DTYPE_INT, 0, false);
18 18
 		$this->initVar('albums', XOBJ_DTYPE_INT, 0, false);
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 	
48 48
 	function getURL() {
49
-    	global $file, $op, $fct, $id, $value, $gid, $vid, $cid, $start, $limit;
50
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
51
-    		return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $this->getVar('name'))).'/'.$op.'-'.$fct.'-'.$this->getVar('gid').'-'.urlencode($value).'-'.$gid.'-'.$vid.'-'.$cid.$GLOBALS['songlistModuleConfig']['endofurl'];
52
-    	} else {
53
-    		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$this->getVar('gid').'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid;
54
-    	}
55
-    }
49
+		global $file, $op, $fct, $id, $value, $gid, $vid, $cid, $start, $limit;
50
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
51
+			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $this->getVar('name'))).'/'.$op.'-'.$fct.'-'.$this->getVar('gid').'-'.urlencode($value).'-'.$gid.'-'.$vid.'-'.$cid.$GLOBALS['songlistModuleConfig']['endofurl'];
52
+		} else {
53
+			return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$this->getVar('gid').'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid;
54
+		}
55
+	}
56 56
 	
57 57
 	
58 58
 	
@@ -61,76 +61,76 @@  discard block
 block discarded – undo
61 61
 
62 62
 class SonglistVoiceHandler extends XoopsPersistableObjectHandler
63 63
 {
64
-    function __construct(&$db) 
65
-    {
66
-        parent::__construct($db, "songlist_voice", 'SonglistVoice', "vcid", "name");
67
-    }
64
+	function __construct(&$db) 
65
+	{
66
+		parent::__construct($db, "songlist_voice", 'SonglistVoice', "vcid", "name");
67
+	}
68 68
 
69 69
 	function filterFields() {
70 70
 		return array('vcid', 'name', 'artists', 'albums', 'songs', 'hits', 'rank', 'votes', 'created', 'updated');
71 71
 	}
72 72
 	
73
-    function getFilterCriteria($filter) {
74
-    	$parts = explode('|', $filter);
75
-    	$criteria = new CriteriaCompo();
76
-    	foreach($parts as $part) {
77
-    		$var = explode(',', $part);
78
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
79
-    			$object = $this->create();
80
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
81
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
82
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
83
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
84
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
85
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
86
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
73
+	function getFilterCriteria($filter) {
74
+		$parts = explode('|', $filter);
75
+		$criteria = new CriteriaCompo();
76
+		foreach($parts as $part) {
77
+			$var = explode(',', $part);
78
+			if (!empty($var[1])&&!is_numeric($var[0])) {
79
+				$object = $this->create();
80
+				if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
81
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
82
+					$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
83
+				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
84
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
85
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
86
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
87 87
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
88
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
88
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
89 89
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
90
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
90
+					$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
91 91
 				}
92
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
93
-    			$criteria->add(new Criteria($var[0], $var[1]));
94
-    		}
95
-    	}
96
-    	return $criteria;
97
-    }
92
+			} elseif (!empty($var[1])&&is_numeric($var[0])) {
93
+				$criteria->add(new Criteria($var[0], $var[1]));
94
+			}
95
+		}
96
+		return $criteria;
97
+	}
98 98
         
99
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
100
-    	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
101
-    	if (is_object($ele))
102
-    		return $ele->render();
103
-    	else 
104
-    		return '&nbsp;';
105
-    }
99
+	function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
100
+		$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
101
+		if (is_object($ele))
102
+			return $ele->render();
103
+		else 
104
+			return '&nbsp;';
105
+	}
106 106
     
107 107
 	function insert($obj, $force=true) {
108
-    	if ($obj->isNew()) {
109
-    		$obj->setVar('created', time());	
110
-    	} else {
111
-    		$obj->setVar('updated', time());
112
-    	}
113
-    	if (strlen($obj->getVar('name'))==0)
114
-    		return false;
115
-    	return parent::insert($obj, $force);
116
-    }
108
+		if ($obj->isNew()) {
109
+			$obj->setVar('created', time());	
110
+		} else {
111
+			$obj->setVar('updated', time());
112
+		}
113
+		if (strlen($obj->getVar('name'))==0)
114
+			return false;
115
+		return parent::insert($obj, $force);
116
+	}
117 117
      
118 118
 	var $_objects = array('object'=>array(), 'array'=>array());
119 119
     
120
-    function get($id, $fields = '*') {
121
-    	if (!isset($this->_objects['object'][$id])) {
122
-	    	$this->_objects['object'][$id] = parent::get($id, $fields);
123
-	    	if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
124
-		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
125
-		    	$GLOBALS['xoopsDB']->queryF($sql);
126
-	    	}
127
-    	}
128
-    	return $this->_objects['object'][$id];
129
-    }
120
+	function get($id, $fields = '*') {
121
+		if (!isset($this->_objects['object'][$id])) {
122
+			$this->_objects['object'][$id] = parent::get($id, $fields);
123
+			if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
124
+				$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
125
+				$GLOBALS['xoopsDB']->queryF($sql);
126
+			}
127
+		}
128
+		return $this->_objects['object'][$id];
129
+	}
130 130
     
131
-    function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
132
-    	$ret = parent::getObjects($criteria, $id_as_key, $as_object);
133
-    	/*if (!isset($GLOBALS['songlistAdmin'])) {
131
+	function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
132
+		$ret = parent::getObjects($criteria, $id_as_key, $as_object);
133
+		/*if (!isset($GLOBALS['songlistAdmin'])) {
134 134
 	    	$id = array();
135 135
 	    	foreach($ret as $data) {
136 136
 	    		if ($as_object==true) {
@@ -150,35 +150,35 @@  discard block
 block discarded – undo
150 150
 	    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` IN ('.implode(',', $id).')';
151 151
 	    	$GLOBALS['xoopsDB']->queryF($sql);
152 152
     	}*/
153
-    	return $ret;
154
-    }
153
+		return $ret;
154
+	}
155 155
 
156
-    function getURL() {
157
-    	global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
158
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
159
-    		return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseurl'].'/'.$file.'/'.$start.'-'.$op.'-'.$fct.'-'.$id.'-'.urlencode($value).'-'.$gid.'-'.$cid.$GLOBALS['songlistModuleConfig']['endofurl'];
160
-    	} else {
161
-    		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&cid='.$cid.'&start='.$start;
162
-    	}
163
-    }
156
+	function getURL() {
157
+		global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
158
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
159
+			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseurl'].'/'.$file.'/'.$start.'-'.$op.'-'.$fct.'-'.$id.'-'.urlencode($value).'-'.$gid.'-'.$cid.$GLOBALS['songlistModuleConfig']['endofurl'];
160
+		} else {
161
+			return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&cid='.$cid.'&start='.$start;
162
+		}
163
+	}
164 164
     
165 165
 	function getTop($limit=1) {
166
-    	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
167
-    	$results = $GLOBALS['xoopsDB']->queryF($sql);
168
-    	$ret = array();
169
-    	$i=0;
170
-    	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
171
-    		$ret[$i] = $this->create();
172
-    		$ret[$i]->assignVars($row);
173
-    		$i++;
174
-    	}
175
-    	return $ret;
176
-    }
166
+		$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
167
+		$results = $GLOBALS['xoopsDB']->queryF($sql);
168
+		$ret = array();
169
+		$i=0;
170
+		while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
171
+			$ret[$i] = $this->create();
172
+			$ret[$i]->assignVars($row);
173
+			$i++;
174
+		}
175
+		return $ret;
176
+	}
177 177
     
178 178
 	function delete($object, $force=true) {
179
-    	parent::delete($object, $force);
180
-    	$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `vcid` = 0 WHERE `vcid` = ' . $object->getVar('vcid');
181
-    	return $GLOBALS['xoopsDB']->queryF($sql);	
182
-    }
179
+		parent::delete($object, $force);
180
+		$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `vcid` = 0 WHERE `vcid` = ' . $object->getVar('vcid');
181
+		return $GLOBALS['xoopsDB']->queryF($sql);	
182
+	}
183 183
 }
184 184
 ?>
185 185
\ 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
@@ -31,16 +31,16 @@  discard block
 block discarded – undo
31 31
 	function toArray() {
32 32
 		$ret = parent::toArray();
33 33
 		$form = $this->getForm(true);
34
-		foreach($form as $key => $element) {
34
+		foreach ($form as $key => $element) {
35 35
 			$ret['form'][$key] = $form[$key]->render();	
36 36
 		}
37
-		foreach(array('created', 'updated') as $key) {
37
+		foreach (array('created', 'updated') as $key) {
38 38
 			if ($this->getVar($key)>0) {
39 39
 				$ret['form'][$key] = date(_DATESTRING, $this->getVar($key)); 
40 40
 				$ret[$key] = date(_DATESTRING, $this->getVar($key));
41 41
 			}
42 42
 		}
43
-		$ret['rank'] = number_format(($this->getVar('rank')>0&&$this->getVar('votes')>0?$this->getVar('rank')/$this->getVar('votes'):0),2)._MI_SONGLIST_OFTEN;
43
+		$ret['rank'] = number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2)._MI_SONGLIST_OFTEN;
44 44
     		
45 45
 		return $ret;
46 46
 	}
@@ -73,30 +73,30 @@  discard block
 block discarded – undo
73 73
     function getFilterCriteria($filter) {
74 74
     	$parts = explode('|', $filter);
75 75
     	$criteria = new CriteriaCompo();
76
-    	foreach($parts as $part) {
76
+    	foreach ($parts as $part) {
77 77
     		$var = explode(',', $part);
78
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
78
+    		if (!empty($var[1]) && !is_numeric($var[0])) {
79 79
     			$object = $this->create();
80
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
81
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
82
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
83
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
80
+    			if ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
81
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) {
82
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2]) ? $var[2] : 'LIKE')));
83
+    			} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
84 84
     						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
85
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
86
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
87
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
88
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
89
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
90
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
85
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT) {
86
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));			
87
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM) {
88
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));    				
89
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY) {
90
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2]) ? $var[2] : 'LIKE')));    				
91 91
 				}
92
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
92
+    		} elseif (!empty($var[1]) && is_numeric($var[0])) {
93 93
     			$criteria->add(new Criteria($var[0], $var[1]));
94 94
     		}
95 95
     	}
96 96
     	return $criteria;
97 97
     }
98 98
         
99
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
99
+    function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list') {
100 100
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
101 101
     	if (is_object($ele))
102 102
     		return $ele->render();
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     		return '&nbsp;';
105 105
     }
106 106
     
107
-	function insert($obj, $force=true) {
107
+	function insert($obj, $force = true) {
108 108
     	if ($obj->isNew()) {
109 109
     		$obj->setVar('created', time());	
110 110
     	} else {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     function get($id, $fields = '*') {
121 121
     	if (!isset($this->_objects['object'][$id])) {
122 122
 	    	$this->_objects['object'][$id] = parent::get($id, $fields);
123
-	    	if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
123
+	    	if (!isset($GLOBALS['songlistAdmin']) && is_object($this->_objects['object'][$id])) {
124 124
 		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
125 125
 		    	$GLOBALS['xoopsDB']->queryF($sql);
126 126
 	    	}
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
     	}
163 163
     }
164 164
     
165
-	function getTop($limit=1) {
165
+	function getTop($limit = 1) {
166 166
     	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
167 167
     	$results = $GLOBALS['xoopsDB']->queryF($sql);
168 168
     	$ret = array();
169
-    	$i=0;
169
+    	$i = 0;
170 170
     	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
171 171
     		$ret[$i] = $this->create();
172 172
     		$ret[$i]->assignVars($row);
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
     	return $ret;
176 176
     }
177 177
     
178
-	function delete($object, $force=true) {
178
+	function delete($object, $force = true) {
179 179
     	parent::delete($object, $force);
180
-    	$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `vcid` = 0 WHERE `vcid` = ' . $object->getVar('vcid');
180
+    	$sql = 'UPDATE '.$GLOBALS['xoopsDB']->prefix('songlist_songs').' SET `vcid` = 0 WHERE `vcid` = '.$object->getVar('vcid');
181 181
     	return $GLOBALS['xoopsDB']->queryF($sql);	
182 182
     }
183 183
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -98,10 +98,11 @@  discard block
 block discarded – undo
98 98
         
99 99
     function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
100 100
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
101
-    	if (is_object($ele))
102
-    		return $ele->render();
103
-    	else 
104
-    		return '&nbsp;';
101
+    	if (is_object($ele)) {
102
+    	    		return $ele->render();
103
+    	} else {
104
+    	    		return '&nbsp;';
105
+    	}
105 106
     }
106 107
     
107 108
 	function insert($obj, $force=true) {
@@ -110,8 +111,9 @@  discard block
 block discarded – undo
110 111
     	} else {
111 112
     		$obj->setVar('updated', time());
112 113
     	}
113
-    	if (strlen($obj->getVar('name'))==0)
114
-    		return false;
114
+    	if (strlen($obj->getVar('name'))==0) {
115
+    	    		return false;
116
+    	}
115 117
     	return parent::insert($obj, $force);
116 118
     }
117 119
      
Please login to merge, or discard this patch.
htdocs/modules/songlist/class/requests.php 3 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 class SonglistRequests extends XoopsObject
11 11
 {
12 12
 
13
-    function SonglistRequests($fid = null)
14
-    {
15
-        $this->initVar('rid', XOBJ_DTYPE_INT, 0, false);
16
-        $this->initVar('aid', XOBJ_DTYPE_INT, 0, false);
13
+	function SonglistRequests($fid = null)
14
+	{
15
+		$this->initVar('rid', XOBJ_DTYPE_INT, 0, false);
16
+		$this->initVar('aid', XOBJ_DTYPE_INT, 0, false);
17 17
 		$this->initVar('artist', XOBJ_DTYPE_TXTBOX, null, false, 128);
18 18
 		$this->initVar('album', XOBJ_DTYPE_TXTBOX, null, false, 128);
19 19
 		$this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false, 128);
@@ -52,75 +52,75 @@  discard block
 block discarded – undo
52 52
 
53 53
 class SonglistRequestsHandler extends XoopsPersistableObjectHandler
54 54
 {
55
-    function __construct(&$db) 
56
-    {
57
-        parent::__construct($db, "songlist_requests", 'SonglistRequests', "rid", "name");
58
-    }
55
+	function __construct(&$db) 
56
+	{
57
+		parent::__construct($db, "songlist_requests", 'SonglistRequests', "rid", "name");
58
+	}
59 59
 
60 60
 	function filterFields() {
61 61
 		return array('rid', 'artist', 'album', 'title', 'lyrics', 'uid', 'name', 'email', 'songid', 'sid', 'created', 'updated');
62 62
 	}
63 63
 	
64
-    function getFilterCriteria($filter) {
65
-    	$parts = explode('|', $filter);
66
-    	$criteria = new CriteriaCompo();
67
-    	foreach($parts as $part) {
68
-    		$var = explode(',', $part);
69
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
70
-    			$object = $this->create();
71
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
72
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
73
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
74
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
75
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
76
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
77
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
64
+	function getFilterCriteria($filter) {
65
+		$parts = explode('|', $filter);
66
+		$criteria = new CriteriaCompo();
67
+		foreach($parts as $part) {
68
+			$var = explode(',', $part);
69
+			if (!empty($var[1])&&!is_numeric($var[0])) {
70
+				$object = $this->create();
71
+				if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
72
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
73
+					$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
74
+				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
75
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
76
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
77
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
78 78
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
79
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
79
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
80 80
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
81
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
81
+					$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
82 82
 				}
83
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
84
-    			$criteria->add(new Criteria($var[0], $var[1]));
85
-    		}
86
-    	}
87
-    	return $criteria;
88
-    }
83
+			} elseif (!empty($var[1])&&is_numeric($var[0])) {
84
+				$criteria->add(new Criteria($var[0], $var[1]));
85
+			}
86
+		}
87
+		return $criteria;
88
+	}
89 89
         
90
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
91
-    	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
92
-    	if (is_object($ele))
93
-    		return $ele->render();
94
-    	else 
95
-    		return '&nbsp;';
96
-    }
90
+	function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
91
+		$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
92
+		if (is_object($ele))
93
+			return $ele->render();
94
+		else 
95
+			return '&nbsp;';
96
+	}
97 97
     
98 98
 	function insert($obj, $force=true) {
99
-    	if ($obj->isNew()) {
100
-    		$obj->setVar('created', time());	
101
-    		$new = true;
102
-    		$sendmail = true;
103
-       	} else {
104
-    		$obj->setVar('updated', time());
105
-    		$new = false;
106
-    		if ($obj->vars['songid']['changed']==true) {
107
-    			$songs_handler = xoops_getmodulehandler('songs', 'songlist');
108
-    			$criteria = new Criteria('songid', $obj->getVar('songid'));
109
-    			$songs = $songs_handler->getObjects($criteria, false);
110
-    			if (is_object($songs[0])) {
111
-    				foreach($songs[0]->getVar('aids') as $aid)
112
-    					$ad[] = $aid;
113
-    				$obj->setVar('sid', $songs[0]->getVar('sid'));
114
-    				$obj->setVar('aid', $ad[0]);
115
-    				$sendmail = true;
116
-    			}
117
-    		}
118
-    	}
119
-    	if ($rid = parent::insert($obj, $force)) {
120
-    		if ($sendmail==true) {
121
-    			if ($new==true) {
122
-    				xoops_loadLanguage('email', 'songlist');
123
-    				$xoopsMailer =& getMailer();
99
+		if ($obj->isNew()) {
100
+			$obj->setVar('created', time());	
101
+			$new = true;
102
+			$sendmail = true;
103
+	   	} else {
104
+			$obj->setVar('updated', time());
105
+			$new = false;
106
+			if ($obj->vars['songid']['changed']==true) {
107
+				$songs_handler = xoops_getmodulehandler('songs', 'songlist');
108
+				$criteria = new Criteria('songid', $obj->getVar('songid'));
109
+				$songs = $songs_handler->getObjects($criteria, false);
110
+				if (is_object($songs[0])) {
111
+					foreach($songs[0]->getVar('aids') as $aid)
112
+						$ad[] = $aid;
113
+					$obj->setVar('sid', $songs[0]->getVar('sid'));
114
+					$obj->setVar('aid', $ad[0]);
115
+					$sendmail = true;
116
+				}
117
+			}
118
+		}
119
+		if ($rid = parent::insert($obj, $force)) {
120
+			if ($sendmail==true) {
121
+				if ($new==true) {
122
+					xoops_loadLanguage('email', 'songlist');
123
+					$xoopsMailer =& getMailer();
124 124
 					$xoopsMailer->setHTML(true);
125 125
 					$xoopsMailer->setTemplateDir($GLOBALS['xoops']->path('/modules/songlist/language/'.$GLOBALS['xoopsConfig']['language'].'/mail_templates/'));
126 126
 					$xoopsMailer->setTemplate('songlist_request_created.html');
@@ -143,32 +143,32 @@  discard block
 block discarded – undo
143 143
 					if(!$xoopsMailer->send() ){
144 144
 						xoops_error($xoopsMailer->getErrors(true), 'Email Send Error');
145 145
 					}
146
-    			} else {
147
-    				xoops_loadLanguage('email', 'songlist');
148
-    				$songs_handler = xoops_getmodulehandler('songs', 'songlist');
149
-    				$artists_handler = xoops_getmodulehandler('artists', 'songlist');
150
-    				$albums_handler = xoops_getmodulehandler('albums', 'songlist');
151
-    				$genre_handler = xoops_getmodulehandler('genre', 'songlist');
146
+				} else {
147
+					xoops_loadLanguage('email', 'songlist');
148
+					$songs_handler = xoops_getmodulehandler('songs', 'songlist');
149
+					$artists_handler = xoops_getmodulehandler('artists', 'songlist');
150
+					$albums_handler = xoops_getmodulehandler('albums', 'songlist');
151
+					$genre_handler = xoops_getmodulehandler('genre', 'songlist');
152 152
     				
153
-    				$song = $songs_handler->get($obj->getVar('sid'));
154
-    				if (is_object($song)) {
155
-    					$sng = $genre->getVar('title');
156
-    				}
157
-    				$album = $album_handler->get($song->getVar('abid'));
158
-    				if (is_object($album)) {
159
-    					$alb = $genre->getVar('title');
160
-    					$alb_img = $genre->getImage();
161
-    				}
162
-    				$genre = $genre_handler->get($song->getVar('abid'));
163
-    				if (is_object($genre)) {
164
-    					$gen = $genre->getVar('name');
165
-    				}
166
-    				$artists = $artists_handler->getObjects(new Criteria('aid', '('.implode(',', $song->getVar('aid')).')', 'IN'), false);
167
-    				$art = '';
168
-    				foreach($artists as $id => $artist) {
169
-    					$art .= $artist->getVar('name') . ($id<sizeof($artists)-1?', ':'');
170
-    				}
171
-    				$xoopsMailer =& getMailer();
153
+					$song = $songs_handler->get($obj->getVar('sid'));
154
+					if (is_object($song)) {
155
+						$sng = $genre->getVar('title');
156
+					}
157
+					$album = $album_handler->get($song->getVar('abid'));
158
+					if (is_object($album)) {
159
+						$alb = $genre->getVar('title');
160
+						$alb_img = $genre->getImage();
161
+					}
162
+					$genre = $genre_handler->get($song->getVar('abid'));
163
+					if (is_object($genre)) {
164
+						$gen = $genre->getVar('name');
165
+					}
166
+					$artists = $artists_handler->getObjects(new Criteria('aid', '('.implode(',', $song->getVar('aid')).')', 'IN'), false);
167
+					$art = '';
168
+					foreach($artists as $id => $artist) {
169
+						$art .= $artist->getVar('name') . ($id<sizeof($artists)-1?', ':'');
170
+					}
171
+					$xoopsMailer =& getMailer();
172 172
 					$xoopsMailer->setHTML(true);
173 173
 					$xoopsMailer->setTemplateDir($GLOBALS['xoops']->path('/modules/songlist/language/'.$GLOBALS['xoopsConfig']['language'].'/mail_templates/'));
174 174
 					$xoopsMailer->setTemplate('songlist_request_updated.html');
@@ -196,19 +196,19 @@  discard block
 block discarded – undo
196 196
 					if(!$xoopsMailer->send() ){
197 197
 						xoops_error($xoopsMailer->getErrors(true), 'Email Send Error');
198 198
 					}
199
-    			}		
200
-    		}
201
-    	}
202
-    	return $rid;
203
-    }
199
+				}		
200
+			}
201
+		}
202
+		return $rid;
203
+	}
204 204
     
205
-    function getURL() {
206
-    	global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
207
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
208
-    		return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$op.'-'.$fct.$GLOBALS['songlistModuleConfig']['endofurl'];
209
-    	} else {
210
-    		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct;
211
-    	}
212
-    }
205
+	function getURL() {
206
+		global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
207
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
208
+			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$op.'-'.$fct.$GLOBALS['songlistModuleConfig']['endofurl'];
209
+		} else {
210
+			return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct;
211
+		}
212
+	}
213 213
 }
214 214
 ?>
215 215
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
 		$ret = parent::toArray();
36 36
 		$form = $this->getForm(true);
37 37
 		$form['songid'] = new XoopsFormText('', $this->getVar('rid').'[songid]', 11, 32);
38
-		foreach($form as $key => $element) {
38
+		foreach ($form as $key => $element) {
39 39
 			$ret['form'][$key] = $form[$key]->render();	
40 40
 		}
41
-		foreach(array('created', 'updated') as $key) {
41
+		foreach (array('created', 'updated') as $key) {
42 42
 			if ($this->getVar($key)>0) {
43 43
 				$ret['form'][$key] = date(_DATESTRING, $this->getVar($key)); 
44 44
 				$ret[$key] = date(_DATESTRING, $this->getVar($key));
@@ -64,30 +64,30 @@  discard block
 block discarded – undo
64 64
     function getFilterCriteria($filter) {
65 65
     	$parts = explode('|', $filter);
66 66
     	$criteria = new CriteriaCompo();
67
-    	foreach($parts as $part) {
67
+    	foreach ($parts as $part) {
68 68
     		$var = explode(',', $part);
69
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
69
+    		if (!empty($var[1]) && !is_numeric($var[0])) {
70 70
     			$object = $this->create();
71
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
72
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
73
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
74
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
71
+    			if ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
72
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) {
73
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2]) ? $var[2] : 'LIKE')));
74
+    			} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
75 75
     						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
76
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
77
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
78
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
79
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
80
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
81
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
76
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT) {
77
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));			
78
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM) {
79
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));    				
80
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY) {
81
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2]) ? $var[2] : 'LIKE')));    				
82 82
 				}
83
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
83
+    		} elseif (!empty($var[1]) && is_numeric($var[0])) {
84 84
     			$criteria->add(new Criteria($var[0], $var[1]));
85 85
     		}
86 86
     	}
87 87
     	return $criteria;
88 88
     }
89 89
         
90
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
90
+    function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list') {
91 91
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
92 92
     	if (is_object($ele))
93 93
     		return $ele->render();
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     		return '&nbsp;';
96 96
     }
97 97
     
98
-	function insert($obj, $force=true) {
98
+	function insert($obj, $force = true) {
99 99
     	if ($obj->isNew()) {
100 100
     		$obj->setVar('created', time());	
101 101
     		$new = true;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     			$criteria = new Criteria('songid', $obj->getVar('songid'));
109 109
     			$songs = $songs_handler->getObjects($criteria, false);
110 110
     			if (is_object($songs[0])) {
111
-    				foreach($songs[0]->getVar('aids') as $aid)
111
+    				foreach ($songs[0]->getVar('aids') as $aid)
112 112
     					$ad[] = $aid;
113 113
     				$obj->setVar('sid', $songs[0]->getVar('sid'));
114 114
     				$obj->setVar('aid', $ad[0]);
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
     		if ($sendmail==true) {
121 121
     			if ($new==true) {
122 122
     				xoops_loadLanguage('email', 'songlist');
123
-    				$xoopsMailer =& getMailer();
123
+    				$xoopsMailer = & getMailer();
124 124
 					$xoopsMailer->setHTML(true);
125 125
 					$xoopsMailer->setTemplateDir($GLOBALS['xoops']->path('/modules/songlist/language/'.$GLOBALS['xoopsConfig']['language'].'/mail_templates/'));
126 126
 					$xoopsMailer->setTemplate('songlist_request_created.html');
127 127
 					$xoopsMailer->setSubject(sprintf(_MN_SONGLIST_SUBJECT_REQUESTMADE, $rid));
128 128
 					
129
-					foreach(explode('|', $GLOBALS['songlistModuleConfig']['email']) as $email)
129
+					foreach (explode('|', $GLOBALS['songlistModuleConfig']['email']) as $email)
130 130
 						$xoopsMailer->setToEmails($email);
131 131
 					
132 132
 					$xoopsMailer->setToEmails($obj->getVar('email'));
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 					$xoopsMailer->assign("EMAIL", $obj->getVar('email'));	
141 141
 					$xoopsMailer->assign("NAME", $obj->getVar('name'));
142 142
 					
143
-					if(!$xoopsMailer->send() ){
143
+					if (!$xoopsMailer->send()) {
144 144
 						xoops_error($xoopsMailer->getErrors(true), 'Email Send Error');
145 145
 					}
146 146
     			} else {
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
     				}
166 166
     				$artists = $artists_handler->getObjects(new Criteria('aid', '('.implode(',', $song->getVar('aid')).')', 'IN'), false);
167 167
     				$art = '';
168
-    				foreach($artists as $id => $artist) {
169
-    					$art .= $artist->getVar('name') . ($id<sizeof($artists)-1?', ':'');
168
+    				foreach ($artists as $id => $artist) {
169
+    					$art .= $artist->getVar('name').($id<sizeof($artists)-1 ? ', ' : '');
170 170
     				}
171
-    				$xoopsMailer =& getMailer();
171
+    				$xoopsMailer = & getMailer();
172 172
 					$xoopsMailer->setHTML(true);
173 173
 					$xoopsMailer->setTemplateDir($GLOBALS['xoops']->path('/modules/songlist/language/'.$GLOBALS['xoopsConfig']['language'].'/mail_templates/'));
174 174
 					$xoopsMailer->setTemplate('songlist_request_updated.html');
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 					$xoopsMailer->assign("EMAIL", $obj->getVar('email'));	
194 194
 					$xoopsMailer->assign("NAME", $obj->getVar('name'));
195 195
 					
196
-					if(!$xoopsMailer->send() ){
196
+					if (!$xoopsMailer->send()) {
197 197
 						xoops_error($xoopsMailer->getErrors(true), 'Email Send Error');
198 198
 					}
199 199
     			}		
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -89,10 +89,11 @@  discard block
 block discarded – undo
89 89
         
90 90
     function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
91 91
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
92
-    	if (is_object($ele))
93
-    		return $ele->render();
94
-    	else 
95
-    		return '&nbsp;';
92
+    	if (is_object($ele)) {
93
+    	    		return $ele->render();
94
+    	} else {
95
+    	    		return '&nbsp;';
96
+    	}
96 97
     }
97 98
     
98 99
 	function insert($obj, $force=true) {
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
     			$criteria = new Criteria('songid', $obj->getVar('songid'));
109 110
     			$songs = $songs_handler->getObjects($criteria, false);
110 111
     			if (is_object($songs[0])) {
111
-    				foreach($songs[0]->getVar('aids') as $aid)
112
-    					$ad[] = $aid;
112
+    				foreach($songs[0]->getVar('aids') as $aid) {
113
+    				    					$ad[] = $aid;
114
+    				}
113 115
     				$obj->setVar('sid', $songs[0]->getVar('sid'));
114 116
     				$obj->setVar('aid', $ad[0]);
115 117
     				$sendmail = true;
@@ -126,8 +128,9 @@  discard block
 block discarded – undo
126 128
 					$xoopsMailer->setTemplate('songlist_request_created.html');
127 129
 					$xoopsMailer->setSubject(sprintf(_MN_SONGLIST_SUBJECT_REQUESTMADE, $rid));
128 130
 					
129
-					foreach(explode('|', $GLOBALS['songlistModuleConfig']['email']) as $email)
130
-						$xoopsMailer->setToEmails($email);
131
+					foreach(explode('|', $GLOBALS['songlistModuleConfig']['email']) as $email) {
132
+											$xoopsMailer->setToEmails($email);
133
+					}
131 134
 					
132 135
 					$xoopsMailer->setToEmails($obj->getVar('email'));
133 136
 					
Please login to merge, or discard this patch.
htdocs/modules/songlist/class/artists.php 3 patches
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
 class SonglistArtists extends XoopsObject
11 11
 {
12 12
 
13
-    function SonglistArtists($fid = null)
14
-    {
15
-        $this->initVar('aid', XOBJ_DTYPE_INT, 0, false);
16
-        $this->initVar('cids', XOBJ_DTYPE_ARRAY, array(), false);
17
-        $this->initVar('sids', XOBJ_DTYPE_ARRAY, array(), false);
13
+	function SonglistArtists($fid = null)
14
+	{
15
+		$this->initVar('aid', XOBJ_DTYPE_INT, 0, false);
16
+		$this->initVar('cids', XOBJ_DTYPE_ARRAY, array(), false);
17
+		$this->initVar('sids', XOBJ_DTYPE_ARRAY, array(), false);
18 18
 		$this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 128);
19 19
 		$this->initVar('albums', XOBJ_DTYPE_INT, 0, false);
20 20
 		$this->initVar('songs', XOBJ_DTYPE_INT, 0, false);
@@ -50,124 +50,124 @@  discard block
 block discarded – undo
50 50
 			$ret['singer'] = constant($ret['singer']); 
51 51
 		
52 52
 		if ($extra==false)
53
-    		return $ret;
53
+			return $ret;
54 54
     		
55 55
 		if (count($this->getVar('cids'))!=0) {
56
-    		$categories_handler = xoops_getmodulehandler('category', 'songlist');
57
-    		foreach($this->getVar('cids') as $aid) {
58
-    			$category = $categories_handler->get($aid);
59
-    			if (is_object($category)) {
60
-    				$ret['categories_array'][$aid] = $category->toArray(false);
61
-    			}
62
-    		} 	
63
-    	}
56
+			$categories_handler = xoops_getmodulehandler('category', 'songlist');
57
+			foreach($this->getVar('cids') as $aid) {
58
+				$category = $categories_handler->get($aid);
59
+				if (is_object($category)) {
60
+					$ret['categories_array'][$aid] = $category->toArray(false);
61
+				}
62
+			} 	
63
+		}
64 64
     		
65 65
     	
66 66
 		if (count($this->getVar('aids'))!=0) {
67
-    		$artists_handler = xoops_getmodulehandler('artists', 'songlist');
68
-    		foreach($this->getVar('aids') as $aid) {
69
-    			$artist = $artists_handler->get($aid);
70
-    			if (is_object($artist)) {
71
-    				$ret['artists_array'][$aid] = $artist->toArray(false);
72
-    			}
73
-    		} 	
74
-    	}
67
+			$artists_handler = xoops_getmodulehandler('artists', 'songlist');
68
+			foreach($this->getVar('aids') as $aid) {
69
+				$artist = $artists_handler->get($aid);
70
+				if (is_object($artist)) {
71
+					$ret['artists_array'][$aid] = $artist->toArray(false);
72
+				}
73
+			} 	
74
+		}
75 75
     	
76 76
 		
77 77
 		if (count($this->getVar('sids'))!=0) {
78
-    		$songs_handler = xoops_getmodulehandler('songs', 'songlist');
79
-    		$criteria = new Criteria('`aids`', '%"'.$this->getVar('aid').'"%', 'LIKE');
80
-    		$criteria->setSort('`songid`');
81
-    		$criteria->setOrder('ASC');
82
-    		foreach($songs_handler->getObjects($criteria, true) as $sid => $song) {
83
-    			if (is_object($song)) {
84
-    				$ret['songs_array'][$sid] = $song->toArray(false);
85
-    			}
86
-    		} 	
87
-    	}
78
+			$songs_handler = xoops_getmodulehandler('songs', 'songlist');
79
+			$criteria = new Criteria('`aids`', '%"'.$this->getVar('aid').'"%', 'LIKE');
80
+			$criteria->setSort('`songid`');
81
+			$criteria->setOrder('ASC');
82
+			foreach($songs_handler->getObjects($criteria, true) as $sid => $song) {
83
+				if (is_object($song)) {
84
+					$ret['songs_array'][$sid] = $song->toArray(false);
85
+				}
86
+			} 	
87
+		}
88 88
     	
89 89
 		return $ret;
90 90
 	}
91 91
 	
92
-    function getURL() {
93
-    	global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
94
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
95
-    	    if ($id!=0) {
96
-    			$artist_handler = xoops_getmodulehandler('artists', 'songlist');
97
-    			$artist = $artist_handler->get($id);
98
-    			if (is_object($artist)&&!$artist->isNew()) {
99
-    				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/artists/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
100
-    			} else {
101
-    				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/artists/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'-'.$vcid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
102
-    			}
103
-    		} else {
104
-    			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/artists/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'-'.$vcid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
105
-    		}
106
-    	} else {
107
-    		return XOOPS_URL.'/modules/songlist/artists.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
108
-    	}
109
-    }
92
+	function getURL() {
93
+		global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
94
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
95
+			if ($id!=0) {
96
+				$artist_handler = xoops_getmodulehandler('artists', 'songlist');
97
+				$artist = $artist_handler->get($id);
98
+				if (is_object($artist)&&!$artist->isNew()) {
99
+					return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/artists/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
100
+				} else {
101
+					return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/artists/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'-'.$vcid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
102
+				}
103
+			} else {
104
+				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/artists/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'-'.$vcid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
105
+			}
106
+		} else {
107
+			return XOOPS_URL.'/modules/songlist/artists.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
108
+		}
109
+	}
110 110
 		
111 111
 }
112 112
 
113 113
 
114 114
 class SonglistArtistsHandler extends XoopsPersistableObjectHandler
115 115
 {
116
-    function __construct(&$db) 
117
-    {
118
-        parent::__construct($db, "songlist_artists", 'SonglistArtists', "aid", "name");
119
-    }
116
+	function __construct(&$db) 
117
+	{
118
+		parent::__construct($db, "songlist_artists", 'SonglistArtists', "aid", "name");
119
+	}
120 120
 
121 121
 	function filterFields() {
122 122
 		return array('aid', 'cids', 'singer', 'name', 'albums', 'songs', 'hits', 'rank', 'votes', 'created', 'updated');
123 123
 	}
124 124
 	
125
-    function getFilterCriteria($filter) {
126
-    	$parts = explode('|', $filter);
127
-    	$criteria = new CriteriaCompo();
128
-    	foreach($parts as $part) {
129
-    		$var = explode(',', $part);
130
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
131
-    			$object = $this->create();
132
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
133
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
134
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
135
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
136
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
137
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
138
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
125
+	function getFilterCriteria($filter) {
126
+		$parts = explode('|', $filter);
127
+		$criteria = new CriteriaCompo();
128
+		foreach($parts as $part) {
129
+			$var = explode(',', $part);
130
+			if (!empty($var[1])&&!is_numeric($var[0])) {
131
+				$object = $this->create();
132
+				if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
133
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
134
+					$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
135
+				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
136
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
137
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
138
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
139 139
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
140
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
140
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
141 141
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
142
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
142
+					$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
143 143
 				}
144
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
145
-    			$criteria->add(new Criteria($var[0], $var[1]));
146
-    		}
147
-    	}
148
-    	return $criteria;
149
-    }
144
+			} elseif (!empty($var[1])&&is_numeric($var[0])) {
145
+				$criteria->add(new Criteria($var[0], $var[1]));
146
+			}
147
+		}
148
+		return $criteria;
149
+	}
150 150
         
151
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
152
-    	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
153
-    	if (is_object($ele))
154
-    		return $ele->render();
155
-    	else 
156
-    		return '&nbsp;';
157
-    }
151
+	function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
152
+		$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
153
+		if (is_object($ele))
154
+			return $ele->render();
155
+		else 
156
+			return '&nbsp;';
157
+	}
158 158
     
159 159
 	function insert($obj, $force=true, $object = null) {
160
-    	if ($obj->isNew()) {
161
-    		$new = true;
162
-    		$old = $this->create();
163
-    		$obj->setVar('created', time());	
164
-    	} else {
165
-    		$new = false;
166
-    		$old = $this->get($obj->getVar('aid'));
167
-    		$obj->setVar('updated', time());
168
-    	}
160
+		if ($obj->isNew()) {
161
+			$new = true;
162
+			$old = $this->create();
163
+			$obj->setVar('created', time());	
164
+		} else {
165
+			$new = false;
166
+			$old = $this->get($obj->getVar('aid'));
167
+			$obj->setVar('updated', time());
168
+		}
169 169
 		
170
-    	$albums_handler = xoops_getmodulehandler('albums', 'songlist');
170
+		$albums_handler = xoops_getmodulehandler('albums', 'songlist');
171 171
 		$songs_handler = xoops_getmodulehandler('songs', 'songlist');
172 172
 		$genre_handler = xoops_getmodulehandler('genre', 'songlist');
173 173
 		$voice_handler = xoops_getmodulehandler('voice', 'songlist');		
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 						$obj->setVar('cids', array_merge($obj->getVar('cids'), array($object->getVar('cid')=>$object->getVar('cid'))));
181 181
 						$category = $category_handler->get($cid);
182 182
 						if (is_object($category)) {
183
-			    			$category->setVar('artists', $category->getVar('artists')+1);
184
-			    			$category_handler->insert($category, true, $obj);
183
+							$category->setVar('artists', $category->getVar('artists')+1);
184
+							$category_handler->insert($category, true, $obj);
185 185
 						}	
186 186
 					}
187 187
 				}
@@ -190,61 +190,61 @@  discard block
 block discarded – undo
190 190
 						if (!in_array($cid, $obj->vars['cids']['value'])&&$cid!=0) {
191 191
 							$category = $category_handler->get($cid);
192 192
 							if (is_object($category)) {
193
-				    			$category->setVar('artists', $category->getVar('artists')-1);
194
-				    			$category_handler->insert($category, true, $obj);
193
+								$category->setVar('artists', $category->getVar('artists')-1);
194
+								$category_handler->insert($category, true, $obj);
195 195
 							}	
196 196
 						}
197 197
 					}
198 198
 				}
199 199
 			}
200 200
 		    	
201
-	    	if ($object->vars['abid']['value']!=0&&$object->vars['aids']['changed']==true) {
202
-    			$album = $albums_handler->get($object->vars['abid']['value']);
203
-    			if (is_object($album)) {
204
-    				$album->setVar('artists', $album->getVar('artists')+1);
205
-    				$albums_handler->insert($album, true, $obj);
206
-    			}
207
-	       	}
201
+			if ($object->vars['abid']['value']!=0&&$object->vars['aids']['changed']==true) {
202
+				$album = $albums_handler->get($object->vars['abid']['value']);
203
+				if (is_object($album)) {
204
+					$album->setVar('artists', $album->getVar('artists')+1);
205
+					$albums_handler->insert($album, true, $obj);
206
+				}
207
+		   	}
208 208
 	    	
209 209
 			if ($object->vars['gid']['value']!=0&&$object->vars['gid']['changed']==true) {
210
-    			$genre = $genre_handler->get($object->vars['gid']['value']);
211
-    			if (is_object($genre)) {
212
-	    			$genre->setVar('artists', $genre->getVar('artists')+1);
213
-	    			$genre_handler->insert($genre, true, $obj);
214
-    			}
215
-	       	}
210
+				$genre = $genre_handler->get($object->vars['gid']['value']);
211
+				if (is_object($genre)) {
212
+					$genre->setVar('artists', $genre->getVar('artists')+1);
213
+					$genre_handler->insert($genre, true, $obj);
214
+				}
215
+		   	}
216 216
 			if ($object->vars['vid']['value']!=0&&$object->vars['vid']['changed']==true) {
217
-    			$voice = $voice_handler->get($object->vars['vid']['value']);
218
-    			if (is_object($voice)) {
219
-	    			$voice->setVar('artists', $voice->getVar('artists')+1);
220
-	    			$voice_handler->insert($voice, true, $obj);
221
-    			}
222
-	       	}
217
+				$voice = $voice_handler->get($object->vars['vid']['value']);
218
+				if (is_object($voice)) {
219
+					$voice->setVar('artists', $voice->getVar('artists')+1);
220
+					$voice_handler->insert($voice, true, $obj);
221
+				}
222
+		   	}
223 223
 			
224 224
 		}
225 225
     	
226 226
 		if (strlen($obj->getVar('name'))==0)
227
-    		return false;
227
+			return false;
228 228
     		
229
-    	return parent::insert($obj, $force);
230
-    }
229
+		return parent::insert($obj, $force);
230
+	}
231 231
      
232 232
 	var $_objects = array('object'=>array(), 'array'=>array());
233 233
     
234
-    function get($id, $fields = '*') {
235
-    	if (!isset($this->_objects['object'][$id])) {
236
-	    	$this->_objects['object'][$id] = parent::get($id, $fields);
237
-	    	if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
238
-		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
239
-		    	$GLOBALS['xoopsDB']->queryF($sql);
240
-	    	}
241
-    	}
242
-    	return $this->_objects['object'][$id];
243
-    }
234
+	function get($id, $fields = '*') {
235
+		if (!isset($this->_objects['object'][$id])) {
236
+			$this->_objects['object'][$id] = parent::get($id, $fields);
237
+			if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
238
+				$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
239
+				$GLOBALS['xoopsDB']->queryF($sql);
240
+			}
241
+		}
242
+		return $this->_objects['object'][$id];
243
+	}
244 244
     
245
-    function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
246
-    	$ret = parent::getObjects($criteria, $id_as_key, $as_object);
247
-    	/*if (!isset($GLOBALS['songlistAdmin'])) {
245
+	function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
246
+		$ret = parent::getObjects($criteria, $id_as_key, $as_object);
247
+		/*if (!isset($GLOBALS['songlistAdmin'])) {
248 248
 	    	$id = array();
249 249
 	    	foreach($ret as $data) {
250 250
 	    		if ($as_object==true) {
@@ -264,52 +264,52 @@  discard block
 block discarded – undo
264 264
 	    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` IN ('.implode(',', $id).')';
265 265
 	    	$GLOBALS['xoopsDB']->queryF($sql);
266 266
     	}*/
267
-    	return $ret;
268
-    }
267
+		return $ret;
268
+	}
269 269
     
270
-    function getURL() {
271
-    	global $file, $op, $fct, $id, $value, $gid, $vid, $cid, $start, $limit;
272
-    	if ($GLOBALS['songlistModuleConfig']['htaccess']) {
273
-    	    if ($cid!=0) {
274
-    			$artist_handler = xoops_getmodulehandler('artists', 'songlist');
275
-    			$artist = $artist_handler->get($cid);
276
-    			if (is_object($artist)&&!$artist->isNew()) {
277
-    				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
278
-    			} else {
279
-    				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
280
-    			}
281
-    		} else {
282
-    			return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
283
-    		}
284
-    	} else {
285
-    		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
286
-    	}
287
-    }
270
+	function getURL() {
271
+		global $file, $op, $fct, $id, $value, $gid, $vid, $cid, $start, $limit;
272
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
273
+			if ($cid!=0) {
274
+				$artist_handler = xoops_getmodulehandler('artists', 'songlist');
275
+				$artist = $artist_handler->get($cid);
276
+				if (is_object($artist)&&!$artist->isNew()) {
277
+					return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
278
+				} else {
279
+					return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
280
+				}
281
+			} else {
282
+				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
283
+			}
284
+		} else {
285
+			return XOOPS_URL.'/modules/songlist/'.$file.'.php?op='.$op.'&fct='.$fct.'&id='.$id.'&value='.urlencode($value).'&gid='.$gid.'&vid='.$vid.'&cid='.$cid.'&start='.$start;
286
+		}
287
+	}
288 288
     
289 289
     
290
-    function getSIDs($criteria = NULL) {
291
-    	$ret = array();
292
-    	$song_handler = xoops_getmodulehandler('songs', 'songlist');
293
-    	foreach($this->getObjects($criteria, true) as $aid => $object) {
294
-    		$crita = new Criteria('`aids`', '%"'.$aid.'"%', 'LIKE');
295
-    		foreach($song_handler->getObjects($crita, true) as $sid => $song) {
296
-    			$ret[$sid] = $sid;
297
-    		}
298
-    	}
299
-    	return $ret;
300
-    }
290
+	function getSIDs($criteria = NULL) {
291
+		$ret = array();
292
+		$song_handler = xoops_getmodulehandler('songs', 'songlist');
293
+		foreach($this->getObjects($criteria, true) as $aid => $object) {
294
+			$crita = new Criteria('`aids`', '%"'.$aid.'"%', 'LIKE');
295
+			foreach($song_handler->getObjects($crita, true) as $sid => $song) {
296
+				$ret[$sid] = $sid;
297
+			}
298
+		}
299
+		return $ret;
300
+	}
301 301
     
302 302
 	function getTop($limit=1) {
303
-    	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
304
-    	$results = $GLOBALS['xoopsDB']->queryF($sql);
305
-    	$ret = array();
306
-    	$i=0;
307
-    	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
308
-    		$ret[$i] = $this->create();
309
-    		$ret[$i]->assignVars($row);
310
-    		$i++;
311
-    	}
312
-    	return $ret;
313
-    }
303
+		$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
304
+		$results = $GLOBALS['xoopsDB']->queryF($sql);
305
+		$ret = array();
306
+		$i=0;
307
+		while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
308
+			$ret[$i] = $this->create();
309
+			$ret[$i]->assignVars($row);
310
+			$i++;
311
+		}
312
+		return $ret;
313
+	}
314 314
 }
315 315
 ?>
316 316
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
 	function toArray($extra = false) {
33 33
 		$ret = parent::toArray();
34 34
 		$form = $this->getForm(true);
35
-		foreach($form as $key => $element) {
35
+		foreach ($form as $key => $element) {
36 36
 			$ret['form'][$key] = $form[$key]->render();	
37 37
 		}
38
-		foreach(array('created', 'updated') as $key) {
38
+		foreach (array('created', 'updated') as $key) {
39 39
 			if ($this->getVar($key)>0) {
40 40
 				$ret['form'][$key] = date(_DATESTRING, $this->getVar($key)); 
41 41
 				$ret[$key] = date(_DATESTRING, $this->getVar($key));
42 42
 			}
43 43
 		}
44 44
 
45
-		$ret['rank'] = number_format(($this->getVar('rank')>0&&$this->getVar('votes')>0?$this->getVar('rank')/$this->getVar('votes'):0),2)._MI_SONGLIST_OFTEN;
45
+		$ret['rank'] = number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2)._MI_SONGLIST_OFTEN;
46 46
 		$ret['url'] = $this->getURL(true);
47 47
 		
48 48
 		xoops_loadLanguage('enum', 'songlist');
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     		
55 55
 		if (count($this->getVar('cids'))!=0) {
56 56
     		$categories_handler = xoops_getmodulehandler('category', 'songlist');
57
-    		foreach($this->getVar('cids') as $aid) {
57
+    		foreach ($this->getVar('cids') as $aid) {
58 58
     			$category = $categories_handler->get($aid);
59 59
     			if (is_object($category)) {
60 60
     				$ret['categories_array'][$aid] = $category->toArray(false);
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     	
66 66
 		if (count($this->getVar('aids'))!=0) {
67 67
     		$artists_handler = xoops_getmodulehandler('artists', 'songlist');
68
-    		foreach($this->getVar('aids') as $aid) {
68
+    		foreach ($this->getVar('aids') as $aid) {
69 69
     			$artist = $artists_handler->get($aid);
70 70
     			if (is_object($artist)) {
71 71
     				$ret['artists_array'][$aid] = $artist->toArray(false);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     		$criteria = new Criteria('`aids`', '%"'.$this->getVar('aid').'"%', 'LIKE');
80 80
     		$criteria->setSort('`songid`');
81 81
     		$criteria->setOrder('ASC');
82
-    		foreach($songs_handler->getObjects($criteria, true) as $sid => $song) {
82
+    		foreach ($songs_handler->getObjects($criteria, true) as $sid => $song) {
83 83
     			if (is_object($song)) {
84 84
     				$ret['songs_array'][$sid] = $song->toArray(false);
85 85
     			}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     	    if ($id!=0) {
96 96
     			$artist_handler = xoops_getmodulehandler('artists', 'songlist');
97 97
     			$artist = $artist_handler->get($id);
98
-    			if (is_object($artist)&&!$artist->isNew()) {
98
+    			if (is_object($artist) && !$artist->isNew()) {
99 99
     				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/artists/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
100 100
     			} else {
101 101
     				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/artists/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'-'.$vcid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
@@ -125,30 +125,30 @@  discard block
 block discarded – undo
125 125
     function getFilterCriteria($filter) {
126 126
     	$parts = explode('|', $filter);
127 127
     	$criteria = new CriteriaCompo();
128
-    	foreach($parts as $part) {
128
+    	foreach ($parts as $part) {
129 129
     		$var = explode(',', $part);
130
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
130
+    		if (!empty($var[1]) && !is_numeric($var[0])) {
131 131
     			$object = $this->create();
132
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
133
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
134
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
135
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
132
+    			if ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
133
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) {
134
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2]) ? $var[2] : 'LIKE')));
135
+    			} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
136 136
     						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
137
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
138
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
139
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
140
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
141
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
142
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
137
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT) {
138
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));			
139
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM) {
140
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));    				
141
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY) {
142
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2]) ? $var[2] : 'LIKE')));    				
143 143
 				}
144
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
144
+    		} elseif (!empty($var[1]) && is_numeric($var[0])) {
145 145
     			$criteria->add(new Criteria($var[0], $var[1]));
146 146
     		}
147 147
     	}
148 148
     	return $criteria;
149 149
     }
150 150
         
151
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
151
+    function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list') {
152 152
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
153 153
     	if (is_object($ele))
154 154
     		return $ele->render();
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     		return '&nbsp;';
157 157
     }
158 158
     
159
-	function insert($obj, $force=true, $object = null) {
159
+	function insert($obj, $force = true, $object = null) {
160 160
     	if ($obj->isNew()) {
161 161
     		$new = true;
162 162
     		$old = $this->create();
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
    	
176 176
 		if (is_a($object, 'SonglistSongs')) {
177 177
 			if ($object->vars['cid']['changed']==true) {
178
-				foreach($obj->vars['cids']['value'] as $cid) {
179
-					if (!in_array($cid, $object->getVar('cid'))&&$cid!=0) {
178
+				foreach ($obj->vars['cids']['value'] as $cid) {
179
+					if (!in_array($cid, $object->getVar('cid')) && $cid!=0) {
180 180
 						$obj->setVar('cids', array_merge($obj->getVar('cids'), array($object->getVar('cid')=>$object->getVar('cid'))));
181 181
 						$category = $category_handler->get($cid);
182 182
 						if (is_object($category)) {
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 					}
187 187
 				}
188 188
 				if (!$old->isNew()) {
189
-					foreach($old->getVar('cids') as $cid) {
190
-						if (!in_array($cid, $obj->vars['cids']['value'])&&$cid!=0) {
189
+					foreach ($old->getVar('cids') as $cid) {
190
+						if (!in_array($cid, $obj->vars['cids']['value']) && $cid!=0) {
191 191
 							$category = $category_handler->get($cid);
192 192
 							if (is_object($category)) {
193 193
 				    			$category->setVar('artists', $category->getVar('artists')-1);
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 				}
199 199
 			}
200 200
 		    	
201
-	    	if ($object->vars['abid']['value']!=0&&$object->vars['aids']['changed']==true) {
201
+	    	if ($object->vars['abid']['value']!=0 && $object->vars['aids']['changed']==true) {
202 202
     			$album = $albums_handler->get($object->vars['abid']['value']);
203 203
     			if (is_object($album)) {
204 204
     				$album->setVar('artists', $album->getVar('artists')+1);
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
     			}
207 207
 	       	}
208 208
 	    	
209
-			if ($object->vars['gid']['value']!=0&&$object->vars['gid']['changed']==true) {
209
+			if ($object->vars['gid']['value']!=0 && $object->vars['gid']['changed']==true) {
210 210
     			$genre = $genre_handler->get($object->vars['gid']['value']);
211 211
     			if (is_object($genre)) {
212 212
 	    			$genre->setVar('artists', $genre->getVar('artists')+1);
213 213
 	    			$genre_handler->insert($genre, true, $obj);
214 214
     			}
215 215
 	       	}
216
-			if ($object->vars['vid']['value']!=0&&$object->vars['vid']['changed']==true) {
216
+			if ($object->vars['vid']['value']!=0 && $object->vars['vid']['changed']==true) {
217 217
     			$voice = $voice_handler->get($object->vars['vid']['value']);
218 218
     			if (is_object($voice)) {
219 219
 	    			$voice->setVar('artists', $voice->getVar('artists')+1);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
     function get($id, $fields = '*') {
235 235
     	if (!isset($this->_objects['object'][$id])) {
236 236
 	    	$this->_objects['object'][$id] = parent::get($id, $fields);
237
-	    	if (!isset($GLOBALS['songlistAdmin'])&&is_object($this->_objects['object'][$id])) {
237
+	    	if (!isset($GLOBALS['songlistAdmin']) && is_object($this->_objects['object'][$id])) {
238 238
 		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$this->_objects['object'][$id]->getVar($this->keyName);
239 239
 		    	$GLOBALS['xoopsDB']->queryF($sql);
240 240
 	    	}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
     	    if ($cid!=0) {
274 274
     			$artist_handler = xoops_getmodulehandler('artists', 'songlist');
275 275
     			$artist = $artist_handler->get($cid);
276
-    			if (is_object($artist)&&!$artist->isNew()) {
276
+    			if (is_object($artist) && !$artist->isNew()) {
277 277
     				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.urlencode(str_replace(array(' ', chr(9)), '-', $artist->getVar('name'))).'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
278 278
     			} else {
279 279
     				return XOOPS_URL.'/'.$GLOBALS['songlistModuleConfig']['baseofurl'].'/'.$file.'/'.$start.'-'.$id.'-'.$op.'-'.$fct.'-'.$gid.'-'.$cid.'/'.urlencode($value).$GLOBALS['songlistModuleConfig']['endofurl'];
@@ -290,20 +290,20 @@  discard block
 block discarded – undo
290 290
     function getSIDs($criteria = NULL) {
291 291
     	$ret = array();
292 292
     	$song_handler = xoops_getmodulehandler('songs', 'songlist');
293
-    	foreach($this->getObjects($criteria, true) as $aid => $object) {
293
+    	foreach ($this->getObjects($criteria, true) as $aid => $object) {
294 294
     		$crita = new Criteria('`aids`', '%"'.$aid.'"%', 'LIKE');
295
-    		foreach($song_handler->getObjects($crita, true) as $sid => $song) {
295
+    		foreach ($song_handler->getObjects($crita, true) as $sid => $song) {
296 296
     			$ret[$sid] = $sid;
297 297
     		}
298 298
     	}
299 299
     	return $ret;
300 300
     }
301 301
     
302
-	function getTop($limit=1) {
302
+	function getTop($limit = 1) {
303 303
     	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
304 304
     	$results = $GLOBALS['xoopsDB']->queryF($sql);
305 305
     	$ret = array();
306
-    	$i=0;
306
+    	$i = 0;
307 307
     	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
308 308
     		$ret[$i] = $this->create();
309 309
     		$ret[$i]->assignVars($row);
Please login to merge, or discard this patch.
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -46,11 +46,13 @@  discard block
 block discarded – undo
46 46
 		$ret['url'] = $this->getURL(true);
47 47
 		
48 48
 		xoops_loadLanguage('enum', 'songlist');
49
-		if (!empty($ret['singer']))
50
-			$ret['singer'] = constant($ret['singer']); 
49
+		if (!empty($ret['singer'])) {
50
+					$ret['singer'] = constant($ret['singer']);
51
+		}
51 52
 		
52
-		if ($extra==false)
53
-    		return $ret;
53
+		if ($extra==false) {
54
+		    		return $ret;
55
+		}
54 56
     		
55 57
 		if (count($this->getVar('cids'))!=0) {
56 58
     		$categories_handler = xoops_getmodulehandler('category', 'songlist');
@@ -150,10 +152,11 @@  discard block
 block discarded – undo
150 152
         
151 153
     function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
152 154
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
153
-    	if (is_object($ele))
154
-    		return $ele->render();
155
-    	else 
156
-    		return '&nbsp;';
155
+    	if (is_object($ele)) {
156
+    	    		return $ele->render();
157
+    	} else {
158
+    	    		return '&nbsp;';
159
+    	}
157 160
     }
158 161
     
159 162
 	function insert($obj, $force=true, $object = null) {
@@ -223,8 +226,9 @@  discard block
 block discarded – undo
223 226
 			
224 227
 		}
225 228
     	
226
-		if (strlen($obj->getVar('name'))==0)
227
-    		return false;
229
+		if (strlen($obj->getVar('name'))==0) {
230
+		    		return false;
231
+		}
228 232
     		
229 233
     	return parent::insert($obj, $force);
230 234
     }
Please login to merge, or discard this patch.
htdocs/modules/songlist/class/category.php 3 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
 class SonglistCategory extends XoopsObject
8 8
 {
9 9
 
10
-    function SonglistCategory($fid = null)
11
-    {
12
-        $this->initVar('cid', XOBJ_DTYPE_INT, 0, false);
13
-        $this->initVar('pid', XOBJ_DTYPE_INT, 0, false);
10
+	function SonglistCategory($fid = null)
11
+	{
12
+		$this->initVar('cid', XOBJ_DTYPE_INT, 0, false);
13
+		$this->initVar('pid', XOBJ_DTYPE_INT, 0, false);
14 14
 		$this->initVar('weight', XOBJ_DTYPE_INT, 1, false);
15 15
 		$this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 128);
16 16
 		$this->initVar('description', XOBJ_DTYPE_OTHER, null, false);
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		}
45 45
 		$ret['picture'] = $this->getImage('image', false);
46 46
 		$ret['rank'] = number_format(($this->getVar('rank')>0&&$this->getVar('votes')>0?$this->getVar('rank')/$this->getVar('votes'):0),2)._MI_SONGLIST_OFTEN;
47
-    	$ret['url'] = $this->getURL();
47
+		$ret['url'] = $this->getURL();
48 48
 		$category_handler = xoops_getmodulehandler('category', 'songlist');
49 49
 		if ($category_handler->getCount(new Criteria('pid', $this->getVar('cid')))) {
50 50
 			foreach($category_handler->getObjects(new Criteria('pid', $this->getVar('cid')), true) as $cid => $cat) {
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
 		if (!file_exists($GLOBALS['xoops']->path($this->getVar('path').$this->getVar($field))))
61 61
 			return false;
62 62
 		if ($local==false)
63
-    		return XOOPS_URL.'/'.str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
64
-    	else 
65
-    		return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
66
-    }
63
+			return XOOPS_URL.'/'.str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
64
+		else 
65
+			return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
66
+	}
67 67
     
68
-    function getURL() {
69
-    	global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
68
+	function getURL() {
69
+		global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
70 70
    		return XOOPS_URL.'/modules/songlist/'.$file.'.php?op=category&fct=set&id='.$this->getVar('cid').'&value='.urlencode($file).'&gid='.$gid.'&cid='.$cid;
71
-    }
71
+	}
72 72
     
73 73
 }
74 74
 
@@ -76,48 +76,48 @@  discard block
 block discarded – undo
76 76
 class SonglistCategoryHandler extends XoopsPersistableObjectHandler
77 77
 {
78 78
 	
79
-    function __construct(&$db) 
80
-    {
81
-        parent::__construct($db, "songlist_category", 'SonglistCategory', "cid", "name");
82
-    }
79
+	function __construct(&$db) 
80
+	{
81
+		parent::__construct($db, "songlist_category", 'SonglistCategory', "cid", "name");
82
+	}
83 83
 
84 84
 	function filterFields() {
85 85
 		return array('cid', 'pid', 'weight', 'name', 'image', 'path', 'artists', 'albums', 'songs', 'hits', 'rank', 'votes', 'created', 'updated');
86 86
 	}
87 87
 	
88
-    function getFilterCriteria($filter) {
89
-    	$parts = explode('|', $filter);
90
-    	$criteria = new CriteriaCompo();
91
-    	foreach($parts as $part) {
92
-    		$var = explode(',', $part);
93
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
94
-    			$object = $this->create();
95
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
96
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
97
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
98
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
99
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
100
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
101
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
88
+	function getFilterCriteria($filter) {
89
+		$parts = explode('|', $filter);
90
+		$criteria = new CriteriaCompo();
91
+		foreach($parts as $part) {
92
+			$var = explode(',', $part);
93
+			if (!empty($var[1])&&!is_numeric($var[0])) {
94
+				$object = $this->create();
95
+				if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
96
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
97
+					$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
98
+				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
99
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
100
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
101
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
102 102
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
103
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
103
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
104 104
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
105
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
105
+					$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
106 106
 				}
107
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
108
-    			$criteria->add(new Criteria($var[0], $var[1]));
109
-    		}
110
-    	}
111
-    	return $criteria;
112
-    }
107
+			} elseif (!empty($var[1])&&is_numeric($var[0])) {
108
+				$criteria->add(new Criteria($var[0], $var[1]));
109
+			}
110
+		}
111
+		return $criteria;
112
+	}
113 113
         
114
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
115
-    	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
116
-    	if (is_object($ele))
117
-    		return $ele->render();
118
-    	else 
119
-    		return '&nbsp;';
120
-    }
114
+	function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
115
+		$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
116
+		if (is_object($ele))
117
+			return $ele->render();
118
+		else 
119
+			return '&nbsp;';
120
+	}
121 121
     
122 122
 	function GetCatAndSubCat($pid=0){
123 123
 		$categories = $this->getObjects(new Criteria('pid', $pid), true);
@@ -136,38 +136,38 @@  discard block
 block discarded – undo
136 136
 	}
137 137
 	
138 138
 	function insert($obj, $force=true) {
139
-    	if ($obj->isNew()) {
140
-    		$obj->setVar('created', time());	
141
-    	} else {
142
-    		$obj->setVar('updated', time());
143
-    	}
144
-    	if (strlen($obj->getVar('name'))==0)
145
-    		return false;
146
-    	return parent::insert($obj, $force);
147
-    }
139
+		if ($obj->isNew()) {
140
+			$obj->setVar('created', time());	
141
+		} else {
142
+			$obj->setVar('updated', time());
143
+		}
144
+		if (strlen($obj->getVar('name'))==0)
145
+			return false;
146
+		return parent::insert($obj, $force);
147
+	}
148 148
 
149
-    var $_objects = array('object'=>array(), 'array'=>array());
149
+	var $_objects = array('object'=>array(), 'array'=>array());
150 150
     
151
-    function get($id, $fields = '*') {
152
-    	if (!isset($this->_objects['object'][$id])) {
153
-	    	$this->_objects['object'][$id] = parent::get($id, $fields);
154
-	    	if (!isset($GLOBALS['songlistAdmin'])) {
155
-		    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$id;
156
-		    	$GLOBALS['xoopsDB']->queryF($sql);
157
-	    	}
158
-    	}
159
-    	return $this->_objects['object'][$id];
160
-    }
151
+	function get($id, $fields = '*') {
152
+		if (!isset($this->_objects['object'][$id])) {
153
+			$this->_objects['object'][$id] = parent::get($id, $fields);
154
+			if (!isset($GLOBALS['songlistAdmin'])) {
155
+				$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` = '.$id;
156
+				$GLOBALS['xoopsDB']->queryF($sql);
157
+			}
158
+		}
159
+		return $this->_objects['object'][$id];
160
+	}
161 161
     
162
-    function delete($object, $force=true) {
163
-    	parent::delete($object, $force);
164
-    	$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `cid` = 0 WHERE `cid` = ' . $object->getVar('cid');
165
-    	return $GLOBALS['xoopsDB']->queryF($sql);	
166
-    }
162
+	function delete($object, $force=true) {
163
+		parent::delete($object, $force);
164
+		$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `cid` = 0 WHERE `cid` = ' . $object->getVar('cid');
165
+		return $GLOBALS['xoopsDB']->queryF($sql);	
166
+	}
167 167
     
168
-    function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
169
-    	$ret = parent::getObjects($criteria, $id_as_key, $as_object);
170
-    	/*if (!isset($GLOBALS['songlistAdmin'])) {
168
+	function getObjects($criteria = NULL, $id_as_key = false, $as_object = true) {
169
+		$ret = parent::getObjects($criteria, $id_as_key, $as_object);
170
+		/*if (!isset($GLOBALS['songlistAdmin'])) {
171 171
 	    	$id = array();
172 172
 	    	foreach($ret as $data) {
173 173
 	    		if ($as_object==true) {
@@ -187,20 +187,20 @@  discard block
 block discarded – undo
187 187
 	    	$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` IN ('.implode(',', $id).')';
188 188
 	    	$GLOBALS['xoopsDB']->queryF($sql);
189 189
     	}*/
190
-    	return $ret;
191
-    }
190
+		return $ret;
191
+	}
192 192
     
193 193
 	function getTop($limit=1) {
194
-    	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
195
-    	$results = $GLOBALS['xoopsDB']->queryF($sql);
196
-    	$ret = array();
197
-    	$i=0;
198
-    	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
199
-    		$ret[$i] = $this->create();
200
-    		$ret[$i]->assignVars($row);
201
-    		$i++;
202
-    	}
203
-    	return $ret;
204
-    }
194
+		$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
195
+		$results = $GLOBALS['xoopsDB']->queryF($sql);
196
+		$ret = array();
197
+		$i=0;
198
+		while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
199
+			$ret[$i] = $this->create();
200
+			$ret[$i]->assignVars($row);
201
+			$i++;
202
+		}
203
+		return $ret;
204
+	}
205 205
 }
206 206
 ?>
207 207
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -33,21 +33,21 @@  discard block
 block discarded – undo
33 33
 	function toArray() {
34 34
 		$ret = parent::toArray();
35 35
 		$form = $this->getForm(true);
36
-		foreach($form as $key => $element) {
36
+		foreach ($form as $key => $element) {
37 37
 			$ret['form'][$key] = $form[$key]->render();	
38 38
 		}
39
-		foreach(array('created', 'updated') as $key) {
39
+		foreach (array('created', 'updated') as $key) {
40 40
 			if ($this->getVar($key)>0) {
41 41
 				$ret['form'][$key] = date(_DATESTRING, $this->getVar($key)); 
42 42
 				$ret[$key] = date(_DATESTRING, $this->getVar($key));
43 43
 			}
44 44
 		}
45 45
 		$ret['picture'] = $this->getImage('image', false);
46
-		$ret['rank'] = number_format(($this->getVar('rank')>0&&$this->getVar('votes')>0?$this->getVar('rank')/$this->getVar('votes'):0),2)._MI_SONGLIST_OFTEN;
46
+		$ret['rank'] = number_format(($this->getVar('rank')>0 && $this->getVar('votes')>0 ? $this->getVar('rank')/$this->getVar('votes') : 0), 2)._MI_SONGLIST_OFTEN;
47 47
     	$ret['url'] = $this->getURL();
48 48
 		$category_handler = xoops_getmodulehandler('category', 'songlist');
49 49
 		if ($category_handler->getCount(new Criteria('pid', $this->getVar('cid')))) {
50
-			foreach($category_handler->getObjects(new Criteria('pid', $this->getVar('cid')), true) as $cid => $cat) {
50
+			foreach ($category_handler->getObjects(new Criteria('pid', $this->getVar('cid')), true) as $cid => $cat) {
51 51
 				$ret['subcategories'][$cid] = $cat->toArray();
52 52
 			}
53 53
 		}
@@ -88,30 +88,30 @@  discard block
 block discarded – undo
88 88
     function getFilterCriteria($filter) {
89 89
     	$parts = explode('|', $filter);
90 90
     	$criteria = new CriteriaCompo();
91
-    	foreach($parts as $part) {
91
+    	foreach ($parts as $part) {
92 92
     		$var = explode(',', $part);
93
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
93
+    		if (!empty($var[1]) && !is_numeric($var[0])) {
94 94
     			$object = $this->create();
95
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
96
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
97
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
98
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
95
+    			if ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
96
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) {
97
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2]) ? $var[2] : 'LIKE')));
98
+    			} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
99 99
     						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
100
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
101
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
102
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
103
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
104
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
105
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
100
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT) {
101
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));			
102
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM) {
103
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));    				
104
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY) {
105
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2]) ? $var[2] : 'LIKE')));    				
106 106
 				}
107
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
107
+    		} elseif (!empty($var[1]) && is_numeric($var[0])) {
108 108
     			$criteria->add(new Criteria($var[0], $var[1]));
109 109
     		}
110 110
     	}
111 111
     	return $criteria;
112 112
     }
113 113
         
114
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
114
+    function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list') {
115 115
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
116 116
     	if (is_object($ele))
117 117
     		return $ele->render();
@@ -119,23 +119,23 @@  discard block
 block discarded – undo
119 119
     		return '&nbsp;';
120 120
     }
121 121
     
122
-	function GetCatAndSubCat($pid=0){
122
+	function GetCatAndSubCat($pid = 0) {
123 123
 		$categories = $this->getObjects(new Criteria('pid', $pid), true);
124 124
 		$langs_array = $this->TreeIDs(array(), $categories, -1);
125 125
 		return $langs_array;
126 126
 	}
127 127
 	
128 128
 	private function TreeIDs($langs_array, $categories, $level) {
129
-		foreach($categories as $catid => $category) {
129
+		foreach ($categories as $catid => $category) {
130 130
 			$langs_array[$catid] = $catid;
131
-			if ($categoriesb = $this->getObjects(new Criteria('pid', $catid), true)){
131
+			if ($categoriesb = $this->getObjects(new Criteria('pid', $catid), true)) {
132 132
 				$langs_array = $this->TreeIDs($langs_array, $categoriesb, $level);
133 133
 			}
134 134
 		}
135 135
 		return ($langs_array);
136 136
 	}
137 137
 	
138
-	function insert($obj, $force=true) {
138
+	function insert($obj, $force = true) {
139 139
     	if ($obj->isNew()) {
140 140
     		$obj->setVar('created', time());	
141 141
     	} else {
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
     	return $this->_objects['object'][$id];
160 160
     }
161 161
     
162
-    function delete($object, $force=true) {
162
+    function delete($object, $force = true) {
163 163
     	parent::delete($object, $force);
164
-    	$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `cid` = 0 WHERE `cid` = ' . $object->getVar('cid');
164
+    	$sql = 'UPDATE '.$GLOBALS['xoopsDB']->prefix('songlist_songs').' SET `cid` = 0 WHERE `cid` = '.$object->getVar('cid');
165 165
     	return $GLOBALS['xoopsDB']->queryF($sql);	
166 166
     }
167 167
     
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
     	return $ret;
191 191
     }
192 192
     
193
-	function getTop($limit=1) {
193
+	function getTop($limit = 1) {
194 194
     	$sql = 'SELECT * FROM `'.$this->table.'` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT '.$limit;
195 195
     	$results = $GLOBALS['xoopsDB']->queryF($sql);
196 196
     	$ret = array();
197
-    	$i=0;
197
+    	$i = 0;
198 198
     	while ($row = $GLOBALS['xoopsDB']->fetchArray($results)) {
199 199
     		$ret[$i] = $this->create();
200 200
     		$ret[$i]->assignVars($row);
Please login to merge, or discard this patch.
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -55,14 +55,17 @@  discard block
 block discarded – undo
55 55
 	}
56 56
     
57 57
 	function getImage($field = 'image', $local = false) {
58
-		if (strlen($this->getVar($field))==0)
59
-			return false;
60
-		if (!file_exists($GLOBALS['xoops']->path($this->getVar('path').$this->getVar($field))))
61
-			return false;
62
-		if ($local==false)
63
-    		return XOOPS_URL.'/'.str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
64
-    	else 
65
-    		return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
58
+		if (strlen($this->getVar($field))==0) {
59
+					return false;
60
+		}
61
+		if (!file_exists($GLOBALS['xoops']->path($this->getVar('path').$this->getVar($field)))) {
62
+					return false;
63
+		}
64
+		if ($local==false) {
65
+		    		return XOOPS_URL.'/'.str_replace(DS, '/', $this->getVar('path')).$this->getVar($field);
66
+		} else {
67
+    	    		return XOOPS_ROOT_PATH.DS.$this->getVar('path').$this->getVar($field);
68
+    	}
66 69
     }
67 70
     
68 71
     function getURL() {
@@ -113,10 +116,11 @@  discard block
 block discarded – undo
113 116
         
114 117
     function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
115 118
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
116
-    	if (is_object($ele))
117
-    		return $ele->render();
118
-    	else 
119
-    		return '&nbsp;';
119
+    	if (is_object($ele)) {
120
+    	    		return $ele->render();
121
+    	} else {
122
+    	    		return '&nbsp;';
123
+    	}
120 124
     }
121 125
     
122 126
 	function GetCatAndSubCat($pid=0){
@@ -141,8 +145,9 @@  discard block
 block discarded – undo
141 145
     	} else {
142 146
     		$obj->setVar('updated', time());
143 147
     	}
144
-    	if (strlen($obj->getVar('name'))==0)
145
-    		return false;
148
+    	if (strlen($obj->getVar('name'))==0) {
149
+    	    		return false;
150
+    	}
146 151
     	return parent::insert($obj, $force);
147 152
     }
148 153
 
Please login to merge, or discard this patch.
htdocs/modules/songlist/class/votes.php 3 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
 class SonglistVotes extends XoopsObject
11 11
 {
12 12
 
13
-    function SonglistVotes($fid = null)
14
-    {
15
-        $this->initVar('vid', XOBJ_DTYPE_INT, 0, false);
16
-        $this->initVar('sid', XOBJ_DTYPE_INT, 0, false);
17
-        $this->initVar('uid', XOBJ_DTYPE_INT, 0, false);
13
+	function SonglistVotes($fid = null)
14
+	{
15
+		$this->initVar('vid', XOBJ_DTYPE_INT, 0, false);
16
+		$this->initVar('sid', XOBJ_DTYPE_INT, 0, false);
17
+		$this->initVar('uid', XOBJ_DTYPE_INT, 0, false);
18 18
 		$this->initVar('ip', XOBJ_DTYPE_TXTBOX, null, false, 64);
19 19
 		$this->initVar('netaddy', XOBJ_DTYPE_TXTBOX, null, false, 255);
20 20
 		$this->initVar('rank', XOBJ_DTYPE_DECIMAL, 0, false);
@@ -40,109 +40,109 @@  discard block
 block discarded – undo
40 40
 
41 41
 class SonglistVotesHandler extends XoopsPersistableObjectHandler
42 42
 {
43
-    function __construct(&$db) 
44
-    {
45
-        parent::__construct($db, "songlist_votes", 'SonglistVotes', "vid", "ip");
46
-    }
43
+	function __construct(&$db) 
44
+	{
45
+		parent::__construct($db, "songlist_votes", 'SonglistVotes', "vid", "ip");
46
+	}
47 47
 
48 48
 	function filterFields() {
49 49
 		return array('vid', 'sid', 'uid', 'ip', 'netaddy', 'rank');
50 50
 	}
51 51
 	
52
-    function getFilterCriteria($filter) {
53
-    	$parts = explode('|', $filter);
54
-    	$criteria = new CriteriaCompo();
55
-    	foreach($parts as $part) {
56
-    		$var = explode(',', $part);
57
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
58
-    			$object = $this->create();
59
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
60
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
61
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
62
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
63
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
64
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
65
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
52
+	function getFilterCriteria($filter) {
53
+		$parts = explode('|', $filter);
54
+		$criteria = new CriteriaCompo();
55
+		foreach($parts as $part) {
56
+			$var = explode(',', $part);
57
+			if (!empty($var[1])&&!is_numeric($var[0])) {
58
+				$object = $this->create();
59
+				if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
60
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
61
+					$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
62
+				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
63
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
64
+							$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
65
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
66 66
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
67
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
67
+					$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
68 68
 				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
69
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
69
+					$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
70 70
 				}
71
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
72
-    			$criteria->add(new Criteria($var[0], $var[1]));
73
-    		}
74
-    	}
75
-    	return $criteria;
76
-    }
71
+			} elseif (!empty($var[1])&&is_numeric($var[0])) {
72
+				$criteria->add(new Criteria($var[0], $var[1]));
73
+			}
74
+		}
75
+		return $criteria;
76
+	}
77 77
         
78
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
79
-    	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
80
-    	if (is_object($ele))
81
-    		return $ele->render();
82
-    	else 
83
-    		return '&nbsp;';
84
-    }
78
+	function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
79
+		$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
80
+		if (is_object($ele))
81
+			return $ele->render();
82
+		else 
83
+			return '&nbsp;';
84
+	}
85 85
     
86 86
 	function insert($obj, $force=true) {
87
-    	if ($obj->isNew()) {
88
-    		$obj->setVar('created', time());	
89
-    	} else {
90
-    		$obj->setVar('updated', time());
91
-    	}
92
-    	return parent::insert($obj, $force);
93
-    }
87
+		if ($obj->isNew()) {
88
+			$obj->setVar('created', time());	
89
+		} else {
90
+			$obj->setVar('updated', time());
91
+		}
92
+		return parent::insert($obj, $force);
93
+	}
94 94
 
95
-    function addVote($sid, $value) {
95
+	function addVote($sid, $value) {
96 96
     	
97
-    	$criteria = new CriteriaCompo(new Criteria('sid', $sid));
97
+		$criteria = new CriteriaCompo(new Criteria('sid', $sid));
98 98
     	
99
-    	$ip = songlist_getIPData(false);
100
-    	if ($ip['uid']>0) {
101
-    		$criteria->add(new Criteria('uid', $ip['uid']));
102
-    	} else {
103
-    		$criteria->add(new Criteria('ip', $ip['ip']));
104
-    		$criteria->add(new Criteria('netaddy', $ip['network-addy']));
105
-    	}
99
+		$ip = songlist_getIPData(false);
100
+		if ($ip['uid']>0) {
101
+			$criteria->add(new Criteria('uid', $ip['uid']));
102
+		} else {
103
+			$criteria->add(new Criteria('ip', $ip['ip']));
104
+			$criteria->add(new Criteria('netaddy', $ip['network-addy']));
105
+		}
106 106
     	
107
-    	if ($this->getCount($criteria)==0&&$sid>0&&$value>0) {
108
-    		$vote = $this->create();
109
-    		$vote->setVar('sid', $sid);
110
-    		$vote->setVar('uid', $ip['uid']);
111
-    		$vote->setVar('ip', $ip['ip']);
112
-    		$vote->setVar('netaddy', $ip['network-addy']);
113
-    		$vote->setVar('rank', $value);
114
-    		if ($this->insert($vote)) {
115
-    			$songs_handler = xoops_getmodulehandler('songs', 'songlist');
116
-    			$albums_handler = xoops_getmodulehandler('albums', 'songlist');
117
-    			$artists_handler = xoops_getmodulehandler('artists', 'songlist');
118
-    			$category_handler = xoops_getmodulehandler('category', 'songlist');
119
-    			$genre_handler = xoops_getmodulehandler('genre', 'songlist');
107
+		if ($this->getCount($criteria)==0&&$sid>0&&$value>0) {
108
+			$vote = $this->create();
109
+			$vote->setVar('sid', $sid);
110
+			$vote->setVar('uid', $ip['uid']);
111
+			$vote->setVar('ip', $ip['ip']);
112
+			$vote->setVar('netaddy', $ip['network-addy']);
113
+			$vote->setVar('rank', $value);
114
+			if ($this->insert($vote)) {
115
+				$songs_handler = xoops_getmodulehandler('songs', 'songlist');
116
+				$albums_handler = xoops_getmodulehandler('albums', 'songlist');
117
+				$artists_handler = xoops_getmodulehandler('artists', 'songlist');
118
+				$category_handler = xoops_getmodulehandler('category', 'songlist');
119
+				$genre_handler = xoops_getmodulehandler('genre', 'songlist');
120 120
 				$voice_handler = xoops_getmodulehandler('voice', 'songlist');				
121 121
     			
122
-    			$song = $songs_handler->get($sid);
123
-    			$sql = array();
124
-    			$sql[] = "UPDATE `" . $songs_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $songs_handler->keyName . "` = " . $sid;
125
-    			$sql[] = "UPDATE `" . $category_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $category_handler->keyName . "` = " . $song->getVar($category_handler->keyName);
126
-    			$sql[] = "UPDATE `" . $genre_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $genre_handler->keyName . "` = " . $song->getVar($genre_handler->keyName);
122
+				$song = $songs_handler->get($sid);
123
+				$sql = array();
124
+				$sql[] = "UPDATE `" . $songs_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $songs_handler->keyName . "` = " . $sid;
125
+				$sql[] = "UPDATE `" . $category_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $category_handler->keyName . "` = " . $song->getVar($category_handler->keyName);
126
+				$sql[] = "UPDATE `" . $genre_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $genre_handler->keyName . "` = " . $song->getVar($genre_handler->keyName);
127 127
 				$sql[] = "UPDATE `" . $voice_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $voice_handler->keyName . "` = " . $song->getVar($voice_handler->keyName);
128
-    			$sql[] = "UPDATE `" . $albums_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $albums_handler->keyName . "` = " . $song->getVar($albums_handler->keyName);
129
-    			foreach($song->getVar('aids') as $aid) {
130
-    				$sql[] = "UPDATE `" . $artists_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $artists_handler->keyName . "` = " . $aid;
131
-    			}
132
-    			foreach($sql as $question) { 
133
-    				$GLOBALS['xoopsDB']->queryF($question);
134
-    			}
135
-    			redirect_header($_POST['uri'], 10, _MN_SONGLIST_MSG_VOTED_FINISHED);
136
-    			exit(0);
137
-    		} else {
138
-	    		redirect_header($_POST['uri'], 10, _MN_SONGLIST_MSG_VOTED_ALREADY);
139
-	    		exit(0);
140
-	    	}
141
-    	} else {
142
-    		redirect_header($_POST['uri'], 10, _MN_SONGLIST_MSG_VOTED_SOMETHINGWRONG);
143
-    		exit(0);
144
-    	}
145
-    	return false;
146
-    }
128
+				$sql[] = "UPDATE `" . $albums_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $albums_handler->keyName . "` = " . $song->getVar($albums_handler->keyName);
129
+				foreach($song->getVar('aids') as $aid) {
130
+					$sql[] = "UPDATE `" . $artists_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $artists_handler->keyName . "` = " . $aid;
131
+				}
132
+				foreach($sql as $question) { 
133
+					$GLOBALS['xoopsDB']->queryF($question);
134
+				}
135
+				redirect_header($_POST['uri'], 10, _MN_SONGLIST_MSG_VOTED_FINISHED);
136
+				exit(0);
137
+			} else {
138
+				redirect_header($_POST['uri'], 10, _MN_SONGLIST_MSG_VOTED_ALREADY);
139
+				exit(0);
140
+			}
141
+		} else {
142
+			redirect_header($_POST['uri'], 10, _MN_SONGLIST_MSG_VOTED_SOMETHINGWRONG);
143
+			exit(0);
144
+		}
145
+		return false;
146
+	}
147 147
 }
148 148
 ?>
149 149
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	function toArray() {
28 28
 		$ret = parent::toArray();
29 29
 		$form = $this->getForm(true);
30
-		foreach($form as $key => $element) {
30
+		foreach ($form as $key => $element) {
31 31
 			$ret['form'][$key] = $form[$key]->render();	
32 32
 		}
33 33
 		
34
-		$ret['rank'] = number_format($this->getVar('rank'),2)._MI_SONGLIST_OFTEN;
34
+		$ret['rank'] = number_format($this->getVar('rank'), 2)._MI_SONGLIST_OFTEN;
35 35
     		
36 36
 		return $ret;
37 37
 	}
@@ -52,30 +52,30 @@  discard block
 block discarded – undo
52 52
     function getFilterCriteria($filter) {
53 53
     	$parts = explode('|', $filter);
54 54
     	$criteria = new CriteriaCompo();
55
-    	foreach($parts as $part) {
55
+    	foreach ($parts as $part) {
56 56
     		$var = explode(',', $part);
57
-    		if (!empty($var[1])&&!is_numeric($var[0])) {
57
+    		if (!empty($var[1]) && !is_numeric($var[0])) {
58 58
     			$object = $this->create();
59
-    			if (		$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
60
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) 	{
61
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2])?$var[2]:'LIKE')));
62
-    			} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
59
+    			if ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTBOX || 
60
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_TXTAREA) {
61
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%'.$var[1].'%', (isset($var[2]) ? $var[2] : 'LIKE')));
62
+    			} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_INT || 
63 63
     						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_DECIMAL || 
64
-    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT ) 	{
65
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));			
66
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM ) 	{
67
-    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2])?$var[2]:'=')));    				
68
-				} elseif (	$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY ) 	{
69
-    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2])?$var[2]:'LIKE')));    				
64
+    						$object->vars[$var[0]]['data_type']==XOBJ_DTYPE_FLOAT) {
65
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));			
66
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ENUM) {
67
+    				$criteria->add(new Criteria('`'.$var[0].'`', $var[1], (isset($var[2]) ? $var[2] : '=')));    				
68
+				} elseif ($object->vars[$var[0]]['data_type']==XOBJ_DTYPE_ARRAY) {
69
+    				$criteria->add(new Criteria('`'.$var[0].'`', '%"'.$var[1].'";%', (isset($var[2]) ? $var[2] : 'LIKE')));    				
70 70
 				}
71
-    		} elseif (!empty($var[1])&&is_numeric($var[0])) {
71
+    		} elseif (!empty($var[1]) && is_numeric($var[0])) {
72 72
     			$criteria->add(new Criteria($var[0], $var[1]));
73 73
     		}
74 74
     	}
75 75
     	return $criteria;
76 76
     }
77 77
         
78
-    function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
78
+    function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list') {
79 79
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
80 80
     	if (is_object($ele))
81 81
     		return $ele->render();
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     		return '&nbsp;';
84 84
     }
85 85
     
86
-	function insert($obj, $force=true) {
86
+	function insert($obj, $force = true) {
87 87
     	if ($obj->isNew()) {
88 88
     		$obj->setVar('created', time());	
89 89
     	} else {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     		$criteria->add(new Criteria('netaddy', $ip['network-addy']));
105 105
     	}
106 106
     	
107
-    	if ($this->getCount($criteria)==0&&$sid>0&&$value>0) {
107
+    	if ($this->getCount($criteria)==0 && $sid>0 && $value>0) {
108 108
     		$vote = $this->create();
109 109
     		$vote->setVar('sid', $sid);
110 110
     		$vote->setVar('uid', $ip['uid']);
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
     			
122 122
     			$song = $songs_handler->get($sid);
123 123
     			$sql = array();
124
-    			$sql[] = "UPDATE `" . $songs_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $songs_handler->keyName . "` = " . $sid;
125
-    			$sql[] = "UPDATE `" . $category_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $category_handler->keyName . "` = " . $song->getVar($category_handler->keyName);
126
-    			$sql[] = "UPDATE `" . $genre_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $genre_handler->keyName . "` = " . $song->getVar($genre_handler->keyName);
127
-				$sql[] = "UPDATE `" . $voice_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $voice_handler->keyName . "` = " . $song->getVar($voice_handler->keyName);
128
-    			$sql[] = "UPDATE `" . $albums_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $albums_handler->keyName . "` = " . $song->getVar($albums_handler->keyName);
129
-    			foreach($song->getVar('aids') as $aid) {
130
-    				$sql[] = "UPDATE `" . $artists_handler->table . "` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `". $artists_handler->keyName . "` = " . $aid;
124
+    			$sql[] = "UPDATE `".$songs_handler->table."` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `".$songs_handler->keyName."` = ".$sid;
125
+    			$sql[] = "UPDATE `".$category_handler->table."` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `".$category_handler->keyName."` = ".$song->getVar($category_handler->keyName);
126
+    			$sql[] = "UPDATE `".$genre_handler->table."` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `".$genre_handler->keyName."` = ".$song->getVar($genre_handler->keyName);
127
+				$sql[] = "UPDATE `".$voice_handler->table."` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `".$voice_handler->keyName."` = ".$song->getVar($voice_handler->keyName);
128
+    			$sql[] = "UPDATE `".$albums_handler->table."` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `".$albums_handler->keyName."` = ".$song->getVar($albums_handler->keyName);
129
+    			foreach ($song->getVar('aids') as $aid) {
130
+    				$sql[] = "UPDATE `".$artists_handler->table."` SET `rank` = `rank` + ".$value.", `votes` = `votes` + 1 WHERE `".$artists_handler->keyName."` = ".$aid;
131 131
     			}
132
-    			foreach($sql as $question) { 
132
+    			foreach ($sql as $question) { 
133 133
     				$GLOBALS['xoopsDB']->queryF($question);
134 134
     			}
135 135
     			redirect_header($_POST['uri'], 10, _MN_SONGLIST_MSG_VOTED_FINISHED);
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -77,10 +77,11 @@
 block discarded – undo
77 77
         
78 78
     function getFilterForm($filter, $field, $sort='created', $op = 'dashboard', $fct='list') {
79 79
     	$ele = songlist_getFilterElement($filter, $field, $sort, $op, $fct);
80
-    	if (is_object($ele))
81
-    		return $ele->render();
82
-    	else 
83
-    		return '&nbsp;';
80
+    	if (is_object($ele)) {
81
+    	    		return $ele->render();
82
+    	} else {
83
+    	    		return '&nbsp;';
84
+    	}
84 85
     }
85 86
     
86 87
 	function insert($obj, $force=true) {
Please login to merge, or discard this patch.