From 658b27c9eceed3c66c9fd4c75da9d9f0cdfd839c Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 13 May 2008 18:15:07 +0000 Subject: [PATCH] - Patch #257644 by Senpai: code cleanup. --- modules/blog/blog.info | 1 + modules/blog/blog.module | 12 ++++++------ modules/blog/blog.pages.inc | 1 - modules/blog/blog.test | 26 ++++++++++++++++---------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/modules/blog/blog.info b/modules/blog/blog.info index ae6430bef98..6093772f419 100644 --- a/modules/blog/blog.info +++ b/modules/blog/blog.info @@ -1,4 +1,5 @@ ; $Id$ + name = Blog description = Enables keeping easily and regularly updated user web pages or blogs. package = Core - optional diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 1cc82a16d60..21f58b721cf 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -61,7 +61,7 @@ function blog_user($type, &$edit, &$user) { function blog_help($path, $arg) { switch ($path) { case 'admin/help#blog': - $output = '

' . t('The blog module allows registered users to maintain an online journal, or blog. Blogs are made up of individual blog entries, and the blog entries are most often displayed in descending order by creation time.') . '

'; + $output = '

' . t('The blog module allows registered users to maintain an online journal, or blog. Blogs are made up of individual blog entries, and the blog entries are most often displayed in descending order by creation time.') . '

'; $output .= '

' . t('There is an (optional) Blogs menu item added to the Navigation menu, which displays all blogs available on your site, and a My blog item displaying the current user\'s blog entries. The Blog entry menu item under Create content allows new blog entries to be created.') . '

'; $output .= '

' . t('Each blog entry is displayed with an automatic link to other blogs created by the same user. By default, blog entries have comments enabled and are automatically promoted to the site front page. The blog module also creates a Recent blog posts block that may be enabled at the blocks administration page.', array('@blocks' => url('admin/build/block'))) . '

'; $output .= '

' . t('When using the aggregator module an automatic blog it icon is displayed next to the items in a feed\'s latest items block. Clicking this icon populates a blog entry with a title (the title of the feed item) and body (a link to the source item on its original site and illustrative content suitable for use in a block quote). Blog authors can use this feature to easily comment on items of interest that appear in aggregator feeds from other sites. To use this feature, be sure to enable the aggregator module, add and configure a feed from another site, and position the feed\'s latest items block.', array('@modules' => url('admin/build/modules'), '@feeds' => url('admin/content/aggregator'), '@blocks' => url('admin/build/block'))) . '

'; @@ -78,7 +78,6 @@ function blog_form(&$node) { $iid = isset($_GET['iid']) ? (int)$_GET['iid'] : 0; $type = node_get_types('type', $node); - if (empty($node->body)) { // If the user clicked a "blog it" link, we load the data from the // database and quote it in the blog. @@ -91,11 +90,11 @@ function blog_form(&$node) { // Note: $item->description has been validated on aggregation. $node->body = '' . check_plain($item->title) . ' - ' . $item->description . ' [' . check_plain($item->ftitle) . "]\n"; } - } $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => !empty($node->title) ? $node->title : NULL, '#weight' => -5); $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count); + return $form; } @@ -104,9 +103,10 @@ function blog_form(&$node) { */ function blog_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { - // Breadcrumb navigation + // Breadcrumb navigation. drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("@name's blog", array('@name' => $node->name)), 'blog/' . $node->uid))); } + return node_prepare($node, $teaser); } @@ -121,7 +121,7 @@ function blog_link($type, $node = NULL, $teaser = FALSE) { $links['blog_usernames_blog'] = array( 'title' => t("@username's blog", array('@username' => $node->name)), 'href' => "blog/$node->uid", - 'attributes' => array('title' => t("Read @username's latest blog entries.", array('@username' => $node->name))) + 'attributes' => array('title' => t("Read @username's latest blog entries.", array('@username' => $node->name))), ); } } @@ -192,7 +192,7 @@ function blog_block($op = 'list', $delta = '') { $block['recent']['info'] = t('Recent blog posts'); return $block; } - else if ($op == 'view') { + elseif ($op == 'view') { if (user_access('access content')) { $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10); if ($node_title_list = node_title_list($result)) { diff --git a/modules/blog/blog.pages.inc b/modules/blog/blog.pages.inc index caa47a207fe..18375167fd6 100644 --- a/modules/blog/blog.pages.inc +++ b/modules/blog/blog.pages.inc @@ -110,6 +110,5 @@ function blog_feed_last() { while ($row = db_fetch_object($result)) { $items[] = $row->nid; } - node_feed($items, $channel); } diff --git a/modules/blog/blog.test b/modules/blog/blog.test index 292aa3bd96e..c9019e9298e 100644 --- a/modules/blog/blog.test +++ b/modules/blog/blog.test @@ -60,8 +60,10 @@ class BlogTestCase extends DrupalWebTestCase { /** * Run basic tests on the indicated user. * - * @param object $user The logged in user. - * @param boolean $admin User has 'access administration pages' privilege. + * @param object $user + * The logged in user. + * @param boolean $admin + * User has 'access administration pages' privilege. */ private function doBasicTests($user, $admin) { // Login the user. @@ -77,10 +79,14 @@ class BlogTestCase extends DrupalWebTestCase { /** * Verify the logged in user has the desired access to the various blog nodes. * - * @param object $node_user The user who creates the node. - * @param object $node Node. - * @param boolean $admin User has 'access administration pages' privilege. - * @param integer $response HTTP response code. + * @param object $node_user + * The user who creates the node. + * @param object $node + * A node object. + * @param boolean $admin + * User has 'access administration pages' privilege. + * @param integer $response + * HTTP response code. */ private function verifyBlogs($node_user, $node, $admin, $response = 200) { $crumb = '›'; @@ -91,11 +97,10 @@ class BlogTestCase extends DrupalWebTestCase { // View blog help node. $this->drupalGet('admin/help/blog'); $this->assertResponse($response2); - // NOTE: The two commented asserts fail because the get returns the 'admin/help' node instead of the indicated node??? if ($response2 == 200) { -// $this->assertTitle(t('Blog | Drupal'), t('Blog help node was displayed')); + $this->assertTitle(t('Blog | Drupal'), t('Blog help node was displayed')); $this->assertText(t('Blog'), t('Blog help node was displayed')); -// $this->assertText(t('Home '. $crumb .' Administer '. $crumb .' Help'), t('Breadcrumbs were displayed')); + $this->assertText(t('Home '. $crumb .' Administer '. $crumb .' Help'), t('Breadcrumbs were displayed')); } // Verify the blog block was displayed. @@ -135,7 +140,8 @@ class BlogTestCase extends DrupalWebTestCase { /** * Verify the blog links are displayed to the logged in user. * - * @param object $user The logged in user. + * @param object $user + * The logged in user. */ private function verifyBlogLinks($user) { $crumb = '›';