CC-84: Smart Playlists
- temp commit
This commit is contained in:
parent
55fd4e5d50
commit
207582eb7e
5 changed files with 84 additions and 36 deletions
|
@ -78,6 +78,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
|
||||
$form = new Application_Form_SmartPlaylistCriteria();
|
||||
$form->removeDecorator('DtDdWrapper');
|
||||
$form->loadCriteria($pl->getId());
|
||||
$this->view->form = $form;
|
||||
|
||||
$this->view->pl = $pl;
|
||||
|
|
|
@ -57,7 +57,7 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
|||
|
||||
$numElements = count($criteriaOptions);
|
||||
for ($i = 0; $i < $numElements; $i++) {
|
||||
$criteria = new Zend_Form_Element_Select('sp_criteria_'.$i);
|
||||
$criteria = new Zend_Form_Element_Select('sp_criteria_field_'.$i);
|
||||
$criteria->setAttrib('class', 'input_select');
|
||||
$criteria->setValue('Select criteria');
|
||||
$criteria->setDecorators(array('viewHelper'));
|
||||
|
@ -84,6 +84,12 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
|||
$criteriaValue->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
$this->addElement($criteriaValue);
|
||||
|
||||
$criteriaExtra = new Zend_Form_Element_Text('sp_criteria_extra_'.$i);
|
||||
$criteriaExtra->setAttrib('class', 'input_text');
|
||||
$criteriaExtra->setDecorators(array('viewHelper'));
|
||||
$criteriaExtra->setAttrib('disabled', 'disabled');
|
||||
$this->addElement($criteriaExtra);
|
||||
}
|
||||
|
||||
$limit = new Zend_Form_Element_Select('sp_limit_options');
|
||||
|
@ -104,4 +110,31 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
|||
$save->setLabel('Generate');
|
||||
$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"){
|
||||
$this->getElement("sp_limit_options")->setValue($modifier);
|
||||
$this->getElement("sp_limit_value")->setValue($value);
|
||||
}else{
|
||||
$this->getElement("sp_criteria_$i")->setValue($criteria);
|
||||
$this->getElement("sp_criteria_modifier_$i")->setValue($criteria);
|
||||
$this->getElement("sp_criteria_value_$i")->setValue($criteria);
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
Logging::log($out);
|
||||
}
|
||||
}
|
|
@ -880,10 +880,8 @@ class Application_Model_Playlist {
|
|||
if (count($error) > 0){
|
||||
$errors[] = array("element"=>"sp_limit_value", "msg"=>$error);
|
||||
}
|
||||
Logging::log($errors);
|
||||
}
|
||||
|
||||
Logging::log($errors);
|
||||
// format validation
|
||||
foreach ($data['criteria'] as $key=>$d){
|
||||
$error = array();
|
||||
|
@ -921,7 +919,6 @@ class Application_Model_Playlist {
|
|||
|
||||
public static function storeCriteriaIntoDb($p_criteriaData, $p_playlistId){
|
||||
// delete criteria under $p_playlistId
|
||||
Logging::log($p_criteriaData);
|
||||
$deleteCrit = new Criteria();
|
||||
$deleteCrit->add(CcPlaylistcriteriaPeer::PLAYLIST_ID, $p_playlistId);
|
||||
CcPlaylistcriteriaPeer::doDelete($deleteCrit);
|
||||
|
@ -964,7 +961,6 @@ class Application_Model_Playlist {
|
|||
public static function generateSmartPlaylist($p_criteria, $p_playlistId)
|
||||
{
|
||||
$result = self::saveSmartPlaylistCriteria($p_criteria, $p_playlistId);
|
||||
Logging::log($result);
|
||||
if ($result['result'] != 0) {
|
||||
return $result;
|
||||
}else{
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
|
||||
<dd id='sp_criteria-element'>
|
||||
<?php for ($i = 0; $i < $this->criteriasLength; $i++) {?>
|
||||
<div <?php if (($i > 0) && ($this->element->getElement('sp_criteria_'.$i)->getAttrib('disabled') == 'disabled')) {
|
||||
<div <?php if (($i > 0) && ($this->element->getElement('sp_criteria_field_'.$i)->getAttrib('disabled') == 'disabled')) {
|
||||
echo 'style=display:none';
|
||||
} ?>>
|
||||
|
||||
<?php echo $this->element->getElement('sp_criteria_'.$i) ?>
|
||||
<?php echo $this->element->getElement('sp_criteria_field_'.$i) ?>
|
||||
<?php echo $this->element->getElement('sp_criteria_modifier_'.$i) ?>
|
||||
<?php echo $this->element->getElement('sp_criteria_value_'.$i) ?>
|
||||
<?php echo $this->element->getElement('sp_criteria_value_'.$i) ?><span id="extra_criteria" 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 { ?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue