You are here

function homebox_layout in Homebox 6

Same name and namespace in other branches
  1. 6.3 homebox.admin.inc \homebox_layout()
  2. 6.2 homebox.admin.inc \homebox_layout()
  3. 7.3 homebox.admin.inc \homebox_layout()
  4. 7.2 homebox.admin.inc \homebox_layout()

Form builder function for module settings.

1 string reference to 'homebox_layout'
homebox_menu in ./homebox.module
Implementation of hook_menu().

File

./homebox.admin.inc, line 207
Home box admin file, takes care admin interface for homebox

Code

function homebox_layout($pid) {
  $page_name = _homebox_get_profile_name($pid);
  drupal_set_title(t('!page_name layout', array(
    '!page_name' => $page_name,
  )));

  // Gets admin build block helper for usort function
  require_once drupal_get_path('module', 'block') . '/block.admin.inc';

  // Fetch and sort blocks
  $blocks = _block_rehash();
  $home_blocks = array();
  $result = db_query("SELECT * FROM {homebox_default} WHERE pid = %d", $pid);
  while ($record = db_fetch_object($result)) {
    $home_blocks["{$record->bid}"] = $record;
  }
  foreach ($blocks as $key => &$block) {

    // We don't want to list exposed views blocks
    if (strpos($block['delta'], '-exp-') === 0) {

      // Remove exposed views blocks
      unset($blocks[$key]);
      continue;
    }
    $bid = $block['bid'];
    $block['pid'] = $pid;
    if (isset($home_blocks[$bid])) {
      $hb = $home_blocks[$bid];
      $block['weight'] = $hb->weight;
      $block['movable'] = (bool) $hb->movable;
      $block['status'] = (bool) $hb->status;
      $block['open'] = (bool) $hb->open;
    }
    else {
      $block['weight'] = 99;
      $block['movable'] = TRUE;
      $block['status'] = TRUE;
      $block['open'] = TRUE;
    }
  }
  usort($blocks, '_homebox_block_compare');
  return drupal_get_form('homebox_admin_display_form', $blocks, $pid, $theme = NULL);
}