| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Page view type
|
| 7 |
*/
|
| 8 |
|
| 9 |
|
| 10 |
include_once(drupal_get_path('module', 'pageroute') .'/pageroute.page.inc');
|
| 11 |
|
| 12 |
class pageroute_page_view extends pageroute_page {
|
| 13 |
/*
|
| 14 |
* Returns the page display for the configured node
|
| 15 |
*/
|
| 16 |
public function get_form(&$form_state, &$args) {
|
| 17 |
|
| 18 |
$form = array();
|
| 19 |
|
| 20 |
if (!isset($this->options['nid'])) {
|
| 21 |
$this->options['nid'] = pageroute_page_get_nid($this);
|
| 22 |
}
|
| 23 |
|
| 24 |
if ($this->options['nid'] == 0) {
|
| 25 |
$this->options['nid'] = $args['nid'];
|
| 26 |
}
|
| 27 |
|
| 28 |
if ($this->options['nid']) {
|
| 29 |
|
| 30 |
$node = node_load($this->options['nid']);
|
| 31 |
if ($node->nid && node_access('view', $node)) {
|
| 32 |
if (empty($this->title)) {
|
| 33 |
drupal_set_title(check_plain($node->title));
|
| 34 |
}
|
| 35 |
node_tag_new($node->nid);
|
| 36 |
$form['page_form'] = array('#value' => node_view($node, FALSE, TRUE, FALSE));
|
| 37 |
|
| 38 |
return $form;
|
| 39 |
}
|
| 40 |
else if (db_result(db_query('SELECT nid FROM {node} WHERE nid = %d', $this->options['nid']))) {
|
| 41 |
drupal_access_denied();
|
| 42 |
pageroute_exit_now();
|
| 43 |
}
|
| 44 |
}
|
| 45 |
drupal_not_found();
|
| 46 |
pageroute_exit_now();
|
| 47 |
}
|
| 48 |
|
| 49 |
public static function ui($page, &$form) {
|
| 50 |
$form['options']['nid'] = array(
|
| 51 |
'#type' => 'textfield',
|
| 52 |
'#title' => t('Node ID'),
|
| 53 |
'#description' => t('Enter the node ID of the node that should be '.
|
| 54 |
'displayed at this page. Enter 0 to use the '.
|
| 55 |
'first argument as node ID like other node '.
|
| 56 |
'page type does.'),
|
| 57 |
'#required' => TRUE,
|
| 58 |
'#default_value' => isset($page->options['nid']) ? $page->options['nid'] : '',
|
| 59 |
'#weight' => 2,
|
| 60 |
);
|
| 61 |
}
|
| 62 |
|
| 63 |
public static function help() {
|
| 64 |
return t('This page type just displays a configurable node. It can also '.
|
| 65 |
'be configured to display the node with the id taken from the '.
|
| 66 |
'first argument. Combined with a node adding or editing form, '.
|
| 67 |
'this enables you to build a page that shows the added or updated node.');
|
| 68 |
}
|
| 69 |
|
| 70 |
public static function info() {
|
| 71 |
return array('name' => t('Node display'));
|
| 72 |
}
|
| 73 |
|
| 74 |
public function get_cancel_target() {
|
| 75 |
return PAGEROUTE_FORWARD;
|
| 76 |
}
|
| 77 |
|
| 78 |
public function set_up() {
|
| 79 |
include_once(drupal_get_path('module', 'node') .'/node.pages.inc');
|
| 80 |
}
|
| 81 |
}
|