public static function GetCreationForm($sOQL = null, $sTableSettings = null) { $oForm = new DesignerForm(); // Find a unique default name // -> The class of the query + an index if necessary if ($sOQL == null) { $sDefault = ''; } else { $oBMSearch = new DBObjectSearch('Shortcut'); $oBMSearch->AddCondition('user_id', UserRights::GetUserId(), '='); $oBMSet = new DBObjectSet($oBMSearch); $aNames = $oBMSet->GetColumnAsArray('name'); $oSearch = DBObjectSearch::FromOQL($sOQL); $sDefault = utils::MakeUniqueName($oSearch->GetClass(), $aNames); } $oField = new DesignerTextField('name', Dict::S('Class:Shortcut/Attribute:name'), $sDefault); $oField->SetMandatory(true); $oForm->AddField($oField); /* $oField = new DesignerComboField('auto_reload', Dict::S('Class:ShortcutOQL/Attribute:auto_reload'), 'none'); $oAttDef = MetaModel::GetAttributeDef(__class__, 'auto_reload'); $oField->SetAllowedValues($oAttDef->GetAllowedValues()); $oField->SetMandatory(true); $oForm->AddField($oField); */ $oField = new DesignerBooleanField('auto_reload', Dict::S('Class:ShortcutOQL/Attribute:auto_reload'), false); $oForm->AddField($oField); $oField = new DesignerTextField('auto_reload_sec', Dict::S('Class:ShortcutOQL/Attribute:auto_reload_sec'), MetaModel::GetConfig()->GetStandardReloadInterval()); $oField->SetValidationPattern('^$|^0*([5-9]|[1-9][0-9]+)$'); // Can be empty, or a number > 4 $oField->SetMandatory(false); $oForm->AddField($oField); $oField = new DesignerHiddenField('oql', '', $sOQL); $oForm->AddField($oField); $oField = new DesignerHiddenField('table_settings', '', $sTableSettings); $oForm->AddField($oField); return $oForm; }
public function RenderProperties($oPage) { // menu to pick a layout and edit other properties of the dashboard $oPage->add('<div class="ui-widget-content ui-corner-all"><div class="ui-widget-header ui-corner-all" style="text-align:center; padding: 2px;">' . Dict::S('UI:DashboardEdit:Properties') . '</div>'); $sUrl = utils::GetAbsoluteUrlAppRoot(); $oPage->add('<div style="text-align:center">' . Dict::S('UI:DashboardEdit:Layout') . '</div>'); $oPage->add('<div id="select_layout" style="text-align:center">'); foreach (get_declared_classes() as $sLayoutClass) { if (is_subclass_of($sLayoutClass, 'DashboardLayout')) { $oReflection = new ReflectionClass($sLayoutClass); if (!$oReflection->isAbstract()) { $aCallSpec = array($sLayoutClass, 'GetInfo'); $aInfo = call_user_func($aCallSpec); $sChecked = $this->sLayoutClass == $sLayoutClass ? 'checked' : ''; $oPage->add('<input type="radio" name="layout_class" ' . $sChecked . ' value="' . $sLayoutClass . '" id="layout_' . $sLayoutClass . '"><label for="layout_' . $sLayoutClass . '"><img src="' . $sUrl . $aInfo['icon'] . '" /></label>'); // title="" on either the img or the label does nothing ! } } } $oPage->add('</div>'); $oForm = new DesignerForm(); $oField = new DesignerHiddenField('dashboard_id', '', $this->sId); $oForm->AddField($oField); $oField = new DesignerLongTextField('dashboard_title', Dict::S('UI:DashboardEdit:DashboardTitle'), $this->sTitle); $oForm->AddField($oField); $oField = new DesignerBooleanField('auto_reload', Dict::S('UI:DashboardEdit:AutoReload'), $this->bAutoReload); $oForm->AddField($oField); $oField = new DesignerTextField('auto_reload_sec', Dict::S('UI:DashboardEdit:AutoReloadSec'), $this->iAutoReloadSec); $oField->SetValidationPattern('^$|^0*([5-9]|[1-9][0-9]+)$'); // Can be empty, or a number > 4 $oForm->AddField($oField); $this->SetFormParams($oForm); $oForm->RenderAsPropertySheet($oPage, false, '.itop-dashboard'); $oPage->add('</div>'); $sRateTitle = addslashes(Dict::S('UI:DashboardEdit:AutoReloadSec+')); $oPage->add_ready_script(<<<EOF \t// Note: the title gets deleted by the validation mechanism \t\$("#attr_auto_reload_sec").tooltip({items: 'input', content: '{$sRateTitle}'}); \t\$("#attr_auto_reload_sec").prop('disabled', !\$('#attr_auto_reload').is(':checked')); \t \t\$('#attr_auto_reload').change( function(ev) { \t\t\$("#attr_auto_reload_sec").prop('disabled', !\$(this).is(':checked')); \t} ); \t\$('#select_layout').buttonset(); \t\$('#select_dashlet').droppable({ \t\taccept: '.dashlet', \t\tdrop: function(event, ui) { \t\t\t\$( this ).find( ".placeholder" ).remove(); \t\t\tvar oDashlet = ui.draggable.data('itopDashlet'); \t\t\toDashlet._remove_dashlet(); \t\t}, \t}); \t\$('#event_bus').bind('dashlet-selected', function(event, data){ \t\tvar sDashletId = data.dashlet_id; \t\tvar sPropId = 'dashlet_properties_'+sDashletId; \t\t\$('.dashlet_properties').each(function() { \t\t\tvar sId = \$(this).attr('id'); \t\t\tvar bShow = (sId == sPropId); \t\t\tif (bShow) \t\t\t{ \t\t\t\t\$(this).show(); \t\t\t} \t\t\telse \t\t\t{ \t\t\t\t\$(this).hide(); \t\t\t} \t\t}); \t}); EOF ); }