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


PHP MetaModel::GetOrderByDefault方法代码示例

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


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

示例1: GetDataModelSettings

 public static function GetDataModelSettings($aClassAliases, $bViewLink, $aDefaultLists)
 {
     $oSettings = new DataTableSettings($aClassAliases);
     // Retrieve the class specific settings for each class/alias based on the 'list' ZList
     //TODO let the caller pass some other default settings (another Zlist, extre fields...)
     $aColumns = array();
     foreach ($aClassAliases as $sAlias => $sClass) {
         if ($aDefaultLists == null) {
             $aList = cmdbAbstract::FlattenZList(MetaModel::GetZListItems($sClass, 'list'));
         } else {
             $aList = $aDefaultLists[$sAlias];
         }
         $aSortOrder = MetaModel::GetOrderByDefault($sClass);
         if ($bViewLink) {
             $sSort = 'none';
             if (array_key_exists('friendlyname', $aSortOrder)) {
                 $sSort = $aSortOrder['friendlyname'] ? 'asc' : 'desc';
             }
             $aColumns[$sAlias]['_key_'] = $oSettings->GetFieldData($sAlias, '_key_', null, true, $sSort);
         }
         foreach ($aList as $sAttCode) {
             $sSort = 'none';
             if (array_key_exists($sAttCode, $aSortOrder)) {
                 $sSort = $aSortOrder[$sAttCode] ? 'asc' : 'desc';
             }
             $oAttDef = Metamodel::GetAttributeDef($sClass, $sAttCode);
             $aFieldData = $oSettings->GetFieldData($sAlias, $sAttCode, $oAttDef, true, $sSort);
             if ($aFieldData) {
                 $aColumns[$sAlias][$sAttCode] = $aFieldData;
             }
         }
     }
     $iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
     $oSettings->Init($iDefaultPageSize, $aSortOrder, $aColumns);
     return $oSettings;
 }
开发者ID:henryavila,项目名称:itop,代码行数:36,代码来源:datatable.class.inc.php

示例2: GetDisplayExtendedSet

 public static function GetDisplayExtendedSet(WebPage $oPage, CMDBObjectSet $oSet, $aExtraParams = array())
 {
     if (empty($aExtraParams['currentId'])) {
         $iListId = $oPage->GetUniqueId();
         // Works only if not in an Ajax page !!
     } else {
         $iListId = $aExtraParams['currentId'];
     }
     $aList = array();
     // Initialize and check the parameters
     $bViewLink = isset($aExtraParams['view_link']) ? $aExtraParams['view_link'] : true;
     $bDisplayMenu = isset($aExtraParams['menu']) ? $aExtraParams['menu'] == true : true;
     // Check if there is a list of aliases to limit the display to...
     $aDisplayAliases = isset($aExtraParams['display_aliases']) ? explode(',', $aExtraParams['display_aliases']) : array();
     $sZListName = isset($aExtraParams['zlist']) ? $aExtraParams['zlist'] : 'list';
     $aExtraFieldsRaw = isset($aExtraParams['extra_fields']) ? explode(',', trim($aExtraParams['extra_fields'])) : array();
     $aExtraFields = array();
     foreach ($aExtraFieldsRaw as $sFieldName) {
         // Ignore attributes not of the main queried class
         if (preg_match('/^(.*)\\.(.*)$/', $sFieldName, $aMatches)) {
             $sClassAlias = $aMatches[1];
             $sAttCode = $aMatches[2];
             if (array_key_exists($sClassAlias, $oSet->GetSelectedClasses())) {
                 $aExtraFields[$sClassAlias][] = $sAttCode;
             }
         } else {
             $aExtraFields['*'] = $sAttCode;
         }
     }
     $sHtml = '';
     $oAppContext = new ApplicationContext();
     $aClasses = $oSet->GetFilter()->GetSelectedClasses();
     $aAuthorizedClasses = array();
     foreach ($aClasses as $sAlias => $sClassName) {
         if (UserRights::IsActionAllowed($sClassName, UR_ACTION_READ, $oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS) && (count($aDisplayAliases) == 0 || in_array($sAlias, $aDisplayAliases))) {
             $aAuthorizedClasses[$sAlias] = $sClassName;
         }
     }
     $aAttribs = array();
     foreach ($aAuthorizedClasses as $sAlias => $sClassName) {
         if (array_key_exists($sAlias, $aExtraFields)) {
             $aList[$sAlias] = $aExtraFields[$sAlias];
         } else {
             $aList[$sAlias] = array();
         }
         if ($sZListName !== false) {
             $aDefaultList = self::FlattenZList(MetaModel::GetZListItems($sClassName, $sZListName));
             $aList[$sAlias] = array_merge($aDefaultList, $aList[$sAlias]);
         }
         // Filter the list to removed linked set since we are not able to display them here
         foreach ($aList[$sAlias] as $index => $sAttCode) {
             $oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttCode);
             if ($oAttDef instanceof AttributeLinkedSet) {
                 // Removed from the display list
                 unset($aList[$sAlias][$index]);
             }
         }
     }
     $sSelectMode = 'none';
     $sClassAlias = $oSet->GetClassAlias();
     $oDataTable = new DataTable($iListId, $oSet, $aAuthorizedClasses);
     $oSettings = DataTableSettings::GetDataModelSettings($aAuthorizedClasses, $bViewLink, $aList);
     $bDisplayLimit = isset($aExtraParams['display_limit']) ? $aExtraParams['display_limit'] : true;
     if ($bDisplayLimit) {
         $iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
         $oSettings->iDefaultPageSize = $iDefaultPageSize;
     }
     $oSettings->aSortOrder = MetaModel::GetOrderByDefault($sClassName);
     return $oDataTable->Display($oPage, $oSettings, $bDisplayMenu, $sSelectMode, $bViewLink, $aExtraParams);
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:70,代码来源:cmdbabstract.class.inc.php

示例3: GetRealSortOrder

 /**
  * Get the sort order used for loading this set from the database
  * 
  * Limitation: the sort order has no effect on objects added in-memory
  * 
  * @return hash Format: field_code => boolean (true = ascending, false = descending)
  */
 public function GetRealSortOrder()
 {
     // Get the class default sort order if not specified with the API
     //
     if (empty($this->m_aOrderBy)) {
         return MetaModel::GetOrderByDefault($this->m_oFilter->GetClass());
     } else {
         return $this->m_aOrderBy;
     }
 }
开发者ID:henryavila,项目名称:itop,代码行数:17,代码来源:dbobjectset.class.php


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