Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
76eaae62f0
|
@ -97,10 +97,8 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$form = new Application_Form_SmartBlockCriteria();
|
||||
$form->removeDecorator('DtDdWrapper');
|
||||
$form->startForm($obj->getId());
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
if ($isBlock){
|
||||
$this->view->obj = $obj;
|
||||
$this->view->id = $obj->getId();
|
||||
if ($isJson) {
|
||||
|
@ -532,8 +530,21 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$this->setPlaylistNameDescAction();
|
||||
|
||||
if ($params['type'] == 'block') {
|
||||
$bl = new Application_Model_Block($params['obj_id']);
|
||||
$result = $bl->saveSmartBlockCriteria($params['criteria']);
|
||||
$form = new Application_Form_SmartBlockCriteria();
|
||||
$form->startForm($params['obj_id']);
|
||||
$bl = new Application_Model_Block($params['obj_id']);
|
||||
if ($form->isValid($params)) {
|
||||
$result = $bl->saveSmartBlockCriteria($params['data']);
|
||||
$result['html'] = $this->createFullResponse($bl, true);
|
||||
$result['result'] = 0;
|
||||
} else {
|
||||
$this->view->obj = $bl;
|
||||
$this->view->id = $bl->getId();
|
||||
$this->view->form = $form;
|
||||
$viewPath = 'playlist/smart-block.phtml';
|
||||
$result['html'] = $this->view->render($viewPath);
|
||||
$result['result'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$result["modified"] = $this->view->modified;
|
||||
|
@ -544,9 +555,11 @@ class PlaylistController extends Zend_Controller_Action
|
|||
{
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
$form = new Application_Form_SmartBlockCriteria();
|
||||
$form->startForm($params['obj_id']);
|
||||
$bl = new Application_Model_Block($params['obj_id']);
|
||||
$result = $bl->generateSmartBlock($params['data']);
|
||||
if ($result['result'] == 0) {
|
||||
if ($form->isValid($params)) {
|
||||
$result = $bl->generateSmartBlock($params['data']);
|
||||
try {
|
||||
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true))));
|
||||
}
|
||||
|
@ -557,6 +570,12 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$this->playlistUnknownError($e);
|
||||
}
|
||||
}else{
|
||||
$this->view->obj = $bl;
|
||||
$this->view->id = $bl->getId();
|
||||
$this->view->form = $form;
|
||||
$viewPath = 'playlist/smart-block.phtml';
|
||||
$result['html'] = $this->view->render($viewPath);
|
||||
$result['result'] = 1;
|
||||
die(json_encode($result));
|
||||
}
|
||||
}
|
||||
|
@ -566,14 +585,8 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
$bl = new Application_Model_Block($params['obj_id']);
|
||||
|
||||
//we need to save criteria in case user hasn't clicked Save or Generate yet
|
||||
$result = $bl->saveSmartBlockCriteria($params['data']);
|
||||
|
||||
//only shuffle if there are no criteria errors
|
||||
if ($result['result'] == 0) {
|
||||
$result = $bl->shuffleSmartBlock();
|
||||
}
|
||||
$result = $bl->shuffleSmartBlock();
|
||||
|
||||
if ($result['result'] == 0) {
|
||||
try {
|
||||
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true))));
|
||||
|
|
|
@ -266,4 +266,153 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
));
|
||||
}
|
||||
|
||||
function isValid($params){
|
||||
Logging::log("isvalid called");
|
||||
$isValid = true;
|
||||
// reconstruct the params['criteria'] so we can populate the form
|
||||
$formData = array();
|
||||
foreach ($params['data'] as $ele) {
|
||||
$formData[$ele['name']] = $ele['value'];
|
||||
}
|
||||
$this->populate($formData);
|
||||
$criteria2PeerMap = array(
|
||||
0 => "Select criteria",
|
||||
"album_title" => "DbAlbumTitle",
|
||||
"artist_name" => "DbArtistName",
|
||||
"bit_rate" => "DbBitRate",
|
||||
"bpm" => "DbBpm",
|
||||
"comments" => "DbComments",
|
||||
"composer" => "DbComposer",
|
||||
"conductor" => "DbConductor",
|
||||
"utime" => "DbUtime",
|
||||
"mtime" => "DbMtime",
|
||||
"lptime" => "DbLPtime",
|
||||
"disc_number" => "DbDiscNumber",
|
||||
"genre" => "DbGenre",
|
||||
"isrc_number" => "DbIsrcNumber",
|
||||
"label" => "DbLabel",
|
||||
"language" => "DbLanguage",
|
||||
"length" => "DbLength",
|
||||
"lyricist" => "DbLyricist",
|
||||
"mood" => "DbMood",
|
||||
"name" => "DbName",
|
||||
"orchestra" => "DbOrchestra",
|
||||
"rating" => "DbRating",
|
||||
"sample_rate" => "DbSampleRate",
|
||||
"track_title" => "DbTrackTitle",
|
||||
"track_number" => "DbTrackNumber",
|
||||
"year" => "DbYear"
|
||||
);
|
||||
$data = Application_Model_Block::organizeSmartPlyalistCriteria($params['data']);
|
||||
// things we need to check
|
||||
// 1. limit value shouldn't be empty and has upperbound of 24 hrs
|
||||
// 2. sp_criteria or sp_criteria_modifier shouldn't be 0
|
||||
// 3. validate formate according to DB column type
|
||||
$multiplier = 1;
|
||||
$result = 0;
|
||||
$errors = array();
|
||||
$error = array();
|
||||
|
||||
// validation start
|
||||
if ($data['etc']['sp_limit_options'] == 'hours') {
|
||||
$multiplier = 60;
|
||||
}
|
||||
if ($data['etc']['sp_limit_options'] == 'hours' || $data['etc']['sp_limit_options'] == 'mins') {
|
||||
$element = $this->getElement("sp_limit_value");
|
||||
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
|
||||
$element->addError("Limit cannot be empty or smaller than 0");
|
||||
$isValid = false;
|
||||
} else {
|
||||
$mins = floatval($data['etc']['sp_limit_value']) * $multiplier;
|
||||
if ($mins > 1440) {
|
||||
$element->addError("Limit cannot be more than 24 hrs");
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$element = $this->getElement("sp_limit_value");
|
||||
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
|
||||
$element->addError("Limit cannot be empty or smaller than 0");
|
||||
$isValid = false;
|
||||
} else if (!ctype_digit($data['etc']['sp_limit_value'])) {
|
||||
$element->addError("The value should be an integer");
|
||||
$isValid = false;
|
||||
} else if (intval($data['etc']['sp_limit_value']) > 500) {
|
||||
$element->addError("500 is the max item limit value you can set");
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
$criteriaFieldsUsed = array();
|
||||
|
||||
if (isset($data['criteria'])) {
|
||||
foreach ($data['criteria'] as $rowKey=>$row) {
|
||||
foreach ($row as $key=>$d){
|
||||
$element = $this->getElement("sp_criteria_field_".$rowKey."_".$key);
|
||||
$error = array();
|
||||
// check for not selected select box
|
||||
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
|
||||
$element->addError("You must select Criteria and Modifier");
|
||||
$isValid = false;
|
||||
} else {
|
||||
$column = CcFilesPeer::getTableMap()->getColumnByPhpName($criteria2PeerMap[$d['sp_criteria_field']]);
|
||||
// validation on type of column
|
||||
if ($d['sp_criteria_field'] == 'length') {
|
||||
if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
|
||||
$element->addError("'Length' should be in '00:00:00' format");
|
||||
$isValid = false;
|
||||
}
|
||||
} else if ($column->getType() == PropelColumnTypes::TIMESTAMP) {
|
||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
|
||||
$element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00");
|
||||
$isValid = false;
|
||||
} else {
|
||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']);
|
||||
if (!$result["success"]) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$element->addError($result["errMsg"]);
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($d['sp_criteria_extra'])) {
|
||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) {
|
||||
$element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00");
|
||||
$isValid = false;
|
||||
} else {
|
||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']);
|
||||
if (!$result["success"]) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$element->addError($result["errMsg"]);
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($column->getType() == PropelColumnTypes::INTEGER) {
|
||||
if (!is_numeric($d['sp_criteria_value'])) {
|
||||
$element->addError("The value has to be numeric");
|
||||
$isValid = false;
|
||||
}
|
||||
// length check
|
||||
if (intval($d['sp_criteria_value']) >= pow(2,31)) {
|
||||
$element->addError("The value should be less then 2147483648");
|
||||
$isValid = false;
|
||||
}
|
||||
} else if ($column->getType() == PropelColumnTypes::VARCHAR) {
|
||||
if (strlen($d['sp_criteria_value']) > $column->getSize()) {
|
||||
$element->addError("The value should be less ".$column->getSize()." characters");
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($d['sp_criteria_value'] == "") {
|
||||
$element->addError("Value cannot be empty");
|
||||
$isValid = false;
|
||||
}
|
||||
}//end foreach
|
||||
}//for loop
|
||||
}//if
|
||||
return $isValid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,9 +242,9 @@ EOT;
|
|||
return $fade;
|
||||
}
|
||||
|
||||
// function return "N/A" if dynamic
|
||||
public function getLength()
|
||||
public function getUnformatedLength()
|
||||
{
|
||||
$this->block->reload();
|
||||
if ($this->isStatic()){
|
||||
$length = $this->block->getDbLength();
|
||||
} else {
|
||||
|
@ -253,8 +253,9 @@ EOT;
|
|||
return $length;
|
||||
}
|
||||
|
||||
public function getFormattedLength()
|
||||
public function getLength()
|
||||
{
|
||||
$this->block->reload();
|
||||
$prepend = "";
|
||||
if ($this->isStatic()){
|
||||
$length = $this->block->getDbLength();
|
||||
|
@ -808,7 +809,7 @@ EOT;
|
|||
throw $e;
|
||||
}
|
||||
|
||||
return array("cliplength"=> $cliplength, "cueIn"=> $cueIn, "cueOut"=> $cueOut, "length"=> $this->getLength(),
|
||||
return array("cliplength"=> $cliplength, "cueIn"=> $cueIn, "cueOut"=> $cueOut, "length"=> $this->getUnformatedLength(),
|
||||
"fadeIn"=> $fadeIn, "fadeOut"=> $fadeOut);
|
||||
}
|
||||
|
||||
|
@ -935,136 +936,30 @@ EOT;
|
|||
public function saveSmartBlockCriteria($p_criteria)
|
||||
{
|
||||
$data = $this->organizeSmartPlyalistCriteria($p_criteria);
|
||||
|
||||
// things we need to check
|
||||
// 1. limit value shouldn't be empty and has upperbound of 24 hrs
|
||||
// 2. sp_criteria or sp_criteria_modifier shouldn't be 0
|
||||
// 3. validate formate according to DB column type
|
||||
$multiplier = 1;
|
||||
$result = 0;
|
||||
$errors = array();
|
||||
$error = array();
|
||||
|
||||
// saving dynamic/static flag
|
||||
$blockType = $data['etc']['sp_type'] == 0 ? 'static':'dynamic';
|
||||
$this->saveType($blockType);
|
||||
|
||||
// validation start
|
||||
if ($data['etc']['sp_limit_options'] == 'hours') {
|
||||
$multiplier = 60;
|
||||
}
|
||||
if ($data['etc']['sp_limit_options'] == 'hours' || $data['etc']['sp_limit_options'] == 'mins') {
|
||||
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
|
||||
$error[] = "Limit cannot be empty or smaller than 0";
|
||||
$this->storeCriteriaIntoDb($data);
|
||||
//get number of files that meet the criteria
|
||||
$files = $this->getListofFilesMeetCriteria();
|
||||
//$output['poolCount'] = $files["count"];
|
||||
// if the block is dynamic, put null to the length
|
||||
// as it cannot be calculated
|
||||
if ($blockType == 'dynamic') {
|
||||
if ($this->hasItemLimit()) {
|
||||
$this->setLength(null);
|
||||
} else {
|
||||
$mins = floatval($data['etc']['sp_limit_value']) * $multiplier;
|
||||
if ($mins > 1440) {
|
||||
$error[] = "Limit cannot be more than 24 hrs";
|
||||
}
|
||||
$this->setLength($this->getDynamicBlockLength());
|
||||
}
|
||||
} else {
|
||||
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
|
||||
$error[] = "Limit cannot be empty or smaller than 0";
|
||||
} else if (!ctype_digit($data['etc']['sp_limit_value'])) {
|
||||
$error[] = "The value should be an integer";
|
||||
} else if (intval($data['etc']['sp_limit_value']) > 500) {
|
||||
$error[] = "500 is the max item limit value you can set";
|
||||
$length = $this->getStaticLength();
|
||||
if (!$length) {
|
||||
$length = "00:00:00";
|
||||
}
|
||||
$this->setLength($length);
|
||||
}
|
||||
|
||||
if (count($error) > 0){
|
||||
$errors[] = array("element"=>"sp_limit_value", "msg"=>$error);
|
||||
}
|
||||
|
||||
$criteriaFieldsUsed = array();
|
||||
|
||||
if (isset($data['criteria'])) {
|
||||
$critKeys = array_keys($data['criteria']);
|
||||
for ($i = 0; $i < count($critKeys); $i++) {
|
||||
foreach ($data['criteria'][$critKeys[$i]] as $key=>$d){
|
||||
$error = array();
|
||||
// check for not selected select box
|
||||
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
|
||||
$error[] = "You must select Criteria and Modifier";
|
||||
} else {
|
||||
$column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']]);
|
||||
// validation on type of column
|
||||
if ($d['sp_criteria_field'] == 'length') {
|
||||
if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
|
||||
$error[] = "'Length' should be in '00:00:00' format";
|
||||
}
|
||||
} else if ($column->getType() == PropelColumnTypes::TIMESTAMP) {
|
||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
|
||||
$error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00";
|
||||
} else {
|
||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']);
|
||||
if (!$result["success"]) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$error[] = $result["errMsg"];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($d['sp_criteria_extra'])) {
|
||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) {
|
||||
$error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00";
|
||||
} else {
|
||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']);
|
||||
if (!$result["success"]) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$error[] = $result["errMsg"];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($column->getType() == PropelColumnTypes::INTEGER) {
|
||||
if (!is_numeric($d['sp_criteria_value'])) {
|
||||
$error[] = "The value has to be numeric";
|
||||
}
|
||||
// length check
|
||||
if (intval($d['sp_criteria_value']) >= pow(2,31)) {
|
||||
$error[] = "The value should be less then 2147483648";
|
||||
}
|
||||
} else if ($column->getType() == PropelColumnTypes::VARCHAR) {
|
||||
if (strlen($d['sp_criteria_value']) > $column->getSize()) {
|
||||
$error[] = "The value should be less ".$column->getSize()." characters";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($d['sp_criteria_value'] == "") {
|
||||
$error[] = "Value cannot be empty";
|
||||
}
|
||||
if(count($error) > 0){
|
||||
$errors[] = array("element"=>"sp_criteria_field_".$critKeys[$i]."_".$key, "msg"=>$error);
|
||||
}
|
||||
}//end foreach
|
||||
}//for loop
|
||||
}//if
|
||||
//$output['blockLength'] = $this->getFormattedLength();
|
||||
|
||||
$result = count($errors) > 0 ? 1 :0;
|
||||
$files["count"] = 0;
|
||||
$output = array("result"=>$result, "errors"=>$errors);
|
||||
if ($result == 0) {
|
||||
$this->storeCriteriaIntoDb($data);
|
||||
//get number of files that meet the criteria
|
||||
$files = $this->getListofFilesMeetCriteria();
|
||||
$output['poolCount'] = $files["count"];
|
||||
// if the block is dynamic, put null to the length
|
||||
// as it cannot be calculated
|
||||
if ($blockType == 'dynamic') {
|
||||
if ($this->hasItemLimit()) {
|
||||
$this->setLength(null);
|
||||
} else {
|
||||
$this->setLength($this->getDynamicBlockLength());
|
||||
}
|
||||
} else {
|
||||
$length = $this->getStaticLength();
|
||||
if (!$length) {
|
||||
$length = "00:00:00";
|
||||
}
|
||||
$this->setLength($length);
|
||||
}
|
||||
$output['blockLength'] = $this->getFormattedLength();
|
||||
}
|
||||
$this->updateBlockLengthInAllPlaylist();
|
||||
return $output;
|
||||
}
|
||||
|
@ -1082,7 +977,7 @@ EOT;
|
|||
public function storeCriteriaIntoDb($p_criteriaData){
|
||||
// delete criteria under $p_blockId
|
||||
CcBlockcriteriaQuery::create()->findByDbBlockId($this->id)->delete();
|
||||
|
||||
Logging::log($p_criteriaData);
|
||||
//insert modifier rows
|
||||
if (isset($p_criteriaData['criteria'])) {
|
||||
$critKeys = array_keys($p_criteriaData['criteria']);
|
||||
|
@ -1119,16 +1014,16 @@ EOT;
|
|||
public function generateSmartBlock($p_criteria, $returnList=false)
|
||||
{
|
||||
$result = $this->saveSmartBlockCriteria($p_criteria);
|
||||
if ($result['result'] != 0) {
|
||||
/*if ($result['result'] != 0) {
|
||||
return $result;
|
||||
} else {
|
||||
} else {*/
|
||||
$insertList = $this->getListOfFilesUnderLimit();
|
||||
$this->deleteAllFilesFromBlock();
|
||||
$this->addAudioClips(array_keys($insertList));
|
||||
// update length in playlist contents.
|
||||
$this->updateBlockLengthInAllPlaylist();
|
||||
return array("result"=>0);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
public function updateBlockLengthInAllPlaylist()
|
||||
|
@ -1137,7 +1032,7 @@ EOT;
|
|||
$blocks->getFirst();
|
||||
$iterator = $blocks->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
$length = $this->getLength();
|
||||
$length = $this->getUnformatedLength();
|
||||
if (!preg_match("/^[0-9]{2}:[0-9]{2}:[0-9]{2}/", $length)) {
|
||||
$iterator->current()->setDbClipLength(null);
|
||||
} else {
|
||||
|
@ -1300,7 +1195,7 @@ EOT;
|
|||
|
||||
}
|
||||
|
||||
private static function organizeSmartPlyalistCriteria($p_criteria)
|
||||
public static function organizeSmartPlyalistCriteria($p_criteria)
|
||||
{
|
||||
$fieldNames = array('sp_criteria_field', 'sp_criteria_modifier', 'sp_criteria_value', 'sp_criteria_extra');
|
||||
$output = array();
|
||||
|
@ -1313,7 +1208,7 @@ EOT;
|
|||
*/
|
||||
$fieldName = substr($ele['name'], 0, $index);
|
||||
|
||||
// Get criteria row index.
|
||||
// Get criteria row index.
|
||||
$tempName = $ele['name'];
|
||||
// Get the last digit in the field name
|
||||
preg_match('/^\D*(?=\d)/', $tempName, $r);
|
||||
|
|
|
@ -95,7 +95,7 @@ class Application_Model_Datatables
|
|||
$r['length'] = $pl->getLength();
|
||||
} else if ($r['ftype'] == "block") {
|
||||
$bl = new Application_Model_Block($r['id']);
|
||||
$r['length'] = $bl->getFormattedLength();
|
||||
$r['length'] = $bl->getLength();
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
|
|
@ -227,7 +227,7 @@ SQL;
|
|||
//format the length for UI.
|
||||
if ($row['type'] == 2) {
|
||||
$bl = new Application_Model_Block($row['item_id']);
|
||||
$formatter = new LengthFormatter($bl->getFormattedLength());
|
||||
$formatter = new LengthFormatter($bl->getLength());
|
||||
} else {
|
||||
$formatter = new LengthFormatter($row['length']);
|
||||
}
|
||||
|
|
|
@ -31,14 +31,21 @@
|
|||
<?php echo $this->element->getElement("sp_criteria_field_".$i."_".$j) ?>
|
||||
<a class='ui-button sp-ui-button-icon-only sp_no_margins' id='modifier_add_<?php echo $i ?>'>
|
||||
<span class='ui-icon ui-icon-plusthick'></span>
|
||||
</a>
|
||||
</a>
|
||||
<?php echo $this->element->getElement("sp_criteria_modifier_".$i."_".$j) ?>
|
||||
<?php echo $this->element->getElement("sp_criteria_value_".$i."_".$j) ?>
|
||||
<span class='sp_text_font' id="extra_criteria" <?php echo $this->element->getElement("sp_criteria_extra_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to <?php echo $this->element->getElement('sp_criteria_extra_'.$i."_".$j) ?></span>
|
||||
<span class='sp_text_font' id="extra_criteria" <?php echo $this->element->getElement("sp_criteria_extra_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to <?php echo $this->element->getElement('sp_criteria_extra_'.$i."_".$j) ?></span>
|
||||
<a class='ui-button sp-ui-button-icon-only' id='criteria_remove_<?php echo $i ?>'>
|
||||
<span class='ui-icon ui-icon-closethick'></span>
|
||||
</a>
|
||||
<br />
|
||||
<?php if($this->element->getElement("sp_criteria_field_".$i."_".$j)->hasErrors()) : ?>
|
||||
<?php foreach($this->element->getElement("sp_criteria_field_".$i."_".$j)->getMessages() as $error): ?>
|
||||
<span class='errors sp-errors'>
|
||||
<?php echo $error; ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
@ -61,20 +68,20 @@
|
|||
files meet the criteria
|
||||
</span>
|
||||
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
|
||||
<?php
|
||||
<?php
|
||||
} else if ($this->poolCount == 1) {
|
||||
echo $this->poolCount;
|
||||
?>
|
||||
file meets the criteria
|
||||
</span>
|
||||
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
|
||||
<?php
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
?>
|
||||
0 files meet the criteria
|
||||
</span>
|
||||
<span class='sp-warning-icon' id='sp_pool_count_icon'></span>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<span>Name:</span><span><?php echo ($this->md["dc:title"]);?></span><br />
|
||||
<span>Creator:</span><span><?php echo ($this->md["dc:creator"]);?></span><br />
|
||||
<?php if ($this->type == "block" && $this->blType == "Dynamic") { ?>
|
||||
<span>Length:</span><span><?php echo $this->block->getFormattedLength();?></span><br />
|
||||
<span>Length:</span><span><?php echo $this->block->getLength();?></span><br />
|
||||
<?php } else { ?>
|
||||
<span>Length:</span><span><?php echo ($this->md["dcterms:extent"]);?></span><br />
|
||||
<?php } ?>
|
||||
|
@ -67,7 +67,7 @@
|
|||
<tr class='file-md-qtip-playlist <?php if ($isStatic) echo 'static'; else echo 'dynamic';?>'>
|
||||
<td class='file-md-qtip-row-width-title file-md-qtip-nowrap'><?php echo $row["track_title"] ?></td>
|
||||
<td class='file-md-qtip-row-width-artist file-md-qtip-nowrap'><?php echo $row["creator"] ?></td>
|
||||
<td class='file-md-qtip-row-width-small'><?php echo $bl->getFormattedLength(); ?></td>
|
||||
<td class='file-md-qtip-row-width-small'><?php echo $bl->getLength(); ?></td>
|
||||
</tr>
|
||||
<?php } else if ($row["type"] == 1) {?>
|
||||
<tr class='file-md-qtip-playlist webstream'>
|
||||
|
|
|
@ -600,7 +600,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
dt = $('table[id="library_display"]').dataTable();
|
||||
enableLoadingIcon();
|
||||
$.post(save_action,
|
||||
{format: "json", criteria: criteria, name: block_name, description: block_desc, obj_id: obj_id, type: obj_type, modified: lastMod},
|
||||
{format: "json", data: criteria, name: block_name, description: block_desc, obj_id: obj_id, type: obj_type, modified: lastMod},
|
||||
function(data){
|
||||
var json = $.parseJSON(data);
|
||||
setModified(json.modified);
|
||||
|
|
|
@ -446,21 +446,10 @@ function callback(data, type) {
|
|||
dt = $('table[id="library_display"]').dataTable();
|
||||
|
||||
form.find('span[class="errors sp-errors"]').remove();
|
||||
|
||||
if (json.result == "1") {
|
||||
form.find('.success').hide();
|
||||
if ($('#smart_playlist_options').hasClass('closed')) {
|
||||
$('#smart_playlist_options').removeClass('closed');
|
||||
}
|
||||
$.each(json.errors, function(index, error){
|
||||
$.each(error.msg, function(index, message){
|
||||
$('#'+error.element).parent().append("<span class='errors sp-errors'>"+message+"</span>");
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (type == 'shuffle' || type == 'generate') {
|
||||
AIRTIME.playlist.fnOpenPlaylist(json);
|
||||
form = $('#smart-playlist-form');
|
||||
if (type == 'shuffle' || type == 'generate') {
|
||||
AIRTIME.playlist.fnOpenPlaylist(json);
|
||||
form = $('#smart-playlist-form');
|
||||
if (json.result == "0") {
|
||||
if (type == 'shuffle') {
|
||||
form.find('.success').text('Smart playlist shuffled');
|
||||
} else if (type == 'generate') {
|
||||
|
@ -468,39 +457,21 @@ function callback(data, type) {
|
|||
//redraw library table so the length gets updated
|
||||
dt.fnStandingRedraw();
|
||||
}
|
||||
form.find('.success').show();
|
||||
form.find('#smart_playlist_options').removeClass("closed");
|
||||
} else {
|
||||
form.find('.success').show();
|
||||
}
|
||||
form.find('#smart_playlist_options').removeClass("closed");
|
||||
} else {
|
||||
AIRTIME.playlist.fnOpenPlaylist(json);
|
||||
if (json.result == "0") {
|
||||
$('#sp-success-saved').text('Smart playlist saved');
|
||||
$('#sp-success-saved').show();
|
||||
|
||||
/* Update number of files that meet criteria and change icon to success/warning
|
||||
* as appropriate. This is also done in the form but we do not pass the form
|
||||
* back on a 'Save' callback.
|
||||
*/
|
||||
if (json.poolCount > 1) {
|
||||
$('#sp_pool_count').text(json.poolCount+' files meet the criteria');
|
||||
if ($('#sp_pool_count_icon').hasClass('sp-warning-icon')) {
|
||||
$('#sp_pool_count_icon').removeClass('sp-warning-icon').addClass('checked-icon sp-checked-icon');
|
||||
}
|
||||
} else if (json.poolCount == 1) {
|
||||
$('#sp_pool_count').text('1 file meets the criteria');
|
||||
if ($('#sp_pool_count_icon').hasClass('sp-warning-icon')) {
|
||||
$('#sp_pool_count_icon').removeClass('sp-warning-icon').addClass('checked-icon sp-checked-icon');
|
||||
}
|
||||
} else {
|
||||
$('#sp_pool_count').text('0 files meet the criteria');
|
||||
if ($('#sp_pool_count_icon').hasClass('checked-icon sp-checked-icon')) {
|
||||
$('#sp_pool_count_icon').removeClass('checked-icon sp-checked-icon').addClass('sp-warning-icon');
|
||||
}
|
||||
}
|
||||
|
||||
//redraw library table so the length gets updated
|
||||
var dt = $('table[id="library_display"]').dataTable();
|
||||
dt.fnStandingRedraw();
|
||||
$('div[class="playlist_title"]').find("h4").html(json.blockLength);
|
||||
}
|
||||
setTimeout(removeSuccessMsg, 5000);
|
||||
}
|
||||
setTimeout(removeSuccessMsg, 5000);
|
||||
}
|
||||
|
||||
function removeSuccessMsg() {
|
||||
|
|
Loading…
Reference in New Issue