CC-3395: Play preview for playlists and timelines for shows should show a list under the pop-up player which will play the entire playlist.

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

Conflicts:
	airtime_mvc/application/controllers/LibraryController.php
	airtime_mvc/public/js/airtime/library/library.js
This commit is contained in:
Daniel 2012-03-12 10:23:50 -04:00
commit d713f830cd
61 changed files with 5112 additions and 200 deletions

View file

@ -26,6 +26,7 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('recorder'))
->add(new Zend_Acl_Resource('showbuilder'))
->add(new Zend_Acl_Resource('auth'))
->add(new Zend_Acl_Resource('playouthistory'))
->add(new Zend_Acl_Resource('usersettings'));
/** Creating permissions */
@ -44,6 +45,7 @@ $ccAcl->allow('G', 'index')
->allow('H', 'search')
->allow('H', 'playlist')
->allow('H', 'showbuilder')
->allow('A', 'playouthistory')
->allow('A', 'user')
->allow('A', 'systemstatus')
->allow('A', 'preference');

View file

@ -11,9 +11,9 @@ $pages = array(
array(
'label' => 'Now Playing',
'module' => 'default',
'controller' => 'Nowplaying',
'controller' => 'Showbuilder',
'action' => 'index',
'resource' => 'nowplaying'
'resource' => 'showbuilder'
),
array(
'label' => 'Add Media',
@ -29,13 +29,6 @@ $pages = array(
'action' => 'index',
'resource' => 'library'
),
array(
'label' => 'Airtimeline',
'module' => 'default',
'controller' => 'Showbuilder',
'action' => 'index',
'resource' => 'showbuilder'
),
array(
'label' => 'Calendar',
'module' => 'default',
@ -85,7 +78,14 @@ $pages = array(
'controller' => 'systemstatus',
'action' => 'index',
'resource' => 'systemstatus'
)
),
array(
'label' => 'Playout History',
'module' => 'default',
'controller' => 'playouthistory',
'action' => 'index',
'resource' => 'playouthistory'
)
)
),
array(

View file

@ -29,9 +29,15 @@ class LibraryController extends Zend_Controller_Action
public function indexAction() {
global $CC_CONFIG;
$this->_helper->layout->setLayout('library');
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_playlistbuilder.js'),'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/main_library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->_helper->actionStack('library', 'library');
$this->_helper->actionStack('index', 'playlist');
@ -56,9 +62,10 @@ class LibraryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/main_library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);

View file

@ -68,7 +68,7 @@ class LoginController extends Zend_Controller_Action
$tempSess = new Zend_Session_Namespace("referrer");
$tempSess->referrer = 'login';
$this->_redirect('Nowplaying');
$this->_redirect('Showbuilder');
}
else
{
@ -95,7 +95,7 @@ class LoginController extends Zend_Controller_Action
public function logoutAction()
{
Zend_Auth::getInstance()->clearIdentity();
$this->_redirect('login/index');
$this->_redirect('showbuilder/index');
}
}

View file

@ -0,0 +1,87 @@
<?php
class PlayoutHistoryController extends Zend_Controller_Action
{
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext
->addActionContext('playout-history-feed', 'json')
->initContext();
}
public function indexAction()
{
global $CC_CONFIG;
$this->_helper->layout->setLayout('playouthistory');
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
//default time is the last 24 hours.
$now = time();
$from = $request->getParam("from", $now - (24*60*60));
$to = $request->getParam("to", $now);
$start = DateTime::createFromFormat("U", $from, new DateTimeZone("UTC"));
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
$end = DateTime::createFromFormat("U", $to, new DateTimeZone("UTC"));
$end->setTimezone(new DateTimeZone(date_default_timezone_get()));
$form = new Application_Form_DateRange();
$form->populate(array(
'his_date_start' => $start->format("Y-m-d"),
'his_time_start' => $start->format("H:i"),
'his_date_end' => $end->format("Y-m-d"),
'his_time_end' => $end->format("H:i")
));
$this->view->date_form = $form;
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/TableTools/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/TableTools/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$offset = date("Z") * -1;
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/playouthistory/historytable.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
//$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools_JUI.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css');
}
public function playoutHistoryFeedAction()
{
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
Logging::log("history starts {$startsDT->format("Y-m-d H:i:s")}");
Logging::log("history ends {$endsDT->format("Y-m-d H:i:s")}");
$history = new Application_Model_PlayoutHistory($startsDT, $endsDT, $params);
$r = $history->getItems();
$this->view->sEcho = $r["sEcho"];
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
$this->view->iTotalRecords = $r["iTotalRecords"];
$this->view->history = $r["history"];
}
}

View file

@ -10,6 +10,7 @@ class ShowbuilderController extends Zend_Controller_Action
->addActionContext('schedule-add', 'json')
->addActionContext('schedule-remove', 'json')
->addActionContext('builder-dialog', 'json')
->addActionContext('check-builder-feed', 'json')
->addActionContext('builder-feed', 'json')
->initContext();
}
@ -17,10 +18,80 @@ class ShowbuilderController extends Zend_Controller_Action
public function indexAction() {
$this->_helper->layout->setLayout('builder');
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js'),'text/javascript');
$this->_helper->viewRenderer->setResponseSegment('dialog');
$this->_helper->actionStack('library', 'library');
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version']),'text/javascript');
$refer_sses = new Zend_Session_Namespace('referrer');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
if ($request->isPost()) {
$form = new Application_Form_RegisterAirtime();
$values = $request->getPost();
if ($values["Publicise"] != 1 && $form->isValid($values)) {
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
if (isset($values["Privacy"])) {
Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]);
}
// unset session
Zend_Session::namespaceUnset('referrer');
}
else if ($values["Publicise"] == '1' && $form->isValid($values)) {
Application_Model_Preference::SetHeadTitle($values["stnName"], $this->view);
Application_Model_Preference::SetPhone($values["Phone"]);
Application_Model_Preference::SetEmail($values["Email"]);
Application_Model_Preference::SetStationWebSite($values["StationWebSite"]);
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);
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
if (isset($values["Privacy"])){
Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]);
}
// unset session
Zend_Session::namespaceUnset('referrer');
}
else {
$logo = Application_Model_Preference::GetStationLogo();
if ($logo) {
$this->view->logoImg = $logo;
}
$this->view->dialog = $form;
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/register.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
}
}
else {
//popup if previous page was login
if ($refer_sses->referrer == 'login' && Application_Model_Nowplaying::ShouldShowPopUp()
&& !Application_Model_Preference::GetSupportFeedback() && $user->isAdmin()){
$form = new Application_Form_RegisterAirtime();
$logo = Application_Model_Preference::GetStationLogo();
if ($logo) {
$this->view->logoImg = $logo;
}
$this->view->dialog = $form;
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/register.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
}
}
$this->_helper->actionStack('library', 'library');
$this->_helper->actionStack('builder', 'showbuilder');
}
@ -33,7 +104,7 @@ class ShowbuilderController extends Zend_Controller_Action
$now = time();
$from = $request->getParam("from", $now);
$to = $request->getParam("to", $now+(24*60*60));
$to = $request->getParam("to", $now + (24*60*60));
$start = DateTime::createFromFormat("U", $from, new DateTimeZone("UTC"));
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
@ -52,12 +123,12 @@ class ShowbuilderController extends Zend_Controller_Action
$offset = date("Z") * -1;
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/builder.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/main_builder.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/main_builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/showbuilder.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
}
public function builderDialogAction() {
@ -88,6 +159,37 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml');
}
public function checkBuilderFeedAction() {
$request = $this->getRequest();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time);
//default ends is 24 hours after starts.
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$show_filter = intval($request->getParam("showFilter", 0));
$my_shows = intval($request->getParam("myShows", 0));
$timestamp = intval($request->getParam("timestamp", -1));
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
Logging::log("showbuilder starts {$startsDT->format("Y-m-d H:i:s")}");
Logging::log("showbuilder ends {$endsDT->format("Y-m-d H:i:s")}");
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
//only send the schedule back if updates have been made.
// -1 default will always call the schedule to be sent back if no timestamp is defined.
if ($showBuilder->hasBeenUpdatedSince($timestamp)) {
$this->view->update = true;
}
else {
$this->view->update = false;
}
}
public function builderFeedAction() {
$request = $this->getRequest();
@ -98,6 +200,7 @@ class ShowbuilderController extends Zend_Controller_Action
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$show_filter = intval($request->getParam("showFilter", 0));
$my_shows = intval($request->getParam("myShows", 0));
$timestamp = intval($request->getParam("timestamp", -1));
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
@ -109,6 +212,7 @@ class ShowbuilderController extends Zend_Controller_Action
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
$this->view->schedule = $showBuilder->GetItems();
$this->view->timestamp = $current_time;
}
public function scheduleAddAction() {

View file

@ -0,0 +1,68 @@
<?php
class Application_Form_DateRange extends Zend_Form_SubForm
{
public function init()
{
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/daterange.phtml'))
));
// Add start date element
$startDate = new Zend_Form_Element_Text('his_date_start');
$startDate->class = 'input_text';
$startDate->setRequired(true)
->setLabel('Date Start:')
->setValue(date("Y-m-d"))
->setFilters(array('StringTrim'))
->setValidators(array(
'NotEmpty',
array('date', false, array('YYYY-MM-DD'))))
->setDecorators(array('ViewHelper'));
$startDate->setAttrib('alt', 'date');
$this->addElement($startDate);
// Add start time element
$startTime = new Zend_Form_Element_Text('his_time_start');
$startTime->class = 'input_text';
$startTime->setRequired(true)
->setValue('00:00')
->setFilters(array('StringTrim'))
->setValidators(array(
'NotEmpty',
array('date', false, array('HH:mm')),
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
$startTime->setAttrib('alt', 'time');
$this->addElement($startTime);
// Add end date element
$endDate = new Zend_Form_Element_Text('his_date_end');
$endDate->class = 'input_text';
$endDate->setRequired(true)
->setLabel('Date End:')
->setValue(date("Y-m-d"))
->setFilters(array('StringTrim'))
->setValidators(array(
'NotEmpty',
array('date', false, array('YYYY-MM-DD'))))
->setDecorators(array('ViewHelper'));
$endDate->setAttrib('alt', 'date');
$this->addElement($endDate);
// Add end time element
$endTime = new Zend_Form_Element_Text('his_time_end');
$endTime->class = 'input_text';
$endTime->setRequired(true)
->setValue('01:00')
->setFilters(array('StringTrim'))
->setValidators(array(
'NotEmpty',
array('date', false, array('HH:mm')),
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
$endTime->setAttrib('alt', 'time');
$this->addElement($endTime);
}
}

View file

@ -11,6 +11,12 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
array('ViewScript', array('viewScript' => 'form/showbuilder.phtml'))
));
//set value to -1 originally to ensure we grab the schedule on first call.
$timestamp = new Zend_Form_Element_Hidden('sb_timestamp');
$timestamp->setValue(-1)
->setDecorators(array('ViewHelper'));
$this->addElement($timestamp);
// Add start date element
$startDate = new Zend_Form_Element_Text('sb_date_start');
$startDate->class = 'input_text';

View file

@ -23,5 +23,8 @@
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded" style="display:none"><?php echo $this->layout()->library ?></div>
<div id="show_builder" class="ui-widget ui-widget-content block-shadow omega-block padded"><?php echo $this->layout()->builder ?></div>
</div>
<?php echo $this->layout()->dialog ?>
</body>
</html>

View file

@ -23,7 +23,7 @@
<div class="wrapper">
<!--Set to z-index 254 to make it lower than the top-panel and the ZFDebug info bar, but higher than the side-playlist-->
<div id="library_content" class="ui-widget ui-widget-content block-shadow alpha-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
<div id="side_playlist" class="ui-widget ui-widget-content block-shadow omega-block"><?php echo $this->layout()->spl ?></div>
<div id="side_playlist" class="ui-widget ui-widget-content block-shadow omega-block padded"><?php echo $this->layout()->spl ?></div>
</div>
</body>
</html>

View file

@ -0,0 +1,27 @@
<?php echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php echo $this->headTitle() ?>
<?php echo $this->headScript() ?>
<?php echo $this->headLink() ?>
<?php echo isset($this->google_analytics)?$this->google_analytics:"" ?>
</head>
<body>
<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');
$this->navigation()->menu()->setPartial($partial); ?>
<?php echo $this->navigation()->menu() ?>
</div>
<div class="wrapper">
<div id="history_content" class="ui-widget ui-widget-content block-shadow alpha-block padded"><?php echo $this->layout()->content ?></div>
</div>
</body>
</html>

View file

@ -0,0 +1,109 @@
<?php
class Application_Model_Datatables {
/*
* query used to return data for a paginated/searchable datatable.
*/
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
{
$where = array();
if ($data["sSearch"] !== "") {
$searchTerms = explode(" ", $data["sSearch"]);
}
$selectorCount = "SELECT COUNT(*) ";
$selectorRows = "SELECT ".join(",", $displayColumns)." ";
$sql = $selectorCount." FROM ".$fromTable;
$sqlTotalRows = $sql;
if (isset($searchTerms)) {
$searchCols = array();
for ($i = 0; $i < $data["iColumns"]; $i++) {
if ($data["bSearchable_".$i] == "true") {
$searchCols[] = $data["mDataProp_{$i}"];
}
}
$outerCond = array();
foreach ($searchTerms as $term) {
$innerCond = array();
foreach ($searchCols as $col) {
$escapedTerm = pg_escape_string($term);
$innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'";
}
$outerCond[] = "(".join(" OR ", $innerCond).")";
}
$where[] = "(".join(" AND ", $outerCond).")";
}
// End Where clause
// Order By clause
$orderby = array();
for ($i = 0; $i < $data["iSortingCols"]; $i++){
$num = $data["iSortCol_".$i];
$orderby[] = $data["mDataProp_{$num}"]." ".$data["sSortDir_".$i];
}
$orderby[] = "id";
$orderby = join("," , $orderby);
// End Order By clause
$displayLength = intval($data["iDisplayLength"]);
if (count($where) > 0) {
$where = join(" AND ", $where);
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
$sqlTotalDisplayRows = $sql;
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby;
//limit the results returned.
if ($displayLength !== -1) {
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
}
}
else {
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby;
//limit the results returned.
if ($displayLength !== -1) {
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
}
}
try {
$r = $con->query($sqlTotalRows);
Logging::log($sqlTotalRows);
$totalRows = $r->fetchColumn(0);
if (isset($sqlTotalDisplayRows)) {
$r = $con->query($sqlTotalDisplayRows);
Logging::log($sqlTotalDisplayRows);
$totalDisplayRows = $r->fetchColumn(0);
}
else {
$totalDisplayRows = $totalRows;
}
$r = $con->query($sql);
$r->setFetchMode(PDO::FETCH_ASSOC);
$results = $r->fetchAll();
}
catch (Exception $e) {
Logging::log($e->getMessage());
}
//display sql executed in airtime log for testing
Logging::log($sql);
return array(
"sEcho" => intval($data["sEcho"]),
"iTotalDisplayRecords" => intval($totalDisplayRows),
"iTotalRecords" => intval($totalRows),
$dataProp => $results
);
}
}

View file

@ -0,0 +1,82 @@
<?php
require_once 'formatters/LengthFormatter.php';
class Application_Model_PlayoutHistory {
private $con;
private $timezone;
//in UTC timezone
private $startDT;
//in UTC timezone
private $endDT;
private $epoch_now;
private $opts;
private $mDataPropMap = array(
"artist" => "file.artist_name",
"title" => "file.track_title",
"played" => "playout.played",
"length" => "file.length",
"composer" => "file.composer",
"copyright" => "file.copyright",
);
public function __construct($p_startDT, $p_endDT, $p_opts) {
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
$this->epoch_now = time();
$this->opts = $p_opts;
}
/*
* map front end mDataProp labels to proper column names for searching etc.
*/
private function translateColumns() {
for ($i = 0; $i < $this->opts["iColumns"]; $i++){
$this->opts["mDataProp_{$i}"] = $this->mDataPropMap[$this->opts["mDataProp_{$i}"]];
}
}
public function getItems() {
$this->translateColumns();
$select = array(
"file.track_title as title",
"file.artist_name as artist",
"playout.played",
"playout.file_id",
"file.composer",
"file.copyright",
"file.length"
);
$start = $this->startDT->format("Y-m-d H:i:s");
$end = $this->endDT->format("Y-m-d H:i:s");
$historyTable = "(
select count(schedule.file_id) as played, schedule.file_id as file_id
from cc_schedule as schedule
where schedule.starts >= '{$start}' and schedule.starts < '{$end}'
group by schedule.file_id
)
AS playout left join cc_files as file on (file.id = playout.file_id)";
$results = Application_Model_Datatables::findEntries($this->con, $select, $historyTable, $this->opts, "history");
foreach ($results["history"] as &$row) {
$formatter = new LengthFormatter($row['length']);
$row['length'] = $formatter->format();
}
return $results;
}
}

View file

@ -162,7 +162,7 @@ class Application_Model_Show {
->find($con);
foreach ($instances as $instance) {
$instance->updateScheduleStatus();
$instance->updateScheduleStatus($con);
}
$con->commit();
@ -1448,7 +1448,8 @@ class Application_Model_Show {
}
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name,
color, background_color, file_id, cc_show_instances.id AS instance_id
color, background_color, file_id, cc_show_instances.id AS instance_id,
last_scheduled
FROM cc_show_instances
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id
WHERE cc_show_instances.modified_instance = FALSE";
@ -1479,6 +1480,9 @@ class Application_Model_Show {
$sql = $sql." AND ({$exclude})";
}
//Logging::log("getShows");
//Logging::log($sql);
return $CC_DBC->GetAll($sql);
}

View file

@ -6,13 +6,19 @@ require_once 'formatters/TimeFilledFormatter.php';
class Application_Model_ShowBuilder {
private $timezone;
//in UTC timezone
private $startDT;
//in UTC timezone
private $endDT;
private $user;
private $opts;
private $contentDT;
private $epoch_now;
private $hasCurrent;
private $defaultRowArray = array(
"header" => false,
@ -47,6 +53,8 @@ class Application_Model_ShowBuilder {
$this->user = Application_Model_User::GetCurrentUser();
$this->opts = $p_opts;
$this->epoch_now = time();
$this->hasCurrent = false;
}
//check to see if this row should be editable.
@ -59,12 +67,12 @@ class Application_Model_ShowBuilder {
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
$schedStartDT = new DateTime($p_item["sched_starts"], new DateTimeZone("UTC"));
$showStartEpoch = intval($showStartDT->format('U'));
$schedStartEpoch = intval($schedStartDT->format('U'));
//can only schedule the show if item hasn't started and you are allowed.
if ($this->epoch_now < max($showStartEpoch, $schedStartEpoch)
if ($this->epoch_now < max($showStartEpoch, $schedStartEpoch)
&& $this->user->canSchedule($p_item["show_id"]) == true) {
$row["allowed"] = true;
}
@ -89,11 +97,13 @@ class Application_Model_ShowBuilder {
}
private function isCurrent($p_epochItemStart, $p_epochItemEnd, &$row) {
if ($this->epoch_now >= $p_epochItemStart && $this->epoch_now < $p_epochItemEnd) {
$row["current"] = true;
//how many seconds the view should wait to redraw itself.
$row["refresh"] = $p_epochItemEnd - $this->epoch_now;
$this->hasCurrent = true;
}
}
@ -111,6 +121,7 @@ class Application_Model_ShowBuilder {
$row["header"] = true;
$row["starts"] = $showStartDT->format("Y-m-d H:i");
$row["timeUntil"] = intval($showStartDT->format("U")) - $this->epoch_now;
$row["ends"] = $showEndDT->format("Y-m-d H:i");
$row["duration"] = $showEndDT->format("U") - $showStartDT->format("U");
$row["title"] = $p_item["show_name"];
@ -194,6 +205,39 @@ class Application_Model_ShowBuilder {
return $row;
}
/*
* @param int $timestamp Unix timestamp in seconds.
*
* @return boolean whether the schedule in the show builder's range has been updated.
*
*/
public function hasBeenUpdatedSince($timestamp) {
$outdated = false;
Logging::log("checking if show builder has been updated since {$timestamp}");
$shows = Application_Model_Show::getShows($this->startDT, $this->endDT);
foreach ($shows as $show) {
if (isset($show["last_scheduled"])) {
$dt = new DateTime($show["last_scheduled"], new DateTimeZone("UTC"));
//check if any of the shows have a more recent timestamp.
if ($timestamp < intval($dt->format("U"))) {
$outdated = true;
break;
}
}
}
if (count($shows) == 0) {
$outdated = true;
}
return $outdated;
}
public function GetItems() {
$current_id = -1;
@ -229,7 +273,7 @@ class Application_Model_ShowBuilder {
//pass in the previous row as it's the last row for the previous show.
$display_items[] = $this->makeFooterRow($scheduled_items[$i-1]);
}
$display_items[] = $this->makeHeaderRow($item);
$current_id = $item["si_id"];
@ -247,6 +291,10 @@ class Application_Model_ShowBuilder {
if (count($scheduled_items) > 0) {
$display_items[] = $this->makeFooterRow($scheduled_items[count($scheduled_items)-1]);
}
if (!$this->hasCurrent) {
}
return $display_items;
}

View file

@ -395,7 +395,7 @@ class Application_Model_StoredFile {
}
private function constructGetFileUrl($p_serverName, $p_serverPort){
Logging::log("getting media! - 2");
Logging::log("getting media! - 2");
return "http://$p_serverName:$p_serverPort/api/get-media/file/".$this->getGunId().".".$this->getFileExtension();
}
@ -660,7 +660,7 @@ Logging::log("getting media! - 2");
if($type == "au"){//&& isset( $audioResults )) {
$row['audioFile'] = $row['gunid'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
$row['image'] = '<div class="big_play"><img src="/css/images/icon_audioclip.png"></div>';
$row['image'] = '<img src="/css/images/icon_audioclip.png">';
}
else {
$row['image'] = '<img src="/css/images/icon_playlist.png">';
@ -669,22 +669,22 @@ Logging::log("getting media! - 2");
return $results;
}
public static function searchFiles($displayColumns, $fromTable, $data)
{
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
$where = array();
if ($data["sSearch"] !== "") {
$searchTerms = explode(" ", $data["sSearch"]);
}
$selectorCount = "SELECT COUNT(*) ";
$selectorRows = "SELECT ".join(",", $displayColumns)." ";
$sql = $selectorCount." FROM ".$fromTable;
$sqlTotalRows = $sql;
if (isset($searchTerms)) {
$searchCols = array();
for ($i = 0; $i < $data["iColumns"]; $i++) {
@ -692,12 +692,12 @@ Logging::log("getting media! - 2");
$searchCols[] = $data["mDataProp_{$i}"];
}
}
$outerCond = array();
foreach ($searchTerms as $term) {
$innerCond = array();
foreach ($searchCols as $col) {
$escapedTerm = pg_escape_string($term);
$innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'";
@ -707,7 +707,7 @@ Logging::log("getting media! - 2");
$where[] = "(".join(" AND ", $outerCond).")";
}
// End Where clause
// Order By clause
$orderby = array();
for ($i = 0; $i < $data["iSortingCols"]; $i++){
@ -717,22 +717,22 @@ Logging::log("getting media! - 2");
$orderby[] = "id";
$orderby = join("," , $orderby);
// End Order By clause
if (count($where) > 0) {
$where = join(" AND ", $where);
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
$sqlTotalDisplayRows = $sql;
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
}
else {
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
}
try {
$r = $con->query($sqlTotalRows);
$totalRows = $r->fetchColumn(0);
if (isset($sqlTotalDisplayRows)) {
$r = $con->query($sqlTotalDisplayRows);
$totalDisplayRows = $r->fetchColumn(0);
@ -740,7 +740,7 @@ Logging::log("getting media! - 2");
else {
$totalDisplayRows = $totalRows;
}
$r = $con->query($sql);
$r->setFetchMode(PDO::FETCH_ASSOC);
$results = $r->fetchAll();
@ -748,10 +748,10 @@ Logging::log("getting media! - 2");
catch (Exception $e) {
Logging::log($e->getMessage());
}
//display sql executed in airtime log for testing
Logging::log($sql);
return array("sEcho" => intval($data["sEcho"]), "iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results);
}
@ -764,15 +764,15 @@ Logging::log("getting media! - 2");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// Settings
$cleanupTargetDir = false; // Remove old files
$maxFileAge = 60 * 60; // Temp file age in seconds
// 5 minutes execution time
@set_time_limit(5 * 60);
// usleep(5000);
// Get parameters
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
@ -781,29 +781,29 @@ Logging::log("getting media! - 2");
// Clean the fileName for security reasons
//this needs fixing for songs not in ascii.
//$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
// Create target dir
if (!file_exists($p_targetDir))
@mkdir($p_targetDir);
// Remove old temp files
if (is_dir($p_targetDir) && ($dir = opendir($p_targetDir))) {
while (($file = readdir($dir)) !== false) {
$filePath = $p_targetDir . DIRECTORY_SEPARATOR . $file;
// Remove temp files if they are older than the max age
if (preg_match('/\.tmp$/', $file) && (filemtime($filePath) < time() - $maxFileAge))
@unlink($filePath);
}
closedir($dir);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
// Look for the content type header
if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
if (isset($_SERVER["CONTENT_TYPE"]))
$contentType = $_SERVER["CONTENT_TYPE"];
@ -819,13 +819,13 @@ Logging::log("getting media! - 2");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen($_FILES['file']['tmp_name'], "rb");
if ($in) {
while ($buff = fread($in, 4096))
fwrite($out, $buff);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
fclose($out);
unlink($_FILES['file']['tmp_name']);
} else
@ -838,18 +838,18 @@ Logging::log("getting media! - 2");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen("php://input", "rb");
if ($in) {
while ($buff = fread($in, 4096))
fwrite($out, $buff);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
fclose($out);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}
return $tempFilePath;
}
@ -899,7 +899,7 @@ Logging::log("getting media! - 2");
Logging::log("copyFileToStor: moving file $audio_file to $audio_stor");
//Martin K.: changed to rename: Much less load + quicker since this is an atomic operation
$r = @rename($audio_file, $audio_stor);
if ($r === false) {
#something went wrong likely there wasn't enough space in the audio_stor to move the file too.
#warn the user that the file wasn't uploaded and they should check if there is enough disk space.

View file

@ -19,6 +19,7 @@ class TimeFilledFormatter {
{
$formatted = "";
$sign = ($this->_seconds < 0) ? "-" : "+";
$perfect = true;
$time = Application_Model_Playlist::secondsToPlaylistTime(abs($this->_seconds));
Logging::log("time is: ".$time);
@ -29,16 +30,24 @@ class TimeFilledFormatter {
if (intval($info[0]) > 0) {
$info[0] = ltrim($info[0], "0");
$formatted .= " {$info[0]}h";
$perfect = false;
}
if (intval($info[1]) > 0) {
$info[1] = ltrim($info[1], "0");
$formatted .= " {$info[1]}m";
$perfect = false;
}
if (intval($info[2]) > 0) {
$sec = round($info[2], 0);
$formatted .= " {$sec}s";
$perfect = false;
}
//0 over/under lap of content.
if ($perfect === true) {
$formatted = "+ 0s";
}
return $formatted;

View file

@ -0,0 +1,7 @@
<div class="his-timerange">
<?php echo $this->element->getElement('his_date_start') ?>
<?php echo $this->element->getElement('his_time_start') ?>
<?php echo $this->element->getElement('his_date_end') ?>
<?php echo $this->element->getElement('his_time_end') ?>
<input type="button" id="his_submit" class="ui-button ui-state-default" value="GO"></input>
</div>

View file

@ -1,4 +1,5 @@
<div class="sb-timerange">
<?php echo $this->element->getElement('sb_timestamp') ?>
<?php echo $this->element->getElement('sb_date_start') ?>
<?php echo $this->element->getElement('sb_time_start') ?>
<?php echo $this->element->getElement('sb_date_end') ?>

View file

@ -0,0 +1,2 @@
<?php echo $this->date_form; ?>
<table id="history_table" cellpadding="0" cellspacing="0" class="datatable"></table>

View file

@ -0,0 +1 @@
<?php echo $this->dialog ?>