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


PHP MetaModel::EnumRelations方法代码示例

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


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

示例1: ajax_page

    return $sIconPath;
}
require_once APPROOT . '/application/startup.inc.php';
require_once APPROOT . '/application/loginwebpage.class.inc.php';
// For developping the Navigator from within Flash
//session_start();
//$_SESSION['auth_user'] = 'admin';
//UserRights::Login($_SESSION['auth_user']); // Set the user's language
LoginWebPage::DoLogin();
// Check user rights and prompt if needed
$oPage = new ajax_page("");
$oPage->no_cache();
$sClass = utils::ReadParam('class', 'Contact', false, 'class');
$id = utils::ReadParam('id', 1);
$sRelation = utils::ReadParam('relation', 'impacts');
$aValidRelations = MetaModel::EnumRelations();
$sFormat = utils::ReadParam('format', 'xml');
$sExcludedClasses = utils::ReadParam('exclude', '', false, 'raw_data');
$aExcludedClasses = explode(',', $sExcludedClasses);
if (!in_array($sRelation, $aValidRelations)) {
    // Not a valid relation, use the default one instead
    $sRelation = 'impacts';
}
try {
    if ($id != 0) {
        switch ($sFormat) {
            case 'html':
                $oPage->SetContentType('text/html');
                $oObj = MetaModel::GetObject($sClass, $id, true);
                $aResults = array();
                $iMaxRecursionDepth = MetaModel::GetConfig()->Get('relations_max_depth', 20);
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:31,代码来源:xml.navigator.php

示例2: DisplayClassesList

/**
 * Display the list of classes from the business model
 */
function DisplayClassesList($oPage, $sContext)
{
    $oPage->add("<h1>" . Dict::S('UI:Schema:Title') . "</h1>\n");
    $oPage->add("<ul id=\"ClassesList\" class=\"treeview fileview\">\n");
    // Get all the "root" classes for display
    $aRootClasses = array();
    foreach (MetaModel::GetClasses() as $sClassName) {
        if (MetaModel::IsRootClass($sClassName)) {
            $aRootClasses[$sClassName] = MetaModel::GetName($sClassName);
        } elseif (MetaModel::IsStandaloneClass($sClassName)) {
            $aRootClasses[$sClassName] = MetaModel::GetName($sClassName);
        }
    }
    // Sort them alphabetically on their display name
    asort($aRootClasses);
    foreach ($aRootClasses as $sClassName => $sDisplayName) {
        if (MetaModel::IsRootClass($sClassName)) {
            $oPage->add("<li class=\"open\">" . MakeClassHLink($sClassName, $sContext) . "\n");
            DisplaySubclasses($oPage, $sClassName, $sContext);
            $oPage->add("</li>\n");
        } elseif (MetaModel::IsStandaloneClass($sClassName)) {
            $oPage->add("<li>" . MakeClassHLink($sClassName, $sContext) . "</li>\n");
        }
    }
    $oPage->add("</ul>\n");
    $oPage->add("<h1>" . Dict::S('UI:Schema:Relationships') . "</h1>\n");
    $oPage->add("<ul id=\"ClassesRelationships\" class=\"treeview\">\n");
    foreach (MetaModel::EnumRelations() as $sRelCode) {
        $oPage->add("<li>" . MakeRelationHLink($sRelCode, $sContext) . "\n");
        $oPage->add("<ul>\n");
        $oPage->add("<li>Description: " . htmlentities(MetaModel::GetRelationDescription($sRelCode), ENT_QUOTES, 'UTF-8') . "</li>\n");
        $oPage->add("<li>Verb up: " . htmlentities(MetaModel::GetRelationVerbUp($sRelCode), ENT_QUOTES, 'UTF-8') . "</li>\n");
        $oPage->add("<li>Verb down: " . htmlentities(MetaModel::GetRelationVerbDown($sRelCode), ENT_QUOTES, 'UTF-8') . "</li>\n");
        $oPage->add("</ul>\n");
        $oPage->add("</li>\n");
    }
    $oPage->add("</ul>\n");
    $oPage->add_ready_script('$("#ClassesList").treeview();');
    $oPage->add_ready_script('$("#ClassesRelationships").treeview();');
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:43,代码来源:schema.php

示例3: GetRenderContent

 /**
  * Renders the "Actions" popup menu for the given set of objects
  * 
  * Note that the menu links containing (or ending) with a hash (#) will have their fragment
  * part (whatever is after the hash) dynamically replaced (by javascript) when the menu is
  * displayed, to correspond to the current hash/fragment in the page. This allows modifying
  * an object in with the same tab active by default as the tab that was active when selecting
  * the "Modify..." action.
  */
 public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId)
 {
     if ($this->m_sStyle == 'popup') {
         $this->m_sStyle = 'list';
     }
     $sHtml = '';
     $oAppContext = new ApplicationContext();
     $sContext = $oAppContext->GetForLink();
     if (!empty($sContext)) {
         $sContext = '&' . $sContext;
     }
     $sClass = $this->m_oFilter->GetClass();
     $oReflectionClass = new ReflectionClass($sClass);
     $oSet = new CMDBObjectSet($this->m_oFilter);
     $sFilter = $this->m_oFilter->serialize();
     $sFilterDesc = $this->m_oFilter->ToOql(true);
     $aActions = array();
     $sUIPage = cmdbAbstractObject::ComputeStandardUIPage($sClass);
     $sRootUrl = utils::GetAbsoluteUrlAppRoot();
     // 1:n links, populate the target object as a default value when creating a new linked object
     if (isset($aExtraParams['target_attr'])) {
         $aExtraParams['default'][$aExtraParams['target_attr']] = $aExtraParams['object_id'];
     }
     $sDefault = '';
     if (!empty($aExtraParams['default'])) {
         foreach ($aExtraParams['default'] as $sKey => $sValue) {
             $sDefault .= "&default[{$sKey}]={$sValue}";
         }
     }
     $bIsCreationAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_CREATE) == UR_ALLOWED_YES && $oReflectionClass->IsSubclassOf('cmdbAbstractObject');
     switch ($oSet->Count()) {
         case 0:
             // No object in the set, the only possible action is "new"
             if ($bIsCreationAllowed) {
                 $aActions['UI:Menu:New'] = array('label' => Dict::S('UI:Menu:New'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=new&class={$sClass}{$sContext}{$sDefault}");
             }
             break;
         case 1:
             $oObj = $oSet->Fetch();
             $id = $oObj->GetKey();
             $bIsModifyAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY, $oSet) == UR_ALLOWED_YES && $oReflectionClass->IsSubclassOf('cmdbAbstractObject');
             $bIsDeleteAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_DELETE, $oSet);
             // Just one object in the set, possible actions are "new / clone / modify and delete"
             if (!isset($aExtraParams['link_attr'])) {
                 if ($bIsModifyAllowed) {
                     $aActions['UI:Menu:Modify'] = array('label' => Dict::S('UI:Menu:Modify'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=modify&class={$sClass}&id={$id}{$sContext}#");
                 }
                 if ($bIsCreationAllowed) {
                     $aActions['UI:Menu:New'] = array('label' => Dict::S('UI:Menu:New'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=new&class={$sClass}{$sContext}{$sDefault}");
                 }
                 if ($bIsDeleteAllowed) {
                     $aActions['UI:Menu:Delete'] = array('label' => Dict::S('UI:Menu:Delete'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=delete&class={$sClass}&id={$id}{$sContext}");
                 }
                 // Transitions / Stimuli
                 $aTransitions = $oObj->EnumTransitions();
                 if (count($aTransitions)) {
                     $this->AddMenuSeparator($aActions);
                     $aStimuli = Metamodel::EnumStimuli(get_class($oObj));
                     foreach ($aTransitions as $sStimulusCode => $aTransitionDef) {
                         $iActionAllowed = get_class($aStimuli[$sStimulusCode]) == 'StimulusUserAction' ? UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSet) : UR_ALLOWED_NO;
                         switch ($iActionAllowed) {
                             case UR_ALLOWED_YES:
                                 $aActions[$sStimulusCode] = array('label' => $aStimuli[$sStimulusCode]->GetLabel(), 'url' => "{$sRootUrl}pages/UI.php?operation=stimulus&stimulus={$sStimulusCode}&class={$sClass}&id={$id}{$sContext}");
                                 break;
                             default:
                                 // Do nothing
                         }
                     }
                 }
                 // Relations...
                 $aRelations = MetaModel::EnumRelations($sClass);
                 if (count($aRelations)) {
                     $this->AddMenuSeparator($aActions);
                     foreach ($aRelations as $sRelationCode) {
                         $aActions[$sRelationCode] = array('label' => MetaModel::GetRelationVerbUp($sRelationCode), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=swf_navigator&relation={$sRelationCode}&class={$sClass}&id={$id}{$sContext}");
                     }
                 }
                 /*
                 $this->AddMenuSeparator($aActions);
                 // Static menus: Email this page & CSV Export
                 $sUrl = ApplicationContext::MakeObjectUrl($sClass, $id);
                 $aActions['UI:Menu:EMail'] = array ('label' => Dict::S('UI:Menu:EMail'), 'url' => "mailto:?subject=".urlencode($oObj->GetRawName())."&body=".urlencode($sUrl));
                 $aActions['UI:Menu:CSVExport'] = array ('label' => Dict::S('UI:Menu:CSVExport'), 'url' => "{$sRootUrl}pages/$sUIPage?operation=search&filter=".urlencode($sFilter)."&format=csv{$sContext}");
                 // The style tells us whether the menu is displayed on a list of one object, or on the details of the given object 
                 if ($this->m_sStyle == 'list')
                 {
                 	// Actions specific to the list
                 	$sOQL = addslashes($sFilterDesc);
                 	$aActions['UI:Menu:AddToDashboard'] = array ('label' => Dict::S('UI:Menu:AddToDashboard'), 'url' => "#", 'onclick' => "return DashletCreationDlg('$sOQL')");
                 }
                 */
//.........这里部分代码省略.........
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:101,代码来源:displayblock.class.inc.php

示例4: AddCondition_RelatedTo

 public function AddCondition_RelatedTo(DBObjectSearch $oFilter, $sRelCode, $iMaxDepth)
 {
     MyHelpers::CheckValueInArray('relation code', $sRelCode, MetaModel::EnumRelations());
     $this->m_aRelatedTo[] = array('flt' => $oFilter, 'relcode' => $sRelCode, 'maxdepth' => $iMaxDepth);
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:5,代码来源:dbobjectsearch.class.php


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