From a917375e7cb3d552d734b9ffd0e08754089c3f10 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 25 Jul 2015 18:14:44 -0700 Subject: [PATCH] Corrected incorrect MySQL row count when using PDO mode. Simple bootstrap 'carousel' mode added to welcome message preferences. For advanced options use the featurebox plugin. --- e107_admin/wmessage.php | 3 ++- e107_core/shortcodes/single/wmessage.php | 15 +++++++++++++- e107_handlers/mysql_class.php | 25 ++++++++++++++++++------ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/e107_admin/wmessage.php b/e107_admin/wmessage.php index 34d121bbd..350422601 100644 --- a/e107_admin/wmessage.php +++ b/e107_admin/wmessage.php @@ -90,7 +90,8 @@ class generic_ui extends e_admin_ui protected $prefs = array( - 'wm_enclose' => array('title'=> WMLAN_05, 'type'=>'boolean', 'data' => 'int','help'=> WMLAN_06), ); + 'wm_enclose' => array('title'=> WMLAN_05, 'type'=>'radio', 'data' => 'int','help'=> WMLAN_06, 'writeParms'=>array('optArray'=>array(0=> LAN_DISABLED, 1=> LAN_ENABLED, 2=> "Enclosed with Carousel"))), + ); public function init() diff --git a/e107_core/shortcodes/single/wmessage.php b/e107_core/shortcodes/single/wmessage.php index 8cf556988..4de4f08c3 100644 --- a/e107_core/shortcodes/single/wmessage.php +++ b/e107_core/shortcodes/single/wmessage.php @@ -62,12 +62,14 @@ function wmessage_shortcode($parm='') SELECT * FROM #generic WHERE gen_type ='wmessage' AND gen_intdata IN (".USERCLASS_LIST.')'; $wmessage = array(); + $wmessageCaption = array(); $wmcaption = ''; if($sql->gen($qry)) { while ($row = $sql->fetch()) { $wmessage[] = $tp->toHTML($row['gen_chardata'], TRUE, 'BODY, defs', 'admin'); + $wmessageCaption[] = $tp->toHTML($row['gen_ip'], TRUE, 'TITLE'); if(!$wmcaption) { $wmcaption = $tp->toHTML($row['gen_ip'], TRUE, 'TITLE'); @@ -75,10 +77,21 @@ function wmessage_shortcode($parm='') } } + if (isset($wmessage) && $wmessage) { ob_start(); - if (vartrue($pref['wm_enclose'])) + if(intval($pref['wm_enclose']) === 2) // carousel + { + $carousel= array(); + foreach($wmessage as $k=>$v) + { + $carousel['slide-'.$k] = array('caption'=>$wmessageCaption[$k], 'text'=>$ns->tablerender($wmessageCaption[$k],$v, 'wm',true)); + } + + echo e107::getForm()->carousel('wmessage-carousel',$carousel); + } + elseif(intval($pref['wm_enclose']) === 1) { $ns->tablerender($wmcaption, implode("
",$wmessage), 'wm'); } diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index 6b7c8653a..c9f346f92 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -438,14 +438,27 @@ class e_db_mysql $this->mySQLresult = $sQryRes; $this->total_results = false; - if ((strpos($query,'SQL_CALC_FOUND_ROWS') !== FALSE) && (strpos($query,'SELECT') !== FALSE)) - { // Need to get the total record count as well. Return code is a resource identifier - // Have to do this before any debug action, otherwise this bit gets messed up - $fr = ($this->pdo) ? $this->mySQLaccess->query('SELECT FOUND_ROWS()') : mysql_query('SELECT FOUND_ROWS()', $this->mySQLaccess); - $rc = ($this->pdo) ? $this->fetch() : mysql_fetch_array($fr); - $this->total_results = (int) $rc['FOUND_ROWS()']; + + // Need to get the total record count as well. Return code is a resource identifier + // Have to do this before any debug action, otherwise this bit gets messed up + if ((strpos($query,'SQL_CALC_FOUND_ROWS') !== false) && (strpos($query,'SELECT') !== false)) + { + if($this->pdo) + { + $fr = $this->mySQLaccess->query('SELECT FOUND_ROWS()'); + $rc = $fr->fetchColumn(); + $this->total_results = (int) $rc; + } + else + { + $fr = mysql_query('SELECT FOUND_ROWS()', $this->mySQLaccess); + $rc = mysql_fetch_array($fr); + $this->total_results = (int) $rc['FOUND_ROWS()']; + } + } + if (E107_DEBUG_LEVEL) { global $db_debug;