CC-84: Smart Playlists
- fixed getCriteria() to non static function
This commit is contained in:
parent
b9739b022d
commit
27017c7903
3 changed files with 64 additions and 42 deletions
|
@ -574,7 +574,7 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
$out = $bl->getContents();
|
$out = $bl->getContents();
|
||||||
$out['isStatic'] = true;
|
$out['isStatic'] = true;
|
||||||
} else {
|
} else {
|
||||||
$out = Application_Model_Block::getCriteria($params['id']);
|
$out = $bl->getCriteria();
|
||||||
$out['isStatic'] = false;
|
$out['isStatic'] = false;
|
||||||
}
|
}
|
||||||
die(json_encode($out));
|
die(json_encode($out));
|
||||||
|
|
|
@ -112,7 +112,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
->setValue($blockType);
|
->setValue($blockType);
|
||||||
$this->addElement($spType);
|
$this->addElement($spType);
|
||||||
|
|
||||||
$storedCrit = Application_Model_Block::getCriteria($p_blockId);
|
$bl = new Application_Model_Block($p_blockId);
|
||||||
|
$storedCrit = $bl->getCriteria();
|
||||||
|
|
||||||
/* $modRoadMap stores the number of modifier rows each
|
/* $modRoadMap stores the number of modifier rows each
|
||||||
* criteria row has. We need to know this so we display the
|
* criteria row has. We need to know this so we display the
|
||||||
|
|
|
@ -193,9 +193,11 @@ class Application_Model_Block
|
||||||
|
|
||||||
$files = array();
|
$files = array();
|
||||||
$sql = <<<"EOT"
|
$sql = <<<"EOT"
|
||||||
SELECT pc.id as id, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout,
|
SELECT pc.id as id, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout, bl.type,
|
||||||
f.id as item_id, f.track_title, f.artist_name as creator, f.file_exists as exists, f.filepath as path FROM cc_blockcontents AS pc
|
f.id as item_id, f.track_title, f.artist_name as creator, f.file_exists as exists, f.filepath as path FROM cc_blockcontents AS pc
|
||||||
LEFT JOIN cc_files AS f ON pc.file_id=f.id WHERE pc.block_id = {$this->id};
|
LEFT JOIN cc_files AS f ON pc.file_id=f.id
|
||||||
|
LEFT JOIN cc_block AS bl ON pc.block_id = bl.id
|
||||||
|
WHERE pc.block_id = {$this->id};
|
||||||
EOT;
|
EOT;
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$rows = $con->query($sql)->fetchAll();
|
$rows = $con->query($sql)->fetchAll();
|
||||||
|
@ -1099,10 +1101,40 @@ EOT;
|
||||||
return $insertList;
|
return $insertList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCriteria($p_blockId)
|
public function getCriteria()
|
||||||
{
|
{
|
||||||
|
$criteriaOptions = array(
|
||||||
|
0 => "Select criteria",
|
||||||
|
"album_title" => "Album",
|
||||||
|
"bit_rate" => "Bit Rate",
|
||||||
|
"bpm" => "Bpm",
|
||||||
|
"comments" => "Comments",
|
||||||
|
"composer" => "Composer",
|
||||||
|
"conductor" => "Conductor",
|
||||||
|
"artist_name" => "Creator",
|
||||||
|
"disc_number" => "Disc Number",
|
||||||
|
"genre" => "Genre",
|
||||||
|
"isrc_number" => "ISRC",
|
||||||
|
"label" => "Label",
|
||||||
|
"language" => "Language",
|
||||||
|
"mtime" => "Last Modified",
|
||||||
|
"lptime" => "Last Played",
|
||||||
|
"length" => "Length",
|
||||||
|
"lyricist" => "Lyricist",
|
||||||
|
"mood" => "Mood",
|
||||||
|
"name" => "Name",
|
||||||
|
"orchestra" => "Orchestra",
|
||||||
|
"radio_station_name" => "Radio Station Name",
|
||||||
|
"rating" => "Rating",
|
||||||
|
"sample_rate" => "Sample Rate",
|
||||||
|
"track_title" => "Title",
|
||||||
|
"track_num" => "Track Number",
|
||||||
|
"utime" => "Uploaded",
|
||||||
|
"year" => "Year"
|
||||||
|
);
|
||||||
|
|
||||||
// Load criteria from db
|
// Load criteria from db
|
||||||
$out = CcBlockcriteriaQuery::create()->orderByDbCriteria()->findByDbBlockId($p_blockId);
|
$out = CcBlockcriteriaQuery::create()->orderByDbCriteria()->findByDbBlockId($this->id);
|
||||||
$storedCrit = array();
|
$storedCrit = array();
|
||||||
|
|
||||||
foreach ($out as $crit) {
|
foreach ($out as $crit) {
|
||||||
|
@ -1114,7 +1146,7 @@ EOT;
|
||||||
if ($criteria == "limit") {
|
if ($criteria == "limit") {
|
||||||
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
||||||
} else {
|
} else {
|
||||||
$storedCrit["crit"][$criteria][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
|
$storedCrit["crit"][$criteria][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra, "display_name"=>$criteriaOptions[$criteria]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1125,25 +1157,13 @@ EOT;
|
||||||
// this function return list of propel object
|
// this function return list of propel object
|
||||||
public function getListofFilesMeetCriteria()
|
public function getListofFilesMeetCriteria()
|
||||||
{
|
{
|
||||||
$out = CcBlockcriteriaQuery::create()->findByDbBlockId($this->id);
|
$storedCrit = $this->getCriteria();
|
||||||
$storedCrit = array();
|
|
||||||
foreach ($out as $crit) {
|
|
||||||
$criteria = $crit->getDbCriteria();
|
|
||||||
$modifier = $crit->getDbModifier();
|
|
||||||
$value = $crit->getDbValue();
|
|
||||||
$extra = $crit->getDbExtra();
|
|
||||||
|
|
||||||
if($criteria == "limit"){
|
|
||||||
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
|
||||||
}else{
|
|
||||||
$storedCrit["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$qry = CcFilesQuery::create();
|
$qry = CcFilesQuery::create();
|
||||||
|
|
||||||
if (isset($storedCrit["crit"])) {
|
if (isset($storedCrit["crit"])) {
|
||||||
foreach ($storedCrit["crit"] as $criteria) {
|
foreach ($storedCrit["crit"] as $crit) {
|
||||||
|
foreach ($crit as $criteria) {
|
||||||
$spCriteriaPhpName = self::$criteria2PeerMap[$criteria['criteria']];
|
$spCriteriaPhpName = self::$criteria2PeerMap[$criteria['criteria']];
|
||||||
$spCriteria = $criteria['criteria'];
|
$spCriteria = $criteria['criteria'];
|
||||||
|
|
||||||
|
@ -1167,6 +1187,7 @@ EOT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// construct limit restriction
|
// construct limit restriction
|
||||||
$limits = array();
|
$limits = array();
|
||||||
if (isset($storedCrit['limit'])) {
|
if (isset($storedCrit['limit'])) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue