Index: s5_book.module =================================================================== RCS file: /cvs/drupal/contributions/modules/s5/s5_book.module,v retrieving revision 1.4 diff -u -p -r1.4 s5_book.module --- s5_book.module 12 Jan 2008 11:33:24 -0000 1.4 +++ s5_book.module 29 Jul 2008 16:54:01 -0000 @@ -2,17 +2,24 @@ // $Id: s5_book.module,v 1.4 2008/01/12 11:33:24 greggles Exp $ /** - * Implementation of hook_help() + * Implementation of hook_help(). */ -function s5_book_help($section) { - switch ($section) { - case 'admin/modules#description': - return t('Play book pages as S5 presentations.'); +function s5_book_help($path, $arg) { + switch ($path) { + case 'admin/help#s5_book': + return t('This module allows you to play book pages as S5 presentations.' . + 'You will need to install S5 from !meyer. To configure the slide themes, ' . + 'visit the !config.', + array( + '!meyer' => l(t('MeyerWeb'),'http://meyerweb.com'), + '!config'=> l(t('S5 Book Settings'), '/admin/settings/s5_book'), + ) + ); } } /** - * Implementation of hook_link() + * Implementation of hook_link(). * Adds an s5 link to a fully displayed book page */ function s5_book_link($type, $node = NULL, $teaser = FALSE) { @@ -30,37 +37,36 @@ function s5_book_link($type, $node = NUL } /** - * Implementation of hook_menu() + * Implementation of hook_menu(). */ -function s5_book_menu($may_cache) { +function s5_book_menu() { $items = array(); - if ($may_cache) { - // plug into book module's book/export URL space - $items[] = array( - 'path' => 'book/export/s5', - 'title' => t('S5 presentation'), - 'access' => user_access('access content'), - 'type' => MENU_CALLBACK, - 'callback' => 's5_book_export' - ); - // add a tab to the outline editor to ease slide addition - $items[] = array( - 'path' => 'admin/node/book/add', - 'title' => t('add book page'), - 'access' => user_access('create book pages'), - 'type' => MENU_LOCAL_TASK, - 'callback' => 's5_book_page_add', - 'weight' => 200 - ); - $items[] = array( - 'path' => 'admin/settings/s5_book', - 'title' => t('S5 Book Settings'), - 'description' => t('Enables site settings for S5 Module.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => 's5_book_settings_form', - 'access' => user_access('administer site configuration'), - ); - } + // plug into book module's book/export URL space + $items['book/export/s5/%'] = array( + 'title' => t('S5 presentation'), + 'access callback' => 'user_access', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + 'page callback' => 's5_book_export', + 'page arguments' => array(3), + ); + // add a tab to the outline editor to ease slide addition + $items['admin/node/book/add'] = array( + 'title' => t('add book page'), + 'access callback' => 'user_access', + 'access arguments' => array('create book pages'), + 'type' => MENU_LOCAL_TASK, + 'page callback' => 's5_book_page_add', + 'weight' => 200 + ); + $items['admin/settings/s5_book'] = array( + 'title' => t('S5 Book Settings'), + 'description' => t('Enables site settings for S5 Module.'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('s5_book_settings_form'), + 'access callback' => 'user_access', + 'access arguments' => array('administer site configuration'), + ); return $items; } @@ -105,14 +111,22 @@ function s5_book_page_add() { } /** - * Export menu handler + * Exports the book as a slide show. */ function s5_book_export($nid = 0) { global $base_url; $nid = (int) $nid; - $depth = count(book_location($nid)) + 1; $node = node_load($nid); + + if (empty($node->book)) { + drupal_goto('node/'.$nid); + } + + // We need to load the book's navigation in order + // to export it. + $book_name = book_menu_name($node->book['bid']); + $book_menu = book_menu_subtree_data($node->book); // Template variables to fill into the file $variables = array( @@ -122,9 +136,11 @@ function s5_book_export($nid = 0) { 'company' => '', 'location' => '', 'presdate' => '', - 'slides' => book_recurse($nid, $depth, 's5_book_node_display', 's5_book_node_dumb'), + + // Recursively descend through the menu, building content: + 'slides' => book_export_traverse($book_menu, 's5_book_node_display'), ); - + // Try to match the node body for information on these details $searchfor = array("author", "company", "location", "presdate"); foreach ($searchfor as $class) { @@ -138,27 +154,43 @@ function s5_book_export($nid = 0) { } /** - * Book recursion function - * Flattens the book structure, immediately closing slides for every node + * Callback for formatting a slide. + * This function is expected to handle all the formatting on a node. + * @see book_export_traverse() */ -function s5_book_node_display($node, $depth, $nid) { - +function s5_book_node_display($node, $kids = '') { + // Let the content hook take action (taken from book.module) if (node_hook($node, 'content')) { $node = node_invoke($node, 'content'); } - + // Enclose slide in wrapper (you can have handout info on slide) if ($node->body) { - return '
'; + $text = '' . $kids; + return $text; } } /** * Just avoid running into the default node addendum */ -function s5_book_node_dumb($node, $depth) { } +//function s5_book_node_dumb($node, $depth) { } + +/** + * Implementation of hook_theme(). + */ +function s5_book_theme($existing, $type, $theme, $path) { + return array( + 's5_book_export' => array ('arguments' => array('variables' => array())), + ); +} /** * This is a very basic S5 template, using the default S5 theme, Index: s5_textfield.module =================================================================== RCS file: /cvs/drupal/contributions/modules/s5/s5_textfield.module,v retrieving revision 1.1 diff -u -p -r1.1 s5_textfield.module --- s5_textfield.module 12 Jan 2008 17:37:52 -0000 1.1 +++ s5_textfield.module 29 Jul 2008 16:54:02 -0000 @@ -4,15 +4,20 @@ /** * Implementation of hook_help() */ -function s5_textfield_help($section) { - switch ($section) { - case 'admin/modules#description': - return t('Play text fields broken by <!--pagebreak--> pages as S5 presentations.'); +function s5_textfield_help($path, $arg) { + switch ($path) { + case 'admin/help#s5_textfield': + return t( + 'Turn standard nodes into online presentations (slide shows). Write all of your ' . + 'slides into a textfield, separating slides by <!--pagebreak--> (and separating ' . + 'the title from the rest of the slide with <!--pagebreak--> comment). Make sure ' . + 'you !enable for the desired content types.', + array('!enable' => l(t('enable s5 slides'),'admin/settings/s5_textfield'))); } } /** - * Implementation of hook_link() + * Implementation of hook_link(). * Adds an s5 link to a fully displayed book page * */ @@ -24,7 +29,7 @@ function s5_textfield_link($type, $node 'title' => t('s5 slideshow'), 'href' => 'node/'. $node->nid .'/s5/', 'attributes' => array( - 'title' => t('View a slideshow of this book page and subpages.') + 'title' => t('View a slideshow of this page.') ) ); } @@ -35,32 +40,24 @@ function s5_textfield_link($type, $node * Implementation of hook_menu() * // TODO add the field name /body | field_textname at end of node/NID/s5/whatevs */ -function s5_textfield_menu($may_cache) { +function s5_textfield_menu() { $items = array(); - if ($may_cache) { - // plug into book module's book/export URL space - - $items[] = array( - 'path' => 'admin/settings/s5_textfield', - 'title' => t('S5 Textfield Settings'), - 'description' => t('Enables site settings for S5 Module.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => 's5_textfield_settings_form', - 'access' => user_access('administer site configuration'), - ); - } - else { - if (arg(0) == 'node' && is_numeric(arg(1))) { - // We don't specify an access check here so that it is inherited by the parent path (i.e. the node) - $items[] = array( - 'path' => 'node/'. arg(1) .'/s5', - 'title' => t('S5 presentation'), - 'type' => MENU_CALLBACK, - 'callback' => 's5_textfield_export', - 'callback arguments' => array(arg(1), arg(3)), - ); - } - } + $items['admin/settings/s5_textfield'] = array( + 'title' => t('S5 Textfield Settings'), + 'description' => t('Enables site settings for S5 Module.'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('s5_textfield_settings_form'), + 'access callback' => 'user_access', + 'access arguments' => array('administer site configuration'), + ); + $items['node/%/s5'] = array( + 'title' => t('S5 presentation'), + 'type' => MENU_CALLBACK, + 'page callback' => 's5_textfield_export', + 'page arguments' => array(1), + 'access callback' => 'node_access', + 'access arguments' => array('view', 1), + ); return $items; } @@ -79,7 +76,8 @@ function s5_textfield_settings_form() { $form['s5_textfield_theme'] = array( '#type' => 'select', '#title' => t('Display of S5 Exported Books'), - '#default_value' => variable_get('s5_textfield_theme', 'default'), + //'#default_value' => variable_get('s5_textfield_theme', 'default'), + '#default_value' => variable_get('s5_textfield_theme', 'faucet'), '#options' => drupal_map_assoc($themes), '#description' => t('Choose your theme from this list. You can also add more themes to S5.'), ); @@ -123,7 +121,6 @@ function s5_textfield_settings_form() { */ function s5_textfield_export($nid = 0, $field = 'body') { global $base_url; - watchdog('s5_textfield', $field); $nid = (int) $nid; $node = node_load($nid); @@ -166,8 +163,21 @@ function s5_textfield_export($nid = 0, $ theme('s5_textfield_export', $variables); } +/** + * Implementation of hook_theme(). + */ +function s5_textfield_theme($existing, $type, $theme, $path) { + return array( + 's5_textfield_export' => array ('arguments' => array('variables' => array())), + ); +} + +/** + * Implementation of hook_nodeapi(). + */ function s5_textfield_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { if ($op == 'view' || $op = 'load') { + // MPB: Untested for CCK in 6 if (isset($node->field_body[0]['view'])) { // support for CCK _s5_textfield_nodeapi($node, $node->field_body[0]['view'], @@ -175,6 +185,7 @@ function s5_textfield_nodeapi(&$node, $o $op, $teaser, $page); } else if (isset($node->field_body[0]['value'])) { // support for CCK + // MPB: Untested for CCK in 6 _s5_textfield_nodeapi($node, $node->field_body[0]['value'], $node->field_teaser[0]['value'], @@ -211,7 +222,7 @@ function _s5_textfield_nodeapi(&$node, & $slides .= ''; } else if (count($slide) == 1) { - $slides .= ''; + $slides .= ''; } else { $slides .= t('The empty slide. Weird - please file a bug explaining how you got here', array('!url' => url('http://drupal.org/node/add/project-issue/s5'))); @@ -235,7 +246,8 @@ function _s5_textfield_nodeapi(&$node, & function theme_s5_textfield_export($variables) { extract($variables); $path = drupal_get_path('module', 's5_textfield'); - $theme = variable_get('s5_textfield_theme', 'default'); + $theme = variable_get('s5_textfield_theme', 'faucet'); + //$slideString = implode('',$slides); echo <<