CC-1724:Phone home statistics

Temp commit
This commit is contained in:
james 2011-06-09 09:56:32 -04:00
parent 6dc3d4d29a
commit 11b601308e
10 changed files with 446 additions and 6 deletions

View file

@ -6,6 +6,9 @@ class PreferenceController extends Zend_Controller_Action
public function init() public function init()
{ {
/* Initialize action controller here */ /* Initialize action controller here */
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('register', 'json')
->initContext();
} }
public function indexAction() public function indexAction()
@ -16,6 +19,9 @@ class PreferenceController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/preferences.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/preferences.js','text/javascript');
$this->view->statusMsg = ""; $this->view->statusMsg = "";
$this->view->registered = Application_Model_Preference::GetRegistered();
$this->view->supportFeedback = Application_Model_Preference::GetSupportFeedback();
$form = new Application_Form_Preferences(); $form = new Application_Form_Preferences();
if ($request->isPost()) { if ($request->isPost()) {
@ -35,14 +41,28 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]); Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]);
Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]); Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]);
Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]); Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]);
Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]); 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"]);
$this->view->statusMsg = "<div class='success'>Preferences updated.</div>"; $this->view->statusMsg = "<div class='success'>Preferences updated.</div>";
} }
} }
$this->view->form = $form; $this->view->form = $form;
} }
public function registerAction(){
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/preferences.js','text/javascript');
$form = new Application_Form_RegisterAirtime();
$this->view->dialog = $form->render($this->view);
}
} }

View file

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

View file

@ -0,0 +1,83 @@
<?php
class Application_Form_RegisterAirtime extends Zend_Form_SubForm
{
public function init()
{
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/register-dialog.phtml'))
));
// checkbox for publicise
$this->addElement('checkbox', 'Publicise', array(
'label' => 'Publicise my station on Sourcefabric.org',
'required' => false,
'value' => Application_Model_Preference::GetSupportFeedback(),
'decorators' => array(
'ViewHelper'
)
));
// Station Name
$this->addElement('text', 'StationName', array(
'label' => 'Station Name:',
'required' => false,
'class' => 'input_text',
'value' => Application_Model_Preference::GetStationName(),
'decorators' => array(
'ViewHelper'
)
));
// Station Web Site
$this->addElement('text', 'StationWebSite', array(
'label' => 'Station Web Site:',
'required' => false,
'class' => 'input_text',
'value' => Application_Model_Preference::GetStationWebSite(),
'decorators' => array(
'ViewHelper'
)
));
// Phone number
$this->addElement('text', 'Phone', array(
'class' => 'input_text',
'label' => 'Phone:',
'required' => false,
'filters' => array('StringTrim'),
'value' => Application_Model_Preference::GetPhone(),
'decorators' => array(
'ViewHelper'
)
));
//Email
$this->addElement('text', 'Email', array(
'class' => 'input_text',
'label' => 'Email:',
'required' => false,
'filters' => array('StringTrim'),
'value' => Application_Model_Preference::GetEmail(),
'decorators' => array(
'ViewHelper'
)
));
// text area for sending detail
$this->addElement('textarea', 'SendInfo', array(
'class' => 'textarea',
'required' => false,
'filters' => array('StringTrim'),
'cols' => 48,
'rows' => 20,
'readonly' => true,
'value' => Application_Model_Preference::GetSystemInfo(),
'decorators' => array(
'ViewHelper'
)
));
}
}

View file

@ -0,0 +1,72 @@
<?php
class Application_Form_SupportPreferences extends Zend_Form_SubForm
{
public function init()
{
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_support.phtml'))
));
// Phone number
$this->addElement('text', 'Phone', array(
'class' => 'input_text',
'label' => 'Phone:',
'required' => false,
'filters' => array('StringTrim'),
'value' => Application_Model_Preference::GetPhone(),
'decorators' => array(
'ViewHelper'
)
));
//Email
$this->addElement('text', 'Email', array(
'class' => 'input_text',
'label' => 'Email:',
'required' => false,
'filters' => array('StringTrim'),
'value' => Application_Model_Preference::GetEmail(),
'decorators' => array(
'ViewHelper'
)
));
// Station Web Site
$this->addElement('text', 'StationWebSite', array(
'label' => 'Station Web Site:',
'required' => false,
'class' => 'input_text',
'value' => Application_Model_Preference::GetStationWebSite(),
'decorators' => array(
'ViewHelper'
)
));
//enable support feedback
$this->addElement('checkbox', 'SupportFeedback', array(
'label' => 'Support feedback enabled',
'required' => false,
'value' => Application_Model_Preference::GetSupportFeedback(),
'decorators' => array(
'ViewHelper'
)
));
//add register button if not registered
if( !Application_Model_Preference::GetRegistered() ){
$this->addElement('submit', 'Register', array(
'class' => 'ui-button ui-state-default',
'ignore' => true,
'label' => 'Register',
'decorators' => array(
'ViewHelper'
)
));
}
}
}

View file

@ -188,6 +188,55 @@ class Application_Model_Preference
return $val; return $val;
} }
} }
public static function SetPhone($phone){
Application_Model_Preference::SetValue("phone", $phone);
}
public static function GetPhone(){
return Application_Model_Preference::GetValue("phone");
}
public static function SetEmail($email){
Application_Model_Preference::SetValue("email", $email);
}
public static function GetEmail(){
return Application_Model_Preference::GetValue("email");
}
public static function SetStationWebSite($site){
Application_Model_Preference::SetValue("station_website", $site);
}
public static function GetStationWebSite(){
return Application_Model_Preference::GetValue("station_website");
}
public static function SetSupportFeedback($feedback){
Application_Model_Preference::SetValue("support_feedback", $feedback);
}
public static function GetSupportFeedback(){
return Application_Model_Preference::GetValue("support_feedback");
}
public static function SetRegistered($registered){
Application_Model_Preference::SetValue("registered", $registered);
}
public static function GetRegistered(){
return Application_Model_Preference::GetValue("registered");
}
public static function GetSystemInfo(){
$output;
exec('airtime-check-system', $output);
$out = implode("\n", preg_replace('/\s+/', ' ', $output));
// Sever API
$out .= php_sapi_name();
return $out;
}
} }

View file

@ -6,6 +6,11 @@
<div class="collapsible-content" id="soundcloud-settings" style="display: none;"> <div class="collapsible-content" id="soundcloud-settings" style="display: none;">
<?php echo $this->element->getSubform('preferences_soundcloud') ?> <?php echo $this->element->getSubform('preferences_soundcloud') ?>
</div> </div>
<h3 class="collapsible-header"><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"> <div class="button-bar bottom" id="submit-element">
<?php echo $this->element->getElement('submit') ?> <?php echo $this->element->getElement('submit') ?>

View file

@ -0,0 +1,67 @@
<fieldset class="padded">
<dl class="zend_form">
<?php if($this->element->getView()->registered){?>
<div>Registered</div>
<?php }else{?>
<div>Please register your Airtime system by clicking Register button at the bottom.</div>
<?php }?>
<?php if($this->element->getView()->supportFeedback === '0'){?>
<div>Be more awesome by selecting "Support feedback" below. You will be helping Airtim improve!</div>
<?php }?>
<dt id="Phone-label" class="block-display">
<label class="optional" for="Phone"><?php echo $this->element->getElement('Phone')->getLabel() ?></label>
</dt>
<dd id="Phone-element" class="block-display">
<?php echo $this->element->getElement('Phone') ?>
<?php if($this->element->getElement('Phone')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('Phone')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="Email-label" class="block-display">
<label class="optional" for="Email"><?php echo $this->element->getElement('Email')->getLabel() ?></label>
</dt>
<dd id="Email-element" class="block-display">
<?php echo $this->element->getElement('Email') ?>
<?php if($this->element->getElement('Email')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('Email')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="StationWebSite-label" class="block-display">
<label class="optional" for="StationWebSite"><?php echo $this->element->getElement('StationWebSite')->getLabel() ?></label>
</dt>
<dd id="StationWebSite-element" class="block-display clearfix">
<?php echo $this->element->getElement('StationWebSite') ?>
<?php if($this->element->getElement('StationWebSite')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('StationWebSite')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dd id="SupportFeedback-element" class="block-display" style=" margin:6px 0 10px 0">
<label class="optional" for="SupportFeedback">
<?php echo $this->element->getElement('SupportFeedback') ?>
<strong><?php echo $this->element->getElement('SupportFeedback')->getLabel() ?></strong>
</label>
<?php if($this->element->getElement('SupportFeedback')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('SupportFeedback')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<div class="button-bar bottom" id="Register-element">
<?php echo $this->element->getElement('Register') ?>
</div>
</dl>
</fieldset>

View file

@ -0,0 +1,103 @@
<div class="dialogPopup register-dialog" title="Register Airtime">
<div class="info-text">
<p>Help Airtime improve by letting us know you are using it. This info
will be collected once per month and is anonymous unless you chose to
advertise your station on sourcefabric.org</p>
</div>
<form method="<?php echo $this->element->getMethod() ?>" action="<?php echo $this->element->getAction() ?>" enctype="application/x-www-form-urlencoded">
<dl class="zend_form">
<dd id="publicize-element">
<label class="optional" for="Publicise">
<?php echo $this->element->getElement('Publicise') ?>
<strong><?php echo $this->element->getElement('Publicise')->getLabel() ?></strong>
</label>
<?php if($this->element->getElement('Publicise')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('Publicise')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
</dl>
<fieldset>
<dl class="zend_form">
<dt id="StationName-label" class="block-display">
<label class="required" for="StationName"><?php echo $this->element->getElement('StationName')->getLabel() ?></label>
</dt>
<dd id="StationName-element" class="block-display clearfix">
<?php echo $this->element->getElement('StationName') ?>
<?php if($this->element->getElement('StationName')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('StationName')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="StationWebSite-label" class="block-display">
<label class="required" for="StationWebSite"><?php echo $this->element->getElement('StationWebSite')->getLabel() ?></label>
</dt>
<dd id="StationWebSite-element" class="block-display clearfix">
<?php echo $this->element->getElement('StationWebSite') ?>
<?php if($this->element->getElement('StationWebSite')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('StationWebSite')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="Phone-label" class="block-display">
<label class="required" for="Phone"><?php echo $this->element->getElement('Phone')->getLabel() ?></label>
</dt>
<dd id="Phone-element" class="block-display">
<?php echo $this->element->getElement('Phone') ?>
<?php if($this->element->getElement('Phone')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('Phone')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="Email-label" class="block-display">
<label class="required" for="Email"><?php echo $this->element->getElement('Email')->getLabel() ?></label>
</dt>
<dd id="Email-element" class="block-display">
<?php echo $this->element->getElement('Email') ?>
<?php if($this->element->getElement('Email')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('Email')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
</dl>
</fieldset>
</form>
<h3 class="collapsible-header">
<span class="arrow-icon"></span>Show me what I am sending
</h3>
<div class="collapsible-content" id="show_what_sending" style="display: block;">
<fieldset class="display_field">
<dl>
<?php echo $this->element->getElement('SendInfo') ?>
<dt>Airtime version:</dt>
<dd>1.9.0</dd>
<dt>Unique ID:</dt>
<dd>AT19236520FR00673</dd>
<dt>Station name:</dt>
<dd>BBC Radio 1</dd>
</dl>
</fieldset>
</div>
</div>

View file

@ -1136,9 +1136,10 @@ button.ui-button.::-moz-focus-inner {
*/ */
.ui-dialog { .ui-dialog {
position: absolute; position: absolute;
padding: .2em; padding: .4em;
width: 300px; width: 300px;
overflow: hidden; overflow: hidden;
border-width: 3px;
} }
.ui-dialog .ui-dialog-titlebar { .ui-dialog .ui-dialog-titlebar {
padding: 6px 8px 6px 8px; padding: 6px 8px 6px 8px;
@ -1171,13 +1172,16 @@ button.ui-button.::-moz-focus-inner {
background: none; background: none;
overflow: auto; overflow: auto;
zoom: 1; zoom: 1;
} }
.ui-dialog .ui-dialog-buttonpane { .ui-dialog .ui-dialog-buttonpane {
text-align: left; text-align: left;
border-width: 1px 0 0 0; border-width: 1px 0 0 0;
background-image: none; background: none;
margin: .5em 0 0 0; margin: .5em 0 0 0;
padding: .3em 1em .5em .4em; margin: 0.3em -0.4em 0;
padding: 0.3em 1em 0 0.4em;
border-color: #9f9f9f;
} }
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
float: right; float: right;

View file

@ -13,5 +13,39 @@ $(document).ready(function() {
h3.addClass("close"); h3.addClass("close");
} }
}); });
$('#Register').click(function(event){
event.preventDefault();
$.get("/Preference/register", {format:"json"}, function(json){
var dialog = $(json.dialog);
dialog.dialog({
autoOpen: false,
title: 'Register Airtime',
width: 400,
height: 500,
modal: true,
buttons: {"Ok": function() {
dialog.remove();
}}
});
dialog.dialog('open');
var form = $("form");
form.find("h3").click(function(){
var h3 = $(this);
h3.next().toggle();
if(h3.hasClass("close")) {
h3.removeClass("close");
}
else {
h3.addClass("close");
}
});
})
})
}); });