public function GetIcon($bImgTag = true, $sMoreStyles = '') { if ($this->Get('url_icon') == '') { return MetaModel::GetClassIcon(get_class($this), $bImgTag); } if ($bImgTag) { return "<img src=\"" . $this->Get('url_icon') . "\" style=\"vertical-align:middle;{$sMoreStyles}\"/>"; } return $this->Get('url_icon'); }
/** * Get the icon representing this object * @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined) * @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file */ public function GetIcon($bImgTag = true) { return MetaModel::GetClassIcon(get_class($this), $bImgTag); }
/** * Get the icon representing this object * @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined) * @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file */ public function GetIcon($bImgTag = true) { $sStatus = $this->Get('status'); switch ($this->GetState()) { case 'approved': case 'implemented': case 'monitored': $sIcon = self::MakeIconFromName('change-approved.png'); break; case 'rejected': case 'notapproved': $sIcon = self::MakeIconFromName('change-rejected.png'); break; case 'closed': $sIcon = self::MakeIconFromName('change-closed.png'); break; default: $sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag); } return $sIcon; }
$sHtml .= "</div>\n"; $oPage->add($sHtml); cmdbAbstractObject::DisplaySet($oPage, $oSet); $oPage->p(''); // Some space } // Then the content of the groups (one table per group) if (count($aGroups) > 0) { $oPage->get_tcpdf()->AddPage(); $oPage->add('<div class="page_header"><h1>' . Dict::S('UI:RelationGroups') . '</h1></div>'); foreach ($aGroups as $idx => $aObjects) { set_time_limit($iLoopTimeLimit); $sListClass = get_class(current($aObjects)); $oSet = CMDBObjectSet::FromArray($sListClass, $aObjects); $sHtml = "<div class=\"page_header\">\n"; $sHtml .= "<table class=\"section\"><tr><td>" . MetaModel::GetClassIcon($sListClass, true, 'width: 24px; height: 24px;') . " " . Dict::Format('UI:RelationGroupNumber_N', 1 + $idx) . "</td></tr></table>\n"; $sHtml .= "</div>\n"; $oPage->add($sHtml); cmdbAbstractObject::DisplaySet($oPage, $oSet); $oPage->p(''); // Some space } } } if ($operation == 'relation_attachment') { $sObjClass = utils::ReadParam('obj_class', '', false, 'class'); $iObjKey = (int) utils::ReadParam('obj_key', 0, false, 'integer'); // Save the generated PDF as an attachment $sPDF = $oPage->get_pdf(); $oPage = new ajax_page(''); $oAttachment = new Attachment();
/** * Display the graph inside the given page, with the "filter" drawer above it * @param WebPage $oP * @param hash $aResults * @param string $sRelation * @param ApplicationContext $oAppContext * @param array $aExcludedObjects */ function Display(WebPage $oP, $aResults, $sRelation, ApplicationContext $oAppContext, $aExcludedObjects = array(), $sObjClass = null, $iObjKey = null, $sContextKey, $aContextParams = array()) { $aContextDefs = static::GetContextDefinitions($sContextKey, true, $aContextParams); $aExcludedByClass = array(); foreach ($aExcludedObjects as $oObj) { if (!array_key_exists(get_class($oObj), $aExcludedByClass)) { $aExcludedByClass[get_class($oObj)] = array(); } $aExcludedByClass[get_class($oObj)][] = $oObj->GetKey(); } $oP->add("<div class=\"not-printable\">\n"); $oP->add("<div id=\"ds_flash\" class=\"SearchDrawer\" style=\"display:none;\">\n"); if (!$oP->IsPrintableVersion()) { $oP->add_ready_script(<<<EOF \t\$( "#tabbedContent_0" ).tabs({ heightStyle: "fill" }); EOF ); } $oP->add_ready_script(<<<EOF \t\$("#dh_flash").click( function() { \t\t\$("#ds_flash").slideToggle('normal', function() { \$("#ds_flash").parent().resize(); \$("#dh_flash").trigger('toggle_complete'); } ); \t\t\$("#dh_flash").toggleClass('open'); \t}); \$('#ReloadMovieBtn').button().button('disable'); EOF ); $aSortedElements = array(); foreach ($aResults as $sClassIdx => $aObjects) { foreach ($aObjects as $oCurrObj) { $sSubClass = get_class($oCurrObj); $aSortedElements[$sSubClass] = MetaModel::GetName($sSubClass); } } asort($aSortedElements); $idx = 0; foreach ($aSortedElements as $sSubClass => $sClassName) { $oP->add("<span style=\"padding-right:2em; white-space:nowrap;\"><input type=\"checkbox\" id=\"exclude_{$idx}\" name=\"excluded[]\" value=\"{$sSubClass}\" checked onChange=\"\$('#ReloadMovieBtn').button('enable')\"><label for=\"exclude_{$idx}\"> " . MetaModel::GetClassIcon($sSubClass) . " {$sClassName}</label></span> "); $idx++; } $oP->add("<p style=\"text-align:right\"><button type=\"button\" id=\"ReloadMovieBtn\" onClick=\"DoReload()\">" . Dict::S('UI:Button:Refresh') . "</button></p>"); $oP->add("</div>\n"); $oP->add("<div class=\"HRDrawer\"></div>\n"); $oP->add("<div id=\"dh_flash\" class=\"DrawerHandle\">" . Dict::S('UI:ElementsDisplayed') . "</div>\n"); $oP->add("</div>\n"); // class="not-printable" $aAdditionalContexts = array(); foreach ($aContextDefs as $sKey => $aDefinition) { $aAdditionalContexts[] = array('key' => $sKey, 'label' => Dict::S($aDefinition['dict']), 'oql' => $aDefinition['oql'], 'default' => array_key_exists('default', $aDefinition) && $aDefinition['default'] == 'yes'); } $sDirection = utils::ReadParam('d', 'horizontal'); $iGroupingThreshold = utils::ReadParam('g', 5); $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/fraphael.js'); $oP->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/jquery.contextMenu.css'); $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.contextMenu.js'); $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/simple_graph.js'); try { $this->InitFromGraphviz(); $sExportAsPdfURL = ''; $sExportAsPdfURL = utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=relation_pdf&relation=' . $sRelation . '&direction=' . ($this->bDirectionDown ? 'down' : 'up'); $oAppcontext = new ApplicationContext(); $sContext = $oAppContext->GetForLink(); $sDrillDownURL = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=details&class=%1$s&id=%2$s&' . $sContext; $sExportAsDocumentURL = utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=relation_attachment&relation=' . $sRelation . '&direction=' . ($this->bDirectionDown ? 'down' : 'up'); $sLoadFromURL = utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=relation_json&relation=' . $sRelation . '&direction=' . ($this->bDirectionDown ? 'down' : 'up'); $sAttachmentExportTitle = ''; if ($sObjClass != null && $iObjKey != null) { $oTargetObj = MetaModel::GetObject($sObjClass, $iObjKey, false); if ($oTargetObj) { $sAttachmentExportTitle = Dict::Format('UI:Relation:AttachmentExportOptions_Name', $oTargetObj->GetName()); } } $sId = 'graph'; $sStyle = ''; if ($oP->IsPrintableVersion()) { // Optimize for printing on A4/Letter vertically $sStyle = 'margin-left:auto; margin-right:auto;'; $oP->add_ready_script("\$('.simple-graph').width(18/2.54*96).resizable({ stop: function() { \$(window).trigger('resized'); }});"); // Default width about 18 cm, since most browsers assume 96 dpi } $oP->add('<div id="' . $sId . '" class="simple-graph" style="' . $sStyle . '"></div>'); $aParams = array('source_url' => $sLoadFromURL, 'sources' => $this->bDirectionDown ? $this->aSourceObjects : $this->aSinkObjects, 'excluded' => $aExcludedByClass, 'grouping_threshold' => $iGroupingThreshold, 'export_as_pdf' => array('url' => $sExportAsPdfURL, 'label' => Dict::S('UI:Relation:ExportAsPDF')), 'export_as_attachment' => array('url' => $sExportAsDocumentURL, 'label' => Dict::S('UI:Relation:ExportAsAttachment'), 'obj_class' => $sObjClass, 'obj_key' => $iObjKey), 'drill_down' => array('url' => $sDrillDownURL, 'label' => Dict::S('UI:Relation:DrillDown')), 'labels' => array('export_pdf_title' => Dict::S('UI:Relation:PDFExportOptions'), 'export_as_attachment_title' => $sAttachmentExportTitle, 'export' => Dict::S('UI:Button:Export'), 'cancel' => Dict::S('UI:Button:Cancel'), 'title' => Dict::S('UI:RelationOption:Title'), 'untitled' => Dict::S('UI:RelationOption:Untitled'), 'include_list' => Dict::S('UI:RelationOption:IncludeList'), 'comments' => Dict::S('UI:RelationOption:Comments'), 'grouping_threshold' => Dict::S('UI:RelationOption:GroupingThreshold'), 'refresh' => Dict::S('UI:Button:Refresh'), 'check_all' => Dict::S('UI:SearchValue:CheckAll'), 'uncheck_all' => Dict::S('UI:SearchValue:UncheckAll'), 'none_selected' => Dict::S('UI:Relation:NoneSelected'), 'nb_selected' => Dict::S('UI:SearchValue:NbSelected'), 'additional_context_info' => Dict::S('UI:Relation:AdditionalContextInfo'), 'zoom' => Dict::S('UI:Relation:Zoom'), 'loading' => Dict::S('UI:Loading')), 'page_format' => array('label' => Dict::S('UI:Relation:PDFExportPageFormat'), 'values' => array('A3' => Dict::S('UI:PageFormat_A3'), 'A4' => Dict::S('UI:PageFormat_A4'), 'Letter' => Dict::S('UI:PageFormat_Letter'))), 'page_orientation' => array('label' => Dict::S('UI:Relation:PDFExportPageOrientation'), 'values' => array('P' => Dict::S('UI:PageOrientation_Portrait'), 'L' => Dict::S('UI:PageOrientation_Landscape'))), 'additional_contexts' => $aAdditionalContexts, 'context_key' => $sContextKey); if (!extension_loaded('gd')) { // PDF export requires GD unset($aParams['export_as_pdf']); } if (!extension_loaded('gd') || is_null($sObjClass) || is_null($iObjKey)) { // Export as Attachment requires GD (for building the PDF) AND a valid objclass/objkey couple unset($aParams['export_as_attachment']); } $oP->add_ready_script("\$('#{$sId}').simple_graph(" . json_encode($aParams) . ");"); } catch (Exception $e) { $oP->add('<div>' . $e->getMessage() . '</div>'); } $oP->add_script(<<<EOF \t\t \tfunction DoReload() \t{ \t\t\$('#ReloadMovieBtn').button('disable'); \t\ttry \t\t{ \t\t\tvar aExcluded = []; \t\t\t\$('input[name^=excluded]').each( function() { \t\t\t\tif (!\$(this).prop('checked')) \t\t\t\t{ \t\t\t\t\taExcluded.push(\$(this).val()); \t\t\t\t} \t\t\t} ); \t\t\t\$('#graph').simple_graph('option', {excluded_classes: aExcluded}); \t\t\t\$('#graph').simple_graph('reload'); \t\t} \t\tcatch(err) \t\t{ \t\t\talert(err); \t\t} \t} EOF ); }
$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 <word1> AND <word2> AND <word3> $aFullTextNeedles = explode(' ', $sFullText); } $oFilter = new DBObjectSearch($sClass); foreach ($aFullTextNeedles as $sSearchText) { $oFilter->AddCondition_FullText($sSearchText); } $oSet = new DBObjectSet($oFilter); $oPage->add("<div class=\"page_header\">\n"); $oPage->add("<h2>" . MetaModel::GetClassIcon($sClass) . " <span class=\"hilite\">" . Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', $oSet->Count(), Metamodel::GetName($sClass)) . "</h2>\n"); $oPage->add("</div>\n"); if ($oSet->Count() > 0) { $aLeafs = array(); while ($oObj = $oSet->Fetch()) { if (get_class($oObj) == $sClass) { $aLeafs[] = $oObj->GetKey(); } } $oLeafsFilter = new DBObjectSearch($sClass); if (count($aLeafs) > 0) { $oLeafsFilter->AddCondition('id', $aLeafs, 'IN'); $oBlock = new DisplayBlock($oLeafsFilter, 'list', false); $sBlockId = 'global_search_' . $sClass; $oPage->add('<div id="' . $sBlockId . '">'); $oBlock->RenderContent($oPage, array('table_id' => $sBlockId, 'currentId' => $sBlockId));
public function GetClassIcon($sClass, $bImgTag = true) { return MetaModel::GetClassIcon($sClass, $bImgTag); }
} } echo "</select>\n"; echo "<input type=\"button\" value=\" Refresh \" onclick=\"CheckDictionary(true);\"/>\n"; echo "<textarea style=\"width:100%;height:400px;\">"; echo MakeDictionaryTemplate($sModules, $sDefaultCode); echo "</textarea>\n"; break; case 'check_db_schema': InitDataModel(ITOP_TOOLKIT_CONFIG_FILE, false); $aAnalysis = CheckDBSchema(); $aSQLFixesTables = array(); $aSQLFixesAll = array(); foreach ($aAnalysis as $sClass => $aData) { if (isset($aData['table_issues'])) { echo "<h2>" . MetaModel::GetClassIcon($sClass) . " Class {$sClass}</h2>\n"; echo "<ul>\n"; foreach ($aData['table_issues'] as $sAttCode => $aIssues) { foreach ($aIssues as $sText) { echo "<li>{$sText}</li>"; } } echo "</ul>\n"; } if (isset($aData['table_fixes'])) { echo "<p class=\"fixes\">\n"; foreach ($aData['table_fixes'] as $sAttCode => $aIssues) { foreach ($aIssues as $sSQL) { $sSQLEscaped = htmlentities($sSQL, ENT_QUOTES, 'UTF-8'); echo "<p class=\"fix-sql\">{$sSQLEscaped}</p>\n"; }
public function GetDefaultValue($sClass = 'Contact') { $sIconPath = MetaModel::GetClassIcon($sClass, false); $sIcon = str_replace(utils::GetAbsoluteUrlModulesRoot(), '', $sIconPath); return $sIcon; }
/** * Get the icon representing this object * @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined) * @return string Either the full IMG tag ($bImgTag == true) or just the URL to the icon file */ public function GetIcon($bImgTag = true) { $sCode = $this->ComputeHighlightCode(); if ($sCode != '') { $aHighlightScale = MetaModel::GetHighlightScale(get_class($this)); if (array_key_exists($sCode, $aHighlightScale)) { $sIconUrl = $aHighlightScale[$sCode]['icon']; if ($bImgTag) { return "<img src=\"{$sIconUrl}\" style=\"vertical-align:middle\"/>"; } else { return $sIconUrl; } } } return MetaModel::GetClassIcon(get_class($this), $bImgTag); }
public function GetObjectCreationDlg(WebPage $oPage, $sProposedRealClass = '') { // For security reasons: check that the "proposed" class is actually a subclass of the linked class // and that the current user is allowed to create objects of this class $sRealClass = ''; $oPage->add('<div class="wizContainer" style="vertical-align:top;"><div>'); $aSubClasses = MetaModel::EnumChildClasses($this->sLinkedClass, ENUM_CHILD_CLASSES_ALL); // Including the specified class itself $aPossibleClasses = array(); foreach ($aSubClasses as $sCandidateClass) { if (!MetaModel::IsAbstract($sCandidateClass) && UserRights::IsActionAllowed($sCandidateClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES) { if ($sCandidateClass == $sProposedRealClass) { $sRealClass = $sProposedRealClass; } $aPossibleClasses[$sCandidateClass] = MetaModel::GetName($sCandidateClass); } } // Only one of the subclasses can be instantiated... if (count($aPossibleClasses) == 1) { $aKeys = array_keys($aPossibleClasses); $sRealClass = $aKeys[0]; } if ($sRealClass != '') { $oPage->add("<h1>" . MetaModel::GetClassIcon($sRealClass) . " " . Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($sRealClass)) . "</h1>\n"); $oLinksetDef = MetaModel::GetAttributeDef($this->sClass, $this->sAttCode); $sExtKeyToMe = $oLinksetDef->GetExtKeyToMe(); $aFieldFlags = array($sExtKeyToMe => OPT_ATT_HIDDEN); cmdbAbstractObject::DisplayCreationForm($oPage, $sRealClass, null, array(), array('formPrefix' => $this->sInputid, 'noRelations' => true, 'fieldsFlags' => $aFieldFlags)); } else { $sClassLabel = MetaModel::GetName($this->sLinkedClass); $oPage->add('<p>' . Dict::Format('UI:SelectTheTypeOf_Class_ToCreate', $sClassLabel)); $oPage->add('<nobr><select name="class">'); asort($aPossibleClasses); foreach ($aPossibleClasses as $sClassName => $sClassLabel) { $oPage->add("<option value=\"{$sClassName}\">{$sClassLabel}</option>"); } $oPage->add('</select>'); $oPage->add(' <button type="button" onclick="$(\'#' . $this->sInputid . '\').directlinks(\'subclassSelected\');">' . Dict::S('UI:Button:Apply') . '</button><span class="indicator" style="display:inline-block;width:16px"></span></nobr></p>'); } $oPage->add('</div></div>'); }
$oGraph->UpdatePositions($aPositions); } $oPage->add($oGraph->GetAsJSON($sContextKey)); $oPage->SetContentType('application/json'); break; case 'relation_groups': $aGroups = utils::ReadParam('groups'); $iBlock = 1; // Zero is not a valid blockid foreach ($aGroups as $idx => $aDefinition) { $sListClass = $aDefinition['class']; $oSearch = new DBObjectSearch($sListClass); $oSearch->AddCondition('id', $aDefinition['keys'], 'IN'); $oPage->add("<h1>" . Dict::Format('UI:RelationGroupNumber_N', 1 + $idx) . "</h1>\n"); $oPage->add("<div id=\"relation_group_{$idx}\" class=\"page_header\">\n"); $oPage->add("<h2>" . MetaModel::GetClassIcon($sListClass) . " <span class=\"hilite\">" . Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', count($aDefinition['keys']), Metamodel::GetName($sListClass)) . "</h2>\n"); $oPage->add("</div>\n"); $oBlock = new DisplayBlock($oSearch, 'list'); $oBlock->Display($oPage, 'group_' . $iBlock++); $oPage->p(' '); // Some space ? } break; case 'ticket_impact': require_once APPROOT . 'core/simplegraph.class.inc.php'; require_once APPROOT . 'core/relationgraph.class.inc.php'; require_once APPROOT . 'core/displayablegraph.class.inc.php'; $sRelation = utils::ReadParam('relation', 'impacts'); $sDirection = utils::ReadParam('direction', 'down'); $iGroupingThreshold = utils::ReadParam('g', 5); $sClass = utils::ReadParam('class', '', false, 'class');
function DisplayNavigatorGroupTab($oP, $aGroups, $sRelation, $oObj) { if (count($aGroups) > 0) { $oP->SetCurrentTab(Dict::S('UI:RelationGroups')); $oP->add("<div id=\"impacted_groupss\" style=\"width:100%;background-color:#fff;padding:10px;\">"); $iBlock = 1; // Zero is not a valid blockid foreach ($aGroups as $idx => $aObjects) { $sListClass = get_class(current($aObjects)); $oSet = CMDBObjectSet::FromArray($sListClass, $aObjects); $oP->add("<h1>" . Dict::Format('UI:RelationGroupNumber_N', 1 + $idx) . "</h1>\n"); $oP->add("<div id=\"relation_group_{$idx}\" class=\"page_header\">\n"); $oP->add("<h2>" . MetaModel::GetClassIcon($sListClass) . " <span class=\"hilite\">" . Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', count($aObjects), Metamodel::GetName($sListClass)) . "</h2>\n"); $oP->add("</div>\n"); $oBlock = DisplayBlock::FromObjectSet($oSet, 'list'); $oBlock->Display($oP, 'group_' . $iBlock++); $oP->p(' '); // Some space ? } $oP->add("</div>"); } }
$iId = utils::ReadParam('id', null); if ($iId == null) { throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'id')); } $oReplica = MetaModel::GetObject('SynchroReplica', $iId); $oReplica->DisplayDetails($oP); break; case 'oql': $sOQL = utils::ReadParam('oql', null, false, 'raw_data'); if ($sOQL == null) { throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'oql')); } $oFilter = DBObjectSearch::FromOQL($sOQL); $oBlock1 = new DisplayBlock($oFilter, 'search', false, array('menu' => false)); $oBlock1->Display($oP, 0); $oP->add('<p class="page-header">' . MetaModel::GetClassIcon('SynchroReplica') . Dict::S('Core:SynchroReplica:ListOfReplicas') . '</p>'); $iSourceId = utils::ReadParam('datasource', null); if ($iSourceId != null) { $oSource = MetaModel::GetObject('SynchroDataSource', $iSourceId); $oP->p(Dict::Format('Core:SynchroReplica:BackToDataSource', $oSource->GetHyperlink()) . '</a>'); } $oBlock = new DisplayBlock($oFilter, 'list', false, array('menu' => false)); $oBlock->Display($oP, 1); break; } } catch (CoreException $e) { $oP->p('<b>An error occured while running the query:</b>'); $oP->p($e->getHtmlDesc()); } catch (Exception $e) { $oP->p('<b>An error occured while running the query:</b>'); $oP->p($e->getMessage());
/** * Get the form to create a new object of the 'target' class */ public function GetObjectCreationForm(WebPage $oPage, $oCurrObject) { // Set all the default values in an object and clone this "default" object $oNewObj = MetaModel::NewObject($this->sTargetClass); // 1st - set context values $oAppContext = new ApplicationContext(); $oAppContext->InitObjectFromContext($oNewObj); // 2nd set the default values from the constraint on the external key... if any if ($oCurrObject != null && $this->sAttCode != '') { $oAttDef = MetaModel::GetAttributeDef(get_class($oCurrObject), $this->sAttCode); $aParams = array('this' => $oCurrObject); $oSet = $oAttDef->GetAllowedValuesAsObjectSet($aParams); $aConsts = $oSet->ListConstantFields(); $sClassAlias = $oSet->GetFilter()->GetClassAlias(); if (isset($aConsts[$sClassAlias])) { foreach ($aConsts[$sClassAlias] as $sAttCode => $value) { $oNewObj->Set($sAttCode, $value); } } } // 3rd - set values from the page argument 'default' $oNewObj->UpdateObjectFromArg('default'); $sDialogTitle = ''; $oPage->add('<div id="ac_create_' . $this->iId . '"><div class="wizContainer" style="vertical-align:top;"><div id="dcr_' . $this->iId . '">'); $oPage->add("<h1>" . MetaModel::GetClassIcon($this->sTargetClass) . " " . Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($this->sTargetClass)) . "</h1>\n"); cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, $oNewObj, array(), array('formPrefix' => $this->iId, 'noRelations' => true)); $oPage->add('</div></div></div>'); // $oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: $(window).width()*0.8, height: 'auto', autoOpen: false, modal: true, title: '$sDialogTitle'});\n"); $oPage->add_ready_script("\$('#ac_create_{$this->iId}').dialog({ width: 'auto', height: 'auto', maxHeight: \$(window).height() - 50, autoOpen: false, modal: true, title: '{$sDialogTitle}'});\n"); $oPage->add_ready_script("\$('#dcr_{$this->iId} form').removeAttr('onsubmit');"); $oPage->add_ready_script("\$('#dcr_{$this->iId} form').bind('submit.uilinksWizard', oACWidget_{$this->iId}.DoCreateObject);"); }
/** * Get the icon representing this object * @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined) * @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file */ public function GetIcon($bImgTag = true) { $sStatus = $this->Get('status'); switch ($this->GetState()) { case 'escalated_tto': case 'escalated_ttr': $sIcon = self::MakeIconFromName('user-request-escalated.png'); break; case 'resolved': case 'closed': $sIcon = self::MakeIconFromName('user-request-closed.png'); break; case 'new': case 'approved': $sIcon = self::MakeIconFromName('user-request.png'); $iEscalationDeadline = $this->Get('tto_escalation_deadline'); if ($iEscalationDeadline != null) { // A SLA is running $oTTOStopWatch = $this->Get('tto'); if ($oTTOStopWatch->IsThresholdPassed(100)) { $sIcon = self::MakeIconFromName('user-request-escalated.png'); } else { if ($oTTOStopWatch->IsThresholdPassed(75)) { $sIcon = self::MakeIconFromName('user-request-deadline.png'); } } } break; case 'assigned': $sIcon = self::MakeIconFromName('user-request.png'); $iEscalationDeadline = $this->Get('ttr_escalation_deadline'); if ($iEscalationDeadline != null) { // A SLA is running $oTTRStopWatch = $this->Get('ttr'); if ($oTTRStopWatch->IsThresholdPassed(100)) { $sIcon = self::MakeIconFromName('user-request-escalated.png'); } else { if ($oTTRStopWatch->IsThresholdPassed(75)) { $sIcon = self::MakeIconFromName('user-request-deadline.png'); } } } break; default: $sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag); } return $sIcon; }
public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId) { $sHtml = ''; // Add the extra params into the filter if they make sense for such a filter $bDoSearch = utils::ReadParam('dosearch', false); if ($this->m_oSet == null) { $aQueryParams = array(); if (isset($aExtraParams['query_params'])) { $aQueryParams = $aExtraParams['query_params']; } if ($this->m_sStyle != 'links') { $oAppContext = new ApplicationContext(); $sClass = $this->m_oFilter->GetClass(); $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($sClass)); $aCallSpec = array($sClass, 'MapContextParam'); if (is_callable($aCallSpec)) { foreach ($oAppContext->GetNames() as $sContextParam) { $sParamCode = call_user_func($aCallSpec, $sContextParam); //Map context parameter to the value/filter code depending on the class if (!is_null($sParamCode)) { $sParamValue = $oAppContext->GetCurrentValue($sContextParam, null); if (!is_null($sParamValue)) { $aExtraParams[$sParamCode] = $sParamValue; } } } } foreach ($aFilterCodes as $sFilterCode) { $externalFilterValue = utils::ReadParam($sFilterCode, '', false, 'raw_data'); $condition = null; if (isset($aExtraParams[$sFilterCode])) { $condition = $aExtraParams[$sFilterCode]; } if ($bDoSearch && $externalFilterValue != "") { // Search takes precedence over context params... unset($aExtraParams[$sFilterCode]); if (!is_array($externalFilterValue)) { $condition = trim($externalFilterValue); } else { if (count($externalFilterValue) == 1) { $condition = trim($externalFilterValue[0]); } else { $condition = $externalFilterValue; } } } if (!is_null($condition)) { $sOpCode = null; // default operator if (is_array($condition)) { // Multiple values, add them as AND X IN (v1, v2, v3...) $sOpCode = 'IN'; } $this->AddCondition($sFilterCode, $condition, $sOpCode); } } if ($bDoSearch) { // Keep the table_id identifying this table if we're performing a search $sTableId = utils::ReadParam('_table_id_', null, false, 'raw_data'); if ($sTableId != null) { $aExtraParams['table_id'] = $sTableId; } } } $aOrderBy = array(); if (isset($aExtraParams['order_by'])) { // Convert the string describing the order_by parameter into an array // The syntax is +attCode1,-attCode2 // attCode1 => ascending, attCode2 => descending $aTemp = explode(',', $aExtraParams['order_by']); foreach ($aTemp as $sTemp) { $aMatches = array(); if (preg_match('/^([+-])?(.+)$/', $sTemp, $aMatches)) { $bAscending = true; if ($aMatches[1] == '-') { $bAscending = false; } $aOrderBy[$aMatches[2]] = $bAscending; } } } $this->m_oSet = new CMDBObjectSet($this->m_oFilter, $aOrderBy, $aQueryParams); } switch ($this->m_sStyle) { case 'count': if (isset($aExtraParams['group_by'])) { if (isset($aExtraParams['group_by_label'])) { $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']); $sGroupByLabel = $aExtraParams['group_by_label']; } else { // Backward compatibility: group_by is simply a field id $sAlias = $this->m_oFilter->GetClassAlias(); $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias); $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']); } $aGroupBy = array(); $aGroupBy['grouped_by_1'] = $oGroupByExp; $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true); $aRes = CMDBSource::QueryToArray($sSql); $aGroupBy = array(); $aLabels = array(); $aValues = array(); $iTotalCount = 0; foreach ($aRes as $iRow => $aRow) { $sValue = $aRow['grouped_by_1']; $aValues[$iRow] = $sValue; $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue); $aLabels[$iRow] = $sHtmlValue; $aGroupBy[$iRow] = (int) $aRow['_itop_count_']; $iTotalCount += $aRow['_itop_count_']; } $aData = array(); $oAppContext = new ApplicationContext(); $sParams = $oAppContext->GetForLink(); foreach ($aGroupBy as $iRow => $iCount) { // Build the search for this subset $oSubsetSearch = $this->m_oFilter->DeepClone(); $oCondition = new BinaryExpression($oGroupByExp, '=', new ScalarExpression($aValues[$iRow])); $oSubsetSearch->AddConditionExpression($oCondition); $sFilter = urlencode($oSubsetSearch->serialize()); $aData[] = array('group' => $aLabels[$iRow], 'value' => "<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=search&dosearch=1&{$sParams}&filter={$sFilter}\">{$iCount}</a>"); // TO DO: add the context information } $aAttribs = array('group' => array('label' => $sGroupByLabel, 'description' => ''), 'value' => array('label' => Dict::S('UI:GroupBy:Count'), 'description' => Dict::S('UI:GroupBy:Count+'))); $sFormat = isset($aExtraParams['format']) ? $aExtraParams['format'] : 'UI:Pagination:HeaderNoSelection'; $sHtml .= $oPage->GetP(Dict::Format($sFormat, $iTotalCount)); $sHtml .= $oPage->GetTable($aAttribs, $aData); } else { // Simply count the number of elements in the set $iCount = $this->m_oSet->Count(); $sFormat = 'UI:CountOfObjects'; if (isset($aExtraParams['format'])) { $sFormat = $aExtraParams['format']; } $sHtml .= $oPage->GetP(Dict::Format($sFormat, $iCount)); } break; case 'join': $aDisplayAliases = isset($aExtraParams['display_aliases']) ? explode(',', $aExtraParams['display_aliases']) : array(); if (!isset($aExtraParams['group_by'])) { $sHtml .= $oPage->GetP(Dict::S('UI:Error:MandatoryTemplateParameter_group_by')); } else { $aGroupByFields = array(); $aGroupBy = explode(',', $aExtraParams['group_by']); foreach ($aGroupBy as $sGroupBy) { $aMatches = array(); if (preg_match('/^(.+)\\.(.+)$/', $sGroupBy, $aMatches) > 0) { $aGroupByFields[] = array('alias' => $aMatches[1], 'att_code' => $aMatches[2]); } } if (count($aGroupByFields) == 0) { $sHtml .= $oPage->GetP(Dict::Format('UI:Error:InvalidGroupByFields', $aExtraParams['group_by'])); } else { $aResults = array(); $aCriteria = array(); while ($aObjects = $this->m_oSet->FetchAssoc()) { $aKeys = array(); foreach ($aGroupByFields as $aField) { $sAlias = $aField['alias']; if (is_null($aObjects[$sAlias])) { $aKeys[$sAlias . '.' . $aField['att_code']] = ''; } else { $aKeys[$sAlias . '.' . $aField['att_code']] = $aObjects[$sAlias]->Get($aField['att_code']); } } $sCategory = implode($aKeys, ' '); $aResults[$sCategory][] = $aObjects; $aCriteria[$sCategory] = $aKeys; } $sHtml .= "<table>\n"; // Construct a new (parametric) query that will return the content of this block $oBlockFilter = $this->m_oFilter->DeepClone(); $aExpressions = array(); $index = 0; foreach ($aGroupByFields as $aField) { $aExpressions[] = '`' . $aField['alias'] . '`.`' . $aField['att_code'] . '` = :param' . $index++; } $sExpression = implode(' AND ', $aExpressions); $oExpression = Expression::FromOQL($sExpression); $oBlockFilter->AddConditionExpression($oExpression); $aExtraParams['menu'] = false; foreach ($aResults as $sCategory => $aObjects) { $sHtml .= "<tr><td><h1>{$sCategory}</h1></td></tr>\n"; if (count($aDisplayAliases) == 1) { $aSimpleArray = array(); foreach ($aObjects as $aRow) { $oObj = $aRow[$aDisplayAliases[0]]; if (!is_null($oObj)) { $aSimpleArray[] = $oObj; } } $oSet = CMDBObjectSet::FromArray($this->m_oFilter->GetClass(), $aSimpleArray); $sHtml .= "<tr><td>" . cmdbAbstractObject::GetDisplaySet($oPage, $oSet, $aExtraParams) . "</td></tr>\n"; } else { $index = 0; $aArgs = array(); foreach ($aGroupByFields as $aField) { $aArgs['param' . $index] = $aCriteria[$sCategory][$aField['alias'] . '.' . $aField['att_code']]; $index++; } $oSet = new CMDBObjectSet($oBlockFilter, array(), $aArgs); $sHtml .= "<tr><td>" . cmdbAbstractObject::GetDisplayExtendedSet($oPage, $oSet, $aExtraParams) . "</td></tr>\n"; } } $sHtml .= "</table>\n"; } } break; case 'list': $aClasses = $this->m_oSet->GetSelectedClasses(); $aAuthorizedClasses = array(); if (count($aClasses) > 1) { // Check the classes that can be read (i.e authorized) by this user... foreach ($aClasses as $sAlias => $sClassName) { if (UserRights::IsActionAllowed($sClassName, UR_ACTION_READ, $this->m_oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) { $aAuthorizedClasses[$sAlias] = $sClassName; } } if (count($aAuthorizedClasses) > 0) { if ($this->m_oSet->Count() > 0) { $sHtml .= cmdbAbstractObject::GetDisplayExtendedSet($oPage, $this->m_oSet, $aExtraParams); } else { // Empty set $sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay')); } } else { // Not authorized $sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay')); } } else { // The list is made of only 1 class of objects, actions on the list are possible if ($this->m_oSet->Count() > 0 && UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES) { $sHtml .= cmdbAbstractObject::GetDisplaySet($oPage, $this->m_oSet, $aExtraParams); } else { $sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay')); $sClass = $this->m_oFilter->GetClass(); $bDisplayMenu = isset($aExtraParams['menu']) ? $aExtraParams['menu'] == true : true; if ($bDisplayMenu) { if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES) { $sLinkTarget = ''; $oAppContext = new ApplicationContext(); $sParams = $oAppContext->GetForLink(); // 1:n links, populate the target object as a default value when creating a new linked object if (isset($aExtraParams['target_attr'])) { $sLinkTarget = ' target="_blank" '; $aExtraParams['default'][$aExtraParams['target_attr']] = $aExtraParams['object_id']; } $sDefault = ''; if (!empty($aExtraParams['default'])) { foreach ($aExtraParams['default'] as $sKey => $sValue) { $sDefault .= "&default[{$sKey}]={$sValue}"; } } $sHtml .= $oPage->GetP("<a{$sLinkTarget} href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=new&class={$sClass}&{$sParams}{$sDefault}\">" . Dict::Format('UI:ClickToCreateNew', Metamodel::GetName($sClass)) . "</a>\n"); } } } } break; case 'links': //$bDashboardMode = isset($aExtraParams['dashboard']) ? ($aExtraParams['dashboard'] == 'true') : false; //$bSelectMode = isset($aExtraParams['select']) ? ($aExtraParams['select'] == 'true') : false; if ($this->m_oSet->Count() > 0 && UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES) { //$sLinkage = isset($aExtraParams['linkage']) ? $aExtraParams['linkage'] : ''; $sHtml .= cmdbAbstractObject::GetDisplaySet($oPage, $this->m_oSet, $aExtraParams); } else { $sClass = $this->m_oFilter->GetClass(); $oAttDef = MetaModel::GetAttributeDef($sClass, $this->m_aParams['target_attr']); $sTargetClass = $oAttDef->GetTargetClass(); $sHtml .= $oPage->GetP(Dict::Format('UI:NoObject_Class_ToDisplay', MetaModel::GetName($sTargetClass))); $bDisplayMenu = isset($this->m_aParams['menu']) ? $this->m_aParams['menu'] == true : true; if ($bDisplayMenu) { if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES) { $oAppContext = new ApplicationContext(); $sParams = $oAppContext->GetForLink(); $sDefaults = ''; if (isset($this->m_aParams['default'])) { foreach ($this->m_aParams['default'] as $sName => $sValue) { $sDefaults .= '&' . urlencode($sName) . '=' . urlencode($sValue); } } $sHtml .= $oPage->GetP("<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=modify_links&class={$sClass}&sParams&link_attr=" . $aExtraParams['link_attr'] . "&id=" . $aExtraParams['object_id'] . "&target_class={$sTargetClass}&addObjects=true{$sDefaults}\">" . Dict::Format('UI:ClickToCreateNew', Metamodel::GetName($sClass)) . "</a>\n"); } } } break; case 'details': while ($oObj = $this->m_oSet->Fetch()) { $sHtml .= $oObj->GetDetails($oPage); // Still used ??? } break; case 'actions': $sClass = $this->m_oFilter->GetClass(); $oAppContext = new ApplicationContext(); $bContextFilter = isset($aExtraParams['context_filter']) ? isset($aExtraParams['context_filter']) != 0 : false; if ($bContextFilter) { $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass())); foreach ($oAppContext->GetNames() as $sFilterCode) { $sContextParamValue = $oAppContext->GetCurrentValue($sFilterCode, null); if (!is_null($sContextParamValue) && !empty($sContextParamValue) && MetaModel::IsValidFilterCode($sClass, $sFilterCode)) { $this->AddCondition($sFilterCode, $sContextParamValue); } } $aQueryParams = array(); if (isset($aExtraParams['query_params'])) { $aQueryParams = $aExtraParams['query_params']; } $this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams); } $iCount = $this->m_oSet->Count(); $sHyperlink = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($this->m_oFilter->serialize()); $sHtml .= '<p><a class="actions" href="' . $sHyperlink . '">'; // Note: border set to 0 due to various browser interpretations (IE9 adding a 2px border) $sHtml .= MetaModel::GetClassIcon($sClass, true, 'float;left;margin-right:10px;border:0;'); $sHtml .= MetaModel::GetName($sClass) . ': ' . $iCount . '</a></p>'; $sParams = $oAppContext->GetForLink(); $sHtml .= '<p>'; if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY)) { $sHtml .= "<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=new&class={$sClass}&{$sParams}\">" . Dict::Format('UI:ClickToCreateNew', MetaModel::GetName($sClass)) . "</a><br/>\n"; } $sHtml .= "<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=search_form&do_search=0&class={$sClass}&{$sParams}\">" . Dict::Format('UI:SearchFor_Class', MetaModel::GetName($sClass)) . "</a>\n"; $sHtml .= '</p>'; break; case 'summary': $sClass = $this->m_oFilter->GetClass(); $oAppContext = new ApplicationContext(); $sTitle = isset($aExtraParams['title[block]']) ? $aExtraParams['title[block]'] : ''; $sLabel = isset($aExtraParams['label[block]']) ? $aExtraParams['label[block]'] : ''; $sStateAttrCode = isset($aExtraParams['status[block]']) ? $aExtraParams['status[block]'] : 'status'; $sStatesList = isset($aExtraParams['status_codes[block]']) ? $aExtraParams['status_codes[block]'] : ''; $bContextFilter = isset($aExtraParams['context_filter']) ? isset($aExtraParams['context_filter']) != 0 : false; if ($bContextFilter) { $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass())); foreach ($oAppContext->GetNames() as $sFilterCode) { $sContextParamValue = $oAppContext->GetCurrentValue($sFilterCode, null); if (!is_null($sContextParamValue) && !empty($sContextParamValue) && MetaModel::IsValidFilterCode($sClass, $sFilterCode)) { $this->AddCondition($sFilterCode, $sContextParamValue); } } $aQueryParams = array(); if (isset($aExtraParams['query_params'])) { $aQueryParams = $aExtraParams['query_params']; } $this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams); } // Summary details $aCounts = array(); $aStateLabels = array(); if (!empty($sStateAttrCode) && !empty($sStatesList)) { $aStates = explode(',', $sStatesList); $oAttDef = MetaModel::GetAttributeDef($sClass, $sStateAttrCode); foreach ($aStates as $sStateValue) { $oFilter = $this->m_oFilter->DeepClone(); $oFilter->AddCondition($sStateAttrCode, $sStateValue, '='); $oSet = new DBObjectSet($oFilter); $aCounts[$sStateValue] = $oSet->Count(); $aStateLabels[$sStateValue] = htmlentities($oAttDef->GetValueLabel($sStateValue), ENT_QUOTES, 'UTF-8'); if ($aCounts[$sStateValue] == 0) { $aCounts[$sStateValue] = '-'; } else { $sHyperlink = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($oFilter->serialize()); $aCounts[$sStateValue] = "<a href=\"{$sHyperlink}\">{$aCounts[$sStateValue]}</a>"; } } } $sHtml .= '<div class="summary-details"><table><tr><th>' . implode('</th><th>', $aStateLabels) . '</th></tr>'; $sHtml .= '<tr><td>' . implode('</td><td>', $aCounts) . '</td></tr></table></div>'; // Title & summary $iCount = $this->m_oSet->Count(); $sHyperlink = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($this->m_oFilter->serialize()); $sHtml .= '<h1>' . Dict::S(str_replace('_', ':', $sTitle)) . '</h1>'; $sHtml .= '<a class="summary" href="' . $sHyperlink . '">' . Dict::Format(str_replace('_', ':', $sLabel), $iCount) . '</a>'; $sHtml .= '<div style="clear:both;"></div>'; break; case 'csv': $bAdvancedMode = utils::ReadParam('advanced', false); $sCsvFile = strtolower($this->m_oFilter->GetClass()) . '.csv'; $sDownloadLink = utils::GetAbsoluteUrlAppRoot() . 'webservices/export.php?expression=' . urlencode($this->m_oFilter->ToOQL(true)) . '&format=csv&filename=' . urlencode($sCsvFile); $sLinkToToggle = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($this->m_oFilter->serialize()) . '&format=csv'; if ($bAdvancedMode) { $sDownloadLink .= '&fields_advanced=1'; $sChecked = 'CHECKED'; } else { $sLinkToToggle = $sLinkToToggle . '&advanced=1'; $sChecked = ''; } $sAjaxLink = $sDownloadLink . '&charset=UTF-8'; // Includes &fields_advanced=1 if in advanced mode /* $sCSVData = cmdbAbstractObject::GetSetAsCSV($this->m_oSet, array('fields_advanced' => $bAdvancedMode)); $sCharset = MetaModel::GetConfig()->Get('csv_file_default_charset'); if ($sCharset == 'UTF-8') { $bLostChars = false; } else { $sConverted = @iconv('UTF-8', $sCharset, $sCSVData); $sRestored = @iconv($sCharset, 'UTF-8', $sConverted); $bLostChars = ($sRestored != $sCSVData); } if ($bLostChars) { $sCharsetNotice = " <span id=\"csv_charset_issue\">"; $sCharsetNotice .= '<img src="../images/error.png" style="vertical-align:middle"/>'; $sCharsetNotice .= "</span>"; $sTip = "<p>".htmlentities(Dict::S('UI:CSVExport:LostChars'), ENT_QUOTES, 'UTF-8')."</p>"; $sTip .= "<p>".htmlentities(Dict::Format('UI:CSVExport:LostChars+', $sCharset), ENT_QUOTES, 'UTF-8')."</p>"; $oPage->add_ready_script("$('#csv_charset_issue').qtip( { content: '$sTip', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );"); } else { $sCharsetNotice = ''; } */ $sCharsetNotice = false; $sHtml .= "<div>"; $sHtml .= '<table style="width:100%" class="transparent">'; $sHtml .= '<tr>'; $sHtml .= '<td><a href="' . $sDownloadLink . '">' . Dict::Format('UI:Download-CSV', $sCsvFile) . '</a>' . $sCharsetNotice . '</td>'; $sHtml .= '<td style="text-align:right"><input type="checkbox" ' . $sChecked . ' onClick="window.location.href=\'' . $sLinkToToggle . '\'"> ' . Dict::S('UI:CSVExport:AdvancedMode') . '</td>'; $sHtml .= '</tr>'; $sHtml .= '</table>'; if ($bAdvancedMode) { $sHtml .= "<p>"; $sHtml .= htmlentities(Dict::S('UI:CSVExport:AdvancedMode+'), ENT_QUOTES, 'UTF-8'); $sHtml .= "</p>"; } $sHtml .= "</div>"; $sHtml .= "<div id=\"csv_content_loading\"><div style=\"width: 250px; height: 20px; background: url(../setup/orange-progress.gif); border: 1px #999 solid; margin-left:auto; margin-right: auto; text-align: center;\">" . Dict::S('UI:Loading') . "</div></div><textarea id=\"csv_content\" style=\"display:none;\">\n"; //$sHtml .= htmlentities($sCSVData, ENT_QUOTES, 'UTF-8'); $sHtml .= "</textarea>\n"; $oPage->add_ready_script("\$.post('{$sAjaxLink}', {}, function(data) { \$('#csv_content').html(data); \$('#csv_content_loading').hide(); \$('#csv_content').show();} );"); break; case 'modify': if (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_MODIFY, $this->m_oSet) == UR_ALLOWED_YES) { while ($oObj = $this->m_oSet->Fetch()) { $sHtml .= $oObj->GetModifyForm($oPage); } } break; case 'search': $sStyle = isset($aExtraParams['open']) && $aExtraParams['open'] == 'true' ? 'SearchDrawer' : 'SearchDrawer DrawerClosed'; $sHtml .= "<div id=\"ds_{$sId}\" class=\"{$sStyle}\">\n"; $oPage->add_ready_script(<<<EOF \t\$("#dh_{$sId}").click( function() { \t\t\$("#ds_{$sId}").slideToggle('normal', function() { \$("#ds_{$sId}").parent().resize(); FixSearchFormsDisposition(); } ); \t\t\$("#dh_{$sId}").toggleClass('open'); \t}); EOF ); $aExtraParams['currentId'] = $sId; $sHtml .= cmdbAbstractObject::GetSearchForm($oPage, $this->m_oSet, $aExtraParams); $sHtml .= "</div>\n"; $sHtml .= "<div class=\"HRDrawer\"></div>\n"; $sHtml .= "<div id=\"dh_{$sId}\" class=\"DrawerHandle\">" . Dict::S('UI:SearchToggle') . "</div>\n"; break; case 'open_flash_chart': static $iChartCounter = 0; $oAppContext = new ApplicationContext(); $sContext = $oAppContext->GetForLink(); if (!empty($sContext)) { $sContext = '&' . $sContext; } $sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie'; $sTitle = isset($aExtraParams['chart_title']) ? $aExtraParams['chart_title'] : ''; $sGroupBy = isset($aExtraParams['group_by']) ? $aExtraParams['group_by'] : ''; $sGroupByExpr = isset($aExtraParams['group_by_expr']) ? '¶ms[group_by_expr]=' . $aExtraParams['group_by_expr'] : ''; $sFilter = $this->m_oFilter->serialize(); $sHtml .= "<div id=\"my_chart_{$sId}{$iChartCounter}\">If the chart does not display, <a href=\"http://get.adobe.com/flash/\" target=\"_blank\">install Flash</a></div>\n"; $oPage->add_script("function ofc_resize(left, width, top, height) { /* do nothing special */ }"); if (isset($aExtraParams['group_by_label'])) { $sUrl = urlencode(utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=open_flash_chart¶ms[group_by]={$sGroupBy}{$sGroupByExpr}¶ms[group_by_label]={$aExtraParams['group_by_label']}¶ms[chart_type]={$sChartType}¶ms[chart_title]={$sTitle}¶ms[currentId]={$sId}&id={$sId}&filter=" . urlencode($sFilter)); } else { $sUrl = urlencode(utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=open_flash_chart¶ms[group_by]={$sGroupBy}{$sGroupByExpr}¶ms[chart_type]={$sChartType}¶ms[chart_title]={$sTitle}¶ms[currentId]={$sId}&id={$sId}&filter=" . urlencode($sFilter)); } $oPage->add_ready_script("swfobject.embedSWF(\"../images/open-flash-chart.swf\", \"my_chart_{$sId}{$iChartCounter}\", \"100%\", \"300\",\"9.0.0\", \"expressInstall.swf\",\n\t\t\t\t{\"data-file\":\"" . $sUrl . "\"}, {wmode: 'transparent'} );\n"); $iChartCounter++; if (isset($aExtraParams['group_by'])) { if (isset($aExtraParams['group_by_label'])) { $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']); $sGroupByLabel = $aExtraParams['group_by_label']; } else { // Backward compatibility: group_by is simply a field id $sAlias = $this->m_oFilter->GetClassAlias(); $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias); $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']); } $aGroupBy = array(); $aGroupBy['grouped_by_1'] = $oGroupByExp; $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true); $aRes = CMDBSource::QueryToArray($sSql); $aGroupBy = array(); $aLabels = array(); $aValues = array(); $iTotalCount = 0; foreach ($aRes as $iRow => $aRow) { $sValue = $aRow['grouped_by_1']; $aValues[$iRow] = $sValue; $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue); $aLabels[$iRow] = $sHtmlValue; $aGroupBy[$iRow] = (int) $aRow['_itop_count_']; $iTotalCount += $aRow['_itop_count_']; } $aData = array(); $idx = 0; $aURLs = array(); foreach ($aGroupBy as $iRow => $iCount) { // Build the search for this subset $oSubsetSearch = $this->m_oFilter->DeepClone(); $oCondition = new BinaryExpression($oGroupByExp, '=', new ScalarExpression($aValues[$iRow])); $oSubsetSearch->AddConditionExpression($oCondition); $aURLs[$idx] = $oSubsetSearch->serialize(); $idx++; } $sURLList = ''; foreach ($aURLs as $index => $sURL) { $sURLList .= "\taURLs[{$index}] = '" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=search&format=html{$sContext}&filter=" . urlencode($sURL) . "';\n"; } $oPage->add_script(<<<EOF function ofc_drill_down_{$sId}(index) { \tvar aURLs = new Array(); {$sURLList} \twindow.location.href=aURLs[index]; } EOF ); } break; case 'open_flash_chart_ajax': require_once APPROOT . '/pages/php-ofc-library/open-flash-chart.php'; $sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie'; $sId = utils::ReadParam('id', ''); $oChart = new open_flash_chart(); switch ($sChartType) { case 'bars': $oChartElement = new bar_glass(); if (isset($aExtraParams['group_by'])) { if (isset($aExtraParams['group_by_label'])) { $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']); $sGroupByLabel = $aExtraParams['group_by_label']; } else { // Backward compatibility: group_by is simply a field id $sAlias = $this->m_oFilter->GetClassAlias(); $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias); $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']); } $aGroupBy = array(); $aGroupBy['grouped_by_1'] = $oGroupByExp; $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true); $aRes = CMDBSource::QueryToArray($sSql); $aGroupBy = array(); $aLabels = array(); $iTotalCount = 0; foreach ($aRes as $iRow => $aRow) { $sValue = $aRow['grouped_by_1']; $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue); $aLabels[$iRow] = strip_tags($sHtmlValue); $aGroupBy[$iRow] = (int) $aRow['_itop_count_']; $iTotalCount += $aRow['_itop_count_']; } $aData = array(); $aChartLabels = array(); $maxValue = 0; foreach ($aGroupBy as $iRow => $iCount) { $oBarValue = new bar_value($iCount); $oBarValue->on_click("ofc_drill_down_{$sId}"); $aData[] = $oBarValue; if ($iCount > $maxValue) { $maxValue = $iCount; } $aChartLabels[] = html_entity_decode($aLabels[$iRow], ENT_QUOTES, 'UTF-8'); } $oYAxis = new y_axis(); $aMagicValues = array(1, 2, 5, 10); $iMultiplier = 1; $index = 0; $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier; while ($maxValue > $iTop) { $index++; $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier; if ($index % count($aMagicValues) == 0) { $iMultiplier = $iMultiplier * 10; } } //echo "oYAxis->set_range(0, $iTop, $iMultiplier);\n"; $oYAxis->set_range(0, $iTop, $iMultiplier); $oChart->set_y_axis($oYAxis); $oChartElement->set_values($aData); $oXAxis = new x_axis(); $oXLabels = new x_axis_labels(); // set them vertical $oXLabels->set_vertical(); // set the label text $oXLabels->set_labels($aChartLabels); // Add the X Axis Labels to the X Axis $oXAxis->set_labels($oXLabels); $oChart->set_x_axis($oXAxis); } break; case 'pie': default: $oChartElement = new pie(); $oChartElement->set_start_angle(35); $oChartElement->set_animate(true); $oChartElement->set_tooltip('#label# - #val# (#percent#)'); $oChartElement->set_colours(array('#FF8A00', '#909980', '#2C2B33', '#CCC08D', '#596664')); if (isset($aExtraParams['group_by'])) { if (isset($aExtraParams['group_by_label'])) { $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']); $sGroupByLabel = $aExtraParams['group_by_label']; } else { // Backward compatibility: group_by is simply a field id $sAlias = $this->m_oFilter->GetClassAlias(); $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias); $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']); } $aGroupBy = array(); $aGroupBy['grouped_by_1'] = $oGroupByExp; $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true); $aRes = CMDBSource::QueryToArray($sSql); $aGroupBy = array(); $aLabels = array(); $iTotalCount = 0; foreach ($aRes as $iRow => $aRow) { $sValue = $aRow['grouped_by_1']; $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue); $aLabels[$iRow] = strip_tags($sHtmlValue); $aGroupBy[$iRow] = (int) $aRow['_itop_count_']; $iTotalCount += $aRow['_itop_count_']; } $aData = array(); foreach ($aGroupBy as $iRow => $iCount) { $sFlashLabel = html_entity_decode($aLabels[$iRow], ENT_QUOTES, 'UTF-8'); $PieValue = new pie_value($iCount, $sFlashLabel); //@@ BUG: not passed via ajax !!! $PieValue->on_click("ofc_drill_down_{$sId}"); $aData[] = $PieValue; } $oChartElement->set_values($aData); $oChart->x_axis = null; } } if (isset($aExtraParams['chart_title'])) { // The title has been given in an url, and urlencoded... // and urlencode transforms utf-8 into something similar to ISO-8859-1 // Example: é (C3A9 becomes %E9) // As a consequence, json_encode (called within open-flash-chart.php) // was returning 'null' and the graph was not displayed at all // To make sure that the graph is displayed AND to get a correct title // (at least for european characters) let's transform back into utf-8 ! $sTitle = iconv("ISO-8859-1", "UTF-8//IGNORE", $aExtraParams['chart_title']); // If the title is a dictionnary entry, fetch it $sTitle = Dict::S($sTitle); $oTitle = new title($sTitle); $oChart->set_title($oTitle); $oTitle->set_style("{font-size: 16px; font-family: Tahoma; font-weight: bold; text-align: center;}"); } $oChart->set_bg_colour('#FFFFFF'); $oChart->add_element($oChartElement); $sHtml = $oChart->toPrettyString(); break; default: // Unsupported style, do nothing. $sHtml .= Dict::format('UI:Error:UnsupportedStyleOfBlock', $this->m_sStyle); } return $sHtml; }
function DisplayNavigatorGraphicsTab($oP, $aResults, $sClass, $id, $sRelation, $oAppContext) { $oP->SetCurrentTab(Dict::S('UI:RelationshipGraph')); $oP->add("<div id=\"ds_flash\" class=\"SearchDrawer\">\n"); $oP->add_ready_script(<<<EOF \t\$("#dh_flash").click( function() { \t\t\$("#ds_flash").slideToggle('normal', function() { \$("#ds_flash").parent().resize(); } ); \t\t\$("#dh_flash").toggleClass('open'); \t}); EOF ); $aSortedElements = array(); foreach ($aResults as $sClassIdx => $aObjects) { foreach ($aObjects as $oCurrObj) { $sSubClass = get_class($oCurrObj); $aSortedElements[$sSubClass] = MetaModel::GetName($sSubClass); } } asort($aSortedElements); $idx = 0; foreach ($aSortedElements as $sSubClass => $sClassName) { $oP->add("<span style=\"padding-right:2em; white-space:nowrap;\"><input type=\"checkbox\" id=\"exclude_{$idx}\" name=\"excluded[]\" value=\"{$sSubClass}\" checked onChange=\"\$('#ReloadMovieBtn').button('enable')\"><label for=\"exclude_{$idx}\"> " . MetaModel::GetClassIcon($sSubClass) . " {$sClassName}</label></span> "); $idx++; } $oP->add("<p style=\"text-align:right\"><button type=\"button\" id=\"ReloadMovieBtn\" onClick=\"DoReload()\">" . Dict::S('UI:Button:Refresh') . "</button></p>"); $oP->add("</div>\n"); $oP->add("<div class=\"HRDrawer\"></div>\n"); $oP->add("<div id=\"dh_flash\" class=\"DrawerHandle\">" . Dict::S('UI:ElementsDisplayed') . "</div>\n"); $width = 1000; $height = 700; $sDrillUrl = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=details&' . $oAppContext->GetForLink(); $sParams = "pWidth={$width}&pHeight={$height}&drillUrl=" . urlencode($sDrillUrl) . "&displayController=false&xmlUrl=" . urlencode("./xml.navigator.php") . "&obj_class={$sClass}&obj_id={$id}&relation={$sRelation}"; $oP->add("<div style=\"z-index:1;background:white;width:100%;height:{$height}px\"><object style=\"z-index:2\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"100%\" height=\"{$height}\" id=\"navigator\" align=\"middle\">\n\t<param name=\"allowScriptAccess\" value=\"always\" />\n\t<param name=\"allowFullScreen\" value=\"false\" />\n\t<param name=\"FlashVars\" value=\"{$sParams}\" />\n\t<param name=\"wmode\" value=\"transparent\"> \n\t<param name=\"movie\" value=\"../navigator/navigator.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#ffffff\" />\n\t<embed src=\"../navigator/navigator.swf\" wmode=\"transparent\" flashVars=\"{$sParams}\" quality=\"high\" bgcolor=\"#ffffff\" width=\"100%\" height=\"{$height}\" name=\"navigator\" align=\"middle\" swliveconnect=\"true\" allowScriptAccess=\"always\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.adobe.com/go/getflashplayer\" />\n\t</object></div>\n"); $oP->add_script(<<<EOF function getFlashMovieObject(movieName) { if (window.document[movieName]) { return window.document[movieName]; } if (navigator.appName.indexOf("Microsoft Internet")==-1) { if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; } else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) { return document.getElementById(movieName); } }\t \tfunction DoReload() \t{ \t\t\$('#ReloadMovieBtn').button('disable'); \t\tvar oMovie = getFlashMovieObject('navigator'); \t\ttry \t\t{ \t\t\tvar aExcluded = []; \t\t\t\$('input[name^=excluded]').each( function() { \t\t\t\tif (!\$(this).attr('checked')) \t\t\t\t{ \t\t\t\t\taExcluded.push(\$(this).val()); \t\t\t\t} \t\t\t} ); \t\t\toMovie.Filter(aExcluded.join(',')); \t\t//oMovie.SetVariable("/:message", "foo"); \t\t} \t\tcatch(err) \t\t{ \t\t\talert(err); \t\t} \t} EOF ); $oP->add_ready_script(<<<EOF \tvar ajax_request = null; \t\$('#ReloadMovieBtn').button().button('disable'); \t \tfunction UpdateImpactedObjects(sClass, iId, sRelation) \t{ \t\tvar class_name = sClass; //\$('select[name=class_name]').val(); \t\tif (class_name != '') \t\t{ \t\t\t\$('#impacted_objects').block(); \t \t\t\t// Make sure that we cancel any pending request before issuing another \t\t\t// since responses may arrive in arbitrary order \t\t\tif (ajax_request != null) \t\t\t{ \t\t\t\tajax_request.abort(); \t\t\t\tajax_request = null; \t\t\t} \t \t\t\tajax_request = \$.get(GetAbsoluteUrlAppRoot()+'pages/xml.navigator.php', { 'class': sClass, id: iId, relation: sRelation, format: 'html' }, \t\t\t\t\tfunction(data) \t\t\t\t\t{ \t\t\t\t\t\t\$('#impacted_objects').empty(); \t\t\t\t\t\t\$('#impacted_objects').append(data); \t\t\t\t\t\t\$('#impacted_objects').unblock(); \t\t\t\t\t} \t\t\t); \t\t} \t} EOF ); }
public static function RenderOQLSearch($sOql, $sTitle, $sUsageId, $bSearchPane, $bSearchOpen, WebPage $oPage, $aExtraParams = array()) { $sUsageId = utils::GetSafeId($sUsageId); $oSearch = DBObjectSearch::FromOQL($sOql); $sIcon = MetaModel::GetClassIcon($oSearch->GetClass()); if ($bSearchPane) { $aParams = array_merge(array('open' => $bSearchOpen, 'table_id' => $sUsageId), $aExtraParams); $oBlock = new DisplayBlock($oSearch, 'search', false, $aParams); $oBlock->Display($oPage, 0); } $oPage->add("<p class=\"page-header\">{$sIcon} " . Dict::S($sTitle) . "</p>"); $aParams = array_merge(array('table_id' => $sUsageId), $aExtraParams); $oBlock = new DisplayBlock($oSearch, 'list', false, $aParams); $oBlock->Display($oPage, $sUsageId); }
/** * Display a banner for the special "synchro" mode * @param WebPage $oP The Page for the output * @param string $sClass The class of objects to synchronize * @param integer $iCount The number of objects to synchronize * @return none */ function DisplaySynchroBanner(WebPage $oP, $sClass, $iCount) { $oP->add("<div class=\"notification\"><p><h1>" . MetaModel::GetClassIcon($sClass) . " " . Dict::Format('UI:Title:BulkSynchro_nbItem_ofClass_class', $iCount, MetaModel::GetName($sClass)) . "</h1></p></div>\n"); }
/** * Process the reply made from a form built with DisplayBulkModifyForm */ public static function DoBulkModify($oP, $sClass, $aSelectedObj, $sCustomOperation, $bPreview, $sCancelUrl, $aContextData = array()) { $aHeaders = array('form::select' => array('label' => "<input type=\"checkbox\" onClick=\"CheckAll('.selectList:not(:disabled)', this.checked);\"></input>", 'description' => Dict::S('UI:SelectAllToggle+')), 'object' => array('label' => MetaModel::GetName($sClass), 'description' => Dict::S('UI:ModifiedObject')), 'status' => array('label' => Dict::S('UI:BulkModifyStatus'), 'description' => Dict::S('UI:BulkModifyStatus+')), 'errors' => array('label' => Dict::S('UI:BulkModifyErrors'), 'description' => Dict::S('UI:BulkModifyErrors+'))); $aRows = array(); $oP->add("<div class=\"page_header\">\n"); $oP->add("<h1>" . MetaModel::GetClassIcon($sClass) . " " . Dict::Format('UI:Modify_N_ObjectsOf_Class', count($aSelectedObj), MetaModel::GetName($sClass)) . "</h1>\n"); $oP->add("</div>\n"); $oP->set_title(Dict::Format('UI:Modify_N_ObjectsOf_Class', count($aSelectedObj), $sClass)); if (!$bPreview) { // Not in preview mode, do the update for real $sTransactionId = utils::ReadPostedParam('transaction_id', ''); if (!utils::IsTransactionValid($sTransactionId, false)) { throw new Exception(Dict::S('UI:Error:ObjectAlreadyUpdated')); } utils::RemoveTransaction($sTransactionId); } $iPreviousTimeLimit = ini_get('max_execution_time'); $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop'); foreach ($aSelectedObj as $iId) { set_time_limit($iLoopTimeLimit); $oObj = MetaModel::GetObject($sClass, $iId); $aErrors = $oObj->UpdateObjectFromPostedForm(''); $bResult = count($aErrors) == 0; if ($bResult) { list($bResult, $aErrors) = $oObj->CheckToWrite(true); } if ($bPreview) { $sStatus = $bResult ? Dict::S('UI:BulkModifyStatusOk') : Dict::S('UI:BulkModifyStatusError'); } else { $sStatus = $bResult ? Dict::S('UI:BulkModifyStatusModified') : Dict::S('UI:BulkModifyStatusSkipped'); } $sCSSClass = $bResult ? HILIGHT_CLASS_NONE : HILIGHT_CLASS_CRITICAL; $sChecked = $bResult ? 'checked' : ''; $sDisabled = $bResult ? '' : 'disabled'; $aRows[] = array('form::select' => "<input type=\"checkbox\" class=\"selectList\" {$sChecked} {$sDisabled}\"></input>", 'object' => $oObj->GetHyperlink(), 'status' => $sStatus, 'errors' => '<p>' . ($bResult ? '' : implode('</p><p>', $aErrors)) . '</p>', '@class' => $sCSSClass); if ($bResult && !$bPreview) { $oObj->DBUpdate(); } } set_time_limit($iPreviousTimeLimit); $oP->Table($aHeaders, $aRows); if ($bPreview) { $sFormAction = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php'; // No parameter in the URL, the only parameter will be the ones passed through the form // Form to submit: $oP->add("<form method=\"post\" action=\"{$sFormAction}\" enctype=\"multipart/form-data\">\n"); $aDefaults = utils::ReadParam('default', array()); $oAppContext = new ApplicationContext(); $oP->add($oAppContext->GetForForm()); foreach ($aContextData as $sKey => $value) { $oP->add("<input type=\"hidden\" name=\"{$sKey}\" value=\"{$value}\">\n"); } $oP->add("<input type=\"hidden\" name=\"operation\" value=\"{$sCustomOperation}\">\n"); $oP->add("<input type=\"hidden\" name=\"class\" value=\"{$sClass}\">\n"); $oP->add("<input type=\"hidden\" name=\"preview_mode\" value=\"0\">\n"); $oP->add("<input type=\"hidden\" name=\"transaction_id\" value=\"" . utils::GetNewTransactionId() . "\">\n"); $oP->add("<button type=\"button\" class=\"action cancel\" onClick=\"window.location.href='{$sCancelUrl}'\">" . Dict::S('UI:Button:Cancel') . "</button> \n"); $oP->add("<button type=\"submit\" class=\"action\"><span>" . Dict::S('UI:Button:ModifyAll') . "</span></button>\n"); foreach ($_POST as $sKey => $value) { if (preg_match('/attr_(.+)/', $sKey, $aMatches)) { // Beware: some values (like durations) are passed as arrays if (is_array($value)) { foreach ($value as $vKey => $vValue) { $oP->add("<input type=\"hidden\" name=\"{$sKey}[{$vKey}]\" value=\"" . htmlentities($vValue, ENT_QUOTES, 'UTF-8') . "\">\n"); } } else { $oP->add("<input type=\"hidden\" name=\"{$sKey}\" value=\"" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "\">\n"); } } } $oP->add("</form>\n"); } else { $oP->add("<button type=\"button\" onClick=\"window.location.href='{$sCancelUrl}'\" class=\"action\"><span>" . Dict::S('UI:Button:Done') . "</span></button>\n"); } }
function DisplayNavigatorListTab($oP, $aResults, $sRelation, $sDirection, $oObj) { $oP->SetCurrentTab(Dict::S('UI:RelationshipList')); $oP->add("<div id=\"impacted_objects\" style=\"width:100%;background-color:#fff;padding:10px;\">"); $sOldRelation = $sRelation; if ($sRelation == 'impacts' && $sDirection == 'up') { $sOldRelation = 'depends on'; } $oP->add("<h1>" . MetaModel::GetRelationDescription($sOldRelation) . ' ' . $oObj->GetName() . "</h1>\n"); $iBlock = 1; // Zero is not a valid blockid foreach ($aResults as $sListClass => $aObjects) { $oSet = CMDBObjectSet::FromArray($sListClass, $aObjects); $oP->add("<div class=\"page_header\">\n"); $oP->add("<h2>" . MetaModel::GetClassIcon($sListClass) . " <span class=\"hilite\">" . Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', count($aObjects), Metamodel::GetName($sListClass)) . "</h2>\n"); $oP->add("</div>\n"); $oBlock = DisplayBlock::FromObjectSet($oSet, 'list'); $oBlock->Display($oP, $iBlock++, array('table_id' => get_class($oObj) . '_' . $sRelation . '_' . $sDirection . '_' . $sListClass)); $oP->P(' '); // Some space ? } $oP->add("</div>"); }