Центрирование рекламного кода в статье на Joomla 2.5

B
На сайте с 03.08.2012
Offline
12
975

Добрый день.

На сайте под управлением CMS Joomla 2.5 используется плагин Ultimate Google AdSense Plugin для отображения рекламы Google adsense. Проблема в том, что при включении плагина в статьях он позиционируется с левой стороны статьи, что не очень красиво. Пытаюсь поставить по центру правкой самого php файла плагина, не получается. Подскажите пожалуйста решение.

Вот сам код плагина:

<?php

/**
* @package Ultimate Google AdSense Plugin By WebSoft
* @subpackage Advertisement
* @copyright Copyright (C) 2011 Websoft Agency <office@websoftserbia.com>. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

jimport('joomla.plugin.plugin');

class plgContentUGAPBW extends JPlugin {

public function __construct($subject, $params){

parent::__construct($subject, $params);

}

public function onContentPrepare($context, &$article, &$params, $limitstart) {

if( JRequest::getWord( "view" ) == "article" ) {

$app =& JFactory::getApplication();
if( $app->isAdmin() ) { return; }

$doc = JFactory::getDocument();
if( $doc->getType() != "html" ) { return; }

$ips = array_map( "trim", explode( ",", $this->params->get( 'blockedIPs' ) ) );
if( in_array( $_SERVER["REMOTE_ADDR"], $ips ) ) { return "<div style='clear:both;'>".$this->params->get('altMessage')."</div>"; }


$ads = array();

if( isset($article) == null || empty($article->id) || isset($this->params) == null ) { return; }

foreach( array('top', 'middle', 'bottom') as $type ) {
$ads[$type] = $this->prepareAdSenseCode($article, $params, $type);
}

if( isset( $ads['middle'] ) ) {

$array = explode('<p>', $article->text);
$count = count($array);
if( $count == 1 ) {
$article->text .= $ads['middle'];
}
else {
$article->text = str_replace("<p> </p>", "########!!!!!!@@@@@@@%%%%%%%%", $article->text);
$temp = $added = null;
for($i=0; $i<$count; $i++) {
$temp .= "<p>".$array[$i];
if( $added == null ) {
if( $count < 4 && $i == 1 ) { $temp .= $ads['middle']; $added = true; }
else if( $count < 5 && $i == 2 ) { $temp .= $ads['middle']; $added = true; }
else if( $i == 3 ) { $temp .= $ads['middle']; $added = true; }
}
}
}
$article->text = $temp;
$article->text = str_replace("########!!!!!!@@@@@@@%%%%%%%%", "<p> </p>", $article->text);
}
if( isset( $ads['top'] ) ) {
$article->text = $ads['top'].$article->text;
}
if( isset( $ads['bottom'] ) ) {
$article->text = $article->text.$ads['bottom'];
}
}
}

private function prepareAdSenseCode(&$article, &$params, &$type){

if( $this->params->get( $type.'Enabled' ) == 0 ) { return; }

// Exluded Articles
$excludedCats = $this->params->get( 'excludeCats' );
$excludeArticles = $this->params->get( 'excludeArticles' );
if( $excludedCats ) { array_map( "trim", $excludedCats = explode(',', $excludedCats) ); }
if( $excludeArticles ) { array_map( "trim", $excludeArticles = explode(',', $excludeArticles) ); }
settype($excludedCats, 'array');
settype($excludeArticles, 'array');
if( in_array( $article->catid, $excludedCats ) || in_array( $article->id, $excludeArticles ) ) { return; }


$publisherId = $this->params->get($type.'PublisherId');
$slotId = $this->params->get($type.'Slot');
$adType = $this->params->get($type.'Type');
$unitName = $this->params->get($type.'Name');
$adFormat = $this->params->get($type.'Format');
$format = explode("-", $adFormat);
$width = explode("x", $format[0]);
$height = explode("_", $width[1]);

$emptyLine = $title = null;
if ( $this->params->get($type.'EmptyLine') == "yes" ) { $emptyLine = "<br />\n"; }
if ( $this->params->get($type.'Title') ) { $title = "\t\t<p>".$this->params->get($type.'Title')."</p>"; }
return $emptyLine.$title.'
<!-- Ultimate Google AdSense Plugin By WebSoft http://websoftserbia.com -->
<script type="text/javascript"><!--
google_ad_client = "' . $publisherId . '";
/* "' . $unitName . '" */
google_ad_slot = "' . $slotId . '";
google_ad_width = "' . $width[0] . '";
google_ad_height = "' . $height[0] . '";
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>'.$emptyLine.$emptyLine;

}
}


---------- Добавлено 16.05.2013 в 21:07 ----------

Подскажите люди добрые):)

---------- Добавлено 16.05.2013 в 21:38 ----------

Все решил. Спасибо):crazy:

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий