From 6658273b36ffc64a6c2ba66bf08cda9f3923252d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 5 May 2005 07:35:58 +0000 Subject: - Patch #21855 by TDobes: the recent commit of phptemplate caused a number of problems for non-phptemplate themes. A patch is attached to address these issues. Changes include: * parsing of the primary/secondary links has been moved out of phptemplate and into theme_get_setting. * unnecessary and XHTML-invalidating duplicate div#help removed from themes/bluemarine/page.tpl.php (this is already generated by theme_help) * weird generation of the "edit primary/secondary links" messages removed from bluemarine and placed in theme.inc * unnecessary changes to themes/bluemarine/style.css rolled back (the phptemplate bluemarine had an older version of style.css than the one in core) * chameleon updated to work with new link scheme (passes links through theme_links) --- includes/theme.inc | 38 ++++++++++++++++++++++----- modules/system.module | 8 +++--- modules/system/system.module | 8 +++--- themes/bluemarine/page.tpl.php | 6 ++--- themes/bluemarine/style.css | 7 ++++- themes/chameleon/chameleon.theme | 4 +-- themes/engines/phptemplate/phptemplate.engine | 35 ++---------------------- 7 files changed, 53 insertions(+), 53 deletions(-) diff --git a/includes/theme.inc b/includes/theme.inc index 0bc46252a..6b210c55e 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -289,12 +289,38 @@ function theme_get_setting($setting_name, $refresh = FALSE) { } } - if (!$settings['toggle_primary_links']) { - $settings['primary_links'] = ''; - } - - if (!$settings['toggle_secondary_links']) { - $settings['secondary_links'] = ''; + foreach (array('primary', 'secondary') as $type) { + // Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format. + $value = $settings[$type . '_links']; + + // Clear out existing (internal) values + $settings[$type .'_links'] = array(); + + // Get the amount of links to show, possibly expanding if there are more links defined than the count specifies. + $count = variable_get($type . '_link_count', 5); + $count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']); + + if ($settings['toggle_' . $type . '_links']) { + for ($i =0; $i < $count; $i++) { + unset($attributes); + if (!empty($value['text'][$i])) { + if (!empty($value['description'][$i])) { + $attributes['title'] = $value['description'][$i]; + } + $text = $value['text'][$i]; + $link = $value['link'][$i]; + if (substr($link, 0, 7) == 'http://') { + $settings[$type .'_links'][] = ''. $text .''; + } + else { + $settings[$type .'_links'][] = l($text, $link, $attributes); + } + } + } + if ($settings[$type .'_links'] == array()) { + $settings[$type .'_links'] = array(l(t('edit %type links', array('%type' => $type)),'admin/themes/settings')); + } + } } } diff --git a/modules/system.module b/modules/system.module index ae057eed1..119c50e52 100644 --- a/modules/system.module +++ b/modules/system.module @@ -658,20 +658,20 @@ function system_theme_settings($key = '') { $group = ''; $rows = array(); - //Use $utype field , and strtolower() it to get the type field.. to avoid issues with ucfirst() and unicode. + // Use $utype field , and strtolower() it to get the type field.. to avoid issues with ucfirst() and unicode. $type = strtolower($utype); - $value = theme_get_setting($type . '_links'); + $value = $settings[$type . '_links']; if (!is_array($value)) { $value = array(); } - //Increment the link count, if the user has requested more links. + // Increment the link count, if the user has requested more links. if (variable_get($type . '_links_more', false)) { variable_del($type . '_links_more'); variable_set($type . '_link_count', variable_get($type . '_link_count', 5) + 5); } - //Get the amount of links to show, possibly expanding if there are more links defined than the count specifies. + // Get the amount of links to show, possibly expanding if there are more links defined than the count specifies. $count = variable_get($type . '_link_count', 5); $count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']); if (variable_get($type . '_link_count', 5) != $count) { diff --git a/modules/system/system.module b/modules/system/system.module index ae057eed1..119c50e52 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -658,20 +658,20 @@ function system_theme_settings($key = '') { $group = ''; $rows = array(); - //Use $utype field , and strtolower() it to get the type field.. to avoid issues with ucfirst() and unicode. + // Use $utype field , and strtolower() it to get the type field.. to avoid issues with ucfirst() and unicode. $type = strtolower($utype); - $value = theme_get_setting($type . '_links'); + $value = $settings[$type . '_links']; if (!is_array($value)) { $value = array(); } - //Increment the link count, if the user has requested more links. + // Increment the link count, if the user has requested more links. if (variable_get($type . '_links_more', false)) { variable_del($type . '_links_more'); variable_set($type . '_link_count', variable_get($type . '_link_count', 5) + 5); } - //Get the amount of links to show, possibly expanding if there are more links defined than the count specifies. + // Get the amount of links to show, possibly expanding if there are more links defined than the count specifies. $count = variable_get($type . '_link_count', 5); $count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']); if (variable_get($type . '_link_count', 5) != $count) { diff --git a/themes/bluemarine/page.tpl.php b/themes/bluemarine/page.tpl.php index f8fd5837a..0ca11414d 100644 --- a/themes/bluemarine/page.tpl.php +++ b/themes/bluemarine/page.tpl.php @@ -20,8 +20,8 @@ -
0) ? theme('links', $secondary_links) : l(t('edit secondary links'),'admin/themes/settings') ?>
-
0) ? theme('links', $primary_links) : l(t('edit primary links'), 'admin/themes/settings') ?>
+
+
\n"; - $primary_links = theme_get_setting('primary_links'); - $secondary_links = theme_get_setting('secondary_links'); + $primary_links = theme('links', theme_get_setting('primary_links')); + $secondary_links = theme('links', theme_get_setting('secondary_links')); if ($primary_links || $secondary_links) { $output .= '