function _block_compare in Drupal 6
Same name and namespace in other branches
- 4 modules/block.module \_block_compare()
- 5 modules/block/block.module \_block_compare()
- 7 modules/block/block.admin.inc \_block_compare()
Helper function for sorting blocks on admin/build/block.
Active blocks are sorted by region, then by weight. Disabled blocks are sorted by name.
1 string reference to '_block_compare'
- block_admin_display in modules/
block/ block.admin.inc - Menu callback for admin/build/block.
File
- modules/
block/ block.admin.inc, line 115 - Admin page callbacks for the block module.
Code
function _block_compare($a, $b) {
global $theme_key;
static $regions;
// We need the region list to correctly order by region.
if (!isset($regions)) {
$regions = array_flip(array_keys(system_region_list($theme_key)));
$regions[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']);
}