From 09268e75c807b17b042f85977b2c3cac4ef884b2 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 7 Oct 2011 00:00:13 +1100 Subject: theme error handling --- mod.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'mod.php') diff --git a/mod.php b/mod.php index 62edac7c..792efbb0 100644 --- a/mod.php +++ b/mod.php @@ -374,21 +374,36 @@ $query->bindValue(':theme', $_theme); $query->execute() or error(db_error($query)); + $result = true; $body = ''; if(isset($theme['install_callback'])) { $ret = $theme['install_callback']($theme['config']); - if($ret && !empty($ret)) + if($ret && !empty($ret)) { + if(is_array($ret) && count($ret) == 2) { + $result = $ret[0]; + $ret = $ret[1]; + } $body .= '
' . $ret . '
'; + } + } + + if($result) { + $body .= '

Successfully installed and built theme.

'; + } else { + // install failed + $query = prepare("DELETE FROM `theme_settings` WHERE `theme` = :theme"); + $query->bindValue(':theme', $_theme); + $query->execute() or error(db_error($query)); } - $body .= '

Successfully installed and built theme.

' . - '

Go back to themes.

'; + + $body .= '

Go back to themes.

'; // Build themes rebuildThemes('all'); echo Element('page.html', Array( 'config'=>$config, - 'title'=>'Installed "' . utf8tohtml($theme['name']) . '"', + 'title'=>($result ? 'Installed "' . utf8tohtml($theme['name']) . '"' : 'Installation failed!'), 'body'=>$body, 'mod'=>true ) -- cgit v1.3