");
-
- $oPage->add('');
-
-
- // MUST NOT be localized, as the information given here will be sent to the support
- $oPage->add("".Dict::S('UI:About:Support')."\n");
- $oPage->add("
");
+
+ $oPage->add('');
+
+
+ // MUST NOT be localized, as the information given here will be sent to the support
+ $oPage->add("".Dict::S('UI:About:Support')."\n");
+ $oPage->add("
");
+ $oPage->add('');
+ $oPage->add("
");
+
+ $oPage->add("
");
+ break;
- $oPage->add("
");
- break;
-
case 'history':
- $oPage->SetContentType('text/html');
- $id = (int)utils::ReadParam('id', 0);
- $iStart = (int)utils::ReadParam('start', 0);
- $iCount = (int)utils::ReadParam('count', MetaModel::GetConfig()->Get('max_history_length', '50'));
- $oObj = MetaModel::GetObject($sClass, $id);
- $oObj->DisplayBareHistory($oPage, false, $iCount, $iStart);
- $oPage->add_ready_script("$('#history table.listResults').tableHover(); $('#history table.listResults').tablesorter( { widgets: ['myZebra', 'truncatedList']} );");
- break;
+ $oPage->SetContentType('text/html');
+ $id = (int)utils::ReadParam('id', 0);
+ $iStart = (int)utils::ReadParam('start', 0);
+ $iCount = (int)utils::ReadParam('count', MetaModel::GetConfig()->Get('max_history_length', '50'));
+ $oObj = MetaModel::GetObject($sClass, $id);
+ $oObj->DisplayBareHistory($oPage, false, $iCount, $iStart);
+ $oPage->add_ready_script("$('#history table.listResults').tableHover(); $('#history table.listResults').tablesorter( { widgets: ['myZebra', 'truncatedList']} );");
+ break;
case 'history_from_filter':
- $oPage->SetContentType('text/html');
- $oHistoryFilter = DBSearch::unserialize($sFilter);
- $iStart = (int)utils::ReadParam('start', 0);
- $iCount = (int)utils::ReadParam('count', MetaModel::GetConfig()->Get('max_history_length', '50'));
- $oBlock = new HistoryBlock($oHistoryFilter, 'table', false);
- $oBlock->SetLimit($iCount, $iStart);
- $oBlock->Display($oPage, 'history');
- $oPage->add_ready_script("$('#history table.listResults').tableHover(); $('#history table.listResults').tablesorter( { widgets: ['myZebra', 'truncatedList']} );");
- break;
+ $oPage->SetContentType('text/html');
+ $oHistoryFilter = DBSearch::unserialize($sFilter);
+ $iStart = (int)utils::ReadParam('start', 0);
+ $iCount = (int)utils::ReadParam('count', MetaModel::GetConfig()->Get('max_history_length', '50'));
+ $oBlock = new HistoryBlock($oHistoryFilter, 'table', false);
+ $oBlock->SetLimit($iCount, $iStart);
+ $oBlock->Display($oPage, 'history');
+ $oPage->add_ready_script("$('#history table.listResults').tableHover(); $('#history table.listResults').tablesorter( { widgets: ['myZebra', 'truncatedList']} );");
+ break;
case 'full_text_search':
- $aFullTextNeedles = utils::ReadParam('needles', array(), false, 'raw_data');
- $sFullText = trim(implode(' ', $aFullTextNeedles));
- $sClassName = utils::ReadParam('class', '');
- $iCount = utils::ReadParam('count', 0);
- $iCurrentPos = utils::ReadParam('position', 0);
- $iTune = utils::ReadParam('tune', 0);
- if (empty($sFullText))
- {
- $oPage->p(Dict::S('UI:Search:NoSearch'));
- break;
- }
-
- // Search in full text mode in all the classes
- $aMatches = array();
-
- // Build the ordered list of classes to search into
- //
- if (empty($sClassName))
- {
- $aSearchClasses = MetaModel::GetClasses('searchable');
- }
- else
- {
- // Search is limited to a given class and its subclasses
- $aSearchClasses = MetaModel::EnumChildClasses($sClassName, ENUM_CHILD_CLASSES_ALL);
- }
- // Skip abstract classes, since we search in all the child classes anyway
- foreach($aSearchClasses as $idx => $sClass)
- {
- if (MetaModel::IsAbstract($sClass))
+ $aFullTextNeedles = utils::ReadParam('needles', array(), false, 'raw_data');
+ $sFullText = trim(implode(' ', $aFullTextNeedles));
+ $sClassName = utils::ReadParam('class', '');
+ $iCount = utils::ReadParam('count', 0);
+ $iCurrentPos = utils::ReadParam('position', 0);
+ $iTune = utils::ReadParam('tune', 0);
+ if (empty($sFullText))
{
- unset($aSearchClasses[$idx]);
+ $oPage->p(Dict::S('UI:Search:NoSearch'));
+ break;
}
- }
- $sMaxChunkDuration = MetaModel::GetConfig()->Get('full_text_chunk_duration');
- $aAccelerators = MetaModel::GetConfig()->Get('full_text_accelerators');
+ // Search in full text mode in all the classes
+ $aMatches = array();
- foreach (array_reverse($aAccelerators) as $sClass => $aRestriction)
- {
- $bSkip = false;
- $iPos = array_search($sClass, $aSearchClasses);
- if ($iPos !== false)
+ // Build the ordered list of classes to search into
+ //
+ if (empty($sClassName))
{
- unset($aSearchClasses[$iPos]);
+ $aSearchClasses = MetaModel::GetClasses('searchable');
}
else
{
- $bSkip = true;
+ // Search is limited to a given class and its subclasses
+ $aSearchClasses = MetaModel::EnumChildClasses($sClassName, ENUM_CHILD_CLASSES_ALL);
}
- $bSkip |= array_key_exists('skip', $aRestriction) ? $aRestriction['skip'] : false ;
- if (!in_array($sClass, $aSearchClasses))
- if ($sClass == $sClassName)
+ // Skip abstract classes, since we search in all the child classes anyway
+ foreach($aSearchClasses as $idx => $sClass)
{
- // Class explicitely requested, do NOT skip it
- // beware: there may not be a 'query' defined for a skipped class !
- $bSkip = false;
- }
- if (!$bSkip)
- {
- // NOT skipped, add the class to the list of classes to search into
- if (array_key_exists('query', $aRestriction))
+ if (MetaModel::IsAbstract($sClass))
{
- array_unshift($aSearchClasses, $aRestriction['query']);
+ unset($aSearchClasses[$idx]);
+ }
+ }
+
+ $sMaxChunkDuration = MetaModel::GetConfig()->Get('full_text_chunk_duration');
+ $aAccelerators = MetaModel::GetConfig()->Get('full_text_accelerators');
+
+ foreach(array_reverse($aAccelerators) as $sClass => $aRestriction)
+ {
+ $bSkip = false;
+ $iPos = array_search($sClass, $aSearchClasses);
+ if ($iPos !== false)
+ {
+ unset($aSearchClasses[$iPos]);
}
else
{
- // No accelerator query
- array_unshift($aSearchClasses, $sClassName);
+ $bSkip = true;
}
- }
- }
-
- $aSearchClasses = array_values($aSearchClasses); // renumbers the array starting from zero, removing the missing indexes
- $fStarted = microtime(true);
- $iFoundInThisRound = 0;
- for($iPos = $iCurrentPos; $iPos < count($aSearchClasses) ; $iPos++)
- {
- if ($iFoundInThisRound && (microtime(true) - $fStarted >= $sMaxChunkDuration))
- {
- break;
- }
-
- $sClassSpec = $aSearchClasses[$iPos];
- if (substr($sClassSpec, 0, 7) == 'SELECT ')
- {
- $oFilter = DBObjectSearch::FromOQL($sClassSpec);
- $sClassName = $oFilter->GetClass();
- $sNeedleFormat = isset($aAccelerators[$sClassName]['needle']) ? $aAccelerators[$sClassName]['needle'] : '%$needle$%';
- $sNeedle = str_replace('$needle$', $sFullText, $sNeedleFormat);
- $aParams = array('needle' => $sNeedle);
- }
- else
- {
- $sClassName = $sClassSpec;
- $oFilter = new DBObjectSearch($sClassName);
- $aParams = array();
-
- foreach($aFullTextNeedles as $sSearchText)
+ $bSkip |= array_key_exists('skip', $aRestriction) ? $aRestriction['skip'] : false;
+ if (!in_array($sClass, $aSearchClasses))
{
- $oFilter->AddCondition_FullText($sSearchText);
+ if ($sClass == $sClassName)
+ {
+ // Class explicitely requested, do NOT skip it
+ // beware: there may not be a 'query' defined for a skipped class !
+ $bSkip = false;
+ }
+ }
+ if (!$bSkip)
+ {
+ // NOT skipped, add the class to the list of classes to search into
+ if (array_key_exists('query', $aRestriction))
+ {
+ array_unshift($aSearchClasses, $aRestriction['query']);
+ }
+ else
+ {
+ // No accelerator query
+ array_unshift($aSearchClasses, $sClassName);
+ }
}
}
- $oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
- // Skip abstract classes
- if (MetaModel::IsAbstract($sClassName)) continue;
- if ($iTune > 0)
+ $aSearchClasses = array_values($aSearchClasses); // renumbers the array starting from zero, removing the missing indexes
+ $fStarted = microtime(true);
+ $iFoundInThisRound = 0;
+ for($iPos = $iCurrentPos; $iPos < count($aSearchClasses); $iPos++)
{
- $fStartedClass = microtime(true);
- }
- $oSet = new DBObjectSet($oFilter, array(), $aParams);
- if (array_key_exists($sClassName, $aAccelerators) && array_key_exists('attributes', $aAccelerators[$sClassName]))
- {
- $oSet->OptimizeColumnLoad(array($oFilter->GetClassAlias() => $aAccelerators[$sClassName]['attributes']));
- }
+ if ($iFoundInThisRound && (microtime(true) - $fStarted >= $sMaxChunkDuration))
+ {
+ break;
+ }
- $sFullTextJS = addslashes($sFullText);
- $bEnableEnlarge = array_key_exists($sClassName, $aAccelerators) && array_key_exists('query', $aAccelerators[$sClassName]);
- if (array_key_exists($sClassName, $aAccelerators) && array_key_exists('enable_enlarge', $aAccelerators[$sClassName]))
- {
- $bEnableEnlarge &= $aAccelerators[$sClassName]['enable_enlarge'];
- }
- $sEnlargeTheSearch =
-<<GetClass();
+ $sNeedleFormat = isset($aAccelerators[$sClassName]['needle']) ? $aAccelerators[$sClassName]['needle'] : '%$needle$%';
+ $sNeedle = str_replace('$needle$', $sFullText, $sNeedleFormat);
+ $aParams = array('needle' => $sNeedle);
+ }
+ else
+ {
+ $sClassName = $sClassSpec;
+ $oFilter = new DBObjectSearch($sClassName);
+ $aParams = array();
+
+ foreach($aFullTextNeedles as $sSearchText)
+ {
+ $oFilter->AddCondition_FullText($sSearchText);
+ }
+ }
+ $oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
+ // Skip abstract classes
+ if (MetaModel::IsAbstract($sClassName)) continue;
+
+ if ($iTune > 0)
+ {
+ $fStartedClass = microtime(true);
+ }
+ $oSet = new DBObjectSet($oFilter, array(), $aParams);
+ if (array_key_exists($sClassName, $aAccelerators) && array_key_exists('attributes', $aAccelerators[$sClassName]))
+ {
+ $oSet->OptimizeColumnLoad(array($oFilter->GetClassAlias() => $aAccelerators[$sClassName]['attributes']));
+ }
+
+ $sFullTextJS = addslashes($sFullText);
+ $bEnableEnlarge = array_key_exists($sClassName, $aAccelerators) && array_key_exists('query', $aAccelerators[$sClassName]);
+ if (array_key_exists($sClassName, $aAccelerators) && array_key_exists('enable_enlarge', $aAccelerators[$sClassName]))
+ {
+ $bEnableEnlarge &= $aAccelerators[$sClassName]['enable_enlarge'];
+ }
+ $sEnlargeTheSearch =
+ <<');
@@ -1501,92 +1502,94 @@ EOF
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
$('.search-class-$sClassName').html(data);
});
-EOF
- ;
+EOF;
-
- $sEnlargeButton = '';
- if ($bEnableEnlarge)
- {
- $sEnlargeButton = " ";
- }
- if ($oSet->Count() > 0)
- {
- $aLeafs = array();
- while($oObj = $oSet->Fetch())
+
+ $sEnlargeButton = '';
+ if ($bEnableEnlarge)
{
- if (get_class($oObj) == $sClassName)
+ $sEnlargeButton = " ";
+ }
+ if ($oSet->Count() > 0)
+ {
+ $aLeafs = array();
+ while ($oObj = $oSet->Fetch())
{
- $aLeafs[] = $oObj->GetKey();
- $iFoundInThisRound ++;
+ if (get_class($oObj) == $sClassName)
+ {
+ $aLeafs[] = $oObj->GetKey();
+ $iFoundInThisRound++;
+ }
+ }
+ $oLeafsFilter = new DBObjectSearch($sClassName);
+ if (count($aLeafs) > 0)
+ {
+ $iCount += count($aLeafs);
+ $oPage->add("
\n");
+ $oPage->add("
\n");
+ if (array_key_exists($sClassName, $aAccelerators))
+ {
+ $oPage->add("
');");
- }
- }
- break;
-
- case 'full_text_search_enlarge':
- $sFullText = trim(utils::ReadParam('text', '', false, 'raw_data'));
- $sClass = trim(utils::ReadParam('class', ''));
- $iTune = utils::ReadParam('tune', 0);
-
- 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);
- }
-
- $oFilter = new DBObjectSearch($sClass);
- foreach($aFullTextNeedles as $sSearchText)
- {
- $oFilter->AddCondition_FullText($sSearchText);
- }
- $oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
- $oSet = new DBObjectSet($oFilter);
- $oPage->add("
');
- $oPage->P(' '); // Some space ?
- // Hide "no object found"
- $oPage->add_ready_script('$("#no_object_found").hide();');
+ // The text is surrounded by double-quotes, remove the quotes and treat it as one single expression
+ $aFullTextNeedles = array($aMatches[1]);
}
- }
- $oPage->add_ready_script(
-<< AND AND
+ $aFullTextNeedles = explode(' ', $sFullText);
+ }
+
+ $oFilter = new DBObjectSearch($sClass);
+ foreach($aFullTextNeedles as $sSearchText)
+ {
+ $oFilter->AddCondition_FullText($sSearchText);
+ }
+ $oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
+ $oSet = new DBObjectSet($oFilter);
+ $oPage->add("
\n";
- $oPage->add($sHtml);
- cmdbAbstractObject::DisplaySet($oPage, $oSet, array('table_id' => $sSourceClass.'_'.$sRelation.'_'.$sDirection.'_'.$sListClass));
- $oPage->p(''); // Some space
- }
-
- // Then the content of the groups (one table per group)
- if (count($aGroups) > 0)
- {
- $oPage->get_tcpdf()->AddPage();
- $oPage->add('
\n";
+ $oPage->add($sHtml);
+ cmdbAbstractObject::DisplaySet($oPage, $oSet, array('table_id' => $sSourceClass.'_'.$sRelation.'_'.$sDirection.'_'.$sListClass));
+ $oPage->p(''); // Some space
+ }
+
+ // Then the content of the groups (one table per group)
+ if (count($aGroups) > 0)
+ {
+ $oPage->get_tcpdf()->AddPage();
+ $oPage->add('