diff options
| author | Savetheinternet <savetheinternet@tinyboard.org> | 2011-10-07 00:00:13 +1100 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@tinyboard.org> | 2011-10-07 00:00:13 +1100 |
| commit | 09268e75c807b17b042f85977b2c3cac4ef884b2 (patch) | |
| tree | 255d26ad7f18d6ef147a0df3ad4e3ee2760c019e /mod.php | |
| parent | 3b7f7afc9737153662feb4e64ee2ea9ebf736caa (diff) | |
theme error handling
Diffstat (limited to 'mod.php')
| -rw-r--r-- | mod.php | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -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 .= '<div style="border:1px dashed maroon;padding:20px;margin:auto;max-width:800px">' . $ret . '</div>'; + } + } + + if($result) { + $body .= '<p style="text-align:center">Successfully installed and built theme.</p>'; + } else { + // install failed + $query = prepare("DELETE FROM `theme_settings` WHERE `theme` = :theme"); + $query->bindValue(':theme', $_theme); + $query->execute() or error(db_error($query)); } - $body .= '<p style="text-align:center">Successfully installed and built theme.</p>' . - '<p style="text-align:center"><a href="?/themes">Go back to themes</a>.</p>'; + + $body .= '<p style="text-align:center"><a href="?/themes">Go back to themes</a>.</p>'; // 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 ) |
