1
0
mirror of https://github.com/e107inc/e107.git synced 2025-02-13 19:15:19 +01:00
php-e107/e107_plugins/banner/banner_menu.php

102 lines
2.3 KiB
PHP
Raw Normal View History

<?php
/*
2009-11-17 10:46:35 +00:00
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
2009-11-17 10:46:35 +00:00
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
/**
* e107 Banner management plugin
*
* Handles the display and sequencing of banners on web pages, including counting impressions
*
* @package e107_plugins
* @subpackage banner
2009-11-17 10:46:35 +00:00
*/
if (!defined('e107_INIT')) { exit; }
/*
To define your own banner to use here ...
1. Go to admin -> banners and create a campaign, then add your banner to it
2. Add this line to this file ...
$campaign = NAME_OF_YOUR_CAMPAIGN
3. Save file
*/
//include_lan(e_PLUGIN.'banner/languages/'.e_LANGUAGE.'_menu_banner.php');
2009-11-19 22:02:19 +00:00
if(file_exists(THEME.'banner_template.php'))
{
require_once (THEME.'banner_template.php');
2009-11-19 22:02:19 +00:00
}
else
{
require_once (e_PLUGIN.'banner/banner_template.php');
}
$menu_pref = e107::getConfig('menu')->getPref('');
if(isset($campaign))
{
2009-11-19 22:02:19 +00:00
$parm = $campaign;
$bannersccode = file_get_contents(e_CORE.'shortcodes/single/banner.sc'); // FIXME file not there?
2009-11-19 22:02:19 +00:00
$BANNER = eval($bannersccode);
$txt = $BANNER_MENU_START;
$txt .= preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_MENU);
$txt .= $BANNER_MENU_END;
}
else
{
2009-11-19 22:02:19 +00:00
if(isset($menu_pref['banner_campaign']) && $menu_pref['banner_campaign'])
{
$parms = array();
2009-11-19 22:02:19 +00:00
if(strstr($menu_pref['banner_campaign'], "|"))
{
$campaignlist = explode('|', $menu_pref['banner_campaign']);
2009-11-19 22:02:19 +00:00
$amount = ($menu_pref['banner_amount'] < 1 ? '1' : $menu_pref['banner_amount']);
$amount = ($amount > count($campaignlist) ? count($campaignlist) : $amount);
$keys = array_rand($campaignlist, $amount); // If one entry, returns a single value
if (!is_array($keys))
{
$keys = array($keys);
}
2009-11-19 22:02:19 +00:00
foreach ($keys as $k=>$v)
{
$parms[] = $campaignlist[$v];
}
}
else
{
$parms[] = $menu_pref['banner_campaign'];
}
}
2010-02-10 21:53:56 +00:00
2009-11-19 22:02:19 +00:00
$txt = $BANNER_MENU_START;
foreach ($parms as $parm)
{
2010-02-10 21:53:56 +00:00
$bannersccode = file_get_contents(e_CORE.'shortcodes/banner.sc');
2009-11-19 22:02:19 +00:00
$BANNER = eval($bannersccode);
$txt .= preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_MENU);
}
2009-11-19 22:02:19 +00:00
$txt .= $BANNER_MENU_END;
}
2009-11-19 22:02:19 +00:00
if(isset($menu_pref['banner_rendertype']) && $menu_pref['banner_rendertype'] == 2)
{
2009-11-19 22:02:19 +00:00
$ns->tablerender($menu_pref['banner_caption'], $txt);
}
else
{
2009-11-19 22:02:19 +00:00
echo $txt;
}
2009-11-19 22:02:19 +00:00
?>