From 020e760bffc2512fa025e66a050aa3d2ac1245c7 Mon Sep 17 00:00:00 2001
From: Stefan Borchert <stefan.borchert@undpaul.de>
Date: Sat, 4 Jun 2011 14:49:02 +0200
Subject: [PATCH] Issue #1167444: Theme section redesign.

---
 modules/system/system.admin.css |  101 +++++++++++++++++-------
 modules/system/system.admin.inc |  164 +++++++++++++++++++++++++++++----------
 modules/system/system.module    |   26 ++++--
 3 files changed, 209 insertions(+), 82 deletions(-)

diff --git a/modules/system/system.admin.css b/modules/system/system.admin.css
index 43340b5..cc027aa 100644
--- a/modules/system/system.admin.css
+++ b/modules/system/system.admin.css
@@ -65,10 +65,10 @@ div.admin-required {
   font-size: 0.9em;
   color: #444;
 }
-span.admin-disabled {
+span.admin-inactive {
   color: #800;
 }
-span.admin-enabled {
+span.admin-active {
   color: #080;
 }
 span.admin-missing {
@@ -157,7 +157,7 @@ table.screenshot {
 .system-themes-list {
   margin-bottom: 20px;
 }
-.system-themes-list-disabled {
+.system-themes-list-inactive {
   border-top: 1px solid #cdcdcd;
   padding-top: 20px;
 }
@@ -169,27 +169,25 @@ table.screenshot {
 }
 .theme-selector .screenshot,
 .theme-selector .no-screenshot {
-  border: 1px solid #e0e0d8;
-  padding: 2px;
   vertical-align: bottom;
-  width: 294px;
-  height: 219px;
-  line-height: 219px;
+  width: 160px;
+  height: 120px;
+  line-height: 120px;
   text-align: center;
 }
 .theme-default .screenshot {
-  border: 1px solid #aaa;
+  border-width: 0px;
 }
-.system-themes-list-enabled .theme-selector .screenshot,
-.system-themes-list-enabled .theme-selector .no-screenshot {
-  float: left; /* LTR */
-  margin: 0 20px 0 0; /* LTR */
+.system-themes-list-active .theme-selector .screenshot,
+.system-themes-list-active .theme-selector .no-screenshot {
+  /* margin: 0 20px 0 0; *//* LTR */
 }
-.system-themes-list-disabled .theme-selector .screenshot,
-.system-themes-list-disabled .theme-selector .no-screenshot {
-  width: 194px;
-  height: 144px;
-  line-height: 144px;
+.system-themes-list-inactive .theme-selector .screenshot,
+.system-themes-list-inactive .theme-selector .no-screenshot {
+  width: 160px;
+  height: 120px;
+  line-height: 120px;
+  float: left;
 }
 .theme-selector h3 {
   font-weight: normal;
@@ -197,19 +195,54 @@ table.screenshot {
 .theme-default h3 {
   font-weight: bold;
 }
-.system-themes-list-enabled .theme-selector h3 {
+.system-themes-list-active .theme-selector {
+  float: left;
+  display: inline-block;
+  width: 202px;
+  height: 230px;
+  margin: 22px 22px 0 0;
+  padding: 44px 0 12px 0;
+  background: #f2f2f2;
+}
+.system-themes-list-active .theme-default {
+  padding-top: 0;
+  height: 274px;
+}
+.system-themes-list-active .theme-selector h3,
+.system-themes-list-inactive .theme-selector h3 {
   margin-top: 0;
+  font-size: 1em;
 }
-.system-themes-list-disabled .theme-selector {
-  width: 300px;
-  float: left; /* LTR */
-  padding: 20px 20px 20px 0; /* LTR */
+.system-themes-list-active .theme-selector h3 {
+  color: #666666;
+}
+.system-themes-list-inactive .theme-selector h3 {
+  font-size: 1.1em;
 }
-.system-themes-list-enabled .theme-info {
+.system-themes-list-inactive .theme-selector {
   max-width: 940px;
+  background: #f2f2f2;
+  padding: 20px; /* LTR */
+}
+.system-themes-list-active .theme-status {
+  line-height: 1.2em;
+  display: inline-block;
+  width: 162px;
+  padding: 14px 20px;
+  background: #666666;
+  color: #ffffff;
+}
+.system-themes-list-active .theme-info {
+  padding: 10px 20px 0 20px;
+}
+.system-themes-list-inactive .theme-info {
+  padding: 0 20px 0 0;
+}
+.system-themes-list-inactive .theme-selector img {
+  margin: 0 20px 0 0;
 }
-.system-themes-list-disabled .theme-info {
-  min-height: 170px;
+.system-themes-list-inactive .theme-description {
+  color: #666666;
 }
 .theme-selector .incompatible {
   margin-top: 10px;
@@ -219,20 +252,26 @@ table.screenshot {
   margin: 10px 0 0 0;
   padding: 0;
 }
+.system-themes-list-inactive .theme-selector .operations {
+  margin-top: 0;
+}
 .theme-selector .operations li {
-  float: left; /* LTR */
   margin: 0;
-  padding: 0 0.7em;
   list-style-type: none;
+}
+.system-themes-list-inactive .theme-selector .operations li {
+  float: left; /* LTR */
+  padding: 0 0.7em;
   border-right: 1px solid #cdcdcd;  /* LTR */
 }
-.theme-selector .operations li.last {
+.system-themes-list-inactive .theme-selector .operations li.last {
   padding: 0 0 0 0.7em; /* LTR */
   border-right: none; /* LTR */
 }
-.theme-selector .operations li.first {
+.system-themes-list-inactive .theme-selector .operations li.first {
   padding: 0 0.7em 0 0; /* LTR */
-}
+ }
+
 #system-themes-admin-form {
   clear: left;
 }
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index 9e7d69d..bc26f44 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -177,21 +177,21 @@ function system_themes_page() {
       $query['theme'] = $theme->name;
       if (drupal_theme_access($theme)) {
         $theme->operations[] = array(
-          'title' => t('Settings'),
-          'href' => 'admin/appearance/settings/' . $theme->name,
-          'attributes' => array('title' => t('Settings for !theme theme', array('!theme' => $theme->info['name']))),
+          'title' => t('Configure'),
+          'href' => 'admin/appearance/configure/' . $theme->name,
+          'attributes' => array('title' => t('Configure !theme', array('!theme' => $theme->info['name']))),
         );
       }
       if (!empty($theme->status)) {
         if (!$theme->is_default) {
           $theme->operations[] = array(
-            'title' => t('Disable'),
-            'href' => 'admin/appearance/disable',
+            'title' => t('Deactivate'),
+            'href' => 'admin/appearance/deactivate',
             'query' => $query,
-            'attributes' => array('title' => t('Disable !theme theme', array('!theme' => $theme->info['name']))),
+            'attributes' => array('title' => t('Deactivate !theme', array('!theme' => $theme->info['name']))),
           );
           $theme->operations[] = array(
-            'title' => t('Set default'),
+            'title' => t('Set as default theme'),
             'href' => 'admin/appearance/default',
             'query' => $query,
             'attributes' => array('title' => t('Set !theme as default theme', array('!theme' => $theme->info['name']))),
@@ -200,16 +200,16 @@ function system_themes_page() {
       }
       else {
         $theme->operations[] = array(
-          'title' => t('Enable'),
-          'href' => 'admin/appearance/enable',
+          'title' => t('Activate'),
+          'href' => 'admin/appearance/activate',
           'query' => $query,
-          'attributes' => array('title' => t('Enable !theme theme', array('!theme' => $theme->info['name']))),
+          'attributes' => array('title' => t('Activate !theme', array('!theme' => $theme->info['name']))),
         );
         $theme->operations[] = array(
-          'title' => t('Enable and set default'),
+          'title' => t('Activate and set as default'),
           'href' => 'admin/appearance/default',
           'query' => $query,
-          'attributes' => array('title' => t('Enable !theme as default theme', array('!theme' => $theme->info['name']))),
+          'attributes' => array('title' => t('Activate !theme and set as default theme', array('!theme' => $theme->info['name']))),
         );
       }
     }
@@ -223,18 +223,18 @@ function system_themes_page() {
     }
 
     // Sort enabled and disabled themes into their own groups.
-    $theme_groups[$theme->status ? 'enabled' : 'disabled'][] = $theme;
+    $theme_groups[$theme->status ? 'active' : 'inactive'][] = $theme;
   }
 
   // There are two possible theme groups.
   $theme_group_titles = array(
-    'enabled' => format_plural(count($theme_groups['enabled']), 'Enabled theme', 'Enabled themes'),
+    'active' => format_plural(count($theme_groups['active']), 'Active theme', 'Active themes'),
   );
-  if (!empty($theme_groups['disabled'])) {
-    $theme_group_titles['disabled'] = format_plural(count($theme_groups['disabled']), 'Disabled theme', 'Disabled themes');
+  if (!empty($theme_groups['inactive'])) {
+    $theme_group_titles['inactive'] = format_plural(count($theme_groups['inactive']), 'Inactive theme', 'Inactive themes');
   }
 
-  uasort($theme_groups['enabled'], 'system_sort_themes');
+  uasort($theme_groups['active'], 'system_sort_themes');
   drupal_alter('system_themes_page', $theme_groups);
 
   $admin_form = drupal_get_form('system_themes_admin_form', $admin_theme_options);
@@ -2645,37 +2645,117 @@ function theme_system_themes_page($variables) {
     $output .= '<div class="system-themes-list system-themes-list-'. $state .' clearfix"><h2>'. $title .'</h2>';
 
     foreach ($theme_groups[$state] as $theme) {
+      $theme_function = "system_themes_page_theme_{$state}";
+      if (function_exists("theme_{$theme_function}")) {
+        $output .= theme($theme_function, array('theme' => $theme));
+      }
+    }
+    $output .= '</div>';
+  }
+  $output .= '</div>';
+
+  return $output;
+}
+
+/**
+ * Returns HTML for active theme on page Appearance.
+ *
+ * @param $variables
+ *   An associative array containing:
+ *   - theme: An object containing the theme information.
+ *
+ * @ingroup themeable
+ */
+function theme_system_themes_page_theme_active($variables) {
+  if (!isset($variables['theme'])) {
+    return '';
+  }
+  $theme = $variables['theme'];
+  $output = '';
+  // Theme the screenshot.
+  $screenshot = $theme->screenshot ? theme('image', $theme->screenshot) : '<div class="no-screenshot">' . t('no screenshot') . '</div>';
 
-      // Theme the screenshot.
-      $screenshot = $theme->screenshot ? theme('image', $theme->screenshot) : '<div class="no-screenshot">' . t('no screenshot') . '</div>';
+  // Localize the theme description.
+  $description = t($theme->info['description']);
 
-      // Localize the theme description.
-      $description = t($theme->info['description']);
+  // Additional notes.
+  $notes = count($theme->notes) ? ' (' . join(', ', $theme->notes) . ')' : '';
 
-      // Style theme info
-      $notes = count($theme->notes) ? ' (' . join(', ', $theme->notes) . ')' : '';
-      $theme->classes[] = 'theme-selector';
-      $theme->classes[] = 'clearfix';
-      $output .= '<div class="'. join(' ', $theme->classes) .'">' . $screenshot . '<div class="theme-info"><h3>' . $theme->info['name'] . ' ' . (isset($theme->info['version']) ? $theme->info['version'] : '') . $notes . '</h3><div class="theme-description">' . $description . '</div>';
+  // Style theme info
+  $theme->classes[] = 'theme-selector';
+  $theme->classes[] = 'clearfix';
+  $output .= '<div class="'. join(' ', $theme->classes) .'">';
+  if ($theme->is_default) {
+    $output .= '<div class="theme-status">' . t('Current default theme')  . '</div>';
+  }
+  $output .= '<div class="theme-info"><h3>' . $theme->info['name'] . (isset($theme->info['version']) ? ' ' . $theme->info['version'] : '') . '</h3>';
+  $output .= $screenshot;
 
-      // Make sure to provide feedback on compatibility.
-      if (!empty($theme->incompatible_core)) {
-        $output .= '<div class="incompatible">' . t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY)) . '</div>';
-      }
-      elseif (!empty($theme->incompatible_php)) {
-        if (substr_count($theme->info['php'], '.') < 2) {
-          $theme->info['php'] .= '.*';
-        }
-        $output .= '<div class="incompatible">' . t('This theme requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $theme->info['php'], '!php_version' => phpversion())) . '</div>';
-      }
-      else {
-        $output .= theme('links', array('links' => $theme->operations, 'attributes' => array('class' => array('operations', 'clearfix'))));
-      }
-      $output .= '</div></div>';
+  // Make sure to provide feedback on compatibility.
+  if (!empty($theme->incompatible_core)) {
+    $output .= '<div class="incompatible">' . t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY)) . '</div>';
+  }
+  elseif (!empty($theme->incompatible_php)) {
+    if (substr_count($theme->info['php'], '.') < 2) {
+      $theme->info['php'] .= '.*';
     }
-    $output .= '</div>';
+    $output .= '<div class="incompatible">' . t('This theme requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $theme->info['php'], '!php_version' => phpversion())) . '</div>';
   }
-  $output .= '</div>';
+  else {
+    $output .= theme('links', array('links' => $theme->operations, 'attributes' => array('class' => array('operations', 'clearfix'))));
+  }
+  $output .= '</div></div>';
+
+  return $output;
+}
+
+/**
+ * Returns HTML for inactive theme on page Appearance.
+ *
+ * @param $variables
+ *   An associative array containing:
+ *   - theme: An object containing the theme information.
+ *
+ * @ingroup themeable
+ */
+function theme_system_themes_page_theme_inactive($variables) {
+  if (!isset($variables['theme'])) {
+    return '';
+  }
+  $theme = $variables['theme'];
+  $output = '';
+  // Theme the screenshot.
+  $screenshot = $theme->screenshot ? theme('image', $theme->screenshot) : '<div class="no-screenshot">' . t('no screenshot') . '</div>';
+
+  // Localize the theme description.
+  $description = t($theme->info['description']);
+
+  // Additional notes.
+  $notes = count($theme->notes) ? ' (' . join(', ', $theme->notes) . ')' : '';
+
+  // Style theme info
+  $theme->classes[] = 'theme-selector';
+  $theme->classes[] = 'clearfix';
+  $output .= '<div class="'. join(' ', $theme->classes) .'">';
+
+  $output .= $screenshot;
+  $output .= '<div class="theme-info"><h3>' . $theme->info['name'] . (isset($theme->info['version']) ? ' ' . $theme->info['version'] : '') . '</h3>';
+  $output .= '<div class="theme-description">' . $description . '</div>';
+
+  // Make sure to provide feedback on compatibility.
+  if (!empty($theme->incompatible_core)) {
+    $output .= '<div class="incompatible">' . t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY)) . '</div>';
+  }
+  elseif (!empty($theme->incompatible_php)) {
+    if (substr_count($theme->info['php'], '.') < 2) {
+      $theme->info['php'] .= '.*';
+    }
+    $output .= '<div class="incompatible">' . t('This theme requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $theme->info['php'], '!php_version' => phpversion())) . '</div>';
+  }
+  else {
+    $output .= theme('links', array('links' => $theme->operations, 'attributes' => array('class' => array('operations', 'clearfix'))));
+  }
+  $output .= '</div></div>';
 
   return $output;
 }
diff --git a/modules/system/system.module b/modules/system/system.module
index 3ebc657..dffe916 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -150,6 +150,14 @@ function system_theme() {
       'variables' => array('theme_groups' => NULL),
       'file' => 'system.admin.inc',
     ),
+    'system_themes_page_theme_active' => array(
+      'variables' => array('theme' => NULL),
+      'file' => 'system.admin.inc',
+    ),
+    'system_themes_page_theme_inactive' => array(
+      'variables' => array('theme' => NULL),
+      'file' => 'system.admin.inc',
+    ),
     'system_settings_form' => array(
       'render element' => 'form',
     ),
@@ -597,15 +605,15 @@ function system_menu() {
     'weight' => -1,
     'file' => 'system.admin.inc',
   );
-  $items['admin/appearance/enable'] = array(
-    'title' => 'Enable theme',
+  $items['admin/appearance/activate'] = array(
+    'title' => 'Activate theme',
     'page callback' => 'system_theme_enable',
     'access arguments' => array('administer themes'),
     'type' => MENU_CALLBACK,
     'file' => 'system.admin.inc',
   );
-  $items['admin/appearance/disable'] = array(
-    'title' => 'Disable theme',
+  $items['admin/appearance/deactivate'] = array(
+    'title' => 'Deactivate theme',
     'page callback' => 'system_theme_disable',
     'access arguments' => array('administer themes'),
     'type' => MENU_CALLBACK,
@@ -618,8 +626,8 @@ function system_menu() {
     'type' => MENU_CALLBACK,
     'file' => 'system.admin.inc',
   );
-  $items['admin/appearance/settings'] = array(
-    'title' => 'Settings',
+  $items['admin/appearance/configure'] = array(
+    'title' => 'Configure',
     'description' => 'Configure default and theme specific settings.',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('system_theme_settings'),
@@ -629,14 +637,14 @@ function system_menu() {
     'weight' => 20,
   );
   // Theme configuration subtabs.
-  $items['admin/appearance/settings/global'] = array(
-    'title' => 'Global settings',
+  $items['admin/appearance/configure/global'] = array(
+    'title' => 'Global theme configuration',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -1,
   );
 
   foreach (list_themes() as $key => $theme) {
-    $items['admin/appearance/settings/' . $theme->name] = array(
+    $items['admin/appearance/configure/' . $theme->name] = array(
       'title' => $theme->info['name'],
       'page arguments' => array('system_theme_settings', $theme->name),
       'type' => MENU_LOCAL_TASK,
-- 
1.7.4

