? headerimage.css Index: headerimage.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/headerimage/headerimage.module,v retrieving revision 1.21 diff -u -p -r1.21 headerimage.module --- headerimage.module 28 Jul 2008 09:30:46 -0000 1.21 +++ headerimage.module 24 Aug 2008 14:05:52 -0000 @@ -588,43 +588,53 @@ function headerimage_nodeapi(&$node, $op function headerimage_help($path, $arg) { switch ($path) { case 'admin/help#headerimage': - // Determine the status of the installation - $type_is_set = count(variable_get('headerimage_node_type', array())) ? t('(DONE)') : t('(TO DO)'); - $block_is_created = count(headerimage_get_blocks()) ? t('(DONE)') : t('(TO DO)'); + $output = "

". t('Header Image allows you to to display an image on selected pages. It can display one image at the front page, a different one at FAQ pages and yet another at all other pages. Visibility of each image, included in a node, can be determined by node ID, path, taxonomy, book, node type or custom PHP code. Header Image uses an arbitrary node type. Multiple images (nodes) can be displayed in one block, with each image having its own conditions. Using a weight per node the order of selection can be controlled.') ."

\n"; + $output .= "

". t('Configuration') ."

\n"; + + // Set up all configuration steps + $config['permissions'] = t('Set up permissions.', array('!permissions' => url('admin/user/permissions', array('fragment' => 'module-headerimage')))); + $config['node_type_set'] = t('Select a node type to be used as Header Image or create one if you haven\'t already.', array('!set_node_type' => url('admin/settings/headerimage/settings'), '!create_node_type' => url('admin/content/types/add'))); + $config['block_created'] = t('Create a Header Image block.', array('!create_header_image_block' => url('admin/settings/headerimage'))); + $config['block_has_nodes'] = t('Create Header Image nodes and set display conditions.'); + $config['block_assigned'] = t('Assign a Header Image block to a region.', array('!assign_header_image_block' => url('admin/build/block'))); + + // Determine the status of the Header Image configuration + drupal_add_css(drupal_get_path('module', 'headerimage') . '/headerimage.css'); + + // See if any one's got permission to view header images + $count = db_result(db_query("SELECT COUNT(perm) FROM {permission} WHERE perm LIKE '%view header image%'")); + $status['permissions'] = $count > 0 ? 'done' : 'todo'; + + // Has a node type been associated with Header Image? + $status['node_type_set'] = count(variable_get('headerimage_node_type', array())) ? 'done' : 'todo'; + + // Has any Header Image block yet been created. + $status['block_created'] = count(headerimage_get_blocks()) ? 'done' : 'todo'; + + // Have any image nodes been created? foreach (headerimage_get_blocks() as $delta => $name) { $block_has_nodes = db_result(db_query("SELECT nid FROM {headerimage} WHERE block = %d", $delta)); if ($block_has_nodes) break; } - $block_has_nodes = $block_has_nodes ? t('(DONE)') : t('(TO DO)'); + $status['block_has_nodes'] = $block_has_nodes ? 'done' : 'todo'; + + // Has a block been assigned to a region? foreach (headerimage_get_blocks() as $delta => $name) { $block_in_region = db_result(db_query("SELECT region FROM {blocks} WHERE module = '%s' AND theme = '%s' AND delta = %d", 'headerimage', variable_get('theme_default', 'garland'), $delta)); if ($block_in_region) break; } - $block_in_region = $block_in_region ? t('(DONE)') : t('(TO DO)'); + $status['block_assigned'] = $block_in_region ? 'done' : 'todo'; - $output = "

". t('Header Image allows you to to display an image on selected pages. It can display one image at the front page, a different one at FAQ pages and yet another at all other pages.') ."

\n"; - $output .= "

". t('Visibility of each image, included in a node, can be determined by node ID, path, taxonomy, book, node type or custom PHP code. Header Image uses an arbitrary node type.') ."

\n"; - $output .= "

". t('Multiple images (nodes) can be displayed in one block, with each image having its own conditions. Using a weight per node the order of selection can be controlled.') ."

\n"; - $output .= "

". t('Installation') ."

\n"; - $output .= "

". t('

    -
  1. Set up permissions.
  2. -
  3. Optionally create a node type which will contain the header image.
  4. -
  5. Select a node type to be used as Header Image. %status_type
  6. -
  7. Create a Header Image block. %status_create
  8. -
  9. Create Header Image nodes. Select a Header Image block and set display conditions for each node. %status_assign
  10. -
  11. Assign the Header Image block to a region. %status_region
  12. -
', array( - '!permissions' => url('admin/user/permissions'), - '!create_node_type' => url('admin/content/types/add'), - '!set_node_type' => url('admin/settings/headerimage/settings'), - '%status_type' => $type_is_set, - '!create_header_image_block' => url('admin/settings/headerimage'), - '%status_create' => $block_is_created, - '!assign_header_image_block' => url('admin/build/block'), - '%status_assign' => $block_has_nodes, - '%status_region' => $block_in_region, - ) -) ."

\n"; + // Build configuration status output. + $items = array(); + foreach ($config as $key => $message) { + $items[] = array( + 'data' => theme('headerimage_config_image', $status[$key]) . $message, + 'class' => is_null($status[$key]) ? NULL : 'configuration-'. $status[$key] , + ); + } + $output .= theme_item_list($items, NULL, 'ul', array('id' => 'headerimage-config')); + $output .= "

". t('For more information please read the configuration and customization handbook on Header Image.', array('@handbook' => 'http://drupal.org/node/201426/')) ."

\n"; return $output; } @@ -676,6 +686,9 @@ function headerimage_theme() { 'template' => 'headerimage-block', 'arguments' => array('node' => NULL, 'teaser' => NULL), ), + 'headerimage_config_image' => array( + 'arguments' => array('status' => NULL), + ), ); } @@ -700,3 +713,20 @@ function template_preprocess_headerimage $variables['content'] = $node->body; } } + +/** + * Format configuration status icon. + * + * @param $status Status of configuration step: done, todo + */ +function theme_headerimage_config_image($status) { + switch ($status) { + case 'done': + $output = ''; + break; + case 'todo': + $output = theme_image('misc/watchdog-warning.png', $status, t('Configuration step not completed.')); + break; + } + return $output; +}