_block_compare

Versions
4.7 – 7
_block_compare($a, $b)

Helper function for sorting blocks on admin/block.

Active blocks are sorted by region, then by weight. Disabled blocks are sorted by name.

Code

modules/block.module, line 254

<?php
function _block_compare($a, $b) {
  $status = $b['status'] - $a['status'];
  // Separate enabled from disabled.
  if ($status) {
    return $status;
  }
  // Enabled blocks
  if ($a['status']) {
    $place = strcmp($a['region'], $b['region']);
    return $place ? $place : ($a['weight'] - $b['weight']);
  }
  // Disabled blocks
  else {
    return strcmp($a['info'], $b['info']);
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.