blog.pages.inc

Page callback file for the blog module.

File

drupal/modules/blog/blog.pages.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Page callback file for the blog module.
  5. */
  6. /**
  7. * Menu callback; displays a Drupal page containing recent blog entries of a given user.
  8. */
  9. function blog_page_user($account) {
  10. global $user;
  11. drupal_set_title($title = t("@name's blog", array('@name' => format_username($account))), PASS_THROUGH);
  12. $build = array();
  13. $query = db_select('node', 'n')->extend('PagerDefault');
  14. $nids = $query
  15. ->fields('n', array('nid', 'sticky', 'created'))
  16. ->condition('type', 'blog')
  17. ->condition('uid', $account->uid)
  18. ->condition('status', 1)
  19. ->orderBy('sticky', 'DESC')
  20. ->orderBy('created', 'DESC')
  21. ->limit(variable_get('default_nodes_main', 10))
  22. ->addTag('node_access')
  23. ->execute()
  24. ->fetchCol();
  25. if (!empty($nids)) {
  26. $nodes = node_load_multiple($nids);
  27. $build += node_view_multiple($nodes);
  28. $build['pager'] = array(
  29. '#theme' => 'pager',
  30. '#weight' => 5,
  31. );
  32. }
  33. else {
  34. if ($account->uid == $user->uid) {
  35. drupal_set_message(t('You have not created any blog entries.'));
  36. }
  37. else {
  38. drupal_set_message(t('!author has not created any blog entries.', array('!author' => theme('username', array('account' => $account)))));
  39. }
  40. }
  41. drupal_add_feed('blog/' . $account->uid . '/feed', t('RSS - !title', array('!title' => $title)));
  42. return $build;
  43. }
  44. /**
  45. * Menu callback; displays a Drupal page containing recent blog entries of all users.
  46. */
  47. function blog_page_last() {
  48. global $user;
  49. $build = array();
  50. $query = db_select('node', 'n')->extend('PagerDefault');
  51. $nids = $query
  52. ->fields('n', array('nid', 'sticky', 'created'))
  53. ->condition('type', 'blog')
  54. ->condition('status', 1)
  55. ->orderBy('sticky', 'DESC')
  56. ->orderBy('created', 'DESC')
  57. ->limit(variable_get('default_nodes_main', 10))
  58. ->addTag('node_access')
  59. ->execute()
  60. ->fetchCol();
  61. if (!empty($nids)) {
  62. $nodes = node_load_multiple($nids);
  63. $build += node_view_multiple($nodes);
  64. $build['pager'] = array(
  65. '#theme' => 'pager',
  66. '#weight' => 5,
  67. );
  68. }
  69. else {
  70. drupal_set_message(t('No blog entries have been created.'));
  71. }
  72. drupal_add_feed('blog/feed', t('RSS - blogs'));
  73. return $build;
  74. }
  75. /**
  76. * Menu callback; displays an RSS feed containing recent blog entries of a given user.
  77. */
  78. function blog_feed_user($account) {
  79. $nids = db_select('node', 'n')
  80. ->fields('n', array('nid', 'created'))
  81. ->condition('type', 'blog')
  82. ->condition('uid', $account->uid)
  83. ->condition('status', 1)
  84. ->orderBy('created', 'DESC')
  85. ->range(0, variable_get('feed_default_items', 10))
  86. ->addTag('node_access')
  87. ->execute()
  88. ->fetchCol();
  89. $channel['title'] = t("!name's blog", array('!name' => format_username($account)));
  90. $channel['link'] = url('blog/' . $account->uid, array('absolute' => TRUE));
  91. node_feed($nids, $channel);
  92. }
  93. /**
  94. * Menu callback; displays an RSS feed containing recent blog entries of all users.
  95. */
  96. function blog_feed_last() {
  97. $nids = db_select('node', 'n')
  98. ->fields('n', array('nid', 'created'))
  99. ->condition('type', 'blog')
  100. ->condition('status', 1)
  101. ->orderBy('created', 'DESC')
  102. ->range(0, variable_get('feed_default_items', 10))
  103. ->addTag('node_access')
  104. ->execute()
  105. ->fetchCol();
  106. $channel['title'] = t('!site_name blogs', array('!site_name' => variable_get('site_name', 'Drupal')));
  107. $channel['link'] = url('blog', array('absolute' => TRUE));
  108. node_feed($nids, $channel);
  109. }

Functions

Namesort descending Description
blog_feed_last Menu callback; displays an RSS feed containing recent blog entries of all users.
blog_feed_user Menu callback; displays an RSS feed containing recent blog entries of a given user.
blog_page_last Menu callback; displays a Drupal page containing recent blog entries of all users.
blog_page_user Menu callback; displays a Drupal page containing recent blog entries of a given user.