From: <ma...@us...> - 2012-06-24 16:14:40
|
Revision: 9702 http://xoops.svn.sourceforge.net/xoops/?rev=9702&view=rev Author: mageg Date: 2012-06-24 16:14:34 +0000 (Sun, 24 Jun 2012) Log Message: ----------- Adding preloads for banner management Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoops.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/admin/banners.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/banners_blocks.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/index.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/admin/banners_admin_banners.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/banners_client.html Added Paths: ----------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/class/renderbanner.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads/core.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads/index.html Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoops.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoops.php 2012-06-24 15:44:53 UTC (rev 9701) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoops.php 2012-06-24 16:14:34 UTC (rev 9702) @@ -581,26 +581,6 @@ /** * @param mixed $optional * - * @return XoopsBannerHandler - */ - public function getHandlerBanner($optional = false) - { - return $this->getHandler('banner', $optional); - } - - /** - * @param mixed $optional - * - * @return XoopsBannerclientHandler - */ - public function getHandlerBannerclient($optional = false) - { - return $this->getHandler('bannerclient', $optional); - } - - /** - * @param mixed $optional - * * @return XoopsBlockHandler */ public function getHandlerBlock($optional = false) @@ -1298,80 +1278,13 @@ /** * Function to get banner html tags for use in templates * - * @param int $nb_banner - * @param string $align - * @param array $client - * @param string $ids - * * @return string */ - public function getBanner($nb_banner = 1, $align = 'H', $client = array(), $ids = '') + public function getBanner() { - if ($this->isActiveModule('banners')) { - // Get banners handler - $banner_Handler = $this->getHandlerBanner(); - // Display banner - $criteria = new CriteriaCompo(); - $criteria->add(new Criteria('status', 0, '!=')); - $criteria->setSort('RAND()'); - if (!empty($client)) { - if (!in_array(0,$client)) { - $criteria->add(new Criteria('cid', '(' . implode(',', $client) . ')','IN')); - } - } - if ($ids == '') { - $criteria->setLimit($nb_banner); - $criteria->setStart(0); - } else { - $criteria->add(new Criteria('bid', '(' . $ids . ')','IN')); - } - $banner_arr = $banner_Handler->getall($criteria); - $numrows = count($banner_arr); - $bannerobject = ''; - if ($numrows > 0) { - foreach (array_keys($banner_arr) as $i) { - $imptotal = $banner_arr[$i]->getVar("imptotal"); - $impmade = $banner_arr[$i]->getVar("impmade"); - $htmlbanner = $banner_arr[$i]->getVar("htmlbanner"); - $htmlcode = $banner_arr[$i]->getVar("htmlcode"); - $imageurl = $banner_arr[$i]->getVar("imageurl"); - $bid = $banner_arr[$i]->getVar("bid"); - $clickurl = $banner_arr[$i]->getVar("clickurl"); - /** - * Print the banner - */ - if ($htmlbanner) { - $bannerobject .= $htmlcode; - } else { - if (stristr($imageurl, '.swf')) { - $bannerobject .= '<a href="' . XOOPS_URL . '/modules/banners/index.php?op=click&bid=' . $bid . '" rel="external" title="' . $clickurl . '"></a>' . '<object type="application/x-shockwave-flash" width="468" height="60" data="' . $imageurl . '" style="z-index:100;">' . '<param name="movie" value="' . $imageurl . '" />' . '<param name="wmode" value="opaque" />' . '</object>'; - } else { - $bannerobject .= '<a href="' . XOOPS_URL . '/modules/banners/index.php?op=click&bid=' . $bid . '" rel="external" title="' . $clickurl . '"><img src="' . $imageurl . '" alt="' . $clickurl . '" /></a>'; - } - } - if ($align == 'V') { - $bannerobject .= '<br /><br />'; - } else { - $bannerobject .= ' '; - } - if ($this->getModuleConfig('banners_myip', 'banners') == $this->getEnv('REMOTE_ADDR')) { - // EMPTY - } else { - /** - * Check if this impression is the last one - */ - $impmade = $impmade + 1; - if ($imptotal > 0 && $impmade >= $imptotal) { - $this->db->queryF(sprintf('UPDATE %s SET status = %u, dateend = %u WHERE bid = %u', $this->db->prefix('banner'), 0, time(), $bid)); - }else{ - $this->db->queryF(sprintf('UPDATE %s SET impmade = %u WHERE bid = %u', $this->db->prefix('banner'), $impmade, $bid)); - } - } - } - return $bannerobject; - } - } - return ''; + $options = ''; + $this->preload->triggerEvent('core.banner.display', array(&$options)); + return $options; } /** Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/admin/banners.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/admin/banners.php 2012-06-24 15:44:53 UTC (rev 9701) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/admin/banners.php 2012-06-24 16:14:34 UTC (rev 9702) @@ -202,7 +202,7 @@ $admin_page->renderButton(); $obj = $banner_Handler->create(); $form = $xoops->getModuleForm($obj, 'banner'); - $form->render(); + $form->render(); $xoops->tpl->assign('form', true); break; Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/banners_blocks.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/banners_blocks.php 2012-06-24 15:44:53 UTC (rev 9701) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/banners_blocks.php 2012-06-24 16:14:34 UTC (rev 9702) @@ -22,7 +22,8 @@ function banners_blocks_show($options) { $block = array(); $xoops = Xoops::getInstance(); - //echo $options[3] . ' - ' . $options[3]; + require_once dirname(dirname(__FILE__)) . '/class/renderbanner.php'; + $render = new RenderBanner(); switch ($options[0]) { case 'random': $nb_display = $options[1]; @@ -31,13 +32,13 @@ array_shift($options); array_shift($options); $client = $options; - $block['banners'] = $xoops->getBanner($nb_display, $align, $client); + $block['banners'] = $render->displayBanner($nb_display, $align, $client); break; case 'id': $ids = $options[1]; $align = $options[2]; - $block['banners'] = $xoops->getBanner(1, $align, 0, $ids); + $block['banners'] = $render->displayBanner(1, $align, 0, $ids); break; } return $block; @@ -69,7 +70,7 @@ array_shift($options); $form .= _MB_BANNERS_CLIENTSTODISPLAY . "<br /><select name=\"options[]\" multiple=\"multiple\" size=\"5\">\n"; $xoops = Xoops::getInstance(); - $client_Handler = $xoops->getHandlerBannerclient(); + $client_Handler = $xoops->getModuleHandler('bannerclient','banners'); $criteria = new CriteriaCompo(); $criteria->setSort('name'); $criteria->setOrder('ASC'); Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/class/renderbanner.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/class/renderbanner.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/class/renderbanner.php 2012-06-24 16:14:34 UTC (rev 9702) @@ -0,0 +1,111 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * banners module + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package banners + * @since 2.6.0 + * @author Mage Gr\xE9gory (AKA Mage) + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class RenderBanner +{ + /** + * Constructor + */ + public function __construct() + { + + } + + /** + * Display banner + * @param $nb_banner + * @param $align + * @param $client + * @param $ids + * @return string + */ + public function displayBanner($nb_banner = 1, $align = 'H', $client = array(), $ids = '') + { + $xoops = Xoops::getInstance(); + if ($xoops->isActiveModule('banners')) { + // Get banners handler + $banner_Handler = $xoops->getModuleHandler('banner','banners'); + // Display banner + $criteria = new CriteriaCompo(); + $criteria->add(new Criteria('status', 0, '!=')); + $criteria->setSort('RAND()'); + if (!empty($client)) { + if (!in_array(0,$client)) { + $criteria->add(new Criteria('cid', '(' . implode(',', $client) . ')','IN')); + } + } + if ($ids == '') { + $criteria->setLimit($nb_banner); + $criteria->setStart(0); + } else { + $criteria->add(new Criteria('bid', '(' . $ids . ')','IN')); + } + $banner_arr = $banner_Handler->getall($criteria); + $numrows = count($banner_arr); + $bannerobject = ''; + if ($numrows > 0) { + foreach (array_keys($banner_arr) as $i) { + $imptotal = $banner_arr[$i]->getVar("imptotal"); + $impmade = $banner_arr[$i]->getVar("impmade"); + $htmlbanner = $banner_arr[$i]->getVar("htmlbanner"); + $htmlcode = $banner_arr[$i]->getVar("htmlcode"); + $imageurl = $banner_arr[$i]->getVar("imageurl"); + $bid = $banner_arr[$i]->getVar("bid"); + $clickurl = $banner_arr[$i]->getVar("clickurl"); + /** + * Print the banner + */ + if ($htmlbanner) { + $bannerobject .= $htmlcode; + } else { + if (stristr($imageurl, '.swf')) { + $bannerobject .= '<a href="' . XOOPS_URL . '/modules/banners/index.php?op=click&bid=' . $bid . '" rel="external" title="' . $clickurl . '"></a>' . '<object type="application/x-shockwave-flash" width="468" height="60" data="' . $imageurl . '" style="z-index:100;">' . '<param name="movie" value="' . $imageurl . '" />' . '<param name="wmode" value="opaque" />' . '</object>'; + } else { + $bannerobject .= '<a href="' . XOOPS_URL . '/modules/banners/index.php?op=click&bid=' . $bid . '" rel="external" title="' . $clickurl . '"><img src="' . $imageurl . '" alt="' . $clickurl . '" /></a>'; + } + } + if ($align == 'V') { + $bannerobject .= '<br /><br />'; + } else { + $bannerobject .= ' '; + } + if ($xoops->getModuleConfig('banners_myip', 'banners') == $xoops->getEnv('REMOTE_ADDR')) { + // EMPTY + } else { + /** + * Check if this impression is the last one + */ + $impmade = $impmade + 1; + if ($imptotal > 0 && $impmade >= $imptotal) { + $xoops->db->queryF(sprintf('UPDATE %s SET status = %u, dateend = %u WHERE bid = %u', $this->db->prefix('banner'), 0, time(), $bid)); + }else{ + $xoops->db->queryF(sprintf('UPDATE %s SET impmade = %u WHERE bid = %u', $this->db->prefix('banner'), $impmade, $bid)); + } + } + } + return $bannerobject; + } + } + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/class/renderbanner.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/index.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/index.php 2012-06-24 15:44:53 UTC (rev 9701) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/index.php 2012-06-24 16:14:34 UTC (rev 9702) @@ -269,7 +269,8 @@ $form->addElement(new XoopsFormHidden('op', 'save')); $form->addElement(new XoopsFormHidden('bid', $obj->getVar('bid'))); $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); - $xoops->tpl->assign('form', $form->render()); + $form->render(); + $xoops->tpl->assign('form', true); $xoops->footer(); } else { $xoops->redirect(XOOPS_URL, 1, _MD_BANNERS_INDEX_DBERROR); Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads/core.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads/core.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads/core.php 2012-06-24 16:14:34 UTC (rev 9702) @@ -0,0 +1,45 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * banners module + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package banners + * @since 2.6.0 + * @author Mage Gr\xE9gory (AKA Mage) + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +/** + * Banners core preloads + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @author Mage Gr\xE9gory (AKA Mage) + */ +class BannersCorePreload extends XoopsPreloadItem +{ + /** + * @static + * @param array $args + * @return void + */ + static public function eventCoreBannerDisplay($args) + { + require_once dirname(dirname(__FILE__)) . '/class/renderbanner.php'; + $render = new RenderBanner(); + $args[0] = $render->displayBanner(); + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads/core.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads/index.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads/index.html (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/preloads/index.html 2012-06-24 16:14:34 UTC (rev 9702) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/admin/banners_admin_banners.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/admin/banners_admin_banners.html 2012-06-24 15:44:53 UTC (rev 9701) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/admin/banners_admin_banners.html 2012-06-24 16:14:34 UTC (rev 9702) @@ -4,7 +4,7 @@ <!--Banner--> <{if $banner_count == true}> <h4><{$smarty.const._AM_BANNERS_BANNERS_CURRENT}></h4> -<table id="xo-bannerslist-sorter" cellspacing="1" class="outer tablesorter"> +<table id="xo-bannerslist-sorter" class="outer tablesorter"> <thead> <tr> <th class="txtcenter"><{$smarty.const._AM_BANNERS_BANNERS_IMPRESSIONS}></th> @@ -52,7 +52,7 @@ <!--Banner Finish--> <{if $banner_finish_count == true}> <h4><{$smarty.const._AM_BANNERS_BANNERS_FINISH}></h4> -<table id="xo-bannersfinish-sorter" cellspacing="1" class="outer tablesorter"> +<table id="xo-bannersfinish-sorter" class="outer tablesorter"> <thead> <tr> <th class="txtcenter"><{$smarty.const._AM_BANNERS_BANNERS_IMPRESSIONS}></th> Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/banners_client.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/banners_client.html 2012-06-24 15:44:53 UTC (rev 9701) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/banners_client.html 2012-06-24 16:14:34 UTC (rev 9702) @@ -1,6 +1,6 @@ <{if $banner_count == true}> <h4><{$smarty.const._AM_BANNERS_BANNERS_CURRENT}></h4> -<table id="xo-bannerslist-sorter" cellspacing="1" class="outer tablesorter"> +<table id="xo-bannerslist-sorter" class="outer tablesorter"> <thead> <tr> <th class="txtcenter width5"><{$smarty.const._MD_BANNERS_INDEX_ID}></th> @@ -54,7 +54,7 @@ <!--Banner Finish--> <{if $banner_finish_count == true}> <h4><{$smarty.const._AM_BANNERS_BANNERS_FINISH}></h4> -<table id="xo-bannersfinish-sorter" cellspacing="1" class="outer tablesorter"> +<table id="xo-bannersfinish-sorter" class="outer tablesorter"> <thead> <tr> <th class="txtcenter width5"><{$smarty.const._MD_BANNERS_INDEX_ID}></th> @@ -109,5 +109,5 @@ <{/if}> <!-- Display form (edit) --> <{if $form}> -<div class="spacer"><{$form}></div> +<{includeq file="module:system|system_form.html"}> <{/if}> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |