You are here

widgets.block.inc in Widgets 6

Implementaion of block functions for Widgets module.

File

widgets.block.inc
View source
<?php

/**
 * @file
 * Implementaion of block functions for Widgets module.
 */

/**
 * List operation of hook_block().
 */
function widgets_block_list($delta, $edit) {
  $blocks[0] = array(
    'info' => t('Widgets'),
  );
  return $blocks;
}

/**
 * Configure operation of hook_block().
 */
function widgets_block_configure($delta, $edit) {
  $form = array();
  return $form;
}

/**
 * Save operation of hook_block().
 */
function widgets_block_save($delta, $edit) {
  return;
}

/**
 * View operation of hook_block().
 */
function widgets_block_view($delta, $edit) {
  $block['subject'] = '<none>';
  $block['content'] = widgets_block_content($delta);
  return $block;
}

/**
 * Assemble block content.
 *
 * @todo
 *	Check parent pages if no widgets where defined for current page and setting "inherit" is checked.
 */
function widgets_block_content($delta) {
  $output = '';

  // Are we viewing a node?
  if (is_numeric(arg(1))) {
    module_load_include('inc', 'widgets');

    // Load node.
    $node = node_load(arg(1));
    if ($node->disable_widgets) {
      return;
    }

    // Use deafault widgets?
    if ($node->default_widgets) {
      $selected = widgets_get_default($node->type);
    }
    else {

      // Get selected widgets.
      $selected = widgets_get_selected(arg(1));
    }

    // Assemble output.
    foreach ($selected as $widget) {
      $n = node_load($widget);
      $output .= node_view($n, FALSE, FALSE, FALSE);
    }
  }
  return $output;
}

Functions

Namesort descending Description
widgets_block_configure Configure operation of hook_block().
widgets_block_content Assemble block content.
widgets_block_list List operation of hook_block().
widgets_block_save Save operation of hook_block().
widgets_block_view View operation of hook_block().