function _mongodb_block_ui_compare in MongoDB 7
Helper for sorting mongodb_block_uis on admin/structure/mongodb_block_ui.
Active mongodb_block_uis are sorted by region, then by weight. Disabled mongodb_block_uis are sorted by name.
1 string reference to '_mongodb_block_ui_compare'
- mongodb_block_ui_admin_display in mongodb_block_ui/
mongodb_block_ui.admin.inc - Menu callback for admin/structure/mongodb_block_ui.
File
- mongodb_block_ui/
mongodb_block_ui.admin.inc, line 171 - Admin page callbacks for the mongodb_block_ui module.
Code
function _mongodb_block_ui_compare($a, $b) {
global $theme_key;
// Theme should be set before calling this function, or the current theme
// is being used.
$theme =& drupal_static(__FUNCTION__ . ':theme');
if (!isset($theme)) {
$theme = $theme_key;
}
$regions =& drupal_static(__FUNCTION__ . ':regions');
// We need the region list to correctly order by region.
if (!isset($regions)) {
$regions = array_flip(array_keys(system_region_list($theme)));
$regions[MONGODB_BLOCK_REGION_NONE] = count($regions);
}
// Separate enabled from disabled.
$status = $b['status'] - $a['status'];
if ($status) {
return $status;
}
// Sort by region (in the order defined by theme .info file).
if (!empty($a['region']) && !empty($b['region']) && ($place = $regions[$a['region']] - $regions[$b['region']])) {
return $place;
}
// Sort by weight.
$weight = $a['weight'] - $b['weight'];
if ($weight) {
return $weight;
}
// Sort by title.
return strcmp($a['info'], $b['info']);
}