working with start form
This commit is contained in:
parent
eff7a19409
commit
6631dd994f
2 changed files with 113 additions and 25 deletions
|
@ -242,7 +242,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
$this->addElement($spType);
|
$this->addElement($spType);
|
||||||
|
|
||||||
$bl = new Application_Model_Block($p_blockId);
|
$bl = new Application_Model_Block($p_blockId);
|
||||||
$storedCrit = $bl->getCriteria();
|
$storedCrit = $bl->getCriteriaGrouped();
|
||||||
|
Logging::info($storedCrit);
|
||||||
|
|
||||||
//need to convert criteria to be displayed in the user's timezone if there's some timestamp type.
|
//need to convert criteria to be displayed in the user's timezone if there's some timestamp type.
|
||||||
self::convertTimestamps($storedCrit["crit"]);
|
self::convertTimestamps($storedCrit["crit"]);
|
||||||
|
@ -263,8 +264,11 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
if (isset($storedCrit["crit"])) {
|
if (isset($storedCrit["crit"])) {
|
||||||
$criteriaKeys = array_keys($storedCrit["crit"]);
|
$criteriaKeys = array_keys($storedCrit["crit"]);
|
||||||
}
|
}
|
||||||
|
//the way the everything is currently built it setups 25 smartblock criteria forms and then disables them
|
||||||
|
//but this creates 29 elements
|
||||||
$numElements = count($this->getCriteriaOptions());
|
$numElements = count($this->getCriteriaOptions());
|
||||||
// loop through once for each potential criteria option ie album, composer, track
|
// loop through once for each potential criteria option ie album, composer, track
|
||||||
|
// criteria from different groups are separated already by the getCriteriaGrouped call
|
||||||
|
|
||||||
for ($i = 0; $i < $numElements; $i++) {
|
for ($i = 0; $i < $numElements; $i++) {
|
||||||
$criteriaType = "";
|
$criteriaType = "";
|
||||||
|
@ -272,32 +276,15 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
// if there is a criteria found then count the number of rows for this specific criteria ie > 1 track title
|
// if there is a criteria found then count the number of rows for this specific criteria ie > 1 track title
|
||||||
// need to refactor this to maintain separation based upon criteria grouping
|
// need to refactor this to maintain separation based upon criteria grouping
|
||||||
if (isset($criteriaKeys[$i])) {
|
if (isset($criteriaKeys[$i])) {
|
||||||
|
//Logging::info($criteriaKeys[$i]);
|
||||||
|
Logging::info($storedCrit["crit"][$criteriaKeys[$i]]);
|
||||||
$critCount = count($storedCrit["crit"][$criteriaKeys[$i]]);
|
$critCount = count($storedCrit["crit"][$criteriaKeys[$i]]);
|
||||||
} else {
|
} else {
|
||||||
$critCount = 1;
|
$critCount = 1;
|
||||||
}
|
}
|
||||||
// need to iterate through here and basically add an element for each new criteria group
|
// the challenge is that we need to increment the element for a new group
|
||||||
// and also iterate through for every item in a specific criteria group
|
// within the same criteria but not the reference point i in the array
|
||||||
if ($critCount > 1) {
|
// and for these secondary groups they will have a differe$storedCrit["crit"][$criteriaKeys[$i]]nt j reference point
|
||||||
$groupCount = 0;
|
|
||||||
$groupVal = null;
|
|
||||||
//this is so that it won't match where $groupVal = 0 matching with null ?
|
|
||||||
$prevGroupVal = -1;
|
|
||||||
// this loops through and counts the number of different grouping of criteria their are
|
|
||||||
// for this criteria to preserve different bundles of criteria and modifiers vs. considering
|
|
||||||
// all criteria to be connected via or - this allows the usage of contains X
|
|
||||||
// AND does not contain Y without including everything
|
|
||||||
foreach ($storedCrit["crit"][$criteriaKeys[$i]] as $item) {
|
|
||||||
$groupVal = $item["criteria_group"];
|
|
||||||
Logging::info($groupVal);
|
|
||||||
if ($groupVal != $prevGroupVal) {
|
|
||||||
$groupCount++;
|
|
||||||
$prevGroupVal = $groupVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Logging::info("group count = ");
|
|
||||||
Logging::info($groupCount);
|
|
||||||
}
|
|
||||||
// store the number of items with the same key in the ModRowMap
|
// store the number of items with the same key in the ModRowMap
|
||||||
$modRowMap[$i] = $critCount;
|
$modRowMap[$i] = $critCount;
|
||||||
|
|
||||||
|
@ -527,7 +514,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
|
|
||||||
$this->setDecorators(array(
|
$this->setDecorators(array(
|
||||||
array('ViewScript', array('viewScript' => 'form/smart-block-criteria.phtml', "openOption"=> $openSmartBlockOption,
|
array('ViewScript', array('viewScript' => 'form/smart-block-criteria.phtml', "openOption"=> $openSmartBlockOption,
|
||||||
'criteriasLength' => count($this->getCriteriaOptions()), 'modRowMap' => $modRowMap))
|
'criteriasLength' => $numElements, 'modRowMap' => $modRowMap))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -540,7 +527,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
public function preValidation($params)
|
public function preValidation($params)
|
||||||
{
|
{
|
||||||
$data = Application_Model_Block::organizeSmartPlaylistCriteria($params['data']);
|
$data = Application_Model_Block::organizeSmartPlaylistCriteria($params['data']);
|
||||||
// add elelments that needs to be added
|
// add elements that needs to be added
|
||||||
// set multioption for modifier according to criteria_field
|
// set multioption for modifier according to criteria_field
|
||||||
$modRowMap = array();
|
$modRowMap = array();
|
||||||
if (!isset($data['criteria'])) {
|
if (!isset($data['criteria'])) {
|
||||||
|
|
|
@ -1522,6 +1522,107 @@ SQL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses each row in the database for the criteria associated with this block and renders human readable labels.
|
||||||
|
* Returns it as an array with each criteria_name and modifier_name added based upon options array lookup.
|
||||||
|
* Maintains original separation of similar criteria that were separated by and statements
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public function getCriteriaGrouped()
|
||||||
|
{
|
||||||
|
$criteriaOptions = array(
|
||||||
|
0 => _("Select criteria"),
|
||||||
|
"album_title" => _("Album"),
|
||||||
|
"bit_rate" => _("Bit Rate (Kbps)"),
|
||||||
|
"bpm" => _("BPM"),
|
||||||
|
"composer" => _("Composer"),
|
||||||
|
"conductor" => _("Conductor"),
|
||||||
|
"copyright" => _("Copyright"),
|
||||||
|
"cuein" => _("Cue In"),
|
||||||
|
"cueout" => _("Cue Out"),
|
||||||
|
"description" => _("Description"),
|
||||||
|
"artist_name" => _("Creator"),
|
||||||
|
"encoded_by" => _("Encoded By"),
|
||||||
|
"genre" => _("Genre"),
|
||||||
|
"isrc_number" => _("ISRC"),
|
||||||
|
"label" => _("Label"),
|
||||||
|
"language" => _("Language"),
|
||||||
|
"utime" => _("Upload Time"),
|
||||||
|
"mtime" => _("Last Modified"),
|
||||||
|
"lptime" => _("Last Played"),
|
||||||
|
"length" => _("Length"),
|
||||||
|
"mime" => _("Mime"),
|
||||||
|
"mood" => _("Mood"),
|
||||||
|
"owner_id" => _("Owner"),
|
||||||
|
"replay_gain" => _("Replay Gain"),
|
||||||
|
"sample_rate" => _("Sample Rate (kHz)"),
|
||||||
|
"track_title" => _("Title"),
|
||||||
|
"track_number" => _("Track Number"),
|
||||||
|
"utime" => _("Uploaded"),
|
||||||
|
"info_url" => _("Website"),
|
||||||
|
"year" => _("Year")
|
||||||
|
);
|
||||||
|
|
||||||
|
$modifierOptions = array(
|
||||||
|
"0" => _("Select modifier"),
|
||||||
|
"contains" => _("contains"),
|
||||||
|
"does not contain" => _("does not contain"),
|
||||||
|
"is" => _("is"),
|
||||||
|
"is not" => _("is not"),
|
||||||
|
"starts with" => _("starts with"),
|
||||||
|
"ends with" => _("ends with"),
|
||||||
|
"before" => _("before"),
|
||||||
|
"after" => _("after"),
|
||||||
|
"between" => _("between"),
|
||||||
|
"is" => _("is"),
|
||||||
|
"is not" => _("is not"),
|
||||||
|
"is greater than" => _("is greater than"),
|
||||||
|
"is less than" => _("is less than"),
|
||||||
|
"is in the range" => _("is in the range")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Load criteria from db
|
||||||
|
$out = CcBlockcriteriaQuery::create()->orderByDbCriteria()->findByDbBlockId($this->id);
|
||||||
|
$storedCrit = array();
|
||||||
|
|
||||||
|
foreach ($out as $crit) {
|
||||||
|
Logging::info($crit);
|
||||||
|
$criteria = $crit->getDbCriteria();
|
||||||
|
$modifier = $crit->getDbModifier();
|
||||||
|
$value = $crit->getDbValue();
|
||||||
|
$extra = $crit->getDbExtra();
|
||||||
|
$criteriagroup = $crit->getDbCriteriaGroup();
|
||||||
|
|
||||||
|
if ($criteria == "limit") {
|
||||||
|
$storedCrit["limit"] = array(
|
||||||
|
"value"=>$value,
|
||||||
|
"modifier"=>$modifier,
|
||||||
|
"display_modifier"=>_($modifier));
|
||||||
|
} else if($criteria == "repeat_tracks") {
|
||||||
|
$storedCrit["repeat_tracks"] = array("value"=>$value);
|
||||||
|
} else if($criteria == "overflow_tracks") {
|
||||||
|
$storedCrit["overflow_tracks"] = array("value"=>$value);
|
||||||
|
} else if($criteria == "sort") {
|
||||||
|
$storedCrit["sort"] = array("value"=>$value);
|
||||||
|
} else {
|
||||||
|
$storedCrit["crit"][$criteria . $criteriagroup][] = array(
|
||||||
|
"criteria"=>$criteria,
|
||||||
|
"value"=>$value,
|
||||||
|
"modifier"=>$modifier,
|
||||||
|
"extra"=>$extra,
|
||||||
|
"display_name"=>$criteriaOptions[$criteria],
|
||||||
|
"display_modifier"=>$modifierOptions[$modifier]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging::info($storedCrit);
|
||||||
|
return $storedCrit;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// this function return list of propel object
|
// this function return list of propel object
|
||||||
public function getListofFilesMeetCriteria($show = null)
|
public function getListofFilesMeetCriteria($show = null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue