* */ namespace Combodo\iTop\Application\Search; use ApplicationContext; use AttributeDefinition; use AttributeExternalField; use AttributeFriendlyName; use AttributeSubItem; use CMDBObjectSet; use Combodo\iTop\Application\Search\CriterionConversion\CriterionToSearchForm; use CoreException; use DBObjectSearch; use DBObjectSet; use Dict; use Exception; use Expression; use FieldExpression; use IssueLog; use MetaModel; use MissingQueryArgument; use TrueExpression; use utils; use WebPage; class SearchForm { /** * @param \WebPage $oPage * @param \CMDBObjectSet $oSet * @param array $aExtraParams * * @return string * @throws \CoreException * @throws \DictExceptionMissingString * @throws \Exception */ public function GetSearchForm(WebPage $oPage, CMDBObjectSet $oSet, $aExtraParams = array()) { $sHtml = ''; $oAppContext = new ApplicationContext(); $sClassName = $oSet->GetFilter()->GetClass(); $aListParams = array(); foreach($aExtraParams as $key => $value) { $aListParams[$key] = $value; } // Simple search form if (isset($aExtraParams['currentId'])) { $sSearchFormId = $aExtraParams['currentId']; } else { $iSearchFormId = $oPage->GetUniqueId(); $sSearchFormId = 'SimpleSearchForm'.$iSearchFormId; $sHtml .= "
\n"; $aListParams['currentId'] = "$iSearchFormId"; } // Check if the current class has some sub-classes if (isset($aExtraParams['baseClass'])) { $sRootClass = $aExtraParams['baseClass']; } else { $sRootClass = $sClassName; } //should the search be opend on load? if (isset($aExtraParams['open'])) { $bOpen = $aExtraParams['open']; } else { $bOpen = true; } $sJson = utils::ReadParam('json', '', false, 'raw_data'); if (!empty($sJson)) { $aListParams['json'] = json_decode($sJson, true); } if (!isset($aExtraParams['result_list_outer_selector'])) { if (isset($aExtraParams['table_id'])) { $aExtraParams['result_list_outer_selector'] = $aExtraParams['table_id']; } else { $aExtraParams['result_list_outer_selector'] = "search_form_result_{$sSearchFormId}"; } } if (isset($aExtraParams['search_header_force_dropdown'])) { $sClassesCombo = $aExtraParams['search_header_force_dropdown']; } else { $aSubClasses = MetaModel::GetSubclasses($sRootClass); if (count($aSubClasses) > 0) { $aOptions = array(); $aOptions[MetaModel::GetName($sRootClass)] = "