CC-84: Smart Playlists
- code cleanup - adds 'Add' button to last row, always
This commit is contained in:
parent
601263b7a0
commit
2dae5f30f7
6 changed files with 81 additions and 91 deletions
|
@ -129,7 +129,7 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
|||
for ($i = 0; $i < $numElements; $i++) {
|
||||
$criteriaType = "";
|
||||
$criteria = new Zend_Form_Element_Select('sp_criteria_field_'.$i);
|
||||
$criteria->setAttrib('class', 'input_select')
|
||||
$criteria->setAttrib('class', 'input_select sp_input_select')
|
||||
->setValue('Select criteria')
|
||||
->setDecorators(array('viewHelper'))
|
||||
->setMultiOptions($criteriaOptions);
|
||||
|
@ -144,7 +144,7 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
|||
|
||||
$criteriaModifers = new Zend_Form_Element_Select('sp_criteria_modifier_'.$i);
|
||||
$criteriaModifers->setValue('Select modifier')
|
||||
->setAttrib('class', 'input_select')
|
||||
->setAttrib('class', 'input_select sp_input_select')
|
||||
->setDecorators(array('viewHelper'));
|
||||
if ($i != 0 && !isset($storedCrit["crit"][$i])){
|
||||
$criteriaModifers->setAttrib('disabled', 'disabled');
|
||||
|
@ -162,7 +162,7 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
|||
$this->addElement($criteriaModifers);
|
||||
|
||||
$criteriaValue = new Zend_Form_Element_Text('sp_criteria_value_'.$i);
|
||||
$criteriaValue->setAttrib('class', 'input_text')
|
||||
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
|
||||
->setDecorators(array('viewHelper'));
|
||||
if ($i != 0 && !isset($storedCrit["crit"][$i])){
|
||||
$criteriaValue->setAttrib('disabled', 'disabled');
|
||||
|
@ -172,14 +172,15 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
|||
}
|
||||
$this->addElement($criteriaValue);
|
||||
|
||||
$criteriaExtra = new Zend_Form_Element_Text('sp_criteria_extra_'.$i);
|
||||
$criteriaExtra->setAttrib('class', 'input_text')
|
||||
$criteriaExtra = new Zend_Form_Element_Text('sp_criteria_extra_'.$i);
|
||||
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
|
||||
->setDecorators(array('viewHelper'));
|
||||
if (isset($storedCrit["crit"][$i]["extra"])) {
|
||||
$criteriaExtra->setValue($storedCrit["crit"][$i]["extra"]);
|
||||
$criteriaExtra->setValue($storedCrit["crit"][$i]["extra"]);
|
||||
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
|
||||
}else{
|
||||
$criteriaExtra->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
$this->addElement($criteriaExtra);
|
||||
}
|
||||
|
||||
|
@ -189,8 +190,6 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
|||
$limit->setMultiOptions($limitOptions);
|
||||
if (isset($storedCrit["limit"])) {
|
||||
$limit->setValue($storedCrit["limit"]["modifier"]);
|
||||
}else{
|
||||
$limit->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
$this->addElement($limit);
|
||||
|
||||
|
@ -201,8 +200,6 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
|||
$this->addElement($limitValue);
|
||||
if (isset($storedCrit["limit"])) {
|
||||
$limitValue->setValue($storedCrit["limit"]["value"]);
|
||||
}else{
|
||||
$limitValue->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
|
||||
$save = new Zend_Form_Element_Button('save_button');
|
||||
|
@ -212,29 +209,5 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
|||
$this->addElement($save);
|
||||
}
|
||||
|
||||
public function loadCriteria($p_playlistId)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(CcPlaylistcriteriaPeer::PLAYLIST_ID, $p_playlistId);
|
||||
$out = CcPlaylistcriteriaPeer::doSelect($c);
|
||||
|
||||
$i = 0;
|
||||
foreach ($out as $crit) {
|
||||
$criteria = $crit->getDbCriteria();
|
||||
$modifier = $crit->getDbModifier();
|
||||
$value = $crit->getDbValue();
|
||||
$extra = $crit->getDbExtra();
|
||||
|
||||
if($criteria == "limit"){
|
||||
Zend_Form::getElement("sp_limit_options")->setValue($modifier);
|
||||
Zend_Form::getElement("sp_limit_value")->setValue($value);
|
||||
}else{
|
||||
Zend_Form::getElement("sp_criteria_$i")->setValue($criteria);
|
||||
Zend_Form::getElement("sp_criteria_modifier_$i")->setValue($criteria);
|
||||
Zend_Form::getElement("sp_criteria_value_$i")->setValue($criteria);
|
||||
Zend_Form::getElement("sp_criteria_extra_$i")->setValue($criteria);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -870,11 +870,11 @@ class Application_Model_Playlist {
|
|||
}
|
||||
if ($data['etc']['sp_limit_options'] == 'hours' || $data['etc']['sp_limit_options'] == 'mins') {
|
||||
if ( $data['etc']['sp_limit_value'] == "" || intval($data['etc']['sp_limit_value']) == 0) {
|
||||
$error[] = "Litmit cannot be empty or 0";
|
||||
$error[] = "Limit cannot be empty or 0";
|
||||
} else {
|
||||
$mins = $data['etc']['sp_limit_value'] * $multiplier;
|
||||
if ($mins > 14400) {
|
||||
$error[] = "Litmit cannot be more than 24 hrs";
|
||||
$error[] = "Limit cannot be more than 24 hrs";
|
||||
}
|
||||
}
|
||||
if (count($error) > 0){
|
||||
|
@ -886,11 +886,11 @@ class Application_Model_Playlist {
|
|||
foreach ($data['criteria'] as $key=>$d){
|
||||
$error = array();
|
||||
// check for not selected select box
|
||||
if ($d['sp_criteria'] == "0" || $d['sp_criteria_modifier'] == "0"){
|
||||
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
|
||||
$error[] = "You must select Criteria and Modifier";
|
||||
} else {
|
||||
// we need to take care 'length' specially since the column type is varchar
|
||||
if ($d['sp_criteria'] == 'length') {
|
||||
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";
|
||||
}
|
||||
|
@ -976,7 +976,7 @@ class Application_Model_Playlist {
|
|||
$c = new Criteria();
|
||||
|
||||
foreach ($p_data as $criteria) {
|
||||
$spCriteria = self::$criteria2PeerMap[$criteria['sp_criteria']];
|
||||
$spCriteria = self::$criteria2PeerMap[$criteria['sp_criteria_field']];
|
||||
$spCriteriaModifier = $criteria['sp_criteria_modifier'];
|
||||
$spCriteriaValue = $criteria['sp_criteria_value'];
|
||||
if ($spCriteriaModifier == "starts with") {
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
<?php echo $this->element->getElement('sp_criteria_value_'.$i) ?><span id="extra_criteria" <?php echo $this->element->getElement('sp_criteria_extra_'.$i)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to <?php echo $this->element->getElement('sp_criteria_extra_'.$i) ?></span>
|
||||
<?php if ($i != 0) { ?>
|
||||
<a href='#' id='criteria_remove_<?php echo $i ?>'>Remove </a>
|
||||
<?php } else { ?>
|
||||
<a href='#' id='criteria_add' class='criteria_add'>Add</a>
|
||||
<?php } ?>
|
||||
<br />
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue