CC-84: Smart Playlists
- controller skeleton - playlist model dummy functions
This commit is contained in:
parent
7358b00c81
commit
93b34bb079
|
@ -22,6 +22,8 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
->addActionContext('set-playlist-description', 'json')
|
->addActionContext('set-playlist-description', 'json')
|
||||||
->addActionContext('playlist-preview', 'json')
|
->addActionContext('playlist-preview', 'json')
|
||||||
->addActionContext('get-playlist', 'json')
|
->addActionContext('get-playlist', 'json')
|
||||||
|
->addActionContext('smart-playlist-criteria-save', 'json')
|
||||||
|
->addActionContext('smart-playlist-generate', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
|
|
||||||
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
||||||
|
@ -438,5 +440,19 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
$this->playlistUnknownError($e);
|
$this->playlistUnknownError($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function smartPlaylistCriteriaSaveAction()
|
||||||
|
{
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$params = $request->getPost();
|
||||||
|
Application_Model_Playlist::saveSmartPlaylistCriteria($param['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function smartPlaylistGenerateAction()
|
||||||
|
{
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$params = $request->getPost();
|
||||||
|
Application_Model_Playlist::generateSmartPlaylist($params['data']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -807,6 +807,53 @@ class Application_Model_Playlist {
|
||||||
CcPlaylistQuery::create()->findPKs($p_ids)->delete();
|
CcPlaylistQuery::create()->findPKs($p_ids)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// smart playlist functions start
|
||||||
|
/**
|
||||||
|
* Saves smart playlist criteria
|
||||||
|
* @param array $p_criteria
|
||||||
|
*/
|
||||||
|
public static function saveSmartPlaylistCriteria($p_criteria)
|
||||||
|
{
|
||||||
|
$data = self::organizeSmartPlyalistCriteria($p_criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get smart playlist criteria
|
||||||
|
* @param array $p_playlistId
|
||||||
|
*/
|
||||||
|
public static function getSmartPlaylistCriteria($p_playlistId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate list of tracks. This function saves creiteria and generate
|
||||||
|
* tracks.
|
||||||
|
* @param array $p_criteria
|
||||||
|
*/
|
||||||
|
public static function generateSmartPlaylist($p_criteria)
|
||||||
|
{
|
||||||
|
self::saveSmartPlaylistCriteria($p_criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function organizeSmartPlyalistCriteria($p_criteria)
|
||||||
|
{
|
||||||
|
$fieldNames = array('sp_criteria', 'sp_criteria_modifier', 'sp_criteria_value');
|
||||||
|
$output = array();
|
||||||
|
foreach ($p_criteria as $ele) {
|
||||||
|
$index = strrpos($ele['name'], '_');
|
||||||
|
$fieldName = substr($ele['name'], 0, $index);
|
||||||
|
if (in_array($fieldName, $fieldNames)) {
|
||||||
|
$rowNum = intval(substr($ele['name'], $index+1));
|
||||||
|
$output['criteria'][$rowNum][$fieldName] = $ele['value'];
|
||||||
|
}else{
|
||||||
|
$output['etc'][$ele['name']] = $ele['value'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// smart playlist functions end
|
||||||
|
|
||||||
} // class Playlist
|
} // class Playlist
|
||||||
|
|
||||||
class PlaylistNotFoundException extends Exception {}
|
class PlaylistNotFoundException extends Exception {}
|
||||||
|
|
Loading…
Reference in New Issue