Index: block_example.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/docs/developer/examples/block_example.module,v
retrieving revision 1.11
diff -u -p -r1.11 block_example.module
--- block_example.module	15 Sep 2008 21:57:07 -0000	1.11
+++ block_example.module	29 Dec 2008 07:19:50 -0000
@@ -8,77 +8,92 @@
  */
 
 /**
- * Implementation of hook_block().
+ * Implementation of hook_block_list().
  *
- * This hook both declares to Drupal what blocks are provided by the module, and
- * generates the contents of the blocks themselves.
+ * This hook declares to Drupal what blocks are provided by the module.
  */
-function block_example_block($op = 'list', $delta = '', $edit = array()) {
-  // The $op parameter determines what piece of information is being requested.
-  switch ($op) {
-    case 'list':
-      // If $op is "list", we just need to return a list of block descriptions.
-      // This is used to provide a list of possible blocks to the administrator;
-      // end users will not see these descriptions.
-      $blocks['configurable-text'] = array(
-        'info'       => t('Example: configurable text string'),
-      );
-      // A block can provide default settings. In this case we'll enable the
-      // block and make it visible only on the 'node/*' pages.
-      $blocks['empty'] = array(
-        'info'       => t('Example: empty block'),
-        'status'     => TRUE,
-        'weight'     => 0,
-        'visibility' => 1,
-        'pages'      => 'node/*',
-      );
-      return $blocks;
+function block_example_block_list() {
+  // This hook returns only a list of block descriptions.
+  // This is used to provide a list of possible blocks to the administrator;
+  // end users will not see these descriptions.
+  $blocks['configurable-text'] = array(
+    'info'       => t('Example: configurable text string'),
+  );
+  // A block can provide default settings. In this case we'll enable the
+  // block and make it visible only on the 'node/*' pages.
+  $blocks['empty'] = array(
+    'info'       => t('Example: empty block'),
+    'status'     => TRUE,
+    'weight'     => 0,
+    'visibility' => 1,
+    'pages'      => 'node/*',
+  );
+  return $blocks;
+}
+
-    case 'configure':
-      // If $op is "configure", we need to provide the administrator with a
-      // configuration form. The $delta parameter tells us which block is being
-      // configured. In this example, we'll allow the administrator to customize
-      // the text of the first block.
-      $form = array();
-      if ($delta == 'configurable-text') {
-        // All we need to provide is a text field, Drupal will take care of
-        // the other block configuration options and the save button.
-        $form['block_example_string'] = array(
-          '#type' => 'textfield',
-          '#title' => t('Block contents'),
-          '#size' => 60,
-          '#description' => t('This string will appear in the example block.'),
-          '#default_value' => variable_get('block_example_string',  t('Some example content.')),
-        );
-      }
-      return $form;
+/**
+ * Implementation of hook_block_configure().
+ *
+ * This hook declares configuration options for blocks provided by this module.
+ */
+function block_example_block_configure($delta = '') {
+  // The $delta parameter tells us which block is being configured.
+  // In this example, we'll allow the administrator to customize
+  // the text of the first block.
+  $form = array();
+  if ($delta == 'configurable-text') {
+    // All we need to provide is a text field, Drupal will take care of
+    // the other block configuration options and the save button.
+    $form['block_example_string'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Block contents'),
+      '#size' => 60,
+      '#description' => t('This string will appear in the example block.'),
+      '#default_value' => variable_get('block_example_string',  t('Some example content.')),
+    );
+  }
+  return $form;
+}
+
-    case 'save':
-      // If $op is "save", we need to save settings from the configuration form.
-      // Since the first block is the only one that allows configuration, we
-      // need to check $delta to make sure we only save it.
-      if ($delta == 'configurable-text') {
-        // Have Drupal save the string to the database.
-        variable_set('block_example_string', $edit['block_example_string']);
-      }
-      return;
+/**
+ * Implementation of hook_block_save().
+ *
+ * This hook declares how the configured options for a block
+ * provided by this module are exactly saved.
+ */
+function block_example_block_save($delta = '', $edit = array()) {
+  // If $op is "save", we need to save settings from the configuration form.
+  // Since the first block is the only one that allows configuration, we
+  // need to check $delta to make sure we only save it.
+  if ($delta == 'configurable-text') {
+    // Have Drupal save the string to the database.
+    variable_set('block_example_string', $edit['block_example_string']);
+  }
+  return;
+}
+
-    case 'view':
-      // If $op is "view", then we need to generate the block for display
-      // purposes. The $delta parameter tells us which block is being requested.
-      switch ($delta) {
-        case 'configurable-text':
-          // The subject is displayed at the top of the block. Note that it
-          // should be passed through t() for translation.
-          $block['subject'] = t('Title of block #1');
-          // The content of the block is typically generated by calling a custom
-          // function.
-          $block['content'] = block_example_contents(1);
-          break;
-        case 'empty':
-          $block['subject'] = t('Title of block #2');
-          $block['content'] = block_example_contents(2);
-          break;
-      }
-      return $block;
-  }
+/**
+ * Implementation of hook_block_view().
+ *
+ * This hook generates the contents of the blocks themselves.
+ */
+function block_example_block_view($delta = '') {
+  //The $delta parameter tells us which block is being requested.
+  switch ($delta) {
+    case 'configurable-text':
+      // The subject is displayed at the top of the block. Note that it
+      // should be passed through t() for translation.
+      $block['subject'] = t('Title of block #1');
+      // The content of the block is typically generated by calling a custom
+      // function.
+      $block['content'] = block_example_contents(1);
+      break;
+    case 'empty':
+      $block['subject'] = t('Title of block #2');
+      $block['content'] = block_example_contents(2);
+      break;
+  }
+  return $block;
 }
 
 /**
