Fix php notices from missing 'feed' and 'owner' attributes.

This commit is contained in:
Matt Lee 2014-10-24 18:20:34 -07:00
parent c8dd28726c
commit 31b6e7971c
2 changed files with 45 additions and 22 deletions

View File

@ -621,17 +621,27 @@
<?php
$default_channels = json_decode($settings->default_channels);
foreach ($default_channels as $channel) :
$thumb_url = '';
$thumb = R::findOne('channel',
' feed = ? LIMIT 1 ', array( $channel->feed )
);
if ($thumb) $thumb_url = $thumb->thumbnail_url;
$name = isset($channel->channel) ? $channel->channel : null;
if (!$name) {
continue;
}
$feed = isset($channel->feed) ? $channel->feed : '';
$owner = isset($channel->owner) ? $channel->owner : 'site';
$thumb = null;
if ($feed) {
$thumb = R::findOne('channel',
' feed = ? LIMIT 1 ', array( $channel->feed )
);
}
$thumb_url = $thumb ? $thumb->thumbnail_url : '';
?>
<li class="channel col-lg-3" data-feed="<?php echo $channel->feed; ?>">
<li class="channel col-lg-3" data-feed="<?php echo $feed; ?>">
<div class="thumbnail"<?php if ($thumb_url != '') : ?> style="background-image: url(<?php echo $thumb_url; ?>);"<?php endif; ?>>
<div class="sponsored"><label><span>Sponsored</span><input type="checkbox" <?php if ($channel->owner == 'sponsor') : ?>checked="checked"<?php endif; ?>/></label></div>
<div class="sponsored"><label><span>Sponsored</span><input type="checkbox" <?php if ($owner == 'sponsor') : ?>checked="checked"<?php endif; ?>/></label></div>
</div>
<span class="name" spellcheck="false" contenteditable="true"><?php echo $channel->channel; ?></span>
<span class="name" spellcheck="false" contenteditable="true"><?php echo $name; ?></span>
</li>
<?php endforeach; ?>
</ul>
@ -672,15 +682,24 @@
<?php
$recommended_channels = json_decode($settings->recommended_channels);
foreach ($recommended_channels as $channel) :
$thumb_url = '';
$thumb = R::findOne('channel',
' feed = ? LIMIT 1 ', array( $channel->feed )
);
if ($thumb) $thumb_url = $thumb->thumbnail_url;
$name = isset($channel->channel) ? $channel->channel : null;
if (!$name) {
continue;
}
$feed = isset($channel->feed) ? $channel->feed : '';
$thumb = null;
if ($feed) {
$thumb = R::findOne('channel',
' feed = ? LIMIT 1 ', array( $channel->feed )
);
}
$thumb_url = $thumb ? $thumb->thumbnail_url : '';
?>
<li class="channel col-lg-3" data-feed="<?php echo $channel->feed; ?>">
<li class="channel col-lg-3" data-feed="<?php echo $feed; ?>">
<div class="thumbnail"<?php if ($thumb_url != '') : ?> style="background-image: url(<?php echo $thumb_url; ?>);"<?php endif; ?>></div>
<span class="name" spellcheck="false" contenteditable="true"><?php echo $channel->channel; ?></span>
<span class="name" spellcheck="false" contenteditable="true"><?php echo $name; ?></span>
</li>
<?php endforeach; ?>
</ul>

View File

@ -18,14 +18,18 @@ function getChannels() {
$db_table = $type . '_channels';
$channels = json_decode($settings->{$db_table});
foreach ($channels as $id => $channel) {
$thumb = R::findOne('channel',
' feed = ? LIMIT 1 ', array( $channel->feed )
);
if (isset($channel->feed)) {
$thumb = R::findOne('channel',
' feed = ? LIMIT 1 ', array( $channel->feed )
);
if ( $thumb && $thumb->thumbnail_url != '' ) {
$channels[$id]->thumbnail = $thumb->thumbnail_url;
}
}
if (!$channels[$id]->owner) $channels[$id]->owner = 'site';
if ( $thumb && $thumb->thumbnail_url != '' )
$channels[$id]->thumbnail = $thumb->thumbnail_url;
if (!isset($channels[$id]->owner) || !$channels[$id]->owner) {
$channels[$id]->owner = 'site';
}
}
$settings_name = $type . '_channels_json';