Skip to content

Commit

Permalink
[Newsfeeds] Use item link instead of guid. (#20717)
Browse files Browse the repository at this point in the history
* Feed links

* Restore http check for now

* CS

* Some cleanups
  • Loading branch information
SharkyKZ authored and Michael Babker committed Jun 12, 2018
1 parent 0c737b5 commit 534bcac
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
14 changes: 7 additions & 7 deletions administrator/modules/mod_feed/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,20 @@
if (!$feed->offsetExists($i)) :
break;
endif;
$uri = (!empty($feed[$i]->uri) || !is_null($feed[$i]->uri)) ? $feed[$i]->uri : $feed[$i]->guid;
$uri = substr($uri, 0, 4) != 'http' ? $params->get('rsslink') : $uri;
$text = !empty($feed[$i]->content) || !is_null($feed[$i]->content) ? $feed[$i]->content : $feed[$i]->description;
$uri = $feed[$i]->uri || !$feed[$i]->isPermaLink ? trim($feed[$i]->uri) : trim($feed[$i]->guid);
$uri = !$uri || stripos($uri, 'http') !== 0 ? $params->get('rsslink') : $uri;
$text = $feed[$i]->content !== '' ? trim($feed[$i]->content) : '';
?>
<li>
<?php if (!empty($uri)) : ?>
<h5 class="feed-link">
<a href="<?php echo $uri; ?>" target="_blank">
<?php echo $feed[$i]->title; ?></a></h5>
<?php echo trim($feed[$i]->title); ?></a></h5>
<?php else : ?>
<h5 class="feed-link"><?php echo $feed[$i]->title; ?></h5>
<?php endif; ?>
<h5 class="feed-link"><?php echo trim($feed[$i]->title); ?></h5>
<?php endif; ?>

<?php if ($params->get('rssitemdesc') && !empty($text)) : ?>
<?php if ($params->get('rssitemdesc') && $text !== '') : ?>
<div class="feed-item-description">
<?php
// Strip the images.
Expand Down
13 changes: 6 additions & 7 deletions components/com_newsfeeds/views/newsfeed/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,20 @@
<?php if (empty($this->rssDoc[$i])) : ?>
<?php break; ?>
<?php endif; ?>
<?php $uri = !empty($this->rssDoc[$i]->guid) || $this->rssDoc[$i]->guid !== null ? trim($this->rssDoc[$i]->guid) : trim($this->rssDoc[$i]->uri); ?>
<?php $uri = strpos($uri, 'http') !== 0 ? $this->item->link : $uri; ?>
<?php $text = !empty($this->rssDoc[$i]->content) || $this->rssDoc[$i]->content !== null ? trim($this->rssDoc[$i]->content) : trim($this->rssDoc[$i]->description); ?>
<?php $title = trim($this->rssDoc[$i]->title); ?>
<?php $uri = $this->rssDoc[$i]->uri || !$this->rssDoc[$i]->isPermaLink ? trim($this->rssDoc[$i]->uri) : trim($this->rssDoc[$i]->guid); ?>
<?php $uri = !$uri || stripos($uri, 'http') !== 0 ? $this->item->link : $uri; ?>
<?php $text = $this->rssDoc[$i]->content !== '' ? trim($this->rssDoc[$i]->content) : ''; ?>
<li>
<?php if (!empty($uri)) : ?>
<h3 class="feed-link">
<a href="<?php echo htmlspecialchars($uri); ?>" target="_blank">
<?php echo $title; ?>
<?php echo trim($this->rssDoc[$i]->title); ?>
</a>
</h3>
<?php else : ?>
<h3 class="feed-link"><?php echo $title; ?></h3>
<h3 class="feed-link"><?php echo trim($this->rssDoc[$i]->title); ?></h3>
<?php endif; ?>
<?php if ($this->params->get('show_item_description') && !empty($text)) : ?>
<?php if ($this->params->get('show_item_description') && $text !== '') : ?>
<div class="feed-item-description">
<?php if ($this->params->get('show_feed_image', 0) == 0) : ?>
<?php $text = JFilterOutput::stripImages($text); ?>
Expand Down
1 change: 1 addition & 0 deletions libraries/src/Feed/Parser/RssParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ protected function processFeedEntry(FeedEntry $entry, \SimpleXMLElement $el)
$entry->updatedDate = (string) $el->pubDate;
$entry->content = (string) $el->description;
$entry->guid = (string) $el->guid;
$entry->isPermaLink = $entry->guid === '' || (string) $el->guid['isPermaLink'] === 'false' ? false : true;
$entry->comments = (string) $el->comments;

// Add the feed entry author if available.
Expand Down
16 changes: 7 additions & 9 deletions modules/mod_feed/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
$iUrl = isset($feed->image) ? $feed->image : null;
$iTitle = isset($feed->imagetitle) ? $feed->imagetitle : null;
?>
<div style="direction: <?php echo $rssrtl ? 'rtl' :'ltr'; ?>; text-align: <?php echo $rssrtl ? 'right' :'left'; ?> !important" class="feed<?php echo $moduleclass_sfx; ?>">
<div style="direction: <?php echo $rssrtl ? 'rtl' :'ltr'; ?>; text-align: <?php echo $rssrtl ? 'right' :'left'; ?> !important" class="feed<?php echo $moduleclass_sfx; ?>">
<?php
// Feed description
if ($feed->title !== null && $params->get('rsstitle', 1))
Expand Down Expand Up @@ -90,26 +90,24 @@
<ul class="newsfeed<?php echo $params->get('moduleclass_sfx'); ?>">
<?php for ($i = 0, $max = min(count($feed), $params->get('rssitems', 5)); $i < $max; $i++) { ?>
<?php
$uri = (!empty($feed[$i]->uri) || $feed[$i]->uri !== null) ? trim($feed[$i]->uri) : trim($feed[$i]->guid);
$uri = strpos($uri, 'http') !== 0 ? $params->get('rsslink') : $uri;
$text = !empty($feed[$i]->content) || $feed[$i]->content !== null ? trim($feed[$i]->content) : trim($feed[$i]->description);
$title = trim($feed[$i]->title);
$uri = $feed[$i]->uri || !$feed[$i]->isPermaLink ? trim($feed[$i]->uri) : trim($feed[$i]->guid);
$uri = !$uri || stripos($uri, 'http') !== 0 ? $params->get('rsslink') : $uri;
$text = $feed[$i]->content !== '' ? trim($feed[$i]->content) : '';
?>
<li>
<?php if (!empty($uri)) : ?>
<span class="feed-link">
<a href="<?php echo htmlspecialchars($uri, ENT_COMPAT, 'UTF-8'); ?>" target="_blank">
<?php echo $feed[$i]->title; ?></a></span>
<?php echo trim($feed[$i]->title); ?></a></span>
<?php else : ?>
<span class="feed-link"><?php echo $title; ?></span>
<span class="feed-link"><?php echo trim($feed[$i]->title); ?></span>
<?php endif; ?>

<?php if (!empty($text) && $params->get('rssitemdesc')) : ?>
<?php if ($params->get('rssitemdesc') && $text !== '') : ?>
<div class="feed-item-description">
<?php
// Strip the images.
$text = JFilterOutput::stripImages($text);

$text = JHtml::_('string.truncate', $text, $params->get('word_count'));
echo str_replace('&apos;', "'", $text);
?>
Expand Down

0 comments on commit 534bcac

Please sign in to comment.