summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--database/database.mysql3
-rw-r--r--database/database.pgsql3
-rw-r--r--database/updates.inc12
-rw-r--r--includes/common.inc11
-rw-r--r--includes/menu.inc636
-rw-r--r--includes/theme.inc21
-rw-r--r--index.php7
-rw-r--r--misc/drupal.css1
-rw-r--r--modules/admin.module15
-rw-r--r--modules/aggregator.module186
-rw-r--r--modules/aggregator/aggregator.module186
-rw-r--r--modules/archive.module38
-rw-r--r--modules/archive/archive.module38
-rw-r--r--modules/block.module58
-rw-r--r--modules/block/block.module58
-rw-r--r--modules/blog.module59
-rw-r--r--modules/blog/blog.module59
-rw-r--r--modules/blogapi.module6
-rw-r--r--modules/blogapi/blogapi.module6
-rw-r--r--modules/book.module82
-rw-r--r--modules/book/book.module82
-rw-r--r--modules/comment.module227
-rw-r--r--modules/comment/comment.module227
-rw-r--r--modules/drupal.module28
-rw-r--r--modules/drupal/drupal.module28
-rw-r--r--modules/filter.module29
-rw-r--r--modules/filter/filter.module29
-rw-r--r--modules/forum.module71
-rw-r--r--modules/forum/forum.module71
-rw-r--r--modules/help.module19
-rw-r--r--modules/help/help.module19
-rw-r--r--modules/locale.module132
-rw-r--r--modules/locale/locale.module132
-rw-r--r--modules/menu.module140
-rw-r--r--modules/menu/menu.module140
-rw-r--r--modules/node.module183
-rw-r--r--modules/node/node.module183
-rw-r--r--modules/page.module35
-rw-r--r--modules/page/page.module35
-rw-r--r--modules/path.module53
-rw-r--r--modules/path/path.module53
-rw-r--r--modules/ping.module2
-rw-r--r--modules/ping/ping.module2
-rw-r--r--modules/poll.module30
-rw-r--r--modules/poll/poll.module30
-rw-r--r--modules/profile.module99
-rw-r--r--modules/profile/profile.module99
-rw-r--r--modules/queue.module187
-rw-r--r--modules/search.module360
-rw-r--r--modules/search/search.module360
-rw-r--r--modules/statistics.module51
-rw-r--r--modules/statistics/statistics.module51
-rw-r--r--modules/story.module24
-rw-r--r--modules/story/story.module24
-rw-r--r--modules/system.module373
-rw-r--r--modules/system/system.module373
-rw-r--r--modules/taxonomy.module630
-rw-r--r--modules/taxonomy/taxonomy.module630
-rw-r--r--modules/throttle.module8
-rw-r--r--modules/throttle/throttle.module8
-rw-r--r--modules/title.module17
-rw-r--r--modules/tracker.module19
-rw-r--r--modules/tracker/tracker.module19
-rw-r--r--modules/user.module192
-rw-r--r--modules/user/user.module192
-rw-r--r--modules/watchdog.module41
-rw-r--r--modules/watchdog/watchdog.module41
-rw-r--r--themes/chameleon/chameleon.theme9
-rw-r--r--themes/chameleon/pure/chameleon.css2
-rw-r--r--themes/example/example.theme2
-rw-r--r--themes/xtemplate/default/xtemplate.css96
-rw-r--r--themes/xtemplate/default/xtemplate.xtmpl6
-rw-r--r--themes/xtemplate/xtemplate.theme17
73 files changed, 4351 insertions, 3044 deletions
diff --git a/database/database.mysql b/database/database.mysql
index 5515af7b2..ea8d8b454 100644
--- a/database/database.mysql
+++ b/database/database.mysql
@@ -268,8 +268,7 @@ CREATE TABLE menu (
path varchar(255) NOT NULL default '',
title varchar(255) NOT NULL default '',
weight tinyint(4) NOT NULL default '0',
- visibility int(1) unsigned NOT NULL default '0',
- status int(1) unsigned NOT NULL default '0',
+ type int(2) unsigned NOT NULL default '0',
PRIMARY KEY (mid)
) TYPE=MyISAM;
diff --git a/database/database.pgsql b/database/database.pgsql
index 3b7812599..b91616ea6 100644
--- a/database/database.pgsql
+++ b/database/database.pgsql
@@ -268,8 +268,7 @@ CREATE TABLE menu (
path varchar(255) NOT NULL default '',
title varchar(255) NOT NULL default '',
weight smallint NOT NULL default '0',
- visibility smallint NOT NULL default '0',
- status smallint NOT NULL default '0',
+ type smallint NOT NULL default '0',
PRIMARY KEY (mid)
);
diff --git a/database/updates.inc b/database/updates.inc
index d0a1b8424..c6c7f00e0 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -58,7 +58,8 @@ $sql_updates = array(
"2004-04-21" => "update_84",
"2004-04-27" => "update_85",
"2004-05-10" => "update_86",
- "2004-05-18" => "update_87"
+ "2004-05-18" => "update_87",
+ "2004-06-11" => "update_88"
);
function update_32() {
@@ -1093,6 +1094,15 @@ function update_87() {
return $ret;
}
+function update_88() {
+ $ret = array();
+ $ret[] = update_sql("ALTER TABLE {menu} DROP status");
+ $ret[] = update_sql("ALTER TABLE {menu} DROP visibility");
+ $ret[] = update_sql("ALTER TABLE {menu} ADD type INT(2) UNSIGNED DEFAULT '0' NOT NULL");
+ $ret[] = update_sql("DELETE FROM {menu}");
+ return $ret;
+}
+
function update_sql($sql) {
$edit = $_POST["edit"];
$result = db_query($sql);
diff --git a/includes/common.inc b/includes/common.inc
index 9fbb41857..ca8963d14 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2,10 +2,6 @@
/* $Id$ */
/**
- * @defgroup common Core functions
- */
-
-/**
* @name Page title
* @ingroup common
*
@@ -949,12 +945,7 @@ function format_name($object) {
$name = $object->name;
}
- if (arg(0) == "admin" and user_access("administer users")) {
- $output = l($name, "admin/user/edit/$object->uid", array("title" => t("Administer user profile.")));
- }
- else {
- $output = l($name, "user/view/$object->uid", array("title" => t("View user profile.")));
- }
+ $output = l($name, "user/$object->uid", array("title" => t("View user profile.")));
}
else if ($object->name) {
/*
diff --git a/includes/menu.inc b/includes/menu.inc
index 49f13a06c..ac035dc0d 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -6,51 +6,78 @@
* @{
*/
-define('MENU_SHOW', 0);
-define('MENU_HIDE', 1);
-define('MENU_HIDE_NOCHILD', 2);
+/**
+ * Flags for use in the "type" attribute of menu items.
+ */
+define('MENU_IS_ROOT', 0x0001);
+define('MENU_VISIBLE_IN_TREE', 0x0002);
+define('MENU_VISIBLE_IN_BREADCRUMB', 0x0004);
+define('MENU_VISIBLE_IF_HAS_CHILDREN', 0x0008);
+define('MENU_MODIFIABLE_BY_ADMIN', 0x0010);
+define('MENU_MODIFIED_BY_ADMIN', 0x0020);
+define('MENU_CREATED_BY_ADMIN', 0x0040);
+define('MENU_IS_LOCAL_TASK', 0x0080);
+define('MENU_IS_LOCAL_SUBTASK', 0x0100);
-define('MENU_NORMAL', 0);
-define('MENU_MODIFIED', 1);
-define('MENU_LOCKED', 2);
-define('MENU_CUSTOM', 3);
+/**
+ * Normal menu items show up in the menu tree and can be moved/hidden by
+ * the administrator.
+ */
+define('MENU_NORMAL_ITEM', MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB | MENU_MODIFIABLE_BY_ADMIN);
-define('MENU_FALLTHROUGH', 0);
-define('MENU_DENIED', 1);
-define('MENU_FOUND', 2);
+/**
+ * Item groupings are used for pages like "node/add" that simply list
+ * subpages to visit.
+ */
+define('MENU_ITEM_GROUPING', MENU_VISIBLE_IF_HAS_CHILDREN | MENU_VISIBLE_IN_BREADCRUMB | MENU_MODIFIABLE_BY_ADMIN);
-/** @} */
+/**
+ * Callbacks simply register a path so that the correct function is fired
+ * when the URL is accessed.
+ */
+define('MENU_CALLBACK', MENU_VISIBLE_IN_BREADCRUMB);
/**
- * Register a menu item with the menu system.
- *
- * @ingroup menu
- * @param $path Location the menu item refers to. Do not add a trailing slash.
- * @param $title The title of the menu item to show in the rendered menu.
- * @param $callback
- * - string - The function to call when this is the active menu item.
- * - MENU_FALLTHROUGH - Use the callback defined by the menu item's parent.
- * - MENU_DENIED - Deny access to this menu item by this user.
- * @param $weight Heavier menu items sink down the menu.
- * @param $visibility
- * - MENU_SHOW - Show the menu item (default).
- * - MENU_HIDE - Hide the menu item, but register a callback.
- * - MENU_HIDE_NOCHILD - Hide the menu item when it has no children.
- * @param $status
- * - MENU_NORMAL - The menu item can be moved (default).
- * - MENU_LOCKED - The administrator may not modify the item.
- */
-function menu($path, $title, $callback = MENU_FALLTHROUGH, $weight = 0, $visibility = MENU_SHOW, $status = MENU_NORMAL) {
- global $_menu;
+ * Dynamic menu items change frequently, and so should not be stored in the
+ * database for administrative customization.
+ */
+define('MENU_DYNAMIC_ITEM', MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB);
- // add the menu to the flat list of menu items:
- $_menu['list'][$path] = array('title' => $title, 'callback' => $callback, 'weight' => $weight, 'visibility' => $visibility, 'status' => $status);
-}
+/**
+ * Modules may "suggest" menu items that the administrator may enable.
+ */
+define('MENU_SUGGESTED_ITEM', MENU_MODIFIABLE_BY_ADMIN);
+
+/**
+ * Local tasks are rendered as tabs by default.
+ */
+define('MENU_LOCAL_TASK', MENU_IS_LOCAL_TASK);
+
+/**
+ * Local subtasks are rendered as a horizontal listing below the tabs by default.
+ */
+define('MENU_LOCAL_SUBTASK', MENU_IS_LOCAL_SUBTASK);
+
+/**
+ * Custom items are those defined by the administrator.
+ */
+define('MENU_CUSTOM_ITEM', MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB | MENU_CREATED_BY_ADMIN | MENU_MODIFIABLE_BY_ADMIN);
+
+/**
+ * Custom menus are those defined by the administrator.
+ */
+define('MENU_CUSTOM_MENU', MENU_IS_ROOT | MENU_VISIBLE_IN_TREE | MENU_CREATED_BY_ADMIN | MENU_MODIFIABLE_BY_ADMIN);
+
+/**
+ * Status codes for menu callbacks.
+ */
+define('MENU_FOUND', 1);
+define('MENU_NOT_FOUND', 2);
+define('MENU_ACCESS_DENIED', 3);
/**
* Return the menu data structure.
*
- * @ingroup menu
* The returned structure contains much information that is useful only
* internally in the menu system. External modules are likely to need only
* the ['visible'] element of the returned array. All menu items that are
@@ -76,38 +103,117 @@ function menu_get_menu() {
global $user;
if (!isset($_menu['items'])) {
- menu_build();
+ _menu_build();
}
return $_menu;
}
/**
- * Returns an array with the menu items that lead to the specified path.
+ * Change the current menu location of the user.
+ *
+ * Frequently, modules may want to make a page or node act as if it were
+ * in the menu tree somewhere, even though it was not registered in a
+ * hook_menu() implementation. If the administrator has rearranged the menu,
+ * the newly set location should respect this in the breadcrumb trail and
+ * expanded/collapsed status of menu items in the tree. This function
+ * allows this behavior.
+ *
+ * @param $location
+ * An array specifying a complete or partial breadcrumb trail for the
+ * new location, in the same format as the return value of hook_menu().
+ * The last element of this array should be the new location itself.
+ *
+ * This function will set the new breadcrumb trail to the passed-in value,
+ * but if any elements of this trail are visible in the site tree, the
+ * trail will be "spliced in" to the existing site navigation at that point.
*/
-function menu_get_trail($path) {
- $menu = menu_get_menu();
+function menu_set_location($location) {
+ global $_menu;
+ $temp_id = min(array_keys($_menu['items'])) - 1;
+ $prev_id = 0;
+
+ foreach (array_reverse($location) as $item) {
+ if (isset($_menu['path index'][$item['path']])) {
+ $mid = $_menu['path index'][$item['path']];
+ if (isset ($_menu['visible'][$mid])) {
+ // Splice in the breadcrumb at this location.
+ if ($prev_id) {
+ $_menu['items'][$prev_id]['pid'] = $mid;
+ }
+ $prev_id = 0;
+ break;
+ }
+ else {
+ // A hidden item; show it, but only temporarily.
+ $_menu['items'][$mid]['type'] |= MENU_VISIBLE_IN_BREADCRUMB;
+ if ($prev_id) {
+ $_menu['items'][$prev_id]['pid'] = $mid;
+ }
+ $prev_id = $mid;
+ }
+ }
+ else {
+ $item['type'] |= MENU_VISIBLE_IN_BREADCRUMB;
+ if ($prev_id) {
+ $_menu['items'][$prev_id]['pid'] = $temp_id;
+ }
+ $_menu['items'][$temp_id] = $item;
+ $_menu['path index'][$item['path']] = $temp_id;
- $trail = array();
+ $prev_id = $temp_id;
+ $temp_id--;
+ }
+ }
- // Find the ID of the given path.
- while ($path && !$menu['path index'][$path]) {
+ if ($prev_id) {
+ // Didn't find a home, so attach this to the main navigation menu.
+ $_menu['items'][$prev_id]['pid'] = 1;
+ }
+
+ $final_item = array_pop($location);
+ menu_set_active_item($final_item['path']);
+}
+
+/**
+ * Execute the handler associated with the active menu item.
+ *
+ * This is called early in the page request. The active menu item is at
+ * this point determined excusively by the URL. The handler that is called
+ * here may, as a side effect, change the active menu item so that later
+ * menu functions (that display the menus and breadcrumbs, for example)
+ * act as if the user were in a different location on the site.
+ */
+function menu_execute_active_handler() {
+ $menu = menu_get_menu();
+
+ // Determine the menu item containing the callback.
+ $path = $_GET['q'];
+ while ($path && (!$menu['path index'][$path] || !$menu['items'][$menu['path index'][$path]]['callback'])) {
$path = substr($path, 0, strrpos($path, '/'));
}
$mid = $menu['path index'][$path];
- // Follow the parents up the chain to get the trail.
- while ($mid && $menu['items'][$mid]) {
- array_unshift($trail, $mid);
- $mid = $menu['items'][$mid]['pid'];
+ if (!is_string($menu['items'][$mid]['callback'])) {
+ return MENU_NOT_FOUND;
}
- return $trail;
+ if (!_menu_item_is_accessible(menu_get_active_item())) {
+ return MENU_ACCESS_DENIED;
+ }
+
+ // We found one, and are allowed to execute it.
+ $arguments = $menu['items'][$mid]['callback arguments'] ? $menu['items'][$mid]['callback arguments'] : array();
+ $arg = substr($_GET['q'], strlen($menu['items'][$mid]['path']) + 1);
+ if (strlen($arg)) {
+ $arguments = array_merge($arguments, explode('/', $arg));
+ }
+ call_user_func_array($menu['items'][$mid]['callback'], $arguments);
+ return MENU_FOUND;
}
/**
* Returns the ID of the active menu item.
- * @ingroup menu
*/
function menu_get_active_item() {
return menu_set_active_item();
@@ -115,7 +221,6 @@ function menu_get_active_item() {
/**
* Sets the path of the active menu item.
- * @ingroup menu
*/
function menu_set_active_item($path = NULL) {
static $stored_mid;
@@ -139,12 +244,30 @@ function menu_set_active_item($path = NULL) {
}
/**
+ * Returns the ID of the current menu item or, if the current item is a
+ * local task, the menu item to which this task is attached.
+ */
+function menu_get_active_nontask_item() {
+ $menu = menu_get_menu();
+ $mid = menu_get_active_item();
+
+ // Find the first non-task item:
+ while ($mid && (($menu['items'][$mid]['type'] & MENU_LOCAL_TASK) || ($menu['items'][$mid]['type'] & MENU_LOCAL_SUBTASK))) {
+ $mid = $menu['items'][$mid]['pid'];
+ }
+
+ if ($mid) {
+ return $mid;
+ }
+}
+
+/**
* Returns the title of the active menu item.
*/
function menu_get_active_title() {
$menu = menu_get_menu();
- if ($mid = menu_get_active_item()) {
+ if ($mid = menu_get_active_nontask_item()) {
return ucfirst($menu['items'][$mid]['title']);
}
}
@@ -153,19 +276,21 @@ function menu_get_active_title() {
* Returns the help associated with the active menu item.
*/
function menu_get_active_help() {
+ $path = $_GET['q'];
+ $output = '';
- if (menu_active_handler_exists()) {
- $path = $_GET['q'];
- $output = '';
+ if (!_menu_item_is_accessible(menu_get_active_item())) {
+ // Don't return help text for areas the user cannot access.
+ return;
+ }
- $return = module_invoke_all('help', $path);
- foreach ($return as $item) {
- if (!empty($item)) {
- $output .= $item ."\n";
- }
+ $return = module_invoke_all('help', $path);
+ foreach ($return as $item) {
+ if (!empty($item)) {
+ $output .= $item ."\n";
}
- return $output;
}
+ return $output;
}
/**
@@ -176,105 +301,96 @@ function menu_get_active_breadcrumb() {
$links[] = l(t('Home'), '');
- $trail = menu_get_trail(drupal_get_path_alias($_GET['q']));
-
- // The last item in the trail is the page title; don't display it here.
- array_pop($trail);
-
+ $trail = _menu_get_trail($_GET['q']);
foreach ($trail as $mid) {
- // Don't show hidden menu items or items without valid link targets.
- if (isset($menu['visible'][$mid]) && $menu['items'][$mid]['path'] != '') {
- $links[] = _menu_render_item($mid);
+ if ($menu['items'][$mid]['type'] & MENU_VISIBLE_IN_BREADCRUMB) {
+ $links[] = theme('menu_item', $mid);
}
}
+ // The last item in the trail is the page title; don't display it here.
+ array_pop($links);
+
return $links;
}
/**
- * Execute the handler associated with the active menu item.
+ * Returns true when the menu item is in the active trail.
*/
-function menu_execute_active_handler() {
- $menu = menu_get_menu();
-
- $path = $_GET['q'];
- while ($path && (!$menu['path index'][$path] || $menu['items'][$menu['path index'][$path]]['callback'] === MENU_FALLTHROUGH)) {
- $path = substr($path, 0, strrpos($path, '/'));
- }
- $mid = $menu['path index'][$path];
- if ($menu['items'][$mid]['callback'] === MENU_DENIED) {
- return MENU_DENIED;
- }
+function menu_in_active_trail($mid) {
+ static $trail;
- if (is_string($menu['items'][$mid]['callback'])) {
- $arg = substr($_GET['q'], strlen($menu['items'][$mid]['path']) + 1);
- if (strlen($arg)) {
- call_user_func_array($menu['items'][$mid]['callback'], explode('/', $arg));
- }
- else {
- call_user_func($menu['items'][$mid]['callback']);
- }
- return MENU_FOUND;
+ if (empty($trail)) {
+ $trail = _menu_get_trail($_GET['q']);
}
- return MENU_FALLTHROUGH;
+ return in_array($mid, $trail);
}
/**
- * Return true if a valid callback can be called from the current path.
+ * Populate the database representation of the menu.
+ *
+ * This need only be called at the start of pages that modify the menu.
*/
-function menu_active_handler_exists() {
+function menu_rebuild() {
+ cache_clear_all();
+ _menu_build();
$menu = menu_get_menu();
- $path = $_GET['q'];
- while ($path && (!$menu['path index'][$path] || $menu['items'][$menu['path index'][$path]]['callback'] === MENU_FALLTHROUGH)) {
- $path = substr($path, 0, strrpos($path, '/'));
- }
- $mid = $menu['path index'][$path];
+ $new_items = array();
+ foreach ($menu['items'] as $mid => $item) {
+ if ($mid < 0 && ($item['type'] & MENU_MODIFIABLE_BY_ADMIN)) {
+ $new_mid = db_next_id('menu_mid');
+ if (isset($new_items[$item['pid']])) {
+ $new_pid = $new_items[$item['pid']]['mid'];
+ }
+ else {
+ $new_pid = $item['pid'];
+ }
- if ($menu['items'][$mid]['callback'] === MENU_FALLTHROUGH) {
- return FALSE;
+ // Fix parent IDs for menu items already added.
+ if ($item['children']) {
+ foreach ($item['children'] as $child) {
+ if (isset($new_items[$child])) {
+ $new_items[$child]['pid'] = $new_mid;
+ }
+ }
+ }
+
+ $new_items[$mid] = array('mid' => $new_mid, 'pid' => $new_pid, 'path' => $item['path'], 'title' => $item['title'], 'weight' => $item['weight'], 'type' => $item['type']);
+ }
}
- if ($menu['items'][$mid]['callback'] === MENU_DENIED) {
- return FALSE;
+
+ foreach ($new_items as $item) {
+ db_query('INSERT INTO {menu} (mid, pid, path, title, weight, type) VALUES (%d, %d, \'%s\', \'%s\', %d, %d)', $item['mid'], $item['pid'], $item['path'], $item['title'], $item['weight'], $item['type']);
}
- return function_exists($menu['items'][$mid]['callback']);
+ // Rebuild the menu to account for any changes.
+ _menu_build();
}
+/** @} end of "menu" function group */
+
/**
- * Returns true when the path is in the active trail.
+ * @addtogroup themeable
+ * @{
*/
-function menu_in_active_trail($mid) {
- static $trail;
-
- if (empty($trail)) {
- $trail = menu_get_trail(drupal_get_path_alias($_GET['q']));
- }
-
- return in_array($mid, $trail);
-}
/**
* Returns a rendered menu tree.
*/
-function menu_tree($pid = 1) {
- static $trail;
+function theme_menu_tree($pid = 1, $all = FALSE) {
$menu = menu_get_menu();
$output = '';
- if (empty($trail)) {
- $trail = menu_get_trail($_GET['q']);
- }
-
if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) {
foreach ($menu['visible'][$pid]['children'] as $mid) {
$style = (count($menu['visible'][$mid]['children']) ? (menu_in_active_trail($mid) ? 'expanded' : 'collapsed') : 'leaf');
$output .= "<li class=\"$style\">";
- $output .= _menu_render_item($mid);
- if (menu_in_active_trail($mid)) {
- $output .= menu_tree($mid);
+ $output .= theme('menu_item', $mid);
+ if ($all || menu_in_active_trail($mid)) {
+ $output .= theme('menu_tree', $mid);
}
$output .= "</li>\n";
}
@@ -288,29 +404,166 @@ function menu_tree($pid = 1) {
}
/**
+ * Generate the HTML representing a given menu item ID.
+ *
+ * @param $mid
+ * The menu ID to render.
+ */
+function theme_menu_item($mid) {
+ $menu = menu_get_menu();
+
+ return l($menu['items'][$mid]['title'], $menu['items'][$mid]['path']);
+}
+
+/**
+ * Returns the rendered local tasks. The default implementation renders
+ * them as tabs.
+ */
+function theme_menu_local_tasks() {
+
+ $active = true;
+
+ if ($mid = menu_get_active_nontask_item()) {
+ $menu = menu_get_menu();
+
+ if ($children = $menu['items'][$mid]['children']) {
+ foreach ($menu['items'][$mid]['children'] as $cid) {
+ if (($menu['items'][$cid]['type'] & MENU_IS_LOCAL_TASK) && _menu_item_is_accessible($cid)) {
+ if (menu_in_active_trail($cid)) {
+ $tabs[] = theme('menu_local_task', $cid, TRUE);
+ $active = false;
+ }
+ else {
+ $tabs[] = theme('menu_local_task', $cid, FALSE);
+ }
+ }
+ }
+
+ if ($tabs) {
+ // We add a default view-tab for the parent:
+ $output = "<ul class=\"tabs primary\">\n";
+ $output .= theme('menu_local_task', $mid, $active);
+ $output .= implode($tabs);
+ $output .= "</ul>\n";
+ }
+ }
+ }
+
+ return $output;
+}
+
+/**
+ * Generate the HTML representing a given menu item ID as a set of tabs.
+ *
+ * @param $mid
+ * The menu ID to render.
+ * @param $active
+ * Whether this tab or a subtab is the active menu item.
+ */
+function theme_menu_local_task($mid, $active) {
+ if ($active) {
+ return '<li class="active">'. theme('menu_item', $mid) . theme('menu_local_subtasks', $mid) ."</li>\n";
+ }
+ else {
+ return '<li>'. theme('menu_item', $mid) ."</li>\n";
+ }
+}
+
+/**
+ * Generate the HTML representing the children of a given menu item ID
+ * as a set of tabs.
+ *
+ * @param $pid
+ * The menu ID of the parent item.
+ */
+function theme_menu_local_subtasks($pid) {
+ $menu = menu_get_menu();
+
+ $tabs = '';
+ if ($children = $menu['items'][$pid]['children']) {
+ foreach ($children as $cid) {
+ if (_menu_item_is_accessible($cid) && ($menu['items'][$cid]['type'] & MENU_IS_LOCAL_SUBTASK)) {
+ $tabs .= theme('menu_local_task', $cid, menu_in_active_trail($cid));
+ }
+ }
+
+ if ($tabs) {
+ return "<ul class=\"tabs secondary\">$tabs</ul>\n";
+ }
+ }
+}
+
+/** @} End of addtogroup themeable */
+
+/**
+ * Returns an array with the menu items that lead to the specified path.
+ */
+function _menu_get_trail($path) {
+ $menu = menu_get_menu();
+
+ $trail = array();
+
+ // Find the ID of the given path.
+ while ($path && !$menu['path index'][$path]) {
+ $path = substr($path, 0, strrpos($path, '/'));
+ }
+ $mid = $menu['path index'][$path];
+
+ // Follow the parents up the chain to get the trail.
+ while ($mid && $menu['items'][$mid]) {
+ array_unshift($trail, $mid);
+ $mid = $menu['items'][$mid]['pid'];
+ }
+
+ return $trail;
+}
+
+/**
+ * Comparator routine for use in sorting menu items.
+ */
+function _menu_sort($a, $b) {
+ $menu = menu_get_menu();
+
+ $a = &$menu['items'][$a];
+ $b = &$menu['items'][$b];
+
+ return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1));
+}
+
+/**
* Build the menu by querying both modules and the database.
*/
-function menu_build() {
+function _menu_build() {
global $_menu;
global $user;
// Start from a clean slate.
$_menu = array();
- // Build a sequential list of all menu items.
- module_invoke_all('link', 'system');
-
$_menu['path index'] = array();
// Set up items array, including default "Navigation" menu.
- $_menu['items'] = array(0 => array(), 1 => array('pid' => 0, 'title' => t('Navigation'), 'weight' => -50, 'visibility' => MENU_SHOW, 'status' => MENU_LOCKED));
+ $_menu['items'] = array(
+ 0 => array('type' => MENU_IS_ROOT),
+ 1 => array('pid' => 0, 'title' => t('Navigation'), 'weight' => -50, 'access' => TRUE, 'type' => MENU_IS_ROOT | MENU_VISIBLE_IN_TREE)
+ );
+
+ // Build a sequential list of all menu items.
+ $menu_item_list = module_invoke_all('menu');
// Menu items not in the DB get temporary negative IDs.
$temp_mid = -1;
- foreach ($_menu['list'] as $path => $data) {
+ foreach ($menu_item_list as $item) {
+ if (!isset($item['type'])) {
+ $item['type'] = MENU_NORMAL_ITEM;
+ }
$mid = $temp_mid;
- $_menu['items'][$mid] = array('path' => $path, 'title' => $data['title'], 'callback' => $data['callback'], 'weight' => $data['weight'], 'visibility' => $data['visibility'], 'status' => $data['status']);
- $_menu['path index'][$path] = $mid;
+ if (isset($_menu['path index'][$item['path']])) {
+ // Newer menu items overwrite older ones.
+ unset($_menu['items'][$_menu['path index'][$item['path']]]);
+ }
+ $_menu['items'][$mid] = $item;
+ $_menu['path index'][$item['path']] = $mid;
$temp_mid--;
}
@@ -319,25 +572,24 @@ function menu_build() {
if (module_exist('menu')) {
$result = db_query('SELECT * FROM {menu}');
while ($item = db_fetch_object($result)) {
- // First, add any custom items added by the administrator.
- if ($item->status == MENU_CUSTOM) {
- $_menu['items'][$item->mid] = array('pid' => $item->pid, 'path' => $item->path, 'title' => $item->title, 'callback' => MENU_FALLTHROUGH, 'weight' => $item->weight, 'visibility' => MENU_SHOW, 'status' => MENU_CUSTOM);
- $_menu['path index'][$item->path] = $item->mid;
- }
// Don't display non-custom menu items if no module declared them.
- else if ($old_mid = $_menu['path index'][$item->path]) {
+ if ($old_mid = $_menu['path index'][$item->path]) {
$_menu['items'][$item->mid] = $_menu['items'][$old_mid];
unset($_menu['items'][$old_mid]);
$_menu['path index'][$item->path] = $item->mid;
// If administrator has changed item position, reflect the change.
- if ($item->status == MENU_MODIFIED) {
+ if ($item->type & MENU_MODIFIED_BY_ADMIN) {
$_menu['items'][$item->mid]['title'] = $item->title;
$_menu['items'][$item->mid]['pid'] = $item->pid;
$_menu['items'][$item->mid]['weight'] = $item->weight;
- $_menu['items'][$item->mid]['visibility'] = $item->visibility;
- $_menu['items'][$item->mid]['status'] = $item->status;
+ $_menu['items'][$item->mid]['type'] = $item->type;
}
}
+ // Next, add any custom items added by the administrator.
+ else if ($item->type & MENU_CREATED_BY_ADMIN) {
+ $_menu['items'][$item->mid] = array('pid' => $item->pid, 'path' => $item->path, 'title' => $item->title, 'access' => TRUE, 'weight' => $item->weight, 'type' => $item->type);
+ $_menu['path index'][$item->path] = $item->mid;
+ }
}
}
@@ -372,7 +624,29 @@ function menu_build() {
}
// Prepare to display trees to the user as required.
- menu_build_visible_tree();
+ _menu_build_visible_tree();
+}
+
+/**
+ * Determine whether the given menu item is accessible to the current user.
+ *
+ * Use this instead of just checking the "access" property of a menu item
+ * to properly handle items with fall-through semantics.
+ */
+function _menu_item_is_accessible($mid) {
+ $menu = menu_get_menu();
+
+ if (isset($menu['items'][$mid]['access'])) {
+ return $menu['items'][$mid]['access'];
+ }
+
+ // Follow the path up to find the actual callback.
+ $path = $menu['items'][$mid]['path'];
+ while ($path && (!$menu['path index'][$path] || !$menu['items'][$menu['path index'][$path]]['callback'])) {
+ $path = substr($path, 0, strrpos($path, '/'));
+ }
+ $callback_mid = $menu['path index'][$path];
+ return $menu['items'][$callback_mid]['access'];
}
/**
@@ -381,7 +655,7 @@ function menu_build() {
* Since this is only for display, we only need title, path, and children
* for each item.
*/
-function menu_build_visible_tree($pid = 0) {
+function _menu_build_visible_tree($pid = 0) {
global $_menu;
if (isset($_menu['items'][$pid])) {
@@ -391,26 +665,14 @@ function menu_build_visible_tree($pid = 0) {
if ($parent['children']) {
usort($parent['children'], '_menu_sort');
foreach ($parent['children'] as $mid) {
- $children = array_merge($children, menu_build_visible_tree($mid));
- }
- }
- $visible = ($parent['visibility'] == MENU_SHOW) ||
- ($parent['visibility'] == MENU_HIDE_NOCHILD && count($children) > 0);
-
- if ($parent['callback'] === MENU_FALLTHROUGH) {
- // Follow the path up to find the actual callback.
- $path = $parent['path'];
- while ($path && (!$_menu['path index'][$path] || $_menu['items'][$_menu['path index'][$path]]['callback'] === MENU_FALLTHROUGH)) {
- $path = substr($path, 0, strrpos($path, '/'));
+ $children = array_merge($children, _menu_build_visible_tree($mid));
}
- $callback_mid = $_menu['path index'][$path];
- $allowed = $_menu['items'][$callback_mid]['callback'] !== MENU_DENIED;
- }
- else {
- $allowed = $parent['callback'] !== MENU_DENIED;
}
+ $visible = ($parent['type'] & MENU_VISIBLE_IN_TREE) ||
+ ($parent['type'] & MENU_VISIBLE_IF_HAS_CHILDREN && count($children) > 0);
+ $allowed = _menu_item_is_accessible($pid);
- if ($visible && $allowed) {
+ if (($parent['type'] & MENU_IS_ROOT) || ($visible && $allowed)) {
$_menu['visible'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children);
foreach ($children as $mid) {
$_menu['visible'][$mid]['pid'] = $pid;
@@ -425,66 +687,4 @@ function menu_build_visible_tree($pid = 0) {
return array();
}
-/**
- * Populate the database representation of the menu.
- *
- * @ingroup menu
- * This need only be called at the start of pages that modify the menu.
- */
-function menu_rebuild() {
- cache_clear_all();
- menu_build();
- $menu = menu_get_menu();
-
- $new_items = array();
- foreach ($menu['items'] as $mid => $item) {
- if ($mid < 0 && ($item->status != MENU_LOCKED)) {
- $new_mid = db_next_id('menu_mid');
- if (isset($new_items[$item['pid']])) {
- $new_pid = $new_items[$item['pid']]['mid'];
- }
- else {
- $new_pid = $item['pid'];
- }
-
- // Fix parent IDs for menu items already added.
- if ($item['children']) {
- foreach ($item['children'] as $child) {
- if (isset($new_items[$child])) {
- $new_items[$child]['pid'] = $new_mid;
- }
- }
- }
-
- $new_items[$mid] = array('mid' => $new_mid, 'pid' => $new_pid, 'path' => $item['path'], 'title' => $item['title'], 'weight' => $item['weight'], 'visibility' => $item['visibility'], 'status' => $item['status']);
- }
- }
-
- foreach ($new_items as $item) {
- db_query('INSERT INTO {menu} (mid, pid, path, title, weight, visibility, status) VALUES (%d, %d, \'%s\', \'%s\', %d, %d, %d)', $item['mid'], $item['pid'], $item['path'], $item['title'], $item['weight'], $item['visibility'], $item['status']);
- }
-
- // Rebuild the menu to account for any changes.
- menu_build();
-}
-
-/**
- * Comparator routine for use in sorting menu items.
- */
-function _menu_sort($a, $b) {
- $menu = menu_get_menu();
-
- $a = &$menu['items'][$a];
- $b = &$menu['items'][$b];
-
- return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1));
-}
-
-function _menu_render_item($mid) {
- $menu = menu_get_menu();
-
- return l($menu['items'][$mid]['title'], $menu['items'][$mid]['path']);
-}
-
-
?>
diff --git a/includes/theme.inc b/includes/theme.inc
index 31c01afca..0e5fd05ff 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -9,7 +9,7 @@
* The theme system allows for nearly all output of the Drupal system to be
* customized by user themes.
*
- * @see <a href="http://drupal.org/node/view/253">Theme system</a>
+ * @see <a href="http://drupal.org/node/253">Theme system</a>
* @see themeable
*/
@@ -24,7 +24,7 @@ function theme_help($section) {
$output = '';
switch ($section) {
- case 'admin/system/themes#description':
+ case 'admin/themes#description':
$output = t("The base theme");
break;
}
@@ -142,6 +142,7 @@ function theme_page($content, $title = NULL, $breadcrumb = NULL) {
if (isset($title)) {
drupal_set_title($title);
}
+
if (isset($breadcrumb)) {
drupal_set_breadcrumb($breadcrumb);
}
@@ -162,6 +163,11 @@ function theme_page($content, $title = NULL, $breadcrumb = NULL) {
$output .= theme("breadcrumb", drupal_get_breadcrumb());
$output .= "<h1>" . drupal_get_title() . "</h1>";
+
+ if ($tabs = theme('menu_local_tasks')) {
+ $output .= $tabs;
+ }
+
if ($help = menu_get_active_help()) {
$output .= "<small>$help</small><hr />";
}
@@ -300,6 +306,17 @@ function theme_form_element($title, $value, $description = NULL, $id = NULL, $re
return $output;
}
+
+/**
+ * Returns themed sub menu, typically displayed under the tabs.
+ *
+ * @param $menus an associative array of links.
+ */
+
+function theme_submenu($links) {
+ return "<div class=\"submenu\">". implode(' | ', $links) ."</div>";
+}
+
/**
* Returns themed table.
*
diff --git a/index.php b/index.php
index 9ab6e6638..5356050f6 100644
--- a/index.php
+++ b/index.php
@@ -9,13 +9,12 @@ fix_gpc_magic();
$status = menu_execute_active_handler();
switch ($status) {
- case MENU_FOUND:
+ case MENU_NOT_FOUND:
+ drupal_not_found();
break;
- case MENU_DENIED:
+ case MENU_ACCESS_DENIED:
drupal_access_denied();
break;
- default:
- drupal_not_found();
}
drupal_page_footer();
diff --git a/misc/drupal.css b/misc/drupal.css
index 62a74c942..4d3ac13fa 100644
--- a/misc/drupal.css
+++ b/misc/drupal.css
@@ -83,7 +83,6 @@ li a.active {
td.menu-disabled {
background: #ccc;
}
-
/*
** Other common styles
*/
diff --git a/modules/admin.module b/modules/admin.module
index b4f5e9c27..3bb035246 100644
--- a/modules/admin.module
+++ b/modules/admin.module
@@ -6,7 +6,7 @@
*/
function admin_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Handles the administration pages.');
case 'admin':
return t('Welcome to the administration section. Below are the most recent system events.');
@@ -14,12 +14,15 @@ function admin_help($section) {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function admin_link($type) {
- if ($type == 'system') {
- menu('admin', t('administer'), user_access('access administration pages') ? 'admin_main_page' : MENU_DENIED, 9);
- }
+function admin_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin', 'title' => t('administer'),
+ 'access' => user_access('access administration pages'),
+ 'callback' => 'admin_main_page',
+ 'weight' => 9);
+ return $items;
}
/**
diff --git a/modules/aggregator.module b/modules/aggregator.module
index f82f5ea27..a06d5d65a 100644
--- a/modules/aggregator.module
+++ b/modules/aggregator.module
@@ -17,8 +17,8 @@ function aggregator_help($section) {
<p>To learn much more about RSS, read Mark Pilgrim\'s <a href="http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html">What is RSS</a> and WebReference.com\'s <a href="http://www.webreference.com/authoring/languages/xml/rss/1/">The Evolution of RSS</a>.</p>
<p>NOTE: Enable your site\'s XML syndication button by turning on the Syndicate block in block management.</p>
<h3>Adding news feeds</h3>
- <p>To subscribe to an RSS feed on another site, use the <a href="%admin-news">RSS/RDF</a> administration page.</p>
- <p>Once there, select <a href="%new-feed">new feed</a> from the menu. Drupal will then ask for the following:</p>
+ <p>To subscribe to an RSS feed on another site, use the <a href="%admin-news">aggregation page</a>.</p>
+ <p>Once there, click the <a href="%new-feed">new feed</a> tab. Drupal will then ask for the following:</p>
<ul>
<li><strong>Title</strong> -- The text entered here will be used in your news aggregator, within the administration configuration section, and as title for the news feed block. As a general rule, use the web site name from which the feed originates.</li>
<li><strong>URL</strong> -- Here you\'ll enter the fully-qualified URL for the feed for the site you want to subscribe to.</li>
@@ -26,9 +26,9 @@ function aggregator_help($section) {
<li><strong>Latest items block</strong> -- The number of items selected here will determine how many of the latest items from the feed will appear in a block which may be enabled and placed in the <a href="%block">blocks</a> administration page.</li>
<li><strong>Automatically file items</strong> -- As items are recieved from a feed they will be put in the checked categories.</li>
</ul>
- <p>Once you submit your new feed, check to see if it is working properly. Select <a href="%update-items">update items</a> on the <a href="%admin-news">RSS/RDF</a> page. If you do not see any items listed for that feed, edit the feed and make sure that the URL was entered correctly.</p>
+ <p>Once you submit your new feed, check to see if it is working properly. Select <a href="%update-items">update items</a> on the <a href="%admin-news">aggregation page</a>. If you do not see any items listed for that feed, edit the feed and make sure that the URL was entered correctly.</p>
<h3>Adding categories</h3>
- <p>News items can be filed into categories. To create a category, start at the <a href="%admin-news">RSS/RDF</a> administration page.</p>
+ <p>News items can be filed into categories. To create a category, start at the <a href="%admin-news">aggregation page</a>.</p>
<p>Once there, select <a href="%new-category">new category</a> from the menu. Drupal will then ask for the following:</p>
<ul>
<li><strong>Title</strong> -- The title will be used in the <i>news by topics</i> listing in your news aggregator and with the customized block created for the bundle.</li>
@@ -53,13 +53,13 @@ function aggregator_help($section) {
<h3>Technical details</h3>
<p>Drupal automatically generates an OPML feed file that is available by selecting the XML icon on the News Sources page.</p>
<p>When fetching feeds Drupal supports conditional GETs, this reduces the bandwidth usage for feeds that have not been updated since the last check.</p>
- <p>If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.</p>', array('%block' => url('admin/system/block'), '%admin-news' => url('admin/aggregator'), '%new-feed' => url('admin/aggregator/add/feed'), '%new-category' => url('admin/aggregator/add/category'), '%update-items' => url('admin/aggregator'), '%news-aggregator' => url('aggregator'), '%sources' => url('aggregator/sources'), '%categories' => url('aggregator/categories')));
- case 'admin/system/modules#description':
+ <p>If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.</p>', array('%block' => url('admin/block'), '%admin-news' => url('admin/aggregator'), '%new-feed' => url('admin/aggregator/add/feed'), '%new-category' => url('admin/aggregator/add/category'), '%update-items' => url('admin/aggregator'), '%news-aggregator' => url('aggregator'), '%sources' => url('aggregator/sources'), '%categories' => url('aggregator/categories')));
+ case 'admin/modules#description':
return t('Used to aggregate syndicated content (RSS and RDF).');
- case 'admin/system/modules/aggregator':
+ case 'admin/settings/aggregator':
return t('These settings control the display of aggregated content.');
case 'admin/aggregator':
- return t('Several web sites, especially news related sites, syndicate parts of their site\'s content for other web sites to display. Usually, the syndicated content includes the latest headlines with a direct link to that story on the remote site. Some syndicated content also includes a description of the headline. The standard method of syndication is using the XML based Rich Site Summary (RSS) or Resource Description Framework (RDF). To get a feed to work you <strong>must</strong> have <a href=\"%cron\">cron</a> working. To display the feed or categoty in a block you must decide how many items to show by editing the feed or block and turn on the <a href="%block">feed\'s block</a>.', array('%block' => url('admin/system/block'), '%cron' => url('admin/help', NULL, 'cron')));
+ return t('Several web sites, especially news related sites, syndicate parts of their site\'s content for other web sites to display. Usually, the syndicated content includes the latest headlines with a direct link to that story on the remote site. Some syndicated content also includes a description of the headline. The standard method of syndication is using the XML based Rich Site Summary (RSS) or Resource Description Framework (RDF). To get a feed to work you <strong>must</strong> have <a href=\"%cron\">cron</a> working. To display the feed or categoty in a block you must decide how many items to show by editing the feed or block and turn on the <a href="%block">feed\'s block</a>.', array('%block' => url('admin/block'), '%cron' => url('admin/help', NULL, 'cron')));
case 'admin/aggregator/add/feed':
return t('Add a site that has an RSS/RDF feed. The URL is the full path to the RSS feed file. For the feed to update automatically you must run "cron.php". If you already have a feed with the URL you are planning to use, the system will not accept another feed with the same URL.');
case 'admin/aggregator/add/category':
@@ -74,10 +74,11 @@ function aggregator_help_page() {
print theme('page', aggregator_help('admin/help#aggregator'));
}
-/**
- * Implementation of hook_settings().
- */
-function aggregator_settings() {
+function aggregator_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
$output = '';
$number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100));
$items = array(0 => t('none'), 3 => t('3 items'), 5 => t('5 items'), 10 => t('10 items'), 15 => t('15 items'), 20 => t('20 items'), 25 => t('25 items'));
@@ -85,7 +86,7 @@ function aggregator_settings() {
$output .= form_select(t('Items shown in sources and categories pages'), 'aggregator_summary_items', variable_get('aggregator_summary_items', 3), $items, t('The number of items which will be shown with each feed or category in the feed and category summary pages.'));
$output .= form_radios(t('Category selection type'), 'aggregator_category_selector', variable_get('aggregator_category_selector', 'check'), array('check' => t('checkboxes'), 'select' => t('multiple selector')), t('The type of category selection widget which is shown on categorization pages. Checkboxes are easier to use; a multiple selector is good for working with large numbers of categories.'));
- return $output;
+ print theme('page', system_settings_form($output));
}
/**
@@ -102,43 +103,91 @@ function aggregator_link($type) {
if ($type == 'page' && user_access('access news feeds')) {
return array(l(t('news feeds'), 'aggregator', array('title' => t('Read the latest news from syndicated web sites.'))));
}
+}
- if ($type == 'system') {
- $access = user_access('administer news feeds');
- menu('admin/aggregator', t('aggregator'), $access ? 'aggregator_admin_overview' : MENU_DENIED);
- menu('admin/aggregator/add/feed', t('new feed'), $access ? 'aggregator_admin_edit_feed' : MENU_DENIED, 2);
- menu('admin/aggregator/edit/feed', t('edit feed'), $access ? 'aggregator_admin_edit_feed' : MENU_DENIED, 2, MENU_HIDE);
- menu('admin/aggregator/add/category', t('new category'), $access ? 'aggregator_admin_edit_category' : MENU_DENIED, 3);
- menu('admin/aggregator/edit/category', t('edit category'), $access ? 'aggregator_admin_edit_category' : MENU_DENIED, 3, MENU_HIDE);
- menu('admin/aggregator/remove', t('remove items'), $access ? 'aggregator_admin_remove_feed' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/aggregator/update', t('update items'), $access ? 'aggregator_admin_refresh_feed' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/aggregator/help', t('help'), $access ? 'aggregator_help_page' : MENU_DENIED, 9);
-
- $access = user_access('access news feeds');
- menu('aggregator', t('news aggregator'), $access ? 'aggregator_page_last' : MENU_DENIED, 5);
- menu('aggregator/sources', t('sources'), $access ? 'aggregator_page_sources' : MENU_DENIED, 0);
- menu('aggregator/categories', t('categories'), $access ? 'aggregator_page_categories' : MENU_DENIED, 1, MENU_HIDE_NOCHILD);
-
- // To reduce the number of SQL queries, we don't query the database when
- // not on an aggregator page.
- // If caching of the menu is implemented, this check should be removed
- // so that DHTML menu presentation can be used correctly.
- if (arg(0) == 'aggregator') {
- // Sources:
- $result = db_query('SELECT title, fid FROM {aggregator_feed} ORDER BY title');
- while ($feed = db_fetch_object($result)) {
- menu('aggregator/sources/'. $feed->fid, $feed->title, $access ? 'aggregator_page_source' : MENU_DENIED);
- }
+/**
+ * Implementation of hook_menu().
+ */
+function aggregator_menu() {
+ $items = array();
- // Categories:
- $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
- while ($category = db_fetch_object($result)) {
- menu('aggregator/categories/'. $category->cid, $category->title, $access ? 'aggregator_page_category' : MENU_DENIED);
- }
+ $edit = user_access('administer news feeds');
+ $view = user_access('access news feeds');
+
+ $items[] = array('path' => 'admin/aggregator', 'title' => t('aggregator'),
+ 'callback' => 'aggregator_admin_overview', 'access' => $edit);
+ $items[] = array('path' => 'admin/aggregator/edit/feed', 'title' => t('edit feed'),
+ 'callback' => 'aggregator_admin_edit_feed', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/aggregator/edit/category', 'title' => t('edit category'),
+ 'callback' => 'aggregator_admin_edit_category', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/aggregator/remove', 'title' => t('remove items'),
+ 'callback' => 'aggregator_admin_remove_feed', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/aggregator/update', 'title' => t('update items'),
+ 'callback' => 'aggregator_admin_refresh_feed', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+
+ // Tabs:
+ $items[] = array('path' => 'admin/aggregator/add/feed', 'title' => t('add feed'),
+ 'callback' => 'aggregator_admin_edit_feed', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/aggregator/add/category', 'title' => t('add category'),
+ 'callback' => 'aggregator_admin_edit_category', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/aggregator/configure', 'title' => t('configure'),
+ 'callback' => 'aggregator_configure', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+
+ $items[] = array('path' => 'aggregator', 'title' => t('news aggregator'),
+ 'callback' => 'aggregator_page_last', 'access' => $view,
+ 'weight' => 5);
+ $items[] = array('path' => 'aggregator/sources', 'title' => t('sources'),
+ 'callback' => 'aggregator_page_sources', 'access' => $view);
+ $items[] = array('path' => 'aggregator/categories', 'title' => t('categories'),
+ 'callback' => 'aggregator_page_categories', 'access' => $view,
+ 'type' => MENU_ITEM_GROUPING);
+
+ // To reduce the number of SQL queries, we don't query the database when
+ // not on an aggregator page.
+ // If caching of the menu is implemented, this check should be removed
+ // so that DHTML menu presentation can be used correctly.
+ if (arg(0) == 'aggregator') {
+ // Sources:
+ $result = db_query('SELECT title, fid FROM {aggregator_feed} ORDER BY title');
+ while ($feed = db_fetch_object($result)) {
+ $items[] = array('path' => 'aggregator/sources/'. $feed->fid, 'title' => $feed->title,
+ 'callback' => 'aggregator_page_source', 'access' => $view);
+ $items[] = array('path' => 'aggregator/sources/'. $feed->fid .'/categorize', 'title' => t('categorize'),
+ 'callback' => 'aggregator_page_source', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'aggregator/sources/'. $feed->fid .'/configure', 'title' => t('configure'),
+ 'callback' => 'aggregator_edit', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1);
}
- menu('aggregator/opml', t('opml'), $access ? 'aggregator_page_opml' : MENU_DENIED, '', MENU_HIDE);
+ // Categories:
+ $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
+ while ($category = db_fetch_object($result)) {
+ $items[] = array('path' => 'aggregator/categories/'. $category->cid, 'title' => $category->title,
+ 'callback' => 'aggregator_page_category', 'access' => $view);
+ $items[] = array('path' => 'aggregator/categories/'. $category->cid .'/categorize', 'title' => t('categorize'),
+ 'callback' => 'aggregator_page_category', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'aggregator/categories/'. $category->cid .'/configure', 'title' => t('configure'),
+ 'callback' => 'aggregator_edit', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1);
+ }
}
+
+ $items[] = array('path' => 'aggregator/opml', 'title' => t('opml'),
+ 'callback' => 'aggregator_page_opml', 'access' => $view,
+ 'type' => MENU_CALLBACK);
+
+ return $items;
}
/**
@@ -501,7 +550,7 @@ function aggregator_form_category($edit = array()) {
$form = form_textfield(t('Title'), 'title', $edit['title'], 50, 64);
$form .= form_textarea(t('Description'), 'description', $edit['description'], 60, 5);
- $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items in this category will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/system/block'))));
+ $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items in this category will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/block'))));
$form .= form_submit(t('Submit'));
if ($edit['cid']) {
@@ -537,7 +586,7 @@ function aggregator_form_feed($edit = array()) {
$form .= form_textfield(t('Title'), 'title', $edit['title'], 50, 64, t('The name of the feed; typically the name of the web site you syndicate content from.'));
$form .= form_textfield(t('URL'), 'url', $edit['url'], 50, 128, t('The fully-qualified URL of the feed.'));
$form .= form_select(t('Update interval'), 'refresh', $edit['refresh'], $period, t('The refresh interval indicating how often you want to update this feed. Requires crontab.'));
- $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items from this feed will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/system/block'))));
+ $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items from this feed will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/block'))));
$categories = db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = %d ORDER BY title', $edit['fid']);
while ($category = db_fetch_object($categories)) {
$checkboxes .= form_checkbox($category->title, "category][$category->cid", 1, $category->fid ? 1 : 0);
@@ -626,6 +675,45 @@ function aggregator_view() {
return $output;
}
+function aggregator_edit() {
+
+ if ($_POST['op'] == t('Submit')) {
+ if (arg(1) == 'categories') {
+ aggregator_save_category($_POST['edit']);
+ drupal_set_message(t('The category has been updated.'));
+ }
+ else {
+ aggregator_save_feed($_POST['edit']);
+ drupal_set_message(t('The feed has been updated.'));
+ }
+ }
+ else if ($_POST['op'] == t('Delete')) {
+ // Unset the title:
+ unset($_POST['edit']['title']);
+
+ if (arg(1) == 'categories') {
+ aggregator_save_category($_POST['edit']);
+ drupal_set_message(t('The category has been deleted.'));
+ }
+ else {
+ aggregator_save_feed($_POST['edit']);
+ drupal_set_message(t('The feed has been deleted.'));
+ }
+
+ drupal_goto('aggregator');
+ }
+
+ if (arg(1) == 'categories') {
+ $output = aggregator_form_category(aggregator_get_category(arg(2)));
+ }
+ else {
+ $output = aggregator_form_feed(aggregator_get_feed(arg(2)));
+ }
+
+ print theme('page', $output);
+}
+
+
/**
* Menu callback; displays the category edit form, or saves changes and
* displays the overview page.
@@ -743,15 +831,11 @@ function _aggregator_page_list($sql, $op, $header = '') {
}
}
}
- $links[] = l(t('categorize news items'), $_GET['q']);
}
else {
$categorize = true;
}
}
- if (user_access('administer news feeds') && $op != 'categorize') {
- $links[] = l(t('categorize news items'), $_GET['q'] .'/categorize');
- }
$output = '<div id="aggregator">';
if ($header) {
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index f82f5ea27..a06d5d65a 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -17,8 +17,8 @@ function aggregator_help($section) {
<p>To learn much more about RSS, read Mark Pilgrim\'s <a href="http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html">What is RSS</a> and WebReference.com\'s <a href="http://www.webreference.com/authoring/languages/xml/rss/1/">The Evolution of RSS</a>.</p>
<p>NOTE: Enable your site\'s XML syndication button by turning on the Syndicate block in block management.</p>
<h3>Adding news feeds</h3>
- <p>To subscribe to an RSS feed on another site, use the <a href="%admin-news">RSS/RDF</a> administration page.</p>
- <p>Once there, select <a href="%new-feed">new feed</a> from the menu. Drupal will then ask for the following:</p>
+ <p>To subscribe to an RSS feed on another site, use the <a href="%admin-news">aggregation page</a>.</p>
+ <p>Once there, click the <a href="%new-feed">new feed</a> tab. Drupal will then ask for the following:</p>
<ul>
<li><strong>Title</strong> -- The text entered here will be used in your news aggregator, within the administration configuration section, and as title for the news feed block. As a general rule, use the web site name from which the feed originates.</li>
<li><strong>URL</strong> -- Here you\'ll enter the fully-qualified URL for the feed for the site you want to subscribe to.</li>
@@ -26,9 +26,9 @@ function aggregator_help($section) {
<li><strong>Latest items block</strong> -- The number of items selected here will determine how many of the latest items from the feed will appear in a block which may be enabled and placed in the <a href="%block">blocks</a> administration page.</li>
<li><strong>Automatically file items</strong> -- As items are recieved from a feed they will be put in the checked categories.</li>
</ul>
- <p>Once you submit your new feed, check to see if it is working properly. Select <a href="%update-items">update items</a> on the <a href="%admin-news">RSS/RDF</a> page. If you do not see any items listed for that feed, edit the feed and make sure that the URL was entered correctly.</p>
+ <p>Once you submit your new feed, check to see if it is working properly. Select <a href="%update-items">update items</a> on the <a href="%admin-news">aggregation page</a>. If you do not see any items listed for that feed, edit the feed and make sure that the URL was entered correctly.</p>
<h3>Adding categories</h3>
- <p>News items can be filed into categories. To create a category, start at the <a href="%admin-news">RSS/RDF</a> administration page.</p>
+ <p>News items can be filed into categories. To create a category, start at the <a href="%admin-news">aggregation page</a>.</p>
<p>Once there, select <a href="%new-category">new category</a> from the menu. Drupal will then ask for the following:</p>
<ul>
<li><strong>Title</strong> -- The title will be used in the <i>news by topics</i> listing in your news aggregator and with the customized block created for the bundle.</li>
@@ -53,13 +53,13 @@ function aggregator_help($section) {
<h3>Technical details</h3>
<p>Drupal automatically generates an OPML feed file that is available by selecting the XML icon on the News Sources page.</p>
<p>When fetching feeds Drupal supports conditional GETs, this reduces the bandwidth usage for feeds that have not been updated since the last check.</p>
- <p>If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.</p>', array('%block' => url('admin/system/block'), '%admin-news' => url('admin/aggregator'), '%new-feed' => url('admin/aggregator/add/feed'), '%new-category' => url('admin/aggregator/add/category'), '%update-items' => url('admin/aggregator'), '%news-aggregator' => url('aggregator'), '%sources' => url('aggregator/sources'), '%categories' => url('aggregator/categories')));
- case 'admin/system/modules#description':
+ <p>If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.</p>', array('%block' => url('admin/block'), '%admin-news' => url('admin/aggregator'), '%new-feed' => url('admin/aggregator/add/feed'), '%new-category' => url('admin/aggregator/add/category'), '%update-items' => url('admin/aggregator'), '%news-aggregator' => url('aggregator'), '%sources' => url('aggregator/sources'), '%categories' => url('aggregator/categories')));
+ case 'admin/modules#description':
return t('Used to aggregate syndicated content (RSS and RDF).');
- case 'admin/system/modules/aggregator':
+ case 'admin/settings/aggregator':
return t('These settings control the display of aggregated content.');
case 'admin/aggregator':
- return t('Several web sites, especially news related sites, syndicate parts of their site\'s content for other web sites to display. Usually, the syndicated content includes the latest headlines with a direct link to that story on the remote site. Some syndicated content also includes a description of the headline. The standard method of syndication is using the XML based Rich Site Summary (RSS) or Resource Description Framework (RDF). To get a feed to work you <strong>must</strong> have <a href=\"%cron\">cron</a> working. To display the feed or categoty in a block you must decide how many items to show by editing the feed or block and turn on the <a href="%block">feed\'s block</a>.', array('%block' => url('admin/system/block'), '%cron' => url('admin/help', NULL, 'cron')));
+ return t('Several web sites, especially news related sites, syndicate parts of their site\'s content for other web sites to display. Usually, the syndicated content includes the latest headlines with a direct link to that story on the remote site. Some syndicated content also includes a description of the headline. The standard method of syndication is using the XML based Rich Site Summary (RSS) or Resource Description Framework (RDF). To get a feed to work you <strong>must</strong> have <a href=\"%cron\">cron</a> working. To display the feed or categoty in a block you must decide how many items to show by editing the feed or block and turn on the <a href="%block">feed\'s block</a>.', array('%block' => url('admin/block'), '%cron' => url('admin/help', NULL, 'cron')));
case 'admin/aggregator/add/feed':
return t('Add a site that has an RSS/RDF feed. The URL is the full path to the RSS feed file. For the feed to update automatically you must run "cron.php". If you already have a feed with the URL you are planning to use, the system will not accept another feed with the same URL.');
case 'admin/aggregator/add/category':
@@ -74,10 +74,11 @@ function aggregator_help_page() {
print theme('page', aggregator_help('admin/help#aggregator'));
}
-/**
- * Implementation of hook_settings().
- */
-function aggregator_settings() {
+function aggregator_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
$output = '';
$number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100));
$items = array(0 => t('none'), 3 => t('3 items'), 5 => t('5 items'), 10 => t('10 items'), 15 => t('15 items'), 20 => t('20 items'), 25 => t('25 items'));
@@ -85,7 +86,7 @@ function aggregator_settings() {
$output .= form_select(t('Items shown in sources and categories pages'), 'aggregator_summary_items', variable_get('aggregator_summary_items', 3), $items, t('The number of items which will be shown with each feed or category in the feed and category summary pages.'));
$output .= form_radios(t('Category selection type'), 'aggregator_category_selector', variable_get('aggregator_category_selector', 'check'), array('check' => t('checkboxes'), 'select' => t('multiple selector')), t('The type of category selection widget which is shown on categorization pages. Checkboxes are easier to use; a multiple selector is good for working with large numbers of categories.'));
- return $output;
+ print theme('page', system_settings_form($output));
}
/**
@@ -102,43 +103,91 @@ function aggregator_link($type) {
if ($type == 'page' && user_access('access news feeds')) {
return array(l(t('news feeds'), 'aggregator', array('title' => t('Read the latest news from syndicated web sites.'))));
}
+}
- if ($type == 'system') {
- $access = user_access('administer news feeds');
- menu('admin/aggregator', t('aggregator'), $access ? 'aggregator_admin_overview' : MENU_DENIED);
- menu('admin/aggregator/add/feed', t('new feed'), $access ? 'aggregator_admin_edit_feed' : MENU_DENIED, 2);
- menu('admin/aggregator/edit/feed', t('edit feed'), $access ? 'aggregator_admin_edit_feed' : MENU_DENIED, 2, MENU_HIDE);
- menu('admin/aggregator/add/category', t('new category'), $access ? 'aggregator_admin_edit_category' : MENU_DENIED, 3);
- menu('admin/aggregator/edit/category', t('edit category'), $access ? 'aggregator_admin_edit_category' : MENU_DENIED, 3, MENU_HIDE);
- menu('admin/aggregator/remove', t('remove items'), $access ? 'aggregator_admin_remove_feed' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/aggregator/update', t('update items'), $access ? 'aggregator_admin_refresh_feed' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/aggregator/help', t('help'), $access ? 'aggregator_help_page' : MENU_DENIED, 9);
-
- $access = user_access('access news feeds');
- menu('aggregator', t('news aggregator'), $access ? 'aggregator_page_last' : MENU_DENIED, 5);
- menu('aggregator/sources', t('sources'), $access ? 'aggregator_page_sources' : MENU_DENIED, 0);
- menu('aggregator/categories', t('categories'), $access ? 'aggregator_page_categories' : MENU_DENIED, 1, MENU_HIDE_NOCHILD);
-
- // To reduce the number of SQL queries, we don't query the database when
- // not on an aggregator page.
- // If caching of the menu is implemented, this check should be removed
- // so that DHTML menu presentation can be used correctly.
- if (arg(0) == 'aggregator') {
- // Sources:
- $result = db_query('SELECT title, fid FROM {aggregator_feed} ORDER BY title');
- while ($feed = db_fetch_object($result)) {
- menu('aggregator/sources/'. $feed->fid, $feed->title, $access ? 'aggregator_page_source' : MENU_DENIED);
- }
+/**
+ * Implementation of hook_menu().
+ */
+function aggregator_menu() {
+ $items = array();
- // Categories:
- $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
- while ($category = db_fetch_object($result)) {
- menu('aggregator/categories/'. $category->cid, $category->title, $access ? 'aggregator_page_category' : MENU_DENIED);
- }
+ $edit = user_access('administer news feeds');
+ $view = user_access('access news feeds');
+
+ $items[] = array('path' => 'admin/aggregator', 'title' => t('aggregator'),
+ 'callback' => 'aggregator_admin_overview', 'access' => $edit);
+ $items[] = array('path' => 'admin/aggregator/edit/feed', 'title' => t('edit feed'),
+ 'callback' => 'aggregator_admin_edit_feed', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/aggregator/edit/category', 'title' => t('edit category'),
+ 'callback' => 'aggregator_admin_edit_category', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/aggregator/remove', 'title' => t('remove items'),
+ 'callback' => 'aggregator_admin_remove_feed', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/aggregator/update', 'title' => t('update items'),
+ 'callback' => 'aggregator_admin_refresh_feed', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+
+ // Tabs:
+ $items[] = array('path' => 'admin/aggregator/add/feed', 'title' => t('add feed'),
+ 'callback' => 'aggregator_admin_edit_feed', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/aggregator/add/category', 'title' => t('add category'),
+ 'callback' => 'aggregator_admin_edit_category', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/aggregator/configure', 'title' => t('configure'),
+ 'callback' => 'aggregator_configure', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+
+ $items[] = array('path' => 'aggregator', 'title' => t('news aggregator'),
+ 'callback' => 'aggregator_page_last', 'access' => $view,
+ 'weight' => 5);
+ $items[] = array('path' => 'aggregator/sources', 'title' => t('sources'),
+ 'callback' => 'aggregator_page_sources', 'access' => $view);
+ $items[] = array('path' => 'aggregator/categories', 'title' => t('categories'),
+ 'callback' => 'aggregator_page_categories', 'access' => $view,
+ 'type' => MENU_ITEM_GROUPING);
+
+ // To reduce the number of SQL queries, we don't query the database when
+ // not on an aggregator page.
+ // If caching of the menu is implemented, this check should be removed
+ // so that DHTML menu presentation can be used correctly.
+ if (arg(0) == 'aggregator') {
+ // Sources:
+ $result = db_query('SELECT title, fid FROM {aggregator_feed} ORDER BY title');
+ while ($feed = db_fetch_object($result)) {
+ $items[] = array('path' => 'aggregator/sources/'. $feed->fid, 'title' => $feed->title,
+ 'callback' => 'aggregator_page_source', 'access' => $view);
+ $items[] = array('path' => 'aggregator/sources/'. $feed->fid .'/categorize', 'title' => t('categorize'),
+ 'callback' => 'aggregator_page_source', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'aggregator/sources/'. $feed->fid .'/configure', 'title' => t('configure'),
+ 'callback' => 'aggregator_edit', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1);
}
- menu('aggregator/opml', t('opml'), $access ? 'aggregator_page_opml' : MENU_DENIED, '', MENU_HIDE);
+ // Categories:
+ $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
+ while ($category = db_fetch_object($result)) {
+ $items[] = array('path' => 'aggregator/categories/'. $category->cid, 'title' => $category->title,
+ 'callback' => 'aggregator_page_category', 'access' => $view);
+ $items[] = array('path' => 'aggregator/categories/'. $category->cid .'/categorize', 'title' => t('categorize'),
+ 'callback' => 'aggregator_page_category', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'aggregator/categories/'. $category->cid .'/configure', 'title' => t('configure'),
+ 'callback' => 'aggregator_edit', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1);
+ }
}
+
+ $items[] = array('path' => 'aggregator/opml', 'title' => t('opml'),
+ 'callback' => 'aggregator_page_opml', 'access' => $view,
+ 'type' => MENU_CALLBACK);
+
+ return $items;
}
/**
@@ -501,7 +550,7 @@ function aggregator_form_category($edit = array()) {
$form = form_textfield(t('Title'), 'title', $edit['title'], 50, 64);
$form .= form_textarea(t('Description'), 'description', $edit['description'], 60, 5);
- $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items in this category will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/system/block'))));
+ $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items in this category will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/block'))));
$form .= form_submit(t('Submit'));
if ($edit['cid']) {
@@ -537,7 +586,7 @@ function aggregator_form_feed($edit = array()) {
$form .= form_textfield(t('Title'), 'title', $edit['title'], 50, 64, t('The name of the feed; typically the name of the web site you syndicate content from.'));
$form .= form_textfield(t('URL'), 'url', $edit['url'], 50, 128, t('The fully-qualified URL of the feed.'));
$form .= form_select(t('Update interval'), 'refresh', $edit['refresh'], $period, t('The refresh interval indicating how often you want to update this feed. Requires crontab.'));
- $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items from this feed will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/system/block'))));
+ $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items from this feed will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/block'))));
$categories = db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = %d ORDER BY title', $edit['fid']);
while ($category = db_fetch_object($categories)) {
$checkboxes .= form_checkbox($category->title, "category][$category->cid", 1, $category->fid ? 1 : 0);
@@ -626,6 +675,45 @@ function aggregator_view() {
return $output;
}
+function aggregator_edit() {
+
+ if ($_POST['op'] == t('Submit')) {
+ if (arg(1) == 'categories') {
+ aggregator_save_category($_POST['edit']);
+ drupal_set_message(t('The category has been updated.'));
+ }
+ else {
+ aggregator_save_feed($_POST['edit']);
+ drupal_set_message(t('The feed has been updated.'));
+ }
+ }
+ else if ($_POST['op'] == t('Delete')) {
+ // Unset the title:
+ unset($_POST['edit']['title']);
+
+ if (arg(1) == 'categories') {
+ aggregator_save_category($_POST['edit']);
+ drupal_set_message(t('The category has been deleted.'));
+ }
+ else {
+ aggregator_save_feed($_POST['edit']);
+ drupal_set_message(t('The feed has been deleted.'));
+ }
+
+ drupal_goto('aggregator');
+ }
+
+ if (arg(1) == 'categories') {
+ $output = aggregator_form_category(aggregator_get_category(arg(2)));
+ }
+ else {
+ $output = aggregator_form_feed(aggregator_get_feed(arg(2)));
+ }
+
+ print theme('page', $output);
+}
+
+
/**
* Menu callback; displays the category edit form, or saves changes and
* displays the overview page.
@@ -743,15 +831,11 @@ function _aggregator_page_list($sql, $op, $header = '') {
}
}
}
- $links[] = l(t('categorize news items'), $_GET['q']);
}
else {
$categorize = true;
}
}
- if (user_access('administer news feeds') && $op != 'categorize') {
- $links[] = l(t('categorize news items'), $_GET['q'] .'/categorize');
- }
$output = '<div id="aggregator">';
if ($header) {
diff --git a/modules/archive.module b/modules/archive.module
index 15825ec25..4ad26b527 100644
--- a/modules/archive.module
+++ b/modules/archive.module
@@ -6,15 +6,15 @@
*/
function archive_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Displays a calendar to navigate old content.');
- case 'admin/system/modules/archive':
+ case 'admin/settings/archive':
return t('Choose the starting "day of the week" for the displayed calendar block.');
}
}
/**
- * Generates a monthly claendar, for display in the archive block.
+ * Generates a monthly calendar, for display in the archive block.
*/
function archive_calendar($original = 0) {
global $user;
@@ -199,15 +199,26 @@ function archive_link($type) {
if ($type == 'page' && user_access('access content')) {
$links[] = l(t('archives'), 'archive', array('title' => t('Read the older content in our archive.')));
}
-
- if ($type == 'system') {
- menu('archive', t('archives'), user_access('access content') ? 'archive_page' : MENU_DENIED, 0, MENU_HIDE);
- }
-
return $links;
}
/**
+ * Implementation of hook_menu().
+ */
+function archive_menu() {
+ $items = array();
+ $items[] = array('path' => 'archive', 'title' => t('archives'),
+ 'access' => user_access('access content'),
+ 'callback' => 'archive_page',
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'archive/configure', 'title' => t('configure'),
+ 'access' => user_access('administer site configuration'),
+ 'callback' => 'archive_configure',
+ 'type' => MENU_LOCAL_TASK);
+ return $items;
+}
+
+/**
* Menu callback; lists all nodes posted on a given date.
*/
function archive_page($year = 0, $month = 0, $day = 0) {
@@ -247,13 +258,14 @@ function archive_page($year = 0, $month = 0, $day = 0) {
print theme('page', $output);
}
-/**
- * Implementation of hook_settings().
- */
-function archive_settings() {
+function archive_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
$output = form_select(t('First day of week'), 'default_firstday', variable_get('default_firstday', 0), array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')), t('The first day of the week. By changing this value you choose how the calendar block is rendered.'));
- return $output;
+ print theme('page', system_settings_form($output));
}
?>
diff --git a/modules/archive/archive.module b/modules/archive/archive.module
index 15825ec25..4ad26b527 100644
--- a/modules/archive/archive.module
+++ b/modules/archive/archive.module
@@ -6,15 +6,15 @@
*/
function archive_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Displays a calendar to navigate old content.');
- case 'admin/system/modules/archive':
+ case 'admin/settings/archive':
return t('Choose the starting "day of the week" for the displayed calendar block.');
}
}
/**
- * Generates a monthly claendar, for display in the archive block.
+ * Generates a monthly calendar, for display in the archive block.
*/
function archive_calendar($original = 0) {
global $user;
@@ -199,15 +199,26 @@ function archive_link($type) {
if ($type == 'page' && user_access('access content')) {
$links[] = l(t('archives'), 'archive', array('title' => t('Read the older content in our archive.')));
}
-
- if ($type == 'system') {
- menu('archive', t('archives'), user_access('access content') ? 'archive_page' : MENU_DENIED, 0, MENU_HIDE);
- }
-
return $links;
}
/**
+ * Implementation of hook_menu().
+ */
+function archive_menu() {
+ $items = array();
+ $items[] = array('path' => 'archive', 'title' => t('archives'),
+ 'access' => user_access('access content'),
+ 'callback' => 'archive_page',
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'archive/configure', 'title' => t('configure'),
+ 'access' => user_access('administer site configuration'),
+ 'callback' => 'archive_configure',
+ 'type' => MENU_LOCAL_TASK);
+ return $items;
+}
+
+/**
* Menu callback; lists all nodes posted on a given date.
*/
function archive_page($year = 0, $month = 0, $day = 0) {
@@ -247,13 +258,14 @@ function archive_page($year = 0, $month = 0, $day = 0) {
print theme('page', $output);
}
-/**
- * Implementation of hook_settings().
- */
-function archive_settings() {
+function archive_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
$output = form_select(t('First day of week'), 'default_firstday', variable_get('default_firstday', 0), array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')), t('The first day of the week. By changing this value you choose how the calendar block is rendered.'));
- return $output;
+ print theme('page', system_settings_form($output));
}
?>
diff --git a/modules/block.module b/modules/block.module
index 50ac5c92d..fb3f2d50a 100644
--- a/modules/block.module
+++ b/modules/block.module
@@ -11,10 +11,10 @@ function block_help($section) {
<p>Blocks are the boxes visible in the sidebar(s) of your web site. These are usually generated automatically by modules (e.g. recent forum topics), but you can also create your own blocks using either static HTML or dynamic PHP content.</p>
<p>The sidebar each block appears in depends on both which theme you're using (some are left-only, some right, some both), and on the settings in block management.</p><p>Whether a block is visible in the first place depends on four things:</p><ul><li>It must have its \"enabled\" box checked in block management.</li><li>If it has its \"custom\" box checked in block management, the user must have chosen to display it in their user preferences.</li><li>If the \"path\" field in block management is set, the visitor must be on a page that matches the path specification (more on this later).</li><li>If the block has its throttle box checked, the user will only see the block if the site throttle level is low.</li></ul>
<p>The block management screen also lets you specify the vertical sort-order of the blocks within a sidebar. You do this by assigning a <strong>weight</strong> to each block. Lighter blocks (smaller weight) \"float up\" towards the top of the sidebar. Heavier ones \"sink down\" towards the bottom of it. Once you've positioned things just so, you can preview what the layout will look like in different types of themes by clicking the preview placement link in the menu to the left.</p>
-<p>The path setting lets you define the pages on which a specific block is visible. If you leave the path blank it will appear on all pages. The path uses a regular expression syntax so remember to escape special characters! The path expression is matched against the relative URL of a Drupal page, e.g. <code>book</code>, <code>node/view/12</code>, <code>admin</code>.</p>
+<p>The path setting lets you define the pages on which a specific block is visible. If you leave the path blank it will appear on all pages. The path uses a regular expression syntax so remember to escape special characters! The path expression is matched against the relative URL of a Drupal page, e.g. <code>book</code>, <code>node/12</code>, <code>admin</code>.</p>
<p>In case you do not know what a regular expression is, you should read about them in the PHP manual. The chapter to look at is the one on <a href=\"%pcre\">Perl-Compatible Regular Expressions (PCRE)</a>.</p>
<p>However, for basic tasks it is sufficient to look at the following examples:</p>
-<p>If the block should only show up on blog pages, use &lt;^blog&gt;. To display on all node views use &lt;^node/view&gt;. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use &lt;^(forum|book)&gt;. The round brackets form a group of expressions, divided by the | character. It matches if any of the expressions in it match. A more complicated example is &lt;^node/add/(story|blog|image)&gt;. Blocks which have their paths set to this expression will show up on story, block, or image composition pages. If you want to show a block an all pages, but not the search page, use &lt;^(?!search)&gt;.</p>
+<p>If the block should only show up on blog pages, use &lt;^blog&gt;. To display on all node views use &lt;^node&gt;. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use &lt;^(forum|book)&gt;. The round brackets form a group of expressions, divided by the | character. It matches if any of the expressions in it match. A more complicated example is &lt;^node/add/(story|blog|image)&gt;. Blocks which have their paths set to this expression will show up on story, block, or image composition pages. If you want to show a block an all pages, but not the search page, use &lt;^(?!search)&gt;.</p>
<h3>Administrator Defined Blocks</h3>
<p>An administrator defined block contains HTML, text or PHP content supplied by you (as opposed to being generated automatically by a module). Each admin-defined block consists of a title, a description, and a body containing text, HTML, or PHP code which can be as long as you wish. The Drupal engine will 'render' the content of the block.</p>
<h4>PHP in admin-defined blocks</h4>
@@ -36,13 +36,13 @@ function block_help($section) {
}
</pre></blockquote>
<p>For more in-depth examples, we recommend that you check the existing boxes and use them as a starting point.</p>", array('%pcre' => 'http://php.net/pcre/'));
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Controls the boxes that are displayed around the main content.');
- case 'admin/system/block':
- return t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the chosen theme. They are created by <strong>active</strong> Drupal modules. The \"enabled\" checkbox sets the default status of the block. Only enabled blocks are shown. When the \"custom\" checkbox is checked, your users can show or hide the block using their account settings. In that case, the 'enabled' checkbox signifies the block's default status. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the <a href=\"%createblock\">new block</a> link in the menu to the left. Edit and delete links will become active below for these admin-defined blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array('%createblock' => url('admin/system/block/add'), '%throttle' => url('admin/system/modules/throttle')));
- case 'admin/system/block/add':
- return t("Here you can create a new block. Once you have created this block you must make it active and give it a place on the page using <a href=\"%overview\">blocks</a>. The title is used when displaying the block. The description is used in the \"block\" column on the <a href=\"%overview\">blocks</a> page. If you are going to place PHP code in the block, and you have the <strong>create php content</strong> permission (see the <a href=\"%permission\">permissions</a> page), you <strong>must</strong> change the type to PHP to make your code active.", array('%overview' => url('admin/system/block'), '%permission' => url('admin/user/permission')));
- case 'admin/system/block/preview':
+ case 'admin/block':
+ return t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the chosen theme. They are created by <strong>active</strong> Drupal modules. The \"enabled\" checkbox sets the default status of the block. Only enabled blocks are shown. When the \"custom\" checkbox is checked, your users can show or hide the block using their account settings. In that case, the 'enabled' checkbox signifies the block's default status. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the <a href=\"%createblock\">add block</a> tab in the menu to the left. Edit and delete links will become active below for these admin-defined blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array('%createblock' => url('admin/block/add'), '%throttle' => url('admin/settings/throttle')));
+ case 'admin/block/add':
+ return t("Here you can create a new block. Once you have created this block you must make it active and give it a place on the page using <a href=\"%overview\">blocks</a>. The title is used when displaying the block. The description is used in the \"block\" column on the <a href=\"%overview\">blocks</a> page. If you are going to place PHP code in the block, and you have the <strong>create php content</strong> permission (see the <a href=\"%permission\">permissions</a> page), you <strong>must</strong> change the type to PHP to make your code active.", array('%overview' => url('admin/block'), '%permission' => url('admin/user/permission')));
+ case 'admin/block/preview':
return t('This page shows you the placement of your blocks in different theme types. The numbers are the weights of each block, which are used to sort them within the sidebars.');
}
}
@@ -62,17 +62,31 @@ function block_perm() {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function block_link($type) {
- if ($type == 'system') {
- menu('admin/system/block', t('blocks'), user_access('administer blocks') ? 'block_admin' : MENU_DENIED, 3);
- menu('admin/system/block/add', t('new block'), user_access('administer blocks') ? 'block_box_edit' : MENU_DENIED, 2);
- menu('admin/system/block/edit', t('edit block'), user_access('administer blocks') ? 'block_box_edit' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/system/block/delete', t('delete block'), user_access('administer blocks') ? 'block_box_delete' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/system/block/preview', t('preview placement'), user_access('administer blocks') ? 'block_admin_preview' : MENU_DENIED, 3);
- menu('admin/system/block/help', t('help'), user_access('administer blocks') ? 'block_help_page' : MENU_DENIED, 9);
- }
+function block_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/block', 'title' => t('blocks'),
+ 'access' => user_access('administer blocks'),
+ 'callback' => 'block_admin');
+ $items[] = array('path' => 'admin/block/edit', 'title' => t('edit block'),
+ 'access' => user_access('administer blocks'),
+ 'callback' => 'block_box_edit',
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/block/delete', 'title' => t('delete block'),
+ 'access' => user_access('administer blocks'),
+ 'callback' => 'block_box_delete',
+ 'type' => MENU_CALLBACK);
+ // Tabs:
+ $items[] = array('path' => 'admin/block/add', 'title' => t('add block'),
+ 'access' => user_access('administer blocks'),
+ 'callback' => 'block_box_edit',
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/block/preview', 'title' => t('preview'),
+ 'access' => user_access('administer blocks'),
+ 'callback' => 'block_admin_preview',
+ 'type' => MENU_LOCAL_TASK);
+ return $items;
}
/**
@@ -173,8 +187,8 @@ function block_admin_display() {
foreach ($blocks as $block) {
if ($block['module'] == 'block') {
- $edit = l(t('edit'), 'admin/system/block/edit/'. $block['delta']);
- $delete = l(t('delete'), 'admin/system/block/delete/'. $block['delta']);
+ $edit = l(t('edit'), 'admin/block/edit/'. $block['delta']);
+ $delete = l(t('delete'), 'admin/block/delete/'. $block['delta']);
}
else {
$edit = '';
@@ -188,7 +202,7 @@ function block_admin_display() {
$output = theme('table', $header, $rows);
$output .= form_submit(t('Save blocks'));
- return form($output, 'post', url('admin/system/block'));
+ return form($output, 'post', url('admin/block'));
}
/**
@@ -374,7 +388,7 @@ function block_user($type, $edit, &$user) {
*
* @return array of block objects, indexed with <i>module</i>_<i>delta</i>
*
- * @see <a href="http://drupal.org/node/view/1042" target="_top">[feature]
+ * @see <a href="http://drupal.org/node/1042" target="_top">[feature]
* Generic template design difficult w/o block region "look-ahead"</a>
* @todo add a proper primary key (bid) to the blocks table so we don't have
* to mess around with this <i>module</i>_<i>delta</i> construct. currently,
diff --git a/modules/block/block.module b/modules/block/block.module
index 50ac5c92d..fb3f2d50a 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -11,10 +11,10 @@ function block_help($section) {
<p>Blocks are the boxes visible in the sidebar(s) of your web site. These are usually generated automatically by modules (e.g. recent forum topics), but you can also create your own blocks using either static HTML or dynamic PHP content.</p>
<p>The sidebar each block appears in depends on both which theme you're using (some are left-only, some right, some both), and on the settings in block management.</p><p>Whether a block is visible in the first place depends on four things:</p><ul><li>It must have its \"enabled\" box checked in block management.</li><li>If it has its \"custom\" box checked in block management, the user must have chosen to display it in their user preferences.</li><li>If the \"path\" field in block management is set, the visitor must be on a page that matches the path specification (more on this later).</li><li>If the block has its throttle box checked, the user will only see the block if the site throttle level is low.</li></ul>
<p>The block management screen also lets you specify the vertical sort-order of the blocks within a sidebar. You do this by assigning a <strong>weight</strong> to each block. Lighter blocks (smaller weight) \"float up\" towards the top of the sidebar. Heavier ones \"sink down\" towards the bottom of it. Once you've positioned things just so, you can preview what the layout will look like in different types of themes by clicking the preview placement link in the menu to the left.</p>
-<p>The path setting lets you define the pages on which a specific block is visible. If you leave the path blank it will appear on all pages. The path uses a regular expression syntax so remember to escape special characters! The path expression is matched against the relative URL of a Drupal page, e.g. <code>book</code>, <code>node/view/12</code>, <code>admin</code>.</p>
+<p>The path setting lets you define the pages on which a specific block is visible. If you leave the path blank it will appear on all pages. The path uses a regular expression syntax so remember to escape special characters! The path expression is matched against the relative URL of a Drupal page, e.g. <code>book</code>, <code>node/12</code>, <code>admin</code>.</p>
<p>In case you do not know what a regular expression is, you should read about them in the PHP manual. The chapter to look at is the one on <a href=\"%pcre\">Perl-Compatible Regular Expressions (PCRE)</a>.</p>
<p>However, for basic tasks it is sufficient to look at the following examples:</p>
-<p>If the block should only show up on blog pages, use &lt;^blog&gt;. To display on all node views use &lt;^node/view&gt;. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use &lt;^(forum|book)&gt;. The round brackets form a group of expressions, divided by the | character. It matches if any of the expressions in it match. A more complicated example is &lt;^node/add/(story|blog|image)&gt;. Blocks which have their paths set to this expression will show up on story, block, or image composition pages. If you want to show a block an all pages, but not the search page, use &lt;^(?!search)&gt;.</p>
+<p>If the block should only show up on blog pages, use &lt;^blog&gt;. To display on all node views use &lt;^node&gt;. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use &lt;^(forum|book)&gt;. The round brackets form a group of expressions, divided by the | character. It matches if any of the expressions in it match. A more complicated example is &lt;^node/add/(story|blog|image)&gt;. Blocks which have their paths set to this expression will show up on story, block, or image composition pages. If you want to show a block an all pages, but not the search page, use &lt;^(?!search)&gt;.</p>
<h3>Administrator Defined Blocks</h3>
<p>An administrator defined block contains HTML, text or PHP content supplied by you (as opposed to being generated automatically by a module). Each admin-defined block consists of a title, a description, and a body containing text, HTML, or PHP code which can be as long as you wish. The Drupal engine will 'render' the content of the block.</p>
<h4>PHP in admin-defined blocks</h4>
@@ -36,13 +36,13 @@ function block_help($section) {
}
</pre></blockquote>
<p>For more in-depth examples, we recommend that you check the existing boxes and use them as a starting point.</p>", array('%pcre' => 'http://php.net/pcre/'));
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Controls the boxes that are displayed around the main content.');
- case 'admin/system/block':
- return t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the chosen theme. They are created by <strong>active</strong> Drupal modules. The \"enabled\" checkbox sets the default status of the block. Only enabled blocks are shown. When the \"custom\" checkbox is checked, your users can show or hide the block using their account settings. In that case, the 'enabled' checkbox signifies the block's default status. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the <a href=\"%createblock\">new block</a> link in the menu to the left. Edit and delete links will become active below for these admin-defined blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array('%createblock' => url('admin/system/block/add'), '%throttle' => url('admin/system/modules/throttle')));
- case 'admin/system/block/add':
- return t("Here you can create a new block. Once you have created this block you must make it active and give it a place on the page using <a href=\"%overview\">blocks</a>. The title is used when displaying the block. The description is used in the \"block\" column on the <a href=\"%overview\">blocks</a> page. If you are going to place PHP code in the block, and you have the <strong>create php content</strong> permission (see the <a href=\"%permission\">permissions</a> page), you <strong>must</strong> change the type to PHP to make your code active.", array('%overview' => url('admin/system/block'), '%permission' => url('admin/user/permission')));
- case 'admin/system/block/preview':
+ case 'admin/block':
+ return t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the chosen theme. They are created by <strong>active</strong> Drupal modules. The \"enabled\" checkbox sets the default status of the block. Only enabled blocks are shown. When the \"custom\" checkbox is checked, your users can show or hide the block using their account settings. In that case, the 'enabled' checkbox signifies the block's default status. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the <a href=\"%createblock\">add block</a> tab in the menu to the left. Edit and delete links will become active below for these admin-defined blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array('%createblock' => url('admin/block/add'), '%throttle' => url('admin/settings/throttle')));
+ case 'admin/block/add':
+ return t("Here you can create a new block. Once you have created this block you must make it active and give it a place on the page using <a href=\"%overview\">blocks</a>. The title is used when displaying the block. The description is used in the \"block\" column on the <a href=\"%overview\">blocks</a> page. If you are going to place PHP code in the block, and you have the <strong>create php content</strong> permission (see the <a href=\"%permission\">permissions</a> page), you <strong>must</strong> change the type to PHP to make your code active.", array('%overview' => url('admin/block'), '%permission' => url('admin/user/permission')));
+ case 'admin/block/preview':
return t('This page shows you the placement of your blocks in different theme types. The numbers are the weights of each block, which are used to sort them within the sidebars.');
}
}
@@ -62,17 +62,31 @@ function block_perm() {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function block_link($type) {
- if ($type == 'system') {
- menu('admin/system/block', t('blocks'), user_access('administer blocks') ? 'block_admin' : MENU_DENIED, 3);
- menu('admin/system/block/add', t('new block'), user_access('administer blocks') ? 'block_box_edit' : MENU_DENIED, 2);
- menu('admin/system/block/edit', t('edit block'), user_access('administer blocks') ? 'block_box_edit' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/system/block/delete', t('delete block'), user_access('administer blocks') ? 'block_box_delete' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/system/block/preview', t('preview placement'), user_access('administer blocks') ? 'block_admin_preview' : MENU_DENIED, 3);
- menu('admin/system/block/help', t('help'), user_access('administer blocks') ? 'block_help_page' : MENU_DENIED, 9);
- }
+function block_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/block', 'title' => t('blocks'),
+ 'access' => user_access('administer blocks'),
+ 'callback' => 'block_admin');
+ $items[] = array('path' => 'admin/block/edit', 'title' => t('edit block'),
+ 'access' => user_access('administer blocks'),
+ 'callback' => 'block_box_edit',
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/block/delete', 'title' => t('delete block'),
+ 'access' => user_access('administer blocks'),
+ 'callback' => 'block_box_delete',
+ 'type' => MENU_CALLBACK);
+ // Tabs:
+ $items[] = array('path' => 'admin/block/add', 'title' => t('add block'),
+ 'access' => user_access('administer blocks'),
+ 'callback' => 'block_box_edit',
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/block/preview', 'title' => t('preview'),
+ 'access' => user_access('administer blocks'),
+ 'callback' => 'block_admin_preview',
+ 'type' => MENU_LOCAL_TASK);
+ return $items;
}
/**
@@ -173,8 +187,8 @@ function block_admin_display() {
foreach ($blocks as $block) {
if ($block['module'] == 'block') {
- $edit = l(t('edit'), 'admin/system/block/edit/'. $block['delta']);
- $delete = l(t('delete'), 'admin/system/block/delete/'. $block['delta']);
+ $edit = l(t('edit'), 'admin/block/edit/'. $block['delta']);
+ $delete = l(t('delete'), 'admin/block/delete/'. $block['delta']);
}
else {
$edit = '';
@@ -188,7 +202,7 @@ function block_admin_display() {
$output = theme('table', $header, $rows);
$output .= form_submit(t('Save blocks'));
- return form($output, 'post', url('admin/system/block'));
+ return form($output, 'post', url('admin/block'));
}
/**
@@ -374,7 +388,7 @@ function block_user($type, $edit, &$user) {
*
* @return array of block objects, indexed with <i>module</i>_<i>delta</i>
*
- * @see <a href="http://drupal.org/node/view/1042" target="_top">[feature]
+ * @see <a href="http://drupal.org/node/1042" target="_top">[feature]
* Generic template design difficult w/o block region "look-ahead"</a>
* @todo add a proper primary key (bid) to the blocks table so we don't have
* to mess around with this <i>module</i>_<i>delta</i> construct. currently,
diff --git a/modules/blog.module b/modules/blog.module
index 0e3891b5e..7e7eca288 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -68,9 +68,9 @@ function blog_help($section) {
<p>Blogs are made up of individual entries (nodes) that are timestamped and are typically viewed by day as you would a diary. Blogs often contain links to things you've seen and/or agree/disagree with. A typical example of a long term blog can be seen at %scripting-com.</p>
<p>The blog module adds a \"user blogs\" navigation link to the site, which takes any visitor to a page that displays the most recent blog entries from all the users on the site. Personal user menus gain a \"create a blog entry\" link (which takes you to a submission form) and a \"view personal blog\" link (which displays your blog entries as other people will see them). On the bottom of each of your own blog entries, there is an \"edit this blog entry\" link that lets you edit or delete that entry.</p>
<p>If a user has the ability to post blogs, then the import module (news aggregator) will display a blog-it link <strong>(b)</strong> next to each news item in its lists. Click on this and you will be taken to the blog submission form, with the title, a link to the item, and a link to the source into the body text already in the text box, ready for you to add your explanation. This actively encourages people to add blog entries about things they see and hear elsewhere in the Drupal site and from your syndicated partner sites.</p>", array('%scripting-com' => '<a href="http://www.scripting.com/">http://www.scripting.com/</a>'));
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables keeping a blog or easily and regularly updated web page.');
- case 'admin/system/modules/blog':
+ case 'admin/settings/blog':
return t("A weblog is a running journal of a user's ideas. Enter the minimum word count for a single entry, and the text displayed on the entry submission form");
case 'node/add/blog':
return variable_get('blog_help', '');
@@ -201,7 +201,7 @@ function blog_form(&$node, &$error) {
*/
if ($nid && $blog = node_load(array('nid' => $nid))) {
- $node->body = '<i>'. $blog->body .'</i> ['. l($blog->name, "node/view/$nid") .']';
+ $node->body = '<i>'. $blog->body .'</i> ['. l($blog->name, "node/$nid") .']';
}
if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
@@ -222,50 +222,40 @@ function blog_form(&$node, &$error) {
/**
* Implementation of hook_content().
*/
-function blog_content($node, $main = 0) {
- return node_prepare($node, $main);
+function blog_content($node, $teaser = FALSE) {
+ return node_prepare($node, $teaser);
}
/**
* Implementation of hook_view().
*/
-function blog_view($node, $main = 0, $page = 0) {
+function blog_view($node, $teaser = FALSE, $page = FALSE) {
if ($page) {
// Breadcrumb navigation
- $breadcrumb[] = l(t('Home'), '');
- $breadcrumb[] = l(t('blogs'), 'blog');
- $breadcrumb[] = l(t("%name's blog", array('%name' => $node->name)), "blog/$node->uid");
- // set the breadcrumb
- drupal_set_breadcrumb($breadcrumb);
+ $breadcrumb[] = array('path' => 'blog', 'title' => t('blogs'));
+ $breadcrumb[] = array('path' => 'blog/'. $node->uid, 'title' => t("%name's blog", array('%name' => $node->name)));
+ $breadcrumb[] = array('path' => 'node/'. $node->nid);
+ menu_set_location($breadcrumb);
}
// prepare the node content
- $node = blog_content($node, $main);
+ $node = blog_content($node, $teaser);
// print the node
- return theme('node', $node, $main, $page);
+ return theme('node', $node, $teaser, $page);
}
/**
* Implementation of hook_link().
*/
function blog_link($type, $node = 0, $main) {
- global $user;
-
$links = array();
- if ($type == 'system') {
- menu('node/add/blog', t('blog entry'), user_access('maintain personal blog') ? MENU_FALLTHROUGH : MENU_DENIED, 0);
- menu('blog/'. $user->uid, t('my blog'), MENU_FALLTHROUGH, 1, MENU_SHOW, MENU_LOCKED);
- menu('blog', t('blogs'), user_access('access content') ? 'blog_page' : MENU_DENIED, 0, MENU_HIDE);
- menu('blog/feed', t('RSS feed'), user_access('access content') ? 'blog_feed' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
-
if ($type == 'page' && user_access('access content')) {
$links[] = l(t('blogs'), 'blog', array('title' => t('Read the latest blog entries.')));
}
if ($type == 'node' && $node->type == 'blog') {
if (blog_access('update', $node)) {
- $links[] = l(t('edit this blog entry'), "node/edit/$node->nid", array('title' => t('Edit this blog entry.')));
+ $links[] = l(t('edit this blog entry'), "node/$node->nid/edit", array('title' => t('Edit this blog entry.')));
}
elseif (arg(0) != 'blog' && arg(1) != $node->uid) {
$links[] = l(t("%username's blog", array('%username' => $node->name)), "blog/$node->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $node->name))));
@@ -276,6 +266,29 @@ function blog_link($type, $node = 0, $main) {
}
/**
+ * Implementation of hook_menu().
+ */
+function blog_menu() {
+ global $user;
+
+ $items = array();
+ $items[] = array('path' => 'node/add/blog', 'title' => t('blog entry'),
+ 'access' => user_access('maintain personal blog'));
+ $items[] = array('path' => 'blog', 'title' => t('blogs'),
+ 'callback' => 'blog_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'blog/'. $user->uid, 'title' => t('my blog'),
+ 'access' => user_access('maintain personal blog'),
+ 'type' => MENU_DYNAMIC_ITEM);
+ $items[] = array('path' => 'blog/feed', 'title' => t('RSS feed'),
+ 'callback' => 'blog_feed',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+ return $items;
+}
+
+/**
* Implementation of hook_block().
*
* Displays the most recent 10 blog titles.
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index 0e3891b5e..7e7eca288 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -68,9 +68,9 @@ function blog_help($section) {
<p>Blogs are made up of individual entries (nodes) that are timestamped and are typically viewed by day as you would a diary. Blogs often contain links to things you've seen and/or agree/disagree with. A typical example of a long term blog can be seen at %scripting-com.</p>
<p>The blog module adds a \"user blogs\" navigation link to the site, which takes any visitor to a page that displays the most recent blog entries from all the users on the site. Personal user menus gain a \"create a blog entry\" link (which takes you to a submission form) and a \"view personal blog\" link (which displays your blog entries as other people will see them). On the bottom of each of your own blog entries, there is an \"edit this blog entry\" link that lets you edit or delete that entry.</p>
<p>If a user has the ability to post blogs, then the import module (news aggregator) will display a blog-it link <strong>(b)</strong> next to each news item in its lists. Click on this and you will be taken to the blog submission form, with the title, a link to the item, and a link to the source into the body text already in the text box, ready for you to add your explanation. This actively encourages people to add blog entries about things they see and hear elsewhere in the Drupal site and from your syndicated partner sites.</p>", array('%scripting-com' => '<a href="http://www.scripting.com/">http://www.scripting.com/</a>'));
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables keeping a blog or easily and regularly updated web page.');
- case 'admin/system/modules/blog':
+ case 'admin/settings/blog':
return t("A weblog is a running journal of a user's ideas. Enter the minimum word count for a single entry, and the text displayed on the entry submission form");
case 'node/add/blog':
return variable_get('blog_help', '');
@@ -201,7 +201,7 @@ function blog_form(&$node, &$error) {
*/
if ($nid && $blog = node_load(array('nid' => $nid))) {
- $node->body = '<i>'. $blog->body .'</i> ['. l($blog->name, "node/view/$nid") .']';
+ $node->body = '<i>'. $blog->body .'</i> ['. l($blog->name, "node/$nid") .']';
}
if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
@@ -222,50 +222,40 @@ function blog_form(&$node, &$error) {
/**
* Implementation of hook_content().
*/
-function blog_content($node, $main = 0) {
- return node_prepare($node, $main);
+function blog_content($node, $teaser = FALSE) {
+ return node_prepare($node, $teaser);
}
/**
* Implementation of hook_view().
*/
-function blog_view($node, $main = 0, $page = 0) {
+function blog_view($node, $teaser = FALSE, $page = FALSE) {
if ($page) {
// Breadcrumb navigation
- $breadcrumb[] = l(t('Home'), '');
- $breadcrumb[] = l(t('blogs'), 'blog');
- $breadcrumb[] = l(t("%name's blog", array('%name' => $node->name)), "blog/$node->uid");
- // set the breadcrumb
- drupal_set_breadcrumb($breadcrumb);
+ $breadcrumb[] = array('path' => 'blog', 'title' => t('blogs'));
+ $breadcrumb[] = array('path' => 'blog/'. $node->uid, 'title' => t("%name's blog", array('%name' => $node->name)));
+ $breadcrumb[] = array('path' => 'node/'. $node->nid);
+ menu_set_location($breadcrumb);
}
// prepare the node content
- $node = blog_content($node, $main);
+ $node = blog_content($node, $teaser);
// print the node
- return theme('node', $node, $main, $page);
+ return theme('node', $node, $teaser, $page);
}
/**
* Implementation of hook_link().
*/
function blog_link($type, $node = 0, $main) {
- global $user;
-
$links = array();
- if ($type == 'system') {
- menu('node/add/blog', t('blog entry'), user_access('maintain personal blog') ? MENU_FALLTHROUGH : MENU_DENIED, 0);
- menu('blog/'. $user->uid, t('my blog'), MENU_FALLTHROUGH, 1, MENU_SHOW, MENU_LOCKED);
- menu('blog', t('blogs'), user_access('access content') ? 'blog_page' : MENU_DENIED, 0, MENU_HIDE);
- menu('blog/feed', t('RSS feed'), user_access('access content') ? 'blog_feed' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
-
if ($type == 'page' && user_access('access content')) {
$links[] = l(t('blogs'), 'blog', array('title' => t('Read the latest blog entries.')));
}
if ($type == 'node' && $node->type == 'blog') {
if (blog_access('update', $node)) {
- $links[] = l(t('edit this blog entry'), "node/edit/$node->nid", array('title' => t('Edit this blog entry.')));
+ $links[] = l(t('edit this blog entry'), "node/$node->nid/edit", array('title' => t('Edit this blog entry.')));
}
elseif (arg(0) != 'blog' && arg(1) != $node->uid) {
$links[] = l(t("%username's blog", array('%username' => $node->name)), "blog/$node->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $node->name))));
@@ -276,6 +266,29 @@ function blog_link($type, $node = 0, $main) {
}
/**
+ * Implementation of hook_menu().
+ */
+function blog_menu() {
+ global $user;
+
+ $items = array();
+ $items[] = array('path' => 'node/add/blog', 'title' => t('blog entry'),
+ 'access' => user_access('maintain personal blog'));
+ $items[] = array('path' => 'blog', 'title' => t('blogs'),
+ 'callback' => 'blog_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'blog/'. $user->uid, 'title' => t('my blog'),
+ 'access' => user_access('maintain personal blog'),
+ 'type' => MENU_DYNAMIC_ITEM);
+ $items[] = array('path' => 'blog/feed', 'title' => t('RSS feed'),
+ 'callback' => 'blog_feed',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+ return $items;
+}
+
+/**
* Implementation of hook_block().
*
* Displays the most recent 10 blog titles.
diff --git a/modules/blogapi.module b/modules/blogapi.module
index 80ab41421..131d82979 100644
--- a/modules/blogapi.module
+++ b/modules/blogapi.module
@@ -8,7 +8,7 @@ function blogapi_help($section) {
switch ($section) {
case 'admin/help#blogapi':
return t('This module adds support for several XML-RPC based blogging APIs. Specifically, it currently implements the %bloggerAPI, %metaweblogAPI, and most of the %moveabletype extensions. This allows users to contribute to drupal using external GUI applications, which can often offer richer functionality that online forms based editing', array('%bloggerAPI' => '<a href="http://www.blogger.com/developers/api/1_docs/">Blogger API</a>', '%metaweblogAPI' => '<a href="http://www.xmlrpc.com/metaWeblogApi">MetaWeblog API</a>', '%moveabletype' => '<a href="http://www.movabletype.org/docs/mtmanual_programmatic.html">Moveable Type API</a>'));
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enable users to post using applications that support XML-RPC blog APIs');
}
}
@@ -143,7 +143,7 @@ function blogapi_new_post($req_params) {
$nid = node_save($node);
if ($nid) {
- watchdog('special', t('%node-type: added "%node-title" using blog API', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/view/$nid"));
+ watchdog('special', t('%node-type: added "%node-title" using blog API', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/$nid"));
return new xmlrpcresp(new xmlrpcval($nid, 'string'));
}
@@ -203,7 +203,7 @@ function blogapi_edit_post($req_params) {
}
$nid = node_save($node);
if ($nid) {
- watchdog('special', t('%node-type: updated "%node-title" using blog API', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/view/$nid"));
+ watchdog('special', t('%node-type: updated "%node-title" using blog API', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/$nid"));
return new xmlrpcresp(new xmlrpcval(true, 'boolean'));
}
diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module
index 80ab41421..131d82979 100644
--- a/modules/blogapi/blogapi.module
+++ b/modules/blogapi/blogapi.module
@@ -8,7 +8,7 @@ function blogapi_help($section) {
switch ($section) {
case 'admin/help#blogapi':
return t('This module adds support for several XML-RPC based blogging APIs. Specifically, it currently implements the %bloggerAPI, %metaweblogAPI, and most of the %moveabletype extensions. This allows users to contribute to drupal using external GUI applications, which can often offer richer functionality that online forms based editing', array('%bloggerAPI' => '<a href="http://www.blogger.com/developers/api/1_docs/">Blogger API</a>', '%metaweblogAPI' => '<a href="http://www.xmlrpc.com/metaWeblogApi">MetaWeblog API</a>', '%moveabletype' => '<a href="http://www.movabletype.org/docs/mtmanual_programmatic.html">Moveable Type API</a>'));
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enable users to post using applications that support XML-RPC blog APIs');
}
}
@@ -143,7 +143,7 @@ function blogapi_new_post($req_params) {
$nid = node_save($node);
if ($nid) {
- watchdog('special', t('%node-type: added "%node-title" using blog API', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/view/$nid"));
+ watchdog('special', t('%node-type: added "%node-title" using blog API', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/$nid"));
return new xmlrpcresp(new xmlrpcval($nid, 'string'));
}
@@ -203,7 +203,7 @@ function blogapi_edit_post($req_params) {
}
$nid = node_save($node);
if ($nid) {
- watchdog('special', t('%node-type: updated "%node-title" using blog API', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/view/$nid"));
+ watchdog('special', t('%node-type: updated "%node-title" using blog API', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/$nid"));
return new xmlrpcresp(new xmlrpcval(true, 'boolean'));
}
diff --git a/modules/book.module b/modules/book.module
index bf55805b0..c7d754fb0 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -69,33 +69,53 @@ function book_link($type, $node = 0, $main = 0) {
if ($type == 'node' && $node->type == 'book') {
if (book_access('update', $node)) {
- $links[] = l(t('edit this page'), "node/edit/$node->nid", array('title' => t('Suggest an update for this book page.')));
+ $links[] = l(t('edit this page'), "node/$node->nid/edit", array('title' => t('Suggest an update for this book page.')));
}
if (!$main) {
$links[] = l(t('printer-friendly version'), "book/print/$node->nid", array('title' => t('Show a printer-friendly version of this book page and its sub-pages.')));
}
}
- if ($type == 'system') {
- menu('node/add/book', t('book page'), user_access('maintain books') ? MENU_FALLTHROUGH : MENU_DENIED, 0);
-
- menu('admin/node/book', t('books'), user_access('administer nodes') ? 'book_admin' : MENU_DENIED, 4);
- menu('admin/node/book/orphan', t('orphan pages'), user_access('administer nodes') ? 'book_admin_orphan' : MENU_DENIED, 8);
- menu('admin/node/book/help', t('help'), user_access('administer nodes') ? 'book_help_page' : MENU_DENIED, 9);
-
- $result = db_query('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title');
- while ($book = db_fetch_object($result)) {
- menu("admin/node/book/$book->nid", t('"%title" book', array('%title' => $book->title)), MENU_FALLTHROUGH);
- }
- menu('book', t('books'), user_access('access content') ? 'book_render' : MENU_DENIED, 0, MENU_HIDE);
- menu('book/view', t('view'), user_access('access content') ? 'book_view_page' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('book/print', t('printer-friendly version'), user_access('access content') ? 'book_print' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
-
return $links;
}
/**
+ * Implementation of hook_menu().
+ */
+function book_menu() {
+ $items = array();
+
+ $items[] = array('path' => 'node/add/book', 'title' => t('book page'),
+ 'access' => user_access('maintain books'));
+ $items[] = array('path' => 'admin/node/book', 'title' => t('books'),
+ 'callback' => 'book_admin',
+ 'access' => user_access('administer nodes'),
+ 'weight' => 4);
+ $items[] = array('path' => 'admin/node/book/orphan', 'title' => t('orphan pages'),
+ 'callback' => 'book_admin_orphan',
+ 'access' => user_access('administer nodes'),
+ 'weight' => 8);
+ $result = db_query('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title');
+ while ($book = db_fetch_object($result)) {
+ $items[] = array('path' => 'admin/node/book/'. $book->nid, 'title' => t('"%title" book', array('%title' => $book->title)));
+ }
+ $items[] = array('path' => 'book', 'title' => t('books'),
+ 'callback' => 'book_render',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'book/view', 'title' => t('view'),
+ 'callback' => 'book_view_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'book/print', 'title' => t('printer-friendly version'),
+ 'callback' => 'book_print',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+
+ return $items;
+}
+
+/**
* Implementation of hook_block().
*
* Displays the book table of contents in a block when a node is being
@@ -402,7 +422,7 @@ function book_next($node) {
/**
* Implementation of hook_content().
*/
-function book_content($node, $main = 0) {
+function book_content($node, $teaser = FALSE) {
$op = $_POST['op'];
/*
@@ -436,7 +456,7 @@ function book_content($node, $main = 0) {
ob_end_clean();
}
else {
- $node = node_prepare($node, $main);
+ $node = node_prepare($node, $teaser);
}
return $node;
@@ -448,13 +468,13 @@ function book_content($node, $main = 0) {
* If not displayed on the main page, we render the node as a page in the
* book with extra links to the previous and next pages.
*/
-function book_view($node, $main = 0, $page = 0) {
- $node = book_content($node, $main);
+function book_view($node, $teaser = FALSE, $page = FALSE) {
+ $node = book_content($node, $teaser);
$output = '';
- if ($main) {
- $output .= theme('node', $node, $main, $page);
+ if ($teaser) {
+ $output .= theme('node', $node, $teaser, $page);
}
else {
if ($node->moderate) {
@@ -464,10 +484,10 @@ function book_view($node, $main = 0, $page = 0) {
if ($page) {
$node = book_navigation($node);
// Print the breadcrumb
- drupal_set_breadcrumb($node->breadcrumb);
+ menu_set_location($node->breadcrumb);
}
// Print the node
- $output .= theme('node', $node, $main, $page);
+ $output .= theme('node', $node, $teaser, $page);
}
return $output;
@@ -511,7 +531,7 @@ function book_show($node, $cid) {
/*
** View the node
*/
- drupal_set_breadcrumb($node->breadcrumb);
+ menu_set_location($node->breadcrumb);
$output .= theme('node', $node, 0, 1);
}
else {
@@ -549,11 +569,11 @@ function book_navigation($node) {
** Construct the breadcrumb:
*/
- $node->breadcrumb = ''; // Overwrite the trail with a book trail.
- $node->breadcrumb[] = l(t('Home'), '');
+ $node->breadcrumb = array(); // Overwrite the trail with a book trail.
foreach ($path as $level) {
- $node->breadcrumb[] = l($level->title, "book/view/$level->nid");
+ $node->breadcrumb[] = array('path' => 'book/view/'. $level->nid, 'title' => $level->title);
}
+ $node->breadcrumb[] = array('path' => 'book/view/'. $node->nid);
if ($node->nid) {
$output .= '<div class="book">';
@@ -778,7 +798,7 @@ function book_print_recurse($parent = '', $depth = 1) {
}
function book_admin_view_line($node, $depth = 0) {
- return array("<div style=\"padding-left: ". (25 * $depth) ."px;\">". form_textfield(NULL, "$node->nid][title", $node->title, 64, 255) ."</div>", form_weight(NULL, "$node->nid][weight", $node->weight), l(t("view node"), "node/view/$node->nid"), l(t("edit node"), "admin/node/edit/$node->nid"), l(t("delete node"), "admin/node/delete/$node->nid"));
+ return array("<div style=\"padding-left: ". (25 * $depth) ."px;\">". form_textfield(NULL, "$node->nid][title", $node->title, 64, 255) ."</div>", form_weight(NULL, "$node->nid][weight", $node->weight), l(t("view node"), "node/$node->nid"), l(t("edit node"), "node/$node->nid/edit"), l(t("delete node"), "admin/node/delete/$node->nid"));
}
function book_admin_view_book($nid, $depth = 1) {
@@ -913,7 +933,7 @@ function book_help($section = "admin/help#book") {
<p>Whenever you come across a post which you want to include in your FAQ, click on the <em>administer</em> link. Then click on the <em>edit book outline</em> button at the bottom of the page. Then place the relevant post wherever is most appropriate in your book by selecting a <em>parent</em>. Books are quite flexible. They can have sections like <em>Flying to Estonia</em>, <em>Eating in Estonia</em> and so on. As you get more experienced with the book module, you can reorganize posts in your book so that it stays organized.</p>
<p>Notes:</p><ul><li>Any comments attached to those relevant posts which you designate as book pages will also be transported into your book. This is a great feature, since much wisdom is shared via comments. Remember that all future comments and edits will automatically be reflected in your book.</li><li>You may wish to edit the title of posts when adding them to your FAQ. This is done on the same page as the <em>Edit book outline</em> button. Clear titles improve navigability enormously.</li><li>Book pages may come from any content type (blog, story, page, etc.). If you are creating a post solely for inclusion in your book, then use the <a href=\"%create\">submit content &raquo; book page</a> link.</li><li>If you don't see the <em>administer</em> link, then you probably have insufficient <a href=\"%permissions\">permissions</a>.</li><li>If you want to get really fancy, note that books are one of the few content types which allow raw PHP in their <em>body</em>. So you've got lots of geeky possibilities there.</li></ul>", array("%permissions" => url("admin/user/permission"), "%create" => url("node/add/book"), "%collaborative-book" => url("admin/node/book"), "%orphans-book" => url("admin/node/book/orphan"), "%export-book" => url("book/print")));
break;
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
$output = t("Allows users to collaboratively author a book.");
break;
case 'admin/node/book':
diff --git a/modules/book/book.module b/modules/book/book.module
index bf55805b0..c7d754fb0 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -69,33 +69,53 @@ function book_link($type, $node = 0, $main = 0) {
if ($type == 'node' && $node->type == 'book') {
if (book_access('update', $node)) {
- $links[] = l(t('edit this page'), "node/edit/$node->nid", array('title' => t('Suggest an update for this book page.')));
+ $links[] = l(t('edit this page'), "node/$node->nid/edit", array('title' => t('Suggest an update for this book page.')));
}
if (!$main) {
$links[] = l(t('printer-friendly version'), "book/print/$node->nid", array('title' => t('Show a printer-friendly version of this book page and its sub-pages.')));
}
}
- if ($type == 'system') {
- menu('node/add/book', t('book page'), user_access('maintain books') ? MENU_FALLTHROUGH : MENU_DENIED, 0);
-
- menu('admin/node/book', t('books'), user_access('administer nodes') ? 'book_admin' : MENU_DENIED, 4);
- menu('admin/node/book/orphan', t('orphan pages'), user_access('administer nodes') ? 'book_admin_orphan' : MENU_DENIED, 8);
- menu('admin/node/book/help', t('help'), user_access('administer nodes') ? 'book_help_page' : MENU_DENIED, 9);
-
- $result = db_query('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title');
- while ($book = db_fetch_object($result)) {
- menu("admin/node/book/$book->nid", t('"%title" book', array('%title' => $book->title)), MENU_FALLTHROUGH);
- }
- menu('book', t('books'), user_access('access content') ? 'book_render' : MENU_DENIED, 0, MENU_HIDE);
- menu('book/view', t('view'), user_access('access content') ? 'book_view_page' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('book/print', t('printer-friendly version'), user_access('access content') ? 'book_print' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
-
return $links;
}
/**
+ * Implementation of hook_menu().
+ */
+function book_menu() {
+ $items = array();
+
+ $items[] = array('path' => 'node/add/book', 'title' => t('book page'),
+ 'access' => user_access('maintain books'));
+ $items[] = array('path' => 'admin/node/book', 'title' => t('books'),
+ 'callback' => 'book_admin',
+ 'access' => user_access('administer nodes'),
+ 'weight' => 4);
+ $items[] = array('path' => 'admin/node/book/orphan', 'title' => t('orphan pages'),
+ 'callback' => 'book_admin_orphan',
+ 'access' => user_access('administer nodes'),
+ 'weight' => 8);
+ $result = db_query('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title');
+ while ($book = db_fetch_object($result)) {
+ $items[] = array('path' => 'admin/node/book/'. $book->nid, 'title' => t('"%title" book', array('%title' => $book->title)));
+ }
+ $items[] = array('path' => 'book', 'title' => t('books'),
+ 'callback' => 'book_render',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'book/view', 'title' => t('view'),
+ 'callback' => 'book_view_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'book/print', 'title' => t('printer-friendly version'),
+ 'callback' => 'book_print',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+
+ return $items;
+}
+
+/**
* Implementation of hook_block().
*
* Displays the book table of contents in a block when a node is being
@@ -402,7 +422,7 @@ function book_next($node) {
/**
* Implementation of hook_content().
*/
-function book_content($node, $main = 0) {
+function book_content($node, $teaser = FALSE) {
$op = $_POST['op'];
/*
@@ -436,7 +456,7 @@ function book_content($node, $main = 0) {
ob_end_clean();
}
else {
- $node = node_prepare($node, $main);
+ $node = node_prepare($node, $teaser);
}
return $node;
@@ -448,13 +468,13 @@ function book_content($node, $main = 0) {
* If not displayed on the main page, we render the node as a page in the
* book with extra links to the previous and next pages.
*/
-function book_view($node, $main = 0, $page = 0) {
- $node = book_content($node, $main);
+function book_view($node, $teaser = FALSE, $page = FALSE) {
+ $node = book_content($node, $teaser);
$output = '';
- if ($main) {
- $output .= theme('node', $node, $main, $page);
+ if ($teaser) {
+ $output .= theme('node', $node, $teaser, $page);
}
else {
if ($node->moderate) {
@@ -464,10 +484,10 @@ function book_view($node, $main = 0, $page = 0) {
if ($page) {
$node = book_navigation($node);
// Print the breadcrumb
- drupal_set_breadcrumb($node->breadcrumb);
+ menu_set_location($node->breadcrumb);
}
// Print the node
- $output .= theme('node', $node, $main, $page);
+ $output .= theme('node', $node, $teaser, $page);
}
return $output;
@@ -511,7 +531,7 @@ function book_show($node, $cid) {
/*
** View the node
*/
- drupal_set_breadcrumb($node->breadcrumb);
+ menu_set_location($node->breadcrumb);
$output .= theme('node', $node, 0, 1);
}
else {
@@ -549,11 +569,11 @@ function book_navigation($node) {
** Construct the breadcrumb:
*/
- $node->breadcrumb = ''; // Overwrite the trail with a book trail.
- $node->breadcrumb[] = l(t('Home'), '');
+ $node->breadcrumb = array(); // Overwrite the trail with a book trail.
foreach ($path as $level) {
- $node->breadcrumb[] = l($level->title, "book/view/$level->nid");
+ $node->breadcrumb[] = array('path' => 'book/view/'. $level->nid, 'title' => $level->title);
}
+ $node->breadcrumb[] = array('path' => 'book/view/'. $node->nid);
if ($node->nid) {
$output .= '<div class="book">';
@@ -778,7 +798,7 @@ function book_print_recurse($parent = '', $depth = 1) {
}
function book_admin_view_line($node, $depth = 0) {
- return array("<div style=\"padding-left: ". (25 * $depth) ."px;\">". form_textfield(NULL, "$node->nid][title", $node->title, 64, 255) ."</div>", form_weight(NULL, "$node->nid][weight", $node->weight), l(t("view node"), "node/view/$node->nid"), l(t("edit node"), "admin/node/edit/$node->nid"), l(t("delete node"), "admin/node/delete/$node->nid"));
+ return array("<div style=\"padding-left: ". (25 * $depth) ."px;\">". form_textfield(NULL, "$node->nid][title", $node->title, 64, 255) ."</div>", form_weight(NULL, "$node->nid][weight", $node->weight), l(t("view node"), "node/$node->nid"), l(t("edit node"), "node/$node->nid/edit"), l(t("delete node"), "admin/node/delete/$node->nid"));
}
function book_admin_view_book($nid, $depth = 1) {
@@ -913,7 +933,7 @@ function book_help($section = "admin/help#book") {
<p>Whenever you come across a post which you want to include in your FAQ, click on the <em>administer</em> link. Then click on the <em>edit book outline</em> button at the bottom of the page. Then place the relevant post wherever is most appropriate in your book by selecting a <em>parent</em>. Books are quite flexible. They can have sections like <em>Flying to Estonia</em>, <em>Eating in Estonia</em> and so on. As you get more experienced with the book module, you can reorganize posts in your book so that it stays organized.</p>
<p>Notes:</p><ul><li>Any comments attached to those relevant posts which you designate as book pages will also be transported into your book. This is a great feature, since much wisdom is shared via comments. Remember that all future comments and edits will automatically be reflected in your book.</li><li>You may wish to edit the title of posts when adding them to your FAQ. This is done on the same page as the <em>Edit book outline</em> button. Clear titles improve navigability enormously.</li><li>Book pages may come from any content type (blog, story, page, etc.). If you are creating a post solely for inclusion in your book, then use the <a href=\"%create\">submit content &raquo; book page</a> link.</li><li>If you don't see the <em>administer</em> link, then you probably have insufficient <a href=\"%permissions\">permissions</a>.</li><li>If you want to get really fancy, note that books are one of the few content types which allow raw PHP in their <em>body</em>. So you've got lots of geeky possibilities there.</li></ul>", array("%permissions" => url("admin/user/permission"), "%create" => url("node/add/book"), "%collaborative-book" => url("admin/node/book"), "%orphans-book" => url("admin/node/book/orphan"), "%export-book" => url("book/print")));
break;
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
$output = t("Allows users to collaboratively author a book.");
break;
case 'admin/node/book':
diff --git a/modules/comment.module b/modules/comment.module
index 4e981825f..09fa1801a 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -68,28 +68,24 @@ function comment_help($section) {
<p>To see a common example of how thresholds work, you might visit <a href=\"%slashdot\">Slashdot</a> and view one of their comment boards associated with a story. You can reset the thresholds in their comment control panel.</p>
<h4>Initial comment scores</h4>
- <p>Finally, you may want to enter some <em>initial comment scores</em>. In <a href=\"%comment-initial\">administer &raquo; comments &raquo; initial comment scores</a> you can assign a beginning rating for all comments posted by a particular permission role. If you do not assign any initial scores, Drupal will assign a rating of <strong>0</strong> as the default.</p>", array('%comment-config' => url('admin/system/modules/comment'), '%site-config' => url('admin/system'), '%user-permissions' => url('admin/user/permission'), '%tracker' => url('tracker'), '%download-notify' => 'http://drupal.org/project/releases', '%permission' => url('admin/user/permission'), '%comment-moderation' => url('admin/comment/moderation'), '%comment-votes' => url('admin/comment/moderation/votes'), '%comment-matrix' => url('admin/comment/moderation/matrix'), '%comment-thresholds' => url('admin/comment/moderation/filters'), '%slashdot' => ' http://slashdot.org', '%comment-initial' => url('admin/comment/moderation/roles')));
- case 'admin/system/modules#description':
+ <p>Finally, you may want to enter some <em>initial comment scores</em>. In <a href=\"%comment-initial\">administer &raquo; comments &raquo; initial comment scores</a> you can assign a beginning rating for all comments posted by a particular permission role. If you do not assign any initial scores, Drupal will assign a rating of <strong>0</strong> as the default.</p>", array('%comment-config' => url('admin/settings/comment'), '%site-config' => url('admin'), '%user-permissions' => url('admin/user/permission'), '%tracker' => url('tracker'), '%download-notify' => 'http://drupal.org/project/releases', '%permission' => url('admin/user/permission'), '%comment-moderation' => url('admin/settings/comment'), '%comment-votes' => url('admin/settings/comment/votes'), '%comment-matrix' => url('admin/settings/comment/matrix'), '%comment-thresholds' => url('admin/settings/comment/thresholds'), '%slashdot' => ' http://slashdot.org', '%comment-initial' => url('admin/settings/comment/roles')));
+ case 'admin/modules#description':
return t('Enables user to comment on content (nodes).');
- case 'admin/system/modules/comment':
- return t("Comments can be attached to any node. Below are the settings for comments. The display comes in two types, a \"flat list\" where everything is flush to the left side, and comments come in cronological order, and a \"threaded list\" where comments to other comments are placed immediately below and slightly indented forming an outline. They also come in two styles: \"expanded\", where you see both the title and the contents, and \"collapsed\" where you only see the title. To set the default threshold you first have to set up thresholds in the <a href=\"%threshold\">administer &raquo; comments &raquo; moderation &raquo; thresholds</a> area. Preview comment forces a user to look at their comment by clicking on a \"Preview\" button before they can actually add the comment. If \"New comment form\" is enabled then at the bottom of every comment page there will be a form too add a new comment.", array('%threshold' => url('admin/comment/moderation/filters')));
+ case 'admin/settings/comment':
+ return t("Comments can be attached to any node. Below are the settings for comments. The display comes in two types, a \"flat list\" where everything is flush to the left side, and comments come in cronological order, and a \"threaded list\" where comments to other comments are placed immediately below and slightly indented forming an outline. They also come in two styles: \"expanded\", where you see both the title and the contents, and \"collapsed\" where you only see the title. To set the default threshold you first have to set up thresholds in the <a href=\"%threshold\">administer &raquo; comments &raquo; moderation &raquo; thresholds</a> area. Preview comment forces a user to look at their comment by clicking on a \"Preview\" button before they can actually add the comment. If \"New comment form\" is enabled then at the bottom of every comment page there will be a form too add a new comment.", array('%threshold' => url('admin/settings/comment/thresholds')));
case 'admin/comment':
- return t('Comments let users give feedback to content authors. Here you may review/approve/deny recent comments, and configure moderation if desired.');
- case 'admin/comment/comments':
- return t("Click on <a href=\"%nup\">new or updated comments</a> to see your latest comments, or <a href=\"%queue\">comment approval queue</a> to approve new comments.", array('%nup' => url('admin/comment/comments/0'), '%queue' => url('admin/comment/comments/1')));
- case 'admin/comment/comments/0':
return t("Below is a list of the latest comments posted your site. Click on a subject to see the comment, the author's name to edit the author's user information , \"edit comment\" to edit the comment, and \"delete comment\" to remove the comment.");
- case 'admin/comment/comments/1':
+ case 'admin/comment/approval':
return t("Below is a list of the comments posted to your site that need approval. To approve a comment click on <strong>\"edit comment\"</strong> and then change its <strong>moderation status</strong> to Approved.<br />Click on a subject to see the comment, the author's name to edit the author's user information, \"edit comment\" to edit the comment, and \"delete comment\" to remove the comment.");
- case 'admin/comment/moderation':
- return t("If you have a get a lot of comments, you can enable comment moderation. Once moderation is enabled users can vote on a comment based on dropdown menus. <a href=\"%votes\">Votes</a> sets up the names in the dropdown menu, and the order in which they appear, using weights. <a href=\"%matrix\">Matrix</a> sets up the value of each user's vote, and <a href=\"%threshhold\">threshhold</a> sets up the levels at which a comment will be displayed.", array('%votes' => url('admin/comment/moderation/votes'), '%matrix' => url('admin/comment/moderation/matrix'), '%threshhold' => url('admin/comment/moderation/filters')));
- case 'admin/comment/moderation/votes':
- return t("Here is where you setup the names of each type of vote. Weight lets you set the order of the drop down menu. Click <strong>edit</strong> to edit a current vote weight.<br />Notes: <ul><li>you can have more than one type with the same name. The system does not protect you from this.</li><li>To <strong>delete</strong> a name/weight combiniation go to the <strong>edit</strong> area.</li></ul>");
- case 'admin/comment/moderation/matrix':
+ case 'admin/settings/comment': // TODO: THIS IS NEVER USED
+ return t("If you get a lot of comments, you can enable comment moderation. Once moderation is enabled, users can vote on a comment based on dropdown menus. <a href=\"%votes\">Votes</a> sets up the names in the dropdown menu, and the order in which they appear, using weights. <a href=\"%matrix\">Matrix</a> sets up the value of each user's vote, and <a href=\"%threshhold\">threshhold</a> sets up the levels at which a comment will be displayed.", array('%votes' => url('admin/settings/comment/votes'), '%matrix' => url('admin/settings/comment/matrix'), '%threshhold' => url('admin/settings/comment/thresholds')));
+ case 'admin/settings/comment/votes':
+ return t('Here is where you set up the name of each type of vote. "Weight" lets you set the order of the drop down menu. Click <strong>edit</strong> to edit a current vote weight.<br />Notes: <ul><li>you can have more than one type with the same name. The system does not protect you from this.</li><li>To <strong>delete</strong> a name/weight combiniation go to the <strong>edit</strong> area.</li></ul>');
+ case 'admin/settings/comment/matrix':
return t("Here is where you assign a value to each item in the dropdown menu. This value is added to the vote total, which is then divided by the number of users who have voted and rounded off to the nearest integer.<br />Notes:<ul><li>In order to use comment moderation, every text box on this page should be populated.</li><li>You must assign the <strong>moderate comments</strong> permission to at least one role in order to use this page.</li><li>Every box not filled in will have a value of zero, which will have the effect of <strong>lowering</strong> a comments over all score.</li></ul>");
- case 'admin/comment/moderation/filters':
+ case 'admin/settings/comment/thresholds':
return t("<em>Optional</em> Here you can setup the name and minimum \"cut off\" score to help your users hide comments that they don't want too see. These thresholds appear in the Comment Control Panel. Click \"edit\" to edit the values of an already exsisting threashold. To <strong>delete</strong> a threshold click on \"edit\".");
- case 'admin/comment/moderation/roles':
+ case 'admin/settings/comment/roles':
return t("Here you can setup the <strong>initial</strong> vote value of a comment posted by each user role. This value is used before any other users vote on the comment.<br />Note: Blank entries are valued at zero");
case 'admin/comment/search':
return t("Enter a simple pattern ( '*' maybe used as a wildcard match) to search for a comment. For example, one may search for 'br' and Drupal might return 'bread brakers', 'our daily bread' and 'brenda'.");
@@ -104,9 +100,13 @@ function comment_help_page() {
}
/**
- * Implementation of hook_settings().
+ * Menu callback; presents the comment settings page.
*/
-function comment_settings() {
+function comment_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
$group = form_radios(t('Default display mode'), 'comment_default_mode', variable_get('comment_default_mode', 4), _comment_get_modes(), t('The default view for comments. Expanded views display the body of the comment. Threaded views keep replies together.'));
$group .= form_radios(t('Default display order'), 'comment_default_order', variable_get('comment_default_order', 1), _comment_get_orders(), t('The default sorting for new users and anonymous users while viewing comments. These users may change their view using the comment control panel. For registered users, this change is remembered as a persistent user preference.'));
$group .= form_select(t('Default comments per page'), 'comment_default_per_page', variable_get('comment_default_per_page', '50'), _comment_per_page(), t('Default number of comments for each page: more comments are distributed in several pages.'));
@@ -128,7 +128,7 @@ function comment_settings() {
$output .= form_group(t('Comment moderation settings'), $group);
}
- return $output;
+ print theme('page', system_settings_form($output));
}
/**
@@ -333,7 +333,7 @@ function comment_post($edit) {
module_invoke_all('comment', 'update', $edit);
// Add entry to the watchdog log.
- watchdog('special', t('comment: updated "%comment-subject"', array('%comment-subject' => $edit['subject'])), l(t('view comment'), 'node/view/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
+ watchdog('special', t('comment: updated "%comment-subject"', array('%comment-subject' => $edit['subject'])), l(t('view comment'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
}
else {
// Add the comment to database.
@@ -442,7 +442,7 @@ function comment_post($edit) {
module_invoke_all('comment', 'insert', $edit);
// Add an entry to the watchdog log.
- watchdog('special', t('comment: added "%comment-subject"', array('%comment-subject' => $edit['subject'])), l(t('view comment'), 'node/view/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
+ watchdog('special', t('comment: added "%comment-subject"', array('%comment-subject' => $edit['subject'])), l(t('view comment'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
}
// Clear the cache so an anonymous user can see his comment being added.
@@ -457,7 +457,7 @@ function comment_post($edit) {
}
else {
// Redirect the user to his comment:
- drupal_goto('node/view/'. $edit['nid'] .'#comment-'. $edit['cid']);
+ drupal_goto('node/'. $edit['nid'] .'#comment-'. $edit['cid']);
}
}
else {
@@ -549,7 +549,7 @@ function comment_render($node, $cid = 0) {
if ($comment = db_fetch_object($result)) {
$comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
- $output .= theme("comment_view", $comment, theme('links', module_invoke_all('link', 'comment', $comment, 1)));
+ $output .= theme('comment_view', $comment, theme('links', module_invoke_all('link', 'comment', $comment, 1)));
}
if ((comment_user_can_moderate($node)) && $user->uid != $comment->uid && !(comment_already_moderated($user->uid, $comment->users))) {
@@ -735,10 +735,10 @@ function comment_link($type, $node = 0, $main = 0) {
$new = comment_num_new($node->nid);
if ($all) {
- $links[] = l(format_plural($all, '1 comment', '%count comments'), "node/view/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
+ $links[] = l(format_plural($all, '1 comment', '%count comments'), "node/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
if ($new) {
- $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/view/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
+ $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
}
}
else {
@@ -772,35 +772,70 @@ function comment_link($type, $node = 0, $main = 0) {
$links = comment_links($node, $main);
}
- if ($type == 'system') {
- $access = user_access('administer comments');
- menu('admin/comment', t('comments'), $access ? 'comment_admin' : MENU_DENIED, 1);
- menu('admin/comment/comments', t('overview'), $access ? 'comment_admin' : MENU_DENIED, 2);
- menu('admin/comment/comments/0', t('new/updated'), $access ? 'comment_admin' : MENU_DENIED, 1);
- menu('admin/comment/comments/1', t('approval queue'), $access ? 'comment_admin' : MENU_DENIED, 2);
- menu('admin/comment/help', t('help'), $access ? 'comment_help_page' : MENU_DENIED, 9);
- menu('admin/comment/edit', t('edit comment'), $access ? 'comment_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/comment/delete', t('delete comment'), $access ? 'comment_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- if (module_exist('search')) {
- menu('admin/comment/search', t('search'), $access ? 'comment_admin' : MENU_DENIED, 8);
- }
-
- // comment settings:
- $access = user_access('administer comments') && user_access('administer moderation');
- menu('admin/comment/moderation', t('moderation'), $access ? 'comment_admin' : MENU_DENIED, 3);
- menu('admin/comment/moderation/votes', t('votes'), $access ? 'comment_admin' : MENU_DENIED);
- menu('admin/comment/moderation/matrix', t('matrix'), $access ? 'comment_admin' : MENU_DENIED);
- menu('admin/comment/moderation/filters', t('thresholds'), $access ? 'comment_admin' : MENU_DENIED);
- menu('admin/comment/moderation/roles', t('initial scores'), $access ? 'comment_admin' : MENU_DENIED, 6);
-
- menu('comment', t('comments'), 'comment_page', 0, MENU_HIDE, MENU_LOCKED);
- }
-
return $links;
}
/**
- * Menu callback.
+ * Implementation of hook_menu().
+ */
+function comment_menu() {
+ $items = array();
+ $access = user_access('administer comments');
+
+ $items[] = array('path' => 'admin/comment', 'title' => t('comments'),
+ 'callback' => 'comment_admin', 'access' => $access);
+ $items[] = array('path' => 'admin/comment/edit', 'title' => t('edit comment'),
+ 'callback' => 'comment_admin', 'access' => $access,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/comment/delete', 'title' => t('delete comment'),
+ 'callback' => 'comment_admin', 'access' => $access,
+ 'type' => MENU_CALLBACK);
+
+ // Tabs:
+ $items[] = array('path' => 'admin/comment/configure', 'title' => t('configure'),
+ 'callback' => 'comment_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_TASK);
+ if (module_exist('search')) {
+ $items[] = array('path' => 'admin/comment/search', 'title' => t('search'),
+ 'callback' => 'comment_admin', 'access' => $access,
+ 'type' => MENU_LOCAL_TASK);
+ }
+
+ // Subtabs:
+ $items[] = array('path' => 'admin/comment/new', 'title' => t('new comments'),
+ 'callback' => 'comment_admin', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/comment/approval', 'title' => t('approval queue'),
+ 'callback' => 'comment_admin', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/comment/configure/settings', 'title' => t('settings'),
+ 'callback' => 'comment_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $access = user_access('administer comments') && user_access('administer moderation');
+ $items[] = array('path' => 'admin/comment/configure/matrix', 'title' => t('moderation matrix'),
+ 'callback' => 'comment_matrix_settings', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/comment/configure/thresholds', 'title' => t('moderation thresholds'),
+ 'callback' => 'comment_threshold_settings', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/comment/configure/votes', 'title' => t('moderation votes'),
+ 'callback' => 'comment_vote_settings', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK,
+ 'weight' => 6);
+ $items[] = array('path' => 'admin/comment/configure/roles', 'title' => t('moderation roles'),
+ 'callback' => 'comment_role_settings', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK,
+ 'weight' => 6);
+
+ $items[] = array('path' => 'comment', 'title' => t('comments'),
+ 'callback' => 'comment_page', 'access' => $access,
+ 'type' => MENU_CALLBACK);
+
+ return $items;
+}
+
+/**
+ * Menu callback; dispatches to the correct comment function.
*/
function comment_page() {
$op = $_POST['op'];
@@ -856,7 +891,7 @@ function comment_node_link($node) {
while ($comment = db_fetch_object($result)) {
$comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
- $rows[] = array(l($comment->subject, "node/view/$node->nid", NULL, NULL, "comment-$comment->cid"), format_name($comment), l(t('view comment'), "node/view/$node->nid", NULL, NULL, $comment->cid), l(t('edit comment'), "admin/comment/edit/$comment->cid"), l(t('delete comment'), "admin/comment/delete/$comment->cid"));
+ $rows[] = array(l($comment->subject, "node/$node->nid", NULL, NULL, "comment-$comment->cid"), format_name($comment), l(t('view comment'), "node/$node->nid", NULL, NULL, $comment->cid), l(t('edit comment'), "admin/comment/edit/$comment->cid"), l(t('delete comment'), "admin/comment/delete/$comment->cid"));
}
if ($rows) {
@@ -934,7 +969,7 @@ function comment_save($id, $edit) {
drupal_set_message(t('the comment has been saved.'));
}
-function comment_admin_overview($status = 0) {
+function comment_admin_overview() {
$header = array(
array('data' => t('subject'), 'field' => 'subject'),
@@ -944,6 +979,7 @@ function comment_admin_overview($status = 0) {
array('data' => t('operations'), 'colspan' => 2)
);
+ $status = (arg(2) == 'approval') ? 1 : 0;
$sql = 'SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.status = '. check_query($status);
$sql .= tablesort_sql($header);
$result = pager_query($sql, 50);
@@ -951,7 +987,7 @@ function comment_admin_overview($status = 0) {
while ($comment = db_fetch_object($result)) {
$comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
$rows[] = array(
- l($comment->subject, "node/view/$comment->nid/$comment->cid", array('title' => htmlspecialchars(truncate_utf8($comment->comment, 128))), NULL, "comment-$comment->cid") ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme('mark') : ''),
+ l($comment->subject, "node/$comment->nid", array('title' => htmlspecialchars(truncate_utf8($comment->comment, 128))), NULL, "comment-$comment->cid") ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme('mark') : ''),
format_name($comment),
($comment->status == 0 ? t('published') : t('not published')),
format_date($comment->timestamp, 'small'),
@@ -967,7 +1003,11 @@ function comment_admin_overview($status = 0) {
return theme('table', $header, $rows);
}
-function comment_mod_matrix($edit) {
+/**
+ * Menu callback; presents the moderation vote matrix.
+ */
+function comment_matrix_settings() {
+ $edit = $_POST['edit'];
$output .= '<h3>Moderation vote/value matrix</h3>';
@@ -1006,10 +1046,15 @@ function comment_mod_matrix($edit) {
$output .= theme('table', $header, $rows);
$output .= '<br />'. form_submit(t('Submit votes'));
- return form($output);
+ print theme('page', form($output));
}
-function comment_mod_roles($edit) {
+/**
+ * Menu callback; allows admin to set default scores for different roles.
+ */
+function comment_role_settings() {
+
+ $edit = $_POST['edit'];
$output .= '<h3>Initial comment scores</h3>';
@@ -1031,11 +1076,15 @@ function comment_mod_roles($edit) {
$output .= theme('table', $header, $rows);
$output .= '<br />'. form_submit(t('Save scores'));
- return form($output);
+ print theme('page', form($output));
}
-function comment_mod_votes($edit) {
+/**
+ * Menu callback; displays page for assigning names to vote values.
+ */
+function comment_vote_settings() {
$op = $_POST['op'];
+ $edit = $_POST['edit'];
$mid = arg(4);
@@ -1061,7 +1110,7 @@ function comment_mod_votes($edit) {
$result = db_query('SELECT mid, vote, weight FROM {moderation_votes} ORDER BY weight');
while ($vote = db_fetch_object($result)) {
- $rows[] = array($vote->vote, array('data' => $vote->weight, 'align' => 'center'), array('data' => l(t('edit'), "admin/comment/moderation/votes/$vote->mid"), 'align' => 'center'));
+ $rows[] = array($vote->vote, array('data' => $vote->weight, 'align' => 'center'), array('data' => l(t('edit'), "admin/settings/comment/votes/$vote->mid"), 'align' => 'center'));
}
$output .= theme('table', $header, $rows);
@@ -1080,13 +1129,15 @@ function comment_mod_votes($edit) {
$form .= form_submit(t('Add new vote'));
}
- $output .= form($form);
-
- return $output;
+ print theme('page', form($form));
}
-function comment_mod_filters($edit) {
+/**
+ * Menu callback; displays settings for thresholds at which comments are displayed.
+ */
+function comment_threshold_settings() {
$op = $_POST['op'];
+ $edit = $_POST['edit'];
$fid = arg(4);
@@ -1112,7 +1163,7 @@ function comment_mod_filters($edit) {
$result = db_query('SELECT fid, filter, minimum FROM {moderation_filters} ORDER BY minimum');
while ($filter = db_fetch_object($result)) {
- $rows[] = array($filter->filter, array('data' => $filter->minimum, 'align' => 'center'), array('data' => l(t('edit'), "admin/comment/moderation/filters/$filter->fid"), 'align' => 'center'));
+ $rows[] = array($filter->filter, array('data' => $filter->minimum, 'align' => 'center'), array('data' => l(t('edit'), "admin/settings/comment/thresholds/$filter->fid"), 'align' => 'center'));
}
$output .= theme('table', $header, $rows);
@@ -1131,12 +1182,9 @@ function comment_mod_filters($edit) {
$form .= form_submit(t('Add new threshold'));
}
- $output .= form($form);
-
- return $output;
+ print theme('page', form($form));
}
-
function comment_admin() {
$op = $_POST['op'];
$edit = $_POST['edit'];
@@ -1145,10 +1193,6 @@ function comment_admin() {
$op = arg(2);
}
- if ($op == 'moderation') {
- $op = arg(3);
- }
-
switch ($op) {
case 'edit':
$output = comment_admin_edit(arg(3));
@@ -1156,34 +1200,6 @@ function comment_admin() {
case 'search':
$output = search_type('comment', url('admin/comment/search'), $_POST['keys']);
break;
- case 'votes':
- case t('Add new vote'):
- case t('Delete vote'):
- case t('Save vote'):
- if (user_access('administer moderation')) {
- $output = comment_mod_votes($edit);
- }
- break;
- case 'roles':
- case t('Save scores'):
- if (user_access('administer moderation')) {
- $output = comment_mod_roles($edit);
- }
- break;
- case 'matrix':
- case t('Submit votes'):
- if (user_access('administer moderation')) {
- $output = comment_mod_matrix($edit);
- }
- break;
- case 'filters':
- case t('Add new threshold'):
- case t('Delete threshold'):
- case t('Save threshold'):
- if (user_access('administer moderation')) {
- $output = comment_mod_filters($edit);
- }
- break;
case 'delete':
$output = comment_delete(arg(3), 0);
break;
@@ -1192,15 +1208,10 @@ function comment_admin() {
break;
case t('Submit'):
$output = comment_save(check_query(arg(3)), $edit);
- $output .= comment_admin_overview(0);
+ $output .= comment_admin_overview();
break;
default:
- if (arg(3) == 1) {
- $output = comment_admin_overview(1);
- }
- else {
- $output = comment_admin_overview(0);
- }
+ $output = comment_admin_overview();
}
print theme('page', $output);
}
@@ -1649,4 +1660,4 @@ function _comment_per_page() {
return drupal_map_assoc(array(10, 30, 50, 70, 90));
}
-?>
+?> \ No newline at end of file
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 4e981825f..09fa1801a 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -68,28 +68,24 @@ function comment_help($section) {
<p>To see a common example of how thresholds work, you might visit <a href=\"%slashdot\">Slashdot</a> and view one of their comment boards associated with a story. You can reset the thresholds in their comment control panel.</p>
<h4>Initial comment scores</h4>
- <p>Finally, you may want to enter some <em>initial comment scores</em>. In <a href=\"%comment-initial\">administer &raquo; comments &raquo; initial comment scores</a> you can assign a beginning rating for all comments posted by a particular permission role. If you do not assign any initial scores, Drupal will assign a rating of <strong>0</strong> as the default.</p>", array('%comment-config' => url('admin/system/modules/comment'), '%site-config' => url('admin/system'), '%user-permissions' => url('admin/user/permission'), '%tracker' => url('tracker'), '%download-notify' => 'http://drupal.org/project/releases', '%permission' => url('admin/user/permission'), '%comment-moderation' => url('admin/comment/moderation'), '%comment-votes' => url('admin/comment/moderation/votes'), '%comment-matrix' => url('admin/comment/moderation/matrix'), '%comment-thresholds' => url('admin/comment/moderation/filters'), '%slashdot' => ' http://slashdot.org', '%comment-initial' => url('admin/comment/moderation/roles')));
- case 'admin/system/modules#description':
+ <p>Finally, you may want to enter some <em>initial comment scores</em>. In <a href=\"%comment-initial\">administer &raquo; comments &raquo; initial comment scores</a> you can assign a beginning rating for all comments posted by a particular permission role. If you do not assign any initial scores, Drupal will assign a rating of <strong>0</strong> as the default.</p>", array('%comment-config' => url('admin/settings/comment'), '%site-config' => url('admin'), '%user-permissions' => url('admin/user/permission'), '%tracker' => url('tracker'), '%download-notify' => 'http://drupal.org/project/releases', '%permission' => url('admin/user/permission'), '%comment-moderation' => url('admin/settings/comment'), '%comment-votes' => url('admin/settings/comment/votes'), '%comment-matrix' => url('admin/settings/comment/matrix'), '%comment-thresholds' => url('admin/settings/comment/thresholds'), '%slashdot' => ' http://slashdot.org', '%comment-initial' => url('admin/settings/comment/roles')));
+ case 'admin/modules#description':
return t('Enables user to comment on content (nodes).');
- case 'admin/system/modules/comment':
- return t("Comments can be attached to any node. Below are the settings for comments. The display comes in two types, a \"flat list\" where everything is flush to the left side, and comments come in cronological order, and a \"threaded list\" where comments to other comments are placed immediately below and slightly indented forming an outline. They also come in two styles: \"expanded\", where you see both the title and the contents, and \"collapsed\" where you only see the title. To set the default threshold you first have to set up thresholds in the <a href=\"%threshold\">administer &raquo; comments &raquo; moderation &raquo; thresholds</a> area. Preview comment forces a user to look at their comment by clicking on a \"Preview\" button before they can actually add the comment. If \"New comment form\" is enabled then at the bottom of every comment page there will be a form too add a new comment.", array('%threshold' => url('admin/comment/moderation/filters')));
+ case 'admin/settings/comment':
+ return t("Comments can be attached to any node. Below are the settings for comments. The display comes in two types, a \"flat list\" where everything is flush to the left side, and comments come in cronological order, and a \"threaded list\" where comments to other comments are placed immediately below and slightly indented forming an outline. They also come in two styles: \"expanded\", where you see both the title and the contents, and \"collapsed\" where you only see the title. To set the default threshold you first have to set up thresholds in the <a href=\"%threshold\">administer &raquo; comments &raquo; moderation &raquo; thresholds</a> area. Preview comment forces a user to look at their comment by clicking on a \"Preview\" button before they can actually add the comment. If \"New comment form\" is enabled then at the bottom of every comment page there will be a form too add a new comment.", array('%threshold' => url('admin/settings/comment/thresholds')));
case 'admin/comment':
- return t('Comments let users give feedback to content authors. Here you may review/approve/deny recent comments, and configure moderation if desired.');
- case 'admin/comment/comments':
- return t("Click on <a href=\"%nup\">new or updated comments</a> to see your latest comments, or <a href=\"%queue\">comment approval queue</a> to approve new comments.", array('%nup' => url('admin/comment/comments/0'), '%queue' => url('admin/comment/comments/1')));
- case 'admin/comment/comments/0':
return t("Below is a list of the latest comments posted your site. Click on a subject to see the comment, the author's name to edit the author's user information , \"edit comment\" to edit the comment, and \"delete comment\" to remove the comment.");
- case 'admin/comment/comments/1':
+ case 'admin/comment/approval':
return t("Below is a list of the comments posted to your site that need approval. To approve a comment click on <strong>\"edit comment\"</strong> and then change its <strong>moderation status</strong> to Approved.<br />Click on a subject to see the comment, the author's name to edit the author's user information, \"edit comment\" to edit the comment, and \"delete comment\" to remove the comment.");
- case 'admin/comment/moderation':
- return t("If you have a get a lot of comments, you can enable comment moderation. Once moderation is enabled users can vote on a comment based on dropdown menus. <a href=\"%votes\">Votes</a> sets up the names in the dropdown menu, and the order in which they appear, using weights. <a href=\"%matrix\">Matrix</a> sets up the value of each user's vote, and <a href=\"%threshhold\">threshhold</a> sets up the levels at which a comment will be displayed.", array('%votes' => url('admin/comment/moderation/votes'), '%matrix' => url('admin/comment/moderation/matrix'), '%threshhold' => url('admin/comment/moderation/filters')));
- case 'admin/comment/moderation/votes':
- return t("Here is where you setup the names of each type of vote. Weight lets you set the order of the drop down menu. Click <strong>edit</strong> to edit a current vote weight.<br />Notes: <ul><li>you can have more than one type with the same name. The system does not protect you from this.</li><li>To <strong>delete</strong> a name/weight combiniation go to the <strong>edit</strong> area.</li></ul>");
- case 'admin/comment/moderation/matrix':
+ case 'admin/settings/comment': // TODO: THIS IS NEVER USED
+ return t("If you get a lot of comments, you can enable comment moderation. Once moderation is enabled, users can vote on a comment based on dropdown menus. <a href=\"%votes\">Votes</a> sets up the names in the dropdown menu, and the order in which they appear, using weights. <a href=\"%matrix\">Matrix</a> sets up the value of each user's vote, and <a href=\"%threshhold\">threshhold</a> sets up the levels at which a comment will be displayed.", array('%votes' => url('admin/settings/comment/votes'), '%matrix' => url('admin/settings/comment/matrix'), '%threshhold' => url('admin/settings/comment/thresholds')));
+ case 'admin/settings/comment/votes':
+ return t('Here is where you set up the name of each type of vote. "Weight" lets you set the order of the drop down menu. Click <strong>edit</strong> to edit a current vote weight.<br />Notes: <ul><li>you can have more than one type with the same name. The system does not protect you from this.</li><li>To <strong>delete</strong> a name/weight combiniation go to the <strong>edit</strong> area.</li></ul>');
+ case 'admin/settings/comment/matrix':
return t("Here is where you assign a value to each item in the dropdown menu. This value is added to the vote total, which is then divided by the number of users who have voted and rounded off to the nearest integer.<br />Notes:<ul><li>In order to use comment moderation, every text box on this page should be populated.</li><li>You must assign the <strong>moderate comments</strong> permission to at least one role in order to use this page.</li><li>Every box not filled in will have a value of zero, which will have the effect of <strong>lowering</strong> a comments over all score.</li></ul>");
- case 'admin/comment/moderation/filters':
+ case 'admin/settings/comment/thresholds':
return t("<em>Optional</em> Here you can setup the name and minimum \"cut off\" score to help your users hide comments that they don't want too see. These thresholds appear in the Comment Control Panel. Click \"edit\" to edit the values of an already exsisting threashold. To <strong>delete</strong> a threshold click on \"edit\".");
- case 'admin/comment/moderation/roles':
+ case 'admin/settings/comment/roles':
return t("Here you can setup the <strong>initial</strong> vote value of a comment posted by each user role. This value is used before any other users vote on the comment.<br />Note: Blank entries are valued at zero");
case 'admin/comment/search':
return t("Enter a simple pattern ( '*' maybe used as a wildcard match) to search for a comment. For example, one may search for 'br' and Drupal might return 'bread brakers', 'our daily bread' and 'brenda'.");
@@ -104,9 +100,13 @@ function comment_help_page() {
}
/**
- * Implementation of hook_settings().
+ * Menu callback; presents the comment settings page.
*/
-function comment_settings() {
+function comment_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
$group = form_radios(t('Default display mode'), 'comment_default_mode', variable_get('comment_default_mode', 4), _comment_get_modes(), t('The default view for comments. Expanded views display the body of the comment. Threaded views keep replies together.'));
$group .= form_radios(t('Default display order'), 'comment_default_order', variable_get('comment_default_order', 1), _comment_get_orders(), t('The default sorting for new users and anonymous users while viewing comments. These users may change their view using the comment control panel. For registered users, this change is remembered as a persistent user preference.'));
$group .= form_select(t('Default comments per page'), 'comment_default_per_page', variable_get('comment_default_per_page', '50'), _comment_per_page(), t('Default number of comments for each page: more comments are distributed in several pages.'));
@@ -128,7 +128,7 @@ function comment_settings() {
$output .= form_group(t('Comment moderation settings'), $group);
}
- return $output;
+ print theme('page', system_settings_form($output));
}
/**
@@ -333,7 +333,7 @@ function comment_post($edit) {
module_invoke_all('comment', 'update', $edit);
// Add entry to the watchdog log.
- watchdog('special', t('comment: updated "%comment-subject"', array('%comment-subject' => $edit['subject'])), l(t('view comment'), 'node/view/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
+ watchdog('special', t('comment: updated "%comment-subject"', array('%comment-subject' => $edit['subject'])), l(t('view comment'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
}
else {
// Add the comment to database.
@@ -442,7 +442,7 @@ function comment_post($edit) {
module_invoke_all('comment', 'insert', $edit);
// Add an entry to the watchdog log.
- watchdog('special', t('comment: added "%comment-subject"', array('%comment-subject' => $edit['subject'])), l(t('view comment'), 'node/view/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
+ watchdog('special', t('comment: added "%comment-subject"', array('%comment-subject' => $edit['subject'])), l(t('view comment'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
}
// Clear the cache so an anonymous user can see his comment being added.
@@ -457,7 +457,7 @@ function comment_post($edit) {
}
else {
// Redirect the user to his comment:
- drupal_goto('node/view/'. $edit['nid'] .'#comment-'. $edit['cid']);
+ drupal_goto('node/'. $edit['nid'] .'#comment-'. $edit['cid']);
}
}
else {
@@ -549,7 +549,7 @@ function comment_render($node, $cid = 0) {
if ($comment = db_fetch_object($result)) {
$comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
- $output .= theme("comment_view", $comment, theme('links', module_invoke_all('link', 'comment', $comment, 1)));
+ $output .= theme('comment_view', $comment, theme('links', module_invoke_all('link', 'comment', $comment, 1)));
}
if ((comment_user_can_moderate($node)) && $user->uid != $comment->uid && !(comment_already_moderated($user->uid, $comment->users))) {
@@ -735,10 +735,10 @@ function comment_link($type, $node = 0, $main = 0) {
$new = comment_num_new($node->nid);
if ($all) {
- $links[] = l(format_plural($all, '1 comment', '%count comments'), "node/view/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
+ $links[] = l(format_plural($all, '1 comment', '%count comments'), "node/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
if ($new) {
- $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/view/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
+ $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
}
}
else {
@@ -772,35 +772,70 @@ function comment_link($type, $node = 0, $main = 0) {
$links = comment_links($node, $main);
}
- if ($type == 'system') {
- $access = user_access('administer comments');
- menu('admin/comment', t('comments'), $access ? 'comment_admin' : MENU_DENIED, 1);
- menu('admin/comment/comments', t('overview'), $access ? 'comment_admin' : MENU_DENIED, 2);
- menu('admin/comment/comments/0', t('new/updated'), $access ? 'comment_admin' : MENU_DENIED, 1);
- menu('admin/comment/comments/1', t('approval queue'), $access ? 'comment_admin' : MENU_DENIED, 2);
- menu('admin/comment/help', t('help'), $access ? 'comment_help_page' : MENU_DENIED, 9);
- menu('admin/comment/edit', t('edit comment'), $access ? 'comment_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/comment/delete', t('delete comment'), $access ? 'comment_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- if (module_exist('search')) {
- menu('admin/comment/search', t('search'), $access ? 'comment_admin' : MENU_DENIED, 8);
- }
-
- // comment settings:
- $access = user_access('administer comments') && user_access('administer moderation');
- menu('admin/comment/moderation', t('moderation'), $access ? 'comment_admin' : MENU_DENIED, 3);
- menu('admin/comment/moderation/votes', t('votes'), $access ? 'comment_admin' : MENU_DENIED);
- menu('admin/comment/moderation/matrix', t('matrix'), $access ? 'comment_admin' : MENU_DENIED);
- menu('admin/comment/moderation/filters', t('thresholds'), $access ? 'comment_admin' : MENU_DENIED);
- menu('admin/comment/moderation/roles', t('initial scores'), $access ? 'comment_admin' : MENU_DENIED, 6);
-
- menu('comment', t('comments'), 'comment_page', 0, MENU_HIDE, MENU_LOCKED);
- }
-
return $links;
}
/**
- * Menu callback.
+ * Implementation of hook_menu().
+ */
+function comment_menu() {
+ $items = array();
+ $access = user_access('administer comments');
+
+ $items[] = array('path' => 'admin/comment', 'title' => t('comments'),
+ 'callback' => 'comment_admin', 'access' => $access);
+ $items[] = array('path' => 'admin/comment/edit', 'title' => t('edit comment'),
+ 'callback' => 'comment_admin', 'access' => $access,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/comment/delete', 'title' => t('delete comment'),
+ 'callback' => 'comment_admin', 'access' => $access,
+ 'type' => MENU_CALLBACK);
+
+ // Tabs:
+ $items[] = array('path' => 'admin/comment/configure', 'title' => t('configure'),
+ 'callback' => 'comment_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_TASK);
+ if (module_exist('search')) {
+ $items[] = array('path' => 'admin/comment/search', 'title' => t('search'),
+ 'callback' => 'comment_admin', 'access' => $access,
+ 'type' => MENU_LOCAL_TASK);
+ }
+
+ // Subtabs:
+ $items[] = array('path' => 'admin/comment/new', 'title' => t('new comments'),
+ 'callback' => 'comment_admin', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/comment/approval', 'title' => t('approval queue'),
+ 'callback' => 'comment_admin', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/comment/configure/settings', 'title' => t('settings'),
+ 'callback' => 'comment_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $access = user_access('administer comments') && user_access('administer moderation');
+ $items[] = array('path' => 'admin/comment/configure/matrix', 'title' => t('moderation matrix'),
+ 'callback' => 'comment_matrix_settings', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/comment/configure/thresholds', 'title' => t('moderation thresholds'),
+ 'callback' => 'comment_threshold_settings', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/comment/configure/votes', 'title' => t('moderation votes'),
+ 'callback' => 'comment_vote_settings', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK,
+ 'weight' => 6);
+ $items[] = array('path' => 'admin/comment/configure/roles', 'title' => t('moderation roles'),
+ 'callback' => 'comment_role_settings', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK,
+ 'weight' => 6);
+
+ $items[] = array('path' => 'comment', 'title' => t('comments'),
+ 'callback' => 'comment_page', 'access' => $access,
+ 'type' => MENU_CALLBACK);
+
+ return $items;
+}
+
+/**
+ * Menu callback; dispatches to the correct comment function.
*/
function comment_page() {
$op = $_POST['op'];
@@ -856,7 +891,7 @@ function comment_node_link($node) {
while ($comment = db_fetch_object($result)) {
$comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
- $rows[] = array(l($comment->subject, "node/view/$node->nid", NULL, NULL, "comment-$comment->cid"), format_name($comment), l(t('view comment'), "node/view/$node->nid", NULL, NULL, $comment->cid), l(t('edit comment'), "admin/comment/edit/$comment->cid"), l(t('delete comment'), "admin/comment/delete/$comment->cid"));
+ $rows[] = array(l($comment->subject, "node/$node->nid", NULL, NULL, "comment-$comment->cid"), format_name($comment), l(t('view comment'), "node/$node->nid", NULL, NULL, $comment->cid), l(t('edit comment'), "admin/comment/edit/$comment->cid"), l(t('delete comment'), "admin/comment/delete/$comment->cid"));
}
if ($rows) {
@@ -934,7 +969,7 @@ function comment_save($id, $edit) {
drupal_set_message(t('the comment has been saved.'));
}
-function comment_admin_overview($status = 0) {
+function comment_admin_overview() {
$header = array(
array('data' => t('subject'), 'field' => 'subject'),
@@ -944,6 +979,7 @@ function comment_admin_overview($status = 0) {
array('data' => t('operations'), 'colspan' => 2)
);
+ $status = (arg(2) == 'approval') ? 1 : 0;
$sql = 'SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.status = '. check_query($status);
$sql .= tablesort_sql($header);
$result = pager_query($sql, 50);
@@ -951,7 +987,7 @@ function comment_admin_overview($status = 0) {
while ($comment = db_fetch_object($result)) {
$comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
$rows[] = array(
- l($comment->subject, "node/view/$comment->nid/$comment->cid", array('title' => htmlspecialchars(truncate_utf8($comment->comment, 128))), NULL, "comment-$comment->cid") ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme('mark') : ''),
+ l($comment->subject, "node/$comment->nid", array('title' => htmlspecialchars(truncate_utf8($comment->comment, 128))), NULL, "comment-$comment->cid") ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme('mark') : ''),
format_name($comment),
($comment->status == 0 ? t('published') : t('not published')),
format_date($comment->timestamp, 'small'),
@@ -967,7 +1003,11 @@ function comment_admin_overview($status = 0) {
return theme('table', $header, $rows);
}
-function comment_mod_matrix($edit) {
+/**
+ * Menu callback; presents the moderation vote matrix.
+ */
+function comment_matrix_settings() {
+ $edit = $_POST['edit'];
$output .= '<h3>Moderation vote/value matrix</h3>';
@@ -1006,10 +1046,15 @@ function comment_mod_matrix($edit) {
$output .= theme('table', $header, $rows);
$output .= '<br />'. form_submit(t('Submit votes'));
- return form($output);
+ print theme('page', form($output));
}
-function comment_mod_roles($edit) {
+/**
+ * Menu callback; allows admin to set default scores for different roles.
+ */
+function comment_role_settings() {
+
+ $edit = $_POST['edit'];
$output .= '<h3>Initial comment scores</h3>';
@@ -1031,11 +1076,15 @@ function comment_mod_roles($edit) {
$output .= theme('table', $header, $rows);
$output .= '<br />'. form_submit(t('Save scores'));
- return form($output);
+ print theme('page', form($output));
}
-function comment_mod_votes($edit) {
+/**
+ * Menu callback; displays page for assigning names to vote values.
+ */
+function comment_vote_settings() {
$op = $_POST['op'];
+ $edit = $_POST['edit'];
$mid = arg(4);
@@ -1061,7 +1110,7 @@ function comment_mod_votes($edit) {
$result = db_query('SELECT mid, vote, weight FROM {moderation_votes} ORDER BY weight');
while ($vote = db_fetch_object($result)) {
- $rows[] = array($vote->vote, array('data' => $vote->weight, 'align' => 'center'), array('data' => l(t('edit'), "admin/comment/moderation/votes/$vote->mid"), 'align' => 'center'));
+ $rows[] = array($vote->vote, array('data' => $vote->weight, 'align' => 'center'), array('data' => l(t('edit'), "admin/settings/comment/votes/$vote->mid"), 'align' => 'center'));
}
$output .= theme('table', $header, $rows);
@@ -1080,13 +1129,15 @@ function comment_mod_votes($edit) {
$form .= form_submit(t('Add new vote'));
}
- $output .= form($form);
-
- return $output;
+ print theme('page', form($form));
}
-function comment_mod_filters($edit) {
+/**
+ * Menu callback; displays settings for thresholds at which comments are displayed.
+ */
+function comment_threshold_settings() {
$op = $_POST['op'];
+ $edit = $_POST['edit'];
$fid = arg(4);
@@ -1112,7 +1163,7 @@ function comment_mod_filters($edit) {
$result = db_query('SELECT fid, filter, minimum FROM {moderation_filters} ORDER BY minimum');
while ($filter = db_fetch_object($result)) {
- $rows[] = array($filter->filter, array('data' => $filter->minimum, 'align' => 'center'), array('data' => l(t('edit'), "admin/comment/moderation/filters/$filter->fid"), 'align' => 'center'));
+ $rows[] = array($filter->filter, array('data' => $filter->minimum, 'align' => 'center'), array('data' => l(t('edit'), "admin/settings/comment/thresholds/$filter->fid"), 'align' => 'center'));
}
$output .= theme('table', $header, $rows);
@@ -1131,12 +1182,9 @@ function comment_mod_filters($edit) {
$form .= form_submit(t('Add new threshold'));
}
- $output .= form($form);
-
- return $output;
+ print theme('page', form($form));
}
-
function comment_admin() {
$op = $_POST['op'];
$edit = $_POST['edit'];
@@ -1145,10 +1193,6 @@ function comment_admin() {
$op = arg(2);
}
- if ($op == 'moderation') {
- $op = arg(3);
- }
-
switch ($op) {
case 'edit':
$output = comment_admin_edit(arg(3));
@@ -1156,34 +1200,6 @@ function comment_admin() {
case 'search':
$output = search_type('comment', url('admin/comment/search'), $_POST['keys']);
break;
- case 'votes':
- case t('Add new vote'):
- case t('Delete vote'):
- case t('Save vote'):
- if (user_access('administer moderation')) {
- $output = comment_mod_votes($edit);
- }
- break;
- case 'roles':
- case t('Save scores'):
- if (user_access('administer moderation')) {
- $output = comment_mod_roles($edit);
- }
- break;
- case 'matrix':
- case t('Submit votes'):
- if (user_access('administer moderation')) {
- $output = comment_mod_matrix($edit);
- }
- break;
- case 'filters':
- case t('Add new threshold'):
- case t('Delete threshold'):
- case t('Save threshold'):
- if (user_access('administer moderation')) {
- $output = comment_mod_filters($edit);
- }
- break;
case 'delete':
$output = comment_delete(arg(3), 0);
break;
@@ -1192,15 +1208,10 @@ function comment_admin() {
break;
case t('Submit'):
$output = comment_save(check_query(arg(3)), $edit);
- $output .= comment_admin_overview(0);
+ $output .= comment_admin_overview();
break;
default:
- if (arg(3) == 1) {
- $output = comment_admin_overview(1);
- }
- else {
- $output = comment_admin_overview(0);
- }
+ $output = comment_admin_overview();
}
print theme('page', $output);
}
@@ -1649,4 +1660,4 @@ function _comment_per_page() {
return drupal_map_assoc(array(10, 30, 50, 70, 90));
}
-?>
+?> \ No newline at end of file
diff --git a/modules/drupal.module b/modules/drupal.module
index 9c05beaca..cbc0f40d1 100644
--- a/modules/drupal.module
+++ b/modules/drupal.module
@@ -12,11 +12,11 @@ function drupal_help($section) {
<p>Currently, the main application of this feature is the <a href=\"%drupal-sites\">Drupal sites</a> page. By default, fresh Drupal installations can use <a href=\"%Drupal\">drupal.org</a> as their <em>directory server</em> and report their existence. This reporting occurs via scheduled <a href=\"%xml-rpc\">XML-RPC</a> pings.</p>
<p>Drupal administrators should simply enable this feature to get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Just set your site's name, e-mail address, slogan and mission statement on the <a href=\"%site-admin\">site administration</a> page. Then make sure that the field called <em>Drupal XML-RPC server</em> on the <a href=\"%drupal-settings\">administer &raquo; configuration &raquo; modules &raquo; drupal</a> page is set to %drupal-xml-rpc, and enable this feature using the dropdown directly below.</p>
<p>The listing of your site will occur shortly after your site's next <a href=\"%cron-run\">cron run</a>. Note that cron.php should be called using the domain name which you want to have listed at <a href=\"%Drupal\">drupal.org</a>. For example, don't kick off cron by requesting http://127.0.0.1/cron.php. Instead, use a publicly accessible domain name such as http://www.example.com/cron.php.</p>
-<p>Also note that your installation need not use drupal.org as its directory server. For example, this feature is perfectly capable of aggregating pings from all of your departmental drupal installations sites within an enterprise.</p>", array('%drupal-sites' => 'http://www.drupal.org/sites', '%Drupal' => 'http://www.drupal.org', '%drupal-xml-rpc' => 'http://www.drupal.org/xmlrpc.php', '%xml-rpc' => 'http://www.xmlrpc.com/', '%site-admin' => url('admin/system'), '%drupal-settings' => url('admin/system/modules/drupal'), '%cron' => url('admin/system/help#cron')));
- case 'admin/system/modules#description':
+<p>Also note that your installation need not use drupal.org as its directory server. For example, this feature is perfectly capable of aggregating pings from all of your departmental drupal installations sites within an enterprise.</p>", array('%drupal-sites' => 'http://www.drupal.org/sites', '%Drupal' => 'http://www.drupal.org', '%drupal-xml-rpc' => 'http://www.drupal.org/xmlrpc.php', '%xml-rpc' => 'http://www.xmlrpc.com/', '%site-admin' => url('admin'), '%drupal-settings' => url('admin/settings/drupal'), '%cron' => url('admin/help#cron')));
+ case 'admin/modules#description':
return t('Lets users log in using a Drupal ID and can notify a central server about your site.');
- case 'admin/system/modules/drupal':
- return t("Using this your Drupal site can \"call home\" and add itself to the Drupal directory. If you want it to add itself to a different directory server you can change the <a href=\"%xml-rpc-setting\">Drupal XML-RPC server</a> setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the <a href=\"%site-admin\">site configuration</a> page and set the site name, the e-mail address, the slogan, and the mission statement.", array('%xml-rpc-setting' => url('admin/system/modules/drupal'), '%site-admin' => url('admin/system')));
+ case 'admin/settings/drupal':
+ return t("Using this your Drupal site can \"call home\" and add itself to the Drupal directory. If you want it to add itself to a different directory server you can change the <a href=\"%xml-rpc-setting\">Drupal XML-RPC server</a> setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the <a href=\"%site-admin\">site configuration</a> page and set the site name, the e-mail address, the slogan, and the mission statement.", array('%xml-rpc-setting' => url('admin/settings/drupal'), '%site-admin' => url('admin')));
case 'user/help#drupal':
return t("<p><a href=\"%Drupal\">Drupal</a> is the name of the software which powers %this-site. There are Drupal web sites all over the world, and many of them share their registration databases so that users may freely login to any Drupal site using a single <strong>Drupal ID</strong>.</p>
<p>So please feel free to login to your account here at %this-site with a username from another Drupal site. The format of a Drupal ID is similar to an email address: <strong>username</strong>@<em>server</em>. An example of a valid Drupal ID is <strong>mwlily</strong>@<em>www.drupal.org</em>.</p>", array('%Drupal' => 'http://www.drupal.org', '%this-site' => '<em>'. variable_get('site_name', 'this web site') .'</em>'));
@@ -29,13 +29,13 @@ function drupal_help($section) {
function drupal_settings() {
// Check if all required fields are present for the Drupal directory
if ((variable_get('site_name', 'drupal') == 'drupal') || (variable_get('site_name', 'drupal') == ''))
- $error['drupal_directory'] = theme('error', t("You must set your site's name at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
+ $error['drupal_directory'] = theme('error', t("You must set your site's name at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin'))));
else if (variable_get('site_mail', ini_get('sendmail_from')) == '')
- $error['drupal_directory'] = theme('error', t("You must set your site's e-mail address at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
+ $error['drupal_directory'] = theme('error', t("You must set your site's e-mail address at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin'))));
else if (variable_get('site_slogan', '') == '')
- $error['drupal_directory'] = theme('error', t("You must set your site's slogan at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
+ $error['drupal_directory'] = theme('error', t("You must set your site's slogan at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin'))));
else if (variable_get('site_mission', '') == '')
- $error['drupal_directory'] = theme('error', t("You must set your site's mission at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
+ $error['drupal_directory'] = theme('error', t("You must set your site's mission at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin'))));
$output = form_textfield(t('Drupal XML-RPC server'), 'drupal_server', variable_get('drupal_server', 'http://www.drupal.org/xmlrpc.php'), 55, 128, t('The URL of your root Drupal XML-RPC server.'));
$output .= form_radios(t('Drupal directory'), 'drupal_directory', variable_get('drupal_directory', 0), array(t('Disabled'), t('Enabled')), t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array('%drupal-xml-rpc' => 'http://www.drupal.org/xmlrpc.php')) . $error['drupal_directory']);
@@ -178,12 +178,14 @@ function drupal_auth($username, $password, $server) {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function drupal_link($type) {
- if ($type == 'system') {
- menu('drupal', t('Drupal'), 'drupal_page_help', 0, MENU_HIDE);
- }
+function drupal_menu() {
+ $items = array();
+ $items[] = array('path' => 'drupal', 'title' => t('Drupal'),
+ 'callback' => 'drupal_page_help', 'access' => TRUE,
+ 'type' => MENU_SUGGESTED_ITEM);
+ return $items;
}
/**
diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module
index 9c05beaca..cbc0f40d1 100644
--- a/modules/drupal/drupal.module
+++ b/modules/drupal/drupal.module
@@ -12,11 +12,11 @@ function drupal_help($section) {
<p>Currently, the main application of this feature is the <a href=\"%drupal-sites\">Drupal sites</a> page. By default, fresh Drupal installations can use <a href=\"%Drupal\">drupal.org</a> as their <em>directory server</em> and report their existence. This reporting occurs via scheduled <a href=\"%xml-rpc\">XML-RPC</a> pings.</p>
<p>Drupal administrators should simply enable this feature to get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Just set your site's name, e-mail address, slogan and mission statement on the <a href=\"%site-admin\">site administration</a> page. Then make sure that the field called <em>Drupal XML-RPC server</em> on the <a href=\"%drupal-settings\">administer &raquo; configuration &raquo; modules &raquo; drupal</a> page is set to %drupal-xml-rpc, and enable this feature using the dropdown directly below.</p>
<p>The listing of your site will occur shortly after your site's next <a href=\"%cron-run\">cron run</a>. Note that cron.php should be called using the domain name which you want to have listed at <a href=\"%Drupal\">drupal.org</a>. For example, don't kick off cron by requesting http://127.0.0.1/cron.php. Instead, use a publicly accessible domain name such as http://www.example.com/cron.php.</p>
-<p>Also note that your installation need not use drupal.org as its directory server. For example, this feature is perfectly capable of aggregating pings from all of your departmental drupal installations sites within an enterprise.</p>", array('%drupal-sites' => 'http://www.drupal.org/sites', '%Drupal' => 'http://www.drupal.org', '%drupal-xml-rpc' => 'http://www.drupal.org/xmlrpc.php', '%xml-rpc' => 'http://www.xmlrpc.com/', '%site-admin' => url('admin/system'), '%drupal-settings' => url('admin/system/modules/drupal'), '%cron' => url('admin/system/help#cron')));
- case 'admin/system/modules#description':
+<p>Also note that your installation need not use drupal.org as its directory server. For example, this feature is perfectly capable of aggregating pings from all of your departmental drupal installations sites within an enterprise.</p>", array('%drupal-sites' => 'http://www.drupal.org/sites', '%Drupal' => 'http://www.drupal.org', '%drupal-xml-rpc' => 'http://www.drupal.org/xmlrpc.php', '%xml-rpc' => 'http://www.xmlrpc.com/', '%site-admin' => url('admin'), '%drupal-settings' => url('admin/settings/drupal'), '%cron' => url('admin/help#cron')));
+ case 'admin/modules#description':
return t('Lets users log in using a Drupal ID and can notify a central server about your site.');
- case 'admin/system/modules/drupal':
- return t("Using this your Drupal site can \"call home\" and add itself to the Drupal directory. If you want it to add itself to a different directory server you can change the <a href=\"%xml-rpc-setting\">Drupal XML-RPC server</a> setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the <a href=\"%site-admin\">site configuration</a> page and set the site name, the e-mail address, the slogan, and the mission statement.", array('%xml-rpc-setting' => url('admin/system/modules/drupal'), '%site-admin' => url('admin/system')));
+ case 'admin/settings/drupal':
+ return t("Using this your Drupal site can \"call home\" and add itself to the Drupal directory. If you want it to add itself to a different directory server you can change the <a href=\"%xml-rpc-setting\">Drupal XML-RPC server</a> setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the <a href=\"%site-admin\">site configuration</a> page and set the site name, the e-mail address, the slogan, and the mission statement.", array('%xml-rpc-setting' => url('admin/settings/drupal'), '%site-admin' => url('admin')));
case 'user/help#drupal':
return t("<p><a href=\"%Drupal\">Drupal</a> is the name of the software which powers %this-site. There are Drupal web sites all over the world, and many of them share their registration databases so that users may freely login to any Drupal site using a single <strong>Drupal ID</strong>.</p>
<p>So please feel free to login to your account here at %this-site with a username from another Drupal site. The format of a Drupal ID is similar to an email address: <strong>username</strong>@<em>server</em>. An example of a valid Drupal ID is <strong>mwlily</strong>@<em>www.drupal.org</em>.</p>", array('%Drupal' => 'http://www.drupal.org', '%this-site' => '<em>'. variable_get('site_name', 'this web site') .'</em>'));
@@ -29,13 +29,13 @@ function drupal_help($section) {
function drupal_settings() {
// Check if all required fields are present for the Drupal directory
if ((variable_get('site_name', 'drupal') == 'drupal') || (variable_get('site_name', 'drupal') == ''))
- $error['drupal_directory'] = theme('error', t("You must set your site's name at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
+ $error['drupal_directory'] = theme('error', t("You must set your site's name at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin'))));
else if (variable_get('site_mail', ini_get('sendmail_from')) == '')
- $error['drupal_directory'] = theme('error', t("You must set your site's e-mail address at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
+ $error['drupal_directory'] = theme('error', t("You must set your site's e-mail address at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin'))));
else if (variable_get('site_slogan', '') == '')
- $error['drupal_directory'] = theme('error', t("You must set your site's slogan at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
+ $error['drupal_directory'] = theme('error', t("You must set your site's slogan at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin'))));
else if (variable_get('site_mission', '') == '')
- $error['drupal_directory'] = theme('error', t("You must set your site's mission at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin/system'))));
+ $error['drupal_directory'] = theme('error', t("You must set your site's mission at the <a href=\"%url\">site configuration</a>.", array('%url' => url('admin'))));
$output = form_textfield(t('Drupal XML-RPC server'), 'drupal_server', variable_get('drupal_server', 'http://www.drupal.org/xmlrpc.php'), 55, 128, t('The URL of your root Drupal XML-RPC server.'));
$output .= form_radios(t('Drupal directory'), 'drupal_directory', variable_get('drupal_directory', 0), array(t('Disabled'), t('Enabled')), t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array('%drupal-xml-rpc' => 'http://www.drupal.org/xmlrpc.php')) . $error['drupal_directory']);
@@ -178,12 +178,14 @@ function drupal_auth($username, $password, $server) {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function drupal_link($type) {
- if ($type == 'system') {
- menu('drupal', t('Drupal'), 'drupal_page_help', 0, MENU_HIDE);
- }
+function drupal_menu() {
+ $items = array();
+ $items[] = array('path' => 'drupal', 'title' => t('Drupal'),
+ 'callback' => 'drupal_page_help', 'access' => TRUE,
+ 'type' => MENU_SUGGESTED_ITEM);
+ return $items;
}
/**
diff --git a/modules/filter.module b/modules/filter.module
index f83f2eb14..a4a59b5f2 100644
--- a/modules/filter.module
+++ b/modules/filter.module
@@ -13,13 +13,13 @@ define('FILTER_STYLE_STRIP', 1);
*/
function filter_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Framework for handling filtering of content.');
- case 'admin/system/filters':
+ case 'admin/filters':
return t("
<p>Filters fit between the raw text in a node and the HTML output. They allow you to replace text selectively. Uses include automatic conversion of emoticons into graphics and filtering HTML content from users' submissions.</p>
-<p>If you notice some filters are causing conflicts in the output, you can <a href=\"%url\">rearrange them</a>.</p>", array('%url' => url('admin/system/filters/order')));
- case 'admin/system/filters/order':
+<p>If you notice some filters are causing conflicts in the output, you can <a href=\"%url\">rearrange them</a>.</p>", array('%url' => url('admin/filters/order')));
+ case 'admin/filters/order':
return t("
<p>Because of the flexible filtering system, you might encounter a situation where one filter prevents another from doing its job. For example: a word in an URL gets converted into a glossary term, before the URL can be converted in a clickable link. When this happens, you will need to rearrange the order in which filters get executed.</p>
<p>Filters are executed from top-to-bottom. You can use the weight column to rearrange them: heavier filters 'sink' to the bottom. Standard HTML filtering is always run first.</p>");
@@ -45,14 +45,21 @@ function filter_help($section) {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function filter_link($type) {
- if ($type == 'system') {
- menu('admin/system/filters', t('filters'), user_access('administer site configuration') ? 'filter_admin_settings' : MENU_DENIED, 5);
- menu('admin/system/filters/order', t('ordering'), user_access('administer site configuration') ? 'filter_admin_order' : MENU_DENIED, 5);
- menu('filter/tips', t('compose tips'), 'filter_tips_long', 0, MENU_HIDE);
- }
+function filter_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/filters', 'title' => t('filters'),
+ 'callback' => 'filter_admin_settings',
+ 'access' => user_access('administer site configuration'));
+ $items[] = array('path' => 'admin/filters/order', 'title' => t('order filters'),
+ 'callback' => 'filter_admin_order',
+ 'access' => user_access('administer site configuration'),
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'filter/tips', 'title' => t('compose tips'),
+ 'callback' => 'filter_tips_long', 'access' => TRUE,
+ 'type' => MENU_SUGGESTED_ITEM);
+ return $items;
}
/**
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index f83f2eb14..a4a59b5f2 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -13,13 +13,13 @@ define('FILTER_STYLE_STRIP', 1);
*/
function filter_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Framework for handling filtering of content.');
- case 'admin/system/filters':
+ case 'admin/filters':
return t("
<p>Filters fit between the raw text in a node and the HTML output. They allow you to replace text selectively. Uses include automatic conversion of emoticons into graphics and filtering HTML content from users' submissions.</p>
-<p>If you notice some filters are causing conflicts in the output, you can <a href=\"%url\">rearrange them</a>.</p>", array('%url' => url('admin/system/filters/order')));
- case 'admin/system/filters/order':
+<p>If you notice some filters are causing conflicts in the output, you can <a href=\"%url\">rearrange them</a>.</p>", array('%url' => url('admin/filters/order')));
+ case 'admin/filters/order':
return t("
<p>Because of the flexible filtering system, you might encounter a situation where one filter prevents another from doing its job. For example: a word in an URL gets converted into a glossary term, before the URL can be converted in a clickable link. When this happens, you will need to rearrange the order in which filters get executed.</p>
<p>Filters are executed from top-to-bottom. You can use the weight column to rearrange them: heavier filters 'sink' to the bottom. Standard HTML filtering is always run first.</p>");
@@ -45,14 +45,21 @@ function filter_help($section) {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function filter_link($type) {
- if ($type == 'system') {
- menu('admin/system/filters', t('filters'), user_access('administer site configuration') ? 'filter_admin_settings' : MENU_DENIED, 5);
- menu('admin/system/filters/order', t('ordering'), user_access('administer site configuration') ? 'filter_admin_order' : MENU_DENIED, 5);
- menu('filter/tips', t('compose tips'), 'filter_tips_long', 0, MENU_HIDE);
- }
+function filter_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/filters', 'title' => t('filters'),
+ 'callback' => 'filter_admin_settings',
+ 'access' => user_access('administer site configuration'));
+ $items[] = array('path' => 'admin/filters/order', 'title' => t('order filters'),
+ 'callback' => 'filter_admin_order',
+ 'access' => user_access('administer site configuration'),
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'filter/tips', 'title' => t('compose tips'),
+ 'callback' => 'filter_tips_long', 'access' => TRUE,
+ 'type' => MENU_SUGGESTED_ITEM);
+ return $items;
}
/**
diff --git a/modules/forum.module b/modules/forum.module
index 972b0ce3f..4c520aa95 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -13,10 +13,10 @@ function forum_help($section) {
<p>When you are happy with your vocabulary, go to <a href=\"%forums\">administer &raquo; configutation &raquo; modules &raquo; forum</a> and set <strong>Forum vocabulary</strong> to the one you have just created. There will now be fora active on the site. For users to access them they must have the \"access content\" <a href=\"%permission\">permission</a> and to create a topic they must have the \"create forum topics\" <a href=\"%permission\">permission</a>. These permissions can be set in the <a href=\"%permission\">permission</a> pages.</p>
<h4>Icons</h4>
<p>To disable icons, set the icon path as blank in <a href=\"%forums\">administer &raquo; configutation &raquo; modules &raquo; forum</a>.</p>
- <p>All files in the icon directory are assumed to be images. You may use images of whatever size you wish, but it is recommended to use 15x15 or 16x16.</p>", array("%taxonomy" => url('admin/taxonomy/add/vocabulary'), '%taxo-terms' => url('admin/taxonomy'), '%forums' => url('admin/system/modules/forum'), '%permission' => url('admin/user/permission')));
- case 'admin/system/modules#description':
+ <p>All files in the icon directory are assumed to be images. You may use images of whatever size you wish, but it is recommended to use 15x15 or 16x16.</p>", array("%taxonomy" => url('admin/taxonomy/add/vocabulary'), '%taxo-terms' => url('admin/taxonomy'), '%forums' => url('admin/settings/forum'), '%permission' => url('admin/user/permission')));
+ case 'admin/modules#description':
return t('Enable threaded discussions about general topics.');
- case 'admin/system/modules/forum':
+ case 'admin/settings/forum':
return t("Forums are threaded discussions based on the taxonomy system. For the forums to work, the taxonomy module has to be installed and enabled. When activated, a taxonomy vocabulary (eg. \"forums\") needs to be <a href=\"%created\">created</a> and bound to the node type \"forum topic\".", array('%created' => url('admin/taxonomy/add/vocabulary')));
case 'node/add/forum':
return variable_get('forum_help', '');
@@ -78,7 +78,7 @@ function forum_settings() {
$group .= form_radios(t('Default order'), 'forum_order', variable_get('forum_order', '1'), $forder, t('The default display order for topics.'));
$output .= form_group(t('Forum viewing options'), $group);
- $group = form_textfield(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), 5, 5, t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/system/block'))));
+ $group = form_textfield(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), 5, 5, t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/block'))));
$output .= form_group(t('"Forum topic" block settings'), $group);
}
}
@@ -149,11 +149,6 @@ function forum_link($type, $node = 0, $main = 0) {
$links[] = l(t('forums'), 'forum');
}
- if ($type == 'system') {
- menu('node/add/forum', t('forum topic'), user_access('create forum topics') ? MENU_FALLTHROUGH : MENU_DENIED);
- menu('forum', t('forums'), user_access('access content') ? 'forum_page' : MENU_DENIED, 0, MENU_HIDE);
- }
-
if (!$main && $type == 'node' && $node->type == 'forum') {
// get previous and next topic
@@ -175,11 +170,11 @@ function forum_link($type, $node = 0, $main = 0) {
}
if ($prev) {
- $links[] = l(t('previous forum topic'), "node/view/$prev->nid", array('title' => $prev->title));
+ $links[] = l(t('previous forum topic'), "node/$prev->nid", array('title' => $prev->title));
}
if ($next) {
- $links[] = l(t('next forum topic'), "node/view/$next->nid", array('title' => $next->title));
+ $links[] = l(t('next forum topic'), "node/$next->nid", array('title' => $next->title));
}
}
@@ -187,31 +182,49 @@ function forum_link($type, $node = 0, $main = 0) {
}
/**
+ * Implementation of hook_menu().
+ */
+function forum_menu() {
+ $items = array();
+
+ $items[] = array('path' => 'node/add/forum', 'title' => t('forum topic'),
+ 'access' => user_access('create forum topics'));
+ $items[] = array('path' => 'forum', 'title' => t('forums'),
+ 'callback' => 'forum_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+
+ return $items;
+}
+
+/**
* Implementation of hook_content().
*/
-function forum_content($node, $main = 0) {
- return node_prepare($node, $main);
+function forum_content($node, $teaser = FALSE) {
+ return node_prepare($node, $teaser);
}
/**
* Implementation of hook_view().
*/
-function forum_view($node, $main = 0, $page = 0) {
+function forum_view($node, $teaser = FALSE, $page = FALSE) {
if ($page) {
$vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
// Breadcrumb navigation
- $breadcrumb = array(l(t('Home'), NULL), l($vocabulary->name, 'forum'));
+ $breadcrumb = array();
+ $breadcrumb[] = array('path' => 'forum', 'title' => $vocabulary->name);
if ($parents = taxonomy_get_parents_all($node->tid)) {
$parents = array_reverse($parents);
foreach ($parents as $p) {
- $breadcrumb[] = l($p->name, "forum/$p->tid");
+ $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name);
}
}
- drupal_set_breadcrumb($breadcrumb);
+ $breadcrumb[] = array('path' => 'node/'. $node->nid);
+ menu_set_location($breadcrumb);
}
- return theme('node', forum_content($node, $main), $main, $page);
+ return theme('node', forum_content($node, $teaser), $teaser, $page);
}
/**
@@ -453,7 +466,7 @@ function forum_page($tid = 0, $display = 'all') {
if (module_exist('taxonomy')) {
if ($display == 'new') {
if ($nid = _forum_new($tid)) {
- drupal_goto("node/view/$nid");
+ drupal_goto("node/$nid");
}
}
else {
@@ -477,7 +490,7 @@ function forum_page($tid = 0, $display = 'all') {
}
}
else {
- print theme('page', forum_help('admin/system/modules/forum'), t('Warning'));
+ print theme('page', forum_help('admin/settings/forum'), t('Warning'));
}
}
@@ -506,12 +519,10 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
$title = $vocabulary->name;
- /*
- ** Breadcrumb navigation:
- */
- $breadcrumb[] = l(t('Home'), '');
+ // Breadcrumb navigation:
+ $breadcrumb = array();
if ($tid) {
- $breadcrumb[] = l($title, 'forum');
+ $breadcrumb[] = array('path' => 'forum', 'title' => $title);
}
if ($parents) {
@@ -521,10 +532,12 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$title = $p->name;
}
else {
- $breadcrumb[] = l($p->name, "forum/$p->tid");
+ $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name);
}
}
}
+ $breadcrumb[] = array('path' => $_GET['q']);
+ menu_set_location($breadcrumb);
if (count($forums) || count($parents)) {
$output = '<div id="forum">';
@@ -561,7 +574,7 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$output = '';
}
- print theme('page', $output, $title, $breadcrumb);
+ print theme('page', $output, $title);
}
/**
@@ -654,8 +667,8 @@ function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset
else {
$rows[] = array(
array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), 'class' => 'icon'),
- array('data' => l($topic->title, "node/view/$topic->nid"), 'class' => 'topic'),
- array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(t('%a new', array('%a' => $topic->new_replies)), "node/view/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
+ array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'),
+ array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(t('%a new', array('%a' => $topic->new_replies)), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
array('data' => _forum_format($topic), 'class' => 'created'),
array('data' => _forum_format($topic->last_reply), 'class' => 'last-reply')
);
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 972b0ce3f..4c520aa95 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -13,10 +13,10 @@ function forum_help($section) {
<p>When you are happy with your vocabulary, go to <a href=\"%forums\">administer &raquo; configutation &raquo; modules &raquo; forum</a> and set <strong>Forum vocabulary</strong> to the one you have just created. There will now be fora active on the site. For users to access them they must have the \"access content\" <a href=\"%permission\">permission</a> and to create a topic they must have the \"create forum topics\" <a href=\"%permission\">permission</a>. These permissions can be set in the <a href=\"%permission\">permission</a> pages.</p>
<h4>Icons</h4>
<p>To disable icons, set the icon path as blank in <a href=\"%forums\">administer &raquo; configutation &raquo; modules &raquo; forum</a>.</p>
- <p>All files in the icon directory are assumed to be images. You may use images of whatever size you wish, but it is recommended to use 15x15 or 16x16.</p>", array("%taxonomy" => url('admin/taxonomy/add/vocabulary'), '%taxo-terms' => url('admin/taxonomy'), '%forums' => url('admin/system/modules/forum'), '%permission' => url('admin/user/permission')));
- case 'admin/system/modules#description':
+ <p>All files in the icon directory are assumed to be images. You may use images of whatever size you wish, but it is recommended to use 15x15 or 16x16.</p>", array("%taxonomy" => url('admin/taxonomy/add/vocabulary'), '%taxo-terms' => url('admin/taxonomy'), '%forums' => url('admin/settings/forum'), '%permission' => url('admin/user/permission')));
+ case 'admin/modules#description':
return t('Enable threaded discussions about general topics.');
- case 'admin/system/modules/forum':
+ case 'admin/settings/forum':
return t("Forums are threaded discussions based on the taxonomy system. For the forums to work, the taxonomy module has to be installed and enabled. When activated, a taxonomy vocabulary (eg. \"forums\") needs to be <a href=\"%created\">created</a> and bound to the node type \"forum topic\".", array('%created' => url('admin/taxonomy/add/vocabulary')));
case 'node/add/forum':
return variable_get('forum_help', '');
@@ -78,7 +78,7 @@ function forum_settings() {
$group .= form_radios(t('Default order'), 'forum_order', variable_get('forum_order', '1'), $forder, t('The default display order for topics.'));
$output .= form_group(t('Forum viewing options'), $group);
- $group = form_textfield(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), 5, 5, t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/system/block'))));
+ $group = form_textfield(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), 5, 5, t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/block'))));
$output .= form_group(t('"Forum topic" block settings'), $group);
}
}
@@ -149,11 +149,6 @@ function forum_link($type, $node = 0, $main = 0) {
$links[] = l(t('forums'), 'forum');
}
- if ($type == 'system') {
- menu('node/add/forum', t('forum topic'), user_access('create forum topics') ? MENU_FALLTHROUGH : MENU_DENIED);
- menu('forum', t('forums'), user_access('access content') ? 'forum_page' : MENU_DENIED, 0, MENU_HIDE);
- }
-
if (!$main && $type == 'node' && $node->type == 'forum') {
// get previous and next topic
@@ -175,11 +170,11 @@ function forum_link($type, $node = 0, $main = 0) {
}
if ($prev) {
- $links[] = l(t('previous forum topic'), "node/view/$prev->nid", array('title' => $prev->title));
+ $links[] = l(t('previous forum topic'), "node/$prev->nid", array('title' => $prev->title));
}
if ($next) {
- $links[] = l(t('next forum topic'), "node/view/$next->nid", array('title' => $next->title));
+ $links[] = l(t('next forum topic'), "node/$next->nid", array('title' => $next->title));
}
}
@@ -187,31 +182,49 @@ function forum_link($type, $node = 0, $main = 0) {
}
/**
+ * Implementation of hook_menu().
+ */
+function forum_menu() {
+ $items = array();
+
+ $items[] = array('path' => 'node/add/forum', 'title' => t('forum topic'),
+ 'access' => user_access('create forum topics'));
+ $items[] = array('path' => 'forum', 'title' => t('forums'),
+ 'callback' => 'forum_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+
+ return $items;
+}
+
+/**
* Implementation of hook_content().
*/
-function forum_content($node, $main = 0) {
- return node_prepare($node, $main);
+function forum_content($node, $teaser = FALSE) {
+ return node_prepare($node, $teaser);
}
/**
* Implementation of hook_view().
*/
-function forum_view($node, $main = 0, $page = 0) {
+function forum_view($node, $teaser = FALSE, $page = FALSE) {
if ($page) {
$vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
// Breadcrumb navigation
- $breadcrumb = array(l(t('Home'), NULL), l($vocabulary->name, 'forum'));
+ $breadcrumb = array();
+ $breadcrumb[] = array('path' => 'forum', 'title' => $vocabulary->name);
if ($parents = taxonomy_get_parents_all($node->tid)) {
$parents = array_reverse($parents);
foreach ($parents as $p) {
- $breadcrumb[] = l($p->name, "forum/$p->tid");
+ $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name);
}
}
- drupal_set_breadcrumb($breadcrumb);
+ $breadcrumb[] = array('path' => 'node/'. $node->nid);
+ menu_set_location($breadcrumb);
}
- return theme('node', forum_content($node, $main), $main, $page);
+ return theme('node', forum_content($node, $teaser), $teaser, $page);
}
/**
@@ -453,7 +466,7 @@ function forum_page($tid = 0, $display = 'all') {
if (module_exist('taxonomy')) {
if ($display == 'new') {
if ($nid = _forum_new($tid)) {
- drupal_goto("node/view/$nid");
+ drupal_goto("node/$nid");
}
}
else {
@@ -477,7 +490,7 @@ function forum_page($tid = 0, $display = 'all') {
}
}
else {
- print theme('page', forum_help('admin/system/modules/forum'), t('Warning'));
+ print theme('page', forum_help('admin/settings/forum'), t('Warning'));
}
}
@@ -506,12 +519,10 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
$title = $vocabulary->name;
- /*
- ** Breadcrumb navigation:
- */
- $breadcrumb[] = l(t('Home'), '');
+ // Breadcrumb navigation:
+ $breadcrumb = array();
if ($tid) {
- $breadcrumb[] = l($title, 'forum');
+ $breadcrumb[] = array('path' => 'forum', 'title' => $title);
}
if ($parents) {
@@ -521,10 +532,12 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$title = $p->name;
}
else {
- $breadcrumb[] = l($p->name, "forum/$p->tid");
+ $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name);
}
}
}
+ $breadcrumb[] = array('path' => $_GET['q']);
+ menu_set_location($breadcrumb);
if (count($forums) || count($parents)) {
$output = '<div id="forum">';
@@ -561,7 +574,7 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$output = '';
}
- print theme('page', $output, $title, $breadcrumb);
+ print theme('page', $output, $title);
}
/**
@@ -654,8 +667,8 @@ function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset
else {
$rows[] = array(
array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), 'class' => 'icon'),
- array('data' => l($topic->title, "node/view/$topic->nid"), 'class' => 'topic'),
- array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(t('%a new', array('%a' => $topic->new_replies)), "node/view/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
+ array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'),
+ array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(t('%a new', array('%a' => $topic->new_replies)), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
array('data' => _forum_format($topic), 'class' => 'created'),
array('data' => _forum_format($topic->last_reply), 'class' => 'last-reply')
);
diff --git a/modules/help.module b/modules/help.module
index a29a58feb..6cfdce90c 100644
--- a/modules/help.module
+++ b/modules/help.module
@@ -2,13 +2,18 @@
// $Id$
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function help_link($type) {
- if ($type == 'system') {
- menu('admin/help/glossary', t('glossary'), user_access('access administration pages') ? 'help_glossary' : MENU_DENIED, 8);
- menu('admin/help', t('help'), user_access('access administration pages') ? 'help_page' : MENU_DENIED, 9);
- }
+function help_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/help/glossary', 'title' => t('glossary'),
+ 'callback' => 'help_glossary',
+ 'access' => user_access('access administration pages'));
+ $items[] = array('path' => 'admin/help', 'title' => t('help'),
+ 'callback' => 'help_page',
+ 'access' => user_access('access administration pages'),
+ 'weight' => 9);
+ return $items;
}
/**
@@ -41,7 +46,7 @@ function help_glossary() {
*/
function help_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
$output = t('Manages displaying online help.');
break;
}
diff --git a/modules/help/help.module b/modules/help/help.module
index a29a58feb..6cfdce90c 100644
--- a/modules/help/help.module
+++ b/modules/help/help.module
@@ -2,13 +2,18 @@
// $Id$
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function help_link($type) {
- if ($type == 'system') {
- menu('admin/help/glossary', t('glossary'), user_access('access administration pages') ? 'help_glossary' : MENU_DENIED, 8);
- menu('admin/help', t('help'), user_access('access administration pages') ? 'help_page' : MENU_DENIED, 9);
- }
+function help_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/help/glossary', 'title' => t('glossary'),
+ 'callback' => 'help_glossary',
+ 'access' => user_access('access administration pages'));
+ $items[] = array('path' => 'admin/help', 'title' => t('help'),
+ 'callback' => 'help_page',
+ 'access' => user_access('access administration pages'),
+ 'weight' => 9);
+ return $items;
}
/**
@@ -41,7 +46,7 @@ function help_glossary() {
*/
function help_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
$output = t('Manages displaying online help.');
break;
}
diff --git a/modules/locale.module b/modules/locale.module
index 1835fd0b0..d5a3a0f13 100644
--- a/modules/locale.module
+++ b/modules/locale.module
@@ -1,8 +1,10 @@
<?php
// $Id$
-function locale_help($section = "admin/help#locale") {
-
+/**
+ * Implementation of hook_help().
+ */
+function locale_help($section) {
switch ($section) {
case 'admin/help#locale':
return t("
@@ -31,64 +33,81 @@ function locale_help($section = "admin/help#locale") {
mysql> ALTER TABLE {locales} ADD en TEXT DEFAULT '' NOT NULL;
mysql> ALTER TABLE {locales} ADD nl TEXT DEFAULT '' NOT NULL;
mysql> ALTER TABLE {locales} ADD fr TEXT DEFAULT '' NOT NULL;
- </pre>", array("%overview" => url("admin/locale")));
+ </pre>", array('%overview' => url('admin/locale')));
break;
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables the translation of the user interface to languages other than English.');
case 'admin/locale':
return t('The locale module handles translations into new languages. It also enables you to add jargon, slang or other special language as fits the web site. For each language you want to support, a line needs to be added to your configuration file.');
case 'admin/locale/search':
- return t("Search the localization database. ('*' can be used as a wildcard)");
+ return t('Search the localization database. ("*" can be used as a wildcard)');
}
}
+/**
+ * Menu callback; prints locale-specific help text from admin/help.
+ */
function locale_help_page() {
- print theme('page', locale_help());
+ print theme('page', locale_help('admin/help#locale'));
}
+/**
+ * Implementation of hook_perm().
+ */
function locale_perm() {
return array('administer locales');
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function locale_link($type) {
+function locale_menu() {
global $languages;
- if ($type == 'system') {
- $access = user_access('administer locales');
- menu('admin/locale', t('localization'), $access ? 'locale_admin' : MENU_DENIED, 5);
- menu('admin/locale/search', t('search string'), $access ? 'locale_admin' : MENU_DENIED, 8);
- menu('admin/locale/help', t('help'), $access ? 'locale_help_page' : MENU_DENIED, 9);
- menu('admin/locale/edit', t('edit string'), $access ? 'locale_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/locale/delete', t('delete string'), $access ? 'locale_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+ $items = array();
+ $access = user_access('administer locales');
- foreach ($languages as $key => $value) {
- menu("admin/locale/$key", "$value", $access ? 'locale_admin' : MENU_DENIED);
- menu("admin/locale/$key/translated", t('translated strings'), $access ? 'locale_admin' : MENU_DENIED);
- menu("admin/locale/$key/untranslated", t('untranslated strings'), $access ? 'locale_admin' : MENU_DENIED);
- }
+ $items[] = array('path' => 'admin/locale', 'title' => t('localization'),
+ 'callback' => 'locale_admin', 'access' => $access);
+ $items[] = array('path' => 'admin/locale/edit', 'title' => t('edit string'),
+ 'callback' => 'locale_admin', 'access' => $access,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/locale/delete', 'title' => t('delete string'),
+ 'callback' => 'locale_admin', 'access' => $access,
+ 'type' => MENU_CALLBACK);
+
+ foreach ($languages as $key => $value) {
+ $items[] = array('path' => "admin/locale/$key", 'title' => $value,
+ 'callback' => 'locale_admin', 'access' => $access);
+ $items[] = array('path' => "admin/locale/$key/translated", 'title' => t('translated strings'),
+ 'callback' => 'locale_admin', 'access' => $access);
+ $items[] = array('path' => "admin/locale/$key/untranslated", 'title' => t('untranslated strings'),
+ 'callback' => 'locale_admin', 'access' => $access);
}
+
+ return $items;
}
+/**
+ * Implementation of hook_user(). Allows each user to select an interface language.
+ */
function locale_user($type, &$edit, &$user) {
global $languages;
if ($type == 'form' && count($languages) > 1) {
- return array(t('Locale settings') => form_radios(t("Language"), 'language', $user->language, $languages, t("Selecting a different language will change the language of the site.")));
+ return array(t('Locale settings') => form_radios(t('Language'), 'language', $user->language, $languages, t('Selecting a different language will change the language of the site.')));
}
}
function locale_delete($lid) {
- db_query("DELETE FROM {locales} WHERE lid = %d", $lid);
+ db_query('DELETE FROM {locales} WHERE lid = %d', $lid);
locale_refresh_cache();
- drupal_set_message(t("deleted string"));
+ drupal_set_message(t('deleted string'));
}
function locale_save($lid) {
- $edit =& $_POST["edit"];
+ $edit =& $_POST['edit'];
foreach ($edit as $key => $value) {
db_query("UPDATE {locales} SET $key = '%s' WHERE lid = %d", $value, $lid);
}
@@ -96,7 +115,7 @@ function locale_save($lid) {
// delete form data so it will remember where it came from
$edit = '';
- drupal_set_message(t("saved string"));
+ drupal_set_message(t('saved string'));
}
function locale_refresh_cache() {
@@ -107,7 +126,7 @@ function locale_refresh_cache() {
** We only load short strings into the cache to improve both performance
** and memory usages.
*/
- $result = db_query("SELECT string, %s FROM {locales} WHERE LENGTH(string) < 75", $locale);
+ $result = db_query('SELECT string, %s FROM {locales} WHERE LENGTH(string) < 75', $locale);
while ($data = db_fetch_object($result)) {
if (empty($data->$locale)) {
$t[$data->string] = $data->string;
@@ -126,7 +145,7 @@ function locale_edit($lid) {
$result = db_query("SELECT * FROM {locales} WHERE lid = '$lid'");
if ($translation = db_fetch_object($result)) {
- $form .= form_item(t("Original text"), wordwrap(drupal_specialchars($translation->string, 0)));
+ $form .= form_item(t('Original text'), wordwrap(drupal_specialchars($translation->string, 0)));
foreach ($languages as $code=>$language) {
$form .= (strlen($translation->string) > 30) ? form_textarea($language, $code, $translation->$code, 50, 10) : form_textfield($language, $code, $translation->$code, 50, 128);
@@ -142,16 +161,16 @@ function locale_languages($translation) {
global $languages;
foreach ($languages as $key => $value) {
- $output .= ($translation->$key) ? "<a href=\"#\" title=\"". $translation->$key ."\">$key</a> " : "<strike>$key</strike> ";
+ $output .= ($translation->$key) ? '<a href="#" title="'. $translation->$key ."\">$key</a> " : "<strike>$key</strike> ";
}
return $output;
}
function locale_seek_query() {
- $fields = array("string", 'language', 'status');
- if (is_array($_REQUEST["edit"])) {
- foreach ($_REQUEST["edit"] as $key => $value) {
+ $fields = array('string', 'language', 'status');
+ if (is_array($_REQUEST['edit'])) {
+ foreach ($_REQUEST['edit'] as $key => $value) {
if (!empty($value) && in_array($key, $fields)) {
$query->$key = $value;
}
@@ -160,7 +179,7 @@ function locale_seek_query() {
else {
foreach ($_REQUEST as $key => $value) {
if (!empty($value) && in_array($key, $fields)) {
- $query->$key = strpos(",", $value) ? explode(",", $value) : $value;
+ $query->$key = strpos(',', $value) ? explode(',', $value) : $value;
}
}
}
@@ -169,27 +188,27 @@ function locale_seek_query() {
function locale_seek() {
global $id, $languages;
- $op = $_POST["op"];
+ $op = $_POST['op'];
$query = locale_seek_query();
if ($query) {
if ($query->status) {
switch ($query->language) {
- case "all":
+ case 'all':
foreach ($languages as $key=>$value) {
- $tmp[] = $key . (check_query($query->status) == 1 ? " !=" : " =") ." ''";
+ $tmp[] = $key . (check_query($query->status) == 1 ? ' !=' : ' =') ." ''";
}
- $sql[] = implode(" AND ", $tmp);
+ $sql[] = implode(' AND ', $tmp);
break;
- case "any":
+ case 'any':
foreach ($languages as $key=>$value) {
- $tmp[] = $key . (check_query($query->status) == 1 ? " !=" : " =") ." ''";
+ $tmp[] = $key . (check_query($query->status) == 1 ? ' !=' : ' =') ." ''";
}
- $sql[] = "(". implode(" OR ", $tmp) .")";
+ $sql[] = '('. implode(' OR ', $tmp) .')';
break;
default:
- $sql[] = check_query($query->language) . (check_query($query->status) == 1 ? " !=" : " =") ." ''";
+ $sql[] = check_query($query->language) . (check_query($query->status) == 1 ? ' !=' : ' =') ." ''";
}
}
@@ -205,28 +224,28 @@ function locale_seek() {
}
}
}
- $sql[] = "(". implode(" OR ", $string_query) .")";
+ $sql[] = '('. implode(' OR ', $string_query) .')';
}
- $result = pager_query("SELECT * FROM {locales} ". (count($sql) ? " WHERE ". implode(" AND ", $sql) : "") ." ORDER BY string", 50);
+ $result = pager_query('SELECT * FROM {locales} '. (count($sql) ? ' WHERE '. implode(' AND ', $sql) : '') .' ORDER BY string', 50);
- $header = array(t("string"), (($query->status != 2 && strlen($query->language) == 2) ? t("translated string") : t("languages")), array("data" => t("operations"), "colspan" => "2"));
+ $header = array(t('string'), (($query->status != 2 && strlen($query->language) == 2) ? t('translated string') : t('languages')), array('data' => t('operations'), 'colspan' => '2'));
while ($locale = db_fetch_object($result)) {
- $rows[] = array("$locale->string<br /><small><i>$locale->location</i></small>", array("data" => (($query->status != 2 && strlen($query->language) == 2) ? $locale->{$query->language} : locale_languages($locale)), "align" => "center"), array("data" => l(t("edit locale"), "admin/locale/edit/$locale->lid"), "nowrap" => "nowrap"), array("data" => l(t("delete locale"), "admin/locale/delete/$locale->lid"), "nowrap" => "nowrap"));
+ $rows[] = array("$locale->string<br /><small><i>$locale->location</i></small>", array('data' => (($query->status != 2 && strlen($query->language) == 2) ? $locale->{$query->language} : locale_languages($locale)), 'align' => 'center'), array('data' => l(t('edit locale'), "admin/locale/edit/$locale->lid"), 'nowrap' => 'nowrap'), array('data' => l(t('delete locale'), "admin/locale/delete/$locale->lid"), 'nowrap' => 'nowrap'));
}
$request = array();
if (count($query)) {
foreach ($query as $key => $value) {
- $request[$key] = (is_array($value)) ? implode(",", $value) : $value;
+ $request[$key] = (is_array($value)) ? implode(',', $value) : $value;
}
}
- if ($pager = theme("pager", NULL, 50, 0, $request)) {
- $rows[] = array(array("data" => "$pager", "colspan" => "5"));
+ if ($pager = theme('pager', NULL, 50, 0, $request)) {
+ $rows[] = array(array('data' => "$pager", 'colspan' => '5'));
}
- $output .= theme("table", $header, $rows);
+ $output .= theme('table', $header, $rows);
}
@@ -235,10 +254,10 @@ function locale_seek() {
function locale_seek_form() {
global $languages;
- $edit =& $_POST["edit"];
- $form .= form_textfield(t("Strings to search for"), "string", $edit["string"], 30, 30, t("Leave blank to show all strings."));
+ $edit =& $_POST['edit'];
+ $form .= form_textfield(t('Strings to search for'), 'string', $edit['string'], 30, 30, t('Leave blank to show all strings.'));
if (count($languages) > 1) {
- $form .= form_radios(t("Language"), 'language', ($edit['language'] ? $edit['language'] : "all"), array_merge(array("any" => t("Any language"), "all" => t("All languages")), $languages), t("In which language must the string be translated/untranslated (see status)?"));
+ $form .= form_radios(t('Language'), 'language', ($edit['language'] ? $edit['language'] : 'all'), array_merge(array('any' => t('Any language'), 'all' => t('All languages')), $languages), t('In which language must the string be translated/untranslated (see status)?'));
}
else {
foreach ($languages as $key => $value) {
@@ -254,8 +273,8 @@ function locale_seek_form() {
}
function locale_admin() {
- $op = $_POST["op"];
- $edit =& $_POST["edit"];
+ $op = $_POST['op'];
+ $edit =& $_POST['edit'];
if (empty($op)) {
$op = arg(2);
@@ -299,6 +318,13 @@ function locale_admin() {
print theme('page', $output);
}
+/**
+ * Does the work of localizing a string of text.
+ *
+ * This function is called by the universally-used t() function each time
+ * an internationalized string is encountered. The string is then localized
+ * by this function if the locale module is enabled.
+ */
function locale($string) {
global $locale;
static $locale_t;
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 1835fd0b0..d5a3a0f13 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -1,8 +1,10 @@
<?php
// $Id$
-function locale_help($section = "admin/help#locale") {
-
+/**
+ * Implementation of hook_help().
+ */
+function locale_help($section) {
switch ($section) {
case 'admin/help#locale':
return t("
@@ -31,64 +33,81 @@ function locale_help($section = "admin/help#locale") {
mysql> ALTER TABLE {locales} ADD en TEXT DEFAULT '' NOT NULL;
mysql> ALTER TABLE {locales} ADD nl TEXT DEFAULT '' NOT NULL;
mysql> ALTER TABLE {locales} ADD fr TEXT DEFAULT '' NOT NULL;
- </pre>", array("%overview" => url("admin/locale")));
+ </pre>", array('%overview' => url('admin/locale')));
break;
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables the translation of the user interface to languages other than English.');
case 'admin/locale':
return t('The locale module handles translations into new languages. It also enables you to add jargon, slang or other special language as fits the web site. For each language you want to support, a line needs to be added to your configuration file.');
case 'admin/locale/search':
- return t("Search the localization database. ('*' can be used as a wildcard)");
+ return t('Search the localization database. ("*" can be used as a wildcard)');
}
}
+/**
+ * Menu callback; prints locale-specific help text from admin/help.
+ */
function locale_help_page() {
- print theme('page', locale_help());
+ print theme('page', locale_help('admin/help#locale'));
}
+/**
+ * Implementation of hook_perm().
+ */
function locale_perm() {
return array('administer locales');
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function locale_link($type) {
+function locale_menu() {
global $languages;
- if ($type == 'system') {
- $access = user_access('administer locales');
- menu('admin/locale', t('localization'), $access ? 'locale_admin' : MENU_DENIED, 5);
- menu('admin/locale/search', t('search string'), $access ? 'locale_admin' : MENU_DENIED, 8);
- menu('admin/locale/help', t('help'), $access ? 'locale_help_page' : MENU_DENIED, 9);
- menu('admin/locale/edit', t('edit string'), $access ? 'locale_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/locale/delete', t('delete string'), $access ? 'locale_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+ $items = array();
+ $access = user_access('administer locales');
- foreach ($languages as $key => $value) {
- menu("admin/locale/$key", "$value", $access ? 'locale_admin' : MENU_DENIED);
- menu("admin/locale/$key/translated", t('translated strings'), $access ? 'locale_admin' : MENU_DENIED);
- menu("admin/locale/$key/untranslated", t('untranslated strings'), $access ? 'locale_admin' : MENU_DENIED);
- }
+ $items[] = array('path' => 'admin/locale', 'title' => t('localization'),
+ 'callback' => 'locale_admin', 'access' => $access);
+ $items[] = array('path' => 'admin/locale/edit', 'title' => t('edit string'),
+ 'callback' => 'locale_admin', 'access' => $access,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/locale/delete', 'title' => t('delete string'),
+ 'callback' => 'locale_admin', 'access' => $access,
+ 'type' => MENU_CALLBACK);
+
+ foreach ($languages as $key => $value) {
+ $items[] = array('path' => "admin/locale/$key", 'title' => $value,
+ 'callback' => 'locale_admin', 'access' => $access);
+ $items[] = array('path' => "admin/locale/$key/translated", 'title' => t('translated strings'),
+ 'callback' => 'locale_admin', 'access' => $access);
+ $items[] = array('path' => "admin/locale/$key/untranslated", 'title' => t('untranslated strings'),
+ 'callback' => 'locale_admin', 'access' => $access);
}
+
+ return $items;
}
+/**
+ * Implementation of hook_user(). Allows each user to select an interface language.
+ */
function locale_user($type, &$edit, &$user) {
global $languages;
if ($type == 'form' && count($languages) > 1) {
- return array(t('Locale settings') => form_radios(t("Language"), 'language', $user->language, $languages, t("Selecting a different language will change the language of the site.")));
+ return array(t('Locale settings') => form_radios(t('Language'), 'language', $user->language, $languages, t('Selecting a different language will change the language of the site.')));
}
}
function locale_delete($lid) {
- db_query("DELETE FROM {locales} WHERE lid = %d", $lid);
+ db_query('DELETE FROM {locales} WHERE lid = %d', $lid);
locale_refresh_cache();
- drupal_set_message(t("deleted string"));
+ drupal_set_message(t('deleted string'));
}
function locale_save($lid) {
- $edit =& $_POST["edit"];
+ $edit =& $_POST['edit'];
foreach ($edit as $key => $value) {
db_query("UPDATE {locales} SET $key = '%s' WHERE lid = %d", $value, $lid);
}
@@ -96,7 +115,7 @@ function locale_save($lid) {
// delete form data so it will remember where it came from
$edit = '';
- drupal_set_message(t("saved string"));
+ drupal_set_message(t('saved string'));
}
function locale_refresh_cache() {
@@ -107,7 +126,7 @@ function locale_refresh_cache() {
** We only load short strings into the cache to improve both performance
** and memory usages.
*/
- $result = db_query("SELECT string, %s FROM {locales} WHERE LENGTH(string) < 75", $locale);
+ $result = db_query('SELECT string, %s FROM {locales} WHERE LENGTH(string) < 75', $locale);
while ($data = db_fetch_object($result)) {
if (empty($data->$locale)) {
$t[$data->string] = $data->string;
@@ -126,7 +145,7 @@ function locale_edit($lid) {
$result = db_query("SELECT * FROM {locales} WHERE lid = '$lid'");
if ($translation = db_fetch_object($result)) {
- $form .= form_item(t("Original text"), wordwrap(drupal_specialchars($translation->string, 0)));
+ $form .= form_item(t('Original text'), wordwrap(drupal_specialchars($translation->string, 0)));
foreach ($languages as $code=>$language) {
$form .= (strlen($translation->string) > 30) ? form_textarea($language, $code, $translation->$code, 50, 10) : form_textfield($language, $code, $translation->$code, 50, 128);
@@ -142,16 +161,16 @@ function locale_languages($translation) {
global $languages;
foreach ($languages as $key => $value) {
- $output .= ($translation->$key) ? "<a href=\"#\" title=\"". $translation->$key ."\">$key</a> " : "<strike>$key</strike> ";
+ $output .= ($translation->$key) ? '<a href="#" title="'. $translation->$key ."\">$key</a> " : "<strike>$key</strike> ";
}
return $output;
}
function locale_seek_query() {
- $fields = array("string", 'language', 'status');
- if (is_array($_REQUEST["edit"])) {
- foreach ($_REQUEST["edit"] as $key => $value) {
+ $fields = array('string', 'language', 'status');
+ if (is_array($_REQUEST['edit'])) {
+ foreach ($_REQUEST['edit'] as $key => $value) {
if (!empty($value) && in_array($key, $fields)) {
$query->$key = $value;
}
@@ -160,7 +179,7 @@ function locale_seek_query() {
else {
foreach ($_REQUEST as $key => $value) {
if (!empty($value) && in_array($key, $fields)) {
- $query->$key = strpos(",", $value) ? explode(",", $value) : $value;
+ $query->$key = strpos(',', $value) ? explode(',', $value) : $value;
}
}
}
@@ -169,27 +188,27 @@ function locale_seek_query() {
function locale_seek() {
global $id, $languages;
- $op = $_POST["op"];
+ $op = $_POST['op'];
$query = locale_seek_query();
if ($query) {
if ($query->status) {
switch ($query->language) {
- case "all":
+ case 'all':
foreach ($languages as $key=>$value) {
- $tmp[] = $key . (check_query($query->status) == 1 ? " !=" : " =") ." ''";
+ $tmp[] = $key . (check_query($query->status) == 1 ? ' !=' : ' =') ." ''";
}
- $sql[] = implode(" AND ", $tmp);
+ $sql[] = implode(' AND ', $tmp);
break;
- case "any":
+ case 'any':
foreach ($languages as $key=>$value) {
- $tmp[] = $key . (check_query($query->status) == 1 ? " !=" : " =") ." ''";
+ $tmp[] = $key . (check_query($query->status) == 1 ? ' !=' : ' =') ." ''";
}
- $sql[] = "(". implode(" OR ", $tmp) .")";
+ $sql[] = '('. implode(' OR ', $tmp) .')';
break;
default:
- $sql[] = check_query($query->language) . (check_query($query->status) == 1 ? " !=" : " =") ." ''";
+ $sql[] = check_query($query->language) . (check_query($query->status) == 1 ? ' !=' : ' =') ." ''";
}
}
@@ -205,28 +224,28 @@ function locale_seek() {
}
}
}
- $sql[] = "(". implode(" OR ", $string_query) .")";
+ $sql[] = '('. implode(' OR ', $string_query) .')';
}
- $result = pager_query("SELECT * FROM {locales} ". (count($sql) ? " WHERE ". implode(" AND ", $sql) : "") ." ORDER BY string", 50);
+ $result = pager_query('SELECT * FROM {locales} '. (count($sql) ? ' WHERE '. implode(' AND ', $sql) : '') .' ORDER BY string', 50);
- $header = array(t("string"), (($query->status != 2 && strlen($query->language) == 2) ? t("translated string") : t("languages")), array("data" => t("operations"), "colspan" => "2"));
+ $header = array(t('string'), (($query->status != 2 && strlen($query->language) == 2) ? t('translated string') : t('languages')), array('data' => t('operations'), 'colspan' => '2'));
while ($locale = db_fetch_object($result)) {
- $rows[] = array("$locale->string<br /><small><i>$locale->location</i></small>", array("data" => (($query->status != 2 && strlen($query->language) == 2) ? $locale->{$query->language} : locale_languages($locale)), "align" => "center"), array("data" => l(t("edit locale"), "admin/locale/edit/$locale->lid"), "nowrap" => "nowrap"), array("data" => l(t("delete locale"), "admin/locale/delete/$locale->lid"), "nowrap" => "nowrap"));
+ $rows[] = array("$locale->string<br /><small><i>$locale->location</i></small>", array('data' => (($query->status != 2 && strlen($query->language) == 2) ? $locale->{$query->language} : locale_languages($locale)), 'align' => 'center'), array('data' => l(t('edit locale'), "admin/locale/edit/$locale->lid"), 'nowrap' => 'nowrap'), array('data' => l(t('delete locale'), "admin/locale/delete/$locale->lid"), 'nowrap' => 'nowrap'));
}
$request = array();
if (count($query)) {
foreach ($query as $key => $value) {
- $request[$key] = (is_array($value)) ? implode(",", $value) : $value;
+ $request[$key] = (is_array($value)) ? implode(',', $value) : $value;
}
}
- if ($pager = theme("pager", NULL, 50, 0, $request)) {
- $rows[] = array(array("data" => "$pager", "colspan" => "5"));
+ if ($pager = theme('pager', NULL, 50, 0, $request)) {
+ $rows[] = array(array('data' => "$pager", 'colspan' => '5'));
}
- $output .= theme("table", $header, $rows);
+ $output .= theme('table', $header, $rows);
}
@@ -235,10 +254,10 @@ function locale_seek() {
function locale_seek_form() {
global $languages;
- $edit =& $_POST["edit"];
- $form .= form_textfield(t("Strings to search for"), "string", $edit["string"], 30, 30, t("Leave blank to show all strings."));
+ $edit =& $_POST['edit'];
+ $form .= form_textfield(t('Strings to search for'), 'string', $edit['string'], 30, 30, t('Leave blank to show all strings.'));
if (count($languages) > 1) {
- $form .= form_radios(t("Language"), 'language', ($edit['language'] ? $edit['language'] : "all"), array_merge(array("any" => t("Any language"), "all" => t("All languages")), $languages), t("In which language must the string be translated/untranslated (see status)?"));
+ $form .= form_radios(t('Language'), 'language', ($edit['language'] ? $edit['language'] : 'all'), array_merge(array('any' => t('Any language'), 'all' => t('All languages')), $languages), t('In which language must the string be translated/untranslated (see status)?'));
}
else {
foreach ($languages as $key => $value) {
@@ -254,8 +273,8 @@ function locale_seek_form() {
}
function locale_admin() {
- $op = $_POST["op"];
- $edit =& $_POST["edit"];
+ $op = $_POST['op'];
+ $edit =& $_POST['edit'];
if (empty($op)) {
$op = arg(2);
@@ -299,6 +318,13 @@ function locale_admin() {
print theme('page', $output);
}
+/**
+ * Does the work of localizing a string of text.
+ *
+ * This function is called by the universally-used t() function each time
+ * an internationalized string is encountered. The string is then localized
+ * by this function if the locale module is enabled.
+ */
function locale($string) {
global $locale;
static $locale_t;
diff --git a/modules/menu.module b/modules/menu.module
index 1f94e3b4b..8be50f4c0 100644
--- a/modules/menu.module
+++ b/modules/menu.module
@@ -2,19 +2,45 @@
// $Id$
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function menu_link($type, $node = 0, $main) {
- if ($type == 'system') {
- menu('admin/menu', t('menus'), user_access('administer menu') ? 'menu_overview' : MENU_DENIED, 0, MENU_SHOW);
- menu('admin/menu/reset', t('reset all menus'), user_access('administer menu') ? 'menu_reset' : MENU_DENIED, 0, MENU_SHOW);
- menu('admin/menu/menu/add', t('add menu'), user_access('administer menu') ? 'menu_add_menu' : MENU_DENIED, 0, MENU_SHOW);
- menu('admin/menu/item/add', t('add menu item'), user_access('administer menu') ? 'menu_edit_item' : MENU_DENIED, 0, MENU_SHOW);
- menu('admin/menu/item/edit', t('edit menu item'), user_access('administer menu') ? 'menu_edit_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/menu/item/reset', t('reset menu item'), user_access('administer menu') ? 'menu_reset_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/menu/item/disable', t('disable menu item'), user_access('administer menu') ? 'menu_disable_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/menu/item/delete', t('delete menu item'), user_access('administer menu') ? 'menu_delete_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
+function menu_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/menu', 'title' => t('menus'),
+ 'callback' => 'menu_overview',
+ 'access' => user_access('administer menu'));
+ $items[] = array('path' => 'admin/menu/item/edit', 'title' => t('edit menu item'),
+ 'callback' => 'menu_edit_item',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/menu/item/reset', 'title' => t('reset menu item'),
+ 'callback' => 'menu_reset_item',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/menu/item/disable', 'title' => t('disable menu item'),
+ 'callback' => 'menu_disable_item',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/menu/item/delete', 'title' => t('delete menu item'),
+ 'callback' => 'menu_delete_item',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_CALLBACK);
+
+ // Tabs:
+ $items[] = array('path' => 'admin/menu/menu/add', 'title' => t('add menu'),
+ 'callback' => 'menu_add_menu',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/menu/item/add', 'title' => t('add menu item'),
+ 'callback' => 'menu_edit_item',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/menu/reset', 'title' => t('reset menus'),
+ 'callback' => 'menu_reset',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_LOCAL_TASK);
+
+ return $items;
}
/**
@@ -22,12 +48,12 @@ function menu_link($type, $node = 0, $main) {
*/
function menu_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Allows administrators to customize the site navigation menu.');
case 'admin/menu':
return t('Select an operation from the list to move, change, or delete a menu item. To add a new menu, add a new menu item, or reset all menu items to default values, choose an option from the main menu.');
case 'admin/menu/menu/add':
- return t('Enter the name for your new menu. Remember to enable the newly created block in the %blocks administration page.', array('%blocks' => l(t('blocks'), 'admin/system/block')));
+ return t('Enter the name for your new menu. Remember to enable the newly created block in the %blocks administration page.', array('%blocks' => l(t('blocks'), 'admin/block')));
}
}
@@ -49,7 +75,7 @@ function menu_block($op = 'list', $delta = 0) {
}
else {
$data['subject'] = $menu['items'][$delta]['title'];
- $data['content'] = menu_tree($delta);
+ $data['content'] = theme('menu_tree', $delta);
return $data;
}
}
@@ -107,7 +133,7 @@ function menu_add_menu() {
break;
default:
$edit['pid'] = 0;
- $edit['status'] = MENU_CUSTOM;
+ $edit['type'] = MENU_CUSTOM_ITEM;
$output .= menu_edit_item_form($edit);
}
@@ -162,7 +188,11 @@ function menu_delete_item($mid) {
* Menu callback; hide a menu item.
*/
function menu_disable_item($mid) {
- db_query('UPDATE {menu} SET visibility = %d, status = %d WHERE mid = %d', MENU_HIDE, MENU_MODIFIED, $mid);
+ $menu = menu_get_menu();
+ $type = $menu['items'][$mid]['type'];
+ $type &= ~MENU_VISIBLE_IN_TREE;
+ $type &= ~MENU_VISIBLE_IN_BREADCRUMB;
+ db_query('UPDATE {menu} SET type = %d WHERE mid = %d', $type, $mid);
menu_rebuild();
drupal_set_message(t('menu item disabled.'));
print theme('page', menu_overview_tree());
@@ -174,6 +204,7 @@ function menu_disable_item($mid) {
function menu_edit_item($mid = 0) {
$op = $_POST['op'];
$edit = $_POST['edit'];
+
$output = '';
switch ($op) {
@@ -194,13 +225,12 @@ function menu_edit_item($mid = 0) {
$edit['path'] = $item->path;
$edit['title'] = $item->title;
$edit['weight'] = $item->weight;
- $edit['visibility'] = $item->visibility;
- $edit['status'] = $item->status;
+ $edit['type'] = $item->type;
}
else {
$edit['mid'] = 0; // In case a negative ID was passed in.
$edit['pid'] = 1; // default to "Navigation" menu.
- $edit['status'] = MENU_CUSTOM;
+ $edit['type'] = MENU_CUSTOM_ITEM;
}
$output .= menu_edit_item_form($edit);
}
@@ -223,11 +253,12 @@ function menu_edit_item_form($edit) {
$form .= form_hidden('weight', 0);
}
else {
- if ($edit['status'] == MENU_CUSTOM) {
+ if ($edit['type'] & MENU_CREATED_BY_ADMIN) {
$form .= form_textfield(t('Path'), 'path', $edit['path'], 60, 128);
}
else {
$form .= form_item(t('Path'), l($edit['path'], $edit['path']));
+ $form .= form_hidden('path', $edit['path']);
}
// Generate a list of possible parents (not including this item or descendants).
@@ -240,14 +271,8 @@ function menu_edit_item_form($edit) {
$form .= form_submit(t('Submit'));
$form .= form_hidden('mid', $edit['mid']);
- $form .= form_hidden('status', $edit['status']);
- if ($edit['visibility'] == MENU_HIDE) {
- // always enable on edit
- $form .= form_hidden('visibility', MENU_SHOW);
- }
- else {
- $form .= form_hidden('visibility', $edit['visibility']);
- }
+ // Always enable menu items when editing them.
+ $form .= form_hidden('type', $edit['type'] | MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB);
return form($form);
}
@@ -257,17 +282,12 @@ function menu_edit_item_form($edit) {
*/
function menu_edit_item_save($edit) {
if ($edit['mid']) {
- if ($edit['status'] == MENU_CUSTOM) {
- db_query("UPDATE {menu} SET pid = %d, path = '%s', title = '%s', weight = %d, visibility = %d WHERE mid = %d", $edit['pid'], $edit['path'], $edit['title'], $edit['weight'], $edit['visibility'], $edit['mid']);
- }
- else {
- db_query("UPDATE {menu} SET pid = %d, title = '%s', weight = %d, visibility = %d, status = %d WHERE mid = %d", $edit['pid'], $edit['title'], $edit['weight'], $edit['visibility'], MENU_MODIFIED, $edit['mid']);
- }
+ db_query("UPDATE {menu} SET pid = %d, path = '%s', title = '%s', weight = %d, type = %d WHERE mid = %d", $edit['pid'], $edit['path'], $edit['title'], $edit['weight'], $edit['type'] | MENU_MODIFIED_BY_ADMIN, $edit['mid']);
drupal_set_message(t('updated menu item "%title".', array('%title' => $edit['title'])));
}
else {
$mid = db_next_id('menu_mid');
- db_query("INSERT INTO {menu} (mid, pid, path, title, weight, visibility, status) VALUES (%d, %d, '%s', '%s', %d, %d, %d)", $mid, $edit['pid'], $edit['path'], $edit['title'], $edit['weight'], $edit['visibility'], $edit['status']);
+ db_query("INSERT INTO {menu} (mid, pid, path, title, weight, type) VALUES (%d, %d, '%s', '%s', %d, %d)", $mid, $edit['pid'], $edit['path'], $edit['title'], $edit['weight'], $edit['type'] | MENU_MODIFIED_BY_ADMIN);
drupal_set_message(t('created new menu item "%title".', array('%title' => $edit['title'])));
}
@@ -284,10 +304,10 @@ function menu_overview_tree() {
foreach ($menu['items'][0]['children'] as $mid) {
$operations = array();
- if ($menu['items'][$mid]['status'] != MENU_LOCKED) {
+ if ($menu['items'][$mid]['type'] & MENU_MODIFIABLE_BY_ADMIN) {
$operations[] = l(t('edit'), 'admin/menu/item/edit/'. $mid);
}
- if ($menu['items'][$mid]['status'] == MENU_CUSTOM) {
+ if ($menu['items'][$mid]['type'] & MENU_CREATED_BY_ADMIN) {
$operations[] = l(t('delete'), 'admin/menu/item/delete/'. $mid);
}
$table = theme('item_list', $operations);
@@ -324,17 +344,13 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
// Populate the operations field.
$operations = array();
- if ($menu['items'][$mid]['status'] == MENU_LOCKED) {
+ if (!($menu['items'][$mid]['type'] & MENU_MODIFIABLE_BY_ADMIN)) {
$operations[] = array('data' => t('locked'), 'colspan' => 3, 'align' => 'center');
}
else {
- if ($menu['items'][$mid]['visibility'] == MENU_HIDE) {
- $operations[] = array('data' => '');
- $operations[] = array('data' => l(t('enable'), 'admin/menu/item/edit/'. $mid));
- }
- else {
+ if ($menu['items'][$mid]['type'] & MENU_VISIBLE_IN_TREE) {
$operations[] = array('data' => l(t('edit'), 'admin/menu/item/edit/'. $mid));
- if ($pid == 0) {
+ if ($menu['items'][$mid]['type'] & MENU_IS_ROOT) {
// Disabling entire menus is done from block admin page.
$operations[] = array('data' => '');
}
@@ -342,32 +358,32 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
$operations[] = array('data' => l(t('disable'), 'admin/menu/item/disable/'. $mid));
}
}
-
- if ($menu['items'][$mid]['status'] == MENU_MODIFIED) {
- $operations[] = array('data' => l(t('reset'), 'admin/menu/item/reset/'. $mid));
+ else {
+ $operations[] = array('data' => '');
+ $operations[] = array('data' => l(t('enable'), 'admin/menu/item/edit/'. $mid));
}
- else if ($menu['items'][$mid]['status'] == MENU_CUSTOM) {
+
+ if ($menu['items'][$mid]['type'] & MENU_CREATED_BY_ADMIN) {
$operations[] = array('data' => l(t('delete'), 'admin/menu/item/delete/'. $mid));
}
+ else if ($menu['items'][$mid]['type'] & MENU_MODIFIED_BY_ADMIN) {
+ $operations[] = array('data' => l(t('reset'), 'admin/menu/item/reset/'. $mid));
+ }
else {
$operations[] = array('data' => '');
}
}
// Call out disabled items.
- if ($menu['items'][$mid]['visibility'] == MENU_HIDE) {
- $title .= ' ('. t('disabled') .')';
- $class = 'menu-disabled';
+ if ($menu['items'][$mid]['type'] & MENU_VISIBLE_IN_TREE) {
+ $class = 'menu-enabled';
}
else {
- $class = 'menu-enabled';
+ $title .= ' ('. t('disabled') .')';
+ $class = 'menu-disabled';
}
- if ($menu['items'][$mid]['visibility'] == MENU_HIDE && $menu['items'][$mid]['status'] == MENU_LOCKED) {
- // Skip items that are hidden and locked; admins will never care about them.
- $rows = array_merge($rows, menu_overview_tree_rows($mid, $depth));
- }
- else {
+ if ($menu['items'][$mid]['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_VISIBLE_IN_TREE)) {
$row = array(array('data' => $title, 'class' => $class));
foreach ($operations as $operation) {
$operation['class'] = $class;
@@ -376,6 +392,10 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
$rows[] = $row;
$rows = array_merge($rows, menu_overview_tree_rows($mid, $depth + 1));
}
+ else {
+ // Skip items that are hidden and locked; admins will never care about them.
+ $rows = array_merge($rows, menu_overview_tree_rows($mid, $depth));
+ }
}
}
@@ -396,12 +416,12 @@ function menu_parent_options($mid, $pid = 0, $depth = 0) {
usort($menu['items'][$pid]['children'], '_menu_sort');
foreach ($menu['items'][$pid]['children'] as $child) {
if ($child != $mid) {
- if ($child == 1 || ($child > 0 && $menu['items'][$child]['status'] != MENU_LOCKED)) {
+ if ($child == 1 || ($child > 0 && ($menu['items'][$child]['type'] & MENU_MODIFIABLE_BY_ADMIN))) {
$title = ' '. $menu['items'][$child]['title'];
for ($i = 0; $i < $depth; $i++) {
$title = '--'. $title;
}
- if ($menu['items'][$child]['visibility'] == MENU_HIDE) {
+ if (!($menu['items'][$child]['type'] & MENU_VISIBLE_IN_TREE)) {
$title .= ' ('. t('disabled') .')';
}
$options[$child] = $title;
diff --git a/modules/menu/menu.module b/modules/menu/menu.module
index 1f94e3b4b..8be50f4c0 100644
--- a/modules/menu/menu.module
+++ b/modules/menu/menu.module
@@ -2,19 +2,45 @@
// $Id$
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function menu_link($type, $node = 0, $main) {
- if ($type == 'system') {
- menu('admin/menu', t('menus'), user_access('administer menu') ? 'menu_overview' : MENU_DENIED, 0, MENU_SHOW);
- menu('admin/menu/reset', t('reset all menus'), user_access('administer menu') ? 'menu_reset' : MENU_DENIED, 0, MENU_SHOW);
- menu('admin/menu/menu/add', t('add menu'), user_access('administer menu') ? 'menu_add_menu' : MENU_DENIED, 0, MENU_SHOW);
- menu('admin/menu/item/add', t('add menu item'), user_access('administer menu') ? 'menu_edit_item' : MENU_DENIED, 0, MENU_SHOW);
- menu('admin/menu/item/edit', t('edit menu item'), user_access('administer menu') ? 'menu_edit_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/menu/item/reset', t('reset menu item'), user_access('administer menu') ? 'menu_reset_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/menu/item/disable', t('disable menu item'), user_access('administer menu') ? 'menu_disable_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/menu/item/delete', t('delete menu item'), user_access('administer menu') ? 'menu_delete_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
+function menu_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/menu', 'title' => t('menus'),
+ 'callback' => 'menu_overview',
+ 'access' => user_access('administer menu'));
+ $items[] = array('path' => 'admin/menu/item/edit', 'title' => t('edit menu item'),
+ 'callback' => 'menu_edit_item',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/menu/item/reset', 'title' => t('reset menu item'),
+ 'callback' => 'menu_reset_item',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/menu/item/disable', 'title' => t('disable menu item'),
+ 'callback' => 'menu_disable_item',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/menu/item/delete', 'title' => t('delete menu item'),
+ 'callback' => 'menu_delete_item',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_CALLBACK);
+
+ // Tabs:
+ $items[] = array('path' => 'admin/menu/menu/add', 'title' => t('add menu'),
+ 'callback' => 'menu_add_menu',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/menu/item/add', 'title' => t('add menu item'),
+ 'callback' => 'menu_edit_item',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/menu/reset', 'title' => t('reset menus'),
+ 'callback' => 'menu_reset',
+ 'access' => user_access('administer menu'),
+ 'type' => MENU_LOCAL_TASK);
+
+ return $items;
}
/**
@@ -22,12 +48,12 @@ function menu_link($type, $node = 0, $main) {
*/
function menu_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Allows administrators to customize the site navigation menu.');
case 'admin/menu':
return t('Select an operation from the list to move, change, or delete a menu item. To add a new menu, add a new menu item, or reset all menu items to default values, choose an option from the main menu.');
case 'admin/menu/menu/add':
- return t('Enter the name for your new menu. Remember to enable the newly created block in the %blocks administration page.', array('%blocks' => l(t('blocks'), 'admin/system/block')));
+ return t('Enter the name for your new menu. Remember to enable the newly created block in the %blocks administration page.', array('%blocks' => l(t('blocks'), 'admin/block')));
}
}
@@ -49,7 +75,7 @@ function menu_block($op = 'list', $delta = 0) {
}
else {
$data['subject'] = $menu['items'][$delta]['title'];
- $data['content'] = menu_tree($delta);
+ $data['content'] = theme('menu_tree', $delta);
return $data;
}
}
@@ -107,7 +133,7 @@ function menu_add_menu() {
break;
default:
$edit['pid'] = 0;
- $edit['status'] = MENU_CUSTOM;
+ $edit['type'] = MENU_CUSTOM_ITEM;
$output .= menu_edit_item_form($edit);
}
@@ -162,7 +188,11 @@ function menu_delete_item($mid) {
* Menu callback; hide a menu item.
*/
function menu_disable_item($mid) {
- db_query('UPDATE {menu} SET visibility = %d, status = %d WHERE mid = %d', MENU_HIDE, MENU_MODIFIED, $mid);
+ $menu = menu_get_menu();
+ $type = $menu['items'][$mid]['type'];
+ $type &= ~MENU_VISIBLE_IN_TREE;
+ $type &= ~MENU_VISIBLE_IN_BREADCRUMB;
+ db_query('UPDATE {menu} SET type = %d WHERE mid = %d', $type, $mid);
menu_rebuild();
drupal_set_message(t('menu item disabled.'));
print theme('page', menu_overview_tree());
@@ -174,6 +204,7 @@ function menu_disable_item($mid) {
function menu_edit_item($mid = 0) {
$op = $_POST['op'];
$edit = $_POST['edit'];
+
$output = '';
switch ($op) {
@@ -194,13 +225,12 @@ function menu_edit_item($mid = 0) {
$edit['path'] = $item->path;
$edit['title'] = $item->title;
$edit['weight'] = $item->weight;
- $edit['visibility'] = $item->visibility;
- $edit['status'] = $item->status;
+ $edit['type'] = $item->type;
}
else {
$edit['mid'] = 0; // In case a negative ID was passed in.
$edit['pid'] = 1; // default to "Navigation" menu.
- $edit['status'] = MENU_CUSTOM;
+ $edit['type'] = MENU_CUSTOM_ITEM;
}
$output .= menu_edit_item_form($edit);
}
@@ -223,11 +253,12 @@ function menu_edit_item_form($edit) {
$form .= form_hidden('weight', 0);
}
else {
- if ($edit['status'] == MENU_CUSTOM) {
+ if ($edit['type'] & MENU_CREATED_BY_ADMIN) {
$form .= form_textfield(t('Path'), 'path', $edit['path'], 60, 128);
}
else {
$form .= form_item(t('Path'), l($edit['path'], $edit['path']));
+ $form .= form_hidden('path', $edit['path']);
}
// Generate a list of possible parents (not including this item or descendants).
@@ -240,14 +271,8 @@ function menu_edit_item_form($edit) {
$form .= form_submit(t('Submit'));
$form .= form_hidden('mid', $edit['mid']);
- $form .= form_hidden('status', $edit['status']);
- if ($edit['visibility'] == MENU_HIDE) {
- // always enable on edit
- $form .= form_hidden('visibility', MENU_SHOW);
- }
- else {
- $form .= form_hidden('visibility', $edit['visibility']);
- }
+ // Always enable menu items when editing them.
+ $form .= form_hidden('type', $edit['type'] | MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB);
return form($form);
}
@@ -257,17 +282,12 @@ function menu_edit_item_form($edit) {
*/
function menu_edit_item_save($edit) {
if ($edit['mid']) {
- if ($edit['status'] == MENU_CUSTOM) {
- db_query("UPDATE {menu} SET pid = %d, path = '%s', title = '%s', weight = %d, visibility = %d WHERE mid = %d", $edit['pid'], $edit['path'], $edit['title'], $edit['weight'], $edit['visibility'], $edit['mid']);
- }
- else {
- db_query("UPDATE {menu} SET pid = %d, title = '%s', weight = %d, visibility = %d, status = %d WHERE mid = %d", $edit['pid'], $edit['title'], $edit['weight'], $edit['visibility'], MENU_MODIFIED, $edit['mid']);
- }
+ db_query("UPDATE {menu} SET pid = %d, path = '%s', title = '%s', weight = %d, type = %d WHERE mid = %d", $edit['pid'], $edit['path'], $edit['title'], $edit['weight'], $edit['type'] | MENU_MODIFIED_BY_ADMIN, $edit['mid']);
drupal_set_message(t('updated menu item "%title".', array('%title' => $edit['title'])));
}
else {
$mid = db_next_id('menu_mid');
- db_query("INSERT INTO {menu} (mid, pid, path, title, weight, visibility, status) VALUES (%d, %d, '%s', '%s', %d, %d, %d)", $mid, $edit['pid'], $edit['path'], $edit['title'], $edit['weight'], $edit['visibility'], $edit['status']);
+ db_query("INSERT INTO {menu} (mid, pid, path, title, weight, type) VALUES (%d, %d, '%s', '%s', %d, %d)", $mid, $edit['pid'], $edit['path'], $edit['title'], $edit['weight'], $edit['type'] | MENU_MODIFIED_BY_ADMIN);
drupal_set_message(t('created new menu item "%title".', array('%title' => $edit['title'])));
}
@@ -284,10 +304,10 @@ function menu_overview_tree() {
foreach ($menu['items'][0]['children'] as $mid) {
$operations = array();
- if ($menu['items'][$mid]['status'] != MENU_LOCKED) {
+ if ($menu['items'][$mid]['type'] & MENU_MODIFIABLE_BY_ADMIN) {
$operations[] = l(t('edit'), 'admin/menu/item/edit/'. $mid);
}
- if ($menu['items'][$mid]['status'] == MENU_CUSTOM) {
+ if ($menu['items'][$mid]['type'] & MENU_CREATED_BY_ADMIN) {
$operations[] = l(t('delete'), 'admin/menu/item/delete/'. $mid);
}
$table = theme('item_list', $operations);
@@ -324,17 +344,13 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
// Populate the operations field.
$operations = array();
- if ($menu['items'][$mid]['status'] == MENU_LOCKED) {
+ if (!($menu['items'][$mid]['type'] & MENU_MODIFIABLE_BY_ADMIN)) {
$operations[] = array('data' => t('locked'), 'colspan' => 3, 'align' => 'center');
}
else {
- if ($menu['items'][$mid]['visibility'] == MENU_HIDE) {
- $operations[] = array('data' => '');
- $operations[] = array('data' => l(t('enable'), 'admin/menu/item/edit/'. $mid));
- }
- else {
+ if ($menu['items'][$mid]['type'] & MENU_VISIBLE_IN_TREE) {
$operations[] = array('data' => l(t('edit'), 'admin/menu/item/edit/'. $mid));
- if ($pid == 0) {
+ if ($menu['items'][$mid]['type'] & MENU_IS_ROOT) {
// Disabling entire menus is done from block admin page.
$operations[] = array('data' => '');
}
@@ -342,32 +358,32 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
$operations[] = array('data' => l(t('disable'), 'admin/menu/item/disable/'. $mid));
}
}
-
- if ($menu['items'][$mid]['status'] == MENU_MODIFIED) {
- $operations[] = array('data' => l(t('reset'), 'admin/menu/item/reset/'. $mid));
+ else {
+ $operations[] = array('data' => '');
+ $operations[] = array('data' => l(t('enable'), 'admin/menu/item/edit/'. $mid));
}
- else if ($menu['items'][$mid]['status'] == MENU_CUSTOM) {
+
+ if ($menu['items'][$mid]['type'] & MENU_CREATED_BY_ADMIN) {
$operations[] = array('data' => l(t('delete'), 'admin/menu/item/delete/'. $mid));
}
+ else if ($menu['items'][$mid]['type'] & MENU_MODIFIED_BY_ADMIN) {
+ $operations[] = array('data' => l(t('reset'), 'admin/menu/item/reset/'. $mid));
+ }
else {
$operations[] = array('data' => '');
}
}
// Call out disabled items.
- if ($menu['items'][$mid]['visibility'] == MENU_HIDE) {
- $title .= ' ('. t('disabled') .')';
- $class = 'menu-disabled';
+ if ($menu['items'][$mid]['type'] & MENU_VISIBLE_IN_TREE) {
+ $class = 'menu-enabled';
}
else {
- $class = 'menu-enabled';
+ $title .= ' ('. t('disabled') .')';
+ $class = 'menu-disabled';
}
- if ($menu['items'][$mid]['visibility'] == MENU_HIDE && $menu['items'][$mid]['status'] == MENU_LOCKED) {
- // Skip items that are hidden and locked; admins will never care about them.
- $rows = array_merge($rows, menu_overview_tree_rows($mid, $depth));
- }
- else {
+ if ($menu['items'][$mid]['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_VISIBLE_IN_TREE)) {
$row = array(array('data' => $title, 'class' => $class));
foreach ($operations as $operation) {
$operation['class'] = $class;
@@ -376,6 +392,10 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
$rows[] = $row;
$rows = array_merge($rows, menu_overview_tree_rows($mid, $depth + 1));
}
+ else {
+ // Skip items that are hidden and locked; admins will never care about them.
+ $rows = array_merge($rows, menu_overview_tree_rows($mid, $depth));
+ }
}
}
@@ -396,12 +416,12 @@ function menu_parent_options($mid, $pid = 0, $depth = 0) {
usort($menu['items'][$pid]['children'], '_menu_sort');
foreach ($menu['items'][$pid]['children'] as $child) {
if ($child != $mid) {
- if ($child == 1 || ($child > 0 && $menu['items'][$child]['status'] != MENU_LOCKED)) {
+ if ($child == 1 || ($child > 0 && ($menu['items'][$child]['type'] & MENU_MODIFIABLE_BY_ADMIN))) {
$title = ' '. $menu['items'][$child]['title'];
for ($i = 0; $i < $depth; $i++) {
$title = '--'. $title;
}
- if ($menu['items'][$child]['visibility'] == MENU_HIDE) {
+ if (!($menu['items'][$child]['type'] & MENU_VISIBLE_IN_TREE)) {
$title .= ' ('. t('disabled') .')';
}
$options[$child] = $title;
diff --git a/modules/node.module b/modules/node.module
index 74e6e147e..afd41f23b 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -30,7 +30,7 @@ function node_help($section = 'admin/help#node') {
<dt>Score</dt><dd>The score of the node is gotten by the votes it is given.</dd>
<dt>Users</dt><dd>The list of users who have voted on a moderated node.</dd>
<dt>Published</dt><dd>When using Drupal's moderation system a node remains unpublished -- unavaliable to non-moderators -- until it is marked Published.</dd></dl>
- <p>Now that you know what is in a node, here are some of the types of nodes available.</p>", array("%teaser" => url("admin/system/modules/node")));
+ <p>Now that you know what is in a node, here are some of the types of nodes available.</p>", array("%teaser" => url("admin/settings/node")));
if ($mod == 'admin') {
foreach (node_list() as $type) {
@@ -40,10 +40,10 @@ function node_help($section = 'admin/help#node') {
}
break;
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
$output = t('The core that allows content to be submitted to the site.');
break;
- case 'admin/system/modules/node':
+ case 'admin/settings/node':
$output = t('Settings for the core of Drupal. Almost everything is a node so these settings will affect most of the site.');
break;
case 'admin/node':
@@ -52,7 +52,7 @@ function node_help($section = 'admin/help#node') {
case 'admin/node/search':
$output = t("Enter a simple pattern to search for a post. This can include the wildcard character *.<br />For example, a search for \"br*\" might return \"bread bakers\", \"our daily bread\" and \"brenda\".");
break;
- case 'admin/node/settings':
+ case 'admin/settings/node/defaults':
$output = t('This page lets you set the defaults used during creation of nodes for all the different node types.<br /><strong>comment:</strong> Read/write setting for comments.<br /><strong>publish:</strong> Is this node publicly viewable, has it been published?<br /><strong>promote:</strong> Is this node to be promoted to the front page?<br /><strong>moderate:</strong> Does this node need approval before it can be viewed?<br /><strong>static:</strong> Is this node always visible on the front page?<br /><strong>revision:</strong> Will this node go into the revision system allowing multiple versions to be saved?');
break;
@@ -77,7 +77,7 @@ function node_help_page() {
function node_title_list($result, $title = NULL) {
while ($node = db_fetch_object($result)) {
$number = module_invoke('comment', 'num_all', $node->nid);
- $items[] = l($node->title, "node/view/$node->nid", array('title' => format_plural($number, '1 comment', '%count comments')));
+ $items[] = l($node->title, "node/$node->nid", array('title' => format_plural($number, '1 comment', '%count comments')));
}
return theme('node_list', $items, $title);
@@ -484,7 +484,7 @@ function node_save($node) {
}
-function node_view($node, $main = 0, $page = 0) {
+function node_view($node, $teaser = FALSE, $page = FALSE) {
$node = array2object($node);
@@ -496,7 +496,7 @@ function node_view($node, $main = 0, $page = 0) {
$node->body = str_replace('<!--break-->', '', $node->body);
// Allow modules to change $node->body before viewing.
- node_invoke_nodeapi($node, 'view', $main, $page);
+ node_invoke_nodeapi($node, 'view', $teaser, $page);
/*
** The 'view' hook can be implemented to overwrite the default function
@@ -504,7 +504,7 @@ function node_view($node, $main = 0, $page = 0) {
*/
if (node_hook($node, 'view')) {
- return node_invoke($node, 'view', $main, $page);
+ return node_invoke($node, 'view', $teaser, $page);
}
else {
@@ -512,13 +512,13 @@ function node_view($node, $main = 0, $page = 0) {
** Default behavior:
*/
- return theme('node', node_prepare($node, $main), $main, $page);
+ return theme('node', node_prepare($node, $teaser), $teaser, $page);
}
}
-function node_prepare($node, $main = 0) {
+function node_prepare($node, $teaser = FALSE) {
$node->readmore = (strlen($node->teaser) < strlen($node->body));
- if ($main == 0) {
+ if ($teaser == FALSE) {
$node->body = check_output($node->body);
}
else {
@@ -596,12 +596,19 @@ function node_search($keys) {
return array(t('Matching nodes ranked in order of relevance'), $find);
}
-function node_settings() {
+/**
+ * Page callback; presents general node configuration options.
+ */
+function node_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
$output .= form_select(t('Number of posts on main page'), 'default_nodes_main', variable_get('default_nodes_main', 10), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), t('The default maximum number of posts to display per page on overview pages such as the main page.'));
$output .= form_select(t('Length of trimmed posts'), 'teaser_length', variable_get('teaser_length', 600), array(0 => t('Unlimited'), 200 => t('200 characters'), 400 => t('400 characters'), 600 => t('600 characters'), 800 => t('800 characters'), 1000 => t('1000 characters'), 1200 => t('1200 characters'), 1400 => t('1400 characters'), 1600 => t('1600 characters'), 1800 => t('1800 characters'), 2000 => t('2000 characters')), t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited'. Note that this setting will only affect new or updated content and will not affect existing teasers."));
$output .= form_radios(t('Preview post'), 'node_preview', variable_get('node_preview', 0), array(t('Optional'), t('Required')), t('Must users preview posts before submitting?'));
- return $output;
+ print theme('page', system_settings_form($output));
}
function node_comment_mode($nid) {
@@ -625,11 +632,7 @@ function node_link($type, $node = 0, $main = 0) {
}
if ($main == 1 && $node->teaser && $node->readmore) {
- $links[] = l(t('read more'), "node/view/$node->nid", array('title' => t('Read the rest of this posting.'), 'class' => 'read-more'));
- }
-
- if (user_access('administer nodes')) {
- $links[] = l(t('administer'), "admin/node/edit/$node->nid", array('title' => t('Administer this node.')));
+ $links[] = l(t('read more'), "node/$node->nid", array('title' => t('Read the rest of this posting.'), 'class' => 'read-more'));
}
if (user_access('administer nodes') && $node->revisions) {
@@ -637,23 +640,71 @@ function node_link($type, $node = 0, $main = 0) {
}
}
- if ($type == 'system') {
- menu('node/add', t('create content'), 'node_page', 1, MENU_HIDE_NOCHILD);
-
- menu('admin/node', t('content'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED);
- menu('admin/node/help', t('help'), user_access('administer nodes') ? 'node_help_page' : MENU_DENIED, 9);
- menu('admin/node/edit', t('edit post'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/node/settings', t('settings'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 8);
- if (module_exist('search')) {
- menu('admin/node/search', t('search'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 8);
- }
-
- menu('node', t('content'), user_access('access content') ? 'node_page' : MENU_DENIED, 0, MENU_HIDE);
- }
-
return $links;
}
+/**
+ * Implementation of hook_menu().
+ */
+function node_menu() {
+ $items = array();
+
+ $items[] = array('path' => 'admin/node', 'title' => t('content'),
+ 'callback' => 'node_admin',
+ 'access' => user_access('administer nodes'));
+
+ // Tabs:
+ $items[] = array('path' => 'admin/node/configure', 'title' => t('configure'),
+ 'callback' => 'node_configure',
+ 'access' => user_access('administer nodes'),
+ 'type' => MENU_LOCAL_TASK);
+ if (module_exist('search')) {
+ $items[] = array('path' => 'admin/node/search', 'title' => t('search'),
+ 'callback' => 'node_admin',
+ 'access' => user_access('administer nodes'),
+ 'type' => MENU_LOCAL_TASK);
+ }
+
+ // Subtabs:
+ $items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'),
+ 'callback' => 'node_configure',
+ 'access' => user_access('administer nodes'),
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/node/configure/defaults', 'title' => t('default workflow'),
+ 'callback' => 'node_default_settings',
+ 'access' => user_access('administer nodes'),
+ 'type' => MENU_LOCAL_SUBTASK);
+
+ $items[] = array('path' => 'node', 'title' => t('content'),
+ 'callback' => 'node_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'node/add', 'title' => t('create content'),
+ 'callback' => 'node_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_ITEM_GROUPING,
+ 'weight' => 1);
+
+ if (arg(0) == 'node' && is_numeric(arg(1))) {
+ $items[] = array('path' => 'node/'. arg(1), 'title' => t('view'),
+ 'callback' => 'node_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'node/'. arg(1) .'/edit', 'title' => t('edit'),
+ 'callback' => 'node_page',
+ 'access' => user_access('administer nodes'),
+ 'type' => MENU_LOCAL_TASK);
+ }
+
+ // Legacy handler
+ $items[] = array('path' => 'node/view', 'title' => t('view'),
+ 'callback' => 'node_old_url',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+
+ return $items;
+}
+
function node_admin_edit($node) {
if (is_numeric($node)) {
@@ -758,7 +809,7 @@ function node_admin_nodes() {
$header = array(NULL, t('title'), t('type'), t('author'), t('status'), array('data' => t('operations'), 'colspan' => 2));
while ($node = db_fetch_object($result)) {
- $rows[] = array(form_checkbox(NULL, "status][$node->nid", 1, 0), l($node->title, "node/view/$node->nid") .' '. (node_is_new($node->nid, $node->changed) ? theme_mark() : ''), node_invoke($node, 'node_name'), format_name($node), ($node->status ? t('published') : t('not published')), l(t('edit node'), "admin/node/edit/$node->nid"), l(t('delete node'), "admin/node/delete/$node->nid"));
+ $rows[] = array(form_checkbox(NULL, "status][$node->nid", 1, 0), l($node->title, "node/$node->nid") .' '. (node_is_new($node->nid, $node->changed) ? theme_mark() : ''), node_invoke($node, 'node_name'), format_name($node), ($node->status ? t('published') : t('not published')), l(t('edit node'), "node/$node->nid/edit"), l(t('delete node'), "admin/node/delete/$node->nid"));
}
if ($pager = theme('pager', NULL, 50, 0)) {
@@ -770,8 +821,9 @@ function node_admin_nodes() {
return form($output);
}
-function node_admin_settings($edit) {
+function node_default_settings() {
$op = $_POST['op'];
+ $edit = $_POST['edit'];
if ($op == t('Save configuration')) {
/*
@@ -810,8 +862,7 @@ function node_admin_settings($edit) {
$output .= form_submit(t('Save configuration'));
$output .= form_submit(t('Reset to defaults'));
- return form($output);
-
+ print theme('page', form($output));
}
function node_revision_overview($nid) {
@@ -823,7 +874,7 @@ function node_revision_overview($nid) {
$header = array(t('older revisions'), array('colspan' => '3', 'data' => t('operations')));
foreach ($node->revisions as $key => $revision) {
- $rows[] = array(t('revision #%r revised by %u on %d', array('%r' => $key, '%u' => format_name(user_load(array('uid' => $revision['uid']))), '%d' => format_date($revision['timestamp'], 'small'))) . ($revision['history'] ? '<br /><small>'. $revision['history'] .'</small>' : ''), l(t('view'), "node/view/$node->nid", array(), "revision=$key"), l(t('rollback'), "node/rollback-revision/$node->nid/$key"), l(t('delete'), "node/delete-revision/$node->nid/$key"));
+ $rows[] = array(t('revision #%r revised by %u on %d', array('%r' => $key, '%u' => format_name(user_load(array('uid' => $revision['uid']))), '%d' => format_date($revision['timestamp'], 'small'))) . ($revision['history'] ? '<br /><small>'. $revision['history'] .'</small>' : ''), l(t('view'), "node/$node->nid", array(), "revision=$key"), l(t('rollback'), "node/rollback-revision/$node->nid/$key"), l(t('delete'), "node/delete-revision/$node->nid/$key"));
}
$output .= theme('table', $header, $rows);
}
@@ -956,27 +1007,9 @@ function node_admin() {
case 'search':
$output = search_type('node', url('admin/node/search'), $_POST['keys']);
break;
- case 'edit':
- $output = node_admin_edit(arg(3));
- break;
case 'delete':
$output = node_delete(array('nid' => arg(3)));
break;
- case t('Preview'):
- $edit = node_validate($edit, $error);
- $output = node_preview($edit, $error);
- break;
- case t('Submit'):
- $output = node_submit($edit);
- break;
- case t('Delete'):
- $output = node_delete($edit);
- break;
- case t('Save configuration'):
- case t('Reset to defaults'):
- case 'settings':
- $output = node_admin_settings($edit);
- break;
default:
$output = node_admin_nodes();
}
@@ -1018,7 +1051,7 @@ function node_feed($nodes = 0, $channel = array()) {
*/
$item = node_load(array('nid' => $node->nid));
- $link = url("node/view/$node->nid", NULL, NULL, 1);
+ $link = url("node/$node->nid", NULL, NULL, 1);
$items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body), array('pubDate' => date('r', $item->changed)));
}
@@ -1146,7 +1179,6 @@ function node_validate($node, &$error) {
function node_form($edit, $error = NULL) {
-
/*
** Validate the node:
*/
@@ -1321,7 +1353,7 @@ function node_edit($id) {
$node = node_load(array('nid' => $id));
- drupal_set_title(t('Edit %name', array('%name' => node_invoke($node, 'node_name'))));
+ drupal_set_title($node->title);
if (node_access('update', $node)) {
$output = node_form($node);
@@ -1434,7 +1466,7 @@ function node_submit($node) {
if (node_access('update', $node)) {
$node->nid = node_save($node);
- watchdog('special', t('%node-type: updated "%node-title"', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/view/$node->nid"));
+ watchdog('special', t('%node-type: updated "%node-title"', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/$node->nid"));
$msg = t('the %name was updated.', array ('%name' => node_invoke($node, 'node_name')));
}
}
@@ -1447,7 +1479,7 @@ function node_submit($node) {
if (node_access('create', $node)) {
$node->nid = node_save($node);
- watchdog('special', t('%node-type: added "%node-title"', array('%node-type' => t("$node->type"), '%node->title' => $node->title)), l(t('view post'), "node/view/$node->nid"));
+ watchdog('special', t('%node-type: added "%node-title"', array('%node-type' => t("$node->type"), '%node->title' => $node->title)), l(t('view post'), "node/$node->nid"));
$msg = t('your %name was created.', array ('%name' => node_invoke($node, 'node_name')));
}
}
@@ -1519,16 +1551,25 @@ function node_page_default() {
<p>The first thing you will need to do is <a href=\"%register\">create the first account</a>. This account will have full administration rights and will allow you to configure your website. Once logged in, you can visit the <a href=\"%admin\">administration section</a> and <a href=\"%config\">set up your site's configuration</a>.</p>
<p>Drupal comes with various modules, each of which contains a specific piece of functionality. You should visit the <a href=\"%modules\">module list</a> and enable those modules which suit your website's needs.</p>
<p><a href=\"%themes\">Themes</a> handle the presentation of your website. You can use one of the existing themes, modify them or create your own from scratch.</p>
- <p>We suggest you look around the administration section and explore the various options Drupal offers you. For more information, you can refer to the <a href=\"%handbook\">Drupal handbook online</a>.</p>", array('%drupal' => 'http://www.drupal.org/', '%register' => url('user/register'), '%admin' => url('admin'), '%config' => url('admin/system'), '%modules' => url('admin/system/modules'), '%themes' => url('admin/system/themes'), '%handbook' => 'http://www.drupal.org/handbook'));
+ <p>We suggest you look around the administration section and explore the various options Drupal offers you. For more information, you can refer to the <a href=\"%handbook\">Drupal handbook online</a>.</p>", array('%drupal' => 'http://www.drupal.org/', '%register' => url('user/register'), '%admin' => url('admin'), '%config' => url('admin'), '%modules' => url('admin/modules'), '%themes' => url('admin/themes'), '%handbook' => 'http://www.drupal.org/handbook'));
}
return $output;
}
+function node_old_url($nid = 0) {
+ drupal_goto("node/$nid");
+}
+
function node_page() {
$op = $_POST['op'] ? $_POST['op'] : arg(1);
$edit = $_POST['edit'];
+ // Temporary solution - backward compatibility?
+ if (is_numeric($op)) {
+ $op = arg(2) ? arg(2) : 'view';
+ }
+
switch ($op) {
case 'feed':
node_feed();
@@ -1537,15 +1578,7 @@ function node_page() {
print theme('page', node_add(arg(2)));
break;
case 'edit':
- print theme('page', node_edit(arg(2)));
- break;
- case 'view':
- if ($node = node_load(array('nid' => arg(2)), $_GET['revision'])) {
- print theme('page', node_show($node, arg(3)), $node->title);
- }
- else {
- drupal_not_found();
- }
+ print theme('page', node_edit(arg(1)));
break;
case 'revisions':
print theme('page', node_revision_overview(arg(2)), t('Revisions'));
@@ -1558,6 +1591,16 @@ function node_page() {
node_revision_delete(arg(2), arg(3));
print theme('page', node_revision_overview(arg(2)), t('Revisions'));
break;
+ case 'view':
+ if (is_numeric(arg(1))) {
+ if ($node = node_load(array('nid' => arg(1)), $_GET['revision'])) {
+ print theme('page', node_show($node, arg(3)), $node->title);
+ }
+ else {
+ drupal_not_found();
+ }
+ }
+ break;
case t('Preview'):
$edit = node_validate($edit, $error);
print theme('page', node_preview($edit, $error), t('Preview %name', array('%name' => $name)));
diff --git a/modules/node/node.module b/modules/node/node.module
index 74e6e147e..afd41f23b 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -30,7 +30,7 @@ function node_help($section = 'admin/help#node') {
<dt>Score</dt><dd>The score of the node is gotten by the votes it is given.</dd>
<dt>Users</dt><dd>The list of users who have voted on a moderated node.</dd>
<dt>Published</dt><dd>When using Drupal's moderation system a node remains unpublished -- unavaliable to non-moderators -- until it is marked Published.</dd></dl>
- <p>Now that you know what is in a node, here are some of the types of nodes available.</p>", array("%teaser" => url("admin/system/modules/node")));
+ <p>Now that you know what is in a node, here are some of the types of nodes available.</p>", array("%teaser" => url("admin/settings/node")));
if ($mod == 'admin') {
foreach (node_list() as $type) {
@@ -40,10 +40,10 @@ function node_help($section = 'admin/help#node') {
}
break;
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
$output = t('The core that allows content to be submitted to the site.');
break;
- case 'admin/system/modules/node':
+ case 'admin/settings/node':
$output = t('Settings for the core of Drupal. Almost everything is a node so these settings will affect most of the site.');
break;
case 'admin/node':
@@ -52,7 +52,7 @@ function node_help($section = 'admin/help#node') {
case 'admin/node/search':
$output = t("Enter a simple pattern to search for a post. This can include the wildcard character *.<br />For example, a search for \"br*\" might return \"bread bakers\", \"our daily bread\" and \"brenda\".");
break;
- case 'admin/node/settings':
+ case 'admin/settings/node/defaults':
$output = t('This page lets you set the defaults used during creation of nodes for all the different node types.<br /><strong>comment:</strong> Read/write setting for comments.<br /><strong>publish:</strong> Is this node publicly viewable, has it been published?<br /><strong>promote:</strong> Is this node to be promoted to the front page?<br /><strong>moderate:</strong> Does this node need approval before it can be viewed?<br /><strong>static:</strong> Is this node always visible on the front page?<br /><strong>revision:</strong> Will this node go into the revision system allowing multiple versions to be saved?');
break;
@@ -77,7 +77,7 @@ function node_help_page() {
function node_title_list($result, $title = NULL) {
while ($node = db_fetch_object($result)) {
$number = module_invoke('comment', 'num_all', $node->nid);
- $items[] = l($node->title, "node/view/$node->nid", array('title' => format_plural($number, '1 comment', '%count comments')));
+ $items[] = l($node->title, "node/$node->nid", array('title' => format_plural($number, '1 comment', '%count comments')));
}
return theme('node_list', $items, $title);
@@ -484,7 +484,7 @@ function node_save($node) {
}
-function node_view($node, $main = 0, $page = 0) {
+function node_view($node, $teaser = FALSE, $page = FALSE) {
$node = array2object($node);
@@ -496,7 +496,7 @@ function node_view($node, $main = 0, $page = 0) {
$node->body = str_replace('<!--break-->', '', $node->body);
// Allow modules to change $node->body before viewing.
- node_invoke_nodeapi($node, 'view', $main, $page);
+ node_invoke_nodeapi($node, 'view', $teaser, $page);
/*
** The 'view' hook can be implemented to overwrite the default function
@@ -504,7 +504,7 @@ function node_view($node, $main = 0, $page = 0) {
*/
if (node_hook($node, 'view')) {
- return node_invoke($node, 'view', $main, $page);
+ return node_invoke($node, 'view', $teaser, $page);
}
else {
@@ -512,13 +512,13 @@ function node_view($node, $main = 0, $page = 0) {
** Default behavior:
*/
- return theme('node', node_prepare($node, $main), $main, $page);
+ return theme('node', node_prepare($node, $teaser), $teaser, $page);
}
}
-function node_prepare($node, $main = 0) {
+function node_prepare($node, $teaser = FALSE) {
$node->readmore = (strlen($node->teaser) < strlen($node->body));
- if ($main == 0) {
+ if ($teaser == FALSE) {
$node->body = check_output($node->body);
}
else {
@@ -596,12 +596,19 @@ function node_search($keys) {
return array(t('Matching nodes ranked in order of relevance'), $find);
}
-function node_settings() {
+/**
+ * Page callback; presents general node configuration options.
+ */
+function node_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
$output .= form_select(t('Number of posts on main page'), 'default_nodes_main', variable_get('default_nodes_main', 10), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), t('The default maximum number of posts to display per page on overview pages such as the main page.'));
$output .= form_select(t('Length of trimmed posts'), 'teaser_length', variable_get('teaser_length', 600), array(0 => t('Unlimited'), 200 => t('200 characters'), 400 => t('400 characters'), 600 => t('600 characters'), 800 => t('800 characters'), 1000 => t('1000 characters'), 1200 => t('1200 characters'), 1400 => t('1400 characters'), 1600 => t('1600 characters'), 1800 => t('1800 characters'), 2000 => t('2000 characters')), t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited'. Note that this setting will only affect new or updated content and will not affect existing teasers."));
$output .= form_radios(t('Preview post'), 'node_preview', variable_get('node_preview', 0), array(t('Optional'), t('Required')), t('Must users preview posts before submitting?'));
- return $output;
+ print theme('page', system_settings_form($output));
}
function node_comment_mode($nid) {
@@ -625,11 +632,7 @@ function node_link($type, $node = 0, $main = 0) {
}
if ($main == 1 && $node->teaser && $node->readmore) {
- $links[] = l(t('read more'), "node/view/$node->nid", array('title' => t('Read the rest of this posting.'), 'class' => 'read-more'));
- }
-
- if (user_access('administer nodes')) {
- $links[] = l(t('administer'), "admin/node/edit/$node->nid", array('title' => t('Administer this node.')));
+ $links[] = l(t('read more'), "node/$node->nid", array('title' => t('Read the rest of this posting.'), 'class' => 'read-more'));
}
if (user_access('administer nodes') && $node->revisions) {
@@ -637,23 +640,71 @@ function node_link($type, $node = 0, $main = 0) {
}
}
- if ($type == 'system') {
- menu('node/add', t('create content'), 'node_page', 1, MENU_HIDE_NOCHILD);
-
- menu('admin/node', t('content'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED);
- menu('admin/node/help', t('help'), user_access('administer nodes') ? 'node_help_page' : MENU_DENIED, 9);
- menu('admin/node/edit', t('edit post'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/node/settings', t('settings'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 8);
- if (module_exist('search')) {
- menu('admin/node/search', t('search'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 8);
- }
-
- menu('node', t('content'), user_access('access content') ? 'node_page' : MENU_DENIED, 0, MENU_HIDE);
- }
-
return $links;
}
+/**
+ * Implementation of hook_menu().
+ */
+function node_menu() {
+ $items = array();
+
+ $items[] = array('path' => 'admin/node', 'title' => t('content'),
+ 'callback' => 'node_admin',
+ 'access' => user_access('administer nodes'));
+
+ // Tabs:
+ $items[] = array('path' => 'admin/node/configure', 'title' => t('configure'),
+ 'callback' => 'node_configure',
+ 'access' => user_access('administer nodes'),
+ 'type' => MENU_LOCAL_TASK);
+ if (module_exist('search')) {
+ $items[] = array('path' => 'admin/node/search', 'title' => t('search'),
+ 'callback' => 'node_admin',
+ 'access' => user_access('administer nodes'),
+ 'type' => MENU_LOCAL_TASK);
+ }
+
+ // Subtabs:
+ $items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'),
+ 'callback' => 'node_configure',
+ 'access' => user_access('administer nodes'),
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/node/configure/defaults', 'title' => t('default workflow'),
+ 'callback' => 'node_default_settings',
+ 'access' => user_access('administer nodes'),
+ 'type' => MENU_LOCAL_SUBTASK);
+
+ $items[] = array('path' => 'node', 'title' => t('content'),
+ 'callback' => 'node_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'node/add', 'title' => t('create content'),
+ 'callback' => 'node_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_ITEM_GROUPING,
+ 'weight' => 1);
+
+ if (arg(0) == 'node' && is_numeric(arg(1))) {
+ $items[] = array('path' => 'node/'. arg(1), 'title' => t('view'),
+ 'callback' => 'node_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'node/'. arg(1) .'/edit', 'title' => t('edit'),
+ 'callback' => 'node_page',
+ 'access' => user_access('administer nodes'),
+ 'type' => MENU_LOCAL_TASK);
+ }
+
+ // Legacy handler
+ $items[] = array('path' => 'node/view', 'title' => t('view'),
+ 'callback' => 'node_old_url',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+
+ return $items;
+}
+
function node_admin_edit($node) {
if (is_numeric($node)) {
@@ -758,7 +809,7 @@ function node_admin_nodes() {
$header = array(NULL, t('title'), t('type'), t('author'), t('status'), array('data' => t('operations'), 'colspan' => 2));
while ($node = db_fetch_object($result)) {
- $rows[] = array(form_checkbox(NULL, "status][$node->nid", 1, 0), l($node->title, "node/view/$node->nid") .' '. (node_is_new($node->nid, $node->changed) ? theme_mark() : ''), node_invoke($node, 'node_name'), format_name($node), ($node->status ? t('published') : t('not published')), l(t('edit node'), "admin/node/edit/$node->nid"), l(t('delete node'), "admin/node/delete/$node->nid"));
+ $rows[] = array(form_checkbox(NULL, "status][$node->nid", 1, 0), l($node->title, "node/$node->nid") .' '. (node_is_new($node->nid, $node->changed) ? theme_mark() : ''), node_invoke($node, 'node_name'), format_name($node), ($node->status ? t('published') : t('not published')), l(t('edit node'), "node/$node->nid/edit"), l(t('delete node'), "admin/node/delete/$node->nid"));
}
if ($pager = theme('pager', NULL, 50, 0)) {
@@ -770,8 +821,9 @@ function node_admin_nodes() {
return form($output);
}
-function node_admin_settings($edit) {
+function node_default_settings() {
$op = $_POST['op'];
+ $edit = $_POST['edit'];
if ($op == t('Save configuration')) {
/*
@@ -810,8 +862,7 @@ function node_admin_settings($edit) {
$output .= form_submit(t('Save configuration'));
$output .= form_submit(t('Reset to defaults'));
- return form($output);
-
+ print theme('page', form($output));
}
function node_revision_overview($nid) {
@@ -823,7 +874,7 @@ function node_revision_overview($nid) {
$header = array(t('older revisions'), array('colspan' => '3', 'data' => t('operations')));
foreach ($node->revisions as $key => $revision) {
- $rows[] = array(t('revision #%r revised by %u on %d', array('%r' => $key, '%u' => format_name(user_load(array('uid' => $revision['uid']))), '%d' => format_date($revision['timestamp'], 'small'))) . ($revision['history'] ? '<br /><small>'. $revision['history'] .'</small>' : ''), l(t('view'), "node/view/$node->nid", array(), "revision=$key"), l(t('rollback'), "node/rollback-revision/$node->nid/$key"), l(t('delete'), "node/delete-revision/$node->nid/$key"));
+ $rows[] = array(t('revision #%r revised by %u on %d', array('%r' => $key, '%u' => format_name(user_load(array('uid' => $revision['uid']))), '%d' => format_date($revision['timestamp'], 'small'))) . ($revision['history'] ? '<br /><small>'. $revision['history'] .'</small>' : ''), l(t('view'), "node/$node->nid", array(), "revision=$key"), l(t('rollback'), "node/rollback-revision/$node->nid/$key"), l(t('delete'), "node/delete-revision/$node->nid/$key"));
}
$output .= theme('table', $header, $rows);
}
@@ -956,27 +1007,9 @@ function node_admin() {
case 'search':
$output = search_type('node', url('admin/node/search'), $_POST['keys']);
break;
- case 'edit':
- $output = node_admin_edit(arg(3));
- break;
case 'delete':
$output = node_delete(array('nid' => arg(3)));
break;
- case t('Preview'):
- $edit = node_validate($edit, $error);
- $output = node_preview($edit, $error);
- break;
- case t('Submit'):
- $output = node_submit($edit);
- break;
- case t('Delete'):
- $output = node_delete($edit);
- break;
- case t('Save configuration'):
- case t('Reset to defaults'):
- case 'settings':
- $output = node_admin_settings($edit);
- break;
default:
$output = node_admin_nodes();
}
@@ -1018,7 +1051,7 @@ function node_feed($nodes = 0, $channel = array()) {
*/
$item = node_load(array('nid' => $node->nid));
- $link = url("node/view/$node->nid", NULL, NULL, 1);
+ $link = url("node/$node->nid", NULL, NULL, 1);
$items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body), array('pubDate' => date('r', $item->changed)));
}
@@ -1146,7 +1179,6 @@ function node_validate($node, &$error) {
function node_form($edit, $error = NULL) {
-
/*
** Validate the node:
*/
@@ -1321,7 +1353,7 @@ function node_edit($id) {
$node = node_load(array('nid' => $id));
- drupal_set_title(t('Edit %name', array('%name' => node_invoke($node, 'node_name'))));
+ drupal_set_title($node->title);
if (node_access('update', $node)) {
$output = node_form($node);
@@ -1434,7 +1466,7 @@ function node_submit($node) {
if (node_access('update', $node)) {
$node->nid = node_save($node);
- watchdog('special', t('%node-type: updated "%node-title"', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/view/$node->nid"));
+ watchdog('special', t('%node-type: updated "%node-title"', array('%node-type' => t("$node->type"), '%node-title' => $node->title)), l(t('view post'), "node/$node->nid"));
$msg = t('the %name was updated.', array ('%name' => node_invoke($node, 'node_name')));
}
}
@@ -1447,7 +1479,7 @@ function node_submit($node) {
if (node_access('create', $node)) {
$node->nid = node_save($node);
- watchdog('special', t('%node-type: added "%node-title"', array('%node-type' => t("$node->type"), '%node->title' => $node->title)), l(t('view post'), "node/view/$node->nid"));
+ watchdog('special', t('%node-type: added "%node-title"', array('%node-type' => t("$node->type"), '%node->title' => $node->title)), l(t('view post'), "node/$node->nid"));
$msg = t('your %name was created.', array ('%name' => node_invoke($node, 'node_name')));
}
}
@@ -1519,16 +1551,25 @@ function node_page_default() {
<p>The first thing you will need to do is <a href=\"%register\">create the first account</a>. This account will have full administration rights and will allow you to configure your website. Once logged in, you can visit the <a href=\"%admin\">administration section</a> and <a href=\"%config\">set up your site's configuration</a>.</p>
<p>Drupal comes with various modules, each of which contains a specific piece of functionality. You should visit the <a href=\"%modules\">module list</a> and enable those modules which suit your website's needs.</p>
<p><a href=\"%themes\">Themes</a> handle the presentation of your website. You can use one of the existing themes, modify them or create your own from scratch.</p>
- <p>We suggest you look around the administration section and explore the various options Drupal offers you. For more information, you can refer to the <a href=\"%handbook\">Drupal handbook online</a>.</p>", array('%drupal' => 'http://www.drupal.org/', '%register' => url('user/register'), '%admin' => url('admin'), '%config' => url('admin/system'), '%modules' => url('admin/system/modules'), '%themes' => url('admin/system/themes'), '%handbook' => 'http://www.drupal.org/handbook'));
+ <p>We suggest you look around the administration section and explore the various options Drupal offers you. For more information, you can refer to the <a href=\"%handbook\">Drupal handbook online</a>.</p>", array('%drupal' => 'http://www.drupal.org/', '%register' => url('user/register'), '%admin' => url('admin'), '%config' => url('admin'), '%modules' => url('admin/modules'), '%themes' => url('admin/themes'), '%handbook' => 'http://www.drupal.org/handbook'));
}
return $output;
}
+function node_old_url($nid = 0) {
+ drupal_goto("node/$nid");
+}
+
function node_page() {
$op = $_POST['op'] ? $_POST['op'] : arg(1);
$edit = $_POST['edit'];
+ // Temporary solution - backward compatibility?
+ if (is_numeric($op)) {
+ $op = arg(2) ? arg(2) : 'view';
+ }
+
switch ($op) {
case 'feed':
node_feed();
@@ -1537,15 +1578,7 @@ function node_page() {
print theme('page', node_add(arg(2)));
break;
case 'edit':
- print theme('page', node_edit(arg(2)));
- break;
- case 'view':
- if ($node = node_load(array('nid' => arg(2)), $_GET['revision'])) {
- print theme('page', node_show($node, arg(3)), $node->title);
- }
- else {
- drupal_not_found();
- }
+ print theme('page', node_edit(arg(1)));
break;
case 'revisions':
print theme('page', node_revision_overview(arg(2)), t('Revisions'));
@@ -1558,6 +1591,16 @@ function node_page() {
node_revision_delete(arg(2), arg(3));
print theme('page', node_revision_overview(arg(2)), t('Revisions'));
break;
+ case 'view':
+ if (is_numeric(arg(1))) {
+ if ($node = node_load(array('nid' => arg(1)), $_GET['revision'])) {
+ print theme('page', node_show($node, arg(3)), $node->title);
+ }
+ else {
+ drupal_not_found();
+ }
+ }
+ break;
case t('Preview'):
$edit = node_validate($edit, $error);
print theme('page', node_preview($edit, $error), t('Preview %name', array('%name' => $name)));
diff --git a/modules/page.module b/modules/page.module
index 09cb73cc8..930ef20ab 100644
--- a/modules/page.module
+++ b/modules/page.module
@@ -14,7 +14,7 @@ function page_help($section) {
<p><strong>create pages:</strong> Allows a role to create pages. They cannot edit or delete pages, even if they are the authors. You must enable this permission to in order for a role to create a page.</p>
<p><strong>maintain personal pages:</strong> Allows a role to add/edit pages if they own the page. Use this permission if you want users to be able to edit and maintain their own pages.</p>
");
- case 'admin/system/modules#description':
+ 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 just want to add a page with a link in the menu to your site, this is the best choice. Unlike a story, a static page bypasses the submission queue.');
@@ -87,24 +87,13 @@ function page_load($node) {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function page_link($type, $node = 0, $main) {
-
- $links = array();
-
- if ($type == 'system') {
- menu('node/add/page', t('page'), page_access('create', $node) ? MENU_FALLTHROUGH : MENU_DENIED, 0);
- }
-
- if ($type == 'node' && $node->type == 'page') {
- /* Don't display a redundant edit link if they are node administrators */
- if (page_access('update', $node) && !user_access('administer nodes')) {
- $links[] = l(t('edit this page'), "node/edit/$node->nid");
- }
- }
-
- return $links;
+function page_menu() {
+ $items = array();
+ $items[] = array('path' => 'node/add/page', 'title' => t('page'),
+ 'access' => page_access('create', NULL));
+ return $items;
}
/**
@@ -112,7 +101,7 @@ function page_link($type, $node = 0, $main) {
*
* If body is dynamic (using PHP code), the body will be generated.
*/
-function page_content($node, $main = 0) {
+function page_content($node, $teaser = FALSE) {
if ($node->format == 1) {
// PHP type
ob_start();
@@ -122,7 +111,7 @@ function page_content($node, $main = 0) {
}
else {
// Assume HTML type by default
- $node = node_prepare($node, $main);
+ $node = node_prepare($node, $teaser);
}
return $node;
}
@@ -130,11 +119,11 @@ function page_content($node, $main = 0) {
/**
* Implementation of hook_view().
*/
-function page_view($node, $main = 0, $page = 0) {
+function page_view($node, $teaser = FALSE, $page = FALSE) {
// prepare the node content
- $node = page_content($node, $main);
+ $node = page_content($node, $teaser);
// print the node
- return theme('node', $node, $main, $page);
+ return theme('node', $node, $teaser, $page);
}
/**
diff --git a/modules/page/page.module b/modules/page/page.module
index 09cb73cc8..930ef20ab 100644
--- a/modules/page/page.module
+++ b/modules/page/page.module
@@ -14,7 +14,7 @@ function page_help($section) {
<p><strong>create pages:</strong> Allows a role to create pages. They cannot edit or delete pages, even if they are the authors. You must enable this permission to in order for a role to create a page.</p>
<p><strong>maintain personal pages:</strong> Allows a role to add/edit pages if they own the page. Use this permission if you want users to be able to edit and maintain their own pages.</p>
");
- case 'admin/system/modules#description':
+ 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 just want to add a page with a link in the menu to your site, this is the best choice. Unlike a story, a static page bypasses the submission queue.');
@@ -87,24 +87,13 @@ function page_load($node) {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function page_link($type, $node = 0, $main) {
-
- $links = array();
-
- if ($type == 'system') {
- menu('node/add/page', t('page'), page_access('create', $node) ? MENU_FALLTHROUGH : MENU_DENIED, 0);
- }
-
- if ($type == 'node' && $node->type == 'page') {
- /* Don't display a redundant edit link if they are node administrators */
- if (page_access('update', $node) && !user_access('administer nodes')) {
- $links[] = l(t('edit this page'), "node/edit/$node->nid");
- }
- }
-
- return $links;
+function page_menu() {
+ $items = array();
+ $items[] = array('path' => 'node/add/page', 'title' => t('page'),
+ 'access' => page_access('create', NULL));
+ return $items;
}
/**
@@ -112,7 +101,7 @@ function page_link($type, $node = 0, $main) {
*
* If body is dynamic (using PHP code), the body will be generated.
*/
-function page_content($node, $main = 0) {
+function page_content($node, $teaser = FALSE) {
if ($node->format == 1) {
// PHP type
ob_start();
@@ -122,7 +111,7 @@ function page_content($node, $main = 0) {
}
else {
// Assume HTML type by default
- $node = node_prepare($node, $main);
+ $node = node_prepare($node, $teaser);
}
return $node;
}
@@ -130,11 +119,11 @@ function page_content($node, $main = 0) {
/**
* Implementation of hook_view().
*/
-function page_view($node, $main = 0, $page = 0) {
+function page_view($node, $teaser = FALSE, $page = FALSE) {
// prepare the node content
- $node = page_content($node, $main);
+ $node = page_content($node, $teaser);
// print the node
- return theme('node', $node, $main, $page);
+ return theme('node', $node, $teaser, $page);
}
/**
diff --git a/modules/path.module b/modules/path.module
index d72c56690..04bb8e9ac 100644
--- a/modules/path.module
+++ b/modules/path.module
@@ -6,7 +6,7 @@
*/
function path_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables users to create custom URLs.');
case 'admin/path':
return t('Drupal provides users complete control over URLs through aliasing. While the original Drupal URLs are always created and accessible, advanced users have the option to override these normal paths.');
@@ -23,7 +23,7 @@ image/tid/16 => store
taxonomy/page/or/7,19,20,21 => store/products/whirlygigs
-node/view/3 => contact
+node/3 => contact
</pre>
<p>This functionality integrates seamlessly into node forms and also provides the administrator an interface to view all aliases that have been created.</p>
<p>Aliases have a 1 to 1 relationship with their original Drupal URLs. In other words you cannot have an alias map to more than one path. Likewise, a Drupal URL can't be mapped to more than one alias.</p>
@@ -37,30 +37,41 @@ node/view/3 => contact
<pre>
function conf_url_rewrite(\$path, \$mode = 'incoming') {
if (\$mode == 'incoming') { // URL coming from a client
- return preg_replace('!^display/(\\d+)\$!', 'node/view/\\1', \$path);
+ return preg_replace('!^display/(\\d+)\$!', 'node/\\1', \$path);
}
else { // URL going out to a client
- \$aliased = preg_replace('!^node/view/(\\d+)\$!', 'display/\\1', \$path);
+ \$aliased = preg_replace('!^node/(\\d+)\$!', 'display/\\1', \$path);
if (\$aliased != \$path) { return \$aliased; }
}
}
</pre>
-<p>This function will shorten every <code>node/view/\$node_id</code> type of URL to <code>display/\$node_id</code>. Individual URL aliases defined on the browser interface of Drupal take precedence, so if you have the 'contact' page alias from the example above, then the <code>display/3</code> alias will not be effective when outgoing links are created. Incoming URLs however always work with the mass URL aliased variant. Only the 'incoming' and 'outgoing' modes are supposed to be supported by your <code>conf_url_rewrite</code> function.</p>
-<p>You cannot only use this feature to shorten the URLs, or to translate them to you own language, but also to add completely new subURLs to an already existing module's URL space, or to compose a bunch of existing stuff together to a common URL space. You can create a <code>news</code> section for example aliasing nodes and taxonomy overview pages falling under a 'news' vocabulary, thus having <code>news/15</code> and <code>news/sections/3</code> instead of <code>node/view/15</code> and <code>taxonomy/view/or/3</code>. You need extensive knowledge of Drupal's inner workings and regular expressions though to make such advanced aliases.</p>");
+<p>This function will shorten every <code>node/\$node_id</code> type of URL to <code>display/\$node_id</code>. Individual URL aliases defined on the browser interface of Drupal take precedence, so if you have the 'contact' page alias from the example above, then the <code>display/3</code> alias will not be effective when outgoing links are created. Incoming URLs however always work with the mass URL aliased variant. Only the 'incoming' and 'outgoing' modes are supposed to be supported by your <code>conf_url_rewrite</code> function.</p>
+<p>You cannot only use this feature to shorten the URLs, or to translate them to you own language, but also to add completely new subURLs to an already existing module's URL space, or to compose a bunch of existing stuff together to a common URL space. You can create a <code>news</code> section for example aliasing nodes and taxonomy overview pages falling under a 'news' vocabulary, thus having <code>news/15</code> and <code>news/sections/3</code> instead of <code>node/15</code> and <code>taxonomy/view/or/3</code>. You need extensive knowledge of Drupal's inner workings and regular expressions though to make such advanced aliases.</p>");
}
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function path_link($type, $node = NULL) {
- if ($type == 'system') {
- menu('admin/path', t('url aliasing'), user_access('administer url aliases') ? 'path_admin' : MENU_DENIED, 4);
- menu('admin/path/add', t('new alias'), user_access('administer url aliases') ? 'path_admin_edit' : MENU_DENIED);
- menu('admin/path/edit', t('edit alias'), user_access('administer url aliases') ? 'path_admin_edit' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/path/delete', t('delete alias'), user_access('administer url aliases') ? 'path_admin_delete' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/path/help', t('help'), user_access('administer url aliases') ? 'path_admin_help' : MENU_DENIED, 9);
- }
+function path_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/path', 'title' => t('url aliasing'),
+ 'callback' => 'path_admin',
+ 'access' => user_access('administer url aliases'));
+ $items[] = array('path' => 'admin/path/edit', 'title' => t('edit alias'),
+ 'callback' => 'path_admin_edit',
+ 'access' => user_access('administer url aliases'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/path/delete', 'title' => t('delete alias'),
+ 'callback' => 'path_admin_delete',
+ 'access' => user_access('administer url aliases'),
+ 'type' => MENU_CALLBACK);
+ // Tabs:
+ $items[] = array('path' => 'admin/path/add', 'title' => t('add alias'),
+ 'callback' => 'path_admin_edit',
+ 'access' => user_access('administer url aliases'),
+ 'type' => MENU_LOCAL_TASK);
+ return $items;
}
/**
@@ -146,7 +157,7 @@ function path_set_alias($path = NULL, $alias = NULL) {
*/
function path_form($edit = '') {
- $form .= form_textfield(t('Existing path'), 'src', $edit['src'], 50, 64, t('Specify the existing path you wish to alias. For example: node/view/28, forum/1, taxonomy/page/or/1,2.'));
+ $form .= form_textfield(t('Existing path'), 'src', $edit['src'], 50, 64, t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/page/or/1,2.'));
$form .= form_textfield(t('New path alias'), 'dst', $edit['dst'], 50, 64, t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'));
if ($edit['pid']) {
@@ -175,7 +186,7 @@ function path_nodeapi(&$node, $op, $arg) {
// viewing of the form. If it is the first time, load the alias, if it isn't
// (i.e., user has clicked preview) let them work with their current form alias.
if (is_null($node->path)) {
- $path = "node/view/$node->nid";
+ $path = "node/$node->nid";
$alias = drupal_get_path_alias($path);
if ($alias != $path) {
$node->path = $alias;
@@ -187,7 +198,7 @@ function path_nodeapi(&$node, $op, $arg) {
$error['path'] = t('The path is invalid.');
return $error;
}
- else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/view/$node->nid"))) {
+ else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) {
$error['path'] = t('The path is already in use.');
return $error;
}
@@ -201,15 +212,15 @@ function path_nodeapi(&$node, $op, $arg) {
// Don't try to insert if path is NULL. We may have already set
// the alias ahead of time.
if ($node->path) {
- path_set_alias("node/view/$node->nid", $node->path);
+ path_set_alias("node/$node->nid", $node->path);
}
break;
case 'update':
- path_set_alias("node/view/$node->nid", $node->path);
+ path_set_alias("node/$node->nid", $node->path);
break;
case 'delete':
- $path = "node/view/$node->nid";
+ $path = "node/$node->nid";
if (drupal_get_path_alias($path) != $path) {
path_set_alias($path);
}
diff --git a/modules/path/path.module b/modules/path/path.module
index d72c56690..04bb8e9ac 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -6,7 +6,7 @@
*/
function path_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables users to create custom URLs.');
case 'admin/path':
return t('Drupal provides users complete control over URLs through aliasing. While the original Drupal URLs are always created and accessible, advanced users have the option to override these normal paths.');
@@ -23,7 +23,7 @@ image/tid/16 => store
taxonomy/page/or/7,19,20,21 => store/products/whirlygigs
-node/view/3 => contact
+node/3 => contact
</pre>
<p>This functionality integrates seamlessly into node forms and also provides the administrator an interface to view all aliases that have been created.</p>
<p>Aliases have a 1 to 1 relationship with their original Drupal URLs. In other words you cannot have an alias map to more than one path. Likewise, a Drupal URL can't be mapped to more than one alias.</p>
@@ -37,30 +37,41 @@ node/view/3 => contact
<pre>
function conf_url_rewrite(\$path, \$mode = 'incoming') {
if (\$mode == 'incoming') { // URL coming from a client
- return preg_replace('!^display/(\\d+)\$!', 'node/view/\\1', \$path);
+ return preg_replace('!^display/(\\d+)\$!', 'node/\\1', \$path);
}
else { // URL going out to a client
- \$aliased = preg_replace('!^node/view/(\\d+)\$!', 'display/\\1', \$path);
+ \$aliased = preg_replace('!^node/(\\d+)\$!', 'display/\\1', \$path);
if (\$aliased != \$path) { return \$aliased; }
}
}
</pre>
-<p>This function will shorten every <code>node/view/\$node_id</code> type of URL to <code>display/\$node_id</code>. Individual URL aliases defined on the browser interface of Drupal take precedence, so if you have the 'contact' page alias from the example above, then the <code>display/3</code> alias will not be effective when outgoing links are created. Incoming URLs however always work with the mass URL aliased variant. Only the 'incoming' and 'outgoing' modes are supposed to be supported by your <code>conf_url_rewrite</code> function.</p>
-<p>You cannot only use this feature to shorten the URLs, or to translate them to you own language, but also to add completely new subURLs to an already existing module's URL space, or to compose a bunch of existing stuff together to a common URL space. You can create a <code>news</code> section for example aliasing nodes and taxonomy overview pages falling under a 'news' vocabulary, thus having <code>news/15</code> and <code>news/sections/3</code> instead of <code>node/view/15</code> and <code>taxonomy/view/or/3</code>. You need extensive knowledge of Drupal's inner workings and regular expressions though to make such advanced aliases.</p>");
+<p>This function will shorten every <code>node/\$node_id</code> type of URL to <code>display/\$node_id</code>. Individual URL aliases defined on the browser interface of Drupal take precedence, so if you have the 'contact' page alias from the example above, then the <code>display/3</code> alias will not be effective when outgoing links are created. Incoming URLs however always work with the mass URL aliased variant. Only the 'incoming' and 'outgoing' modes are supposed to be supported by your <code>conf_url_rewrite</code> function.</p>
+<p>You cannot only use this feature to shorten the URLs, or to translate them to you own language, but also to add completely new subURLs to an already existing module's URL space, or to compose a bunch of existing stuff together to a common URL space. You can create a <code>news</code> section for example aliasing nodes and taxonomy overview pages falling under a 'news' vocabulary, thus having <code>news/15</code> and <code>news/sections/3</code> instead of <code>node/15</code> and <code>taxonomy/view/or/3</code>. You need extensive knowledge of Drupal's inner workings and regular expressions though to make such advanced aliases.</p>");
}
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function path_link($type, $node = NULL) {
- if ($type == 'system') {
- menu('admin/path', t('url aliasing'), user_access('administer url aliases') ? 'path_admin' : MENU_DENIED, 4);
- menu('admin/path/add', t('new alias'), user_access('administer url aliases') ? 'path_admin_edit' : MENU_DENIED);
- menu('admin/path/edit', t('edit alias'), user_access('administer url aliases') ? 'path_admin_edit' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/path/delete', t('delete alias'), user_access('administer url aliases') ? 'path_admin_delete' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/path/help', t('help'), user_access('administer url aliases') ? 'path_admin_help' : MENU_DENIED, 9);
- }
+function path_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/path', 'title' => t('url aliasing'),
+ 'callback' => 'path_admin',
+ 'access' => user_access('administer url aliases'));
+ $items[] = array('path' => 'admin/path/edit', 'title' => t('edit alias'),
+ 'callback' => 'path_admin_edit',
+ 'access' => user_access('administer url aliases'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/path/delete', 'title' => t('delete alias'),
+ 'callback' => 'path_admin_delete',
+ 'access' => user_access('administer url aliases'),
+ 'type' => MENU_CALLBACK);
+ // Tabs:
+ $items[] = array('path' => 'admin/path/add', 'title' => t('add alias'),
+ 'callback' => 'path_admin_edit',
+ 'access' => user_access('administer url aliases'),
+ 'type' => MENU_LOCAL_TASK);
+ return $items;
}
/**
@@ -146,7 +157,7 @@ function path_set_alias($path = NULL, $alias = NULL) {
*/
function path_form($edit = '') {
- $form .= form_textfield(t('Existing path'), 'src', $edit['src'], 50, 64, t('Specify the existing path you wish to alias. For example: node/view/28, forum/1, taxonomy/page/or/1,2.'));
+ $form .= form_textfield(t('Existing path'), 'src', $edit['src'], 50, 64, t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/page/or/1,2.'));
$form .= form_textfield(t('New path alias'), 'dst', $edit['dst'], 50, 64, t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'));
if ($edit['pid']) {
@@ -175,7 +186,7 @@ function path_nodeapi(&$node, $op, $arg) {
// viewing of the form. If it is the first time, load the alias, if it isn't
// (i.e., user has clicked preview) let them work with their current form alias.
if (is_null($node->path)) {
- $path = "node/view/$node->nid";
+ $path = "node/$node->nid";
$alias = drupal_get_path_alias($path);
if ($alias != $path) {
$node->path = $alias;
@@ -187,7 +198,7 @@ function path_nodeapi(&$node, $op, $arg) {
$error['path'] = t('The path is invalid.');
return $error;
}
- else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/view/$node->nid"))) {
+ else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) {
$error['path'] = t('The path is already in use.');
return $error;
}
@@ -201,15 +212,15 @@ function path_nodeapi(&$node, $op, $arg) {
// Don't try to insert if path is NULL. We may have already set
// the alias ahead of time.
if ($node->path) {
- path_set_alias("node/view/$node->nid", $node->path);
+ path_set_alias("node/$node->nid", $node->path);
}
break;
case 'update':
- path_set_alias("node/view/$node->nid", $node->path);
+ path_set_alias("node/$node->nid", $node->path);
break;
case 'delete':
- $path = "node/view/$node->nid";
+ $path = "node/$node->nid";
if (drupal_get_path_alias($path) != $path) {
path_set_alias($path);
}
diff --git a/modules/ping.module b/modules/ping.module
index 4e363bb11..880886c5a 100644
--- a/modules/ping.module
+++ b/modules/ping.module
@@ -15,7 +15,7 @@ function ping_help($section) {
<p>The ping feature requires crontab.</p>", array('%weblogs' => '<a href="http://www.weblogs.com/">Weblogs.com</a>', '%weblogs-XML' => '<a href="http://www.xmlrpc.com/weblogsCom/">'. t('XML-RPC interface of weblogs.com') .'</a>', '%weblogs-RSS' => '<a href="http://www.xmlrpc.com/weblogsComForRSS">'. t('Weblogs.Com for RSS') .'</a>', '%weblogs-RSS-changes' => '<a href="http://www.weblogs.com/rssUpdates/changes.xml">'. t('the weblogs.com for RSS') .'</a>', '%blo-gs' => '<a href="http://blo.gs/">blo.gs</a>', '%blogtracker' => '<a href="http://www.dansanderson.com/blogtracker">blogtracker</a>', '%blogrolling' => '<a href="http://www.blogrolling.com">blogrolling.com</a>', '%blo-gs-XML' => '<a href="http://blo.gs/ping.php">'. t('XML-RPC interface of blo.gs') .'</a>'));
break;
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
$output = t('Alerts other sites that your site has been updated.');
break;
}
diff --git a/modules/ping/ping.module b/modules/ping/ping.module
index 4e363bb11..880886c5a 100644
--- a/modules/ping/ping.module
+++ b/modules/ping/ping.module
@@ -15,7 +15,7 @@ function ping_help($section) {
<p>The ping feature requires crontab.</p>", array('%weblogs' => '<a href="http://www.weblogs.com/">Weblogs.com</a>', '%weblogs-XML' => '<a href="http://www.xmlrpc.com/weblogsCom/">'. t('XML-RPC interface of weblogs.com') .'</a>', '%weblogs-RSS' => '<a href="http://www.xmlrpc.com/weblogsComForRSS">'. t('Weblogs.Com for RSS') .'</a>', '%weblogs-RSS-changes' => '<a href="http://www.weblogs.com/rssUpdates/changes.xml">'. t('the weblogs.com for RSS') .'</a>', '%blo-gs' => '<a href="http://blo.gs/">blo.gs</a>', '%blogtracker' => '<a href="http://www.dansanderson.com/blogtracker">blogtracker</a>', '%blogrolling' => '<a href="http://www.blogrolling.com">blogrolling.com</a>', '%blo-gs-XML' => '<a href="http://blo.gs/ping.php">'. t('XML-RPC interface of blo.gs') .'</a>'));
break;
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
$output = t('Alerts other sites that your site has been updated.');
break;
}
diff --git a/modules/poll.module b/modules/poll.module
index c63fd6f6a..757f183a1 100644
--- a/modules/poll.module
+++ b/modules/poll.module
@@ -16,7 +16,7 @@ function poll_help($section) {
<li>To administer polls you need the \"administer nodes\" permission.</li>
</ul>
<p>Creating a poll is much like creating any other node. Click \"create poll\" in your user box. The title of the poll should be the question, then enter the answers and the \"base\" vote counts. You can also choose the time period over which the vote will run.</p><p>The <a href=\"%poll\">Poll</a> item in the navigation links will take you to a page where you can see all the current polls, vote on them (if you haven't already) and view the results.</p>", array("%permissions" => url("admin/user/permission"), "%poll" => url("poll")));
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t("Enables your site to capture votes on different topics in the form of multiple choice questions.");
case 'node/add#poll':
return t("A poll is a multiple-choice question which visitors can vote on.");
@@ -185,11 +185,7 @@ function poll_insert($node) {
function poll_link($type, $node = 0, $main) {
$links = array();
- if ($type == 'system') {
- menu('node/add/poll', t('poll'), user_access('create polls') ? MENU_FALLTHROUGH : MENU_DENIED, 0);
- menu('poll', t('polls'), user_access('access content') ? 'poll_page' : MENU_DENIED, 0, MENU_HIDE);
- }
- else if ($type == 'page' && user_access('access content')) {
+ if ($type == 'page' && user_access('access content')) {
$links[] = l(t('polls'), 'poll', array('title' => t('View the list of polls on this site.')));
}
else if ($type == 'node' && $node->type == 'poll') {
@@ -200,10 +196,10 @@ function poll_link($type, $node = 0, $main) {
if ($node->allowvotes) {
if (arg(3) == 'results') {
- $links[] = l(t('voting form'), 'node/view/'. $node->nid);
+ $links[] = l(t('voting form'), 'node/'. $node->nid);
}
else {
- $links[] = l(t('view results'), 'node/view/'. $node->nid .'/results');
+ $links[] = l(t('view results'), 'node/'. $node->nid .'/results');
}
}
}
@@ -212,6 +208,20 @@ function poll_link($type, $node = 0, $main) {
}
/**
+ * Implementation of hook_menu().
+ */
+function poll_menu() {
+ $items = array();
+ $items[] = array('path' => 'node/add/poll', 'title' => t('poll'),
+ 'access' => user_access('create polls'));
+ $items[] = array('path' => 'poll', 'title' => t('polls'),
+ 'callback' => 'poll_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ return $items;
+}
+
+/**
* Determine an adjusted user id, to allow for basic tracking of anonymous
* users (IP-based).
*/
@@ -261,7 +271,7 @@ function poll_page() {
$result = pager_query("SELECT n.nid, n.title, p.active, SUM(c.chvotes) AS votes FROM {node} n INNER JOIN {poll} p ON n.nid=p.nid INNER JOIN {poll_choices} c ON n.nid=c.nid WHERE type = 'poll' AND status = '1' AND moderate = '0' GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC", 15);
$output = '<ul>';
while ($node = db_fetch_object($result)) {
- $output .= '<li>'. l($node->title, "node/view/$node->nid") .' - '. format_plural($node->votes, '1 vote', '%count votes') .' - '. ($node->active ? t('open') : t('closed')) .'</li>';
+ $output .= '<li>'. l($node->title, "node/$node->nid") .' - '. format_plural($node->votes, '1 vote', '%count votes') .' - '. ($node->active ? t('open') : t('closed')) .'</li>';
}
$output .= '</ul>';
$output .= theme("pager", NULL, 15);
@@ -307,7 +317,7 @@ function poll_view_voting(&$node, $main, $page, $block) {
$form .= form_hidden('nid', $node->nid);
$form .= form_submit(t('Vote'), 'vote') .'</div>';
- $output .= form($form, 'post', url('node/view/'. $node->nid));
+ $output .= form($form, 'post', url('node/'. $node->nid));
$output .= '</div>';
return $output;
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index c63fd6f6a..757f183a1 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -16,7 +16,7 @@ function poll_help($section) {
<li>To administer polls you need the \"administer nodes\" permission.</li>
</ul>
<p>Creating a poll is much like creating any other node. Click \"create poll\" in your user box. The title of the poll should be the question, then enter the answers and the \"base\" vote counts. You can also choose the time period over which the vote will run.</p><p>The <a href=\"%poll\">Poll</a> item in the navigation links will take you to a page where you can see all the current polls, vote on them (if you haven't already) and view the results.</p>", array("%permissions" => url("admin/user/permission"), "%poll" => url("poll")));
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t("Enables your site to capture votes on different topics in the form of multiple choice questions.");
case 'node/add#poll':
return t("A poll is a multiple-choice question which visitors can vote on.");
@@ -185,11 +185,7 @@ function poll_insert($node) {
function poll_link($type, $node = 0, $main) {
$links = array();
- if ($type == 'system') {
- menu('node/add/poll', t('poll'), user_access('create polls') ? MENU_FALLTHROUGH : MENU_DENIED, 0);
- menu('poll', t('polls'), user_access('access content') ? 'poll_page' : MENU_DENIED, 0, MENU_HIDE);
- }
- else if ($type == 'page' && user_access('access content')) {
+ if ($type == 'page' && user_access('access content')) {
$links[] = l(t('polls'), 'poll', array('title' => t('View the list of polls on this site.')));
}
else if ($type == 'node' && $node->type == 'poll') {
@@ -200,10 +196,10 @@ function poll_link($type, $node = 0, $main) {
if ($node->allowvotes) {
if (arg(3) == 'results') {
- $links[] = l(t('voting form'), 'node/view/'. $node->nid);
+ $links[] = l(t('voting form'), 'node/'. $node->nid);
}
else {
- $links[] = l(t('view results'), 'node/view/'. $node->nid .'/results');
+ $links[] = l(t('view results'), 'node/'. $node->nid .'/results');
}
}
}
@@ -212,6 +208,20 @@ function poll_link($type, $node = 0, $main) {
}
/**
+ * Implementation of hook_menu().
+ */
+function poll_menu() {
+ $items = array();
+ $items[] = array('path' => 'node/add/poll', 'title' => t('poll'),
+ 'access' => user_access('create polls'));
+ $items[] = array('path' => 'poll', 'title' => t('polls'),
+ 'callback' => 'poll_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ return $items;
+}
+
+/**
* Determine an adjusted user id, to allow for basic tracking of anonymous
* users (IP-based).
*/
@@ -261,7 +271,7 @@ function poll_page() {
$result = pager_query("SELECT n.nid, n.title, p.active, SUM(c.chvotes) AS votes FROM {node} n INNER JOIN {poll} p ON n.nid=p.nid INNER JOIN {poll_choices} c ON n.nid=c.nid WHERE type = 'poll' AND status = '1' AND moderate = '0' GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC", 15);
$output = '<ul>';
while ($node = db_fetch_object($result)) {
- $output .= '<li>'. l($node->title, "node/view/$node->nid") .' - '. format_plural($node->votes, '1 vote', '%count votes') .' - '. ($node->active ? t('open') : t('closed')) .'</li>';
+ $output .= '<li>'. l($node->title, "node/$node->nid") .' - '. format_plural($node->votes, '1 vote', '%count votes') .' - '. ($node->active ? t('open') : t('closed')) .'</li>';
}
$output .= '</ul>';
$output .= theme("pager", NULL, 15);
@@ -307,7 +317,7 @@ function poll_view_voting(&$node, $main, $page, $block) {
$form .= form_hidden('nid', $node->nid);
$form .= form_submit(t('Vote'), 'vote') .'</div>';
- $output .= form($form, 'post', url('node/view/'. $node->nid));
+ $output .= form($form, 'post', url('node/'. $node->nid));
$output .= '</div>';
return $output;
diff --git a/modules/profile.module b/modules/profile.module
index 9663342d3..d3b2c6201 100644
--- a/modules/profile.module
+++ b/modules/profile.module
@@ -3,31 +3,47 @@
// TODO: add a 'date' field so we can migrate the birthday information.
+/**
+ * Implementation of hook_help().
+ */
function profile_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
- $output = t("Support for configurable user profiles.");
- break;
+ case 'admin/modules#description':
+ return t('Support for configurable user profiles.');
}
- return $output;
-
-
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function profile_link($type) {
- if ($type == 'system') {
- menu('profile', t('browse'), 'profile_browse', 0, MENU_HIDE);
-
- menu('admin/system/modules/profile', t('profile'), user_access('administer users') ? 'profile_admin_overview' : MENU_DENIED);
- menu('admin/system/modules/profile/add', NULL, user_access('administer users') ? 'profile_admin_add' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/system/modules/profile/edit', NULL, user_access('administer users') ? 'profile_admin_edit' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/system/modules/profile/delete', NULL, user_access('administer users') ? 'profile_admin_delete' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
+function profile_menu() {
+ $items = array();
+ $items[] = array('path' => 'profile', 'title' => t('browse'),
+ 'callback' => 'profile_browse',
+ 'access' => TRUE,
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'admin/user/configure/profile', 'title' => t('profiles'),
+ 'callback' => 'profile_admin_overview',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/profile/add', 'title' => t('add field'),
+ 'callback' => 'profile_browse',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/user/configure/profile/edit', 'title' => t('edit field'),
+ 'callback' => 'profile_browse',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/user/configure/profile/delete', 'title' => t('delete field'),
+ 'callback' => 'profile_browse',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_CALLBACK);
+ return $items;
}
+/**
+ * Menu callback; display a list of user information.
+ */
function profile_browse() {
$name = strip_tags(arg(1));
@@ -38,7 +54,7 @@ function profile_browse() {
if ($field->fid) {
// Compile a list of fields to show
$fields = array();
- $result = db_query("SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1", $field->fid);
+ $result = db_query('SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1', $field->fid);
while ($record = db_fetch_object($result)) {
$fields[] = $record;
}
@@ -71,7 +87,7 @@ function profile_browse() {
else {
$title = $field->page;
}
- $output .= "</div>";
+ $output .= '</div>';
print theme('page', $output, $title);
}
@@ -111,7 +127,7 @@ function profile_view_field($user, $field) {
case 'checkbox':
return l($field->title, "profile/$field->name");
case 'url':
- return "<a href=\"". check_url(strip_tags($value)) ."\">". strip_tags($value) ."</a>"; case 'list':
+ return '<a href="'. check_url(strip_tags($value)) .'">'. strip_tags($value) .'</a>'; case 'list':
$values = split("[\n\r]", $value);
$fields = array();
foreach ($values as $value) {
@@ -157,7 +173,7 @@ function profile_edit_profile($edit, $user) {
$fields[$field->category] .= form_textarea($field->title, $field->name, $edit[$field->name], 60, 5, $field->explanation, NULL, $field->required);
break;
case 'list':
- $fields[$field->category] .= form_textarea($field->title, $field->name, $edit[$field->name], 60, 5, $field->explanation ." ". t('Put each entry on a separate line. No HTML allowed.'), NULL, $field->required);
+ $fields[$field->category] .= form_textarea($field->title, $field->name, $edit[$field->name], 60, 5, $field->explanation .' '. t('Put each entry on a separate line. No HTML allowed.'), NULL, $field->required);
break;
case 'checkbox':
$fields[$field->category] .= form_checkbox($field->title, $field->name, 1, $edit[$field->name], $field->explanation, NULL, $field->required);
@@ -185,17 +201,20 @@ function profile_validate_profile($edit) {
while ($field = db_fetch_object($result)) {
if ($edit[$field->name]) {
if ($field->type == 'url' && !valid_url($edit[$field->name], true)) {
- form_set_error($field->name, t("The value provided for '%field' is not a valid URL.", array('%field' => $field->title)));
+ form_set_error($field->name, t('The value provided for "%field" is not a valid URL.', array('%field' => $field->title)));
}
}
else if ($field->required) {
- form_set_error($field->name, t("The field '%field' is required.", array('%field' => $field->title)));
+ form_set_error($field->name, t('The field "%field" is required.', array('%field' => $field->title)));
}
}
return $edit;
}
+/**
+ * Implementation of hook_user().
+ */
function profile_user($type, &$edit, &$user) {
switch ($type) {
case 'load':
@@ -236,6 +255,9 @@ function profile_validate_form($edit) {
}
}
+/**
+ * Menu callback; adds a new field to all user profiles.
+ */
function profile_admin_add($type) {
$type = _profile_field_types($type);
@@ -267,6 +289,9 @@ function profile_admin_add($type) {
print theme('page', _profile_field_form($type, $data), t('Add new %type', array('%type' => $type)));
}
+/**
+ * Menu callback; displays the profile field editing form.
+ */
function profile_admin_edit($fid) {
if ($_POST['op']) {
@@ -288,6 +313,9 @@ function profile_admin_edit($fid) {
print theme('page', _profile_field_form($data['type'], $data), t('Edit %type', array('%type' => $edit['type'])));
}
+/**
+ * Menu callback; deletes a field from all user profiles.
+ */
function profile_admin_delete($fid) {
db_query('DELETE FROM {profile_fields} WHERE fid = %d', $fid);
drupal_set_message(t('the field has been deleted.'));
@@ -296,24 +324,24 @@ function profile_admin_delete($fid) {
function _profile_field_form($type, $edit = array()) {
- $group = form_textfield(t('Category'), 'category', $edit['category'], 70, 128, t("The category the new field should be part of. Categories are used to group fields logically. An example category is 'Personal information'."));
- $group .= form_textfield(t('Title'), 'title', $edit['title'], 70, 128, t("The title of the new field. The title will be shown to the user. An example title is 'Favorite color'."));
- $group .= form_textfield(t('Form name'), 'name', $edit['name'], 70, 128, t("The name of the field. The form name is not shown to the user but used internally in the HTML code and URLs.
-Unless you know what you are doing, it is highly recommended that you prefix the form name with <code>profile_</code> to avoid name clashes with other fields. Spaces or any other special characters except dash (-) and underscore (_) are not allowed. An example name is 'profile_favorite_color' or perhaps just 'profile_color'."));
- $group .= form_textarea(t('Explanation'), 'explanation', $edit['explanation'], 70, 3, t("An optional explanation to go with the new field. The explanation will be shown to the user."));
+ $group = form_textfield(t('Category'), 'category', $edit['category'], 70, 128, t('The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".'));
+ $group .= form_textfield(t('Title'), 'title', $edit['title'], 70, 128, t('The title of the new field. The title will be shown to the user. An example title is "Favorite color".'));
+ $group .= form_textfield(t('Form name'), 'name', $edit['name'], 70, 128, t('The name of the field. The form name is not shown to the user but used internally in the HTML code and URLs.
+Unless you know what you are doing, it is highly recommended that you prefix the form name with <code>profile_</code> to avoid name clashes with other fields. Spaces or any other special characters except dash (-) and underscore (_) are not allowed. An example name is "profile_favorite_color" or perhaps just "profile_color".'));
+ $group .= form_textarea(t('Explanation'), 'explanation', $edit['explanation'], 70, 3, t('An optional explanation to go with the new field. The explanation will be shown to the user.'));
if ($type == 'selection') {
- $group .= form_textarea(t('Selection options'), 'options', $edit['options'], 70, 8, t("A list of all options. Put each option on a separate line. Example options are 'red', 'blue', 'green', etc."));
+ $group .= form_textarea(t('Selection options'), 'options', $edit['options'], 70, 8, t('A list of all options. Put each option on a separate line. Example options are "red", "blue", "green", etc.'));
}
- $group .= form_weight(t('Weight'), 'weight', $edit['weight'], 5, t("The weights define the order in which the form fields are shown. Lighter fields \"float up\" towards the top of the category."));
+ $group .= form_weight(t('Weight'), 'weight', $edit['weight'], 5, t('The weights define the order in which the form fields are shown. Lighter fields "float up" towards the top of the category.'));
$group .= form_checkbox(t('Required field.'), 'required', 1, $edit['required']);
$output = form_group(t('Field settings'), $group);
$group = '';
if ($type == 'selection' || $type == 'list') {
- $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t("The title of the page showing all users with the specified field. The word <code>%value</code> will be substituted with the corresponding value. An example page title is 'People whose favorite color is %value'."));
+ $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t('The title of the page showing all users with the specified field. The word <code>%value</code> will be substituted with the corresponding value. An example page title is "People whose favorite color is %value".'));
}
else {
- $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t("The title of the page showing all users with the specified field."));
+ $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t('The title of the page showing all users with the specified field.'));
}
$group .= form_checkbox(t('Should this field be shown on the member listing pages.'), 'overview', 1, $edit['overview']);
@@ -323,11 +351,14 @@ Unless you know what you are doing, it is highly recommended that you prefix the
return form($output);
}
+/**
+ * Menu callback; display a listing of all editable profile fields.
+ */
function profile_admin_overview() {
$result = db_query('SELECT * FROM {profile_fields} ORDER BY category, weight');
while ($field = db_fetch_object($result)) {
- $rows[] = array($field->title, $field->name, $field->type, $field->category, l(t('edit'), "admin/system/modules/profile/edit/$field->fid"), l(t('delete'), "admin/system/modules/profile/delete/$field->fid"));
+ $rows[] = array($field->title, $field->name, $field->type, $field->category, l(t('edit'), "admin/user/configure/profile/edit/$field->fid"), l(t('delete'), "admin/user/configure/profile/delete/$field->fid"));
}
$header = array(t('title'), t('name'), t('type'), t('category'), array('data' => t('operations'), 'colspan' => '2'));
@@ -336,7 +367,7 @@ function profile_admin_overview() {
$output .= '<h2>'. t('Create new field') .'</h2>';
$output .= '<ul>';
foreach (_profile_field_types() as $key => $value) {
- $output .= "<li>". l(t('Add new %type', array('%type' => $value)), "admin/system/modules/profile/add/$key") ."</li>";
+ $output .= '<li>'. l(t('Add new %type', array('%type' => $value)), "admin/user/configure/profile/add/$key") .'</li>';
}
$output .= '</ul>';
@@ -347,7 +378,7 @@ function theme_profile_profile($user, $fields = array()) {
$output = "<div class=\"profile\">\n";
$output .= theme('user_picture', $user);
- $output .= " <div class=\"name\">". format_name($user) ."</div>\n";
+ $output .= ' <div class="name">'. format_name($user) ."</div>\n";
foreach ($fields as $field) {
if ($value = profile_view_field($user, $field)) {
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index 9663342d3..d3b2c6201 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -3,31 +3,47 @@
// TODO: add a 'date' field so we can migrate the birthday information.
+/**
+ * Implementation of hook_help().
+ */
function profile_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
- $output = t("Support for configurable user profiles.");
- break;
+ case 'admin/modules#description':
+ return t('Support for configurable user profiles.');
}
- return $output;
-
-
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function profile_link($type) {
- if ($type == 'system') {
- menu('profile', t('browse'), 'profile_browse', 0, MENU_HIDE);
-
- menu('admin/system/modules/profile', t('profile'), user_access('administer users') ? 'profile_admin_overview' : MENU_DENIED);
- menu('admin/system/modules/profile/add', NULL, user_access('administer users') ? 'profile_admin_add' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/system/modules/profile/edit', NULL, user_access('administer users') ? 'profile_admin_edit' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/system/modules/profile/delete', NULL, user_access('administer users') ? 'profile_admin_delete' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
+function profile_menu() {
+ $items = array();
+ $items[] = array('path' => 'profile', 'title' => t('browse'),
+ 'callback' => 'profile_browse',
+ 'access' => TRUE,
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'admin/user/configure/profile', 'title' => t('profiles'),
+ 'callback' => 'profile_admin_overview',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/profile/add', 'title' => t('add field'),
+ 'callback' => 'profile_browse',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/user/configure/profile/edit', 'title' => t('edit field'),
+ 'callback' => 'profile_browse',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/user/configure/profile/delete', 'title' => t('delete field'),
+ 'callback' => 'profile_browse',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_CALLBACK);
+ return $items;
}
+/**
+ * Menu callback; display a list of user information.
+ */
function profile_browse() {
$name = strip_tags(arg(1));
@@ -38,7 +54,7 @@ function profile_browse() {
if ($field->fid) {
// Compile a list of fields to show
$fields = array();
- $result = db_query("SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1", $field->fid);
+ $result = db_query('SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1', $field->fid);
while ($record = db_fetch_object($result)) {
$fields[] = $record;
}
@@ -71,7 +87,7 @@ function profile_browse() {
else {
$title = $field->page;
}
- $output .= "</div>";
+ $output .= '</div>';
print theme('page', $output, $title);
}
@@ -111,7 +127,7 @@ function profile_view_field($user, $field) {
case 'checkbox':
return l($field->title, "profile/$field->name");
case 'url':
- return "<a href=\"". check_url(strip_tags($value)) ."\">". strip_tags($value) ."</a>"; case 'list':
+ return '<a href="'. check_url(strip_tags($value)) .'">'. strip_tags($value) .'</a>'; case 'list':
$values = split("[\n\r]", $value);
$fields = array();
foreach ($values as $value) {
@@ -157,7 +173,7 @@ function profile_edit_profile($edit, $user) {
$fields[$field->category] .= form_textarea($field->title, $field->name, $edit[$field->name], 60, 5, $field->explanation, NULL, $field->required);
break;
case 'list':
- $fields[$field->category] .= form_textarea($field->title, $field->name, $edit[$field->name], 60, 5, $field->explanation ." ". t('Put each entry on a separate line. No HTML allowed.'), NULL, $field->required);
+ $fields[$field->category] .= form_textarea($field->title, $field->name, $edit[$field->name], 60, 5, $field->explanation .' '. t('Put each entry on a separate line. No HTML allowed.'), NULL, $field->required);
break;
case 'checkbox':
$fields[$field->category] .= form_checkbox($field->title, $field->name, 1, $edit[$field->name], $field->explanation, NULL, $field->required);
@@ -185,17 +201,20 @@ function profile_validate_profile($edit) {
while ($field = db_fetch_object($result)) {
if ($edit[$field->name]) {
if ($field->type == 'url' && !valid_url($edit[$field->name], true)) {
- form_set_error($field->name, t("The value provided for '%field' is not a valid URL.", array('%field' => $field->title)));
+ form_set_error($field->name, t('The value provided for "%field" is not a valid URL.', array('%field' => $field->title)));
}
}
else if ($field->required) {
- form_set_error($field->name, t("The field '%field' is required.", array('%field' => $field->title)));
+ form_set_error($field->name, t('The field "%field" is required.', array('%field' => $field->title)));
}
}
return $edit;
}
+/**
+ * Implementation of hook_user().
+ */
function profile_user($type, &$edit, &$user) {
switch ($type) {
case 'load':
@@ -236,6 +255,9 @@ function profile_validate_form($edit) {
}
}
+/**
+ * Menu callback; adds a new field to all user profiles.
+ */
function profile_admin_add($type) {
$type = _profile_field_types($type);
@@ -267,6 +289,9 @@ function profile_admin_add($type) {
print theme('page', _profile_field_form($type, $data), t('Add new %type', array('%type' => $type)));
}
+/**
+ * Menu callback; displays the profile field editing form.
+ */
function profile_admin_edit($fid) {
if ($_POST['op']) {
@@ -288,6 +313,9 @@ function profile_admin_edit($fid) {
print theme('page', _profile_field_form($data['type'], $data), t('Edit %type', array('%type' => $edit['type'])));
}
+/**
+ * Menu callback; deletes a field from all user profiles.
+ */
function profile_admin_delete($fid) {
db_query('DELETE FROM {profile_fields} WHERE fid = %d', $fid);
drupal_set_message(t('the field has been deleted.'));
@@ -296,24 +324,24 @@ function profile_admin_delete($fid) {
function _profile_field_form($type, $edit = array()) {
- $group = form_textfield(t('Category'), 'category', $edit['category'], 70, 128, t("The category the new field should be part of. Categories are used to group fields logically. An example category is 'Personal information'."));
- $group .= form_textfield(t('Title'), 'title', $edit['title'], 70, 128, t("The title of the new field. The title will be shown to the user. An example title is 'Favorite color'."));
- $group .= form_textfield(t('Form name'), 'name', $edit['name'], 70, 128, t("The name of the field. The form name is not shown to the user but used internally in the HTML code and URLs.
-Unless you know what you are doing, it is highly recommended that you prefix the form name with <code>profile_</code> to avoid name clashes with other fields. Spaces or any other special characters except dash (-) and underscore (_) are not allowed. An example name is 'profile_favorite_color' or perhaps just 'profile_color'."));
- $group .= form_textarea(t('Explanation'), 'explanation', $edit['explanation'], 70, 3, t("An optional explanation to go with the new field. The explanation will be shown to the user."));
+ $group = form_textfield(t('Category'), 'category', $edit['category'], 70, 128, t('The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".'));
+ $group .= form_textfield(t('Title'), 'title', $edit['title'], 70, 128, t('The title of the new field. The title will be shown to the user. An example title is "Favorite color".'));
+ $group .= form_textfield(t('Form name'), 'name', $edit['name'], 70, 128, t('The name of the field. The form name is not shown to the user but used internally in the HTML code and URLs.
+Unless you know what you are doing, it is highly recommended that you prefix the form name with <code>profile_</code> to avoid name clashes with other fields. Spaces or any other special characters except dash (-) and underscore (_) are not allowed. An example name is "profile_favorite_color" or perhaps just "profile_color".'));
+ $group .= form_textarea(t('Explanation'), 'explanation', $edit['explanation'], 70, 3, t('An optional explanation to go with the new field. The explanation will be shown to the user.'));
if ($type == 'selection') {
- $group .= form_textarea(t('Selection options'), 'options', $edit['options'], 70, 8, t("A list of all options. Put each option on a separate line. Example options are 'red', 'blue', 'green', etc."));
+ $group .= form_textarea(t('Selection options'), 'options', $edit['options'], 70, 8, t('A list of all options. Put each option on a separate line. Example options are "red", "blue", "green", etc.'));
}
- $group .= form_weight(t('Weight'), 'weight', $edit['weight'], 5, t("The weights define the order in which the form fields are shown. Lighter fields \"float up\" towards the top of the category."));
+ $group .= form_weight(t('Weight'), 'weight', $edit['weight'], 5, t('The weights define the order in which the form fields are shown. Lighter fields "float up" towards the top of the category.'));
$group .= form_checkbox(t('Required field.'), 'required', 1, $edit['required']);
$output = form_group(t('Field settings'), $group);
$group = '';
if ($type == 'selection' || $type == 'list') {
- $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t("The title of the page showing all users with the specified field. The word <code>%value</code> will be substituted with the corresponding value. An example page title is 'People whose favorite color is %value'."));
+ $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t('The title of the page showing all users with the specified field. The word <code>%value</code> will be substituted with the corresponding value. An example page title is "People whose favorite color is %value".'));
}
else {
- $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t("The title of the page showing all users with the specified field."));
+ $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t('The title of the page showing all users with the specified field.'));
}
$group .= form_checkbox(t('Should this field be shown on the member listing pages.'), 'overview', 1, $edit['overview']);
@@ -323,11 +351,14 @@ Unless you know what you are doing, it is highly recommended that you prefix the
return form($output);
}
+/**
+ * Menu callback; display a listing of all editable profile fields.
+ */
function profile_admin_overview() {
$result = db_query('SELECT * FROM {profile_fields} ORDER BY category, weight');
while ($field = db_fetch_object($result)) {
- $rows[] = array($field->title, $field->name, $field->type, $field->category, l(t('edit'), "admin/system/modules/profile/edit/$field->fid"), l(t('delete'), "admin/system/modules/profile/delete/$field->fid"));
+ $rows[] = array($field->title, $field->name, $field->type, $field->category, l(t('edit'), "admin/user/configure/profile/edit/$field->fid"), l(t('delete'), "admin/user/configure/profile/delete/$field->fid"));
}
$header = array(t('title'), t('name'), t('type'), t('category'), array('data' => t('operations'), 'colspan' => '2'));
@@ -336,7 +367,7 @@ function profile_admin_overview() {
$output .= '<h2>'. t('Create new field') .'</h2>';
$output .= '<ul>';
foreach (_profile_field_types() as $key => $value) {
- $output .= "<li>". l(t('Add new %type', array('%type' => $value)), "admin/system/modules/profile/add/$key") ."</li>";
+ $output .= '<li>'. l(t('Add new %type', array('%type' => $value)), "admin/user/configure/profile/add/$key") .'</li>';
}
$output .= '</ul>';
@@ -347,7 +378,7 @@ function theme_profile_profile($user, $fields = array()) {
$output = "<div class=\"profile\">\n";
$output .= theme('user_picture', $user);
- $output .= " <div class=\"name\">". format_name($user) ."</div>\n";
+ $output .= ' <div class="name">'. format_name($user) ."</div>\n";
foreach ($fields as $field) {
if ($value = profile_view_field($user, $field)) {
diff --git a/modules/queue.module b/modules/queue.module
index 149ee1f69..6f8537eba 100644
--- a/modules/queue.module
+++ b/modules/queue.module
@@ -1,56 +1,56 @@
<?php
// $Id$
+/**
+ * Implementation of hook_help().
+ */
function queue_help($section) {
- $output = "";
-
switch ($section) {
- case 'admin/system/modules#description':
- $output = t("Enables content to be moderated by the community.");
- break;
- case 'admin/system/modules/queue':
- $output = t("The queue provides a way for your users to vote on submitted content. This is called <strong>moderation</strong>. Users can moderate a post up (give it a point), or down (subtract a point). The settings below give you control over how many points are required for the status of a post to be automatically changed. See individual items for details.");
- break;
+ case 'admin/modules#description':
+ return t("Enables content to be moderated by the community.");
+ case 'admin/settings/queue':
+ return t("The queue provides a way for your users to vote on submitted content. This is called <strong>moderation</strong>. Users can moderate a post up (give it a point), or down (subtract a point). The settings below give you control over how many points are required for the status of a post to be automatically changed. See individual items for details.");
}
- return $output;
}
function queue_settings() {
$post_and_expire = drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100));
$dump = drupal_map_assoc(array(-1, -2, -3, -4, -5, -6, -7, -8, -8, -10, -11, -12, -13, -14, -15, -20, -25, -30));
- $output .= form_select(t("Post threshold"), "queue_threshold_post", variable_get("queue_threshold_post", 4), $post_and_expire, t("When a post gets this number of moderation points, it is <strong>promoted to the front page</strong> automatically."));
- $output .= form_select(t("Dump threshold"), "queue_threshold_dump", variable_get("queue_threshold_dump", -2), $dump, t("When a post drops below this number of points, its status is changed to <strong>unpublished</strong>."));
- $output .= form_select(t("Expiration threshold"), "queue_threshold_expire", variable_get("queue_threshold_expire", 8), $post_and_expire, t("When a post gets this number of points, its status is changed to <strong>unpublished</strong>."));
- $output .= form_item(t("Show comments"), form_checkbox(t("Enabled"), "queue_show_comments", 1, variable_get("queue_show_comments", 1)), t("Tick the box to show comments below the moderation form."));
+ $output .= form_select(t('Post threshold'), 'queue_threshold_post', variable_get('queue_threshold_post', 4), $post_and_expire, t('When a post gets this number of moderation points, it is <strong>promoted to the front page</strong> automatically.'));
+ $output .= form_select(t('Dump threshold'), 'queue_threshold_dump', variable_get('queue_threshold_dump', -2), $dump, t('When a post drops below this number of points, its status is changed to <strong>unpublished</strong>.'));
+ $output .= form_select(t('Expiration threshold'), 'queue_threshold_expire', variable_get('queue_threshold_expire', 8), $post_and_expire, t('When a post gets this number of points, its status is changed to <strong>unpublished</strong>.'));
+ $output .= form_item(t('Show comments'), form_checkbox(t('Enabled'), 'queue_show_comments', 1, variable_get('queue_show_comments', 1)), t('Tick the box to show comments below the moderation form.'));
return $output;
}
+/**
+ * Implementation of hook_perm().
+ */
function queue_perm() {
- return array("access submission queue");
+ return array('access submission queue');
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function queue_link($type) {
- $links = array();
-
- if ($type == 'system') {
- menu('queue', t('submission queue'), user_access('access submission queue') ? 'queue_page' : MENU_DENIED, 1);
- }
-
- return $links;
+function queue_menu($type) {
+ $items = array();
+ $items[] = array('path' => 'queue', 'title' => t('submission queue'),
+ 'callback' => 'queue_page',
+ 'access' => user_access('access submission queue'),
+ 'weight' => 1);
+ return $items;
}
function queue_count() {
- $result = db_query("SELECT COUNT(nid) FROM {node} WHERE moderate = 1");
+ $result = db_query('SELECT COUNT(nid) FROM {node} WHERE moderate = 1');
return ($result) ? db_result($result, 0) : 0;
}
function queue_score($id) {
- $result = db_query("SELECT score FROM {node} WHERE nid = %d", $id);
+ $result = db_query('SELECT score FROM {node} WHERE nid = %d', $id);
return ($result) ? db_result($result, 0) : 0;
}
@@ -59,23 +59,23 @@ function queue_vote($node, $vote) {
if (!field_get($node->users, $user->uid)) {
// Update submission's score- and votes-field:
- db_query("UPDATE {node} SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->uid, $vote) ."' WHERE nid = '$node->nid'");
+ db_query("UPDATE {node} SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->uid, $vote) ."' WHERE nid = %d", $node->nid);
// Reload the updated node from the database:
- $node = node_load(array("nid" => $node->nid));
+ $node = node_load(array('nid' => $node->nid));
$terms = module_invoke('taxonomy', 'node_get_terms', $node->nid, 'tid');
foreach ($terms as $term) {
$node->taxonomy[] = $term->tid;
}
- if (variable_get("queue_threshold_post", 4) <= $node->score) {
+ if (variable_get('queue_threshold_post', 4) <= $node->score) {
$node->moderate = 0;
$node->promote = 1;
node_save($node);
watchdog('special', t('moderation: approved "%node-title"', array('%node-title' => $node->title)));
}
- else if (variable_get("queue_threshold_dump", -2) >= $node->score) {
+ else if (variable_get('queue_threshold_dump', -2) >= $node->score) {
if ($node->revisions) {
node_revision_rollback($node, end(node_revision_list($node)));
watchdog('special', t('moderation: declined "%node-title" (rollback)', array('%node-title' => $node->title)));
@@ -87,7 +87,7 @@ function queue_vote($node, $vote) {
watchdog('special', t('moderation: declined "%node-title"', array('%node-title' => $node->title)));
}
}
- else if (variable_get("queue_threshold_expire", 8) <= $node->votes) {
+ else if (variable_get('queue_threshold_expire', 8) <= $node->votes) {
if ($node->revisions) {
node_revision_rollback($node, end(node_revision_list($node)));
watchdog('special', t('moderation: expired "%node-title" (rollback)', array('%node-title' => $node->title)));
@@ -102,135 +102,131 @@ function queue_vote($node, $vote) {
}
}
+/**
+ * Display a page listing the nodes in the submission queue.
+ */
function queue_overview() {
global $user;
- $header = array(array("data" => t("subject")), array("data" => t("author")), array("data" => t("type")), array("data" => t("score")));
+ $header = array(array('data' => t('subject')), array('data' => t('author')), array('data' => t('type')), array('data' => t('score')));
- $sresult = pager_query("SELECT n.*, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.moderate = 1", 10, 0);
+ $sresult = pager_query('SELECT n.*, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.moderate = 1', 10, 0);
while ($node = db_fetch_object($sresult)) {
if ($user->uid == $node->uid || field_get($node->users, $user->uid)) {
- $rows[] = array(array("data" => l($node->title, "queue/$node->nid"), "class" => "title"), array("data" => format_name($node), "class" => "name"), array("data" => module_invoke($node->type, "node_name", $node), "class" => "type"), array("data" => queue_score($node->nid), "class" => "score"));
+ $rows[] = array(array('data' => l($node->title, 'queue/'. $node->nid), 'class' => 'title'), array('data' => format_name($node), 'class' => 'name'), array('data' => module_invoke($node->type, 'node_name', $node), 'class' => 'type'), array('data' => queue_score($node->nid), 'class' => 'score'));
}
else {
- $rows[] = array(array("data" => l($node->title, "queue/$node->nid"), "class" => "title"), array("data" => format_name($node), "class" => "name"), array("data" => module_invoke($node->type, "node_name", $node), "class" => "type"), array("data" => l(t("vote"), "queue/$node->nid"), "class" => "score"));
+ $rows[] = array(array('data' => l($node->title, 'queue/'. $node->nid), 'class' => 'title'), array('data' => format_name($node), 'class' => 'name'), array('data' => module_invoke($node->type, 'node_name', $node), 'class' => 'type'), array('data' => l(t('vote'), 'queue/', $node->nid), 'class' => 'score'));
}
}
- if ($pager = theme("pager", NULL, 10, 0, tablesort_pager())) {
- $rows[] = array(array("data" => $pager, "colspan" => 4));
+ if ($pager = theme('pager', NULL, 10, 0, tablesort_pager())) {
+ $rows[] = array(array('data' => $pager, 'colspan' => 4));
}
- $output = "<div id=\"queue\">";
- $output .= theme("table", $header, $rows);
- $output .= "</div>";
+ $output = '<div id="queue">';
+ $output .= theme('table', $header, $rows);
+ $output .= '</div>';
- drupal_set_title(t("Submission queue"));
+ drupal_set_title(t('Submission queue'));
- print theme("page", $output);
+ print theme('page', $output);
}
+/**
+ * Display a queued node along with voting options for it.
+ */
function queue_view($nid) {
global $user;
- $op = $_POST["op"];
- $edit = $_POST["edit"];
-
- /*
- ** An associative array with the possible voting options:
- */
-
- $votes = array("+ 0" => t("neutral (+0)"), "+ 1" => t("post it (+1)"), "- 1" => t("dump it (-1)"));
+ $op = $_POST['op'];
+ $edit = $_POST['edit'];
- /*
- ** Load the node from the database:
- */
+ // An associative array with the possible voting options.
+ $votes = array('+ 0' => t('neutral (+0)'), '+ 1' => t('post it (+1)'), '- 1' => t('dump it (-1)'));
- $node = node_load(array("nid" => $nid, "moderate" => 1));
+ // Load the node from the database.
+ $node = node_load(array('nid' => $nid, 'moderate' => 1));
if ($node) {
if ($user->uid != $node->uid && !field_get($node->users, $user->uid)) {
- if ($op == t("Vote") && $votes[$edit["vote"]]) {
- /*
- ** If it is a valid vote, record it.
- */
+ if ($op == t('Vote') && $votes[$edit['vote']]) {
+ // If it is a valid vote, record it.
- queue_vote($node, $edit["vote"]);
+ queue_vote($node, $edit['vote']);
- $output = t("Your vote has been recorded.");
+ $output = t('Your vote has been recorded.');
}
else {
- /*
- ** Display some explanation or voting guidelines:
- */
+ // Display some explanation or voting guidelines:
+ $output .= '<p>'. t('When new content is submitted, it goes into the submission queue. Registered users with the appropriate permission can access this queue and vote whether they think the content should be approved or not. When enough people vote to approve the content, it is displayed on the front page. On the other hand, if enough people vote to drop it, the content will disappear.') .'</p>';
- $output .= "<p>". t("When new content is submitted it goes into the submission queue. Registered users with the appropriate permission can access this queue and vote whether they think the content should be approved or not. When enough people vote to approve the content it is displayed on the front page. On the other hand, if enough people vote to drop it, the content will disappear.") ."</p>";
-
- /*
- ** Display a voting form:
- */
-
- $output .= form_select(t("Your vote"), "vote", "", $votes);
- $output .= form_hidden("id", $node->nid);
- $output .= form_submit(t("Vote"));
+ // Display a voting form:
+ $output .= form_select(t('Your vote'), 'vote', '', $votes);
+ $output .= form_hidden('id', $node->nid);
+ $output .= form_submit(t('Vote'));
$output = form($output);
}
}
$output .= node_view($node);
- $output = theme("box", t("Moderate"), $output);
+ $output = theme('box', t('Moderate'), $output);
- if ($node->comment && variable_get("queue_show_comments", 1)) {
- $output .= module_invoke("comment", "render", $node);
+ if ($node->comment && variable_get('queue_show_comments', 1)) {
+ $output .= module_invoke('comment', 'render', $node);
}
- print theme("page", $output);
+ print theme('page', $output);
}
else {
drupal_not_found();
}
}
-function queue_page() {
- global $user, $vote;
-
- if (arg(1)) {
- queue_view(arg(1));
+/**
+ * Menu callback; displays the queue management page.
+ */
+function queue_page($nid = 0) {
+ if ($nid) {
+ queue_view($nid);
}
else {
queue_overview();
}
}
-function queue_block($op = "list", $delta = 0) {
+/**
+ * Implementation of hook_block().
+ */
+function queue_block($op = 'list', $delta = 0) {
global $user;
- if ($op == "list") {
- $blocks[0]["info"] = t("Moderation results");
+ if ($op == 'list') {
+ $blocks[0]['info'] = t('Moderation results');
return $blocks;
}
else {
- if (user_access("access submission queue") && (arg(0) == "queue") || arg(0) == "node") {
+ if (user_access('access submission queue') && (arg(0) == 'queue') || arg(0) == 'node') {
if ($user->uid) {
- if (arg(0) == "queue") {
+ if (arg(0) == 'queue') {
$id = arg(1);
}
else {
$id = arg(2);
}
- $node = node_load(array("nid" => $id));
+ $node = node_load(array('nid' => $id));
if (($user->uid == $node->uid || field_get($node->users, $user->uid)) && $node->moderate == 1) {
- foreach (explode(",", $node->users) as $vote) {
+ foreach (explode(',', $node->users) as $vote) {
if ($vote) {
- $data = explode("=", $vote);
- $account = user_load(array("uid" => $data[0]));
- $output .= format_name($account) ." voted '$data[1]'.<br />";
+ $data = explode('=', $vote);
+ $account = user_load(array('uid' => $data[0]));
+ $output .= format_name($account) ." voted \"$data[1]\".<br />";
}
}
- $block["subject"] = t("Moderation results");
- $block["content"] = $output ? $output : t("This node has not yet been moderated.");
+ $block['subject'] = t('Moderation results');
+ $block['content'] = $output ? $output : t('This node has not yet been moderated.');
}
}
@@ -239,7 +235,10 @@ function queue_block($op = "list", $delta = 0) {
}
}
-function queue_nodeapi(&$node, $op, $arg = 0) {
+/**
+ * Implementation of hook_nodeapi().
+ */
+function queue_nodeapi(&$node, $op) {
switch ($op) {
case 'fields':
return array('score', 'users', 'votes');
@@ -253,7 +252,7 @@ function queue_nodeapi(&$node, $op, $arg = 0) {
break;
case 'insert':
case 'update':
- if ($node->moderate && user_access("access submission queue")) {
+ if ($node->moderate && user_access('access submission queue')) {
drupal_set_message(t('The post is queued for approval. You can check the votes in the <a href="%queue">submission queue</a>.', array('%queue' => url('queue'))));
}
else if ($node->moderate) {
diff --git a/modules/search.module b/modules/search.module
index 6503d10bd..baf0809be 100644
--- a/modules/search.module
+++ b/modules/search.module
@@ -1,32 +1,29 @@
<?php
// $Id$
-function search_help($section = "admin/help#search") {
- $output = "";
-
+/**
+ * Implementation of hook_help().
+ */
+function search_help($section = 'admin/help#search') {
switch ($section) {
case 'admin/help#search':
- $output = t("
+ return t("
<strong>Search guidelines</strong>
<p>The search page allows you to search the web site's content. You can specify multiple words, and they will all be searched for. You can also use wildcards, so 'walk*' will match 'walk', 'walking', 'walker', 'walkable' and so on. Furthermore, searches are not case sensitive so searching for 'walk', 'Walk' or 'WALK' will yield exactly the same results.</p>
<strong>Words excluded from the search</strong>
- <p>Words that frequently occur, typically called 'noise words', are ignored. Example words are 'a', 'at', 'and', 'are', 'as', 'how', 'where', etc. Words shorter than %number letters are also ignored.</p>", array("%number" => variable_get("minimum_word_size", 2)));
- break;
- case 'admin/system/modules#description':
- $output = t("Enables site wide keyword searching.");
- break;
- case 'admin/system/modules/search':
- $output = t("The search engine works by keeping an index of \"interesting\" words. To make sure we only get \"interesting\" words you need to set the following.");
- break;
+ <p>Words that frequently occur, typically called 'noise words', are ignored. Example words are 'a', 'at', 'and', 'are', 'as', 'how', 'where', etc. Words shorter than %number letters are also ignored.</p>", array('%number' => variable_get('minimum_word_size', 2)));
+ case 'admin/modules#description':
+ return t('Enables site-wide keyword searching.');
+ case 'admin/settings/search':
+ return t('The search engine works by keeping an index of "interesting" words. To make sure we only get "interesting" words you need to set the following.');
}
- return $output;
}
/**
- * Return an array of valid search access permissions
+ * Implementation of hook_perm().
*/
function search_perm() {
- return array("search content", "administer search");
+ return array('search content', 'administer search');
}
/**
@@ -39,29 +36,59 @@ function search_link($type) {
$links[] = l(t('search'), 'search', array('title' => t('Search for older content.')));
}
- if ($type == 'system') {
- menu('search', t('search'), user_access('search content') ? 'search_page' : MENU_DENIED, 0, MENU_HIDE);
- }
-
return $links;
}
-function search_settings() {
- $output = form_textfield(t("Minimum word length to index"), "minimum_word_size", variable_get("minimum_word_size", 2), 10, 10, t("The number of characters a word has to be to be indexed. Words shorter than this will not be searchable."));
- $output .= form_textfield(t("Minimum word length to search for"), "remove_short", variable_get("remove_short", 0), 10, 10, t("The number of characters a word has to be to be searched for."));
- $output .= form_textarea(t("Noise words"), "noisewords", variable_get("noisewords", ""), 70, 10, t("These words will not be indexed, enter comma separated list, linebreaks and whitespace do not matter. Example: and, or, not, a, to, I, it, ..."));
- $output .= form_radios(t("Help text position"), "help_pos", variable_get("help_pos", 1), array("1" => t("Above search output"), "2" => t("Below search output"), "3" => t("Link from above search output"), "4" => t("Link from below search output")), t("Where to show the help text for users on the search page."));
+/**
+ * Implementation of hook_menu().
+ */
+function search_menu() {
+ $items = array();
+ $items[] = array('path' => 'search', 'title' => t('search'),
+ 'callback' => 'search_view',
+ 'access' => user_access('search content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'search/help', 'title' => t('search help'),
+ 'callback' => 'search_help_page',
+ 'access' => user_access('search content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'search/configure', 'title' => t('configure'),
+ 'callback' => 'search_configure',
+ 'access' => user_access('administer site configuration'),
+ 'type' => MENU_LOCAL_TASK);
+ return $items;
+}
+
+/**
+ * Menu callback; displays the search module settings page.
+ */
+function search_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
+ // Indexing settings:
+ $group = form_textfield(t('Minimum word length to index'), 'minimum_word_size', variable_get('minimum_word_size', 2), 10, 10, t('The number of characters a word has to be to be indexed. Words shorter than this will not be searchable.'));
+ $group .= form_textfield(t('Minimum word length to search for'), 'remove_short', variable_get('remove_short', 0), 10, 10, t('The number of characters a word has to be to be searched for.'));
+ $group .= form_textarea(t('Noise words'), 'noisewords', variable_get('noisewords', ''), 70, 10, t('These words will not be indexed. Enter a comma separated list; linebreaks and whitespace do not matter. Example: and, or, not, a, to, I, it, ...'));
+ $output = form_group(t('Indexing settings'), $group);
+
+ // Visual settings:
+ $group = form_radios(t('Help text position'), 'help_pos', variable_get('help_pos', 1), array('1' => t('Above search output'), '2' => t('Below search output'), '3' => t('Link from above search output'), '4' => t('Link from below search output')), t('Where to show the help text for users on the search page.'));
+ $output .= form_group(t('Viewing options'), $group);
- return $output;
+ print theme('page', system_settings_form($output));
}
/**
- * perform a regularly run action across all modules that have the
- * <i>module</i>_update_index function in them.
+ * Implementation of hook_cron().
+ *
+ * Fires hook_update_index() in all modules and uses the results to make
+ * the search index current.
*/
function search_cron() {
foreach (module_list() as $module) {
- $module_array = module_invoke($module, "update_index");
+ $module_array = module_invoke($module, 'update_index');
if ($module_array) {
update_index($module_array);
}
@@ -71,75 +98,75 @@ function search_cron() {
}
/**
- * Perform a search on a word(s).
+ * Perform a search on a word or words.
*
- * Search function called by each node that supports the indexed search.
+ * This function is called by each node that supports the indexed search.
*
- * @param $search_array an array as returned from <i>module</i>_search of type
- * array("keys" => ..., "type" => ..., "select" => ...)
- * @see node_search for an explanation of array items
+ * @param $search_array
+ * An array as returned from hook_search(). The format of this array is
+ * array('keys' => ..., 'type' => ..., 'select' => ...). See the hook_search()
+ * documentation for an explanation of the array values.
*
- * @return array of search results, each element being an array indexed with
- * "count", "title", "link", "user" (name), "date", "keywords"
+ * @return
+ * An array of search results, of which each element is an array with the
+ * keys "count", "title", "link", "user" (name), "date", and "keywords".
*/
function do_search($search_array) {
- $keys = strtolower($search_array["keys"]);
- $type = $search_array["type"];
- $select = $search_array["select"];
+ $keys = strtolower($search_array['keys']);
+ $type = $search_array['type'];
+ $select = $search_array['select'];
- // Replace wildcards with mysql wildcards
- $keys = str_replace("*", "%", $keys);
+ // Replace wildcards with MySQL wildcards.
+ $keys = str_replace('*', '%', $keys);
- // Split the words entered into an array
- $words = explode(" ", $keys);
+ // Split the words entered into an array.
+ $words = explode(' ', $keys);
foreach ($words as $word) {
- // If the word is too short, and we've got it set to skip them, loop
- if (strlen($word) < variable_get("remove_short", 0)) {
+ // If the word is too short, and we've got it set to skip them, loop.
+ if (strlen($word) < variable_get('remove_short', 0)) {
continue;
}
- // Put the next search word into the query and do the query
+ // Put the next search word into the query and do the query.
$query = str_replace("'%'", "'". check_query($word) ."'", $select);
$result = db_query($query);
- // If we got any results
if (db_num_rows($result) != 0) {
+ // At least one matching record was found.
$found = 1;
- // Create an in memory array of the results,
+ // Create an in memory array of the results.
while ($row = db_fetch_array($result)) {
- $lno = $row["lno"];
- $nid = $row["nid"];
- $title = $row["title"];
- $created = $row["created"];
- $uid = $row["uid"];
- $name = $row["name"];
- $count = $row["count"];
-
- // Build reduction variable
+ $lno = $row['lno'];
+ $nid = $row['nid'];
+ $title = $row['title'];
+ $created = $row['created'];
+ $uid = $row['uid'];
+ $name = $row['name'];
+ $count = $row['count'];
+
+ // Build reduction variable.
$reduction[$lno][$word] = true;
- // If the just fetched row is not already in the table
- if ($results[$lno]["lno"] != $lno) {
- $results[$lno]["count"] = $count;
+ // Check whether the just-fetched row is already in the table.
+ if ($results[$lno]['lno'] != $lno) {
+ $results[$lno]['count'] = $count;
- $results[$lno]["lno"] = $lno;
- $results[$lno]["nid"] = $nid;
- $results[$lno]["title"] = $title;
- $results[$lno]["created"] = $created;
- $results[$lno]["uid"] = $uid;
- $results[$lno]["name"] = $name;
+ $results[$lno]['lno'] = $lno;
+ $results[$lno]['nid'] = $nid;
+ $results[$lno]['title'] = $title;
+ $results[$lno]['created'] = $created;
+ $results[$lno]['uid'] = $uid;
+ $results[$lno]['name'] = $name;
}
else {
- /*
- ** Different word, but existing "lno", increase the count of
- ** matches against this "lno" by the number of times this
- ** word appears in the text
- */
- $results[$lno]["count"] = $results[$lno]["count"] + $count;
+ // Different word, but existing "lno". Increase the count of
+ // matches against this "lno" by the number of times this
+ // word appears in the text.
+ $results[$lno]['count'] = $results[$lno]['count'] + $count;
}
}
}
@@ -163,24 +190,25 @@ function do_search($search_array) {
}
}
if ($found) {
- // Black magic here to sort the results
+ // Black magic here to sort the results.
array_multisort($results, SORT_DESC);
- // OK, time to output the results.
+ // Now, output the results.
foreach ($results as $key => $value) {
- $lno = $value["lno"];
- $nid = $value["nid"];
- $title = $value["title"];
- $created = $value["created"];
- $uid = $value["uid"];
- $name = $value["name"];
- $count = $value["count"];
+ $lno = $value['lno'];
+ $nid = $value['nid'];
+ $title = $value['title'];
+ $created = $value['created'];
+ $uid = $value['uid'];
+ $name = $value['name'];
+ $count = $value['count'];
switch ($type) {
- case "node":
- $find[$i++] = array("count" => $count, "title" => $title, "link" => (strstr(request_uri(), "admin") ? url("admin/node/edit/$lno") : url("node/view/$lno")), "user" => $name, "date" => $created, "keywords" => implode("|", $words));
- break;
- case "comment":
- $find[$i++] = array("count" => $count, "title" => $title, "link" => (strstr(request_uri(), "admin") ? url("admin/comment/edit/$lno") : url("node/view/$nid", NULL, "comment-$lno")), "user" => $name, "date" => $created, "keywords" => implode("|", $words));
+ case 'node':
+ $find[$i++] = array('count' => $count, 'title' => $title, 'link' => url("node/$lno"), 'user' => $name, 'date' => $created, 'keywords' => implode('|', $words));
+ break;
+ case 'comment':
+ $find[$i++] = array('count' => $count, 'title' => $title, 'link' => (strstr(request_uri(), 'admin') ? url("admin/comment/edit/$lno") : url("node/$nid", NULL, "comment-$lno")), 'user' => $name, 'date' => $created, 'keywords' => implode('|', $words));
+ break;
break;
}
}
@@ -190,72 +218,64 @@ function do_search($search_array) {
}
/**
- * Update the search_index table
+ * Update the search_index table.
*
- * @param $search_array an array as returned from <i>module</i>_update_index
- * of type array("last_update" => ..., "node_type" => ..., "select" => ...)
- * @see node_update_index for an explanation of array items
+ * @param $search_array
+ * An array as returned from hook_update_index().
*/
function update_index($search_array) {
- $last_update = variable_get($search_array["last_update"], 1);
- $node_type = $search_array["node_type"];
- $select = $search_array["select"];
- $minimum_word_size = variable_get("minimum_word_size", 2);
+ $last_update = variable_get($search_array['last_update'], 1);
+ $node_type = $search_array['node_type'];
+ $select = $search_array['select'];
+ $minimum_word_size = variable_get('minimum_word_size', 2);
- //watchdog("user", "$last_update<br />$node_type<br />$select");
+ //watchdog('user', "$last_update<br />$node_type<br />$select");
$result = db_query($select);
if (db_num_rows($result)) {
- // Wohoo, found some, look through the nodes we just selected
+ // Results were found. Look through the nodes we just selected.
while ($node = db_fetch_array ($result)) {
- /*
- ** Trash any existing entries in the search index for this node,
- ** in case its a modified node.
- */
- db_query("DELETE from {search_index} where lno = '". $node["lno"] ."' and type = '". $node_type ."'");
+ // Trash any existing entries in the search index for this node,
+ // in case it is a modified node.
+ db_query("DELETE from {search_index} where lno = '". $node['lno'] ."' and type = '". $node_type ."'");
- /*
- ** Build the wordlist, teaser not included, as it then gives a
- ** false count of the number of hits, and doesn't show up
- ** when clicking on a node from the search interface anyway.
- */
- $wordlist = $node["text1"] ." ". $node["text2"];
+ // Build the word list (teaser not included, as it would give a
+ // false count of the number of hits).
+ $wordlist = $node['text1'] .' '. $node['text2'];
- // Strip heaps of stuff out of it
- $wordlist = preg_replace("'<[\/\!]*?[^<>]*?>'si", "", $wordlist);
+ // Strip heaps of stuff out of it.
+ $wordlist = preg_replace("'<[\/\!]*?[^<>]*?>'si", '', $wordlist);
- // Remove punctuation and stuff
- $wordlist = preg_replace("'(\xBB|\xAB|!|\xA1|%|,|:|;|\(|\)|\&|\"|\'|\.|-|\/|\?|\\\)'", "", $wordlist);
+ // Remove punctuation/special characters.
+ $wordlist = preg_replace("'(\xBB|\xAB|!|\xA1|%|,|:|;|\(|\)|\&|\"|\'|\.|-|\/|\?|\\\)'", '', $wordlist);
// Strip out (now mangled) http and tags.
- $wordlist = preg_replace("'http\w+'", "", $wordlist);
- $wordlist = preg_replace("'www\w+'", "", $wordlist);
+ $wordlist = preg_replace("'http\w+'", '', $wordlist);
+ $wordlist = preg_replace("'www\w+'", '', $wordlist);
- // Remove all newlines of any type
- $wordlist = preg_replace("'([\r\n]|[\r]|[\n])'", " ", $wordlist);
+ // Remove all newlines of any type.
+ $wordlist = preg_replace("'([\r\n]|[\r]|[\n])'", ' ', $wordlist);
// Lower case the whole thing.
$wordlist = strtolower($wordlist);
- // Remove "noisewords"
- $noise = explode(",", variable_get("noisewords", ""));
+ // Remove "noise words".
+ $noise = explode(',', variable_get('noisewords', ''));
foreach ($noise as $word) {
$word = trim($word);
- $wordlist = trim(preg_replace("' $word '", " ", " " .$wordlist. " "));
+ $wordlist = trim(preg_replace("' $word '", ' ', ' ' .$wordlist. ' '));
}
- // Remove whitespace
- $wordlist = preg_replace("'[\s]+'", " ", $wordlist);
+ // Remove whitespace.
+ $wordlist = preg_replace("'[\s]+'", ' ', $wordlist);
- // Make it an array
- $eachword = explode(" ", $wordlist);
+ // Make it an array.
+ $eachword = explode(' ', $wordlist);
- /*
- ** walk through the array, giving a "weight" to each word, based on
- ** the number of times it appears in a page.
- */
+ // Walk through the array, giving a "weight" to each word based on
+ // the number of times it appears in a page.
foreach ($eachword as $word) {
if (strlen($word) >= $minimum_word_size) {
if ($newwords[$word]) {
@@ -267,23 +287,21 @@ function update_index($search_array) {
}
}
- /*
- ** Walk through the weighted words array, inserting them into
- ** the search index
- */
+ // Walk through the weighted words array, inserting them into
+ // the search index.
if ($newwords) {
foreach ($newwords as $key => $value) {
- db_query("INSERT INTO {search_index} VALUES('%s', %d, '%s', %d)", $key, $node["lno"], $node_type, $value);
+ db_query("INSERT INTO {search_index} VALUES('%s', %d, '%s', %d)", $key, $node['lno'], $node_type, $value);
}
}
- // Zap the weighted words array, so we don't add multiples.
+ // Reset the weighted words array, so we don't add multiples.
$newwords = array ();
}
}
- // update the last time this process was run.
- variable_set($search_array["last_update"], time());
+ // Update the last time this process was run.
+ variable_set($search_array['last_update'], time());
return true;
}
@@ -291,9 +309,9 @@ function update_index($search_array) {
function search_invalidate() {
foreach (module_list() as $module) {
- $module_array = module_invoke($module, "update_index");
+ $module_array = module_invoke($module, 'update_index');
if ($module_array) {
- variable_set($module_array["last_update"], 1);
+ variable_set($module_array['last_update'], 1);
}
$module_array = null;
}
@@ -303,59 +321,64 @@ function search_invalidate() {
/**
* Save the values entered by the administrator for the search module
*
- * @param $edit An array of fields as setup via calling form_textfield,
- * form_textarea etc
+ * @param $edit
+ * An array of fields as set up by calling form_textfield(),
+ * form_textarea(), etc.
*/
function search_save($edit) {
- variable_set("minimum_word_size", $edit["minimum_word_size"]);
+ variable_set('minimum_word_size', $edit['minimum_word_size']);
- $data = strtr($edit["noisewords"], "\n\r\t", " ");
- $data = str_replace(" ", "", $data);
- variable_set("noisewords", $data);
- variable_set("help_pos", $edit["help_pos"]);
- variable_set("remove_short", $edit["remove_short"]);
+ $data = strtr($edit['noisewords'], "\n\r\t", ' ');
+ $data = str_replace(' ', '', $data);
+ variable_set('noisewords', $data);
+ variable_set('help_pos', $edit['help_pos']);
+ variable_set('remove_short', $edit['remove_short']);
}
-function search_view($keys) {
+/**
+ * Menu callback; presents the search form and/or search results.
+ */
+function search_view() {
global $type;
+ $keys = isset($_GET['keys']) ? $_GET['keys'] : $_POST['keys'];
- if (user_access("search content")) {
- // Construct the search form:
+ if (user_access('search content')) {
+ // Construct the search form.
$output = search_form(NULL, $keys, TRUE);
- // Display form and search results:
- $help_link = l(t("search help"), "search/help");
- switch (variable_get("help_pos", 1)) {
- case "1":
- $output = search_help(). $output ."<br />";
+ // Display form and search results.
+ $help_link = l(t('search help'), 'search/help');
+ switch (variable_get('help_pos', 1)) {
+ case '1':
+ $output = search_help(). $output .'<br />';
break;
- case "2":
- $output .= search_help() ."<br />";
+ case '2':
+ $output .= search_help() .'<br />';
break;
- case "3":
- $output = $help_link. "<br />". $output ."<br />";
+ case '3':
+ $output = $help_link. '<br />'. $output .'<br />';
break;
- case "4":
- $output .= "<br />". $help_link ."<br />";
+ case '4':
+ $output .= '<br />'. $help_link .'<br />';
}
// Only perform search if there is non-whitespace search term:
if (trim($keys)) {
// Log the search keys:
- watchdog('search', t('search: "%keys"', array('%keys' => $keys)), l("view results", "search", NULL, "keys=". urlencode($keys)));
+ watchdog('search', t('search: "%keys"', array('%keys' => $keys)), l('view results', 'search', NULL, 'keys='. urlencode($keys)));
// Collect the search results:
$results = search_data($keys);
if ($results) {
- $output .= theme("box", t("Search Results"), $results);
+ $output .= theme('box', t('Search Results'), $results);
}
else {
- $output .= theme("box", t("Search Results"), t("Your search yielded no results."));
+ $output .= theme('box', t('Search Results'), t('Your search yielded no results.'));
}
}
- print theme("page", $output, t("Search"));
+ print theme('page', $output, t('Search'));
}
else {
drupal_access_denied();
@@ -363,16 +386,11 @@ function search_view($keys) {
}
-function search_page() {
- $keys = isset($_GET["keys"]) ? $_GET["keys"] : $_POST["keys"];
-
- switch (arg(1)) {
- case "help":
- print theme("page", search_help(), t("Search Help"));
- break;
- default:
- search_view($keys);
- }
+/**
+ * Menu callback; prints the search engine help page.
+ */
+function search_help_page() {
+ print theme('page', search_help());
}
?>
diff --git a/modules/search/search.module b/modules/search/search.module
index 6503d10bd..baf0809be 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -1,32 +1,29 @@
<?php
// $Id$
-function search_help($section = "admin/help#search") {
- $output = "";
-
+/**
+ * Implementation of hook_help().
+ */
+function search_help($section = 'admin/help#search') {
switch ($section) {
case 'admin/help#search':
- $output = t("
+ return t("
<strong>Search guidelines</strong>
<p>The search page allows you to search the web site's content. You can specify multiple words, and they will all be searched for. You can also use wildcards, so 'walk*' will match 'walk', 'walking', 'walker', 'walkable' and so on. Furthermore, searches are not case sensitive so searching for 'walk', 'Walk' or 'WALK' will yield exactly the same results.</p>
<strong>Words excluded from the search</strong>
- <p>Words that frequently occur, typically called 'noise words', are ignored. Example words are 'a', 'at', 'and', 'are', 'as', 'how', 'where', etc. Words shorter than %number letters are also ignored.</p>", array("%number" => variable_get("minimum_word_size", 2)));
- break;
- case 'admin/system/modules#description':
- $output = t("Enables site wide keyword searching.");
- break;
- case 'admin/system/modules/search':
- $output = t("The search engine works by keeping an index of \"interesting\" words. To make sure we only get \"interesting\" words you need to set the following.");
- break;
+ <p>Words that frequently occur, typically called 'noise words', are ignored. Example words are 'a', 'at', 'and', 'are', 'as', 'how', 'where', etc. Words shorter than %number letters are also ignored.</p>", array('%number' => variable_get('minimum_word_size', 2)));
+ case 'admin/modules#description':
+ return t('Enables site-wide keyword searching.');
+ case 'admin/settings/search':
+ return t('The search engine works by keeping an index of "interesting" words. To make sure we only get "interesting" words you need to set the following.');
}
- return $output;
}
/**
- * Return an array of valid search access permissions
+ * Implementation of hook_perm().
*/
function search_perm() {
- return array("search content", "administer search");
+ return array('search content', 'administer search');
}
/**
@@ -39,29 +36,59 @@ function search_link($type) {
$links[] = l(t('search'), 'search', array('title' => t('Search for older content.')));
}
- if ($type == 'system') {
- menu('search', t('search'), user_access('search content') ? 'search_page' : MENU_DENIED, 0, MENU_HIDE);
- }
-
return $links;
}
-function search_settings() {
- $output = form_textfield(t("Minimum word length to index"), "minimum_word_size", variable_get("minimum_word_size", 2), 10, 10, t("The number of characters a word has to be to be indexed. Words shorter than this will not be searchable."));
- $output .= form_textfield(t("Minimum word length to search for"), "remove_short", variable_get("remove_short", 0), 10, 10, t("The number of characters a word has to be to be searched for."));
- $output .= form_textarea(t("Noise words"), "noisewords", variable_get("noisewords", ""), 70, 10, t("These words will not be indexed, enter comma separated list, linebreaks and whitespace do not matter. Example: and, or, not, a, to, I, it, ..."));
- $output .= form_radios(t("Help text position"), "help_pos", variable_get("help_pos", 1), array("1" => t("Above search output"), "2" => t("Below search output"), "3" => t("Link from above search output"), "4" => t("Link from below search output")), t("Where to show the help text for users on the search page."));
+/**
+ * Implementation of hook_menu().
+ */
+function search_menu() {
+ $items = array();
+ $items[] = array('path' => 'search', 'title' => t('search'),
+ 'callback' => 'search_view',
+ 'access' => user_access('search content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'search/help', 'title' => t('search help'),
+ 'callback' => 'search_help_page',
+ 'access' => user_access('search content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+ $items[] = array('path' => 'search/configure', 'title' => t('configure'),
+ 'callback' => 'search_configure',
+ 'access' => user_access('administer site configuration'),
+ 'type' => MENU_LOCAL_TASK);
+ return $items;
+}
+
+/**
+ * Menu callback; displays the search module settings page.
+ */
+function search_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
+ // Indexing settings:
+ $group = form_textfield(t('Minimum word length to index'), 'minimum_word_size', variable_get('minimum_word_size', 2), 10, 10, t('The number of characters a word has to be to be indexed. Words shorter than this will not be searchable.'));
+ $group .= form_textfield(t('Minimum word length to search for'), 'remove_short', variable_get('remove_short', 0), 10, 10, t('The number of characters a word has to be to be searched for.'));
+ $group .= form_textarea(t('Noise words'), 'noisewords', variable_get('noisewords', ''), 70, 10, t('These words will not be indexed. Enter a comma separated list; linebreaks and whitespace do not matter. Example: and, or, not, a, to, I, it, ...'));
+ $output = form_group(t('Indexing settings'), $group);
+
+ // Visual settings:
+ $group = form_radios(t('Help text position'), 'help_pos', variable_get('help_pos', 1), array('1' => t('Above search output'), '2' => t('Below search output'), '3' => t('Link from above search output'), '4' => t('Link from below search output')), t('Where to show the help text for users on the search page.'));
+ $output .= form_group(t('Viewing options'), $group);
- return $output;
+ print theme('page', system_settings_form($output));
}
/**
- * perform a regularly run action across all modules that have the
- * <i>module</i>_update_index function in them.
+ * Implementation of hook_cron().
+ *
+ * Fires hook_update_index() in all modules and uses the results to make
+ * the search index current.
*/
function search_cron() {
foreach (module_list() as $module) {
- $module_array = module_invoke($module, "update_index");
+ $module_array = module_invoke($module, 'update_index');
if ($module_array) {
update_index($module_array);
}
@@ -71,75 +98,75 @@ function search_cron() {
}
/**
- * Perform a search on a word(s).
+ * Perform a search on a word or words.
*
- * Search function called by each node that supports the indexed search.
+ * This function is called by each node that supports the indexed search.
*
- * @param $search_array an array as returned from <i>module</i>_search of type
- * array("keys" => ..., "type" => ..., "select" => ...)
- * @see node_search for an explanation of array items
+ * @param $search_array
+ * An array as returned from hook_search(). The format of this array is
+ * array('keys' => ..., 'type' => ..., 'select' => ...). See the hook_search()
+ * documentation for an explanation of the array values.
*
- * @return array of search results, each element being an array indexed with
- * "count", "title", "link", "user" (name), "date", "keywords"
+ * @return
+ * An array of search results, of which each element is an array with the
+ * keys "count", "title", "link", "user" (name), "date", and "keywords".
*/
function do_search($search_array) {
- $keys = strtolower($search_array["keys"]);
- $type = $search_array["type"];
- $select = $search_array["select"];
+ $keys = strtolower($search_array['keys']);
+ $type = $search_array['type'];
+ $select = $search_array['select'];
- // Replace wildcards with mysql wildcards
- $keys = str_replace("*", "%", $keys);
+ // Replace wildcards with MySQL wildcards.
+ $keys = str_replace('*', '%', $keys);
- // Split the words entered into an array
- $words = explode(" ", $keys);
+ // Split the words entered into an array.
+ $words = explode(' ', $keys);
foreach ($words as $word) {
- // If the word is too short, and we've got it set to skip them, loop
- if (strlen($word) < variable_get("remove_short", 0)) {
+ // If the word is too short, and we've got it set to skip them, loop.
+ if (strlen($word) < variable_get('remove_short', 0)) {
continue;
}
- // Put the next search word into the query and do the query
+ // Put the next search word into the query and do the query.
$query = str_replace("'%'", "'". check_query($word) ."'", $select);
$result = db_query($query);
- // If we got any results
if (db_num_rows($result) != 0) {
+ // At least one matching record was found.
$found = 1;
- // Create an in memory array of the results,
+ // Create an in memory array of the results.
while ($row = db_fetch_array($result)) {
- $lno = $row["lno"];
- $nid = $row["nid"];
- $title = $row["title"];
- $created = $row["created"];
- $uid = $row["uid"];
- $name = $row["name"];
- $count = $row["count"];
-
- // Build reduction variable
+ $lno = $row['lno'];
+ $nid = $row['nid'];
+ $title = $row['title'];
+ $created = $row['created'];
+ $uid = $row['uid'];
+ $name = $row['name'];
+ $count = $row['count'];
+
+ // Build reduction variable.
$reduction[$lno][$word] = true;
- // If the just fetched row is not already in the table
- if ($results[$lno]["lno"] != $lno) {
- $results[$lno]["count"] = $count;
+ // Check whether the just-fetched row is already in the table.
+ if ($results[$lno]['lno'] != $lno) {
+ $results[$lno]['count'] = $count;
- $results[$lno]["lno"] = $lno;
- $results[$lno]["nid"] = $nid;
- $results[$lno]["title"] = $title;
- $results[$lno]["created"] = $created;
- $results[$lno]["uid"] = $uid;
- $results[$lno]["name"] = $name;
+ $results[$lno]['lno'] = $lno;
+ $results[$lno]['nid'] = $nid;
+ $results[$lno]['title'] = $title;
+ $results[$lno]['created'] = $created;
+ $results[$lno]['uid'] = $uid;
+ $results[$lno]['name'] = $name;
}
else {
- /*
- ** Different word, but existing "lno", increase the count of
- ** matches against this "lno" by the number of times this
- ** word appears in the text
- */
- $results[$lno]["count"] = $results[$lno]["count"] + $count;
+ // Different word, but existing "lno". Increase the count of
+ // matches against this "lno" by the number of times this
+ // word appears in the text.
+ $results[$lno]['count'] = $results[$lno]['count'] + $count;
}
}
}
@@ -163,24 +190,25 @@ function do_search($search_array) {
}
}
if ($found) {
- // Black magic here to sort the results
+ // Black magic here to sort the results.
array_multisort($results, SORT_DESC);
- // OK, time to output the results.
+ // Now, output the results.
foreach ($results as $key => $value) {
- $lno = $value["lno"];
- $nid = $value["nid"];
- $title = $value["title"];
- $created = $value["created"];
- $uid = $value["uid"];
- $name = $value["name"];
- $count = $value["count"];
+ $lno = $value['lno'];
+ $nid = $value['nid'];
+ $title = $value['title'];
+ $created = $value['created'];
+ $uid = $value['uid'];
+ $name = $value['name'];
+ $count = $value['count'];
switch ($type) {
- case "node":
- $find[$i++] = array("count" => $count, "title" => $title, "link" => (strstr(request_uri(), "admin") ? url("admin/node/edit/$lno") : url("node/view/$lno")), "user" => $name, "date" => $created, "keywords" => implode("|", $words));
- break;
- case "comment":
- $find[$i++] = array("count" => $count, "title" => $title, "link" => (strstr(request_uri(), "admin") ? url("admin/comment/edit/$lno") : url("node/view/$nid", NULL, "comment-$lno")), "user" => $name, "date" => $created, "keywords" => implode("|", $words));
+ case 'node':
+ $find[$i++] = array('count' => $count, 'title' => $title, 'link' => url("node/$lno"), 'user' => $name, 'date' => $created, 'keywords' => implode('|', $words));
+ break;
+ case 'comment':
+ $find[$i++] = array('count' => $count, 'title' => $title, 'link' => (strstr(request_uri(), 'admin') ? url("admin/comment/edit/$lno") : url("node/$nid", NULL, "comment-$lno")), 'user' => $name, 'date' => $created, 'keywords' => implode('|', $words));
+ break;
break;
}
}
@@ -190,72 +218,64 @@ function do_search($search_array) {
}
/**
- * Update the search_index table
+ * Update the search_index table.
*
- * @param $search_array an array as returned from <i>module</i>_update_index
- * of type array("last_update" => ..., "node_type" => ..., "select" => ...)
- * @see node_update_index for an explanation of array items
+ * @param $search_array
+ * An array as returned from hook_update_index().
*/
function update_index($search_array) {
- $last_update = variable_get($search_array["last_update"], 1);
- $node_type = $search_array["node_type"];
- $select = $search_array["select"];
- $minimum_word_size = variable_get("minimum_word_size", 2);
+ $last_update = variable_get($search_array['last_update'], 1);
+ $node_type = $search_array['node_type'];
+ $select = $search_array['select'];
+ $minimum_word_size = variable_get('minimum_word_size', 2);
- //watchdog("user", "$last_update<br />$node_type<br />$select");
+ //watchdog('user', "$last_update<br />$node_type<br />$select");
$result = db_query($select);
if (db_num_rows($result)) {
- // Wohoo, found some, look through the nodes we just selected
+ // Results were found. Look through the nodes we just selected.
while ($node = db_fetch_array ($result)) {
- /*
- ** Trash any existing entries in the search index for this node,
- ** in case its a modified node.
- */
- db_query("DELETE from {search_index} where lno = '". $node["lno"] ."' and type = '". $node_type ."'");
+ // Trash any existing entries in the search index for this node,
+ // in case it is a modified node.
+ db_query("DELETE from {search_index} where lno = '". $node['lno'] ."' and type = '". $node_type ."'");
- /*
- ** Build the wordlist, teaser not included, as it then gives a
- ** false count of the number of hits, and doesn't show up
- ** when clicking on a node from the search interface anyway.
- */
- $wordlist = $node["text1"] ." ". $node["text2"];
+ // Build the word list (teaser not included, as it would give a
+ // false count of the number of hits).
+ $wordlist = $node['text1'] .' '. $node['text2'];
- // Strip heaps of stuff out of it
- $wordlist = preg_replace("'<[\/\!]*?[^<>]*?>'si", "", $wordlist);
+ // Strip heaps of stuff out of it.
+ $wordlist = preg_replace("'<[\/\!]*?[^<>]*?>'si", '', $wordlist);
- // Remove punctuation and stuff
- $wordlist = preg_replace("'(\xBB|\xAB|!|\xA1|%|,|:|;|\(|\)|\&|\"|\'|\.|-|\/|\?|\\\)'", "", $wordlist);
+ // Remove punctuation/special characters.
+ $wordlist = preg_replace("'(\xBB|\xAB|!|\xA1|%|,|:|;|\(|\)|\&|\"|\'|\.|-|\/|\?|\\\)'", '', $wordlist);
// Strip out (now mangled) http and tags.
- $wordlist = preg_replace("'http\w+'", "", $wordlist);
- $wordlist = preg_replace("'www\w+'", "", $wordlist);
+ $wordlist = preg_replace("'http\w+'", '', $wordlist);
+ $wordlist = preg_replace("'www\w+'", '', $wordlist);
- // Remove all newlines of any type
- $wordlist = preg_replace("'([\r\n]|[\r]|[\n])'", " ", $wordlist);
+ // Remove all newlines of any type.
+ $wordlist = preg_replace("'([\r\n]|[\r]|[\n])'", ' ', $wordlist);
// Lower case the whole thing.
$wordlist = strtolower($wordlist);
- // Remove "noisewords"
- $noise = explode(",", variable_get("noisewords", ""));
+ // Remove "noise words".
+ $noise = explode(',', variable_get('noisewords', ''));
foreach ($noise as $word) {
$word = trim($word);
- $wordlist = trim(preg_replace("' $word '", " ", " " .$wordlist. " "));
+ $wordlist = trim(preg_replace("' $word '", ' ', ' ' .$wordlist. ' '));
}
- // Remove whitespace
- $wordlist = preg_replace("'[\s]+'", " ", $wordlist);
+ // Remove whitespace.
+ $wordlist = preg_replace("'[\s]+'", ' ', $wordlist);
- // Make it an array
- $eachword = explode(" ", $wordlist);
+ // Make it an array.
+ $eachword = explode(' ', $wordlist);
- /*
- ** walk through the array, giving a "weight" to each word, based on
- ** the number of times it appears in a page.
- */
+ // Walk through the array, giving a "weight" to each word based on
+ // the number of times it appears in a page.
foreach ($eachword as $word) {
if (strlen($word) >= $minimum_word_size) {
if ($newwords[$word]) {
@@ -267,23 +287,21 @@ function update_index($search_array) {
}
}
- /*
- ** Walk through the weighted words array, inserting them into
- ** the search index
- */
+ // Walk through the weighted words array, inserting them into
+ // the search index.
if ($newwords) {
foreach ($newwords as $key => $value) {
- db_query("INSERT INTO {search_index} VALUES('%s', %d, '%s', %d)", $key, $node["lno"], $node_type, $value);
+ db_query("INSERT INTO {search_index} VALUES('%s', %d, '%s', %d)", $key, $node['lno'], $node_type, $value);
}
}
- // Zap the weighted words array, so we don't add multiples.
+ // Reset the weighted words array, so we don't add multiples.
$newwords = array ();
}
}
- // update the last time this process was run.
- variable_set($search_array["last_update"], time());
+ // Update the last time this process was run.
+ variable_set($search_array['last_update'], time());
return true;
}
@@ -291,9 +309,9 @@ function update_index($search_array) {
function search_invalidate() {
foreach (module_list() as $module) {
- $module_array = module_invoke($module, "update_index");
+ $module_array = module_invoke($module, 'update_index');
if ($module_array) {
- variable_set($module_array["last_update"], 1);
+ variable_set($module_array['last_update'], 1);
}
$module_array = null;
}
@@ -303,59 +321,64 @@ function search_invalidate() {
/**
* Save the values entered by the administrator for the search module
*
- * @param $edit An array of fields as setup via calling form_textfield,
- * form_textarea etc
+ * @param $edit
+ * An array of fields as set up by calling form_textfield(),
+ * form_textarea(), etc.
*/
function search_save($edit) {
- variable_set("minimum_word_size", $edit["minimum_word_size"]);
+ variable_set('minimum_word_size', $edit['minimum_word_size']);
- $data = strtr($edit["noisewords"], "\n\r\t", " ");
- $data = str_replace(" ", "", $data);
- variable_set("noisewords", $data);
- variable_set("help_pos", $edit["help_pos"]);
- variable_set("remove_short", $edit["remove_short"]);
+ $data = strtr($edit['noisewords'], "\n\r\t", ' ');
+ $data = str_replace(' ', '', $data);
+ variable_set('noisewords', $data);
+ variable_set('help_pos', $edit['help_pos']);
+ variable_set('remove_short', $edit['remove_short']);
}
-function search_view($keys) {
+/**
+ * Menu callback; presents the search form and/or search results.
+ */
+function search_view() {
global $type;
+ $keys = isset($_GET['keys']) ? $_GET['keys'] : $_POST['keys'];
- if (user_access("search content")) {
- // Construct the search form:
+ if (user_access('search content')) {
+ // Construct the search form.
$output = search_form(NULL, $keys, TRUE);
- // Display form and search results:
- $help_link = l(t("search help"), "search/help");
- switch (variable_get("help_pos", 1)) {
- case "1":
- $output = search_help(). $output ."<br />";
+ // Display form and search results.
+ $help_link = l(t('search help'), 'search/help');
+ switch (variable_get('help_pos', 1)) {
+ case '1':
+ $output = search_help(). $output .'<br />';
break;
- case "2":
- $output .= search_help() ."<br />";
+ case '2':
+ $output .= search_help() .'<br />';
break;
- case "3":
- $output = $help_link. "<br />". $output ."<br />";
+ case '3':
+ $output = $help_link. '<br />'. $output .'<br />';
break;
- case "4":
- $output .= "<br />". $help_link ."<br />";
+ case '4':
+ $output .= '<br />'. $help_link .'<br />';
}
// Only perform search if there is non-whitespace search term:
if (trim($keys)) {
// Log the search keys:
- watchdog('search', t('search: "%keys"', array('%keys' => $keys)), l("view results", "search", NULL, "keys=". urlencode($keys)));
+ watchdog('search', t('search: "%keys"', array('%keys' => $keys)), l('view results', 'search', NULL, 'keys='. urlencode($keys)));
// Collect the search results:
$results = search_data($keys);
if ($results) {
- $output .= theme("box", t("Search Results"), $results);
+ $output .= theme('box', t('Search Results'), $results);
}
else {
- $output .= theme("box", t("Search Results"), t("Your search yielded no results."));
+ $output .= theme('box', t('Search Results'), t('Your search yielded no results.'));
}
}
- print theme("page", $output, t("Search"));
+ print theme('page', $output, t('Search'));
}
else {
drupal_access_denied();
@@ -363,16 +386,11 @@ function search_view($keys) {
}
-function search_page() {
- $keys = isset($_GET["keys"]) ? $_GET["keys"] : $_POST["keys"];
-
- switch (arg(1)) {
- case "help":
- print theme("page", search_help(), t("Search Help"));
- break;
- default:
- search_view($keys);
- }
+/**
+ * Menu callback; prints the search engine help page.
+ */
+function search_help_page() {
+ print theme('page', search_help());
}
?>
diff --git a/modules/statistics.module b/modules/statistics.module
index 01a61dd72..71b4dfbfe 100644
--- a/modules/statistics.module
+++ b/modules/statistics.module
@@ -46,10 +46,10 @@ function statistics_help($section) {
<li><em>administer statistics module</em> - enable for user roles that get to configure the statistics module.</li><li><em>administer statistics</em> - enable for user roles that get to view the referrer statistics.</li>
</ul>
<p>If '<em>administer statistics</em>' and '<em>access statistics</em>' are both enabled, the user will see a link from each node to that node's referrer statistics (if enabled).</p>",
- array('%modules' => url('admin/system/modules'), '%permissions' => url('admin/user/permission'), '%referer' => url('admin/logs/referrer'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/system/modules/statistics'), '%block' => url('admin/system/block')));
- case 'admin/system/modules#description':
+ array('%modules' => url('admin/modules'), '%permissions' => url('admin/user/permission'), '%referer' => url('admin/logs/referrer'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/settings/statistics'), '%block' => url('admin/block')));
+ case 'admin/modules#description':
return t('Logs access statistics for your site.');
- case 'admin/system/modules/statistics':
+ case 'admin/settings/statistics':
return t('Settings for the statistical information that Drupal will keep about the site. See <a href="%statistics">site statistics</a> for the actual information.', array('%statistics' => url('admin/logs/topnodes')));
case 'admin/logs/topnodes':
return t('This page gives you an at-a-glance look at your most popular content.');
@@ -140,21 +140,36 @@ function statistics_link($type, $node = 0, $main = 0) {
}
}
- if ($type == 'system') {
- menu('statistics', t('most popular content'), user_access('access content') ? 'statistics_page' : MENU_DENIED, 0, MENU_HIDE);
-
- $access = user_access('administer statistics module') || user_access('administer statistics');
-
- menu('admin/logs/topnodes', t('top nodes'), $access ? 'statistics_admin_topnodes' : MENU_DENIED, 1);
- menu('admin/logs/referrer', t('referrer'), $access ? 'statistics_top_refer' : MENU_DENIED, 2);
- menu('admin/logs/referrer/internal', t('internal referrers only'), MENU_FALLTHROUGH);
- menu('admin/logs/referrer/external', t('external referrers only'), MENU_FALLTHROUGH);
- menu('admin/logs/access', t('access'), $access ? 'statistics_admin_displaylog' : MENU_DENIED, 3);
- }
-
return $links;
}
+/**
+ * Implementation of hook_menu().
+ */
+function statistics_menu() {
+ $items = array();
+ $items[] = array('path' => 'statistics', 'title' => t('most popular content'),
+ 'callback' => 'statistics_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+
+ $access = user_access('administer statistics module') || user_access('administer statistics');
+ $items[] = array('path' => 'admin/logs/topnodes', 'title' => t('top nodes'),
+ 'callback' => 'statistics_admin_topnodes', 'access' => $access,
+ 'weight' => 1);
+ $items[] = array('path' => 'admin/logs/referrer', 'title' => t('referrer'),
+ 'callback' => 'statistics_top_refer', 'access' => $access,
+ 'weight' => 2);
+ $items[] = array('path' => 'admin/logs/referrer/internal', 'title' => t('internal referrers only'),
+ 'access' => $access);
+ $items[] = array('path' => 'admin/logs/referrer/external', 'title' => t('external referrers only'),
+ 'access' => $access);
+ $items[] = array('path' => 'admin/logs/access', 'title' => t('access'),
+ 'callback' => 'statistics_admin_displaylog', 'access' => $access,
+ 'weight' => 3);
+ return $items;
+}
+
function statistics_admin_topnodes_table() {
$header = array(
@@ -169,7 +184,7 @@ function statistics_admin_topnodes_table() {
$result = pager_query($sql, 20); // WHERE s.%s <> '0'
while ($nid = db_fetch_array($result)) {
- $rows[] = array(l($nid['title'], 'node/view/'. $nid['nid'], array('title' => t('View this posting.'))), $nid['daycount'], $nid['totalcount'], format_date($nid['timestamp'], 'small'), l('track node', "admin/logs/access/node/$nid[nid]"));
+ $rows[] = array(l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))), $nid['daycount'], $nid['totalcount'], format_date($nid['timestamp'], 'small'), l('track node', "admin/logs/access/node/$nid[nid]"));
}
if ($pager = theme('pager', NULL, 20, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 5));
@@ -226,7 +241,7 @@ function statistics_admin_accesslog_table($type, $id) {
$url = message_na();
}
- $rows[] = array(array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), ($log->nid ? l($log->title, "node/view/$log->nid") : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t('track node'), "admin/logs/access/node/$log->nid") : ''), ($user->uid ? l(t('track user'), "admin/logs/access/user/$user->uid") : ''), ($log->hostname ? l(t('track host'), "admin/logs/access/host/$log->hostname") : ''));
+ $rows[] = array(array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), ($log->nid ? l($log->title, "node/$log->nid") : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t('track node'), "admin/logs/access/node/$log->nid") : ''), ($user->uid ? l(t('track user'), "admin/logs/access/user/$user->uid") : ''), ($log->hostname ? l(t('track host'), "admin/logs/access/host/$log->hostname") : ''));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
@@ -513,7 +528,7 @@ function statistics_summary($dbfield, $dbrows) {
$content = node_load(array('nid' => $nid['nid']));
$links = link_node($content, 1);
- $output .= '<tr><td><strong>'. l($nid['title'], 'node/view/'. $nid['nid'], array('title' => t('View this posting.'))) .'</strong></td><td style="text-align: right;"><small>'. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .'</small></td></tr>';
+ $output .= '<tr><td><strong>'. l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))) .'</strong></td><td style="text-align: right;"><small>'. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .'</small></td></tr>';
$output .= '<tr><td colspan="2"><div style="margin-left: 20px;">'. check_output($content->teaser) .'</div></td></tr>';
$output .= '<tr><td style="text-align: right;" colspan="2">[ '. theme('links', $links) .' ]<br /><br /></td></tr>';
}
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 01a61dd72..71b4dfbfe 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -46,10 +46,10 @@ function statistics_help($section) {
<li><em>administer statistics module</em> - enable for user roles that get to configure the statistics module.</li><li><em>administer statistics</em> - enable for user roles that get to view the referrer statistics.</li>
</ul>
<p>If '<em>administer statistics</em>' and '<em>access statistics</em>' are both enabled, the user will see a link from each node to that node's referrer statistics (if enabled).</p>",
- array('%modules' => url('admin/system/modules'), '%permissions' => url('admin/user/permission'), '%referer' => url('admin/logs/referrer'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/system/modules/statistics'), '%block' => url('admin/system/block')));
- case 'admin/system/modules#description':
+ array('%modules' => url('admin/modules'), '%permissions' => url('admin/user/permission'), '%referer' => url('admin/logs/referrer'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/settings/statistics'), '%block' => url('admin/block')));
+ case 'admin/modules#description':
return t('Logs access statistics for your site.');
- case 'admin/system/modules/statistics':
+ case 'admin/settings/statistics':
return t('Settings for the statistical information that Drupal will keep about the site. See <a href="%statistics">site statistics</a> for the actual information.', array('%statistics' => url('admin/logs/topnodes')));
case 'admin/logs/topnodes':
return t('This page gives you an at-a-glance look at your most popular content.');
@@ -140,21 +140,36 @@ function statistics_link($type, $node = 0, $main = 0) {
}
}
- if ($type == 'system') {
- menu('statistics', t('most popular content'), user_access('access content') ? 'statistics_page' : MENU_DENIED, 0, MENU_HIDE);
-
- $access = user_access('administer statistics module') || user_access('administer statistics');
-
- menu('admin/logs/topnodes', t('top nodes'), $access ? 'statistics_admin_topnodes' : MENU_DENIED, 1);
- menu('admin/logs/referrer', t('referrer'), $access ? 'statistics_top_refer' : MENU_DENIED, 2);
- menu('admin/logs/referrer/internal', t('internal referrers only'), MENU_FALLTHROUGH);
- menu('admin/logs/referrer/external', t('external referrers only'), MENU_FALLTHROUGH);
- menu('admin/logs/access', t('access'), $access ? 'statistics_admin_displaylog' : MENU_DENIED, 3);
- }
-
return $links;
}
+/**
+ * Implementation of hook_menu().
+ */
+function statistics_menu() {
+ $items = array();
+ $items[] = array('path' => 'statistics', 'title' => t('most popular content'),
+ 'callback' => 'statistics_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_SUGGESTED_ITEM);
+
+ $access = user_access('administer statistics module') || user_access('administer statistics');
+ $items[] = array('path' => 'admin/logs/topnodes', 'title' => t('top nodes'),
+ 'callback' => 'statistics_admin_topnodes', 'access' => $access,
+ 'weight' => 1);
+ $items[] = array('path' => 'admin/logs/referrer', 'title' => t('referrer'),
+ 'callback' => 'statistics_top_refer', 'access' => $access,
+ 'weight' => 2);
+ $items[] = array('path' => 'admin/logs/referrer/internal', 'title' => t('internal referrers only'),
+ 'access' => $access);
+ $items[] = array('path' => 'admin/logs/referrer/external', 'title' => t('external referrers only'),
+ 'access' => $access);
+ $items[] = array('path' => 'admin/logs/access', 'title' => t('access'),
+ 'callback' => 'statistics_admin_displaylog', 'access' => $access,
+ 'weight' => 3);
+ return $items;
+}
+
function statistics_admin_topnodes_table() {
$header = array(
@@ -169,7 +184,7 @@ function statistics_admin_topnodes_table() {
$result = pager_query($sql, 20); // WHERE s.%s <> '0'
while ($nid = db_fetch_array($result)) {
- $rows[] = array(l($nid['title'], 'node/view/'. $nid['nid'], array('title' => t('View this posting.'))), $nid['daycount'], $nid['totalcount'], format_date($nid['timestamp'], 'small'), l('track node', "admin/logs/access/node/$nid[nid]"));
+ $rows[] = array(l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))), $nid['daycount'], $nid['totalcount'], format_date($nid['timestamp'], 'small'), l('track node', "admin/logs/access/node/$nid[nid]"));
}
if ($pager = theme('pager', NULL, 20, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => 5));
@@ -226,7 +241,7 @@ function statistics_admin_accesslog_table($type, $id) {
$url = message_na();
}
- $rows[] = array(array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), ($log->nid ? l($log->title, "node/view/$log->nid") : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t('track node'), "admin/logs/access/node/$log->nid") : ''), ($user->uid ? l(t('track user'), "admin/logs/access/user/$user->uid") : ''), ($log->hostname ? l(t('track host'), "admin/logs/access/host/$log->hostname") : ''));
+ $rows[] = array(array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), ($log->nid ? l($log->title, "node/$log->nid") : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t('track node'), "admin/logs/access/node/$log->nid") : ''), ($user->uid ? l(t('track user'), "admin/logs/access/user/$user->uid") : ''), ($log->hostname ? l(t('track host'), "admin/logs/access/host/$log->hostname") : ''));
}
if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
@@ -513,7 +528,7 @@ function statistics_summary($dbfield, $dbrows) {
$content = node_load(array('nid' => $nid['nid']));
$links = link_node($content, 1);
- $output .= '<tr><td><strong>'. l($nid['title'], 'node/view/'. $nid['nid'], array('title' => t('View this posting.'))) .'</strong></td><td style="text-align: right;"><small>'. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .'</small></td></tr>';
+ $output .= '<tr><td><strong>'. l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))) .'</strong></td><td style="text-align: right;"><small>'. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .'</small></td></tr>';
$output .= '<tr><td colspan="2"><div style="margin-left: 20px;">'. check_output($content->teaser) .'</div></td></tr>';
$output .= '<tr><td style="text-align: right;" colspan="2">[ '. theme('links', $links) .' ]<br /><br /></td></tr>';
}
diff --git a/modules/story.module b/modules/story.module
index 857ff2beb..104220551 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -6,9 +6,9 @@
*/
function story_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables users to submit stories, articles or similar content.');
- case 'admin/system/modules/story':
+ case 'admin/settings/story':
return t("Stories are like newspaper articles. They tend to follow a publishing flow of <strong>submit -&gt; moderate -&gt; post to the main page -&gt; comments</strong>. Below you may fix a minimum word count for stories and also write some submission or content guidelines for users wanting to post a story.");
case 'admin/help#story':
return t("
@@ -17,7 +17,7 @@ function story_help($section) {
<h3>User access permissions for stories</h3>
<p><strong>create stories:</strong> Allows a role to create stories. They cannot edit or delete stories, even if they are the authors. You must enable this permission to in order for a role to create a story.</p>
<p><strong>maintain personal stories:</strong> Allows a role to add/edit stories if they own the story. Use this permission if you want users to be able to edit and maintain their own stories.</p>
- ", array('%story-config' => url('admin/system/modules/story')));
+ ", array('%story-config' => url('admin/settings/story')));
case 'node/add/story':
return variable_get('story_help', '');
case 'node/add#story':
@@ -78,14 +78,10 @@ function story_access($op, $node) {
function story_link($type, $node = 0, $main) {
$links = array();
- if ($type == 'system') {
- menu('node/add/story', t('story'), story_access('create', $node) ? MENU_FALLTHROUGH : MENU_DENIED, 0);
- }
-
if ($type == 'node' && $node->type == 'story') {
- /* Don't display a redundant edit link if they are node administrators */
+ // Don't display a redundant edit link if they are node administrators.
if (story_access('update', $node) && !user_access('administer nodes')) {
- $links[] = l(t('edit this story'), "node/edit/$node->nid");
+ $links[] = l(t('edit this story'), "node/$node->nid/edit");
}
}
@@ -93,6 +89,16 @@ function story_link($type, $node = 0, $main) {
}
/**
+ * Implementation of hook_menu().
+ */
+function story_menu() {
+ $items = array();
+ $items[] = array('path' => 'node/add/story', 'title' => t('story'),
+ 'access' => story_access('create', NULL));
+ return $items;
+}
+
+/**
* Implementation of hook_validate().
*
* Ensures the story is of adequate length.
diff --git a/modules/story/story.module b/modules/story/story.module
index 857ff2beb..104220551 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -6,9 +6,9 @@
*/
function story_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables users to submit stories, articles or similar content.');
- case 'admin/system/modules/story':
+ case 'admin/settings/story':
return t("Stories are like newspaper articles. They tend to follow a publishing flow of <strong>submit -&gt; moderate -&gt; post to the main page -&gt; comments</strong>. Below you may fix a minimum word count for stories and also write some submission or content guidelines for users wanting to post a story.");
case 'admin/help#story':
return t("
@@ -17,7 +17,7 @@ function story_help($section) {
<h3>User access permissions for stories</h3>
<p><strong>create stories:</strong> Allows a role to create stories. They cannot edit or delete stories, even if they are the authors. You must enable this permission to in order for a role to create a story.</p>
<p><strong>maintain personal stories:</strong> Allows a role to add/edit stories if they own the story. Use this permission if you want users to be able to edit and maintain their own stories.</p>
- ", array('%story-config' => url('admin/system/modules/story')));
+ ", array('%story-config' => url('admin/settings/story')));
case 'node/add/story':
return variable_get('story_help', '');
case 'node/add#story':
@@ -78,14 +78,10 @@ function story_access($op, $node) {
function story_link($type, $node = 0, $main) {
$links = array();
- if ($type == 'system') {
- menu('node/add/story', t('story'), story_access('create', $node) ? MENU_FALLTHROUGH : MENU_DENIED, 0);
- }
-
if ($type == 'node' && $node->type == 'story') {
- /* Don't display a redundant edit link if they are node administrators */
+ // Don't display a redundant edit link if they are node administrators.
if (story_access('update', $node) && !user_access('administer nodes')) {
- $links[] = l(t('edit this story'), "node/edit/$node->nid");
+ $links[] = l(t('edit this story'), "node/$node->nid/edit");
}
}
@@ -93,6 +89,16 @@ function story_link($type, $node = 0, $main) {
}
/**
+ * Implementation of hook_menu().
+ */
+function story_menu() {
+ $items = array();
+ $items[] = array('path' => 'node/add/story', 'title' => t('story'),
+ 'access' => story_access('create', NULL));
+ return $items;
+}
+
+/**
* Implementation of hook_validate().
*
* Ensures the story is of adequate length.
diff --git a/modules/system.module b/modules/system.module
index 76372d8d6..affee64f7 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -1,22 +1,21 @@
<?php
// $Id$
-function system_help($section = "admin/help#system") {
+/**
+ * Implementation of hook_help().
+ */
+function system_help($section) {
global $base_url;
- $output = "";
switch ($section) {
- case 'admin/system':
- $output = t("General configuration options for your site. Set up the name of the site, e-mail address used in mail-outs, clean URL options, caching, etc.");
- break;
- case 'admin/system/themes':
- $output = t("Select which themes are available to your users and specify the default theme.");
- break;
- case 'admin/system/modules':
- $output = t("Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. Click on the name of the module in the navigation menu for their individual configuration pages. Once a module is enabled, new <a href=\"%permissions\">permissions</a> might be made available. Modules can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array("%permissions" => url("admin/user/permission"), "%throttle" => url("admin/system/modules/throttle")));
- break;
+ case 'admin':
+ return t('General configuration options for your site. Set up the name of the site, e-mail address used in mail-outs, clean URL options, caching, etc.');
+ case 'admin/themes':
+ return t('Select which themes are available to your users and specify the default theme.');
+ case 'admin/modules':
+ return t("Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. Click on the name of the module in the navigation menu for their individual configuration pages. Once a module is enabled, new <a href=\"%permissions\">permissions</a> might be made available. Modules can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array('%permissions' => url('admin/user/permission'), '%throttle' => url('admin/settings/throttle')));
case 'admin/help#system':
- $output .= t("
+ return t("
<p>Drupal comes with system-wide defaults but the setting-module provides control over many Drupal preferences, behaviours including visual and operational settings.</p>
<h3><a id=\"cron\">Cron</a></h3>
<p>Some modules require regularly scheduled actions, such as cleaning up logfiles. Cron, which stands for chronograph, is a periodic command scheduler executing commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period measured in seconds). Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution.</p>
@@ -27,75 +26,92 @@ function system_help($section = "admin/help#system") {
<pre> 00 * * * * /home/www/drupal/scripts/cron-lynx.sh</pre>
Note that it is essential to access <code>cron.php</code> using a browser on the web site's domain; do not run it using command line PHP and avoid using <code>localhost</code> or <code>127.0.0.1</code> or some of the environment varibles will not be set correctly and features may not work as expected.</p>
<h3><a id=\"cache\">Cache</a></h3>
- <p>Drupal has a caching mechanism which stores dynamically generated web pages in a database. By caching a web page, Drupal does not have to create the page each time someone wants to view it, instead it takes only one SQL query to display it, reducing response time and the server's load. Only pages requested by \"anonymous\" users are cached.</p>", array("%base_url" => $base_url, "%cron-link" => "<a href=\"$base_url/cron.php\">$base_url/cron.php</a>", "%lynx" => "http://lynx.browser.org", "%wget" => "http://www.gnu.org/software/wget/wget.html" ));
- break;
- case 'admin/system/modules#description':
- $output = t("Configuration system that lets administrators modify the workings of the site.");
- break;
+ <p>Drupal has a caching mechanism which stores dynamically generated web pages in a database. By caching a web page, Drupal does not have to create the page each time someone wants to view it, instead it takes only one SQL query to display it, reducing response time and the server's load. Only pages requested by \"anonymous\" users are cached.</p>", array('%base_url' => $base_url, '%cron-link' => "<a href=\"$base_url/cron.php\">$base_url/cron.php</a>", '%lynx' => 'http://lynx.browser.org', '%wget' => 'http://www.gnu.org/software/wget/wget.html' ));
+ case 'admin/modules#description':
+ return t('Configuration system that lets administrators modify the workings of the site.');
}
-
- return $output;
}
+/**
+ * Menu callback; presents system-specific help text from admin/help.
+ */
function system_help_page() {
- print theme("page", system_help());
+ print theme('page', system_help('admin/help#system'));
}
+/**
+ * Implementation of hook_perm().
+ */
function system_perm() {
- return array("administer site configuration", "access administration pages", "bypass input data check", "create php content");
+ return array('administer site configuration', 'access administration pages', 'bypass input data check', 'create php content');
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function system_link($type) {
- if ($type == 'system') {
- menu('system/files', t('file download'), 'file_download', 0, MENU_HIDE, MENU_LOCKED);
- $access = user_access('administer site configuration');
-
- menu('admin/system', t('configuration'), $access ? 'system_admin' : MENU_DENIED, 3);
- menu('admin/system/themes', t('themes'), $access ? 'system_admin' : MENU_DENIED, 2);
-
- foreach (list_themes() as $theme) {
- // TODO: reenable 'forced refresh' once we move the menu_build() later in the request. it added overhead with no benefit
- // NOTE: refresh the list because some themes might have been enabled/disabled.
- include_once "$theme->filename";
- $function = $theme->name .'_settings';
- if (function_exists($function)) {
- menu("admin/system/themes/$theme->name", $theme->name, $access ? 'system_admin' : MENU_DENIED);
- }
+function system_menu() {
+ $items = array();
+ $items[] = array('path' => 'system/files', 'title' => t('file download'),
+ 'callback' => 'file_download',
+ 'access' => TRUE,
+ 'type' => MENU_CALLBACK);
+
+ $access = user_access('administer site configuration');
+ // Themes:
+ $items[] = array('path' => 'admin/themes', 'title' => t('themes'),
+ 'callback' => 'system_themes', 'access' => $access);
+ foreach (list_themes() as $theme) {
+ // TODO: reenable 'forced refresh' once we move the menu_build() later
+ // in the request. It added overhead with no benefit.
+ // NOTE: refresh the list because some themes might have been enabled/disabled.
+ include_once $theme->filename;
+ $function = $theme->name .'_settings';
+ if (function_exists($function)) {
+ $items[] = array('path' => 'admin/themes/'. $theme->name, 'title' => $theme->name,
+ 'callback' => 'system_configure_theme', 'access' => $access);
}
+ }
- menu('admin/system/modules', t('modules'), $access ? 'system_admin' : MENU_DENIED, 3);
- foreach (module_list() as $name) {
- // TODO: reenable 'forced refresh' once we move the menu_build() later in the request. it added overhead with no benefit
- // NOTE: refresh the list because some modules might have been enabled/disabled.
- if (module_hook($name, 'settings')) {
- menu("admin/system/modules/$name", t($name), $access ? 'system_admin' : MENU_DENIED);
- }
+ // Modules:
+ $items[] = array('path' => 'admin/settings', 'title' => t('settings'),
+ 'callback' => 'system_site_settings', 'access' => $access);
+ foreach (module_list() as $name) {
+ // TODO: reenable 'forced refresh' once we move the menu_build() later
+ // in the request. It added overhead with no benefit.
+ // NOTE: refresh the list because some modules might have been enabled/disabled.
+ if (module_hook($name, 'settings')) {
+ $items[] = array('path' => 'admin/settings/'. $name, 'title' => t($name));
}
- menu('admin/system/help', t('help'), $access ? 'system_help_page' : MENU_DENIED, 9);
}
+ $items[] = array('path' => 'admin/modules', 'title' => t('modules'),
+ 'callback' => 'system_modules', 'access' => $access);
+
+ return $items;
}
+/**
+ * Implementation of hook_user().
+ *
+ * Allows users to individually set their theme and time zone.
+ */
function system_user($type, $edit, &$user) {
if ($type == 'form') {
- $options = "<option value=\"\">". t("Default theme") ."</option>\n";
+ $options = '<option value="">'. t('Default theme') ."</option>\n";
if (count($themes = list_themes()) > 1) {
foreach ($themes as $key => $value) {
- $options .= "<option value=\"$key\"". (($edit["theme"] == $key) ? " selected=\"selected\"" : "") .">$key - $value->description</option>\n";
+ $options .= "<option value=\"$key\"". (($edit['theme'] == $key) ? ' selected="selected"' : '') .">$key - $value->description</option>\n";
}
- $data[t('Theme settings')] = form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site."));
+ $data[t('Theme settings')] = form_item(t('Theme'), "<select name=\"edit[theme]\">$options</select>", t('Selecting a different theme will change the look and feel of the site.'));
}
- if (!variable_get("sitewide_timezone", 0)) {
+ if (!variable_get('sitewide_timezone', 0)) {
$timestamp = time();
$zonelist = array(-11, -10, -9.5, -9, -8, -7, -6, -5, -4, -3.5, -3, -2, -1, 0, 1, 2, 3, 3.5, 4, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 14);
foreach ($zonelist as $offset) {
$zone = $offset * 3600;
$zones[$zone] = format_date($timestamp, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone);
}
- $data[t('Locale settings')] = form_select(t("Time zone"), "timezone", $edit["timezone"], $zones, t("Select what time you currently have and your time zone settings will be set appropriate."));
+ $data[t('Locale settings')] = form_select(t('Time zone'), 'timezone', $edit['timezone'], $zones, t('Select what time you currently have and your time zone settings will be set appropriately.'));
}
return $data;
}
@@ -105,23 +121,28 @@ function system_view_general() {
global $conf;
// general settings:
- $group = form_textfield(t("Name"), "site_name", variable_get("site_name", "drupal"), 70, 70, t("The name of this web site."));
- $group .= form_textfield(t("E-mail address"), "site_mail", variable_get("site_mail", ini_get("sendmail_from")), 70, 128, t("A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc."));
- $group .= form_textfield(t("Slogan"), "site_slogan", variable_get("site_slogan", ""), 70, 128, t("The slogan of this website. Some themes display a slogan when available."));
- $group .= form_textarea(t("Mission"), "site_mission", variable_get("site_mission", ""), 70, 5, t("Your site's mission statement or focus."));
- $group .= form_textarea(t("Footer message"), "site_footer", variable_get("site_footer", ""), 70, 5, t("This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages."));
- $group .= form_textfield(t("Anonymous user"), "anonymous", variable_get("anonymous", "Anonymous"), 70, 70, t("The name used to indicate anonymous users."));
- $group .= form_textfield(t("Default front page"), "site_frontpage", variable_get("site_frontpage", "node"), 70, 70, t("The home page displays content from this relative URL. If you are not using clean URLs, specify the part after '?q='. If unsure, specify 'node'."));
- $group .= form_textfield(t("Default 403 (access denied) page"), "site_403", variable_get("site_403", ""), 70, 70, t("This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after '?q='. If unsure, specify nothing."));
- $group .= form_textfield(t("Default 404 (not found) page"), "site_404", variable_get("site_404", ""), 70, 70, t("This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after '?q='. If unsure, specify nothing."));
- $group .= form_radios(t("Clean URLs"), "clean_url", variable_get("clean_url", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable clean URLs. If enabled, you'll need <code>ModRewrite</code> support. See also the <code>.htaccess</code> file in Drupal's top-level directory."));
-
- $output = form_group(t("General settings"), $group);
+ $group = form_textfield(t('Name'), 'site_name', variable_get('site_name', 'drupal'), 70, 70, t('The name of this web site.'));
+ $group .= form_textfield(t('E-mail address'), 'site_mail', variable_get('site_mail', ini_get('sendmail_from')), 70, 128, t('A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc.'));
+ $group .= form_textfield(t('Slogan'), 'site_slogan', variable_get('site_slogan', ''), 70, 128, t('The slogan of this website. Some themes display a slogan when available.'));
+ $group .= form_textarea(t('Mission'), 'site_mission', variable_get('site_mission', ''), 70, 5, t('Your site\'s mission statement or focus.'));
+ $group .= form_textarea(t('Footer message'), 'site_footer', variable_get('site_footer', ''), 70, 5, t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.'));
+ $group .= form_textfield(t('Anonymous user'), 'anonymous', variable_get('anonymous', 'Anonymous'), 70, 70, t('The name used to indicate anonymous users.'));
+ $group .= form_textfield(t('Default front page'), 'site_frontpage', variable_get('site_frontpage', 'node'), 70, 70, t('The home page displays content from this relative URL. If you are not using clean URLs, specify the part after "?q=". If unsure, specify "node".'));
+ $group .= form_textfield(t('Default 403 (access denied) page'), 'site_403', variable_get('site_403', ''), 70, 70, t('This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
+ $group .= form_textfield(t('Default 404 (not found) page'), 'site_404', variable_get('site_404', ''), 70, 70, t('This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
+ $group .= form_radios(t('Clean URLs'), 'clean_url', variable_get('clean_url', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable clean URLs. If enabled, you\'ll need <code>ModRewrite</code> support. See also the <code>.htaccess</code> file in Drupal\'s top-level directory.'));
+
+ // watchdog setting:
+ $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
+ $period['1000000000'] = t('Never');
+ $group .= form_select(t('Discard log entries older than'), 'watchdog_clear', variable_get('watchdog_clear', 604800), $period, t('The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.'));
+
+ $output = form_group(t('General settings'), $group);
// caching:
- $group = form_radios(t("Cache support"), "cache", variable_get("cache", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable the caching of rendered pages. When caching is enabled, Drupal will flush the cache when required to make sure updates take effect immediately. Check the <a href=\"%documentation\">cache documentation</a> for information on Drupal's cache system.", array("%documentation" => url("admin/system/help", NULL, NULL, "cache"))));
+ $group = form_radios(t('Cache support'), 'cache', variable_get('cache', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable the caching of rendered pages. When caching is enabled, Drupal will flush the cache when required to make sure updates take effect immediately. Check the <a href="%documentation">cache documentation</a> for information on Drupal\'s cache system.', array('%documentation' => url('admin/help', NULL, NULL, 'cache'))));
- $output .= form_group(t("Cache settings"), $group);
+ $output .= form_group(t('Cache settings'), $group);
// file system:
if (!file_check_directory(variable_get('file_directory_path', 'files'))) {
@@ -144,93 +165,50 @@ function system_view_general() {
}
// date settings: possible date formats
- $dateshort = array("m/d/Y - H:i", "d/m/Y - H:i", "Y/m/d - H:i",
- "m/d/Y - g:ia", "d/m/Y - g:ia", "Y/m/d - g:ia",
- "M j Y - H:i", "j M Y - H:i", "Y M j - H:i",
- "M j Y - g:ia", "j M Y - g:ia", "Y M j - g:ia");
- $datemedium = array("D, m/d/Y - H:i", "D, d/m/Y - H:i", "D, Y/m/d - H:i",
- "F j, Y - H:i", "j F, Y - H:i", "Y, F j - H:i",
- "D, m/d/Y - g:ia", "D, d/m/Y - g:ia", "D, Y/m/d - g:ia",
- "F j, Y - g:ia", "j F, Y - g:ia", "Y, F j - g:ia");
- $datelong = array("l, F j, Y - H:i", "l, j F, Y - H:i", "l, Y, F j - H:i",
- "l, F j, Y - g:ia", "l, j F, Y - g:ia", "l, Y, F j - g:ia");
+ $dateshort = array('m/d/Y - H:i', 'd/m/Y - H:i', 'Y/m/d - H:i',
+ 'm/d/Y - g:ia', 'd/m/Y - g:ia', 'Y/m/d - g:ia',
+ 'M j Y - H:i', 'j M Y - H:i', 'Y M j - H:i',
+ 'M j Y - g:ia', 'j M Y - g:ia', 'Y M j - g:ia');
+ $datemedium = array('D, m/d/Y - H:i', 'D, d/m/Y - H:i', 'D, Y/m/d - H:i',
+ 'F j, Y - H:i', 'j F, Y - H:i', 'Y, F j - H:i',
+ 'D, m/d/Y - g:ia', 'D, d/m/Y - g:ia', 'D, Y/m/d - g:ia',
+ 'F j, Y - g:ia', 'j F, Y - g:ia', 'Y, F j - g:ia');
+ $datelong = array('l, F j, Y - H:i', 'l, j F, Y - H:i', 'l, Y, F j - H:i',
+ 'l, F j, Y - g:ia', 'l, j F, Y - g:ia', 'l, Y, F j - g:ia');
// date settings: construct choices for user
foreach ($dateshort as $f) {
- $dateshortchoices[$f] = format_date(time(), "custom", $f);
+ $dateshortchoices[$f] = format_date(time(), 'custom', $f);
}
foreach ($datemedium as $f) {
- $datemediumchoices[$f] = format_date(time(), "custom", $f);
+ $datemediumchoices[$f] = format_date(time(), 'custom', $f);
}
foreach ($datelong as $f) {
- $datelongchoices[$f] = format_date(time(), "custom", $f);
+ $datelongchoices[$f] = format_date(time(), 'custom', $f);
}
- $group = form_select(t("Time zone"), "date_default_timezone", variable_get('date_default_timezone', 0), $zones, t("Select the default site timezone."));
- $group .= form_radios(t("Use sitewide timezone"), "sitewide_timezone", variable_get("sitewide_timezone", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable the sidewide timezone feature. Disabled means that users could choose their own timezone."));
- $group .= form_select(t("Date format (short)"), "date_format_short", variable_get("date_format_short", $dateshort[0]), $dateshortchoices, t("The short format of date display."));
- $group .= form_select(t("Date format (medium)"), "date_format_medium", variable_get("date_format_medium", $datemedium[0]), $datemediumchoices, t("The medium sized date display."));
- $group .= form_select(t("Date format (long)"), "date_format_long", variable_get("date_format_long", $datelong[0]), $datelongchoices, t("Longer date format used for detailed display."));
+ $group = form_select(t('Time zone'), 'date_default_timezone', variable_get('date_default_timezone', 0), $zones, t('Select the default site timezone.'));
+ $group .= form_radios(t('Use sitewide timezone'), 'sitewide_timezone', variable_get('sitewide_timezone', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable the sidewide timezone feature. Disabled means that users could choose their own timezone.'));
+ $group .= form_select(t('Date format (short)'), 'date_format_short', variable_get('date_format_short', $dateshort[0]), $dateshortchoices, t('The short format of date display.'));
+ $group .= form_select(t('Date format (medium)'), 'date_format_medium', variable_get('date_format_medium', $datemedium[0]), $datemediumchoices, t('The medium sized date display.'));
+ $group .= form_select(t('Date format (long)'), 'date_format_long', variable_get('date_format_long', $datelong[0]), $datelongchoices, t('Longer date format used for detailed display.'));
- $output .= form_group(t("Date format settings"), $group);
+ $output .= form_group(t('Date format settings'), $group);
return $output;
}
-function system_view_theme($name) {
- $themes = list_themes();
- $theme = $themes[$name];
- if ($theme) {
- include_once "$theme->filename";
-
- $function = $theme->name ."_settings";
- if (function_exists($function)) {
- $output .= $function();
- }
- }
- else {
- $output = t("Invalid theme specified");
- }
- return $output;
-}
-
-function system_view($type, $arg = "") {
- // The module/theme lists don't use the generic settings handler
- if (($type == "modules" || $type == "themes") && $arg == "") {
- system_listing_save();
- $form = system_listing($type);
- $form .= form_submit(t("Save configuration"));
- return form($form);
- }
-
- system_settings_save();
-
- switch ($type) {
- case "modules":
- $form = module_invoke($arg, "settings");
- break;
- case "themes":
- $form = system_view_theme($arg);
- break;
- default:
- $form = system_view_general();
- break;
- }
-
- return system_settings_form($form);
-}
-
function system_listing($type) {
// Pick appropriate directory and filetype
switch ($type) {
- case "modules":
- $directory = "modules";
- $type = "module";
+ case 'modules':
+ $directory = 'modules';
+ $type = 'module';
break;
- case "themes":
+ case 'themes':
default:
- $directory = "themes";
- $type = "theme";
+ $directory = 'themes';
+ $type = 'theme';
break;
}
@@ -249,23 +227,23 @@ function system_listing($type) {
ksort($files);
- if ($type == "module") {
- $required = array("modules/admin.module", "modules/filter.module", "modules/system.module", "modules/user.module", "modules/watchdog.module");
+ if ($type == 'module') {
+ $required = array('modules/admin.module', 'modules/filter.module', 'modules/system.module', 'modules/user.module', 'modules/watchdog.module');
// the throttle mechanism requires additional modules always be enabled
- $throttle_required = array_merge($required, array("modules/statistics.module", "modules/throttle.module"));
+ $throttle_required = array_merge($required, array('modules/statistics.module', 'modules/throttle.module'));
- $header = array(t("name"), t("description"), t("status"), t("throttle"));
+ $header = array(t('name'), t('description'), t('status'), t('throttle'));
}
else {
$required = array();
- $header = array(t("name"), t("description"), t("enable"), t("default"));
+ $header = array(t('name'), t('description'), t('enable'), t('default'));
}
foreach ($files as $filename => $file) {
include_once($filename);
- if ($type == "module") {
- $info->name = module_invoke($file->name, "help", "admin/system/modules#name") ? module_invoke($file->name, "help", "admin/system/modules#name") : module_invoke($file->name, "system", "name") ? module_invoke($file->name, "system", "name") : $file->name;
- $info->description = module_invoke($file->name, "help", "admin/system/modules#description") ? module_invoke($file->name, "help", "admin/system/modules#description") : module_invoke($file->name, "system", "description");
+ if ($type == 'module') {
+ $info->name = module_invoke($file->name, 'help', 'admin/modules#name') ? module_invoke($file->name, 'help', 'admin/modules#name') : module_invoke($file->name, 'system', 'name') ? module_invoke($file->name, 'system', 'name') : $file->name;
+ $info->description = module_invoke($file->name, 'help', 'admin/modules#description') ? module_invoke($file->name, 'help', 'admin/modules#description') : module_invoke($file->name, 'system', 'description');
// log the critical hooks implemented by this module
$bootstrap = 0;
foreach (bootstrap_hooks() as $hook) {
@@ -275,13 +253,13 @@ function system_listing($type) {
}
}
}
- elseif ($type == "theme") {
+ elseif ($type == 'theme') {
$info->name = $file->name;
- $info->description = module_invoke($file->name, "help", "admin/system/themes#description");
+ $info->description = module_invoke($file->name, 'help', 'admin/themes#description');
$themes[] = $info->name;
// Enable the default theme:
- if ($info->name == variable_get("theme_default", 0)) {
+ if ($info->name == variable_get('theme_default', 0)) {
$file->status = 1;
}
}
@@ -290,63 +268,63 @@ function system_listing($type) {
db_query("DELETE FROM {system} WHERE filename = '%s' AND type = '%s'", $filename, $type);
db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $info->name, $info->description, $type, $filename, $file->status, $file->throttle, $bootstrap);
- $row = array($info->name, $info->description, array("data" => (in_array($filename, $required) ? form_hidden("status][$filename", 1) . t("required") : form_checkbox("", "status][$filename", 1, $file->status)), "align" => "center"));
- if ($type == "module") {
- $row[] = array("data" => (in_array($filename, $throttle_required) ? form_hidden("throttle][$filename", 0) . t("required") : form_checkbox(NULL, "throttle][$filename", 1, $file->throttle, NULL, module_exist('throttle') ? NULL : array("disabled" => "disabled"))), "align" => "center");
+ $row = array($info->name, $info->description, array('data' => (in_array($filename, $required) ? form_hidden("status][$filename", 1) . t('required') : form_checkbox('', "status][$filename", 1, $file->status)), 'align' => 'center'));
+ if ($type == 'module') {
+ $row[] = array('data' => (in_array($filename, $throttle_required) ? form_hidden("throttle][$filename", 0) . t('required') : form_checkbox(NULL, "throttle][$filename", 1, $file->throttle, NULL, module_exist('throttle') ? NULL : array('disabled' => 'disabled'))), 'align' => 'center');
}
- else if ($type == "theme") {
- $row[] = array("data" => form_radio("", "theme_default", $info->name, (variable_get("theme_default",0) == $info->name) ? 1 : 0), "align" => "center");
+ else if ($type == 'theme') {
+ $row[] = array('data' => form_radio('', 'theme_default', $info->name, (variable_get('theme_default', 0) == $info->name) ? 1 : 0), 'align' => 'center');
}
$rows[] = $row;
}
- $output = theme("table", $header, $rows);
- $output .= form_hidden("type", $type);
+ $output = theme('table', $header, $rows);
+ $output .= form_hidden('type', $type);
return $output;
}
function system_listing_save($edit = array()) {
- $op = $_POST["op"];
- $edit = $_POST["edit"];
+ $op = $_POST['op'];
+ $edit = $_POST['edit'];
- if ($op == t("Save configuration")) {
- db_query("UPDATE {system} SET status = '0' WHERE type = '%s'", $edit["type"]);
- foreach ($edit["status"] as $filename => $status) {
- db_query("UPDATE {system} SET status = %d, throttle = %d WHERE filename = '$filename'", $status, $edit["throttle"]["$filename"]);
+ if ($op == t('Save configuration')) {
+ db_query("UPDATE {system} SET status = 0 WHERE type = '%s'", $edit['type']);
+ foreach ($edit['status'] as $filename => $status) {
+ db_query("UPDATE {system} SET status = %d, throttle = %d WHERE filename = '%s'", $status, $edit['throttle'][$filename], $filename);
}
- if ($edit["type"] == "theme") {
- variable_set("theme_default", $edit["theme_default"]);
+ if ($edit['type'] == 'theme') {
+ variable_set('theme_default', $edit['theme_default']);
}
cache_clear_all();
- drupal_set_message(t("the configuration options have been saved."));
+ drupal_set_message(t('the configuration options have been saved.'));
}
}
function system_settings_form($form) {
- $form .= form_submit(t("Save configuration"));
- $form .= form_submit(t("Reset to defaults"));
+ $form .= form_submit(t('Save configuration'));
+ $form .= form_submit(t('Reset to defaults'));
return form($form);
}
function system_settings_save() {
- $op = $_POST["op"];
- $edit = $_POST["edit"];
+ $op = $_POST['op'];
+ $edit = $_POST['edit'];
- if ($op == t("Reset to defaults")) {
+ if ($op == t('Reset to defaults')) {
foreach ($edit as $name => $value) {
variable_del($name);
}
- drupal_set_message(t("the configuration options have been reset to their default values."));
+ drupal_set_message(t('the configuration options have been reset to their default values.'));
}
- if ($op == t("Save configuration")) {
+ if ($op == t('Save configuration')) {
foreach ($edit as $name => $value) {
variable_set($name, $value);
}
- drupal_set_message(t("the configuration options have been saved."));
+ drupal_set_message(t('the configuration options have been saved.'));
}
else {
return;
@@ -355,9 +333,62 @@ function system_settings_save() {
cache_clear_all();
}
-function system_admin() {
- $output = system_view(arg(2), arg(3));
- print theme("page", $output);
+/**
+ * Menu callback; displays a listing of all themes.
+ */
+function system_themes() {
+ system_listing_save();
+ $form = system_listing('themes');
+ $form .= form_submit(t('Save configuration'));
+ print theme('page', form($form));
+}
+
+/**
+ * Menu callback; displays a listing of all modules.
+ */
+function system_modules() {
+ system_listing_save();
+ $form = system_listing('modules');
+ $form .= form_submit(t('Save configuration'));
+ print theme('page', form($form));
+}
+
+/**
+ * Menu callback; displays a theme's settings page.
+ */
+function system_configure_theme() {
+ system_settings_save();
+
+ $name = arg(2);
+ $themes = list_themes();
+ $theme = $themes[$name];
+
+ if ($theme) {
+ include_once "$theme->filename";
+
+ $function = $theme->name .'_settings';
+ if (function_exists($function)) {
+ $form .= $function();
+ }
+ }
+
+ print theme('page', system_settings_form($form));
+}
+
+/**
+ * Menu callback; displays a module's settings page.
+ */
+function system_site_settings($module = NULL) {
+ system_settings_save();
+
+ if ($module) {
+ $form = module_invoke($module, 'settings');
+ }
+ else {
+ $form = system_view_general();
+ }
+
+ print theme('page', system_settings_form($form));
}
?>
diff --git a/modules/system/system.module b/modules/system/system.module
index 76372d8d6..affee64f7 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -1,22 +1,21 @@
<?php
// $Id$
-function system_help($section = "admin/help#system") {
+/**
+ * Implementation of hook_help().
+ */
+function system_help($section) {
global $base_url;
- $output = "";
switch ($section) {
- case 'admin/system':
- $output = t("General configuration options for your site. Set up the name of the site, e-mail address used in mail-outs, clean URL options, caching, etc.");
- break;
- case 'admin/system/themes':
- $output = t("Select which themes are available to your users and specify the default theme.");
- break;
- case 'admin/system/modules':
- $output = t("Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. Click on the name of the module in the navigation menu for their individual configuration pages. Once a module is enabled, new <a href=\"%permissions\">permissions</a> might be made available. Modules can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array("%permissions" => url("admin/user/permission"), "%throttle" => url("admin/system/modules/throttle")));
- break;
+ case 'admin':
+ return t('General configuration options for your site. Set up the name of the site, e-mail address used in mail-outs, clean URL options, caching, etc.');
+ case 'admin/themes':
+ return t('Select which themes are available to your users and specify the default theme.');
+ case 'admin/modules':
+ return t("Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. Click on the name of the module in the navigation menu for their individual configuration pages. Once a module is enabled, new <a href=\"%permissions\">permissions</a> might be made available. Modules can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array('%permissions' => url('admin/user/permission'), '%throttle' => url('admin/settings/throttle')));
case 'admin/help#system':
- $output .= t("
+ return t("
<p>Drupal comes with system-wide defaults but the setting-module provides control over many Drupal preferences, behaviours including visual and operational settings.</p>
<h3><a id=\"cron\">Cron</a></h3>
<p>Some modules require regularly scheduled actions, such as cleaning up logfiles. Cron, which stands for chronograph, is a periodic command scheduler executing commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period measured in seconds). Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution.</p>
@@ -27,75 +26,92 @@ function system_help($section = "admin/help#system") {
<pre> 00 * * * * /home/www/drupal/scripts/cron-lynx.sh</pre>
Note that it is essential to access <code>cron.php</code> using a browser on the web site's domain; do not run it using command line PHP and avoid using <code>localhost</code> or <code>127.0.0.1</code> or some of the environment varibles will not be set correctly and features may not work as expected.</p>
<h3><a id=\"cache\">Cache</a></h3>
- <p>Drupal has a caching mechanism which stores dynamically generated web pages in a database. By caching a web page, Drupal does not have to create the page each time someone wants to view it, instead it takes only one SQL query to display it, reducing response time and the server's load. Only pages requested by \"anonymous\" users are cached.</p>", array("%base_url" => $base_url, "%cron-link" => "<a href=\"$base_url/cron.php\">$base_url/cron.php</a>", "%lynx" => "http://lynx.browser.org", "%wget" => "http://www.gnu.org/software/wget/wget.html" ));
- break;
- case 'admin/system/modules#description':
- $output = t("Configuration system that lets administrators modify the workings of the site.");
- break;
+ <p>Drupal has a caching mechanism which stores dynamically generated web pages in a database. By caching a web page, Drupal does not have to create the page each time someone wants to view it, instead it takes only one SQL query to display it, reducing response time and the server's load. Only pages requested by \"anonymous\" users are cached.</p>", array('%base_url' => $base_url, '%cron-link' => "<a href=\"$base_url/cron.php\">$base_url/cron.php</a>", '%lynx' => 'http://lynx.browser.org', '%wget' => 'http://www.gnu.org/software/wget/wget.html' ));
+ case 'admin/modules#description':
+ return t('Configuration system that lets administrators modify the workings of the site.');
}
-
- return $output;
}
+/**
+ * Menu callback; presents system-specific help text from admin/help.
+ */
function system_help_page() {
- print theme("page", system_help());
+ print theme('page', system_help('admin/help#system'));
}
+/**
+ * Implementation of hook_perm().
+ */
function system_perm() {
- return array("administer site configuration", "access administration pages", "bypass input data check", "create php content");
+ return array('administer site configuration', 'access administration pages', 'bypass input data check', 'create php content');
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function system_link($type) {
- if ($type == 'system') {
- menu('system/files', t('file download'), 'file_download', 0, MENU_HIDE, MENU_LOCKED);
- $access = user_access('administer site configuration');
-
- menu('admin/system', t('configuration'), $access ? 'system_admin' : MENU_DENIED, 3);
- menu('admin/system/themes', t('themes'), $access ? 'system_admin' : MENU_DENIED, 2);
-
- foreach (list_themes() as $theme) {
- // TODO: reenable 'forced refresh' once we move the menu_build() later in the request. it added overhead with no benefit
- // NOTE: refresh the list because some themes might have been enabled/disabled.
- include_once "$theme->filename";
- $function = $theme->name .'_settings';
- if (function_exists($function)) {
- menu("admin/system/themes/$theme->name", $theme->name, $access ? 'system_admin' : MENU_DENIED);
- }
+function system_menu() {
+ $items = array();
+ $items[] = array('path' => 'system/files', 'title' => t('file download'),
+ 'callback' => 'file_download',
+ 'access' => TRUE,
+ 'type' => MENU_CALLBACK);
+
+ $access = user_access('administer site configuration');
+ // Themes:
+ $items[] = array('path' => 'admin/themes', 'title' => t('themes'),
+ 'callback' => 'system_themes', 'access' => $access);
+ foreach (list_themes() as $theme) {
+ // TODO: reenable 'forced refresh' once we move the menu_build() later
+ // in the request. It added overhead with no benefit.
+ // NOTE: refresh the list because some themes might have been enabled/disabled.
+ include_once $theme->filename;
+ $function = $theme->name .'_settings';
+ if (function_exists($function)) {
+ $items[] = array('path' => 'admin/themes/'. $theme->name, 'title' => $theme->name,
+ 'callback' => 'system_configure_theme', 'access' => $access);
}
+ }
- menu('admin/system/modules', t('modules'), $access ? 'system_admin' : MENU_DENIED, 3);
- foreach (module_list() as $name) {
- // TODO: reenable 'forced refresh' once we move the menu_build() later in the request. it added overhead with no benefit
- // NOTE: refresh the list because some modules might have been enabled/disabled.
- if (module_hook($name, 'settings')) {
- menu("admin/system/modules/$name", t($name), $access ? 'system_admin' : MENU_DENIED);
- }
+ // Modules:
+ $items[] = array('path' => 'admin/settings', 'title' => t('settings'),
+ 'callback' => 'system_site_settings', 'access' => $access);
+ foreach (module_list() as $name) {
+ // TODO: reenable 'forced refresh' once we move the menu_build() later
+ // in the request. It added overhead with no benefit.
+ // NOTE: refresh the list because some modules might have been enabled/disabled.
+ if (module_hook($name, 'settings')) {
+ $items[] = array('path' => 'admin/settings/'. $name, 'title' => t($name));
}
- menu('admin/system/help', t('help'), $access ? 'system_help_page' : MENU_DENIED, 9);
}
+ $items[] = array('path' => 'admin/modules', 'title' => t('modules'),
+ 'callback' => 'system_modules', 'access' => $access);
+
+ return $items;
}
+/**
+ * Implementation of hook_user().
+ *
+ * Allows users to individually set their theme and time zone.
+ */
function system_user($type, $edit, &$user) {
if ($type == 'form') {
- $options = "<option value=\"\">". t("Default theme") ."</option>\n";
+ $options = '<option value="">'. t('Default theme') ."</option>\n";
if (count($themes = list_themes()) > 1) {
foreach ($themes as $key => $value) {
- $options .= "<option value=\"$key\"". (($edit["theme"] == $key) ? " selected=\"selected\"" : "") .">$key - $value->description</option>\n";
+ $options .= "<option value=\"$key\"". (($edit['theme'] == $key) ? ' selected="selected"' : '') .">$key - $value->description</option>\n";
}
- $data[t('Theme settings')] = form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site."));
+ $data[t('Theme settings')] = form_item(t('Theme'), "<select name=\"edit[theme]\">$options</select>", t('Selecting a different theme will change the look and feel of the site.'));
}
- if (!variable_get("sitewide_timezone", 0)) {
+ if (!variable_get('sitewide_timezone', 0)) {
$timestamp = time();
$zonelist = array(-11, -10, -9.5, -9, -8, -7, -6, -5, -4, -3.5, -3, -2, -1, 0, 1, 2, 3, 3.5, 4, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 14);
foreach ($zonelist as $offset) {
$zone = $offset * 3600;
$zones[$zone] = format_date($timestamp, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone);
}
- $data[t('Locale settings')] = form_select(t("Time zone"), "timezone", $edit["timezone"], $zones, t("Select what time you currently have and your time zone settings will be set appropriate."));
+ $data[t('Locale settings')] = form_select(t('Time zone'), 'timezone', $edit['timezone'], $zones, t('Select what time you currently have and your time zone settings will be set appropriately.'));
}
return $data;
}
@@ -105,23 +121,28 @@ function system_view_general() {
global $conf;
// general settings:
- $group = form_textfield(t("Name"), "site_name", variable_get("site_name", "drupal"), 70, 70, t("The name of this web site."));
- $group .= form_textfield(t("E-mail address"), "site_mail", variable_get("site_mail", ini_get("sendmail_from")), 70, 128, t("A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc."));
- $group .= form_textfield(t("Slogan"), "site_slogan", variable_get("site_slogan", ""), 70, 128, t("The slogan of this website. Some themes display a slogan when available."));
- $group .= form_textarea(t("Mission"), "site_mission", variable_get("site_mission", ""), 70, 5, t("Your site's mission statement or focus."));
- $group .= form_textarea(t("Footer message"), "site_footer", variable_get("site_footer", ""), 70, 5, t("This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages."));
- $group .= form_textfield(t("Anonymous user"), "anonymous", variable_get("anonymous", "Anonymous"), 70, 70, t("The name used to indicate anonymous users."));
- $group .= form_textfield(t("Default front page"), "site_frontpage", variable_get("site_frontpage", "node"), 70, 70, t("The home page displays content from this relative URL. If you are not using clean URLs, specify the part after '?q='. If unsure, specify 'node'."));
- $group .= form_textfield(t("Default 403 (access denied) page"), "site_403", variable_get("site_403", ""), 70, 70, t("This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after '?q='. If unsure, specify nothing."));
- $group .= form_textfield(t("Default 404 (not found) page"), "site_404", variable_get("site_404", ""), 70, 70, t("This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after '?q='. If unsure, specify nothing."));
- $group .= form_radios(t("Clean URLs"), "clean_url", variable_get("clean_url", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable clean URLs. If enabled, you'll need <code>ModRewrite</code> support. See also the <code>.htaccess</code> file in Drupal's top-level directory."));
-
- $output = form_group(t("General settings"), $group);
+ $group = form_textfield(t('Name'), 'site_name', variable_get('site_name', 'drupal'), 70, 70, t('The name of this web site.'));
+ $group .= form_textfield(t('E-mail address'), 'site_mail', variable_get('site_mail', ini_get('sendmail_from')), 70, 128, t('A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc.'));
+ $group .= form_textfield(t('Slogan'), 'site_slogan', variable_get('site_slogan', ''), 70, 128, t('The slogan of this website. Some themes display a slogan when available.'));
+ $group .= form_textarea(t('Mission'), 'site_mission', variable_get('site_mission', ''), 70, 5, t('Your site\'s mission statement or focus.'));
+ $group .= form_textarea(t('Footer message'), 'site_footer', variable_get('site_footer', ''), 70, 5, t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.'));
+ $group .= form_textfield(t('Anonymous user'), 'anonymous', variable_get('anonymous', 'Anonymous'), 70, 70, t('The name used to indicate anonymous users.'));
+ $group .= form_textfield(t('Default front page'), 'site_frontpage', variable_get('site_frontpage', 'node'), 70, 70, t('The home page displays content from this relative URL. If you are not using clean URLs, specify the part after "?q=". If unsure, specify "node".'));
+ $group .= form_textfield(t('Default 403 (access denied) page'), 'site_403', variable_get('site_403', ''), 70, 70, t('This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
+ $group .= form_textfield(t('Default 404 (not found) page'), 'site_404', variable_get('site_404', ''), 70, 70, t('This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
+ $group .= form_radios(t('Clean URLs'), 'clean_url', variable_get('clean_url', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable clean URLs. If enabled, you\'ll need <code>ModRewrite</code> support. See also the <code>.htaccess</code> file in Drupal\'s top-level directory.'));
+
+ // watchdog setting:
+ $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
+ $period['1000000000'] = t('Never');
+ $group .= form_select(t('Discard log entries older than'), 'watchdog_clear', variable_get('watchdog_clear', 604800), $period, t('The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.'));
+
+ $output = form_group(t('General settings'), $group);
// caching:
- $group = form_radios(t("Cache support"), "cache", variable_get("cache", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable the caching of rendered pages. When caching is enabled, Drupal will flush the cache when required to make sure updates take effect immediately. Check the <a href=\"%documentation\">cache documentation</a> for information on Drupal's cache system.", array("%documentation" => url("admin/system/help", NULL, NULL, "cache"))));
+ $group = form_radios(t('Cache support'), 'cache', variable_get('cache', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable the caching of rendered pages. When caching is enabled, Drupal will flush the cache when required to make sure updates take effect immediately. Check the <a href="%documentation">cache documentation</a> for information on Drupal\'s cache system.', array('%documentation' => url('admin/help', NULL, NULL, 'cache'))));
- $output .= form_group(t("Cache settings"), $group);
+ $output .= form_group(t('Cache settings'), $group);
// file system:
if (!file_check_directory(variable_get('file_directory_path', 'files'))) {
@@ -144,93 +165,50 @@ function system_view_general() {
}
// date settings: possible date formats
- $dateshort = array("m/d/Y - H:i", "d/m/Y - H:i", "Y/m/d - H:i",
- "m/d/Y - g:ia", "d/m/Y - g:ia", "Y/m/d - g:ia",
- "M j Y - H:i", "j M Y - H:i", "Y M j - H:i",
- "M j Y - g:ia", "j M Y - g:ia", "Y M j - g:ia");
- $datemedium = array("D, m/d/Y - H:i", "D, d/m/Y - H:i", "D, Y/m/d - H:i",
- "F j, Y - H:i", "j F, Y - H:i", "Y, F j - H:i",
- "D, m/d/Y - g:ia", "D, d/m/Y - g:ia", "D, Y/m/d - g:ia",
- "F j, Y - g:ia", "j F, Y - g:ia", "Y, F j - g:ia");
- $datelong = array("l, F j, Y - H:i", "l, j F, Y - H:i", "l, Y, F j - H:i",
- "l, F j, Y - g:ia", "l, j F, Y - g:ia", "l, Y, F j - g:ia");
+ $dateshort = array('m/d/Y - H:i', 'd/m/Y - H:i', 'Y/m/d - H:i',
+ 'm/d/Y - g:ia', 'd/m/Y - g:ia', 'Y/m/d - g:ia',
+ 'M j Y - H:i', 'j M Y - H:i', 'Y M j - H:i',
+ 'M j Y - g:ia', 'j M Y - g:ia', 'Y M j - g:ia');
+ $datemedium = array('D, m/d/Y - H:i', 'D, d/m/Y - H:i', 'D, Y/m/d - H:i',
+ 'F j, Y - H:i', 'j F, Y - H:i', 'Y, F j - H:i',
+ 'D, m/d/Y - g:ia', 'D, d/m/Y - g:ia', 'D, Y/m/d - g:ia',
+ 'F j, Y - g:ia', 'j F, Y - g:ia', 'Y, F j - g:ia');
+ $datelong = array('l, F j, Y - H:i', 'l, j F, Y - H:i', 'l, Y, F j - H:i',
+ 'l, F j, Y - g:ia', 'l, j F, Y - g:ia', 'l, Y, F j - g:ia');
// date settings: construct choices for user
foreach ($dateshort as $f) {
- $dateshortchoices[$f] = format_date(time(), "custom", $f);
+ $dateshortchoices[$f] = format_date(time(), 'custom', $f);
}
foreach ($datemedium as $f) {
- $datemediumchoices[$f] = format_date(time(), "custom", $f);
+ $datemediumchoices[$f] = format_date(time(), 'custom', $f);
}
foreach ($datelong as $f) {
- $datelongchoices[$f] = format_date(time(), "custom", $f);
+ $datelongchoices[$f] = format_date(time(), 'custom', $f);
}
- $group = form_select(t("Time zone"), "date_default_timezone", variable_get('date_default_timezone', 0), $zones, t("Select the default site timezone."));
- $group .= form_radios(t("Use sitewide timezone"), "sitewide_timezone", variable_get("sitewide_timezone", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable the sidewide timezone feature. Disabled means that users could choose their own timezone."));
- $group .= form_select(t("Date format (short)"), "date_format_short", variable_get("date_format_short", $dateshort[0]), $dateshortchoices, t("The short format of date display."));
- $group .= form_select(t("Date format (medium)"), "date_format_medium", variable_get("date_format_medium", $datemedium[0]), $datemediumchoices, t("The medium sized date display."));
- $group .= form_select(t("Date format (long)"), "date_format_long", variable_get("date_format_long", $datelong[0]), $datelongchoices, t("Longer date format used for detailed display."));
+ $group = form_select(t('Time zone'), 'date_default_timezone', variable_get('date_default_timezone', 0), $zones, t('Select the default site timezone.'));
+ $group .= form_radios(t('Use sitewide timezone'), 'sitewide_timezone', variable_get('sitewide_timezone', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable the sidewide timezone feature. Disabled means that users could choose their own timezone.'));
+ $group .= form_select(t('Date format (short)'), 'date_format_short', variable_get('date_format_short', $dateshort[0]), $dateshortchoices, t('The short format of date display.'));
+ $group .= form_select(t('Date format (medium)'), 'date_format_medium', variable_get('date_format_medium', $datemedium[0]), $datemediumchoices, t('The medium sized date display.'));
+ $group .= form_select(t('Date format (long)'), 'date_format_long', variable_get('date_format_long', $datelong[0]), $datelongchoices, t('Longer date format used for detailed display.'));
- $output .= form_group(t("Date format settings"), $group);
+ $output .= form_group(t('Date format settings'), $group);
return $output;
}
-function system_view_theme($name) {
- $themes = list_themes();
- $theme = $themes[$name];
- if ($theme) {
- include_once "$theme->filename";
-
- $function = $theme->name ."_settings";
- if (function_exists($function)) {
- $output .= $function();
- }
- }
- else {
- $output = t("Invalid theme specified");
- }
- return $output;
-}
-
-function system_view($type, $arg = "") {
- // The module/theme lists don't use the generic settings handler
- if (($type == "modules" || $type == "themes") && $arg == "") {
- system_listing_save();
- $form = system_listing($type);
- $form .= form_submit(t("Save configuration"));
- return form($form);
- }
-
- system_settings_save();
-
- switch ($type) {
- case "modules":
- $form = module_invoke($arg, "settings");
- break;
- case "themes":
- $form = system_view_theme($arg);
- break;
- default:
- $form = system_view_general();
- break;
- }
-
- return system_settings_form($form);
-}
-
function system_listing($type) {
// Pick appropriate directory and filetype
switch ($type) {
- case "modules":
- $directory = "modules";
- $type = "module";
+ case 'modules':
+ $directory = 'modules';
+ $type = 'module';
break;
- case "themes":
+ case 'themes':
default:
- $directory = "themes";
- $type = "theme";
+ $directory = 'themes';
+ $type = 'theme';
break;
}
@@ -249,23 +227,23 @@ function system_listing($type) {
ksort($files);
- if ($type == "module") {
- $required = array("modules/admin.module", "modules/filter.module", "modules/system.module", "modules/user.module", "modules/watchdog.module");
+ if ($type == 'module') {
+ $required = array('modules/admin.module', 'modules/filter.module', 'modules/system.module', 'modules/user.module', 'modules/watchdog.module');
// the throttle mechanism requires additional modules always be enabled
- $throttle_required = array_merge($required, array("modules/statistics.module", "modules/throttle.module"));
+ $throttle_required = array_merge($required, array('modules/statistics.module', 'modules/throttle.module'));
- $header = array(t("name"), t("description"), t("status"), t("throttle"));
+ $header = array(t('name'), t('description'), t('status'), t('throttle'));
}
else {
$required = array();
- $header = array(t("name"), t("description"), t("enable"), t("default"));
+ $header = array(t('name'), t('description'), t('enable'), t('default'));
}
foreach ($files as $filename => $file) {
include_once($filename);
- if ($type == "module") {
- $info->name = module_invoke($file->name, "help", "admin/system/modules#name") ? module_invoke($file->name, "help", "admin/system/modules#name") : module_invoke($file->name, "system", "name") ? module_invoke($file->name, "system", "name") : $file->name;
- $info->description = module_invoke($file->name, "help", "admin/system/modules#description") ? module_invoke($file->name, "help", "admin/system/modules#description") : module_invoke($file->name, "system", "description");
+ if ($type == 'module') {
+ $info->name = module_invoke($file->name, 'help', 'admin/modules#name') ? module_invoke($file->name, 'help', 'admin/modules#name') : module_invoke($file->name, 'system', 'name') ? module_invoke($file->name, 'system', 'name') : $file->name;
+ $info->description = module_invoke($file->name, 'help', 'admin/modules#description') ? module_invoke($file->name, 'help', 'admin/modules#description') : module_invoke($file->name, 'system', 'description');
// log the critical hooks implemented by this module
$bootstrap = 0;
foreach (bootstrap_hooks() as $hook) {
@@ -275,13 +253,13 @@ function system_listing($type) {
}
}
}
- elseif ($type == "theme") {
+ elseif ($type == 'theme') {
$info->name = $file->name;
- $info->description = module_invoke($file->name, "help", "admin/system/themes#description");
+ $info->description = module_invoke($file->name, 'help', 'admin/themes#description');
$themes[] = $info->name;
// Enable the default theme:
- if ($info->name == variable_get("theme_default", 0)) {
+ if ($info->name == variable_get('theme_default', 0)) {
$file->status = 1;
}
}
@@ -290,63 +268,63 @@ function system_listing($type) {
db_query("DELETE FROM {system} WHERE filename = '%s' AND type = '%s'", $filename, $type);
db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $info->name, $info->description, $type, $filename, $file->status, $file->throttle, $bootstrap);
- $row = array($info->name, $info->description, array("data" => (in_array($filename, $required) ? form_hidden("status][$filename", 1) . t("required") : form_checkbox("", "status][$filename", 1, $file->status)), "align" => "center"));
- if ($type == "module") {
- $row[] = array("data" => (in_array($filename, $throttle_required) ? form_hidden("throttle][$filename", 0) . t("required") : form_checkbox(NULL, "throttle][$filename", 1, $file->throttle, NULL, module_exist('throttle') ? NULL : array("disabled" => "disabled"))), "align" => "center");
+ $row = array($info->name, $info->description, array('data' => (in_array($filename, $required) ? form_hidden("status][$filename", 1) . t('required') : form_checkbox('', "status][$filename", 1, $file->status)), 'align' => 'center'));
+ if ($type == 'module') {
+ $row[] = array('data' => (in_array($filename, $throttle_required) ? form_hidden("throttle][$filename", 0) . t('required') : form_checkbox(NULL, "throttle][$filename", 1, $file->throttle, NULL, module_exist('throttle') ? NULL : array('disabled' => 'disabled'))), 'align' => 'center');
}
- else if ($type == "theme") {
- $row[] = array("data" => form_radio("", "theme_default", $info->name, (variable_get("theme_default",0) == $info->name) ? 1 : 0), "align" => "center");
+ else if ($type == 'theme') {
+ $row[] = array('data' => form_radio('', 'theme_default', $info->name, (variable_get('theme_default', 0) == $info->name) ? 1 : 0), 'align' => 'center');
}
$rows[] = $row;
}
- $output = theme("table", $header, $rows);
- $output .= form_hidden("type", $type);
+ $output = theme('table', $header, $rows);
+ $output .= form_hidden('type', $type);
return $output;
}
function system_listing_save($edit = array()) {
- $op = $_POST["op"];
- $edit = $_POST["edit"];
+ $op = $_POST['op'];
+ $edit = $_POST['edit'];
- if ($op == t("Save configuration")) {
- db_query("UPDATE {system} SET status = '0' WHERE type = '%s'", $edit["type"]);
- foreach ($edit["status"] as $filename => $status) {
- db_query("UPDATE {system} SET status = %d, throttle = %d WHERE filename = '$filename'", $status, $edit["throttle"]["$filename"]);
+ if ($op == t('Save configuration')) {
+ db_query("UPDATE {system} SET status = 0 WHERE type = '%s'", $edit['type']);
+ foreach ($edit['status'] as $filename => $status) {
+ db_query("UPDATE {system} SET status = %d, throttle = %d WHERE filename = '%s'", $status, $edit['throttle'][$filename], $filename);
}
- if ($edit["type"] == "theme") {
- variable_set("theme_default", $edit["theme_default"]);
+ if ($edit['type'] == 'theme') {
+ variable_set('theme_default', $edit['theme_default']);
}
cache_clear_all();
- drupal_set_message(t("the configuration options have been saved."));
+ drupal_set_message(t('the configuration options have been saved.'));
}
}
function system_settings_form($form) {
- $form .= form_submit(t("Save configuration"));
- $form .= form_submit(t("Reset to defaults"));
+ $form .= form_submit(t('Save configuration'));
+ $form .= form_submit(t('Reset to defaults'));
return form($form);
}
function system_settings_save() {
- $op = $_POST["op"];
- $edit = $_POST["edit"];
+ $op = $_POST['op'];
+ $edit = $_POST['edit'];
- if ($op == t("Reset to defaults")) {
+ if ($op == t('Reset to defaults')) {
foreach ($edit as $name => $value) {
variable_del($name);
}
- drupal_set_message(t("the configuration options have been reset to their default values."));
+ drupal_set_message(t('the configuration options have been reset to their default values.'));
}
- if ($op == t("Save configuration")) {
+ if ($op == t('Save configuration')) {
foreach ($edit as $name => $value) {
variable_set($name, $value);
}
- drupal_set_message(t("the configuration options have been saved."));
+ drupal_set_message(t('the configuration options have been saved.'));
}
else {
return;
@@ -355,9 +333,62 @@ function system_settings_save() {
cache_clear_all();
}
-function system_admin() {
- $output = system_view(arg(2), arg(3));
- print theme("page", $output);
+/**
+ * Menu callback; displays a listing of all themes.
+ */
+function system_themes() {
+ system_listing_save();
+ $form = system_listing('themes');
+ $form .= form_submit(t('Save configuration'));
+ print theme('page', form($form));
+}
+
+/**
+ * Menu callback; displays a listing of all modules.
+ */
+function system_modules() {
+ system_listing_save();
+ $form = system_listing('modules');
+ $form .= form_submit(t('Save configuration'));
+ print theme('page', form($form));
+}
+
+/**
+ * Menu callback; displays a theme's settings page.
+ */
+function system_configure_theme() {
+ system_settings_save();
+
+ $name = arg(2);
+ $themes = list_themes();
+ $theme = $themes[$name];
+
+ if ($theme) {
+ include_once "$theme->filename";
+
+ $function = $theme->name .'_settings';
+ if (function_exists($function)) {
+ $form .= $function();
+ }
+ }
+
+ print theme('page', system_settings_form($form));
+}
+
+/**
+ * Menu callback; displays a module's settings page.
+ */
+function system_site_settings($module = NULL) {
+ system_settings_save();
+
+ if ($module) {
+ $form = module_invoke($module, 'settings');
+ }
+ else {
+ $form = system_view_general();
+ }
+
+ print theme('page', system_settings_form($form));
}
?>
diff --git a/modules/taxonomy.module b/modules/taxonomy.module
index a38d5b9ff..9b27d6db5 100644
--- a/modules/taxonomy.module
+++ b/modules/taxonomy.module
@@ -4,21 +4,24 @@
function taxonomy_feed($taxonomy) {
global $id, $type;
- if ($type == "voc") {
+ if ($type == 'voc') {
//TODO - vocabulary feed.
}
else {
$result = taxonomy_select_nodes($taxonomy, 0);
$term = taxonomy_get_term($taxonomy->tids[0]);
- $channel["link"] = url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids", NULL, NULL, TRUE);
- $channel["title"] = variable_get("site_name", "drupal") ." - ". $term->name;
- $channel["description"] = $term->description;
+ $channel['link'] = url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids", NULL, NULL, TRUE);
+ $channel['title'] = variable_get('site_name', 'drupal') .' - '. $term->name;
+ $channel['description'] = $term->description;
node_feed($result, $channel);
}
}
+/**
+ * Implementation of hook_perm().
+ */
function taxonomy_perm() {
- return array("administer taxonomy");
+ return array('administer taxonomy');
}
/**
@@ -33,14 +36,7 @@ function taxonomy_perm() {
* }
*/
function taxonomy_link($type, $node = NULL) {
- if ($type == 'system') {
- menu('admin/taxonomy', t('categories'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED, 3);
- menu('admin/taxonomy/add/vocabulary', t('create new vocabulary'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED);
- menu('admin/taxonomy/help', t('help'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED, 9);
-
- menu('taxonomy', t('taxonomy'), user_access('access content') ? 'taxonomy_page' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
- else if ($type == 'taxonomy terms' && $node != NULL) {
+ if ($type == 'taxonomy terms' && $node != NULL) {
$links = array();
if ($node->taxonomy) {
foreach ($node->taxonomy as $tid) {
@@ -59,53 +55,68 @@ function taxonomy_link($type, $node = NULL) {
}
}
-/*
-** admin pages (form, save, overview)
-*/
+/**
+ * Implementation of hook_menu().
+ */
+function taxonomy_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/taxonomy', 'title' => t('categories'),
+ 'callback' => 'taxonomy_admin',
+ 'access' => user_access('administer taxonomy'));
+ $items[] = array('path' => 'admin/taxonomy/add/vocabulary', 'title' => t('add vocabulary'),
+ 'callback' => 'taxonomy_admin',
+ 'access' => user_access('administer taxonomy'),
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'taxonomy', 'title' => t('taxonomy'),
+ 'callback' => 'taxonomy_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+ return $items;
+}
function taxonomy_form_vocabulary($edit = array()) {
foreach (node_list() as $type) {
- $nodetypes[$type] = node_invoke($type, "node_name");
+ $nodetypes[$type] = node_invoke($type, 'node_name');
}
- $form .= form_textfield(t("Vocabulary name"), "name", $edit["name"], 50, 64, t("Required") .". ". t("The name for this vocabulary. Example: 'Topic'") .".");
- $form .= form_textarea(t("Description"), "description", $edit["description"], 60, 5, t("Optional") .". ". t("Description of the vocabulary, can be used by modules."));
- $form .= form_textfield(t("Help text"), "help", $edit["help"], 50, 255, t("Optional") .". ". t("Instructions to present to the user when choosing a term.") .".");
- $form .= form_checkboxes(t("Types"), "nodes", explode(",", $edit["nodes"]), $nodetypes, t("Required") .". ". t("A list of node types you want to associate this vocabulary with."));
- $form .= form_checkbox(t("Related terms"), "relations", 1, $edit["relations"], t("Optional") .". ". t("Allows <a href=\"%help-url\">related terms</a> in this vocabulary.", array("%help-url" => url("admin/taxonomy/help", NULL, NULL, "related-terms"))));
- $form .= form_radios(t("Hierarchy"), "hierarchy", $edit["hierarchy"], array(t("Disabled"), t("Single"), t("Multiple")), t("Optional") .". ". t("Allows <a href=\"%help-url\">a tree-like hierarchy</a> between terms of this vocabulary.", array("%help-url" => url("admin/taxonomy/help", NULL, NULL, "hierarchy"))), "");
- $form .= form_checkbox(t("Multiple select"), "multiple", 1, $edit["multiple"], t("Optional") .". ". t("Allows nodes to have more than one term in this vocabulary."));
- $form .= form_checkbox(t("Required"), "required", 1, $edit["required"], t("If enabled every node <strong>must</strong> have at least one term in this vocabulary"));
- $form .= form_weight(t("Weight"), "weight", $edit["weight"], 10, t("Optional. In listings, the heavier vocabularies will sink and the lighter vocabularies will be positioned nearer the top."));
- $form .= form_submit(t("Submit"));
+ $form .= form_textfield(t('Vocabulary name'), 'name', $edit['name'], 50, 64, t('Required') .'. '. t('The name for this vocabulary. Example: "Topic"') .'.');
+ $form .= form_textarea(t('Description'), 'description', $edit['description'], 60, 5, t('Optional') .'. '. t('Description of the vocabulary; can be used by modules.'));
+ $form .= form_textfield(t('Help text'), 'help', $edit['help'], 50, 255, t('Optional') .'. '. t('Instructions to present to the user when choosing a term.') .'.');
+ $form .= form_checkboxes(t('Types'), 'nodes', explode(',', $edit['nodes']), $nodetypes, t('Required') .'. '. t('A list of node types you want to associate with this vocabulary.'));
+ $form .= form_checkbox(t('Related terms'), 'relations', 1, $edit['relations'], t('Optional') .'. '. t('Allows <a href="%help-url">related terms</a> in this vocabulary.', array('%help-url' => url('admin/taxonomy/help', NULL, NULL, 'related-terms'))));
+ $form .= form_radios(t('Hierarchy'), 'hierarchy', $edit['hierarchy'], array(t('Disabled'), t('Single'), t('Multiple')), t('Optional') .'. '. t('Allows <a href="%help-url">a tree-like hierarchy</a> between terms of this vocabulary.', array('%help-url' => url('admin/taxonomy/help', NULL, NULL, 'hierarchy'))), '');
+ $form .= form_checkbox(t('Multiple select'), 'multiple', 1, $edit['multiple'], t('Optional') .'. '. t('Allows nodes to have more than one term in this vocabulary.'));
+ $form .= form_checkbox(t('Required'), 'required', 1, $edit['required'], t('If enabled, every node <strong>must</strong> have at least one term in this vocabulary.'));
+ $form .= form_weight(t('Weight'), 'weight', $edit['weight'], 10, t('Optional. In listings, the heavier vocabularies will sink and the lighter vocabularies will be positioned nearer the top.'));
+ $form .= form_submit(t('Submit'));
- if ($edit["vid"]) {
- $form .= form_submit(t("Delete"));
- $form .= form_hidden("vid", $edit["vid"]);
+ if ($edit['vid']) {
+ $form .= form_submit(t('Delete'));
+ $form .= form_hidden('vid', $edit['vid']);
}
return form($form);
}
function taxonomy_save_vocabulary($edit) {
- if (!$edit["nodes"]) {
- $edit["nodes"] = array();
+ if (!$edit['nodes']) {
+ $edit['nodes'] = array();
}
- $data = array("name" => $edit["name"], "nodes" => implode(",", $edit["nodes"]), "description" => $edit["description"], "help" => $edit["help"], "multiple" => $edit["multiple"], "required" => $edit["required"], "hierarchy" => $edit["hierarchy"], "relations" => $edit["relations"], "weight" => $edit["weight"]);
- if ($edit["vid"] && $edit["name"]) {
- db_query("UPDATE {vocabulary} SET ". _prepare_update($data) ." WHERE vid = %d", $edit["vid"]);
- module_invoke_all("taxonomy", "update", "vocabulary", $edit);
- $message = t("updated vocabulary '%name'.", array("%name" => $edit["name"]));
+ $data = array('name' => $edit['name'], 'nodes' => implode(',', $edit['nodes']), 'description' => $edit['description'], 'help' => $edit['help'], 'multiple' => $edit['multiple'], 'required' => $edit['required'], 'hierarchy' => $edit['hierarchy'], 'relations' => $edit['relations'], 'weight' => $edit['weight']);
+ if ($edit['vid'] && $edit['name']) {
+ db_query('UPDATE {vocabulary} SET '. _prepare_update($data) .' WHERE vid = %d', $edit['vid']);
+ module_invoke_all('taxonomy', 'update', 'vocabulary', $edit);
+ $message = t('updated vocabulary "%name".', array('%name' => $edit['name']));
}
- else if ($edit["vid"]) {
- $message = taxonomy_del_vocabulary($edit["vid"]);
+ else if ($edit['vid']) {
+ $message = taxonomy_del_vocabulary($edit['vid']);
}
else {
- $data["vid"] = $edit["vid"] = db_next_id("{vocabulary}_vid");
- db_query("INSERT INTO {vocabulary} ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2));
- module_invoke_all("taxonomy", "insert", "vocabulary", $edit);
- $message = t("created new vocabulary '%name'.", array("%name" => $edit["name"]));
+ $data['vid'] = $edit['vid'] = db_next_id('{vocabulary}_vid');
+ db_query('INSERT INTO {vocabulary} '. _prepare_insert($data, 1) .' VALUES '. _prepare_insert($data, 2));
+ module_invoke_all('taxonomy', 'insert', 'vocabulary', $edit);
+ $message = t('created new vocabulary "%name".', array('%name' => $edit['name']));
}
cache_clear_all();
@@ -117,121 +128,119 @@ function taxonomy_save_vocabulary($edit) {
function taxonomy_del_vocabulary($vid) {
$vocabulary = taxonomy_get_vocabulary($vid);
- db_query("DELETE FROM {vocabulary} WHERE vid = %d", $vid);
- $result = db_query("SELECT tid FROM {term_data} WHERE vid = %d", $vid);
+ db_query('DELETE FROM {vocabulary} WHERE vid = %d', $vid);
+ $result = db_query('SELECT tid FROM {term_data} WHERE vid = %d', $vid);
while ($term = db_fetch_object($result)) {
taxonomy_del_term($term->tid);
}
- module_invoke_all("taxonomy", "delete", "vocabulary", $vocabulary);
+ module_invoke_all('taxonomy', 'delete', 'vocabulary', $vocabulary);
cache_clear_all();
- return t("deleted vocabulary '%name'.", array("%name" => $vocabulary->name));
+ return t('deleted vocabulary "%name".', array('%name' => $vocabulary->name));
}
function _taxonomy_confirm_del_vocabulary($vid) {
$vocabulary = taxonomy_get_vocabulary($vid);
- $form .= form_hidden("confirm", 1);
- $form .= form_hidden("type", "vocabulary");
- $form .= form_hidden("vid", $vid);
- $form .= form_submit(t("Delete"));
- $form .= form_submit(t("Cancel"));
+ $form .= form_hidden('confirm', 1);
+ $form .= form_hidden('type', 'vocabulary');
+ $form .= form_hidden('vid', $vid);
+ $form .= form_submit(t('Delete'));
+ $form .= form_submit(t('Cancel'));
- return form(form_item(t("Delete vocabulary '%name'", array("%name" => $vocabulary->name)), $form, t("Are you sure you want to delete the vocabulary and all its terms?")));
+ return form(form_item(t('Delete vocabulary "%name"', array('%name' => $vocabulary->name)), $form, t('Are you sure you want to delete the vocabulary and all its terms?')));
}
function taxonomy_form_term($edit = array()) {
- $vocabulary_id = isset($edit["vid"]) ? $edit["vid"] : arg(4);
+ $vocabulary_id = isset($edit['vid']) ? $edit['vid'] : arg(4);
$vocabulary = taxonomy_get_vocabulary($vocabulary_id);
- $form = form_textfield(t("Term name"), "name", $edit["name"], 50, 64, t("Required") .". ". t("The name for this term. Example: 'Linux'."));
- $form .= form_textarea(t("Description"), "description", $edit["description"], 60, 5, t("Optional") .". ". t("A description of the term."));
+ $form = form_textfield(t('Term name'), 'name', $edit['name'], 50, 64, t('Required') .'. '. t('The name for this term. Example: "Linux".'));
+ $form .= form_textarea(t('Description'), 'description', $edit['description'], 60, 5, t('Optional') .'. '. t('A description of the term.'));
if ($vocabulary->hierarchy) {
- $parent = array_keys(taxonomy_get_parents($edit["tid"]));
- $children = taxonomy_get_tree($vocabulary_id, $edit["tid"]);
+ $parent = array_keys(taxonomy_get_parents($edit['tid']));
+ $children = taxonomy_get_tree($vocabulary_id, $edit['tid']);
- // you can't be son of yourself nor of your children
+ // A term can't be the child of itself, nor of its children.
foreach ($children as $child) {
$exclude[] = $child->tid;
}
- $exclude[] = $edit["tid"];
+ $exclude[] = $edit['tid'];
if ($vocabulary->hierarchy == 1) {
- $form .= _taxonomy_term_select(t("Parent"), "parent", $parent, $vocabulary_id, t("Required") .". ". l(t("Parent term"), "admin/taxonomy/help", NULL, NULL, "parent") .".", 0, "<". t("root") .">", $exclude);
+ $form .= _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary_id, t('Required') .'. '. l(t('Parent term'), 'admin/taxonomy/help', NULL, NULL, 'parent') .'.', 0, '<'. t('root') .'>', $exclude);
}
elseif ($vocabulary->hierarchy == 2) {
- $form .= _taxonomy_term_select(t("Parents"), "parent", $parent, $vocabulary_id, t("Required") .". ". l(t("Parent terms"), "admin/taxonomy/help", NULL, NULL, "parent") .".", 1, "<". t("root") .">", $exclude);
+ $form .= _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary_id, t('Required') .'. '. l(t('Parent terms'), 'admin/taxonomy/help', NULL, NULL, 'parent') .'.', 1, '<'. t('root') .'>', $exclude);
}
}
if ($vocabulary->relations) {
- $form .= _taxonomy_term_select(t("Related terms"), "relations", array_keys(taxonomy_get_related($edit["tid"])), $vocabulary_id, t("Optional") .". ", 1, "<". t("none") .">", array($edit["tid"]));
+ $form .= _taxonomy_term_select(t('Related terms'), 'relations', array_keys(taxonomy_get_related($edit['tid'])), $vocabulary_id, t('Optional') .'. ', 1, '<'. t('none') .'>', array($edit['tid']));
}
- $form .= form_textarea(t("Synonyms"), "synonyms", implode("\n", taxonomy_get_synonyms($edit["tid"])), 30, 5, t("Optional") . ". ". t("<a href=\"%help-url\">Synonyms</a> of this term, one synonym per line.", array("%help-url" => url("admin/taxonomy/help", NULL, NULL, "synonyms"))));
- $form .= form_weight(t("Weight"), "weight", $edit["weight"], 10, t("Optional. In listings, the heavier terms will sink and the lighter terms will be positioned nearer the top."));
- $form .= form_hidden("vid", $vocabulary->vid);
- $form .= form_submit(t("Submit"));
+ $form .= form_textarea(t('Synonyms'), 'synonyms', implode("\n", taxonomy_get_synonyms($edit['tid'])), 30, 5, t('Optional') . '. '. t('<a href="%help-url">Synonyms</a> of this term, one synonym per line.', array('%help-url' => url('admin/taxonomy/help', NULL, NULL, 'synonyms'))));
+ $form .= form_weight(t('Weight'), 'weight', $edit['weight'], 10, t('Optional. In listings, the heavier terms will sink and the lighter terms will be positioned nearer the top.'));
+ $form .= form_hidden('vid', $vocabulary->vid);
+ $form .= form_submit(t('Submit'));
- if ($edit["tid"]) {
- $form .= form_submit(t("Delete"));
- $form .= form_hidden("tid", $edit["tid"]);
+ if ($edit['tid']) {
+ $form .= form_submit(t('Delete'));
+ $form .= form_hidden('tid', $edit['tid']);
}
return form($form);
}
function taxonomy_save_term($edit) {
- if ($edit["tid"] && $edit["name"]) {
- $data = array("name" => $edit["name"], "description" => $edit["description"], "weight" => $edit["weight"]);
+ if ($edit['tid'] && $edit['name']) {
+ $data = array('name' => $edit['name'], 'description' => $edit['description'], 'weight' => $edit['weight']);
- db_query("UPDATE {term_data} SET ". _prepare_update($data) ." WHERE tid = %d", $edit["tid"]);
- module_invoke_all("taxonomy", "update", "term", $edit);
- $message = t("the term '%a' has been updated.", array("%a" => $edit["name"]));
+ db_query('UPDATE {term_data} SET '. _prepare_update($data) .' WHERE tid = %d', $edit['tid']);
+ module_invoke_all('taxonomy', 'update', 'term', $edit);
+ $message = t('the term "%a" has been updated.', array('%a' => $edit['name']));
}
- else if ($edit["tid"]) {
- return taxonomy_del_term($edit["tid"]);
+ else if ($edit['tid']) {
+ return taxonomy_del_term($edit['tid']);
}
else {
- $edit["tid"] = db_next_id("{term_data}_tid");
- $data = array("tid" => $edit["tid"], "name" => $edit["name"], "description" => $edit["description"], "vid" => $edit["vid"], "weight" => $edit["weight"]);
- db_query("INSERT INTO {term_data} ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2));
- module_invoke_all("taxonomy", "insert", "term", $edit);
- $message = t("created new term '%name'.", array("%name" => $edit["name"]));
+ $edit['tid'] = db_next_id('{term_data}_tid');
+ $data = array('tid' => $edit['tid'], 'name' => $edit['name'], 'description' => $edit['description'], 'vid' => $edit['vid'], 'weight' => $edit['weight']);
+ db_query('INSERT INTO {term_data} '. _prepare_insert($data, 1) .' VALUES '. _prepare_insert($data, 2));
+ module_invoke_all('taxonomy', 'insert', 'term', $edit);
+ $message = t('created new term "%name".', array('%name' => $edit['name']));
}
- // relations (seem very powerful, but I have to understand it completely)
- db_query("DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d", $edit["tid"], $edit["tid"]);
- if ($edit["relations"]) {
- foreach ($edit["relations"] as $related_id) {
+ db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $edit['tid'], $edit['tid']);
+ if ($edit['relations']) {
+ foreach ($edit['relations'] as $related_id) {
if ($related_id != 0) {
- db_query("INSERT INTO {term_relation} (tid1, tid2) VALUES (%d, %d)", $edit["tid"], $related_id);
+ db_query('INSERT INTO {term_relation} (tid1, tid2) VALUES (%d, %d)', $edit['tid'], $related_id);
}
}
}
- // hierarchy
- db_query("DELETE FROM {term_hierarchy} WHERE tid = %d", $edit["tid"]);
- if (!isset($edit["parent"])) {
- $edit["parent"] = 0;
+ db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $edit['tid']);
+ if (!isset($edit['parent'])) {
+ $edit['parent'] = 0;
}
- if (is_array($edit["parent"])) {
- foreach ($edit["parent"] as $parent) {
- db_query("INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)", $edit["tid"], $parent);
+ if (is_array($edit['parent'])) {
+ foreach ($edit['parent'] as $parent) {
+ db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $edit['tid'], $parent);
}
}
else {
- db_query("INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)", $edit["tid"], $edit["parent"][0]);
+ db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $edit['tid'], $edit['parent'][0]);
}
- db_query("DELETE FROM {term_synonym} WHERE tid = %d", $edit["tid"]);
- if ($edit["synonyms"]) {
- foreach (explode ("\n", str_replace("\r", "", $edit["synonyms"])) as $synonym) {
+ db_query('DELETE FROM {term_synonym} WHERE tid = %d', $edit['tid']);
+ if ($edit['synonyms']) {
+ foreach (explode ("\n", str_replace("\r", '', $edit['synonyms'])) as $synonym) {
if ($synonym) {
- db_query("INSERT INTO {term_synonym} (tid, name) VALUES (%d, '%s')", $edit["tid"], chop($synonym));
+ db_query("INSERT INTO {term_synonym} (tid, name) VALUES (%d, '%s')", $edit['tid'], chop($synonym));
}
}
}
@@ -245,86 +254,90 @@ function taxonomy_save_term($edit) {
function taxonomy_del_term($tid) {
$term = taxonomy_get_term($tid);
- db_query("DELETE FROM {term_data} WHERE tid = %d", $tid);
- db_query("DELETE FROM {term_hierarchy} WHERE tid = %d", $tid);
- db_query("DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d", $tid, $tid);
- db_query("DELETE FROM {term_synonym} WHERE tid = %d", $tid);
- db_query("DELETE FROM {term_node} WHERE tid = %d", $tid);
+ db_query('DELETE FROM {term_data} WHERE tid = %d', $tid);
+ db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $tid);
+ db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $tid, $tid);
+ db_query('DELETE FROM {term_synonym} WHERE tid = %d', $tid);
+ db_query('DELETE FROM {term_node} WHERE tid = %d', $tid);
- module_invoke_all("taxonomy", "delete", "term", $term);
+ module_invoke_all('taxonomy', 'delete', 'term', $term);
cache_clear_all();
- return t("deleted term '%name'.", array("%name" => $term->name));
+ return t('deleted term "%name".', array('%name' => $term->name));
}
function _taxonomy_confirm_del_term($tid) {
$term = taxonomy_get_term($tid);
- $form .= form_hidden("confirm", 1);
- $form .= form_hidden("type", "term");
- $form .= form_hidden("tid", $tid);
- $form .= form_submit(t("Delete"));
- $form .= form_submit(t("Cancel"));
+ $form .= form_hidden('confirm', 1);
+ $form .= form_hidden('type', 'term');
+ $form .= form_hidden('tid', $tid);
+ $form .= form_submit(t('Delete'));
+ $form .= form_submit(t('Cancel'));
- return form(form_item(t("Delete term '%name'", array("%name" => $term->name)), $form, t("Are you sure you want to delete the term?")));
+ return form(form_item(t('Delete term "%name"', array('%name' => $term->name)), $form, t('Are you sure you want to delete the term?')));
}
+/**
+ * Generate a tabular listing of administrative functions for vocabularies.
+ */
function taxonomy_overview() {
-
- $output .= "<h3>". t("Vocabularies overview") ."</h3>";
-
- $header = array(t("name"), t("node types"), array("data" => t("operations"), "colspan" => 3));
+ $header = array(t('name'), t('node types'), array('data' => t('operations'), 'colspan' => 3));
$vocabularies = taxonomy_get_vocabularies();
foreach ($vocabularies as $vocabulary) {
$links = array();
$types = array();
- foreach(explode(",", $vocabulary->nodes) as $type) {
- $types[] = node_invoke($type, "node_name");
+ foreach(explode(',', $vocabulary->nodes) as $type) {
+ $types[] = node_invoke($type, 'node_name');
}
- $rows[] = array($vocabulary->name, array("data" => implode(", ", $types), "align" => "center"), l(t("edit vocabulary"), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t("add term"), "admin/taxonomy/add/term/$vocabulary->vid"), l(t("preview form"), "admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
+ $rows[] = array($vocabulary->name, array('data' => implode(', ', $types), 'align' => 'center'), l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('add term'), "admin/taxonomy/add/term/$vocabulary->vid"), l(t('preview form'), "admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
$tree = taxonomy_get_tree($vocabulary->vid);
if ($tree) {
unset($data);
foreach ($tree as $term) {
- $data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". l(t("edit term"), "admin/taxonomy/edit/term/$term->tid") .")<br />";
+ $data .= _taxonomy_depth($term->depth) .' '. $term->name .' ('. l(t('edit term'), "admin/taxonomy/edit/term/$term->tid") .')<br />';
}
- $rows[] = array(array("data" => $data, "colspan" => 5));
+ $rows[] = array(array('data' => $data, 'colspan' => 5));
}
}
- return theme("table", $header, $rows);
+ return theme('table', $header, $rows);
}
-function taxonomy_form($vocabulary_id, $value = 0, $error = array(), $help = NULL) {
- $vocabulary = taxonomy_get_vocabulary($vocabulary_id);
+/**
+ * Generate a form element for selecting terms from a vocabulary.
+ */
+function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL) {
+ $vocabulary = taxonomy_get_vocabulary($vid);
$help = ($help) ? $help : $vocabulary->help;
if ($vocabulary->required) {
$blank = 0;
}
else {
- $blank = "<". t("none") .">";
+ $blank = '<'. t('none') .'>';
}
$help .= $error['taxonomy'];
- return _taxonomy_term_select($vocabulary->name, 'taxonomy', $value, $vocabulary_id, $help, intval($vocabulary->multiple), $blank);
+ return _taxonomy_term_select($vocabulary->name, 'taxonomy', $value, $vid, $help, intval($vocabulary->multiple), $blank);
}
-/*
-** API functions
-*/
-
-// return array of vocabularies, as objects
-function taxonomy_get_vocabularies($type = '', $key = "vid") {
+/**
+ * Return an array of all vocabulary objects.
+ *
+ * @param $type
+ * If set, return only those vocabularies associated with this node type.
+ */
+function taxonomy_get_vocabularies($type = '', $key = 'vid') {
if ($type) {
$result = db_query("SELECT * FROM {vocabulary} WHERE nodes LIKE '%%%s%%' ORDER BY weight, name", $type);
}
else {
- $result = db_query("SELECT * FROM {vocabulary} ORDER BY weight, name");
+ $result = db_query('SELECT * FROM {vocabulary} ORDER BY weight, name');
}
$vocabularies = array();
while ($voc = db_fetch_object($result)) {
@@ -334,7 +347,9 @@ function taxonomy_get_vocabularies($type = '', $key = "vid") {
return $vocabularies;
}
-// return form with current term
+/**
+ * Generate a form for selecting terms to associate with a node.
+ */
function taxonomy_node_form($type, $node = '', $error = array()) {
if (!$node->taxonomy) {
if ($node->nid) {
@@ -355,16 +370,20 @@ function taxonomy_node_form($type, $node = '', $error = array()) {
return $result ? $result : array();
}
-// return 1 if node identified by $nid contains a taxonomy term identified by $tid in his body or title
+/**
+ * Determine whether a node mentions the name of a term.
+ */
function taxonomy_node_has_term($nid, $tid) {
- $term_name = db_result(db_query("SELECT name FROM {term_data} WHERE tid = %d", $tid));
+ $term_name = db_result(db_query('SELECT name FROM {term_data} WHERE tid = %d', $tid));
return db_result(db_query("SELECT COUNT(n.nid) FROM {node} n WHERE n.nid = %d AND ((n.body LIKE '%%%s%%') OR (n.body LIKE '%%%s%%'))", $nid, $term_name, $term_name));
}
-// return array of terms of a node beloging to a particular vocabulary identified by $vid
-function taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = "tid") {
- $result = db_query("SELECT t.* FROM {term_data} t, {term_node} r WHERE t.tid = r.tid AND t.vid = %d AND r.nid = %d ORDER BY weight", $vid, $nid);
+/**
+ * Find all terms associated to the given node, within one vocabulary.
+ */
+function taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = 'tid') {
+ $result = db_query('SELECT t.* FROM {term_data} t, {term_node} r WHERE t.tid = r.tid AND t.vid = %d AND r.nid = %d ORDER BY weight', $vid, $nid);
$terms = array();
while ($term = db_fetch_object($result)) {
$terms[$term->$key] = $term;
@@ -372,12 +391,14 @@ function taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = "tid") {
return $terms;
}
-// return array of terms of a node
-function taxonomy_node_get_terms($nid, $key = "tid") {
+/**
+ * Find all terms associated to the given node.
+ */
+function taxonomy_node_get_terms($nid, $key = 'tid') {
static $terms;
if (!isset($terms[$nid])) {
- $result = db_query("SELECT t.* FROM {term_data} t, {term_node} r WHERE r.tid = t.tid AND r.nid = %d ORDER BY weight, name", $nid);
+ $result = db_query('SELECT t.* FROM {term_data} t, {term_node} r WHERE r.tid = t.tid AND r.nid = %d ORDER BY weight, name', $nid);
$terms[$nid] = array();
while ($term = db_fetch_object($result)) {
$terms[$nid][$term->$key] = $term;
@@ -386,28 +407,34 @@ function taxonomy_node_get_terms($nid, $key = "tid") {
return $terms[$nid];
}
-// save terms of a node
+/**
+ * Save term associations for a given node.
+ */
function taxonomy_node_save($nid, $terms) {
taxonomy_node_delete($nid);
if ($terms) {
foreach ($terms as $term) {
if ($term) {
- db_query("INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)", $nid, $term);
+ db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $term);
}
}
}
}
-// clean up terms
+/**
+ * Remove associations of a node to its terms.
+ */
function taxonomy_node_delete($nid) {
- db_query("DELETE FROM {term_node} WHERE nid = %d", $nid);
+ db_query('DELETE FROM {term_node} WHERE nid = %d', $nid);
}
-// relations: return array of related terms
-function taxonomy_get_related($tid, $key = "tid") {
+/**
+ * Find all term objects related to a given term ID.
+ */
+function taxonomy_get_related($tid, $key = 'tid') {
if ($tid) {
- $result = db_query("SELECT t.*, tid1, tid2 FROM {term_relation} , {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name", $tid, $tid, $tid);
+ $result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid);
$related = array();
while ($term = db_fetch_object($result)) {
$related[$term->$key] = $term;
@@ -419,10 +446,12 @@ function taxonomy_get_related($tid, $key = "tid") {
}
}
-// hierarchy: get parent terms
-function taxonomy_get_parents($tid, $key = "tid") {
+/**
+ * Find all parents of a given term ID.
+ */
+function taxonomy_get_parents($tid, $key = 'tid') {
if ($tid) {
- $result = db_query("SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE h.parent = t.tid AND h.tid = %d ORDER BY weight, name", $tid);
+ $result = db_query('SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE h.parent = t.tid AND h.tid = %d ORDER BY weight, name', $tid);
$parents = array();
while ($parent = db_fetch_object($result)) {
$parents[$parent->$key] = $parent;
@@ -434,8 +463,10 @@ function taxonomy_get_parents($tid, $key = "tid") {
}
}
-// Gets all parents, parents of parents, etc.
-function taxonomy_get_parents_all($tid, $key = "tid") {
+/**
+ * Find all ancestors of a given term ID.
+ */
+function taxonomy_get_parents_all($tid) {
$parents = array();
if ($tid) {
$parents[] = taxonomy_get_term($tid);
@@ -448,13 +479,15 @@ function taxonomy_get_parents_all($tid, $key = "tid") {
return $parents;
}
-// hierarchy: get children
-function taxonomy_get_children($tid, $vid = 0, $key = "tid") {
+/**
+ * Find all children of a term ID.
+ */
+function taxonomy_get_children($tid, $vid = 0, $key = 'tid') {
if ($vid) {
- $result = db_query("SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE t.vid = %d AND h.tid = t.tid AND h.parent = %d ORDER BY weight, name", $vid, $tid);
+ $result = db_query('SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE t.vid = %d AND h.tid = t.tid AND h.parent = %d ORDER BY weight, name', $vid, $tid);
}
else {
- $result = db_query("SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE h.tid = t.tid AND parent = %d ORDER BY weight", $tid);
+ $result = db_query('SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE h.tid = t.tid AND parent = %d ORDER BY weight', $tid);
}
$children = array();
while ($term = db_fetch_object($result)) {
@@ -463,34 +496,52 @@ function taxonomy_get_children($tid, $vid = 0, $key = "tid") {
return $children;
}
-// hierarchy: get whole family, with tid, parent and depth; useful to show
-function taxonomy_get_tree($vocabulary_id, $parent = 0, $depth = -1, $max_depth = NULL) {
+/**
+ * Create a hierarchical representation of a vocabulary.
+ *
+ * @param $vid
+ * Which vocabulary to generate the tree for.
+ *
+ * @param $parent
+ * The term ID under which to generate the tree. If 0, generate the tree
+ * for the entire vocabulary.
+ *
+ * @param $depth
+ * Internal use only.
+ *
+ * @return
+ * An array of all term objects in the tree. Each term object is extended
+ * to have "depth" and "parents" attributes in addition to its normal ones.
+ */
+function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
static $children, $parents, $terms;
$depth++;
- // we cache trees, so it's not cpu-intensive to call get_tree on a term and its children too
- if (!isset($children[$vocabulary_id])) {
- $children[$vocabulary_id] = array();
+ // We cache trees, so it's not CPU-intensive to call get_tree() on a term
+ // and its children, too.
+ if (!isset($children[$vid])) {
+ $children[$vid] = array();
- $result = db_query("SELECT t.*, parent FROM {term_data} t, {term_hierarchy} h WHERE t.tid = h.tid AND t.vid = %d ORDER BY weight, name", $vocabulary_id);
+ $result = db_query('SELECT t.*, parent FROM {term_data} t, {term_hierarchy} h WHERE t.tid = h.tid AND t.vid = %d ORDER BY weight, name', $vid);
while ($term = db_fetch_object($result)) {
- $children[$vocabulary_id][$term->parent][] = $term->tid;
- $parents[$vocabulary_id][$term->tid][] = $term->parent;
- $terms[$vocabulary_id][$term->tid] = $term;
+ $children[$vid][$term->parent][] = $term->tid;
+ $parents[$vid][$term->tid][] = $term->parent;
+ $terms[$vid][$term->tid] = $term;
}
}
- $max_depth = ($max_depth == '') ? count($children[$vocabulary_id]) : $max_depth;
- if ($children[$vocabulary_id][$parent]) {
- foreach ($children[$vocabulary_id][$parent] as $child) {
+ $max_depth = ($max_depth == '') ? count($children[$vid]) : $max_depth;
+ if ($children[$vid][$parent]) {
+ foreach ($children[$vid][$parent] as $child) {
if ($max_depth > $depth) {
- $terms[$vocabulary_id][$child]->depth = $depth;
- unset($terms[$vocabulary_id][$child]->parent); // this is not useful as it would show one parent only
- $terms[$vocabulary_id][$child]->parents = $parents[$vocabulary_id][$child];
- $tree[] = $terms[$vocabulary_id][$child];
+ $terms[$vid][$child]->depth = $depth;
+ // The "parent" attribute is not useful, as it would show one parent only.
+ unset($terms[$vid][$child]->parent);
+ $terms[$vid][$child]->parents = $parents[$vid][$child];
+ $tree[] = $terms[$vid][$child];
- $tree = array_merge($tree, taxonomy_get_tree($vocabulary_id, $child, $depth, $max_depth));
+ $tree = array_merge($tree, taxonomy_get_tree($vid, $child, $depth, $max_depth));
}
}
}
@@ -498,12 +549,14 @@ function taxonomy_get_tree($vocabulary_id, $parent = 0, $depth = -1, $max_depth
return $tree ? $tree : array();
}
-// synonyms: return array of synonyms
+/**
+ * Return an array of synonyms of the given term ID.
+ */
function taxonomy_get_synonyms($tid) {
if ($tid) {
- $result = db_query("SELECT name FROM {term_synonym} WHERE tid = %d", $tid);
+ $result = db_query('SELECT name FROM {term_synonym} WHERE tid = %d', $tid);
while ($synonym = db_fetch_array($result)) {
- $synonyms[] = $synonym["name"];
+ $synonyms[] = $synonym['name'];
}
return $synonyms ? $synonyms : array();
}
@@ -512,19 +565,23 @@ function taxonomy_get_synonyms($tid) {
}
}
-// synonyms: return original term
-function taxonomy_get_synonym_root($term) {
- return db_fetch_object(db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = '%s'", $term));
+/**
+ * Return the term object that has the given string as a synonym.
+ */
+function taxonomy_get_synonym_root($synonym) {
+ return db_fetch_object(db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = '%s'", $synonym));
}
-// given a term id, count number of published nodes in it
+/**
+ * Given a term id, count the number of published nodes in it.
+ */
function taxonomy_term_count_nodes($tid, $type = 0) {
static $count;
if (!isset($count[$type])) {
// $type == 0 always evaluates true is $type is a string
if (is_numeric($type)) {
- $result = db_query("SELECT t.tid, COUNT(*) AS c FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 GROUP BY t.tid");
+ $result = db_query('SELECT t.tid, COUNT(*) AS c FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 GROUP BY t.tid');
}
else {
$result = db_query("SELECT t.tid, COUNT(*) AS c FROM {term_node} t, {node} n WHERE t.nid = n.nid AND n.status = 1 AND n.type = '%s' GROUP BY t.tid", $type);
@@ -540,12 +597,14 @@ function taxonomy_term_count_nodes($tid, $type = 0) {
return $count[$type][$tid] + $children_count;
}
-// helper for above function
+/**
+ * Helper for taxonomy_term_count_nodes().
+ */
function _taxonomy_term_children($tid) {
static $children;
if (!isset($children)) {
- $result = db_query("SELECT tid, parent FROM {term_hierarchy} ");
+ $result = db_query('SELECT tid, parent FROM {term_hierarchy}');
while ($term = db_fetch_object($result)) {
$children[$term->parent][] = $term->tid;
}
@@ -554,14 +613,18 @@ function _taxonomy_term_children($tid) {
}
/**
- * Try to map a string to existing vocabularies. Provide case insensitive and
- * trimmed map so as to maximize likelihood of successful mapping.
+ * Try to map a string to an existing vocabulary.
+ *
+ * Provides a case-insensitive and trimmed mapping, to maximize the
+ * likelihood of a successful match.
+ *
+ * @param name
+ * Name of the vocabulary to search for.
*
- * @param $name Name of the vocabulary to search
- * @return array of matching vocabularies, as objects
+ * @return
+ * An array of matching vocabulary objects.
*/
function taxonomy_get_vocabulary_by_name($name) {
- // LOWER is ANSI SQL-92
$db_result = db_query("SELECT * FROM {vocabulary} WHERE LOWER('%s') LIKE LOWER(name)", trim($name));
$result = array();
while ($vocabulary = db_fetch_object($db_result)) {
@@ -572,14 +635,18 @@ function taxonomy_get_vocabulary_by_name($name) {
}
/**
- * Try to map a string to existing terms Provide case insensitive and trimmed
- * map so as to maximize likelihood of successful mapping.
+ * Try to map a string to an existing term, as for glossary use.
*
- * @param name Name of the term to search
- * @return rray of matching terms, as objects
+ * Provides a case-insensitive and trimmed mapping, to maximize the
+ * likelihood of a successful match.
+ *
+ * @param name
+ * Name of the term to search for.
+ *
+ * @return
+ * An array of matching term objects.
*/
function taxonomy_get_term_by_name($name) {
- // LOWER is ANSI SQL-92
$db_result = db_query("SELECT * FROM {term_data} WHERE LOWER('%s') LIKE LOWER(name)", trim($name));
$result = array();
while ($term = db_fetch_object($db_result)) {
@@ -589,20 +656,21 @@ function taxonomy_get_term_by_name($name) {
return $result;
}
+/**
+ * Return the vocabulary object matching a vocabulary ID.
+ */
function taxonomy_get_vocabulary($vid) {
- // simple cache using a static var?
- return db_fetch_object(db_query("SELECT * FROM {vocabulary} WHERE vid = %d", $vid));
+ return db_fetch_object(db_query('SELECT * FROM {vocabulary} WHERE vid = %d', $vid));
}
+/**
+ * Return the term object matching a term ID.
+ */
function taxonomy_get_term($tid) {
// simple cache using a static var?
- return db_fetch_object(db_query("SELECT * FROM {term_data} WHERE tid = %d", $tid));
+ return db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
}
-/*
-** service functions
-*/
-
function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) {
$tree = taxonomy_get_tree($vocabulary_id);
@@ -615,13 +683,13 @@ function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $descripti
}
if ($blank) {
- $options[] = array("tid" => 0, "name" => $blank);
+ $options[] = array('tid' => 0, 'name' => $blank);
}
if ($tree) {
foreach ($tree as $term) {
if (!in_array($term->tid, $exclude)) {
- $options[] = array("tid" => $term->tid, "name" => _taxonomy_depth($term->depth, '-').$term->name);
+ $options[] = array('tid' => $term->tid, 'name' => _taxonomy_depth($term->depth, '-').$term->name);
}
}
if (!$blank && !$value) {
@@ -632,12 +700,12 @@ function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $descripti
if (count($options) > 0) {
foreach ($options as $option) {
- $select .= "<option value=\"". $option["tid"] ."\"". (is_array($value) ? (in_array($option["tid"], $value) ? " selected=\"selected\"" : "") : ($option["tid"] == $value ? " selected=\"selected\"" : "")) .">". check_form($option["name"]) ."</option>";
+ $select .= '<option value="'. $option['tid'] .'"'. (is_array($value) ? (in_array($option['tid'], $value) ? ' selected="selected"' : '') : ($option['tid'] == $value ? ' selected="selected"' : '')) .'>'. check_form($option['name']) .'</option>';
}
$size = min(12, count($options));
- return form_item($title, "<select name=\"edit[$name][]\"". ($multiple ? " multiple=\"multiple\" size=\"$size\"" : "") . ($extra ? " $extra" : "") .">$select</select>", $description);
+ return form_item($title, "<select name=\"edit[$name][]\"". ($multiple ? " multiple=\"multiple\" size=\"$size\"" : '') . ($extra ? " $extra" : '') .">$select</select>", $description);
}
}
@@ -652,46 +720,57 @@ function _prepare_update($data) {
foreach ($data as $key => $value) {
$q[] = "$key = '". check_query($value) ."'";
}
- $result = implode(", ", $q);
+ $result = implode(', ', $q);
return $result;
}
function _prepare_insert($data, $stage) {
if ($stage == 1) {
- $result = implode(", ", array_keys($data));
+ $result = implode(', ', array_keys($data));
}
else {
foreach (array_values($data) as $value) {
$q[] = "'". check_query($value) ."'";
}
- $result = implode(", ", $q);
+ $result = implode(', ', $q);
}
return "($result)";
}
-/*
-** Accepts taxonomy conditions and returns a resource identifier. If
-** you intend to use the nodes without a pager (eg. in a XML feed),
-** then set $pager to false.
-*/
-function taxonomy_select_nodes($taxonomy, $pager = 1) {
- global $user;
-
+/**
+ * Finds all nodes that match selected taxonomy conditions.
+ *
+ * @param $taxonomy
+ * An object containing the conditions to match. The attributes of this
+ * object are:
+ * - "tids": An array of term IDs to match.
+ * - "str_tids": A comma-separated list of the same IDs.
+ * - "operator": How to interpret multiple IDs in the array. Can be
+ * "or" or "and".
+ *
+ * @param $pager
+ * Whether the nodes are to be used with a pager (the case on most Drupal
+ * pages) or not (in an XML feed, for example).
+ *
+ * @return
+ * A resource identifier pointing to the query results.
+ */
+function taxonomy_select_nodes($taxonomy, $pager = TRUE) {
if ($taxonomy->str_tids) {
- if ($taxonomy->operator == "or") {
- $sql = "SELECT DISTINCT(n.nid), n.title, n.type, n.created, n.changed, n.uid, n.static, n.created, u.name FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = '1' ORDER BY static DESC, created DESC";
- $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = '1'";
+ if ($taxonomy->operator == 'or') {
+ $sql = "SELECT DISTINCT(n.nid), n.title, n.type, n.created, n.changed, n.uid, n.static, n.created, u.name FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = 1 ORDER BY static DESC, created DESC";
+ $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = 1";
}
else {
- $sql = "SELECT n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = '1' GROUP BY n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name HAVING COUNT(n.nid) = ". count($taxonomy->tids) ." ORDER BY static DESC, created DESC";
+ $sql = "SELECT n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = 1 GROUP BY n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name HAVING COUNT(n.nid) = ". count($taxonomy->tids) ." ORDER BY static DESC, created DESC";
// Special trick as we could not find anything better:
- $count = db_num_rows(db_query("SELECT n.nid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = '1' GROUP BY n.nid HAVING COUNT(n.nid) = ". count($taxonomy->tids)));
+ $count = db_num_rows(db_query("SELECT n.nid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = 1 GROUP BY n.nid HAVING COUNT(n.nid) = ". count($taxonomy->tids)));
$sql_count = "SELECT $count";
}
if ($pager) {
- $result = pager_query($sql, variable_get("default_nodes_main", 10) , 0, $sql_count);
+ $result = pager_query($sql, variable_get('default_nodes_main', 10) , 0, $sql_count);
}
else {
$result = db_query_range($sql, 0, 15);
@@ -701,29 +780,31 @@ function taxonomy_select_nodes($taxonomy, $pager = 1) {
return $result;
}
-/*
-** Accepts the result of a db_query() and formats each node along
-** with a pager.
+/**
+ * Accepts the result of a pager_query() call, such as that performed by
+ * taxonomy_select_nodes(), and formats each node along with a pager.
*/
function taxonomy_render_nodes($result) {
while ($node = db_fetch_object($result)) {
- $output .= node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1);
+ $output .= node_view(node_load(array('nid' => $node->nid, 'type' => $node->type)), 1);
}
- $output .= theme("pager", NULL, variable_get("default_nodes_main", 10), 0);
+ $output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0);
return $output;
}
+/**
+ * Implementation of hook_nodeapi().
+ */
function taxonomy_nodeapi($node, $op, $arg = 0) {
-
switch ($op) {
- case "insert":
+ case 'insert':
taxonomy_node_save($node->nid, $node->taxonomy);
break;
- case "update":
+ case 'update':
taxonomy_node_save($node->nid, $node->taxonomy);
break;
- case "delete":
+ case 'delete':
taxonomy_node_delete($node->nid);
break;
}
@@ -733,11 +814,11 @@ function taxonomy_page() {
$taxonomy->operator = arg(2);
$taxonomy->str_tids = check_query(arg(3));
- $taxonomy->tids = explode(",", $taxonomy->str_tids);
+ $taxonomy->tids = explode(',', $taxonomy->str_tids);
- if (ereg("^([0-9]+,){0,}[0-9]+$", $taxonomy->str_tids)) {
+ if (ereg('^([0-9]+,){0,}[0-9]+$', $taxonomy->str_tids)) {
switch (arg(1)) {
- case "feed":
+ case 'feed':
taxonomy_feed($taxonomy);
break;
default:
@@ -751,17 +832,18 @@ function taxonomy_page() {
// Build breadcrumb based on first hierarchy of first term:
$current->tid = $taxonomy->tids[0];
+ $breadcrumbs = array(array('path' => $_GET['q']));
while ($parents = taxonomy_get_parents($current->tid)) {
$current = array_shift($parents);
- $breadcrumbs[] = l($current->name, "taxonomy/view/or/$current->tid");
+ $breadcrumbs[] = array('path' => 'taxonomy/view/or/'. $current->tid, 'title' => $current->name);
}
- $breadcrumbs[] = l(t('Home'), '');
$breadcrumbs = array_reverse($breadcrumbs);
+ menu_set_location($breadcrumbs);
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. implode(' : ', $names) .'" href="'. url("taxonomy/feed/or/$taxonomy->str_tids") .'" />');
$output = taxonomy_render_nodes(taxonomy_select_nodes($taxonomy));
- print theme("page", $output, implode(', ', $names), $breadcrumbs);
+ print theme('page', $output, implode(', ', $names));
break;
}
}
@@ -770,62 +852,61 @@ function taxonomy_page() {
}
}
-/*
-** admin
-*/
-
+/**
+ * Menu callback; dispatches to the proper taxonomy administration function.
+ */
function taxonomy_admin() {
- $op = $_POST["op"];
- $edit = $_POST["edit"];
+ $op = $_POST['op'];
+ $edit = $_POST['edit'];
if (empty($op)) {
$op = arg(2);
}
switch ($op) {
- case "add":
- if (arg(3) == "vocabulary") {
+ case 'add':
+ if (arg(3) == 'vocabulary') {
$output .= taxonomy_form_vocabulary();
}
- else if (arg(3) == "term") {
+ else if (arg(3) == 'term') {
$output .= taxonomy_form_term();
}
break;
- case "edit":
- if (arg(3) == "vocabulary") {
+ case 'edit':
+ if (arg(3) == 'vocabulary') {
$output .= taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(4))));
}
- else if (arg(3) == "term") {
+ else if (arg(3) == 'term') {
$output .= taxonomy_form_term(object2array(taxonomy_get_term(arg(4))));
}
break;
- case "preview":
+ case 'preview':
$output .= taxonomy_form(arg(4));
break;
- case "help":
+ case 'help':
$output .= taxonomy_help();
break;
- case t("Delete"):
- if (!$edit["confirm"]) {
- if (arg(3) == "vocabulary") {
- $output .= _taxonomy_confirm_del_vocabulary($edit["vid"]);
+ case t('Delete'):
+ if (!$edit['confirm']) {
+ if (arg(3) == 'vocabulary') {
+ $output .= _taxonomy_confirm_del_vocabulary($edit['vid']);
}
else {
- $output .= _taxonomy_confirm_del_term($edit["tid"]);
+ $output .= _taxonomy_confirm_del_term($edit['tid']);
}
break;
}
else {
- $edit["name"] = 0;
+ $edit['name'] = 0;
// fall through:
}
- case t("Submit"):
- if (arg(3) == "vocabulary") {
+ case t('Submit'):
+ if (arg(3) == 'vocabulary') {
taxonomy_save_vocabulary($edit);
}
else {
taxonomy_save_term($edit);
- if (!$edit["tid"]) {
+ if (!$edit['tid']) {
// if INSERT show form again
$output .= taxonomy_form_term();
break;
@@ -837,24 +918,22 @@ function taxonomy_admin() {
$output .= taxonomy_overview();
}
- print theme("page", $output);
+ print theme('page', $output);
}
-function taxonomy_help($section = "admin/help#taxonomy") {
- $output = "";
-
+/**
+ * Implementation of hook_help().
+ */
+function taxonomy_help($section = 'admin/help#taxonomy') {
switch ($section) {
- case 'admin/system/modules#description':
- $output = t("Enables the organization of content into categories.");
- break;
+ case 'admin/modules#description':
+ return t('Enables the organization of content into categories.');
case 'admin/taxonomy':
- $output = t("The taxonomy module allows you to classify content into categories and subcategories; it allows multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically). To delete a term choose \"edit term\". To delete a vocabulary, and all its terms, choose \"edit vocabulary\".");
- break;
+ return t('The taxonomy module allows you to classify content into categories and subcategories; it allows multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically). To delete a term choose "edit term". To delete a vocabulary, and all its terms, choose "edit vocabulary".');
case 'admin/taxonomy/add/vocabulary':
- $output = t("When you create a controlled vocabulary you are creating a set of terms to use for describing content (known as descriptors in indexing lingo). Drupal allows you to describe each node type (blog, story, etc.) using one or many of these terms. For simple implementations, you might create a set of categories without subcategories, similar to Slashdot.org's or Kuro5hin.org's sections. For more complex implementations, you might create a hierarchical list of categories.");
- break;
+ return t("When you create a controlled vocabulary you are creating a set of terms to use for describing content (known as descriptors in indexing lingo). Drupal allows you to describe each node type (blog, story, etc.) using one or many of these terms. For simple implementations, you might create a set of categories without subcategories, similar to Slashdot.org's or Kuro5hin.org's sections. For more complex implementations, you might create a hierarchical list of categories.");
case 'admin/help#taxonomy':
- $output .= t("
+ return t("
<h3>Background</h3>
<p>Taxonomy is the study of classification. Drupal's taxonomy module allows you to define categories which are used to classify content. The module supports hierarchical classification and association between terms, allowing for truly flexible information retrieval and classification. For more details about <a href=\"%classification-types\">classification types</a> and insight into the development of the <em>taxonomy.module</em>, see this <a href=\"%drupal-dis\">drupal.org discussion</a>.</p>
<h3>An example taxonomy: food</h3>
@@ -886,10 +965,7 @@ function taxonomy_help($section = "admin/help#taxonomy") {
<h3><a id=\"taxonomy-url\"></a>Displaying nodes organized by term(s)</h3>
<p>In order to view the nodes associated with a term or a collection of terms, you should browse to a properly formed Taxonomy URL. For example, <a href=\"%taxo-example\">taxonomy/page/or/1,2</a>. Taxonomy URLs always contain one or more term IDs (tid) at the end of the URL (a.k.a the <em>querystring</em>). You may learn the term ID for a given term by hovering over that term in the <a href=\"%taxo-overview\">taxonomy overview</a> page and noting the number at the end or the URL. To build a Taxonomy URL start with \"taxonomy/page\". Now add the querystring parameter, either <em>or</em>, which chooses nodes tagged with <strong>any</strong> of the given term IDs, or <em>and</em>, which chooses nodes tagged with <strong>all</strong> of the given Term IDs. Thus <em>or</em> is less specific than <em>and</em>. Finally add a comma seperated list of term IDs.</p>
<h3>RSS feeds</h3>
- <p>Every term, or collection of terms, provides an <a href=\"%userland-rss\">RSS</a> feed to which interested users may subscribe. The URL format for a sample RSS feed is <a href=\"%sample-rss\">node/feed/or/1,2</a>. Built like a Taxonomy URL, <a href=\"%taxo-help\">see above</a> it starts with \"node/feed\", then has the querystring parameter, and finally the Term IDs.</p>", array("%classification-types" => "http://www.eleganthack.com/archives/002165.html#002165", "%drupal-dis" => "http://www.drupal.org/node/view/55", "%slashdot" => "http://www.slashdot.com/", "%taxo-example" => url("taxonomy/page/or/1,2"), "%taxo-overview" => url("admin/taxonomy"), "%userland-rss" => "http://backend.userland.com/stories/rss", "%sample-rss" => url("node/feed/or/1,2"), "%taxo-help" => url("admin/taxonomy/help", NULL, "taxonomy-url")));
- break;
+ <p>Every term, or collection of terms, provides an <a href=\"%userland-rss\">RSS</a> feed to which interested users may subscribe. The URL format for a sample RSS feed is <a href=\"%sample-rss\">node/feed/or/1,2</a>. Built like a Taxonomy URL, <a href=\"%taxo-help\">see above</a> it starts with \"node/feed\", then has the querystring parameter, and finally the Term IDs.</p>", array('%classification-types' => 'http://www.eleganthack.com/archives/002165.html#002165', '%drupal-dis' => 'http://www.drupal.org/node/55', '%slashdot' => 'http://www.slashdot.com/', '%taxo-example' => url('taxonomy/page/or/1,2'), '%taxo-overview' => url('admin/taxonomy'), '%userland-rss' => 'http://backend.userland.com/stories/rss', '%sample-rss' => url('node/feed/or/1,2'), '%taxo-help' => url('admin/taxonomy/help', NULL, 'taxonomy-url')));
}
-
- return $output;
}
?>
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index a38d5b9ff..9b27d6db5 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -4,21 +4,24 @@
function taxonomy_feed($taxonomy) {
global $id, $type;
- if ($type == "voc") {
+ if ($type == 'voc') {
//TODO - vocabulary feed.
}
else {
$result = taxonomy_select_nodes($taxonomy, 0);
$term = taxonomy_get_term($taxonomy->tids[0]);
- $channel["link"] = url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids", NULL, NULL, TRUE);
- $channel["title"] = variable_get("site_name", "drupal") ." - ". $term->name;
- $channel["description"] = $term->description;
+ $channel['link'] = url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids", NULL, NULL, TRUE);
+ $channel['title'] = variable_get('site_name', 'drupal') .' - '. $term->name;
+ $channel['description'] = $term->description;
node_feed($result, $channel);
}
}
+/**
+ * Implementation of hook_perm().
+ */
function taxonomy_perm() {
- return array("administer taxonomy");
+ return array('administer taxonomy');
}
/**
@@ -33,14 +36,7 @@ function taxonomy_perm() {
* }
*/
function taxonomy_link($type, $node = NULL) {
- if ($type == 'system') {
- menu('admin/taxonomy', t('categories'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED, 3);
- menu('admin/taxonomy/add/vocabulary', t('create new vocabulary'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED);
- menu('admin/taxonomy/help', t('help'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED, 9);
-
- menu('taxonomy', t('taxonomy'), user_access('access content') ? 'taxonomy_page' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
- else if ($type == 'taxonomy terms' && $node != NULL) {
+ if ($type == 'taxonomy terms' && $node != NULL) {
$links = array();
if ($node->taxonomy) {
foreach ($node->taxonomy as $tid) {
@@ -59,53 +55,68 @@ function taxonomy_link($type, $node = NULL) {
}
}
-/*
-** admin pages (form, save, overview)
-*/
+/**
+ * Implementation of hook_menu().
+ */
+function taxonomy_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/taxonomy', 'title' => t('categories'),
+ 'callback' => 'taxonomy_admin',
+ 'access' => user_access('administer taxonomy'));
+ $items[] = array('path' => 'admin/taxonomy/add/vocabulary', 'title' => t('add vocabulary'),
+ 'callback' => 'taxonomy_admin',
+ 'access' => user_access('administer taxonomy'),
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'taxonomy', 'title' => t('taxonomy'),
+ 'callback' => 'taxonomy_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+ return $items;
+}
function taxonomy_form_vocabulary($edit = array()) {
foreach (node_list() as $type) {
- $nodetypes[$type] = node_invoke($type, "node_name");
+ $nodetypes[$type] = node_invoke($type, 'node_name');
}
- $form .= form_textfield(t("Vocabulary name"), "name", $edit["name"], 50, 64, t("Required") .". ". t("The name for this vocabulary. Example: 'Topic'") .".");
- $form .= form_textarea(t("Description"), "description", $edit["description"], 60, 5, t("Optional") .". ". t("Description of the vocabulary, can be used by modules."));
- $form .= form_textfield(t("Help text"), "help", $edit["help"], 50, 255, t("Optional") .". ". t("Instructions to present to the user when choosing a term.") .".");
- $form .= form_checkboxes(t("Types"), "nodes", explode(",", $edit["nodes"]), $nodetypes, t("Required") .". ". t("A list of node types you want to associate this vocabulary with."));
- $form .= form_checkbox(t("Related terms"), "relations", 1, $edit["relations"], t("Optional") .". ". t("Allows <a href=\"%help-url\">related terms</a> in this vocabulary.", array("%help-url" => url("admin/taxonomy/help", NULL, NULL, "related-terms"))));
- $form .= form_radios(t("Hierarchy"), "hierarchy", $edit["hierarchy"], array(t("Disabled"), t("Single"), t("Multiple")), t("Optional") .". ". t("Allows <a href=\"%help-url\">a tree-like hierarchy</a> between terms of this vocabulary.", array("%help-url" => url("admin/taxonomy/help", NULL, NULL, "hierarchy"))), "");
- $form .= form_checkbox(t("Multiple select"), "multiple", 1, $edit["multiple"], t("Optional") .". ". t("Allows nodes to have more than one term in this vocabulary."));
- $form .= form_checkbox(t("Required"), "required", 1, $edit["required"], t("If enabled every node <strong>must</strong> have at least one term in this vocabulary"));
- $form .= form_weight(t("Weight"), "weight", $edit["weight"], 10, t("Optional. In listings, the heavier vocabularies will sink and the lighter vocabularies will be positioned nearer the top."));
- $form .= form_submit(t("Submit"));
+ $form .= form_textfield(t('Vocabulary name'), 'name', $edit['name'], 50, 64, t('Required') .'. '. t('The name for this vocabulary. Example: "Topic"') .'.');
+ $form .= form_textarea(t('Description'), 'description', $edit['description'], 60, 5, t('Optional') .'. '. t('Description of the vocabulary; can be used by modules.'));
+ $form .= form_textfield(t('Help text'), 'help', $edit['help'], 50, 255, t('Optional') .'. '. t('Instructions to present to the user when choosing a term.') .'.');
+ $form .= form_checkboxes(t('Types'), 'nodes', explode(',', $edit['nodes']), $nodetypes, t('Required') .'. '. t('A list of node types you want to associate with this vocabulary.'));
+ $form .= form_checkbox(t('Related terms'), 'relations', 1, $edit['relations'], t('Optional') .'. '. t('Allows <a href="%help-url">related terms</a> in this vocabulary.', array('%help-url' => url('admin/taxonomy/help', NULL, NULL, 'related-terms'))));
+ $form .= form_radios(t('Hierarchy'), 'hierarchy', $edit['hierarchy'], array(t('Disabled'), t('Single'), t('Multiple')), t('Optional') .'. '. t('Allows <a href="%help-url">a tree-like hierarchy</a> between terms of this vocabulary.', array('%help-url' => url('admin/taxonomy/help', NULL, NULL, 'hierarchy'))), '');
+ $form .= form_checkbox(t('Multiple select'), 'multiple', 1, $edit['multiple'], t('Optional') .'. '. t('Allows nodes to have more than one term in this vocabulary.'));
+ $form .= form_checkbox(t('Required'), 'required', 1, $edit['required'], t('If enabled, every node <strong>must</strong> have at least one term in this vocabulary.'));
+ $form .= form_weight(t('Weight'), 'weight', $edit['weight'], 10, t('Optional. In listings, the heavier vocabularies will sink and the lighter vocabularies will be positioned nearer the top.'));
+ $form .= form_submit(t('Submit'));
- if ($edit["vid"]) {
- $form .= form_submit(t("Delete"));
- $form .= form_hidden("vid", $edit["vid"]);
+ if ($edit['vid']) {
+ $form .= form_submit(t('Delete'));
+ $form .= form_hidden('vid', $edit['vid']);
}
return form($form);
}
function taxonomy_save_vocabulary($edit) {
- if (!$edit["nodes"]) {
- $edit["nodes"] = array();
+ if (!$edit['nodes']) {
+ $edit['nodes'] = array();
}
- $data = array("name" => $edit["name"], "nodes" => implode(",", $edit["nodes"]), "description" => $edit["description"], "help" => $edit["help"], "multiple" => $edit["multiple"], "required" => $edit["required"], "hierarchy" => $edit["hierarchy"], "relations" => $edit["relations"], "weight" => $edit["weight"]);
- if ($edit["vid"] && $edit["name"]) {
- db_query("UPDATE {vocabulary} SET ". _prepare_update($data) ." WHERE vid = %d", $edit["vid"]);
- module_invoke_all("taxonomy", "update", "vocabulary", $edit);
- $message = t("updated vocabulary '%name'.", array("%name" => $edit["name"]));
+ $data = array('name' => $edit['name'], 'nodes' => implode(',', $edit['nodes']), 'description' => $edit['description'], 'help' => $edit['help'], 'multiple' => $edit['multiple'], 'required' => $edit['required'], 'hierarchy' => $edit['hierarchy'], 'relations' => $edit['relations'], 'weight' => $edit['weight']);
+ if ($edit['vid'] && $edit['name']) {
+ db_query('UPDATE {vocabulary} SET '. _prepare_update($data) .' WHERE vid = %d', $edit['vid']);
+ module_invoke_all('taxonomy', 'update', 'vocabulary', $edit);
+ $message = t('updated vocabulary "%name".', array('%name' => $edit['name']));
}
- else if ($edit["vid"]) {
- $message = taxonomy_del_vocabulary($edit["vid"]);
+ else if ($edit['vid']) {
+ $message = taxonomy_del_vocabulary($edit['vid']);
}
else {
- $data["vid"] = $edit["vid"] = db_next_id("{vocabulary}_vid");
- db_query("INSERT INTO {vocabulary} ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2));
- module_invoke_all("taxonomy", "insert", "vocabulary", $edit);
- $message = t("created new vocabulary '%name'.", array("%name" => $edit["name"]));
+ $data['vid'] = $edit['vid'] = db_next_id('{vocabulary}_vid');
+ db_query('INSERT INTO {vocabulary} '. _prepare_insert($data, 1) .' VALUES '. _prepare_insert($data, 2));
+ module_invoke_all('taxonomy', 'insert', 'vocabulary', $edit);
+ $message = t('created new vocabulary "%name".', array('%name' => $edit['name']));
}
cache_clear_all();
@@ -117,121 +128,119 @@ function taxonomy_save_vocabulary($edit) {
function taxonomy_del_vocabulary($vid) {
$vocabulary = taxonomy_get_vocabulary($vid);
- db_query("DELETE FROM {vocabulary} WHERE vid = %d", $vid);
- $result = db_query("SELECT tid FROM {term_data} WHERE vid = %d", $vid);
+ db_query('DELETE FROM {vocabulary} WHERE vid = %d', $vid);
+ $result = db_query('SELECT tid FROM {term_data} WHERE vid = %d', $vid);
while ($term = db_fetch_object($result)) {
taxonomy_del_term($term->tid);
}
- module_invoke_all("taxonomy", "delete", "vocabulary", $vocabulary);
+ module_invoke_all('taxonomy', 'delete', 'vocabulary', $vocabulary);
cache_clear_all();
- return t("deleted vocabulary '%name'.", array("%name" => $vocabulary->name));
+ return t('deleted vocabulary "%name".', array('%name' => $vocabulary->name));
}
function _taxonomy_confirm_del_vocabulary($vid) {
$vocabulary = taxonomy_get_vocabulary($vid);
- $form .= form_hidden("confirm", 1);
- $form .= form_hidden("type", "vocabulary");
- $form .= form_hidden("vid", $vid);
- $form .= form_submit(t("Delete"));
- $form .= form_submit(t("Cancel"));
+ $form .= form_hidden('confirm', 1);
+ $form .= form_hidden('type', 'vocabulary');
+ $form .= form_hidden('vid', $vid);
+ $form .= form_submit(t('Delete'));
+ $form .= form_submit(t('Cancel'));
- return form(form_item(t("Delete vocabulary '%name'", array("%name" => $vocabulary->name)), $form, t("Are you sure you want to delete the vocabulary and all its terms?")));
+ return form(form_item(t('Delete vocabulary "%name"', array('%name' => $vocabulary->name)), $form, t('Are you sure you want to delete the vocabulary and all its terms?')));
}
function taxonomy_form_term($edit = array()) {
- $vocabulary_id = isset($edit["vid"]) ? $edit["vid"] : arg(4);
+ $vocabulary_id = isset($edit['vid']) ? $edit['vid'] : arg(4);
$vocabulary = taxonomy_get_vocabulary($vocabulary_id);
- $form = form_textfield(t("Term name"), "name", $edit["name"], 50, 64, t("Required") .". ". t("The name for this term. Example: 'Linux'."));
- $form .= form_textarea(t("Description"), "description", $edit["description"], 60, 5, t("Optional") .". ". t("A description of the term."));
+ $form = form_textfield(t('Term name'), 'name', $edit['name'], 50, 64, t('Required') .'. '. t('The name for this term. Example: "Linux".'));
+ $form .= form_textarea(t('Description'), 'description', $edit['description'], 60, 5, t('Optional') .'. '. t('A description of the term.'));
if ($vocabulary->hierarchy) {
- $parent = array_keys(taxonomy_get_parents($edit["tid"]));
- $children = taxonomy_get_tree($vocabulary_id, $edit["tid"]);
+ $parent = array_keys(taxonomy_get_parents($edit['tid']));
+ $children = taxonomy_get_tree($vocabulary_id, $edit['tid']);
- // you can't be son of yourself nor of your children
+ // A term can't be the child of itself, nor of its children.
foreach ($children as $child) {
$exclude[] = $child->tid;
}
- $exclude[] = $edit["tid"];
+ $exclude[] = $edit['tid'];
if ($vocabulary->hierarchy == 1) {
- $form .= _taxonomy_term_select(t("Parent"), "parent", $parent, $vocabulary_id, t("Required") .". ". l(t("Parent term"), "admin/taxonomy/help", NULL, NULL, "parent") .".", 0, "<". t("root") .">", $exclude);
+ $form .= _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary_id, t('Required') .'. '. l(t('Parent term'), 'admin/taxonomy/help', NULL, NULL, 'parent') .'.', 0, '<'. t('root') .'>', $exclude);
}
elseif ($vocabulary->hierarchy == 2) {
- $form .= _taxonomy_term_select(t("Parents"), "parent", $parent, $vocabulary_id, t("Required") .". ". l(t("Parent terms"), "admin/taxonomy/help", NULL, NULL, "parent") .".", 1, "<". t("root") .">", $exclude);
+ $form .= _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary_id, t('Required') .'. '. l(t('Parent terms'), 'admin/taxonomy/help', NULL, NULL, 'parent') .'.', 1, '<'. t('root') .'>', $exclude);
}
}
if ($vocabulary->relations) {
- $form .= _taxonomy_term_select(t("Related terms"), "relations", array_keys(taxonomy_get_related($edit["tid"])), $vocabulary_id, t("Optional") .". ", 1, "<". t("none") .">", array($edit["tid"]));
+ $form .= _taxonomy_term_select(t('Related terms'), 'relations', array_keys(taxonomy_get_related($edit['tid'])), $vocabulary_id, t('Optional') .'. ', 1, '<'. t('none') .'>', array($edit['tid']));
}
- $form .= form_textarea(t("Synonyms"), "synonyms", implode("\n", taxonomy_get_synonyms($edit["tid"])), 30, 5, t("Optional") . ". ". t("<a href=\"%help-url\">Synonyms</a> of this term, one synonym per line.", array("%help-url" => url("admin/taxonomy/help", NULL, NULL, "synonyms"))));
- $form .= form_weight(t("Weight"), "weight", $edit["weight"], 10, t("Optional. In listings, the heavier terms will sink and the lighter terms will be positioned nearer the top."));
- $form .= form_hidden("vid", $vocabulary->vid);
- $form .= form_submit(t("Submit"));
+ $form .= form_textarea(t('Synonyms'), 'synonyms', implode("\n", taxonomy_get_synonyms($edit['tid'])), 30, 5, t('Optional') . '. '. t('<a href="%help-url">Synonyms</a> of this term, one synonym per line.', array('%help-url' => url('admin/taxonomy/help', NULL, NULL, 'synonyms'))));
+ $form .= form_weight(t('Weight'), 'weight', $edit['weight'], 10, t('Optional. In listings, the heavier terms will sink and the lighter terms will be positioned nearer the top.'));
+ $form .= form_hidden('vid', $vocabulary->vid);
+ $form .= form_submit(t('Submit'));
- if ($edit["tid"]) {
- $form .= form_submit(t("Delete"));
- $form .= form_hidden("tid", $edit["tid"]);
+ if ($edit['tid']) {
+ $form .= form_submit(t('Delete'));
+ $form .= form_hidden('tid', $edit['tid']);
}
return form($form);
}
function taxonomy_save_term($edit) {
- if ($edit["tid"] && $edit["name"]) {
- $data = array("name" => $edit["name"], "description" => $edit["description"], "weight" => $edit["weight"]);
+ if ($edit['tid'] && $edit['name']) {
+ $data = array('name' => $edit['name'], 'description' => $edit['description'], 'weight' => $edit['weight']);
- db_query("UPDATE {term_data} SET ". _prepare_update($data) ." WHERE tid = %d", $edit["tid"]);
- module_invoke_all("taxonomy", "update", "term", $edit);
- $message = t("the term '%a' has been updated.", array("%a" => $edit["name"]));
+ db_query('UPDATE {term_data} SET '. _prepare_update($data) .' WHERE tid = %d', $edit['tid']);
+ module_invoke_all('taxonomy', 'update', 'term', $edit);
+ $message = t('the term "%a" has been updated.', array('%a' => $edit['name']));
}
- else if ($edit["tid"]) {
- return taxonomy_del_term($edit["tid"]);
+ else if ($edit['tid']) {
+ return taxonomy_del_term($edit['tid']);
}
else {
- $edit["tid"] = db_next_id("{term_data}_tid");
- $data = array("tid" => $edit["tid"], "name" => $edit["name"], "description" => $edit["description"], "vid" => $edit["vid"], "weight" => $edit["weight"]);
- db_query("INSERT INTO {term_data} ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2));
- module_invoke_all("taxonomy", "insert", "term", $edit);
- $message = t("created new term '%name'.", array("%name" => $edit["name"]));
+ $edit['tid'] = db_next_id('{term_data}_tid');
+ $data = array('tid' => $edit['tid'], 'name' => $edit['name'], 'description' => $edit['description'], 'vid' => $edit['vid'], 'weight' => $edit['weight']);
+ db_query('INSERT INTO {term_data} '. _prepare_insert($data, 1) .' VALUES '. _prepare_insert($data, 2));
+ module_invoke_all('taxonomy', 'insert', 'term', $edit);
+ $message = t('created new term "%name".', array('%name' => $edit['name']));
}
- // relations (seem very powerful, but I have to understand it completely)
- db_query("DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d", $edit["tid"], $edit["tid"]);
- if ($edit["relations"]) {
- foreach ($edit["relations"] as $related_id) {
+ db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $edit['tid'], $edit['tid']);
+ if ($edit['relations']) {
+ foreach ($edit['relations'] as $related_id) {
if ($related_id != 0) {
- db_query("INSERT INTO {term_relation} (tid1, tid2) VALUES (%d, %d)", $edit["tid"], $related_id);
+ db_query('INSERT INTO {term_relation} (tid1, tid2) VALUES (%d, %d)', $edit['tid'], $related_id);
}
}
}
- // hierarchy
- db_query("DELETE FROM {term_hierarchy} WHERE tid = %d", $edit["tid"]);
- if (!isset($edit["parent"])) {
- $edit["parent"] = 0;
+ db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $edit['tid']);
+ if (!isset($edit['parent'])) {
+ $edit['parent'] = 0;
}
- if (is_array($edit["parent"])) {
- foreach ($edit["parent"] as $parent) {
- db_query("INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)", $edit["tid"], $parent);
+ if (is_array($edit['parent'])) {
+ foreach ($edit['parent'] as $parent) {
+ db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $edit['tid'], $parent);
}
}
else {
- db_query("INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)", $edit["tid"], $edit["parent"][0]);
+ db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $edit['tid'], $edit['parent'][0]);
}
- db_query("DELETE FROM {term_synonym} WHERE tid = %d", $edit["tid"]);
- if ($edit["synonyms"]) {
- foreach (explode ("\n", str_replace("\r", "", $edit["synonyms"])) as $synonym) {
+ db_query('DELETE FROM {term_synonym} WHERE tid = %d', $edit['tid']);
+ if ($edit['synonyms']) {
+ foreach (explode ("\n", str_replace("\r", '', $edit['synonyms'])) as $synonym) {
if ($synonym) {
- db_query("INSERT INTO {term_synonym} (tid, name) VALUES (%d, '%s')", $edit["tid"], chop($synonym));
+ db_query("INSERT INTO {term_synonym} (tid, name) VALUES (%d, '%s')", $edit['tid'], chop($synonym));
}
}
}
@@ -245,86 +254,90 @@ function taxonomy_save_term($edit) {
function taxonomy_del_term($tid) {
$term = taxonomy_get_term($tid);
- db_query("DELETE FROM {term_data} WHERE tid = %d", $tid);
- db_query("DELETE FROM {term_hierarchy} WHERE tid = %d", $tid);
- db_query("DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d", $tid, $tid);
- db_query("DELETE FROM {term_synonym} WHERE tid = %d", $tid);
- db_query("DELETE FROM {term_node} WHERE tid = %d", $tid);
+ db_query('DELETE FROM {term_data} WHERE tid = %d', $tid);
+ db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $tid);
+ db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $tid, $tid);
+ db_query('DELETE FROM {term_synonym} WHERE tid = %d', $tid);
+ db_query('DELETE FROM {term_node} WHERE tid = %d', $tid);
- module_invoke_all("taxonomy", "delete", "term", $term);
+ module_invoke_all('taxonomy', 'delete', 'term', $term);
cache_clear_all();
- return t("deleted term '%name'.", array("%name" => $term->name));
+ return t('deleted term "%name".', array('%name' => $term->name));
}
function _taxonomy_confirm_del_term($tid) {
$term = taxonomy_get_term($tid);
- $form .= form_hidden("confirm", 1);
- $form .= form_hidden("type", "term");
- $form .= form_hidden("tid", $tid);
- $form .= form_submit(t("Delete"));
- $form .= form_submit(t("Cancel"));
+ $form .= form_hidden('confirm', 1);
+ $form .= form_hidden('type', 'term');
+ $form .= form_hidden('tid', $tid);
+ $form .= form_submit(t('Delete'));
+ $form .= form_submit(t('Cancel'));
- return form(form_item(t("Delete term '%name'", array("%name" => $term->name)), $form, t("Are you sure you want to delete the term?")));
+ return form(form_item(t('Delete term "%name"', array('%name' => $term->name)), $form, t('Are you sure you want to delete the term?')));
}
+/**
+ * Generate a tabular listing of administrative functions for vocabularies.
+ */
function taxonomy_overview() {
-
- $output .= "<h3>". t("Vocabularies overview") ."</h3>";
-
- $header = array(t("name"), t("node types"), array("data" => t("operations"), "colspan" => 3));
+ $header = array(t('name'), t('node types'), array('data' => t('operations'), 'colspan' => 3));
$vocabularies = taxonomy_get_vocabularies();
foreach ($vocabularies as $vocabulary) {
$links = array();
$types = array();
- foreach(explode(",", $vocabulary->nodes) as $type) {
- $types[] = node_invoke($type, "node_name");
+ foreach(explode(',', $vocabulary->nodes) as $type) {
+ $types[] = node_invoke($type, 'node_name');
}
- $rows[] = array($vocabulary->name, array("data" => implode(", ", $types), "align" => "center"), l(t("edit vocabulary"), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t("add term"), "admin/taxonomy/add/term/$vocabulary->vid"), l(t("preview form"), "admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
+ $rows[] = array($vocabulary->name, array('data' => implode(', ', $types), 'align' => 'center'), l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('add term'), "admin/taxonomy/add/term/$vocabulary->vid"), l(t('preview form'), "admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
$tree = taxonomy_get_tree($vocabulary->vid);
if ($tree) {
unset($data);
foreach ($tree as $term) {
- $data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". l(t("edit term"), "admin/taxonomy/edit/term/$term->tid") .")<br />";
+ $data .= _taxonomy_depth($term->depth) .' '. $term->name .' ('. l(t('edit term'), "admin/taxonomy/edit/term/$term->tid") .')<br />';
}
- $rows[] = array(array("data" => $data, "colspan" => 5));
+ $rows[] = array(array('data' => $data, 'colspan' => 5));
}
}
- return theme("table", $header, $rows);
+ return theme('table', $header, $rows);
}
-function taxonomy_form($vocabulary_id, $value = 0, $error = array(), $help = NULL) {
- $vocabulary = taxonomy_get_vocabulary($vocabulary_id);
+/**
+ * Generate a form element for selecting terms from a vocabulary.
+ */
+function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL) {
+ $vocabulary = taxonomy_get_vocabulary($vid);
$help = ($help) ? $help : $vocabulary->help;
if ($vocabulary->required) {
$blank = 0;
}
else {
- $blank = "<". t("none") .">";
+ $blank = '<'. t('none') .'>';
}
$help .= $error['taxonomy'];
- return _taxonomy_term_select($vocabulary->name, 'taxonomy', $value, $vocabulary_id, $help, intval($vocabulary->multiple), $blank);
+ return _taxonomy_term_select($vocabulary->name, 'taxonomy', $value, $vid, $help, intval($vocabulary->multiple), $blank);
}
-/*
-** API functions
-*/
-
-// return array of vocabularies, as objects
-function taxonomy_get_vocabularies($type = '', $key = "vid") {
+/**
+ * Return an array of all vocabulary objects.
+ *
+ * @param $type
+ * If set, return only those vocabularies associated with this node type.
+ */
+function taxonomy_get_vocabularies($type = '', $key = 'vid') {
if ($type) {
$result = db_query("SELECT * FROM {vocabulary} WHERE nodes LIKE '%%%s%%' ORDER BY weight, name", $type);
}
else {
- $result = db_query("SELECT * FROM {vocabulary} ORDER BY weight, name");
+ $result = db_query('SELECT * FROM {vocabulary} ORDER BY weight, name');
}
$vocabularies = array();
while ($voc = db_fetch_object($result)) {
@@ -334,7 +347,9 @@ function taxonomy_get_vocabularies($type = '', $key = "vid") {
return $vocabularies;
}
-// return form with current term
+/**
+ * Generate a form for selecting terms to associate with a node.
+ */
function taxonomy_node_form($type, $node = '', $error = array()) {
if (!$node->taxonomy) {
if ($node->nid) {
@@ -355,16 +370,20 @@ function taxonomy_node_form($type, $node = '', $error = array()) {
return $result ? $result : array();
}
-// return 1 if node identified by $nid contains a taxonomy term identified by $tid in his body or title
+/**
+ * Determine whether a node mentions the name of a term.
+ */
function taxonomy_node_has_term($nid, $tid) {
- $term_name = db_result(db_query("SELECT name FROM {term_data} WHERE tid = %d", $tid));
+ $term_name = db_result(db_query('SELECT name FROM {term_data} WHERE tid = %d', $tid));
return db_result(db_query("SELECT COUNT(n.nid) FROM {node} n WHERE n.nid = %d AND ((n.body LIKE '%%%s%%') OR (n.body LIKE '%%%s%%'))", $nid, $term_name, $term_name));
}
-// return array of terms of a node beloging to a particular vocabulary identified by $vid
-function taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = "tid") {
- $result = db_query("SELECT t.* FROM {term_data} t, {term_node} r WHERE t.tid = r.tid AND t.vid = %d AND r.nid = %d ORDER BY weight", $vid, $nid);
+/**
+ * Find all terms associated to the given node, within one vocabulary.
+ */
+function taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = 'tid') {
+ $result = db_query('SELECT t.* FROM {term_data} t, {term_node} r WHERE t.tid = r.tid AND t.vid = %d AND r.nid = %d ORDER BY weight', $vid, $nid);
$terms = array();
while ($term = db_fetch_object($result)) {
$terms[$term->$key] = $term;
@@ -372,12 +391,14 @@ function taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = "tid") {
return $terms;
}
-// return array of terms of a node
-function taxonomy_node_get_terms($nid, $key = "tid") {
+/**
+ * Find all terms associated to the given node.
+ */
+function taxonomy_node_get_terms($nid, $key = 'tid') {
static $terms;
if (!isset($terms[$nid])) {
- $result = db_query("SELECT t.* FROM {term_data} t, {term_node} r WHERE r.tid = t.tid AND r.nid = %d ORDER BY weight, name", $nid);
+ $result = db_query('SELECT t.* FROM {term_data} t, {term_node} r WHERE r.tid = t.tid AND r.nid = %d ORDER BY weight, name', $nid);
$terms[$nid] = array();
while ($term = db_fetch_object($result)) {
$terms[$nid][$term->$key] = $term;
@@ -386,28 +407,34 @@ function taxonomy_node_get_terms($nid, $key = "tid") {
return $terms[$nid];
}
-// save terms of a node
+/**
+ * Save term associations for a given node.
+ */
function taxonomy_node_save($nid, $terms) {
taxonomy_node_delete($nid);
if ($terms) {
foreach ($terms as $term) {
if ($term) {
- db_query("INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)", $nid, $term);
+ db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $term);
}
}
}
}
-// clean up terms
+/**
+ * Remove associations of a node to its terms.
+ */
function taxonomy_node_delete($nid) {
- db_query("DELETE FROM {term_node} WHERE nid = %d", $nid);
+ db_query('DELETE FROM {term_node} WHERE nid = %d', $nid);
}
-// relations: return array of related terms
-function taxonomy_get_related($tid, $key = "tid") {
+/**
+ * Find all term objects related to a given term ID.
+ */
+function taxonomy_get_related($tid, $key = 'tid') {
if ($tid) {
- $result = db_query("SELECT t.*, tid1, tid2 FROM {term_relation} , {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name", $tid, $tid, $tid);
+ $result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid);
$related = array();
while ($term = db_fetch_object($result)) {
$related[$term->$key] = $term;
@@ -419,10 +446,12 @@ function taxonomy_get_related($tid, $key = "tid") {
}
}
-// hierarchy: get parent terms
-function taxonomy_get_parents($tid, $key = "tid") {
+/**
+ * Find all parents of a given term ID.
+ */
+function taxonomy_get_parents($tid, $key = 'tid') {
if ($tid) {
- $result = db_query("SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE h.parent = t.tid AND h.tid = %d ORDER BY weight, name", $tid);
+ $result = db_query('SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE h.parent = t.tid AND h.tid = %d ORDER BY weight, name', $tid);
$parents = array();
while ($parent = db_fetch_object($result)) {
$parents[$parent->$key] = $parent;
@@ -434,8 +463,10 @@ function taxonomy_get_parents($tid, $key = "tid") {
}
}
-// Gets all parents, parents of parents, etc.
-function taxonomy_get_parents_all($tid, $key = "tid") {
+/**
+ * Find all ancestors of a given term ID.
+ */
+function taxonomy_get_parents_all($tid) {
$parents = array();
if ($tid) {
$parents[] = taxonomy_get_term($tid);
@@ -448,13 +479,15 @@ function taxonomy_get_parents_all($tid, $key = "tid") {
return $parents;
}
-// hierarchy: get children
-function taxonomy_get_children($tid, $vid = 0, $key = "tid") {
+/**
+ * Find all children of a term ID.
+ */
+function taxonomy_get_children($tid, $vid = 0, $key = 'tid') {
if ($vid) {
- $result = db_query("SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE t.vid = %d AND h.tid = t.tid AND h.parent = %d ORDER BY weight, name", $vid, $tid);
+ $result = db_query('SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE t.vid = %d AND h.tid = t.tid AND h.parent = %d ORDER BY weight, name', $vid, $tid);
}
else {
- $result = db_query("SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE h.tid = t.tid AND parent = %d ORDER BY weight", $tid);
+ $result = db_query('SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE h.tid = t.tid AND parent = %d ORDER BY weight', $tid);
}
$children = array();
while ($term = db_fetch_object($result)) {
@@ -463,34 +496,52 @@ function taxonomy_get_children($tid, $vid = 0, $key = "tid") {
return $children;
}
-// hierarchy: get whole family, with tid, parent and depth; useful to show
-function taxonomy_get_tree($vocabulary_id, $parent = 0, $depth = -1, $max_depth = NULL) {
+/**
+ * Create a hierarchical representation of a vocabulary.
+ *
+ * @param $vid
+ * Which vocabulary to generate the tree for.
+ *
+ * @param $parent
+ * The term ID under which to generate the tree. If 0, generate the tree
+ * for the entire vocabulary.
+ *
+ * @param $depth
+ * Internal use only.
+ *
+ * @return
+ * An array of all term objects in the tree. Each term object is extended
+ * to have "depth" and "parents" attributes in addition to its normal ones.
+ */
+function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
static $children, $parents, $terms;
$depth++;
- // we cache trees, so it's not cpu-intensive to call get_tree on a term and its children too
- if (!isset($children[$vocabulary_id])) {
- $children[$vocabulary_id] = array();
+ // We cache trees, so it's not CPU-intensive to call get_tree() on a term
+ // and its children, too.
+ if (!isset($children[$vid])) {
+ $children[$vid] = array();
- $result = db_query("SELECT t.*, parent FROM {term_data} t, {term_hierarchy} h WHERE t.tid = h.tid AND t.vid = %d ORDER BY weight, name", $vocabulary_id);
+ $result = db_query('SELECT t.*, parent FROM {term_data} t, {term_hierarchy} h WHERE t.tid = h.tid AND t.vid = %d ORDER BY weight, name', $vid);
while ($term = db_fetch_object($result)) {
- $children[$vocabulary_id][$term->parent][] = $term->tid;
- $parents[$vocabulary_id][$term->tid][] = $term->parent;
- $terms[$vocabulary_id][$term->tid] = $term;
+ $children[$vid][$term->parent][] = $term->tid;
+ $parents[$vid][$term->tid][] = $term->parent;
+ $terms[$vid][$term->tid] = $term;
}
}
- $max_depth = ($max_depth == '') ? count($children[$vocabulary_id]) : $max_depth;
- if ($children[$vocabulary_id][$parent]) {
- foreach ($children[$vocabulary_id][$parent] as $child) {
+ $max_depth = ($max_depth == '') ? count($children[$vid]) : $max_depth;
+ if ($children[$vid][$parent]) {
+ foreach ($children[$vid][$parent] as $child) {
if ($max_depth > $depth) {
- $terms[$vocabulary_id][$child]->depth = $depth;
- unset($terms[$vocabulary_id][$child]->parent); // this is not useful as it would show one parent only
- $terms[$vocabulary_id][$child]->parents = $parents[$vocabulary_id][$child];
- $tree[] = $terms[$vocabulary_id][$child];
+ $terms[$vid][$child]->depth = $depth;
+ // The "parent" attribute is not useful, as it would show one parent only.
+ unset($terms[$vid][$child]->parent);
+ $terms[$vid][$child]->parents = $parents[$vid][$child];
+ $tree[] = $terms[$vid][$child];
- $tree = array_merge($tree, taxonomy_get_tree($vocabulary_id, $child, $depth, $max_depth));
+ $tree = array_merge($tree, taxonomy_get_tree($vid, $child, $depth, $max_depth));
}
}
}
@@ -498,12 +549,14 @@ function taxonomy_get_tree($vocabulary_id, $parent = 0, $depth = -1, $max_depth
return $tree ? $tree : array();
}
-// synonyms: return array of synonyms
+/**
+ * Return an array of synonyms of the given term ID.
+ */
function taxonomy_get_synonyms($tid) {
if ($tid) {
- $result = db_query("SELECT name FROM {term_synonym} WHERE tid = %d", $tid);
+ $result = db_query('SELECT name FROM {term_synonym} WHERE tid = %d', $tid);
while ($synonym = db_fetch_array($result)) {
- $synonyms[] = $synonym["name"];
+ $synonyms[] = $synonym['name'];
}
return $synonyms ? $synonyms : array();
}
@@ -512,19 +565,23 @@ function taxonomy_get_synonyms($tid) {
}
}
-// synonyms: return original term
-function taxonomy_get_synonym_root($term) {
- return db_fetch_object(db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = '%s'", $term));
+/**
+ * Return the term object that has the given string as a synonym.
+ */
+function taxonomy_get_synonym_root($synonym) {
+ return db_fetch_object(db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = '%s'", $synonym));
}
-// given a term id, count number of published nodes in it
+/**
+ * Given a term id, count the number of published nodes in it.
+ */
function taxonomy_term_count_nodes($tid, $type = 0) {
static $count;
if (!isset($count[$type])) {
// $type == 0 always evaluates true is $type is a string
if (is_numeric($type)) {
- $result = db_query("SELECT t.tid, COUNT(*) AS c FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 GROUP BY t.tid");
+ $result = db_query('SELECT t.tid, COUNT(*) AS c FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 GROUP BY t.tid');
}
else {
$result = db_query("SELECT t.tid, COUNT(*) AS c FROM {term_node} t, {node} n WHERE t.nid = n.nid AND n.status = 1 AND n.type = '%s' GROUP BY t.tid", $type);
@@ -540,12 +597,14 @@ function taxonomy_term_count_nodes($tid, $type = 0) {
return $count[$type][$tid] + $children_count;
}
-// helper for above function
+/**
+ * Helper for taxonomy_term_count_nodes().
+ */
function _taxonomy_term_children($tid) {
static $children;
if (!isset($children)) {
- $result = db_query("SELECT tid, parent FROM {term_hierarchy} ");
+ $result = db_query('SELECT tid, parent FROM {term_hierarchy}');
while ($term = db_fetch_object($result)) {
$children[$term->parent][] = $term->tid;
}
@@ -554,14 +613,18 @@ function _taxonomy_term_children($tid) {
}
/**
- * Try to map a string to existing vocabularies. Provide case insensitive and
- * trimmed map so as to maximize likelihood of successful mapping.
+ * Try to map a string to an existing vocabulary.
+ *
+ * Provides a case-insensitive and trimmed mapping, to maximize the
+ * likelihood of a successful match.
+ *
+ * @param name
+ * Name of the vocabulary to search for.
*
- * @param $name Name of the vocabulary to search
- * @return array of matching vocabularies, as objects
+ * @return
+ * An array of matching vocabulary objects.
*/
function taxonomy_get_vocabulary_by_name($name) {
- // LOWER is ANSI SQL-92
$db_result = db_query("SELECT * FROM {vocabulary} WHERE LOWER('%s') LIKE LOWER(name)", trim($name));
$result = array();
while ($vocabulary = db_fetch_object($db_result)) {
@@ -572,14 +635,18 @@ function taxonomy_get_vocabulary_by_name($name) {
}
/**
- * Try to map a string to existing terms Provide case insensitive and trimmed
- * map so as to maximize likelihood of successful mapping.
+ * Try to map a string to an existing term, as for glossary use.
*
- * @param name Name of the term to search
- * @return rray of matching terms, as objects
+ * Provides a case-insensitive and trimmed mapping, to maximize the
+ * likelihood of a successful match.
+ *
+ * @param name
+ * Name of the term to search for.
+ *
+ * @return
+ * An array of matching term objects.
*/
function taxonomy_get_term_by_name($name) {
- // LOWER is ANSI SQL-92
$db_result = db_query("SELECT * FROM {term_data} WHERE LOWER('%s') LIKE LOWER(name)", trim($name));
$result = array();
while ($term = db_fetch_object($db_result)) {
@@ -589,20 +656,21 @@ function taxonomy_get_term_by_name($name) {
return $result;
}
+/**
+ * Return the vocabulary object matching a vocabulary ID.
+ */
function taxonomy_get_vocabulary($vid) {
- // simple cache using a static var?
- return db_fetch_object(db_query("SELECT * FROM {vocabulary} WHERE vid = %d", $vid));
+ return db_fetch_object(db_query('SELECT * FROM {vocabulary} WHERE vid = %d', $vid));
}
+/**
+ * Return the term object matching a term ID.
+ */
function taxonomy_get_term($tid) {
// simple cache using a static var?
- return db_fetch_object(db_query("SELECT * FROM {term_data} WHERE tid = %d", $tid));
+ return db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
}
-/*
-** service functions
-*/
-
function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) {
$tree = taxonomy_get_tree($vocabulary_id);
@@ -615,13 +683,13 @@ function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $descripti
}
if ($blank) {
- $options[] = array("tid" => 0, "name" => $blank);
+ $options[] = array('tid' => 0, 'name' => $blank);
}
if ($tree) {
foreach ($tree as $term) {
if (!in_array($term->tid, $exclude)) {
- $options[] = array("tid" => $term->tid, "name" => _taxonomy_depth($term->depth, '-').$term->name);
+ $options[] = array('tid' => $term->tid, 'name' => _taxonomy_depth($term->depth, '-').$term->name);
}
}
if (!$blank && !$value) {
@@ -632,12 +700,12 @@ function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $descripti
if (count($options) > 0) {
foreach ($options as $option) {
- $select .= "<option value=\"". $option["tid"] ."\"". (is_array($value) ? (in_array($option["tid"], $value) ? " selected=\"selected\"" : "") : ($option["tid"] == $value ? " selected=\"selected\"" : "")) .">". check_form($option["name"]) ."</option>";
+ $select .= '<option value="'. $option['tid'] .'"'. (is_array($value) ? (in_array($option['tid'], $value) ? ' selected="selected"' : '') : ($option['tid'] == $value ? ' selected="selected"' : '')) .'>'. check_form($option['name']) .'</option>';
}
$size = min(12, count($options));
- return form_item($title, "<select name=\"edit[$name][]\"". ($multiple ? " multiple=\"multiple\" size=\"$size\"" : "") . ($extra ? " $extra" : "") .">$select</select>", $description);
+ return form_item($title, "<select name=\"edit[$name][]\"". ($multiple ? " multiple=\"multiple\" size=\"$size\"" : '') . ($extra ? " $extra" : '') .">$select</select>", $description);
}
}
@@ -652,46 +720,57 @@ function _prepare_update($data) {
foreach ($data as $key => $value) {
$q[] = "$key = '". check_query($value) ."'";
}
- $result = implode(", ", $q);
+ $result = implode(', ', $q);
return $result;
}
function _prepare_insert($data, $stage) {
if ($stage == 1) {
- $result = implode(", ", array_keys($data));
+ $result = implode(', ', array_keys($data));
}
else {
foreach (array_values($data) as $value) {
$q[] = "'". check_query($value) ."'";
}
- $result = implode(", ", $q);
+ $result = implode(', ', $q);
}
return "($result)";
}
-/*
-** Accepts taxonomy conditions and returns a resource identifier. If
-** you intend to use the nodes without a pager (eg. in a XML feed),
-** then set $pager to false.
-*/
-function taxonomy_select_nodes($taxonomy, $pager = 1) {
- global $user;
-
+/**
+ * Finds all nodes that match selected taxonomy conditions.
+ *
+ * @param $taxonomy
+ * An object containing the conditions to match. The attributes of this
+ * object are:
+ * - "tids": An array of term IDs to match.
+ * - "str_tids": A comma-separated list of the same IDs.
+ * - "operator": How to interpret multiple IDs in the array. Can be
+ * "or" or "and".
+ *
+ * @param $pager
+ * Whether the nodes are to be used with a pager (the case on most Drupal
+ * pages) or not (in an XML feed, for example).
+ *
+ * @return
+ * A resource identifier pointing to the query results.
+ */
+function taxonomy_select_nodes($taxonomy, $pager = TRUE) {
if ($taxonomy->str_tids) {
- if ($taxonomy->operator == "or") {
- $sql = "SELECT DISTINCT(n.nid), n.title, n.type, n.created, n.changed, n.uid, n.static, n.created, u.name FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = '1' ORDER BY static DESC, created DESC";
- $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = '1'";
+ if ($taxonomy->operator == 'or') {
+ $sql = "SELECT DISTINCT(n.nid), n.title, n.type, n.created, n.changed, n.uid, n.static, n.created, u.name FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = 1 ORDER BY static DESC, created DESC";
+ $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = 1";
}
else {
- $sql = "SELECT n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = '1' GROUP BY n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name HAVING COUNT(n.nid) = ". count($taxonomy->tids) ." ORDER BY static DESC, created DESC";
+ $sql = "SELECT n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = 1 GROUP BY n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name HAVING COUNT(n.nid) = ". count($taxonomy->tids) ." ORDER BY static DESC, created DESC";
// Special trick as we could not find anything better:
- $count = db_num_rows(db_query("SELECT n.nid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = '1' GROUP BY n.nid HAVING COUNT(n.nid) = ". count($taxonomy->tids)));
+ $count = db_num_rows(db_query("SELECT n.nid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid WHERE r.tid IN ($taxonomy->str_tids) AND n.status = 1 GROUP BY n.nid HAVING COUNT(n.nid) = ". count($taxonomy->tids)));
$sql_count = "SELECT $count";
}
if ($pager) {
- $result = pager_query($sql, variable_get("default_nodes_main", 10) , 0, $sql_count);
+ $result = pager_query($sql, variable_get('default_nodes_main', 10) , 0, $sql_count);
}
else {
$result = db_query_range($sql, 0, 15);
@@ -701,29 +780,31 @@ function taxonomy_select_nodes($taxonomy, $pager = 1) {
return $result;
}
-/*
-** Accepts the result of a db_query() and formats each node along
-** with a pager.
+/**
+ * Accepts the result of a pager_query() call, such as that performed by
+ * taxonomy_select_nodes(), and formats each node along with a pager.
*/
function taxonomy_render_nodes($result) {
while ($node = db_fetch_object($result)) {
- $output .= node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1);
+ $output .= node_view(node_load(array('nid' => $node->nid, 'type' => $node->type)), 1);
}
- $output .= theme("pager", NULL, variable_get("default_nodes_main", 10), 0);
+ $output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0);
return $output;
}
+/**
+ * Implementation of hook_nodeapi().
+ */
function taxonomy_nodeapi($node, $op, $arg = 0) {
-
switch ($op) {
- case "insert":
+ case 'insert':
taxonomy_node_save($node->nid, $node->taxonomy);
break;
- case "update":
+ case 'update':
taxonomy_node_save($node->nid, $node->taxonomy);
break;
- case "delete":
+ case 'delete':
taxonomy_node_delete($node->nid);
break;
}
@@ -733,11 +814,11 @@ function taxonomy_page() {
$taxonomy->operator = arg(2);
$taxonomy->str_tids = check_query(arg(3));
- $taxonomy->tids = explode(",", $taxonomy->str_tids);
+ $taxonomy->tids = explode(',', $taxonomy->str_tids);
- if (ereg("^([0-9]+,){0,}[0-9]+$", $taxonomy->str_tids)) {
+ if (ereg('^([0-9]+,){0,}[0-9]+$', $taxonomy->str_tids)) {
switch (arg(1)) {
- case "feed":
+ case 'feed':
taxonomy_feed($taxonomy);
break;
default:
@@ -751,17 +832,18 @@ function taxonomy_page() {
// Build breadcrumb based on first hierarchy of first term:
$current->tid = $taxonomy->tids[0];
+ $breadcrumbs = array(array('path' => $_GET['q']));
while ($parents = taxonomy_get_parents($current->tid)) {
$current = array_shift($parents);
- $breadcrumbs[] = l($current->name, "taxonomy/view/or/$current->tid");
+ $breadcrumbs[] = array('path' => 'taxonomy/view/or/'. $current->tid, 'title' => $current->name);
}
- $breadcrumbs[] = l(t('Home'), '');
$breadcrumbs = array_reverse($breadcrumbs);
+ menu_set_location($breadcrumbs);
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. implode(' : ', $names) .'" href="'. url("taxonomy/feed/or/$taxonomy->str_tids") .'" />');
$output = taxonomy_render_nodes(taxonomy_select_nodes($taxonomy));
- print theme("page", $output, implode(', ', $names), $breadcrumbs);
+ print theme('page', $output, implode(', ', $names));
break;
}
}
@@ -770,62 +852,61 @@ function taxonomy_page() {
}
}
-/*
-** admin
-*/
-
+/**
+ * Menu callback; dispatches to the proper taxonomy administration function.
+ */
function taxonomy_admin() {
- $op = $_POST["op"];
- $edit = $_POST["edit"];
+ $op = $_POST['op'];
+ $edit = $_POST['edit'];
if (empty($op)) {
$op = arg(2);
}
switch ($op) {
- case "add":
- if (arg(3) == "vocabulary") {
+ case 'add':
+ if (arg(3) == 'vocabulary') {
$output .= taxonomy_form_vocabulary();
}
- else if (arg(3) == "term") {
+ else if (arg(3) == 'term') {
$output .= taxonomy_form_term();
}
break;
- case "edit":
- if (arg(3) == "vocabulary") {
+ case 'edit':
+ if (arg(3) == 'vocabulary') {
$output .= taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(4))));
}
- else if (arg(3) == "term") {
+ else if (arg(3) == 'term') {
$output .= taxonomy_form_term(object2array(taxonomy_get_term(arg(4))));
}
break;
- case "preview":
+ case 'preview':
$output .= taxonomy_form(arg(4));
break;
- case "help":
+ case 'help':
$output .= taxonomy_help();
break;
- case t("Delete"):
- if (!$edit["confirm"]) {
- if (arg(3) == "vocabulary") {
- $output .= _taxonomy_confirm_del_vocabulary($edit["vid"]);
+ case t('Delete'):
+ if (!$edit['confirm']) {
+ if (arg(3) == 'vocabulary') {
+ $output .= _taxonomy_confirm_del_vocabulary($edit['vid']);
}
else {
- $output .= _taxonomy_confirm_del_term($edit["tid"]);
+ $output .= _taxonomy_confirm_del_term($edit['tid']);
}
break;
}
else {
- $edit["name"] = 0;
+ $edit['name'] = 0;
// fall through:
}
- case t("Submit"):
- if (arg(3) == "vocabulary") {
+ case t('Submit'):
+ if (arg(3) == 'vocabulary') {
taxonomy_save_vocabulary($edit);
}
else {
taxonomy_save_term($edit);
- if (!$edit["tid"]) {
+ if (!$edit['tid']) {
// if INSERT show form again
$output .= taxonomy_form_term();
break;
@@ -837,24 +918,22 @@ function taxonomy_admin() {
$output .= taxonomy_overview();
}
- print theme("page", $output);
+ print theme('page', $output);
}
-function taxonomy_help($section = "admin/help#taxonomy") {
- $output = "";
-
+/**
+ * Implementation of hook_help().
+ */
+function taxonomy_help($section = 'admin/help#taxonomy') {
switch ($section) {
- case 'admin/system/modules#description':
- $output = t("Enables the organization of content into categories.");
- break;
+ case 'admin/modules#description':
+ return t('Enables the organization of content into categories.');
case 'admin/taxonomy':
- $output = t("The taxonomy module allows you to classify content into categories and subcategories; it allows multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically). To delete a term choose \"edit term\". To delete a vocabulary, and all its terms, choose \"edit vocabulary\".");
- break;
+ return t('The taxonomy module allows you to classify content into categories and subcategories; it allows multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically). To delete a term choose "edit term". To delete a vocabulary, and all its terms, choose "edit vocabulary".');
case 'admin/taxonomy/add/vocabulary':
- $output = t("When you create a controlled vocabulary you are creating a set of terms to use for describing content (known as descriptors in indexing lingo). Drupal allows you to describe each node type (blog, story, etc.) using one or many of these terms. For simple implementations, you might create a set of categories without subcategories, similar to Slashdot.org's or Kuro5hin.org's sections. For more complex implementations, you might create a hierarchical list of categories.");
- break;
+ return t("When you create a controlled vocabulary you are creating a set of terms to use for describing content (known as descriptors in indexing lingo). Drupal allows you to describe each node type (blog, story, etc.) using one or many of these terms. For simple implementations, you might create a set of categories without subcategories, similar to Slashdot.org's or Kuro5hin.org's sections. For more complex implementations, you might create a hierarchical list of categories.");
case 'admin/help#taxonomy':
- $output .= t("
+ return t("
<h3>Background</h3>
<p>Taxonomy is the study of classification. Drupal's taxonomy module allows you to define categories which are used to classify content. The module supports hierarchical classification and association between terms, allowing for truly flexible information retrieval and classification. For more details about <a href=\"%classification-types\">classification types</a> and insight into the development of the <em>taxonomy.module</em>, see this <a href=\"%drupal-dis\">drupal.org discussion</a>.</p>
<h3>An example taxonomy: food</h3>
@@ -886,10 +965,7 @@ function taxonomy_help($section = "admin/help#taxonomy") {
<h3><a id=\"taxonomy-url\"></a>Displaying nodes organized by term(s)</h3>
<p>In order to view the nodes associated with a term or a collection of terms, you should browse to a properly formed Taxonomy URL. For example, <a href=\"%taxo-example\">taxonomy/page/or/1,2</a>. Taxonomy URLs always contain one or more term IDs (tid) at the end of the URL (a.k.a the <em>querystring</em>). You may learn the term ID for a given term by hovering over that term in the <a href=\"%taxo-overview\">taxonomy overview</a> page and noting the number at the end or the URL. To build a Taxonomy URL start with \"taxonomy/page\". Now add the querystring parameter, either <em>or</em>, which chooses nodes tagged with <strong>any</strong> of the given term IDs, or <em>and</em>, which chooses nodes tagged with <strong>all</strong> of the given Term IDs. Thus <em>or</em> is less specific than <em>and</em>. Finally add a comma seperated list of term IDs.</p>
<h3>RSS feeds</h3>
- <p>Every term, or collection of terms, provides an <a href=\"%userland-rss\">RSS</a> feed to which interested users may subscribe. The URL format for a sample RSS feed is <a href=\"%sample-rss\">node/feed/or/1,2</a>. Built like a Taxonomy URL, <a href=\"%taxo-help\">see above</a> it starts with \"node/feed\", then has the querystring parameter, and finally the Term IDs.</p>", array("%classification-types" => "http://www.eleganthack.com/archives/002165.html#002165", "%drupal-dis" => "http://www.drupal.org/node/view/55", "%slashdot" => "http://www.slashdot.com/", "%taxo-example" => url("taxonomy/page/or/1,2"), "%taxo-overview" => url("admin/taxonomy"), "%userland-rss" => "http://backend.userland.com/stories/rss", "%sample-rss" => url("node/feed/or/1,2"), "%taxo-help" => url("admin/taxonomy/help", NULL, "taxonomy-url")));
- break;
+ <p>Every term, or collection of terms, provides an <a href=\"%userland-rss\">RSS</a> feed to which interested users may subscribe. The URL format for a sample RSS feed is <a href=\"%sample-rss\">node/feed/or/1,2</a>. Built like a Taxonomy URL, <a href=\"%taxo-help\">see above</a> it starts with \"node/feed\", then has the querystring parameter, and finally the Term IDs.</p>", array('%classification-types' => 'http://www.eleganthack.com/archives/002165.html#002165', '%drupal-dis' => 'http://www.drupal.org/node/55', '%slashdot' => 'http://www.slashdot.com/', '%taxo-example' => url('taxonomy/page/or/1,2'), '%taxo-overview' => url('admin/taxonomy'), '%userland-rss' => 'http://backend.userland.com/stories/rss', '%sample-rss' => url('node/feed/or/1,2'), '%taxo-help' => url('admin/taxonomy/help', NULL, 'taxonomy-url')));
}
-
- return $output;
}
?>
diff --git a/modules/throttle.module b/modules/throttle.module
index 1dd8f0ed9..6f6c2333f 100644
--- a/modules/throttle.module
+++ b/modules/throttle.module
@@ -59,10 +59,10 @@ function throttle_perm() {
*/
function throttle_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Allows configuration of congestion control auto-throttle mechanism.');
- case 'admin/system/modules/throttle':
- return t('If your site gets linked to by a popular website, or otherwise comes under a "Denial of Service" (DoS) attack, your webserver might become overwhelmed. This module provides a mechanism for automatically detecting a surge in incoming traffic. This mechanism is utilized by other Drupal models to automatically optimize their performance by temporarily disabling CPU-intensive functionality. To use the auto-throttle, the access log must be enabled. It is advised that you carefully read the explainations below and then properly tune this module based on your site\'s requirements and your webserver\'s capabilities.', array('%access' => url('admin/system/modules/statistics')));
+ case 'admin/modules/throttle':
+ return t('If your site gets linked to by a popular website, or otherwise comes under a "Denial of Service" (DoS) attack, your webserver might become overwhelmed. This module provides a mechanism for automatically detecting a surge in incoming traffic. This mechanism is utilized by other Drupal models to automatically optimize their performance by temporarily disabling CPU-intensive functionality. To use the auto-throttle, the access log must be enabled. It is advised that you carefully read the explainations below and then properly tune this module based on your site\'s requirements and your webserver\'s capabilities.', array('%access' => url('admin/modules/statistics')));
case 'admin/help#throttle':
return t("
<h3>Introduction</h3>
@@ -96,7 +96,7 @@ function throttle_help($section) {
else {
// throttle limit not reached, execute normally
}</pre>
- </p>", array('%statistics-module' => url('admin/statistics'), '%throttle-block' => url('admin/user/permission'), '%modules-enable' => url('admin/system/modules'), '%throttle-config' => url('admin/system/modules/throttle'), '%statistics-config' => url('admin/system/modules/statistics'), '%throttle-access' => url('admin/user/permission'), '%throttle-block-enable' => url('admin/block'), '%permissions' => url('admin/user/permission')));
+ </p>", array('%statistics-module' => url('admin/statistics'), '%throttle-block' => url('admin/user/permission'), '%modules-enable' => url('admin/modules'), '%throttle-config' => url('admin/modules/throttle'), '%statistics-config' => url('admin/modules/statistics'), '%throttle-access' => url('admin/user/permission'), '%throttle-block-enable' => url('admin/block'), '%permissions' => url('admin/user/permission')));
}
}
diff --git a/modules/throttle/throttle.module b/modules/throttle/throttle.module
index 1dd8f0ed9..6f6c2333f 100644
--- a/modules/throttle/throttle.module
+++ b/modules/throttle/throttle.module
@@ -59,10 +59,10 @@ function throttle_perm() {
*/
function throttle_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Allows configuration of congestion control auto-throttle mechanism.');
- case 'admin/system/modules/throttle':
- return t('If your site gets linked to by a popular website, or otherwise comes under a "Denial of Service" (DoS) attack, your webserver might become overwhelmed. This module provides a mechanism for automatically detecting a surge in incoming traffic. This mechanism is utilized by other Drupal models to automatically optimize their performance by temporarily disabling CPU-intensive functionality. To use the auto-throttle, the access log must be enabled. It is advised that you carefully read the explainations below and then properly tune this module based on your site\'s requirements and your webserver\'s capabilities.', array('%access' => url('admin/system/modules/statistics')));
+ case 'admin/modules/throttle':
+ return t('If your site gets linked to by a popular website, or otherwise comes under a "Denial of Service" (DoS) attack, your webserver might become overwhelmed. This module provides a mechanism for automatically detecting a surge in incoming traffic. This mechanism is utilized by other Drupal models to automatically optimize their performance by temporarily disabling CPU-intensive functionality. To use the auto-throttle, the access log must be enabled. It is advised that you carefully read the explainations below and then properly tune this module based on your site\'s requirements and your webserver\'s capabilities.', array('%access' => url('admin/modules/statistics')));
case 'admin/help#throttle':
return t("
<h3>Introduction</h3>
@@ -96,7 +96,7 @@ function throttle_help($section) {
else {
// throttle limit not reached, execute normally
}</pre>
- </p>", array('%statistics-module' => url('admin/statistics'), '%throttle-block' => url('admin/user/permission'), '%modules-enable' => url('admin/system/modules'), '%throttle-config' => url('admin/system/modules/throttle'), '%statistics-config' => url('admin/system/modules/statistics'), '%throttle-access' => url('admin/user/permission'), '%throttle-block-enable' => url('admin/block'), '%permissions' => url('admin/user/permission')));
+ </p>", array('%statistics-module' => url('admin/statistics'), '%throttle-block' => url('admin/user/permission'), '%modules-enable' => url('admin/modules'), '%throttle-config' => url('admin/modules/throttle'), '%statistics-config' => url('admin/modules/statistics'), '%throttle-access' => url('admin/user/permission'), '%throttle-block-enable' => url('admin/block'), '%permissions' => url('admin/user/permission')));
}
}
diff --git a/modules/title.module b/modules/title.module
index 78b7177c4..907dd007e 100644
--- a/modules/title.module
+++ b/modules/title.module
@@ -6,7 +6,7 @@
*/
function title_help($section) {
switch ($section) {
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables users to link to stories, articles or similar content by title.');
case 'filter#short-tip' :
return t('<a href=\"%title-help\">Link to content</a> on this site using <em>[title|text]</em>.', array("%title-help" => url('filter/tips', NULL, 'filter-title')));
@@ -16,12 +16,15 @@ function title_help($section) {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function title_link($type) {
- if ($type == 'system') {
- menu('title', t('search'), user_access('access content') ? 'title_page' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- }
+function title_menu() {
+ $items = array();
+ $items[] = array('path' => 'title', 'title' => t('search'),
+ 'callback' => 'title_page',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK);
+ return $items;
}
/**
@@ -50,7 +53,7 @@ function title_page($query) {
$header = array(t('Type'), t('Title'), t('Author'));
while ($node = db_fetch_object($result)) {
$type = ucfirst(module_invoke($node->type, 'node', 'name'));
- $title = l($node->title, "node/view/$node->nid");
+ $title = l($node->title, "node/$node->nid");
$author = format_name($node);
$rows[] = array(array('data' => $type, 'class' => 'type'), array('data' => $title, 'class' => 'content'), array('data' => $author, 'class' => 'author'));
}
diff --git a/modules/tracker.module b/modules/tracker.module
index b88984c87..33665f552 100644
--- a/modules/tracker.module
+++ b/modules/tracker.module
@@ -8,18 +8,21 @@ function tracker_help($section) {
switch ($section) {
case 'admin/help#tracker':
return t('<p>The tracker module is a handy module for displaying the most recent posts. By following the <em>recent posts</em> link in the user block, a user may quickly review all recent postings.</p>');
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables tracking of recent posts for users.');
}
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function tracker_link($type) {
- if ($type == 'system') {
- menu('tracker', t('recent posts'), user_access('access content') ? 'tracker_page' : MENU_DENIED, 1);
- }
+function tracker_menu() {
+ $items = array();
+ $items[] = array('path' => 'tracker', 'title' => t('recent posts'),
+ 'callback' => 'tracker_page',
+ 'access' => user_access('access content'),
+ 'weight' => 1);
+ return $items;
}
/**
@@ -54,7 +57,7 @@ function tracker_page($uid = 0) {
if ($new = comment_num_new($node->nid)) {
$comments .= '<br />';
- $comments .= l(t('%num new', array('%num' => $new)), "node/view/$node->nid", NULL, NULL, 'new');
+ $comments .= l(t('%num new', array('%num' => $new)), "node/$node->nid", NULL, NULL, 'new');
}
}
else {
@@ -63,7 +66,7 @@ function tracker_page($uid = 0) {
$rows[] = array(
ucfirst(node_invoke($node->type, 'node_name')),
- l($node->title, "node/view/$node->nid") .' '. (node_is_new($node->nid, $node->changed) ? theme('mark') : ''),
+ l($node->title, "node/$node->nid") .' '. (node_is_new($node->nid, $node->changed) ? theme('mark') : ''),
format_name($node),
array('class' => 'replies', 'data' => $comments),
format_interval(time() - $node->last_post) .' '. t('ago')
diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module
index b88984c87..33665f552 100644
--- a/modules/tracker/tracker.module
+++ b/modules/tracker/tracker.module
@@ -8,18 +8,21 @@ function tracker_help($section) {
switch ($section) {
case 'admin/help#tracker':
return t('<p>The tracker module is a handy module for displaying the most recent posts. By following the <em>recent posts</em> link in the user block, a user may quickly review all recent postings.</p>');
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables tracking of recent posts for users.');
}
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function tracker_link($type) {
- if ($type == 'system') {
- menu('tracker', t('recent posts'), user_access('access content') ? 'tracker_page' : MENU_DENIED, 1);
- }
+function tracker_menu() {
+ $items = array();
+ $items[] = array('path' => 'tracker', 'title' => t('recent posts'),
+ 'callback' => 'tracker_page',
+ 'access' => user_access('access content'),
+ 'weight' => 1);
+ return $items;
}
/**
@@ -54,7 +57,7 @@ function tracker_page($uid = 0) {
if ($new = comment_num_new($node->nid)) {
$comments .= '<br />';
- $comments .= l(t('%num new', array('%num' => $new)), "node/view/$node->nid", NULL, NULL, 'new');
+ $comments .= l(t('%num new', array('%num' => $new)), "node/$node->nid", NULL, NULL, 'new');
}
}
else {
@@ -63,7 +66,7 @@ function tracker_page($uid = 0) {
$rows[] = array(
ucfirst(node_invoke($node->type, 'node_name')),
- l($node->title, "node/view/$node->nid") .' '. (node_is_new($node->nid, $node->changed) ? theme('mark') : ''),
+ l($node->title, "node/$node->nid") .' '. (node_is_new($node->nid, $node->changed) ? theme('mark') : ''),
format_name($node),
array('class' => 'replies', 'data' => $comments),
format_interval(time() - $node->last_post) .' '. t('ago')
diff --git a/modules/user.module b/modules/user.module
index ba85e5a32..ea544987d 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -410,7 +410,7 @@ function user_search($keys) {
$result = db_query_range("SELECT * FROM {users} WHERE LOWER(name) LIKE '%%%s%%'", strtolower($keys), 0, 20);
while ($account = db_fetch_object($result)) {
- $find[] = array('title' => $account->name, 'link' => (strstr(request_uri(), 'admin') ? url("admin/user/edit/$account->uid") : url("user/view/$account->uid")), 'user' => $account->name);
+ $find[] = array('title' => $account->name, 'link' => url("user/$account->uid/view"), 'user' => $account->name);
}
return array(t('Matching users'), $find);
}
@@ -484,7 +484,7 @@ function user_block($op = 'list', $delta = 0) {
}
return $block;
case 1:
- if ($menu = menu_tree()) {
+ if ($menu = theme('menu_tree')) {
$block['subject'] = $user->uid ? $user->name : t('Navigation');
$block['content'] = '<div class="menu">'. $menu .'</div>';
}
@@ -573,11 +573,6 @@ function theme_user_profile($account, $fields) {
foreach ($fields as $category => $value) {
$output .= "<h2>$category</h2>$value";
}
-
- if (user_access('administer users')) {
- $output .= form_item(t('Administration'), l(t('edit account'), "admin/user/edit/$account->uid"));
- }
-
$output .= "</div>\n";
return $output;
@@ -588,37 +583,82 @@ function theme_user_list($items, $title = NULL) {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function user_link($type) {
+function user_menu() {
global $user;
- if ($type == 'system') {
- if ($user->uid) {
- menu('user', t('my account'), 'user_page', 0);
- menu('user/edit', t('edit account'), 'user_page', 0);
- menu('logout', t('log out'), 'user_logout', 10);
- }
- else {
- menu('user', t('user'), 'user_page', 0, MENU_HIDE);
- menu('user/edit', t('edit account'), MENU_DENIED);
- menu('logout', t('log out'), MENU_DENIED);
- }
+ $items = array();
- $access = user_access('administer users');
- menu('admin/user', t('accounts'), $access ? 'user_admin' : MENU_DENIED, 2);
- menu('admin/user/create', t('new user'), $access ? 'user_admin' : MENU_DENIED, 1);
- menu('admin/user/access', t('access rules'), $access ? 'user_admin' : MENU_DENIED, 3);
- menu('admin/user/access/mail', t('e-mail rules'), $access ? 'user_admin' : MENU_DENIED);
- menu('admin/user/access/user', t('name rules'), $access ? 'user_admin' : MENU_DENIED);
- menu('admin/user/role', t('roles'), $access ? 'user_admin' : MENU_DENIED, 4);
- menu('admin/user/permission', t('permissions'), $access ? 'user_admin' : MENU_DENIED, 5);
- menu('admin/user/help', t('help'), $access ? 'user_help_page' : MENU_DENIED, 9);
- menu('admin/user/edit', t('edit user account'), $access ? 'user_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- if (module_exist('search')) {
- menu('admin/user/search', t('search'), $access ? 'user_admin' : MENU_DENIED, 8);
- }
+ $access = user_access('administer users');
+
+ if (arg(0) == 'user' && is_numeric(arg(1))) {
+ $items[] = array('path' => 'user/'. arg(1), 'title' => t('user'),
+ 'callback' => 'user_page', 'access' => TRUE);
+ // Add the edit menu:
+ if ($access) $function = 'user_admin_edit';
+ else $function = 'user_edit';
+ $items[] = array('path' => 'user/'. arg(1) .'/edit', 'title' => t('edit'),
+ 'callback' => $function, 'access' => $access || $user->uid == arg(1),
+ 'type' => MENU_LOCAL_TASK);
}
+
+ if ($user->uid) {
+ $items[] = array('path' => "user/$user->uid", 'title' => t('my account'),
+ 'callback' => 'user_page', 'access' => TRUE);
+ $items[] = array('path' => 'logout', 'title' => t('log out'),
+ 'access' => TRUE,
+ 'callback' => 'user_logout',
+ 'weight' => 10);
+ }
+ else {
+ $items[] = array('path' => 'logout', 'title' => t('log out'),
+ 'callback' => 'user_logout', 'access' => FALSE);
+ }
+
+ $items[] = array('path' => 'user', 'title' => t('user'),
+ 'callback' => 'user_page', 'access' => TRUE,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'user/login', 'title' => t('log in'),
+ 'type' => MENU_CALLBACK);
+
+ $items[] = array('path' => 'admin/user', 'title' => t('users'),
+ 'callback' => 'user_admin', 'access' => $access);
+
+ // Tabs:
+ $items[] = array('path' => 'admin/user/create', 'title' => t('add user'),
+ 'callback' => 'user_admin', 'access' => $access,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/user/configure', 'title' => t('configure'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_TASK);
+ if (module_exist('search')) {
+ $items[] = array('path' => 'admin/user/search', 'title' => t('search'),
+ 'callback' => 'user_admin', 'access' => $access,
+ 'type' => MENU_LOCAL_TASK);
+ }
+
+ // Sub-tabs:
+ $items[] = array('path' => 'admin/user/configure/settings', 'title' => t('settings'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/access', 'title' => t('access rules'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/access/mail', 'title' => t('e-mail rules'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/access/user', 'title' => t('name rules'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/role', 'title' => t('roles'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/permission', 'title' => t('permissions'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+
+ return $items;
}
/**
@@ -720,7 +760,7 @@ function user_login($edit = array(), $msg = '') {
if (module_invoke($module, 'auth', $name, $pass, $server)) {
if (variable_get('user_register', 1) == 1 && !user_load(array('name' => "$name@$server"))) { // Register this new user.
$user = user_save('', array('name' => "$name@$server", 'pass' => user_password(), 'init' => "$name@$server", 'status' => 1, "authname_$module" => "$name@$server", 'rid' => array(_user_authenticated_id())));
- watchdog('user', "new user: $name@$server ($module ID)", l(t('edit user'), "admin/user/edit/$user->uid"));
+ watchdog('user', "new user: $name@$server ($module ID)", l(t('edit user'), "user/$user->uid/edit"));
break;
}
}
@@ -1133,7 +1173,7 @@ function user_page() {
$op = $_POST['op'];
if (empty($op)) {
- $op = arg(1);
+ $op = arg(2);
}
switch ($op) {
@@ -1160,17 +1200,14 @@ function user_page() {
case 'edit':
$output = user_edit($edit);
$GLOBALS['theme'] = init_theme();
- print theme('page', $output, t('Edit account'));
- break;
- case 'view':
- user_view(arg(2));
+ print theme('page', $output);
break;
case t('Logout'):
case 'logout':
print user_logout();
break;
default:
- print user_view();
+ print user_view(arg(1));
}
}
@@ -1202,10 +1239,7 @@ function _user_mail_text($messageid, $variables = array()) {
}
}
-/**
- * Implementation of hook_settings().
- */
-function user_settings() {
+function user_configure_settings() {
// User registration settings.
$group = form_radios(t('Public registrations'), 'user_register', variable_get('user_register', 1), array(t('Only site administrators can create new user accounts.'), t('Visitors can create accounts and no administrator approval is required.'), t('Visitors can create accounts but administrator approval is required.')));
$group .= form_textarea(t('User registration guidelines'), 'user_registration_help', variable_get('user_registration_help', ''), 70, 4, t('This text is displayed at the top of the user registration form. It\'s useful for helping or instructing your users.'));
@@ -1244,6 +1278,7 @@ function user_settings() {
}
function user_admin_create($edit = array()) {
+
if ($edit['name'] || $edit['mail']) {
if ($error = user_validate_name($edit['name'])) {
form_set_error('name', $error);
@@ -1459,15 +1494,16 @@ function user_admin_role($edit = array()) {
return $output;
}
-function user_admin_edit($edit = array()) {
+function user_admin_edit() {
$op = $_POST['op'];
- $id = arg(3);
+ $edit = $_POST['edit'];
+ $id = arg(1);
if ($account = user_load(array('uid' => $id))) {
-
if ($op == t('Save account')) {
// TODO: This display/edit/validate should be moved to a new profile
// module implementing hook_user().
+
if ($error = user_validate_name($edit['name'])) {
form_set_error('name', $error);
}
@@ -1523,7 +1559,8 @@ function user_admin_edit($edit = array()) {
db_query('DELETE FROM {authmap} WHERE uid = %d', $account->uid);
drupal_set_message(t('the account has been deleted.'));
module_invoke_all('user', 'delete', $edit, $account);
- return user_admin_account();
+ print theme('page', user_admin_account());
+ return;
}
else {
drupal_set_message(t('Failed to delete account: the account has to be blocked first.'), 'error');
@@ -1559,12 +1596,12 @@ function user_admin_edit($edit = array()) {
$output .= form_submit(t('Delete account'));
$output = form($output, 'post', 0, array('enctype' => 'multipart/form-data'));
+
+ print theme('page', $output, $account->name);
}
else {
- $output = t('No such user');
+ print theme('page', t('No such user'));
}
-
- return $output;
}
function user_admin_account() {
@@ -1589,7 +1626,7 @@ function user_admin_account() {
$roles[] = $role->name;
}
- $rows[] = array($account->uid, format_name($account), $status[$account->status], implode(',<br />', $roles), format_date($account->changed, 'small'), l(t('edit account'), "admin/user/edit/$account->uid"));
+ $rows[] = array($account->uid, format_name($account), $status[$account->status], implode(',<br />', $roles), format_date($account->changed, 'small'), l(t('edit account'), "user/$account->uid/edit"));
}
$pager = theme('pager', NULL, 50, 0, tablesort_pager());
@@ -1599,43 +1636,55 @@ function user_admin_account() {
return theme('table', $header, $rows);
}
-function user_admin() {
+function user_configure() {
$op = $_POST['op'];
$edit = $_POST['edit'];
if (empty($op)) {
- $op = arg(2);
+ $op = arg(3);
}
switch ($op) {
- case 'search':
- $output = search_type('user', url('admin/user/search'), $_POST['keys']);
- break;
case t('Add rule'):
case t('Check'):
case 'access':
- $output .= user_admin_access($edit);
+ $output = user_admin_access($edit);
break;
case t('Save permissions'):
drupal_set_message(t('user permissions saved.'));
case 'permission':
- $output .= user_admin_perm($edit);
- break;
- case t('Create account'):
- case 'create':
- $output = user_admin_create($edit);
+ $output = user_admin_perm($edit);
break;
case t('Add role'):
case t('Delete role'):
case t('Save role'):
drupal_set_message(t('your role changes were saved.'));
case 'role':
- $output .= user_admin_role($edit);
+ $output = user_admin_role($edit);
break;
- case t('Delete account'):
- case t('Save account'):
- case 'edit':
- $output = user_admin_edit($edit);
+ default:
+ if ($_POST) system_settings_save();
+ $output = system_settings_form(user_configure_settings());
+ }
+
+ print theme('page', $output);
+}
+
+function user_admin() {
+ $op = $_POST['op'];
+ $edit = $_POST['edit'];
+
+ if (empty($op)) {
+ $op = arg(2);
+ }
+
+ switch ($op) {
+ case 'search':
+ $output = search_type('user', url('admin/user/search'), $_POST['keys']);
+ break;
+ case t('Create account'):
+ case 'create':
+ $output = user_admin_create($edit);
break;
default:
$output = user_admin_account();
@@ -1671,9 +1720,9 @@ function user_help($section) {
</ul>', array('%permission' => url('admin/user/permission')));
case 'admin/user/search':
return t('Enter a simple pattern ("*" may be user as a wildcard match) to search for a username. For example, one may search for "br" and Drupal might return "brian", "brad", and "brenda".');
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables the user registration and login system.');
- case 'admin/system/modules/user':
+ case 'admin/settings/user':
return t('In order to use the full power of Drupal a visitor must sign up for an account. This page lets you setup how a user signs up, logs out, the guidelines from the system about user subscriptions, and the e-mails the system will send to the user.');
case 'user/help#user':
$site = variable_get('site_name', 'this website');
@@ -1706,8 +1755,7 @@ function user_help($section) {
<p>One key element of DA is the 'authmap' table, which maps a user's authname (e.g. joe@remote.delphiforums.com) to his local UID (i.e. user identification number). This map is checked whenever a user successfully logs into an external authentication source. Once Drupal knows that the current user is definately joe@remote.delphiforums.com (because Delphi says so), he looks up Joe's UID and logs Joe into that account.</p>
<p>To disable distributed authentication, simply <a href=\"%dis-module\">disable</a> or remove all DA modules. For a virgin install, that means removing/disabling the jabber module and the drupal module.</p>
<p>Drupal is setup so that it is very easy to add support for any external authentication source. You currently have the following authentication modules installed ...</p>
- %module-list
-", array('%user-role' => url('admin/user/role'), '%user-permission' => url('admin/user/permission'), '%jabber' => 'http://www.jabber.org', '%delphiforums' => 'http://www.delphiforums.com', '%drupal' => 'http://www.drupal.org', '%da-auth' => url('user/help', NULL, 'da'), '%php-sess' => 'http://www.php.net/manual/en/ref.session.php', '%user-prefs' => url('user/edit'), '%admin-user' => url('admin/user'), '%xml' => 'http://www.xmlrpc.org', '%http-post' => 'http://www.w3.org/Protocols/', '%soap' => 'http://www.soapware.org', '%dis-module' => url('admin/system/modules'), '%blogger' => 'http://www.blogger.com', '%blogger-api' => 'http://plant.blogger.com/API', '%drupal-lists' => 'http://drupal.org/mailing-lists', '%drupal-org' => 'http://www.drupal.org', '%registration' => url('user/register'), '%user-acct' => url('user'), '%user-admin' => url('admin/user')));
+ %module-list");
foreach (module_list() as $module) {
if (module_hook($module, 'auth')) {
diff --git a/modules/user/user.module b/modules/user/user.module
index ba85e5a32..ea544987d 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -410,7 +410,7 @@ function user_search($keys) {
$result = db_query_range("SELECT * FROM {users} WHERE LOWER(name) LIKE '%%%s%%'", strtolower($keys), 0, 20);
while ($account = db_fetch_object($result)) {
- $find[] = array('title' => $account->name, 'link' => (strstr(request_uri(), 'admin') ? url("admin/user/edit/$account->uid") : url("user/view/$account->uid")), 'user' => $account->name);
+ $find[] = array('title' => $account->name, 'link' => url("user/$account->uid/view"), 'user' => $account->name);
}
return array(t('Matching users'), $find);
}
@@ -484,7 +484,7 @@ function user_block($op = 'list', $delta = 0) {
}
return $block;
case 1:
- if ($menu = menu_tree()) {
+ if ($menu = theme('menu_tree')) {
$block['subject'] = $user->uid ? $user->name : t('Navigation');
$block['content'] = '<div class="menu">'. $menu .'</div>';
}
@@ -573,11 +573,6 @@ function theme_user_profile($account, $fields) {
foreach ($fields as $category => $value) {
$output .= "<h2>$category</h2>$value";
}
-
- if (user_access('administer users')) {
- $output .= form_item(t('Administration'), l(t('edit account'), "admin/user/edit/$account->uid"));
- }
-
$output .= "</div>\n";
return $output;
@@ -588,37 +583,82 @@ function theme_user_list($items, $title = NULL) {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function user_link($type) {
+function user_menu() {
global $user;
- if ($type == 'system') {
- if ($user->uid) {
- menu('user', t('my account'), 'user_page', 0);
- menu('user/edit', t('edit account'), 'user_page', 0);
- menu('logout', t('log out'), 'user_logout', 10);
- }
- else {
- menu('user', t('user'), 'user_page', 0, MENU_HIDE);
- menu('user/edit', t('edit account'), MENU_DENIED);
- menu('logout', t('log out'), MENU_DENIED);
- }
+ $items = array();
- $access = user_access('administer users');
- menu('admin/user', t('accounts'), $access ? 'user_admin' : MENU_DENIED, 2);
- menu('admin/user/create', t('new user'), $access ? 'user_admin' : MENU_DENIED, 1);
- menu('admin/user/access', t('access rules'), $access ? 'user_admin' : MENU_DENIED, 3);
- menu('admin/user/access/mail', t('e-mail rules'), $access ? 'user_admin' : MENU_DENIED);
- menu('admin/user/access/user', t('name rules'), $access ? 'user_admin' : MENU_DENIED);
- menu('admin/user/role', t('roles'), $access ? 'user_admin' : MENU_DENIED, 4);
- menu('admin/user/permission', t('permissions'), $access ? 'user_admin' : MENU_DENIED, 5);
- menu('admin/user/help', t('help'), $access ? 'user_help_page' : MENU_DENIED, 9);
- menu('admin/user/edit', t('edit user account'), $access ? 'user_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- if (module_exist('search')) {
- menu('admin/user/search', t('search'), $access ? 'user_admin' : MENU_DENIED, 8);
- }
+ $access = user_access('administer users');
+
+ if (arg(0) == 'user' && is_numeric(arg(1))) {
+ $items[] = array('path' => 'user/'. arg(1), 'title' => t('user'),
+ 'callback' => 'user_page', 'access' => TRUE);
+ // Add the edit menu:
+ if ($access) $function = 'user_admin_edit';
+ else $function = 'user_edit';
+ $items[] = array('path' => 'user/'. arg(1) .'/edit', 'title' => t('edit'),
+ 'callback' => $function, 'access' => $access || $user->uid == arg(1),
+ 'type' => MENU_LOCAL_TASK);
}
+
+ if ($user->uid) {
+ $items[] = array('path' => "user/$user->uid", 'title' => t('my account'),
+ 'callback' => 'user_page', 'access' => TRUE);
+ $items[] = array('path' => 'logout', 'title' => t('log out'),
+ 'access' => TRUE,
+ 'callback' => 'user_logout',
+ 'weight' => 10);
+ }
+ else {
+ $items[] = array('path' => 'logout', 'title' => t('log out'),
+ 'callback' => 'user_logout', 'access' => FALSE);
+ }
+
+ $items[] = array('path' => 'user', 'title' => t('user'),
+ 'callback' => 'user_page', 'access' => TRUE,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'user/login', 'title' => t('log in'),
+ 'type' => MENU_CALLBACK);
+
+ $items[] = array('path' => 'admin/user', 'title' => t('users'),
+ 'callback' => 'user_admin', 'access' => $access);
+
+ // Tabs:
+ $items[] = array('path' => 'admin/user/create', 'title' => t('add user'),
+ 'callback' => 'user_admin', 'access' => $access,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/user/configure', 'title' => t('configure'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_TASK);
+ if (module_exist('search')) {
+ $items[] = array('path' => 'admin/user/search', 'title' => t('search'),
+ 'callback' => 'user_admin', 'access' => $access,
+ 'type' => MENU_LOCAL_TASK);
+ }
+
+ // Sub-tabs:
+ $items[] = array('path' => 'admin/user/configure/settings', 'title' => t('settings'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/access', 'title' => t('access rules'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/access/mail', 'title' => t('e-mail rules'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/access/user', 'title' => t('name rules'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/role', 'title' => t('roles'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+ $items[] = array('path' => 'admin/user/configure/permission', 'title' => t('permissions'),
+ 'callback' => 'user_configure', 'access' => $access,
+ 'type' => MENU_LOCAL_SUBTASK);
+
+ return $items;
}
/**
@@ -720,7 +760,7 @@ function user_login($edit = array(), $msg = '') {
if (module_invoke($module, 'auth', $name, $pass, $server)) {
if (variable_get('user_register', 1) == 1 && !user_load(array('name' => "$name@$server"))) { // Register this new user.
$user = user_save('', array('name' => "$name@$server", 'pass' => user_password(), 'init' => "$name@$server", 'status' => 1, "authname_$module" => "$name@$server", 'rid' => array(_user_authenticated_id())));
- watchdog('user', "new user: $name@$server ($module ID)", l(t('edit user'), "admin/user/edit/$user->uid"));
+ watchdog('user', "new user: $name@$server ($module ID)", l(t('edit user'), "user/$user->uid/edit"));
break;
}
}
@@ -1133,7 +1173,7 @@ function user_page() {
$op = $_POST['op'];
if (empty($op)) {
- $op = arg(1);
+ $op = arg(2);
}
switch ($op) {
@@ -1160,17 +1200,14 @@ function user_page() {
case 'edit':
$output = user_edit($edit);
$GLOBALS['theme'] = init_theme();
- print theme('page', $output, t('Edit account'));
- break;
- case 'view':
- user_view(arg(2));
+ print theme('page', $output);
break;
case t('Logout'):
case 'logout':
print user_logout();
break;
default:
- print user_view();
+ print user_view(arg(1));
}
}
@@ -1202,10 +1239,7 @@ function _user_mail_text($messageid, $variables = array()) {
}
}
-/**
- * Implementation of hook_settings().
- */
-function user_settings() {
+function user_configure_settings() {
// User registration settings.
$group = form_radios(t('Public registrations'), 'user_register', variable_get('user_register', 1), array(t('Only site administrators can create new user accounts.'), t('Visitors can create accounts and no administrator approval is required.'), t('Visitors can create accounts but administrator approval is required.')));
$group .= form_textarea(t('User registration guidelines'), 'user_registration_help', variable_get('user_registration_help', ''), 70, 4, t('This text is displayed at the top of the user registration form. It\'s useful for helping or instructing your users.'));
@@ -1244,6 +1278,7 @@ function user_settings() {
}
function user_admin_create($edit = array()) {
+
if ($edit['name'] || $edit['mail']) {
if ($error = user_validate_name($edit['name'])) {
form_set_error('name', $error);
@@ -1459,15 +1494,16 @@ function user_admin_role($edit = array()) {
return $output;
}
-function user_admin_edit($edit = array()) {
+function user_admin_edit() {
$op = $_POST['op'];
- $id = arg(3);
+ $edit = $_POST['edit'];
+ $id = arg(1);
if ($account = user_load(array('uid' => $id))) {
-
if ($op == t('Save account')) {
// TODO: This display/edit/validate should be moved to a new profile
// module implementing hook_user().
+
if ($error = user_validate_name($edit['name'])) {
form_set_error('name', $error);
}
@@ -1523,7 +1559,8 @@ function user_admin_edit($edit = array()) {
db_query('DELETE FROM {authmap} WHERE uid = %d', $account->uid);
drupal_set_message(t('the account has been deleted.'));
module_invoke_all('user', 'delete', $edit, $account);
- return user_admin_account();
+ print theme('page', user_admin_account());
+ return;
}
else {
drupal_set_message(t('Failed to delete account: the account has to be blocked first.'), 'error');
@@ -1559,12 +1596,12 @@ function user_admin_edit($edit = array()) {
$output .= form_submit(t('Delete account'));
$output = form($output, 'post', 0, array('enctype' => 'multipart/form-data'));
+
+ print theme('page', $output, $account->name);
}
else {
- $output = t('No such user');
+ print theme('page', t('No such user'));
}
-
- return $output;
}
function user_admin_account() {
@@ -1589,7 +1626,7 @@ function user_admin_account() {
$roles[] = $role->name;
}
- $rows[] = array($account->uid, format_name($account), $status[$account->status], implode(',<br />', $roles), format_date($account->changed, 'small'), l(t('edit account'), "admin/user/edit/$account->uid"));
+ $rows[] = array($account->uid, format_name($account), $status[$account->status], implode(',<br />', $roles), format_date($account->changed, 'small'), l(t('edit account'), "user/$account->uid/edit"));
}
$pager = theme('pager', NULL, 50, 0, tablesort_pager());
@@ -1599,43 +1636,55 @@ function user_admin_account() {
return theme('table', $header, $rows);
}
-function user_admin() {
+function user_configure() {
$op = $_POST['op'];
$edit = $_POST['edit'];
if (empty($op)) {
- $op = arg(2);
+ $op = arg(3);
}
switch ($op) {
- case 'search':
- $output = search_type('user', url('admin/user/search'), $_POST['keys']);
- break;
case t('Add rule'):
case t('Check'):
case 'access':
- $output .= user_admin_access($edit);
+ $output = user_admin_access($edit);
break;
case t('Save permissions'):
drupal_set_message(t('user permissions saved.'));
case 'permission':
- $output .= user_admin_perm($edit);
- break;
- case t('Create account'):
- case 'create':
- $output = user_admin_create($edit);
+ $output = user_admin_perm($edit);
break;
case t('Add role'):
case t('Delete role'):
case t('Save role'):
drupal_set_message(t('your role changes were saved.'));
case 'role':
- $output .= user_admin_role($edit);
+ $output = user_admin_role($edit);
break;
- case t('Delete account'):
- case t('Save account'):
- case 'edit':
- $output = user_admin_edit($edit);
+ default:
+ if ($_POST) system_settings_save();
+ $output = system_settings_form(user_configure_settings());
+ }
+
+ print theme('page', $output);
+}
+
+function user_admin() {
+ $op = $_POST['op'];
+ $edit = $_POST['edit'];
+
+ if (empty($op)) {
+ $op = arg(2);
+ }
+
+ switch ($op) {
+ case 'search':
+ $output = search_type('user', url('admin/user/search'), $_POST['keys']);
+ break;
+ case t('Create account'):
+ case 'create':
+ $output = user_admin_create($edit);
break;
default:
$output = user_admin_account();
@@ -1671,9 +1720,9 @@ function user_help($section) {
</ul>', array('%permission' => url('admin/user/permission')));
case 'admin/user/search':
return t('Enter a simple pattern ("*" may be user as a wildcard match) to search for a username. For example, one may search for "br" and Drupal might return "brian", "brad", and "brenda".');
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Enables the user registration and login system.');
- case 'admin/system/modules/user':
+ case 'admin/settings/user':
return t('In order to use the full power of Drupal a visitor must sign up for an account. This page lets you setup how a user signs up, logs out, the guidelines from the system about user subscriptions, and the e-mails the system will send to the user.');
case 'user/help#user':
$site = variable_get('site_name', 'this website');
@@ -1706,8 +1755,7 @@ function user_help($section) {
<p>One key element of DA is the 'authmap' table, which maps a user's authname (e.g. joe@remote.delphiforums.com) to his local UID (i.e. user identification number). This map is checked whenever a user successfully logs into an external authentication source. Once Drupal knows that the current user is definately joe@remote.delphiforums.com (because Delphi says so), he looks up Joe's UID and logs Joe into that account.</p>
<p>To disable distributed authentication, simply <a href=\"%dis-module\">disable</a> or remove all DA modules. For a virgin install, that means removing/disabling the jabber module and the drupal module.</p>
<p>Drupal is setup so that it is very easy to add support for any external authentication source. You currently have the following authentication modules installed ...</p>
- %module-list
-", array('%user-role' => url('admin/user/role'), '%user-permission' => url('admin/user/permission'), '%jabber' => 'http://www.jabber.org', '%delphiforums' => 'http://www.delphiforums.com', '%drupal' => 'http://www.drupal.org', '%da-auth' => url('user/help', NULL, 'da'), '%php-sess' => 'http://www.php.net/manual/en/ref.session.php', '%user-prefs' => url('user/edit'), '%admin-user' => url('admin/user'), '%xml' => 'http://www.xmlrpc.org', '%http-post' => 'http://www.w3.org/Protocols/', '%soap' => 'http://www.soapware.org', '%dis-module' => url('admin/system/modules'), '%blogger' => 'http://www.blogger.com', '%blogger-api' => 'http://plant.blogger.com/API', '%drupal-lists' => 'http://drupal.org/mailing-lists', '%drupal-org' => 'http://www.drupal.org', '%registration' => url('user/register'), '%user-acct' => url('user'), '%user-admin' => url('admin/user')));
+ %module-list");
foreach (module_list() as $module) {
if (module_hook($module, 'auth')) {
diff --git a/modules/watchdog.module b/modules/watchdog.module
index a2be7242c..14c2c17d7 100644
--- a/modules/watchdog.module
+++ b/modules/watchdog.module
@@ -9,7 +9,7 @@ function watchdog_help($section = 'admin/help#watchdog') {
case 'admin/help#watchdog':
return t('
<p>Watchdog module monitors your web site, capturing system events in a log to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to <a href="%watchdog">check the watchdog report</a> on a regular basis as it is often the only way to tell what is going on.</p>
- <p>To ease administration, the watchdog will automatically discard old log entries, <a href="%log-entry">as configured</a>. Needs "cron.php" to discard the entries.</p>', array('%watchdog' => url('admin/logs'), '%log-entry' => url('admin/system/modules/watchdog')));
+ <p>To ease administration, the watchdog will automatically discard old log entries, <a href="%log-entry">as configured</a>. Needs "cron.php" to discard the entries.</p>', array('%watchdog' => url('admin/logs'), '%log-entry' => url('admin/settings/watchdog')));
case 'admin/logs':
return t('The watchdog module monitors your web site, captures system events in a log and records them to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of events recorded during operation and contains usage data, performance data, errors, warnings and operational information. It is vital to check the watchdog report on a regular basis as it is often the only way to tell what is going on.');
case 'admin/logs/user':
@@ -26,9 +26,9 @@ function watchdog_help($section = 'admin/help#watchdog') {
return t('Watchdog events about PHP and database errors.');
case 'admin/logs/warning':
return t('Watchdog warning events. These events don\'t stop Drupal from running, but are things you should know.');
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Logs and records system events.');
- case 'admin/system/modules/watchdog':
+ case 'admin/settings/watchdog':
return t('Watchdog logs your system events. To see these events go to the <a href="%watchdog">logs</a>. Since these logs can grow out of control if kept around forever, below set how long an item should be kept in the log. Note that to discard entries as set below you must run "cron.php" regularly.', array('%watchdog' => url('admin/logs')));
}
}
@@ -41,29 +41,24 @@ function watchdog_perm() {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function watchdog_link($type) {
- if ($type == 'system') {
- menu('admin/logs', t('logs'), user_access('administer watchdog') ? 'watchdog_overview' : MENU_DENIED, 7);
- menu('admin/logs/view', t('view details'), user_access('administer watchdog') ? 'watchdog_view' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
-
- if (arg(1) == 'logs') {
- foreach (_watchdog_get_message_types() as $type) {
- menu("admin/logs/$type", t($type), MENU_FALLTHROUGH, 0, MENU_SHOW, MENU_LOCKED);
- }
+function watchdog_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/logs', 'title' => t('logs'),
+ 'callback' => 'watchdog_overview',
+ 'access' => user_access('administer watchdog'));
+ $items[] = array('path' => 'admin/logs/view', 'title' => t('view details'),
+ 'callback' => 'watchdog_view',
+ 'access' => user_access('administer watchdog'),
+ 'type' => MENU_CALLBACK);
+ if (arg(1) == 'logs') {
+ foreach (_watchdog_get_message_types() as $type) {
+ $items[] = array('path' => 'admin/logs/'. $type, 'title' => t($type),
+ 'type' => MENU_DYNAMIC_ITEM);
}
}
-}
-
-/**
- * Implementation of hook_settings().
- */
-function watchdog_settings() {
- $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
- $period[1000000000] = t('Never');
- $output .= form_select(t('Discard entries older than'), 'watchdog_clear', variable_get('watchdog_clear', 604800), $period, t('The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.'));
- return $output;
+ return $items;
}
/**
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index a2be7242c..14c2c17d7 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/watchdog.module
@@ -9,7 +9,7 @@ function watchdog_help($section = 'admin/help#watchdog') {
case 'admin/help#watchdog':
return t('
<p>Watchdog module monitors your web site, capturing system events in a log to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to <a href="%watchdog">check the watchdog report</a> on a regular basis as it is often the only way to tell what is going on.</p>
- <p>To ease administration, the watchdog will automatically discard old log entries, <a href="%log-entry">as configured</a>. Needs "cron.php" to discard the entries.</p>', array('%watchdog' => url('admin/logs'), '%log-entry' => url('admin/system/modules/watchdog')));
+ <p>To ease administration, the watchdog will automatically discard old log entries, <a href="%log-entry">as configured</a>. Needs "cron.php" to discard the entries.</p>', array('%watchdog' => url('admin/logs'), '%log-entry' => url('admin/settings/watchdog')));
case 'admin/logs':
return t('The watchdog module monitors your web site, captures system events in a log and records them to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of events recorded during operation and contains usage data, performance data, errors, warnings and operational information. It is vital to check the watchdog report on a regular basis as it is often the only way to tell what is going on.');
case 'admin/logs/user':
@@ -26,9 +26,9 @@ function watchdog_help($section = 'admin/help#watchdog') {
return t('Watchdog events about PHP and database errors.');
case 'admin/logs/warning':
return t('Watchdog warning events. These events don\'t stop Drupal from running, but are things you should know.');
- case 'admin/system/modules#description':
+ case 'admin/modules#description':
return t('Logs and records system events.');
- case 'admin/system/modules/watchdog':
+ case 'admin/settings/watchdog':
return t('Watchdog logs your system events. To see these events go to the <a href="%watchdog">logs</a>. Since these logs can grow out of control if kept around forever, below set how long an item should be kept in the log. Note that to discard entries as set below you must run "cron.php" regularly.', array('%watchdog' => url('admin/logs')));
}
}
@@ -41,29 +41,24 @@ function watchdog_perm() {
}
/**
- * Implementation of hook_link().
+ * Implementation of hook_menu().
*/
-function watchdog_link($type) {
- if ($type == 'system') {
- menu('admin/logs', t('logs'), user_access('administer watchdog') ? 'watchdog_overview' : MENU_DENIED, 7);
- menu('admin/logs/view', t('view details'), user_access('administer watchdog') ? 'watchdog_view' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
-
- if (arg(1) == 'logs') {
- foreach (_watchdog_get_message_types() as $type) {
- menu("admin/logs/$type", t($type), MENU_FALLTHROUGH, 0, MENU_SHOW, MENU_LOCKED);
- }
+function watchdog_menu() {
+ $items = array();
+ $items[] = array('path' => 'admin/logs', 'title' => t('logs'),
+ 'callback' => 'watchdog_overview',
+ 'access' => user_access('administer watchdog'));
+ $items[] = array('path' => 'admin/logs/view', 'title' => t('view details'),
+ 'callback' => 'watchdog_view',
+ 'access' => user_access('administer watchdog'),
+ 'type' => MENU_CALLBACK);
+ if (arg(1) == 'logs') {
+ foreach (_watchdog_get_message_types() as $type) {
+ $items[] = array('path' => 'admin/logs/'. $type, 'title' => t($type),
+ 'type' => MENU_DYNAMIC_ITEM);
}
}
-}
-
-/**
- * Implementation of hook_settings().
- */
-function watchdog_settings() {
- $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
- $period[1000000000] = t('Never');
- $output .= form_select(t('Discard entries older than'), 'watchdog_clear', variable_get('watchdog_clear', 604800), $period, t('The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.'));
- return $output;
+ return $items;
}
/**
diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme
index 6906fbaa8..f3dcf1b6e 100644
--- a/themes/chameleon/chameleon.theme
+++ b/themes/chameleon/chameleon.theme
@@ -6,7 +6,7 @@ function chameleon_help($section) {
$output = '';
switch ($section) {
- case 'admin/system/themes#description':
+ case 'admin/themes#description':
$output = t('A fast PHP theme with different stylesheets.');
break;
}
@@ -37,6 +37,7 @@ function chameleon_page($content, $title = NULL, $breadcrumb = NULL) {
if (isset($title)) {
drupal_set_title($title);
}
+
if (isset($breadcrumb)) {
drupal_set_breadcrumb($breadcrumb);
}
@@ -68,6 +69,10 @@ function chameleon_page($content, $title = NULL, $breadcrumb = NULL) {
$output .= "<h2>$title</h2>";
}
+ if ($tabs = theme('menu_local_tasks')) {
+ $output .= $tabs;
+ }
+
if ($help = menu_get_active_help()) {
$output .= "<small>$help</small><hr />";
}
@@ -106,7 +111,7 @@ function chameleon_node($node, $main = 0, $page = 0) {
$output = "<div class=\"node\">\n";
if (!$page) {
- $output .= " <h2 class=\"title\">". ($main ? l($node->title, "node/view/$node->nid") : $node->title) ."</h2>\n";
+ $output .= " <h2 class=\"title\">". ($main ? l($node->title, "node/$node->nid") : $node->title) ."</h2>\n";
}
$output .= " <div class=\"content\">\n";
diff --git a/themes/chameleon/pure/chameleon.css b/themes/chameleon/pure/chameleon.css
index e555b68ac..a7ab2ac76 100644
--- a/themes/chameleon/pure/chameleon.css
+++ b/themes/chameleon/pure/chameleon.css
@@ -87,4 +87,4 @@ ul {
color: gray;
font-style: italic;
font-size: 0.9em;
-} \ No newline at end of file
+}
diff --git a/themes/example/example.theme b/themes/example/example.theme
index bf4b780ef..d9a040f3e 100644
--- a/themes/example/example.theme
+++ b/themes/example/example.theme
@@ -6,7 +6,7 @@ function example_help($section) {
$output = "";
switch ($section) {
- case 'admin/system/themes#description':
+ case 'admin/themes#description':
$output = t("Internet explorer, Netscape, Opera, Lynx");
break;
}
diff --git a/themes/xtemplate/default/xtemplate.css b/themes/xtemplate/default/xtemplate.css
index 67994520a..6b2ff09a3 100644
--- a/themes/xtemplate/default/xtemplate.css
+++ b/themes/xtemplate/default/xtemplate.css
@@ -188,21 +188,89 @@ table {
}
.tabs {
- color: #999;
- margin: 0.5em 0;
- padding: 0.5em 1em;
- border-bottom: 1px solid black;
+ width: 100%;
+ diplay: block;
+ margin: 0;
+ padding: 0;
+ white-space: nowrap;
}
-.tabs a {
- border: 1px solid black;
- background: #f0f0f0;
- font-weight: bold;
- margin-right: 1em;
- padding: 0.5em 1em;
+
+.tabs ul {
+ float: left;
+ diplay: block;
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ list-style-type: none;
}
-.tabs a.active {
- border-bottom: 1px solid white;
- background: #fff;
+
+.tabs li {
+ float: left;
+ diplay: block;
+ width: auto;
+ margin: 0 0.2em 0 0.2em;
+ padding: 0;
+ list-style-type: none;
+}
+
+.tabs li a {
+ position: relative;
+ display: block;
+ margin: 0;
+ padding: 0 0.9em;
+ background-color: #eee;
+ border-top: 1px solid #888;
+ border-right: 1px solid #888;
+ border-bottom: 2px solid #fff;
+ border-left: 1px solid #888;
+ background-color: #fff;
+ text-align: center;
+ }
+
+.tabs li.active a, .tabs li.active {
+ background-color: #eee;
+ border-top: 1px solid #bbb;
+ border-right: 1px solid #bbb;
+ border-bottom: 2px solid #eee;
+ border-left: 1px solid #ccc;
+ z-index: 2;
+}
+
+.tabs li.active ul {
+ display: inline;
+ float: none;
+ position: absolute;
+ padding: 0;
+ margin: 0;
+ border-top: 2px solid #888;
+ border-left: 2px solid #bbb;
+ background-color: none;
+ white-space: nowrap;
+}
+
+.tabs li.active ul li {
+ width: auto;
+ display: inline;
+ list-style: none;
+ margin: 0;
+ border: 0;
+ z-index: 1;
+}
+
+.tabs li.active ul li a {
+ width: auto;
+ margin: 0;
+ padding: 0;
+ background-color: #eee;
+ border-top: none;
+ border-right: 1px solid #bbb;
+ border-bottom: none;
+ border-left: none;
+ z-index: 2;
+}
+
+.clear-tabs {
+ clear: both;
}
.block, .box {
@@ -222,7 +290,7 @@ table {
.node {
margin: .5em 0 1em 0;
}
-.static {
+.sticky {
padding: .5em;
background-color: #eee;
border: solid 1px #ddd;
diff --git a/themes/xtemplate/default/xtemplate.xtmpl b/themes/xtemplate/default/xtemplate.xtmpl
index a1e0e72ac..2c8db0eef 100644
--- a/themes/xtemplate/default/xtemplate.xtmpl
+++ b/themes/xtemplate/default/xtemplate.xtmpl
@@ -45,6 +45,10 @@
<!-- BEGIN: title -->
{breadcrumb}
<h1 class="title">{title}</h1>
+ <!-- BEGIN: tabs -->
+ <div class="tabs">{tabs}</div>
+ <div class="clear-tabs"></div>
+ <!-- END: tabs -->
<!-- END: title -->
<!-- BEGIN: help -->
<div id="help">{help}</div>
@@ -55,7 +59,7 @@
<!-- END: header -->
<!-- BEGIN: node -->
- <div class="node {static}">
+ <div class="node {sticky}">
<!-- BEGIN: picture -->
{picture}
<!-- END: picture -->
diff --git a/themes/xtemplate/xtemplate.theme b/themes/xtemplate/xtemplate.theme
index 3a63e03ee..9d72d6a96 100644
--- a/themes/xtemplate/xtemplate.theme
+++ b/themes/xtemplate/xtemplate.theme
@@ -26,8 +26,8 @@ function xtemplate_settings() {
$output = form_group(t('Template selection'), $group);
$group = form_textarea(t('Logo'), 'xtemplate_logo', variable_get('xtemplate_logo', "<img src=\"themes/xtemplate/$template_directory/logo.gif\" alt=\"Logo\" />"), 70, 4, t('The HTML code for displaying the logo.'));
- $group .= form_textarea(t('Primary links'), 'xtemplate_primary_links', variable_get('xtemplate_primary_links', l('edit primary links', 'admin/system/themes/xtemplate')), 70, 8, t('The HTML code for the primary links.'));
- $group .= form_textarea(t('Secondary links'), 'xtemplate_secondary_links', variable_get('xtemplate_secondary_links', l('edit secondary links', 'admin/system/themes/xtemplate')), 70, 8, t('The HTML code for the secondary links.'));
+ $group .= form_textarea(t('Primary links'), 'xtemplate_primary_links', variable_get('xtemplate_primary_links', l('edit primary links', 'admin/themes/xtemplate')), 70, 8, t('The HTML code for the primary links.'));
+ $group .= form_textarea(t('Secondary links'), 'xtemplate_secondary_links', variable_get('xtemplate_secondary_links', l('edit secondary links', 'admin/themes/xtemplate')), 70, 8, t('The HTML code for the secondary links.'));
$group .= form_textarea(t('Message on front page'), 'xtemplate_mission', variable_get('xtemplate_mission', 'edit mission'), 70, 6, t('This text will be displayed on the front page. It can be used to display a mission statement, announcement or site description..'));
$group .= form_radios(t('Search box'), 'xtemplate_search_box', variable_get('xtemplate_search_box', 0), array(t('Disabled'), t('Enabled')), t('Show a search box in the upper right corner.'));
$output .= form_group(t('Header settings'), $group);
@@ -44,7 +44,7 @@ function xtemplate_help($section) {
$output = '';
switch ($section) {
- case 'admin/system/themes#description':
+ case 'admin/themes#description':
$output = t('A template driven theme');
break;
}
@@ -59,7 +59,7 @@ function xtemplate_node($node, $main = 0, $page = 0) {
"submitted" => t("Submitted by %a on %b.",
array("%a" => format_name($node),
"%b" => format_date($node->created))),
- "link" => url("node/view/$node->nid"),
+ "link" => url("node/$node->nid"),
"title" => $node->title,
"author" => format_name($node),
"date" => format_date($node->created),
@@ -144,10 +144,15 @@ function xtemplate_page($content, $title = NULL, $breadcrumb = NULL) {
"directory" => "themes/xtemplate/$template_directory",
"onload_attributes" => theme_onload_attribute(),
"logo" => variable_get('xtemplate_logo', "<img src=\"themes/xtemplate/$template_directory/logo.gif\" alt=\"Logo\" />"),
- "primary_links" => variable_get("xtemplate_primary_links", l("edit primary links", "admin/system/themes/xtemplate")),
- "secondary_links" => variable_get("xtemplate_secondary_links", l("edit secondary links", "admin/system/themes/xtemplate"))
+ "primary_links" => variable_get("xtemplate_primary_links", l("edit primary links", "admin/themes/xtemplate")),
+ "secondary_links" => variable_get("xtemplate_secondary_links", l("edit secondary links", "admin/themes/xtemplate"))
));
+ if ($tabs = theme('menu_local_tasks')) {
+ $xtemplate->template->assign("tabs", $tabs);
+ $xtemplate->template->parse("header.title.tabs");
+ }
+
if ($title = drupal_get_title()) {
$xtemplate->template->assign("title", $title);
$xtemplate->template->assign("breadcrumb", theme("breadcrumb", drupal_get_breadcrumb()));