Skip to content

Commit f5ba30d

Browse files
committed
fix MySql strict broken ecommerce search and bs4/bs5 styling
1 parent e260e54 commit f5ba30d

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

framework/core/forms/controls/autocompletecontrol.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
class autocompletecontrol extends formcontrol {
2929

3030
var $placeholder = "";
31-
var $wwidth = "320px";
31+
var $wwidth = "320px"; // widget/input width
32+
var $lwidth = "320px"; // dropdown list width
3233
var $controller = ""; // controller to call
3334
var $action = ""; // action to call
3435
var $searchmodel = ""; // model to search
@@ -44,7 +45,11 @@ function toHTML($label,$name) {
4445
}
4546

4647
function controlToHTML($name,$label) {
47-
$html = '<div class="yui3-skin-sam" style="z-index: 999;">';
48+
$html = "";
49+
if (bs4() || bs5()) {
50+
$html .= "<div class=\"col\">";
51+
}
52+
$html .= '<div class="yui3-skin-sam" style="z-index: 999;">';
4853
$ac_input = new genericcontrol();
4954
$ac_input->type = 'search';
5055
$ac_input->id = $name . '_autoc';
@@ -53,12 +58,15 @@ function controlToHTML($name,$label) {
5358
$ac_input->placeholder = $this->placeholder;
5459
$html .= $ac_input->toHTML(null, "$name");
5560
$html .= '</div>';
61+
if (bs4() || bs5()) {
62+
$html .= '</div>';
63+
}
5664

5765
$script = "
5866
YUI(EXPONENT.YUI3_CONFIG).use('*', function (Y) {
5967
var autocomplete = Y.one('#".$name."_autoc');
6068
autocomplete.plug(Y.Plugin.AutoComplete, {
61-
width:'".$this->wwidth."',
69+
width:'".$this->lwidth."',
6270
maxResults: ".$this->maxresults.",
6371
resultListLocator: 'data', // 'data' field of json response
6472
resultTextLocator: 'title', // the field to place in the input after selection

framework/modules/ecommerce/controllers/storeController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ public function search() {
17901790
$search_type = ecomconfig::getConfig('ecom_search_results');
17911791

17921792
// look for term in full text search
1793-
$sql = "SELECT DISTINCT(p.id) AS id, p.title, model, sef_url, f.id AS fileid, MATCH (p.title,p.model,p.body) AGAINST ('" . $this->params['query'] . "*' IN BOOLEAN MODE) AS score ";
1793+
$sql = "SELECT DISTINCT(p.id) AS id, ANY_VALUE(p.title) as title, ANY_VALUE(model) as model, ANY_VALUE(sef_url) as sef_url, ANY_VALUE(f.id) AS fileid, MATCH (p.title,p.model,p.body) AGAINST ('" . $this->params['query'] . "*' IN BOOLEAN MODE) AS score ";
17941794
$sql .= " FROM " . $db->tableStmt('product') . " AS p LEFT JOIN " .
17951795
$db->tableStmt('content_expFiles') . " AS cef ON p.id=cef.content_id AND cef.content_type IN ('product','eventregistration','donation','giftcard') AND cef.subtype='mainimage' LEFT JOIN " . $db->tableStmt('expFiles') .
17961796
" AS f ON cef.expFiles_id = f.id WHERE ";
@@ -1808,7 +1808,7 @@ public function search() {
18081808
}
18091809

18101810
// look for specific term in fields
1811-
$sql = "SELECT DISTINCT(p.id) AS id, p.title, model, sef_url, f.id AS fileid FROM " . $db->tableStmt('product') . " AS p LEFT JOIN " .
1811+
$sql = "SELECT DISTINCT(p.id) AS id, ANY_VALUE(p.title) as title, ANY_VALUE(model) as model, ANY_VALUE(sef_url) as sef_url, ANY_VALUE(f.id) AS fileid FROM " . $db->tableStmt('product') . " AS p LEFT JOIN " .
18121812
$db->tableStmt('content_expFiles') . " AS cef ON p.id=cef.content_id AND cef.content_type IN ('product','eventregistration','donation','giftcard') AND cef.subtype='mainimage' LEFT JOIN " . $db->tableStmt('expFiles') .
18131813
" AS f ON cef.expFiles_id = f.id WHERE ";
18141814
if (!($user->isAdmin())) $sql .= '(p.active_type=0 OR p.active_type IS NULL OR p.active_type=1) AND ';
@@ -1825,7 +1825,7 @@ public function search() {
18251825
}
18261826

18271827
// look for begins with term in fields
1828-
$sql = "SELECT DISTINCT(p.id) AS id, p.title, model, sef_url, f.id AS fileid FROM " . $db->tableStmt('product') . " AS p LEFT JOIN " .
1828+
$sql = "SELECT DISTINCT(p.id) AS id, ANY_VALUE(p.title) as title, ANY_VALUE(model) as model, ANY_VALUE(sef_url) as sef_url, ANY_VALUE(f.id) AS fileid FROM " . $db->tableStmt('product') . " AS p LEFT JOIN " .
18291829
$db->tableStmt('content_expFiles') . " AS cef ON p.id=cef.content_id AND cef.content_type IN ('product','eventregistration','donation','giftcard') AND cef.subtype='mainimage' LEFT JOIN " . $db->tableStmt('expFiles') .
18301830
" AS f ON cef.expFiles_id = f.id WHERE ";
18311831
if (!($user->isAdmin())) $sql .= '(p.active_type=0 OR p.active_type IS NULL OR p.active_type=1) AND ';
@@ -1859,7 +1859,8 @@ function sortSearch($a, $b) {
18591859
}
18601860
}
18611861
}
1862-
usort($res, 'sortSearch');
1862+
if (!empty($res))
1863+
usort($res, 'sortSearch');
18631864

18641865
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
18651866
$ar->send();

framework/modules/ecommerce/views/store/ecomSearch.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@
5656

5757
<div class="module ecommerce ecom-search">
5858
{form id="autocompsearch" controller=search action=search}
59-
{control type="autocomplete" controller="store" action="search" name="search_string" label=$moduletitle placeholder="Search title or SKU to locate item" schema="title,id,sef_url,expFile,model" searchmodel="product" searchoncol="title,model" maxresults=30 wwidth="80%" jsinject=$callbacks}
59+
{control type="autocomplete" controller="store" action="search" name="search_string" label=$moduletitle placeholder="Search title or SKU to locate item" schema="title,id,sef_url,expFile,model" searchmodel="product" searchoncol="title,model" maxresults=30 wwidth="80%" lwidth="100%" jsinject=$callbacks}
6060
{/form}
6161
</div>

0 commit comments

Comments
 (0)