first commit
This commit is contained in:
17
administrator/modules/mod_feed/mod_feed.php
Normal file
17
administrator/modules/mod_feed/mod_feed.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_feed
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
$feed = \Joomla\Module\Feed\Administrator\Helper\FeedHelper::getFeed($params);
|
||||
$rssurl = $params->get('rssurl', '');
|
||||
$rssrtl = $params->get('rssrtl', 0);
|
||||
|
||||
require \Joomla\CMS\Helper\ModuleHelper::getLayoutPath('mod_feed', $params->get('layout', 'default'));
|
||||
157
administrator/modules/mod_feed/mod_feed.xml
Normal file
157
administrator/modules/mod_feed/mod_feed.xml
Normal file
@ -0,0 +1,157 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="module" client="administrator" method="upgrade">
|
||||
<name>mod_feed</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2005-07</creationDate>
|
||||
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>MOD_FEED_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Module\Feed</namespace>
|
||||
<files>
|
||||
<filename module="mod_feed">mod_feed.php</filename>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/mod_feed.ini</language>
|
||||
<language tag="en-GB">language/en-GB/mod_feed.sys.ini</language>
|
||||
</languages>
|
||||
<help key="Admin_Modules:_Feed_Display" />
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="rssurl"
|
||||
type="url"
|
||||
label="MOD_FEED_FIELD_RSSURL_LABEL"
|
||||
filter="url"
|
||||
required="true"
|
||||
validate="url"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="rssrtl"
|
||||
type="radio"
|
||||
label="MOD_FEED_FIELD_RTL_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="rssdate"
|
||||
type="radio"
|
||||
label="MOD_FEED_FIELD_DATE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="rssdesc"
|
||||
type="radio"
|
||||
label="MOD_FEED_FIELD_DESCRIPTION_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="rssimage"
|
||||
type="radio"
|
||||
label="MOD_FEED_FIELD_IMAGE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="rssitems"
|
||||
type="number"
|
||||
label="MOD_FEED_FIELD_ITEMS_LABEL"
|
||||
default="3"
|
||||
filter="integer"
|
||||
min="1"
|
||||
validate="number"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="rssitemdesc"
|
||||
type="radio"
|
||||
label="MOD_FEED_FIELD_ITEMDESCRIPTION_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="rssitemdate"
|
||||
type="radio"
|
||||
label="MOD_FEED_FIELD_ITEMDATE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
<fieldset name="advanced">
|
||||
<field
|
||||
name="layout"
|
||||
type="modulelayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="moduleclass_sfx"
|
||||
type="textarea"
|
||||
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
|
||||
rows="3"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cache"
|
||||
type="list"
|
||||
label="COM_MODULES_FIELD_CACHING_LABEL"
|
||||
default="1"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="cache_time"
|
||||
type="number"
|
||||
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
|
||||
default="900"
|
||||
filter="integer"
|
||||
min="1"
|
||||
validate="number"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
55
administrator/modules/mod_feed/src/Helper/FeedHelper.php
Normal file
55
administrator/modules/mod_feed/src/Helper/FeedHelper.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_feed
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Module\Feed\Administrator\Helper;
|
||||
|
||||
use Joomla\CMS\Feed\FeedFactory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Helper for mod_feed
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class FeedHelper
|
||||
{
|
||||
/**
|
||||
* Method to load a feed.
|
||||
*
|
||||
* @param \Joomla\Registry\Registry $params The parameters object.
|
||||
*
|
||||
* @return \Joomla\CMS\Feed\Feed|string Return a JFeedReader object or a string message if error.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getFeed($params)
|
||||
{
|
||||
// Module params
|
||||
$rssurl = $params->get('rssurl', '');
|
||||
|
||||
// Get RSS parsed object
|
||||
try {
|
||||
$feed = new FeedFactory();
|
||||
$rssDoc = $feed->getFeed($rssurl);
|
||||
} catch (\Exception $e) {
|
||||
return Text::_('MOD_FEED_ERR_FEED_NOT_RETRIEVED');
|
||||
}
|
||||
|
||||
if (empty($rssDoc)) {
|
||||
return Text::_('MOD_FEED_ERR_FEED_NOT_RETRIEVED');
|
||||
}
|
||||
|
||||
return $rssDoc;
|
||||
}
|
||||
}
|
||||
118
administrator/modules/mod_feed/tmpl/default.php
Normal file
118
administrator/modules/mod_feed/tmpl/default.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_feed
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Filter\OutputFilter;
|
||||
|
||||
// Check if feed URL has been set
|
||||
if (empty($rssurl)) {
|
||||
echo '<div>' . Text::_('MOD_FEED_ERR_NO_URL') . '</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($feed) && is_string($feed)) {
|
||||
echo $feed;
|
||||
} else {
|
||||
$lang = $app->getLanguage();
|
||||
$myrtl = $params->get('rssrtl', 0);
|
||||
$direction = ' ';
|
||||
|
||||
if ($lang->isRtl() && $myrtl == 0) {
|
||||
$direction = ' redirect-rtl';
|
||||
} elseif ($lang->isRtl() && $myrtl == 1) {
|
||||
// Feed description
|
||||
$direction = ' redirect-ltr';
|
||||
} elseif ($lang->isRtl() && $myrtl == 2) {
|
||||
$direction = ' redirect-rtl';
|
||||
} elseif ($myrtl == 0) {
|
||||
$direction = ' redirect-ltr';
|
||||
} elseif ($myrtl == 1) {
|
||||
$direction = ' redirect-ltr';
|
||||
} elseif ($myrtl == 2) {
|
||||
$direction = ' redirect-rtl';
|
||||
}
|
||||
|
||||
if ($feed != false) :
|
||||
?>
|
||||
<div style="direction: <?php echo $rssrtl ? 'rtl' : 'ltr'; ?>; text-align: <?php echo $rssrtl ? 'right' : 'left'; ?> !important" class="feed">
|
||||
<?php
|
||||
|
||||
// Feed title
|
||||
if (!is_null($feed->title) && $params->get('rsstitle', 1)) : ?>
|
||||
<h2 class="<?php echo $direction; ?>">
|
||||
<a href="<?php echo str_replace('&', '&', $rssurl); ?>" target="_blank" rel="noopener noreferrer">
|
||||
<?php echo $feed->title; ?></a>
|
||||
</h2>
|
||||
<?php endif;
|
||||
// Feed date
|
||||
if ($params->get('rssdate', 1)) : ?>
|
||||
<h3>
|
||||
<?php echo HTMLHelper::_('date', $feed->publishedDate, Text::_('DATE_FORMAT_LC3')); ?>
|
||||
</h3>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // Feed description ?>
|
||||
<?php if ($params->get('rssdesc', 1)) : ?>
|
||||
<?php echo $feed->description; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // Feed image ?>
|
||||
<?php if ($params->get('rssimage', 1) && $feed->image) : ?>
|
||||
<img class="w-100" src="<?php echo $feed->image->uri; ?>" alt="<?php echo $feed->image->title; ?>"/>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php // Show items ?>
|
||||
<?php if (!empty($feed)) : ?>
|
||||
<ul class="newsfeed list-group">
|
||||
<?php for ($i = 0; $i < $params->get('rssitems', 3); $i++) :
|
||||
if (!$feed->offsetExists($i)) :
|
||||
break;
|
||||
endif;
|
||||
$uri = $feed[$i]->uri || !$feed[$i]->isPermaLink ? trim($feed[$i]->uri) : trim($feed[$i]->guid);
|
||||
$uri = !$uri || stripos($uri, 'http') !== 0 ? $rssurl : $uri;
|
||||
$text = $feed[$i]->content !== '' ? trim($feed[$i]->content) : '';
|
||||
?>
|
||||
<li class="list-group-item mb-2">
|
||||
<?php if (!empty($uri)) : ?>
|
||||
<h5 class="feed-link">
|
||||
<a href="<?php echo $uri; ?>" target="_blank">
|
||||
<?php echo trim($feed[$i]->title); ?></a></h5>
|
||||
<?php else : ?>
|
||||
<h5 class="feed-link"><?php echo trim($feed[$i]->title); ?></h5>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($params->get('rssitemdate', 0)) : ?>
|
||||
<div class="feed-item-date">
|
||||
<?php echo HTMLHelper::_('date', $feed[$i]->publishedDate, Text::_('DATE_FORMAT_LC3')); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($params->get('rssitemdesc', 1) && $text !== '') : ?>
|
||||
<div class="feed-item-description">
|
||||
<?php
|
||||
// Strip the images.
|
||||
$text = OutputFilter::stripImages($text);
|
||||
$text = HTMLHelper::_('string.truncate', $text, $params->get('word_count', 0), true, false);
|
||||
echo str_replace(''', "'", $text);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endfor; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif;
|
||||
}
|
||||
Reference in New Issue
Block a user