theme error handling
This commit is contained in:
parent
3b7f7afc97
commit
09268e75c8
23
mod.php
23
mod.php
@ -374,21 +374,36 @@
|
|||||||
$query->bindValue(':theme', $_theme);
|
$query->bindValue(':theme', $_theme);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
|
$result = true;
|
||||||
$body = '';
|
$body = '';
|
||||||
if(isset($theme['install_callback'])) {
|
if(isset($theme['install_callback'])) {
|
||||||
$ret = $theme['install_callback']($theme['config']);
|
$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>';
|
$body .= '<div style="border:1px dashed maroon;padding:20px;margin:auto;max-width:800px">' . $ret . '</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$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>';
|
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"><a href="?/themes">Go back to themes</a>.</p>';
|
||||||
|
|
||||||
// Build themes
|
// Build themes
|
||||||
rebuildThemes('all');
|
rebuildThemes('all');
|
||||||
|
|
||||||
echo Element('page.html', Array(
|
echo Element('page.html', Array(
|
||||||
'config'=>$config,
|
'config'=>$config,
|
||||||
'title'=>'Installed "' . utf8tohtml($theme['name']) . '"',
|
'title'=>($result ? 'Installed "' . utf8tohtml($theme['name']) . '"' : 'Installation failed!'),
|
||||||
'body'=>$body,
|
'body'=>$body,
|
||||||
'mod'=>true
|
'mod'=>true
|
||||||
)
|
)
|
||||||
|
@ -27,4 +27,16 @@ Requires $config[\'boards\'] and $config[\'categories\'].';
|
|||||||
|
|
||||||
// Unique function name for building everything
|
// Unique function name for building everything
|
||||||
$theme['build_function'] = 'categories_build';
|
$theme['build_function'] = 'categories_build';
|
||||||
|
|
||||||
|
$theme['install_callback'] = 'categories_install';
|
||||||
|
if(!function_exists('categories_install')) {
|
||||||
|
function categories_install($settings) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
if(!isset($config['boards']) || !isset($config['categories'])) {
|
||||||
|
return Array(false, '<h2>Prerequisites not met!</h2>' .
|
||||||
|
'This theme requires $config[\'boards\'] and $config[\'categories\'] to be set.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -121,27 +121,31 @@
|
|||||||
'<li><a class="system" href="javascript:parent.removeFrames()">[Remove Frames]</a></li>' .
|
'<li><a class="system" href="javascript:parent.removeFrames()">[Remove Frames]</a></li>' .
|
||||||
'</ul></fieldset>';
|
'</ul></fieldset>';
|
||||||
|
|
||||||
for($cat = 0; $cat < count($config['categories']); $cat++) {
|
if(isset($config['categories'])) {
|
||||||
$body .= '<fieldset><legend>' . $config['categories'][$cat] . '</legend><ul>';
|
for($cat = 0; $cat < count($config['categories']); $cat++) {
|
||||||
|
$body .= '<fieldset><legend>' . $config['categories'][$cat] . '</legend><ul>';
|
||||||
|
|
||||||
foreach($config['boards'][$cat] as &$board) {
|
foreach($config['boards'][$cat] as &$board) {
|
||||||
$body .= '<li><a href="' .
|
$body .= '<li><a href="' .
|
||||||
sprintf($config['board_path'], $board) .
|
sprintf($config['board_path'], $board) .
|
||||||
'">' . boardTitle($board) . '</a></li>';
|
'">' . boardTitle($board) . '</a></li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$body .= '</ul></fieldset>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$body .= '</ul></fieldset>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($config['custom_categories'] as $name => &$group) {
|
if(isset($config['custom_categories'])) {
|
||||||
$body .= '<fieldset><legend>' . $name . '</legend><ul>';
|
foreach($config['custom_categories'] as $name => &$group) {
|
||||||
|
$body .= '<fieldset><legend>' . $name . '</legend><ul>';
|
||||||
|
|
||||||
foreach($group as $title => &$url) {
|
foreach($group as $title => &$url) {
|
||||||
$body .= '<li><a href="' . $url .
|
$body .= '<li><a href="' . $url .
|
||||||
'">' . $title . '</a></li>';
|
'">' . $title . '</a></li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$body .= '</ul></fieldset>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$body .= '</ul></fieldset>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finish page
|
// Finish page
|
||||||
|
Loading…
Reference in New Issue
Block a user