Merge branch 'master' into smartblock-overflow

This commit is contained in:
frecuencialibre 2018-12-11 14:17:18 -06:00 committed by GitHub
commit c7b55f60e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
72 changed files with 3804 additions and 3949 deletions

View file

@ -15,7 +15,7 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm
// Add autoplaylist checkbox element
$this->addElement('checkbox', 'add_show_has_autoplaylist', array(
'label' => _('Auto Schedule Playlist ?'),
'label' => _('Add Autoloading Playlist ?'),
'required' => false,
'class' => 'input_text',
'decorators' => array('ViewHelper')
@ -29,7 +29,7 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm
$this->addElement($autoPlaylistSelect);
// Add autoplaylist checkbox element
$this->addElement('checkbox', 'add_show_autoplaylist_repeat', array(
'label' => _('Repeat AutoPlaylist Until Show is Full ?'),
'label' => _('Repeat Playlist Until Show is Full ?'),
'required' => false,
'class' => 'input_text',
'decorators' => array('ViewHelper')

View file

@ -485,15 +485,6 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$limitValue->setValue(1);
}
//getting block content candidate count that meets criteria
$bl = new Application_Model_Block($p_blockId);
if ($p_isValid) {
$files = $bl->getListofFilesMeetCriteria();
$showPoolCount = true;
} else {
$files = null;
$showPoolCount = false;
}
$generate = new Zend_Form_Element_Button('generate_button');
$generate->setAttrib('class', 'sp-button btn');

View file

@ -1475,7 +1475,7 @@ SQL;
foreach ($out as $crit) {
$criteria = $crit->getDbCriteria();
$modifier = $crit->getDbModifier();
$value = htmlspecialchars($crit->getDbValue());
$value = $crit->getDbValue();
$extra = $crit->getDbExtra();
if ($criteria == "limit") {

View file

@ -1,251 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'imported_podcast' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class ImportedPodcast extends BaseImportedPodcast
{
// These fields should never be modified with POST/PUT data
private static $privateFields = array(
"id",
"url",
"type",
"owner"
);
/** Creates a Podcast object from the given podcast URL.
* This is used by our Podcast REST API
*
* @param $data An array containing the URL for a Podcast object.
*
* @return array - Podcast Array with a full list of episodes
* @throws Exception
* @throws InvalidPodcastException
* @throws PodcastLimitReachedException
*/
public static function create($data)
{
if (Application_Service_PodcastService::podcastLimitReached()) {
throw new PodcastLimitReachedException();
}
$rss = Application_Service_PodcastService::getPodcastFeed($data["url"]);
if (!$rss) {
throw new InvalidPodcastException();
}
// Ensure we are only creating Podcast with the given URL, and excluding
// any extra data fields that may have been POSTED
$podcastArray = array();
$podcastArray["url"] = $data["url"];
$podcastArray["title"] = $rss->get_title();
$podcastArray["description"] = $rss->get_description();
$podcastArray["link"] = $rss->get_link();
$podcastArray["language"] = $rss->get_language();
$podcastArray["copyright"] = $rss->get_copyright();
$podcastArray["creator"] = $rss->get_author()->get_name();
$podcastArray["category"] = $rss->get_categories();
$itunesChannel = "http://www.itunes.com/dtds/podcast-1.0.dtd";
$itunesSubtitle = $rss->get_channel_tags($itunesChannel, 'subtitle');
$podcastArray["itunes_subtitle"] = isset($itunesSubtitle[0]["data"]) ? $itunesSubtitle[0]["data"] : "";
$itunesCategory = $rss->get_channel_tags($itunesChannel, 'category');
$categoryArray = array();
foreach ($itunesCategory as $c => $data) {
foreach ($data["attribs"] as $attrib) {
array_push($categoryArray, $attrib["text"]);
}
}
$podcastArray["itunes_category"] = implode(",", $categoryArray);
$itunesAuthor = $rss->get_channel_tags($itunesChannel, 'author');
$podcastArray["itunes_author"] = isset($itunesAuthor[0]["data"]) ? $itunesAuthor[0]["data"] : "";
$itunesSummary = $rss->get_channel_tags($itunesChannel, 'summary');
$podcastArray["itunes_summary"] = isset($itunesSummary[0]["data"]) ? $itunesSummary[0]["data"] : "";
$itunesKeywords = $rss->get_channel_tags($itunesChannel, 'keywords');
$podcastArray["itunes_keywords"] = isset($itunesKeywords[0]["data"]) ? $itunesKeywords[0]["data"] : "";
$itunesExplicit = $rss->get_channel_tags($itunesChannel, 'explicit');
$podcastArray["itunes_explicit"] = isset($itunesExplicit[0]["data"]) ? $itunesExplicit[0]["data"] : "";
self::validatePodcastMetadata($podcastArray);
try {
$podcast = new ImportedPodcast();
$podcast->fromArray($podcastArray, BasePeer::TYPE_FIELDNAME);
$podcast->setDbOwner(self::getOwnerId());
$podcast->setDbType(IMPORTED_PODCAST);
$podcast->save();
return self::_generatePodcastArray($podcast, $rss);
} catch(Exception $e) {
$podcast->delete();
throw $e;
}
}
/**
* Fetches a Podcast's rss feed and returns all its episodes with
* the Podcast object
*
* @param $podcastId
*
* @throws PodcastNotFoundException
* @throws InvalidPodcastException
* @return array - Podcast Array with a full list of episodes
*/
public static function getPodcastById($podcastId)
{
$podcast = PodcastQuery::create()->findPk($podcastId);
if (!$podcast) {
throw new PodcastNotFoundException();
}
$rss = Application_Service_PodcastService::getPodcastFeed($podcast->getDbUrl());
if (!$rss) {
throw new InvalidPodcastException();
}
return self::_generatePodcastArray($podcast, $rss);
}
/**
* Given a podcast object and a SimplePie feed object,
* generate a data array to pass back to the front-end
*
* @param Podcast $podcast Podcast model object
* @param SimplePie $rss SimplePie feed object
*
* @return array
*/
private static function _generatePodcastArray($podcast, $rss) {
$podcastArray = $podcast->toArray(BasePeer::TYPE_FIELDNAME);
$podcastArray["episodes"] = array();
foreach ($rss->get_items() as $item) {
/** @var SimplePie_Item $item */
array_push($podcastArray["episodes"], array(
"guid" => $item->get_id(),
"title" => $item->get_title(),
"author" => $item->get_author()->get_name(),
"description" => $item->get_description(),
"pub_date" => $item->get_date("Y-m-d H:i:s"),
"link" => $item->get_link(),
"enclosure" => $item->get_enclosure()
));
}
return $podcastArray;
}
/**
* Updates a Podcast object with the given metadata
*
* @param $podcastId
* @param $data
* @return array
* @throws Exception
* @throws PodcastNotFoundException
*/
public static function updateFromArray($podcastId, $data)
{
$podcast = PodcastQuery::create()->findPk($podcastId);
if (!$podcast) {
throw new PodcastNotFoundException();
}
self::removePrivateFields($data);
self::validatePodcastMetadata($data);
$podcast->fromArray($data, BasePeer::TYPE_FIELDNAME);
$podcast->save();
return $podcast->toArray(BasePeer::TYPE_FIELDNAME);
}
/**
* Deletes a Podcast and its podcast episodes
*
* @param $podcastId
* @throws Exception
* @throws PodcastNotFoundException
*/
public static function deleteById($podcastId)
{
$podcast = PodcastQuery::create()->findPk($podcastId);
if ($podcast) {
$podcast->delete();
} else {
throw new PodcastNotFoundException();
}
}
/**
* Trims the podcast metadata to fit the table's column max size
*
* @param $podcastArray
*/
private static function validatePodcastMetadata(&$podcastArray)
{
$podcastTable = PodcastPeer::getTableMap();
foreach ($podcastArray as $key => &$value) {
try {
// Make sure column exists in table
$columnMaxSize = $podcastTable->getColumn($key)->getSize();
} catch (PropelException $e) {
continue;
}
if (strlen($value) > $columnMaxSize) {
$value = substr($value, 0, $podcastTable->getColumn($key)->getSize());
}
}
}
private static function removePrivateFields(&$data)
{
foreach (self::$privateFields as $key) {
unset($data[$key]);
}
}
//TODO move this somewhere where it makes sense
private static function getOwnerId()
{
try {
if (Zend_Auth::getInstance()->hasIdentity()) {
$service_user = new Application_Service_UserService();
return $service_user->getCurrentUser()->getDbId();
} else {
$defaultOwner = CcSubjsQuery::create()
->filterByDbType('A')
->orderByDbId()
->findOne();
if (!$defaultOwner) {
// what to do if there is no admin user?
// should we handle this case?
return null;
}
return $defaultOwner->getDbId();
}
} catch(Exception $e) {
Logging::info($e->getMessage());
}
}
}

View file

@ -7,9 +7,11 @@
</dt>
<dd>
<?php echo $this->element->getElement('add_show_has_autoplaylist') ?>
<span class="show_autoplaylist_help_icon" aria-describedby="ui-tooltip-2"></span>
</dd>
<div id="add_show_playlist_dropdown">
<p><?php echo _("Autoloading playlists' contents are added to shows one hour before the show airs. <a target='_blank' href='http://libretime.org/manual/calendar/#autoloading-playlist'>More information</a>"); ?></p>
<dt id="add_show_autoplaylist_id">
<label for="add_show_autoplaylist_id" class="required">
<?php echo $this->element->getElement('add_show_autoplaylist_id')->getLabel()?>

View file

@ -2,6 +2,23 @@
$items = $this->contents;
$isSmartBlock = ($this->obj instanceof Application_Model_Block);
$isPlaylist = ($this->obj instanceof Application_Model_Playlist);
if ($this->showPoolCount) { ?>
<div class='sp_text_font sp_text_font_bold'>
<span id='sp_pool_count' class='sp_text_font sp_text_font_bold'>
<?php
echo $this->poolCount;
echo ngettext(" track matches your search criteria.", " tracks match your search criteria.", $this->poolCount);
?>
</span>
<?php if ($this->poolCount > 0) { ?>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php }
else { ?>
<span class='sp-warning-icon' id='sp_pool_count_icon'></span>
<?php } ?>
</div>
<?php
}
if (count($items) && ($isSmartBlock || $isPlaylist)) : ?>
<?php $i = 0; ?>
<?php if ($isSmartBlock && !($this->obj->isStatic())) {
@ -148,4 +165,4 @@ if (($i < count($items) -1) && ($items[$i+1]['type'] == 0)) {
}
?>
</div>
<?php endif; ?>
<?php endif; ?>

View file

@ -25,7 +25,7 @@
<?php echo $this->repeats; ?>
</div>
<h3 class="collapsible-header"><span class="arrow-icon"></span><?php echo _("Automatic Playlist") ?></h3>
<h3 class="collapsible-header"><span class="arrow-icon"></span><?php echo _("Autoloading Playlist") ?></h3>
<div id="schedule-show-auto" class="collapsible-content">
<?php echo $this->autoplaylist; ?>
</div>
@ -33,12 +33,6 @@
<div id="live-stream-override" class="collapsible-content">
<?php echo $this->live; ?>
</div>
<h3 class="collapsible-header"><span class="arrow-icon"></span><?php echo _("Record & Rebroadcast")?></h3>
<div id="schedule-record-rebroadcast" class="collapsible-content">
<?php echo $this->rr; ?>
<?php echo $this->absoluteRebroadcast; ?>
<?php echo $this->rebroadcast; ?>
</div>
<h3 class="collapsible-header"><span class="arrow-icon"></span><?php echo _("Who") ?></h3>
<div id="schedule-show-who" class="collapsible-content">
<?php echo $this->who; ?>