Procházet zdrojové kódy

#2634 API: ability to return array data in search results

Alex Trofimov před 6 roky
rodič
revize
145ae91e6b
1 změnil soubory, kde provedl 15 přidání a 2 odebrání
  1. 15 2
      inc/classes/BxDolSearch.php

+ 15 - 2
inc/classes/BxDolSearch.php

@@ -40,6 +40,7 @@ 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 $_bRawProcessing = false; ///< display search results without design box and paginate
     protected $_bRawProcessing = false; ///< display search results without design box and paginate
+    protected $_bDataProcessing = false; ///< return result as array of data
 
 
     protected $_bLiveSearch = false;
     protected $_bLiveSearch = false;
     protected $_sMetaType = '';
     protected $_sMetaType = '';
@@ -82,7 +83,7 @@ class BxDolSearch extends BxDol
      */
      */
     public function response ()
     public function response ()
     {
     {
-        $sCode = '';
+        $sCode = $this->_bDataProcessing ? array() : '';
 
 
         $bSingle = count($this->aChoice) == 1;
         $bSingle = count($this->aChoice) == 1;
         foreach ($this->aChoice as $sKey => $aValue) {
         foreach ($this->aChoice as $sKey => $aValue) {
@@ -109,7 +110,11 @@ class BxDolSearch extends BxDol
             $oEx->aCurrent = array_merge($oEx->aCurrent, $this->_aCustomCurrentCondition);
             $oEx->aCurrent = array_merge($oEx->aCurrent, $this->_aCustomCurrentCondition);
             if ($this->_sUnitTemplate)
             if ($this->_sUnitTemplate)
                 $oEx->setUnitTemplate($this->_sUnitTemplate);
                 $oEx->setUnitTemplate($this->_sUnitTemplate);
-            $sCode .= $this->_bRawProcessing ? $oEx->processingRaw() : $oEx->processing();
+
+            if ($this->_bDataProcessing)
+                $sCode[$sKey] = $oEx->getSearchData();
+            else
+                $sCode .= $this->_bRawProcessing ? $oEx->processingRaw() : $oEx->processing();
         }
         }
 
 
         return $sCode;
         return $sCode;
@@ -184,6 +189,14 @@ class BxDolSearch extends BxDol
     {
     {
         $this->_bRawProcessing = $b;
         $this->_bRawProcessing = $b;
     }
     }
+
+    /**
+     * Return search result as array of data
+     */ 
+    public function setDataProcessing($b)
+    {
+        $this->_bDataProcessing = $b;
+    }
 }
 }
 
 
 /*
 /*