summaryrefslogtreecommitdiff
path: root/modules/page.module
blob: 81610551a36255fcc3a37c790f259d66d6d1b9a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
// $Id$

/**
 * @file
 * Enables the creation of pages that can be added to the navigation system.
 */

/**
 * Implementation of hook_help().
 */
function page_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('Enables the creation of pages that can be added to the navigation system.');
    case 'node/add#page':
      return t('If you want to add a static page, like a contact page or an about page, use a page.');
  }
}

/**
 * Implementation of hook_perm().
 */
function page_perm() {
  return array('create pages', 'edit own pages');
}

/**
 * Implementation of hook_node_info().
 */
function page_node_info() {
  return array('page' => array('name' => t('page'), 'base' => 'page'));
}

/**
 * Implementation of hook_access().
 */
function page_access($op, $node) {
  global $user;

  if ($op == 'create') {
    return user_access('create pages');
  }

  if ($op == 'update' || $op == 'delete') {
    if (user_access('edit own pages') && ($user->uid == $node->uid)) {
      return TRUE;
    }
  }
}

/**
 * Implementation of hook_menu().
 */
function page_menu($may_cache) {
  $items = array();

  if ($may_cache) {
    $items[] = array('path' => 'node/add/page', 'title' => t('page'),
      'access' => page_access('create', NULL));
  }

  return $items;
}

/**
 * Implementation of hook_validate().
 */
function page_validate(&$node) {
  node_validate_title($node);
}

/**
 * Implementation of hook_form().
 */
function page_form(&$node) {

  $form['title'] = array(type => 'textfield', title => t('Title'), size => 60, maxlength => 128, required => TRUE, default_value => $node->title);

  if (function_exists('taxonomy_node_form')) {
    $form['taxonomy'] = taxonomy_node_form('page', $node);
  }

  $form['body'] = array(
    type => 'textarea', title => t('Body'), default_value => $node->body, required => TRUE
  );
  $form = array_merge($form, filter_form($node->format));


  $form['log'] = array(
    type => 'textarea', title => t('Log message'), default_value => $node->log, rows => 5,
    description => t('An explanation of the additions or updates being made to help other authors understand your motivations.')
  );

  return $form;
}