Index: webcomic.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webcomic/webcomic.install,v retrieving revision 1.6 diff -u -r1.6 webcomic.install --- webcomic.install 18 Apr 2006 21:05:55 -0000 1.6 +++ webcomic.install 4 Dec 2007 11:16:12 -0000 @@ -1,33 +1,59 @@ "views_handler_arg_webcomic_parent", ), ); + return $arguments; } -function views_handler_arg_webcomic_parent($op, & $query, $argtype, $arg = '') { - switch ($op) - { +function views_handler_arg_webcomic_parent($op, &$query, $arg_type, $arg = '') { + switch ($op) { case 'summary' : $query->ensure_table("webcomic_parent_node"); $query->add_field("nid"); @@ -148,11 +149,11 @@ $query->add_field("title", "webcomic_parent_node"); $query->add_field("nid", "webcomic_parent_node", "pnid"); $query->add_where("webcomic_parent_node.nid IS NOT NULL"); - $fieldinfo['field'] = "webcomic_parent_node.title"; - return $fieldinfo; + $field_info['field'] = "webcomic_parent_node.title"; + return $field_info; break; case 'sort': - $query->add_orderby('webcomic_parent_node', 'title', $argtype); + $query->add_orderby('webcomic_parent_node', 'title', $arg_type); break; case 'filter' : $query->ensure_table("webcomic_parent"); @@ -161,8 +162,7 @@ case 'link' : return l($query->title, "$arg/$query->pnid"); case 'title' : - if ($query) - { + if ($query) { $term = db_fetch_object(db_query("SELECT title FROM {node} WHERE nid = '%d'", $query)); return $term->title; } @@ -172,11 +172,11 @@ /* * Format a field as a link to the webcomic parent node */ -function views_handler_field_webcomic_parent_title($fieldinfo, $fielddata, $value, $data) { +function views_handler_field_webcomic_parent_title($field_info, $field_data, $value, $data) { return l($value, "node/$data->webcomic_parent_node_nid"); } -function views_handler_field_webcomic_parent_title_nl($fieldinfo, $fielddata, $value, $data) { +function views_handler_field_webcomic_parent_title_nl($field_info, $field_data, $value, $data) { return check_plain($value); } @@ -186,6 +186,7 @@ while ($obj = db_fetch_object($result)) { $parents[$obj->parent_nid] = "$obj->parent_nid"; } + return $parents; } @@ -193,17 +194,17 @@ /** * Format a date as "X time ago/until". */ -function webcomic_views_handler_field_diff($fieldinfo, $fielddata, $value, $data) { +function webcomic_views_handler_field_diff($field_info, $field_data, $value, $data) { if ($value == 0) { return ''; } $current = time(); if ($current > $value) { - return format_interval($current - $value) . ' ago'; + return format_interval($current - $value) .' ago'; } else { - return format_interval($value - $current) . ' from now'; + return format_interval($value - $current) .' from now'; } } @@ -211,8 +212,7 @@ $view = new stdClass(); $view->name = 'strip_archive'; $view->description = 'Strips in a simple list'; - $view->access = array ( - ); + $view->access = array (); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = ''; @@ -234,8 +234,7 @@ 'options' => '', ), ); - $view->argument = array ( - ); + $view->argument = array (); $view->field = array ( array ( 'tablename' => 'node', @@ -250,9 +249,7 @@ 'field' => 'type', 'operator' => 'OR', 'options' => '', - 'value' => array ( - 0 => 'webcomic_strip', - ), + 'value' => array (0 => 'webcomic_strip',), ), array ( 'tablename' => 'node', @@ -268,8 +265,7 @@ $view = new stdClass(); $view->name = 'latest'; $view->description = 'latest webcomic'; - $view->access = array ( -); + $view->access = array (); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = 'Latest comic'; @@ -305,10 +301,8 @@ 'options' => '', ), ); - $view->argument = array ( - ); - $view->field = array ( - ); + $view->argument = array (); + $view->field = array (); $view->filter = array ( array ( 'tablename' => 'node', @@ -322,9 +316,7 @@ 'field' => 'type', 'operator' => 'OR', 'options' => '', - 'value' => array ( - 0 => 'webcomic_strip', -), + 'value' => array (0 => 'webcomic_strip',), ), ); $view->requires = array(webcomic_content, node); @@ -333,8 +325,7 @@ $view = new stdClass(); $view->name = 'cast'; $view->description = 'shows all the characters in a webcomic'; - $view->access = array ( -); + $view->access = array (); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = 'Cast of characters'; @@ -356,10 +347,8 @@ 'options' => '', ), ); - $view->argument = array ( - ); - $view->field = array ( - ); + $view->argument = array (); + $view->field = array (); $view->filter = array ( array ( 'tablename' => 'node', @@ -373,13 +362,11 @@ 'field' => 'type', 'operator' => 'OR', 'options' => '', - 'value' => array ( - 0 => 'webcomic_character', -), + 'value' => array (0 => 'webcomic_character',), ), ); $view->requires = array(node); $views[$view->name] = $view; return $views; -} \ No newline at end of file +} Index: webcomic.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webcomic/webcomic.module,v retrieving revision 1.10 diff -u -r1.10 webcomic.module --- webcomic.module 20 Apr 2006 07:23:48 -0000 1.10 +++ webcomic.module 4 Dec 2007 11:16:13 -0000 @@ -1,98 +1,95 @@ '. t('Provides content types and tools for managing a webcomic.') .'

'; } } /** - * Implementation of hook_node_info + * Implementation of hook_node_info(). */ function webcomic_node_info() { return array( - 'webcomic_strip' => array('name' => t('strip'), 'base' => 'webcomic_content'), - 'webcomic_character' => array('name' => t('character bio'), 'base' => 'webcomic_character'), - 'webcomic_episode' => array('name' => t('episode'), 'base' => 'webcomic_content'), - 'webcomic_storyline' => array('name' => t('storyline'), 'base' => 'webcomic_content'), + 'webcomic_strip' => array( + 'name' => t('Strip'), + 'module' => 'webcomic', + 'description' => t('A single comic strip image.'), + ), + 'webcomic_character' => array( + 'name' => t('Character bio'), + 'module' => 'webcomic', + 'description' => t('A biography for a comic character.'), + ), + 'webcomic_episode' => array( + 'name' => t('Episode'), + 'module' => 'webcomic', + 'description' => t('A comic episode containing multiple strips (for example, an issue of a graphic novel).'), + ), + 'webcomic_storyline' => array( + 'name' => t('Storyline'), + 'module' => 'webcomic', + 'description' => t('A comic storyline containing one or more episodes.'), + ), ); } /** - * Implementation of hook_perm + * Implementation of hook_perm(). */ function webcomic_perm() { - return array( - 'administer webcomic system', - ); -} - -/** - * Implementation of hook_access - */ -function webcomic_content_access($op, $node) { - global $user; - if (user_access('administer comic system')) { - return TRUE; - } + return array('administer webcomic'); } /** - * Implementation of hook_access + * Implementation of hook_access(). */ -function webcomic_character_access($op, $node) { +function webcomic_access($op, $node) { global $user; - if (user_access('administer comic system')) { + if (user_access('administer webcomic')) { return TRUE; } } /** - * Implementation of hook_menu + * Implementation of hook_menu(). */ function webcomic_menu($may_cache) { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'node/add/webcomic_strip', 'title' => t('strip'), - 'type' => MENU_NORMAL_ITEM); - $items[] = array( - 'path' => 'node/add/webcomic_episode', 'title' => t('episode'), - 'type' => MENU_NORMAL_ITEM); - $items[] = array( - 'path' => 'node/add/webcomic_storyline', 'title' => t('storyline'), - 'type' => MENU_NORMAL_ITEM); - $items[] = array( - 'path' => 'node/add/webcomic_character', 'title' => t('character'), - 'type' => MENU_NORMAL_ITEM); + $items[] = array( + 'path' => 'admin/settings/webcomic', + 'title' => t('Webcomic'), + 'description' => t('Webcomic settings.'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('webcomic_admin_settings'), + 'access' => user_access('administer site configuration') || user_access('administer webcomic'), + 'type' => MENU_NORMAL_ITEM, + ); } + return $items; } - /** - * Implementation of hook_settings + * Menu callback; Webcomic administration page */ -function webcomic_settings() { +function webcomic_admin_settings() { $form['webcomic_discussions'] = array( '#type' => 'radios', '#title' => t('Discussions'), @@ -138,7 +135,6 @@ '#type' => 'fieldset', '#title' => t('Archive settings') ); - $form['archive']['webcomic_archive_mode'] = array( '#type' => 'radios', '#title' => t('Archive organization'), @@ -155,7 +151,6 @@ ), '#description' => t('How should your webcomic\'s archive be organized?'), ); - $form['archive']['webcomic_archive_view'] = array( '#type' => 'radios', '#title' => t('Archive presentation'), @@ -167,50 +162,63 @@ ), '#description' => t('How should each item in your archive be displayed?'), ); - return $form; + + return system_settings_form($form); } -function webcomic_character_form($node) { - $form['title'] = array('#type' => 'textfield', +function _webcomic_character_form($node) { + $form['title'] = array( + '#type' => 'textfield', '#title' => t('Name'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5, ); - $form['body_filter']['body'] = array('#type' => 'textarea', + $form['body_filter']['body'] = array( + '#type' => 'textarea', '#title' => t('Character bio'), '#default_value' => $node->body, '#rows' => 10, '#required' => TRUE, ); + $form['body_filter']['format'] = filter_form($node->format); return $form; } -function webcomic_content_form($node) { - $form['title'] = array('#type' => 'textfield', +function _webcomic_content_form($node) { + $form['title'] = array( + '#type' => 'textfield', '#title' => t('Title'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5, ); - $form['#attributes'] = array("enctype" => "multipart/form-data"); - $sizes = _image_get_sizes(); - $form['images']['#tree'] = TRUE; - $form['images']['_original'] = array('#type' => 'hidden', '#value' => $form['images']['_original']); - foreach ($sizes as $size) { - if ($node->new_file) { - $form['images'][$size['label']] = array('#type' => 'hidden', '#value' => $node->images[$size['label']]); - } - else { - $form['images'][$size['label']] = array('#type' => 'hidden', '#default_value' => $node->images[$size['label']]); - } - } - - $form['thumbnail']['#after_build'] = array('webcomic_form_add_thumbnail'); +// $form['#attributes'] = array("enctype" => "multipart/form-data"); +// $form['images']['#tree'] = TRUE; +// $form['images']['_original'] = array( +// '#type' => 'hidden', +// '#value' => $form['images']['_original'] +// ); +// $sizes = _image_get_sizes(); +// foreach ($sizes as $size) { +// if ($node->new_file) { +// $form['images'][$size['label']] = array( +// '#type' => 'hidden', +// '#value' => $node->images[$size['label']] +// ); +// } +// else { +// $form['images'][$size['label']] = array( +// '#type' => 'hidden', +// '#default_value' => $node->images[$size['label']] +// ); +// } +// } +// $form['thumbnail']['#after_build'][] = array('webcomic_form_add_thumbnail'); $form['image'] = array( '#type' => 'file', '#title' => t('Image'), @@ -231,7 +239,8 @@ break; } if (count($parent_list) > 1) { - $form['parent_nid'] = array('#type' => 'select', + $form['parent_nid'] = array( + '#type' => 'select', '#title' => $parent_title, '#default_value' => $node->parent_nid, '#options' => $parent_list, @@ -246,7 +255,7 @@ '#maxlength' => 25, '#weight' => 6, '#default_value' => $node->publish_date, - '#description' => t('Used to delay publishing of content. Leave blank for normal behavior. Format: %time. ', array('%time' => $node->date)), + '#description' => t('Used to delay publishing of content. Leave blank for normal behavior. Format: !time. ', array('!time' => $node->date)), ); $form['storyline_date'] = array( @@ -255,7 +264,7 @@ '#maxlength' => 25, '#weight' => 7, '#default_value' => $node->storyline_date, - '#description' => t('Used to organize webcomic content that follows a custom timeline, or when strips are posted out of order. Format: %time. ', array('%time' => $node->date)), + '#description' => t('Used to organize webcomic content that follows a custom timeline, or when strips are posted out of order. Format: !time. ', array('!time' => $node->date)), ); switch ($node->type) { @@ -294,58 +303,74 @@ } } - $form['body_filter']['body'] = array('#type' => 'textarea', + $form['body_filter']['body'] = array( + '#type' => 'textarea', '#title' => t('Description'), '#default_value' => $node->body, '#rows' => 10, '#required' => FALSE, ); + $form['body_filter']['format'] = filter_form($node->format); return $form; } /** -* Moved this over directly from image so I could change the weight. -*/ -function webcomic_form_add_thumbnail($form_id, $edit) { - if ($edit['images']['thumbnail']) { - $node = (object)($edit); - $form = array( - '#type' => 'item', - '#title' => t('Thumbnail'), - '#value' => image_display($node, 'thumbnail'), - '#weight' => 2, - ); + * Implementation of hook_form(). + */ +function webcomic_form($node) { + if ($node->type == 'webcomic_character') { + return _webcomic_character_form($node); } - return $form; + + return _webcomic_content_form($node); } /** +* Moved this over directly from image so I could change the weight. +*/ +//function webcomic_form_add_thumbnail($form_id, $edit) { +// if ($edit['images']['thumbnail']) { +// $node = (object)($edit); +// $form = array( +// '#type' => 'item', +// '#title' => t('Thumbnail'), +// '#value' => image_display($node, 'thumbnail'), +// '#weight' => 2, +// ); +// } +// +// return $form; +//} + +/** * Implementation of hook_load(). */ -function webcomic_content_load(&$node) { - // basic webcomic data - $content = db_fetch_object(db_query('SELECT * FROM {webcomic_content} WHERE nid = %d', $node->nid)); - if ($content->publish_timestamp != 0) { - $content->publish_date = format_date($content->publish_timestamp, 'custom', 'Y-m-d H:i:s O'); - } - if ($content->storyline_timestamp != 0) { - $content->storyline_date = format_date($content->storyline_timestamp, 'custom', 'Y-m-d H:i:s O'); - } - - // image loading - image_load($node); - - // parent relationships - $parent = db_fetch_object(db_query('SELECT * FROM {webcomic_parent} WHERE child_nid = %d', $node->nid)); - $content->parent_nid = $parent->parent_nid; - - // character associations - if ($node->type == 'webcomic_strip') { - $result = db_query('SELECT * FROM {webcomic_strip_character} WHERE strip_nid = %d', $nid); - while ($strip_char = db_fetch_object($result)) { - $content->characters[] = $strip_char->character_nid; +function webcomic_load(&$node) { + if ($node->type == 'webcomic_storyline' || $node->type == 'webcomic_episode' || $node->type == 'webcomic_strip') { + // basic webcomic data + $content = db_fetch_object(db_query('SELECT * FROM {webcomic_content} WHERE nid = %d', $node->nid)); + if ($content->publish_timestamp != 0) { + $content->publish_date = format_date($content->publish_timestamp, 'custom', 'Y-m-d H:i:s O'); + } + if ($content->storyline_timestamp != 0) { + $content->storyline_date = format_date($content->storyline_timestamp, 'custom', 'Y-m-d H:i:s O'); + } + + // image loading + image_load($node); + + // parent relationships + $parent = db_fetch_object(db_query('SELECT * FROM {webcomic_parent} WHERE child_nid = %d', $node->nid)); + $content->parent_nid = $parent->parent_nid; + + // character associations + if ($node->type == 'webcomic_strip') { + $result = db_query('SELECT * FROM {webcomic_strip_character} WHERE strip_nid = %d', $node->nid); + while ($strip_char = db_fetch_object($result)) { + $content->characters[] = $strip_char->character_nid; + } } } @@ -355,20 +380,22 @@ /** * Implementation of hook_insert(). */ -function webcomic_content_insert($node) { - db_query("INSERT INTO {webcomic_content} (nid, publish_timestamp, storyline_timestamp, weight, sequence) VALUES (%d, %d, %d, %d, '%s')", $node->nid, $node->publish_timestamp, $node->storyline_timestamp, $node->weight, $node->sequence); - if (isset($node->parent_nid)) { - db_query("INSERT INTO {webcomic_parent} (child_nid, parent_nid) VALUES (%d, %d)", $node->nid, $node->parent_nid); - } - if (function_exists('image_prepare') && function_exists('image_insert')) { - image_prepare($node, 'image'); - if($node->images['_original'] != '') { - image_insert($node); - } - } - if ($node->type == 'webcomic_strip' && is_array($node->characters)) { - foreach($node->characters as $char_nid) { - db_query("INSERT INTO {webcomic_strip_character} (strip_nid, character_nid) VALUES (%d, %d)", $node->nid, $char_nid); +function webcomic_insert($node) { + if ($node->type == 'webcomic_storyline' || $node->type == 'webcomic_episode' || $node->type == 'webcomic_strip') { + db_query("INSERT INTO {webcomic_content} (nid, publish_timestamp, storyline_timestamp, weight, sequence) VALUES (%d, %d, %d, %d, '%s')", $node->nid, $node->publish_timestamp, $node->storyline_timestamp, $node->weight, $node->sequence); + if (isset($node->parent_nid)) { + db_query("INSERT INTO {webcomic_parent} (child_nid, parent_nid) VALUES (%d, %d)", $node->nid, $node->parent_nid); + } + if (function_exists('image_prepare') && function_exists('image_insert')) { + image_prepare($node, 'image'); + if($node->images['_original'] != '') { + image_insert($node); + } + } + if ($node->type == 'webcomic_strip' && is_array($node->characters)) { + foreach($node->characters as $char_nid) { + db_query("INSERT INTO {webcomic_strip_character} (strip_nid, character_nid) VALUES (%d, %d)", $node->nid, $char_nid); + } } } } @@ -376,25 +403,28 @@ /** * Implementation of hook_update(). */ -function webcomic_content_update($node) { - db_query("UPDATE {webcomic_content} SET publish_timestamp = %d, storyline_timestamp = %d, weight = %d, sequence = '%s' WHERE nid = %d", $node->publish_timestamp, $node->storyline_timestamp, $node->weight, $node->sequence, $node->nid); - db_query("DELETE FROM {webcomic_parent} WHERE child_nid = %d", $node->nid); - db_query("DELETE FROM {webcomic_strip_character} WHERE strip_nid = %d", $node->nid); +function webcomic_update($node) { + if ($node->type == 'webcomic_storyline' || $node->type == 'webcomic_episode' || $node->type == 'webcomic_strip') { + db_query("UPDATE {webcomic_content} SET publish_timestamp = %d, storyline_timestamp = %d, weight = %d, sequence = '%s' WHERE nid = %d", $node->publish_timestamp, $node->storyline_timestamp, $node->weight, $node->sequence, $node->nid); + db_query("DELETE FROM {webcomic_parent} WHERE child_nid = %d", $node->nid); + db_query("DELETE FROM {webcomic_strip_character} WHERE strip_nid = %d", $node->nid); - if (isset($node->parent_nid)) { - db_query("INSERT INTO {webcomic_parent} (child_nid, parent_nid) VALUES (%d, %d)", $node->nid, $node->parent_nid); - } - if ($node->type == 'webcomic_strip' && is_array($node->characters)) { - foreach($node->characters as $char_nid) { - db_query("INSERT INTO {webcomic_strip_character} (strip_nid, character_nid) VALUES (%d, %d)", $node->nid, $char_nid); + if (isset($node->parent_nid)) { + db_query("INSERT INTO {webcomic_parent} (child_nid, parent_nid) VALUES (%d, %d)", $node->nid, $node->parent_nid); + } + + if ($node->type == 'webcomic_strip' && is_array($node->characters)) { + foreach($node->characters as $char_nid) { + db_query("INSERT INTO {webcomic_strip_character} (strip_nid, character_nid) VALUES (%d, %d)", $node->nid, $char_nid); + } } - } - if (function_exists('image_prepare') && function_exists('image_update')) { - image_prepare($node, 'image'); - //print_r($node, FALSE); - if($node->images[_original] != '') { - image_update($node); + if (function_exists('image_prepare') && function_exists('image_update')) { + image_prepare($node, 'image'); + //print_r($node, FALSE); + if($node->images[_original] != '') { + image_update($node); + } } } } @@ -402,42 +432,45 @@ /** * Implementation of hook_delete(). */ -function webcomic_content_delete(&$node) { - db_query('DELETE FROM {webcomic_content} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {webcomic_parent} WHERE child_nid = %d OR parent_nid = %d', $node->nid, $node->nid); - db_query('DELETE FROM {webcomic_strip_character} WHERE strip_nid = %d', $node->nid); - - foreach ($node->images as $label => $image) { - file_delete(file_create_path($image)); - db_query("DELETE FROM {files} WHERE filename='%s' AND nid=%d", $label, $node->nid); +function webcomic_delete(&$node) { + if ($node->type == 'webcomic_character') { + db_query('DELETE FROM {webcomic_strip_character} WHERE character_nid = %d', $node->nid); + } else { + db_query('DELETE FROM {webcomic_content} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {webcomic_parent} WHERE child_nid = %d OR parent_nid = %d', $node->nid, $node->nid); + db_query('DELETE FROM {webcomic_strip_character} WHERE strip_nid = %d', $node->nid); + + foreach ($node->images as $label => $image) { + file_delete(file_create_path($image)); + db_query("DELETE FROM {files} WHERE filename='%s' AND nid=%d", $label, $node->nid); + } } } -function webcomic_character_delete(&$node) { - db_query('DELETE FROM {webcomic_strip_character} WHERE character_nid = %d', $node->nid); -} - /** * Implementation of hook_submit(). */ -function webcomic_content_submit(&$node) { - // If a publish date has been set, and is in the future, override the publish flag - // otherwise, set the publish date to the created date - if ($node->publish_date != '') { - $node->publish_timestamp = strtotime($node->publish_date); - if ($node->publish_timestamp > time()) { - // unpublish the node. It shouldn't be visible! - $node->status = 0; +function webcomic_submit(&$node) { + if ($node->type == 'webcomic_storyline' || $node->type == 'webcomic_episode' || $node->type == 'webcomic_strip') { + // If a publish date has been set, and is in the future, override the publish flag + // otherwise, set the publish date to the created date + if ($node->publish_date != '') { + $node->publish_timestamp = strtotime($node->publish_date); + if ($node->publish_timestamp > time()) { + // Unpublish the node. It shouldn't be visible! + $node->status = 0; + } + } + else { + $node->publish_timestamp = $node->created; + } + + if ($node->storyline_date != '') { + $node->storyline_timestamp = strtotime($node->storyline_timestamp); } - } - else { - $node->publish_timestamp = $node->created; - } - if ($node->storyline_date != '') { - $node->storyline_timestamp = strtotime($node->storyline_timestamp); - } - $node->sequence = _webcomic_generate_sequence($node); + $node->sequence = _webcomic_generate_sequence($node); + } } function _webcomic_list_type($type = NULL) { @@ -457,6 +490,7 @@ } $items[$key] = $value; } + return $items; } @@ -473,6 +507,7 @@ } $chars[$key] = $value; } + return $chars; } @@ -500,6 +535,7 @@ if ($node->parent_nid) { $seq = _webcomic_get_sequence(node_load($node->parent_nid)) . $seq; } + return $seq; } @@ -520,7 +556,9 @@ } /** - * Implements hook_cron. (auto-publishes content) + * Implementation of hook_cron(). + * + * Auto-publishes content. */ function webcomic_cron() { $result = db_query('SELECT wcc.nid FROM {webcomic_content} wcc INNER JOIN {node} n ON wcc.nid = n.nid WHERE n.status = 0 AND wcc.publish_timestamp <= %d', time()); @@ -528,39 +566,46 @@ $node = node_load($tmp->nid); $node->status = 1; node_save($node); - watchdog('webcomic', $node->title . ' published.'); + + watchdog('webcomic', $node->title .' published.'); } } /** - * Implementation of hook_view + * Implementation of hook_view(). */ -function webcomic_content_view(&$node, $teaser = 0, $page = 0) { +function webcomic_view(&$node, $teaser = FALSE, $page = FALSE) { + drupal_add_css(drupal_get_path('module', 'webcomic') .'/webcomic.css'); if ($page && $node->parent_nid) { $episode = node_load($node->parent_nid); $breadcrumb = array(); - $breadcrumb[] = array('path' => 'node/'.$episode->nid, 'title' => $episode->title); + $breadcrumb[] = array('path' => 'node/'. $episode->nid, 'title' => $episode->title); if ($episode->parent_nid) { $storyline = node_load($episode->parent_nid); $breadcrumb[] = array('path' => 'node/'. $storyline->nid, 'title' => $storyline->title); } + menu_set_location($breadcrumb); } $node = node_prepare($node, $teaser); - $node->teaser = theme('webcomic_teaser', $node); + $nav = theme('webcomic_navigation', $node); - $node->body = $nav . theme('webcomic_body', $node, 'preview') . $nav; + + $node->content['teaser']['#value'] = theme('webcomic_teaser', $node); + $node->content['body']['#value'] = $nav; + $node->content['body']['#value'] .= theme('webcomic_body', $node, 'preview'); + $node->content['body']['#value'] .= $nav; + + return $node; } - - - function webcomic_update_sequences() { $result = db_query('SELECT nid FROM {webcomic_content}'); while ($nid = db_fetch_object($result)) { $node = node_load($nid->nid); $node->sequence = _webcomic_generate_sequence($node); + node_save($node); } } @@ -568,109 +613,114 @@ function webcomic_first($node) { switch (variable_get('webcomic_browsing_style', 'all_images')) { case 'like_kinds': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; case 'all_images': break; case 'episode_index': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; case 'story_index': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; } $sql = "SELECT n.nid, n.title, wcc.sequence FROM {node} n"; $sql .= " INNER JOIN {webcomic_content} wcc ON n.nid = wcc.nid"; - $sql .= " WHERE n.status = 1 AND n.moderate = 0 " . $where; + $sql .= " WHERE n.status = 1 AND n.moderate = 0 ". $where; $sql .= " ORDER BY wcc.sequence ASC, n.title ASC LIMIT 1"; $result = db_query($sql, $node->nid); $first = db_fetch_object($result); + if ($first->nid != $node->nid) { return $first; - }} + } +} function webcomic_prev($node) { switch (variable_get('webcomic_browsing_style', 'all_images')) { case 'like_kinds': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; case 'all_images': break; case 'episode_index': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; case 'story_index': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; } $sql = "SELECT n.nid, n.title, wcc.sequence FROM {node} n"; $sql .= " INNER JOIN {webcomic_content} wcc ON n.nid = wcc.nid"; - $sql .= " WHERE n.status = 1 AND n.moderate = 0 " . $where; + $sql .= " WHERE n.status = 1 AND n.moderate = 0 ". $where; $sql .= " AND (wcc.sequence < '%s' OR (wcc.sequence = '%s' AND n.title < '%s')) "; $sql .= " ORDER BY wcc.sequence DESC, n.title DESC LIMIT 1"; $result = db_query($sql, $node->sequence, $node->sequence, $node->title); $prev = db_fetch_object($result); + return $prev; } function webcomic_next($node) { switch (variable_get('webcomic_browsing_style', 'all_images')) { case 'like_kinds': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; case 'all_images': break; case 'episode_index': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; case 'story_index': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; } $sql = "SELECT n.nid, n.title, wcc.sequence FROM {node} n"; $sql .= " INNER JOIN {webcomic_content} wcc ON n.nid = wcc.nid"; - $sql .= " WHERE n.status = 1 AND n.moderate = 0 " . $where; + $sql .= " WHERE n.status = 1 AND n.moderate = 0 ". $where; $sql .= " AND (wcc.sequence > '%s' OR (wcc.sequence = '%s' AND n.title > '%s'))"; $sql .= " ORDER BY wcc.sequence ASC, n.title ASC LIMIT 1"; $result = db_query($sql, $node->sequence, $node->sequence, $node->title); $next = db_fetch_object($result); + return $next; } function webcomic_last($node) { switch (variable_get('webcomic_browsing_style', 'all_images')) { case 'like_kinds': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; case 'all_images': break; case 'episode_index': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; case 'story_index': - $where = " AND n.type = '" . $node->type . "'"; + $where = " AND n.type = '". $node->type ."'"; break; } $sql = "SELECT n.nid, n.title, wcc.sequence FROM {node} n"; $sql .= " INNER JOIN {webcomic_content} wcc ON n.nid = wcc.nid"; - $sql .= " WHERE n.status = 1 AND n.moderate = 0 " . $where; + $sql .= " WHERE n.status = 1 AND n.moderate = 0 ". $where; $sql .= " ORDER BY wcc.sequence DESC, n.title DESC LIMIT 1"; $result = db_query($sql, $node->nid); $last = db_fetch_object($result); + if ($last->nid != $node->nid) { return $last; } } -// this should be modified to return the proper URL for the current +// This should be modified to return the proper URL for the current function webcomic_index() { switch (variable_get('webcomic_archive_mode', 'strips_month')) { case 'strips': Index: webcomic_theme.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webcomic/webcomic_theme.inc,v retrieving revision 1.2 diff -u -r1.2 webcomic_theme.inc --- webcomic_theme.inc 19 Apr 2006 16:32:21 -0000 1.2 +++ webcomic_theme.inc 4 Dec 2007 11:16:13 -0000 @@ -1,9 +1,15 @@ nid, array(), NULL, NULL, FALSE, TRUE) . $node->teaser; @@ -11,6 +17,8 @@ /** * Theme a body + * + * @ingroup themeable */ function theme_webcomic_body($node, $size) { return image_display($node, $size) . $node->body; @@ -23,69 +31,93 @@ * @ingroup themeable */ function theme_webcomic_navigation($node) { - $output = ''; - if ($node->nid) { - $links .= theme('webcomic_first_link', $node); - $links .= theme('webcomic_prev_link', $node); - $links .= theme('webcomic_index_link', $node); - $links .= theme('webcomic_next_link', $node); - $links .= theme('webcomic_last_link', $node); - - $output = '
' . $links . '
'; - } + $output = '
'; + $output .= theme('webcomic_first_link', $node); + $output .= theme('webcomic_prev_link', $node); + $output .= theme('webcomic_index_link', $node); + $output .= theme('webcomic_next_link', $node); + $output .= theme('webcomic_last_link', $node); + $output .= '
'; return $output; } + +/** + * Theme first link + * + * @ingroup themeable + */ function theme_webcomic_first_link($node) { if ($first = webcomic_first($node)) { - $path = '/' . drupal_get_path('module', 'webcomic') . '/img/go-first.png'; + $path = drupal_get_path('module', 'webcomic') .'/img/go-first.png'; drupal_add_link(array('rel' => 'first', 'href' => url('node/'. $first->nid))); - return l('', 'node/'. $first->nid, array('class' => 'page-first', 'title' => $first->title), NULL, NULL, FALSE, TRUE); + return l('', 'node/'. $first->nid, array('class' => 'page-first', 'title' => $first->title), NULL, NULL, FALSE, TRUE); } else { - $path = '/' . drupal_get_path('module', 'webcomic') . '/img/go-first-dim.png'; - return ''; + $path = drupal_get_path('module', 'webcomic') .'/img/go-first-dim.png'; + return ''; } } +/** + * Theme prev link + * + * @ingroup themeable + */ function theme_webcomic_prev_link($node) { if ($prev = webcomic_prev($node)) { - $path = '/' . drupal_get_path('module', 'webcomic') . '/img/go-previous.png'; + $path = drupal_get_path('module', 'webcomic') .'/img/go-previous.png'; drupal_add_link(array('rel' => 'prev', 'href' => url('node/'. $prev->nid))); - return l('', 'node/'. $prev->nid, array('class' => 'page-prev', 'title' => $prev->title), NULL, NULL, FALSE, TRUE); + return l('', 'node/'. $prev->nid, array('class' => 'page-prev', 'title' => $prev->title), NULL, NULL, FALSE, TRUE); } else { - $path = '/' . drupal_get_path('module', 'webcomic') . '/img/go-previous-dim.png'; - return ''; + $path = drupal_get_path('module', 'webcomic') .'/img/go-previous-dim.png'; + return ''; } } +/** + * Theme index link + * + * @ingroup themeable + */ function theme_webcomic_index_link($node) { - $path = '/' . drupal_get_path('module', 'webcomic') . '/img/go-up.png'; + $path = drupal_get_path('module', 'webcomic') .'/img/go-up.png'; drupal_add_link(array('rel' => 'index', 'href' => webcomic_index())); - return l('', webcomic_index(), array('class' => 'page-up', 'title' => t('Go to index page')), NULL, NULL, FALSE, TRUE); + + return l('', webcomic_index(), array('class' => 'page-up', 'title' => t('Go to index page')), NULL, NULL, FALSE, TRUE); } +/** + * Theme next link + * + * @ingroup themeable + */ function theme_webcomic_next_link($node) { if ($next = webcomic_next($node)) { - $path = '/' . drupal_get_path('module', 'webcomic') . '/img/go-next.png'; - drupal_add_link(array('rel' => 'next', 'href' => url('node/'. $next->nid))); - return l('', 'node/'. $next->nid, array('class' => 'page-next', 'title' => $next->title), NULL, NULL, FALSE, TRUE); + $path = drupal_get_path('module', 'webcomic') .'/img/go-next.png'; + drupal_add_link(array('rel' => 'next', 'href' => url('node/' . $next->nid))); + return l('', 'node/'. $next->nid, array('class' => 'page-next', 'title' => $next->title), NULL, NULL, FALSE, TRUE); } else { - $path = '/' . drupal_get_path('module', 'webcomic') . '/img/go-next-dim.png'; - return ''; + $path = drupal_get_path('module', 'webcomic') .'/img/go-next-dim.png'; + return ''; } } +/** + * Theme last link + * + * @ingroup themeable + */ function theme_webcomic_last_link($node) { if ($latest = webcomic_last($node)) { - $path = '/' . drupal_get_path('module', 'webcomic') . '/img/go-last.png'; - drupal_add_link(array('rel' => 'last', 'href' => url('node/'. $latest->nid))); - return l('', 'node/'. $latest->nid, array('class' => 'page-latest', 'title' => $latest->title), NULL, NULL, FALSE, TRUE); + $path = drupal_get_path('module', 'webcomic') .'/img/go-last.png'; + drupal_add_link(array('rel' => 'last', 'href' => url('node/' . $latest->nid))); + return l('', 'node/'. $latest->nid, array('class' => 'page-latest', 'title' => $latest->title), NULL, NULL, FALSE, TRUE); } else { - $path = '/' . drupal_get_path('module', 'webcomic') . '/img/go-last-dim.png'; - return ''; + $path = drupal_get_path('module', 'webcomic') .'/img/go-last-dim.png'; + return ''; } } @@ -96,11 +128,16 @@ return $value; } else { - $path = '/' . drupal_get_path('module', 'webcomic') . '/img/go-first-dim.png'; - return ''; + $path = drupal_get_path('module', 'webcomic') .'/img/go-first-dim.png'; + return ''; } } +/** + * Theme strip archive + * + * @ingroup themeable + */ function theme_views_view_strip_archive($view, $type, $nodes) { if ($type == 'page') { $output = ''; @@ -124,7 +161,7 @@ $output .= theme('node_list', $list); $list = array(); } - $output .= '

' . $month . '

'; + $output .= '

'. $month .'

'; } $list[] = theme('webcomic_strip_listing', $node); } @@ -140,7 +177,7 @@ $output .= theme('node_list', $list); $list = array(); } - $output .= '

' . $year . '

'; + $output .= '

'. $year .'

'; } $list[] = theme('webcomic_strip_listing', $node); } @@ -168,7 +205,7 @@ return "
$output
\n"; } else { - return theme('views_view', $view, $type, $nodes); + return theme('views_view', $view, $type, $nodes); } } @@ -177,27 +214,53 @@ * views of the assorted node types. */ +/** + * Theme strip listing + * + * @ingroup themeable + */ function theme_webcomic_strip_listing($node) { - return l($node->title, 'node/'.$node->nid); + return l($node->title, 'node/'. $node->nid); } - +/** + * Theme episode listing + * + * @ingroup themeable + */ function theme_webcomic_episode_listing($node) { - return l($node->title, 'node/'.$node->nid); + return l($node->title, 'node/'. $node->nid); } +/** + * Theme episode grouping + * + * @ingroup themeable + */ function theme_webcomic_episode_grouping($node) { - $output .= '

' . $node->title . '

'; - $output .= '

' . $node->teaser . '

'; + $output .= '

'. $node->title .'

'; + $output .= '

'. $node->teaser .'

'; + return $output; } +/** + * Theme storyline listing + * + * @ingroup themeable + */ function theme_webcomic_storyline_listing($node) { - return l($node->title, 'node/'.$node->nid); + return l($node->title, 'node/'. $node->nid); } +/** + * Theme storyline grouping + * + * @ingroup themeable + */ function theme_webcomic_storyline_grouping($node) { - $output .= '

' . $node->title . '

'; - $output .= '

' . $node->teaser . '

'; + $output .= '

'. $node->title .'

'; + $output .= '

'. $node->teaser .'

'; + return $output; -} \ No newline at end of file +} Index: webcomic.css =================================================================== RCS file: webcomic.css diff -N webcomic.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ webcomic.css 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,1 @@ +/* $Id$ */ Index: webcomic.info =================================================================== RCS file: webcomic.info diff -N webcomic.info --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ webcomic.info 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,4 @@ +; $Id$ +name = Webcomic +description = Provides content types and tools for managing a webcomic +version = 5.x-0.x-dev