mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 20:58:30 +01:00
Banner plugin may use keywords to display relevant banners on current news/pages. (exact match only, so use with caution)
This commit is contained in:
parent
e9869319f3
commit
85f67aa084
@ -2885,7 +2885,9 @@ class e_form
|
||||
}
|
||||
|
||||
$tags = str_replace(', ',',', $tags); //BC Fix, all tags should be comma separated without spaces ie. one,two NOT one, two
|
||||
|
||||
|
||||
e107::setRegistry('core/form/related',$tags); // TODO Move to elsewhere so it works without rendering? e107::related() set and get by plugins?
|
||||
|
||||
if(!varset($parm['limit']))
|
||||
{
|
||||
$parm = array('limit' => 5);
|
||||
@ -2925,7 +2927,10 @@ class e_form
|
||||
continue;
|
||||
}
|
||||
|
||||
$parm['current'] = intval(varset($curVal[$plug]));
|
||||
$parm['current'] = intval(varset($curVal[$plug]));
|
||||
|
||||
|
||||
|
||||
|
||||
$tmp = $obj->compile($tags,$parm);
|
||||
|
||||
|
@ -125,6 +125,7 @@ class banner_ui extends e_admin_ui
|
||||
'banner_tooltip' => array ( 'title' => BNRLAN_49, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'center', 'thclass' => 'center', ),
|
||||
|
||||
'banner_description' => array ( 'title' => LAN_DESCRIPTION, 'type' => 'textarea', 'data' => 'str', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'banner_keywords' => array ( 'title' => LAN_KEYWORDS, 'type' => 'tags', 'data' => 'str', 'width' => 'auto', 'filter' => false, 'help' => 'When news or pages are loaded, this will limit banner result to matching keywords. Use with caution.', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
|
||||
'banner_startdate' => array ( 'title' => BNRLAN_17, 'type' => 'datestamp', 'tab'=>1,'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'banner_enddate' => array ( 'title' => BNRLAN_18, 'type' => 'datestamp', 'tab'=>1, 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
|
@ -101,7 +101,14 @@ if(!empty($menu_pref['banner_campaign']) && !empty($menu_pref['banner_amount']))
|
||||
$query = " (banner_startdate=0 OR banner_startdate <= {$time}) AND (banner_enddate=0 OR banner_enddate > {$time}) AND (banner_impurchased=0 OR banner_impressions<=banner_impurchased)";
|
||||
$query .= (count($filter)) ? " AND (".implode(" OR ",$filter)." ) " : "";
|
||||
$query .= ($parm ? " AND banner_campaign='".$tp->toDB($parm)."'" : '');
|
||||
|
||||
|
||||
|
||||
if($tags = e107::getRegistry('core/form/related'))
|
||||
{
|
||||
$tags_regexp = "'(^|,)(".str_replace(",", "|", $tags).")(,|$)'";
|
||||
$query .= " AND banner_keywords REGEXP ".$tags_regexp;
|
||||
}
|
||||
|
||||
$query .= " AND banner_active IN (".USERCLASS_LIST.") ORDER BY RAND($seed) LIMIT ".intval($menu_pref['banner_amount']);
|
||||
|
||||
if($data = $sql->retrieve('banner', 'banner_id, banner_image, banner_clickurl,banner_campaign, banner_description', $query,true))
|
||||
@ -122,7 +129,6 @@ if(!empty($menu_pref['banner_campaign']) && !empty($menu_pref['banner_amount']))
|
||||
|
||||
$foot = e107::getParser()->parseTemplate($BANNER_MENU_END,true);
|
||||
|
||||
|
||||
switch ($menu_pref['banner_rendertype'])
|
||||
{
|
||||
|
||||
|
@ -15,5 +15,6 @@ CREATE TABLE banner (
|
||||
banner_tooltip varchar(250) NOT NULL default '',
|
||||
banner_description text NOT NULL,
|
||||
banner_campaign varchar(150) NOT NULL default '',
|
||||
banner_keywords varchar(250) NOT NULL default '',
|
||||
PRIMARY KEY (banner_id)
|
||||
) ENGINE=MyISAM;
|
@ -27,21 +27,26 @@ class banner_shortcodes extends e_shortcode
|
||||
function sc_banner($parm='')
|
||||
{
|
||||
|
||||
$e107 = e107::getInstance();
|
||||
$sql = e107::getDb();
|
||||
$tp = e107::getParser();
|
||||
|
||||
$ret = '';
|
||||
|
||||
$text = '';
|
||||
|
||||
mt_srand ((double) microtime() * 1000000);
|
||||
$seed = mt_rand(1,2000000000);
|
||||
$time = time();
|
||||
|
||||
$query = " (banner_startdate=0 OR banner_startdate <= {$time}) AND (banner_enddate=0 OR banner_enddate > {$time}) AND (banner_impurchased=0 OR banner_impressions<=banner_impurchased)".($parm ? " AND banner_campaign='".$tp->toDB($parm)."'" : '')."
|
||||
AND banner_active IN (".USERCLASS_LIST.")
|
||||
ORDER BY RAND($seed) LIMIT 1";
|
||||
|
||||
AND banner_active IN (".USERCLASS_LIST.") ";
|
||||
|
||||
if($tags = e107::getRegistry('core/form/related'))
|
||||
{
|
||||
$tags_regexp = "'(^|,)(".str_replace(",", "|", $tags).")(,|$)'";
|
||||
$query .= " AND banner_keywords REGEXP ".$tags_regexp;
|
||||
}
|
||||
|
||||
$query .= " ORDER BY RAND($seed) LIMIT 1";
|
||||
|
||||
|
||||
|
||||
if($sql->select('banner', 'banner_id, banner_image, banner_clickurl, banner_description', $query))
|
||||
{
|
||||
$row = $sql->fetch();
|
||||
@ -110,6 +115,9 @@ class banner_shortcodes extends e_shortcode
|
||||
$text .= "<div class='e-banner-description'>".$start.$tp->toHtml($row['banner_description'], true).$end. "</div>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user