当前位置: 首页>>代码示例>>PHP>>正文


PHP MetaModel::GetAllowedValues_att方法代码示例

本文整理汇总了PHP中MetaModel::GetAllowedValues_att方法的典型用法代码示例。如果您正苦于以下问题:PHP MetaModel::GetAllowedValues_att方法的具体用法?PHP MetaModel::GetAllowedValues_att怎么用?PHP MetaModel::GetAllowedValues_att使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MetaModel的用法示例。


在下文中一共展示了MetaModel::GetAllowedValues_att方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DisplayStimulusForm

    public function DisplayStimulusForm(WebPage $oPage, $sStimulus)
    {
        $sClass = get_class($this);
        $iKey = $this->GetKey();
        $aTransitions = $this->EnumTransitions();
        $aStimuli = MetaModel::EnumStimuli($sClass);
        if (!isset($aTransitions[$sStimulus])) {
            // Invalid stimulus
            throw new ApplicationException(Dict::Format('UI:Error:Invalid_Stimulus_On_Object_In_State', $sStimulus, $this->GetName(), $this->GetStateLabel()));
        }
        // Check for concurrent access lock
        $LockEnabled = MetaModel::GetConfig()->Get('concurrent_lock_enabled');
        $sOwnershipToken = null;
        if ($LockEnabled) {
            $sOwnershipToken = utils::ReadPostedParam('ownership_token', null, false, 'raw_data');
            $aLockInfo = iTopOwnershipLock::AcquireLock($sClass, $iKey);
            if ($aLockInfo['success']) {
                $sOwnershipToken = $aLockInfo['token'];
                $sOwnershipDate = $aLockInfo['acquired'];
            } else {
                $oOwner = $aLockInfo['lock']->GetOwner();
                // If the object is locked by the current user, it's worth trying again, since
                // the lock may be released by 'onunload' which is called AFTER loading the current page.
                //$bTryAgain = $oOwner->GetKey() == UserRights::GetUserId();
                self::ReloadAndDisplay($oPage, $this, array('operation' => 'stimulus', 'stimulus' => $sStimulus));
                return;
            }
        }
        $sActionLabel = $aStimuli[$sStimulus]->GetLabel();
        $sActionDetails = $aStimuli[$sStimulus]->GetDescription();
        $aTransition = $aTransitions[$sStimulus];
        $sTargetState = $aTransition['target_state'];
        $aTargetStates = MetaModel::EnumStates($sClass);
        $oPage->add("<div class=\"page_header\">\n");
        $oPage->add("<h1>{$sActionLabel} - <span class=\"hilite\">{$this->GetName()}</span></h1>\n");
        $oPage->set_title($sActionLabel);
        $oPage->add("</div>\n");
        $aTargetState = $aTargetStates[$sTargetState];
        $aExpectedAttributes = $aTargetState['attribute_list'];
        $oPage->add("<h1>{$sActionDetails}</h1>\n");
        $sButtonsPosition = MetaModel::GetConfig()->Get('buttons_position');
        if ($sButtonsPosition == 'bottom') {
            // bottom: Displays the ticket details BEFORE the actions
            $oPage->add('<div class="ui-widget-content">');
            $this->DisplayBareProperties($oPage);
            $oPage->add('</div>');
        }
        $oPage->add("<div class=\"wizContainer\">\n");
        $oPage->add("<form id=\"apply_stimulus\" method=\"post\" onSubmit=\"return OnSubmit('apply_stimulus');\">\n");
        $aDetails = array();
        $iFieldIndex = 0;
        $aFieldsMap = array();
        // The list of candidate fields is made of the ordered list of "details" attributes + other attributes
        $aAttributes = array();
        foreach ($this->FlattenZList(MetaModel::GetZListItems($sClass, 'details')) as $sAttCode) {
            $aAttributes[$sAttCode] = true;
        }
        foreach (MetaModel::GetAttributesList($sClass) as $sAttCode) {
            if (!array_key_exists($sAttCode, $aAttributes)) {
                $aAttributes[$sAttCode] = true;
            }
        }
        // Order the fields based on their dependencies, set the fields for which there is only one possible value
        // and perform this in the order of dependencies to avoid dead-ends
        $aDeps = array();
        foreach ($aAttributes as $sAttCode => $trash) {
            $aDeps[$sAttCode] = MetaModel::GetPrerequisiteAttributes($sClass, $sAttCode);
        }
        $aList = $this->OrderDependentFields($aDeps);
        foreach ($aList as $sAttCode) {
            // Consider only the "expected" fields for the target state
            if (array_key_exists($sAttCode, $aExpectedAttributes)) {
                $iExpectCode = $aExpectedAttributes[$sAttCode];
                // Prompt for an attribute if
                // - the attribute must be changed or must be displayed to the user for confirmation
                // - or the field is mandatory and currently empty
                if ($iExpectCode & (OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT) || $iExpectCode & OPT_ATT_MANDATORY && $this->Get($sAttCode) == '') {
                    $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
                    $aArgs = array('this' => $this);
                    // If the field is mandatory, set it to the only possible value
                    if (!$oAttDef->IsNullAllowed() || $iExpectCode & OPT_ATT_MANDATORY) {
                        if ($oAttDef->IsExternalKey()) {
                            $oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs);
                            if ($oAllowedValues->Count() == 1) {
                                $oRemoteObj = $oAllowedValues->Fetch();
                                $this->Set($sAttCode, $oRemoteObj->GetKey());
                            }
                        } else {
                            $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs);
                            if (count($aAllowedValues) == 1) {
                                $aValues = array_keys($aAllowedValues);
                                $this->Set($sAttCode, $aValues[0]);
                            }
                        }
                    }
                    $sHTMLValue = cmdbAbstractObject::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $this->Get($sAttCode), $this->GetEditValue($sAttCode), 'att_' . $iFieldIndex, '', $iExpectCode, $aArgs);
                    $aDetails[] = array('label' => '<span>' . $oAttDef->GetLabel() . '</span>', 'value' => "<span id=\"field_att_{$iFieldIndex}\">{$sHTMLValue}</span>");
                    $aFieldsMap[$sAttCode] = 'att_' . $iFieldIndex;
                    $iFieldIndex++;
                }
//.........这里部分代码省略.........
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:101,代码来源:cmdbabstract.class.inc.php

示例2: DisplayStimulusForm

    public function DisplayStimulusForm(WebPage $oPage, $sStimulus)
    {
        $sClass = get_class($this);
        $aTransitions = $this->EnumTransitions();
        $aStimuli = MetaModel::EnumStimuli($sClass);
        if (!isset($aTransitions[$sStimulus])) {
            // Invalid stimulus
            throw new ApplicationException(Dict::Format('UI:Error:Invalid_Stimulus_On_Object_In_State', $sStimulus, $this->GetName(), $this->GetStateLabel()));
        }
        $sActionLabel = $aStimuli[$sStimulus]->GetLabel();
        $sActionDetails = $aStimuli[$sStimulus]->GetDescription();
        $aTransition = $aTransitions[$sStimulus];
        $sTargetState = $aTransition['target_state'];
        $aTargetStates = MetaModel::EnumStates($sClass);
        $oPage->add("<div class=\"page_header\">\n");
        $oPage->add("<h1>{$sActionLabel} - <span class=\"hilite\">{$this->GetName()}</span></h1>\n");
        $oPage->set_title($sActionLabel);
        $oPage->add("</div>\n");
        $aTargetState = $aTargetStates[$sTargetState];
        $aExpectedAttributes = $aTargetState['attribute_list'];
        $oPage->add("<h1>{$sActionDetails}</h1>\n");
        $sButtonsPosition = MetaModel::GetConfig()->Get('buttons_position');
        if ($sButtonsPosition == 'bottom') {
            // bottom: Displays the ticket details BEFORE the actions
            $oPage->add('<div class="ui-widget-content">');
            $this->DisplayBareProperties($oPage);
            $oPage->add('</div>');
        }
        $oPage->add("<div class=\"wizContainer\">\n");
        $oPage->add("<form id=\"apply_stimulus\" method=\"post\" onSubmit=\"return OnSubmit('apply_stimulus');\">\n");
        $aDetails = array();
        $iFieldIndex = 0;
        $aFieldsMap = array();
        $aDetailsList = $this->FlattenZList(MetaModel::GetZListItems($sClass, 'details'));
        // Order the fields based on their dependencies, set the fields for which there is only one possible value
        // and perform this in the order of dependencies to avoid dead-ends
        $aDeps = array();
        foreach ($aDetailsList as $sAttCode) {
            $aDeps[$sAttCode] = MetaModel::GetPrequisiteAttributes($sClass, $sAttCode);
        }
        $aList = $this->OrderDependentFields($aDeps);
        foreach ($aList as $sAttCode) {
            // Consider only the "expected" fields for the target state
            if (array_key_exists($sAttCode, $aExpectedAttributes)) {
                $iExpectCode = $aExpectedAttributes[$sAttCode];
                // Prompt for an attribute if
                // - the attribute must be changed or must be displayed to the user for confirmation
                // - or the field is mandatory and currently empty
                if ($iExpectCode & (OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT) || $iExpectCode & OPT_ATT_MANDATORY && $this->Get($sAttCode) == '') {
                    $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
                    $aArgs = array('this' => $this);
                    // If the field is mandatory, set it to the only possible value
                    if (!$oAttDef->IsNullAllowed() || $iExpectCode & OPT_ATT_MANDATORY) {
                        if ($oAttDef->IsExternalKey()) {
                            $oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs);
                            if ($oAllowedValues->Count() == 1) {
                                $oRemoteObj = $oAllowedValues->Fetch();
                                $this->Set($sAttCode, $oRemoteObj->GetKey());
                            }
                        } else {
                            $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs);
                            if (count($aAllowedValues) == 1) {
                                $aValues = array_keys($aAllowedValues);
                                $this->Set($sAttCode, $aValues[0]);
                            }
                        }
                    }
                    $sHTMLValue = cmdbAbstractObject::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $this->Get($sAttCode), $this->GetEditValue($sAttCode), 'att_' . $iFieldIndex, '', $iExpectCode, $aArgs);
                    $aDetails[] = array('label' => '<span>' . $oAttDef->GetLabel() . '</span>', 'value' => "<span id=\"field_att_{$iFieldIndex}\">{$sHTMLValue}</span>");
                    $aFieldsMap[$sAttCode] = 'att_' . $iFieldIndex;
                    $iFieldIndex++;
                }
            }
        }
        $oPage->add('<table><tr><td>');
        $oPage->details($aDetails);
        $oPage->add('</td></tr></table>');
        $oPage->add("<input type=\"hidden\" name=\"id\" value=\"" . $this->GetKey() . "\" id=\"id\">\n");
        $aFieldsMap['id'] = 'id';
        $oPage->add("<input type=\"hidden\" name=\"class\" value=\"{$sClass}\">\n");
        $oPage->add("<input type=\"hidden\" name=\"operation\" value=\"apply_stimulus\">\n");
        $oPage->add("<input type=\"hidden\" name=\"stimulus\" value=\"{$sStimulus}\">\n");
        $oPage->add("<input type=\"hidden\" name=\"transaction_id\" value=\"" . utils::GetNewTransactionId() . "\">\n");
        $oAppContext = new ApplicationContext();
        $oPage->add($oAppContext->GetForForm());
        $oPage->add("<button type=\"button\" class=\"action\" onClick=\"BackToDetails('{$sClass}', " . $this->GetKey() . ")\"><span>" . Dict::S('UI:Button:Cancel') . "</span></button>&nbsp;&nbsp;&nbsp;&nbsp;\n");
        $oPage->add("<button type=\"submit\" class=\"action\"><span>{$sActionLabel}</span></button>\n");
        $oPage->add("</form>\n");
        $oPage->add("</div>\n");
        if ($sButtonsPosition != 'top') {
            // bottom or both: Displays the ticket details AFTER the actions
            $oPage->add('<div class="ui-widget-content">');
            $this->DisplayBareProperties($oPage);
            $oPage->add('</div>');
        }
        $iFieldsCount = count($aFieldsMap);
        $sJsonFieldsMap = json_encode($aFieldsMap);
        $oPage->add_script(<<<EOF
\t\t// Initializes the object once at the beginning of the page...
\t\tvar oWizardHelper = new WizardHelper('{$sClass}', '', '{$sTargetState}');
//.........这里部分代码省略.........
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:101,代码来源:cmdbabstract.class.inc.php

示例3: GetAllowedValues_att

 public function GetAllowedValues_att($sClass, $sAttCode)
 {
     return MetaModel::GetAllowedValues_att($sClass, $sAttCode);
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:4,代码来源:modelreflection.class.inc.php

示例4: DisplayClassDetails

/**
 * Display the details of a given class of objects
 */
function DisplayClassDetails($oPage, $sClass, $sContext)
{
    $oPage->add("<h2>" . MetaModel::GetName($sClass) . " ({$sClass}) - " . MetaModel::GetClassDescription($sClass) . "</h2>\n");
    if (MetaModel::IsAbstract($sClass)) {
        $oPage->p(Dict::S('UI:Schema:AbstractClass'));
    } else {
        $oPage->p(Dict::S('UI:Schema:NonAbstractClass'));
    }
    //	$oPage->p("<h3>".Dict::S('UI:Schema:ClassHierarchyTitle')."</h3>");
    $aParentClasses = array();
    foreach (MetaModel::EnumParentClasses($sClass) as $sParentClass) {
        $aParentClasses[] = MakeClassHLink($sParentClass, $sContext);
    }
    if (count($aParentClasses) > 0) {
        $sParents = implode(' &gt;&gt; ', $aParentClasses) . " &gt;&gt; <b>{$sClass}</b>";
    } else {
        $sParents = '';
    }
    $oPage->p("[<a href=\"schema.php?operation=list{$sContext}\">" . Dict::S('UI:Schema:AllClasses') . "</a>] {$sParents}");
    if (MetaModel::HasChildrenClasses($sClass)) {
        $oPage->add("<ul id=\"ClassHierarchy\">");
        $oPage->add("<li class=\"closed\">" . $sClass . "\n");
        DisplaySubclasses($oPage, $sClass, $sContext);
        $oPage->add("</li>\n");
        $oPage->add("</ul>\n");
        $oPage->add_ready_script('$("#ClassHierarchy").treeview();');
    }
    $oPage->p('');
    $oPage->AddTabContainer('details');
    $oPage->SetCurrentTabContainer('details');
    // List the attributes of the object
    $aForwardChangeTracking = MetaModel::GetTrackForwardExternalKeys($sClass);
    $aDetails = array();
    foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
        if ($oAttDef->IsExternalKey()) {
            $sValue = Dict::Format('UI:Schema:ExternalKey_To', MakeClassHLink($oAttDef->GetTargetClass(), $sContext));
            if (array_key_exists($sAttCode, $aForwardChangeTracking)) {
                $oLinkSet = $aForwardChangeTracking[$sAttCode];
                $sRemoteClass = $oLinkSet->GetHostClass();
                $sValue = $sValue . "<span title=\"Forward changes to {$sRemoteClass}\">*</span>";
            }
        } elseif ($oAttDef->IsLinkSet()) {
            $sValue = MakeClassHLink($oAttDef->GetLinkedClass(), $sContext);
        } else {
            $sValue = $oAttDef->GetDescription();
        }
        $sType = $oAttDef->GetType() . ' (' . $oAttDef->GetTypeDesc() . ')';
        $sOrigin = MetaModel::GetAttributeOrigin($sClass, $sAttCode);
        $sAllowedValues = "";
        $sMoreInfo = "";
        $aCols = array();
        foreach ($oAttDef->GetSQLColumns() as $sCol => $sFieldDesc) {
            $aCols[] = "{$sCol}: {$sFieldDesc}";
        }
        if (count($aCols) > 0) {
            $sCols = implode(', ', $aCols);
            $aMoreInfo = array();
            $aMoreInfo[] = Dict::Format('UI:Schema:Columns_Description', $sCols);
            $aMoreInfo[] = Dict::Format('UI:Schema:Default_Description', $oAttDef->GetDefaultValue());
            $aMoreInfo[] = $oAttDef->IsNullAllowed() ? Dict::S('UI:Schema:NullAllowed') : Dict::S('UI:Schema:NullNotAllowed');
            $sMoreInfo .= implode(', ', $aMoreInfo);
        }
        if ($oAttDef instanceof AttributeEnum) {
            // Display localized values for the enum (which depend on the localization provided by the class)
            $aLocalizedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array());
            $aDescription = array();
            foreach ($aLocalizedValues as $val => $sDisplay) {
                $aDescription[] = htmlentities("{$val} => ", ENT_QUOTES, 'UTF-8') . $sDisplay;
            }
            $sAllowedValues = implode(', ', $aDescription);
        } else {
            $sAllowedValues = '';
        }
        $aDetails[] = array('code' => $oAttDef->GetCode(), 'type' => $sType, 'origin' => $sOrigin, 'label' => $oAttDef->GetLabel(), 'description' => $sValue, 'values' => $sAllowedValues, 'moreinfo' => $sMoreInfo);
    }
    $oPage->SetCurrentTab(Dict::S('UI:Schema:Attributes'));
    $aConfig = array('code' => array('label' => Dict::S('UI:Schema:AttributeCode'), 'description' => Dict::S('UI:Schema:AttributeCode+')), 'label' => array('label' => Dict::S('UI:Schema:Label'), 'description' => Dict::S('UI:Schema:Label+')), 'type' => array('label' => Dict::S('UI:Schema:Type'), 'description' => Dict::S('UI:Schema:Type+')), 'origin' => array('label' => Dict::S('UI:Schema:Origin'), 'description' => Dict::S('UI:Schema:Origin+')), 'description' => array('label' => Dict::S('UI:Schema:Description'), 'description' => Dict::S('UI:Schema:Description+')), 'values' => array('label' => Dict::S('UI:Schema:AllowedValues'), 'description' => Dict::S('UI:Schema:AllowedValues+')), 'moreinfo' => array('label' => Dict::S('UI:Schema:MoreInfo'), 'description' => Dict::S('UI:Schema:MoreInfo+')));
    $oPage->table($aConfig, $aDetails);
    // List the search criteria for this object
    $aDetails = array();
    foreach (MetaModel::GetClassFilterDefs($sClass) as $sFilterCode => $oFilterDef) {
        $aOpDescs = array();
        foreach ($oFilterDef->GetOperators() as $sOpCode => $sOpDescription) {
            $sIsTheLooser = $sOpCode == $oFilterDef->GetLooseOperator() ? " (loose search)" : "";
            $aOpDescs[] = "{$sOpCode} ({$sOpDescription}){$sIsTheLooser}";
        }
        $aDetails[] = array('code' => $sFilterCode, 'description' => $oFilterDef->GetLabel(), 'operators' => implode(" / ", $aOpDescs));
    }
    $oPage->SetCurrentTab(Dict::S('UI:Schema:SearchCriteria'));
    $aConfig = array('code' => array('label' => Dict::S('UI:Schema:FilterCode'), 'description' => Dict::S('UI:Schema:FilterCode+')), 'description' => array('label' => Dict::S('UI:Schema:FilterDescription'), 'description' => Dict::S('UI:Schema:FilterDescription+')), 'operators' => array('label' => Dict::S('UI:Schema:AvailOperators'), 'description' => Dict::S('UI:Schema:AvailOperators+')));
    $oPage->table($aConfig, $aDetails);
    $oPage->SetCurrentTab(Dict::S('UI:Schema:ChildClasses'));
    DisplaySubclasses($oPage, $sClass, $sContext);
    $oPage->SetCurrentTab(Dict::S('UI:Schema:ReferencingClasses'));
    DisplayReferencingClasses($oPage, $sClass, $sContext);
    $oPage->SetCurrentTab(Dict::S('UI:Schema:RelatedClasses'));
    DisplayRelatedClasses($oPage, $sClass, $sContext);
//.........这里部分代码省略.........
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:101,代码来源:schema.php


注:本文中的MetaModel::GetAllowedValues_att方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。