diff --git a/includes/theme.inc b/includes/theme.inc index b934462d6a33ed47002215acb9cc0ffa94cbe0aa..952984372fa0550f9625c45b45a7e594c8558c93 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -918,11 +918,6 @@ function theme_get_settings($key = NULL) { 'toggle_secondary_menu' => 1, ); - if (module_exists('node')) { - foreach (node_get_types() as $type => $name) { - $defaults['toggle_node_info_' . $type] = 1; - } - } $settings = array_merge($defaults, variable_get('theme_settings', array())); if ($key) { @@ -2009,8 +2004,8 @@ function template_preprocess_node(&$variables) { // Flatten the node object's member fields. $variables = array_merge((array)$node, $variables); - // Display info only on certain node types. - if (theme_get_setting('toggle_node_info_' . $node->type)) { + // Display post information only on certain node types. + if (variable_get('node_submitted_' . $node->type, TRUE)) { $variables['submitted'] = theme('node_submitted', $node); $variables['picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', $node) : ''; } diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index be1dd765461c7c9222c3fc5a97df1edd877a82a2..3868c50f4ec21c3b1bf504ab529097318f94487c 100644 --- a/modules/node/content_types.inc +++ b/modules/node/content_types.inc @@ -159,7 +159,18 @@ function node_type_form(&$form_state, $type = NULL) { ), '#description' => t('Users with the <em>administer nodes</em> permission will be able to override these options.'), ); - + $form['display'] = array( + '#type' => 'fieldset', + '#title' => t('Display settings'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['display']['node_submitted'] = array( + '#type' => 'checkbox', + '#title' => t('Display post information'), + '#default_value' => variable_get('node_submitted_'. $type->type, TRUE), + '#description' => t('Enable the <em>submitted by Username on date</em> text.'), + ); $form['old_type'] = array( '#type' => 'value', '#value' => $type->type, diff --git a/modules/node/node.test b/modules/node/node.test index 419a1dfd3c28bfbb1cab35e49f2bb1b099a2bf32..42294f721927cc86aa9feb6e73bed52fbca93504 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -537,3 +537,65 @@ class NodeBlockTestCase extends DrupalWebTestCase { $this->assertText(t('The block settings have been updated.'), t('Block successfully move to footer region.')); } } + +/** + * Check that the post information displays when enabled for a content type. + */ +class NodePostSettingsTestCase extends DrupalWebTestCase { + function getInfo() { + return array( + 'name' => t('Node post information display'), + 'description' => t('Check that the post information (submitted by Username on date) text displays appropriately.'), + 'group' => t('Node'), + ); + } + + function setUp() { + parent::setUp(); + + $web_user = $this->drupalCreateUser(array('create page content', 'administer content types', 'access user profiles')); + $this->drupalLogin($web_user); + } + + /** + * Set page content type to display post information and confirm its presence on a new node. + */ + function testPagePostInfo() { + + // Set page content type to display post information. + $edit = array(); + $edit['node_submitted'] = TRUE; + $this->drupalPost('admin/build/node-type/page', $edit, t('Save content type')); + + // Create a node. + $edit = array(); + $edit['title'] = $this->randomName(8); + $edit['body'] = $this->randomName(16); + $this->drupalPost('node/add/page', $edit, t('Save')); + + // Check that the post information is displayed. + $node = $this->drupalGetNodeByTitle($edit['title']); + $this->assertRaw(theme('node_submitted', $node), t('Post information is displayed.')); + } + + /** + * Set page content type to not display post information and confirm its absence on a new node. + */ + function testPageNotPostInfo() { + + // Set page content type to display post information. + $edit = array(); + $edit['node_submitted'] = FALSE; + $this->drupalPost('admin/build/node-type/page', $edit, t('Save content type')); + + // Create a node. + $edit = array(); + $edit['title'] = $this->randomName(8); + $edit['body'] = $this->randomName(16); + $this->drupalPost('node/add/page', $edit, t('Save')); + + // Check that the post information is displayed. + $node = $this->drupalGetNodeByTitle($edit['title']); + $this->assertNoRaw(theme('node_submitted', $node), t('Post information is not displayed.')); + } +} \ No newline at end of file diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index d67213e64d2fecb331508786fe6c428ef82028ed..dbf0d39d04a2bbb1c553dbe7f3e5d52397bd1883 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -399,30 +399,7 @@ function system_theme_settings(&$form_state, $key = '') { } } - // System wide only settings. - if (!$key) { - // Create neat 2-column layout for the toggles - $form['theme_settings'] += array( - '#prefix' => '<div class="theme-settings-left">', - '#suffix' => '</div>', - ); - - // Toggle node display. - $node_types = node_get_types('names'); - if ($node_types) { - $form['node_info'] = array( - '#type' => 'fieldset', - '#title' => t('Display post information on'), - '#description' => t('Enable or disable the <em>submitted by Username on date</em> text when displaying posts of the following type.'), - '#prefix' => '<div class="theme-settings-right">', - '#suffix' => '</div>', - ); - foreach ($node_types as $type => $name) { - $form['node_info']["toggle_node_info_$type"] = array('#type' => 'checkbox', '#title' => check_plain($name), '#default_value' => $settings["toggle_node_info_$type"]); - } - } - } - elseif (!element_children($form['theme_settings'])) { + if (!element_children($form['theme_settings'])) { // If there is no element in the theme settings fieldset then do not show // it -- but keep it in the form if another module wants to alter. $form['theme_settings']['#access'] = FALSE; @@ -436,7 +413,7 @@ function system_theme_settings(&$form_state, $key = '') { '#description' => t('If toggled on, the following logo will be displayed.'), '#attributes' => array('class' => 'theme-settings-bottom'), ); - $form['logo']["default_logo"] = array( + $form['logo']['default_logo'] = array( '#type' => 'checkbox', '#title' => t('Use the default logo'), '#default_value' => $settings['default_logo'], @@ -461,7 +438,7 @@ function system_theme_settings(&$form_state, $key = '') { $form['favicon'] = array( '#type' => 'fieldset', '#title' => t('Shortcut icon settings'), - '#description' => t("Your shortcut icon, or 'favicon', is displayed in the address bar and bookmarks of most browsers.") + '#description' => t("Your shortcut icon, or 'favicon', is displayed in the address bar and bookmarks of most browsers."), ); $form['favicon']['default_favicon'] = array( '#type' => 'checkbox', diff --git a/modules/system/system.install b/modules/system/system.install index e75b916583002a01fa78ab42765b4d16c461dbd3..5b73c4b87e8edd5f32f8882d3b4351a6bb7a7ba1 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -3165,6 +3165,35 @@ function system_update_7016() { return $ret; } +/** + * Change the theme setting 'toggle_node_info' into a per content type variable. + */ +function system_update_7017() { + $ret = array(); + $types = node_get_types(); + if (count($types)) { + foreach ($types as $type) { + $node_info = theme_get_setting('toggle_node_info_' . $type->type); + if ($node_info !== NULL) { + variable_set('node_submitted_' . $type->type, $node_info); + $ret[] = array('success' => TRUE, 'query' => "variable_set('node_submitted_$type->type')"); + } + } + } + + // Unset deprecated 'toggle_node_info' theme settings. + $theme_settings = theme_get_settings(); + foreach ($theme_settings as $setting => $value) { + if (substr($setting, 0, 16) == 'toggle_node_info') { + unset($theme_settings[$setting]); + } + } + variable_set('theme_settings', $theme_settings); + $ret[] = array('success' => TRUE, 'query' => "variable_set('theme_settings')"); + + return $ret; +} + /** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. diff --git a/modules/system/system.module b/modules/system/system.module index f71ccd75c6ed4339795e0fb918a159b6797b3fcd..49caeea0001c892b3c417e6a2feefa704c2bb398 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1353,25 +1353,6 @@ function _system_sort_requirements($a, $b) { return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight']; } -/** - * Implementation of hook_node_type(). - * - * Updates theme settings after a node type change. - */ -function system_node_type($op, $info) { - if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) { - $old = 'toggle_node_info_' . $info->old_type; - $new = 'toggle_node_info_' . $info->type; - - $theme_settings = variable_get('theme_settings', array()); - if (isset($theme_settings[$old])) { - $theme_settings[$new] = $theme_settings[$old]; - unset($theme_settings[$old]); - variable_set('theme_settings', $theme_settings); - } - } -} - /** * Output a confirmation form * diff --git a/profiles/default/default.profile b/profiles/default/default.profile index 1af48d2de79d6085d9b55f562c019b61694d183d..a3ddc7f2bddf2d6de1b14e932ff679ddef9c768a 100644 --- a/profiles/default/default.profile +++ b/profiles/default/default.profile @@ -125,9 +125,7 @@ function default_profile_tasks(&$task, $url) { variable_set('comment_page', COMMENT_NODE_DISABLED); // Don't display date and author information for page nodes by default. - $theme_settings = variable_get('theme_settings', array()); - $theme_settings['toggle_node_info_page'] = FALSE; - variable_set('theme_settings', $theme_settings); + variable_set('node_submitted_page', FALSE); // Create a default vocabulary named "Tags", enabled for the 'article' content type. $description = st('Use tags to group articles on similar topics into categories.'); diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme index 74a332b98d5ed3f1b654cd0679c58302225e624a..eb5d7b33ba984afc7eccf1dd1bb65c16d6f3c181 100644 --- a/themes/chameleon/chameleon.theme +++ b/themes/chameleon/chameleon.theme @@ -134,7 +134,7 @@ function chameleon_node($node, $teaser = 0) { $output .= " </div>\n"; $submitted = ''; - if (theme_get_setting("toggle_node_info_$node->type")) { + if (variable_get('node_submitted_' . $node->type, TRUE)) { $submitted = t("By !author at @date", array('!author' => theme('username', $node), '@date' => format_date($node->created, 'small'))); }