1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
if (!defined('XOOPS_ROOT_PATH')) { |
4
|
|
|
exit(); |
5
|
|
|
} |
6
|
|
|
|
7
|
|
|
include_once(dirname(dirname(__FILE__)).'/include/songlist.object.php'); |
8
|
|
|
include_once(dirname(dirname(__FILE__)).'/include/songlist.form.php'); |
9
|
|
|
|
10
|
|
|
class SonglistSongs extends XoopsObject |
11
|
|
|
{ |
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); |
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); |
21
|
|
|
$this->initVar('songid', XOBJ_DTYPE_TXTBOX, null, false, 32); |
22
|
|
|
$this->initVar('traxid', XOBJ_DTYPE_TXTBOX, null, false, 32); |
23
|
|
|
$this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false, 128); |
24
|
|
|
$this->initVar('lyrics', XOBJ_DTYPE_OTHER, null, false); |
25
|
|
|
$this->initVar('hits', XOBJ_DTYPE_INT, 0, false); |
26
|
|
|
$this->initVar('rank', XOBJ_DTYPE_DECIMAL, 0, false); |
27
|
|
|
$this->initVar('votes', XOBJ_DTYPE_INT, 0, false); |
28
|
|
|
$this->initVar('tags', XOBJ_DTYPE_TXTBOX, null, false, 255); |
29
|
|
|
$this->initVar('mp3', XOBJ_DTYPE_OTHER, null, false, 500); |
30
|
|
|
$this->initVar('created', XOBJ_DTYPE_INT, 0, false); |
31
|
|
|
$this->initVar('updated', XOBJ_DTYPE_INT, 0, false); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
function getForm($as_array = false) { |
|
|
|
|
35
|
|
|
return songlist_songs_get_form($this, $as_array); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
function toArray($extra = true) { |
|
|
|
|
39
|
|
|
$ret = parent::toArray(); |
40
|
|
|
|
41
|
|
|
$GLOBALS['myts'] = MyTextSanitizer::getInstance(); |
42
|
|
|
|
43
|
|
|
$ret['lyrics'] = $GLOBALS['myts']->displayTarea($this->getVar('lyrics'), true, true, true, true, true); |
44
|
|
|
|
45
|
|
|
$form = $this->getForm(true); |
46
|
|
|
foreach($form as $key => $element) { |
47
|
|
|
$ret['form'][$key] = $form[$key]->render(); |
48
|
|
|
} |
49
|
|
|
foreach(array('created', 'updated') as $key) { |
50
|
|
|
if ($this->getVar($key)>0) { |
51
|
|
|
$ret['form'][$key] = date(_DATESTRING, $this->getVar($key)); |
52
|
|
|
$ret[$key] = date(_DATESTRING, $this->getVar($key)); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$ret['url'] = $this->getURL(); |
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; |
59
|
|
|
|
60
|
|
|
if (!empty($ret['mp3'])) { |
61
|
|
|
$ret['mp3'] = "<embed flashvars=\"playerID=1&bg=0xf8f8f8&leftbg=0x3786b3&lefticon=0x78bee3&rightbg=0x3786b3&rightbghover=0x78bee3&righticon=0x78bee3&righticonhover=0x3786b3&text=0x666666&slider=0x3786b3&track=0xcccccc&border=0x666666&loader=0x78bee3&loop=no&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
|
|
|
} |
63
|
|
|
|
64
|
|
|
if (file_exists($GLOBALS['xoops']->path("/modules/tag/include/tagbar.php"))&&$GLOBALS['songlistModuleConfig']['tags']) { |
65
|
|
|
include_once XOOPS_ROOT_PATH."/modules/tag/include/tagbar.php"; |
66
|
|
|
$ret['tagbar'] = tagBar($this->getVar('sid'), $this->getVar('cid')); |
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
$extras_handler = xoops_getmodulehandler('extras', 'songlist'); |
70
|
|
|
$field_handler = xoops_getmodulehandler('field', 'songlist'); |
71
|
|
|
$visibility_handler = xoops_getmodulehandler('visibility', 'songlist'); |
72
|
|
|
|
73
|
|
|
if ($extras = $extras_handler->get($this->getVar('sid'))) { |
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()); |
79
|
|
|
|
80
|
|
|
if (count($fields_id)>0) { |
|
|
|
|
81
|
|
|
$criteria = new Criteria('field_id', '('.implode(',',$fields_id).')', 'IN'); |
82
|
|
|
$criteria->setSort('field_weight'); |
83
|
|
|
$fields = $field_handler->getObjects($criteria, true); |
|
|
|
|
84
|
|
|
foreach($fields as $id => $field) { |
85
|
|
|
if (in_array($this->getVar('cid'), $field->getVar('cids'))) { |
86
|
|
|
$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'))); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
if ($extra==false) |
97
|
|
|
return $ret; |
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
|
|
|
} |
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
|
|
|
} |
121
|
|
|
|
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
|
|
|
} |
129
|
|
|
|
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; |
136
|
|
|
} |
137
|
|
|
|
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
|
|
|
} |
146
|
|
|
|
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
|
150
|
|
|
class SonglistSongsHandler extends XoopsPersistableObjectHandler |
151
|
|
|
{ |
152
|
|
|
function __construct(&$db) |
|
|
|
|
153
|
|
|
{ |
154
|
|
|
$module_handler = xoops_gethandler('module'); |
155
|
|
|
$config_handler = xoops_gethandler('config'); |
156
|
|
|
$GLOBALS['songlistModule'] = $module_handler->getByDirname('songlist'); |
|
|
|
|
157
|
|
|
$GLOBALS['songlistModuleConfig'] = $config_handler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
|
|
|
|
158
|
|
|
|
159
|
|
|
parent::__construct($db, "songlist_songs", 'SonglistSongs', "sid", "title"); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
function filterFields() { |
|
|
|
|
163
|
|
|
return array('sid', 'cid', 'mp3', 'gid', 'vcid', 'aids', 'abid', 'songid', 'title', 'lyrics', 'hits', 'rank', 'votes', 'tags', 'created', 'updated'); |
164
|
|
|
} |
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]:'='))); |
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
|
|
|
} |
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
|
|
|
|
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 ' '; |
198
|
|
|
} |
199
|
|
|
|
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
|
|
|
} |
210
|
|
|
|
211
|
|
|
$albums_handler = xoops_getmodulehandler('albums', 'songlist'); |
212
|
|
|
$artists_handler = xoops_getmodulehandler('artists', 'songlist'); |
213
|
|
|
$genre_handler = xoops_getmodulehandler('genre', 'songlist'); |
214
|
|
|
$voice_handler = xoops_getmodulehandler('voice', 'songlist'); |
215
|
|
|
$category_handler = xoops_getmodulehandler('category', 'songlist'); |
216
|
|
|
|
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
|
|
|
} |
233
|
|
|
|
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
|
|
|
} |
250
|
|
|
|
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
|
|
|
} |
268
|
|
|
if (!$old->isNew()&&$old->getVar('cid')>0) { |
269
|
|
|
$category = $category_handler->get($old->vars['cid']['value']); |
270
|
|
|
if (is_object($category)) { |
271
|
|
|
$category->setVar('songs', $category->getVar('songs')-1); |
272
|
|
|
$category_handler->insert($category, true, null); |
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
|
|
|
} |
285
|
|
|
} |
286
|
|
|
} |
287
|
|
|
} |
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
|
|
|
} |
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)) { |
351
|
|
|
$voice->setVar('albums', $voice->getVar('albums')-1); |
352
|
|
|
$voice_handler->insert($voice, true, null); |
353
|
|
|
} |
354
|
|
|
} |
355
|
|
|
} |
356
|
|
|
} |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
if (strlen($obj->getVar('title'))==0) |
360
|
|
|
return false; |
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
|
|
|
} |
372
|
|
|
if (count($obj->getVar('aids'))>0) { |
373
|
|
|
foreach($obj->getVar('aids') as $aid) { |
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
|
|
|
} |
385
|
|
|
|
386
|
|
|
var $_objects = array('object'=>array(), 'array'=>array()); |
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
|
|
|
} |
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'])) { |
402
|
|
|
foreach($ret as $data) { |
403
|
|
|
$id = array(); |
404
|
|
|
if ($as_object==true) { |
405
|
|
|
if (!in_array($data->getVar($this->keyName), array_keys($this->_objects['object']))) { |
406
|
|
|
$this->_objects['object'][$data->getVar($this->keyName)] = $data; |
407
|
|
|
$id[$data->getVar($this->keyName)] = $data->getVar($this->keyName); |
408
|
|
|
} |
409
|
|
|
} else { |
410
|
|
|
if (!in_array($data[$this->keyName], array_keys($this->_objects['array']))) { |
411
|
|
|
$this->_objects['array'][$data[$this->keyName]] = $data; |
412
|
|
|
$id[$data[$this->keyName]] = $data[$this->keyName];; |
413
|
|
|
} |
414
|
|
|
} |
415
|
|
|
} |
416
|
|
|
} |
417
|
|
|
if (!isset($GLOBALS['songlistAdmin'])&&count($id)>0) { |
418
|
|
|
$sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` IN ('.implode(',', $id).')'; |
419
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
420
|
|
|
}*/ |
421
|
|
|
return $ret; |
422
|
|
|
} |
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
|
|
|
} |
442
|
|
|
|
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
|
|
|
} |
452
|
|
|
|
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
|
|
|
} |
465
|
|
|
} |
466
|
|
|
?> |
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.