From 95d30302cc2a4b431cea5c1ce39fb39081a9c3cd Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 16 Dec 2012 02:04:46 +0100 Subject: [PATCH] Implement new template path structure with theme support --- frontend/api.local.php | 2 + frontend/authenticator.admin.php | 6 +- frontend/authenticator.vps.php | 14 +++-- frontend/module.admin.container.suspend.php | 41 ++++++++----- frontend/module.admin.containers.create.php | 4 +- frontend/module.admin.containers.php | 3 +- frontend/module.admin.node.php | 8 ++- frontend/module.admin.nodes.add.php | 2 +- frontend/module.admin.nodes.php | 2 +- frontend/module.admin.overview.php | 2 +- frontend/module.admin.user.php | 12 +++- frontend/module.admin.users.php | 2 +- frontend/module.list.php | 2 +- frontend/module.login.php | 14 +++-- frontend/module.logout.php | 12 ++-- frontend/module.vps.console.php | 4 +- frontend/module.vps.overview.php | 2 +- frontend/module.vps.password.php | 44 +++++++++----- frontend/module.vps.reinstall.php | 57 ++++++++++++------- frontend/rewrite.php | 23 +++++--- frontend/submodule.restart.php | 24 +++++--- frontend/submodule.start.php | 30 ++++++---- frontend/submodule.stop.php | 30 ++++++---- .../admin/main.tpl} | 0 .../admin/node/add.tpl} | 0 .../admin/node/list.tpl} | 0 .../admin/node/lookup.tpl} | 0 .../admin/overview/index.tpl} | 0 .../admin/user/list.tpl} | 0 .../admin/user/lookup.tpl} | 0 .../admin/vps/add.tpl} | 0 .../admin/vps/list.tpl} | 0 .../admin/vps/suspend.tpl} | 0 .../client/vps/console.tpl} | 0 .../client/vps/error/notfound.tpl} | 0 .../{ => default/client/vps}/list.tpl | 0 .../client/vps/lookup.tpl} | 0 .../client/vps/main.tpl} | 0 .../client/vps/password.tpl} | 0 .../client/vps/reinstall.tpl} | 0 .../shared/error/error.tpl} | 0 .../shared/error/info.tpl} | 0 .../shared/error/success.tpl} | 0 .../shared/error/warning.tpl} | 0 .../templates/{ => default/shared}/login.tpl | 0 .../templates/{ => default/shared}/main.tpl | 0 46 files changed, 227 insertions(+), 113 deletions(-) rename frontend/templates/{main.admin.tpl => default/admin/main.tpl} (100%) rename frontend/templates/{admin.nodes.add.tpl => default/admin/node/add.tpl} (100%) rename frontend/templates/{admin.nodes.tpl => default/admin/node/list.tpl} (100%) rename frontend/templates/{admin.node.tpl => default/admin/node/lookup.tpl} (100%) rename frontend/templates/{admin.overview.tpl => default/admin/overview/index.tpl} (100%) rename frontend/templates/{admin.users.tpl => default/admin/user/list.tpl} (100%) rename frontend/templates/{admin.user.tpl => default/admin/user/lookup.tpl} (100%) rename frontend/templates/{admin.containers.add.tpl => default/admin/vps/add.tpl} (100%) rename frontend/templates/{admin.containers.tpl => default/admin/vps/list.tpl} (100%) rename frontend/templates/{admin.container.suspend.tpl => default/admin/vps/suspend.tpl} (100%) rename frontend/templates/{vps.console.tpl => default/client/vps/console.tpl} (100%) rename frontend/templates/{error.vps.notfound.tpl => default/client/vps/error/notfound.tpl} (100%) rename frontend/templates/{ => default/client/vps}/list.tpl (100%) rename frontend/templates/{vps.overview.tpl => default/client/vps/lookup.tpl} (100%) rename frontend/templates/{main.vps.tpl => default/client/vps/main.tpl} (100%) rename frontend/templates/{vps.password.tpl => default/client/vps/password.tpl} (100%) rename frontend/templates/{vps.reinstall.tpl => default/client/vps/reinstall.tpl} (100%) rename frontend/templates/{errorhandler.error.tpl => default/shared/error/error.tpl} (100%) rename frontend/templates/{errorhandler.info.tpl => default/shared/error/info.tpl} (100%) rename frontend/templates/{errorhandler.success.tpl => default/shared/error/success.tpl} (100%) rename frontend/templates/{errorhandler.warning.tpl => default/shared/error/warning.tpl} (100%) rename frontend/templates/{ => default/shared}/login.tpl (100%) rename frontend/templates/{ => default/shared}/main.tpl (100%) diff --git a/frontend/api.local.php b/frontend/api.local.php index f2d646a..5917f0b 100644 --- a/frontend/api.local.php +++ b/frontend/api.local.php @@ -11,6 +11,8 @@ * licensing text. */ +/* TODO: Switch to PDO here. */ + $_CVM = true; require("includes/include.base.php"); diff --git a/frontend/authenticator.admin.php b/frontend/authenticator.admin.php index 3db4c93..9a2508b 100644 --- a/frontend/authenticator.admin.php +++ b/frontend/authenticator.admin.php @@ -23,8 +23,10 @@ try } catch (InsufficientAccessLevelException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-unauthorized-title'], $locale->strings['error-unauthorized-text']); - $sMainContents .= $err->Render(); + $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-unauthorized-title'], + 'message' => $locale->strings['error-unauthorized-text'] + )); $sRouterAuthenticated = false; diff --git a/frontend/authenticator.vps.php b/frontend/authenticator.vps.php index c06395d..0989c2c 100644 --- a/frontend/authenticator.vps.php +++ b/frontend/authenticator.vps.php @@ -32,19 +32,23 @@ try } catch (ContainerSuspendedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_WARNING, $locale->strings['warning-suspended-title'], $locale->strings['warning-suspended-text']); - $sMainContents .= $err->Render(); + $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/warning", $locale->strings, array( + 'title' => $locale->strings['warning-suspended-title'], + 'message' => $locale->strings['warning-suspended-text'] + )); } catch (ContainerTerminatedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_WARNING, $locale->strings['warning-terminated-title'], $locale->strings['warning-terminated-text']); - $sMainContents .= $err->Render(); + $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/warning", $locale->strings, array( + 'title' => $locale->strings['warning-terminated-title'], + 'message' => $locale->strings['warning-terminated-text'] + )); } } catch(NotFoundException $e) { $router->uVariables['display_menu'] = false; - $sMainContents = Templater::AdvancedParse("error.vps.notfound", $locale->strings, array()); + $sMainContents = Templater::AdvancedParse("{$sTheme}/client/vps/error/notfound", $locale->strings, array()); $sRouterAuthenticated = false; } catch(UnauthorizedException $e) diff --git a/frontend/module.admin.container.suspend.php b/frontend/module.admin.container.suspend.php index d41fc63..1709fff 100644 --- a/frontend/module.admin.container.suspend.php +++ b/frontend/module.admin.container.suspend.php @@ -25,44 +25,59 @@ try { $sContainer->Suspend(); - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-suspend-success-title'], $locale->strings['error-suspend-success-text']); - $sMainContents .= $err->Render(); + $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array( + 'title' => $locale->strings['error-suspend-success-title'], + 'message' => $locale->strings['error-suspend-success-text'] + )); } elseif($_POST['action'] == "unsuspend") { $sContainer->Unsuspend(); - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-unsuspend-success-title'], $locale->strings['error-unsuspend-success-text']); - $sMainContents .= $err->Render(); + $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array( + 'title' => $locale->strings['error-unsuspend-success-title'], + 'message' => $locale->strings['error-unsuspend-success-text'] + )); } $sContainer->RefreshData(); + + /* TODO: Flash message and redirect to VPS lookup page. */ } $sSuspended = ($sContainer->sStatus == CVM_STATUS_SUSPENDED) ? true : false; - $sPageContents = Templater::AdvancedParse("admin.container.suspend", $locale->strings, array( + $sPageContents = Templater::AdvancedParse("{$sTheme}/admin/vps/suspend", $locale->strings, array( 'id' => $sContainer->sId, 'suspended' => $sSuspended )); } catch (InsufficientAccessLevelException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-unauthorized-title'], $locale->strings['error-unauthorized-text']); - $sMainContents .= $err->Render(); + /* TODO: Is this really necessary? */ + $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-unauthorized-title'], + 'message' => $locale->strings['error-unauthorized-text'] + )); } catch (NotFoundException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-notfound-title'], $locale->strings['error-notfound-text']); - $sMainContents .= $err->Render(); + $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-notfound-title'], + 'message' => $locale->strings['error-notfound-text'] + )); } catch (ContainerSuspendException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-suspend-error-title'], $locale->strings['error-suspend-error-text']); - $sMainContents .= $err->Render(); + $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-suspend-error-title'], + 'message' => $locale->strings['error-suspend-error-text'] + )); } catch (ContainerUnsuspendException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-unsuspend-error-title'], $locale->strings['error-unsuspend-error-text']); - $sMainContents .= $err->Render(); + $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-unsuspend-error-title'], + 'message' => $locale->strings['error-unsuspend-error-text'] + )); } diff --git a/frontend/module.admin.containers.create.php b/frontend/module.admin.containers.create.php index 0d1b35a..f4eddc3 100644 --- a/frontend/module.admin.containers.create.php +++ b/frontend/module.admin.containers.create.php @@ -136,6 +136,8 @@ if(isset($_POST['submit'])) $sContainer->InsertIntoDatabase(); $sContainer->Deploy(); + /* TODO: Flash message. */ + redirect("/admin/node/{$node->sId}/"); } } @@ -189,7 +191,7 @@ foreach($result->data as $row) ); } -$sPageContents = Templater::AdvancedParse("admin.containers.add", $locale->strings, array( +$sPageContents = Templater::AdvancedParse("{$sTheme}/admin/vps/add", $locale->strings, array( 'errors' => $sErrors, 'nodes' => $sNodes, 'users' => $sUsers, diff --git a/frontend/module.admin.containers.php b/frontend/module.admin.containers.php index a3789d9..1d9a788 100644 --- a/frontend/module.admin.containers.php +++ b/frontend/module.admin.containers.php @@ -37,6 +37,7 @@ if($result = mysql_query_cached("SELECT * FROM containers")) } } -$sPageContents = Templater::AdvancedParse("admin.containers", $locale->strings, array( +/* TODO: Change variable name to phase out the use of the term "container". */ +$sPageContents = Templater::AdvancedParse("{$sTheme}/admin/vps/list", $locale->strings, array( 'containers' => $sContainerList )); diff --git a/frontend/module.admin.node.php b/frontend/module.admin.node.php index 9de4efe..d39dba8 100644 --- a/frontend/module.admin.node.php +++ b/frontend/module.admin.node.php @@ -39,7 +39,7 @@ try } } - $sPageContents = Templater::AdvancedParse("admin.node", $locale->strings, array( + $sPageContents = Templater::AdvancedParse("{$sTheme}/admin/node/lookup", $locale->strings, array( 'id' => $sNode->sId, 'hostname' => $sNode->sHostname, 'location' => $sNode->sPhysicalLocation, @@ -48,7 +48,9 @@ try } catch (NotFoundException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-admin-node-title'], $locale->strings['error-admin-node-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-admin-node-title'], + 'message' => $locale->strings['error-admin-node-text'] + )); } diff --git a/frontend/module.admin.nodes.add.php b/frontend/module.admin.nodes.add.php index 20329cf..48e3ad2 100644 --- a/frontend/module.admin.nodes.add.php +++ b/frontend/module.admin.nodes.add.php @@ -83,6 +83,6 @@ if(isset($_POST['submit'])) } } -$sPageContents = Templater::AdvancedParse("admin.nodes.add", $locale->strings, array( +$sPageContents = Templater::AdvancedParse("{$sTheme}/admin/node/add", $locale->strings, array( 'errors' => $sErrors )); diff --git a/frontend/module.admin.nodes.php b/frontend/module.admin.nodes.php index a7a2d2a..80fca76 100644 --- a/frontend/module.admin.nodes.php +++ b/frontend/module.admin.nodes.php @@ -29,6 +29,6 @@ if($result = mysql_query_cached("SELECT * FROM nodes")) } } -$sPageContents = Templater::AdvancedParse("admin.nodes", $locale->strings, array( +$sPageContents = Templater::AdvancedParse("{$sTheme}/admin/node/list", $locale->strings, array( 'nodes' => $sNodeList )); diff --git a/frontend/module.admin.overview.php b/frontend/module.admin.overview.php index 544acc2..51dda62 100644 --- a/frontend/module.admin.overview.php +++ b/frontend/module.admin.overview.php @@ -13,4 +13,4 @@ if(!isset($_CVM)) { die("Unauthorized."); } -$sPageContents = Templater::AdvancedParse("admin.overview", $locale->strings, array()); +$sPageContents = Templater::AdvancedParse("{$sTheme}/admin/overview/index", $locale->strings, array()); diff --git a/frontend/module.admin.user.php b/frontend/module.admin.user.php index 8b9a32d..c7bc2cd 100644 --- a/frontend/module.admin.user.php +++ b/frontend/module.admin.user.php @@ -11,6 +11,8 @@ * licensing text. */ +/* TODO: Add "create VPS" button. */ + if(!isset($_CVM)) { die("Unauthorized."); } try @@ -25,6 +27,8 @@ try { $sContainer = new Container($row); + /* TODO: Deal with unreachable servers (SshException). */ + $sContainerList[] = array( 'id' => $sContainer->sId, 'hostname' => $sContainer->sHostname, @@ -41,7 +45,7 @@ try } } - $sPageContents = Templater::AdvancedParse("admin.user", $locale->strings, array( + $sPageContents = Templater::AdvancedParse("{$sTheme}/admin/user/lookup", $locale->strings, array( 'id' => $sUserEntry->sId, 'username' => $sUserEntry->sUsername, 'email' => $sUserEntry->sEmailAddress, @@ -52,7 +56,9 @@ try } catch (NotFoundException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-admin-user-title'], $locale->strings['error-admin-user-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-admin-user-title'], + 'message' => $locale->strings['error-admin-user-text'] + )); } diff --git a/frontend/module.admin.users.php b/frontend/module.admin.users.php index 36abdec..39f79ea 100644 --- a/frontend/module.admin.users.php +++ b/frontend/module.admin.users.php @@ -28,6 +28,6 @@ foreach($result->data as $row) ); } -$sPageContents = Templater::AdvancedParse("admin.users", $locale->strings, array( +$sPageContents = Templater::AdvancedParse("{$sTheme}/admin/user/list", $locale->strings, array( 'users' => $sUserList )); diff --git a/frontend/module.list.php b/frontend/module.list.php index bdb9d9c..c1c7e44 100644 --- a/frontend/module.list.php +++ b/frontend/module.list.php @@ -47,7 +47,7 @@ if($sLoggedIn === true) ); } - $sMainContents = Templater::AdvancedParse("list", $locale->strings, array( + $sMainContents = Templater::AdvancedParse("{$sTheme}/client/vps/list", $locale->strings, array( 'containers' => $sContainerList )); } diff --git a/frontend/module.login.php b/frontend/module.login.php index 7cd7ead..01ad5cf 100644 --- a/frontend/module.login.php +++ b/frontend/module.login.php @@ -39,18 +39,22 @@ if(isset($_POST['submit'])) } else { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-login-invalid-title'], $locale->strings['error-login-invalid-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-login-invalid-title'], + 'message' => $locale->strings['error-login-invalid-text'] + )); } } else { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-login-invalid-title'], $locale->strings['error-login-invalid-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-login-invalid-title'], + 'message' => $locale->strings['error-login-invalid-text'] + )); } } -$sMainContents = Templater::AdvancedParse("login", $locale->strings, array( +$sMainContents = Templater::AdvancedParse("{$sTheme}/shared/login", $locale->strings, array( 'error' => $sError, 'field-username' => $sFieldUsername )); diff --git a/frontend/module.logout.php b/frontend/module.logout.php index 5650931..b3f5a1c 100644 --- a/frontend/module.logout.php +++ b/frontend/module.logout.php @@ -19,11 +19,15 @@ if($sLoggedIn === true) $sUser = new User(0); $sLoggedIn = false; - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-logout-success-title'], $locale->strings['error-logout-success-text']); - $sMainContents .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array( + 'title' => $locale->strings['error-logout-success-title'], + 'message' => $locale->strings['error-logout-success-text'] + )); } else { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-logout-notloggedin-title'], $locale->strings['error-logout-notloggedin-text']); - $sMainContents .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-logout-notloggedin-title'], + 'message' => $locale->strings['error-logout-notloggedin-text'] + )); } diff --git a/frontend/module.vps.console.php b/frontend/module.vps.console.php index b6678ac..0b7ee8e 100644 --- a/frontend/module.vps.console.php +++ b/frontend/module.vps.console.php @@ -13,6 +13,8 @@ if(!isset($_CVM)) { die("Unauthorized."); } -$sPageContents .= Templater::AdvancedParse("vps.console", $locale->strings, array( +/* TODO: Specify user, password and port as variables. */ + +$sPageContents .= Templater::AdvancedParse("{$sTheme}/client/vps/console", $locale->strings, array( 'host' => htmlspecialchars($_SERVER['SERVER_NAME']) )); diff --git a/frontend/module.vps.overview.php b/frontend/module.vps.overview.php index a7fc8d1..34b1a87 100644 --- a/frontend/module.vps.overview.php +++ b/frontend/module.vps.overview.php @@ -95,5 +95,5 @@ catch (SshExitException $e) } -$sPageContents = Templater::AdvancedParse("vps.overview", $locale->strings, $sVariables); +$sPageContents = Templater::AdvancedParse("{$sTheme}/client/vps/lookup", $locale->strings, $sVariables); diff --git a/frontend/module.vps.password.php b/frontend/module.vps.password.php index eb4bd84..f52292e 100644 --- a/frontend/module.vps.password.php +++ b/frontend/module.vps.password.php @@ -25,44 +25,58 @@ if(isset($_POST['submit'])) { $sContainer->SetRootPassword($_POST['password']); - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-password-success-title'], $locale->strings['error-password-success-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array( + 'title' => $locale->strings['error-password-success-title'], + 'message' => $locale->strings['error-password-success-text'] + )); } else { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-password-nomatch-title'], $locale->strings['error-password-nomatch-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-password-nomatch-title'], + 'message' => $locale->strings['error-password-nomatch-text'] + )); } } else { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-password-missing-title'], $locale->strings['error-password-missing-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-password-missing-title'], + 'message' => $locale->strings['error-password-missing-text'] + )); } } catch (ContainerSuspendedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-password-suspended-title'], $locale->strings['error-password-suspended-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-password-suspended-title'], + 'message' => $locale->strings['error-password-suspended-text'] + )); } catch (ContainerTerminatedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-password-terminated-title'], $locale->strings['error-password-terminated-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-password-terminated-title'], + 'message' => $locale->strings['error-password-terminated-text'] + )); } catch (SshExitException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-password-invalid-title'], $locale->strings['error-password-invalid-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-password-invalid-title'], + 'message' => $locale->strings['error-password-invalid-text'] + )); } } if($display_form === true) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_WARNING, $locale->strings['warning-password-title'], $locale->strings['warning-password-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/warning", $locale->strings, array( + 'title' => $locale->strings['warning-password-title'], + 'message' => $locale->strings['warning-password-text'] + )); - $sPageContents .= Templater::AdvancedParse("vps.password", $locale->strings, array( + $sPageContents .= Templater::AdvancedParse("{$sTheme}/client/vps/password", $locale->strings, array( 'id' => $sContainer->sId )); } diff --git a/frontend/module.vps.reinstall.php b/frontend/module.vps.reinstall.php index 0268f4c..6d37ecd 100644 --- a/frontend/module.vps.reinstall.php +++ b/frontend/module.vps.reinstall.php @@ -32,50 +32,69 @@ if(isset($_POST['submit'])) $sContainer->Reinstall(); $sContainer->Start(); - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-reinstall-success-title'], $locale->strings['error-reinstall-success-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array( + 'title' => $locale->strings['error-reinstall-success-title'], + 'message' => $locale->strings['error-reinstall-success-text'] + )); } else { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-confirm-title'], $locale->strings['error-reinstall-confirm-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-reinstall-confirm-title'], + 'message' => $locale->strings['error-reinstall-confirm-text'] + )); } } catch (NotFoundException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-notfound-title'], $locale->strings['error-reinstall-notfound-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-reinstall-notfound-title'], + 'message' => $locale->strings['error-reinstall-notfound-text'] + )); } catch (TemplateUnavailableException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-unavailable-title'], $locale->strings['error-reinstall-unavailable-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-reinstall-unavailable-title'], + 'message' => $locale->strings['error-reinstall-unavailable-text'] + )); } catch (ContainerReinstallException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-failed-title'], $locale->strings['error-reinstall-failed-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-reinstall-failed-title'], + 'message' => $locale->strings['error-reinstall-failed-text'] + )); } catch (ContainerStartException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_WARNING, $locale->strings['error-reinstall-start-title'], $locale->strings['error-reinstall-start-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-reinstall-start-title'], + 'message' => $locale->strings['error-reinstall-start-text'] + )); } catch (ContainerSuspendedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-suspended-title'], $locale->strings['error-reinstall-suspended-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-reinstall-suspended-title'], + 'message' => $locale->strings['error-reinstall-suspended-text'] + )); } catch (ContainerTerminatedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-terminated-title'], $locale->strings['error-reinstall-terminated-text']); - $sPageContents .= $err->Render(); + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-reinstall-terminated-title'], + 'message' => $locale->strings['error-reinstall-terminated-text'] + )); } } else { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "No template selected", "You did not select a template from the list. Please select a template and try again."); - $sPageContents .= $err->Render(); + /* TODO: Grab text from locale file. */ + $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => "No template selected", + 'message' => "You did not select a template from the list. Please select a template and try again." + )); } } @@ -95,7 +114,7 @@ if($display_form === true) ); } - $sPageContents .= Templater::AdvancedParse("vps.reinstall", $locale->strings, array( + $sPageContents .= Templater::AdvancedParse("{$sTheme}/client/vps/reinstall", $locale->strings, array( 'templates' => $sTemplateList )); } diff --git a/frontend/rewrite.php b/frontend/rewrite.php index 8dfbde0..d2636e2 100644 --- a/frontend/rewrite.php +++ b/frontend/rewrite.php @@ -16,6 +16,8 @@ $timing_start = microtime(true); $_CVM = true; require("includes/include.base.php"); +$sTheme = "default"; + $sTemplateParameters = array(); if(!empty($_SESSION['userid'])) @@ -201,18 +203,24 @@ try } catch (ContainerSuspendedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Container is suspended", $e->getMessage()); - $sError .= $err->Render(); + /* TODO: Grab error title from locale file? */ + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => "Container is suspended", + 'message' => $e->getMessage() + )); } catch (ContainerTerminatedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Container is terminated", $e->getMessage()); - $sError .= $err->Render(); + /* TODO: Grab error title from locale file? */ + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => "Container is terminated", + 'message' => $e->getMessage() + )); } if($router->uVariables['menu'] == "vps" && $router->uVariables['display_menu'] === true) { - $sMainContents .= Templater::AdvancedParse("main.vps", $locale->strings, array( + $sMainContents .= Templater::AdvancedParse("{$sTheme}/client/vps/main", $locale->strings, array( 'error' => $sError, 'contents' => $sPageContents, 'id' => $sContainer->sId @@ -220,7 +228,7 @@ try } elseif($router->uVariables['menu'] == "admin" && $router->uVariables['display_menu'] === true) { - $sMainContents .= Templater::AdvancedParse("main.admin", $locale->strings, array( + $sMainContents .= Templater::AdvancedParse("{$sTheme}/admin/main", $locale->strings, array( 'error' => $sError, 'contents' => $sPageContents )); @@ -228,6 +236,7 @@ try } catch (UnauthorizedException $e) { + /* TODO: Create a proper template for this. */ $sPageTitle = "Unauthorized"; $sMainContents = "You are not authorized to view this page."; } @@ -240,4 +249,4 @@ $sTemplateParameters = array_merge($sTemplateParameters, array( 'generation' => "" )); -echo(Templater::AdvancedParse("main", $locale->strings, $sTemplateParameters)); +echo(Templater::AdvancedParse("{$sTheme}/shared/main", $locale->strings, $sTemplateParameters)); diff --git a/frontend/submodule.restart.php b/frontend/submodule.restart.php index 3e2396f..13d9925 100644 --- a/frontend/submodule.restart.php +++ b/frontend/submodule.restart.php @@ -27,21 +27,29 @@ try $sContainer->Start(); $sContainer->sCurrentStatus = CVM_STATUS_STARTED; - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-restart-success-title'], $locale->strings['error-restart-success-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array( + 'title' => $locale->strings['error-stop-restart-success'], + 'message' => $locale->strings['error-stop-restart-success'] + )); } catch (ContainerSuspendedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-restart-suspended-title'], $locale->strings['error-restart-suspended-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-restart-suspended-title'], + 'message' => $locale->strings['error-restart-suspended-text'] + )); } catch (ContainerTerminatedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-restart-terminated-title'], $locale->strings['error-restart-terminated-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-restart-terminated-title'], + 'message' => $locale->strings['error-restart-terminated-text'] + )); } catch(ContainerStartException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-restart-start-title'], $locale->strings['error-restart-start-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-restart-start-title'], + 'message' => $locale->strings['error-restart-start-text'] + )); } diff --git a/frontend/submodule.start.php b/frontend/submodule.start.php index 7790529..03ce7e0 100644 --- a/frontend/submodule.start.php +++ b/frontend/submodule.start.php @@ -20,27 +20,37 @@ if($sContainer->sCurrentStatus != CVM_STATUS_STARTED) $sContainer->Start(); $sContainer->sCurrentStatus = CVM_STATUS_STARTED; - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-start-success-title'], $locale->strings['error-start-success-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array( + 'title' => $locale->strings['error-start-success-title'], + 'message' => $locale->strings['error-start-success-text'] + )); } catch (ContainerSuspendedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-start-suspended-title'], $locale->strings['error-start-suspended-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-start-suspended-title'], + 'message' => $locale->strings['error-start-suspended-text'] + )); } catch (ContainerTerminatedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-start-terminated-title'], $locale->strings['error-start-terminated-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-start-terminated-title'], + 'message' => $locale->strings['error-start-terminated-text'] + )); } catch (ContainerStartException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-start-failed-title'], $locale->strings['error-start-failed-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-start-failed-title'], + 'message' => $locale->strings['error-start-failed-text'] + )); } } else { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-start-running-title'], $locale->strings['error-start-running-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-start-running-title'], + 'message' => $locale->strings['error-start-running-text'] + )); } diff --git a/frontend/submodule.stop.php b/frontend/submodule.stop.php index 3e56bb3..aacefd8 100644 --- a/frontend/submodule.stop.php +++ b/frontend/submodule.stop.php @@ -20,27 +20,37 @@ if($sContainer->sCurrentStatus != CVM_STATUS_STOPPED) $sContainer->Stop(); $sContainer->sCurrentStatus = CVM_STATUS_STOPPED; - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-stop-success-title'], $locale->strings['error-stop-success-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array( + 'title' => $locale->strings['error-stop-success-title'], + 'message' => $locale->strings['error-stop-success-text'] + )); } catch (ContainerSuspendedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-stop-suspended-title'], $locale->strings['error-stop-suspended-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-stop-suspended-title'], + 'message' => $locale->strings['error-stop-suspended-text'] + )); } catch (ContainerTerminatedException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-stop-terminated-title'], $locale->strings['error-stop-terminated-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-stop-terminated-title'], + 'message' => $locale->strings['error-stop-terminated-text'] + )); } catch(ContainerStopException $e) { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-stop-failed-title'], $locale->strings['error-stop-failed-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-stop-failed-title'], + 'message' => $locale->strings['error-stop-failed-text'] + )); } } else { - $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-stop-stopped-title'], $locale->strings['error-stop-stopped-text']); - $sError .= $err->Render(); + $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array( + 'title' => $locale->strings['error-stop-stopped-title'], + 'message' => $locale->strings['error-stop-stopped-text'] + )); } diff --git a/frontend/templates/main.admin.tpl b/frontend/templates/default/admin/main.tpl similarity index 100% rename from frontend/templates/main.admin.tpl rename to frontend/templates/default/admin/main.tpl diff --git a/frontend/templates/admin.nodes.add.tpl b/frontend/templates/default/admin/node/add.tpl similarity index 100% rename from frontend/templates/admin.nodes.add.tpl rename to frontend/templates/default/admin/node/add.tpl diff --git a/frontend/templates/admin.nodes.tpl b/frontend/templates/default/admin/node/list.tpl similarity index 100% rename from frontend/templates/admin.nodes.tpl rename to frontend/templates/default/admin/node/list.tpl diff --git a/frontend/templates/admin.node.tpl b/frontend/templates/default/admin/node/lookup.tpl similarity index 100% rename from frontend/templates/admin.node.tpl rename to frontend/templates/default/admin/node/lookup.tpl diff --git a/frontend/templates/admin.overview.tpl b/frontend/templates/default/admin/overview/index.tpl similarity index 100% rename from frontend/templates/admin.overview.tpl rename to frontend/templates/default/admin/overview/index.tpl diff --git a/frontend/templates/admin.users.tpl b/frontend/templates/default/admin/user/list.tpl similarity index 100% rename from frontend/templates/admin.users.tpl rename to frontend/templates/default/admin/user/list.tpl diff --git a/frontend/templates/admin.user.tpl b/frontend/templates/default/admin/user/lookup.tpl similarity index 100% rename from frontend/templates/admin.user.tpl rename to frontend/templates/default/admin/user/lookup.tpl diff --git a/frontend/templates/admin.containers.add.tpl b/frontend/templates/default/admin/vps/add.tpl similarity index 100% rename from frontend/templates/admin.containers.add.tpl rename to frontend/templates/default/admin/vps/add.tpl diff --git a/frontend/templates/admin.containers.tpl b/frontend/templates/default/admin/vps/list.tpl similarity index 100% rename from frontend/templates/admin.containers.tpl rename to frontend/templates/default/admin/vps/list.tpl diff --git a/frontend/templates/admin.container.suspend.tpl b/frontend/templates/default/admin/vps/suspend.tpl similarity index 100% rename from frontend/templates/admin.container.suspend.tpl rename to frontend/templates/default/admin/vps/suspend.tpl diff --git a/frontend/templates/vps.console.tpl b/frontend/templates/default/client/vps/console.tpl similarity index 100% rename from frontend/templates/vps.console.tpl rename to frontend/templates/default/client/vps/console.tpl diff --git a/frontend/templates/error.vps.notfound.tpl b/frontend/templates/default/client/vps/error/notfound.tpl similarity index 100% rename from frontend/templates/error.vps.notfound.tpl rename to frontend/templates/default/client/vps/error/notfound.tpl diff --git a/frontend/templates/list.tpl b/frontend/templates/default/client/vps/list.tpl similarity index 100% rename from frontend/templates/list.tpl rename to frontend/templates/default/client/vps/list.tpl diff --git a/frontend/templates/vps.overview.tpl b/frontend/templates/default/client/vps/lookup.tpl similarity index 100% rename from frontend/templates/vps.overview.tpl rename to frontend/templates/default/client/vps/lookup.tpl diff --git a/frontend/templates/main.vps.tpl b/frontend/templates/default/client/vps/main.tpl similarity index 100% rename from frontend/templates/main.vps.tpl rename to frontend/templates/default/client/vps/main.tpl diff --git a/frontend/templates/vps.password.tpl b/frontend/templates/default/client/vps/password.tpl similarity index 100% rename from frontend/templates/vps.password.tpl rename to frontend/templates/default/client/vps/password.tpl diff --git a/frontend/templates/vps.reinstall.tpl b/frontend/templates/default/client/vps/reinstall.tpl similarity index 100% rename from frontend/templates/vps.reinstall.tpl rename to frontend/templates/default/client/vps/reinstall.tpl diff --git a/frontend/templates/errorhandler.error.tpl b/frontend/templates/default/shared/error/error.tpl similarity index 100% rename from frontend/templates/errorhandler.error.tpl rename to frontend/templates/default/shared/error/error.tpl diff --git a/frontend/templates/errorhandler.info.tpl b/frontend/templates/default/shared/error/info.tpl similarity index 100% rename from frontend/templates/errorhandler.info.tpl rename to frontend/templates/default/shared/error/info.tpl diff --git a/frontend/templates/errorhandler.success.tpl b/frontend/templates/default/shared/error/success.tpl similarity index 100% rename from frontend/templates/errorhandler.success.tpl rename to frontend/templates/default/shared/error/success.tpl diff --git a/frontend/templates/errorhandler.warning.tpl b/frontend/templates/default/shared/error/warning.tpl similarity index 100% rename from frontend/templates/errorhandler.warning.tpl rename to frontend/templates/default/shared/error/warning.tpl diff --git a/frontend/templates/login.tpl b/frontend/templates/default/shared/login.tpl similarity index 100% rename from frontend/templates/login.tpl rename to frontend/templates/default/shared/login.tpl diff --git a/frontend/templates/main.tpl b/frontend/templates/default/shared/main.tpl similarity index 100% rename from frontend/templates/main.tpl rename to frontend/templates/default/shared/main.tpl