95 lines
2.1 KiB
Plaintext
95 lines
2.1 KiB
Plaintext
<?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);
|
|
|
|
$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;
|
|
}
|
|
|
|
|