| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* This is a library of useful node functions and methods.
|
| 7 |
* please insert the link if you have a patch for core to introduce a function from this lib to core.
|
| 8 |
*/
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Implementation of hook_help().
|
| 12 |
*/
|
| 13 |
function helpers_node_help($section) {
|
| 14 |
switch ($section) {
|
| 15 |
case 'admin/modules#description':
|
| 16 |
return t('A development library for nodes. Contains useful functions and methods for node manipulation and node queries.');
|
| 17 |
}
|
| 18 |
}
|
| 19 |
|
| 20 |
/**
|
| 21 |
* Find out if the current page is a node page.
|
| 22 |
* @return TRUE if the page is a node, FALSE if it is another page.
|
| 23 |
*/
|
| 24 |
function is_node_page() {
|
| 25 |
if (arg(0) == 'node' && is_numeric(arg(1))) {
|
| 26 |
return TRUE;
|
| 27 |
}
|
| 28 |
return FALSE;
|
| 29 |
}
|
| 30 |
|
| 31 |
/**
|
| 32 |
* Grab the current 'active' node
|
| 33 |
* An active node is the one node 123 as shown on page with path node/123, or
|
| 34 |
* its aliased path(s).
|
| 35 |
* @return $node object if the page is a node, empty $node object if it is not a
|
| 36 |
* node, or if we cannot see it, for any valid reason.
|
| 37 |
*/
|
| 38 |
function node_load_current() {
|
| 39 |
$node = new stdClass();
|
| 40 |
|
| 41 |
if (is_node_page()) {
|
| 42 |
$node = node_load(arg(1));
|
| 43 |
}
|
| 44 |
|
| 45 |
return $node;
|
| 46 |
}
|