Track Type Select Menu in Smartblock
This commit is contained in:
parent
339fddf652
commit
00e860183a
3 changed files with 182 additions and 11 deletions
|
@ -8,6 +8,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
private $timePeriodCriteriaOptions;
|
||||
private $sortOptions;
|
||||
private $limitOptions;
|
||||
private $isOrNotCriteriaOptions;
|
||||
private $trackTypeOptions;
|
||||
|
||||
/* We need to know if the criteria value will be a string
|
||||
* or numeric value in order to populate the modifier
|
||||
|
@ -43,7 +45,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
"track_number" => "n",
|
||||
"info_url" => "s",
|
||||
"year" => "n",
|
||||
"track_type" => "s"
|
||||
"track_type" => "tt"
|
||||
);
|
||||
|
||||
private function getCriteriaOptions($option = null)
|
||||
|
@ -174,13 +176,36 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
"random" => _("Randomly"),
|
||||
"newest" => _("Newest"),
|
||||
"oldest" => _("Oldest"),
|
||||
"mostrecentplay" => ("Most recently played"),
|
||||
"leastrecentplay" => ("Least recently played")
|
||||
"mostrecentplay" => _("Most recently played"),
|
||||
"leastrecentplay" => _("Least recently played")
|
||||
);
|
||||
}
|
||||
return $this->sortOptions;
|
||||
}
|
||||
|
||||
private function getIsNotOptions()
|
||||
{
|
||||
if (!isset($this->isOrNotCriteriaOptions)) {
|
||||
$this->isOrNotCriteriaOptions = array(
|
||||
"0" => _("Select modifier"),
|
||||
"is" => _("is"),
|
||||
"is not" => _("is not")
|
||||
);
|
||||
}
|
||||
return $this->isOrNotCriteriaOptions;
|
||||
}
|
||||
|
||||
private function getTracktypeOptions()
|
||||
{
|
||||
if (!isset($this->trackTypeOptions)) {
|
||||
$tracktypes = Application_Model_Tracktype::getTracktypes();
|
||||
$names[] = _("Select Track Type");
|
||||
foreach($tracktypes as $arr => $a){
|
||||
$names[$a["code"]] = $tracktypes[$arr]["type_name"];
|
||||
}
|
||||
}
|
||||
return $names;
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
@ -339,6 +364,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
$criteriaModifers->setMultiOptions($this->getStringCriteriaOptions());
|
||||
} elseif ($criteriaType == "d") {
|
||||
$criteriaModifers->setMultiOptions($this->getDateTimeCriteriaOptions());
|
||||
} elseif ($criteriaType == "tt") {
|
||||
$criteriaModifers->setMultiOptions($this->getIsNotOptions());
|
||||
} else {
|
||||
$criteriaModifers->setMultiOptions($this->getNumericCriteriaOptions());
|
||||
}
|
||||
|
@ -350,11 +377,33 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
|
||||
/****************** VALUE ***********/
|
||||
/* The challenge here is that datetime */
|
||||
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_" . $i . "_" . $j);
|
||||
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
|
||||
->setDecorators(array('viewHelper'));
|
||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||
$criteriaValue->setAttrib('disabled', 'disabled');
|
||||
if (isset($criteriaKeys[$i])) {
|
||||
$modifierTest = (string)$storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"];
|
||||
if (isset($criteriaType) && $criteriaType == "tt" &&
|
||||
preg_match('/is|is not/', $modifierTest) == 1) {
|
||||
|
||||
$criteriaValue = new Zend_Form_Element_Select("sp_criteria_value_" . $i . "_" . $j);
|
||||
$criteriaValue->setAttrib('class', 'input_select sp_input_select')->setDecorators(array('viewHelper'));
|
||||
|
||||
if (isset($criteriaKeys[$i]) ) { //do if $relativeTT above
|
||||
$criteriaValue->setAttrib('enabled', 'enabled');
|
||||
} else {
|
||||
$criteriaValue->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
} else {
|
||||
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_" . $i . "_" . $j);
|
||||
$criteriaValue->setAttrib('class', 'input_text sp_input_text')->setDecorators(array('viewHelper'));
|
||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||
$criteriaValue->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_" . $i . "_" . $j);
|
||||
$criteriaValue->setAttrib('class', 'input_text sp_input_text')->setDecorators(array('viewHelper'));
|
||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||
$criteriaValue->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
if (isset($criteriaKeys[$i])) {
|
||||
/*
|
||||
|
@ -367,8 +416,24 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
preg_match('/before|after|between/', $modifierTest) == 1) {
|
||||
// set relativeDatetime boolean to true so that the datetime select is displayed below
|
||||
$relativeDateTime = true;
|
||||
// the criteria value will be a number followed by time unit and ago so set input to number part
|
||||
$criteriaValue->setValue(filter_var($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"], FILTER_SANITIZE_NUMBER_INT));
|
||||
} elseif (isset($criteriaType) && $criteriaType == "tt" &&
|
||||
preg_match('/is|is not/', $modifierTest) == 1) {
|
||||
// set relativeDatetime boolean to true so that the datetime select is displayed below
|
||||
$relativeDateTime = false;
|
||||
|
||||
$tracktypeSelectValue = preg_replace('/[0-9]+/', '', $storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]);
|
||||
$tracktypeSelectValue = trim(preg_replace('/\W\w+\s*(\W*)$/', '$1', $tracktypeSelectValue));
|
||||
$criteriaValue->setMultiOptions($this->getTracktypeOptions());
|
||||
|
||||
if ($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]){
|
||||
$criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]);
|
||||
} else {
|
||||
$criteriaValue->setMultiOptions(array('0' => _('Select track type')));
|
||||
$criteriaValue->setMultiOptions($this->getTracktypeOptions());
|
||||
$criteriaValue->setValue($tracktypeSelectValue);
|
||||
}
|
||||
$criteriaValue->setAttrib('enabled', 'enabled');
|
||||
} else {
|
||||
$criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]);
|
||||
}
|
||||
|
@ -554,6 +619,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
$eleMod->setMultiOptions($this->getNumericCriteriaOptions());
|
||||
} elseif ($criteriaType == "d") {
|
||||
$eleMod->setMultiOptions($this->getDateTimeCriteriaOptions());
|
||||
} elseif ($criteriaType == "tt") {
|
||||
$eleMod->setMultiOptions($this->getIsNotOptions());
|
||||
} else {
|
||||
$eleMod->setMultiOptions(array('0' => _('Select modifier')));
|
||||
}
|
||||
|
@ -613,6 +680,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
}
|
||||
elseif ($criteriaType == "d") {
|
||||
$criteriaModifers->setMultiOptions($this->getDateTimeCriteriaOptions());
|
||||
} elseif ($criteriaType == "tt") {
|
||||
$criteriaModifers->setMultiOptions($this->getIsNotOptions());
|
||||
} else {
|
||||
$criteriaModifers->setMultiOptions(array('0' => _('Select modifier')));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue