From a28d8ce30574449a5208f8326923082585956dcb Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sun, 3 Apr 2011 17:34:44 -0400 Subject: [PATCH] CC-2145 : Redesign & layout fixes for the Preferences screen view templates are all done, form works. just need javascript. --- .zfproject.xml | 2 + .../controllers/PreferenceController.php | 26 ++-- application/forms/GeneralPreferences.php | 65 ++++++++ application/forms/Preferences.php | 141 ++---------------- application/forms/SoundcloudPreferences.php | 115 ++++++++++++++ .../views/scripts/form/preferences.phtml | 14 ++ .../scripts/form/preferences_general.phtml | 50 +++++++ .../scripts/form/preferences_soundcloud.phtml | 46 ++++++ .../views/scripts/preference/index.phtml | 3 +- 9 files changed, 321 insertions(+), 141 deletions(-) create mode 100644 application/forms/GeneralPreferences.php create mode 100644 application/forms/SoundcloudPreferences.php create mode 100644 application/views/scripts/form/preferences.phtml create mode 100644 application/views/scripts/form/preferences_general.phtml create mode 100644 application/views/scripts/form/preferences_soundcloud.phtml diff --git a/.zfproject.xml b/.zfproject.xml index cb27bbd9d..48c691121 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -125,6 +125,8 @@ + + diff --git a/application/controllers/PreferenceController.php b/application/controllers/PreferenceController.php index c3a40b3e3..1dcb4bd38 100644 --- a/application/controllers/PreferenceController.php +++ b/application/controllers/PreferenceController.php @@ -22,22 +22,24 @@ class PreferenceController extends Zend_Controller_Action if (!$this->getRequest()->isPost()) { return $this->_forward('Preference/index'); } - + $form = new Application_Form_Preferences(); if ($form->isValid($request->getPost())) { $values = $form->getValues(); - Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view); - Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]); - Application_Model_Preference::SetStreamLabelFormat($values["streamFormat"]); - Application_Model_Preference::SetAllow3rdPartyApi($values["thirdPartyApi"]); - Application_Model_Preference::SetDoSoundCloudUpload($values["UseSoundCloud"]); - Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]); - Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]); - Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]); - Application_Model_Preference::SetSoundCloudGenre($values["SoundCloudGenre"]); - Application_Model_Preference::SetSoundCloudTrackType($values["SoundCloudTrackType"]); - Application_Model_Preference::SetSoundCloudLicense($values["SoundCloudLicense"]); + + Application_Model_Preference::SetHeadTitle($values["preferences_general"]["stationName"], $this->view); + Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]); + Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]); + Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]); + + Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]); + Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]); + Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]); + Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]); + Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]); + Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]); + Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]); $this->view->statusMsg = "
Preferences updated.
"; } diff --git a/application/forms/GeneralPreferences.php b/application/forms/GeneralPreferences.php new file mode 100644 index 000000000..4f3630f90 --- /dev/null +++ b/application/forms/GeneralPreferences.php @@ -0,0 +1,65 @@ +setDecorators(array( + array('ViewScript', array('viewScript' => 'form/preferences_general.phtml')) + )); + + //Station name + $this->addElement('text', 'stationName', array( + 'class' => 'input_text', + 'label' => 'Station Name:', + 'required' => true, + 'filters' => array('StringTrim'), + 'validators' => array('NotEmpty'), + 'value' => Application_Model_Preference::GetValue("station_name"), + 'decorators' => array( + 'ViewHelper' + ) + )); + + $defaultFade = Application_Model_Preference::GetDefaultFade(); + if($defaultFade == ""){ + $defaultFade = '00:00:00.000000'; + } + + //Default station fade + $this->addElement('text', 'stationDefaultFade', array( + 'class' => 'input_text', + 'label' => 'Default Fade:', + 'required' => false, + 'filters' => array('StringTrim'), + 'validators' => array(array('regex', false, + array('/^[0-2][0-3]:[0-5][0-9]:[0-5][0-9](\.\d{1,6})?$/', + 'messages' => 'enter a time 00:00:00{.000000}'))), + 'value' => $defaultFade, + 'decorators' => array( + 'ViewHelper' + ) + )); + + $stream_format = new Zend_Form_Element_Radio('streamFormat'); + $stream_format->setLabel('Stream Label:'); + $stream_format->setMultiOptions(array("Artist - Title", + "Show - Artist - Title", + "Station name - Show name")); + $stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat()); + $stream_format->setDecorators(array('ViewHelper')); + $this->addElement($stream_format); + + $third_party_api = new Zend_Form_Element_Radio('thirdPartyApi'); + $third_party_api->setLabel('Allow Remote Websites To Access Show Schedule Info'); + $third_party_api->setMultiOptions(array("Disabled", + "Enabled")); + $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); + $third_party_api->setDecorators(array('ViewHelper')); + $this->addElement($third_party_api); + } + + +} + diff --git a/application/forms/Preferences.php b/application/forms/Preferences.php index edb69b1b6..c86fa6492 100644 --- a/application/forms/Preferences.php +++ b/application/forms/Preferences.php @@ -6,139 +6,24 @@ class Application_Form_Preferences extends Zend_Form public function init() { $this->setAction('/Preference/update')->setMethod('post'); + + $this->setDecorators(array( + array('ViewScript', array('viewScript' => 'form/preferences.phtml')) + )); - //Station name - $this->addElement('text', 'stationName', array( - 'class' => 'input_text', - 'label' => 'Station Name:', - 'required' => true, - 'filters' => array('StringTrim'), - 'validators' => array('NotEmpty'), - 'value' => Application_Model_Preference::GetValue("station_name") - )); + $general_pref = new Application_Form_GeneralPreferences(); + $this->addSubForm($general_pref, 'preferences_general'); - $defaultFade = Application_Model_Preference::GetDefaultFade(); - if($defaultFade == ""){ - $defaultFade = '00:00:00.000000'; - } - - //Default station fade - $this->addElement('text', 'stationDefaultFade', array( - 'class' => 'input_text', - 'label' => 'Default Fade:', - 'required' => false, - 'filters' => array('StringTrim'), - 'validators' => array(array('regex', false, - array('/^[0-2][0-3]:[0-5][0-9]:[0-5][0-9](\.\d{1,6})?$/', - 'messages' => 'enter a time 00:00:00{.000000}'))), - 'value' => $defaultFade - )); - - $stream_format = new Zend_Form_Element_Radio('streamFormat'); - $stream_format->setLabel('Stream Label:'); - $stream_format->setMultiOptions(array("Artist - Title", - "Show - Artist - Title", - "Station name - Show name")); - $stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat()); - $this->addElement($stream_format); - - $third_party_api = new Zend_Form_Element_Radio('thirdPartyApi'); - $third_party_api->setLabel('Allow Remote Websites To Access Show Schedule Info'); - $third_party_api->setMultiOptions(array("Disabled", - "Enabled")); - $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); - $this->addElement($third_party_api); - - - $this->addElement('checkbox', 'UseSoundCloud', array( - 'label' => 'Automatically Upload Recorded Shows To SoundCloud', - 'required' => false, - 'value' => Application_Model_Preference::GetDoSoundCloudUpload() - )); - - //SoundCloud Username - $this->addElement('text', 'SoundCloudUser', array( - 'class' => 'input_text', - 'label' => 'SoundCloud Email:', - 'required' => false, - 'filters' => array('StringTrim'), - 'value' => Application_Model_Preference::GetSoundCloudUser() - )); - - //SoundCloud Password - $this->addElement('password', 'SoundCloudPassword', array( - 'class' => 'input_text', - 'label' => 'SoundCloud Password:', - 'required' => false, - 'filters' => array('StringTrim'), - 'value' => Application_Model_Preference::GetSoundCloudPassword() - )); - - // Add the description element - $this->addElement('textarea', 'SoundCloudTags', array( - 'label' => 'space separated SoundCloud Tags', - 'required' => false, - 'class' => 'input_text_area', - 'value' => Application_Model_Preference::GetSoundCloudTags() - )); - - //SoundCloud default genre - $this->addElement('text', 'SoundCloudGenre', array( - 'class' => 'input_text', - 'label' => 'Default Genre:', - 'required' => false, - 'filters' => array('StringTrim'), - 'value' => Application_Model_Preference::GetSoundCloudGenre() - )); - - $select = new Zend_Form_Element_Select('SoundCloudTrackType'); - $select->setLabel('Default Track Type:'); - $select->setAttrib('class', 'input_select'); - $select->setMultiOptions(array( - "" => "", - "original" => "Original", - "remix" => "Remix", - "live" => "Live", - "recording" => "Recording", - "spoken" => "Spoken", - "podcast" => "Podcast", - "demo" => "Demo", - "in progress" => "Work in progress", - "stem" => "Stem", - "loop" => "Loop", - "sound effect" => "Sound Effect", - "sample" => "One Shot Sample", - "other" => "Other" - )); - $select->setRequired(false); - $select->setValue(Application_Model_Preference::GetSoundCloudTrackType()); - $this->addElement($select); - - $select = new Zend_Form_Element_Select('SoundCloudLicense'); - $select->setLabel('Default License:'); - $select->setAttrib('class', 'input_select'); - $select->setMultiOptions(array( - "" => "", - "no-rights-reserved" => "The work is in the public domain", - "all-rights-reserved" => "All rights are reserved", - "cc-by" => "Creative Commons Attribution", - "cc-by-nc" => "Creative Commons Attribution Noncommercial", - "cc-by-nd" => "Creative Commons Attribution No Derivative Works", - "cc-by-sa" => "Creative Commons Attribution Share Alike", - "cc-by-nc-nd" => "Creative Commons Attribution Noncommercial Non Derivate Works", - "cc-by-nc-sa" => "Creative Commons Attribution Noncommercial Share Alike" - )); - $select->setRequired(false); - $select->setValue(Application_Model_Preference::GetSoundCloudLicense()); - $this->addElement($select); + $soundcloud_pref = new Application_Form_SoundcloudPreferences(); + $this->addSubForm($soundcloud_pref, 'preferences_soundcloud'); $this->addElement('submit', 'submit', array( - 'class' => 'ui-button ui-state-default', + 'class' => 'ui-button ui-state-default right-floated', 'ignore' => true, 'label' => 'Submit', - )); - - - + 'decorators' => array( + 'ViewHelper' + ) + )); } } diff --git a/application/forms/SoundcloudPreferences.php b/application/forms/SoundcloudPreferences.php new file mode 100644 index 000000000..96bbaee89 --- /dev/null +++ b/application/forms/SoundcloudPreferences.php @@ -0,0 +1,115 @@ +setDecorators(array( + array('ViewScript', array('viewScript' => 'form/preferences_soundcloud.phtml')) + )); + + //enable soundcloud uploads + $this->addElement('checkbox', 'UseSoundCloud', array( + 'label' => 'Automatically Upload Recorded Shows To SoundCloud', + 'required' => false, + 'value' => Application_Model_Preference::GetDoSoundCloudUpload(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + //SoundCloud Username + $this->addElement('text', 'SoundCloudUser', array( + 'class' => 'input_text', + 'label' => 'SoundCloud Email:', + 'required' => false, + 'filters' => array('StringTrim'), + 'value' => Application_Model_Preference::GetSoundCloudUser(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + //SoundCloud Password + $this->addElement('password', 'SoundCloudPassword', array( + 'class' => 'input_text', + 'label' => 'SoundCloud Password:', + 'required' => false, + 'filters' => array('StringTrim'), + 'value' => Application_Model_Preference::GetSoundCloudPassword(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + // Add the description element + $this->addElement('textarea', 'SoundCloudTags', array( + 'label' => 'space separated SoundCloud Tags', + 'required' => false, + 'class' => 'input_text_area', + 'value' => Application_Model_Preference::GetSoundCloudTags(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + //SoundCloud default genre + $this->addElement('text', 'SoundCloudGenre', array( + 'class' => 'input_text', + 'label' => 'Default Genre:', + 'required' => false, + 'filters' => array('StringTrim'), + 'value' => Application_Model_Preference::GetSoundCloudGenre(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + $select = new Zend_Form_Element_Select('SoundCloudTrackType'); + $select->setLabel('Default Track Type:'); + $select->setAttrib('class', 'input_select'); + $select->setMultiOptions(array( + "" => "", + "original" => "Original", + "remix" => "Remix", + "live" => "Live", + "recording" => "Recording", + "spoken" => "Spoken", + "podcast" => "Podcast", + "demo" => "Demo", + "in progress" => "Work in progress", + "stem" => "Stem", + "loop" => "Loop", + "sound effect" => "Sound Effect", + "sample" => "One Shot Sample", + "other" => "Other" + )); + $select->setRequired(false); + $select->setValue(Application_Model_Preference::GetSoundCloudTrackType()); + $select->setDecorators(array('ViewHelper')); + $this->addElement($select); + + $select = new Zend_Form_Element_Select('SoundCloudLicense'); + $select->setLabel('Default License:'); + $select->setAttrib('class', 'input_select'); + $select->setMultiOptions(array( + "" => "", + "no-rights-reserved" => "The work is in the public domain", + "all-rights-reserved" => "All rights are reserved", + "cc-by" => "Creative Commons Attribution", + "cc-by-nc" => "Creative Commons Attribution Noncommercial", + "cc-by-nd" => "Creative Commons Attribution No Derivative Works", + "cc-by-sa" => "Creative Commons Attribution Share Alike", + "cc-by-nc-nd" => "Creative Commons Attribution Noncommercial Non Derivate Works", + "cc-by-nc-sa" => "Creative Commons Attribution Noncommercial Share Alike" + )); + $select->setRequired(false); + $select->setValue(Application_Model_Preference::GetSoundCloudLicense()); + $select->setDecorators(array('ViewHelper')); + $this->addElement($select); + } + + +} + diff --git a/application/views/scripts/form/preferences.phtml b/application/views/scripts/form/preferences.phtml new file mode 100644 index 000000000..8694d5115 --- /dev/null +++ b/application/views/scripts/form/preferences.phtml @@ -0,0 +1,14 @@ +
+ + element->getSubform('preferences_general') ?> + +

SoundCloud settings

+
+ element->getSubform('preferences_soundcloud') ?> +
+ +
+ element->getElement('submit') ?> +
+ +
diff --git a/application/views/scripts/form/preferences_general.phtml b/application/views/scripts/form/preferences_general.phtml new file mode 100644 index 000000000..ce4654a09 --- /dev/null +++ b/application/views/scripts/form/preferences_general.phtml @@ -0,0 +1,50 @@ +
+
+ +
+ +
+
+ element->getElement('stationName') ?> +
+
+ +
+
+ element->getElement('stationDefaultFade') ?> +
+
+ +
+
+ element->getElement('streamFormat')->getValue(); + ?> + element->getElement('streamFormat')->getMultiOptions() as $radio) : ?> + + + +
+
+ +
+
+ element->getElement('thirdPartyApi')->getValue(); + ?> + element->getElement('thirdPartyApi')->getMultiOptions() as $radio) : ?> + + + +
+ +
+
diff --git a/application/views/scripts/form/preferences_soundcloud.phtml b/application/views/scripts/form/preferences_soundcloud.phtml new file mode 100644 index 000000000..ea0c46202 --- /dev/null +++ b/application/views/scripts/form/preferences_soundcloud.phtml @@ -0,0 +1,46 @@ +
+
+
+ +
+
+ +
+
+ element->getElement('SoundCloudUser') ?> +
+
+ +
+
+ element->getElement('SoundCloudPassword') ?> +
+
+ +
+
+ element->getElement('SoundCloudTags') ?> +
+
+ +
+
+ element->getElement('SoundCloudGenre') ?> +
+
+ +
+
+ element->getElement('SoundCloudTrackType') ?> +
+
+ +
+
+ element->getElement('SoundCloudLicense') ?> +
+
+
diff --git a/application/views/scripts/preference/index.phtml b/application/views/scripts/preference/index.phtml index 68cb33a1b..b5cf1fd4b 100644 --- a/application/views/scripts/preference/index.phtml +++ b/application/views/scripts/preference/index.phtml @@ -1,4 +1,5 @@ -
+
+

Preferences

statusMsg; echo $this->form;