Merge pull request #364 from Robbt/feature/smart-block-dynamic-preview

Feature: Modified form to allow preview of tracks for dynamic smartblocks
This commit is contained in:
Lucas Bickel 2018-01-04 21:10:13 +01:00 committed by GitHub
commit 63e97692b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 8 deletions

View File

@ -163,6 +163,8 @@ final class LocaleController extends Zend_Controller_Action
"is greater than" => _("is greater than"),
"is less than" => _("is less than"),
"is in the range" => _("is in the range"),
"Preview" => _("Preview"),
"Generate" => _("Generate"),
//preferences/musicdirs.js
"Choose Storage Folder" => _("Choose Storage Folder"),
"Choose Folder to Watch" => _("Choose Folder to Watch"),

View File

@ -347,7 +347,12 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$generate->setAttrib('class', 'sp-button btn');
$generate->setAttrib('title', _('Generate playlist content and save criteria'));
$generate->setIgnore(true);
$generate->setLabel(_('Generate'));
if ($blockType == 0) {
$generate->setLabel(_('Generate'));
}
else {
$generate->setLabel(_('Preview'));
}
$generate->setDecorators(array('viewHelper'));
$this->addElement($generate);

View File

@ -179,7 +179,7 @@ class Application_Model_Block implements Application_Model_LibraryEditable
}
/**
* Get the entire block as a two dimentional array, sorted in order of play.
* Get the entire block as a two dimensional array, sorted in order of play.
* @param boolean $filterFiles if this is true, it will only return files that has
* file_exists flag set to true
* @return array
@ -273,7 +273,7 @@ SQL;
/**
* The database stores fades in 00:00:00 Time format with optional millisecond resolution .000000
* but this isn't practical since fades shouldn't be very long usuall 1 second or less. This function
* but this isn't practical since fades shouldn't be very long usually 1 second or less. This function
* will normalize the fade so that it looks like 00.000000 to the user.
**/
public function normalizeFade($fade)
@ -1250,7 +1250,7 @@ SQL;
}
/**
* generate list of tracks. This function saves creiteria and generate
* generate list of tracks. This function saves criteria and generate
* tracks.
* @param array $p_criteria
*/
@ -1259,7 +1259,7 @@ SQL;
$this->saveSmartBlockCriteria($p_criteria);
$insertList = $this->getListOfFilesUnderLimit();
$this->deleteAllFilesFromBlock();
// constrcut id array
// construct id array
$ids = array();
foreach ($insertList as $ele) {
$ids[] = $ele['id'];

View File

@ -1,9 +1,12 @@
<?php
$items = $this->contents;
$isStaticSmartBlock = ($this->obj instanceof Application_Model_Block && $this->obj->isStatic());
$isSmartBlock = ($this->obj instanceof Application_Model_Block);
$isPlaylist = ($this->obj instanceof Application_Model_Playlist);
if (count($items) && ($isStaticSmartBlock || $isPlaylist)) : ?>
if (count($items) && ($isSmartBlock || $isPlaylist)) : ?>
<?php $i = 0; ?>
<?php if (!($this->obj->isStatic())) {
echo _("</br>This is only a preview of possible content generated by the smart block based upon the above criteria.");}
?>
<?php foreach($items as $item) :
$staticBlock = null;
$nextFileUrl = null;

View File

@ -385,11 +385,12 @@ function setupUI() {
if (playlist_type == "0") {
shuffleButton.removeAttr("disabled");
generateButton.removeAttr("disabled");
generateButton.html($.i18n._("Generate"));
fadesButton.removeAttr("disabled");
//sortable.children().show();
} else {
shuffleButton.attr("disabled", "disabled");
generateButton.attr("disabled", "disabled");
generateButton.html($.i18n._("Preview"));
fadesButton.attr("disabled", "disabled");
//sortable.children().hide();
}