Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Rudi Grinberg 2012-07-18 12:37:32 -04:00
commit df86fad6bf
24 changed files with 4016 additions and 52 deletions

View File

@ -78,6 +78,13 @@ return array (
'BaseCcPlaylistcontentsPeer' => 'airtime/om/BaseCcPlaylistcontentsPeer.php',
'BaseCcPlaylistcontents' => 'airtime/om/BaseCcPlaylistcontents.php',
'BaseCcPlaylistcontentsQuery' => 'airtime/om/BaseCcPlaylistcontentsQuery.php',
'CcPlaylistcriteriaTableMap' => 'airtime/map/CcPlaylistcriteriaTableMap.php',
'CcPlaylistcriteriaPeer' => 'airtime/CcPlaylistcriteriaPeer.php',
'CcPlaylistcriteria' => 'airtime/CcPlaylistcriteria.php',
'CcPlaylistcriteriaQuery' => 'airtime/CcPlaylistcriteriaQuery.php',
'BaseCcPlaylistcriteriaPeer' => 'airtime/om/BaseCcPlaylistcriteriaPeer.php',
'BaseCcPlaylistcriteria' => 'airtime/om/BaseCcPlaylistcriteria.php',
'BaseCcPlaylistcriteriaQuery' => 'airtime/om/BaseCcPlaylistcriteriaQuery.php',
'CcPrefTableMap' => 'airtime/map/CcPrefTableMap.php',
'CcPrefPeer' => 'airtime/CcPrefPeer.php',
'CcPref' => 'airtime/CcPref.php',

View File

@ -22,6 +22,9 @@ class PlaylistController extends Zend_Controller_Action
->addActionContext('set-playlist-description', 'json')
->addActionContext('playlist-preview', 'json')
->addActionContext('get-playlist', 'json')
->addActionContext('smart-playlist-criteria-save', 'json')
->addActionContext('smart-playlist-generate', 'json')
->addActionContext('smart-playlist-shuffle', 'json')
->initContext();
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
@ -67,18 +70,32 @@ class PlaylistController extends Zend_Controller_Action
unset($this->view->pl);
}
private function createFullResponse($pl = null)
private function createFullResponse($pl = null, $isJson = false)
{
if (isset($pl)) {
$formatter = new LengthFormatter($pl->getLength());
$this->view->length = $formatter->format();
$form = new Application_Form_SmartPlaylistCriteria();
$form->removeDecorator('DtDdWrapper');
$form->startForm($pl->getId());
$this->view->form = $form;
$this->view->pl = $pl;
$this->view->id = $pl->getId();
$this->view->html = $this->view->render('playlist/playlist.phtml');
if ($isJson){
return $this->view->render('playlist/playlist.phtml');
}else{
$this->view->html = $this->view->render('playlist/playlist.phtml');
}
unset($this->view->pl);
} else {
$this->view->html = $this->view->render('playlist/playlist.phtml');
}
else {
if ($isJson){
return $this->view->render('playlist/playlist.phtml');
}else{
$this->view->html = $this->view->render('playlist/playlist.phtml');
}
}
}
@ -87,6 +104,12 @@ class PlaylistController extends Zend_Controller_Action
$this->view->error = $e->getMessage();
}
private function playlistDynamic($pl)
{
$this->view->error = "You cannot add tracks to dynamic playlist.";
$this->createFullResponse($pl);
}
private function playlistNotFound()
{
$this->view->error = "Playlist not found";
@ -136,6 +159,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/playlist/smart_playlistbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']);
try {
@ -147,6 +171,9 @@ class PlaylistController extends Zend_Controller_Action
if($isAdminOrPM || $pl->getCreatorId() == $userInfo->id){
$this->view->pl = $pl;
$form = new Application_Form_SmartPlaylistCriteria();
$form->startForm($this->pl_sess->id);
$this->view->form = $form;
}
$formatter = new LengthFormatter($pl->getLength());
@ -176,6 +203,8 @@ class PlaylistController extends Zend_Controller_Action
{
$id = $this->_getParam('id', null);
Logging::log("editing playlist {$id}");
//$form = new Application_Form_SmartPlaylistCriteria();
if (!is_null($id)) {
$this->changePlaylist($id);
@ -230,16 +259,26 @@ class PlaylistController extends Zend_Controller_Action
$ids = (!is_array($ids)) ? array($ids) : $ids;
$afterItem = $this->_getParam('afterItem', null);
$addType = $this->_getParam('type', 'after');
try {
$pl = $this->getPlaylist();
$pl->addAudioClips($ids, $afterItem, $addType);
$this->createUpdateResponse($pl);
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
if ($pl->isStatic()) {
$pl->addAudioClips($ids, $afterItem, $addType);
$this->createUpdateResponse($pl);
} else {
throw new PlaylistDyanmicException;
}
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
}
catch (PlaylistDyanmicException $e) {
$this->playlistDynamic($pl);
}
catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
@ -409,4 +448,55 @@ class PlaylistController extends Zend_Controller_Action
$this->playlistUnknownError($e);
}
}
public function smartPlaylistCriteriaSaveAction()
{
$request = $this->getRequest();
$params = $request->getPost();
$pl = new Application_Model_Playlist($params['pl_id']);
$result = $pl->saveSmartPlaylistCriteria($params['data']);
die(json_encode($result));
}
public function smartPlaylistGenerateAction()
{
$request = $this->getRequest();
$params = $request->getPost();
$pl = new Application_Model_Playlist($params['pl_id']);
$result = $pl->generateSmartPlaylist($params['data']);
if ($result['result'] == 0) {
try {
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($pl, true))));
}
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
}
catch (Exception $e) {
$this->playlistUnknownError($e);
}
}else{
die(json_encode($result));
}
}
public function smartPlaylistShuffleAction()
{
$request = $this->getRequest();
$params = $request->getPost();
$pl = new Application_Model_Playlist($params['pl_id']);
$result = $pl->shuffleSmartPlaylist();
if ($result['result'] == 0) {
try {
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($pl, true))));
}
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
}
catch (Exception $e) {
$this->playlistUnknownError($e);
}
}else{
die(json_encode($result));
}
}
}

View File

@ -0,0 +1,240 @@
<?php
class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
{
public function init(){
}
public function startForm($p_playlistId)
{
$criteriaOptions = array(
0 => "Select criteria",
"album_title" => "Album",
"artist_name" => "Artist",
"bit_rate" => "Bit Rate",
"bpm" => "Bpm",
"comments" => "Comments",
"composer" => "Composer",
"conductor" => "Conductor",
"disc_number" => "Disc Number",
"genre" => "Genre",
"isrc_number" => "ISRC",
"label" => "Label",
"language" => "Language",
"mtime" => "Last Modified",
"length" => "Length",
"lyricist" => "Lyricist",
"mood" => "Mood",
"name" => "Name",
"orchestra" => "Orchestra",
"radio_station_name" => "Radio Station Name",
"rating" => "Rating",
"sample_rate" => "Sample Rate",
"soundcloud_id" => "Soundcloud Upload",
"track_title" => "Title",
"track_num" => "Track Number",
"utime" => "Uploaded",
"year" => "Year"
);
$criteriaTypes = array(
0 => "",
"album_title" => "s",
"artist_name" => "s",
"bit_rate" => "n",
"bpm" => "n",
"comments" => "s",
"composer" => "s",
"conductor" => "s",
"utime" => "n",
"mtime" => "n",
"disc_number" => "n",
"genre" => "s",
"isrc_number" => "s",
"label" => "s",
"language" => "s",
"length" => "n",
"lyricist" => "s",
"mood" => "s",
"name" => "s",
"orchestra" => "s",
"radio_station_name" => "s",
"rating" => "n",
"sample_rate" => "n",
"soundcloud_id" => "n",
"track_title" => "s",
"track_num" => "n",
"year" => "n"
);
$stringCriteriaOptions = 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"
);
$numericCriteriaOptions = array(
"0" => "Select modifier",
"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"
);
$limitOptions = array(
"hours" => "hours",
"minutes" => "minutes",
"items" => "items"
);
// load type
$out = CcPlaylistQuery::create()->findPk($p_playlistId);
if ($out->getDbType() == "static") {
$playlistType = 0;
} else {
$playlistType = 1;
}
$spType = new Zend_Form_Element_Radio('sp_type');
$spType->setLabel('Set smart playlist type:')
->setDecorators(array('viewHelper'))
->setMultiOptions(array(
'static' => 'Static',
'dynamic' => 'Dynamic'
))
->setValue($playlistType);
$this->addElement($spType);
// load criteria from db
$out = CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($p_playlistId);
$storedCrit = array();
foreach ($out as $crit) {
$criteria = $crit->getDbCriteria();
$modifier = $crit->getDbModifier();
$value = $crit->getDbValue();
$extra = $crit->getDbExtra();
if($criteria == "limit"){
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
}else{
$storedCrit["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
}
}
$openSmartPlaylistOption = false;
if (!empty($storedCrit)) {
$openSmartPlaylistOption = true;
}
$numElements = count($criteriaOptions);
for ($i = 0; $i < $numElements; $i++) {
$criteriaType = "";
$criteria = new Zend_Form_Element_Select('sp_criteria_field_'.$i);
$criteria->setAttrib('class', 'input_select sp_input_select')
->setValue('Select criteria')
->setDecorators(array('viewHelper'))
->setMultiOptions($criteriaOptions);
if ($i != 0 && !isset($storedCrit["crit"][$i])){
$criteria->setAttrib('disabled', 'disabled');
}
if (isset($storedCrit["crit"][$i])) {
$criteriaType = $criteriaTypes[$storedCrit["crit"][$i]["criteria"]];
$criteria->setValue($storedCrit["crit"][$i]["criteria"]);
}
$this->addElement($criteria);
$criteriaModifers = new Zend_Form_Element_Select('sp_criteria_modifier_'.$i);
$criteriaModifers->setValue('Select modifier')
->setAttrib('class', 'input_select sp_input_select')
->setDecorators(array('viewHelper'));
if ($i != 0 && !isset($storedCrit["crit"][$i])){
$criteriaModifers->setAttrib('disabled', 'disabled');
}
if (isset($storedCrit["crit"][$i])) {
if($criteriaType == "s"){
$criteriaModifers->setMultiOptions($stringCriteriaOptions);
}else{
$criteriaModifers->setMultiOptions($numericCriteriaOptions);
}
$criteriaModifers->setValue($storedCrit["crit"][$i]["modifier"]);
}else{
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
}
$this->addElement($criteriaModifers);
$criteriaValue = new Zend_Form_Element_Text('sp_criteria_value_'.$i);
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
->setDecorators(array('viewHelper'));
if ($i != 0 && !isset($storedCrit["crit"][$i])){
$criteriaValue->setAttrib('disabled', 'disabled');
}
if (isset($storedCrit["crit"][$i])) {
$criteriaValue->setValue($storedCrit["crit"][$i]["value"]);
}
$this->addElement($criteriaValue);
$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"]);
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
}else{
$criteriaExtra->setAttrib('disabled', 'disabled');
}
$this->addElement($criteriaExtra);
}
$limit = new Zend_Form_Element_Select('sp_limit_options');
$limit->setAttrib('class', 'sp_input_select');
$limit->setDecorators(array('viewHelper'));
$limit->setMultiOptions($limitOptions);
if (isset($storedCrit["limit"])) {
$limit->setValue($storedCrit["limit"]["modifier"]);
}
$this->addElement($limit);
$limitValue = new Zend_Form_Element_Text('sp_limit_value');
$limitValue->setAttrib('class', 'sp_input_text_limit');
$limitValue->setLabel('Limit to');
$limitValue->setDecorators(array('viewHelper'));
$this->addElement($limitValue);
if (isset($storedCrit["limit"])) {
$limitValue->setValue($storedCrit["limit"]["value"]);
}
$save = new Zend_Form_Element_Button('save_button');
$save->setAttrib('class', 'ui-button ui-state-default sp-button');
$save->setAttrib('title', 'Save criteria only');
$save->setIgnore(true);
$save->setLabel('Save');
$save->setDecorators(array('viewHelper'));
$this->addElement($save);
$generate = new Zend_Form_Element_Button('generate_button');
$generate->setAttrib('class', 'ui-button ui-state-default sp-button');
$generate->setAttrib('title', 'Save criteria and generate playlist content');
$generate->setIgnore(true);
$generate->setLabel('Generate');
$generate->setDecorators(array('viewHelper'));
$this->addElement($generate);
$shuffle = new Zend_Form_Element_Button('shuffle_button');
$shuffle->setAttrib('class', 'ui-button ui-state-default sp-button');
$shuffle->setAttrib('title', 'Shuffle playlist content');
$shuffle->setIgnore(true);
$shuffle->setLabel('Shuffle');
$shuffle->setDecorators(array('viewHelper'));
$this->addElement($shuffle);
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/smart-playlist-criteria.phtml', "openOption"=> $openSmartPlaylistOption,
'criteriasLength' => count($criteriaOptions)))
));
}
}

View File

@ -45,6 +45,47 @@ class Application_Model_Playlist
"dc:description" => "Description",
"dcterms:extent" => "Length"
);
private static $modifier2CriteriaMap = array(
"contains" => Criteria::LIKE,
"does not contain" => Criteria::NOT_LIKE,
"is" => Criteria::EQUAL,
"is not" => Criteria::NOT_EQUAL,
"starts with" => Criteria::LIKE,
"ends with" => Criteria::LIKE,
"is greater than" => Criteria::GREATER_THAN,
"is less than" => Criteria::LESS_THAN,
"is in the range" => Criteria::CUSTOM);
private static $criteria2PeerMap = array(
0 => "Select criteria",
"album_title" => "DbAlbumTitle",
"artist_name" => "DbArtistName",
"bit_rate" => "DbBitRate",
"bpm" => "DbBpm",
"comments" => "DbComments",
"composer" => "DbComposer",
"conductor" => "DbConductor",
"utime" => "DbUtime",
"mtime" => "DbMtime",
"disc_number" => "DbDiscNumber",
"genre" => "DbGenre",
"isrc_number" => "DbIsrcNumber",
"label" => "DbLabel",
"language" => "DbLanguage",
"length" => "DbLength",
"lyricist" => "DbLyricist",
"mood" => "DbMood",
"name" => "DbName",
"orchestra" => "DbOrchestra",
"radio_station_name" => "DbRadioStation",
"rating" => "DbRating",
"sample_rate" => "DbSampleRate",
"soundcloud_id" => "DbSoundcloudId",
"track_title" => "DbTrackTitle",
"track_num" => "DbTrackNum",
"year" => "DbYear"
);
public function __construct($id=null, $con=null)
@ -251,6 +292,14 @@ class Application_Model_Playlist
throw new Exception("trying to add a file that does not exist.");
}
}
public function isStatic(){
if ($this->pl->getDbType() == "static") {
return true;
} else {
return false;
}
}
/*
* @param array $p_items
@ -825,9 +874,263 @@ class Application_Model_Playlist
$leftOvers = array_diff($selectedPls, $ownedPls);
return $leftOvers;
}
/**
* Delete all files from playlist
* @param int $p_playlistId
*/
public function deleteAllFilesFromPlaylist()
{
CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete();
}
// smart playlist functions start
public function shuffleSmartPlaylist(){
// if it here that means it's static pl
$this->saveType("static");
$contents = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->orderByDbPosition()
->find();
$shuffledPos = range(0, count($contents)-1);
shuffle($shuffledPos);
$temp = new CcPlaylist();
foreach ($contents as $item) {
$item->setDbPosition(array_shift($shuffledPos));
$item->save();
}
return array("result"=>0);
}
public function saveType($p_playlistType)
{
// saving dynamic/static flag
CcPlaylistQuery::create()->findPk($this->id)->setDbType($p_playlistType)->save();
}
/**
* Saves smart playlist criteria
* @param array $p_criteria
*/
public function saveSmartPlaylistCriteria($p_criteria)
{
$data = $this->organizeSmartPlyalistCriteria($p_criteria);
// things we need to check
// 1. limit value shouldn't be empty and has upperbound of 24 hrs
// 2. sp_criteria or sp_criteria_modifier shouldn't be 0
// 3. validate formate according to DB column type
$multiplier = 1;
$result = 0;
$errors = array();
$error = array();
// saving dynamic/static flag
$playlistType = $data['etc']['sp_type'] == 0 ? 'static':'dynamic';
$this->saveType($playlistType);
if ($data['etc']['sp_limit_options'] == 'hours') {
$multiplier = 60;
}
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[] = "Limit cannot be empty or 0";
} else {
$mins = $data['etc']['sp_limit_value'] * $multiplier;
if ($mins > 14400) {
$error[] = "Limit cannot be more than 24 hrs";
}
}
if (count($error) > 0){
$errors[] = array("element"=>"sp_limit_value", "msg"=>$error);
}
}
// format validation
foreach ($data['criteria'] as $key=>$d){
$error = array();
// check for not selected select box
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_field'] == 'length') {
if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
$error[] = "'Length' should be in '00:00:00' format";
}
}else{
if (CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']])->getType() == PropelColumnTypes::TIMESTAMP) {
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
$error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00";
}
}
}
}
if ($d['sp_criteria_value'] == "") {
$error[] = "Value cannot be empty";
}
if(count($error) > 0){
$errors[] = array("element"=>"sp_criteria_field_".$key, "msg"=>$error);
}
}
$result = count($errors) > 0 ? 1 :0;
if ($result == 0) {
$this->storeCriteriaIntoDb($data);
}
return array("result"=>$result, "errors"=>$errors);
}
public function storeCriteriaIntoDb($p_criteriaData){
// delete criteria under $p_playlistId
CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($this->id)->delete();
foreach( $p_criteriaData['criteria'] as $d){
$qry = new CcPlaylistcriteria();
$qry->setDbCriteria($d['sp_criteria_field'])
->setDbModifier($d['sp_criteria_modifier'])
->setDbValue($d['sp_criteria_value'])
->setDbPlaylistId($this->id);
if (isset($d['sp_criteria_extra'])) {
$qry->setDbExtra($d['sp_criteria_extra']);
}
$qry->save();
}
// insert limit info
$qry = new CcPlaylistcriteria();
$qry->setDbCriteria("limit")
->setDbModifier($p_criteriaData['etc']['sp_limit_options'])
->setDbValue($p_criteriaData['etc']['sp_limit_value'])
->setDbPlaylistId($this->id)
->save();
}
/**
* generate list of tracks. This function saves creiteria and generate
* tracks.
* @param array $p_criteria
*/
public function generateSmartPlaylist($p_criteria, $returnList=false)
{
$result = $this->saveSmartPlaylistCriteria($p_criteria);
if ($result['result'] != 0) {
return $result;
} else {
$insertList = $this->getListOfFilesUnderLimit();
$this->deleteAllFilesFromPlaylist();
$this->addAudioClips(array_keys($insertList));
return array("result"=>0);
}
}
public function getListOfFilesUnderLimit()
{
$info = $this->getListofFilesMeetCriteria();
$files = $info['files'];
$limit = $info['limit'];
// construct ids of track candidates
$insertList = array();
$totalTime = 0;
while ($totalTime < $limit['time'] && !empty($files)) {
$key = array_rand($files);
$insertList[$key] = $files[$key];
$totalTime += $files[$key];
unset($files[$key]);
if ( !is_null($limit['items']) && $limit['items'] == count($insertList)) {
break;
}
}
return $insertList;
}
// this function return list of propel object
private function getListofFilesMeetCriteria()
{
$out = CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($this->id);
$storedCrit = array();
foreach ($out as $crit) {
$criteria = $crit->getDbCriteria();
$modifier = $crit->getDbModifier();
$value = $crit->getDbValue();
$extra = $crit->getDbExtra();
if($criteria == "limit"){
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
}else{
$storedCrit["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
}
}
$qry = CcFilesQuery::create();
foreach ($storedCrit["crit"] as $criteria) {
// propel doc says we should use phpname for column name but
// it looks like we have to use actual column name
//$spCriteria = self::$criteria2PeerMap[$criteria['criteria']];
$spCriteria = $criteria['criteria'];
$spCriteriaModifier = $criteria['modifier'];
$spCriteriaValue = $criteria['value'];
if ($spCriteriaModifier == "starts with") {
$spCriteriaValue = "$spCriteriaValue%";
} else if ($spCriteriaModifier == "ends with") {
$spCriteriaValue = "%$spCriteriaValue";
} else if ($spCriteriaModifier == "is in the range") {
$spCriteriaValue = "$spCriteria > '$spCriteriaValue' AND $spCriteria < '$criteria[extra]'";
}
$spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier];
try{
$qry->filterBy($spCriteria, $spCriteriaValue, $spCriteriaModifier);
}catch (Exception $e){
Logging::log($e);
}
}
// construct limit restriction
$limits = array();
if ($storedCrit['limit']['modifier'] == "items") {
$limits['time'] = 1440 * 60;
$limits['items'] = $storedCrit['limit']['value'];
} else {
$limits['time'] = $storedCrit['limit']['modifier'] == "hours" ? intval($storedCrit['limit']['value']) * 60 * 60 : intval($storedCrit['limit']['value'] * 60);
$limits['items'] = null;
}
Logging::log("2222");
try{
$out = $qry->find();
Logging::log("3333");
$files = array();
foreach ($out as $file) {
$files[$file->getDbId()] = Application_Common_DateHelper::calculateLengthInSeconds($file->getDbLength());
}
Logging::log($files);
return array("files"=>$files, "limit"=>$limits);
}catch(Exception $e){
Logging::log($e);
}
}
private static function organizeSmartPlyalistCriteria($p_criteria)
{
$fieldNames = array('sp_criteria_field', 'sp_criteria_modifier', 'sp_criteria_value', 'sp_criteria_extra');
$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] = trim($ele['value']);
}else{
$output['etc'][$ele['name']] = $ele['value'];
}
}
return $output;
}
// smart playlist functions end
} // class Playlist
class PlaylistNotFoundException extends Exception {}
class PlaylistNoPermissionException extends Exception {}
class PlaylistOutDatedException extends Exception {}
class PlaylistDyanmicException extends Exception {}

View File

@ -145,32 +145,50 @@ class Application_Model_Scheduler
$files[] = $data;
}
} elseif ($type === "playlist") {
$contents = CcPlaylistcontentsQuery::create()
->orderByDbPosition()
->filterByDbPlaylistId($id)
->find($this->con);
}
else if ($type === "playlist") {
// find if the playslit is static or dynamic
$c = new Criteria();
$c->add(CcPlaylistPeer::ID, $id);
$pl = CcPlaylistPeer::doSelect($c);
$playlistType = $pl[0]->getDbType();
if ($playlistType == "static") {
$contents = CcPlaylistcontentsQuery::create()
->orderByDbPosition()
->filterByDbPlaylistId($id)
->find($this->con);
} else {
$pl = new Application_Model_Playlist($id);
$contents = $pl->getListOfFilesUnderLimit();
}
if (is_null($contents)) {
throw new Exception("A selected Playlist does not exist!");
}
foreach ($contents as $plItem) {
$file = $plItem->getCcFiles($this->con);
if (isset($file) && $file->getDbFileExists()) {
$data = $this->fileInfo;
$data["id"] = $plItem->getDbFileId();
$data["cliplength"] = $plItem->getDbCliplength();
$data["cuein"] = $plItem->getDbCuein();
$data["cueout"] = $plItem->getDbCueout();
$data["fadein"] = $plItem->getDbFadein();
$data["fadeout"] = $plItem->getDbFadeout();
$files[] = $data;
foreach ($contents as $fileId => $plItem) {
$data = $this->fileInfo;
if ($playlistType == "static"){
$file = $plItem->getCcFiles($this->con);
if (isset($file) && $file->getDbFileExists()) {
$data["id"] = $plItem->getDbFileId();
$data["cliplength"] = $plItem->getDbCliplength();
$data["cuein"] = $plItem->getDbCuein();
$data["cueout"] = $plItem->getDbCueout();
$data["fadein"] = $plItem->getDbFadein();
$data["fadeout"] = $plItem->getDbFadeout();
}
} else {
// on dynamic playslsit, $fileId is id of files
$file = Application_Model_StoredFile::Recall($fileId)->getPropelOrm();
if (isset($file) && $file->getDbFileExists()) {
$data["id"] = $fileId;
$data["cliplength"] = $file->getDbLength();
}
}
$files[] = $data;
}
}

View File

@ -0,0 +1,18 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_playlistcriteria' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPlaylistcriteria extends BaseCcPlaylistcriteria {
} // CcPlaylistcriteria

View File

@ -0,0 +1,18 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlistcriteria' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPlaylistcriteriaPeer extends BaseCcPlaylistcriteriaPeer {
} // CcPlaylistcriteriaPeer

View File

@ -0,0 +1,18 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlistcriteria' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPlaylistcriteriaQuery extends BaseCcPlaylistcriteriaQuery {
} // CcPlaylistcriteriaQuery

View File

@ -45,6 +45,7 @@ class CcPlaylistTableMap extends TableMap {
$this->addForeignKey('CREATOR_ID', 'DbCreatorId', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
$this->addColumn('LENGTH', 'DbLength', 'VARCHAR', false, null, '00:00:00');
$this->addColumn('TYPE', 'DbType', 'VARCHAR', false, 7, 'static');
// validators
} // initialize()
@ -55,6 +56,7 @@ class CcPlaylistTableMap extends TableMap {
{
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('creator_id' => 'id', ), null, null);
$this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null);
$this->addRelation('CcPlaylistcriteria', 'CcPlaylistcriteria', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null);
} // buildRelations()
/**

View File

@ -0,0 +1,58 @@
<?php
/**
* This class defines the structure of the 'cc_playlistcriteria' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.airtime.map
*/
class CcPlaylistcriteriaTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'airtime.map.CcPlaylistcriteriaTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_playlistcriteria');
$this->setPhpName('CcPlaylistcriteria');
$this->setClassname('CcPlaylistcriteria');
$this->setPackage('airtime');
$this->setUseIdGenerator(true);
$this->setPrimaryKeyMethodInfo('cc_playlistcriteria_id_seq');
// columns
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
$this->addColumn('CRITERIA', 'DbCriteria', 'VARCHAR', true, 16, null);
$this->addColumn('MODIFIER', 'DbModifier', 'VARCHAR', true, 16, null);
$this->addColumn('VALUE', 'DbValue', 'VARCHAR', true, 32, null);
$this->addColumn('EXTRA', 'DbExtra', 'VARCHAR', false, 32, null);
$this->addForeignKey('PLAYLIST_ID', 'DbPlaylistId', 'INTEGER', 'cc_playlist', 'ID', true, null, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::MANY_TO_ONE, array('playlist_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CcPlaylistcriteriaTableMap

View File

@ -68,6 +68,13 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
*/
protected $length;
/**
* The value for the type field.
* Note: this column has a database default value of: 'static'
* @var string
*/
protected $type;
/**
* @var CcSubjs
*/
@ -78,6 +85,11 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
*/
protected $collCcPlaylistcontentss;
/**
* @var array CcPlaylistcriteria[] Collection to store aggregation of CcPlaylistcriteria objects.
*/
protected $collCcPlaylistcriterias;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@ -102,6 +114,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
{
$this->name = '';
$this->length = '00:00:00';
$this->type = 'static';
}
/**
@ -230,6 +243,16 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this->length;
}
/**
* Get the [type] column value.
*
* @return string
*/
public function getDbType()
{
return $this->type;
}
/**
* Set the value of [id] column.
*
@ -432,6 +455,26 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this;
} // setDbLength()
/**
* Set the value of [type] column.
*
* @param string $v new value
* @return CcPlaylist The current object (for fluent API support)
*/
public function setDbType($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->type !== $v || $this->isNew()) {
$this->type = $v;
$this->modifiedColumns[] = CcPlaylistPeer::TYPE;
}
return $this;
} // setDbType()
/**
* Indicates whether the columns in this object are only set to default values.
*
@ -450,6 +493,10 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return false;
}
if ($this->type !== 'static') {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@ -479,6 +526,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->creator_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
$this->description = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
$this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
$this->type = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
$this->resetModified();
$this->setNew(false);
@ -487,7 +535,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 7; // 7 = CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 8; // 8 = CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcPlaylist object", $e);
@ -555,6 +603,8 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->aCcSubjs = null;
$this->collCcPlaylistcontentss = null;
$this->collCcPlaylistcriterias = null;
} // if (deep)
}
@ -708,6 +758,14 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
}
if ($this->collCcPlaylistcriterias !== null) {
foreach ($this->collCcPlaylistcriterias as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
@ -799,6 +857,14 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
}
if ($this->collCcPlaylistcriterias !== null) {
foreach ($this->collCcPlaylistcriterias as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
@ -853,6 +919,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
case 6:
return $this->getDbLength();
break;
case 7:
return $this->getDbType();
break;
default:
return null;
break;
@ -884,6 +953,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$keys[4] => $this->getDbCreatorId(),
$keys[5] => $this->getDbDescription(),
$keys[6] => $this->getDbLength(),
$keys[7] => $this->getDbType(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcSubjs) {
@ -941,6 +1011,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
case 6:
$this->setDbLength($value);
break;
case 7:
$this->setDbType($value);
break;
} // switch()
}
@ -972,6 +1045,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
if (array_key_exists($keys[4], $arr)) $this->setDbCreatorId($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbDescription($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbLength($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbType($arr[$keys[7]]);
}
/**
@ -990,6 +1064,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
if ($this->isColumnModified(CcPlaylistPeer::CREATOR_ID)) $criteria->add(CcPlaylistPeer::CREATOR_ID, $this->creator_id);
if ($this->isColumnModified(CcPlaylistPeer::DESCRIPTION)) $criteria->add(CcPlaylistPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(CcPlaylistPeer::LENGTH)) $criteria->add(CcPlaylistPeer::LENGTH, $this->length);
if ($this->isColumnModified(CcPlaylistPeer::TYPE)) $criteria->add(CcPlaylistPeer::TYPE, $this->type);
return $criteria;
}
@ -1057,6 +1132,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$copyObj->setDbCreatorId($this->creator_id);
$copyObj->setDbDescription($this->description);
$copyObj->setDbLength($this->length);
$copyObj->setDbType($this->type);
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@ -1069,6 +1145,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
}
foreach ($this->getCcPlaylistcriterias() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCcPlaylistcriteria($relObj->copy($deepCopy));
}
}
} // if ($deepCopy)
@ -1297,6 +1379,115 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this->getCcPlaylistcontentss($query, $con);
}
/**
* Clears out the collCcPlaylistcriterias collection
*
* This does not modify the database; however, it will remove any associated objects, causing
* them to be refetched by subsequent calls to accessor method.
*
* @return void
* @see addCcPlaylistcriterias()
*/
public function clearCcPlaylistcriterias()
{
$this->collCcPlaylistcriterias = null; // important to set this to NULL since that means it is uninitialized
}
/**
* Initializes the collCcPlaylistcriterias collection.
*
* By default this just sets the collCcPlaylistcriterias collection to an empty array (like clearcollCcPlaylistcriterias());
* however, you may wish to override this method in your stub class to provide setting appropriate
* to your application -- for example, setting the initial array to the values stored in database.
*
* @return void
*/
public function initCcPlaylistcriterias()
{
$this->collCcPlaylistcriterias = new PropelObjectCollection();
$this->collCcPlaylistcriterias->setModel('CcPlaylistcriteria');
}
/**
* Gets an array of CcPlaylistcriteria objects which contain a foreign key that references this object.
*
* If the $criteria is not null, it is used to always fetch the results from the database.
* Otherwise the results are fetched from the database the first time, then cached.
* Next time the same method is called without $criteria, the cached collection is returned.
* If this CcPlaylist is new, it will return
* an empty collection or the current collection; the criteria is ignored on a new object.
*
* @param Criteria $criteria optional Criteria object to narrow the query
* @param PropelPDO $con optional connection object
* @return PropelCollection|array CcPlaylistcriteria[] List of CcPlaylistcriteria objects
* @throws PropelException
*/
public function getCcPlaylistcriterias($criteria = null, PropelPDO $con = null)
{
if(null === $this->collCcPlaylistcriterias || null !== $criteria) {
if ($this->isNew() && null === $this->collCcPlaylistcriterias) {
// return empty collection
$this->initCcPlaylistcriterias();
} else {
$collCcPlaylistcriterias = CcPlaylistcriteriaQuery::create(null, $criteria)
->filterByCcPlaylist($this)
->find($con);
if (null !== $criteria) {
return $collCcPlaylistcriterias;
}
$this->collCcPlaylistcriterias = $collCcPlaylistcriterias;
}
}
return $this->collCcPlaylistcriterias;
}
/**
* Returns the number of related CcPlaylistcriteria objects.
*
* @param Criteria $criteria
* @param boolean $distinct
* @param PropelPDO $con
* @return int Count of related CcPlaylistcriteria objects.
* @throws PropelException
*/
public function countCcPlaylistcriterias(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
if(null === $this->collCcPlaylistcriterias || null !== $criteria) {
if ($this->isNew() && null === $this->collCcPlaylistcriterias) {
return 0;
} else {
$query = CcPlaylistcriteriaQuery::create(null, $criteria);
if($distinct) {
$query->distinct();
}
return $query
->filterByCcPlaylist($this)
->count($con);
}
} else {
return count($this->collCcPlaylistcriterias);
}
}
/**
* Method called to associate a CcPlaylistcriteria object to this object
* through the CcPlaylistcriteria foreign key attribute.
*
* @param CcPlaylistcriteria $l CcPlaylistcriteria
* @return void
* @throws PropelException
*/
public function addCcPlaylistcriteria(CcPlaylistcriteria $l)
{
if ($this->collCcPlaylistcriterias === null) {
$this->initCcPlaylistcriterias();
}
if (!$this->collCcPlaylistcriterias->contains($l)) { // only add it if the **same** object is not already associated
$this->collCcPlaylistcriterias[]= $l;
$l->setCcPlaylist($this);
}
}
/**
* Clears the current object and sets all attributes to their default values
*/
@ -1309,6 +1500,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->creator_id = null;
$this->description = null;
$this->length = null;
$this->type = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
@ -1335,9 +1527,15 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$o->clearAllReferences($deep);
}
}
if ($this->collCcPlaylistcriterias) {
foreach ((array) $this->collCcPlaylistcriterias as $o) {
$o->clearAllReferences($deep);
}
}
} // if ($deep)
$this->collCcPlaylistcontentss = null;
$this->collCcPlaylistcriterias = null;
$this->aCcSubjs = null;
}

View File

@ -26,7 +26,7 @@ abstract class BaseCcPlaylistPeer {
const TM_CLASS = 'CcPlaylistTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 7;
const NUM_COLUMNS = 8;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -52,6 +52,9 @@ abstract class BaseCcPlaylistPeer {
/** the column name for the LENGTH field */
const LENGTH = 'cc_playlist.LENGTH';
/** the column name for the TYPE field */
const TYPE = 'cc_playlist.TYPE';
/**
* An identiy map to hold any loaded instances of CcPlaylist objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
@ -68,12 +71,12 @@ abstract class BaseCcPlaylistPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', 'DbType', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', 'dbType', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, self::TYPE, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', 'TYPE', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', 'type', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@ -83,12 +86,12 @@ abstract class BaseCcPlaylistPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::CREATOR_ID => 4, self::DESCRIPTION => 5, self::LENGTH => 6, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, 'DbType' => 7, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, 'dbType' => 7, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::CREATOR_ID => 4, self::DESCRIPTION => 5, self::LENGTH => 6, self::TYPE => 7, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, 'TYPE' => 7, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, 'type' => 7, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@ -167,6 +170,7 @@ abstract class BaseCcPlaylistPeer {
$criteria->addSelectColumn(CcPlaylistPeer::CREATOR_ID);
$criteria->addSelectColumn(CcPlaylistPeer::DESCRIPTION);
$criteria->addSelectColumn(CcPlaylistPeer::LENGTH);
$criteria->addSelectColumn(CcPlaylistPeer::TYPE);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.NAME');
@ -175,6 +179,7 @@ abstract class BaseCcPlaylistPeer {
$criteria->addSelectColumn($alias . '.CREATOR_ID');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.LENGTH');
$criteria->addSelectColumn($alias . '.TYPE');
}
}
@ -371,6 +376,9 @@ abstract class BaseCcPlaylistPeer {
// Invalidate objects in CcPlaylistcontentsPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcPlaylistcontentsPeer::clearInstancePool();
// Invalidate objects in CcPlaylistcriteriaPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcPlaylistcriteriaPeer::clearInstancePool();
}
/**

View File

@ -13,6 +13,7 @@
* @method CcPlaylistQuery orderByDbCreatorId($order = Criteria::ASC) Order by the creator_id column
* @method CcPlaylistQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
* @method CcPlaylistQuery orderByDbLength($order = Criteria::ASC) Order by the length column
* @method CcPlaylistQuery orderByDbType($order = Criteria::ASC) Order by the type column
*
* @method CcPlaylistQuery groupByDbId() Group by the id column
* @method CcPlaylistQuery groupByDbName() Group by the name column
@ -21,6 +22,7 @@
* @method CcPlaylistQuery groupByDbCreatorId() Group by the creator_id column
* @method CcPlaylistQuery groupByDbDescription() Group by the description column
* @method CcPlaylistQuery groupByDbLength() Group by the length column
* @method CcPlaylistQuery groupByDbType() Group by the type column
*
* @method CcPlaylistQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcPlaylistQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@ -34,6 +36,10 @@
* @method CcPlaylistQuery rightJoinCcPlaylistcontents($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcPlaylistcontents relation
* @method CcPlaylistQuery innerJoinCcPlaylistcontents($relationAlias = '') Adds a INNER JOIN clause to the query using the CcPlaylistcontents relation
*
* @method CcPlaylistQuery leftJoinCcPlaylistcriteria($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcPlaylistcriteria relation
* @method CcPlaylistQuery rightJoinCcPlaylistcriteria($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcPlaylistcriteria relation
* @method CcPlaylistQuery innerJoinCcPlaylistcriteria($relationAlias = '') Adds a INNER JOIN clause to the query using the CcPlaylistcriteria relation
*
* @method CcPlaylist findOne(PropelPDO $con = null) Return the first CcPlaylist matching the query
* @method CcPlaylist findOneOrCreate(PropelPDO $con = null) Return the first CcPlaylist matching the query, or a new CcPlaylist object populated from the query conditions when no match is found
*
@ -44,6 +50,7 @@
* @method CcPlaylist findOneByDbCreatorId(int $creator_id) Return the first CcPlaylist filtered by the creator_id column
* @method CcPlaylist findOneByDbDescription(string $description) Return the first CcPlaylist filtered by the description column
* @method CcPlaylist findOneByDbLength(string $length) Return the first CcPlaylist filtered by the length column
* @method CcPlaylist findOneByDbType(string $type) Return the first CcPlaylist filtered by the type column
*
* @method array findByDbId(int $id) Return CcPlaylist objects filtered by the id column
* @method array findByDbName(string $name) Return CcPlaylist objects filtered by the name column
@ -52,6 +59,7 @@
* @method array findByDbCreatorId(int $creator_id) Return CcPlaylist objects filtered by the creator_id column
* @method array findByDbDescription(string $description) Return CcPlaylist objects filtered by the description column
* @method array findByDbLength(string $length) Return CcPlaylist objects filtered by the length column
* @method array findByDbType(string $type) Return CcPlaylist objects filtered by the type column
*
* @package propel.generator.airtime.om
*/
@ -337,6 +345,28 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
return $this->addUsingAlias(CcPlaylistPeer::LENGTH, $dbLength, $comparison);
}
/**
* Filter the query on the type column
*
* @param string $dbType The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistQuery The current query, for fluid interface
*/
public function filterByDbType($dbType = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbType)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbType)) {
$dbType = str_replace('*', '%', $dbType);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcPlaylistPeer::TYPE, $dbType, $comparison);
}
/**
* Filter the query by a related CcSubjs object
*
@ -465,6 +495,70 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcontents', 'CcPlaylistcontentsQuery');
}
/**
* Filter the query by a related CcPlaylistcriteria object
*
* @param CcPlaylistcriteria $ccPlaylistcriteria the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistQuery The current query, for fluid interface
*/
public function filterByCcPlaylistcriteria($ccPlaylistcriteria, $comparison = null)
{
return $this
->addUsingAlias(CcPlaylistPeer::ID, $ccPlaylistcriteria->getDbPlaylistId(), $comparison);
}
/**
* Adds a JOIN clause to the query using the CcPlaylistcriteria relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcPlaylistQuery The current query, for fluid interface
*/
public function joinCcPlaylistcriteria($relationAlias = '', $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CcPlaylistcriteria');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CcPlaylistcriteria');
}
return $this;
}
/**
* Use the CcPlaylistcriteria relation CcPlaylistcriteria object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcPlaylistcriteriaQuery A secondary query class using the current class as primary query
*/
public function useCcPlaylistcriteriaQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCcPlaylistcriteria($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcriteria', 'CcPlaylistcriteriaQuery');
}
/**
* Exclude object from result
*

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,993 @@
<?php
/**
* Base static class for performing query and update operations on the 'cc_playlistcriteria' table.
*
*
*
* @package propel.generator.airtime.om
*/
abstract class BaseCcPlaylistcriteriaPeer {
/** the default database name for this class */
const DATABASE_NAME = 'airtime';
/** the table name for this class */
const TABLE_NAME = 'cc_playlistcriteria';
/** the related Propel class for this table */
const OM_CLASS = 'CcPlaylistcriteria';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'airtime.CcPlaylistcriteria';
/** the related TableMap class for this table */
const TM_CLASS = 'CcPlaylistcriteriaTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 6;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the ID field */
const ID = 'cc_playlistcriteria.ID';
/** the column name for the CRITERIA field */
const CRITERIA = 'cc_playlistcriteria.CRITERIA';
/** the column name for the MODIFIER field */
const MODIFIER = 'cc_playlistcriteria.MODIFIER';
/** the column name for the VALUE field */
const VALUE = 'cc_playlistcriteria.VALUE';
/** the column name for the EXTRA field */
const EXTRA = 'cc_playlistcriteria.EXTRA';
/** the column name for the PLAYLIST_ID field */
const PLAYLIST_ID = 'cc_playlistcriteria.PLAYLIST_ID';
/**
* An identiy map to hold any loaded instances of CcPlaylistcriteria objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
* queries.
* @var array CcPlaylistcriteria[]
*/
public static $instances = array();
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbCriteria', 'DbModifier', 'DbValue', 'DbExtra', 'DbPlaylistId', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbCriteria', 'dbModifier', 'dbValue', 'dbExtra', 'dbPlaylistId', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::CRITERIA, self::MODIFIER, self::VALUE, self::EXTRA, self::PLAYLIST_ID, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CRITERIA', 'MODIFIER', 'VALUE', 'EXTRA', 'PLAYLIST_ID', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'criteria', 'modifier', 'value', 'extra', 'playlist_id', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbCriteria' => 1, 'DbModifier' => 2, 'DbValue' => 3, 'DbExtra' => 4, 'DbPlaylistId' => 5, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbCriteria' => 1, 'dbModifier' => 2, 'dbValue' => 3, 'dbExtra' => 4, 'dbPlaylistId' => 5, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::CRITERIA => 1, self::MODIFIER => 2, self::VALUE => 3, self::EXTRA => 4, self::PLAYLIST_ID => 5, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CRITERIA' => 1, 'MODIFIER' => 2, 'VALUE' => 3, 'EXTRA' => 4, 'PLAYLIST_ID' => 5, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'criteria' => 1, 'modifier' => 2, 'value' => 3, 'extra' => 4, 'playlist_id' => 5, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
);
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
* @throws PropelException - if the specified name could not be found in the fieldname mappings.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. CcPlaylistcriteriaPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(CcPlaylistcriteriaPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CcPlaylistcriteriaPeer::ID);
$criteria->addSelectColumn(CcPlaylistcriteriaPeer::CRITERIA);
$criteria->addSelectColumn(CcPlaylistcriteriaPeer::MODIFIER);
$criteria->addSelectColumn(CcPlaylistcriteriaPeer::VALUE);
$criteria->addSelectColumn(CcPlaylistcriteriaPeer::EXTRA);
$criteria->addSelectColumn(CcPlaylistcriteriaPeer::PLAYLIST_ID);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.CRITERIA');
$criteria->addSelectColumn($alias . '.MODIFIER');
$criteria->addSelectColumn($alias . '.VALUE');
$criteria->addSelectColumn($alias . '.EXTRA');
$criteria->addSelectColumn($alias . '.PLAYLIST_ID');
}
}
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
* @param PropelPDO $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
{
// we may modify criteria, so copy it first
$criteria = clone $criteria;
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(CcPlaylistcriteriaPeer::TABLE_NAME);
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->setDistinct();
}
if (!$criteria->hasSelectClause()) {
CcPlaylistcriteriaPeer::addSelectColumns($criteria);
}
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
$criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
if ($con === null) {
$con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
// BasePeer returns a PDOStatement
$stmt = BasePeer::doCount($criteria, $con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param PropelPDO $con
* @return CcPlaylistcriteria
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = CcPlaylistcriteriaPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param PropelPDO $con
* @return array Array of selected Objects
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, PropelPDO $con = null)
{
return CcPlaylistcriteriaPeer::populateObjects(CcPlaylistcriteriaPeer::doSelectStmt($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
*
* Use this method directly if you want to work with an executed statement durirectly (for example
* to perform your own object hydration).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param PropelPDO $con The connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return PDOStatement The executed PDOStatement object.
* @see BasePeer::doSelect()
*/
public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
if (!$criteria->hasSelectClause()) {
$criteria = clone $criteria;
CcPlaylistcriteriaPeer::addSelectColumns($criteria);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a PDOStatement
return BasePeer::doSelect($criteria, $con);
}
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param CcPlaylistcriteria $value A CcPlaylistcriteria object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(CcPlaylistcriteria $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getDbId();
} // if key === null
self::$instances[$key] = $obj;
}
}
/**
* Removes an object from the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doDelete
* methods in your stub classes -- you may need to explicitly remove objects
* from the cache in order to prevent returning objects that no longer exist.
*
* @param mixed $value A CcPlaylistcriteria object or a primary key value.
*/
public static function removeInstanceFromPool($value)
{
if (Propel::isInstancePoolingEnabled() && $value !== null) {
if (is_object($value) && $value instanceof CcPlaylistcriteria) {
$key = (string) $value->getDbId();
} elseif (is_scalar($value)) {
// assume we've been passed a primary key
$key = (string) $value;
} else {
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CcPlaylistcriteria object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
throw $e;
}
unset(self::$instances[$key]);
}
} // removeInstanceFromPool()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param string $key The key (@see getPrimaryKeyHash()) for this instance.
* @return CcPlaylistcriteria Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
* @see getPrimaryKeyHash()
*/
public static function getInstanceFromPool($key)
{
if (Propel::isInstancePoolingEnabled()) {
if (isset(self::$instances[$key])) {
return self::$instances[$key];
}
}
return null; // just to be explicit
}
/**
* Clear the instance pool.
*
* @return void
*/
public static function clearInstancePool()
{
self::$instances = array();
}
/**
* Method to invalidate the instance pool of all tables related to cc_playlistcriteria
* by a foreign key with ON DELETE CASCADE
*/
public static function clearRelatedInstancePool()
{
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @return string A string version of PK or NULL if the components of primary key in result array are all null.
*/
public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[$startcol] === null) {
return null;
}
return (string) $row[$startcol];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $startcol = 0)
{
return (int) $row[$startcol];
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(PDOStatement $stmt)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = CcPlaylistcriteriaPeer::getOMClass(false);
// populate the object(s)
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key = CcPlaylistcriteriaPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj = CcPlaylistcriteriaPeer::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CcPlaylistcriteriaPeer::addInstanceToPool($obj, $key);
} // if key exists
}
$stmt->closeCursor();
return $results;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CcPlaylistcriteria object, last column rank)
*/
public static function populateObject($row, $startcol = 0)
{
$key = CcPlaylistcriteriaPeer::getPrimaryKeyHashFromRow($row, $startcol);
if (null !== ($obj = CcPlaylistcriteriaPeer::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $startcol, true); // rehydrate
$col = $startcol + CcPlaylistcriteriaPeer::NUM_COLUMNS;
} else {
$cls = CcPlaylistcriteriaPeer::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $startcol);
CcPlaylistcriteriaPeer::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* Returns the number of rows matching criteria, joining the related CcPlaylist table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
public static function doCountJoinCcPlaylist(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(CcPlaylistcriteriaPeer::TABLE_NAME);
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->setDistinct();
}
if (!$criteria->hasSelectClause()) {
CcPlaylistcriteriaPeer::addSelectColumns($criteria);
}
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
if ($con === null) {
$con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria->addJoin(CcPlaylistcriteriaPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
}
/**
* Selects a collection of CcPlaylistcriteria objects pre-filled with their CcPlaylist objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return array Array of CcPlaylistcriteria objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinCcPlaylist(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
// Set the correct dbName if it has not been overridden
if ($criteria->getDbName() == Propel::getDefaultDB()) {
$criteria->setDbName(self::DATABASE_NAME);
}
CcPlaylistcriteriaPeer::addSelectColumns($criteria);
$startcol = (CcPlaylistcriteriaPeer::NUM_COLUMNS - CcPlaylistcriteriaPeer::NUM_LAZY_LOAD_COLUMNS);
CcPlaylistPeer::addSelectColumns($criteria);
$criteria->addJoin(CcPlaylistcriteriaPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key1 = CcPlaylistcriteriaPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj1 = CcPlaylistcriteriaPeer::getInstanceFromPool($key1))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj1->hydrate($row, 0, true); // rehydrate
} else {
$cls = CcPlaylistcriteriaPeer::getOMClass(false);
$obj1 = new $cls();
$obj1->hydrate($row);
CcPlaylistcriteriaPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
$key2 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
$obj2 = CcPlaylistPeer::getInstanceFromPool($key2);
if (!$obj2) {
$cls = CcPlaylistPeer::getOMClass(false);
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
CcPlaylistPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
// Add the $obj1 (CcPlaylistcriteria) to $obj2 (CcPlaylist)
$obj2->addCcPlaylistcriteria($obj1);
} // if joined row was not null
$results[] = $obj1;
}
$stmt->closeCursor();
return $results;
}
/**
* Returns the number of rows matching criteria, joining all related tables
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(CcPlaylistcriteriaPeer::TABLE_NAME);
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->setDistinct();
}
if (!$criteria->hasSelectClause()) {
CcPlaylistcriteriaPeer::addSelectColumns($criteria);
}
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
if ($con === null) {
$con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria->addJoin(CcPlaylistcriteriaPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
}
/**
* Selects a collection of CcPlaylistcriteria objects pre-filled with all related objects.
*
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return array Array of CcPlaylistcriteria objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
// Set the correct dbName if it has not been overridden
if ($criteria->getDbName() == Propel::getDefaultDB()) {
$criteria->setDbName(self::DATABASE_NAME);
}
CcPlaylistcriteriaPeer::addSelectColumns($criteria);
$startcol2 = (CcPlaylistcriteriaPeer::NUM_COLUMNS - CcPlaylistcriteriaPeer::NUM_LAZY_LOAD_COLUMNS);
CcPlaylistPeer::addSelectColumns($criteria);
$startcol3 = $startcol2 + (CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS);
$criteria->addJoin(CcPlaylistcriteriaPeer::PLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key1 = CcPlaylistcriteriaPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj1 = CcPlaylistcriteriaPeer::getInstanceFromPool($key1))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj1->hydrate($row, 0, true); // rehydrate
} else {
$cls = CcPlaylistcriteriaPeer::getOMClass(false);
$obj1 = new $cls();
$obj1->hydrate($row);
CcPlaylistcriteriaPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
// Add objects for joined CcPlaylist rows
$key2 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
$obj2 = CcPlaylistPeer::getInstanceFromPool($key2);
if (!$obj2) {
$cls = CcPlaylistPeer::getOMClass(false);
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
CcPlaylistPeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
// Add the $obj1 (CcPlaylistcriteria) to the collection in $obj2 (CcPlaylist)
$obj2->addCcPlaylistcriteria($obj1);
} // if joined row not null
$results[] = $obj1;
}
$stmt->closeCursor();
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this peer class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getDatabaseMap(BaseCcPlaylistcriteriaPeer::DATABASE_NAME);
if (!$dbMap->hasTable(BaseCcPlaylistcriteriaPeer::TABLE_NAME))
{
$dbMap->addTableObject(new CcPlaylistcriteriaTableMap());
}
}
/**
* The class that the Peer will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CcPlaylistcriteriaPeer::CLASS_DEFAULT : CcPlaylistcriteriaPeer::OM_CLASS;
}
/**
* Method perform an INSERT on the database, given a CcPlaylistcriteria or Criteria object.
*
* @param mixed $values Criteria or CcPlaylistcriteria object containing data that is used to create the INSERT statement.
* @param PropelPDO $con the PropelPDO connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from CcPlaylistcriteria object
}
if ($criteria->containsKey(CcPlaylistcriteriaPeer::ID) && $criteria->keyContainsValue(CcPlaylistcriteriaPeer::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlaylistcriteriaPeer::ID.')');
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a CcPlaylistcriteria or Criteria object.
*
* @param mixed $values Criteria or CcPlaylistcriteria object containing data that is used to create the UPDATE statement.
* @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(CcPlaylistcriteriaPeer::ID);
$value = $criteria->remove(CcPlaylistcriteriaPeer::ID);
if ($value) {
$selectCriteria->add(CcPlaylistcriteriaPeer::ID, $value, $comparison);
} else {
$selectCriteria->setPrimaryTableName(CcPlaylistcriteriaPeer::TABLE_NAME);
}
} else { // $values is CcPlaylistcriteria object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
/**
* Method to DELETE all rows from the cc_playlistcriteria table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDeleteAll(CcPlaylistcriteriaPeer::TABLE_NAME, $con, CcPlaylistcriteriaPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CcPlaylistcriteriaPeer::clearInstancePool();
CcPlaylistcriteriaPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a CcPlaylistcriteria or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CcPlaylistcriteria object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param PropelPDO $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
// invalidate the cache for all objects of this type, since we have no
// way of knowing (without running a query) what objects should be invalidated
// from the cache based on this Criteria.
CcPlaylistcriteriaPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof CcPlaylistcriteria) { // it's a model object
// invalidate the cache for this single object
CcPlaylistcriteriaPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(CcPlaylistcriteriaPeer::ID, (array) $values, Criteria::IN);
// invalidate the cache for this object(s)
foreach ((array) $values as $singleval) {
CcPlaylistcriteriaPeer::removeInstanceFromPool($singleval);
}
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDelete($criteria, $con);
CcPlaylistcriteriaPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Validates all modified columns of given CcPlaylistcriteria object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param CcPlaylistcriteria $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(CcPlaylistcriteria $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(CcPlaylistcriteriaPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(CcPlaylistcriteriaPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach ($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
return BasePeer::doValidate(CcPlaylistcriteriaPeer::DATABASE_NAME, CcPlaylistcriteriaPeer::TABLE_NAME, $columns);
}
/**
* Retrieve a single object by pkey.
*
* @param int $pk the primary key.
* @param PropelPDO $con the connection to use
* @return CcPlaylistcriteria
*/
public static function retrieveByPK($pk, PropelPDO $con = null)
{
if (null !== ($obj = CcPlaylistcriteriaPeer::getInstanceFromPool((string) $pk))) {
return $obj;
}
if ($con === null) {
$con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria = new Criteria(CcPlaylistcriteriaPeer::DATABASE_NAME);
$criteria->add(CcPlaylistcriteriaPeer::ID, $pk);
$v = CcPlaylistcriteriaPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
/**
* Retrieve multiple objects by pkey.
*
* @param array $pks List of primary keys
* @param PropelPDO $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function retrieveByPKs($pks, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPlaylistcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria(CcPlaylistcriteriaPeer::DATABASE_NAME);
$criteria->add(CcPlaylistcriteriaPeer::ID, $pks, Criteria::IN);
$objs = CcPlaylistcriteriaPeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseCcPlaylistcriteriaPeer
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
BaseCcPlaylistcriteriaPeer::buildTableMap();

View File

@ -0,0 +1,372 @@
<?php
/**
* Base class that represents a query for the 'cc_playlistcriteria' table.
*
*
*
* @method CcPlaylistcriteriaQuery orderByDbId($order = Criteria::ASC) Order by the id column
* @method CcPlaylistcriteriaQuery orderByDbCriteria($order = Criteria::ASC) Order by the criteria column
* @method CcPlaylistcriteriaQuery orderByDbModifier($order = Criteria::ASC) Order by the modifier column
* @method CcPlaylistcriteriaQuery orderByDbValue($order = Criteria::ASC) Order by the value column
* @method CcPlaylistcriteriaQuery orderByDbExtra($order = Criteria::ASC) Order by the extra column
* @method CcPlaylistcriteriaQuery orderByDbPlaylistId($order = Criteria::ASC) Order by the playlist_id column
*
* @method CcPlaylistcriteriaQuery groupByDbId() Group by the id column
* @method CcPlaylistcriteriaQuery groupByDbCriteria() Group by the criteria column
* @method CcPlaylistcriteriaQuery groupByDbModifier() Group by the modifier column
* @method CcPlaylistcriteriaQuery groupByDbValue() Group by the value column
* @method CcPlaylistcriteriaQuery groupByDbExtra() Group by the extra column
* @method CcPlaylistcriteriaQuery groupByDbPlaylistId() Group by the playlist_id column
*
* @method CcPlaylistcriteriaQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcPlaylistcriteriaQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method CcPlaylistcriteriaQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method CcPlaylistcriteriaQuery leftJoinCcPlaylist($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcPlaylist relation
* @method CcPlaylistcriteriaQuery rightJoinCcPlaylist($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcPlaylist relation
* @method CcPlaylistcriteriaQuery innerJoinCcPlaylist($relationAlias = '') Adds a INNER JOIN clause to the query using the CcPlaylist relation
*
* @method CcPlaylistcriteria findOne(PropelPDO $con = null) Return the first CcPlaylistcriteria matching the query
* @method CcPlaylistcriteria findOneOrCreate(PropelPDO $con = null) Return the first CcPlaylistcriteria matching the query, or a new CcPlaylistcriteria object populated from the query conditions when no match is found
*
* @method CcPlaylistcriteria findOneByDbId(int $id) Return the first CcPlaylistcriteria filtered by the id column
* @method CcPlaylistcriteria findOneByDbCriteria(string $criteria) Return the first CcPlaylistcriteria filtered by the criteria column
* @method CcPlaylistcriteria findOneByDbModifier(string $modifier) Return the first CcPlaylistcriteria filtered by the modifier column
* @method CcPlaylistcriteria findOneByDbValue(string $value) Return the first CcPlaylistcriteria filtered by the value column
* @method CcPlaylistcriteria findOneByDbExtra(string $extra) Return the first CcPlaylistcriteria filtered by the extra column
* @method CcPlaylistcriteria findOneByDbPlaylistId(int $playlist_id) Return the first CcPlaylistcriteria filtered by the playlist_id column
*
* @method array findByDbId(int $id) Return CcPlaylistcriteria objects filtered by the id column
* @method array findByDbCriteria(string $criteria) Return CcPlaylistcriteria objects filtered by the criteria column
* @method array findByDbModifier(string $modifier) Return CcPlaylistcriteria objects filtered by the modifier column
* @method array findByDbValue(string $value) Return CcPlaylistcriteria objects filtered by the value column
* @method array findByDbExtra(string $extra) Return CcPlaylistcriteria objects filtered by the extra column
* @method array findByDbPlaylistId(int $playlist_id) Return CcPlaylistcriteria objects filtered by the playlist_id column
*
* @package propel.generator.airtime.om
*/
abstract class BaseCcPlaylistcriteriaQuery extends ModelCriteria
{
/**
* Initializes internal state of BaseCcPlaylistcriteriaQuery object.
*
* @param string $dbName The dabase name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'airtime', $modelName = 'CcPlaylistcriteria', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new CcPlaylistcriteriaQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return CcPlaylistcriteriaQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof CcPlaylistcriteriaQuery) {
return $criteria;
}
$query = new CcPlaylistcriteriaQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key
* Use instance pooling to avoid a database query if the object exists
* <code>
* $obj = $c->findPk(12, $con);
* </code>
* @param mixed $key Primary key to use for the query
* @param PropelPDO $con an optional connection object
*
* @return CcPlaylistcriteria|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ((null !== ($obj = CcPlaylistcriteriaPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
// the object is alredy in the instance pool
return $obj;
} else {
// the object has not been requested yet, or the formatter is not an object formatter
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria
->filterByPrimaryKey($key)
->getSelectStatement($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
}
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param PropelPDO $con an optional connection object
*
* @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
$criteria = $this->isKeepQuery() ? clone $this : $this;
return $this
->filterByPrimaryKeys($keys)
->find($con);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(CcPlaylistcriteriaPeer::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(CcPlaylistcriteriaPeer::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* @param int|array $dbId The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function filterByDbId($dbId = null, $comparison = null)
{
if (is_array($dbId) && null === $comparison) {
$comparison = Criteria::IN;
}
return $this->addUsingAlias(CcPlaylistcriteriaPeer::ID, $dbId, $comparison);
}
/**
* Filter the query on the criteria column
*
* @param string $dbCriteria The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function filterByDbCriteria($dbCriteria = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbCriteria)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbCriteria)) {
$dbCriteria = str_replace('*', '%', $dbCriteria);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcPlaylistcriteriaPeer::CRITERIA, $dbCriteria, $comparison);
}
/**
* Filter the query on the modifier column
*
* @param string $dbModifier The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function filterByDbModifier($dbModifier = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbModifier)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbModifier)) {
$dbModifier = str_replace('*', '%', $dbModifier);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcPlaylistcriteriaPeer::MODIFIER, $dbModifier, $comparison);
}
/**
* Filter the query on the value column
*
* @param string $dbValue The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function filterByDbValue($dbValue = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbValue)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbValue)) {
$dbValue = str_replace('*', '%', $dbValue);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcPlaylistcriteriaPeer::VALUE, $dbValue, $comparison);
}
/**
* Filter the query on the extra column
*
* @param string $dbExtra The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function filterByDbExtra($dbExtra = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbExtra)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbExtra)) {
$dbExtra = str_replace('*', '%', $dbExtra);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcPlaylistcriteriaPeer::EXTRA, $dbExtra, $comparison);
}
/**
* Filter the query on the playlist_id column
*
* @param int|array $dbPlaylistId The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function filterByDbPlaylistId($dbPlaylistId = null, $comparison = null)
{
if (is_array($dbPlaylistId)) {
$useMinMax = false;
if (isset($dbPlaylistId['min'])) {
$this->addUsingAlias(CcPlaylistcriteriaPeer::PLAYLIST_ID, $dbPlaylistId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbPlaylistId['max'])) {
$this->addUsingAlias(CcPlaylistcriteriaPeer::PLAYLIST_ID, $dbPlaylistId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcPlaylistcriteriaPeer::PLAYLIST_ID, $dbPlaylistId, $comparison);
}
/**
* Filter the query by a related CcPlaylist object
*
* @param CcPlaylist $ccPlaylist the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function filterByCcPlaylist($ccPlaylist, $comparison = null)
{
return $this
->addUsingAlias(CcPlaylistcriteriaPeer::PLAYLIST_ID, $ccPlaylist->getDbId(), $comparison);
}
/**
* Adds a JOIN clause to the query using the CcPlaylist relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function joinCcPlaylist($relationAlias = '', $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CcPlaylist');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CcPlaylist');
}
return $this;
}
/**
* Use the CcPlaylist relation CcPlaylist object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcPlaylistQuery A secondary query class using the current class as primary query
*/
public function useCcPlaylistQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCcPlaylist($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CcPlaylist', 'CcPlaylistQuery');
}
/**
* Exclude object from result
*
* @param CcPlaylistcriteria $ccPlaylistcriteria Object to remove from the list of results
*
* @return CcPlaylistcriteriaQuery The current query, for fluid interface
*/
public function prune($ccPlaylistcriteria = null)
{
if ($ccPlaylistcriteria) {
$this->addUsingAlias(CcPlaylistcriteriaPeer::ID, $ccPlaylistcriteria->getDbId(), Criteria::NOT_EQUAL);
}
return $this;
}
} // BaseCcPlaylistcriteriaQuery

View File

@ -0,0 +1,52 @@
<form id="smart-playlist-form" method="post" action="">
<fieldset class='toggle <?php echo $this->openOption ? "" : "closed"?>' id='smart_playlist_options'>
<legend style='cursor: pointer;'><span class='ui-icon ui-icon-triangle-2-n-s'></span>Smart Playlist Options</legend>
<dl class='zend_form'>
<div id='sp-success' class='success' style='display:none'></div>
<dd id='sp_type-element' class='radio-inline-list'>
<label for='sp_type'>
<?php echo $this->element->getElement('sp_type')->getLabel() ?>
<span class='playlist_type_help_icon'></span>
<?php $i=0;
$value = $this->element->getElement('sp_type')->getValue();
foreach ($this->element->getElement('sp_type')->getMultiOptions() as $radio) : ?>
<input type="radio" value="<?php echo $i ?>" id="sp_type-<?php echo $i ?>" name="sp_type" <?php if($i == $value){echo 'checked="checked"';}?> >
<?php echo $radio ?>
</input>
<?php $i = $i + 1; ?>
<?php endforeach; ?>
<?php echo $this->element->getElement('save_button') ?>
<?php echo $this->element->getElement('generate_button') ?>
<?php echo $this->element->getElement('shuffle_button') ?>
</label>
</dd>
<dd id='sp_criteria-element'>
<?php for ($i = 0; $i < $this->criteriasLength; $i++) {?>
<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_field_'.$i) ?>
<?php echo $this->element->getElement('sp_criteria_modifier_'.$i) ?>
<?php echo $this->element->getElement('sp_criteria_value_'.$i) ?>
<span class='sp_text_font' 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>
<a class='ui-button sp-ui-button-icon-only' id='criteria_remove_<?php echo $i ?>'>
<span class='ui-icon ui-icon-closethick'></span>
</a>
<br />
</div>
<?php } ?>
<br />
</dd>
<dd id='sp_limit-element'>
<span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value')->getLabel() ?></span>
<?php echo $this->element->getElement('sp_limit_value')?>
<?php echo $this->element->getElement('sp_limit_options') ?>
</dd>
</dl>
</fieldset>
</form>

View File

@ -30,6 +30,8 @@
</dd>
</dl>
</fieldset>
<?php echo $this->form; ?>
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;">
<span class="ui-icon ui-icon-closethick"></span>

View File

@ -224,6 +224,7 @@
<column name="creator_id" phpName="DbCreatorId" type="INTEGER" required="false"/>
<column name="description" phpName="DbDescription" type="VARCHAR" size="512" required="false"/>
<column name="length" phpName="DbLength" type="VARCHAR" sqlType="interval" defaultValue="00:00:00"/>
<column name="type" phpName="DbType" type="VARCHAR" size="7" defaultValue="static"/>
<behavior name="aggregate_column">
<parameter name="name" value="length" />
<parameter name="foreign_table" value="cc_playlistcontents" />
@ -250,6 +251,17 @@
<reference local="playlist_id" foreign="id"/>
</foreign-key>
</table>
<table name="cc_playlistcriteria" phpName="CcPlaylistcriteria">
<column name="id" phpName="DbId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="criteria" phpName="DbCriteria" type="VARCHAR" size="16" required="true"/>
<column name="modifier" phpName="DbModifier" type="VARCHAR" size="16" required="true"/>
<column name="value" phpName="DbValue" type="VARCHAR" size="32" required="true"/>
<column name="extra" phpName="DbExtra" type="VARCHAR" size="32" required="false"/>
<column name="playlist_id" phpName="DbPlaylistId" type="INTEGER" required="true"/>
<foreign-key foreignTable="cc_playlist" name="cc_playlistcontents_playlist_id_fkey" onDelete="CASCADE">
<reference local="playlist_id" foreign="id"/>
</foreign-key>
</table>
<table name="cc_pref" phpName="CcPref">
<column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="subjid" phpName="Subjid" type="INTEGER" required="false"/>

View File

@ -301,6 +301,7 @@ CREATE TABLE "cc_playlist"
"creator_id" INTEGER,
"description" VARCHAR(512),
"length" interval default '00:00:00',
"type" VARCHAR(7) default 'static',
PRIMARY KEY ("id")
);
@ -332,6 +333,28 @@ CREATE TABLE "cc_playlistcontents"
COMMENT ON TABLE "cc_playlistcontents" IS '';
SET search_path TO public;
-----------------------------------------------------------------------------
-- cc_playlistcriteria
-----------------------------------------------------------------------------
DROP TABLE "cc_playlistcriteria" CASCADE;
CREATE TABLE "cc_playlistcriteria"
(
"id" serial NOT NULL,
"criteria" VARCHAR(16) NOT NULL,
"modifier" VARCHAR(16) NOT NULL,
"value" VARCHAR(32) NOT NULL,
"extra" VARCHAR(32),
"playlist_id" INTEGER NOT NULL,
PRIMARY KEY ("id")
);
COMMENT ON TABLE "cc_playlistcriteria" IS '';
SET search_path TO public;
-----------------------------------------------------------------------------
-- cc_pref
@ -606,6 +629,8 @@ ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_file_id_fk
ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_playlist_id_fkey" FOREIGN KEY ("playlist_id") REFERENCES "cc_playlist" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_playlistcriteria" ADD CONSTRAINT "cc_playlistcontents_playlist_id_fkey" FOREIGN KEY ("playlist_id") REFERENCES "cc_playlist" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_pref" ADD CONSTRAINT "cc_pref_subjid_fkey" FOREIGN KEY ("subjid") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_schedule" ADD CONSTRAINT "cc_show_inst_fkey" FOREIGN KEY ("instance_id") REFERENCES "cc_show_instances" ("id") ON DELETE CASCADE;

View File

@ -93,7 +93,7 @@ select {
}
/* Version Notification Ends*/
.override_help_icon, .icecast_metadata_help_icon {
.override_help_icon, .icecast_metadata_help_icon {
cursor: help;
position: relative;
@ -104,7 +104,7 @@ select {
line-height:16px !important;
}
.airtime_auth_help_icon, .custom_auth_help_icon, .stream_username_help_icon {
.airtime_auth_help_icon, .custom_auth_help_icon, .stream_username_help_icon, .playlist_type_help_icon {
cursor: help;
position: relative;
display:inline-block; zoom:1;
@ -416,6 +416,50 @@ input[type="text"]:focus, input[type="password"]:focus, textarea:focus, .input_t
padding: 2px 2px 2px 0;
vertical-align: top;
}
/***** SMART PLAYLIST SPECIFIC STYLES BEGIN *****/
.sp_input_select{
width: 130px;
}
.sp_input_text_limit{
width: 75px !important;
}
input.input_text.sp_input_text{
width: 200px !important;
}
input.input_text.sp_extra_input_text{
width: 87px !important;
}
.sp_text_font{
font-size:13px;
font-family:Helvetica, Arial, sans-serif;
color: #5B5B5B;
}
.sp-ui-button-icon-only {
position: relative;
top: 5px;
margin-top: -10px;
margin-left: 5px;
}
.sp-ui-button-icon-only .ui-icon-closethick:hover, .sp-ui-button-icon-only .ui-icon-plusthick:hover {
background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png)
}
.sp-button{
float: right !important;
width: 60px;
height: 24px !important;
margin-right: 0px !important;
margin-left: 10px !important;
}
/***** SMART PLAYLIST SPECIFIC STYLES END *****/
label {
font-size:13px;
color:#5b5b5b;
@ -1409,7 +1453,7 @@ div.success{
border:1px solid #488214;
}
div.errors{
div.errors, span.errors{
color:#902d2d;
font-size:11px;
padding:2px 4px;
@ -1418,6 +1462,11 @@ div.errors{
border:1px solid #c83f3f;
}
span.errors.sp-errors{
width: 466px;
display: block;
}
.collapsible-header, .collapsible-header-disabled {
border: 1px solid #8f8f8f;
background-color: #cccccc;

View File

@ -60,7 +60,7 @@ var AIRTIME = (function(AIRTIME) {
count++;
}
}
visibleChosenItems = {};
return count;
};
@ -123,7 +123,7 @@ var AIRTIME = (function(AIRTIME) {
data.push(visibleChosenItems[id]);
}
}
visibleChosenItems = {};
return data;
};
@ -441,7 +441,6 @@ var AIRTIME = (function(AIRTIME) {
$tr = $(el).parent();
data = $tr.data("aData");
AIRTIME.library.dblClickAdd(data.id, data.ftype);
//AIRTIME.playlist.fnAddItems([data.id], undefined, 'after');
}
else
{

View File

@ -318,8 +318,14 @@ var AIRTIME = (function(AIRTIME){
$("#side_playlist")
.empty()
.append(json.html);
setUpPlaylist();
// functions in smart_playlistbuilder.js
setupUI();
appendAddButton();
removeButtonCheck();
}
//sets events dynamically for playlist entries (each row in the playlist)
@ -656,6 +662,10 @@ var AIRTIME = (function(AIRTIME){
});
};
mod.fnOpenPlaylist = function(json) {
openPlaylist(json);
};
mod.enableUI = function() {
$lib.unblock();
@ -664,6 +674,7 @@ var AIRTIME = (function(AIRTIME){
//Block UI changes the postion to relative to display the messages.
$lib.css("position", "static");
$pl.css("position", "static");
setupUI();
};
function playlistResponse(json){

View File

@ -0,0 +1,376 @@
$(document).ready(function() {
setSmartPlaylistEvents();
$(".playlist_type_help_icon").qtip({
content: {
text: "A static playlist will save the criteria and generate the playlist content immediately." +
"This allows you to edit and view it in the Playlist Builder before adding it to a show.<br /><br />" +
"A dynamic playlist will only save the criteria. The playlist content will get generated upon " +
"adding it to a show. You will not be able to view and edit it in the Playlist Builder."
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
})
});
function setSmartPlaylistEvents() {
var form = $('#smart-playlist-form');
form.find('.criteria_add').live("click", function(){
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last').next();
div.show();
div.children().removeAttr('disabled');
div = div.next();
if (div.length === 0) {
$(this).hide();
}
appendAddButton();
removeButtonCheck();
});
form.find('a[id^="criteria_remove"]').live("click", function(){
var curr = $(this).parent();
var curr_pos = curr.index();
var list = curr.parent();
var list_length = list.find("div:visible").length;
var count = list_length - curr_pos;
var next = curr.next();
var add_button = form.find('a[id="criteria_add"]');
var item_to_hide;
//remove error message from current row, if any
var error_element = curr.find('span[class="errors sp-errors"]');
if (error_element.is(':visible')) {
error_element.remove();
}
/* assign next row to current row for all rows below and including
* the row getting removed
*/
for (var i=0; i<count; i++) {
var criteria = next.find('[name^="sp_criteria_field"]').val();
curr.find('[name^="sp_criteria_field"]').val(criteria);
var modifier = next.find('[name^="sp_criteria_modifier"]').val();
populateModifierSelect(curr.find('[name^="sp_criteria_field"]'));
curr.find('[name^="sp_criteria_modifier"]').val(modifier);
var criteria_value = next.find('[name^="sp_criteria_value"]').val();
curr.find('[name^="sp_criteria_value"]').val(criteria_value);
var id = curr.find('[name^="sp_criteria"]').attr('id');
var index = id.charAt(id.length-1);
/* if current and next row have the extra criteria value
* (for 'is in the range' modifier), then assign the next
* extra value to current and remove that element from
* next row
*/
if (curr.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled"
&& next.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled") {
var criteria_extra = next.find('[name^="sp_criteria_extra"]').val();
curr.find('[name^="sp_criteria_extra"]').val(criteria_extra);
disableAndHideExtraField(next.find(':first-child'), index+1);
/* if only the current row has the extra criteria value,
* then just remove the current row's extra criteria element
*/
} else if (curr.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled"
&& next.find('[name^="sp_criteria_extra"]').attr("disabled") == "disabled") {
disableAndHideExtraField(curr.find(':first-child'), index);
/* if only the next row has the extra criteria value,
* then add the extra criteria element to current row
* and assign next row's value to it
*/
} else if (next.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled") {
criteria_extra = next.find('[name^="sp_criteria_extra"]').val();
enableAndShowExtraField(curr.find(':first-child'), index);
curr.find('[name^="sp_criteria_extra"]').val(criteria_extra);
}
curr = next;
next = curr.next();
}
/* Disable the last visible row since it holds the values the user removed
* Reset the values to empty and resize the criteria value textbox
* in case the row had the extra criteria textbox
*/
item_to_hide = list.find('div:visible:last');
item_to_hide.children().attr('disabled', 'disabled');
item_to_hide.find('[name^="sp_criteria_field"]').val(0).end()
.find('[name^="sp_criteria_modifier"]').val(0).end()
.find('[name^="sp_criteria_value"]').val('');
sizeTextBoxes(item_to_hide.find('[name^="sp_criteria_value"]'), 'sp_extra_input_text', 'sp_input_text');
item_to_hide.hide();
list.next().show();
// always put '+' button on the last enabled row
appendAddButton();
// remove the 'x' button if only one row is enabled
removeButtonCheck();
});
form.find('button[id="save_button"]').live("click", function(event){
var playlist_type = form.find('input:radio[name=sp_type]:checked').val(),
data = $('form').serializeArray(),
save_action = 'Playlist/smart-playlist-criteria-save',
playlist_id = $('input[id="pl_id"]').val();
$.post(save_action, {format: "json", data: data, pl_id: playlist_id}, function(data){
callback(data, "save");
});
});
form.find('button[id="generate_button"]').live("click", function(event){
var playlist_type = form.find('input:radio[name=sp_type]:checked').val(),
data = $('form').serializeArray(),
generate_action = 'Playlist/smart-playlist-generate',
playlist_id = $('input[id="pl_id"]').val();
$.post(generate_action, {format: "json", data: data, pl_id: playlist_id}, function(data){
callback(data, "generate");
});
});
form.find('button[id="shuffle_button"]').live("click", function(event){
var playlist_type = form.find('input:radio[name=sp_type]:checked').val(),
data = $('form').serializeArray(),
shuffle_action = 'Playlist/smart-playlist-shuffle',
playlist_id = $('input[id="pl_id"]').val();
$.post(shuffle_action, {format: "json", data: data, pl_id: playlist_id}, function(data){
callback(data, "shuffle");
});
});
form.find('dd[id="sp_type-element"]').live("change", function(){
setupUI();
});
form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"])').live("change", function(){
var index_name = $(this).attr('id'),
index_num = index_name.charAt(index_name.length-1);
// disable extra field and hide the span
disableAndHideExtraField($(this), index_num);
populateModifierSelect(this);
});
form.find('select[id^="sp_criteria_modifier"]').live("change", function(){
var criteria_value = $(this).next(),
index_name = criteria_value.attr('id'),
index_num = index_name.charAt(index_name.length-1);
if ($(this).val() == 'is in the range') {
enableAndShowExtraField(criteria_value, index_num);
} else {
disableAndHideExtraField(criteria_value, index_num);
}
});
setupUI();
appendAddButton();
removeButtonCheck();
}
function setupUI() {
var playlist_type = $('input:radio[name=sp_type]:checked').val();
if (playlist_type == "0") {
$('button[id="generate_button"]').show();
$('button[id="shuffle_button"]').show();
$('#spl_sortable').unblock();
$('#spl_sortable').css("position", "static");
} else {
$('button[id="generate_button"]').hide();
$('button[id="shuffle_button"]').hide();
$('#spl_sortable').block({
message: "",
theme: true,
applyPlatformOpacityRules: false
});
}
}
function enableAndShowExtraField(valEle, index) {
var spanExtra = valEle.nextAll("#extra_criteria");
spanExtra.children('#sp_criteria_extra_'+index).removeAttr("disabled");
spanExtra.show();
//make value input smaller since we have extra element now
var criteria_val = $('#sp_criteria_value_'+index);
sizeTextBoxes(criteria_val, 'sp_input_text', 'sp_extra_input_text');
}
function disableAndHideExtraField(valEle, index) {
var spanExtra = valEle.nextAll("#extra_criteria");
spanExtra.children('#sp_criteria_extra_'+index).val("").attr("disabled", "disabled");
spanExtra.hide();
//make value input larger since we don't have extra field now
var criteria_value = $('#sp_criteria_value_'+index);
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
}
function sizeTextBoxes(ele, classToRemove, classToAdd) {
var form = $('#smart-playlist-form');
if (ele.hasClass(classToRemove)) {
ele.removeClass(classToRemove).addClass(classToAdd);
}
}
function populateModifierSelect(e) {
var criteria = $(e).val(),
criteria_type = criteriaTypes[criteria],
div = $(e);
$(e).next().children().remove();
if (criteria_type == 's') {
$.each(stringCriteriaOptions, function(key, value){
div.next().append($('<option></option>')
.attr('value', key)
.text(value));
});
} else {
$.each(numericCriteriaOptions, function(key, value){
div.next().append($('<option></option>')
.attr('value', key)
.text(value));
});
}
}
function callback(data, type) {
var form = $('#smart-playlist-form'),
json = $.parseJSON(data);
form.find('span[class="errors sp-errors"]').remove();
if (json.result == "1") {
form.find('.success').hide();
$.each(json.errors, function(index, error){
$.each(error.msg, function(index, message){
$('#'+error.element).parent().append("<span class='errors sp-errors'>"+message+"</span>");
});
});
} else {
if (type == 'shuffle' || type == 'generate') {
AIRTIME.playlist.fnOpenPlaylist(json);
form = $('#smart-playlist-form');
if (type == 'shuffle') {
form.find('.success').text('Playlist shuffled');
} else {
form.find('.success').text('Smart playlist generated');
}
form.find('.success').show();
form.find('#smart_playlist_options').removeClass("closed");
} else {
form.find('.success').text('Criteria saved');
form.find('.success').show();
}
setTimeout('removeSuccessMsg()', 5000);
}
}
function removeSuccessMsg() {
var form = $('#smart-playlist-form');
form.find('.success').text('');
form.find('.success').hide();
}
function appendAddButton() {
var rows = $('#smart-playlist-form');
var add_button = "<a class='ui-button sp-ui-button-icon-only criteria_add'>" +
"<span class='ui-icon ui-icon-plusthick'></span></a>";
rows.find('.criteria_add').remove();
if (rows.find('select[name^="sp_criteria_field"]:enabled').length > 1) {
rows.find('select[name^="sp_criteria_field"]:enabled:last')
.siblings('a[id^="criteria_remove"]')
.after(add_button);
} else {
rows.find('select[name^="sp_criteria_field"]:enabled')
.siblings('span[id="extra_criteria"]')
.after(add_button);
}
}
function removeButtonCheck() {
var rows = $('#smart-playlist-form');
if (rows.find('select[name^="sp_criteria_field"]:enabled').length == 1) {
rows.find('a[id="criteria_remove_0"]').attr('disabled', 'disabled');
rows.find('a[id="criteria_remove_0"]').hide();
} else {
rows.find('a[id="criteria_remove_0"]').removeAttr('disabled');
rows.find('a[id="criteria_remove_0"]').show();
}
}
var criteriaTypes = {
0 : "",
"album_title" : "s",
"artist_name" : "s",
"bit_rate" : "n",
"bpm" : "n",
"comments" : "s",
"composer" : "s",
"conductor" : "s",
"utime" : "n",
"mtime" : "n",
"disc_number" : "n",
"genre" : "s",
"isrc_number" : "s",
"label" : "s",
"language" : "s",
"length" : "n",
"lyricist" : "s",
"mood" : "s",
"name" : "s",
"orchestra" : "s",
"radio_station_name" : "s",
"rating" : "n",
"sample_rate" : "n",
"soundcloud_id" : "n",
"track_title" : "s",
"track_num" : "n",
"year" : "n"
};
var stringCriteriaOptions = {
"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"
};
var numericCriteriaOptions = {
"0" : "Select modifier",
"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"
};