Index: goofy.theme
===================================================================
RCS file: /cvs/drupal-contrib/contributions/themes/goofy/goofy.theme,v
retrieving revision 1.22
diff -u -r1.22 goofy.theme
--- goofy.theme	5 Mar 2006 09:13:56 -0000	1.22
+++ goofy.theme	5 Jun 2008 21:09:40 -0000
@@ -1,21 +1,77 @@
 <?php
 // $Id: goofy.theme,v 1.22 2006/03/05 09:13:56 tdobes Exp $
+/*
+ * Initialize theme settings
+ * 
+ * Based on http://drupal.org/node/177868
+ * but doesn't work
+ */
+if (is_null(theme_get_setting('goofy_logo2'))) {
+  global $theme_key;
+  
+  /*
+   * The default values for the theme variables. Make sure $defaults exactly
+   * matches the $defaults in the theme-settings.php file.
+   */
+  $defaults = array(    
+    'goofy_default_logo2' => 1,
+    'goofy_logo2'         => '',
+  );
 
-function goofy_features() {
-  return array('logo', 'toggle_node_user_picture', 'toggle_comment_user_picture', 'toggle_favicon');
+  // Get default theme settings.
+  $settings = theme_get_settings($theme_key);
+  // Don't save the toggle_node_info_ variables.
+  if (module_exists('node')) {
+    foreach (node_get_types() as $type => $name) {
+      unset($settings['toggle_node_info_' . $type]);
+    }
+  }
+  // Save default theme settings.
+  variable_set(
+    str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
+    array_merge($defaults, $settings)
+  );
+  // Force refresh of Drupal internals.
+  theme_get_setting('', TRUE);
 }
 
-function goofy_regions() {
-  return array(
-       'left' => t('left sidebar'),
-       'right' => t('right sidebar')
-  );
+/**
+ * Implementation of hook_theme. Auto-discover theme functions.
+ * New in D6 version
+ * @return array
+ */
+function goofy_theme($existing, $type, $theme, $path) {
+  return drupal_find_theme_functions($existing, array($theme));
 }
 
-function goofy_settings() {
-  $output = form_checkbox(t('Use the default secondary logo'), "goofy_default_logo2", 1, variable_get('goofy_default_logo2', 1), t('Check here if you want the theme to use the secondary logo supplied with it.'));
-  $output .= form_textfield(t('Path to custom secondary logo'), "goofy_logo2", variable_get('goofy_logo2', ''), 50, 60, t('The path to the file you would like to use as your secondary logo file instead of the default logo.'));
-  return $output;
+/**
+ * This is 4.6 code which was still there in the 4.7 version, apparently unused.
+ *
+ * @return string
+ */
+function goofy_settings($saved_settings) {
+  $defaults = array(    
+    'goofy_default_logo2' => 1,
+    'goofy_logo2'         => '',
+  );
+  $settings = array_merge($defaults, $saved_settings);
+    
+  $form = array();
+  $form['goofy_default_logo2'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use the default secondary logo'),
+    '#default_value' => $settings['goofy_default_logo2'],
+    '#description' => t('Check here if you want the theme to use the secondary logo supplied with it.'),  
+  );
+  $form['goofy_logo2'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Path to custom secondary logo'),
+    '#default_value' => $settings['goofy_logo2'],
+    '#size' => 50,
+    '#maxlength' => 60,
+    '#description' => t('The path to the file you would like to use as your secondary logo file instead of the default logo.'),
+  );
+  return $form;
 }
 
 function goofy_page($content) {
@@ -31,7 +87,7 @@
     $colspan++;
   }
 
-  $language = $GLOBALS['locale'];
+  $language = array_key_exists('locale', $GLOBALS) ? $GLOBALS['locale'] : NULL;
   $output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="'. $language .'" xml:lang="'. $language .'">
   <head>
@@ -48,7 +104,10 @@
 
   $output .= '</title>
 ';
-  $output .= theme_get_styles();
+  
+  $output .= drupal_get_css();   // in 4.7: $output .= theme_get_styles();  
+  $output .= drupal_get_js(); // New in D6
+  
   $output .= '
   </head>
   <body>
@@ -56,10 +115,14 @@
      <tr>
       <td colspan="' . $colspan . '" style="width: 100%;"><table border="0" cellspacing="0" cellpadding="0" style="width: 100%;" class="goofy"><tr><td>';
   if ($logo = theme_get_setting('logo')) {
-    $output .= l('<img src="'. theme_get_setting('logo') .'" alt="'. t('Home') .'" />', '', array('title' => t('Home')), NULL, NULL, FALSE, TRUE);
+    $output .= l('<img src="'. theme_get_setting('logo') .'" alt="'. t('Home') .'" />', '', 
+      array('attributes' => array('title' => t('Home')), 'html' => TRUE)
+    ); 
   }
   $output .= '</td><td style="text-align: right;">';
-  $logo2 = variable_get('goofy_default_logo2', 1) ? (base_path() . path_to_theme() .'/drupal.png') : variable_get('goofy_logo2', '');
+  $logo2 = variable_get('goofy_default_logo2', 1) 
+    ? (drupal_get_path('theme', 'goofy') .'/drupal.png') 
+    : variable_get('goofy_logo2', '');
   if ($logo2) {
     $output .= '<img src="'. $logo2 .'" alt="" />';
   }
@@ -142,12 +205,16 @@
 }
 
 function goofy_node($node, $teaser = 0, $page = 0) {
-  $img_path = base_path() . path_to_theme() .'/images/';
+  $img_path = drupal_get_path('theme', 'goofy') .'/images/'; // was  base_path() . path_to_theme() . '/images'
   $output = "\n<!-- node: \"". check_plain($node->title) ."\" -->\n";
-  $title = ($teaser ? l($node->title, "node/$node->nid") : check_plain($node->title));
-  $subleft = theme_get_setting("toggle_node_info_$node->type") ? t("Submitted by %a on %b", array("%a" => theme('username', $node), "%b" => format_date($node->created, "large"))) : '';
+  $title = $teaser 
+    ? l($node->title, "node/$node->nid") 
+    : check_plain($node->title);
+  $subleft = theme_get_setting("toggle_node_info_$node->type") 
+    ? t("Submitted by !user on !date", array("!user" => theme('username', $node), "!date" => format_date($node->created, "large"))) 
+    : '';
 
-  if (module_exist("taxonomy")) {
+  if (module_exists("taxonomy")) {
     $terms = taxonomy_link("taxonomy terms", $node);
     $subright = theme("links", $terms);
   }
@@ -217,7 +284,6 @@
   return $output;
 }
 
-
 function goofy_comment($comment, $links = array()) {
   $img_path = base_path() . path_to_theme() .'/images/';
   $output = "\n<!-- comment: \"$comment->subject\" -->\n";
@@ -332,3 +398,22 @@
     return '<div class="help">'. $help .'</div><hr />';
   }
 }
+
+/**
+ * Preserve the old 4.6 look used by Goofy from the then-current default theme
+ *
+ * @param $links
+ * @param $attributes
+ * @return string
+ */
+function goofy_links($links, $attributes = array('class' => 'links')) {
+  $arLinks = array();
+  foreach($links as $link) {
+    if (array_key_exists('attributes', $link)) {
+      $arLinks[] = l($link['title'], $link['href'], array('attributes' => $link['attributes']));
+    } else {
+      $arLinks[] = l($link['title'], $link['href']);
+    }
+  }
+  return implode(' | ', $arLinks); 
+}
\ No newline at end of file

