summaryrefslogtreecommitdiffstats
path: root/modules/page.module
blob: 8eeb8794a389f54b574fa65f77009f2cc2fb21a4 (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
99
100
101
<?php

/**
 * @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/help#page':
      $output = '<p>'. t('The page module allows users to create static pages, which are the most basic type of content.  Pages are commonly collected in books via the book module.  Users should create a page if the information on the page is static.  An example would be an "about" page. ') .'</p>';
      $output .= '<p>'. t('When a  page is created, a user can set authoring information, configure publishing options, whether readers will be able to post comments.  They can also select the content type of the page (e.g., full HTML, filtered HTML). ') .'</p>';
      $output .= '<p>'. t('As an administrator, you can set the publishing default for a page (in its workflow): you can specify whether a page is by default published, sent to moderation, promoted to the front page, sticky at the top of lists, and whether revisions are enabled by default.    You can set the permissions that different user roles have to view, create, and edit pages.') .'</p>';
      $output .= '<p>'. t('If the location module is enabled, then location specific information can be added.  If the trackback module is enabled trackbacks can be configured.') .'</p>';
      $output .= t('<p>You can</p>
<ul>
<li>read the node administration help at <a href="%admin-help-node">administer &gt;&gt; help &gt;&gt; node</a>.</li>
<li>read the page administration help at <a href="%admin-help-page">administer &gt;&gt; help &gt;&gt; page</a>.</li>
<li>read the story administration help at <a href="%admin-help-story">administer &gt;&gt; help &gt;&gt; story</a>.</li>
<li>create a page at <a href="%node-add-page">create content &gt;&gt; page</a>.</li>
<li>administer page content type at <a href="%admin-settings-content-types-page">administer &gt;&gt; settings &gt;&gt; content types &gt;&gt; configure page</a>.</li>
</ul>
', array('%admin-help-node' => url('admin/help/node'), '%admin-help-page' => url('admin/help/page'), '%admin-help-story' => url('admin/help/story'), '%node-add-page' => url('node/add/page'), '%admin-settings-content-types-page' => url('admin/settings/content-types/page')));
      $output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="%page">Page page</a>.', array('%page' => 'http://drupal.org/handbook/modules/page/')) .'</p>';
      return $output;
    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' => user_access('create pages'));
  }

  return $items;
}

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

  $form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5);

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

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

  return $form;
}