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
|
|
|
/**
|
- 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
|
|
|
* Implementation of hook_node().
|
2004-03-10 09:32:46 +00:00
|
|
|
*/
|
- 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
|
|
|
function page_node() {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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) {
|
2004-05-09 19:28:43 +00:00
|
|
|
if (function_exists('taxonomy_node_form')) {
|
|
|
|
$output .= implode('', taxonomy_node_form('page', $node));
|
2002-05-19 23:05:05 +00:00
|
|
|
}
|
|
|
|
|
The Input formats - filter patch has landed. I still need to make update instructions for modules and update the hook docs.
Here's an overview of the changes:
1) Multiple Input formats: they are complete filter configurations (what filters to use, in what order and with which settings). Input formats are admin-definable, and usage of them is role-dependant. For example, you can set it up so that regular users can only use limited HTML, while admins can free HTML without any tag limitations.
The input format can be chosen per content item (nodes, comments, blocks, ...) when you add/edit them. If only a single format is available, there is no choice, and nothing changes with before.
The default install (and the upgrade) contains a basic set of formats which should satisfy the average user's needs.
2) Filters have toggles
Because now you might want to enable a filter only on some input formats, an explicit toggle is provided by the filter system. Modules do not need to worry about it and filters that still have their own on/off switch should get rid of it.
3) Multiple filters per module
This was necessary to accomodate the next change, and it's also a logical extension of the filter system.
4) Embedded PHP is now a filter
Thanks to the multiple input formats, I was able to move the 'embedded PHP' feature from block.module, page.module and book.module into a simple filter which executes PHP code. This filter is part of filter.module, and by default there is an input format 'PHP', restricted to the administrator only, which contains this filter.
This change means that block.module now passes custom block contents through the filter system.
As well as from reducing code duplication and avoiding two type selectors for page/book nodes, you can now combine PHP code with other filters.
5) User-supplied PHP code now requires <?php ?> tags.
This is required for teasers to work with PHP code. Because PHP evaluation is now just another step in the filter process, we can't do this. Also, because teasers are generated before filtering, this would result in errors when the teaser generation would cut off a piece of PHP code.
Also, regular PHP syntax explicitly includes the <?php ?> tags for PHP files, so it makes sense to use the same convention for embedded PHP in Drupal.
6) Filter caching was added.
Benchmarking shows that even for a simple setup (basic html filtering + legacy URL rewriting), filtercache can offer speedups. Unlike the old filtercache, this uses the normal cache table.
7) Filtertips were moved from help into a hook_filter_tips(). This was required to accomodate the fact that there are multiple filters per module, and that filter settings are format dependant. Shoehorning filter tips into _help was ugly and silly. The display of the filter tips is done through the input format selector, so filter_tips_short() no longer exists.
8) A more intelligent linebreak convertor was added, which doesn't stop working if you use block-level tags and which adds <p> tags.
2004-08-10 18:34:29 +00:00
|
|
|
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
|
2004-09-28 19:13:03 +00:00
|
|
|
$output .= filter_form('format', $node->format);
|
2004-03-10 09:32:46 +00:00
|
|
|
|
2001-12-05 18:46:24 +00:00
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
2005-08-25 21:14:17 +00:00
|
|
|
|