2012-08-21 22:55:10 +02:00
|
|
|
<?php
|
|
|
|
|
2012-08-29 16:58:03 +02:00
|
|
|
class Application_Model_Library
|
2012-08-21 22:55:10 +02:00
|
|
|
{
|
|
|
|
public static function getObjInfo($p_type)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$info = [];
|
2012-08-29 16:58:03 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if (strcmp($p_type, 'playlist') == 0) {
|
2012-08-21 22:55:10 +02:00
|
|
|
$info['className'] = 'Application_Model_Playlist';
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif (strcmp($p_type, 'block') == 0) {
|
2012-08-21 22:55:10 +02:00
|
|
|
$info['className'] = 'Application_Model_Block';
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif (strcmp($p_type, 'webstream') == 0) {
|
2012-08-21 22:55:10 +02:00
|
|
|
$info['className'] = 'Application_Model_Webstream';
|
2012-08-22 21:56:18 +02:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception("Unknown object type: '{$p_type}'");
|
2012-08-21 22:55:10 +02:00
|
|
|
}
|
2012-08-29 16:58:03 +02:00
|
|
|
|
2012-08-21 22:55:10 +02:00
|
|
|
return $info;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function changePlaylist($p_id, $p_type)
|
|
|
|
{
|
|
|
|
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
|
|
|
|
|
|
|
|
if (is_null($p_id) || is_null($p_type)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
unset($obj_sess->id, $obj_sess->type);
|
2012-08-21 22:55:10 +02:00
|
|
|
} else {
|
|
|
|
$obj_sess->id = intval($p_id);
|
|
|
|
$obj_sess->type = $p_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-31 04:45:29 +02:00
|
|
|
public static function getPlaylistNames($alphasort = false)
|
2017-03-10 16:20:44 +01:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$playlistNames = [null => _('None')];
|
2022-03-14 11:15:04 +01:00
|
|
|
// if we want to return the playlists sorted alphabetically by name
|
2017-03-31 04:45:29 +02:00
|
|
|
if ($alphasort) {
|
|
|
|
$playlists = CcPlaylistQuery::create()
|
|
|
|
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
|
|
|
->orderByname()
|
2022-01-23 19:15:55 +01:00
|
|
|
->find();
|
2021-10-11 16:10:47 +02:00
|
|
|
} else {
|
2017-03-31 04:45:29 +02:00
|
|
|
$playlists = CcPlaylistQuery::create()
|
|
|
|
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
2022-01-23 19:15:55 +01:00
|
|
|
->find();
|
2017-03-31 04:45:29 +02:00
|
|
|
}
|
2017-03-10 16:20:44 +01:00
|
|
|
foreach ($playlists as $playlist) {
|
|
|
|
$playlistNames[$playlist->getDbId()] = $playlist->getDbName();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $playlistNames;
|
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
|
|
|
public static function getTracktypes()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$track_type_options = [null => _('None')];
|
2020-05-04 06:32:52 +02:00
|
|
|
$track_types = Application_Model_Tracktype::getTracktypes();
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
array_multisort(array_map(function ($element) {
|
2020-12-16 07:28:14 +01:00
|
|
|
return $element['type_name'];
|
|
|
|
}, $track_types), SORT_ASC, $track_types);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2020-05-04 06:32:52 +02:00
|
|
|
foreach ($track_types as $key => $tt) {
|
2022-06-08 16:31:01 +02:00
|
|
|
$track_type_options[$tt['id']] = $tt['type_name'];
|
2020-05-04 06:32:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $track_type_options;
|
|
|
|
}
|
2012-08-21 22:55:10 +02:00
|
|
|
}
|