Просмотр исходного кода

#48 - site search: search refactoring and quick(live) search mode

Alex Trofimov 12 лет назад
Родитель
Сommit
72d083b0aa

+ 30 - 5
inc/classes/BxDolSearch.php

@@ -40,11 +40,13 @@ class BxDolSearch extends BxDol
     protected $aClasses = array(); ///< array of all search classes
     protected $aClasses = array(); ///< array of all search classes
     protected $aChoice  = array(); ///< array of current search classes which were choosen in search area
     protected $aChoice  = array(); ///< array of current search classes which were choosen in search area
 
 
+    protected $_bQuickSearch = false;
+
     /**
     /**
      * Constructor
      * Constructor
      * @param array $aChoice - array of choosen classes (will take a part only existing in `sys_objects_search` table)
      * @param array $aChoice - array of choosen classes (will take a part only existing in `sys_objects_search` table)
      */
      */
-    function __construct ($aChoice = '') 
+    public function __construct ($aChoice = '') 
     {
     {
         parent::__construct();
         parent::__construct();
 
 
@@ -70,7 +72,7 @@ class BxDolSearch extends BxDol
     /**
     /**
      * create units for all classes and calling their processing methods
      * create units for all classes and calling their processing methods
      */
      */
-    function response () 
+    public function response () 
     {
     {
         bx_import('BxDolTemplate');
         bx_import('BxDolTemplate');
         $sCode = '';
         $sCode = '';
@@ -81,17 +83,30 @@ class BxDolSearch extends BxDol
             }
             }
             $oEx = new $aValue['class']();
             $oEx = new $aValue['class']();
             $oEx->setId($aValue['id']);
             $oEx->setId($aValue['id']);
+            $oEx->setQuickSearch($this->_bQuickSearch);
             $sCode .= $oEx->processing();
             $sCode .= $oEx->processing();
         }
         }
         return $sCode;
         return $sCode;
     }
     }
 
 
-    function getEmptyResult () 
+    public function getEmptyResult () 
     {
     {
         $sKey = _t('_Empty');
         $sKey = _t('_Empty');
         return DesignBoxContent($sKey, MsgBox($sKey), 1);
         return DesignBoxContent($sKey, MsgBox($sKey), 1);
     }
     }
 
 
+    protected function getKeyTitlesPairs ()
+    {
+        $a = array();
+        foreach ($this->aChoice as $sKey => $r)
+            $a[$sKey] = _t($r['title']);
+        return $a;
+    }
+
+    public function setQuickSearch($bQuickSearch)
+    {
+        $this->_bQuickSearch = $bQuickSearch;
+    }
 }
 }
 
 
 /*
 /*
@@ -212,6 +227,8 @@ class BxDolSearchResult implements iBxDolReplaceable
     protected $bProcessPrivateContent = true; ///< check each item for privacy, if view isn't allowed then display private view instead
     protected $bProcessPrivateContent = true; ///< check each item for privacy, if view isn't allowed then display private view instead
     protected $bForceAjaxPaginate = false; ///< force ajax paginate
     protected $bForceAjaxPaginate = false; ///< force ajax paginate
 
 
+    protected $_bQuickSearch = false;
+
     protected $_aMarkers = array (); ///< markers to replace somewhere, usually title and browse url (defined in custom class)
     protected $_aMarkers = array (); ///< markers to replace somewhere, usually title and browse url (defined in custom class)
 
 
     /**
     /**
@@ -239,6 +256,11 @@ class BxDolSearchResult implements iBxDolReplaceable
         $this->bForceAjaxPaginate = $b;
         $this->bForceAjaxPaginate = $b;
     }
     }
 
 
+    public function setQuickSearch($bQuickSearch)
+    {
+        $this->_bQuickSearch = $bQuickSearch;
+    }
+
     /**
     /**
      * Display empty message if there is no content, custom empty message can be used.
      * Display empty message if there is no content, custom empty message can be used.
      * @param $b - boolan value to enable or disable 'empty' message
      * @param $b - boolan value to enable or disable 'empty' message
@@ -700,6 +722,8 @@ class BxDolSearchResult implements iBxDolReplaceable
         if (!$sKeyword)
         if (!$sKeyword)
             return;
             return;
 
 
+        $sTable = empty($this->aCurrent['tableSearch']) ? $this->aCurrent['table'] : $this->aCurrent['tableSearch'];
+
         $oDb = BxDolDb::getInstance();
         $oDb = BxDolDb::getInstance();
 
 
         $bLike = getParam('useLikeOperator');
         $bLike = getParam('useLikeOperator');
@@ -718,12 +742,13 @@ class BxDolSearchResult implements iBxDolReplaceable
                   'word' => '%' . preg_replace('/\s+/', '%', $sKeyword) . '%'
                   'word' => '%' . preg_replace('/\s+/', '%', $sKeyword) . '%'
             );
             );
         }
         }
+
         $sqlWhere = " {$aSql['function']}(";
         $sqlWhere = " {$aSql['function']}(";
         if (is_array($aFields)) {
         if (is_array($aFields)) {
             foreach ($aFields as $sValue)
             foreach ($aFields as $sValue)
-                $sqlWhere .= "`{$this->aCurrent['table']}`.`$sValue`, ";
+                $sqlWhere .= "`{$sTable}`.`$sValue`, ";
         } else {
         } else {
-                $sqlWhere .= "`{$this->aCurrent['table']}`.`$aFields`";
+                $sqlWhere .= "`{$sTable}`.`$aFields`";
         }
         }
         $sqlWhere = trim($sqlWhere, ', ') . ") {$aSql['operator']} ('{$aSql['word']}')";
         $sqlWhere = trim($sqlWhere, ', ') . ") {$aSql['operator']} ('{$aSql['word']}')";
 
 

+ 2 - 0
inc/classes/BxDolTemplate.php

@@ -321,6 +321,7 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
             'general.css',
             'general.css',
             'icons.css',
             'icons.css',
             'colors.css',
             'colors.css',
+            'forms.css',
             'media-desktop.css',
             'media-desktop.css',
             'media-tablet.css',
             'media-tablet.css',
             'media-phone.css',
             'media-phone.css',
@@ -334,6 +335,7 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
             'jquery.easing.js',
             'jquery.easing.js',
             'jquery.cookie.js',
             'jquery.cookie.js',
             'functions.js',
             'functions.js',
+            'jquery.webForms.js',
             'jquery.dolPopup.js',
             'jquery.dolPopup.js',
             'jquery.ui.position.min.js',
             'jquery.ui.position.min.js',
             BX_DOL_URL_PLUGINS . 'spin.min.js',
             BX_DOL_URL_PLUGINS . 'spin.min.js',

+ 16 - 0
inc/js/functions.js

@@ -426,3 +426,19 @@ function bx_append_url_params (sUrl, mixedParams) {
 
 
     return sUrl + sParams;
     return sUrl + sParams;
 }
 }
+
+function bx_search (sFormSel, sResultsContSel, sLoadingContSel) {
+    if ('undefined' == typeof(sLoadingContSel))
+        sLoadingContSel = sResultsContSel;
+    
+    var sQuery = $('input', sFormSel).serialize();
+
+    bx_loading($(sLoadingContSel), true);
+    $.post(sUrlRoot + 'searchKeywordContent.php', sQuery, function(data) {
+        $(sResultsContSel).html(data).bxTime();
+        bx_loading($(sLoadingContSel), false);
+    });
+
+    return false;
+}
+

+ 1 - 1
inc/utils.inc.php

@@ -710,7 +710,7 @@ function bx_html_attribute ($mixedInput, $iQuoteType = BX_ESCAPE_STR_AUTO) {
     if (BX_ESCAPE_STR_APOS == $iQuoteType)
     if (BX_ESCAPE_STR_APOS == $iQuoteType)
         $aUnits["'"] = "\\'";
         $aUnits["'"] = "\\'";
     elseif (BX_ESCAPE_STR_QUOTE == $iQuoteType)
     elseif (BX_ESCAPE_STR_QUOTE == $iQuoteType)
-        $aUnits['"'] = '\\"';
+        $aUnits['"'] = '&quot;';
     else
     else
         $aUnits = array("\"" => "&quot;", "'" => "&apos;");
         $aUnits = array("\"" => "&quot;", "'" => "&apos;");
 
 

+ 1 - 1
install/sql/system.sql

@@ -2783,7 +2783,7 @@ CREATE TABLE IF NOT EXISTS `sys_objects_menu` (
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 
 
 INSERT INTO `sys_objects_menu` (`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES
 INSERT INTO `sys_objects_menu` (`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES
-('sys_site', '_sys_menu_title_main', 'sys_site', 'system', 7, 0, 1, '', ''),
+('sys_site', '_sys_menu_title_main', 'sys_site', 'system', 7, 0, 1, 'BxTemplMenuSite', ''),
 ('sys_site_submenu', '_sys_menu_title_submenu', 'sys_site', 'system', 1, 0, 1, 'BxTemplMenuSubmenu', ''),
 ('sys_site_submenu', '_sys_menu_title_submenu', 'sys_site', 'system', 1, 0, 1, 'BxTemplMenuSubmenu', ''),
 ('sys_site_submenu_main', '_sys_menu_title_submenu_main', 'sys_site', 'system', 8, 0, 1, '', ''),
 ('sys_site_submenu_main', '_sys_menu_title_submenu_main', 'sys_site', 'system', 8, 0, 1, '', ''),
 ('sys_footer', '_sys_menu_title_footer', 'sys_footer', 'system', 2, 0, 1, '', ''),
 ('sys_footer', '_sys_menu_title_footer', 'sys_footer', 'system', 2, 0, 1, '', ''),

+ 11 - 2
modules/base/profile/classes/BxBaseModProfileDb.php

@@ -35,8 +35,17 @@ class BxBaseModProfileDb extends BxBaseModGeneralDb
 
 
     public function searchByTerm($sTerm, $iLimit) 
     public function searchByTerm($sTerm, $iLimit) 
     {
     {
-        $sQuery = $this->prepare("SELECT `c`.`id` AS `content_id`, `p`.`account_id`, `p`.`id` AS `profile_id`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = ?) WHERE `p`.`status` = ? AND `c`.`fullname` LIKE ? ORDER BY `added` DESC LIMIT ?", $this->_oConfig->getName(), BX_PROFILE_STATUS_ACTIVE, '%' . $sTerm . '%', (int)$iLimit);
-        return $this->getAll($sQuery);
+        if (!$this->_oConfig->CNF['FIELDS_QUICK_SEARCH'])
+            return array();
+
+        $sWhere = '';
+        foreach ($this->_oConfig->CNF['FIELDS_QUICK_SEARCH'] as $sField)
+            $sWhere .= $this->prepare(" OR `c`.`$sField` LIKE ? ", '%' . $sTerm . '%');
+
+        $sOrderBy = $this->prepare(" ORDER BY `added` DESC LIMIT ?", (int)$iLimit);
+
+        $sQuery = $this->prepare("SELECT `c`.`id` AS `content_id`, `p`.`account_id`, `p`.`id` AS `profile_id`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = ?) WHERE `p`.`status` = ?", $this->_oConfig->getName(), BX_PROFILE_STATUS_ACTIVE);
+        return $this->getAll($sQuery . " AND (0 $sWhere) " . $sOrderBy);
     }
     }
 }
 }
 
 

+ 1 - 0
modules/boonex/english/data/langs/system.xml

@@ -1829,6 +1829,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_search_main_title"><![CDATA[Search Home]]></string>
 	<string name="_sys_search_main_title"><![CDATA[Search Home]]></string>
 	<string name="_sys_select"><![CDATA[Select]]></string>
 	<string name="_sys_select"><![CDATA[Select]]></string>
 	<string name="_sys_send"><![CDATA[Send]]></string>
 	<string name="_sys_send"><![CDATA[Send]]></string>
+    <string name="_sys_search_placeholder"><![CDATA[Search...]]></string>
 	<string name="_sys_spam_detected"><![CDATA[Sorry, it looks like you are trying to submit spam]]></string>
 	<string name="_sys_spam_detected"><![CDATA[Sorry, it looks like you are trying to submit spam]]></string>
 	<string name="_sys_spam_detected_contact"><![CDATA[Sorry, it looks like you are trying to submit spam, if you believe that it is not spam please submit false positive report here: {0}]]></string>
 	<string name="_sys_spam_detected_contact"><![CDATA[Sorry, it looks like you are trying to submit spam, if you believe that it is not spam please submit false positive report here: {0}]]></string>
 	<string name="_sys_splash_btn_start"><![CDATA[Start]]></string>
 	<string name="_sys_splash_btn_start"><![CDATA[Start]]></string>

+ 1 - 0
modules/boonex/organizations/classes/BxOrgsConfig.php

@@ -43,6 +43,7 @@ class BxOrgsConfig extends BxBaseModProfileConfig
             'FIELD_PICTURE_PREVIEW' => 'picture_preview',
             'FIELD_PICTURE_PREVIEW' => 'picture_preview',
             'FIELD_COVER' => 'cover',
             'FIELD_COVER' => 'cover',
             'FIELD_COVER_PREVIEW' => 'cover_preview',
             'FIELD_COVER_PREVIEW' => 'cover_preview',
+            'FIELDS_QUICK_SEARCH' => array('org_name', 'id'),
 
 
             // page URIs
             // page URIs
             'URI_VIEW_ENTRY' => 'view-organization-profile',
             'URI_VIEW_ENTRY' => 'view-organization-profile',

+ 1 - 0
modules/boonex/organizations/classes/BxOrgsSearchResult.php

@@ -21,6 +21,7 @@ class BxOrgsSearchResult extends BxBaseModProfileSearchResult
             'name' => 'bx_organizations',
             'name' => 'bx_organizations',
             'title' => _t('_bx_orgs_page_title_browse'),
             'title' => _t('_bx_orgs_page_title_browse'),
             'table' => 'sys_profiles',
             'table' => 'sys_profiles',
+            'tableSearch' => 'bx_organizations_data',
             'ownFields' => array(),
             'ownFields' => array(),
             'searchFields' => array('org_name'),
             'searchFields' => array('org_name'),
             'restriction' => array(
             'restriction' => array(

+ 1 - 0
modules/boonex/persons/classes/BxPersonsConfig.php

@@ -43,6 +43,7 @@ class BxPersonsConfig extends BxBaseModProfileConfig
             'FIELD_PICTURE_PREVIEW' => 'picture_preview',
             'FIELD_PICTURE_PREVIEW' => 'picture_preview',
             'FIELD_COVER' => 'cover',
             'FIELD_COVER' => 'cover',
             'FIELD_COVER_PREVIEW' => 'cover_preview',
             'FIELD_COVER_PREVIEW' => 'cover_preview',
+            'FIELDS_QUICK_SEARCH' => array('fullname', 'id'),
 
 
             // page URIs
             // page URIs
             'URI_VIEW_ENTRY' => 'view-persons-profile',
             'URI_VIEW_ENTRY' => 'view-persons-profile',

+ 1 - 0
modules/boonex/persons/classes/BxPersonsSearchResult.php

@@ -21,6 +21,7 @@ class BxPersonsSearchResult extends BxBaseModProfileSearchResult
             'name' => 'bx_persons',
             'name' => 'bx_persons',
             'title' => _t('_bx_persons_page_title_browse'),
             'title' => _t('_bx_persons_page_title_browse'),
             'table' => 'sys_profiles',
             'table' => 'sys_profiles',
+            'tableSearch' => 'bx_persons_data',
             'ownFields' => array(),
             'ownFields' => array(),
             'searchFields' => array('fullname'),
             'searchFields' => array('fullname'),
             'restriction' => array(
             'restriction' => array(

+ 22 - 0
modules/boonex/uni/data/template/system/scripts/BxTemplMenuSite.php

@@ -0,0 +1,22 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+bx_import('BxBaseMenuSite');
+
+/**
+ * @see BxDolMenu
+ */
+class BxTemplMenuSite extends BxBaseMenuSite {
+
+    public function __construct ($aObject, $oTemplate = false) {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 20 - 0
modules/boonex/uni/data/template/system/scripts/BxTemplSearch.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+bx_import('BxBaseSearch');
+
+class BxTemplSearch extends BxBaseSearch 
+{
+    public function __construct ($aChoice = '', $oTemplate = false) 
+    {
+        parent::__construct ($aChoice, $oTemplate);
+    }
+}
+
+/** @} */

+ 8 - 98
searchKeyword.php

@@ -9,114 +9,24 @@ require_once('./inc/header.inc.php');
 require_once(BX_DIRECTORY_PATH_INC . "params.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "params.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
 
 
-bx_import('BxDolSearch');
+bx_import('BxTemplSearch');
 bx_import('BxDolTemplate');
 bx_import('BxDolTemplate');
 
 
-$oZ = new BxDolSearch();
+$o = new BxDolSearch();
+$o->setQuickSearch(bx_get('quick_search') ? 1 : 0);
 
 
 $sCode = '';
 $sCode = '';
 if (bx_get('keyword')) {
 if (bx_get('keyword')) {
-    $sCode = $oZ->response();
+    $sCode = $o->response();
     if (mb_strlen($sCode) == 0)
     if (mb_strlen($sCode) == 0)
-        $sCode = $oZ->getEmptyResult();
+        $sCode = $o->getEmptyResult();
 }
 }
 
 
-$sSearchArea = '<div id="searchArea" class="bx-def-margin-top">'.$sCode.'</div>';
-
-/*
-bx_import('BxTemplMenu');
-$aVars = array();
-BxTemplMenu::getInstance()->setCustomSubActions($aVars, '');
-*/
+$oSearch = new BxTemplSearch();
+$oSearch->setQuickSearch(false);
 
 
 $oTemplate = BxDolTemplate::getInstance();
 $oTemplate = BxDolTemplate::getInstance();
 $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
 $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
 $oTemplate->setPageHeader (_t("_Search"));
 $oTemplate->setPageHeader (_t("_Search"));
-$oTemplate->setPageContent ('page_main_code', getExtraJs() . getSearchForm($oTemplate) . $sSearchArea);
+$oTemplate->setPageContent ('page_main_code', $oSearch->getForm() . $oSearch->getResultsContainer($sCode));
 $oTemplate->getPageCode();
 $oTemplate->getPageCode();
-
-function getSearchForm ($oTemplate) 
-{
-    $aList = BxDolDb::getInstance()->fromCache('sys_objects_search', 'getAllWithKey',
-           'SELECT `ID` as `id`,
-                   `Title` as `title`,
-                   `ClassName` as `class`,
-                   `ClassPath` as `file`,
-                   `ObjectName`
-            FROM `sys_objects_search`', 'ObjectName'
-    );
-    $aValues = array();
-    foreach ($aList as $sKey => $aValue) {
-        $aValues[$sKey] = _t($aValue['title']);
-        if (!class_exists($aValue['class'])) {
-            $sPath = BX_DIRECTORY_PATH_ROOT . str_replace('{tmpl}', $oTemplate->getCode(), $aValue['file']);
-            require_once($sPath);
-        }
-        $oClass = new $aValue['class']();
-    }
-
-    if (isset($_GET['type'])) {
-        $aValue = bx_process_input($_GET['type']);
-    } else {
-        $aValue = array_keys($aValues);
-    }
-
-    $aForm = array(
-        'form_attrs' => array(
-           'id' => 'searchForm',
-           'action' => '',
-           'method' => 'post',
-           'onsubmit' => '',
-        ),
-        'inputs' => array(
-            'section' => array(
-                'type' => 'checkbox_set',
-                'name' => 'section',
-                'caption' => _t('_Section'),
-                'values' => $aValues,
-                'value' => $aValue,
-            ),
-            'keyword' => array(
-                'type' => 'text',
-                'name' => 'keyword',
-                'caption' => _t('_Keyword')
-            ),
-            'search' => array(
-                'type' => 'submit',
-                'name' => 'search',
-                'value' => _t('_Search')
-            )
-        )
-    );
-
-    bx_import('BxTemplFormView');
-    $oForm = new BxTemplFormView($aForm);
-    $sFormVal = $oForm->getCode();
-
-    bx_import('BxTemplPaginate');
-    $o = new BxTemplPaginate(array());
-    $o->addCssJs();
-
-    return DesignBoxContent(_t( "_Search" ), $sFormVal, BX_DB_PADDING_DEF);
-}
-
-function getExtraJs() {
-    ob_start();
-?>
-<script language="javascript">
-    $(document).ready( function() {
-        $('#searchForm').bind( 'submit', function() {
-            bx_loading('searchForm', true);
-            var sQuery = $('input', '#searchForm').serialize();
-            $.post('searchKeywordContent.php', sQuery, function(data) {
-                $('#searchArea').html(data).bxTime();                
-                bx_loading('searchForm', false);
-            });
-            return false;
-        });
-    });
-</script>
-<?php
-    return ob_get_clean();
-}
-

+ 1 - 0
searchKeywordContent.php

@@ -13,6 +13,7 @@ bx_import('BxDolLanguages');
 bx_import('BxDolSearch');
 bx_import('BxDolSearch');
 
 
 $o = new BxDolSearch(bx_get('section'));
 $o = new BxDolSearch(bx_get('section'));
+$o->setQuickSearch(bx_get('quick_search') ? 1 : 0);
 $s = $o->response();
 $s = $o->response();
 if (!$s)
 if (!$s)
     $s = $o->getEmptyResult();
     $s = $o->getEmptyResult();

+ 2 - 2
template/css/menu.css

@@ -267,8 +267,8 @@ ul.bx-menu-toolbar li .sys-icon {
 /* --------------- floating blocks menu */
 /* --------------- floating blocks menu */
 
 
 .bx-popup-content .bx-menu-floating-blocks {
 .bx-popup-content .bx-menu-floating-blocks {
-    width:128px;
-    width:8rem;
+    width:256px;
+    width:16rem;
 }
 }
 
 
 ul.bx-menu-floating-blocks {
 ul.bx-menu-floating-blocks {

+ 5 - 0
template/menu_site.html

@@ -0,0 +1,5 @@
+<div id="bx-menu-site">
+    <div id="bx-menu-site-search">__search__</div>
+    <div class="bx-def-color-bg-sec bx-def-margin-top bx-def-margin-bottom" style="height:0.5em; margin-left:-3em; margin-right:-3em;"></div>
+    <div id="bx-menu-site-menu">__menu__</div>
+</div>

+ 6 - 2
template/scripts/BxBaseFunctions.php

@@ -54,6 +54,7 @@ class BxBaseFunctions extends BxDol implements iBxDolSingleton {
     }
     }
 
 
     /**
     /**
+    * TODO: remove (along with related code), the only use is in genObjectsActions method which is for removal as well
     * Function will generate object's action link ;
     * Function will generate object's action link ;
     *
     *
     * @param          : $aObjectParamaters (array) contain special markers ;
     * @param          : $aObjectParamaters (array) contain special markers ;
@@ -226,6 +227,7 @@ class BxBaseFunctions extends BxDol implements iBxDolSingleton {
     }
     }
 
 
     /**
     /**
+     * // TODO: remove, along with all related code
      * @description : function will generate object's action lists;
      * @description : function will generate object's action lists;
      * @param :  $aKeys (array)  - array with all nedded keys;
      * @param :  $aKeys (array)  - array with all nedded keys;
      * @param :  $sActionsType (string) - type of actions;
      * @param :  $sActionsType (string) - type of actions;
@@ -661,12 +663,14 @@ EOF;
      *     @see BX_FORMAT_DATE_TIME
      *     @see BX_FORMAT_DATE_TIME
      * @param $bForceFormat force provided format and don't use "from now" time autoformat.
      * @param $bForceFormat force provided format and don't use "from now" time autoformat.
      */
      */
-    function timeForJs ($iUnixTimestamp, $sFormatIdentifier = BX_FORMAT_DATE, $bForceFormat = false) {
+    function timeForJs ($iUnixTimestamp, $sFormatIdentifier = BX_FORMAT_DATE, $bForceFormat = false)
+    {
         $sDateUTC = bx_time_utc ($iUnixTimestamp);
         $sDateUTC = bx_time_utc ($iUnixTimestamp);
         return '<time datetime="' . $sDateUTC . '" data-bx-format="' . getParam($sFormatIdentifier) . '" data-bx-autoformat="' . ($bForceFormat ? 0 : getParam('sys_format_timeago')) . '">' . $sDateUTC . '</time>';
         return '<time datetime="' . $sDateUTC . '" data-bx-format="' . getParam($sFormatIdentifier) . '" data-bx-autoformat="' . ($bForceFormat ? 0 : getParam('sys_format_timeago')) . '">' . $sDateUTC . '</time>';
     }
     }
 
 
-    function statusOnOff ($mixed) {
+    function statusOnOff ($mixed) 
+    {
         if ($mixed)
         if ($mixed)
             return '<i class="sys-icon circle col-green1"></i> ' . _t('_sys_on');
             return '<i class="sys-icon circle col-green1"></i> ' . _t('_sys_on');
         return '<i class="sys-icon circle col-red2"></i> ' . _t('_sys_off');
         return '<i class="sys-icon circle col-red2"></i> ' . _t('_sys_off');

+ 41 - 0
template/scripts/BxBaseMenuSite.php

@@ -0,0 +1,41 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+bx_import('BxTemplMenu');
+
+/**
+ * Site main menu representation.
+ */
+class BxBaseMenuSite extends BxTemplMenu 
+{
+
+    protected $_sObjectSubmenu = false;
+    protected $_mixedMainMenuItemSelected = false;
+
+    public function __construct ($aObject, $oTemplate) 
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+
+    public function getCode () 
+    {
+        bx_import('BxTemplSearch');
+        $oSearch = new BxTemplSearch();
+        $oSearch->setQuickSearch(true);
+
+        $aVars = array (
+            'menu' => parent::getCode (),
+            'search' => $oSearch->getForm(BX_DB_CONTENT_ONLY) . $oSearch->getResultsContainer(),
+        );
+        return $this->_oTemplate->parseHtmlByName('menu_site.html', $aVars); 
+    }
+
+}
+
+/** @} */

+ 99 - 0
template/scripts/BxBaseSearch.php

@@ -0,0 +1,99 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
+
+bx_import('BxDolSearch');
+
+class BxBaseSearch extends BxDolSearch
+{
+    protected $_oTemplate;
+    protected $_sIdForm = 'sys_search_form';
+    protected $_sIdResults = 'sys_search_results';
+    protected $_sSuffixQuickSearch = '_quick';
+
+    public function __construct($aChoice, $oTemplate)
+    {
+        parent::__construct($aChoice);
+
+        $this->_oTemplate = $oTemplate ? $oTemplate : BxDolTemplate::getInstance();
+    }
+
+    public function getForm($iDesignBoxTemplate = BX_DB_PADDING_DEF, $sTitle = false)
+    {
+        if (false === $sTitle)
+            $sTitle = _t( "_Search");
+
+        $aValues = $this->getKeyTitlesPairs ();        
+        $aValue = isset($_GET['type']) ? bx_process_input($_GET['type']) : array_keys($aValues);
+
+        $sIdForm = $this->_sIdForm . ($this->_bQuickSearch ? $this->_sSuffixQuickSearch : '');
+        $sIdResults = $this->_sIdResults . ($this->_bQuickSearch ? $this->_sSuffixQuickSearch : '');
+        $sIdLoadingContainer = $this->_bQuickSearch ? $sIdResults : $sIdForm;
+
+        $aForm = array(
+            'form_attrs' => array(
+               'id' => $sIdForm,
+               'action' => '',
+               'method' => 'post',
+               'onsubmit' => "return bx_search('#{$sIdForm}', '#{$sIdResults}', '#{$sIdLoadingContainer}');",
+            ),
+            'inputs' => array(
+                'quick_search' => array(
+                    'type' => 'hidden',
+                    'name' => 'quick_search',
+                    'value' => $this->_bQuickSearch ? 1 : 0,
+                ),
+                'section' => array(
+                    'type' => 'checkbox_set',
+                    'name' => 'section',
+                    'caption' => _t('_Section'),
+                    'values' => $aValues,
+                    'value' => $aValue,
+                ),
+                'keyword' => array(
+                    'type' => 'text',
+                    'name' => 'keyword',
+                    'caption' => _t('_Keyword'),
+                ),
+                'search' => array(
+                    'type' => 'submit',
+                    'name' => 'search',
+                    'value' => _t('_Search'),
+                )
+            )
+        );
+
+        if ($this->_bQuickSearch) {
+            unset($aForm['inputs']['section']);
+            unset($aForm['inputs']['search']);
+            unset($aForm['inputs']['keyword']['caption']);
+        }
+
+        bx_import('BxTemplFormView');
+        $oForm = new BxTemplFormView($aForm);
+        $sForm = $oForm->getCode();
+
+        if (!$this->_bQuickSearch) {
+            bx_import('BxTemplPaginate');
+            $o = new BxTemplPaginate(array());
+            $o->addCssJs();
+        }
+
+        return DesignBoxContent($sTitle, $sForm, $iDesignBoxTemplate);
+    }
+
+    public function getResultsContainer($sCode = '')
+    {
+        $sIdResults = $this->_sIdResults . ($this->_bQuickSearch ? $this->_sSuffixQuickSearch : '');
+        return '<div id="' . $sIdResults . '" class="bx-def-margin-top">' . $sCode . '</div>';
+    }
+}
+
+/** @} */

+ 2 - 1
template/scripts/BxBaseSearchResult.php

@@ -16,6 +16,7 @@ class BxBaseSearchResult extends BxDolSearchResult
     protected $sBrowseUrl; ///< currect browse url, used for paginate and other links in browsing
     protected $sBrowseUrl; ///< currect browse url, used for paginate and other links in browsing
 
 
     protected $sUnitTemplate = 'unit.html'; ///< common template to try to use for displaying one item
     protected $sUnitTemplate = 'unit.html'; ///< common template to try to use for displaying one item
+    protected $sUnitTemplateQuickSearch = 'unit_quick_search.html'; ///< common template to try to use for displaying quick search results
 
 
     protected $aGetParams = array(); ///< get params to keep in paginate and other browsing links
     protected $aGetParams = array(); ///< get params to keep in paginate and other browsing links
 
 
@@ -83,7 +84,7 @@ class BxBaseSearchResult extends BxDolSearchResult
     function displaySearchUnit ($aData) 
     function displaySearchUnit ($aData) 
     {
     {
         $oMain = $this->getMain();
         $oMain = $this->getMain();
-        return $oMain->_oTemplate->unit($aData, $this->bProcessPrivateContent, $this->sUnitTemplate);
+        return $oMain->_oTemplate->unit($aData, $this->bProcessPrivateContent, $this->_bQuickSearch ? $this->sUnitTemplateQuickSearch : $this->sUnitTemplate);
     }
     }
 
 
     function getDesignBoxMenu () 
     function getDesignBoxMenu ()