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

+ 9 - 9
inc/classes/BxDolPaginate.php

@@ -289,7 +289,7 @@ abstract class BxDolPaginate extends BxDol {
             'paginate_class' => $this->_sPaginateClass,
         );
 
-        $this->_addCssJs();
+        $this->addCssJs();
         return $this->_oTemplate->parseHtmlByName('paginate.html', $aVariables);
     }
 
@@ -313,6 +313,14 @@ abstract class BxDolPaginate extends BxDol {
         return $this->getPaginate($iStart, $iNum, $iPerPage);
     }
 
+    public function addCssJs () {
+        if (self::$_isCssAdded)
+            return false;
+        $this->_oTemplate->addCss('paginate.css');
+        self::$_isCssAdded = true;
+        return true;
+    }
+
     protected function _getReplacement() {
         return array(
             'start' => $this->_iStart,
@@ -328,13 +336,5 @@ abstract class BxDolPaginate extends BxDol {
         return !empty($this->_sOnChangePage) ? 'onclick="javascript:' . $this->_oTemplate->parseHtmlByContent($this->_sOnChangePage, $aReplacement, array('{', '}')) . '; return false;"' : '';
     }
 
-    protected function _addCssJs () {
-        if (self::$_isCssAdded)
-            return false;
-        $this->_oTemplate->addCss('paginate.css');
-        self::$_isCssAdded = true;
-        return true;
-    }
-
 }
 

+ 12 - 1
inc/classes/BxDolSearch.php

@@ -71,6 +71,7 @@ class BxDolSearch extends BxDol
      */
     function response () 
     {
+        bx_import('BxDolTemplate');
         $sCode = '';
         foreach ($this->aChoice as $sKey => $aValue) {
             if (!class_exists($aValue['class'])) {
@@ -78,7 +79,7 @@ class BxDolSearch extends BxDol
                 require_once(BX_DIRECTORY_PATH_ROOT . $sClassPath);
             }
             $oEx = new $aValue['class']();
-            $oEx->id = $aValue['id'];
+            $oEx->setId($aValue['id']);
             $sCode .= $oEx->processing();
         }
         return $sCode;
@@ -221,6 +222,16 @@ class BxDolSearchResult implements iBxDolReplaceable
             $this->aCurrent['ident'] = $this->aPseud['id'];
     }
 
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    public function setId($sId)
+    {
+        $this->id = $sId;
+    }
+
     /**
      * Display empty message if there is no content, custom empty message can be used.
      * @param $b - boolan value to enable or disable 'empty' message

+ 1 - 0
modules/base/general/classes/BxBaseModGeneralSearchResult.php

@@ -22,6 +22,7 @@ class BxBaseModGeneralSearchResult extends BxTemplSearchResult
 
     function getMain() 
     {
+        bx_import('BxDolModule');
         return BxDolModule::getInstance($this->aCurrent['name']);
     }
 

+ 2 - 0
modules/base/text/classes/BxBaseModTextSearchResult.php

@@ -30,6 +30,8 @@ class BxBaseModTextSearchResult extends BxBaseModGeneralSearchResult
     function getDesignBoxMenu () 
     {
         $aMenu = parent::getDesignBoxMenu ();
+        if (!$aMenu)
+            return false;
 
         return array_merge(
             array(

+ 7 - 2
modules/boonex/notes/classes/BxNotesSearchResult.php

@@ -19,7 +19,7 @@ class BxNotesSearchResult extends BxBaseModTextSearchResult
 
         $this->aCurrent = array(
             'name' => 'bx_notes',
-            'title' => '_bx_notes_page_title_browse',
+            'title' => _t('_bx_notes_page_title_browse'),
             'table' => 'bx_notes_posts',
             'ownFields' => array('id', 'title', 'text', 'summary', 'thumb', 'author', 'added'),
             'searchFields' => array('title', 'text'),
@@ -78,13 +78,18 @@ class BxNotesSearchResult extends BxBaseModTextSearchResult
                 break;
             
             case 'public':
-            case '':
                 bx_import('BxDolPermalinks');
                 $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
                 $this->aCurrent['title'] = _t('_bx_notes_page_title_browse_recent');
                 $this->aCurrent['rss']['link'] = 'modules/?r=notes/rss/' . $sMode;
                 break;
 
+            case '': // search results
+                $this->sBrowseUrl = '';
+                $this->aCurrent['title'] = _t('_bx_notes');
+                unset($this->aCurrent['rss']);
+                break;
+
             default:
                 $sMode = '';
                 $this->isError = true;

+ 7 - 3
modules/boonex/notes/install/sql/disable.sql

@@ -33,10 +33,14 @@ DELETE `sys_acl_actions`, `sys_acl_matrix` FROM `sys_acl_actions`, `sys_acl_matr
 DELETE FROM `sys_acl_actions` WHERE `Module` = 'bx_notes';
 
 -- COMMENTS
-DELETE FROM `sys_objects_cmts` WHERE `Name`='bx_notes';
+DELETE FROM `sys_objects_cmts` WHERE `Name` = 'bx_notes';
 
 -- VOTES
-DELETE FROM `sys_objects_vote` WHERE `Name`='bx_notes';
+DELETE FROM `sys_objects_vote` WHERE `Name` = 'bx_notes';
 
 -- VIEWS
-DELETE FROM `sys_objects_view` WHERE `Name`='bx_notes';
+DELETE FROM `sys_objects_view` WHERE `Name` = 'bx_notes';
+
+-- SEARCH
+DELETE FROM `sys_objects_search` WHERE `ObjectName` = 'bx_notes';
+

+ 5 - 0
modules/boonex/notes/install/sql/enable.sql

@@ -265,3 +265,8 @@ INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`
 -- VIEWS
 INSERT INTO `sys_objects_view` (`name`, `table_track`, `period`, `is_on`, `trigger_table`, `trigger_field_id`, `trigger_field_count`, `class_name`, `class_file`) VALUES 
 ('bx_notes', 'bx_notes_views_track', '86400', '1', 'bx_notes_posts', 'id', 'views', '', '');
+
+-- SEARCH
+INSERT INTO `sys_objects_search` (`ObjectName`, `Title`, `ClassName`, `ClassPath`) VALUES
+('bx_notes', '_bx_notes', 'BxNotesSearchResult', 'modules/boonex/notes/classes/BxNotesSearchResult.php');
+

+ 25 - 19
searchKeyword.php

@@ -6,11 +6,12 @@
  */
 
 require_once('./inc/header.inc.php');
-require_once(BX_DIRECTORY_PATH_INC . "languages.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "params.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
 
 bx_import('BxDolSearch');
+bx_import('BxDolTemplate');
+
 $oZ = new BxDolSearch();
 
 $sCode = '';
@@ -20,18 +21,22 @@ if (bx_get('keyword')) {
         $sCode = $oZ->getEmptyResult();
 }
 
+$sSearchArea = '<div id="searchArea" class="bx-def-margin-top">'.$sCode.'</div>';
+
+/*
 bx_import('BxTemplMenu');
 $aVars = array();
 BxTemplMenu::getInstance()->setCustomSubActions($aVars, '');
+*/
 
 $oTemplate = BxDolTemplate::getInstance();
 $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
 $oTemplate->setPageHeader (_t("_Search"));
-$oTemplate->setPageContent ('page_main_code', getExtraJs() . getSearchForm() . $sCode);
-
-PageCode();
+$oTemplate->setPageContent ('page_main_code', getExtraJs() . getSearchForm($oTemplate) . $sSearchArea);
+$oTemplate->getPageCode();
 
-function getSearchForm () {
+function getSearchForm ($oTemplate) 
+{
     $aList = BxDolDb::getInstance()->fromCache('sys_objects_search', 'getAllWithKey',
            'SELECT `ID` as `id`,
                    `Title` as `title`,
@@ -44,7 +49,7 @@ function getSearchForm () {
     foreach ($aList as $sKey => $aValue) {
         $aValues[$sKey] = _t($aValue['title']);
         if (!class_exists($aValue['class'])) {
-            $sPath = BX_DIRECTORY_PATH_ROOT . str_replace('{tmpl}', $GLOBALS['tmpl'], $aValue['file']);
+            $sPath = BX_DIRECTORY_PATH_ROOT . str_replace('{tmpl}', $oTemplate->getCode(), $aValue['file']);
             require_once($sPath);
         }
         $oClass = new $aValue['class']();
@@ -88,7 +93,11 @@ function getSearchForm () {
     $oForm = new BxTemplFormView($aForm);
     $sFormVal = $oForm->getCode();
 
-    return DesignBoxContent(_t( "_Search" ), $sFormVal, 1);
+    bx_import('BxTemplPaginate');
+    $o = new BxTemplPaginate(array());
+    $o->addCssJs();
+
+    return DesignBoxContent(_t( "_Search" ), $sFormVal, BX_DB_PADDING_DEF);
 }
 
 function getExtraJs() {
@@ -96,19 +105,16 @@ function getExtraJs() {
 ?>
 <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);
-                         bx_loading('searchForm', false);
-                    }
-                );
+        $('#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();

+ 7 - 10
searchKeywordContent.php

@@ -6,18 +6,15 @@
  */
 
 require_once('./inc/header.inc.php');
-require_once(BX_DIRECTORY_PATH_INC . "languages.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "params.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
 
-$bAjaxMode = ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) ? true : false;
-$aChoice = bx_get('section');
-
 bx_import('BxDolSearch');
-$oZ = new BxDolSearch($aChoice);
-$sCode = $oZ->response();
-if ($sCode)
-    echo $sCode;
-else
-    echo $oZ->getEmptyResult();
 
+$o = new BxDolSearch(bx_get('section'));
+$s = $o->response();
+if (!$s)
+    $s = $o->getEmptyResult();
+
+header('Content-type: text/html; charset=utf-8');
+echo $s;

+ 1 - 3
template/paginate.html

@@ -1,4 +1,4 @@
-<div class="bx-paginate __paginate_class__">
+<div class="bx-paginate bx-clearfix __paginate_class__">
 
     <div class="bx-paginate-btns bx-def-margin-sec-left bx-btn-group bx-clearfix">
         __btn_prev__
@@ -17,6 +17,4 @@
         </div>
     </bx_if:view_all>
 
-    <div class="bx-clear"></div>
-
 </div>