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


PHP MetaModel::EnumInitialStates方法代码示例

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


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

示例1: DisplayModifyForm

    public function DisplayModifyForm(WebPage $oPage, $aExtraParams = array())
    {
        self::$iGlobalFormId++;
        $this->aFieldsMap = array();
        $sPrefix = '';
        if (isset($aExtraParams['formPrefix'])) {
            $sPrefix = $aExtraParams['formPrefix'];
        }
        $aFieldsComments = isset($aExtraParams['fieldsComments']) ? $aExtraParams['fieldsComments'] : array();
        $this->m_iFormId = $sPrefix . self::$iGlobalFormId;
        $sClass = get_class($this);
        $oAppContext = new ApplicationContext();
        $sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
        $iKey = $this->GetKey();
        $aDetails = array();
        $aFieldsMap = array();
        if (!isset($aExtraParams['action'])) {
            $sFormAction = $_SERVER['SCRIPT_NAME'];
            // No parameter in the URL, the only parameter will be the ones passed through the form
        } else {
            $sFormAction = $aExtraParams['action'];
        }
        // Custom label for the apply button ?
        if (isset($aExtraParams['custom_button'])) {
            $sApplyButton = $aExtraParams['custom_button'];
        } else {
            if ($iKey > 0) {
                $sApplyButton = Dict::S('UI:Button:Apply');
            } else {
                $sApplyButton = Dict::S('UI:Button:Create');
            }
        }
        // Custom operation for the form ?
        if (isset($aExtraParams['custom_operation'])) {
            $sOperation = $aExtraParams['custom_operation'];
        } else {
            if ($iKey > 0) {
                $sOperation = 'apply_modify';
            } else {
                $sOperation = 'apply_new';
            }
        }
        if ($iKey > 0) {
            // The object already exists in the database, it's a modification
            $sButtons = "<input id=\"{$sPrefix}_id\" type=\"hidden\" name=\"id\" value=\"{$iKey}\">\n";
            $sButtons .= "<input type=\"hidden\" name=\"operation\" value=\"{$sOperation}\">\n";
            $sButtons .= "<button type=\"button\" class=\"action cancel\"><span>" . Dict::S('UI:Button:Cancel') . "</span></button>&nbsp;&nbsp;&nbsp;&nbsp;\n";
            $sButtons .= "<button type=\"submit\" class=\"action\"><span>{$sApplyButton}</span></button>\n";
        } else {
            // The object does not exist in the database it's a creation
            $sButtons = "<input type=\"hidden\" name=\"operation\" value=\"{$sOperation}\">\n";
            $sButtons .= "<button type=\"button\" class=\"action cancel\">" . Dict::S('UI:Button:Cancel') . "</button>&nbsp;&nbsp;&nbsp;&nbsp;\n";
            $sButtons .= "<button type=\"submit\" class=\"action\"><span>{$sApplyButton}</span></button>\n";
        }
        $aTransitions = $this->EnumTransitions();
        if (!isset($aExtraParams['custom_operation']) && count($aTransitions)) {
            // transitions are displayed only for the standard new/modify actions, not for modify_all or any other case...
            $oSetToCheckRights = DBObjectSet::FromObject($this);
            $aStimuli = Metamodel::EnumStimuli($sClass);
            foreach ($aTransitions as $sStimulusCode => $aTransitionDef) {
                $iActionAllowed = get_class($aStimuli[$sStimulusCode]) == 'StimulusUserAction' ? UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSetToCheckRights) : UR_ALLOWED_NO;
                switch ($iActionAllowed) {
                    case UR_ALLOWED_YES:
                        $sButtons .= "<button type=\"submit\" name=\"next_action\" value=\"{$sStimulusCode}\" class=\"action\"><span>" . $aStimuli[$sStimulusCode]->GetLabel() . "</span></button>\n";
                        break;
                    default:
                        // Do nothing
                }
            }
        }
        $sButtonsPosition = MetaModel::GetConfig()->Get('buttons_position');
        $iTransactionId = isset($aExtraParams['transaction_id']) ? $aExtraParams['transaction_id'] : utils::GetNewTransactionId();
        $oPage->SetTransactionId($iTransactionId);
        $oPage->add("<form action=\"{$sFormAction}\" id=\"form_{$this->m_iFormId}\" enctype=\"multipart/form-data\" method=\"post\" onSubmit=\"return OnSubmit('form_{$this->m_iFormId}');\">\n");
        $sStatesSelection = '';
        if (!isset($aExtraParams['custom_operation']) && $this->IsNew()) {
            $aInitialStates = MetaModel::EnumInitialStates($sClass);
            //$aInitialStates = array('new' => 'foo', 'closed' => 'bar');
            if (count($aInitialStates) > 1) {
                $sStatesSelection = Dict::Format('UI:Create_Class_InState', MetaModel::GetName($sClass)) . '<select name="obj_state" class="state_select_' . $this->m_iFormId . '">';
                foreach ($aInitialStates as $sStateCode => $sStateData) {
                    $sSelected = '';
                    if ($sStateCode == $this->GetState()) {
                        $sSelected = ' selected';
                    }
                    $sStatesSelection .= '<option value="' . $sStateCode . '"' . $sSelected . '>' . MetaModel::GetStateLabel($sClass, $sStateCode) . '</option>';
                }
                $sStatesSelection .= '</select>';
                $oPage->add_ready_script("\$('.state_select_{$this->m_iFormId}').change( function() { oWizardHelper{$sPrefix}.ReloadObjectCreationForm('form_{$this->m_iFormId}', \$(this).val()); } );");
            }
        }
        $sConfirmationMessage = addslashes(Dict::S('UI:NavigateAwayConfirmationMessage'));
        $oPage->add_ready_script(<<<EOF
\t\$(window).unload(function() { return OnUnload('{$iTransactionId}') } );
\twindow.onbeforeunload = function() {
\t\tif (!window.bInSubmit && !window.bInCancel)
\t\t{
\t\t\treturn '{$sConfirmationMessage}';\t
\t\t}
\t\t// return nothing ! safer for IE
//.........这里部分代码省略.........
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:101,代码来源:cmdbabstract.class.inc.php

示例2: DisplayModifyForm


//.........这里部分代码省略.........
            // The object already exists in the database, it's a modification
            $sButtons = "<input id=\"{$sPrefix}_id\" type=\"hidden\" name=\"id\" value=\"{$iKey}\">\n";
            $sButtons .= "<input type=\"hidden\" name=\"operation\" value=\"{$sOperation}\">\n";
            $sButtons .= "<button type=\"button\" class=\"action cancel\"><span>" . Dict::S('UI:Button:Cancel') . "</span></button>&nbsp;&nbsp;&nbsp;&nbsp;\n";
            $sButtons .= "<button type=\"submit\" class=\"action\"><span>{$sApplyButton}</span></button>\n";
        } else {
            // The object does not exist in the database it's a creation
            $sButtons = "<input type=\"hidden\" name=\"operation\" value=\"{$sOperation}\">\n";
            $sButtons .= "<button type=\"button\" class=\"action cancel\">" . Dict::S('UI:Button:Cancel') . "</button>&nbsp;&nbsp;&nbsp;&nbsp;\n";
            $sButtons .= "<button type=\"submit\" class=\"action\"><span>{$sApplyButton}</span></button>\n";
        }
        $aTransitions = $this->EnumTransitions();
        if (!isset($aExtraParams['custom_operation']) && count($aTransitions)) {
            // transitions are displayed only for the standard new/modify actions, not for modify_all or any other case...
            $oSetToCheckRights = DBObjectSet::FromObject($this);
            $aStimuli = Metamodel::EnumStimuli($sClass);
            foreach ($aTransitions as $sStimulusCode => $aTransitionDef) {
                $iActionAllowed = get_class($aStimuli[$sStimulusCode]) == 'StimulusUserAction' ? UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSetToCheckRights) : UR_ALLOWED_NO;
                switch ($iActionAllowed) {
                    case UR_ALLOWED_YES:
                        $sButtons .= "<button type=\"submit\" name=\"next_action\" value=\"{$sStimulusCode}\" class=\"action\"><span>" . $aStimuli[$sStimulusCode]->GetLabel() . "</span></button>\n";
                        break;
                    default:
                        // Do nothing
                }
            }
        }
        $sButtonsPosition = MetaModel::GetConfig()->Get('buttons_position');
        $iTransactionId = isset($aExtraParams['transaction_id']) ? $aExtraParams['transaction_id'] : utils::GetNewTransactionId();
        $oPage->SetTransactionId($iTransactionId);
        $oPage->add("<form action=\"{$sFormAction}\" id=\"form_{$this->m_iFormId}\" enctype=\"multipart/form-data\" method=\"post\" onSubmit=\"return OnSubmit('form_{$this->m_iFormId}');\">\n");
        $sStatesSelection = '';
        if (!isset($aExtraParams['custom_operation']) && $this->IsNew()) {
            $aInitialStates = MetaModel::EnumInitialStates($sClass);
            //$aInitialStates = array('new' => 'foo', 'closed' => 'bar');
            if (count($aInitialStates) > 1) {
                $sStatesSelection = Dict::Format('UI:Create_Class_InState', MetaModel::GetName($sClass)) . '<select name="obj_state" class="state_select_' . $this->m_iFormId . '">';
                foreach ($aInitialStates as $sStateCode => $sStateData) {
                    $sSelected = '';
                    if ($sStateCode == $this->GetState()) {
                        $sSelected = ' selected';
                    }
                    $sStatesSelection .= '<option value="' . $sStateCode . '"' . $sSelected . '>' . MetaModel::GetStateLabel($sClass, $sStateCode) . '</option>';
                }
                $sStatesSelection .= '</select>';
                $oPage->add_ready_script("\$('.state_select_{$this->m_iFormId}').change( function() { oWizardHelper{$sPrefix}.ReloadObjectCreationForm('form_{$this->m_iFormId}', \$(this).val()); } );");
            }
        }
        $sConfirmationMessage = addslashes(Dict::S('UI:NavigateAwayConfirmationMessage'));
        $sJSToken = json_encode($sOwnershipToken);
        $oPage->add_ready_script(<<<EOF
\t\$(window).unload(function() { return OnUnload('{$iTransactionId}', '{$sClass}', {$iKey}, {$sJSToken}) } );
\twindow.onbeforeunload = function() {
\t\tif (!window.bInSubmit && !window.bInCancel)
\t\t{
\t\t\treturn '{$sConfirmationMessage}';\t
\t\t}
\t\t// return nothing ! safer for IE
\t};
EOF
);
        if ($sButtonsPosition != 'bottom') {
            // top or both, display the buttons here
            $oPage->p($sStatesSelection);
            $oPage->add($sButtons);
        }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:67,代码来源:cmdbabstract.class.inc.php

示例3: GetInitialStateAttributeFlags

 /**
  * Combines the flags from the all states that compose the initial_state_path
  */
 public static function GetInitialStateAttributeFlags($sClass, $sState, $sAttCode)
 {
     $iFlags = self::GetAttributeFlags($sClass, $sState, $sAttCode);
     // Be default set the same flags as the 'target' state
     $sStateAttCode = self::GetStateAttributeCode($sClass);
     if (!empty($sStateAttCode)) {
         $aStates = MetaModel::EnumInitialStates($sClass);
         if (array_key_exists($sState, $aStates)) {
             $bReadOnly = ($iFlags & OPT_ATT_READONLY) == OPT_ATT_READONLY;
             $bHidden = ($iFlags & OPT_ATT_HIDDEN) == OPT_ATT_HIDDEN;
             foreach ($aStates[$sState] as $sPrevState) {
                 $iPrevFlags = self::GetAttributeFlags($sClass, $sPrevState, $sAttCode);
                 if (($iPrevFlags & OPT_ATT_HIDDEN) != OPT_ATT_HIDDEN) {
                     $bReadOnly = $bReadOnly && ($iPrevFlags & OPT_ATT_READONLY) == OPT_ATT_READONLY;
                     // if it is/was not readonly => then it's not
                 }
                 $bHidden = $bHidden && ($iPrevFlags & OPT_ATT_HIDDEN) == OPT_ATT_HIDDEN;
                 // if it is/was not hidden => then it's not
             }
             if ($bReadOnly) {
                 $iFlags = $iFlags | OPT_ATT_READONLY;
             } else {
                 $iFlags = $iFlags & ~OPT_ATT_READONLY;
             }
             if ($bHidden) {
                 $iFlags = $iFlags | OPT_ATT_HIDDEN;
             } else {
                 $iFlags = $iFlags & ~OPT_ATT_HIDDEN;
             }
         }
     }
     return $iFlags;
 }
开发者ID:henryavila,项目名称:itop,代码行数:36,代码来源:metamodel.class.php


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