2001-12-05 18:46:24 +00:00
|
|
|
<?php
|
|
|
|
// $Id$
|
|
|
|
|
2004-08-21 06:42:38 +00:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Enables the creation of pages that can be added to the navigation system.
|
|
|
|
*/
|
|
|
|
|
2004-03-10 09:32:46 +00:00
|
|
|
/**
|
2004-05-09 19:28:43 +00:00
|
|
|
* Implementation of hook_help().
|
2004-03-10 09:32:46 +00:00
|
|
|
*/
|
2004-05-09 19:28:43 +00:00
|
|
|
function page_help($section) {
|
2003-08-21 20:50:03 +00:00
|
|
|
switch ($section) {
|
2004-06-18 15:04:37 +00:00
|
|
|
case 'admin/modules#description':
|
2004-05-09 19:28:43 +00:00
|
|
|
return t('Enables the creation of pages that can be added to the navigation system.');
|
2004-01-27 18:47:07 +00:00
|
|
|
case 'node/add#page':
|
2005-01-25 20:29:19 +00:00
|
|
|
return t('If you want to add a static page, like a contact page or an about page, use a page.');
|
2003-08-21 20:50:03 +00:00
|
|
|
}
|
2002-02-25 20:26:38 +00:00
|
|
|
}
|
|
|
|
|
2004-03-10 09:32:46 +00:00
|
|
|
/**
|
2004-05-09 19:28:43 +00:00
|
|
|
* Implementation of hook_perm().
|
2004-03-10 09:32:46 +00:00
|
|
|
*/
|
2002-12-10 20:35:20 +00:00
|
|
|
function page_perm() {
|
2004-07-13 20:40:46 +00:00
|
|
|
return array('create pages', 'edit own pages');
|
2002-12-10 20:35:20 +00:00
|
|
|
}
|
|
|
|
|
2004-03-10 09:32:46 +00:00
|
|
|
/**
|
2005-08-29 19:58:49 +00:00
|
|
|
* Implementation of hook_node_info().
|
2004-03-10 09:32:46 +00:00
|
|
|
*/
|
2005-08-29 19:58:49 +00:00
|
|
|
function page_node_info() {
|
- Patch #29785 by Chx: multiple node types were broken so we refactored
part of the node system! If you have a module that implements node
types, you'll have to udpate its CVS HEAD version.
We replaced _node_name() and _node_types() by _node(). The new _node()
hook let's you define one or more node types, including their names.
The implementation of the _node() hook needs to:
return array($type1 => array('name' => $name1, 'base' => $base1),
$type2 => array('name' => $name2, 'base' => $base2));
where $type is the node type, $name is the human readable name of the type
and $base is used instead of <hook> for <hook>_load, <hook>_view, etc.
For example, the story module's node hook looks like this:
function story_node() {
return array('story' => array('name' => t('story'), 'base' => 'story'));
}
The page module's node hook module like:
function page_node() {
return array('page' => array('name' => t('page'), 'base' => 'page'));
}
However, more complex node modules like the project module and the
flexinode module can use the 'base' parameter to specify a different base.
The project module implements two node types, proejcts and issues, so it
can do:
function project_node() {
return array(
array('project_project' => array('name' => t('project'), 'base' => 'project'),
array('project_issue' => array('name' => t('issue'), 'base' => 'project_issue'));
}
In the flexinode module's case there can only one base ...
This hook will simplify the CCK, and will make it easy (or easier) to merge
the story and page module.
In addition, node_list() became node_get_types(). In addition, we created
the following functions: node_get_name($type) and node_get_base($type).
2005-08-28 15:29:34 +00:00
|
|
|
return array('page' => array('name' => t('page'), 'base' => 'page'));
|
2001-12-05 18:46:24 +00:00
|
|
|
}
|
|
|
|
|
2004-03-10 09:32:46 +00:00
|
|
|
/**
|
2004-05-09 19:28:43 +00:00
|
|
|
* Implementation of hook_access().
|
2004-03-10 09:32:46 +00:00
|
|
|
*/
|
2001-12-05 18:46:24 +00:00
|
|
|
function page_access($op, $node) {
|
2004-03-10 09:32:46 +00:00
|
|
|
global $user;
|
|
|
|
|
2004-05-09 19:28:43 +00:00
|
|
|
if ($op == 'create') {
|
2004-03-10 09:32:46 +00:00
|
|
|
return user_access('create pages');
|
2002-12-10 20:35:20 +00:00
|
|
|
}
|
|
|
|
|
2004-07-31 09:30:09 +00:00
|
|
|
if ($op == 'update' || $op == 'delete') {
|
|
|
|
if (user_access('edit own pages') && ($user->uid == $node->uid)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-12-10 20:35:20 +00:00
|
|
|
}
|
2001-12-05 18:46:24 +00:00
|
|
|
}
|
|
|
|
|
2004-03-10 09:32:46 +00:00
|
|
|
/**
|
2004-06-18 15:04:37 +00:00
|
|
|
* Implementation of hook_menu().
|
2004-03-10 09:32:46 +00:00
|
|
|
*/
|
2004-09-16 07:17:56 +00:00
|
|
|
function page_menu($may_cache) {
|
2004-06-18 15:04:37 +00:00
|
|
|
$items = array();
|
2004-09-16 07:17:56 +00:00
|
|
|
|
|
|
|
if ($may_cache) {
|
|
|
|
$items[] = array('path' => 'node/add/page', 'title' => t('page'),
|
|
|
|
'access' => page_access('create', NULL));
|
|
|
|
}
|
|
|
|
|
2004-06-18 15:04:37 +00:00
|
|
|
return $items;
|
2001-12-05 18:46:24 +00:00
|
|
|
}
|
|
|
|
|
2005-09-23 08:47:13 +00:00
|
|
|
/**
|
|
|
|
* Implementation of hook_validate().
|
|
|
|
*/
|
|
|
|
function page_validate(&$node) {
|
|
|
|
node_validate_title($node);
|
|
|
|
}
|
|
|
|
|
2004-03-10 09:32:46 +00:00
|
|
|
/**
|
2004-05-09 19:28:43 +00:00
|
|
|
* Implementation of hook_form().
|
2004-03-10 09:32:46 +00:00
|
|
|
*/
|
2004-07-04 16:50:02 +00:00
|
|
|
function page_form(&$node) {
|
2005-10-07 06:11:12 +00:00
|
|
|
|
2005-10-11 19:44:35 +00:00
|
|
|
$form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#size' => 60, '#maxlength' => 128, '#required' => TRUE, '#default_value' => $node->title);
|
2002-05-19 23:05:05 +00:00
|
|
|
|
2005-10-07 06:11:12 +00:00
|
|
|
$form['body'] = array(
|
2005-10-11 19:44:35 +00:00
|
|
|
'#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#required' => TRUE
|
2005-10-07 06:11:12 +00:00
|
|
|
);
|
|
|
|
$form = array_merge($form, filter_form($node->format));
|
2004-03-10 09:32:46 +00:00
|
|
|
|
2005-10-07 06:11:12 +00:00
|
|
|
$form['log'] = array(
|
2005-10-28 14:04:20 +00:00
|
|
|
'#type' => 'fieldset', '#title' => t('Log message'), '#collapsible' => TRUE, '#collapsed' => TRUE
|
|
|
|
);
|
|
|
|
$form['log']['message'] = array(
|
|
|
|
'#type' => 'textarea', '#default_value' => $node->log, '#rows' => 5,
|
2005-10-11 19:44:35 +00:00
|
|
|
'#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.')
|
2005-10-07 06:11:12 +00:00
|
|
|
);
|
2005-10-07 06:51:43 +00:00
|
|
|
|
2005-10-07 06:11:12 +00:00
|
|
|
return $form;
|
2001-12-05 18:46:24 +00:00
|
|
|
}
|
|
|
|
|
2005-08-25 21:14:17 +00:00
|
|
|
|