libretime/legacy/application/models/Library.php

71 lines
2.1 KiB
PHP
Raw Permalink Normal View History

<?php
class Application_Model_Library
{
public static function getObjInfo($p_type)
{
2021-10-11 16:10:47 +02:00
$info = [];
2021-10-11 16:10:47 +02:00
if (strcmp($p_type, 'playlist') == 0) {
$info['className'] = 'Application_Model_Playlist';
2021-10-11 16:10:47 +02:00
} elseif (strcmp($p_type, 'block') == 0) {
$info['className'] = 'Application_Model_Block';
2021-10-11 16:10:47 +02:00
} elseif (strcmp($p_type, 'webstream') == 0) {
$info['className'] = 'Application_Model_Webstream';
} else {
2021-10-11 16:10:47 +02:00
throw new Exception("Unknown object type: '{$p_type}'");
}
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);
} 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')];
// 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()
->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)
->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) {
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) {
$track_type_options[$tt['id']] = $tt['type_name'];
2020-05-04 06:32:52 +02:00
}
return $track_type_options;
}
}