diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 84718c66d..767fd3b62 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -34,15 +34,11 @@ class PreferenceController extends Zend_Controller_Action $form = new Application_Form_Preferences(); $values = array(); - if ($request->isPost()) { - $params = $request->getPost(); - $postData = explode('&', $params['data']); - foreach($postData as $k=>$v) { - $v = explode('=', $v); - $values[$v[0]] = urldecode($v[1]); - } - if ($form->isValid($values)) { + if ($request->isPost()) { + $values = $request->getPost(); + if ($form->isValid($values)) + { Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view); Application_Model_Preference::SetDefaultCrossfadeDuration($values["stationDefaultCrossfadeDuration"]); Application_Model_Preference::SetDefaultFadeIn($values["stationDefaultFadeIn"]); @@ -52,6 +48,11 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetDefaultTimezone($values["timezone"]); Application_Model_Preference::SetWeekStartDay($values["weekStartDay"]); + $logoUploadElement = $form->getSubForm('preferences_general')->getElement('stationLogo'); + $logoUploadElement->receive(); + $imagePath = $logoUploadElement->getFileName(); + Application_Model_Preference::SetStationLogo($imagePath); + Application_Model_Preference::SetEnableSystemEmail($values["enableSystemEmail"]); Application_Model_Preference::SetSystemEmail($values["systemEmail"]); Application_Model_Preference::SetMailServerConfigured($values["configureMailServer"]); @@ -73,12 +74,14 @@ class PreferenceController extends Zend_Controller_Action $this->view->statusMsg = "
". _("Preferences updated.")."
"; $this->view->form = $form; - $this->_helper->json->sendJson(array("valid"=>"true", "html"=>$this->view->render('preference/index.phtml'))); + //$this->_helper->json->sendJson(array("valid"=>"true", "html"=>$this->view->render('preference/index.phtml'))); } else { $this->view->form = $form; - $this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('preference/index.phtml'))); + //$this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('preference/index.phtml'))); } } + $this->view->logoImg = Application_Model_Preference::GetStationLogo(); + $this->view->form = $form; } @@ -111,13 +114,9 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); Application_Model_Preference::SetPublicise($values["Publicise"]); - $form->Logo->receive(); - $imagePath = $form->Logo->getFileName(); - Application_Model_Preference::SetStationCountry($values["Country"]); Application_Model_Preference::SetStationCity($values["City"]); Application_Model_Preference::SetStationDescription($values["Description"]); - Application_Model_Preference::SetStationLogo($imagePath); if (isset($values["Privacy"])) { Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]); } @@ -125,10 +124,6 @@ class PreferenceController extends Zend_Controller_Action $this->view->statusMsg = "
"._("Support setting updated.")."
"; } - $logo = Application_Model_Preference::GetStationLogo(); - if ($logo) { - $this->view->logoImg = $logo; - } $privacyChecked = false; if (Application_Model_Preference::GetPrivacyPolicyCheck() == 1) { $privacyChecked = true; diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index d956b8d1e..52f14332a 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -1,11 +1,14 @@ setEnctype(Zend_Form::ENCTYPE_MULTIPART); $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); $rangeValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(0, 59.9); @@ -34,6 +37,18 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $stationDescription->setAttrib('rows', 4); $this->addElement($stationDescription); + // Station Logo + $stationLogoUpload = new Zend_Form_Element_File('stationLogo'); + $stationLogoUpload->setLabel(_('Station Logo:')) + ->setDescription(_("Note: Anything larger than 600x600 will be resized.")) + ->setRequired(false) + ->addValidator('Count', false, 1) + ->addValidator('Extension', false, 'jpg,jpeg,png,gif') + ->setMaxFileSize(1000000) + ->addFilter('ImageSize'); + $stationLogoUpload->setAttrib('accept', 'image/*'); + $this->addElement($stationLogoUpload); + //Default station crossfade duration $this->addElement('text', 'stationDefaultCrossfadeDuration', array( 'class' => 'input_text', diff --git a/airtime_mvc/application/forms/Preferences.php b/airtime_mvc/application/forms/Preferences.php index 977cae355..7187c467c 100644 --- a/airtime_mvc/application/forms/Preferences.php +++ b/airtime_mvc/application/forms/Preferences.php @@ -7,9 +7,6 @@ class Application_Form_Preferences extends Zend_Form { $baseUrl = Application_Common_OsPath::getBaseDir(); - $this->setMethod('post'); - - $this->setDecorators(array( array('ViewScript', array('viewScript' => 'form/preferences.phtml')) )); @@ -31,5 +28,12 @@ class Application_Form_Preferences extends Zend_Form $soundcloud_pref = new Application_Form_SoundcloudPreferences(); $this->addSubForm($soundcloud_pref, 'preferences_soundcloud'); + $submit = new Zend_Form_Element_Submit('submit'); + $submit->setLabel(_('Save')); + //$submit->removeDecorator('Label'); + $submit->setAttribs(array('class'=>'btn right-floated')); + $submit->removeDecorator('DtDdWrapper'); + + $this->addElement($submit); } } diff --git a/airtime_mvc/application/forms/SupportSettings.php b/airtime_mvc/application/forms/SupportSettings.php index 87e5588de..0fbf0ccf7 100644 --- a/airtime_mvc/application/forms/SupportSettings.php +++ b/airtime_mvc/application/forms/SupportSettings.php @@ -1,7 +1,5 @@ setAttrib('COLS','58'); $this->addElement($description); - // Station Logo - $upload = new Zend_Form_Element_File('Logo'); - $upload->setLabel(_('Station Logo:')) - ->setRequired(false) - ->setDecorators(array('File')) - ->addValidator('Count', false, 1) - ->addValidator('Extension', false, 'jpg,jpeg,png,gif') - ->addFilter('ImageSize'); - $upload->setAttrib('accept', 'image/*'); - $this->addElement($upload); - //enable support feedback $this->addElement('checkbox', 'SupportFeedback', array( 'label' => _('Send support feedback'), diff --git a/airtime_mvc/application/views/scripts/form/preferences.phtml b/airtime_mvc/application/views/scripts/form/preferences.phtml index afc324126..53062036a 100644 --- a/airtime_mvc/application/views/scripts/form/preferences.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences.phtml @@ -1,7 +1,7 @@
element->getElement('csrf') ?> + element->getSubform('preferences_general') ?> -

element->getSubform('preferences_email_server') ?> @@ -12,5 +12,7 @@
element->getSubform('preferences_soundcloud') ?>
+
+ element->submit->render() ?> diff --git a/airtime_mvc/application/views/scripts/form/preferences_general.phtml b/airtime_mvc/application/views/scripts/form/preferences_general.phtml index de3f6b13d..7bf5d487d 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_general.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_general.phtml @@ -5,6 +5,10 @@ element->getElement('stationDescription')->render() ?> + element->getElement('stationLogo')->render() ?> + +
+ element->getElement('locale')->render() ?> element->getElement('timezone')->render() ?> diff --git a/airtime_mvc/application/views/scripts/form/support-setting.phtml b/airtime_mvc/application/views/scripts/form/support-setting.phtml index b1c0a3e37..7b164bdee 100644 --- a/airtime_mvc/application/views/scripts/form/support-setting.phtml +++ b/airtime_mvc/application/views/scripts/form/support-setting.phtml @@ -143,26 +143,6 @@ -
- -
-
- element->getView()->logoImg){?> -
- - - element->getElement('Logo') ?> -
-

-
- element->getElement('Logo')->hasErrors()) : ?> -
    - element->getElement('Logo')->getMessages() as $error): ?> -
  • - -
- -
diff --git a/airtime_mvc/application/views/scripts/preference/index.phtml b/airtime_mvc/application/views/scripts/preference/index.phtml index 7d84200b4..147cd1b99 100644 --- a/airtime_mvc/application/views/scripts/preference/index.phtml +++ b/airtime_mvc/application/views/scripts/preference/index.phtml @@ -1,16 +1,15 @@

-
- - + + + form->getElement('submit')->render() ?>
- + statusMsg; echo $this->form; ?>
-
diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index a868e5df7..f5442493d 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -2121,6 +2121,7 @@ span.errors.sp-errors{ } .preferences { width: 500px; + margin-bottom: 40px; } .manage-folders { width: 610px; diff --git a/airtime_mvc/public/js/airtime/preferences/preferences.js b/airtime_mvc/public/js/airtime/preferences/preferences.js index e774033d0..4f37d7033 100644 --- a/airtime_mvc/public/js/airtime/preferences/preferences.js +++ b/airtime_mvc/public/js/airtime/preferences/preferences.js @@ -103,7 +103,8 @@ $(document).ready(function() { $(this).toggleClass("closed"); return false; }).next().hide(); - + + /* No longer using AJAX for this form. Zend + our code makes it needlessly hard to deal with. -- Albert $('#pref_save').live('click', function() { var data = $('#pref_form').serialize(); var url = baseUrl+'Preference/index'; @@ -116,7 +117,7 @@ $(document).ready(function() { setConfigureMailServerListener(); setEnableSystemEmailsListener(); }); - }); + });*/ showErrorSections();