Merge pull request #605 from Robbt/feature-smartblock-remaining-time
Add Fill Remaining Time Smartblock Limit
This commit is contained in:
commit
4752c728b9
|
@ -159,7 +159,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
$this->limitOptions = array(
|
$this->limitOptions = array(
|
||||||
"hours" => _("hours"),
|
"hours" => _("hours"),
|
||||||
"minutes" => _("minutes"),
|
"minutes" => _("minutes"),
|
||||||
"items" => _("items")
|
"items" => _("items"),
|
||||||
|
"remaining" => _("time remaining in show")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $this->limitOptions;
|
return $this->limitOptions;
|
||||||
|
|
|
@ -1321,9 +1321,13 @@ SQL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getListOfFilesUnderLimit()
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function getListOfFilesUnderLimit($show = null)
|
||||||
{
|
{
|
||||||
$info = $this->getListofFilesMeetCriteria();
|
$info = $this->getListofFilesMeetCriteria($show);
|
||||||
$files = $info['files'];
|
$files = $info['files'];
|
||||||
$limit = $info['limit'];
|
$limit = $info['limit'];
|
||||||
$repeat = $info['repeat_tracks'];
|
$repeat = $info['repeat_tracks'];
|
||||||
|
@ -1507,7 +1511,7 @@ SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function return list of propel object
|
// this function return list of propel object
|
||||||
public function getListofFilesMeetCriteria()
|
public function getListofFilesMeetCriteria($show = null)
|
||||||
{
|
{
|
||||||
$storedCrit = $this->getCriteria();
|
$storedCrit = $this->getCriteria();
|
||||||
|
|
||||||
|
@ -1645,6 +1649,17 @@ SQL;
|
||||||
if ($storedCrit['limit']['modifier'] == "items") {
|
if ($storedCrit['limit']['modifier'] == "items") {
|
||||||
$limits['time'] = 1440 * 60;
|
$limits['time'] = 1440 * 60;
|
||||||
$limits['items'] = $storedCrit['limit']['value'];
|
$limits['items'] = $storedCrit['limit']['value'];
|
||||||
|
} elseif (($storedCrit['limit']['modifier'] == "remaining") ){
|
||||||
|
// show will be null unless being called inside a show instance
|
||||||
|
if (!(is_null($show))) {
|
||||||
|
$showInstance = new Application_Model_ShowInstance($show);
|
||||||
|
$limits['time'] = $showInstance->getSecondsRemaining();
|
||||||
|
$limits['items'] = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$limits['time'] = 60 * 60;
|
||||||
|
$limits['items'] = null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$limits['time'] = $storedCrit['limit']['modifier'] == "hours" ?
|
$limits['time'] = $storedCrit['limit']['modifier'] == "hours" ?
|
||||||
intval(floatval($storedCrit['limit']['value']) * 60 * 60) :
|
intval(floatval($storedCrit['limit']['value']) * 60 * 60) :
|
||||||
|
|
|
@ -207,10 +207,11 @@ final class Application_Model_Scheduler
|
||||||
/*
|
/*
|
||||||
* @param $id
|
* @param $id
|
||||||
* @param $type
|
* @param $type
|
||||||
|
* @param $show
|
||||||
*
|
*
|
||||||
* @return $files
|
* @return $files
|
||||||
*/
|
*/
|
||||||
private function retrieveMediaFiles($id, $type)
|
private function retrieveMediaFiles($id, $type, $show)
|
||||||
{
|
{
|
||||||
$files = array();
|
$files = array();
|
||||||
|
|
||||||
|
@ -337,7 +338,7 @@ final class Application_Model_Scheduler
|
||||||
} else {
|
} else {
|
||||||
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
|
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
|
||||||
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
|
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
|
||||||
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
$dynamicFiles = $bl->getListOfFilesUnderLimit($show);
|
||||||
foreach ($dynamicFiles as $f) {
|
foreach ($dynamicFiles as $f) {
|
||||||
$fileId = $f['id'];
|
$fileId = $f['id'];
|
||||||
$file = CcFilesQuery::create()->findPk($fileId);
|
$file = CcFilesQuery::create()->findPk($fileId);
|
||||||
|
@ -788,11 +789,14 @@ final class Application_Model_Scheduler
|
||||||
Logging::debug(floatval($pend) - floatval($pstart));
|
Logging::debug(floatval($pend) - floatval($pstart));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// passing $schedule["instance"] so that the instance being scheduled
|
||||||
|
// can be used to determine the remaining time
|
||||||
|
// in the case of a fill remaining time smart block
|
||||||
if (is_null($filesToInsert)) {
|
if (is_null($filesToInsert)) {
|
||||||
$filesToInsert = array();
|
$filesToInsert = array();
|
||||||
foreach ($mediaItems as $media) {
|
foreach ($mediaItems as $media) {
|
||||||
$filesToInsert = array_merge($filesToInsert,
|
$filesToInsert = array_merge($filesToInsert,
|
||||||
$this->retrieveMediaFiles($media["id"], $media["type"]));
|
$this->retrieveMediaFiles($media["id"], $media["type"], $schedule["instance"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -476,6 +476,12 @@ SQL;
|
||||||
return intval($ends->format('U')) - intval($starts->format('U'));
|
return intval($ends->format('U')) - intval($starts->format('U'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// should return the amount of seconds remaining to be scheduled in a show instance
|
||||||
|
public function getSecondsRemaining()
|
||||||
|
{
|
||||||
|
return ($this->getDurationSecs() - $this->getTimeScheduledSecs());
|
||||||
|
}
|
||||||
|
|
||||||
public function getPercentScheduled()
|
public function getPercentScheduled()
|
||||||
{
|
{
|
||||||
$durationSeconds = $this->getDurationSecs();
|
$durationSeconds = $this->getDurationSecs();
|
||||||
|
|
|
@ -711,7 +711,7 @@ table.library-get-file-md.table-small{
|
||||||
}
|
}
|
||||||
|
|
||||||
.sp_input_select{
|
.sp_input_select{
|
||||||
width: 130px;
|
width: 140px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sp_input_text_limit{
|
.sp_input_text_limit{
|
||||||
|
|
|
@ -291,8 +291,20 @@ function setSmartBlockEvents() {
|
||||||
setupUI();
|
setupUI();
|
||||||
AIRTIME.library.checkAddButton();
|
AIRTIME.library.checkAddButton();
|
||||||
});
|
});
|
||||||
|
|
||||||
/********** CRITERIA CHANGE **********/
|
/********** LIMIT CHANGE *************/
|
||||||
|
form.find('select[id="sp_limit_options"]').live("change", function() {
|
||||||
|
var limVal = form.find('input[id="sp_limit_value"]');
|
||||||
|
if ($(this).val() === 'remaining') {
|
||||||
|
disableAndHideLimitValue();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enableAndShowLimitValue();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/********** CRITERIA CHANGE **********/
|
||||||
form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"])').live("change", function(){
|
form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"])').live("change", function(){
|
||||||
var index = getRowIndex($(this).parent());
|
var index = getRowIndex($(this).parent());
|
||||||
//need to change the criteria value for any modifier rows
|
//need to change the criteria value for any modifier rows
|
||||||
|
@ -461,6 +473,9 @@ function setupUI() {
|
||||||
shuffleButton = activeTab.find('button[name="shuffle_button"]'),
|
shuffleButton = activeTab.find('button[name="shuffle_button"]'),
|
||||||
generateButton = activeTab.find('button[name="generate_button"]'),
|
generateButton = activeTab.find('button[name="generate_button"]'),
|
||||||
fadesButton = activeTab.find('#spl_crossfade, #pl-bl-clear-content');
|
fadesButton = activeTab.find('#spl_crossfade, #pl-bl-clear-content');
|
||||||
|
if (activeTab.find('#sp_limit_options').val() == 'remaining') {
|
||||||
|
disableAndHideLimitValue();
|
||||||
|
}
|
||||||
|
|
||||||
if (!plContents.hasClass('spl_empty')) {
|
if (!plContents.hasClass('spl_empty')) {
|
||||||
if (shuffleButton.hasClass('ui-state-disabled')) {
|
if (shuffleButton.hasClass('ui-state-disabled')) {
|
||||||
|
@ -633,6 +648,14 @@ function disableAndHideExtraField(valEle, index) {
|
||||||
var criteria_value = $('#sp_criteria_value_'+index);
|
var criteria_value = $('#sp_criteria_value_'+index);
|
||||||
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
|
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
|
||||||
}
|
}
|
||||||
|
function disableAndHideLimitValue() {
|
||||||
|
console.log('we hide it');
|
||||||
|
$('#sp_limit_value').hide();
|
||||||
|
}
|
||||||
|
function enableAndShowLimitValue() {
|
||||||
|
console.log('we show it');
|
||||||
|
$('#sp_limit_value').show();
|
||||||
|
}
|
||||||
|
|
||||||
function sizeTextBoxes(ele, classToRemove, classToAdd) {
|
function sizeTextBoxes(ele, classToRemove, classToAdd) {
|
||||||
if (ele.hasClass(classToRemove)) {
|
if (ele.hasClass(classToRemove)) {
|
||||||
|
|
Loading…
Reference in New Issue