From 363268ab990454feec7d88f148716af04d42014c Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 22 Mar 2010 15:03:43 +0000 Subject: [PATCH] ture 1514: improvement, impossible to activate a theme is a parent is missing (a parent includes grand father and his own father, and his own father, and so on... until the root theme is "default" or has no parent declared) git-svn-id: http://piwigo.org/svn/trunk@5259 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/include/themes.class.php | 36 +++++++++++++++++++ .../default/template/themes_installed.tpl | 8 +++++ admin/themes_installed.php | 21 ++++++++--- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/admin/include/themes.class.php b/admin/include/themes.class.php index ad32b6f7f..82622d878 100644 --- a/admin/include/themes.class.php +++ b/admin/include/themes.class.php @@ -80,6 +80,20 @@ class themes // the theme is already active break; } + + $missing_parent = $this->missing_parent_theme($theme_id); + if (isset($missing_parent)) + { + array_push( + $errors, + sprintf( + l10n('Impossible to activate this theme, the parent theme is missing: %s'), + $missing_parent + ) + ); + + break; + } $query = " INSERT INTO ".THEMES_TABLE." @@ -168,6 +182,28 @@ DELETE return $errors; } + function missing_parent_theme($theme_id) + { + if (!isset($this->fs_themes[$theme_id]['parent'])) + { + return null; + } + + $parent = $this->fs_themes[$theme_id]['parent']; + + if ('default' == $parent) + { + return null; + } + + if (!isset($this->fs_themes[$parent])) + { + return $parent; + } + + return $this->missing_parent_theme($parent); + } + function get_children_themes($theme_id) { $children = array(); diff --git a/admin/themes/default/template/themes_installed.tpl b/admin/themes/default/template/themes_installed.tpl index 0a5a0cc85..4b050c51c 100644 --- a/admin/themes/default/template/themes_installed.tpl +++ b/admin/themes/default/template/themes_installed.tpl @@ -33,13 +33,21 @@
{$theme.name}
+ + {if $theme.activable} {'Activate'|@translate} + {else} + {'Activate'|@translate} + {/if} + | + {if $theme.deletable} {'Delete'|@translate} {else} {'Delete'|@translate} {/if} +
diff --git a/admin/themes_installed.php b/admin/themes_installed.php index 82efe569a..dda2ab6ed 100644 --- a/admin/themes_installed.php +++ b/admin/themes_installed.php @@ -89,7 +89,24 @@ foreach ($themes->fs_themes as $theme_id => $fs_theme) } else { + // is the theme "activable" ? + $fs_theme['activable'] = true; + + $missing_parent = $themes->missing_parent_theme($theme_id); + if (isset($missing_parent)) + { + $fs_theme['activable'] = false; + + $fs_theme['activate_tooltip'] = sprintf( + l10n('Impossible to activate this theme, the parent theme is missing: %s'), + $missing_parent + ); + } + + // is the theme "deletable" ? $children = $themes->get_children_themes($theme_id); + + $fs_theme['deletable'] = true; if (count($children) > 0) { @@ -100,10 +117,6 @@ foreach ($themes->fs_themes as $theme_id => $fs_theme) implode(', ', $children) ); } - else - { - $fs_theme['deletable'] = true; - } array_push($inactive_themes, $fs_theme); }