- Patch #257644 by Senpai: code cleanup.

merge-requests/26/head
Dries Buytaert 2008-05-13 18:15:07 +00:00
parent 8758b297a6
commit 658b27c9ec
4 changed files with 23 additions and 17 deletions

View File

@ -1,4 +1,5 @@
; $Id$
name = Blog
description = Enables keeping easily and regularly updated user web pages or blogs.
package = Core - optional

View File

@ -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 = '<a href="' . check_url($item->link) . '">' . check_plain($item->title) . '</a> - <em>' . $item->description . '</em> [<a href="' . check_url($item->flink) . '">' . check_plain($item->ftitle) . "</a>]\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)) {

View File

@ -110,6 +110,5 @@ function blog_feed_last() {
while ($row = db_fetch_object($result)) {
$items[] = $row->nid;
}
node_feed($items, $channel);
}

View File

@ -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 = '';