sort autoplaylists alphabetically

This commit is contained in:
Robb Ebright 2017-03-30 22:45:29 -04:00
parent 4b9a105a89
commit 0fdd6d8d57
2 changed files with 15 additions and 6 deletions

View File

@ -23,7 +23,7 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm
$autoPlaylistSelect = new Zend_Form_Element_Select("add_show_autoplaylist_id");
$autoPlaylistSelect->setLabel(_("Select Playlist"));
$autoPlaylistSelect->setMultiOptions(Application_Model_Library::getPlaylistNames());
$autoPlaylistSelect->setMultiOptions(Application_Model_Library::getPlaylistNames(true));
$autoPlaylistSelect->setValue(null);
$autoPlaylistSelect->setDecorators(array('ViewHelper'));
$this->addElement($autoPlaylistSelect);

View File

@ -33,14 +33,23 @@ class Application_Model_Library
}
}
public static function getPlaylistNames()
public static function getPlaylistNames($alphasort = false)
{
$playlistNames = array(NULL => _("None"));
//if we want to return the playlists sorted alphabetically by name
if ($alphasort) {
$playlists = CcPlaylistQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->orderByname()
->find();
$playlists = CcPlaylistQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->find();
}
else {
$playlists = CcPlaylistQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->find();
}
foreach ($playlists as $playlist) {
$playlistNames[$playlist->getDbId()] = $playlist->getDbName();
}