Index: multiblock.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/multiblock/multiblock.install,v retrieving revision 1.1 diff -u -r1.1 multiblock.install --- multiblock.install 29 Feb 2008 20:26:31 -0000 1.1 +++ multiblock.install 17 May 2008 17:27:27 -0000 @@ -2,13 +2,13 @@ // $Id: multiblock.install,v 1.1 2008/02/29 20:26:31 andrewlevine Exp $ function multiblock_install() { - switch($GLOBALS['db_type']) { + switch ($GLOBALS['db_type']) { case 'pgsql': db_query("CREATE TABLE {multiblock} ( delta int_unsigned NOT NULL default '1', title varchar(64) NOT NULL default '', module varchar(64) NOT NULL default '', - orig_delta varchar(32) NOT NULL default '', + orig_delta varchar(32) NOT NULL default '', multi_settings int_unsigned NOT NULL default '0', PRIMARY KEY (delta) )"); @@ -16,14 +16,14 @@ break; case 'mysql': case 'mysqli': - db_query(" CREATE TABLE {multiblock} ( - `delta` INT( 11 ) UNSIGNED NOT NULL DEFAULT '1', - `title` VARCHAR( 64 ) NOT NULL , - `module` VARCHAR( 64 ) NOT NULL , - `orig_delta` VARCHAR( 32 ) NOT NULL , - `multi_settings` INT( 10 ) NOT NULL DEFAULT '0', - PRIMARY KEY ( `delta` ) + db_query("CREATE TABLE {multiblock} ( + delta int(11) UNSIGNED NOT NULL DEFAULT '1', + title varchar(64) NOT NULL , + module varchar(64) NOT NULL , + orig_delta varchar(32) NOT NULL , + multi_settings int(10) NOT NULL DEFAULT '0', + PRIMARY KEY (delta) )"); break; } -} \ No newline at end of file +} Index: multiblock.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/multiblock/multiblock.module,v retrieving revision 1.1 diff -u -r1.1 multiblock.module --- multiblock.module 29 Feb 2008 20:26:31 -0000 1.1 +++ multiblock.module 17 May 2008 17:27:27 -0000 @@ -1,7 +1,8 @@ delta] = array( 'info' => check_plain($row->title), ); } return $blocks; } - //any op besides list we want to dispatch the call to its respective module + // Any op besides list we want to dispatch the call to its respective module. else if ($op == 'view' || $op == 'configure' || $op == 'save') { return multiblock_call_block($delta, $op, $edit); } } -/* +/** * Dispatch a hook_block call to it's respective module. Paramater $delta * is the new multiblock delta that we're using and $op is the op we are * dispatching. @@ -55,7 +56,7 @@ function multiblock_call_block($delta, $op, $edit) { $result = db_query("SELECT module, orig_delta, delta, multi_settings FROM {multiblock} WHERE delta='%s'", $delta); if ($block_info = db_fetch_object($result)) { - //if this block is multiblock enabled, send it the delta of the block we're using + // If this block is multiblock enabled, send it the delta of the block we're using. if ($block_info->multi_settings == 1 ) { $edit['multiblock_delta'] = array( '#type' => 'value', @@ -64,23 +65,23 @@ } return module_invoke($block_info->module, 'block', $op, $block_info->orig_delta, $edit); } - //no such multiblock, shouldn't ever happen + // No such multiblock, shouldn't ever happen. return; } -/* - * Page callback for the "Manage Block Instances page" +/** + * Page callback for the "Manage Block Instances page". */ function multiblock_general() { - //fetch blocks directly from modules using block.module function + // Fetch blocks directly from modules using block.module function. $blocks = _block_rehash(); - //sort blocks how we want them + // Sort blocks how we want them. usort($blocks, 'multiblock_block_sort'); - //fetch "Add Instance" form + // Fetch "Add Instance" form. $form = drupal_get_form('multiblock_add_block', $blocks); - //get an array of existing blocks + // Get an array of existing blocks. $result = db_query('SELECT * FROM {multiblock} ORDER BY title'); $multiblocks = array(); while ($multiblock = db_fetch_object($result)) { @@ -90,8 +91,8 @@ return theme('multiblock_general', $form, $multiblocks); } -/* - * "Add Instance" form +/** + * "Add Instance" form. */ function multiblock_add_block($blocks) { $form = array(); @@ -102,14 +103,14 @@ '#required' => TRUE, ); - //turn $blocks into form options of block types - //remember we need the module and delta to be able to tell what kind of blocks - //we're talking about. + // Turn $blocks into form options of block types. + // Temember we need the module and delta to be able to tell what kind of + // blocks we're talking about. $options = array(); foreach ($blocks as $block) { - //don't include multiblock module blocks in the list + // Don't include multiblock module blocks in the list. if ($block['module'] != 'multiblock') { - $options[$block['module'].'***MB***'.$block['delta']] = $block['info']; + $options[$block['module'] .'***MB***'. $block['delta']] = $block['info']; } } @@ -126,14 +127,14 @@ return $form; } -/* - * Call back that deletes the block instance with a delta of arg(2) - * and redirects the user back to the "Manage Block Instances" form +/** + * Callback that deletes the block instance with a delta of arg(2) + * and redirects the user back to the "Manage Block Instances" form. */ function multiblock_delete() { $multiblock_delta = arg(2); $result = db_query('DELETE FROM {multiblock} WHERE delta=%d', (int)$multiblock_delta); - //if we actually deleted something + // If we actually deleted something. if (ctype_digit($multiblock_delta) && db_affected_rows() == 1) { drupal_set_message(t('Block successfully deleted!')); _block_rehash(); @@ -145,16 +146,16 @@ exit; } -/* - * Validate "Add Block Instance" form +/** + * Validate "Add Block Instance" form. */ function multiblock_add_block_validate($form_id, $form_values) { - //make sure we are getting a valid block to add + // Make sure we are getting a valid block to add. if (!preg_match('/^.+\*\*\*MB\*\*\*.+$/', $form_values['block'])) { form_set_error('block', t('Bad block module input, contact administrator')); return; } - //make sure the block and delta exist + // Make sure the block and delta exist. $orig_block = multiblock_blockinfo_from_form($form_values['block']); if (!module_hook($orig_block['module'], 'block') || !array_key_exists($orig_block['delta'], module_invoke($orig_block['module'], 'block', 'list'))) { @@ -162,15 +163,15 @@ } } -/* - * Add block instance to database from "Add Block Instance" form +/** + * Add block instance to database from "Add Block Instance" form. */ function multiblock_add_block_submit($form_id, $form_values) { - //create new delta for block instance + // Create new delta for block instance. $delta = db_next_id('{multiblock}_delta'); - //get the original block info + // Get the original block info. $orig_block = multiblock_blockinfo_from_form($form_values['block']); - //check whether this module is multiblock enabled + // Check whether this module is multiblock enabled. $mb_enabled = (int)(module_invoke($orig_block['module'], 'block', 'mb_enabled') == 'mb_enabled'); $sql = "INSERT INTO {multiblock} (delta, title, module, orig_delta, multi_settings) @@ -179,39 +180,39 @@ drupal_set_message(t('Block instance %instance created.', array('%instance' => $form_values['title']))); } -/* - * Custom sort based on info element of array +/** + * Custom sort based on info element of array. */ function multiblock_block_sort($a, $b) { return strcmp($a['info'], $b['info']); } -/* - * Get the module and delta from the "Add Block Instance" block form element +/** + * Get the module and delta from the "Add Block Instance" block form element. */ function multiblock_blockinfo_from_form($form_value) { $matches = array(); preg_match('/^(.+)\*\*\*MB\*\*\*(.+)$/', $form_value, $matches); - return array ('module' => $matches[1], 'delta' => $matches[2]); + return array('module' => $matches[1], 'delta' => $matches[2]); } -/* - * Get title of a block by its module and delta +/** + * Get title of a block by its module and delta. */ function multiblock_get_block_title($module, $delta) { $block_info = module_invoke($module, 'block', 'list'); return $block_info[$delta]['info']; } -/* - * Theme function for the "Manage Block Instances" page +/** + * Theme function for the "Manage Block Instances" page. */ function theme_multiblock_general($add_block_form, $multiblocks) { $output = ''; - $output .= '