From c3b5d47edcd508bf861fbbea8a051cedefb4c7dc Mon Sep 17 00:00:00 2001 From: Nancy Nicoles Date: Fri, 28 Oct 2011 17:06:24 -0500 Subject: [PATCH] Issue #1313980 by jn2: Fixed node module documentation to Doxygen standards. --- core/modules/node/content_types.inc | 22 +- core/modules/node/node.admin.inc | 125 ++++++- core/modules/node/node.api.php | 42 +-- core/modules/node/node.install | 2 +- core/modules/node/node.module | 439 ++++++++++++++++------- core/modules/node/node.pages.inc | 127 ++++++- core/modules/node/node.test | 6 +- core/modules/node/tests/node_access_test.module | 14 +- 8 files changed, 582 insertions(+), 195 deletions(-) diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc index d58bc31..c76a5e2 100644 --- a/core/modules/node/content_types.inc +++ b/core/modules/node/content_types.inc @@ -6,7 +6,11 @@ */ /** - * Displays the content type admin overview page. + * Page callback: Displays the content type admin overview page. + * + * Path: admin/structure/types + * + * @see node_menu() */ function node_overview_types() { $types = node_type_get_types(); @@ -54,7 +58,7 @@ function node_overview_types() { } /** - * Returns HTML for a node type description for the content type admin overview page. + * Returns HTML for a node type description for the content type admin page. * * @param $variables * An associative array containing: @@ -409,7 +413,17 @@ function node_type_reset($type) { } /** - * Menu callback; delete a single content type. + * Page callback: Form constructor for the content type delete form. + * + * Path: admin/structure/types/manage/%node_type/delete + * + * @param $type + * Content type object. + * + * @return + * Form array for delete confirmation form. + * + * @see node_type_delete_confirm_submit() */ function node_type_delete_confirm($form, &$form_state, $type) { $form['type'] = array('#type' => 'value', '#value' => $type->type); @@ -429,7 +443,7 @@ function node_type_delete_confirm($form, &$form_state, $type) { } /** - * Process content type delete confirm submissions. + * Form submission handler for node_type_delete_confirm(). */ function node_type_delete_confirm_submit($form, &$form_state) { node_type_delete($form_state['values']['type']); diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index 8f46df4..b59d58b 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -6,7 +6,12 @@ */ /** - * Menu callback: confirm rebuilding of permissions. + * Page callback: Form constructor for the permission rebuild confirmation form. + * + * Path: admin/reports/status/rebuild + * + * @see node_menu() + * @see node_configure_rebuild_confirm_submit() */ function node_configure_rebuild_confirm() { return confirm_form(array(), t('Are you sure you want to rebuild the permissions on site content?'), @@ -14,7 +19,7 @@ function node_configure_rebuild_confirm() { } /** - * Handler for wipe confirmation + * Form submission handler for node_configure_rebuild_confirm(). */ function node_configure_rebuild_confirm_submit($form, &$form_state) { node_access_rebuild(TRUE); @@ -65,7 +70,10 @@ function node_node_operations() { } /** - * List node administration filters that can be applied. + * Lists node administration filters that can be applied. + * + * @return + * Associative array of filters. */ function node_filters() { // Regular filters @@ -110,7 +118,7 @@ function node_filters() { } /** - * Apply filters for node administration filters based on session. + * Applies filters for the node administration overview based on session. * * @param $query * A SelectQuery to which the filters should be applied. @@ -133,7 +141,15 @@ function node_build_filter_query(SelectQueryInterface $query) { } /** - * Return form for node administration filters. + * Returns the node administration filters form object to node_admin_content(). + * + * @see node_multiple_delete_confirm() + * @see node_multiple_delete_confirm_submit() + * @see node_admin_nodes() + * @see node_admin_nodes_submit() + * @see node_admin_nodes_validate() + * @see node_filter_form_submit() + * @ingroup forms */ function node_filter_form() { $session = isset($_SESSION['node_overview_filter']) ? $_SESSION['node_overview_filter'] : array(); @@ -208,7 +224,15 @@ function node_filter_form() { } /** - * Process result from node administration filter form. + * Form submission handler for node_filter_form(). + * + * @see node_admin_content() + * @see node_multiple_delete_confirm() + * @see node_multiple_delete_confirm_submit() + * @see node_admin_nodes() + * @see node_admin_nodes_submit() + * @see node_admin_nodes_validate() + * @see node_filter_form() */ function node_filter_form_submit($form, &$form_state) { $filters = node_filters(); @@ -237,18 +261,19 @@ function node_filter_form_submit($form, &$form_state) { } /** - * Make mass update of nodes, changing all nodes in the $nodes array - * to update them with the field values in $updates. + * Updates all nodes in the passed-in array with the passed-in field values. * * IMPORTANT NOTE: This function is intended to work when called - * from a form submit handler. Calling it outside of the form submission + * from a form submission handler. Calling it outside of the form submission * process may not work correctly. * * @param array $nodes * Array of node nids to update. * @param array $updates - * Array of key/value pairs with node field names and the - * value to update that field to. + * Array of key/value pairs with node field names and the value to update + * that field to. + * + * @ingroup batch */ function node_mass_update($nodes, $updates) { // We use batch processing to prevent timeout when updating a large number @@ -279,7 +304,14 @@ function node_mass_update($nodes, $updates) { } /** - * Node Mass Update - helper function. + * Updates individual nodes when fewer than 10 are queued. + * + * @param $nid + * ID of node to update. + * @param $updates + * Associative array of updates. + * + * @see node_mass_update() */ function _node_mass_update_helper($nid, $updates) { $node = node_load($nid, NULL, TRUE); @@ -293,7 +325,7 @@ function _node_mass_update_helper($nid, $updates) { } /** - * Node Mass Update Batch operation + * Executes a batch operation for node_mass_update(). */ function _node_mass_update_batch_process($nodes, $updates, &$context) { if (!isset($context['sandbox']['progress'])) { @@ -324,7 +356,7 @@ function _node_mass_update_batch_process($nodes, $updates, &$context) { } /** - * Node Mass Update Batch 'finished' callback. + * Reports the 'finished' status of batch operation for node_mass_update(). */ function _node_mass_update_batch_finished($success, $results, $operations) { if ($success) { @@ -339,7 +371,18 @@ function _node_mass_update_batch_finished($success, $results, $operations) { } /** - * Menu callback: content administration. + * Page callback: Form constructor for the content administration form. + * + * Path: admin/content + * + * @see node_multiple_delete_confirm() + * @see node_multiple_delete_confirm_submit() + * @see node_admin_nodes() + * @see node_admin_nodes_submit() + * @see node_admin_nodes_validate() + * @see node_filter_form() + * @see node_filter_form_submit() + * @see node_menu() */ function node_admin_content($form, $form_state) { if (isset($form_state['values']['operation']) && $form_state['values']['operation'] == 'delete') { @@ -353,7 +396,15 @@ function node_admin_content($form, $form_state) { } /** - * Form builder: Builds the node administration overview. + * Returns the admin form object to node_admin_content(). + * + * @see node_multiple_delete_confirm() + * @see node_multiple_delete_confirm_submit() + * @see node_admin_nodes_submit() + * @see node_admin_nodes_validate() + * @see node_filter_form() + * @see node_filter_form_submit() + * @ingroup forms */ function node_admin_nodes() { $admin_access = user_access('administer nodes'); @@ -521,10 +572,17 @@ function node_admin_nodes() { } /** - * Validate node_admin_nodes form submissions. + * Form validation handler for node_admin_nodes(). * - * Check if any nodes have been selected to perform the chosen + * Checks if any nodes have been selected to perform the chosen * 'Update option' on. + * + * @see node_multiple_delete_confirm() + * @see node_multiple_delete_confirm_submit() + * @see node_admin_nodes() + * @see node_admin_nodes_submit() + * @see node_filter_form() + * @see node_filter_form_submit() */ function node_admin_nodes_validate($form, &$form_state) { // Error if there are no items to select. @@ -534,9 +592,16 @@ function node_admin_nodes_validate($form, &$form_state) { } /** - * Process node_admin_nodes form submissions. + * Form submission handler for node_admin_nodes(). + * + * Executes the chosen 'Update option' on the selected nodes. * - * Execute the chosen 'Update option' on the selected nodes. + * @see node_multiple_delete_confirm() + * @see node_multiple_delete_confirm_submit() + * @see node_admin_nodes() + * @see node_admin_nodes_validate() + * @see node_filter_form() + * @see node_filter_form_submit() */ function node_admin_nodes_submit($form, &$form_state) { $operations = module_invoke_all('node_operations'); @@ -562,6 +627,16 @@ function node_admin_nodes_submit($form, &$form_state) { } } +/** + * Multiple node deletion confirmation form for node_admin_content(). + * + * @see node_multiple_delete_confirm_submit() + * @see node_admin_nodes() + * @see node_admin_nodes_submit() + * @see node_admin_nodes_validate() + * @see node_filter_form() + * @see node_filter_form_submit() + */ function node_multiple_delete_confirm($form, &$form_state, $nodes) { $form['nodes'] = array('#prefix' => '', '#tree' => TRUE); // array_filter returns only elements with TRUE values @@ -585,6 +660,16 @@ function node_multiple_delete_confirm($form, &$form_state, $nodes) { t('Delete'), t('Cancel')); } +/** + * Form submission handler for node_multiple_delete_confirm(). + * + * @see node_multiple_delete_confirm() + * @see node_admin_nodes() + * @see node_admin_nodes_submit() + * @see node_admin_nodes_validate() + * @see node_filter_form() + * @see node_filter_form_submit() + */ function node_multiple_delete_confirm_submit($form, &$form_state) { if ($form_state['values']['confirm']) { node_delete_multiple(array_keys($form_state['values']['nodes'])); diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index 66eb26a..d526c48 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -177,9 +177,6 @@ * sure to restore your {node_access} record after node_access_rebuild() is * called. * - * @see node_access_view_all_nodes() - * @see node_access_rebuild() - * * @param $account * The user object whose grants are requested. * @param $op @@ -191,6 +188,8 @@ * * For a detailed example, see node_access_example.module. * + * @see node_access_view_all_nodes() + * @see node_access_rebuild() * @ingroup node_access */ function hook_node_grants($account, $op) { @@ -252,14 +251,13 @@ function hook_node_grants($account, $op) { * * Note: a deny all grant is not written to the database; denies are implicit. * - * @see _node_access_write_grants() - * * @param $node * The node that has just been saved. * * @return * An array of grants as defined above. * + * @see _node_access_write_grants() * @ingroup node_access */ function hook_node_access_records($node) { @@ -304,8 +302,6 @@ function hook_node_access_records($node) { * modules to modify the $grants array by reference before it is stored, so * custom or advanced business logic can be applied. * - * @see hook_node_access_records() - * * Upon viewing, editing or deleting a node, hook_node_grants() builds a * permissions array that is compared against the stored access records. The * user must have one or more matching permissions in order to complete the @@ -313,9 +309,6 @@ function hook_node_access_records($node) { * * A module may deny all access to a node by setting $grants to an empty array. * - * @see hook_node_grants() - * @see hook_node_grants_alter() - * * @param $grants * The $grants array returned by hook_node_access_records(). * @param $node @@ -325,6 +318,9 @@ function hook_node_access_records($node) { * access modules with a configurable behavior, as shown in the example with the * 'is_preview' field. * + * @see hook_node_access_records() + * @see hook_node_grants() + * @see hook_node_grants_alter() * @ingroup node_access */ function hook_node_access_records_alter(&$grants, $node) { @@ -351,15 +347,15 @@ function hook_node_access_records_alter(&$grants, $node) { * multiple node access modules can be altered or advanced business logic can be * applied. * - * @see hook_node_grants() - * * The resulting grants are then checked against the records stored in the * {node_access} table to determine if the operation may be completed. * * A module may deny all access to a user by setting $grants to an empty array. * - * @see hook_node_access_records() - * @see hook_node_access_records_alter() + * Developers may use this hook to either add additional grants to a user + * or to remove existing grants. These rules are typically based on either the + * permissions assigned to a user role, or specific attributes of a user + * account. * * @param $grants * The $grants array returned by hook_node_grants(). @@ -368,11 +364,9 @@ function hook_node_access_records_alter(&$grants, $node) { * @param $op * The operation being performed, 'view', 'update' or 'delete'. * - * Developers may use this hook to either add additional grants to a user - * or to remove existing grants. These rules are typically based on either the - * permissions assigned to a user role, or specific attributes of a user - * account. - * + * @see hook_node_grants() + * @see hook_node_access_records() + * @see hook_node_access_records_alter() * @ingroup node_access */ function hook_node_grants_alter(&$grants, $account, $op) { @@ -549,7 +543,7 @@ function hook_node_load($nodes, $types) { } /** - * Control access to a node. + * Controls access to a node. * * Modules may implement this hook if they want to have a say in whether or not * a given user has access to perform a given operation on a node. @@ -785,9 +779,6 @@ function hook_node_submit($node, $form, &$form_state) { * the RSS item generated for this node. * For details on how this is used, see node_feed(). * - * @see forum_node_view() - * @see comment_node_view() - * * @param $node * The node that is being assembled for rendering. * @param $view_mode @@ -795,6 +786,8 @@ function hook_node_submit($node, $form, &$form_state) { * @param $langcode * The language code used for rendering. * + * @see forum_node_view() + * @see comment_node_view() * @see hook_entity_view() * * @ingroup node_api_hooks @@ -1231,8 +1224,9 @@ function hook_validate($node, $form, &$form_state) { * The node to be displayed, as returned by node_load(). * @param $view_mode * View mode, e.g. 'full', 'teaser', ... + * * @return - * $node. The passed $node parameter should be modified as necessary and + * The passed $node parameter should be modified as necessary and * returned so it can be properly presented. Nodes are prepared for display * by assembling a structured array, formatted as in the Form API, in * $node->content. As with Form API arrays, the #weight property can be diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 3f732a4..a6d0b7a 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -444,7 +444,7 @@ function node_install() { } /** - * Utility function: fetch the node types directly from the database. + * Fetches node types directly from the database. * * @ingroup update-api-7.x-to-8.x */ diff --git a/core/modules/node/node.module b/core/modules/node/node.module index c429fe5..6def162 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -2,60 +2,72 @@ /** * @file - * The core that allows content to be submitted to the site. Modules and - * scripts may programmatically submit nodes using the usual form API pattern. + * The core module that allows content to be submitted to the site. + * + * Modules and scripts may programmatically submit nodes using the usual form + * API pattern. */ /** - * Node is not published. + * Denotes that the node is not published. */ define('NODE_NOT_PUBLISHED', 0); /** - * Node is published. + * Denotes that the node is published. */ define('NODE_PUBLISHED', 1); /** - * Node is not promoted to front page. + * Denotes that the node is not promoted to the front page. */ define('NODE_NOT_PROMOTED', 0); /** - * Node is promoted to front page. + * Denotes that the node is promoted to the front page. */ define('NODE_PROMOTED', 1); /** - * Node is not sticky at top of the page. + * Denotes that the node is not sticky at the top of the page. */ define('NODE_NOT_STICKY', 0); /** - * Node is sticky at top of the page. + * Denotes that the node is sticky at the top of the page. */ define('NODE_STICKY', 1); /** - * Nodes changed before this time are always marked as read. + * Denotes the time cutoff for nodes marked as read. * - * Nodes changed after this time may be marked new, updated, or read, depending - * on their state for the current user. Defaults to 30 days ago. + * Nodes changed before this time are always marked as read. Nodes changed after + * this time may be marked new, updated, or read, depending on their state for + * the current user. Defaults to 30 days ago. */ define('NODE_NEW_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60); /** - * Modules should return this value from hook_node_access() to allow access to a node. + * Denotes that access is allowed for a node. + * + * Modules should return this value from hook_node_access() to allow access to a + * node. */ define('NODE_ACCESS_ALLOW', 'allow'); /** - * Modules should return this value from hook_node_access() to deny access to a node. + * Denotes that access is denied for a node. + * + * Modules should return this value from hook_node_access() to deny access to a + * node. */ define('NODE_ACCESS_DENY', 'deny'); /** - * Modules should return this value from hook_node_access() to not affect node access. + * Denotes that access is unaffected for a node. + * + * Modules should return this value from hook_node_access() to indicate no + * effect on node access. */ define('NODE_ACCESS_IGNORE', NULL); @@ -277,7 +289,7 @@ function node_admin_paths() { * field is available, a title attribute will be added to show the number of * comments. * @param $title - * A heading for the resulting list. + * (optional) A heading for the resulting list. * * @return * A renderable array containing a list of linked node titles fetched from @@ -295,7 +307,7 @@ function node_title_list($result, $title = NULL) { } /** - * Update the 'last viewed' timestamp of the specified node for current user. + * Updates the 'last viewed' timestamp of the specified node for current user. * * @param $node * A node object. @@ -314,8 +326,7 @@ function node_tag_new($node) { } /** - * Retrieves the timestamp at which the current user last viewed the - * specified node. + * Retrieves the timestamp for the current user's last view of a specified node. */ function node_last_viewed($nid) { global $user; @@ -329,12 +340,13 @@ function node_last_viewed($nid) { } /** - * Decide on the type of marker to be displayed for a given node. + * Decides on the type of marker to be displayed for a given node. * * @param $nid * Node ID whose history supplies the "last viewed" timestamp. * @param $timestamp * Time which is compared against node's "last viewed" timestamp. + * * @return * One of the MARK constants. */ @@ -358,7 +370,7 @@ function node_mark($nid, $timestamp) { } /** - * Extract the type name. + * Extracts the type name. * * @param $node * Either a string or object, containing the node type information. @@ -466,7 +478,7 @@ function node_types_rebuild() { } /** - * Menu argument loader: loads a node type by string. + * Menu argument loader: Loads a node type by string. * * @param $name * The machine-readable name of a node type to load, where '_' is replaced @@ -539,12 +551,12 @@ function node_type_save($info) { } /** - * Add default body field to a node type. + * Adds the default body field to a node type. * * @param $type * A node type object. * @param $label - * The label for the body instance. + * (optional) The label for the body instance. * * @return * Body field instance. @@ -654,6 +666,7 @@ function node_type_update_nodes($old_type, $type) { * * @param $rebuild * TRUE to rebuild node types. Equivalent to calling node_types_rebuild(). + * * @return * Associative array with two components: * - names: Associative array of the names of node types, keyed by the type. @@ -760,8 +773,8 @@ function node_type_cache_reset() { * which prevents users from changing the machine name of the type. * * @param $info - * An object or array containing values to override the defaults. See - * hook_node_info() for details on what the array elements mean. + * (optional) An object or array containing values to override the defaults. + * See hook_node_info() for details on what the array elements mean. * * @return * A node type object, with missing values in $info set to their defaults. @@ -844,12 +857,13 @@ function node_rdf_mapping() { } /** - * Determine whether a node hook exists. + * Determines whether a node hook exists. * * @param $node * A node object or a string containing the node type. * @param $hook * A string containing the name of the hook. + * * @return * TRUE if the $hook exists in the node type of $node. */ @@ -859,7 +873,7 @@ function node_hook($node, $hook) { } /** - * Invoke a node hook. + * Invokes a node hook. * * @param $node * A node object or a string containing the node type. @@ -867,6 +881,7 @@ function node_hook($node, $hook) { * A string containing the name of the hook. * @param $a2, $a3, $a4 * Arguments to pass on to the hook, after the $node argument. + * * @return * The returned value of the invoked hook. */ @@ -879,17 +894,14 @@ function node_invoke($node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) { } /** - * Load node entities from the database. + * Loads node entities from the database. * * This function should be used whenever you need to load more than one node * from the database. Nodes are loaded into memory and will not require * database access if loaded again during the same page request. * - * @see entity_load() - * @see EntityFieldQuery - * * @param $nids - * An array of node IDs. + * (optional) An array of node IDs. * @param $conditions * (deprecated) An associative array of conditions on the {node} * table, where the keys are the database fields and the values are the @@ -897,26 +909,29 @@ function node_invoke($node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) { * EntityFieldQuery to retrieve a list of entity IDs loadable by * this function. * @param $reset - * Whether to reset the internal node_load cache. + * (optional) Whether to reset the internal node_load() cache. * * @return * An array of node objects indexed by nid. * * @todo Remove $conditions in Drupal 8. + * + * @see entity_load() + * @see EntityFieldQuery */ function node_load_multiple($nids = array(), $conditions = array(), $reset = FALSE) { return entity_load('node', $nids, $conditions, $reset); } /** - * Load a node object from the database. + * Loads a node object from the database. * * @param $nid - * The node ID. + * (optional) The node ID. * @param $vid - * The revision ID. + * (optional) The revision ID. * @param $reset - * Whether to reset the node_load_multiple cache. + * (optional) Whether to reset the node_load_multiple() cache. * * @return * A fully-populated node object. @@ -933,6 +948,9 @@ function node_load($nid = NULL, $vid = NULL, $reset = FALSE) { * * Fills in a few default values, and then invokes hook_prepare() on the node * type module, and hook_node_prepare() on all modules. + * + * @param $node + * The node object. */ function node_object_prepare($node) { // Set up default values, if required. @@ -962,7 +980,9 @@ function node_object_prepare($node) { } /** - * Perform validation checks on the given node. + * Performs validation checks on the given node. + * + * @see node_form_validate() */ function node_validate($node, $form, &$form_state) { $type = node_type_get_type($node); @@ -999,7 +1019,7 @@ function node_validate($node, $form, &$form_state) { } /** - * Prepare node for saving by populating author and creation date. + * Prepares a node for saving by populating the author and creation date. */ function node_submit($node) { global $user; @@ -1022,7 +1042,7 @@ function node_submit($node) { } /** - * Save changes to a node or add a new node. + * Saves changes to a node or adds a new node. * * @param $node * The $node object to be saved. If $node->nid is @@ -1157,9 +1177,21 @@ function node_save($node) { } /** - * Helper function to save a revision with the uid of the current user. + * Saves a revision with the ID of the current user. * * The resulting revision ID is available afterward in $node->vid. + * + * @param $node + * The node object to be processed. + * @param $uid + * User ID of the current user. + * @param $update + * (optional) To indicate that this is a new record to be inserted, omit this + * argument. If this is an update, this argument specifies the primary keys' + * field names. If there is only 1 field in the key, you may pass in a string; + * if there are multiple fields in the key, pass in an array. + * + * @see node_save() */ function _node_save_revision($node, $uid, $update = NULL) { $temp_uid = $node->uid; @@ -1175,7 +1207,7 @@ function _node_save_revision($node, $uid, $update = NULL) { } /** - * Delete a node. + * Deletes a node. * * @param $nid * A node ID. @@ -1185,7 +1217,7 @@ function node_delete($nid) { } /** - * Delete multiple nodes. + * Deletes multiple nodes. * * @param $nids * An array of node IDs. @@ -1238,10 +1270,13 @@ function node_delete_multiple($nids) { } /** - * Delete a node revision. + * Deletes a node revision. * * @param $revision_id * The revision ID to delete. + * + * @return + * TRUE if the revision deletion was successful. */ function node_revision_delete($revision_id) { if ($revision = node_load(NULL, $revision_id)) { @@ -1263,12 +1298,12 @@ function node_revision_delete($revision_id) { } /** - * Generate an array for rendering the given node. + * Generates an array for rendering the given node. * * @param $node * A node object. * @param $view_mode - * View mode, e.g. 'full', 'teaser'... + * (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'full.' * @param $langcode * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. @@ -1333,7 +1368,7 @@ function node_view($node, $view_mode = 'full', $langcode = NULL) { * @param $node * A node object. * @param $view_mode - * View mode, e.g. 'full', 'teaser'... + * (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'full.' * @param $langcode * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. @@ -1389,14 +1424,20 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) { } /** - * Generate an array which displays a node detail page. + * Page callback: Generates an array which displays a node detail page. + * + * Path: node/%node/revisions/%/view * * @param $node * A node object. * @param $message - * A flag which sets a page title relevant to the revision being viewed. + * (optional) A flag which sets a page title relevant to the revision being + * viewed. + * * @return * A $page element suitable for use by drupal_page_render(). + * + * @see node_menu() */ function node_show($node, $message = FALSE) { if ($message) { @@ -1413,10 +1454,13 @@ function node_show($node, $message = FALSE) { } /** - * Returns whether the current page is the full page view of the passed-in node. + * Checks whether the current page is the full page view of the passed-in node. * * @param $node * A node object. + * + * @return + * The ID of the node if this is a full page view, otherwise FALSE. */ function node_is_page($node) { $page_node = menu_get_object(); @@ -1424,16 +1468,17 @@ function node_is_page($node) { } /** - * Process variables for node.tpl.php + * Processes variables for node.tpl.php. * * Most themes utilize their own copy of node.tpl.php. The default is located * inside "modules/node/node.tpl.php". Look in there for the full list of * variables. * - * The $variables array contains the following arguments: - * - $node - * - $view_mode - * - $page + * @param $variables + * An array containing the following arguments: + * - $node + * - $view_mode + * - $page * * @see node.tpl.php */ @@ -1549,7 +1594,7 @@ function node_permission() { } /** - * Gather the rankings from the the hook_ranking implementations. + * Gathers the rankings from the the hook_ranking implementations. * * @param $query * A query object that has been extended with the Search DB Extender. @@ -1796,6 +1841,7 @@ function node_user_delete($account) { * An associative array containing: * - form: A render element representing the form. * + * @see node_search_admin() * @ingroup themeable */ function theme_node_search_admin($variables) { @@ -1817,6 +1863,25 @@ function theme_node_search_admin($variables) { return $output; } +/** + * Access callback: Checks node revision access. + * + * Paths: + * - node/%node/revisions + * - node/%node/revisions/%/view + * - node/%node/revisions/%/revert + * - node/%node/revisions/%/delete + * + * @param $node + * The node to check. + * @param $op + * (optional) The specific operation being checked. Defaults to 'view.' + * + * @return + * Access status for the revision. + * + * @see node_menu() + */ function _node_revision_access($node, $op = 'view') { $access = &drupal_static(__FUNCTION__, array()); if (!isset($access[$node->vid])) { @@ -1832,7 +1897,7 @@ function _node_revision_access($node, $op = 'view') { $is_current_revision = $node_current_revision->vid == $node->vid; // There should be at least two revisions. If the vid of the given node - // and the vid of the current revision differs, then we already have two + // and the vid of the current revision differ, then we already have two // different revisions so there is no need for a separate database check. // Also, if you try to revert to or delete the current revision, that's // not good. @@ -1851,6 +1916,16 @@ function _node_revision_access($node, $op = 'view') { return $access[$node->vid]; } +/** + * Access callback: Checks whether the user has permission to add a node. + * + * Paths: node/add + * + * @return + * TRUE if the user has permission, otherwise FALSE. + * + * @see node_menu() + */ function _node_add_access() { $types = node_type_get_types(); foreach ($types as $type) { @@ -1956,8 +2031,8 @@ function node_menu() { 'type' => MENU_CALLBACK, ); // @todo Remove this loop when we have a 'description callback' property. - // Reset internal static cache of _node_types_build(), forces to rebuild the - // node type information. + // Resets the internal static cache of _node_types_build() and forces a + // rebuild of the node type information. node_type_cache_reset(); foreach (node_type_get_types() as $type) { $type_url_str = str_replace('_', '-', $type->type); @@ -2065,14 +2140,28 @@ function node_menu_local_tasks_alter(&$data, $router_item, $root_path) { } /** - * Title callback for a node type. + * Title callback: Provides the title for a node type edit form. + * + * Path: admin/structure/types/manage/%node_type + * + * @param $type + * The node type object. + * + * @see node_menu() */ function node_type_page_title($type) { return $type->name; } /** - * Title callback. + * Title callback: Displays the node's title. + * + * Path: node/%node + * + * @param $node + * The node object. + * + * @see node_menu() */ function node_page_title($node) { return $node->title; @@ -2092,7 +2181,7 @@ function node_last_changed($nid) { } /** - * Return a list of all the existing revision numbers. + * Returns a list of all the existing revision numbers for the node passed in. */ function node_revision_list($node) { $revisions = array(); @@ -2281,7 +2370,7 @@ function theme_node_recent_content($variables) { } /** - * Implements hook_form_FORMID_alter(). + * Implements hook_form_FORM_ID_alter(). * * Adds node-type specific visibility options to add block form. * @@ -2292,10 +2381,11 @@ function node_form_block_add_block_form_alter(&$form, &$form_state) { } /** - * Implements hook_form_FORMID_alter(). + * Implements hook_form_FORM_ID_alter(). * * Adds node-type specific visibility options to block configuration form. * + * @see node_form_block_admin_configure_submit() * @see block_admin_configure() */ function node_form_block_admin_configure_alter(&$form, &$form_state) { @@ -2322,9 +2412,7 @@ function node_form_block_admin_configure_alter(&$form, &$form_state) { } /** - * Form submit handler for block configuration form. - * - * @see node_form_block_admin_configure_alter() + * Form submission handler for node_form_block_admin_configure_alter(). */ function node_form_block_admin_configure_submit($form, &$form_state) { db_delete('block_node_type') @@ -2343,10 +2431,11 @@ function node_form_block_admin_configure_submit($form, &$form_state) { } /** - * Implements hook_form_FORMID_alter(). + * Implements hook_form_FORM_ID_alter(). * * Adds node specific submit handler to delete custom block form. * + * @see node_form_block_custom_block_delete_submit() * @see block_custom_block_delete() */ function node_form_block_custom_block_delete_alter(&$form, &$form_state) { @@ -2354,9 +2443,7 @@ function node_form_block_custom_block_delete_alter(&$form, &$form_state) { } /** - * Form submit handler for custom block delete form. - * - * @see node_form_block_custom_block_delete_alter() + * Form submission handler for node_form_block_custom_block_delete_alter(). */ function node_form_block_custom_block_delete_submit($form, &$form_state) { db_delete('block_node_type') @@ -2368,7 +2455,7 @@ function node_form_block_custom_block_delete_submit($form, &$form_state) { /** * Implements hook_modules_uninstalled(). * - * Cleanup {block_node_type} table from modules' blocks. + * Cleans up the {block_node_type} table from modules' blocks. */ function node_modules_uninstalled($modules) { db_delete('block_node_type') @@ -2379,8 +2466,8 @@ function node_modules_uninstalled($modules) { /** * Implements hook_block_list_alter(). * - * Check the content type specific visibilty settings. - * Remove the block if the visibility conditions are not met. + * Checks the content type specific visibility settings and removes the block + * if the visibility conditions are not met. */ function node_block_list_alter(&$blocks) { global $theme_key; @@ -2433,20 +2520,25 @@ function node_block_list_alter(&$blocks) { } /** - * Generates and prints an RSS feed. + * Page callback: Generates and prints an RSS feed. + * + * Path: rss.xml * * Generates an RSS feed from an array of node IDs, and prints it with an HTTP * header, with Content Type set to RSS/XML. * * @param $nids - * An array of node IDs (nid). Defaults to FALSE so empty feeds can be - * generated with passing an empty array, if no items are to be added + * (optional) An array of node IDs (nid). Defaults to FALSE so empty feeds can + * be generated with passing an empty array, if no items are to be added * to the feed. * @param $channel - * An associative array containing title, link, description and other keys, - * to be parsed by format_rss_channel() and format_xml_elements(). - * A list of channel elements can be found at the @link http://cyber.law.harvard.edu/rss/rss.html RSS 2.0 Specification. @endlink + * (optional) An associative array containing 'title', 'link', 'description', + * and other keys, to be parsed by format_rss_channel() and + * format_xml_elements(). A list of channel elements can be found at the + * @link http://cyber.law.harvard.edu/rss/rss.html RSS 2.0 Specification. @endlink * The link should be an absolute URL. + * + * @see node_menu() */ function node_feed($nids = FALSE, $channel = array()) { global $base_url, $language_content; @@ -2519,14 +2611,14 @@ function node_feed($nids = FALSE, $channel = array()) { } /** - * Construct a drupal_render() style array from an array of loaded nodes. + * Constructs a drupal_render() style array from an array of loaded nodes. * * @param $nodes * An array of nodes as returned by node_load_multiple(). * @param $view_mode - * View mode, e.g. 'full', 'teaser'... + * (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'teaser.' * @param $weight - * An integer representing the weight of the first node in the list. + * (optional) Integer representing the weight of the first node in the list. * @param $langcode * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. @@ -2548,7 +2640,11 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcod } /** - * Menu callback; Generate a listing of promoted nodes. + * Page callback: Generates a listing of promoted nodes. + * + * Path: node + * + * @see node_menu() */ function node_page_default() { $select = db_select('node', 'n') @@ -2598,7 +2694,14 @@ function node_page_default() { } /** - * Menu callback; view a single node. + * Page callback: Displays a single node. + * + * Path: node/%node + * + * @param $node + * The node object. + * + * @see node_menu() */ function node_page_view($node) { // If there is a menu link to this node, the link becomes the last part @@ -2627,7 +2730,7 @@ function node_update_index() { } /** - * Index a single node. + * Indexes a single node. * * @param $node * The node to index. @@ -2658,6 +2761,8 @@ function _node_index_node($node) { /** * Implements hook_form_FORM_ID_alter(). + * + * @see node_search_validate() */ function node_form_search_form_alter(&$form, $form_state) { if (isset($form['module']) && $form['module']['#value'] == 'node' && user_access('use advanced search')) { @@ -2731,7 +2836,7 @@ function node_form_search_form_alter(&$form, $form_state) { } /** - * Form API callback for the search form. Registered in node_form_alter(). + * Form validation handler for node_form_search_form_alter(). */ function node_search_validate($form, &$form_state) { // Initialize using any existing basic search keywords. @@ -2817,8 +2922,13 @@ function node_search_validate($form, &$form_state) { */ /** - * Determine whether the current user may perform the given operation on the - * specified node. + * Access callback: Checks a user's permission for performing a node operation. + * + * Paths: + * - node/%node + * - node/%node/edit + * - node/%node/delete + * - 'node/add/' . $type_url_str (part of foreach) * * @param $op * The operation to be performed on the node. Possible values are: @@ -2827,13 +2937,16 @@ function node_search_validate($form, &$form_state) { * - "delete" * - "create" * @param $node - * The node object on which the operation is to be performed, or node type - * (e.g. 'forum') for "create" operation. + * The node object on which the operation is to be performed, or the node type + * (e.g., 'forum') for the 'create' operation. * @param $account - * Optional, a user object representing the user for whom the operation is to + * (optional) A user object representing the user for whom the operation is to * be performed. Determines access for a user other than the current user. + * * @return * TRUE if the operation may be performed, FALSE otherwise. + * + * @see node_menu() */ function node_access($op, $node, $account = NULL) { $rights = &drupal_static(__FUNCTION__, array()); @@ -2964,6 +3077,7 @@ function node_node_access($node, $op, $account) { * * @param $type * The machine-readable name of the node type. + * * @return array * An array of permission names and descriptions. */ @@ -3021,7 +3135,7 @@ function node_permissions_get_configured_types() { } /** - * Fetch an array of permission IDs granted to the given user ID. + * Fetches an array of permission IDs granted to the given user ID. * * The implementation here provides only the universal "all" grant. A node * access module should implement hook_node_grants() to provide a grant @@ -3034,8 +3148,9 @@ function node_permissions_get_configured_types() { * @param $op * The operation that the user is trying to perform. * @param $account - * The user object for the user performing the operation. If omitted, the - * current user is used. + * (optional) The user object for the user performing the operation. If + * omitted, the current user is used. + * * @return * An associative array in which the keys are realms, and the values are * arrays of grants for those realms. @@ -3067,8 +3182,8 @@ function node_access_grants($op, $account = NULL) { * added to the query. * * @param $account - * The user object for the user whose access is being checked. If omitted, - * the current user is used. + * (optional) The user object for the user whose access is being checked. If + * omitted, the current user is used. * * @return * TRUE if 'view' access to all nodes is granted, FALSE otherwise. @@ -3323,10 +3438,9 @@ function _node_query_node_access_alter($query, $type) { * * @param $node * The $node to acquire grants for. - * * @param $delete - * Whether to delete existing node access records before inserting new ones. - * Defaults to TRUE. + * (optional) Whether to delete existing node access records before inserting + * new ones. Defaults to TRUE. */ function node_access_acquire_grants($node, $delete = TRUE) { $grants = module_invoke_all('node_access_records', $node); @@ -3360,10 +3474,11 @@ function node_access_acquire_grants($node, $delete = TRUE) { * is a module-defined id to define grant privileges. each grant_* field * is a boolean value. * @param $realm - * If provided, only read/write grants for that realm. + * (optional) If provided, read/write grants for that realm only. * @param $delete - * If false, do not delete records. This is only for optimization purposes, - * and assumes the caller has already performed a mass delete of some form. + * (optional) If false, does not delete records. This is only for optimization + * purposes, and assumes the caller has already performed a mass delete of + * some form. */ function _node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE) { if ($delete) { @@ -3392,8 +3507,7 @@ function _node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE } /** - * Flag / unflag the node access grants for rebuilding, or read the current - * value of the flag. + * Toggles or reads the value of a flag for rebuilding the node access grants. * * When the flag is set, a message is displayed to users with 'access * administration pages' permission, pointing to the 'rebuild' confirm form. @@ -3404,9 +3518,10 @@ function _node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE * should be used instead. * * @param $rebuild - * (Optional) The boolean value to be written. - * @return - * (If no value was provided for $rebuild) The current value of the flag. + * (optional) The boolean value to be written. + * + * @return + * The current value of the flag if no value was provided for $rebuild. */ function node_access_needs_rebuild($rebuild = NULL) { if (!isset($rebuild)) { @@ -3421,26 +3536,25 @@ function node_access_needs_rebuild($rebuild = NULL) { } /** - * Rebuild the node access database. This is occasionally needed by modules - * that make system-wide changes to access levels. + * Rebuilds the node access database. * - * When the rebuild is required by an admin-triggered action (e.g module - * settings form), calling node_access_needs_rebuild(TRUE) instead of - * node_access_rebuild() lets the user perform his changes and actually + * This rebuild is occasionally needed by modules that make system-wide changes + * to access levels. When the rebuild is required by an admin-triggered action + * (e.g module settings form), calling node_access_needs_rebuild(TRUE) instead + * of node_access_rebuild() lets the user perform his changes and actually * rebuild only once he is done. * * Note : As of Drupal 6, node access modules are not required to (and actually * should not) call node_access_rebuild() in hook_enable/disable anymore. * - * @see node_access_needs_rebuild() - * * @param $batch_mode - * Set to TRUE to process in 'batch' mode, spawning processing over several - * HTTP requests (thus avoiding the risk of PHP timeout if the site has a - * large number of nodes). - * hook_update_N and any form submit handler are safe contexts to use the - * 'batch mode'. Less decidable cases (such as calls from hook_user, - * hook_taxonomy, etc...) might consider using the non-batch mode. + * (optional) Set to TRUE to process in 'batch' mode, spawning processing over + * several HTTP requests (thus avoiding the risk of PHP timeout if the site + * has a large number of nodes). hook_update_N() and any form submit handler + * are safe contexts to use the 'batch mode'. Less decidable cases (such as + * calls from hook_user(), hook_taxonomy(), etc.) might consider using the + * non-batch mode. + * @see node_access_needs_rebuild() */ function node_access_rebuild($batch_mode = FALSE) { db_delete('node_access')->execute(); @@ -3581,6 +3695,7 @@ function node_content_form($node, $form_state) { /** * Implements hook_forms(). + * * All node forms share the same form handler. */ function node_forms() { @@ -3665,6 +3780,12 @@ function node_action_info() { /** * Sets the status of a node to 1 (published). * + * @param $node + * A node object. + * @param $context + * (optional) Array of additional information about what triggered the action. + * Not used for this action. + * * @ingroup actions */ function node_publish_action($node, $context = array()) { @@ -3675,6 +3796,12 @@ function node_publish_action($node, $context = array()) { /** * Sets the status of a node to 0 (unpublished). * + * @param $node + * A node object. + * @param $context + * (optional) Array of additional information about what triggered the action. + * Not used for this action. + * * @ingroup actions */ function node_unpublish_action($node, $context = array()) { @@ -3685,6 +3812,12 @@ function node_unpublish_action($node, $context = array()) { /** * Sets the sticky-at-top-of-list property of a node to 1. * + * @param $node + * A node object. + * @param $context + * (optional) Array of additional information about what triggered the action. + * Not used for this action. + * * @ingroup actions */ function node_make_sticky_action($node, $context = array()) { @@ -3695,6 +3828,12 @@ function node_make_sticky_action($node, $context = array()) { /** * Sets the sticky-at-top-of-list property of a node to 0. * + * @param $node + * A node object. + * @param $context + * (optional) Array of additional information about what triggered the action. + * Not used for this action. + * * @ingroup actions */ function node_make_unsticky_action($node, $context = array()) { @@ -3705,6 +3844,12 @@ function node_make_unsticky_action($node, $context = array()) { /** * Sets the promote property of a node to 1. * + * @param $node + * A node object. + * @param $context + * (optional) Array of additional information about what triggered the action. + * Not used for this action. + * * @ingroup actions */ function node_promote_action($node, $context = array()) { @@ -3715,6 +3860,12 @@ function node_promote_action($node, $context = array()) { /** * Sets the promote property of a node to 0. * + * @param $node + * A node object. + * @param $context + * (optional) Array of additional information about what triggered the action. + * Not used for this action. + * * @ingroup actions */ function node_unpromote_action($node, $context = array()) { @@ -3725,6 +3876,9 @@ function node_unpromote_action($node, $context = array()) { /** * Saves a node. * + * @param $node + * The node to be saved. + * * @ingroup actions */ function node_save_action($node) { @@ -3738,9 +3892,13 @@ function node_save_action($node) { * @param $node * A node object to modify. * @param $context - * Array with the following elements: - * - 'owner_uid': User ID to assign to the node. + * Array of additional information about what triggered the action. Includes + * the following elements: + * - owner_uid: User ID to assign to the node. * + * @see node_assign_owner_action_form() + * @see node_assign_owner_action_validate() + * @see node_assign_owner_action_submit() * @ingroup actions */ function node_assign_owner_action($node, $context) { @@ -3750,7 +3908,16 @@ function node_assign_owner_action($node, $context) { } /** - * Generates the settings form for node_assign_owner_action(). + * Form constructor for the settings form for node_assign_owner_action(). + * + * @param $context + * Array of additional information about what triggered the action. Includes + * the following elements: + * - owner_uid: User ID to assign to the node. + * + * @see node_assign_owner_action_submit() + * @see node_assign_owner_action_validate() + * @ingroup form */ function node_assign_owner_action_form($context) { $description = t('The username of the user to which you would like to assign ownership.'); @@ -3790,7 +3957,9 @@ function node_assign_owner_action_form($context) { } /** - * Validates settings form for node_assign_owner_action(). + * Form validation handler for node_assign_owner_action_form(). + * + * @see node_assign_owner_action_submit() */ function node_assign_owner_action_validate($form, $form_state) { $exists = (bool) db_query_range('SELECT 1 FROM {users} WHERE name = :name', 0, 1, array(':name' => $form_state['values']['owner_name']))->fetchField(); @@ -3800,7 +3969,9 @@ function node_assign_owner_action_validate($form, $form_state) { } /** - * Saves settings form for node_assign_owner_action(). + * Form submission handler for node_assign_owner_action_form(). + * + * @see node_assign_owner_action_validate() */ function node_assign_owner_action_submit($form, $form_state) { // Username can change, so we need to store the ID, not the username. @@ -3822,7 +3993,7 @@ function node_unpublish_by_keyword_action_form($context) { } /** - * Saves settings form for node_unpublish_by_keyword_action(). + * Form submission handler for node_unpublish_by_keyword_action(). */ function node_unpublish_by_keyword_action_submit($form, $form_state) { return array('keywords' => drupal_explode_tags($form_state['values']['keywords'])); @@ -3834,10 +4005,14 @@ function node_unpublish_by_keyword_action_submit($form, $form_state) { * @param $node * A node object to modify. * @param $context - * Array with the following elements: - * - 'keywords': Array of keywords. If any keyword is present in the rendered + * Array of additional information about what triggered the action. Includes + * the following elements: + * - keywords: Array of keywords. If any keyword is present in the rendered * node, the node's status flag is set to unpublished. * + * @see node_unpublish_by_keyword_action_form() + * @see node_unpublish_by_keyword_action_submit() + * * @ingroup actions */ function node_unpublish_by_keyword_action($node, $context) { @@ -3896,6 +4071,9 @@ function node_modules_enabled($modules) { */ class NodeController extends DrupalDefaultEntityController { + /** + * Overrides DrupalDefaultEntityController::attachLoad(). + */ protected function attachLoad(&$nodes, $revision_id = FALSE) { // Create an array of nodes for each content type and pass this to the // object type specific callback. @@ -3918,6 +4096,9 @@ class NodeController extends DrupalDefaultEntityController { parent::attachLoad($nodes, $revision_id); } + /** + * Overrides DrupalDefaultEntityController::buildQuery(). + */ protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) { // Ensure that uid is taken from the {node} table, // alias timestamp to revision_timestamp and add revision_uid. diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index c7b26e7..423b9c9 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -2,12 +2,20 @@ /** * @file - * Page callbacks for adding, editing, deleting, and revisions management for content. + * Callbacks for adding, editing, and deleting content and managing revisions. + * + * Also includes validation, submission and other helper functions. + * + * @see node_menu() */ /** - * Menu callback; presents the node editing form. + * Page callback: Presents the node editing form. + * + * Path: node/%node/edit + * + * @see node_menu() */ function node_page_edit($node) { $type_name = node_type_get_name($node); @@ -15,6 +23,13 @@ function node_page_edit($node) { return drupal_get_form($node->type . '_node_form', $node); } +/** + * Page callback: Presents the node add form. + * + * Path: node/add + * + * @see node_menu() + */ function node_add_page() { $item = menu_get_item(); $content = system_admin_menu_block($item); @@ -33,6 +48,7 @@ function node_add_page() { * An associative array containing: * - content: An array of content types. * + * @see node_add_page() * @ingroup themeable */ function theme_node_add_list($variables) { @@ -55,7 +71,17 @@ function theme_node_add_list($variables) { /** - * Returns a node submission form. + * Page callback: Provides the node submission form. + * + * Path: 'node/add/' . $type_url_str (part of a foreach) + * + * @param $type + * The node type for the submitted node. + * + * @return + * Returns a node submission form. + * + * @see node_menu() */ function node_add($type) { global $user; @@ -68,6 +94,14 @@ function node_add($type) { return $output; } +/** + * Form validation handler for node_form(). + * + * @see node_form_delete_submit() + * @see node_form_build_preview() + * @see node_form_submit() + * @see node_form_submit_build_node() + */ function node_form_validate($form, &$form_state) { // $form_state['node'] contains the actual entity being edited, but we must // not update it with form values that have not yet been validated, so we @@ -78,7 +112,14 @@ function node_form_validate($form, &$form_state) { } /** - * Generate the node add/edit form array. + * Form constructor for the node add/edit form. + * + * @see node_form_delete_submit() + * @see node_form_build_preview() + * @see node_form_validate() + * @see node_form_submit() + * @see node_form_submit_build_node() + * @ingroup forms */ function node_form($form, &$form_state, $node) { global $user; @@ -303,7 +344,12 @@ function node_form($form, &$form_state, $node) { } /** - * Button submit function: handle the 'Delete' button on the node form. + * Form submission handler for the 'Delete' button for node_form(). + * + * @see node_form_build_preview() + * @see node_form_validate() + * @see node_form_submit() + * @see node_form_submit_build_node() */ function node_form_delete_submit($form, &$form_state) { $destination = array(); @@ -315,7 +361,14 @@ function node_form_delete_submit($form, &$form_state) { $form_state['redirect'] = array('node/' . $node->nid . '/delete', array('query' => $destination)); } - +/** + * Form submission handler for the 'Preview' button for node_form(). + * + * @see node_form_delete_submit() + * @see node_form_validate() + * @see node_form_submit() + * @see node_form_submit_build_node() + */ function node_form_build_preview($form, &$form_state) { $node = node_form_submit_build_node($form, $form_state); $form_state['node_preview'] = node_preview($node); @@ -323,7 +376,15 @@ function node_form_build_preview($form, &$form_state) { } /** - * Generate a node preview. + * Generates a node preview. + * + * @param $node + * The node to preview. + * + * @return + * Themed node preview. + * + * @see node_form_build_preview() */ function node_preview($node) { if (node_access('create', $node) || node_access('update', $node)) { @@ -369,6 +430,7 @@ function node_preview($node) { * An associative array containing: * - node: The node object which is being previewed. * + * @see node_preview() * @ingroup themeable */ function theme_node_preview($variables) { @@ -399,6 +461,14 @@ function theme_node_preview($variables) { return $output; } +/** + * Form submission handler that saves the node for node_form(). + * + * @see node_form_delete_submit() + * @see node_form_build_preview() + * @see node_form_validate() + * @see node_form_submit_build_node() + */ function node_form_submit($form, &$form_state) { $node = node_form_submit_build_node($form, $form_state); $insert = empty($node->nid); @@ -440,6 +510,10 @@ function node_form_submit($form, &$form_state) { * before proceeding to the next step. * * @see node_form() + * @see node_form_delete_submit() + * @see node_form_build_preview() + * @see node_form_validate() + * @see node_form_submit() */ function node_form_submit_build_node($form, &$form_state) { // @todo Legacy support for modules that extend the node form with form-level @@ -464,7 +538,11 @@ function node_form_submit_build_node($form, &$form_state) { } /** - * Menu callback -- ask for confirmation of node deletion + * Page callback: Form constructor for node deletion confirmation form. + * + * Path: node/%node/delete + * + * @see node_menu() */ function node_delete_confirm($form, &$form_state, $node) { $form['#node'] = $node; @@ -480,7 +558,7 @@ function node_delete_confirm($form, &$form_state, $node) { } /** - * Execute node deletion + * Form submission handler for node_delete_confirm(). */ function node_delete_confirm_submit($form, &$form_state) { if ($form_state['values']['confirm']) { @@ -494,7 +572,11 @@ function node_delete_confirm_submit($form, &$form_state) { } /** - * Generate an overview table of older revisions of a node. + * Page callback: Generates an overview table of older revisions of a node. + * + * Path: node/%node/revisions + * + * @see node_menu() */ function node_revision_overview($node) { drupal_set_title(t('Revisions for %title', array('%title' => $node->title)), PASS_THROUGH); @@ -545,13 +627,23 @@ function node_revision_overview($node) { } /** - * Ask for confirmation of the reversion to prevent against CSRF attacks. + * Page callback: Form constructor for the reversion confirmation form. + * + * Path: node/%node/revisions/%/revert + * + * This form prevents against CSRF attacks. + * + * @see node_menu() + * @see node_revision_revert_confirm_submit() */ function node_revision_revert_confirm($form, $form_state, $node_revision) { $form['#node_revision'] = $node_revision; return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', '', t('Revert'), t('Cancel')); } +/** + * Form submission handler for node_revision_revert_confirm(). + */ function node_revision_revert_confirm_submit($form, &$form_state) { $node_revision = $form['#node_revision']; $node_revision->revision = 1; @@ -564,11 +656,24 @@ function node_revision_revert_confirm_submit($form, &$form_state) { $form_state['redirect'] = 'node/' . $node_revision->nid . '/revisions'; } +/** + * Page callback: Form constructor for the revision deletion confirmation form. + * + * Path: node/%node/revisions/%/delete + * + * This form prevents against CSRF attacks. + * + * @see node_menu() + * @see node_revision_delete_confirm_submit() + */ function node_revision_delete_confirm($form, $form_state, $node_revision) { $form['#node_revision'] = $node_revision; return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', t('This action cannot be undone.'), t('Delete'), t('Cancel')); } +/** + * Form submission handler for node_revision_delete_confirm(). + */ function node_revision_delete_confirm_submit($form, &$form_state) { $node_revision = $form['#node_revision']; node_revision_delete($node_revision->vid); diff --git a/core/modules/node/node.test b/core/modules/node/node.test index 817f390..0a09943 100644 --- a/core/modules/node/node.test +++ b/core/modules/node/node.test @@ -6,7 +6,7 @@ */ /** - * Test the node_load_multiple() function. + * Tests the node_load_multiple() function. */ class NodeLoadMultipleUnitTest extends DrupalWebTestCase { @@ -25,7 +25,7 @@ class NodeLoadMultipleUnitTest extends DrupalWebTestCase { } /** - * Create four nodes and ensure they're loaded correctly. + * Creates four nodes and ensures that they are loaded correctly. */ function testNodeMultipleLoad() { $node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); @@ -102,7 +102,7 @@ class NodeLoadHooksTestCase extends DrupalWebTestCase { } /** - * Test that hook_node_load() is invoked correctly. + * Tests that hook_node_load() is invoked correctly. */ function testHookNodeLoad() { // Create some sample articles and pages. diff --git a/core/modules/node/tests/node_access_test.module b/core/modules/node/tests/node_access_test.module index 91c117a..34d2237 100644 --- a/core/modules/node/tests/node_access_test.module +++ b/core/modules/node/tests/node_access_test.module @@ -65,7 +65,7 @@ function node_access_test_permission() { /** * Implements hook_menu(). * - * Sets up a page that lists nodes. + * Sets up a test page that lists nodes. */ function node_access_test_menu() { $items = array(); @@ -85,13 +85,17 @@ function node_access_test_menu() { } /** - * Page callback for node access test page. + * Page callback: Creates the node access test page. + * + * Path: node_access_test_page * * Page should say "No nodes" if there are no nodes, and "Yes, # nodes" (with * the number filled in) if there were nodes the user could access. Also, the * database query is shown, and a list of the node IDs, for debugging purposes. * And if there is a query exception, the page says "Exception" and gives the * error. + * + * @see node_access_test_menu() */ function node_access_test_page() { $output = ''; @@ -125,13 +129,17 @@ function node_access_test_page() { } /** - * Page callback for node access entity test page. + * Page callback: Creates the node access entity test page. + * + * Path: node_access_entity_test_page * * Page should say "No nodes" if there are no nodes, and "Yes, # nodes" (with * the number filled in) if there were nodes the user could access. Also, the * database query is shown, and a list of the node IDs, for debugging purposes. * And if there is a query exception, the page says "Exception" and gives the * error. + * + * @see node_access_test_menu() */ function node_access_entity_test_page() { $output = ''; -- 1.7.1