/[drupal]/contributions/modules/atom/atom.module
ViewVC logotype

Contents of /contributions/modules/atom/atom.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.48 - (show annotations) (download) (as text)
Mon Sep 21 22:32:17 2009 UTC (2 months ago) by davereid
Branch: MAIN
CVS Tags: HEAD
Changes since 1.47: +2 -2 lines
File MIME type: text/x-php
by Dave Reid: Swapped around some variables for readability.
1 <?php
2 // $Id: atom.module,v 1.47 2009/09/21 21:36:40 davereid Exp $
3
4 /**
5 * @file
6 * Provides an Atom 1.0 feed.
7 *
8 * @author David Kent Norman
9 * @link http://deekayen.net/
10 * @author Kristjan Jansen
11 * @link http://kika.trip.ee/
12 */
13
14 /**
15 * Implement hook_permission().
16 */
17 function atom_permission() {
18 return array(
19 'administer atom' => array(
20 'title' => t('Administer Atom feeds and settings'),
21 'description' => t('Set the number of items to display and the amount of each to show.')
22 )
23 );
24 }
25
26 /**
27 * Implement hook_menu().
28 */
29 function atom_menu() {
30 $items['atom.xml'] = array(
31 'page callback' => 'atom_feed',
32 'access arguments' => array('access content'),
33 'type' => MENU_CALLBACK,
34 'file' => 'atom.pages.inc',
35 );
36 $items['node/%node/atom.xml'] = array(
37 'page callback' => 'atom_node_feed',
38 'page arguments' => array(1),
39 'access arguments' => array('access content'),
40 'type' => MENU_CALLBACK,
41 'file' => 'atom.pages.inc',
42 );
43 if (module_exists('blog')) {
44 $items['blog/atom.xml'] = array(
45 'page callback' => 'atom_blog_feed',
46 'access arguments' => array('access content'),
47 'type' => MENU_CALLBACK,
48 'file' => 'atom.pages.inc',
49 );
50 $items['blog/%user/atom.xml'] = array(
51 'page callback' => 'atom_user_blog_feed',
52 'page arguments' => array(1),
53 'access arguments' => array('access content'),
54 'type' => MENU_CALLBACK,
55 'file' => 'atom.pages.inc',
56 );
57 }
58 if (module_exists('taxonomy')) {
59 $items['taxonomy/term/%taxonomy_term/atom.xml'] = array(
60 'page callback' => 'atom_taxonomy_feed',
61 'page arguments' => array(2),
62 'access arguments' => array('access content'),
63 'type' => MENU_CALLBACK,
64 'file' => 'atom.pages.inc',
65 );
66 }
67 $items['admin/config/services/atom'] = array(
68 'title' => 'Atom publishing',
69 'description' => 'Configure the number of items per feed and whether feeds should be teasers and/or full-text.',
70 'page callback' => 'drupal_get_form',
71 'page arguments' => array('atom_settings_form'),
72 'access arguments' => array('administer atom'),
73 'file' => 'atom.admin.inc',
74 );
75
76 return $items;
77 }
78
79 /**
80 * Implement hook_init().
81 */
82 function atom_init() {
83 if (variable_get('site_offline', 0) || !user_access('access content')) {
84 return;
85 }
86
87 $link = FALSE;
88 if (preg_match('%^blog/\d+$%', $_GET['q'])) {
89 $link = 'blog/' . arg(1) . '/atom.xml';
90 }
91 elseif (preg_match('%^node/\d+$%', $_GET['q'])) {
92 $node = node_load(arg(1));
93 if ($node && node_access('view', $node)) {
94 $link = 'node/' . $node->nid . '/atom.xml';
95 }
96 }
97 elseif (preg_match('%^taxonomy/term/\d+$%', $_GET['q'])) {
98 $link = 'taxonomy/term/' . arg(2) . '/atom.xml';
99 }
100 elseif ($_GET['q'] == 'blog') {
101 $link = 'blog/atom.xml';
102 }
103 elseif (drupal_is_front_page() || $_GET['q'] == 'node') {
104 $link = 'atom.xml';
105 }
106
107 if ($link) {
108 drupal_add_link(array(
109 'rel' => 'alternate',
110 'type' => 'application/atom+xml',
111 'title' => t('!site_name Atom', array('!site_name' => variable_get('site_name', 'Drupal'))),
112 'href' => url($link, array('absolute' => TRUE)),
113 ));
114 }
115 }
116
117 /**
118 * Implement hook_theme().
119 */
120 function atom_theme() {
121 return array(
122 'atom_feed_item' => array(
123 'arguments' => array(
124 'title' => NULL,
125 'link' => NULL,
126 'item' => NULL,
127 'extra' => array(),
128 ),
129 'file' => 'atom.pages.inc',
130 ),
131 'atom_feed' => array(
132 'arguments' => array(
133 'feed_info' => array(),
134 'items' => '',
135 ),
136 'file' => 'atom.pages.inc',
137 ),
138 );
139 }
140
141 /**
142 * Load contrib module element handlers.
143 */
144 function _atom_contrib_load() {
145 static $loaded = FALSE;
146 if (!$loaded) {
147 // Load all atom contrib module elements handlers from ./contrib
148 $path = drupal_get_path('module', 'atom') . '/contrib';
149 $files = drupal_system_listing('.*\.inc$', $path, 'name', 0);
150 foreach ($files as $file) {
151 require_once("./$file->filename");
152 }
153 // Rebuild cache.
154 module_implements('', FALSE, TRUE);
155 }
156 $loaded = TRUE;
157 }

  ViewVC Help
Powered by ViewVC 1.1.2