/** * Is used to build a state filter for the backend when fetching child * objects for the hover menu child list. If the childs should be sorted * by state it may be possible to limit the number of requested objects * dramatically when using the state filters. */ public function getChildFetchingStateFilters() { global $_MAINCFG; $stateCounts = array(); $stateWeight = $_MAINCFG->getStateWeight(); if ($this->aStateCounts !== null) { foreach ($this->aStateCounts as $sState => $aSubstates) { if (isset($stateWeight[$sState]) && isset($stateWeight[$sState]['normal']) && isset($aSubstates['normal']) && $aSubstates['normal'] !== 0) { $stateCounts[] = array('name' => $sState, 'weight' => $stateWeight[$sState]['normal'], 'count' => $aSubstates['normal']); } } } NagVisObject::$sSortOrder = $this->hover_childs_order; usort($stateCounts, array("NagVisStatefulObject", "sortStateCountsByState")); $objCount = 0; $stateFilter = array(); foreach ($stateCounts as $aState) { $stateFilter[] = $aState['name']; if (($objCount += $aState['count']) >= $this->hover_childs_limit) { break; } } return $stateFilter; }
/** * PUBLIC getSortedObjectMembers() * * Gets an array of member objects * * @return Array Member object information * @author Lars Michelsen <*****@*****.**> */ public function getSortedObjectMembers() { $arr = array(); $aTmpMembers = $this->getStateRelevantMembers(); // Set the sort order self::$sSortOrder = $this->hover_childs_order; // Sort the array of child objects by the sort option switch ($this->hover_childs_sort) { case 's': // Order by State usort($aTmpMembers, array("NagVisObject", "sortObjectsByState")); break; case 'a': default: // Order alhpabetical usort($aTmpMembers, array("NagVisObject", "sortObjectsAlphabetical")); break; } // Count only once, not in loop header $iNumObjects = count($aTmpMembers); // Loop all child object until all looped or the child limit is reached for ($i = 0; $this->belowHoverChildsLimit($i) && $i < $iNumObjects; $i++) { $arr[] = $aTmpMembers[$i]; } return $arr; }