From 5a105ff4c8441cd41540bf25edd4e37de01fcee4 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sat, 2 Apr 2011 16:33:45 -0400 Subject: [PATCH 01/12] CC-2110 : Soundcloud file metadata added all defaults or ways to input a default for soundcloud metadata. --- application/controllers/ApiController.php | 6 ++- .../controllers/PreferenceController.php | 5 +- .../controllers/ScheduleController.php | 6 +++ application/forms/Preferences.php | 50 +++++++++++++++++++ application/models/Preference.php | 24 +++++++++ application/models/Soundcloud.php | 29 ++++++++++- python_apps/show-recorder/testrecordscript.py | 16 +++--- 7 files changed, 126 insertions(+), 10 deletions(-) diff --git a/application/controllers/ApiController.php b/application/controllers/ApiController.php index 00d1b8e9e..06e4ffe35 100644 --- a/application/controllers/ApiController.php +++ b/application/controllers/ApiController.php @@ -276,6 +276,8 @@ class ApiController extends Zend_Controller_Action $file = StoredFile::uploadFile($upload_dir); $show_instance = $this->_getParam('show_instance'); + $show_name = $this->_getParam('show_name'); + $start_time = $this->_getParam('start_time'); $show_inst = new ShowInstance($show_instance); $show_inst->setRecordedFile($file->getId()); @@ -288,9 +290,11 @@ class ApiController extends Zend_Controller_Action $description = $show->getDescription(); $hosts = $show->getHosts(); + $tags = array_merge($hosts, array($show_name)); + try { $soundcloud = new ATSoundcloud(); - $soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $hosts); + $soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $tags, $start_time); $show_inst->setSoundCloudFileId($soundcloud_id); break; } diff --git a/application/controllers/PreferenceController.php b/application/controllers/PreferenceController.php index 46d82054f..c3a40b3e3 100644 --- a/application/controllers/PreferenceController.php +++ b/application/controllers/PreferenceController.php @@ -34,7 +34,10 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetDoSoundCloudUpload($values["UseSoundCloud"]); Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]); Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]); - Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]); + Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]); + Application_Model_Preference::SetSoundCloudGenre($values["SoundCloudGenre"]); + Application_Model_Preference::SetSoundCloudTrackType($values["SoundCloudTrackType"]); + Application_Model_Preference::SetSoundCloudLicense($values["SoundCloudLicense"]); $this->view->statusMsg = "
Preferences updated.
"; } diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 6f14ae10a..f6f4ee924 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -409,6 +409,9 @@ class ScheduleController extends Zend_Controller_Action $rebroad = $formRebroadcast->checkReliantFields($data); } } + else { + $rebroad = 1; + } } else { $formRebroadcast->reset(); @@ -422,6 +425,9 @@ class ScheduleController extends Zend_Controller_Action $rebroadAb = $formAbsoluteRebroadcast->checkReliantFields($data); } } + else { + $rebroadAb = 1; + } } $who = $formWho->isValid($data); diff --git a/application/forms/Preferences.php b/application/forms/Preferences.php index a319476a2..edb69b1b6 100644 --- a/application/forms/Preferences.php +++ b/application/forms/Preferences.php @@ -82,6 +82,56 @@ class Application_Form_Preferences extends Zend_Form 'value' => Application_Model_Preference::GetSoundCloudTags() )); + //SoundCloud default genre + $this->addElement('text', 'SoundCloudGenre', array( + 'class' => 'input_text', + 'label' => 'Default Genre:', + 'required' => false, + 'filters' => array('StringTrim'), + 'value' => Application_Model_Preference::GetSoundCloudGenre() + )); + + $select = new Zend_Form_Element_Select('SoundCloudTrackType'); + $select->setLabel('Default Track Type:'); + $select->setAttrib('class', 'input_select'); + $select->setMultiOptions(array( + "" => "", + "original" => "Original", + "remix" => "Remix", + "live" => "Live", + "recording" => "Recording", + "spoken" => "Spoken", + "podcast" => "Podcast", + "demo" => "Demo", + "in progress" => "Work in progress", + "stem" => "Stem", + "loop" => "Loop", + "sound effect" => "Sound Effect", + "sample" => "One Shot Sample", + "other" => "Other" + )); + $select->setRequired(false); + $select->setValue(Application_Model_Preference::GetSoundCloudTrackType()); + $this->addElement($select); + + $select = new Zend_Form_Element_Select('SoundCloudLicense'); + $select->setLabel('Default License:'); + $select->setAttrib('class', 'input_select'); + $select->setMultiOptions(array( + "" => "", + "no-rights-reserved" => "The work is in the public domain", + "all-rights-reserved" => "All rights are reserved", + "cc-by" => "Creative Commons Attribution", + "cc-by-nc" => "Creative Commons Attribution Noncommercial", + "cc-by-nd" => "Creative Commons Attribution No Derivative Works", + "cc-by-sa" => "Creative Commons Attribution Share Alike", + "cc-by-nc-nd" => "Creative Commons Attribution Noncommercial Non Derivate Works", + "cc-by-nc-sa" => "Creative Commons Attribution Noncommercial Share Alike" + )); + $select->setRequired(false); + $select->setValue(Application_Model_Preference::GetSoundCloudLicense()); + $this->addElement($select); + $this->addElement('submit', 'submit', array( 'class' => 'ui-button ui-state-default', 'ignore' => true, diff --git a/application/models/Preference.php b/application/models/Preference.php index b234a36b9..0ca748ebb 100644 --- a/application/models/Preference.php +++ b/application/models/Preference.php @@ -133,6 +133,30 @@ class Application_Model_Preference return Application_Model_Preference::GetValue("soundcloud_tags"); } + public static function SetSoundCloudGenre($genre) { + Application_Model_Preference::SetValue("soundcloud_genre", $genre); + } + + public static function GetSoundCloudGenre() { + return Application_Model_Preference::GetValue("soundcloud_genre"); + } + + public static function SetSoundCloudTrackType($track_type) { + Application_Model_Preference::SetValue("soundcloud_tracktype", $track_type); + } + + public static function GetSoundCloudTrackType() { + return Application_Model_Preference::GetValue("soundcloud_tracktype"); + } + + public static function SetSoundCloudLicense($license) { + Application_Model_Preference::SetValue("soundcloud_license", $license); + } + + public static function GetSoundCloudLicense() { + return Application_Model_Preference::GetValue("soundcloud_license"); + } + public static function SetAllow3rdPartyApi($bool) { Application_Model_Preference::SetValue("third_party_api", $bool); } diff --git a/application/models/Soundcloud.php b/application/models/Soundcloud.php index 6f5ca58f2..1b0d29a39 100644 --- a/application/models/Soundcloud.php +++ b/application/models/Soundcloud.php @@ -28,7 +28,7 @@ class ATSoundcloud { return $token; } - public function uploadTrack($filepath, $filename, $description, $tags=array()) + public function uploadTrack($filepath, $filename, $description, $tags=array(), $release=null) { if($this->getToken()) { @@ -50,6 +50,33 @@ class ATSoundcloud { ); + if(isset($release)) { + $release = str_replace(" ", "-", $release); + $release = str_replace(":", "-", $release); + + //YYYY-MM-DD-HH-mm-SS + $release = explode("-", $release); + + $track_data['track[release_year]'] = $release[0]; + $track_data['track[release_month]'] = $release[1]; + $track_data['track[release_day]'] = $release[2]; + } + + $genre = Application_Model_Preference::GetSoundCloudGenre(); + if ($genre != "") { + $track_data['track[genre]'] = $genre; + } + + $track_type = Application_Model_Preference::GetSoundCloudTrackType(); + if ($track_type != "") { + $track_data['track[track_type]'] = $track_type; + } + + $license = Application_Model_Preference::GetSoundCloudLicense(); + if ($license != "") { + $track_data['track[license]'] = $license; + } + $response = json_decode( $this->_soundcloud->post('tracks', $track_data), true diff --git a/python_apps/show-recorder/testrecordscript.py b/python_apps/show-recorder/testrecordscript.py index f76211a1c..691550aec 100644 --- a/python_apps/show-recorder/testrecordscript.py +++ b/python_apps/show-recorder/testrecordscript.py @@ -47,18 +47,20 @@ def getDateTimeObj(time): class ShowRecorder(Thread): - def __init__ (self, show_instance, filelength, filename, filetype): + def __init__ (self, show_instance, filelength, show_name, start_time, filetype): Thread.__init__(self) self.api_client = api_client.api_client_factory(config) self.filelength = filelength - self.filename = filename + self.show_name = show_name + self.start_time = start_time self.filetype = filetype self.show_instance = show_instance def record_show(self): length = str(self.filelength)+".0" - filename = self.filename.replace(" ", "-") + filename = self.show_name+" "+self.start_time + filename = filename.replace(" ", "-") filepath = "%s%s.%s" % (config["base_recorded_files"], filename, self.filetype) command = "ecasound -i alsa -o %s -t:%s" % (filepath, length) @@ -82,7 +84,8 @@ class ShowRecorder(Thread): # headers contains the necessary Content-Type and Content-Length # datagen is a generator object that yields the encoded parameters - datagen, headers = multipart_encode({"file": open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance}) + datagen, headers = multipart_encode({"file": open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance, \ + 'show_name': self.show_name, 'start_time': self.start_time}) self.api_client.upload_recorded_show(datagen, headers) @@ -134,9 +137,8 @@ class Record(): show_length = self.shows_to_record[start_time][0] show_instance = self.shows_to_record[start_time][1] show_name = self.shows_to_record[start_time][2] - filename = show_name+"-"+start_time - - show = ShowRecorder(show_instance, show_length.seconds, filename, filetype="mp3") + + show = ShowRecorder(show_instance, show_length.seconds, show_name, start_time, filetype="mp3", ) show.start() #remove show from shows to record. From b97e79773b0e232eea2c9c72f3652a9973b75d0e Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sat, 2 Apr 2011 17:09:37 -0400 Subject: [PATCH 02/12] CC-2110 : Soundcloud file metadata added show genre column, this is used instead of soundcloud default genre if set. --- application/controllers/ApiController.php | 9 +- application/forms/AddShowWhat.php | 10 ++- application/models/Shows.php | 7 ++ application/models/Soundcloud.php | 13 ++- .../models/airtime/map/CcShowTableMap.php | 1 + application/models/airtime/om/BaseCcShow.php | 82 +++++++++++++++---- .../models/airtime/om/BaseCcShowPeer.php | 31 ++++--- .../models/airtime/om/BaseCcShowQuery.php | 26 ++++++ build/schema.xml | 1 + build/sql/schema.sql | 1 + .../Version20110402164819.php | 28 +++++++ python_apps/show-recorder/testrecordscript.py | 3 +- 12 files changed, 174 insertions(+), 38 deletions(-) create mode 100644 install/DoctrineMigrations/Version20110402164819.php diff --git a/application/controllers/ApiController.php b/application/controllers/ApiController.php index 06e4ffe35..04368b94c 100644 --- a/application/controllers/ApiController.php +++ b/application/controllers/ApiController.php @@ -276,11 +276,12 @@ class ApiController extends Zend_Controller_Action $file = StoredFile::uploadFile($upload_dir); $show_instance = $this->_getParam('show_instance'); - $show_name = $this->_getParam('show_name'); - $start_time = $this->_getParam('start_time'); - $show_inst = new ShowInstance($show_instance); + $show_inst->setRecordedFile($file->getId()); + $show_name = $show_inst->getName(); + $show_genre = $show_inst->getGenre(); + $show_start_time = $show_inst->getShowStart(); if(Application_Model_Preference::GetDoSoundCloudUpload()) { @@ -294,7 +295,7 @@ class ApiController extends Zend_Controller_Action try { $soundcloud = new ATSoundcloud(); - $soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $tags, $start_time); + $soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $tags, $show_start_time, $show_genre); $show_inst->setSoundCloudFileId($soundcloud_id); break; } diff --git a/application/forms/AddShowWhat.php b/application/forms/AddShowWhat.php index 74e7b0dcc..2a252d8c1 100644 --- a/application/forms/AddShowWhat.php +++ b/application/forms/AddShowWhat.php @@ -21,7 +21,15 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm 'required' => false, 'filters' => array('StringTrim'), 'validators' => array('NotEmpty') - )); + )); + + // Add genre element + $this->addElement('text', 'add_show_genre', array( + 'label' => 'Genre:', + 'class' => 'input_text', + 'required' => false, + 'filters' => array('StringTrim') + )); // Add the description element $this->addElement('textarea', 'add_show_description', array( diff --git a/application/models/Shows.php b/application/models/Shows.php index 7daf2fc63..8db07c8ec 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -155,6 +155,7 @@ class Show { $show->setDbName($data['add_show_name']); $show->setDbDescription($data['add_show_description']); $show->setDbUrl($data['add_show_url']); + $show->setDbGenre($data['add_show_genre']); $show->setDbColor($data['add_show_color']); $show->setDbBackgroundColor($data['add_show_background_color']); $show->save(); @@ -616,6 +617,12 @@ class ShowInstance { return $show->getDbName(); } + public function getGenre() + { + $show = CcShowQuery::create()->findPK($this->getShowId()); + return $show->getDbGenre(); + } + public function getShowStart() { $showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); diff --git a/application/models/Soundcloud.php b/application/models/Soundcloud.php index 1b0d29a39..bc9f416d1 100644 --- a/application/models/Soundcloud.php +++ b/application/models/Soundcloud.php @@ -28,7 +28,7 @@ class ATSoundcloud { return $token; } - public function uploadTrack($filepath, $filename, $description, $tags=array(), $release=null) + public function uploadTrack($filepath, $filename, $description, $tags=array(), $release=null, $genre=null) { if($this->getToken()) { @@ -61,11 +61,16 @@ class ATSoundcloud { $track_data['track[release_month]'] = $release[1]; $track_data['track[release_day]'] = $release[2]; } - - $genre = Application_Model_Preference::GetSoundCloudGenre(); - if ($genre != "") { + + if (isset($genre) && $genre != "") { $track_data['track[genre]'] = $genre; } + else { + $default_genre = Application_Model_Preference::GetSoundCloudTrackType(); + if ($genre != "") { + $track_data['track[genre]'] = $default_genre; + } + } $track_type = Application_Model_Preference::GetSoundCloudTrackType(); if ($track_type != "") { diff --git a/application/models/airtime/map/CcShowTableMap.php b/application/models/airtime/map/CcShowTableMap.php index 6d466e7a2..b558b6e93 100644 --- a/application/models/airtime/map/CcShowTableMap.php +++ b/application/models/airtime/map/CcShowTableMap.php @@ -41,6 +41,7 @@ class CcShowTableMap extends TableMap { $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); $this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, ''); $this->addColumn('URL', 'DbUrl', 'VARCHAR', false, 255, ''); + $this->addColumn('GENRE', 'DbGenre', 'VARCHAR', false, 255, ''); $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null); $this->addColumn('COLOR', 'DbColor', 'VARCHAR', false, 6, null); $this->addColumn('BACKGROUND_COLOR', 'DbBackgroundColor', 'VARCHAR', false, 6, null); diff --git a/application/models/airtime/om/BaseCcShow.php b/application/models/airtime/om/BaseCcShow.php index 7c1ec043d..b2ab6b257 100644 --- a/application/models/airtime/om/BaseCcShow.php +++ b/application/models/airtime/om/BaseCcShow.php @@ -44,6 +44,13 @@ abstract class BaseCcShow extends BaseObject implements Persistent */ protected $url; + /** + * The value for the genre field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $genre; + /** * The value for the description field. * @var string @@ -106,6 +113,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent { $this->name = ''; $this->url = ''; + $this->genre = ''; } /** @@ -148,6 +156,16 @@ abstract class BaseCcShow extends BaseObject implements Persistent return $this->url; } + /** + * Get the [genre] column value. + * + * @return string + */ + public function getDbGenre() + { + return $this->genre; + } + /** * Get the [description] column value. * @@ -238,6 +256,26 @@ abstract class BaseCcShow extends BaseObject implements Persistent return $this; } // setDbUrl() + /** + * Set the value of [genre] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbGenre($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->genre !== $v || $this->isNew()) { + $this->genre = $v; + $this->modifiedColumns[] = CcShowPeer::GENRE; + } + + return $this; + } // setDbGenre() + /** * Set the value of [description] column. * @@ -316,6 +354,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent return false; } + if ($this->genre !== '') { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -341,9 +383,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; $this->url = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->color = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->background_color = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->genre = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->color = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->background_color = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; $this->resetModified(); $this->setNew(false); @@ -352,7 +395,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 6; // 6 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 7; // 7 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcShow object", $e); @@ -733,12 +776,15 @@ abstract class BaseCcShow extends BaseObject implements Persistent return $this->getDbUrl(); break; case 3: - return $this->getDbDescription(); + return $this->getDbGenre(); break; case 4: - return $this->getDbColor(); + return $this->getDbDescription(); break; case 5: + return $this->getDbColor(); + break; + case 6: return $this->getDbBackgroundColor(); break; default: @@ -767,9 +813,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent $keys[0] => $this->getDbId(), $keys[1] => $this->getDbName(), $keys[2] => $this->getDbUrl(), - $keys[3] => $this->getDbDescription(), - $keys[4] => $this->getDbColor(), - $keys[5] => $this->getDbBackgroundColor(), + $keys[3] => $this->getDbGenre(), + $keys[4] => $this->getDbDescription(), + $keys[5] => $this->getDbColor(), + $keys[6] => $this->getDbBackgroundColor(), ); return $result; } @@ -811,12 +858,15 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->setDbUrl($value); break; case 3: - $this->setDbDescription($value); + $this->setDbGenre($value); break; case 4: - $this->setDbColor($value); + $this->setDbDescription($value); break; case 5: + $this->setDbColor($value); + break; + case 6: $this->setDbBackgroundColor($value); break; } // switch() @@ -846,9 +896,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setDbUrl($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbColor($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbBackgroundColor($arr[$keys[5]]); + if (array_key_exists($keys[3], $arr)) $this->setDbGenre($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbDescription($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbColor($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbBackgroundColor($arr[$keys[6]]); } /** @@ -863,6 +914,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent if ($this->isColumnModified(CcShowPeer::ID)) $criteria->add(CcShowPeer::ID, $this->id); if ($this->isColumnModified(CcShowPeer::NAME)) $criteria->add(CcShowPeer::NAME, $this->name); if ($this->isColumnModified(CcShowPeer::URL)) $criteria->add(CcShowPeer::URL, $this->url); + if ($this->isColumnModified(CcShowPeer::GENRE)) $criteria->add(CcShowPeer::GENRE, $this->genre); if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description); if ($this->isColumnModified(CcShowPeer::COLOR)) $criteria->add(CcShowPeer::COLOR, $this->color); if ($this->isColumnModified(CcShowPeer::BACKGROUND_COLOR)) $criteria->add(CcShowPeer::BACKGROUND_COLOR, $this->background_color); @@ -929,6 +981,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent { $copyObj->setDbName($this->name); $copyObj->setDbUrl($this->url); + $copyObj->setDbGenre($this->genre); $copyObj->setDbDescription($this->description); $copyObj->setDbColor($this->color); $copyObj->setDbBackgroundColor($this->background_color); @@ -1526,6 +1579,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->id = null; $this->name = null; $this->url = null; + $this->genre = null; $this->description = null; $this->color = null; $this->background_color = null; diff --git a/application/models/airtime/om/BaseCcShowPeer.php b/application/models/airtime/om/BaseCcShowPeer.php index 15426809c..110c08101 100644 --- a/application/models/airtime/om/BaseCcShowPeer.php +++ b/application/models/airtime/om/BaseCcShowPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcShowPeer { const TM_CLASS = 'CcShowTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 6; + const NUM_COLUMNS = 7; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -40,6 +40,9 @@ abstract class BaseCcShowPeer { /** the column name for the URL field */ const URL = 'cc_show.URL'; + /** the column name for the GENRE field */ + const GENRE = 'cc_show.GENRE'; + /** the column name for the DESCRIPTION field */ const DESCRIPTION = 'cc_show.DESCRIPTION'; @@ -65,12 +68,12 @@ abstract class BaseCcShowPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbDescription', 'DbColor', 'DbBackgroundColor', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbDescription', 'dbColor', 'dbBackgroundColor', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'description', 'color', 'background_color', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::GENRE, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -80,12 +83,12 @@ abstract class BaseCcShowPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbDescription' => 3, 'DbColor' => 4, 'DbBackgroundColor' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbDescription' => 3, 'dbColor' => 4, 'dbBackgroundColor' => 5, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::DESCRIPTION => 3, self::COLOR => 4, self::BACKGROUND_COLOR => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'DESCRIPTION' => 3, 'COLOR' => 4, 'BACKGROUND_COLOR' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'description' => 3, 'color' => 4, 'background_color' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::GENRE => 3, self::DESCRIPTION => 4, self::COLOR => 5, self::BACKGROUND_COLOR => 6, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -160,6 +163,7 @@ abstract class BaseCcShowPeer { $criteria->addSelectColumn(CcShowPeer::ID); $criteria->addSelectColumn(CcShowPeer::NAME); $criteria->addSelectColumn(CcShowPeer::URL); + $criteria->addSelectColumn(CcShowPeer::GENRE); $criteria->addSelectColumn(CcShowPeer::DESCRIPTION); $criteria->addSelectColumn(CcShowPeer::COLOR); $criteria->addSelectColumn(CcShowPeer::BACKGROUND_COLOR); @@ -167,6 +171,7 @@ abstract class BaseCcShowPeer { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.NAME'); $criteria->addSelectColumn($alias . '.URL'); + $criteria->addSelectColumn($alias . '.GENRE'); $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.COLOR'); $criteria->addSelectColumn($alias . '.BACKGROUND_COLOR'); diff --git a/application/models/airtime/om/BaseCcShowQuery.php b/application/models/airtime/om/BaseCcShowQuery.php index 27f3ab381..10f9dac11 100644 --- a/application/models/airtime/om/BaseCcShowQuery.php +++ b/application/models/airtime/om/BaseCcShowQuery.php @@ -9,6 +9,7 @@ * @method CcShowQuery orderByDbId($order = Criteria::ASC) Order by the id column * @method CcShowQuery orderByDbName($order = Criteria::ASC) Order by the name column * @method CcShowQuery orderByDbUrl($order = Criteria::ASC) Order by the url column + * @method CcShowQuery orderByDbGenre($order = Criteria::ASC) Order by the genre column * @method CcShowQuery orderByDbDescription($order = Criteria::ASC) Order by the description column * @method CcShowQuery orderByDbColor($order = Criteria::ASC) Order by the color column * @method CcShowQuery orderByDbBackgroundColor($order = Criteria::ASC) Order by the background_color column @@ -16,6 +17,7 @@ * @method CcShowQuery groupByDbId() Group by the id column * @method CcShowQuery groupByDbName() Group by the name column * @method CcShowQuery groupByDbUrl() Group by the url column + * @method CcShowQuery groupByDbGenre() Group by the genre column * @method CcShowQuery groupByDbDescription() Group by the description column * @method CcShowQuery groupByDbColor() Group by the color column * @method CcShowQuery groupByDbBackgroundColor() Group by the background_color column @@ -46,6 +48,7 @@ * @method CcShow findOneByDbId(int $id) Return the first CcShow filtered by the id column * @method CcShow findOneByDbName(string $name) Return the first CcShow filtered by the name column * @method CcShow findOneByDbUrl(string $url) Return the first CcShow filtered by the url column + * @method CcShow findOneByDbGenre(string $genre) Return the first CcShow filtered by the genre column * @method CcShow findOneByDbDescription(string $description) Return the first CcShow filtered by the description column * @method CcShow findOneByDbColor(string $color) Return the first CcShow filtered by the color column * @method CcShow findOneByDbBackgroundColor(string $background_color) Return the first CcShow filtered by the background_color column @@ -53,6 +56,7 @@ * @method array findByDbId(int $id) Return CcShow objects filtered by the id column * @method array findByDbName(string $name) Return CcShow objects filtered by the name column * @method array findByDbUrl(string $url) Return CcShow objects filtered by the url column + * @method array findByDbGenre(string $genre) Return CcShow objects filtered by the genre column * @method array findByDbDescription(string $description) Return CcShow objects filtered by the description column * @method array findByDbColor(string $color) Return CcShow objects filtered by the color column * @method array findByDbBackgroundColor(string $background_color) Return CcShow objects filtered by the background_color column @@ -226,6 +230,28 @@ abstract class BaseCcShowQuery extends ModelCriteria return $this->addUsingAlias(CcShowPeer::URL, $dbUrl, $comparison); } + /** + * Filter the query on the genre column + * + * @param string $dbGenre 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 CcShowQuery The current query, for fluid interface + */ + public function filterByDbGenre($dbGenre = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbGenre)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbGenre)) { + $dbGenre = str_replace('*', '%', $dbGenre); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcShowPeer::GENRE, $dbGenre, $comparison); + } + /** * Filter the query on the description column * diff --git a/build/schema.xml b/build/schema.xml index d08f9387f..ac1151636 100644 --- a/build/schema.xml +++ b/build/schema.xml @@ -118,6 +118,7 @@ + diff --git a/build/sql/schema.sql b/build/sql/schema.sql index 6bdc5351d..6231f20e5 100644 --- a/build/sql/schema.sql +++ b/build/sql/schema.sql @@ -142,6 +142,7 @@ CREATE TABLE "cc_show" "id" serial NOT NULL, "name" VARCHAR(255) default '' NOT NULL, "url" VARCHAR(255) default '', + "genre" VARCHAR(255) default '', "description" VARCHAR(512), "color" VARCHAR(6), "background_color" VARCHAR(6), diff --git a/install/DoctrineMigrations/Version20110402164819.php b/install/DoctrineMigrations/Version20110402164819.php new file mode 100644 index 000000000..d4e84145c --- /dev/null +++ b/install/DoctrineMigrations/Version20110402164819.php @@ -0,0 +1,28 @@ +getTable('cc_show'); + + $show_table->addColumn('genre', 'string', array('notnull' => 0, 'length' => 255, 'default' => "")); + //end cc_show modifications + + } + + public function down(Schema $schema) + { + //start cc_show modifications + $show_table = $schema->getTable('cc_show'); + + $show_table->dropColumn('genre'); + //end cc_show modifications + } +} diff --git a/python_apps/show-recorder/testrecordscript.py b/python_apps/show-recorder/testrecordscript.py index 691550aec..7e1f7ef7a 100644 --- a/python_apps/show-recorder/testrecordscript.py +++ b/python_apps/show-recorder/testrecordscript.py @@ -84,8 +84,7 @@ class ShowRecorder(Thread): # headers contains the necessary Content-Type and Content-Length # datagen is a generator object that yields the encoded parameters - datagen, headers = multipart_encode({"file": open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance, \ - 'show_name': self.show_name, 'start_time': self.start_time}) + datagen, headers = multipart_encode({"file": open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance}) self.api_client.upload_recorded_show(datagen, headers) From 108b518b1a774bc17e5fb905f3d2bd62a0e62ef0 Mon Sep 17 00:00:00 2001 From: lukabazuka Date: Sun, 3 Apr 2011 17:24:19 +0200 Subject: [PATCH 03/12] reverted jQuery CSS issue CC-2139 --- public/css/redmond/jquery-ui-1.8.8.custom.css | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/public/css/redmond/jquery-ui-1.8.8.custom.css b/public/css/redmond/jquery-ui-1.8.8.custom.css index 64086d9c2..1de938884 100644 --- a/public/css/redmond/jquery-ui-1.8.8.custom.css +++ b/public/css/redmond/jquery-ui-1.8.8.custom.css @@ -1085,7 +1085,7 @@ button.ui-button-icons-only { padding-right: 2.1em; } /* no icon support for input elements, provide padding by default */ -input.ui-button, button.ui-button { +input.ui-button { padding: .4em 1em; } /*button icon element(s) */ @@ -1093,6 +1093,7 @@ input.ui-button, button.ui-button { position: absolute; top: 50%; margin-top: -8px; + left: 0.2em; } .ui-button-icon-only .ui-icon { left: 50%; @@ -1117,10 +1118,12 @@ input.ui-button, button.ui-button { } /* workarounds */ -/*button.ui-button::-moz-focus-inner { -border: 0; -padding: 0; -}*/ + +button.ui-button.::-moz-focus-inner { + border: 0; + padding: 0; +} + /* reset extra padding in Firefox */ /* * jQuery UI Dialog 1.8.6 @@ -1514,4 +1517,4 @@ padding: 0; .ui-datepicker { display:none; -} +} \ No newline at end of file From 6cbbd62a3cc55a3725b5f87a7f4a6ea1738c0853 Mon Sep 17 00:00:00 2001 From: lukabazuka Date: Sun, 3 Apr 2011 19:15:49 +0200 Subject: [PATCH 04/12] added styles for the redesigned preferences screen. Issue CC-2145 Signed-off-by: lukabazuka --- public/css/styles.css | 49 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/public/css/styles.css b/public/css/styles.css index 4b05fb512..4ef4decee 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -1269,9 +1269,8 @@ div.success{ margin: 0 0 8px 0; } #schedule-add-show .button-bar.bottom { - margin: 16px 0 0 0; + margin: 16px 0 0; } - .schedule { text-align:left; height:38px; @@ -1541,3 +1540,49 @@ div.success{ .medium-icon.finishedplaying { background:url(images/icon_finishedplaying_m.png) no-repeat 0 0; } +.preferences { + width: 500px; +} + +dt.block-display, dd.block-display { + display: block; + float: none; + margin-left: 0; + padding-left: 0; +} +.preferences dt.block-display, .preferences dd.block-display { + padding: 0 0 5px 0; +} +.preferences dd.block-display { + margin-bottom:4px; +} +.preferences dd.block-display:last-child { + margin-bottom:0; +} +.simple-formblock dd.block-display { + width: 100%; +} +.preferences input[type="radio"] { + margin:0; +} +.preferences label input[type="radio"] { + margin:0 1px 0 0; +} +.preferences label input[type="checkbox"] { + margin:0 5px 0 0; +} +dd.radio-inline-list, .preferences dd.radio-inline-list { + margin-bottom:6px; +} +.radio-inline-list label { + margin-right:12px; +} +.preferences.simple-formblock dd.block-display { + width: 100%; +} +.preferences dd.block-display .input_select { + width: 100%; +} +.preferences dd.block-display .input_text_area, .preferences dd.block-display .input_text { + width: 99.5%; +} \ No newline at end of file From a28d8ce30574449a5208f8326923082585956dcb Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sun, 3 Apr 2011 17:34:44 -0400 Subject: [PATCH 05/12] CC-2145 : Redesign & layout fixes for the Preferences screen view templates are all done, form works. just need javascript. --- .zfproject.xml | 2 + .../controllers/PreferenceController.php | 26 ++-- application/forms/GeneralPreferences.php | 65 ++++++++ application/forms/Preferences.php | 141 ++---------------- application/forms/SoundcloudPreferences.php | 115 ++++++++++++++ .../views/scripts/form/preferences.phtml | 14 ++ .../scripts/form/preferences_general.phtml | 50 +++++++ .../scripts/form/preferences_soundcloud.phtml | 46 ++++++ .../views/scripts/preference/index.phtml | 3 +- 9 files changed, 321 insertions(+), 141 deletions(-) create mode 100644 application/forms/GeneralPreferences.php create mode 100644 application/forms/SoundcloudPreferences.php create mode 100644 application/views/scripts/form/preferences.phtml create mode 100644 application/views/scripts/form/preferences_general.phtml create mode 100644 application/views/scripts/form/preferences_soundcloud.phtml diff --git a/.zfproject.xml b/.zfproject.xml index cb27bbd9d..48c691121 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -125,6 +125,8 @@ + + diff --git a/application/controllers/PreferenceController.php b/application/controllers/PreferenceController.php index c3a40b3e3..1dcb4bd38 100644 --- a/application/controllers/PreferenceController.php +++ b/application/controllers/PreferenceController.php @@ -22,22 +22,24 @@ class PreferenceController extends Zend_Controller_Action if (!$this->getRequest()->isPost()) { return $this->_forward('Preference/index'); } - + $form = new Application_Form_Preferences(); if ($form->isValid($request->getPost())) { $values = $form->getValues(); - Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view); - Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]); - Application_Model_Preference::SetStreamLabelFormat($values["streamFormat"]); - Application_Model_Preference::SetAllow3rdPartyApi($values["thirdPartyApi"]); - Application_Model_Preference::SetDoSoundCloudUpload($values["UseSoundCloud"]); - Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]); - Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]); - Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]); - Application_Model_Preference::SetSoundCloudGenre($values["SoundCloudGenre"]); - Application_Model_Preference::SetSoundCloudTrackType($values["SoundCloudTrackType"]); - Application_Model_Preference::SetSoundCloudLicense($values["SoundCloudLicense"]); + + Application_Model_Preference::SetHeadTitle($values["preferences_general"]["stationName"], $this->view); + Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]); + Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]); + Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]); + + Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]); + Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]); + Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]); + Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]); + Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]); + Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]); + Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]); $this->view->statusMsg = "
Preferences updated.
"; } diff --git a/application/forms/GeneralPreferences.php b/application/forms/GeneralPreferences.php new file mode 100644 index 000000000..4f3630f90 --- /dev/null +++ b/application/forms/GeneralPreferences.php @@ -0,0 +1,65 @@ +setDecorators(array( + array('ViewScript', array('viewScript' => 'form/preferences_general.phtml')) + )); + + //Station name + $this->addElement('text', 'stationName', array( + 'class' => 'input_text', + 'label' => 'Station Name:', + 'required' => true, + 'filters' => array('StringTrim'), + 'validators' => array('NotEmpty'), + 'value' => Application_Model_Preference::GetValue("station_name"), + 'decorators' => array( + 'ViewHelper' + ) + )); + + $defaultFade = Application_Model_Preference::GetDefaultFade(); + if($defaultFade == ""){ + $defaultFade = '00:00:00.000000'; + } + + //Default station fade + $this->addElement('text', 'stationDefaultFade', array( + 'class' => 'input_text', + 'label' => 'Default Fade:', + 'required' => false, + 'filters' => array('StringTrim'), + 'validators' => array(array('regex', false, + array('/^[0-2][0-3]:[0-5][0-9]:[0-5][0-9](\.\d{1,6})?$/', + 'messages' => 'enter a time 00:00:00{.000000}'))), + 'value' => $defaultFade, + 'decorators' => array( + 'ViewHelper' + ) + )); + + $stream_format = new Zend_Form_Element_Radio('streamFormat'); + $stream_format->setLabel('Stream Label:'); + $stream_format->setMultiOptions(array("Artist - Title", + "Show - Artist - Title", + "Station name - Show name")); + $stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat()); + $stream_format->setDecorators(array('ViewHelper')); + $this->addElement($stream_format); + + $third_party_api = new Zend_Form_Element_Radio('thirdPartyApi'); + $third_party_api->setLabel('Allow Remote Websites To Access Show Schedule Info'); + $third_party_api->setMultiOptions(array("Disabled", + "Enabled")); + $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); + $third_party_api->setDecorators(array('ViewHelper')); + $this->addElement($third_party_api); + } + + +} + diff --git a/application/forms/Preferences.php b/application/forms/Preferences.php index edb69b1b6..c86fa6492 100644 --- a/application/forms/Preferences.php +++ b/application/forms/Preferences.php @@ -6,139 +6,24 @@ class Application_Form_Preferences extends Zend_Form public function init() { $this->setAction('/Preference/update')->setMethod('post'); + + $this->setDecorators(array( + array('ViewScript', array('viewScript' => 'form/preferences.phtml')) + )); - //Station name - $this->addElement('text', 'stationName', array( - 'class' => 'input_text', - 'label' => 'Station Name:', - 'required' => true, - 'filters' => array('StringTrim'), - 'validators' => array('NotEmpty'), - 'value' => Application_Model_Preference::GetValue("station_name") - )); + $general_pref = new Application_Form_GeneralPreferences(); + $this->addSubForm($general_pref, 'preferences_general'); - $defaultFade = Application_Model_Preference::GetDefaultFade(); - if($defaultFade == ""){ - $defaultFade = '00:00:00.000000'; - } - - //Default station fade - $this->addElement('text', 'stationDefaultFade', array( - 'class' => 'input_text', - 'label' => 'Default Fade:', - 'required' => false, - 'filters' => array('StringTrim'), - 'validators' => array(array('regex', false, - array('/^[0-2][0-3]:[0-5][0-9]:[0-5][0-9](\.\d{1,6})?$/', - 'messages' => 'enter a time 00:00:00{.000000}'))), - 'value' => $defaultFade - )); - - $stream_format = new Zend_Form_Element_Radio('streamFormat'); - $stream_format->setLabel('Stream Label:'); - $stream_format->setMultiOptions(array("Artist - Title", - "Show - Artist - Title", - "Station name - Show name")); - $stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat()); - $this->addElement($stream_format); - - $third_party_api = new Zend_Form_Element_Radio('thirdPartyApi'); - $third_party_api->setLabel('Allow Remote Websites To Access Show Schedule Info'); - $third_party_api->setMultiOptions(array("Disabled", - "Enabled")); - $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); - $this->addElement($third_party_api); - - - $this->addElement('checkbox', 'UseSoundCloud', array( - 'label' => 'Automatically Upload Recorded Shows To SoundCloud', - 'required' => false, - 'value' => Application_Model_Preference::GetDoSoundCloudUpload() - )); - - //SoundCloud Username - $this->addElement('text', 'SoundCloudUser', array( - 'class' => 'input_text', - 'label' => 'SoundCloud Email:', - 'required' => false, - 'filters' => array('StringTrim'), - 'value' => Application_Model_Preference::GetSoundCloudUser() - )); - - //SoundCloud Password - $this->addElement('password', 'SoundCloudPassword', array( - 'class' => 'input_text', - 'label' => 'SoundCloud Password:', - 'required' => false, - 'filters' => array('StringTrim'), - 'value' => Application_Model_Preference::GetSoundCloudPassword() - )); - - // Add the description element - $this->addElement('textarea', 'SoundCloudTags', array( - 'label' => 'space separated SoundCloud Tags', - 'required' => false, - 'class' => 'input_text_area', - 'value' => Application_Model_Preference::GetSoundCloudTags() - )); - - //SoundCloud default genre - $this->addElement('text', 'SoundCloudGenre', array( - 'class' => 'input_text', - 'label' => 'Default Genre:', - 'required' => false, - 'filters' => array('StringTrim'), - 'value' => Application_Model_Preference::GetSoundCloudGenre() - )); - - $select = new Zend_Form_Element_Select('SoundCloudTrackType'); - $select->setLabel('Default Track Type:'); - $select->setAttrib('class', 'input_select'); - $select->setMultiOptions(array( - "" => "", - "original" => "Original", - "remix" => "Remix", - "live" => "Live", - "recording" => "Recording", - "spoken" => "Spoken", - "podcast" => "Podcast", - "demo" => "Demo", - "in progress" => "Work in progress", - "stem" => "Stem", - "loop" => "Loop", - "sound effect" => "Sound Effect", - "sample" => "One Shot Sample", - "other" => "Other" - )); - $select->setRequired(false); - $select->setValue(Application_Model_Preference::GetSoundCloudTrackType()); - $this->addElement($select); - - $select = new Zend_Form_Element_Select('SoundCloudLicense'); - $select->setLabel('Default License:'); - $select->setAttrib('class', 'input_select'); - $select->setMultiOptions(array( - "" => "", - "no-rights-reserved" => "The work is in the public domain", - "all-rights-reserved" => "All rights are reserved", - "cc-by" => "Creative Commons Attribution", - "cc-by-nc" => "Creative Commons Attribution Noncommercial", - "cc-by-nd" => "Creative Commons Attribution No Derivative Works", - "cc-by-sa" => "Creative Commons Attribution Share Alike", - "cc-by-nc-nd" => "Creative Commons Attribution Noncommercial Non Derivate Works", - "cc-by-nc-sa" => "Creative Commons Attribution Noncommercial Share Alike" - )); - $select->setRequired(false); - $select->setValue(Application_Model_Preference::GetSoundCloudLicense()); - $this->addElement($select); + $soundcloud_pref = new Application_Form_SoundcloudPreferences(); + $this->addSubForm($soundcloud_pref, 'preferences_soundcloud'); $this->addElement('submit', 'submit', array( - 'class' => 'ui-button ui-state-default', + 'class' => 'ui-button ui-state-default right-floated', 'ignore' => true, 'label' => 'Submit', - )); - - - + 'decorators' => array( + 'ViewHelper' + ) + )); } } diff --git a/application/forms/SoundcloudPreferences.php b/application/forms/SoundcloudPreferences.php new file mode 100644 index 000000000..96bbaee89 --- /dev/null +++ b/application/forms/SoundcloudPreferences.php @@ -0,0 +1,115 @@ +setDecorators(array( + array('ViewScript', array('viewScript' => 'form/preferences_soundcloud.phtml')) + )); + + //enable soundcloud uploads + $this->addElement('checkbox', 'UseSoundCloud', array( + 'label' => 'Automatically Upload Recorded Shows To SoundCloud', + 'required' => false, + 'value' => Application_Model_Preference::GetDoSoundCloudUpload(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + //SoundCloud Username + $this->addElement('text', 'SoundCloudUser', array( + 'class' => 'input_text', + 'label' => 'SoundCloud Email:', + 'required' => false, + 'filters' => array('StringTrim'), + 'value' => Application_Model_Preference::GetSoundCloudUser(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + //SoundCloud Password + $this->addElement('password', 'SoundCloudPassword', array( + 'class' => 'input_text', + 'label' => 'SoundCloud Password:', + 'required' => false, + 'filters' => array('StringTrim'), + 'value' => Application_Model_Preference::GetSoundCloudPassword(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + // Add the description element + $this->addElement('textarea', 'SoundCloudTags', array( + 'label' => 'space separated SoundCloud Tags', + 'required' => false, + 'class' => 'input_text_area', + 'value' => Application_Model_Preference::GetSoundCloudTags(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + //SoundCloud default genre + $this->addElement('text', 'SoundCloudGenre', array( + 'class' => 'input_text', + 'label' => 'Default Genre:', + 'required' => false, + 'filters' => array('StringTrim'), + 'value' => Application_Model_Preference::GetSoundCloudGenre(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + $select = new Zend_Form_Element_Select('SoundCloudTrackType'); + $select->setLabel('Default Track Type:'); + $select->setAttrib('class', 'input_select'); + $select->setMultiOptions(array( + "" => "", + "original" => "Original", + "remix" => "Remix", + "live" => "Live", + "recording" => "Recording", + "spoken" => "Spoken", + "podcast" => "Podcast", + "demo" => "Demo", + "in progress" => "Work in progress", + "stem" => "Stem", + "loop" => "Loop", + "sound effect" => "Sound Effect", + "sample" => "One Shot Sample", + "other" => "Other" + )); + $select->setRequired(false); + $select->setValue(Application_Model_Preference::GetSoundCloudTrackType()); + $select->setDecorators(array('ViewHelper')); + $this->addElement($select); + + $select = new Zend_Form_Element_Select('SoundCloudLicense'); + $select->setLabel('Default License:'); + $select->setAttrib('class', 'input_select'); + $select->setMultiOptions(array( + "" => "", + "no-rights-reserved" => "The work is in the public domain", + "all-rights-reserved" => "All rights are reserved", + "cc-by" => "Creative Commons Attribution", + "cc-by-nc" => "Creative Commons Attribution Noncommercial", + "cc-by-nd" => "Creative Commons Attribution No Derivative Works", + "cc-by-sa" => "Creative Commons Attribution Share Alike", + "cc-by-nc-nd" => "Creative Commons Attribution Noncommercial Non Derivate Works", + "cc-by-nc-sa" => "Creative Commons Attribution Noncommercial Share Alike" + )); + $select->setRequired(false); + $select->setValue(Application_Model_Preference::GetSoundCloudLicense()); + $select->setDecorators(array('ViewHelper')); + $this->addElement($select); + } + + +} + diff --git a/application/views/scripts/form/preferences.phtml b/application/views/scripts/form/preferences.phtml new file mode 100644 index 000000000..8694d5115 --- /dev/null +++ b/application/views/scripts/form/preferences.phtml @@ -0,0 +1,14 @@ +
+ + element->getSubform('preferences_general') ?> + +

SoundCloud settings

+
+ element->getSubform('preferences_soundcloud') ?> +
+ +
+ element->getElement('submit') ?> +
+ +
diff --git a/application/views/scripts/form/preferences_general.phtml b/application/views/scripts/form/preferences_general.phtml new file mode 100644 index 000000000..ce4654a09 --- /dev/null +++ b/application/views/scripts/form/preferences_general.phtml @@ -0,0 +1,50 @@ +
+
+ +
+ +
+
+ element->getElement('stationName') ?> +
+
+ +
+
+ element->getElement('stationDefaultFade') ?> +
+
+ +
+
+ element->getElement('streamFormat')->getValue(); + ?> + element->getElement('streamFormat')->getMultiOptions() as $radio) : ?> + + + +
+
+ +
+
+ element->getElement('thirdPartyApi')->getValue(); + ?> + element->getElement('thirdPartyApi')->getMultiOptions() as $radio) : ?> + + + +
+ +
+
diff --git a/application/views/scripts/form/preferences_soundcloud.phtml b/application/views/scripts/form/preferences_soundcloud.phtml new file mode 100644 index 000000000..ea0c46202 --- /dev/null +++ b/application/views/scripts/form/preferences_soundcloud.phtml @@ -0,0 +1,46 @@ +
+
+
+ +
+
+ +
+
+ element->getElement('SoundCloudUser') ?> +
+
+ +
+
+ element->getElement('SoundCloudPassword') ?> +
+
+ +
+
+ element->getElement('SoundCloudTags') ?> +
+
+ +
+
+ element->getElement('SoundCloudGenre') ?> +
+
+ +
+
+ element->getElement('SoundCloudTrackType') ?> +
+
+ +
+
+ element->getElement('SoundCloudLicense') ?> +
+
+
diff --git a/application/views/scripts/preference/index.phtml b/application/views/scripts/preference/index.phtml index 68cb33a1b..b5cf1fd4b 100644 --- a/application/views/scripts/preference/index.phtml +++ b/application/views/scripts/preference/index.phtml @@ -1,4 +1,5 @@ -
+
+

Preferences

statusMsg; echo $this->form; From 9bd1aa14a954eab25de9b0602417b37c99b60f03 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sun, 3 Apr 2011 18:04:14 -0400 Subject: [PATCH 06/12] CC-2145 : Redesign & layout fixes for the Preferences screen added javascript to page, got rid of separate index/update actions and moved everything to just index since update was not needed as a separate action. --- .../controllers/PreferenceController.php | 49 +++++++++---------- application/forms/Preferences.php | 3 +- .../views/scripts/form/preferences.phtml | 4 +- .../views/scripts/preference/update.phtml | 1 - public/js/airtime/preferences/preferences.js | 17 +++++++ 5 files changed, 43 insertions(+), 31 deletions(-) delete mode 100644 application/views/scripts/preference/update.phtml create mode 100644 public/js/airtime/preferences/preferences.js diff --git a/application/controllers/PreferenceController.php b/application/controllers/PreferenceController.php index 1dcb4bd38..d1fd4c3e6 100644 --- a/application/controllers/PreferenceController.php +++ b/application/controllers/PreferenceController.php @@ -10,42 +10,37 @@ class PreferenceController extends Zend_Controller_Action public function indexAction() { + $this->view->headScript()->appendFile('/js/airtime/preferences/preferences.js','text/javascript'); + + $request = $this->getRequest(); $this->view->statusMsg = ""; $form = new Application_Form_Preferences(); - $this->view->form = $form; - } - - public function updateAction() - { - $request = $this->getRequest(); - if (!$this->getRequest()->isPost()) { - return $this->_forward('Preference/index'); - } + + if ($request->isPost()) { - $form = new Application_Form_Preferences(); - if ($form->isValid($request->getPost())) { + if ($form->isValid($request->getPost())) { - $values = $form->getValues(); - - Application_Model_Preference::SetHeadTitle($values["preferences_general"]["stationName"], $this->view); - Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]); - Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]); - Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]); + $values = $form->getValues(); + + Application_Model_Preference::SetHeadTitle($values["preferences_general"]["stationName"], $this->view); + Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]); + Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]); + Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]); - Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]); - Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]); - Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]); - Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]); - Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]); - Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]); - Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]); - - $this->view->statusMsg = "
Preferences updated.
"; + Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]); + Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]); + Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]); + Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]); + Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]); + Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]); + Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]); + + $this->view->statusMsg = "
Preferences updated.
"; + } } $this->view->form = $form; - return $this->render('index'); //render the phtml file } } diff --git a/application/forms/Preferences.php b/application/forms/Preferences.php index c86fa6492..e329e48ff 100644 --- a/application/forms/Preferences.php +++ b/application/forms/Preferences.php @@ -5,7 +5,8 @@ class Application_Form_Preferences extends Zend_Form public function init() { - $this->setAction('/Preference/update')->setMethod('post'); + $this->setAction('/Preference'); + $this->setMethod('post'); $this->setDecorators(array( array('ViewScript', array('viewScript' => 'form/preferences.phtml')) diff --git a/application/views/scripts/form/preferences.phtml b/application/views/scripts/form/preferences.phtml index 8694d5115..c9844209d 100644 --- a/application/views/scripts/form/preferences.phtml +++ b/application/views/scripts/form/preferences.phtml @@ -1,9 +1,9 @@ -
+ element->getSubform('preferences_general') ?>

SoundCloud settings

-
+ diff --git a/application/views/scripts/preference/update.phtml b/application/views/scripts/preference/update.phtml deleted file mode 100644 index 3c48814f4..000000000 --- a/application/views/scripts/preference/update.phtml +++ /dev/null @@ -1 +0,0 @@ -Left empty on purpose diff --git a/public/js/airtime/preferences/preferences.js b/public/js/airtime/preferences/preferences.js new file mode 100644 index 000000000..a6fa7448e --- /dev/null +++ b/public/js/airtime/preferences/preferences.js @@ -0,0 +1,17 @@ +$(document).ready(function() { + + var form = $("form"); + + form.find("h3").click(function(){ + var h3 = $(this); + h3.next().toggle(); + + if(h3.hasClass("close")) { + h3.removeClass("close"); + } + else { + h3.addClass("close"); + } + }); +}); + From 119e21ec8277a50cd202ee18eecab496e2240f67 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sun, 3 Apr 2011 18:32:47 -0400 Subject: [PATCH 07/12] CC-2145 : Redesign & layout fixes for the Preferences screen printing out errors if the element has a problem --- .../scripts/form/preferences_general.phtml | 30 +++++++++++- .../scripts/form/preferences_soundcloud.phtml | 49 +++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/application/views/scripts/form/preferences_general.phtml b/application/views/scripts/form/preferences_general.phtml index ce4654a09..92e7956f4 100644 --- a/application/views/scripts/form/preferences_general.phtml +++ b/application/views/scripts/form/preferences_general.phtml @@ -6,12 +6,26 @@
element->getElement('stationName') ?> + element->getElement('stationName')->hasErrors()) : ?> +
    + element->getElement('stationName')->getMessages() as $error): ?> +
  • + +
+
element->getElement('stationDefaultFade') ?> + element->getElement('stationDefaultFade')->hasErrors()) : ?> +
    + element->getElement('stationDefaultFade')->getMessages() as $error): ?> +
  • + +
+
@@ -28,6 +42,13 @@ + element->getElement('streamFormat')->hasErrors()) : ?> +
    + element->getElement('streamFormat')->getMessages() as $error): ?> +
  • + +
+
@@ -43,7 +64,14 @@ - + + element->getElement('thirdPartyApi')->hasErrors()) : ?> +
    + element->getElement('thirdPartyApi')->getMessages() as $error): ?> +
  • + +
+ diff --git a/application/views/scripts/form/preferences_soundcloud.phtml b/application/views/scripts/form/preferences_soundcloud.phtml index ea0c46202..3ee3ad54e 100644 --- a/application/views/scripts/form/preferences_soundcloud.phtml +++ b/application/views/scripts/form/preferences_soundcloud.phtml @@ -5,42 +5,91 @@ element->getElement('UseSoundCloud') ?> element->getElement('UseSoundCloud')->getLabel() ?> + element->getElement('UseSoundCloud')->hasErrors()) : ?> +
    + element->getElement('UseSoundCloud')->getMessages() as $error): ?> +
  • + +
+
element->getElement('SoundCloudUser') ?> + element->getElement('SoundCloudUser')->hasErrors()) : ?> +
    + element->getElement('SoundCloudUser')->getMessages() as $error): ?> +
  • + +
+
element->getElement('SoundCloudPassword') ?> + element->getElement('SoundCloudPassword')->hasErrors()) : ?> +
    + element->getElement('SoundCloudPassword')->getMessages() as $error): ?> +
  • + +
+
element->getElement('SoundCloudTags') ?> + element->getElement('SoundCloudTags')->hasErrors()) : ?> +
    + element->getElement('SoundCloudTags')->getMessages() as $error): ?> +
  • + +
+
element->getElement('SoundCloudGenre') ?> + element->getElement('SoundCloudGenre')->hasErrors()) : ?> +
    + element->getElement('SoundCloudGenre')->getMessages() as $error): ?> +
  • + +
+
element->getElement('SoundCloudTrackType') ?> + element->getElement('SoundCloudTrackType')->hasErrors()) : ?> +
    + element->getElement('SoundCloudTrackType')->getMessages() as $error): ?> +
  • + +
+
element->getElement('SoundCloudLicense') ?> + element->getElement('SoundCloudLicense')->hasErrors()) : ?> +
    + element->getElement('SoundCloudLicense')->getMessages() as $error): ?> +
  • + +
+
From 1cdbce55a715a006663783aca814c062a3d522a2 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sun, 3 Apr 2011 22:32:11 -0400 Subject: [PATCH 08/12] CC-2125 : Soundcloud: ability to retry to upload if a recorded show in the past does not have a soundcloud file id, context menu action appears to upload to soundcloud if it is enabled in preferences. if a recorded file is on soundcloud the soundcloud icon replaces the record icon. --- .../controllers/ScheduleController.php | 57 +++++++++++++++++- application/models/Shows.php | 20 ++++++ public/css/images/upload-icon.gif | Bin 0 -> 1188 bytes public/css/styles.css | 7 ++- .../schedule/full-calendar-functions.js | 18 +++--- public/js/airtime/schedule/schedule.js | 24 ++++++++ 6 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 public/css/images/upload-icon.gif diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index f6f4ee924..85d5b13ff 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -25,6 +25,7 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('edit-show', 'json') ->addActionContext('add-show', 'json') ->addActionContext('cancel-show', 'json') + ->addActionContext('upload-to-sound-cloud', 'json') ->initContext(); $this->sched_sess = new Zend_Session_Namespace("schedule"); @@ -145,6 +146,52 @@ class ScheduleController extends Zend_Controller_Action } } + public function uploadToSoundCloudAction() + { + global $CC_CONFIG; + $show_instance = $this->_getParam('id'); + $show_inst = new ShowInstance($show_instance); + + $file = $show_inst->getRecordedFile(); + + if(is_null($file)) { + $this->view->error = "Recorded file does not exist"; + return; + } + + $show_name = $show_inst->getName(); + $show_genre = $show_inst->getGenre(); + $show_start_time = $show_inst->getShowStart(); + + if(Application_Model_Preference::GetDoSoundCloudUpload()) + { + for($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) { + + $show = new Show($show_inst->getShowId()); + $description = $show->getDescription(); + $hosts = $show->getHosts(); + + $tags = array_merge($hosts, array($show_name)); + + try { + $soundcloud = new ATSoundcloud(); + $soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $tags, $show_start_time, $show_genre); + $show_inst->setSoundCloudFileId($soundcloud_id); + $this->view->soundcloud_id = $soundcloud_id; + break; + } + catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { + $code = $e->getHttpCode(); + if(!in_array($code, array(0, 100))) { + break; + } + } + + sleep($CC_CONFIG['soundcloud-connection-wait']); + } + } + } + public function makeContextMenuAction() { $id = $this->_getParam('id'); @@ -174,10 +221,18 @@ class ScheduleController extends Zend_Controller_Action 'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content'); } + if (strtotime($show->getShowEnd()) <= strtotime($today_timestamp) + && is_null($show->getSoundCloudFileId()) + && Application_Model_Preference::GetDoSoundCloudUpload()) { + $menu[] = array('action' => array('type' => 'fn', + 'callback' => "window['uploadToSoundCloud']($id)"), + 'title' => 'Upload to Soundcloud'); + } + if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) && strtotime($today_timestamp) < strtotime($show->getShowEnd()) && - $user->isAdmin()) { + $user->isAdmin() && !$show->isRecorded()) { $menu[] = array('action' => array('type' => 'fn', 'callback' => "window['confirmCancelShow']($id)"), 'title' => 'Cancel Current Show'); diff --git a/application/models/Shows.php b/application/models/Shows.php index 8db07c8ec..a7ee8d232 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -648,6 +648,26 @@ class ShowInstance { return $showInstance->getDbSoundCloudId(); } + public function getRecordedFile() + { + $showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); + $file_id = $showInstance->getDbRecordedFile(); + + if(isset($file_id)) { + $file = StoredFile::Recall($file_id); + + if (PEAR::isError($file)) { + return null; + } + + if(file_exists($file->getRealFilePath())) { + return $file; + } + } + + return null; + } + public function setShowStart($start) { $showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); diff --git a/public/css/images/upload-icon.gif b/public/css/images/upload-icon.gif new file mode 100644 index 0000000000000000000000000000000000000000..45b4f81a9b07809afd31a9770df6bcc1c65780b8 GIT binary patch literal 1188 zcmZ?wbhEHbhoft^E!f#HBdBP*wrhyugHgN;1=UL_WW4h=0rx_(nS zCN4VEFKf%i!vWIGil$o&S+~!M4+@8y1?2fe6dV>gbO{)H@dz+HbZVASmXeVWKxk)S zU}0bbLIw^=nD!<%emN0^1cwF&W(lhn3j+m&YDNZj1`eQ`88}24m{}wo3V=>$V&@P@ z5O6ry%F4`yP{{x{R}7-E;Xo6IAeX>`35r17@@y=~N*RGhasY+J7}!}j6ec`qU}R!Z z2&wp>0Q8|8s!|51Yb8Lg6;L?9z{tcQ`aV*eW4q!Mu01B`P Q0Ch1qHS;jDurOEy0I9`Cm;e9( literal 0 HcmV?d00001 diff --git a/public/css/styles.css b/public/css/styles.css index 4ef4decee..2049c042b 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -1511,6 +1511,11 @@ div.success{ background:url(images/icon_soundcloud.png) no-repeat 0 0; width:21px; } +.small-icon.progress { + background:url(images/upload-icon.gif) no-repeat; + background-color:black; + background-position:center; +} .medium-icon { display:block; width:25px; @@ -1585,4 +1590,4 @@ dd.radio-inline-list, .preferences dd.radio-inline-list { } .preferences dd.block-display .input_text_area, .preferences dd.block-display .input_text { width: 99.5%; -} \ No newline at end of file +} diff --git a/public/js/airtime/schedule/full-calendar-functions.js b/public/js/airtime/schedule/full-calendar-functions.js index ab8eb34c9..86fc03b78 100644 --- a/public/js/airtime/schedule/full-calendar-functions.js +++ b/public/js/airtime/schedule/full-calendar-functions.js @@ -148,8 +148,8 @@ function viewDisplay( view ) { function eventRender(event, element, view) { - //only put progress bar on shows that aren't being recorded and are not a rebroadcast. - if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 0 /* && event.rebroadcast === 0 */) { + //only put progress bar on shows that aren't being recorded. + if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 0) { var div = $('
'); div .height('5px') @@ -168,15 +168,17 @@ function eventRender(event, element, view) { } //add the record/rebroadcast icons if needed. - if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 1) { + + //record icon (only if not on soundcloud, will always be true for future events) + if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 1 && event.soundcloud_id === -1) { $(element).find(".fc-event-time").after(''); } - if(view.name === 'month' && event.record === 1) { + if(view.name === 'month' && event.record === 1 && event.soundcloud_id === -1) { $(element).find(".fc-event-title").after(''); } - + //rebroadcast icon if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.rebroadcast === 1) { $(element).find(".fc-event-time").after(''); @@ -185,12 +187,12 @@ function eventRender(event, element, view) { $(element).find(".fc-event-title").after(''); } - - if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.soundcloud_id != -1 && event.record === 1) { + //soundcloud icon + if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.soundcloud_id !== -1 && event.record === 1) { $(element).find(".fc-event-time").after(''); } - if(view.name === 'month' && event.soundcloud_id != -1 && event.record === 1) { + if(view.name === 'month' && event.soundcloud_id !== -1 && event.record === 1) { $(element).find(".fc-event-title").after(''); } diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index 79c364e4c..9a9840a83 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -165,6 +165,30 @@ function confirmCancelShow(show_instance_id){ } } +function uploadToSoundCloud(show_instance_id){ + + var url = "/Schedule/upload-to-sound-cloud"; + var span = $(window.triggerElement).find(".recording"); + + span.removeClass("recording") + .addClass("progress"); + + $.post(url, + {id: show_instance_id, format: "json"}, + function(data){ + if(data.error) { + span.removeClass("progress") + .addClass("recording"); + + alert(data.error); + return; + } + span.removeClass("progress") + .addClass("soundcloud"); + }); + +} + function buildContentDialog(json){ var dialog = $(json.dialog); From 665aae0a1885672d04890219dbce91af2e18f256 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sun, 3 Apr 2011 22:37:19 -0400 Subject: [PATCH 09/12] removed automatically, since it applies to manually through interface as well. --- application/forms/SoundcloudPreferences.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/SoundcloudPreferences.php b/application/forms/SoundcloudPreferences.php index 96bbaee89..d4c485713 100644 --- a/application/forms/SoundcloudPreferences.php +++ b/application/forms/SoundcloudPreferences.php @@ -11,7 +11,7 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm //enable soundcloud uploads $this->addElement('checkbox', 'UseSoundCloud', array( - 'label' => 'Automatically Upload Recorded Shows To SoundCloud', + 'label' => 'Upload Recorded Shows To SoundCloud', 'required' => false, 'value' => Application_Model_Preference::GetDoSoundCloudUpload(), 'decorators' => array( From 2033b904c86cc5de097307d83b8af476dadb6d79 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sun, 3 Apr 2011 22:55:34 -0400 Subject: [PATCH 10/12] prevent fullcalendar caching from switching back to incorrect icon. --- public/js/airtime/schedule/schedule.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index 9a9840a83..24c889439 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -183,8 +183,7 @@ function uploadToSoundCloud(show_instance_id){ alert(data.error); return; } - span.removeClass("progress") - .addClass("soundcloud"); + scheduleRefetchEvents(); }); } From 7f775105e216653d7a0e4b0f0493888e4bfba549 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Mon, 4 Apr 2011 00:02:35 -0400 Subject: [PATCH 11/12] adding end date check in get shows just incase nobody checks calendar for a while. preferences had to be updated because there will be no user id if the daemon process updates the date pouplated until pref. --- application/controllers/ApiController.php | 5 +++- application/forms/AddShowRebroadcastDates.php | 2 +- application/models/Preference.php | 27 ++++++++++++++++--- application/models/Shows.php | 17 ++++++------ 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/application/controllers/ApiController.php b/application/controllers/ApiController.php index 04368b94c..1b0e8ac51 100644 --- a/application/controllers/ApiController.php +++ b/application/controllers/ApiController.php @@ -257,7 +257,10 @@ class ApiController extends Zend_Controller_Action } $today_timestamp = date("Y-m-d H:i:s"); - $this->view->shows = Show::getShows($today_timestamp, null, $excludeInstance=NULL, $onlyRecord=TRUE); + $now = new DateTime($today_timestamp); + $end_timestamp = $now->add(new DateInterval("PT2H")); + $end_timestamp = $end_timestamp->format("Y-m-d H:i:s"); + $this->view->shows = Show::getShows($today_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=TRUE); } public function uploadRecordedAction() diff --git a/application/forms/AddShowRebroadcastDates.php b/application/forms/AddShowRebroadcastDates.php index 6cc86b134..22e28a1a3 100644 --- a/application/forms/AddShowRebroadcastDates.php +++ b/application/forms/AddShowRebroadcastDates.php @@ -165,7 +165,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $show_end->add(new DateInterval("PT$duration[0]H")); $show_end->add(new DateInterval("PT$duration[1]M")); - $show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast + $show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast $rebroad_start = $formData['add_show_start_date']."".$formData['add_show_rebroadcast_time_'.$i]; $rebroad_start = new DateTime($rebroad_start); diff --git a/application/models/Preference.php b/application/models/Preference.php index 0ca748ebb..400e99d8a 100644 --- a/application/models/Preference.php +++ b/application/models/Preference.php @@ -6,19 +6,38 @@ class Application_Model_Preference public static function SetValue($key, $value){ global $CC_CONFIG, $CC_DBC; - $auth = Zend_Auth::getInstance(); - $id = $auth->getIdentity()->id; + //called from a daemon process + if(!Zend_Auth::getInstance()->hasIdentity()) { + $id = NULL; + } + else { + $auth = Zend_Auth::getInstance(); + $id = $auth->getIdentity()->id; + } + + $key = pg_escape_string($key); + $value = pg_escape_string($value); //Check if key already exists $sql = "SELECT COUNT(*) FROM cc_pref" ." WHERE keystr = '$key'"; $result = $CC_DBC->GetOne($sql); - if ($result == 1){ + if ($result == 1 && is_null($id)){ + $sql = "UPDATE cc_pref" + ." SET subjid = NULL, valstr = '$value'" + ." WHERE keystr = '$key'"; + } + else if ($result == 1 && !is_null($id)){ $sql = "UPDATE cc_pref" ." SET subjid = $id, valstr = '$value'" ." WHERE keystr = '$key'"; - } else { + } + else if(is_null($id)) { + $sql = "INSERT INTO cc_pref (keystr, valstr)" + ." VALUES ('$key', '$value')"; + } + else { $sql = "INSERT INTO cc_pref (subjid, keystr, valstr)" ." VALUES ($id, '$key', '$value')"; } diff --git a/application/models/Shows.php b/application/models/Shows.php index a7ee8d232..ac682bc7f 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -275,6 +275,14 @@ class Show { { global $CC_DBC; + $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); + + //if application is requesting shows past our previous populated until date, generate shows up until this point. + if ($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end_timestamp)) { + Show::populateAllShowsInRange($showsPopUntil, $end_timestamp); + Application_Model_Preference::SetShowsPopulatedUntil($end_timestamp); + } + $sql = "SELECT starts, ends, record, rebroadcast, soundcloud_id, instance_id, show_id, name, description, color, background_color, cc_show_instances.id AS instance_id FROM cc_show_instances @@ -283,7 +291,7 @@ class Show { //only want shows that are starting at the time or later. if ($onlyRecord) { - $sql = $sql." WHERE (starts >= '{$start_timestamp}' AND starts < timestamp '{$start_timestamp}' + interval '2 hours')"; + $sql = $sql." WHERE (starts >= '{$start_timestamp}' AND starts < timestamp '{$end_timestamp}')"; $sql = $sql." AND (record = 1)"; } else { @@ -525,13 +533,6 @@ class Show { public static function getFullCalendarEvents($start, $end, $editable=false) { $events = array(); - $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); - - //if fullcalendar is requesting shows past our previous populated until date, generate shows up until this point. - if ($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end)) { - Show::populateAllShowsInRange($showsPopUntil, $end); - Application_Model_Preference::SetShowsPopulatedUntil($end); - } $shows = Show::getShows($start, $end); From add7744740128405db75469b588979b423a80c20 Mon Sep 17 00:00:00 2001 From: lukabazuka Date: Mon, 4 Apr 2011 13:23:13 +0200 Subject: [PATCH 12/12] Changed hight of textarea in the Preferences screen Signed-off-by: lukabazuka --- public/css/styles.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/css/styles.css b/public/css/styles.css index 2049c042b..4f53d7415 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -1591,3 +1591,6 @@ dd.radio-inline-list, .preferences dd.radio-inline-list { .preferences dd.block-display .input_text_area, .preferences dd.block-display .input_text { width: 99.5%; } +.preferences dd#SoundCloudTags-element.block-display .input_text_area { + height: 120px; +} \ No newline at end of file