From b7cd90bc287880a4304af161bbda46ee25e43808 Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 10 Jul 2012 15:25:29 -0400 Subject: [PATCH] CC-84: Smart Playlists -created form and view script --- .../controllers/PlaylistController.php | 9 ++ .../forms/SmartPlaylistCriteria.php | 121 ++++++++++++++++++ .../form/smart-playlist-criteria.phtml | 41 ++++++ .../views/scripts/playlist/playlist.phtml | 4 + .../airtime/library/smart_playlistbuilder.js | 12 ++ 5 files changed, 187 insertions(+) create mode 100644 airtime_mvc/application/forms/SmartPlaylistCriteria.php create mode 100644 airtime_mvc/application/views/scripts/form/smart-playlist-criteria.phtml create mode 100644 airtime_mvc/public/js/airtime/library/smart_playlistbuilder.js diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 892da79ce..1978011e4 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -72,6 +72,10 @@ class PlaylistController extends Zend_Controller_Action if (isset($pl)) { $formatter = new LengthFormatter($pl->getLength()); $this->view->length = $formatter->format(); + + $form = new Application_Form_SmartPlaylistCriteria(); + $form->removeDecorator('DtDdWrapper'); + $this->view->form = $form; $this->view->pl = $pl; $this->view->id = $pl->getId(); @@ -133,12 +137,15 @@ class PlaylistController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/smart_playlistbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']); try { if (isset($this->pl_sess->id)) { $pl = new Application_Model_Playlist($this->pl_sess->id); $this->view->pl = $pl; + $form = new Application_Form_SmartPlaylistCriteria(); + $this->view->form = $form; $formatter = new LengthFormatter($pl->getLength()); $this->view->length = $formatter->format(); @@ -169,6 +176,8 @@ class PlaylistController extends Zend_Controller_Action { $id = $this->_getParam('id', null); Logging::log("editing playlist {$id}"); + //$form = new Application_Form_SmartPlaylistCriteria(); + if (!is_null($id)) { $this->changePlaylist($id); diff --git a/airtime_mvc/application/forms/SmartPlaylistCriteria.php b/airtime_mvc/application/forms/SmartPlaylistCriteria.php new file mode 100644 index 000000000..a635963de --- /dev/null +++ b/airtime_mvc/application/forms/SmartPlaylistCriteria.php @@ -0,0 +1,121 @@ +setDecorators(array( + array('ViewScript', array('viewScript' => 'form/smart-playlist-criteria.phtml', 'ids' => $ids)) + )); + + $criteriaOptions = array( + 0 => "Select criteria", + "track_title" => "Title", + "artist_name" => "Artist", + "bit_rate" => "Bit Rate", + "sample_rate" => "Sample Rate", + "length" => "Length", + "album_title" => "Album", + "genre" => "Genre", + "year" => "Year", + "track_num" => "Track Number", + "bmp" => "Bpm", + "rating" => "Rating", + "disc_number" => "Disc Number", + "mood" => "Mood", + "label" => "Label", + "composer" => "Composer", + "lyricist" => "Lyricist", + "name" => "Name", + "isrc_number" => "ISRC Number", + "language" => "Language", + "utime" => "Date Added", + "mtime" => "Date Modified", + "comments" => "Comments", + "orchestra" => "Orchestra", + "composer" => "Composer", + "conductor" => "Conductor", + "radio_station_name" => "Radio Station Name", + "soundcloud_id" => "Soundcloud Upload" + ); + + $stringCriteriaOptions = array( + "contains", + "does not contain", + "is", + "is not", + "starts with", + "ends with" + ); + + $numericCriteriaOptions = array( + "is", + "is not", + "is greater than", + "is less than", + "is in the range" + ); + + $limitOptions = array( + "hours", + "minutes", + "items" + ); + + $spType = new Zend_Form_Element_Radio('sp_type'); + $spType->setLabel('Set smart playlist type:'); + $spType->setDecorators(array('viewHelper')); + $spType->setMultiOptions(array( + 'Static', + 'Dynamic' + )); + $spType->setValue('Static'); + $this->addElement($spType); + + foreach($ids as $id) { + $criteria = new Zend_Form_Element_Select('sp_criteria_'.$id); + $criteria->setAttrib('id', $id); + $criteria->setAttrib('class', 'input_select'); + $criteria->setDecorators(array('viewHelper')); + $criteria->setMultiOptions($criteriaOptions); + $this->addElement($criteria); + } + + foreach($ids as $id) { + $criteriaOptions = new Zend_Form_Element_Select('sp_criteria_options_'.$id); + $criteriaOptions->setAttrib('id', $id); + $criteriaOptions->setAttrib('class', 'input_select'); + $criteriaOptions->setDecorators(array('viewHelper')); + $criteriaOptions->setMultiOptions($stringCriteriaOptions); + $this->addElement($criteriaOptions); + } + + foreach($ids as $id) { + $criteriaValue = new Zend_Form_Element_Text('sp_criteria_value_'.$id); + $criteriaValue->setAttrib('id', $id); + $criteriaValue->setAttrib('class', 'input_text'); + $criteriaValue->setDecorators(array('viewHelper')); + $this->addElement($criteriaValue); + } + + $limitCheck = new Zend_Form_Element_Checkbox('sp_limit_check'); + $limitCheck->setLabel('Limit to'); + $limitCheck->setDecorators(array('viewHelper')); + $limitCheck->setValue(true); + $this->addElement($limitCheck); + + $limit = new Zend_Form_Element_Select('sp_limit_options'); + $limit->setAttrib('class', 'input_select'); + $limit->setDecorators(array('viewHelper')); + $limit->setMultiOptions($limitOptions); + $this->addElement($limit); + + $limitValue = new Zend_Form_Element_Text('sp_limit_value'); + $limitValue->setAttrib('class', 'input_text'); + $limitValue->setDecorators(array('viewHelper')); + $this->addElement($limitValue); + } +} \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/form/smart-playlist-criteria.phtml b/airtime_mvc/application/views/scripts/form/smart-playlist-criteria.phtml new file mode 100644 index 000000000..1a1cd6398 --- /dev/null +++ b/airtime_mvc/application/views/scripts/form/smart-playlist-criteria.phtml @@ -0,0 +1,41 @@ +
+
+Smart Playlist Options +
+
+ +
+ +
+ ids as $id) {?> + element->getElement('sp_criteria_'.$id) ?> + element->getElement('sp_criteria_options_'.$id) ?> + element->getElement('sp_criteria_value_'.$id) ?> + >Remove +
+ + Add +
+ +
+ +
+ +
+
+
\ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/playlist/playlist.phtml b/airtime_mvc/application/views/scripts/playlist/playlist.phtml index b01309bcf..5f958318c 100644 --- a/airtime_mvc/application/views/scripts/playlist/playlist.phtml +++ b/airtime_mvc/application/views/scripts/playlist/playlist.phtml @@ -30,6 +30,10 @@ + + form; ?>