diff options
Diffstat (limited to 'modules/node')
-rw-r--r-- | modules/node/content_types.inc | 3 | ||||
-rw-r--r-- | modules/node/content_types.js | 1 | ||||
-rw-r--r-- | modules/node/node-rtl.css | 1 | ||||
-rw-r--r-- | modules/node/node.admin.inc | 7 | ||||
-rw-r--r-- | modules/node/node.api.php | 26 | ||||
-rw-r--r-- | modules/node/node.css | 1 | ||||
-rw-r--r-- | modules/node/node.info | 1 | ||||
-rw-r--r-- | modules/node/node.install | 86 | ||||
-rw-r--r-- | modules/node/node.js | 1 | ||||
-rw-r--r-- | modules/node/node.module | 39 | ||||
-rw-r--r-- | modules/node/node.pages.inc | 1 | ||||
-rw-r--r-- | modules/node/node.test | 10 | ||||
-rw-r--r-- | modules/node/node.tokens.inc | 1 | ||||
-rw-r--r-- | modules/node/node.tpl.php | 1 | ||||
-rw-r--r-- | modules/node/tests/node_access_test.info | 1 | ||||
-rw-r--r-- | modules/node/tests/node_access_test.module | 1 | ||||
-rw-r--r-- | modules/node/tests/node_test.info | 1 | ||||
-rw-r--r-- | modules/node/tests/node_test.module | 1 | ||||
-rw-r--r-- | modules/node/tests/node_test_exception.info | 1 | ||||
-rw-r--r-- | modules/node/tests/node_test_exception.module | 1 |
20 files changed, 116 insertions, 69 deletions
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index d31becb0d..11ecc2c38 100644 --- a/modules/node/content_types.inc +++ b/modules/node/content_types.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -70,7 +69,7 @@ function theme_node_admin_overview($variables) { $type = $variables['type']; $output = check_plain($name); - $output .= ' <small> (Machine name: ' . check_plain($type->type) . ')</small>'; + $output .= ' <small>' . t('(Machine name: @type)', array('@type' => $type->type)) . '</small>'; $output .= '<div class="description">' . filter_xss_admin($type->description) . '</div>'; return $output; } diff --git a/modules/node/content_types.js b/modules/node/content_types.js index dfbd01cbf..0031c323f 100644 --- a/modules/node/content_types.js +++ b/modules/node/content_types.js @@ -1,4 +1,3 @@ -// $Id$ (function ($) { Drupal.behaviors.contentTypes = { diff --git a/modules/node/node-rtl.css b/modules/node/node-rtl.css index 48d62aedc..a5fe99eaa 100644 --- a/modules/node/node-rtl.css +++ b/modules/node/node-rtl.css @@ -1,4 +1,3 @@ -/* $Id$ */ #node-admin-content dl.multiselect dd .form-item label { display: block; diff --git a/modules/node/node.admin.inc b/modules/node/node.admin.inc index d7efc00a7..a6ea1b5e5 100644 --- a/modules/node/node.admin.inc +++ b/modules/node/node.admin.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -388,9 +387,9 @@ function node_admin_nodes() { '#submit' => array('node_admin_nodes_submit'), ); - // Enable language column if translation module is enabled - // or if we have any node with language. - $multilanguage = (module_exists('translation') || db_query("SELECT COUNT(*) FROM {node} WHERE language <> :language", array(':language' => LANGUAGE_NONE))->fetchField()); + // Enable language column if translation module is enabled or if we have any + // node with language. + $multilanguage = (module_exists('translation') || db_query_range("SELECT 1 FROM {node} WHERE language <> :language", 0, 1, array(':language' => LANGUAGE_NONE))->fetchField()); // Build the sortable table header. $header = array( diff --git a/modules/node/node.api.php b/modules/node/node.api.php index 2e60cea09..3e8029cfc 100644 --- a/modules/node/node.api.php +++ b/modules/node/node.api.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -38,6 +37,7 @@ * - Creating a new node (calling node_save() on a new node): * - field_attach_presave() * - hook_node_presave() (all) + * - hook_entity_presave() (all) * - Node and revision records are written to the database * - hook_insert() (node-type-specific) * - field_attach_insert() @@ -48,6 +48,7 @@ * - Updating an existing node (calling node_save() on an existing node): * - field_attach_presave() * - hook_node_presave() (all) + * - hook_entity_presave() (all) * - Node and revision records are written to the database * - hook_update() (node-type-specific) * - field_attach_update() @@ -70,6 +71,9 @@ * - hook_entity_prepare_view() (all) * - field_attach_view() * - hook_node_view() (all) + * - hook_entity_view() (all) + * - hook_node_view_alter() (all) + * - hook_entity_view_alter() (all) * - Viewing multiple nodes (calling node_view_multiple() - note that the input * to node_view_multiple() is a set of loaded nodes, so the Loading steps * above are already done): @@ -78,13 +82,16 @@ * - hook_view() (node-type-specific) * - field_attach_view() * - hook_node_view() (all) + * - hook_entity_view() (all) * - hook_node_view_alter() (all) + * - hook_entity_view_alter() (all) * - Deleting a node (calling node_delete() or node_delete_multiple()): * - Node is loaded (see Loading section above) - * - Node and revision information is deleted from database * - hook_delete() (node-type-specific) * - hook_node_delete() (all) + * - hook_entity_delete() (all) * - field_attach_delete() + * - Node and revision information are deleted from database * - Deleting a node revision (calling node_revision_delete()): * - Node is loaded (see Loading section above) * - Revision information is deleted from database @@ -315,7 +322,7 @@ function hook_node_access_records($node) { * @see hook_node_grants() * @see hook_node_grants_alter() * - * @param &$grants + * @param $grants * The $grants array returned by hook_node_access_records(). * @param $node * The node for which the grants were acquired. @@ -360,7 +367,7 @@ function hook_node_access_records_alter(&$grants, $node) { * @see hook_node_access_records() * @see hook_node_access_records_alter() * - * @param &$grants + * @param $grants * The $grants array returned by hook_node_grants(). * @param $account * The user account requesting access to content. @@ -454,9 +461,10 @@ function hook_node_operations() { /** * Respond to node deletion. * - * This hook is invoked from node_delete_multiple() after the node has been - * removed from the node table in the database, after the type-specific - * hook_delete() has been invoked, and before field_attach_delete() is called. + * This hook is invoked from node_delete_multiple() after the type-specific + * hook_delete() has been invoked, but before hook_entity_delete and + * field_attach_delete() are called, and before the node is removed from the + * node table in the database. * * @param $node * The node that is being deleted. @@ -580,7 +588,7 @@ function hook_node_load($nodes, $types) { * @return * NODE_ACCESS_ALLOW if the operation is to be allowed; * NODE_ACCESS_DENY if the operation is to be denied; - * NODE_ACCESSS_IGNORE to not affect this operation at all. + * NODE_ACCESS_IGNORE to not affect this operation at all. */ function hook_node_access($node, $op, $account) { $type = is_string($node) ? $node : $node->type; @@ -1057,8 +1065,6 @@ function hook_prepare($node) { * displayed automatically by the node module. This hook just needs to * return the node title and form editing fields specific to the node type. * - * For a detailed usage example, see node_example.module. - * * @param $node * The node being added or edited. * @param $form_state diff --git a/modules/node/node.css b/modules/node/node.css index efd21b589..07540fa90 100644 --- a/modules/node/node.css +++ b/modules/node/node.css @@ -1,4 +1,3 @@ -/* $Id$ */ .node-unpublished { background-color: #fff4f4; diff --git a/modules/node/node.info b/modules/node/node.info index 9767f7ee3..85866e7af 100644 --- a/modules/node/node.info +++ b/modules/node/node.info @@ -1,4 +1,3 @@ -; $Id$ name = Node description = Allows content to be submitted to the site and displayed on pages. package = Core diff --git a/modules/node/node.install b/modules/node/node.install index 4be27cbe8..852c1117b 100644 --- a/modules/node/node.install +++ b/modules/node/node.install @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -396,6 +395,34 @@ function node_schema() { ), ); + $schema['history'] = array( + 'description' => 'A record of which {users} have read which {node}s.', + 'fields' => array( + 'uid' => array( + 'description' => 'The {users}.uid that read the {node} nid.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'nid' => array( + 'description' => 'The {node}.nid that was read.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'timestamp' => array( + 'description' => 'The Unix timestamp at which the read occurred.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('uid', 'nid'), + 'indexes' => array( + 'nid' => array('nid'), + ), + ); + return $schema; } @@ -442,7 +469,26 @@ function node_update_dependencies() { * @ingroup update-api-6.x-to-7.x */ function _update_7000_node_get_types() { - return db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ); + $node_types = db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ); + + // Create default settings for orphan nodes. + $all_types = db_query('SELECT DISTINCT type FROM {node}')->fetchCol(); + $extra_types = array_diff($all_types, array_keys($node_types)); + + foreach ($extra_types as $type) { + $type_object = new stdClass; + $type_object->type = $type; + + // In Drupal 6, whether you have a body field or not is a flag in the node + // type table. If it's enabled, nodes may or may not have an empty string + // for the bodies. As we can't detect what this setting should be in + // Drupal 7 without access to the Drupal 6 node type settings, we assume + // the default, which is to enable the body field. + $type_object->has_body = 1; + $type_object->body_label = 'Body'; + $node_types[$type_object->type] = $type_object; + } + return $node_types; } /** @@ -573,19 +619,6 @@ function node_update_7006(&$sandbox) { // Get node type info, specifically the body field settings. $node_types = _update_7000_node_get_types(); - // Create default settings for orphan nodes. - $extra_types = db_query('SELECT DISTINCT type FROM {node} WHERE type NOT IN (:types)', array(':types' => array_keys($node_types)))->fetchCol(); - foreach ($extra_types as $type) { - $type_object = new stdClass; - $type_object->type = $type; - // Always create a body. Querying node_revisions for a non-empty body - // would skip creating body fields for types that have a body but - // the nodes of that type so far had empty bodies. - $type_object->has_body = 1; - $type_object->body_label = 'Body'; - $node_types[$type_object->type] = $type_object; - } - // Add body field instances for existing node types. foreach ($node_types as $node_type) { if ($node_type->has_body) { @@ -804,5 +837,28 @@ function node_update_7010() { } /** + * Update the database from Drupal 6 to match the schema. + */ +function node_update_7011() { + // Drop node moderation field. + db_drop_field('node', 'moderate'); + db_drop_index('node', 'node_moderate'); + + // Change {node_revision}.status field to default to 1. + db_change_field('node_revision', 'status', 'status', array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 1, + )); + + // Change {node_type}.module field default. + db_change_field('node_type', 'module', 'module', array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + )); +} + +/** * @} End of "addtogroup updates-6.x-to-7.x" */ diff --git a/modules/node/node.js b/modules/node/node.js index 077930660..ebf68eb3b 100644 --- a/modules/node/node.js +++ b/modules/node/node.js @@ -1,4 +1,3 @@ -// $Id$ (function ($) { diff --git a/modules/node/node.module b/modules/node/node.module index 399fa7ea3..524a57fa7 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -365,7 +364,7 @@ function node_mark($nid, $timestamp) { * Either a string or object, containing the node type information. * * @return - * Node type of the passed in data. + * Node type of the passed-in data. */ function _node_extract_type($node) { return is_object($node) ? $node->type : $node; @@ -490,7 +489,6 @@ function node_type_load($name) { * Status flag indicating outcome of the operation. */ function node_type_save($info) { - $is_existing = FALSE; $existing_type = !empty($info->old_type) ? $info->old_type : $info->type; $is_existing = (bool) db_query_range('SELECT 1 FROM {node_type} WHERE type = :type', 0, 1, array(':type' => $existing_type))->fetchField(); $type = node_type_set_defaults($info); @@ -570,7 +568,7 @@ function node_add_body_field($type, $label = 'Body') { 'entity_type' => 'node', 'bundle' => $type->type, 'label' => $label, - 'widget_type' => 'text_textarea_with_summary', + 'widget' => array('type' => 'text_textarea_with_summary'), 'settings' => array('display_summary' => TRUE), 'display' => array( 'default' => array( @@ -754,17 +752,20 @@ function node_type_cache_reset() { } /** - * Set the default values for a node type. + * Sets the default values for a node type. * - * The defaults are for a type defined through hook_node_info(). - * When populating a custom node type $info should have the 'custom' - * key set to 1. + * The defaults are appropriate for a type defined through hook_node_info(), + * since 'custom' is TRUE for types defined in the user interface, and FALSE + * for types defined by modules. (The 'custom' flag prevents types from being + * deleted through the user interface.) Also, the default for 'locked' is TRUE, + * which prevents users from changing the machine name of the type. * * @param $info - * An object or array containing values to override the defaults. + * 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. + * A node type object, with missing values in $info set to their defaults. */ function node_type_set_defaults($info = array()) { $info = (array) $info; @@ -1349,15 +1350,15 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) { // The 'view' hook can be implemented to overwrite the default function // to display nodes. if (node_hook($node, 'view')) { - $node = node_invoke($node, 'view', $view_mode); + $node = node_invoke($node, 'view', $view_mode, $langcode); } // Build fields content. // In case of a multiple view, node_view_multiple() already ran the // 'prepare_view' step. An internal flag prevents the operation from running // twice. - field_attach_prepare_view('node', array($node->nid => $node), $view_mode); - entity_prepare_view('node', array($node->nid => $node)); + field_attach_prepare_view('node', array($node->nid => $node), $view_mode, $langcode); + entity_prepare_view('node', array($node->nid => $node), $langcode); $node->content += field_attach_view('node', $node, $view_mode, $langcode); // Always display a read more link on teasers because we have no way @@ -1411,7 +1412,7 @@ function node_show($node, $message = FALSE) { } /** - * Returns whether the current page is the full page view of the passed in node. + * Returns whether the current page is the full page view of the passed-in node. * * @param $node * A node object. @@ -1450,10 +1451,6 @@ function template_preprocess_node(&$variables) { $variables['title'] = check_plain($node->title); $variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node); - if (!empty($node->in_preview)) { - unset($node->content['links']); - } - // Flatten the node object's member fields. $variables = array_merge((array) $node, $variables); @@ -2190,7 +2187,7 @@ function node_get_recent($number = 10) { } $nids = $query ->fields('n', array('nid')) - ->orderBy('changed', 'DESC') + ->orderBy('n.changed', 'DESC') ->range(0, $number) ->addTag('node_access') ->execute() @@ -2516,8 +2513,8 @@ function node_feed($nids = FALSE, $channel = array()) { * An array in the format expected by drupal_render(). */ function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcode = NULL) { - field_attach_prepare_view('node', $nodes, $view_mode); - entity_prepare_view('node', $nodes); + field_attach_prepare_view('node', $nodes, $view_mode, $langcode); + entity_prepare_view('node', $nodes, $langcode); $build = array(); foreach ($nodes as $node) { $build['nodes'][$node->nid] = node_view($node, $view_mode, $langcode); diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index fdb773df3..facc7f6ee 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/node/node.test b/modules/node/node.test index 3e0db8615..8a871c0c7 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -1,5 +1,9 @@ <?php -// $Id$ + +/** + * @file + * Tests for node.module. + */ /** * Test the node_load_multiple() function. @@ -2126,7 +2130,7 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('node' => $node), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized node token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized node token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -2138,7 +2142,7 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('node' => $node), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized node token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized node token %token replaced.', array('%token' => $input))); } } } diff --git a/modules/node/node.tokens.inc b/modules/node/node.tokens.inc index be064ab29..80dbda517 100644 --- a/modules/node/node.tokens.inc +++ b/modules/node/node.tokens.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/node/node.tpl.php b/modules/node/node.tpl.php index 26128960d..6d0f489d7 100644 --- a/modules/node/node.tpl.php +++ b/modules/node/node.tpl.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/node/tests/node_access_test.info b/modules/node/tests/node_access_test.info index e3f041d12..dc5e53040 100644 --- a/modules/node/tests/node_access_test.info +++ b/modules/node/tests/node_access_test.info @@ -1,4 +1,3 @@ -; $Id$ name = "Node module access tests" description = "Support module for node permission testing." package = Testing diff --git a/modules/node/tests/node_access_test.module b/modules/node/tests/node_access_test.module index 50fb169c6..3004e0c90 100644 --- a/modules/node/tests/node_access_test.module +++ b/modules/node/tests/node_access_test.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/node/tests/node_test.info b/modules/node/tests/node_test.info index 5c171233b..fa6c093d1 100644 --- a/modules/node/tests/node_test.info +++ b/modules/node/tests/node_test.info @@ -1,4 +1,3 @@ -; $Id$ name = "Node module tests" description = "Support module for node related testing." package = Testing diff --git a/modules/node/tests/node_test.module b/modules/node/tests/node_test.module index 821f48ca1..b0ebc149a 100644 --- a/modules/node/tests/node_test.module +++ b/modules/node/tests/node_test.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/node/tests/node_test_exception.info b/modules/node/tests/node_test_exception.info index ba1b81706..1a339e0ea 100644 --- a/modules/node/tests/node_test_exception.info +++ b/modules/node/tests/node_test_exception.info @@ -1,4 +1,3 @@ -; $Id$ name = "Node module exception tests" description = "Support module for node related exception testing." package = Testing diff --git a/modules/node/tests/node_test_exception.module b/modules/node/tests/node_test_exception.module index 6dfe18b61..0fe9f35ea 100644 --- a/modules/node/tests/node_test_exception.module +++ b/modules/node/tests/node_test_exception.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file |