| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @file 5 * Page callback file for the blog module. 6 */ 7 8 /** 9 * Menu callback; displays a Drupal page containing recent blog entries of a given user. 10 */ 11 function blog_page_user($account) { 12 global $user; 13 14 drupal_set_title($title = t("@name's blog", array('@name' => $account->name))); 15 16 $items = array(); 17 18 if (($account->uid == $user->uid) && user_access('create blog entries')) { 19 $items[] = l(t('Post new blog entry.'), "node/add/blog"); 20 } 21 else if ($account->uid == $user->uid) { 22 $items[] = t('You are not allowed to post a new blog entry.'); 23 } 24 25 $output = theme('item_list', $items); 26 27 $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid); 28 $has_posts = FALSE; 29 30 while ($node = db_fetch_object($result)) { 31 $output .= node_view(node_load($node->nid), 1); 32 $has_posts = TRUE; 33 } 34 35 if ($has_posts) { 36 $output .= theme('pager', NULL, variable_get('default_nodes_main', 10)); 37 } 38 else { 39 if ($account->uid == $user->uid) { 40 drupal_set_message(t('You have not created any blog entries.')); 41 } 42 else { 43 drupal_set_message(t('!author has not created any blog entries.', array('!author' => theme('username', $account)))); 44 } 45 } 46 drupal_add_feed(url('blog/'. $account->uid .'/feed'), t('RSS - !title', array('!title' => $title))); 47 48 return $output; 49 } 50 51 /** 52 * Menu callback; displays a Drupal page containing recent blog entries of all users. 53 */ 54 function blog_page_last() { 55 global $user; 56 57 $output = ''; 58 $items = array(); 59 60 if (user_access('create blog entries')) { 61 $items[] = l(t('Create new blog entry.'), "node/add/blog"); 62 } 63 64 $output = theme('item_list', $items); 65 66 $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10)); 67 $has_posts = FALSE; 68 69 while ($node = db_fetch_object($result)) { 70 $output .= node_view(node_load($node->nid), 1); 71 $has_posts = TRUE; 72 } 73 74 if ($has_posts) { 75 $output .= theme('pager', NULL, variable_get('default_nodes_main', 10)); 76 } 77 else { 78 drupal_set_message(t('No blog entries have been created.')); 79 } 80 drupal_add_feed(url('blog/feed'), t('RSS - blogs')); 81 82 return $output; 83 } 84 85 /** 86 * Menu callback; displays an RSS feed containing recent blog entries of a given user. 87 */ 88 function blog_feed_user($account) { 89 $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $account->uid, 0, variable_get('feed_default_items', 10)); 90 $channel['title'] = t("!name's blog", array('!name' => $account->name)); 91 $channel['link'] = url('blog/'. $account->uid, array('absolute' => TRUE)); 92 93 $items = array(); 94 while ($row = db_fetch_object($result)) { 95 $items[] = $row->nid; 96 } 97 node_feed($items, $channel); 98 } 99 100 /** 101 * Menu callback; displays an RSS feed containing recent blog entries of all users. 102 */ 103 function blog_feed_last() { 104 $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10)); 105 $channel['title'] = t('!site_name blogs', array('!site_name' => variable_get('site_name', 'Drupal'))); 106 $channel['link'] = url('blog', array('absolute' => TRUE)); 107 108 $items = array(); 109 while ($row = db_fetch_object($result)) { 110 $items[] = $row->nid; 111 } 112 113 node_feed($items, $channel); 114 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |