Index: taxonomy_block.info =================================================================== RCS file: taxonomy_block.info diff -N taxonomy_block.info --- /dev/null 1970-01-01 01:00:00.000000000 +0100 +++ taxonomy_block.info 2007-01-16 01:54:17.828125000 +0100 @@ -0,0 +1,5 @@ +name = Taxonomy Block +description = Makes blocks based on taxonomy vocabularies and terms. +dependencies = taxonomy +package = Taxonomy +version = 5.0 dev Index: taxonomy_block.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_block/taxonomy_block.module,v retrieving revision 1.14 diff -u -F^f -r1.14 taxonomy_block.module --- taxonomy_block.module 31 Jan 2006 15:00:56 -0000 1.14 +++ taxonomy_block.module 16 Jan 2007 01:40:37 -0000 @@ -2,17 +2,6 @@ // $Id: taxonomy_block.module,v 1.14 2006/01/31 15:00:56 budda Exp $ /** - * Implementation of hook_help. - */ -function taxonomy_block_help($section) { - switch ($section) { - case 'admin/modules#description' : - return t('Makes blocks based on taxonomy vocabularies and terms.'); - break; - } -} - -/** * Implementation of hook_perm. */ function taxonomy_block_perm() { @@ -26,8 +15,20 @@ function taxonomy_block_menu($may_cache) $items = array(); if ($may_cache) { - $items[] = array('path' => 'admin/block/taxonomy_block', 'title' => t('taxonomy block'), 'callback' => 'taxonomy_block_admin', 'access' => user_access('administer taxonomy blocks')); - $items[] = array('path' => 'admin/block/taxonomy_block/edit', 'title' => t('edit taxonomy block'), 'callback' => 'taxonomy_block_form', 'access' => user_access('administer taxonomy blocks'), 'type' => MENU_CALLBACK); + $items[] = array( + 'path' => 'admin/settings/taxonomy-block', + 'title' => t('Taxonomy Block'), + 'description' => t('Configure how taxonomy blocks are displayed.'), + 'callback' => 'taxonomy_block_admin', + 'access' => user_access('administer taxonomy blocks') + ); + $items[] = array( + 'path' => 'admin/settings/taxonomy-block/edit', + 'title' => t('edit Taxonomy Block'), + 'callback' => 'taxonomy_block_edit', + 'access' => user_access('administer taxonomy blocks'), + 'type' => MENU_CALLBACK + ); } return $items; @@ -53,15 +54,11 @@ function taxonomy_block_block($op = 'lis function taxonomy_block_admin($op = NULL, $bid = NULL) { switch ($op) { case 'delete' : - $form['bid'] = array( - '#type' => 'hidden', - '#value' => $bid, - ); - $output = confirm_form('taxonomy_block_delete_form', $form, t('Are you sure you want to delete the taxonomy block?'), 'admin/block/taxonomy_block'); + return drupal_get_form('taxonomy_block_delete_form', $bid); break; default: - $output = taxonomy_block_blocks(); - $output .= taxonomy_block_form(); + $output = drupal_get_form('taxonomy_block_blocks_form'); + $output .= drupal_get_form('taxonomy_block_form'); break; } @@ -70,6 +67,21 @@ function taxonomy_block_admin($op = NULL } /** + * Displays block delete confirmation form. + */ +function taxonomy_block_delete_form($bid){ + $form['bid'] = array( + '#type' => 'value', + '#value' => $bid, + ); + return confirm_form($form, + t('Are you sure you want to delete the taxonomy block?'), + 'admin/settings/taxonomy-block', t('This action cannot be undone.'), + t('Delete'), t('Cancel') ); +} + + +/** * Inserts a block into the database. */ function taxonomy_block_insert($edit) { @@ -97,6 +109,13 @@ function taxonomy_block_delete($bid) { /** * Displays the block creation form. */ +function taxonomy_block_edit($bid = NULL) { + return drupal_get_form('taxonomy_block_form', $bid); +} + +/** +* Generates the block creation form. +*/ function taxonomy_block_form($bid = NULL) { if ($bid) { $block = db_fetch_object(db_query('SELECT * FROM {taxonomy_block} WHERE bid = %d', $bid)); @@ -156,7 +175,7 @@ function taxonomy_block_form($bid = NULL ); } - return drupal_get_form('taxonomy_block_form', $form); + return $form; } /** @@ -177,7 +196,7 @@ function taxonomy_block_form_validate($f * taxonomy_block_form form execute callback function. */ function taxonomy_block_form_submit($form_id, $edit) { - $op = $_POST['op']; + $op = $edit['op']; if(substr($edit['tid'], 0, 1)=='v') { $edit['type'] = 'vocabulary'; @@ -193,24 +212,30 @@ function taxonomy_block_form_submit($for elseif($op == t('Edit Block')) { taxonomy_block_update($edit); } - drupal_goto('admin/block/taxonomy_block'); + return 'admin/settings/taxonomy-block'; } function taxonomy_block_delete_form_submit($form_id, $edit) { taxonomy_block_delete($edit['bid']); + cache_clear_all(); //Not sure if it is really needed - maybe it is too drastic! drupal_set_message(t('The block has been deleted.')); - drupal_goto('admin/block/taxonomy_block'); + return 'admin/settings/taxonomy-block'; + } /** * Displays a list of the blocks. */ -function taxonomy_block_blocks() { +function taxonomy_block_blocks_form() { $result = db_query('SELECT * FROM {taxonomy_block}'); while ($block = db_fetch_object($result)) { $links = array(); - $links[] = l(t('edit'), 'admin/block/taxonomy_block/edit/'. $block->bid, array('title'=>t('edit block')));; - $links[] = l(t('delete'), 'admin/block/taxonomy_block/delete/'. $block->bid, array('title'=>t('delete block')));; + $links['edit'] = array( + 'title'=>t('edit block'), + 'href' => 'admin/settings/taxonomy-block/edit/'. $block->bid); + $links['delete'] = array( + 'title'=>t('delete'), + 'href' => 'admin/settings/taxonomy-block/delete/'. $block->bid); $blocks[] = $block->description .' - '. theme('links', $links); } @@ -220,7 +245,7 @@ function taxonomy_block_blocks() { '#value' => theme('item_list', $blocks), ); - return drupal_get_form('taxonomy_block_admin', $form); + return $form; } /** @@ -319,4 +344,3 @@ function theme_taxonomy_block_list($item return $output; } -?>