| 1 |
<?php |
<?php |
| 2 |
// $Id: $ |
// $Id: export_opml.module,v 1.1 2005/11/28 08:44:12 puregin Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
/** |
/** |
| 10 |
|
* Implementation of hook_perm(). |
| 11 |
|
*/ |
| 12 |
|
function export_opml_perm() { |
| 13 |
|
return array('export books as opml'); |
| 14 |
|
} |
| 15 |
|
|
| 16 |
|
/** |
| 17 |
* Implementation of hook_link(). |
* Implementation of hook_link(). |
| 18 |
*/ |
*/ |
| 19 |
function export_opml_link($type, $node = 0, $main = 0) { |
function export_opml_link($type, $node = 0, $main = 0) { |
| 20 |
$links = array(); |
$links = array(); |
| 21 |
if ($type == 'node' && isset($node->parent)) { |
if ($type == 'node' && isset($node->parent)) { |
| 22 |
if (!$main) { |
if (!$main) { |
| 23 |
if (user_access('export books')) { |
if (user_access('export books as opml')) { |
| 24 |
$links[] = l(t('export OPML'), 'book/export/opml/'. $node->nid, array('title' => t('Export this book page and its sub-pages as OPML.'))); |
$links[] = l(t('export OPML'), 'book/export/opml/'. $node->nid, array('title' => t('Export this book page and its sub-pages as OPML.'))); |
| 25 |
} |
} |
| 26 |
} |
} |
| 50 |
|
|
| 51 |
*/ |
*/ |
| 52 |
function book_export_opml($nid, $depth) { |
function book_export_opml($nid, $depth) { |
| 53 |
if (user_access('export books')) { |
if (user_access('export books as opml')) { |
| 54 |
drupal_set_header('Content-Type: text/xml; charset=utf-8'); |
drupal_set_header('Content-Type: text/xml; charset=utf-8'); |
| 55 |
$output .= book_recurse($nid, $depth, 'book_node_visitor_opml_pre', 'book_node_visitor_opml_post'); |
$output .= book_recurse($nid, $depth, 'book_node_visitor_opml_pre', 'book_node_visitor_opml_post'); |
| 56 |
$ompl = "<?xml version='1.0'?>\n"; |
$ompl = "<?xml version='1.0'?>\n"; |
| 115 |
} |
} |
| 116 |
} |
} |
| 117 |
|
|
| 118 |
|
/** |
| 119 |
|
* Implementation of hook_menu(). |
| 120 |
|
*/ |
| 121 |
|
function export_opml_menu($may_cache) { |
| 122 |
|
$items = array(); |
| 123 |
|
|
| 124 |
|
if ($may_cache) { |
| 125 |
|
$items[] = array( |
| 126 |
|
'path' => 'book/export', |
| 127 |
|
'callback' => 'book_export', |
| 128 |
|
'access' => (user_access('export books as opml') && user_access('access content')), |
| 129 |
|
'type' => MENU_CALLBACK); |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
return $items; |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|