Mercurial > defr > drupal > core
comparison modules/blog/blog.pages.inc @ 1:c1f4ac30525a 6.0
Drupal 6.0
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Tue, 23 Dec 2008 14:28:28 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:5a113a1c4740 | 1:c1f4ac30525a |
---|---|
1 <?php | |
2 // $Id: blog.pages.inc,v 1.6.2.1 2008/02/08 21:15:12 goba Exp $ | |
3 | |
4 /** | |
5 * @file | |
6 * Page callback file for the blog module. | |
7 */ | |
8 | |
9 /** | |
10 * Menu callback; displays a Drupal page containing recent blog entries of a given user. | |
11 */ | |
12 function blog_page_user($account) { | |
13 global $user; | |
14 | |
15 drupal_set_title($title = t("@name's blog", array('@name' => $account->name))); | |
16 | |
17 $items = array(); | |
18 | |
19 if (($account->uid == $user->uid) && user_access('create blog entries')) { | |
20 $items[] = l(t('Post new blog entry.'), "node/add/blog"); | |
21 } | |
22 else if ($account->uid == $user->uid) { | |
23 $items[] = t('You are not allowed to post a new blog entry.'); | |
24 } | |
25 | |
26 $output = theme('item_list', $items); | |
27 | |
28 $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); | |
29 $has_posts = FALSE; | |
30 | |
31 while ($node = db_fetch_object($result)) { | |
32 $output .= node_view(node_load($node->nid), 1); | |
33 $has_posts = TRUE; | |
34 } | |
35 | |
36 if ($has_posts) { | |
37 $output .= theme('pager', NULL, variable_get('default_nodes_main', 10)); | |
38 } | |
39 else { | |
40 if ($account->uid == $user->uid) { | |
41 drupal_set_message(t('You have not created any blog entries.')); | |
42 } | |
43 else { | |
44 drupal_set_message(t('!author has not created any blog entries.', array('!author' => theme('username', $account)))); | |
45 } | |
46 } | |
47 drupal_add_feed(url('blog/'. $account->uid .'/feed'), t('RSS - !title', array('!title' => $title))); | |
48 | |
49 return $output; | |
50 } | |
51 | |
52 /** | |
53 * Menu callback; displays a Drupal page containing recent blog entries of all users. | |
54 */ | |
55 function blog_page_last() { | |
56 global $user; | |
57 | |
58 $output = ''; | |
59 $items = array(); | |
60 | |
61 if (user_access('edit own blog')) { | |
62 $items[] = l(t('Create new blog entry.'), "node/add/blog"); | |
63 } | |
64 | |
65 $output = theme('item_list', $items); | |
66 | |
67 $result = pager_query(db_rewrite_sql("SELECT n.nid, 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)); | |
68 $has_posts = FALSE; | |
69 | |
70 while ($node = db_fetch_object($result)) { | |
71 $output .= node_view(node_load($node->nid), 1); | |
72 $has_posts = TRUE; | |
73 } | |
74 | |
75 if ($has_posts) { | |
76 $output .= theme('pager', NULL, variable_get('default_nodes_main', 10)); | |
77 } | |
78 else { | |
79 drupal_set_message(t('No blog entries have been created.')); | |
80 } | |
81 drupal_add_feed(url('blog/feed'), t('RSS - blogs')); | |
82 | |
83 return $output; | |
84 } | |
85 | |
86 /** | |
87 * Menu callback; displays an RSS feed containing recent blog entries of a given user. | |
88 */ | |
89 function blog_feed_user($account) { | |
90 $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)); | |
91 $channel['title'] = $account->name ."'s blog"; | |
92 $channel['link'] = url('blog/'. $account->uid, array('absolute' => TRUE)); | |
93 | |
94 $items = array(); | |
95 while ($row = db_fetch_object($result)) { | |
96 $items[] = $row->nid; | |
97 } | |
98 node_feed($items, $channel); | |
99 } | |
100 | |
101 /** | |
102 * Menu callback; displays an RSS feed containing recent blog entries of all users. | |
103 */ | |
104 function blog_feed_last() { | |
105 $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)); | |
106 $channel['title'] = variable_get('site_name', 'Drupal') .' blogs'; | |
107 $channel['link'] = url('blog', array('absolute' => TRUE)); | |
108 | |
109 $items = array(); | |
110 while ($row = db_fetch_object($result)) { | |
111 $items[] = $row->nid; | |
112 } | |
113 | |
114 node_feed($items, $channel); | |
115 } |