Whitespace and deadcode nitpick

This commit is contained in:
Lucas Bickel 2017-03-10 16:20:44 +01:00
parent 6e50af344a
commit 2a53241ba3
15 changed files with 59 additions and 122 deletions

View file

@ -1,7 +1,6 @@
<?php <?php
class AutoPlaylistManager { class AutoPlaylistManager {
/** /**
* @var int how often, in seconds, to check for and ingest new podcast episodes * @var int how often, in seconds, to check for and ingest new podcast episodes
*/ */
@ -19,7 +18,6 @@ class AutoPlaylistManager {
return empty($lastPolled) || (microtime(true) > $lastPolled + self::$_AUTOPLAYLIST_POLL_INTERVAL_SECONDS); return empty($lastPolled) || (microtime(true) > $lastPolled + self::$_AUTOPLAYLIST_POLL_INTERVAL_SECONDS);
} }
/* /*
* This function is copied from the TestUser class and is used to instantiate a user so that * This function is copied from the TestUser class and is used to instantiate a user so that
* the Scheduler model can be utilized by buildAutoPlaylist. * the Scheduler model can be utilized by buildAutoPlaylist.
@ -45,7 +43,6 @@ class AutoPlaylistManager {
} }
} }
/** /**
* Find all shows with autoplaylists who have yet to have their playlists built and added to the schedule * Find all shows with autoplaylists who have yet to have their playlists built and added to the schedule
* *
@ -70,7 +67,6 @@ class AutoPlaylistManager {
Zend_Session::stop(); Zend_Session::stop();
} }
/** /**
* Find all show instances starting in the next hour with autoplaylists not yet added to the schedule * Find all show instances starting in the next hour with autoplaylists not yet added to the schedule
* *
@ -93,5 +89,4 @@ class AutoPlaylistManager {
->filterByDbAutoPlaylistBuilt(false) ->filterByDbAutoPlaylistBuilt(false)
->find(); ->find();
} }
} }

View file

@ -223,7 +223,6 @@ class CeleryTask implements AirtimeTask {
} }
/** /**
*
* Class AutoPlaylistTask * Class AutoPlaylistTask
* *
* Checks for shows with an autoplaylist that needs to be filled in * Checks for shows with an autoplaylist that needs to be filled in
@ -231,7 +230,6 @@ class CeleryTask implements AirtimeTask {
*/ */
class AutoPlaylistTask implements AirtimeTask class AutoPlaylistTask implements AirtimeTask
{ {
/** /**
* Checks whether or not the autoplaylist polling interval has passed * Checks whether or not the autoplaylist polling interval has passed
* *
@ -251,8 +249,6 @@ class AutoPlaylistTask implements AirtimeTask
} }
} }
/** /**
* Class PodcastTask * Class PodcastTask
* *

View file

@ -1,6 +1,6 @@
<?php <?php
// This file generated by Propel 1.7.0 convert-conf target // This file generated by Propel 1.7.0 convert-conf target
// from XML runtime conf file /home/wcrs/airtime-dev-test/airtime_mvc/build/runtime-conf.xml // from XML runtime conf file /home/sourcefabric/dev/Airtime/airtime_mvc/build/runtime-conf.xml
$conf = array ( $conf = array (
'datasources' => 'datasources' =>
array ( array (
@ -22,14 +22,6 @@ $conf = array (
), ),
'default' => 'airtime', 'default' => 'airtime',
), ),
'log' =>
array (
'type' => 'file',
'name' => './propel.log',
'ident' => 'propel',
'level' => '7',
'conf' => '',
),
'generator_version' => '1.7.0', 'generator_version' => '1.7.0',
); );
$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-airtime-conf.php'); $conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-airtime-conf.php');

View file

@ -1 +1 @@
ALTER TABLE third_party_track_references ALTER COLUMN file_id SET NOT NULL; ALTER TABLE third_party_track_references ALTER COLUMN file_id SET NOT NULL;

View file

@ -4,14 +4,12 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm
{ {
public function init() public function init()
{ {
$this->setDecorators(array( $this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/add-show-autoplaylist.phtml')) array('ViewScript', array('viewScript' => 'form/add-show-autoplaylist.phtml'))
)); ));
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
// retrieves the length limit for each char field // retrieves the length limit for each char field
// and store to assoc array // and store to assoc array
$maxLens = Application_Model_Show::getMaxLengths(); $maxLens = Application_Model_Show::getMaxLengths();
@ -25,31 +23,12 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm
$autoPlaylistSelect = new Zend_Form_Element_Select("add_show_autoplaylist_id"); $autoPlaylistSelect = new Zend_Form_Element_Select("add_show_autoplaylist_id");
$autoPlaylistSelect->setLabel(_("Select Playlist")); $autoPlaylistSelect->setLabel(_("Select Playlist"));
$autoPlaylistSelect->setMultiOptions($this->getPlaylistNames()); $autoPlaylistSelect->setMultiOptions(Application_Model_Library::getPlaylistNames());
$autoPlaylistSelect->setValue(null); $autoPlaylistSelect->setValue(null);
$autoPlaylistSelect->setDecorators(array('ViewHelper')); $autoPlaylistSelect->setDecorators(array('ViewHelper'));
$this->addElement($autoPlaylistSelect); $this->addElement($autoPlaylistSelect);
}
private function getPlaylistNames()
{
$playlistNames = array(NULL => _("None"));
$playlists = CcPlaylistQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->find();
foreach ($playlists as $playlist) {
$playlistNames[$playlist->getDbId()] = $playlist->getDbName();
} }
return $playlistNames;
}
public function disable() public function disable()
{ {
$elements = $this->getElements(); $elements = $this->getElements();

View file

@ -39,7 +39,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'validators' => array($notEmptyValidator, array('StringLength', false, array(0, $maxLens['url']))) 'validators' => array($notEmptyValidator, array('StringLength', false, array(0, $maxLens['url'])))
)); ));
// Add genre element // Add genre element
$this->addElement('text', 'add_show_genre', array( $this->addElement('text', 'add_show_genre', array(
'label' => _('Genre:'), 'label' => _('Genre:'),
@ -59,7 +59,6 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
$descText = $this->getElement('add_show_description'); $descText = $this->getElement('add_show_description');
$descText->setDecorators(array(array('ViewScript', array( $descText->setDecorators(array(array('ViewScript', array(
'viewScript' => 'form/add-show-block.phtml', 'viewScript' => 'form/add-show-block.phtml',
'class' => 'block-display' 'class' => 'block-display'
@ -67,51 +66,30 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
// Add the instance description // Add the instance description
$this->addElement('textarea', 'add_show_instance_description', array( $this->addElement('textarea', 'add_show_instance_description', array(
'label' => _('Instance Description:'), 'label' => _('Instance Description:'),
'required' => false, 'required' => false,
'class' => 'input_text_area', 'class' => 'input_text_area',
'validators' => array(array('StringLength', false, array(0, $maxLens['description']))) 'validators' => array(array('StringLength', false, array(0, $maxLens['description'])))
)); ));
$instanceDesc = $this->getElement('add_show_instance_description'); $instanceDesc = $this->getElement('add_show_instance_description');
$instanceDesc->setDecorators(array(array('ViewScript', array( $instanceDesc->setDecorators(array(array('ViewScript', array(
'viewScript' => 'form/add-show-block.phtml', 'viewScript' => 'form/add-show-block.phtml',
'class' => 'block-display' 'class' => 'block-display'
)))); ))));
$instanceDesc->setAttrib('disabled','disabled'); $instanceDesc->setAttrib('disabled','disabled');
} }
/**
private function getPlaylistNames()
{
$playlistNames = array(NULL => _("None"));
$playlists = CcPlaylistQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->find();
foreach ($playlists as $playlist) {
$playlistNames[$playlist->getDbId()] = $playlist->getDbName();
}
return $playlistNames;
}
/**
* Enable the instance description when editing a show instance * Enable the instance description when editing a show instance
*/ */
public function enableInstanceDesc() public function enableInstanceDesc()
{ {
$el = $this->getElement('add_show_instance_description'); $el = $this->getElement('add_show_instance_description');
Logging::info($el); Logging::info($el);
$el->setAttrib('disabled', null); $el->setAttrib('disabled', null);
$el->setAttrib('readonly', null); $el->setAttrib('readonly', null);
} }
public function disable() public function disable()

View file

@ -33,4 +33,18 @@ class Application_Model_Library
} }
} }
public static function getPlaylistNames()
{
$playlistNames = array(NULL => _("None"));
$playlists = CcPlaylistQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->find();
foreach ($playlists as $playlist) {
$playlistNames[$playlist->getDbId()] = $playlist->getDbName();
}
return $playlistNames;
}
} }

View file

@ -129,7 +129,6 @@ class Application_Model_Show
return $this->_showId; return $this->_showId;
} }
public function getHasAutoPlaylist() public function getHasAutoPlaylist()
{ {
$show = CcShowQuery::create()->findPK($this->_showId); $show = CcShowQuery::create()->findPK($this->_showId);
@ -156,7 +155,6 @@ class Application_Model_Show
$show->setDbAutoPlaylistId($playlistid); $show->setDbAutoPlaylistId($playlistid);
} }
public function getHosts() public function getHosts()
{ {
$sql = <<<SQL $sql = <<<SQL

View file

@ -169,16 +169,11 @@ SQL;
->save(); ->save();
} }
public function updateScheduledTime() public function updateScheduledTime()
{ {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME);
$this->_showInstance->updateDbTimeFilled($con); $this->_showInstance->updateDbTimeFilled($con);
} }
public function isDeleted() public function isDeleted()
{ {

View file

@ -20,7 +20,7 @@ class Application_Service_ShowFormService
public function createShowForms() public function createShowForms()
{ {
$formWhat = new Application_Form_AddShowWhat(); $formWhat = new Application_Form_AddShowWhat();
$formAutoPlaylist = new Application_Form_AddShowAutoPlaylist(); $formAutoPlaylist = new Application_Form_AddShowAutoPlaylist();
$formWho = new Application_Form_AddShowWho(); $formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen(); $formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats(); $formRepeats = new Application_Form_AddShowRepeats();
@ -31,7 +31,7 @@ class Application_Service_ShowFormService
$formRebroadcast = new Application_Form_AddShowRebroadcastDates(); $formRebroadcast = new Application_Form_AddShowRebroadcastDates();
$formWhat->removeDecorator('DtDdWrapper'); $formWhat->removeDecorator('DtDdWrapper');
$formAutoPlaylist->removeDecorator('DtDdWrapper'); $formAutoPlaylist->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper'); $formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper'); $formRepeats->removeDecorator('DtDdWrapper');
@ -43,7 +43,7 @@ class Application_Service_ShowFormService
$forms = array(); $forms = array();
$forms["what"] = $formWhat; $forms["what"] = $formWhat;
$forms["autoplaylist"] = $formAutoPlaylist; $forms["autoplaylist"] = $formAutoPlaylist;
$forms["who"] = $formWho; $forms["who"] = $formWho;
$forms["when"] = $formWhen; $forms["when"] = $formWhen;
$forms["repeats"] = $formRepeats; $forms["repeats"] = $formRepeats;
@ -61,7 +61,7 @@ class Application_Service_ShowFormService
* Popluates the what, autoplaylist, when, and repeat forms * Popluates the what, autoplaylist, when, and repeat forms
* with default values * with default values
*/ */
public function populateNewShowForms($formWhat, $formWhen, $formRepeats) public function populateNewShowForms($formWhat, $formWhen, $formRepeats)
{ {
$formWhat->populate( $formWhat->populate(
array('add_show_id' => '-1', array('add_show_id' => '-1',
@ -96,7 +96,7 @@ class Application_Service_ShowFormService
*/ */
$forms["what"]->makeReadonly(); $forms["what"]->makeReadonly();
$forms["what"]->enableInstanceDesc(); $forms["what"]->enableInstanceDesc();
$forms["autoplaylist"]->disable(); $forms["autoplaylist"]->disable();
$forms["repeats"]->disable(); $forms["repeats"]->disable();
$forms["who"]->disable(); $forms["who"]->disable();
$forms["style"]->disable(); $forms["style"]->disable();
@ -119,7 +119,7 @@ class Application_Service_ShowFormService
{ {
$this->populateFormWhat($forms["what"]); $this->populateFormWhat($forms["what"]);
//local show start DT //local show start DT
$this->populateFormAutoPlaylist($forms["autoplaylist"]); $this->populateFormAutoPlaylist($forms["autoplaylist"]);
$showStart = $this->populateFormWhen($forms["when"]); $showStart = $this->populateFormWhen($forms["when"]);
$this->populateFormRepeats($forms["repeats"], $showStart); $this->populateFormRepeats($forms["repeats"], $showStart);
$this->populateFormWho($forms["who"]); $this->populateFormWho($forms["who"]);
@ -130,12 +130,11 @@ class Application_Service_ShowFormService
$this->populateFormRebroadcastAbsolute($forms["abs_rebroadcast"]); $this->populateFormRebroadcastAbsolute($forms["abs_rebroadcast"]);
} }
private function populateFormWhat($form) private function populateFormWhat($form)
{ {
$ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId); $ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId);
$form->populate( $form->populate(
array( array(
'add_show_instance_id' => $this->instanceId, 'add_show_instance_id' => $this->instanceId,
'add_show_id' => $this->ccShow->getDbId(), 'add_show_id' => $this->ccShow->getDbId(),
@ -143,18 +142,15 @@ class Application_Service_ShowFormService
'add_show_url' => $this->ccShow->getDbUrl(), 'add_show_url' => $this->ccShow->getDbUrl(),
'add_show_genre' => $this->ccShow->getDbGenre(), 'add_show_genre' => $this->ccShow->getDbGenre(),
'add_show_description' => $this->ccShow->getDbDescription(), 'add_show_description' => $this->ccShow->getDbDescription(),
'add_show_instance_description' => $ccShowInstance->getDbDescription(), 'add_show_instance_description' => $ccShowInstance->getDbDescription(),
)); ));
} }
private function populateFormAutoPlaylist($form) private function populateFormAutoPlaylist($form)
{ {
$ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId); $ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId);
if (!$this->ccShow->getDbAutoPlaylistId()) {
// $form->disableAutoPlaylist();
}
$form->populate( $form->populate(
array( array(
'add_show_has_autoplaylist' => $this->ccShow->getDbHasAutoPlaylist() ? 1 : 0, 'add_show_has_autoplaylist' => $this->ccShow->getDbHasAutoPlaylist() ? 1 : 0,
'add_show_autoplaylist_id' => $this->ccShow->getDbAutoPlaylistId() 'add_show_autoplaylist_id' => $this->ccShow->getDbAutoPlaylistId()
@ -294,7 +290,7 @@ class Application_Service_ShowFormService
//end dates are stored non-inclusively so we need to //end dates are stored non-inclusively so we need to
//subtract one day //subtract one day
if (!is_null($repeatEndDate)) { if (!is_null($repeatEndDate)) {
$repeatEndDate->sub(new DateInterval("P1D")); $repeatEndDate->sub(new DateInterval("P1D"));
} }
//default monthly repeat type //default monthly repeat type
@ -348,27 +344,27 @@ class Application_Service_ShowFormService
private function populateFormStyle($form) private function populateFormStyle($form)
{ {
$src = $this->ccShow->getDbImagePath() ? $src = $this->ccShow->getDbImagePath() ?
$this->imagePathToDataUri($this->ccShow->getDbImagePath()) : ''; $this->imagePathToDataUri($this->ccShow->getDbImagePath()) : '';
$form->populate( $form->populate(
array( array(
'add_show_background_color' => $this->ccShow->getDbBackgroundColor(), 'add_show_background_color' => $this->ccShow->getDbBackgroundColor(),
'add_show_color' => $this->ccShow->getDbColor(), 'add_show_color' => $this->ccShow->getDbColor(),
'add_show_logo_current' => $src)); 'add_show_logo_current' => $src));
} }
/** /**
* Convert a static image from disk to a base64 data URI * Convert a static image from disk to a base64 data URI
* *
* @param unknown $path * @param unknown $path
* - the path to the image on the disk * - the path to the image on the disk
* @return string * @return string
* - the data URI representation of the image * - the data URI representation of the image
*/ */
private function imagePathToDataUri($path) { private function imagePathToDataUri($path) {
$imageData = null; $imageData = null;
$bytesRead = 0; $bytesRead = 0;
try { try {
ob_start(); ob_start();
header("Content-type: image/*"); header("Content-type: image/*");
@ -382,9 +378,9 @@ class Application_Service_ShowFormService
Logging::error("Failed to read image: " . $path); Logging::error("Failed to read image: " . $path);
$imageData = null; $imageData = null;
} }
// return the data URI - data:{mime};base64,{data} // return the data URI - data:{mime};base64,{data}
return ($imageData === null || $imageData === '') ? return ($imageData === null || $imageData === '') ?
'' : 'data: '.mime_content_type($path).';base64,'.$imageData; '' : 'data: '.mime_content_type($path).';base64,'.$imageData;
} }
private function populateFormLive($form) private function populateFormLive($form)
@ -587,8 +583,8 @@ class Application_Service_ShowFormService
public function calculateDuration($start, $end, $timezone) public function calculateDuration($start, $end, $timezone)
{ {
try { try {
$tz = new DateTimeZone($timezone); $tz = new DateTimeZone($timezone);
$startDateTime = new DateTime($start, $tz); $startDateTime = new DateTime($start, $tz);
$endDateTime = new DateTime($end, $tz); $endDateTime = new DateTime($end, $tz);
@ -606,7 +602,7 @@ class Application_Service_ShowFormService
return $duration->format('%r%Hh %Im'); return $duration->format('%r%Hh %Im');
} }
} catch (Exception $e) { } catch (Exception $e) {
Logging::info($e->getMessage()); Logging::info($e->getMessage());
return "Invalid Date"; return "Invalid Date";
} }
} }

View file

@ -1542,8 +1542,8 @@ SQL;
$ccShow->setDbLiveStreamPass($showData['custom_password']); $ccShow->setDbLiveStreamPass($showData['custom_password']);
$ccShow->setDbHasAutoPlaylist($showData['add_show_has_autoplaylist'] == 1); $ccShow->setDbHasAutoPlaylist($showData['add_show_has_autoplaylist'] == 1);
// added to prevent errors with insert due to a lack of data // added to prevent errors with insert due to a lack of data
if ($showData['add_show_autoplaylist_id'] != '') { if ($showData['add_show_autoplaylist_id'] != '') {
$ccShow->setDbAutoPlaylistId($showData['add_show_autoplaylist_id']); $ccShow->setDbAutoPlaylistId($showData['add_show_autoplaylist_id']);
} }
//Here a user has edited a show and linked it. //Here a user has edited a show and linked it.

View file

@ -20,4 +20,3 @@
</div> </div>
</dl> </dl>
</fieldset> </fieldset>

View file

@ -13,5 +13,3 @@
} }
?> ?>
</dd> </dd>

View file

@ -15,7 +15,6 @@
<div id="schedule-show-what" class="collapsible-content"> <div id="schedule-show-what" class="collapsible-content">
<?php echo $this->autoplaylist; ?> <?php echo $this->autoplaylist; ?>
</div> </div>
<h3 class="collapsible-header"><span class="arrow-icon"></span><?php echo _("When") ?></h3> <h3 class="collapsible-header"><span class="arrow-icon"></span><?php echo _("When") ?></h3>
<div id="schedule-show-when" class="collapsible-content"> <div id="schedule-show-when" class="collapsible-content">
<?php <?php

View file

@ -274,7 +274,6 @@ function setAddShowEvents(form) {
$("#add_show_playlist_dropdown").show(); $("#add_show_playlist_dropdown").show();
} }
if(!form.find("#add_show_repeats").attr('checked')) { if(!form.find("#add_show_repeats").attr('checked')) {
form.find("#schedule-show-when > fieldset:last").hide(); form.find("#schedule-show-when > fieldset:last").hide();
$("#add_show_rebroadcast_relative").hide(); $("#add_show_rebroadcast_relative").hide();
@ -313,7 +312,6 @@ function setAddShowEvents(form) {
} }
}); });
form.find("#add_show_repeats").click(function(){ form.find("#add_show_repeats").click(function(){
$(this).blur(); $(this).blur();
form.find("#schedule-show-when > fieldset:last").toggle(); form.find("#schedule-show-when > fieldset:last").toggle();