本文整理汇总了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;
}
示例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);
}
示例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;
}
}