From 3b7f7afc9737153662feb4e64ee2ea9ebf736caa Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Thu, 6 Oct 2011 23:46:37 +1100 Subject: [PATCH] theme management --- mod.php | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/mod.php b/mod.php index 55358a13..62edac7c 100644 --- a/mod.php +++ b/mod.php @@ -315,7 +315,23 @@ echo Element('page.html', Array( 'config'=>$config, 'title'=>'No theme', - 'body'=>'

Successfully stopped using all themes.

', + 'body'=>'

Successfully uninstalled all themes.

' . + '

Go back to themes.

', + 'mod'=>true + ) + ); + } elseif(preg_match('/^\/themes\/(\w+)\/uninstall$/', $query, $match)) { + if(!hasPermission($config['mod']['themes'])) error($config['error']['noaccess']); + + $query = prepare("DELETE FROM `theme_settings` WHERE `theme` = :theme"); + $query->bindValue(':theme', $match[1]); + $query->execute() or error(db_error($query)); + + echo Element('page.html', Array( + 'config'=>$config, + 'title'=>'Uninstalled', + 'body'=>'

Successfully uninstalled the ' . $match[1] . ' theme.

' . + '

Go back to themes.

', 'mod'=>true ) ); @@ -364,7 +380,8 @@ if($ret && !empty($ret)) $body .= '
' . $ret . '
'; } - $body .= '

Successfully installed and built theme.

'; + $body .= '

Successfully installed and built theme.

' . + '

Go back to themes.

'; // Build themes rebuildThemes('all'); @@ -411,7 +428,13 @@ ); } } else { - + + $themes_in_use = Array(); + $query = query("SELECT `theme` FROM `theme_settings` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error()); + while($theme = $query->fetch()) { + $themes_in_use[$theme['theme']] = true; + } + // Scan directory for themes $themes = Array(); while($file = readdir($dir)) { @@ -445,17 +468,22 @@ '' . '' . 'Thumbnail' . - '' . + '' . '' . '' . 'Actions' . '' . '' . '
'; @@ -463,7 +491,8 @@ $body .= ''; } - $body .= '

Don\'t use a theme.

'; + if(!empty($themes_in_use)) + $body .= '

Uninstall all themes.

'; echo Element('page.html', Array( 'config'=>$config,