Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2011-11-14 14:12:18 -05:00
commit 469c9c59fe
18 changed files with 202 additions and 5 deletions

View File

@ -53,6 +53,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$view->headLink()->appendStylesheet($baseUrl.'/css/redmond/jquery-ui-1.8.8.custom.css');
$view->headLink()->appendStylesheet($baseUrl.'/css/pro_dropdown_3.css');
$view->headLink()->appendStylesheet($baseUrl.'/css/qtip/jquery.qtip.min.css');
$view->headLink()->appendStylesheet($baseUrl.'/css/styles.css');
}
@ -71,6 +72,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
//scripts for now playing bar
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js','text/javascript');
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript');
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/versiontooltip.js','text/javascript');
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js','text/javascript');
}

View File

@ -36,7 +36,6 @@ class LibraryController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/qtip/jquery.qtip.min.css');
$this->_helper->layout->setLayout('library');

View File

@ -160,8 +160,10 @@ class PreferenceController extends Zend_Controller_Action
$num_of_stream = intval(Application_Model_Preference::GetNumOfStreams());
$form = new Application_Form_StreamSetting();
$form->setSetting($setting);
$form->startFrom();
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
$form->setSetting($setting);
$form->startFrom();
}
for($i=1; $i<=$num_of_stream; $i++){
$subform = new Application_Form_StreamSettingSubForm();
$subform->setPrefix($i);

View File

@ -56,7 +56,6 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/colorpicker/css/colorpicker.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/qtip/jquery.qtip.min.css');
Application_Model_Schedule::createNewFormSections($this->view);

View File

@ -10,6 +10,7 @@
<div id="Panel">
<div class="logo"></div>
<?php echo $this->versionNotify() ?>
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
<?php $partial = array('menu.phtml', 'default');

View File

@ -10,6 +10,7 @@
<div id="Panel">
<div class="logo"></div>
<?php echo $this->versionNotify() ?>
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
<?php $partial = array('menu.phtml', 'default');

View File

@ -516,6 +516,23 @@ class Application_Model_Preference
public static function GetAirtimeVersion(){
return self::GetValue("system_version");
}
public static function GetLatestVersion(){
$latest = self::GetValue("latest_version");
if($latest == null || strlen($latest) == 0) {
return self::GetAirtimeVersion();
} else {
return $latest;
}
}
public static function SetLatestVersion($version){
$pattern = "/^[0-9]+\.[0-9]+\.[0-9]+/";
if(!preg_match($pattern, $version)) {
$version = self::GetAirtimeVersion();
}
self::SetValue("latest_version", $version);
}
public static function SetUploadToSoundcloudOption($upload) {
self::SetValue("soundcloud_upload_option", $upload);

View File

@ -50,6 +50,13 @@ class Application_Model_StreamSetting {
return $rows;
}
/*
* function that take all the information of stream and sets them.
* This is used by stream setting via UI.
*
* @param $data - array that contains all the data. $data is [][] which
* contains multiple stream information
*/
public static function setStreamSetting($data){
global $CC_DBC;
foreach($data as $key=>$d){
@ -76,6 +83,20 @@ class Application_Model_StreamSetting {
}
}
/*
* Sets indivisual stream setting.
*
* $data - data array. $data is [].
*/
public static function setIndivisualStreamSetting($data){
global $CC_DBC;
foreach($data as $keyname => $v){
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
$CC_DBC->query($sql);
}
}
public static function setLiquidsoapError($stream_id, $msg){
global $CC_DBC;

View File

@ -0,0 +1,61 @@
<?php
/**
* This file does the following things:
* 1. Calculate how many major versions back the current installation
* is from the latest release
* 2. Returns the matching icon based on result of 1, as HTML
* 3. Returns the matching tooltip message based on result of 1, as HTML
* (stored in pair of invisible div tags)
* 4. Returns the current version, as HTML (stored in pair of invisible div tags)
*/
class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract{
public function versionNotify(){
if(Application_Model_Preference::GetPlanLevel() != 'disabled'){
return "";
}
// retrieve and validate current and latest versions,
$current = Application_Model_Preference::GetAirtimeVersion();
$latest = Application_Model_Preference::GetLatestVersion();
$pattern = "/^([0-9]+)\.([0-9]+)\.[0-9]+/";
preg_match($pattern, $current, $curMatch);
preg_match($pattern, $latest, $latestMatch);
if(count($curMatch) == 0 || count($latestMatch) == 0) {
return "";
}
// Calculate version diff
// Note: algorithm assumes the number after 1st dot never goes above 9
$diff = (intval($latestMatch[1]) * 10 + intval($latestMatch[2]))
- (intval($curMatch[1]) * 10 + intval($curMatch[2]));
// Pick icon and tooltip msg
$bg = "/css/images/";
$msg = "";
$link = "<a href='http://apt.sourcefabric.org/misc/'>" . $latest . "</a>";
if(($diff == 0 && $current == $latest) || $diff < 0) {
// current version is up to date
$bg .= "icon_uptodate.png";
$msg = "You are running the latest version";
} else if($diff <= 2) {
// 2 or less major versions back
$bg .= "icon_update.png";
$msg = "New version available: " . $link;
} else if($diff == 3) {
// 3 major versions back
$bg .= "icon_update2.png";
$msg = "This version will soon be obsolete.<br/>Please upgrade to " . $link;
} else {
// more than 3 major versions back
$bg .= "icon_outdated.png";
$msg = "This version is no longer supported.<br/>Please upgrade to " . $link;
}
$result = "<div id='version_message' style='display:none'>" . $msg . "</div>"
. "<div id='version_current' style='display:none'>" . $current . "</div>"
. "<div id='version_icon' style='background-image: url(" . $bg . ");'></div>";
return $result;
}
}

View File

@ -8,6 +8,7 @@
<div style="clear:both"></div>
<?php }?>
<?php echo $this->statusMsg;?>
<?php if($this->form->getElement('output_sound_device') != null){?>
<fieldset class="padded">
<legend>Hardware Audio Out</legend>
<dl class="zend_form">
@ -21,6 +22,7 @@
</dd>
</dl>
</fieldset>
<?php } ?>
<?php
for($i=1;$i<=$this->num_stream;$i++){
echo $this->form->getSubform("s".$i."_subform");

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -57,6 +57,31 @@ select {
display:block;
}
/* Version Notification Starts*/
#version_icon {
position:absolute;
right:85px;
top:104px;
height:35px;
width:35px;
z-index:1000;
display:block;
cursor:pointer;
background-repeat:no-repeat;
background-position:center;
}
#ui-tooltip-version a {
color:#ff5d1a;
text-decoration:none;
}
#ui-tooltip-version {
font-size: 14px;
}
/* Version Notification Ends*/
/* Clearfix */
.clearfix:after, li:after { content: "."; display: block; height: 0; clear: both; visibility: hidden;}
.clearfix, li { display: inline-block; }

View File

@ -0,0 +1,53 @@
/**
* Get the tooltip message to be displayed,
* which is stored inside a pair of hidden div tags
*/
function getContent() {
return $("#version_message").html();
}
/**
* Get the current version,
* which is stored inside a pair of hidden div tags
*/
function getCurrentVersion() {
return $("#version_current").html();
}
/**
* Sets up the tooltip for version notification
*/
function setupVersionQtip(){
var qtipElem = $('#version_icon');
if (qtipElem.length > 0){
qtipElem.qtip({
id: 'version',
content: {
text: getContent(),
title: {
text: getCurrentVersion(),
button: true
}
},
show: 'click', /* Show on click */
hide: false, /* Don't hide on mouseout */
position: {
my: "top right",
at: "bottom left"
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
}
});
}
}
$(document).ready(function() {
if($('#version_message').length > 0) {
setupVersionQtip();
}
});

View File

@ -30,7 +30,9 @@ function rebuildStreamURL(ele){
function restrictOggBitrate(ele, on){
var div = ele.closest("div")
if(on){
div.find("select[id$=data-bitrate]").find("option[value='48']").attr('selected','selected');
if(parseInt(div.find("select[id$=data-bitrate]").val(),10) < 48){
div.find("select[id$=data-bitrate]").find("option[value='48']").attr("selected","selected");
}
div.find("select[id$=data-bitrate]").find("option[value='24']").attr("disabled","disabled");
div.find("select[id$=data-bitrate]").find("option[value='32']").attr("disabled","disabled");
}else{

View File

@ -74,6 +74,18 @@ if(Application_Model_Preference::GetSupportFeedback() == '1'){
$result = curl_exec($ch);
}
// Get latest version from stat server and store to db
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
$url = 'http://stat-dev.sourcefabric.org/airtime_latest_version';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
Application_Model_Preference::SetLatestVersion($result);
}
/**
* Ensures that the user is running this PHP script with root
* permissions. If not running with root permissions, causes the