CC-2701: Separate Support Settings from Preference page

- done.
This commit is contained in:
James 2011-08-18 18:58:59 -04:00
parent 91df62a3dd
commit d83f9f1b96
9 changed files with 149 additions and 98 deletions

View File

@ -58,6 +58,12 @@ $pages = array(
'module' => 'default',
'controller' => 'Preference',
'action' => 'directory-config'
),
array(
'label' => 'Support Settings',
'module' => 'default',
'controller' => 'Preference',
'action' => 'support-setting'
)
)
),

View File

@ -7,9 +7,7 @@ class PreferenceController extends Zend_Controller_Action
{
/* Initialize action controller here */
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext/*->addActionContext('register', 'json')
->addActionContext('remindme', 'json')*/
->addActionContext('server-browse', 'json')
$ajaxContext->addActionContext('server-browse', 'json')
->addActionContext('change-stor-directory', 'json')
->addActionContext('reload-watch-directory', 'json')
->addActionContext('remove-watch-directory', 'json')
@ -45,30 +43,50 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]);
Application_Model_Preference::SetPhone($values["preferences_support"]["Phone"]);
Application_Model_Preference::SetEmail($values["preferences_support"]["Email"]);
Application_Model_Preference::SetStationWebSite($values["preferences_support"]["StationWebSite"]);
Application_Model_Preference::SetSupportFeedback($values["preferences_support"]["SupportFeedback"]);
Application_Model_Preference::SetPublicise($values["preferences_support"]["Publicise"]);
$form->getSubForm('preferences_support')->Logo->receive();
$imagePath = $form->getSubForm('preferences_support')->Logo->getFileName();
Application_Model_Preference::SetStationCountry($values["preferences_support"]["Country"]);
Application_Model_Preference::SetStationCity($values["preferences_support"]["City"]);
Application_Model_Preference::SetStationDescription($values["preferences_support"]["Description"]);
Application_Model_Preference::SetStationLogo($imagePath);
$this->view->statusMsg = "<div class='success'>Preferences updated.</div>";
}
}
$logo = Application_Model_Preference::GetStationLogo();
if($logo){
$this->view->logoImg = $logo;
}
$this->view->form = $form;
}
public function supportSettingAction()
{
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/support-setting.js','text/javascript');
$this->view->statusMsg = "";
$form = new Application_Form_SupportSettings();
if ($request->isPost()) {
if ($form->isValid($request->getPost())) {
$values = $form->getValues();
Application_Model_Preference::SetPhone($values["Phone"]);
Application_Model_Preference::SetEmail($values["Email"]);
Application_Model_Preference::SetStationWebSite($values["StationWebSite"]);
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);
$this->view->statusMsg = "<div class='success'>Support setting updated.</div>";
}
}
$logo = Application_Model_Preference::GetStationLogo();
if($logo){
$this->view->logoImg = $logo;
}
$this->view->form = $form;
}
public function directoryConfigAction()
{
$request = $this->getRequest();

View File

@ -18,8 +18,8 @@ class Application_Form_Preferences extends Zend_Form
$soundcloud_pref = new Application_Form_SoundcloudPreferences();
$this->addSubForm($soundcloud_pref, 'preferences_soundcloud');
$support_pref = new Application_Form_SupportPreferences();
$this->addSubForm($support_pref, 'preferences_support');
/*$support_pref = new Application_Form_SupportPreferences();
$this->addSubForm($support_pref, 'preferences_support');*/
$this->addElement('submit', 'submit', array(
'class' => 'ui-button ui-state-default right-floated',

View File

@ -1,6 +1,6 @@
<?php
class Application_Form_SupportPreferences extends Zend_Form_SubForm
class Application_Form_SupportSettings extends Zend_Form
{
public function init()
@ -8,8 +8,8 @@ class Application_Form_SupportPreferences extends Zend_Form_SubForm
$country_list = Application_Model_Preference::GetCountryList();
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_support.phtml')),
array('File', array('viewScript' => 'form/preferences_support.phtml', 'placement' => false)))
array('ViewScript', array('viewScript' => 'form/support-setting.phtml')),
array('File', array('viewScript' => 'form/support-setting.phtml', 'placement' => false)))
);
// Phone number
@ -134,6 +134,14 @@ class Application_Form_SupportPreferences extends Zend_Form_SubForm
$checkboxPrivacy->setLabel("By checking this box, I agree to Sourcefabric's <a id=\"link_to_privacy\" href=\"http://www.sourcefabric.org/en/about/policy/\" onclick=\"window.open(this.href); return false;\">privacy policy</a>.")
->setDecorators(array('ViewHelper'));
$this->addElement($checkboxPrivacy);
// submit button
$submit = new Zend_Form_Element_Submit("submit");
$submit->class = 'ui-button ui-state-default right-floated';
$submit->setIgnore(true)
->setLabel("Submit")
->setDecorators(array('ViewHelper'));
$this->addElement($submit);
}
// overwriting isValid function

View File

@ -9,11 +9,6 @@
<?php echo $this->element->getSubform('preferences_soundcloud') ?>
</div>
<h3 class="collapsible-header" id="support-heading"><span class="arrow-icon"></span>Support Settings</h3>
<div class="collapsible-content" id="support-settings" style="display: none;">
<?php echo $this->element->getSubform('preferences_support') ?>
</div>
<div class="button-bar bottom" id="submit-element">
<?php echo $this->element->getElement('submit') ?>
</div>

View File

@ -30,10 +30,10 @@
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
</dl>
<div class="info-text" style="clear: both;padding: 4px 0 4px 15px;"><p> Note: In order to promote your station, "Send support feedback" must be enabled</p></div>
<dl id="public-info" style="display:none;">
</dd>
</dl>
<div class="info-text" style="clear: both;padding: 4px 0 4px 15px;"><p> Note: In order to promote your station, "Send support feedback" must be enabled</p></div>
<dl id="public-info" style="display:none;">
<dt id="Phone-label" class="block-display">
<label class="optional" for="Phone"><?php echo $this->element->getElement('Phone')->getLabel() ?></label>
<span class="info-text-small">(for verification purposes only, will not be published)</span>
@ -144,7 +144,7 @@
</div>
<div>
<br>
<label class="optional" for="Privacy">
<label class="optional" for="Privacy">
<?php echo $this->element->getElement('Privacy') ?>
<?php echo $this->element->getElement('Privacy')->getLabel() ?>
</label>
@ -156,4 +156,4 @@
</ul>
<?php endif; ?>
</div>
</fieldset>
</fieldset>

View File

@ -0,0 +1,12 @@
<div class="ui-widget ui-widget-content block-shadow simple-formblock clearfix padded-strong preferences">
<h2>Support Setting</h2>
<form method="post" action="/Preference/support-setting" enctype="multipart/form-data">
<div id="support-settings">
<?php echo $this->statusMsg ?>
<?php echo $this->form ?>
</div>
<div class="button-bar bottom" id="submit-element">
<?php echo $this->form->getElement('submit') ?>
</div>
</form>
</div>

View File

@ -4,39 +4,9 @@ function showErrorSections() {
$("#soundcloud-settings").show();
$(window).scrollTop($("soundcloud-settings .errors").position().top);
}
if($("#support-settings .errors").length > 0) {
$("#support-settings").show();
$(window).scrollTop($("#support-settings .errors").position().top);
}
}
function resizeImg(ele){
var img = $(ele);
var width = ele.width;
var height = ele.height;
// resize img proportionaly
if( width > height && width > 450){
var ratio = 450/width;
img.css("width", "450px");
var newHeight = height * ratio;
img.css("height", newHeight );
}else if( width < height && height > 450){
var ratio = 450/height;
img.css("height", "450px");
var newWidth = width * ratio;
img.css("width", newWidth );
}else if( width == height && width > 450){
img.css("height", "450px");
img.css("width", "450px" );
}
}
$(document).ready(function() {
var form = $("form");
$('.collapsible-header').live('click',function() {
$(this).next().toggle('fast');
@ -44,36 +14,5 @@ $(document).ready(function() {
return false;
}).next().hide();
$("#SupportFeedback").click( function(){
var pub = $("#Publicise");
if( !$(this).is(':checked') ){
pub.removeAttr("checked");
pub.attr("disabled", true);
}else{
pub.removeAttr("disabled");
}
});
var promote = $("#Publicise");
if(!$("#SupportFeedback").is(':checked')){
promote.removeAttr("checked");
promote.attr("disabled", true);
}
promote.live('click', function(){
if($(this).is(':checked')){
$("#public-info").show();
}else{
$("#public-info").hide();
}
});
if( promote.is(":checked")){
$("#public-info").show();
}
showErrorSections();
$('.toggle legend').click(function() {
$('.toggle').toggleClass('closed');
return false;
});
});

View File

@ -0,0 +1,73 @@
function showErrorSections() {
if($("soundcloud-settings .errors").length > 0) {
$("#soundcloud-settings").show();
$(window).scrollTop($("soundcloud-settings .errors").position().top);
}
if($("#support-settings .errors").length > 0) {
$("#support-settings").show();
$(window).scrollTop($("#support-settings .errors").position().top);
}
}
function resizeImg(ele){
var img = $(ele);
var width = ele.width;
var height = ele.height;
// resize img proportionaly
if( width > height && width > 450){
var ratio = 450/width;
img.css("width", "450px");
var newHeight = height * ratio;
img.css("height", newHeight );
}else if( width < height && height > 450){
var ratio = 450/height;
img.css("height", "450px");
var newWidth = width * ratio;
img.css("width", newWidth );
}else if( width == height && width > 450){
img.css("height", "450px");
img.css("width", "450px" );
}
}
$(document).ready(function() {
var form = $("form");
$("#SupportFeedback").click( function(){
var pub = $("#Publicise");
if( !$(this).is(':checked') ){
pub.removeAttr("checked");
pub.attr("disabled", true);
}else{
pub.removeAttr("disabled");
}
});
var promote = $("#Publicise");
if(!$("#SupportFeedback").is(':checked')){
promote.removeAttr("checked");
promote.attr("disabled", true);
}
promote.live('click', function(){
if($(this).is(':checked')){
$("#public-info").show();
}else{
$("#public-info").hide();
}
});
if( promote.is(":checked")){
$("#public-info").show();
}
showErrorSections();
$('.toggle legend').click(function() {
$('.toggle').toggleClass('closed');
return false;
});
});