/components/com_newsfeeds/tmpl/newsfeed/default.php

https://github.com/joomla/joomla-cms · PHP · 157 lines · 144 code · 6 blank · 7 comment · 16 complexity · c3d6313405224793820149dd99ff3b67 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Site
  4. * @subpackage com_newsfeeds
  5. *
  6. * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. defined('_JEXEC') or die;
  10. use Joomla\CMS\Factory;
  11. use Joomla\CMS\Filter\OutputFilter;
  12. use Joomla\CMS\HTML\HTMLHelper;
  13. use Joomla\CMS\Language\Text;
  14. use Joomla\CMS\Layout\FileLayout;
  15. use Joomla\CMS\Layout\LayoutHelper;
  16. ?>
  17. <?php if (!empty($this->msg)) : ?>
  18. <?php echo $this->msg; ?>
  19. <?php else : ?>
  20. <?php $lang = Factory::getLanguage(); ?>
  21. <?php $myrtl = $this->item->rtl; ?>
  22. <?php $direction = ' '; ?>
  23. <?php $isRtl = $lang->isRtl(); ?>
  24. <?php if ($isRtl && $myrtl == 0) : ?>
  25. <?php $direction = ' redirect-rtl'; ?>
  26. <?php elseif ($isRtl && $myrtl == 1) : ?>
  27. <?php $direction = ' redirect-ltr'; ?>
  28. <?php elseif ($isRtl && $myrtl == 2) : ?>
  29. <?php $direction = ' redirect-rtl'; ?>
  30. <?php elseif ($myrtl == 0) : ?>
  31. <?php $direction = ' redirect-ltr'; ?>
  32. <?php elseif ($myrtl == 1) : ?>
  33. <?php $direction = ' redirect-ltr'; ?>
  34. <?php elseif ($myrtl == 2) : ?>
  35. <?php $direction = ' redirect-rtl'; ?>
  36. <?php endif; ?>
  37. <?php $images = json_decode($this->item->images); ?>
  38. <div class="com-newsfeeds-newsfeed newsfeed<?php echo $direction; ?>">
  39. <?php if ($this->params->get('display_num')) : ?>
  40. <h1 class="<?php echo $direction; ?>">
  41. <?php echo $this->escape($this->params->get('page_heading')); ?>
  42. </h1>
  43. <?php endif; ?>
  44. <h2 class="<?php echo $direction; ?>">
  45. <?php if ($this->item->published == 0) : ?>
  46. <span class="badge bg-warning text-light"><?php echo Text::_('JUNPUBLISHED'); ?></span>
  47. <?php endif; ?>
  48. <a href="<?php echo $this->item->link; ?>" target="_blank" rel="noopener">
  49. <?php echo str_replace('&apos;', "'", $this->item->name); ?>
  50. </a>
  51. </h2>
  52. <?php if ($this->params->get('show_tags', 1)) : ?>
  53. <?php $this->item->tagLayout = new FileLayout('joomla.content.tags'); ?>
  54. <?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
  55. <?php endif; ?>
  56. <!-- Show Images from Component -->
  57. <?php if (isset($images->image_first) && !empty($images->image_first)) : ?>
  58. <?php $imgfloat = empty($images->float_first) ? $this->params->get('float_first') : $images->float_first; ?>
  59. <div class="com-newsfeeds-newsfeed__first-image img-intro-<?php echo $this->escape($imgfloat); ?>">
  60. <figure>
  61. <?php echo LayoutHelper::render(
  62. 'joomla.html.image',
  63. [
  64. 'src' => $images->image_first,
  65. 'alt' => empty($images->image_first_alt) && empty($images->image_first_alt_empty) ? false : $images->image_first_alt,
  66. ]
  67. ); ?>
  68. <?php if ($images->image_first_caption) : ?>
  69. <figcaption class="caption"><?php echo $this->escape($images->image_first_caption); ?></figcaption>
  70. <?php endif; ?>
  71. </figure>
  72. </div>
  73. <?php endif; ?>
  74. <?php if (isset($images->image_second) and !empty($images->image_second)) : ?>
  75. <?php $imgfloat = empty($images->float_second) ? $this->params->get('float_second') : $images->float_second; ?>
  76. <div class="com-newsfeeds-newsfeed__second-image float-<?php echo $this->escape($imgfloat); ?> item-image">
  77. <figure>
  78. <?php echo LayoutHelper::render(
  79. 'joomla.html.image',
  80. [
  81. 'src' => $images->image_second,
  82. 'alt' => empty($images->image_second_alt) && empty($images->image_second_alt_empty) ? false : $images->image_second_alt,
  83. ]
  84. ); ?>
  85. <?php if ($images->image_second_caption) : ?>
  86. <figcaption class="caption"><?php echo $this->escape($images->image_second_caption); ?></figcaption>
  87. <?php endif; ?>
  88. </figure>
  89. </div>
  90. <?php endif; ?>
  91. <!-- Show Description from Component -->
  92. <?php echo $this->item->description; ?>
  93. <!-- Show Feed's Description -->
  94. <?php if ($this->params->get('show_feed_description')) : ?>
  95. <div class="com-newsfeeds-newsfeed__description feed-description">
  96. <?php echo str_replace('&apos;', "'", $this->rssDoc->description); ?>
  97. </div>
  98. <?php endif; ?>
  99. <!-- Show Image -->
  100. <?php if ($this->rssDoc->image && $this->params->get('show_feed_image')) : ?>
  101. <div class="com-newsfeeds-newsfeed__feed-image">
  102. <?php echo LayoutHelper::render(
  103. 'joomla.html.image',
  104. [
  105. 'src' => $this->rssDoc->image->uri,
  106. 'alt' => $this->rssDoc->image->title,
  107. ]
  108. ); ?>
  109. </div>
  110. <?php endif; ?>
  111. <!-- Show items -->
  112. <?php if (!empty($this->rssDoc[0])) : ?>
  113. <ol class="com-newsfeeds-newsfeed__items">
  114. <?php for ($i = 0; $i < $this->item->numarticles; $i++) : ?>
  115. <?php if (empty($this->rssDoc[$i])) : ?>
  116. <?php break; ?>
  117. <?php endif; ?>
  118. <?php $uri = $this->rssDoc[$i]->uri || !$this->rssDoc[$i]->isPermaLink ? trim($this->rssDoc[$i]->uri) : trim($this->rssDoc[$i]->guid); ?>
  119. <?php $uri = !$uri || stripos($uri, 'http') !== 0 ? $this->item->link : $uri; ?>
  120. <?php $text = $this->rssDoc[$i]->content !== '' ? trim($this->rssDoc[$i]->content) : ''; ?>
  121. <li>
  122. <?php if (!empty($uri)) : ?>
  123. <h3 class="feed-link">
  124. <a href="<?php echo htmlspecialchars($uri); ?>" target="_blank" rel="noopener">
  125. <?php echo trim($this->rssDoc[$i]->title); ?>
  126. </a>
  127. </h3>
  128. <?php else : ?>
  129. <h3 class="feed-link"><?php echo trim($this->rssDoc[$i]->title); ?></h3>
  130. <?php endif; ?>
  131. <?php if ($this->params->get('show_item_description') && $text !== '') : ?>
  132. <div class="feed-item-description">
  133. <?php if ($this->params->get('show_feed_image', 0) == 0) : ?>
  134. <?php $text = OutputFilter::stripImages($text); ?>
  135. <?php endif; ?>
  136. <?php $text = HTMLHelper::_('string.truncate', $text, $this->params->get('feed_character_count')); ?>
  137. <?php echo str_replace('&apos;', "'", $text); ?>
  138. </div>
  139. <?php endif; ?>
  140. </li>
  141. <?php endfor; ?>
  142. </ol>
  143. <?php endif; ?>
  144. </div>
  145. <?php endif; ?>