first commit
This commit is contained in:
25
modules/mod_banners/mod_banners.php
Normal file
25
modules/mod_banners/mod_banners.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_banners
|
||||
*
|
||||
* @copyright (C) 2005 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\Helper\ModuleHelper;
|
||||
use Joomla\Component\Banners\Administrator\Helper\BannersHelper as BannersComponentHelper;
|
||||
use Joomla\Module\Banners\Site\Helper\BannersHelper;
|
||||
|
||||
$headerText = trim($params->get('header_text', ''));
|
||||
$footerText = trim($params->get('footer_text', ''));
|
||||
|
||||
BannersComponentHelper::updateReset();
|
||||
|
||||
$model = $app->bootComponent('com_banners')->getMVCFactory()->createModel('Banners', 'Site', ['ignore_request' => true]);
|
||||
$list = BannersHelper::getList($params, $model, $app);
|
||||
|
||||
require ModuleHelper::getLayoutPath('mod_banners', $params->get('layout', 'default'));
|
||||
154
modules/mod_banners/mod_banners.xml
Normal file
154
modules/mod_banners/mod_banners.xml
Normal file
@ -0,0 +1,154 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="module" client="site" method="upgrade">
|
||||
<name>mod_banners</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2006-07</creationDate>
|
||||
<copyright>(C) 2006 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_BANNERS_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Module\Banners</namespace>
|
||||
<files>
|
||||
<filename module="mod_banners">mod_banners.php</filename>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/mod_banners.ini</language>
|
||||
<language tag="en-GB">language/en-GB/mod_banners.sys.ini</language>
|
||||
</languages>
|
||||
<help key="Site_Modules:_Banners" />
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset
|
||||
name="basic"
|
||||
addfieldprefix="Joomla\Component\Banners\Administrator\Field"
|
||||
>
|
||||
|
||||
<field
|
||||
name="target"
|
||||
type="list"
|
||||
label="MOD_BANNERS_FIELD_TARGET_LABEL"
|
||||
default="1"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JBROWSERTARGET_PARENT</option>
|
||||
<option value="1">JBROWSERTARGET_NEW</option>
|
||||
<option value="2">JBROWSERTARGET_POPUP</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="count"
|
||||
type="number"
|
||||
label="MOD_BANNERS_FIELD_COUNT_LABEL"
|
||||
description="MOD_BANNERS_FIELD_COUNT_DESC"
|
||||
default="5"
|
||||
filter="integer"
|
||||
class="validate-numeric"
|
||||
min="1"
|
||||
validate="number"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cid"
|
||||
type="bannerclient"
|
||||
label="MOD_BANNERS_FIELD_BANNERCLIENT_LABEL"
|
||||
description="MOD_BANNERS_FIELD_BANNERCLIENT_DESC"
|
||||
filter="integer"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="catid"
|
||||
type="category"
|
||||
label="JCATEGORY"
|
||||
extension="com_banners"
|
||||
multiple="true"
|
||||
filter="intarray"
|
||||
class="multipleCategories"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="tag_search"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="MOD_BANNERS_FIELD_TAG_LABEL"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="ordering"
|
||||
type="list"
|
||||
label="MOD_BANNERS_FIELD_RANDOMISE_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">MOD_BANNERS_VALUE_STICKYORDERING</option>
|
||||
<option value="random">MOD_BANNERS_VALUE_STICKYRANDOMISE</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="header_text"
|
||||
type="textarea"
|
||||
label="MOD_BANNERS_FIELD_HEADER_LABEL"
|
||||
filter="safehtml"
|
||||
rows="3"
|
||||
cols="40"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="footer_text"
|
||||
type="textarea"
|
||||
label="MOD_BANNERS_FIELD_FOOTER_LABEL"
|
||||
filter="safehtml"
|
||||
rows="3"
|
||||
cols="40"
|
||||
/>
|
||||
</fieldset>
|
||||
<fieldset name="advanced">
|
||||
<field
|
||||
name="layout"
|
||||
type="modulelayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
validate="moduleLayout"
|
||||
/>
|
||||
|
||||
<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"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
63
modules/mod_banners/src/Helper/BannersHelper.php
Normal file
63
modules/mod_banners/src/Helper/BannersHelper.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_banners
|
||||
*
|
||||
* @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\Banners\Site\Helper;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Environment\Browser;
|
||||
use Joomla\Component\Banners\Site\Model\BannersModel;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Helper for mod_banners
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class BannersHelper
|
||||
{
|
||||
/**
|
||||
* Retrieve list of banners
|
||||
*
|
||||
* @param Registry $params The module parameters
|
||||
* @param BannersModel $model The model
|
||||
* @param CMSApplication $app The application
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getList(Registry $params, BannersModel $model, CMSApplication $app)
|
||||
{
|
||||
$keywords = explode(',', $app->getDocument()->getMetaData('keywords'));
|
||||
$config = ComponentHelper::getParams('com_banners');
|
||||
|
||||
$model->setState('filter.client_id', (int) $params->get('cid'));
|
||||
$model->setState('filter.category_id', $params->get('catid', []));
|
||||
$model->setState('list.limit', (int) $params->get('count', 1));
|
||||
$model->setState('list.start', 0);
|
||||
$model->setState('filter.ordering', $params->get('ordering'));
|
||||
$model->setState('filter.tag_search', $params->get('tag_search'));
|
||||
$model->setState('filter.keywords', $keywords);
|
||||
$model->setState('filter.language', $app->getLanguageFilter());
|
||||
|
||||
$banners = $model->getItems();
|
||||
|
||||
if ($banners) {
|
||||
if ($config->get('track_robots_impressions', 1) == 1 || !Browser::getInstance()->isRobot()) {
|
||||
$model->impress();
|
||||
}
|
||||
}
|
||||
|
||||
return $banners;
|
||||
}
|
||||
}
|
||||
119
modules/mod_banners/tmpl/default.php
Normal file
119
modules/mod_banners/tmpl/default.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_banners
|
||||
*
|
||||
* @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\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\Component\Banners\Site\Helper\BannerHelper;
|
||||
|
||||
?>
|
||||
<div class="mod-banners bannergroup">
|
||||
<?php if ($headerText) : ?>
|
||||
<div class="bannerheader">
|
||||
<?php echo $headerText; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($list as $item) : ?>
|
||||
<div class="mod-banners__item banneritem">
|
||||
<?php $link = Route::_('index.php?option=com_banners&task=click&id=' . $item->id); ?>
|
||||
<?php if ($item->type == 1) : ?>
|
||||
<?php // Text based banners ?>
|
||||
<?php echo str_replace(['{CLICKURL}', '{NAME}'], [$link, $item->name], $item->custombannercode); ?>
|
||||
<?php else : ?>
|
||||
<?php $imageurl = $item->params->get('imageurl'); ?>
|
||||
<?php $width = $item->params->get('width'); ?>
|
||||
<?php $height = $item->params->get('height'); ?>
|
||||
<?php if (BannerHelper::isImage($imageurl)) : ?>
|
||||
<?php // Image based banner ?>
|
||||
<?php $baseurl = strpos($imageurl, 'http') === 0 ? '' : Uri::base(); ?>
|
||||
<?php $alt = $item->params->get('alt'); ?>
|
||||
<?php $alt = $alt ?: $item->name; ?>
|
||||
<?php $alt = $alt ?: Text::_('MOD_BANNERS_BANNER'); ?>
|
||||
<?php if ($item->clickurl) : ?>
|
||||
<?php // Wrap the banner in a link ?>
|
||||
<?php $target = $params->get('target', 1); ?>
|
||||
<?php if ($target == 1) : ?>
|
||||
<?php // Open in a new window ?>
|
||||
<a
|
||||
href="<?php echo $link; ?>" target="_blank" rel="noopener noreferrer"
|
||||
title="<?php echo htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<img
|
||||
src="<?php echo $baseurl . $imageurl; ?>"
|
||||
alt="<?php echo htmlspecialchars($alt, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
<?php if (!empty($width)) {
|
||||
echo 'width="' . $width . '"';
|
||||
} ?>
|
||||
<?php if (!empty($height)) {
|
||||
echo 'height="' . $height . '"';
|
||||
} ?>
|
||||
>
|
||||
</a>
|
||||
<?php elseif ($target == 2) : ?>
|
||||
<?php // Open in a popup window ?>
|
||||
<a
|
||||
href="<?php echo $link; ?>" onclick="window.open(this.href, '',
|
||||
'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');
|
||||
return false"
|
||||
title="<?php echo htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<img
|
||||
src="<?php echo $baseurl . $imageurl; ?>"
|
||||
alt="<?php echo htmlspecialchars($alt, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
<?php if (!empty($width)) {
|
||||
echo 'width="' . $width . '"';
|
||||
} ?>
|
||||
<?php if (!empty($height)) {
|
||||
echo 'height="' . $height . '"';
|
||||
} ?>
|
||||
>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<?php // Open in parent window ?>
|
||||
<a
|
||||
href="<?php echo $link; ?>"
|
||||
title="<?php echo htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<img
|
||||
src="<?php echo $baseurl . $imageurl; ?>"
|
||||
alt="<?php echo htmlspecialchars($alt, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
<?php if (!empty($width)) {
|
||||
echo 'width="' . $width . '"';
|
||||
} ?>
|
||||
<?php if (!empty($height)) {
|
||||
echo 'height="' . $height . '"';
|
||||
} ?>
|
||||
>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<?php // Just display the image if no link specified ?>
|
||||
<img
|
||||
src="<?php echo $baseurl . $imageurl; ?>"
|
||||
alt="<?php echo htmlspecialchars($alt, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
<?php if (!empty($width)) {
|
||||
echo 'width="' . $width . '"';
|
||||
} ?>
|
||||
<?php if (!empty($height)) {
|
||||
echo 'height="' . $height . '"';
|
||||
} ?>
|
||||
>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ($footerText) : ?>
|
||||
<div class="mod-banners__footer bannerfooter">
|
||||
<?php echo $footerText; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user