diff --git a/pages/UI.php b/pages/UI.php
index f63670b48..a1bce7648 100644
--- a/pages/UI.php
+++ b/pages/UI.php
@@ -528,90 +528,59 @@ try
case 'full_text': // Global "google-like" search
$sFullText = trim(utils::ReadParam('text', '', false, 'raw_data'));
+ $iTune = utils::ReadParam('tune', 0);
if (empty($sFullText))
{
$oP->p(Dict::S('UI:Search:NoSearch'));
}
else
{
- $oP->set_title(Dict::S('UI:SearchResultsPageTitle'));
- $oP->p("
".Dict::Format('UI:FullTextSearchTitle_Text', htmlentities($sFullText, ENT_QUOTES, 'UTF-8'))."
");
- $iCount = 0;
- $iBlock = 0;
- // Search in full text mode in all the classes
- $aMatches = array();
- $sClassName = '';
-
- // Check if a class name/label is supplied to limit the search
- if (preg_match('/^(.+):(.+)$/', $sFullText, $aMatches))
+ // Sanity check of the accelerators
+ $iErrors = 0;
+ $aAccelerators = MetaModel::GetConfig()->Get('full_text_accelerators');
+ foreach ($aAccelerators as $sClass => $aAccelerator)
{
- $sClassName = $aMatches[1];
- if (MetaModel::IsValidClass($sClassName))
+ try
{
- $sFullText = $aMatches[2];
- }
- elseif ($sClassName = MetaModel::GetClassFromLabel($sClassName, false /* => not case sensitive */))
- {
- $sFullText = $aMatches[2];
- }
- }
-
- if (preg_match('/^"(.*)"$/', $sFullText, $aMatches))
- {
- // The text is surrounded by double-quotes, remove the quotes and treat it as one single expression
- $aFullTextNeedles = array($aMatches[1]);
- }
- else
- {
- // Split the text on the blanks and treat this as a search for AND AND
- $aFullTextNeedles = explode(' ', $sFullText);
- }
-
- // Search is limited ot a given class, or not...
- if (empty($sClassName))
- {
- $aSearchClasses = MetaModel::GetClasses('searchable');
- }
- else
- {
- $aSearchClasses = MetaModel::EnumChildClasses($sClassName, ENUM_CHILD_CLASSES_ALL);
- }
-
- foreach($aSearchClasses as $sClassName)
- {
- $oFilter = new DBObjectSearch($sClassName);
- foreach($aFullTextNeedles as $sSearchText)
- {
- $oFilter->AddCondition_FullText($sSearchText);
- }
- $oSet = new DBObjectSet($oFilter);
- if ($oSet->Count() > 0)
- {
- $aLeafs = array();
- while($oObj = $oSet->Fetch())
+ $oSearch = DBObjectSearch::FromOQL($aAccelerator['query']);
+ if ($sClass != $oSearch->GetClass())
{
- if (get_class($oObj) == $sClassName)
- {
- $aLeafs[] = $oObj->GetKey();
- }
- }
- $oLeafsFilter = new DBObjectSearch($sClassName);
- if (count($aLeafs) > 0)
- {
- $iCount += count($aLeafs);
- $oP->add("\n");
- $oLeafsFilter->AddCondition('id', $aLeafs, 'IN');
- $oBlock = new DisplayBlock($oLeafsFilter, 'list', false);
- $oBlock->Display($oP, $iBlock++, array('table_id' => 'global_search'));
- $oP->P(' '); // Some space ?
+ $oP->p("Full text accelerator for class '$sClass': searched class mismatch (".$oSearch->GetClass().")");
+ $iErrors++;
}
}
+ catch (OqlException $e)
+ {
+ $oP->p("Full text accelerator for class '$sClass': ".$e->getHtmlDesc());
+ $iErrors++;
+ }
}
- if ($iCount == 0)
+
+ if ($iErrors == 0)
{
- $oP->p(Dict::S('UI:Search:NoObjectFound'));
+ $oP->set_title(Dict::S('UI:SearchResultsPageTitle'));
+ $oP->add("\n");
+ $oP->add("\n");
+ $oP->add("
\n");
+ $oP->add("
\n");
+ $oP->add("
".Dict::Format('UI:FullTextSearchTitle_Text', htmlentities($sFullText, ENT_QUOTES, 'UTF-8'))."
");
+ $oP->add("
\n");
+ $oP->add("
\n");
+ $sJSNeedle = addslashes($sFullText);
+ $oP->add_ready_script(
+<< 0)
+ {
+ $oP->add_script("var oTimeStatistics = {};");
+ }
}
}
break;