<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_banners'.DS.'helpers'.DS.'banner.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_banners'.DS.'models'.DS.'banner.php');
// Import library dependencies
jimport('joomla.event.plugin');
class plgContentDYBanners extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for
* plugins because func_get_args ( void ) returns a copy of all passed arguments
* NOT references. This causes problems with cross-referencing necessary for the
* observer design pattern.
*/
function plgContentDYBanners ( &$subject, $config )
{
parent::__construct( $subject, $config );
// load plugin parameters
$this->_plugin = JPluginHelper::getPlugin( 'content', 'dybanners' );
$this->_params = new JParameter( $this->_plugin->params );
// Added in 1.0.3 to Load Language Files
$lang = & JFactory::getLanguage();
$lang->load( 'plg_content_dybanners' , JPATH_ADMINISTRATOR );
// End of 1.0.3 addition
// Added in 1.0.3 to remove the {dybanners}a,b,c,d,e,f{/dybanners} from the content when you print to PDF
$this->flag = $flag;
// End of 1.0.3 addition
}
// Added in 1.0.5 to increment impressions
function impress($list)
{
$n = count($list);
if ($n > 0) {
$db = &JFactory::getDBO();
$date = &JFactory::getDate();
$trackDate = $date->toFormat('%Y-%m-%d');
for ($i = 0; $i < $n; $i++) {
$item = &$list[$i];
$item->impmade++;
$expire = ($item->impmade >= $item->imptotal) && ($item->imptotal != 0);
$query = 'UPDATE #__banner SET impmade=impmade+1'
. ($expire ? ', showBanner=0' : '')
. ' WHERE bid = '.(int)$item->bid;
$db->setQuery($query);
if (!$db->query()) {
JError::raiseError(500, $db->stderror());
}
}
}
}
// End of 1.0.5 addition
// Added in 1.0.3 to remove the {dybanners}a,b,c,d,e,f{/dybanners} from the content when you print to PDF, or to show the banner images
function onBeforeDisplayTitle( &$row, $params=array(), $flag=0 ) {
if ($flag!=32) return true;
$replacethis = array(
'/{dybanners}(.*){\/dybanners}/iU'
);
$bannerpdf = $this->params->get( 'bannerpdf' );
if ($bannerpdf) {
global $mainframe;
global $database;
$db=& JFactory::getDBO();
$error1 = JText::_( 'noavailablebanner' );
$error2 = JText::_( 'bannerfieldempty' );
// Added in 1.0.8
$error3 = JText::_( 'bannerfieldplugindefault' );
// End of 1.0.8 addition
// Find all plugin occurrences
$firsttime = true;
$working = "";
$replacethis = "";
$withthis = "";
$regex = '/{dybanners}(.*){\/dybanners}/iU';
preg_match_all( $regex, $row->text, $matches );
$count = count( $matches[0] );
// Perform once for each plugin occurrence
for ( $i=0; $i < $count; $i++ ) {
// Moved and changed in 1.0.9 for styling
$withthis = '<div id="dybanners'. ($i + 1). '">';
// End of 1.0.9 move/change
$firsttime = true;
$replacethis = $matches[0][$i];
$working = $replacethis;
$working = str_replace( '{dybanners}', '', $working );
$working = str_replace( '{/dybanners}', '', $working );
$working = trim($working);
// Added in 1.0.4 to allow more than one banner inside a single DIV (Side by side)
$countbannersets = 0;
$bannersets = explode(";",$working);
$countbannersets = count( $bannersets );
for ( $j=0; $j < $countbannersets; $j++ ) {
// End of 1.0.4
$bannerid = '';
$windowtype = 1;
$style = '';
$countpartsofbannerset = 0;
$bannerdata = explode(",",$bannersets[$j]);
$countpartsofbannerset = count( $bannerdata );
$bannerid = trim($bannerdata[0]);
// Moved up above the Database calls in 1.0.8 and added default values from the editor button
// Changed in 1.0.2 to improve the output if no settings entered
if ($countpartsofbannerset >1) {
if ((trim($bannerdata[1]) == "") || (trim($bannerdata[1]) == "window_type")) {
$windowtype = 1;
}
else {
$windowtype = trim($bannerdata[1]);
}
}
if ($countpartsofbannerset >2) {
if ((trim($bannerdata[2]) == "") || (trim($bannerdata[2]) == "style_suffix")) {
$style = '';
}
else {
$style = trim($bannerdata[2]);
}
}
if ($countpartsofbannerset >3) {
if ((trim($bannerdata[3]) == "") || (trim($bannerdata[3]) == "image_alt")) {
$alt = $item->name;
}
else {
$alt = trim($bannerdata[3]);
}
}
// End of 1.0.2 changes
// Added in 1.0.8 to allow a random banner selection based on a client or category
if ($countpartsofbannerset >4) {
if ((trim($bannerdata[4]) == "") || (trim($bannerdata[4]) == "client_id")) {
$client = "1";
}
else {
$client = trim($bannerdata[4]);
}
}
if ($countpartsofbannerset >5) {
if ((trim($bannerdata[5]) == "") || (trim($bannerdata[5]) == "category_id")) {
$category = "1";
}
else {
$category = trim($bannerdata[5]);
}
}
// End of 1.0.8 addition
// End of 1.0.8 move
// Added in 1.0.9 for styling
if ($firsttime) {
$withthis .= '<div class="dybannersclass'. $style . '">';
$withthis .= '<p>';
$addclass = true;
}
// End of 1.0.9 addition
// Added in 1.0.2 to get the article title to use as part of the banner name in place of the banner id
// Moved to the top in 1.0.8
if ($bannerid == "") {
$withthis .= $error2;
break;
}
// Added in 1.0.8 for the plugin
else if ($bannerid == "banner_id/title/random") {
$withthis .= $error3;
break;
}
// End of 1.0.8 addtion
// End of 1.0.8 move
else if ($bannerid == "title") {
$content_id = intval(JRequest::getVar('id', 0));
$query = "SELECT id,title"
. "\n FROM #__content"
. "\n WHERE id=".$content_id;
$db->setQuery( $query );
$contentrows = $db->loadObjectList();
$contentitem = $contentrows[0];
if (!$db->query()) {
JError::raiseError( 500, $contentrows->getError());
return;
}
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE name = '$contentitem->title'"
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
// Added in 1.0.7 to allow a random banner selection
else if ($bannerid == "random") {
$query = "SELECT bid,name"
. "\n FROM #__banner"
. "\n WHERE showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$i = count($rows);
$random = mt_rand(1, $i);
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE bid = '$random'"
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
// End of 1.0.7 addition
// Added in 1.0.8 to allow a random banner selection based on a single client or category
else if ($bannerid == "client") {
$query = "SELECT bid,cid"
. "\n FROM #__banner"
. "\n WHERE showBanner = 1"
. "\n AND cid = '$client'";
$db->setQuery( $query );
$banner_ids = $db->loadObjectList();
$banner_id_array_list = array();
foreach( $banner_ids as $o )
{
$banner_id_array_list[] = $o->bid;
}
$array = $banner_id_array_list;
srand((float) microtime() * 10000000);
$last_key = count($array) - 1;
$range = array(0, $last_key);
$rand_array = rand($range[0], $range[1]);
$random_banner_id = $array[$rand_array];
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE bid = '$random_banner_id'"
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
else if ($bannerid == "category") {
$query = "SELECT bid,cid,catid"
. "\n FROM #__banner"
. "\n WHERE showBanner = 1"
. "\n AND catid = '$category'";
$db->setQuery( $query );
$banner_ids = $db->loadObjectList();
$banner_id_array_list = array();
foreach( $banner_ids as $o )
{
$banner_id_array_list[] = $o->bid;
}
$array = $banner_id_array_list;
srand((float) microtime() * 10000000);
$last_key = count($array) - 1;
$range = array(0, $last_key);
$rand_array = rand($range[0], $range[1]);
$random_banner_id = $array[$rand_array];
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE bid = '$random_banner_id'"
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
else if ($bannerid == "clientcategory") {
$query = "SELECT bid,cid,catid"
. "\n FROM #__banner"
. "\n WHERE showBanner = 1"
. "\n AND cid = '$client'"
. "\n AND catid = '$category'";
$db->setQuery( $query );
$banner_ids = $db->loadObjectList();
$banner_id_array_list = array();
foreach( $banner_ids as $o )
{
$banner_id_array_list[] = $o->bid;
}
$array = $banner_id_array_list;
srand((float) microtime() * 10000000);
$last_key = count($array) - 1;
$range = array(0, $last_key);
$rand_array = rand($range[0], $range[1]);
$random_banner_id = $array[$rand_array];
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE bid = '$random_banner_id'"
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
// End of 1.0.8 addition
else {
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE bid=".$bannerid
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
$alt = $item->name;
// End of 1.0.2 addition
// Added in 1.0.5 to increment impressions
$query = 'SELECT bid,imageurl,custombannercode,description,impmade,imptotal FROM #__banner WHERE showBanner=1 AND (imptotal = 0 OR impmade < imptotal) AND bid='.$item->bid;
$db = &JFactory::getDBO();
$db->setQuery($query);
$data = $db->loadObjectList();
plgContentDYBanners::impress($data);
// End of 1.0.5 addition
$link = JRoute::_( 'index.php?option=com_banners&task=click&bid='. $item->bid );
$baseurl = JURI::base();
if (trim($item->custombannercode))
{
// template replacements
$withthispart1 = str_replace( '{CLICKURL}', $link, $item->custombannercode );
$withthis .= str_replace( '{NAME}', $item->name, $withthispart1 );
}
else if (BannerHelper::isImage( $item->imageurl ))
{
// Changed in 1.0.9 for styling
$image = '<img src="'.$baseurl.'images/banners/'.$item->imageurl.'" alt="'.$alt.'" />';
// End of 1.0.9 change
if ($item->clickurl)
{
switch ($windowtype)
{
// Window type
// 0 = Open in parent window
// 1 = Open in new window with navigation
// 2 = Open in pop-up window without navigation
case 0:
$a = '<a href="'. $link .'">';
break;
case 1:
$a = '<a href="'. $link .'" target="_blank">';
break;
case 2:
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
$link = str_replace('index.php', 'index2.php', $link);
$a = '<a href="'.$link.'" onclick="window.open(this.href,\'targetWindow\',\''.$attribs.'\');return false;">';
break;
}
$withthis .= $a . $image . '</a>';
}
else
{
$withthis .= $image;
}
}
else if (BannerHelper::isFlash( $item->imageurl ))
{
$imageurl = $baseurl."images/banners/".$item->imageurl;
$clearimageurl = $baseurl."plugins/content/dybanners/clear.gif";
$size = getimagesize($imageurl);
$width = $size[0];
$height = $size[1];
if ($item->clickurl)
{
switch ($windowtype)
{
// Window type
// 0 = Open in parent window
// 1 = Open in new window with navigation
// 2 = Open in pop-up window without navigation
case 0:
$b = '<a href="'. $link .'">';
break;
case 1:
$b = '<a href="'. $link .'" target="_blank">';
break;
case 2:
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
$link = str_replace('index.php', 'index2.php', $link);
$b = '<a href="'.$link.'" onclick="window.open(this.href,\'targetWindow\',\''.$attribs.'\');return false;">';
break;
}
}
$withthis .= "<object width=\"$width\" height=\"$height\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" border=\"0\">
<param name=\"movie\" value=\"$imageurl\"><embed width=\"$width\" height=\"$height\" src=\"$imageurl\" loop=\"false\" pluginspage=\"http://www.macromedia.com/go/get/flashplayer\" type=\"application/x-shockwave-flash\"></embed>
</object>";
$negheight = $height - $height - $height;
/* Removed in 1.0.9 until a working solution is found
$withthis .= '<p style="position:relative; top:' .$negheight. 'px; z-index:1;">';
$withthis .= $b;
$withthis .= '<img src="'.$clearimageurl.'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'" />';
$withthis .= '</a>';
$withthis .= '</p>';
*/
}
// Added in 1.0.9 for styling
if (($addclass) && (!$firsttime)) {
$withthis .= '</p>';
$withthis .= '</div>';
}
// End of 1.0.9 addition
$firsttime = false;
// Added in 1.0.4 to close the countbannersets
}
// End 1.0.4
$withthis .= '</div>';
$row->text = str_replace( $replacethis, $withthis, $row->text );
}
}
else {
$withthis[] = '';
foreach($replacethis as $item);
$row->text = preg_replace($replacethis, $withthis, $row->text);
return true;
}
}
// End of 1.0.3 addition
function onPrepareContent( &$row, &$params, &$content_id ) {
global $mainframe;
global $database;
$db=& JFactory::getDBO();
$error1 = JText::_( 'noavailablebanner' );
$error2 = JText::_( 'bannerfieldempty' );
// Added in 1.0.8
$error3 = JText::_( 'bannerfieldplugindefault' );
// End of 1.0.8 addition
// Find all plugin occurrences
$firsttime = true;
$working = "";
$replacethis = "";
$withthis = "";
$regex = '/{dybanners}(.*){\/dybanners}/iU';
preg_match_all( $regex, $row->text, $matches );
$count = count( $matches[0] );
// Perform once for each plugin occurrence
for ( $i=0; $i < $count; $i++ ) {
// Moved and changed in 1.0.9 for styling
$withthis = '<div id="dybanners'. ($i + 1). '">';
// End of 1.0.9 move/change
$firsttime = true;
$replacethis = $matches[0][$i];
$working = $replacethis;
$working = str_replace( '{dybanners}', '', $working );
$working = str_replace( '{/dybanners}', '', $working );
$working = trim($working);
// Added in 1.0.4 to allow more than one banner inside a single DIV (Side by side)
$countbannersets = 0;
$bannersets = explode(";",$working);
$countbannersets = count( $bannersets );
for ( $j=0; $j < $countbannersets; $j++ ) {
// End of 1.0.4
$bannerid = '';
$windowtype = 1;
$style = '';
$countpartsofbannerset = 0;
$bannerdata = explode(",",$bannersets[$j]);
$countpartsofbannerset = count( $bannerdata );
$bannerid = trim($bannerdata[0]);
// Moved up above the Database calls in 1.0.8 and added default values from the editor button
// Changed in 1.0.2 to improve the output if no settings entered
if ($countpartsofbannerset >1) {
if ((trim($bannerdata[1]) == "") || (trim($bannerdata[1]) == "window_type")) {
$windowtype = 1;
}
else {
$windowtype = trim($bannerdata[1]);
}
}
if ($countpartsofbannerset >2) {
if ((trim($bannerdata[2]) == "") || (trim($bannerdata[2]) == "style_suffix")) {
$style = '';
}
else {
$style = trim($bannerdata[2]);
}
}
if ($countpartsofbannerset >3) {
if ((trim($bannerdata[3]) == "") || (trim($bannerdata[3]) == "image_alt")) {
$alt = $item->name;
}
else {
$alt = trim($bannerdata[3]);
}
}
// End of 1.0.2 changes
// Added in 1.0.8 to allow a random banner selection based on a client or category
if ($countpartsofbannerset >4) {
if ((trim($bannerdata[4]) == "") || (trim($bannerdata[4]) == "client_id")) {
$client = "1";
}
else {
$client = trim($bannerdata[4]);
}
}
if ($countpartsofbannerset >5) {
if ((trim($bannerdata[5]) == "") || (trim($bannerdata[5]) == "category_id")) {
$category = "1";
}
else {
$category = trim($bannerdata[5]);
}
}
// End of 1.0.8 addition
// End of 1.0.8 move
// Added in 1.0.9 for styling
if ($firsttime) {
$withthis .= '<div class="dybannersclass'. $style . '">';
$withthis .= '<p>';
$addclass = true;
}
// End of 1.0.9 addition
// Added in 1.0.2 to get the article title to use as part of the banner name in place of the banner id
// Moved to the top in 1.0.8
if ($bannerid == "") {
$withthis .= $error2;
break;
}
// Added in 1.0.8 for the plugin
else if ($bannerid == "banner_id/title/random") {
$withthis .= $error3;
break;
}
// End of 1.0.8 addtion
// End of 1.0.8 move
else if ($bannerid == "title") {
$content_id = intval(JRequest::getVar('id', 0));
$query = "SELECT id,title"
. "\n FROM #__content"
. "\n WHERE id=".$content_id;
$db->setQuery( $query );
$contentrows = $db->loadObjectList();
$contentitem = $contentrows[0];
if (!$db->query()) {
JError::raiseError( 500, $contentrows->getError());
return;
}
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE name = '$contentitem->title'"
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
// Added in 1.0.7 to allow a random banner selection
else if ($bannerid == "random") {
$query = "SELECT bid,name"
. "\n FROM #__banner"
. "\n WHERE showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$i = count($rows);
$random = mt_rand(1, $i);
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE bid = '$random'"
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
// End of 1.0.7 addition
// Added in 1.0.8 to allow a random banner selection based on a single client or category
else if ($bannerid == "client") {
$query = "SELECT bid,cid"
. "\n FROM #__banner"
. "\n WHERE showBanner = 1"
. "\n AND cid = '$client'";
$db->setQuery( $query );
$banner_ids = $db->loadObjectList();
$banner_id_array_list = array();
foreach( $banner_ids as $o )
{
$banner_id_array_list[] = $o->bid;
}
$array = $banner_id_array_list;
srand((float) microtime() * 10000000);
$last_key = count($array) - 1;
$range = array(0, $last_key);
$rand_array = rand($range[0], $range[1]);
$random_banner_id = $array[$rand_array];
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE bid = '$random_banner_id'"
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
else if ($bannerid == "category") {
$query = "SELECT bid,cid,catid"
. "\n FROM #__banner"
. "\n WHERE showBanner = 1"
. "\n AND catid = '$category'";
$db->setQuery( $query );
$banner_ids = $db->loadObjectList();
$banner_id_array_list = array();
foreach( $banner_ids as $o )
{
$banner_id_array_list[] = $o->bid;
}
$array = $banner_id_array_list;
srand((float) microtime() * 10000000);
$last_key = count($array) - 1;
$range = array(0, $last_key);
$rand_array = rand($range[0], $range[1]);
$random_banner_id = $array[$rand_array];
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE bid = '$random_banner_id'"
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
else if ($bannerid == "clientcategory") {
$query = "SELECT bid,cid,catid"
. "\n FROM #__banner"
. "\n WHERE showBanner = 1"
. "\n AND cid = '$client'"
. "\n AND catid = '$category'";
$db->setQuery( $query );
$banner_ids = $db->loadObjectList();
$banner_id_array_list = array();
foreach( $banner_ids as $o )
{
$banner_id_array_list[] = $o->bid;
}
$array = $banner_id_array_list;
srand((float) microtime() * 10000000);
$last_key = count($array) - 1;
$range = array(0, $last_key);
$rand_array = rand($range[0], $range[1]);
$random_banner_id = $array[$rand_array];
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE bid = '$random_banner_id'"
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
// End of 1.0.8 addition
else {
$query = "SELECT bid,name,imageurl,clickurl,custombannercode"
. "\n FROM #__banner"
. "\n WHERE bid=".$bannerid
. "\n AND showBanner = 1";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$item = $rows[0];
$bannercount = count( $item );
if ((!$db->query()) || ($bannercount < 1) ) {
$withthis .= $error1;
}
}
$alt = $item->name;
// End of 1.0.2 addition
// Added in 1.0.5 to increment impressions
$query = 'SELECT bid,imageurl,custombannercode,description,impmade,imptotal FROM #__banner WHERE showBanner=1 AND (imptotal = 0 OR impmade < imptotal) AND bid='.$item->bid;
$db = &JFactory::getDBO();
$db->setQuery($query);
$data = $db->loadObjectList();
plgContentDYBanners::impress($data);
// End of 1.0.5 addition
$link = JRoute::_( 'index.php?option=com_banners&task=click&bid='. $item->bid );
$baseurl = JURI::base();
if (trim($item->custombannercode))
{
// template replacements
$withthispart1 = str_replace( '{CLICKURL}', $link, $item->custombannercode );
$withthis .= str_replace( '{NAME}', $item->name, $withthispart1 );
}
else if (BannerHelper::isImage( $item->imageurl ))
{
// Changed in 1.0.9 for styling
$image = '<img src="'.$baseurl.'images/banners/'.$item->imageurl.'" alt="'.$alt.'" />';
// End of 1.0.9 change
if ($item->clickurl)
{
switch ($windowtype)
{
// Window type
// 0 = Open in parent window
// 1 = Open in new window with navigation
// 2 = Open in pop-up window without navigation
case 0:
$a = '<a href="'. $link .'">';
break;
case 1:
$a = '<a href="'. $link .'" target="_blank">';
break;
case 2:
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
$link = str_replace('index.php', 'index2.php', $link);
$a = '<a href="'.$link.'" onclick="window.open(this.href,\'targetWindow\',\''.$attribs.'\');return false;">';
break;
}
$withthis .= $a . $image . '</a>';
}
else
{
$withthis .= $image;
}
}
else if (BannerHelper::isFlash( $item->imageurl ))
{
$imageurl = $baseurl."images/banners/".$item->imageurl;
$clearimageurl = $baseurl."plugins/content/dybanners/clear.gif";
$size = getimagesize($imageurl);
$width = $size[0];
$height = $size[1];
if ($item->clickurl)
{
switch ($windowtype)
{
// Window type
// 0 = Open in parent window
// 1 = Open in new window with navigation
// 2 = Open in pop-up window without navigation
case 0:
$b = '<a href="'. $link .'">';
break;
case 1:
$b = '<a href="'. $link .'" target="_blank">';
break;
case 2:
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
$link = str_replace('index.php', 'index2.php', $link);
$b = '<a href="'.$link.'" onclick="window.open(this.href,\'targetWindow\',\''.$attribs.'\');return false;">';
break;
}
}
$withthis .= "<object width=\"$width\" height=\"$height\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" border=\"0\">
<param name=\"movie\" value=\"$imageurl\"><embed width=\"$width\" height=\"$height\" src=\"$imageurl\" loop=\"false\" pluginspage=\"http://www.macromedia.com/go/get/flashplayer\" type=\"application/x-shockwave-flash\"></embed>
</object>";
$negheight = $height - $height - $height;
/* Removed in 1.0.9 until a working solution is found
$withthis .= '<p style="position:relative; top:' .$negheight. 'px; z-index:1;">';
$withthis .= $b;
$withthis .= '<img src="'.$clearimageurl.'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'" />';
$withthis .= '</a>';
$withthis .= '</p>';
*/
}
// Added in 1.0.9 for styling
if (($addclass) && (!$firsttime)) {
$withthis .= '</p>';
$withthis .= '</div>';
}
// End of 1.0.9 addition
$firsttime = false;
// Added in 1.0.4 to close the countbannersets
}
// End 1.0.4
$withthis .= '</div>';
$row->text = str_replace( $replacethis, $withthis, $row->text );
}
return true;
}
}