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


PHP MetaModel::ListAttributeDefs方法代码示例

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


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

示例1: MakeResultValue

 /**
  * Helper to make an output value for a given attribute
  * 	 
  * @param DBObject $oObject The object being reported
  * @param string $sAttCode The attribute code (must be valid)
  * @param boolean $bExtendedOutput Output all of the link set attributes ?
  * @return string A scalar representation of the value
  */
 protected function MakeResultValue(DBObject $oObject, $sAttCode, $bExtendedOutput = false)
 {
     if ($sAttCode == 'id') {
         $value = $oObject->GetKey();
     } else {
         $sClass = get_class($oObject);
         $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
         if ($oAttDef instanceof AttributeLinkedSet) {
             // Iterate on the set and build an array of array of attcode=>value
             $oSet = $oObject->Get($sAttCode);
             $value = array();
             while ($oLnk = $oSet->Fetch()) {
                 $sLnkRefClass = $bExtendedOutput ? get_class($oLnk) : $oAttDef->GetLinkedClass();
                 $aLnkValues = array();
                 foreach (MetaModel::ListAttributeDefs($sLnkRefClass) as $sLnkAttCode => $oLnkAttDef) {
                     // Skip attributes pointing to the current object (redundant data)
                     if ($sLnkAttCode == $oAttDef->GetExtKeyToMe()) {
                         continue;
                     }
                     // Skip any attribute of the link that points to the current object
                     $oLnkAttDef = MetaModel::GetAttributeDef($sLnkRefClass, $sLnkAttCode);
                     if (method_exists($oLnkAttDef, 'GetKeyAttCode')) {
                         if ($oLnkAttDef->GetKeyAttCode() == $oAttDef->GetExtKeyToMe()) {
                             continue;
                         }
                     }
                     $aLnkValues[$sLnkAttCode] = $this->MakeResultValue($oLnk, $sLnkAttCode, $bExtendedOutput);
                 }
                 $value[] = $aLnkValues;
             }
         } else {
             $value = $oAttDef->GetForJSON($oObject->Get($sAttCode));
         }
     }
     return $value;
 }
开发者ID:henryavila,项目名称:itop,代码行数:44,代码来源:restservices.class.inc.php

示例2: Fingerprint

 /**
  * Computes a text-like fingerprint identifying the content of the object
  * but excluding the specified columns
  * @param $aExcludedColumns array The list of columns to exclude
  * @return string
  */
 public function Fingerprint($aExcludedColumns = array())
 {
     $sFingerprint = '';
     foreach (MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef) {
         if (!in_array($sAttCode, $aExcludedColumns)) {
             if ($oAttDef->IsPartOfFingerprint()) {
                 $sFingerprint .= chr(0) . $oAttDef->Fingerprint($this->Get($sAttCode));
             }
         }
     }
     return $sFingerprint;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:18,代码来源:dbobject.class.php

示例3: FindVisibleRedundancySettings

 /**
  * Find redundancy settings that can be viewed and modified in a tab
  * Settings are distributed to the corresponding link set attribute so as to be shown in the relevant tab	 
  */
 protected function FindVisibleRedundancySettings()
 {
     $aRet = array();
     foreach (MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef) {
         if ($oAttDef instanceof AttributeRedundancySettings) {
             if ($oAttDef->IsVisible()) {
                 $aQueryInfo = $oAttDef->GetRelationQueryData();
                 if (isset($aQueryInfo['sAttribute'])) {
                     $oUpperAttDef = MetaModel::GetAttributeDef($aQueryInfo['sFromClass'], $aQueryInfo['sAttribute']);
                     $oHostAttDef = $oUpperAttDef->GetMirrorLinkAttribute();
                     if ($oHostAttDef) {
                         $sHostAttCode = $oHostAttDef->GetCode();
                         $aRet[$sHostAttCode][] = $oAttDef;
                     }
                 }
             }
         }
     }
     return $aRet;
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:24,代码来源:cmdbabstract.class.inc.php

示例4: ListAttributes

 public function ListAttributes($sClass, $sScope = null)
 {
     $aScope = null;
     if ($sScope != null) {
         $aScope = array();
         foreach (explode(',', $sScope) as $sScopeClass) {
             $aScope[] = trim($sScopeClass);
         }
     }
     $aAttributes = array();
     foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
         $sAttributeClass = get_class($oAttDef);
         if ($aScope != null) {
             foreach ($aScope as $sScopeClass) {
                 if ($sAttributeClass == $sScopeClass || is_subclass_of($sAttributeClass, $sScopeClass)) {
                     $aAttributes[$sAttCode] = $sAttributeClass;
                     break;
                 }
             }
         } else {
             $aAttributes[$sAttCode] = $sAttributeClass;
         }
     }
     return $aAttributes;
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:25,代码来源:modelreflection.class.inc.php

示例5: ToDataArray

 /**
  * @param hash $aOrderBy Array of '[<classalias>.]attcode' => bAscending
  */
 public function ToDataArray($aColumns = array(), $aOrderBy = array(), $aArgs = array())
 {
     $sSQL = $this->MakeSelectQuery($aOrderBy, $aArgs);
     $resQuery = CMDBSource::Query($sSQL);
     if (!$resQuery) {
         return;
     }
     if (count($aColumns) == 0) {
         $aColumns = array_keys(MetaModel::ListAttributeDefs($this->GetClass()));
         // Add the standard id (as first column)
         array_unshift($aColumns, 'id');
     }
     $aQueryCols = CMDBSource::GetColumns($resQuery);
     $sClassAlias = $this->GetClassAlias();
     $aColMap = array();
     foreach ($aColumns as $sAttCode) {
         $sColName = $sClassAlias . $sAttCode;
         if (in_array($sColName, $aQueryCols)) {
             $aColMap[$sAttCode] = $sColName;
         }
     }
     $aRes = array();
     while ($aRow = CMDBSource::FetchArray($resQuery)) {
         $aMappedRow = array();
         foreach ($aColMap as $sAttCode => $sColName) {
             $aMappedRow[$sAttCode] = $aRow[$sColName];
         }
         $aRes[] = $aMappedRow;
     }
     CMDBSource::FreeResult($resQuery);
     return $aRes;
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:35,代码来源:dbsearch.class.php

示例6: ComputeWizardStructure

 /**
  * Compute the order of the fields & pages in the wizard
  * @param $oPage iTopWebPage The current page (used to display error messages) 
  * @param $sClass string Name of the class
  * @param $sStateCode string Code of the target state of the object
  * @return hash Two dimensional array: each element represents the list of fields for a given page   
  */
 protected function ComputeWizardStructure()
 {
     $aWizardSteps = array('mandatory' => array(), 'optional' => array());
     $aFieldsDone = array();
     // Store all the fields that are already covered by a previous step of the wizard
     $aStates = MetaModel::EnumStates($this->m_sClass);
     $sStateAttCode = MetaModel::GetStateAttributeCode($this->m_sClass);
     $aMandatoryAttributes = array();
     // Some attributes are always mandatory independently of the state machine (if any)
     foreach (MetaModel::GetAttributesList($this->m_sClass) as $sAttCode) {
         $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
         if (!$oAttDef->IsExternalField() && !$oAttDef->IsNullAllowed() && $oAttDef->IsWritable() && $sAttCode != $sStateAttCode) {
             $aMandatoryAttributes[$sAttCode] = OPT_ATT_MANDATORY;
         }
     }
     // Now check the attributes that are mandatory in the specified state
     if (!empty($this->m_sTargetState) && count($aStates[$this->m_sTargetState]['attribute_list']) > 0) {
         // Check all the fields that *must* be included in the wizard for this
         // particular target state
         $aFields = array();
         foreach ($aStates[$this->m_sTargetState]['attribute_list'] as $sAttCode => $iOptions) {
             if (isset($aMandatoryAttributes[$sAttCode]) && $aMandatoryAttributes[$sAttCode] & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT)) {
                 $aMandatoryAttributes[$sAttCode] |= $iOptions;
             } else {
                 $aMandatoryAttributes[$sAttCode] = $iOptions;
             }
         }
     }
     // Check all the fields that *must* be included in the wizard
     // i.e. all mandatory, must-change or must-prompt fields that are
     // not also read-only or hidden.
     // Some fields may be required (null not allowed) from the database
     // perspective, but hidden or read-only from the user interface perspective
     $aFields = array();
     foreach ($aMandatoryAttributes as $sAttCode => $iOptions) {
         if ($iOptions & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT) && !($iOptions & (OPT_ATT_READONLY | OPT_ATT_HIDDEN))) {
             $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
             $aPrerequisites = $oAttDef->GetPrerequisiteAttributes();
             $aFields[$sAttCode] = array();
             foreach ($aPrerequisites as $sCode) {
                 $aFields[$sAttCode][$sCode] = '';
             }
         }
     }
     // Now use the dependencies between the fields to order them
     // Start from the order of the 'details'
     $aList = MetaModel::FlattenZlist(MetaModel::GetZListItems($this->m_sClass, 'details'));
     $index = 0;
     $aOrder = array();
     foreach ($aFields as $sAttCode => $void) {
         $aOrder[$sAttCode] = 999;
         // At the end of the list...
     }
     foreach ($aList as $sAttCode) {
         if (array_key_exists($sAttCode, $aFields)) {
             $aOrder[$sAttCode] = $index;
         }
         $index++;
     }
     foreach ($aFields as $sAttCode => $aDependencies) {
         // All fields with no remaining dependencies can be entered at this
         // step of the wizard
         if (count($aDependencies) > 0) {
             $iMaxPos = 0;
             // Remove this field from the dependencies of the other fields
             foreach ($aDependencies as $sDependentAttCode => $void) {
                 // position the current field after the ones it depends on
                 $iMaxPos = max($iMaxPos, 1 + $aOrder[$sDependentAttCode]);
             }
         }
     }
     asort($aOrder);
     $aCurrentStep = array();
     foreach ($aOrder as $sAttCode => $rank) {
         $aCurrentStep[] = $sAttCode;
         $aFieldsDone[$sAttCode] = '';
     }
     $aWizardSteps['mandatory'][] = $aCurrentStep;
     // Now computes the steps to fill the optional fields
     $aFields = array();
     // reset
     foreach (MetaModel::ListAttributeDefs($this->m_sClass) as $sAttCode => $oAttDef) {
         $iOptions = isset($aStates[$this->m_sTargetState]['attribute_list'][$sAttCode]) ? $aStates[$this->m_sTargetState]['attribute_list'][$sAttCode] : 0;
         if ($sStateAttCode != $sAttCode && !$oAttDef->IsExternalField() && ($iOptions & (OPT_ATT_HIDDEN | OPT_ATT_READONLY)) == 0 && !isset($aFieldsDone[$sAttCode])) {
             // 'State', external fields, read-only and hidden fields
             // and fields that are already listed in the wizard
             // are removed from the 'optional' part of the wizard
             $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
             $aPrerequisites = $oAttDef->GetPrerequisiteAttributes();
             $aFields[$sAttCode] = array();
             foreach ($aPrerequisites as $sCode) {
                 if (!isset($aFieldsDone[$sCode])) {
                     // retain only the dependencies that were not covered
//.........这里部分代码省略.........
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:101,代码来源:uiwizard.class.inc.php

示例7: GetReconciliationFormElement

 public function GetReconciliationFormElement($sTargetClass, $sFieldName)
 {
     $sHtml = "<select name=\"{$sFieldName}\">\n";
     $sSelected = '' == $this->Get('reconciliation_attcode') ? ' selected' : '';
     $sHtml .= "<option value=\"\" {$sSelected}>" . Dict::S('Core:SynchroAttExtKey:ReconciliationById') . "</option>\n";
     foreach (MetaModel::ListAttributeDefs($sTargetClass) as $sAttCode => $oAttDef) {
         if ($oAttDef->IsScalar()) {
             $sSelected = $sAttCode == $this->Get('reconciliation_attcode') ? ' selected' : '';
             $sHtml .= "<option value=\"{$sAttCode}\" {$sSelected}>" . MetaModel::GetLabel($sTargetClass, $sAttCode) . "</option>\n";
         }
     }
     $sHtml .= "</select>\n";
     return $sHtml;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:14,代码来源:synchrodatasource.class.inc.php

示例8: GetObjectActionGrant

 protected function GetObjectActionGrant($oUser, $sClass, $iActionCode, $oObject = null)
 {
     if (is_null($oObject)) {
         $iObjectRef = -999;
     } else {
         $iObjectRef = $oObject->GetKey();
     }
     // load and cache permissions for the current user on the given object
     //
     $aTest = @$this->m_aObjectActionGrants[$oUser->GetKey()][$sClass][$iObjectRef][$iActionCode];
     if (is_array($aTest)) {
         return $aTest;
     }
     $sAction = self::$m_aActionCodes[$iActionCode];
     $iInstancePermission = UR_ALLOWED_NO;
     $aAttributes = array();
     foreach ($this->GetMatchingProfiles($oUser, $sClass, $oObject) as $iProfile) {
         $oGrantRecord = $this->GetClassActionGrant($iProfile, $sClass, $sAction);
         if (is_null($oGrantRecord)) {
             continue;
             // loop to the next profile
         } else {
             $iInstancePermission = UR_ALLOWED_YES;
             // update the list of attributes with those allowed for this profile
             //
             $oSearch = DBObjectSearch::FromOQL_AllData("SELECT URP_AttributeGrant WHERE actiongrantid = :actiongrantid");
             $oSet = new DBObjectSet($oSearch, array(), array('actiongrantid' => $oGrantRecord->GetKey()));
             $aProfileAttributes = $oSet->GetColumnAsArray('attcode', false);
             if (count($aProfileAttributes) == 0) {
                 $aAllAttributes = array_keys(MetaModel::ListAttributeDefs($sClass));
                 $aAttributes = array_merge($aAttributes, $aAllAttributes);
             } else {
                 $aAttributes = array_merge($aAttributes, $aProfileAttributes);
             }
         }
     }
     $aRes = array('permission' => $iInstancePermission, 'attributes' => $aAttributes);
     $this->m_aObjectActionGrants[$oUser->GetKey()][$sClass][$iObjectRef][$iActionCode] = $aRes;
     return $aRes;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:40,代码来源:userrightsprojection.class.inc.php

示例9: GetTrackForwardExternalKeys

 /**
  * List external keys for which there is a LinkSet (direct or indirect) on the other end
  * For those external keys, a change will have a special meaning on the other end
  * in term of change tracking	 	 	 
  */
 public static final function GetTrackForwardExternalKeys($sClass)
 {
     if (!isset(self::$m_aTrackForwardCache[$sClass])) {
         $aRes = array();
         foreach (MetaModel::GetExternalKeys($sClass) as $sAttCode => $oAttDef) {
             $sRemoteClass = $oAttDef->GetTargetClass();
             foreach (MetaModel::ListAttributeDefs($sRemoteClass) as $sRemoteAttCode => $oRemoteAttDef) {
                 if (!$oRemoteAttDef->IsLinkSet()) {
                     continue;
                 }
                 if (!is_subclass_of($sClass, $oRemoteAttDef->GetLinkedClass()) && $oRemoteAttDef->GetLinkedClass() != $sClass) {
                     continue;
                 }
                 if ($oRemoteAttDef->GetExtKeyToMe() != $sAttCode) {
                     continue;
                 }
                 $aRes[$sAttCode] = $oRemoteAttDef;
             }
         }
         self::$m_aTrackForwardCache[$sClass] = $aRes;
     }
     return self::$m_aTrackForwardCache[$sClass];
 }
开发者ID:henryavila,项目名称:itop,代码行数:28,代码来源:metamodel.class.php

示例10: FindRecipients

 protected function FindRecipients($sRecipAttCode, $aArgs)
 {
     $sOQL = $this->Get($sRecipAttCode);
     if (strlen($sOQL) == '') {
         return '';
     }
     try {
         $oSearch = DBObjectSearch::FromOQL($sOQL);
         $oSearch->AllowAllData();
     } catch (OQLException $e) {
         $this->m_aMailErrors[] = "query syntax error for recipient '{$sRecipAttCode}'";
         return $e->getMessage();
     }
     $sClass = $oSearch->GetClass();
     // Determine the email attribute (the first one will be our choice)
     foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
         if ($oAttDef instanceof AttributeEmailAddress) {
             $sEmailAttCode = $sAttCode;
             // we've got one, exit the loop
             break;
         }
     }
     if (!isset($sEmailAttCode)) {
         $this->m_aMailErrors[] = "wrong target for recipient '{$sRecipAttCode}'";
         return "The objects of the class '{$sClass}' do not have any email attribute";
     }
     $oSet = new DBObjectSet($oSearch, array(), $aArgs);
     $aRecipients = array();
     while ($oObj = $oSet->Fetch()) {
         $sAddress = trim($oObj->Get($sEmailAttCode));
         if (strlen($sAddress) > 0) {
             $aRecipients[] = $sAddress;
             $this->m_iRecipients++;
         }
     }
     return implode(', ', $aRecipients);
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:37,代码来源:action.class.inc.php

示例11: 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

示例12: ResolveExternalKeys

 /**
  * Maps an external key to its (newly created) value
  */
 protected function ResolveExternalKeys()
 {
     foreach ($this->m_aObjectsCache as $sClass => $oObjList) {
         foreach ($oObjList as $oTargetObj) {
             $bChanged = false;
             $sClass = get_class($oTargetObj);
             foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
                 if ($oAttDef->IsExternalKey() && $oTargetObj->Get($sAttCode) < 0) {
                     $sTargetClass = $oAttDef->GetTargetClass();
                     $iTempKey = $oTargetObj->Get($sAttCode);
                     $iExtKey = $this->GetObjectKey($sTargetClass, -$iTempKey);
                     if ($iExtKey == 0) {
                         $sMsg = "unresolved extkey in {$sClass}::" . $oTargetObj->GetKey() . "(" . $oTargetObj->GetName() . ")::{$sAttCode}={$sTargetClass}::{$iTempKey}";
                         SetupPage::log_warning($sMsg);
                         $this->m_aWarnings[] = $sMsg;
                         //echo "<pre>aKeys[".$sTargetClass."]:\n";
                         //print_r($this->m_aKeys[$sTargetClass]);
                         //echo "</pre>\n";
                     } else {
                         $bChanged = true;
                         $oTargetObj->Set($sAttCode, $iExtKey);
                     }
                 }
             }
             if ($bChanged) {
                 try {
                     if (is_subclass_of($oTargetObj, 'CMDBObject')) {
                         $oTargetObj->DBUpdateTracked($this->m_oChange);
                     } else {
                         $oTargetObj->DBUpdate();
                     }
                 } catch (Exception $e) {
                     $this->m_aErrors[] = "The object changes could not be tracked - {$sClass}/{$iExtKey} - " . $e->getMessage();
                 }
             }
         }
     }
     return true;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:42,代码来源:xmldataloader.class.inc.php

示例13: GetResetPasswordEmail

 /**
  * The email recipient is the person who is allowed to regain control when the password gets lost	
  * Throws an exception if the feature cannot be available
  */
 public function GetResetPasswordEmail()
 {
     if (!MetaModel::IsValidAttCode(get_class($this), 'contactid')) {
         throw new Exception(Dict::S('UI:ResetPwd-Error-NoContact'));
     }
     $iContactId = $this->Get('contactid');
     if ($iContactId == 0) {
         throw new Exception(Dict::S('UI:ResetPwd-Error-NoContact'));
     }
     $oContact = MetaModel::GetObject('Contact', $iContactId);
     // Determine the email attribute (the first one will be our choice)
     foreach (MetaModel::ListAttributeDefs(get_class($oContact)) as $sAttCode => $oAttDef) {
         if ($oAttDef instanceof AttributeEmailAddress) {
             $sEmailAttCode = $sAttCode;
             // we've got one, exit the loop
             break;
         }
     }
     if (!isset($sEmailAttCode)) {
         throw new Exception(Dict::S('UI:ResetPwd-Error-NoEmailAtt'));
     }
     $sRes = trim($oContact->Get($sEmailAttCode));
     return $sRes;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:28,代码来源:userrights.class.inc.php

示例14: MakeDictionaryTemplate

function MakeDictionaryTemplate($sModules = '', $sLanguage = 'EN US')
{
    $sRes = '';
    Dict::SetDefaultLanguage($sLanguage);
    $aAvailableLanguages = Dict::GetLanguages();
    $sDesc = $aAvailableLanguages[$sLanguage]['description'];
    $sLocalizedDesc = $aAvailableLanguages[$sLanguage]['localized_description'];
    $sRes .= "// Dictionary conventions\n";
    $sRes .= htmlentities("// Class:<class_name>\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>+\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>+\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>/Value:<value>\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>/Value:<value>+\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Stimulus:<stimulus_code>\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Stimulus:<stimulus_code>+\n", ENT_QUOTES, 'UTF-8');
    $sRes .= "\n";
    // Note: I did not use EnumCategories(), because a given class maybe found in several categories
    // Need to invent the "module", to characterize the origins of a class
    if (strlen($sModules) == 0) {
        $aModules = array('bizmodel', 'core/cmdb', 'gui', 'application', 'addon/userrights', 'monitoring');
    } else {
        $aModules = explode(', ', $sModules);
    }
    $sRes .= "//////////////////////////////////////////////////////////////////////\n";
    $sRes .= "// Note: The classes have been grouped by categories: " . implode(', ', $aModules) . "\n";
    $sRes .= "//////////////////////////////////////////////////////////////////////\n";
    foreach ($aModules as $sCategory) {
        $sRes .= "//////////////////////////////////////////////////////////////////////\n";
        $sRes .= "// Classes in '{$sCategory}'\n";
        $sRes .= "//////////////////////////////////////////////////////////////////////\n";
        $sRes .= "//\n";
        $sRes .= "\n";
        foreach (MetaModel::GetClasses($sCategory) as $sClass) {
            if (!MetaModel::HasTable($sClass)) {
                continue;
            }
            $bNotInDico = false;
            $bNotImportant = true;
            $sClassRes = "//\n";
            $sClassRes .= "// Class: {$sClass}\n";
            $sClassRes .= "//\n";
            $sClassRes .= "\n";
            $sClassRes .= "Dict::Add('{$sLanguage}', '{$sDesc}', '{$sLocalizedDesc}', array(\n";
            $sClassRes .= MakeDictEntry("Class:{$sClass}", MetaModel::GetName_Obsolete($sClass), $sClass, $bNotInDico);
            $sClassRes .= MakeDictEntry("Class:{$sClass}+", MetaModel::GetClassDescription_Obsolete($sClass), '', $bNotImportant);
            foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
                if ($sAttCode == 'friendlyname') {
                    continue;
                }
                // Skip this attribute if not originaly defined in this class
                if (MetaModel::GetAttributeOrigin($sClass, $sAttCode) != $sClass) {
                    continue;
                }
                $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}", $oAttDef->GetLabel_Obsolete(), $sAttCode, $bNotInDico);
                $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}+", $oAttDef->GetDescription_Obsolete(), '', $bNotImportant);
                if ($oAttDef instanceof AttributeEnum) {
                    if (MetaModel::GetStateAttributeCode($sClass) == $sAttCode) {
                        foreach (MetaModel::EnumStates($sClass) as $sStateCode => $aStateData) {
                            if (array_key_exists('label', $aStateData)) {
                                $sValue = $aStateData['label'];
                            } else {
                                $sValue = MetaModel::GetStateLabel($sClass, $sStateCode);
                            }
                            if (array_key_exists('description', $aStateData)) {
                                $sValuePlus = $aStateData['description'];
                            } else {
                                $sValuePlus = MetaModel::GetStateDescription($sClass, $sStateCode);
                            }
                            $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sStateCode}", $sValue, '', $bNotInDico);
                            $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sStateCode}+", $sValuePlus, '', $bNotImportant);
                        }
                    } else {
                        foreach ($oAttDef->GetAllowedValues() as $sKey => $value) {
                            $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sKey}", $value, '', $bNotInDico);
                            $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sKey}+", $value, '', $bNotImportant);
                        }
                    }
                }
            }
            foreach (MetaModel::EnumStimuli($sClass) as $sStimulusCode => $oStimulus) {
                $sClassRes .= MakeDictEntry("Class:{$sClass}/Stimulus:{$sStimulusCode}", $oStimulus->GetLabel_Obsolete(), '', $bNotInDico);
                $sClassRes .= MakeDictEntry("Class:{$sClass}/Stimulus:{$sStimulusCode}+", $oStimulus->GetDescription_Obsolete(), '', $bNotImportant);
            }
            $sClassRes .= "));\n";
            $sClassRes .= "\n";
            $sRes .= $sClassRes;
        }
    }
    return $sRes;
}
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:91,代码来源:ajax.toolkit.php

示例15: CopyFrom

 /**
  * Helpr to clone (in memory) an object and to apply to it the values taken from a second object
  * @param DBObject $oObjToClone
  * @param DBObject $oObjWithValues
  * @return DBObject The modified clone
  */
 protected function CopyFrom($oObjToClone, $oObjWithValues)
 {
     $oObj = MetaModel::GetObject(get_class($oObjToClone), $oObjToClone->GetKey());
     foreach (MetaModel::ListAttributeDefs(get_class($oObj)) as $sAttCode => $oAttDef) {
         if (!in_array($sAttCode, $this->aExcludedColumns) && $oAttDef->IsWritable()) {
             $oObj->Set($sAttCode, $oObjWithValues->Get($sAttCode));
         }
     }
     return $oObj;
 }
开发者ID:henryavila,项目名称:itop,代码行数:16,代码来源:dbobjectset.class.php


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