=== modified file 'database/database.mysql' --- database/database.mysql 2004-05-19 14:55:19 +0000 +++ database/database.mysql 2004-06-18 15:04:33 +0000 @@ -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; === modified file 'database/database.pgsql' --- database/database.pgsql 2004-05-19 14:55:19 +0000 +++ database/database.pgsql 2004-06-18 15:04:33 +0000 @@ -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) ); === modified file 'database/updates.inc' --- database/updates.inc 2004-05-22 21:28:51 +0000 +++ database/updates.inc 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ "function"); $sql_updates = array( @@ -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); === modified file 'includes/common.inc' --- includes/common.inc 2004-06-04 18:10:05 +0000 +++ includes/common.inc 2004-06-18 15:04:33 +0000 @@ -1,9 +1,5 @@ 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) { /* === modified file 'includes/menu.inc' --- includes/menu.inc 2004-06-01 21:58:45 +0000 +++ includes/menu.inc 2004-06-18 15:04:33 +0000 @@ -1,56 +1,83 @@ $title, 'callback' => $callback, 'weight' => $weight, 'visibility' => $visibility, 'status' => $status); -} +/** + * 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); + +/** + * 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); + +/** + * 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); + +/** + * 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; - $trail = array(); + 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; - // Find the ID of the given path. - while ($path && !$menu['path index'][$path]) { + $prev_id = $temp_id; + $temp_id--; + } + } + + 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 = NU } /** + * 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']; + } + + // 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; + } + } + } - if ($menu['items'][$mid]['callback'] === MENU_FALLTHROUGH) { - return FALSE; + $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 .= "
NOTE: Enable your site\'s XML syndication button by turning on the Syndicate block in block management.
To subscribe to an RSS feed on another site, use the RSS/RDF administration page.
-Once there, select new feed from the menu. Drupal will then ask for the following:
+To subscribe to an RSS feed on another site, use the aggregation page.
+Once there, click the new feed tab. Drupal will then ask for the following:
Once you submit your new feed, check to see if it is working properly. Select update items on the RSS/RDF page. If you do not see any items listed for that feed, edit the feed and make sure that the URL was entered correctly.
+Once you submit your new feed, check to see if it is working properly. Select update items on the aggregation page. If you do not see any items listed for that feed, edit the feed and make sure that the URL was entered correctly.
News items can be filed into categories. To create a category, start at the RSS/RDF administration page.
+News items can be filed into categories. To create a category, start at the aggregation page.
Once there, select new category from the menu. Drupal will then ask for the following:
Drupal automatically generates an OPML feed file that is available by selecting the XML icon on the News Sources page.
When fetching feeds Drupal supports conditional GETs, this reduces the bandwidth usage for feeds that have not been updated since the last check.
-If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.
', 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': +If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.
', 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 must have cron 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 feed\'s block.', 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 must have cron 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 feed\'s block.', 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'); - menu('aggregator/opml', t('opml'), $access ? 'aggregator_page_opml' : MENU_DENIED, '', MENU_HIDE); - } + $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); + } + + // 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 $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 block configuration 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 block configuration page.', array('%url' => url('admin/block')))); $form .= form_submit(t('Submit')); if ($edit['cid']) { @@ -537,7 +586,7 @@ function aggregator_form_feed($edit = ar $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 block configuration 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 block configuration 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 } } } - $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 = 'NOTE: Enable your site\'s XML syndication button by turning on the Syndicate block in block management.
To subscribe to an RSS feed on another site, use the RSS/RDF administration page.
-Once there, select new feed from the menu. Drupal will then ask for the following:
+To subscribe to an RSS feed on another site, use the aggregation page.
+Once there, click the new feed tab. Drupal will then ask for the following:
Once you submit your new feed, check to see if it is working properly. Select update items on the RSS/RDF page. If you do not see any items listed for that feed, edit the feed and make sure that the URL was entered correctly.
+Once you submit your new feed, check to see if it is working properly. Select update items on the aggregation page. If you do not see any items listed for that feed, edit the feed and make sure that the URL was entered correctly.
News items can be filed into categories. To create a category, start at the RSS/RDF administration page.
+News items can be filed into categories. To create a category, start at the aggregation page.
Once there, select new category from the menu. Drupal will then ask for the following:
Drupal automatically generates an OPML feed file that is available by selecting the XML icon on the News Sources page.
When fetching feeds Drupal supports conditional GETs, this reduces the bandwidth usage for feeds that have not been updated since the last check.
-If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.
', 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': +If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.
', 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 must have cron 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 feed\'s block.', 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 must have cron 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 feed\'s block.', 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'); - menu('aggregator/opml', t('opml'), $access ? 'aggregator_page_opml' : MENU_DENIED, '', MENU_HIDE); - } + $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); + } + + // 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 $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 block configuration 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 block configuration page.', array('%url' => url('admin/block')))); $form .= form_submit(t('Submit')); if ($edit['cid']) { @@ -537,7 +586,7 @@ function aggregator_form_feed($edit = ar $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 block configuration 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 block configuration 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 } } } - $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 = '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.
Whether a block is visible in the first place depends on four things:
The block management screen also lets you specify the vertical sort-order of the blocks within a sidebar. You do this by assigning a weight 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.
-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. book
, node/view/12
, admin
.
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. book
, node/12
, admin
.
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 Perl-Compatible Regular Expressions (PCRE).
However, for basic tasks it is sufficient to look at the following examples:
-If the block should only show up on blog pages, use <^blog>. To display on all node views use <^node/view>. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use <^(forum|book)>. 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 <^node/add/(story|blog|image)>. 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 <^(?!search)>.
+If the block should only show up on blog pages, use <^blog>. To display on all node views use <^node>. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use <^(forum|book)>. 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 <^node/add/(story|blog|image)>. 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 <^(?!search)>.
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.
For more in-depth examples, we recommend that you check the existing boxes and use them as a starting point.
", 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 active 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 new block 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 throttle configuration page 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 blocks. The title is used when displaying the block. The description is used in the \"block\" column on the blocks page. If you are going to place PHP code in the block, and you have the create php content permission (see the permissions page), you must 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 active 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 add block 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 throttle configuration page 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 blocks. The title is used when displaying the block. The description is used in the \"block\" column on the blocks page. If you are going to place PHP code in the block, and you have the create php content permission (see the permissions page), you must 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 module_delta * - * @see [feature] + * @see [feature] * Generic template design difficult w/o block region "look-ahead" * @todo add a proper primary key (bid) to the blocks table so we don't have * to mess around with this module_delta construct. currently, === modified file 'modules/block/block.module' --- modules/block/block.module 2004-06-02 18:49:22 +0000 +++ modules/block/block.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 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.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.
Whether a block is visible in the first place depends on four things:
The block management screen also lets you specify the vertical sort-order of the blocks within a sidebar. You do this by assigning a weight 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.
-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. book
, node/view/12
, admin
.
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. book
, node/12
, admin
.
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 Perl-Compatible Regular Expressions (PCRE).
However, for basic tasks it is sufficient to look at the following examples:
-If the block should only show up on blog pages, use <^blog>. To display on all node views use <^node/view>. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use <^(forum|book)>. 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 <^node/add/(story|blog|image)>. 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 <^(?!search)>.
+If the block should only show up on blog pages, use <^blog>. To display on all node views use <^node>. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use <^(forum|book)>. 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 <^node/add/(story|blog|image)>. 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 <^(?!search)>.
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.
For more in-depth examples, we recommend that you check the existing boxes and use them as a starting point.
", 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 active 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 new block 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 throttle configuration page 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 blocks. The title is used when displaying the block. The description is used in the \"block\" column on the blocks page. If you are going to place PHP code in the block, and you have the create php content permission (see the permissions page), you must 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 active 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 add block 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 throttle configuration page 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 blocks. The title is used when displaying the block. The description is used in the \"block\" column on the blocks page. If you are going to place PHP code in the block, and you have the create php content permission (see the permissions page), you must 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 module_delta * - * @see [feature] + * @see [feature] * Generic template design difficult w/o block region "look-ahead" * @todo add a proper primary key (bid) to the blocks table so we don't have * to mess around with this module_delta construct. currently, === modified file 'modules/blog.module' --- modules/blog.module 2004-06-04 19:02:03 +0000 +++ modules/blog.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 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.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.
If a user has the ability to post blogs, then the import module (news aggregator) will display a blog-it link (b) 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.
", array('%scripting-com' => 'http://www.scripting.com/')); - 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 = ''. $blog->body .' ['. l($blog->name, "node/view/$nid") .']'; + $node->body = ''. $blog->body .' ['. 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, $ma } /** + * 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. === modified file 'modules/blog/blog.module' --- modules/blog/blog.module 2004-06-04 19:02:03 +0000 +++ modules/blog/blog.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 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.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.
If a user has the ability to post blogs, then the import module (news aggregator) will display a blog-it link (b) 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.
", array('%scripting-com' => 'http://www.scripting.com/')); - 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 = ''. $blog->body .' ['. l($blog->name, "node/view/$nid") .']'; + $node->body = ''. $blog->body .' ['. 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, $ma } /** + * 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. === modified file 'modules/blogapi.module' --- modules/blogapi.module 2004-06-15 17:45:44 +0000 +++ modules/blogapi.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 'Blogger API', '%metaweblogAPI' => 'MetaWeblog API', '%moveabletype' => 'Moveable Type API')); - 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')); } === modified file 'modules/blogapi/blogapi.module' --- modules/blogapi/blogapi.module 2004-06-15 17:45:44 +0000 +++ modules/blogapi/blogapi.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 'Blogger API', '%metaweblogAPI' => 'MetaWeblog API', '%moveabletype' => 'Moveable Type API')); - 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')); } === modified file 'modules/book.module' --- modules/book.module 2004-06-03 11:19:38 +0000 +++ modules/book.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 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); + return $links; +} - 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); - } +/** + * Implementation of hook_menu(). + */ +function book_menu() { + $items = array(); - return $links; + $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; } /** @@ -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, $pa 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 .= 'Whenever you come across a post which you want to include in your FAQ, click on the administer link. Then click on the edit book outline button at the bottom of the page. Then place the relevant post wherever is most appropriate in your book by selecting a parent. Books are quite flexible. They can have sections like Flying to Estonia, Eating in Estonia and so on. As you get more experienced with the book module, you can reorganize posts in your book so that it stays organized.
Notes:
Whenever you come across a post which you want to include in your FAQ, click on the administer link. Then click on the edit book outline button at the bottom of the page. Then place the relevant post wherever is most appropriate in your book by selecting a parent. Books are quite flexible. They can have sections like Flying to Estonia, Eating in Estonia and so on. As you get more experienced with the book module, you can reorganize posts in your book so that it stays organized.
Notes:
Finally, you may want to enter some initial comment scores. In administer » comments » initial comment scores 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 0 as the default.
", 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': +Finally, you may want to enter some initial comment scores. In administer » comments » initial comment scores 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 0 as the default.
", 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 administer » comments » moderation » thresholds 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 administer » comments » moderation » thresholds 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 new or updated comments to see your latest comments, or comment approval queue 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 \"edit comment\" and then change its moderation status to Approved.Finally, you may want to enter some initial comment scores. In administer » comments » initial comment scores 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 0 as the default.
", 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': +Finally, you may want to enter some initial comment scores. In administer » comments » initial comment scores 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 0 as the default.
", 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 administer » comments » moderation » thresholds 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 administer » comments » moderation » thresholds 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 new or updated comments to see your latest comments, or comment approval queue 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 \"edit comment\" and then change its moderation status to Approved.Drupal administrators should simply enable this feature to get listed on the Drupal sites page. Just set your site's name, e-mail address, slogan and mission statement on the site administration page. Then make sure that the field called Drupal XML-RPC server on the administer » configuration » modules » drupal page is set to %drupal-xml-rpc, and enable this feature using the dropdown directly below.
The listing of your site will occur shortly after your site's next cron run. Note that cron.php should be called using the domain name which you want to have listed at drupal.org. 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.
-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.
", 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': +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.
", 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 Drupal XML-RPC server setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the site configuration 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 Drupal XML-RPC server setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the site configuration 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("Drupal 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 Drupal ID.
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: username@server. An example of a valid Drupal ID is mwlily@www.drupal.org.
", array('%Drupal' => 'http://www.drupal.org', '%this-site' => ''. variable_get('site_name', 'this web site') .'')); @@ -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 site configuration.", array('%url' => url('admin/system')))); + $error['drupal_directory'] = theme('error', t("You must set your site's name at the site configuration.", 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 site configuration.", array('%url' => url('admin/system')))); + $error['drupal_directory'] = theme('error', t("You must set your site's e-mail address at the site configuration.", 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 site configuration.", array('%url' => url('admin/system')))); + $error['drupal_directory'] = theme('error', t("You must set your site's slogan at the site configuration.", 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 site configuration.", array('%url' => url('admin/system')))); + $error['drupal_directory'] = theme('error', t("You must set your site's mission at the site configuration.", 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 Drupal sites 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, $passwor } /** - * 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; } /** === modified file 'modules/drupal/drupal.module' --- modules/drupal/drupal.module 2004-06-02 19:01:40 +0000 +++ modules/drupal/drupal.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ Currently, the main application of this feature is the Drupal sites page. By default, fresh Drupal installations can use drupal.org as their directory server and report their existence. This reporting occurs via scheduled XML-RPC pings.Drupal administrators should simply enable this feature to get listed on the Drupal sites page. Just set your site's name, e-mail address, slogan and mission statement on the site administration page. Then make sure that the field called Drupal XML-RPC server on the administer » configuration » modules » drupal page is set to %drupal-xml-rpc, and enable this feature using the dropdown directly below.
The listing of your site will occur shortly after your site's next cron run. Note that cron.php should be called using the domain name which you want to have listed at drupal.org. 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.
-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.
", 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': +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.
", 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 Drupal XML-RPC server setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the site configuration 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 Drupal XML-RPC server setting -- but the directory server has to be able to handle Drupal XML. To get all your site information listed go to the site configuration 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("Drupal 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 Drupal ID.
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: username@server. An example of a valid Drupal ID is mwlily@www.drupal.org.
", array('%Drupal' => 'http://www.drupal.org', '%this-site' => ''. variable_get('site_name', 'this web site') .'')); @@ -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 site configuration.", array('%url' => url('admin/system')))); + $error['drupal_directory'] = theme('error', t("You must set your site's name at the site configuration.", 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 site configuration.", array('%url' => url('admin/system')))); + $error['drupal_directory'] = theme('error', t("You must set your site's e-mail address at the site configuration.", 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 site configuration.", array('%url' => url('admin/system')))); + $error['drupal_directory'] = theme('error', t("You must set your site's slogan at the site configuration.", 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 site configuration.", array('%url' => url('admin/system')))); + $error['drupal_directory'] = theme('error', t("You must set your site's mission at the site configuration.", 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 Drupal sites 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, $passwor } /** - * 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; } /** === modified file 'modules/filter.module' --- modules/filter.module 2004-06-15 18:02:52 +0000 +++ modules/filter.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 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. -If you notice some filters are causing conflicts in the output, you can rearrange them.
", array('%url' => url('admin/system/filters/order'))); - case 'admin/system/filters/order': +If you notice some filters are causing conflicts in the output, you can rearrange them.
", array('%url' => url('admin/filters/order'))); + case 'admin/filters/order': return t("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.
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.
"); @@ -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; } /** === modified file 'modules/filter/filter.module' --- modules/filter/filter.module 2004-06-15 18:02:52 +0000 +++ modules/filter/filter.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 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. -If you notice some filters are causing conflicts in the output, you can rearrange them.
", array('%url' => url('admin/system/filters/order'))); - case 'admin/system/filters/order': +If you notice some filters are causing conflicts in the output, you can rearrange them.
", array('%url' => url('admin/filters/order'))); + case 'admin/filters/order': return t("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.
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.
"); @@ -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; } /** === modified file 'modules/forum.module' --- modules/forum.module 2004-05-17 22:00:06 +0000 +++ modules/forum.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ When you are happy with your vocabulary, go to administer » configutation » modules » forum and set Forum vocabulary 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\" permission and to create a topic they must have the \"create forum topics\" permission. These permissions can be set in the permission pages.To disable icons, set the icon path as blank in administer » configutation » modules » forum.
-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.
", 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': +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.
", 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 created 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 block administration 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 block administration 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, $m $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, $m } 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, $m } /** + * 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 = 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 = } } 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, $t $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, $t $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 = 'To disable icons, set the icon path as blank in administer » configutation » modules » forum.
-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.
", 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': +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.
", 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 created 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 block administration 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 block administration 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, $m $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, $m } 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, $m } /** + * 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 = 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 = } } 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, $t $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, $t $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 = 'Now that you know what is in a node, here are some of the types of nodes available.
", array("%teaser" => url("admin/system/modules/node"))); +Now that you know what is in a node, here are some of the types of nodes available.
", array("%teaser" => url("admin/settings/node"))); if ($mod == 'admin') { foreach (node_list() as $type) { @@ -40,10 +40,10 @@ function node_help($section = 'admin/hel } 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/hel case 'admin/node/search': $output = t("Enter a simple pattern to search for a post. This can include the wildcard character *.The first thing you will need to do is create the first account. This account will have full administration rights and will allow you to configure your website. Once logged in, you can visit the administration section and set up your site's configuration.
Drupal comes with various modules, each of which contains a specific piece of functionality. You should visit the module list and enable those modules which suit your website's needs.
Themes handle the presentation of your website. You can use one of the existing themes, modify them or create your own from scratch.
-We suggest you look around the administration section and explore the various options Drupal offers you. For more information, you can refer to the Drupal handbook online.
", 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')); +We suggest you look around the administration section and explore the various options Drupal offers you. For more information, you can refer to the Drupal handbook online.
", 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))); === modified file 'modules/node/node.module' --- modules/node/node.module 2004-06-17 18:46:41 +0000 +++ modules/node/node.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ ScoreNow that you know what is in a node, here are some of the types of nodes available.
", array("%teaser" => url("admin/system/modules/node"))); +Now that you know what is in a node, here are some of the types of nodes available.
", array("%teaser" => url("admin/settings/node"))); if ($mod == 'admin') { foreach (node_list() as $type) { @@ -40,10 +40,10 @@ function node_help($section = 'admin/hel } 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/hel case 'admin/node/search': $output = t("Enter a simple pattern to search for a post. This can include the wildcard character *.The first thing you will need to do is create the first account. This account will have full administration rights and will allow you to configure your website. Once logged in, you can visit the administration section and set up your site's configuration.
Drupal comes with various modules, each of which contains a specific piece of functionality. You should visit the module list and enable those modules which suit your website's needs.
Themes handle the presentation of your website. You can use one of the existing themes, modify them or create your own from scratch.
-We suggest you look around the administration section and explore the various options Drupal offers you. For more information, you can refer to the Drupal handbook online.
", 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')); +We suggest you look around the administration section and explore the various options Drupal offers you. For more information, you can refer to the Drupal handbook online.
", 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))); === modified file 'modules/page.module' --- modules/page.module 2004-05-09 19:28:43 +0000 +++ modules/page.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ create pages: 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.maintain personal pages: 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.
"); - 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, $ma * * 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); } /** === modified file 'modules/page/page.module' --- modules/page/page.module 2004-05-09 19:28:43 +0000 +++ modules/page/page.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ create pages: 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.maintain personal pages: 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.
"); - 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, $ma * * 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); } /** === modified file 'modules/path.module' --- modules/path.module 2004-06-01 21:58:45 +0000 +++ modules/path.module 2004-06-18 15:04:33 +0000 @@ -1,12 +1,12 @@ store taxonomy/page/or/7,19,20,21 => store/products/whirlygigs -node/view/3 => contact +node/3 => contactThis functionality integrates seamlessly into node forms and also provides the administrator an interface to view all aliases that have been created.
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.
@@ -37,30 +37,41 @@ node/view/3 => contactfunction 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; } } }-
This function will shorten every node/view/\$node_id
type of URL to display/\$node_id
. 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 display/3
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 conf_url_rewrite
function.
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 news
section for example aliasing nodes and taxonomy overview pages falling under a 'news' vocabulary, thus having news/15
and news/sections/3
instead of node/view/15
and taxonomy/view/or/3
. You need extensive knowledge of Drupal's inner workings and regular expressions though to make such advanced aliases.
This function will shorten every node/\$node_id
type of URL to display/\$node_id
. 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 display/3
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 conf_url_rewrite
function.
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 news
section for example aliasing nodes and taxonomy overview pages falling under a 'news' vocabulary, thus having news/15
and news/sections/3
instead of node/15
and taxonomy/view/or/3
. You need extensive knowledge of Drupal's inner workings and regular expressions though to make such advanced aliases.
This functionality integrates seamlessly into node forms and also provides the administrator an interface to view all aliases that have been created.
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.
@@ -37,30 +37,41 @@ node/view/3 => contactfunction 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; } } }-
This function will shorten every node/view/\$node_id
type of URL to display/\$node_id
. 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 display/3
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 conf_url_rewrite
function.
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 news
section for example aliasing nodes and taxonomy overview pages falling under a 'news' vocabulary, thus having news/15
and news/sections/3
instead of node/view/15
and taxonomy/view/or/3
. You need extensive knowledge of Drupal's inner workings and regular expressions though to make such advanced aliases.
This function will shorten every node/\$node_id
type of URL to display/\$node_id
. 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 display/3
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 conf_url_rewrite
function.
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 news
section for example aliasing nodes and taxonomy overview pages falling under a 'news' vocabulary, thus having news/15
and news/sections/3
instead of node/15
and taxonomy/view/or/3
. You need extensive knowledge of Drupal's inner workings and regular expressions though to make such advanced aliases.
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.
The Poll 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.
", 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, $ma 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, $ma } /** + * 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 = '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.
The Poll 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.
", 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, $ma 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, $ma } /** + * 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 = 'profile_
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 profile_
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 %value
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 %value
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 i
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 .= 'profile_
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 profile_
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 %value
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 %value
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 i
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 .= '". 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.") ."
"; - - /* - ** Display a voting form: - */ - - $output .= form_select(t("Your vote"), "vote", "", $votes); - $output .= form_hidden("id", $node->nid); - $output .= form_submit(t("Vote")); + // Display some explanation or voting guidelines: + $output .= ''. 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.') .'
'; + + // 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]'.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.
Words excluded from the search -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.
", 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; +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.
", 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; +} - return $output; +/** + * 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); + + print theme('page', system_settings_form($output)); } /** - * perform a regularly run action across all modules that have the - * module_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 module_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"]; + $lno = $row['lno']; + $nid = $row['nid']; + $title = $row['title']; + $created = $row['created']; + $uid = $row['uid']; + $name = $row['name']; + $count = $row['count']; - // Build reduction variable + // 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; - - $results[$lno]["lno"] = $lno; - $results[$lno]["nid"] = $nid; - $results[$lno]["title"] = $title; - $results[$lno]["created"] = $created; - $results[$lno]["uid"] = $uid; - $results[$lno]["name"] = $name; + // 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; } 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 module_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_updateThe 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.
Words excluded from the search -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.
", 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; +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.
", 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; +} - return $output; +/** + * 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); + + print theme('page', system_settings_form($output)); } /** - * perform a regularly run action across all modules that have the - * module_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 module_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"]; + $lno = $row['lno']; + $nid = $row['nid']; + $title = $row['title']; + $created = $row['created']; + $uid = $row['uid']; + $name = $row['name']; + $count = $row['count']; - // Build reduction variable + // 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; - - $results[$lno]["lno"] = $lno; - $results[$lno]["nid"] = $nid; - $results[$lno]["title"] = $title; - $results[$lno]["created"] = $created; - $results[$lno]["uid"] = $uid; - $results[$lno]["name"] = $name; + // 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; } 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 module_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_updateIf 'administer statistics' and 'access statistics' are both enabled, the user will see a link from each node to that node's referrer statistics (if enabled).
", - 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 site statistics 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 = } } - 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_tabl $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, $d $content = node_load(array('nid' => $nid['nid'])); $links = link_node($content, 1); - $output .= 'If 'administer statistics' and 'access statistics' are both enabled, the user will see a link from each node to that node's referrer statistics (if enabled).
", - 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 site statistics 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 = } } - 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_tabl $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, $d $content = node_load(array('nid' => $nid['nid'])); $links = link_node($content, 1); - $output .= 'create stories: 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.
maintain personal stories: 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.
- ", 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, $m } /** + * 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. === modified file 'modules/story/story.module' --- modules/story/story.module 2004-05-08 07:17:47 +0000 +++ modules/story/story.module 2004-06-18 15:04:33 +0000 @@ -1,14 +1,14 @@ submit -> moderate -> post to the main page -> comments. 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) {create stories: 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.
maintain personal stories: 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.
- ", 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, $m } /** + * 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. === modified file 'modules/system.module' --- modules/system.module 2004-05-01 09:14:49 +0000 +++ modules/system.module 2004-06-18 15:04:33 +0000 @@ -1,22 +1,21 @@ permissions 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 throttle configuration page 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 permissions 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 throttle configuration page 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("Drupal comes with system-wide defaults but the setting-module provides control over many Drupal preferences, behaviours including visual and operational settings.
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.
@@ -27,75 +26,92 @@ function system_help($section = "admin/h00 * * * * /home/www/drupal/scripts/cron-lynx.shNote that it is essential to access
cron.php
using a browser on the web site's domain; do not run it using command line PHP and avoid using localhost
or 127.0.0.1
or some of the environment varibles will not be set correctly and features may not work as expected.
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.
", array("%base_url" => $base_url, "%cron-link" => "$base_url/cron.php", "%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; +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.
", array('%base_url' => $base_url, '%cron-link' => "$base_url/cron.php", '%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 = "\n"; + $options = '\n"; if (count($themes = list_themes()) > 1) { foreach ($themes as $key => $value) { - $options .= "\n"; + $options .= "\n"; } - $data[t('Theme settings')] = form_item(t("Theme"), "", t("Selecting a different theme will change the look and feel of the site.")); + $data[t('Theme settings')] = form_item(t('Theme'), "", 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 needModRewrite
support. See also the .htaccess
file in Drupal's top-level directory."));
+ $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 ModRewrite
support. See also the .htaccess
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);
+ $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 cache documentation 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 cache documentation 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));
}
?>
=== modified file 'modules/system/system.module'
--- modules/system/system.module 2004-05-01 09:14:49 +0000
+++ modules/system/system.module 2004-06-18 15:04:33 +0000
@@ -1,22 +1,21 @@
permissions 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 throttle configuration page 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 permissions 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 throttle configuration page 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("
Drupal comes with system-wide defaults but the setting-module provides control over many Drupal preferences, behaviours including visual and operational settings.
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.
@@ -27,75 +26,92 @@ function system_help($section = "admin/h00 * * * * /home/www/drupal/scripts/cron-lynx.shNote that it is essential to access
cron.php
using a browser on the web site's domain; do not run it using command line PHP and avoid using localhost
or 127.0.0.1
or some of the environment varibles will not be set correctly and features may not work as expected.
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.
", array("%base_url" => $base_url, "%cron-link" => "$base_url/cron.php", "%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; +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.
", array('%base_url' => $base_url, '%cron-link' => "$base_url/cron.php", '%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 = "\n"; + $options = '\n"; if (count($themes = list_themes()) > 1) { foreach ($themes as $key => $value) { - $options .= "\n"; + $options .= "\n"; } - $data[t('Theme settings')] = form_item(t("Theme"), "", t("Selecting a different theme will change the look and feel of the site.")); + $data[t('Theme settings')] = form_item(t('Theme'), "", 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 needModRewrite
support. See also the .htaccess
file in Drupal's top-level directory."));
+ $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 ModRewrite
support. See also the .htaccess
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);
+ $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 cache documentation 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 cache documentation 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));
}
?>
=== modified file 'modules/taxonomy.module'
--- modules/taxonomy.module 2004-06-17 18:10:05 +0000
+++ modules/taxonomy.module 2004-06-18 15:04:33 +0000
@@ -1,24 +1,27 @@
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 = NU
}
}
-/*
-** 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 related terms 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 tree-like hierarchy 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 must 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"]);
+ $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 related terms 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 tree-like hierarchy 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 must 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']);
}
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("Synonyms 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('Synonyms 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 .= "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 classification types and insight into the development of the taxonomy.module, see this drupal.org discussion.
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, taxonomy/page/or/1,2. Taxonomy URLs always contain one or more term IDs (tid) at the end of the URL (a.k.a the querystring). You may learn the term ID for a given term by hovering over that term in the taxonomy overview 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 or, which chooses nodes tagged with any of the given term IDs, or and, which chooses nodes tagged with all of the given Term IDs. Thus or is less specific than and. Finally add a comma seperated list of term IDs.
Every term, or collection of terms, provides an RSS feed to which interested users may subscribe. The URL format for a sample RSS feed is node/feed/or/1,2. Built like a Taxonomy URL, see above it starts with \"node/feed\", then has the querystring parameter, and finally the Term IDs.
", 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; +Every term, or collection of terms, provides an RSS feed to which interested users may subscribe. The URL format for a sample RSS feed is node/feed/or/1,2. Built like a Taxonomy URL, see above it starts with \"node/feed\", then has the querystring parameter, and finally the Term IDs.
", 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; } ?> === modified file 'modules/taxonomy/taxonomy.module' --- modules/taxonomy/taxonomy.module 2004-06-17 18:10:05 +0000 +++ modules/taxonomy/taxonomy.module 2004-06-18 15:04:33 +0000 @@ -1,24 +1,27 @@ 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 = NU } } -/* -** 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 related terms 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 tree-like hierarchy 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 must 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"]); + $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 related terms 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 tree-like hierarchy 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 must 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']); } 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("Synonyms 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('Synonyms 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 .= "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 classification types and insight into the development of the taxonomy.module, see this drupal.org discussion.
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, taxonomy/page/or/1,2. Taxonomy URLs always contain one or more term IDs (tid) at the end of the URL (a.k.a the querystring). You may learn the term ID for a given term by hovering over that term in the taxonomy overview 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 or, which chooses nodes tagged with any of the given term IDs, or and, which chooses nodes tagged with all of the given Term IDs. Thus or is less specific than and. Finally add a comma seperated list of term IDs.
Every term, or collection of terms, provides an RSS feed to which interested users may subscribe. The URL format for a sample RSS feed is node/feed/or/1,2. Built like a Taxonomy URL, see above it starts with \"node/feed\", then has the querystring parameter, and finally the Term IDs.
", 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; +Every term, or collection of terms, provides an RSS feed to which interested users may subscribe. The URL format for a sample RSS feed is node/feed/or/1,2. Built like a Taxonomy URL, see above it starts with \"node/feed\", then has the querystring parameter, and finally the Term IDs.
", 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; } ?> === modified file 'modules/throttle.module' --- modules/throttle.module 2004-06-02 19:01:40 +0000 +++ modules/throttle.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 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("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.
To disable distributed authentication, simply disable or remove all DA modules. For a virgin install, that means removing/disabling the jabber module and the drupal module.
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 ...
- %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')) { === modified file 'modules/user/user.module' --- modules/user/user.module 2004-06-14 17:32:51 +0000 +++ modules/user/user.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ $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 } return $block; case 1: - if ($menu = menu_tree()) { + if ($menu = theme('menu_tree')) { $block['subject'] = $user->uid ? $user->name : t('Navigation'); $block['content'] = ' '; } @@ -573,11 +573,6 @@ function theme_user_profile($account, $f foreach ($fields as $category => $value) { $output .= "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.
To disable distributed authentication, simply disable or remove all DA modules. For a virgin install, that means removing/disabling the jabber module and the drupal module.
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 ...
- %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')) { === modified file 'modules/watchdog.module' --- modules/watchdog.module 2004-06-01 11:01:26 +0000 +++ modules/watchdog.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 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 check the watchdog report on a regular basis as it is often the only way to tell what is going on. -To ease administration, the watchdog will automatically discard old log entries, as configured. Needs "cron.php" to discard the entries.
', array('%watchdog' => url('admin/logs'), '%log-entry' => url('admin/system/modules/watchdog'))); +To ease administration, the watchdog will automatically discard old log entries, as configured. Needs "cron.php" to discard the entries.
', 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 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 logs. 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; } /** === modified file 'modules/watchdog/watchdog.module' --- modules/watchdog/watchdog.module 2004-06-01 11:01:26 +0000 +++ modules/watchdog/watchdog.module 2004-06-18 15:04:33 +0000 @@ -1,5 +1,5 @@ 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 check the watchdog report on a regular basis as it is often the only way to tell what is going on. -To ease administration, the watchdog will automatically discard old log entries, as configured. Needs "cron.php" to discard the entries.
', array('%watchdog' => url('admin/logs'), '%log-entry' => url('admin/system/modules/watchdog'))); +To ease administration, the watchdog will automatically discard old log entries, as configured. Needs "cron.php" to discard the entries.
', 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 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 logs. 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; } /** === modified file 'themes/chameleon/chameleon.theme' --- themes/chameleon/chameleon.theme 2004-05-20 10:23:52 +0000 +++ themes/chameleon/chameleon.theme 2004-06-18 15:04:33 +0000 @@ -1,12 +1,12 @@ $title"; } + if ($tabs = theme('menu_local_tasks')) { + $output .= $tabs; + } + if ($help = menu_get_active_help()) { $output .= "$help