| 1 |
<?php
|
| 2 |
// $Id: nodetypeviews.module,v 1.3 2008/08/30 22:54:39 yaph Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Creates teaser views and RSS feeds for published content by node type.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implemetation of hook_menu().
|
| 11 |
*/
|
| 12 |
function nodetypeviews_menu() {
|
| 13 |
$items = array();
|
| 14 |
$items['admin/content/nodetypeviews'] = array(
|
| 15 |
'title' => 'Node Type Views',
|
| 16 |
'description' => 'Enable the node types to generate views for.',
|
| 17 |
'page callback' => 'drupal_get_form',
|
| 18 |
'page arguments' => array('nodetypeviews_admin_settings'),
|
| 19 |
'access arguments' => array('administer site configuration'),
|
| 20 |
'type' => MENU_NORMAL_ITEM,
|
| 21 |
'file' => 'nodetypeviews.admin.inc'
|
| 22 |
);
|
| 23 |
$node_types = variable_get('nodetypeviews_node_types', array());
|
| 24 |
if (is_array($node_types)) {
|
| 25 |
foreach ($node_types as $type => $isset) {
|
| 26 |
if ($isset) {
|
| 27 |
$path = str_replace('_', '-', $type);
|
| 28 |
$title = ucfirst($type);
|
| 29 |
$items[$path] = array(
|
| 30 |
'title' => $title,
|
| 31 |
'access arguments' => array('access content'),
|
| 32 |
'type' => MENU_NORMAL_ITEM,
|
| 33 |
'page callback' => 'nodetypeviews_type_teaser_view',
|
| 34 |
'page arguments' => array($type),
|
| 35 |
'file' => 'nodetypeviews.pages.inc'
|
| 36 |
);
|
| 37 |
$items[$path .'/feed'] = array(
|
| 38 |
'title' => $title,
|
| 39 |
'access arguments' => array('access content'),
|
| 40 |
'type' => MENU_CALLBACK,
|
| 41 |
'page callback' => 'nodetypeviews_type_teaser_feed',
|
| 42 |
'page arguments' => array($type),
|
| 43 |
'file' => 'nodetypeviews.pages.inc'
|
| 44 |
);
|
| 45 |
}
|
| 46 |
}
|
| 47 |
}
|
| 48 |
return $items;
|
| 49 |
}
|
| 50 |
|
| 51 |
/**
|
| 52 |
* Check whether the given node type exists
|
| 53 |
*
|
| 54 |
* @param String $type
|
| 55 |
* @return Boolean
|
| 56 |
*/
|
| 57 |
function nodetypeviews_check_type($type) {
|
| 58 |
$node_types = node_get_types();
|
| 59 |
if (isset($node_types[$type])) {
|
| 60 |
return TRUE;
|
| 61 |
}
|
| 62 |
|
| 63 |
$msg = 'Content type %type does not exist.';
|
| 64 |
$placeholder = array('%type' => $type);
|
| 65 |
watchdog('security', $msg, $placeholder, WATCHDOG_ALERT);
|
| 66 |
drupal_set_message(t($msg, $placeholder));
|
| 67 |
return false;
|
| 68 |
}
|