public function GetPropertiesFields(DesignerForm $oForm) { $oField = new DesignerTextField('title', Dict::S('UI:DashletHeaderDynamic:Prop-Title'), $this->aProperties['title']); $oForm->AddField($oField); $oField = $this->oModelReflection->GetIconSelectionField('icon', Dict::S('UI:DashletHeaderDynamic:Prop-Icon'), $this->aProperties['icon']); $oForm->AddField($oField); $oField = new DesignerTextField('subtitle', Dict::S('UI:DashletHeaderDynamic:Prop-Subtitle'), $this->aProperties['subtitle']); $oForm->AddField($oField); $oField = new DesignerTextField('query', Dict::S('UI:DashletHeaderDynamic:Prop-Query'), $this->aProperties['query']); $oField->SetMandatory(); $oForm->AddField($oField); try { // Group by field: build the list of possible values (attribute codes + ...) $oQuery = $this->oModelReflection->GetQuery($this->aProperties['query']); $sClass = $oQuery->GetClass(); $aGroupBy = array(); foreach ($this->oModelReflection->ListAttributes($sClass, 'AttributeEnum,AttributeFinalClass') as $sAttCode => $sAttType) { if (is_subclass_of($sAttType, 'AttributeFinalClass') || $sAttType == 'AttributeFinalClass') { if (!$this->oModelReflection->HasChildrenClasses($sClass)) { continue; } } $sLabel = $this->oModelReflection->GetLabel($sClass, $sAttCode); $aGroupBy[$sAttCode] = $sLabel; } $oField = new DesignerComboField('group_by', Dict::S('UI:DashletHeaderDynamic:Prop-GroupBy'), $this->aProperties['group_by']); $oField->SetMandatory(); $oField->SetAllowedValues($aGroupBy); } catch (Exception $e) { $oField = new DesignerTextField('group_by', Dict::S('UI:DashletHeaderDynamic:Prop-GroupBy'), $this->aProperties['group_by']); $oField->SetReadOnly(); } $oForm->AddField($oField); $oField = new DesignerComboField('values', Dict::S('UI:DashletHeaderDynamic:Prop-Values'), $this->aProperties['values']); $oField->MultipleSelection(true); if (isset($sClass) && $this->oModelReflection->IsValidAttCode($sClass, $this->aProperties['group_by'])) { $aValues = $this->oModelReflection->GetAllowedValues_att($sClass, $this->aProperties['group_by']); $oField->SetAllowedValues($aValues); } else { $oField->SetReadOnly(); } $oForm->AddField($oField); }
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; }