diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/node/content_types.inc | 13 | ||||
-rw-r--r-- | modules/node/node.test | 62 | ||||
-rw-r--r-- | modules/system/system.admin.inc | 29 | ||||
-rw-r--r-- | modules/system/system.install | 29 | ||||
-rw-r--r-- | modules/system/system.module | 19 |
5 files changed, 106 insertions, 46 deletions
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index be1dd7654..3868c50f4 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 419a1dfd3..42294f721 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 d67213e64..dbf0d39d0 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 e75b91658..5b73c4b87 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -3166,6 +3166,35 @@ function system_update_7016() { } /** + * 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 f71ccd75c..49caeea00 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1354,25 +1354,6 @@ function _system_sort_requirements($a, $b) { } /** - * 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 * * This function returns a complete form for confirming an action. A link is |