Implement new template path structure with theme support

feature/node-rewrite
Sven Slootweg 12 years ago
parent c716f98db6
commit 95d30302cc

@ -11,6 +11,8 @@
* licensing text. * licensing text.
*/ */
/* TODO: Switch to PDO here. */
$_CVM = true; $_CVM = true;
require("includes/include.base.php"); require("includes/include.base.php");

@ -23,8 +23,10 @@ try
} }
catch (InsufficientAccessLevelException $e) catch (InsufficientAccessLevelException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-unauthorized-title'], $locale->strings['error-unauthorized-text']); $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sMainContents .= $err->Render(); 'title' => $locale->strings['error-unauthorized-title'],
'message' => $locale->strings['error-unauthorized-text']
));
$sRouterAuthenticated = false; $sRouterAuthenticated = false;

@ -32,19 +32,23 @@ try
} }
catch (ContainerSuspendedException $e) catch (ContainerSuspendedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_WARNING, $locale->strings['warning-suspended-title'], $locale->strings['warning-suspended-text']); $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/warning", $locale->strings, array(
$sMainContents .= $err->Render(); 'title' => $locale->strings['warning-suspended-title'],
'message' => $locale->strings['warning-suspended-text']
));
} }
catch (ContainerTerminatedException $e) catch (ContainerTerminatedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_WARNING, $locale->strings['warning-terminated-title'], $locale->strings['warning-terminated-text']); $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/warning", $locale->strings, array(
$sMainContents .= $err->Render(); 'title' => $locale->strings['warning-terminated-title'],
'message' => $locale->strings['warning-terminated-text']
));
} }
} }
catch(NotFoundException $e) catch(NotFoundException $e)
{ {
$router->uVariables['display_menu'] = false; $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; $sRouterAuthenticated = false;
} }
catch(UnauthorizedException $e) catch(UnauthorizedException $e)

@ -25,44 +25,59 @@ try
{ {
$sContainer->Suspend(); $sContainer->Suspend();
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-suspend-success-title'], $locale->strings['error-suspend-success-text']); $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array(
$sMainContents .= $err->Render(); 'title' => $locale->strings['error-suspend-success-title'],
'message' => $locale->strings['error-suspend-success-text']
));
} }
elseif($_POST['action'] == "unsuspend") elseif($_POST['action'] == "unsuspend")
{ {
$sContainer->Unsuspend(); $sContainer->Unsuspend();
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-unsuspend-success-title'], $locale->strings['error-unsuspend-success-text']); $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array(
$sMainContents .= $err->Render(); 'title' => $locale->strings['error-unsuspend-success-title'],
'message' => $locale->strings['error-unsuspend-success-text']
));
} }
$sContainer->RefreshData(); $sContainer->RefreshData();
/* TODO: Flash message and redirect to VPS lookup page. */
} }
$sSuspended = ($sContainer->sStatus == CVM_STATUS_SUSPENDED) ? true : false; $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, 'id' => $sContainer->sId,
'suspended' => $sSuspended 'suspended' => $sSuspended
)); ));
} }
catch (InsufficientAccessLevelException $e) catch (InsufficientAccessLevelException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-unauthorized-title'], $locale->strings['error-unauthorized-text']); /* TODO: Is this really necessary? */
$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']
));
} }
catch (NotFoundException $e) catch (NotFoundException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-notfound-title'], $locale->strings['error-notfound-text']); $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sMainContents .= $err->Render(); 'title' => $locale->strings['error-notfound-title'],
'message' => $locale->strings['error-notfound-text']
));
} }
catch (ContainerSuspendException $e) catch (ContainerSuspendException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-suspend-error-title'], $locale->strings['error-suspend-error-text']); $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sMainContents .= $err->Render(); 'title' => $locale->strings['error-suspend-error-title'],
'message' => $locale->strings['error-suspend-error-text']
));
} }
catch (ContainerUnsuspendException $e) catch (ContainerUnsuspendException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-unsuspend-error-title'], $locale->strings['error-unsuspend-error-text']); $sMainContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sMainContents .= $err->Render(); 'title' => $locale->strings['error-unsuspend-error-title'],
'message' => $locale->strings['error-unsuspend-error-text']
));
} }

@ -136,6 +136,8 @@ if(isset($_POST['submit']))
$sContainer->InsertIntoDatabase(); $sContainer->InsertIntoDatabase();
$sContainer->Deploy(); $sContainer->Deploy();
/* TODO: Flash message. */
redirect("/admin/node/{$node->sId}/"); 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, 'errors' => $sErrors,
'nodes' => $sNodes, 'nodes' => $sNodes,
'users' => $sUsers, 'users' => $sUsers,

@ -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 'containers' => $sContainerList
)); ));

@ -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, 'id' => $sNode->sId,
'hostname' => $sNode->sHostname, 'hostname' => $sNode->sHostname,
'location' => $sNode->sPhysicalLocation, 'location' => $sNode->sPhysicalLocation,
@ -48,7 +48,9 @@ try
} }
catch (NotFoundException $e) catch (NotFoundException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-admin-node-title'], $locale->strings['error-admin-node-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-admin-node-title'],
'message' => $locale->strings['error-admin-node-text']
));
} }

@ -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 'errors' => $sErrors
)); ));

@ -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 'nodes' => $sNodeList
)); ));

@ -13,4 +13,4 @@
if(!isset($_CVM)) { die("Unauthorized."); } if(!isset($_CVM)) { die("Unauthorized."); }
$sPageContents = Templater::AdvancedParse("admin.overview", $locale->strings, array()); $sPageContents = Templater::AdvancedParse("{$sTheme}/admin/overview/index", $locale->strings, array());

@ -11,6 +11,8 @@
* licensing text. * licensing text.
*/ */
/* TODO: Add "create VPS" button. */
if(!isset($_CVM)) { die("Unauthorized."); } if(!isset($_CVM)) { die("Unauthorized."); }
try try
@ -25,6 +27,8 @@ try
{ {
$sContainer = new Container($row); $sContainer = new Container($row);
/* TODO: Deal with unreachable servers (SshException). */
$sContainerList[] = array( $sContainerList[] = array(
'id' => $sContainer->sId, 'id' => $sContainer->sId,
'hostname' => $sContainer->sHostname, '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, 'id' => $sUserEntry->sId,
'username' => $sUserEntry->sUsername, 'username' => $sUserEntry->sUsername,
'email' => $sUserEntry->sEmailAddress, 'email' => $sUserEntry->sEmailAddress,
@ -52,7 +56,9 @@ try
} }
catch (NotFoundException $e) catch (NotFoundException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-admin-user-title'], $locale->strings['error-admin-user-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-admin-user-title'],
'message' => $locale->strings['error-admin-user-text']
));
} }

@ -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 'users' => $sUserList
)); ));

@ -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 'containers' => $sContainerList
)); ));
} }

@ -39,18 +39,22 @@ if(isset($_POST['submit']))
} }
else else
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-login-invalid-title'], $locale->strings['error-login-invalid-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-login-invalid-title'],
'message' => $locale->strings['error-login-invalid-text']
));
} }
} }
else else
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-login-invalid-title'], $locale->strings['error-login-invalid-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); '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, 'error' => $sError,
'field-username' => $sFieldUsername 'field-username' => $sFieldUsername
)); ));

@ -19,11 +19,15 @@ if($sLoggedIn === true)
$sUser = new User(0); $sUser = new User(0);
$sLoggedIn = false; $sLoggedIn = false;
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-logout-success-title'], $locale->strings['error-logout-success-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array(
$sMainContents .= $err->Render(); 'title' => $locale->strings['error-logout-success-title'],
'message' => $locale->strings['error-logout-success-text']
));
} }
else else
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-logout-notloggedin-title'], $locale->strings['error-logout-notloggedin-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sMainContents .= $err->Render(); 'title' => $locale->strings['error-logout-notloggedin-title'],
'message' => $locale->strings['error-logout-notloggedin-text']
));
} }

@ -13,6 +13,8 @@
if(!isset($_CVM)) { die("Unauthorized."); } 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']) 'host' => htmlspecialchars($_SERVER['SERVER_NAME'])
)); ));

@ -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);

@ -25,44 +25,58 @@ if(isset($_POST['submit']))
{ {
$sContainer->SetRootPassword($_POST['password']); $sContainer->SetRootPassword($_POST['password']);
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-password-success-title'], $locale->strings['error-password-success-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-password-success-title'],
'message' => $locale->strings['error-password-success-text']
));
} }
else else
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-password-nomatch-title'], $locale->strings['error-password-nomatch-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-password-nomatch-title'],
'message' => $locale->strings['error-password-nomatch-text']
));
} }
} }
else else
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-password-missing-title'], $locale->strings['error-password-missing-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-password-missing-title'],
'message' => $locale->strings['error-password-missing-text']
));
} }
} }
catch (ContainerSuspendedException $e) catch (ContainerSuspendedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-password-suspended-title'], $locale->strings['error-password-suspended-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-password-suspended-title'],
'message' => $locale->strings['error-password-suspended-text']
));
} }
catch (ContainerTerminatedException $e) catch (ContainerTerminatedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-password-terminated-title'], $locale->strings['error-password-terminated-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-password-terminated-title'],
'message' => $locale->strings['error-password-terminated-text']
));
} }
catch (SshExitException $e) catch (SshExitException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-password-invalid-title'], $locale->strings['error-password-invalid-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-password-invalid-title'],
'message' => $locale->strings['error-password-invalid-text']
));
} }
} }
if($display_form === true) if($display_form === true)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_WARNING, $locale->strings['warning-password-title'], $locale->strings['warning-password-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/warning", $locale->strings, array(
$sPageContents .= $err->Render(); '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 'id' => $sContainer->sId
)); ));
} }

@ -32,50 +32,69 @@ if(isset($_POST['submit']))
$sContainer->Reinstall(); $sContainer->Reinstall();
$sContainer->Start(); $sContainer->Start();
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, $locale->strings['error-reinstall-success-title'], $locale->strings['error-reinstall-success-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-reinstall-success-title'],
'message' => $locale->strings['error-reinstall-success-text']
));
} }
else else
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-confirm-title'], $locale->strings['error-reinstall-confirm-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-reinstall-confirm-title'],
'message' => $locale->strings['error-reinstall-confirm-text']
));
} }
} }
catch (NotFoundException $e) catch (NotFoundException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-notfound-title'], $locale->strings['error-reinstall-notfound-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-reinstall-notfound-title'],
'message' => $locale->strings['error-reinstall-notfound-text']
));
} }
catch (TemplateUnavailableException $e) catch (TemplateUnavailableException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-unavailable-title'], $locale->strings['error-reinstall-unavailable-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-reinstall-unavailable-title'],
'message' => $locale->strings['error-reinstall-unavailable-text']
));
} }
catch (ContainerReinstallException $e) catch (ContainerReinstallException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-failed-title'], $locale->strings['error-reinstall-failed-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-reinstall-failed-title'],
'message' => $locale->strings['error-reinstall-failed-text']
));
} }
catch (ContainerStartException $e) catch (ContainerStartException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_WARNING, $locale->strings['error-reinstall-start-title'], $locale->strings['error-reinstall-start-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-reinstall-start-title'],
'message' => $locale->strings['error-reinstall-start-text']
));
} }
catch (ContainerSuspendedException $e) catch (ContainerSuspendedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-suspended-title'], $locale->strings['error-reinstall-suspended-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-reinstall-suspended-title'],
'message' => $locale->strings['error-reinstall-suspended-text']
));
} }
catch (ContainerTerminatedException $e) catch (ContainerTerminatedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-reinstall-terminated-title'], $locale->strings['error-reinstall-terminated-text']); $sPageContents .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sPageContents .= $err->Render(); 'title' => $locale->strings['error-reinstall-terminated-title'],
'message' => $locale->strings['error-reinstall-terminated-text']
));
} }
} }
else 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."); /* TODO: Grab text from locale file. */
$sPageContents .= $err->Render(); $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 'templates' => $sTemplateList
)); ));
} }

@ -16,6 +16,8 @@ $timing_start = microtime(true);
$_CVM = true; $_CVM = true;
require("includes/include.base.php"); require("includes/include.base.php");
$sTheme = "default";
$sTemplateParameters = array(); $sTemplateParameters = array();
if(!empty($_SESSION['userid'])) if(!empty($_SESSION['userid']))
@ -201,18 +203,24 @@ try
} }
catch (ContainerSuspendedException $e) catch (ContainerSuspendedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Container is suspended", $e->getMessage()); /* TODO: Grab error title from locale file? */
$sError .= $err->Render(); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
'title' => "Container is suspended",
'message' => $e->getMessage()
));
} }
catch (ContainerTerminatedException $e) catch (ContainerTerminatedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Container is terminated", $e->getMessage()); /* TODO: Grab error title from locale file? */
$sError .= $err->Render(); $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) 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, 'error' => $sError,
'contents' => $sPageContents, 'contents' => $sPageContents,
'id' => $sContainer->sId 'id' => $sContainer->sId
@ -220,7 +228,7 @@ try
} }
elseif($router->uVariables['menu'] == "admin" && $router->uVariables['display_menu'] === true) 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, 'error' => $sError,
'contents' => $sPageContents 'contents' => $sPageContents
)); ));
@ -228,6 +236,7 @@ try
} }
catch (UnauthorizedException $e) catch (UnauthorizedException $e)
{ {
/* TODO: Create a proper template for this. */
$sPageTitle = "Unauthorized"; $sPageTitle = "Unauthorized";
$sMainContents = "You are not authorized to view this page."; $sMainContents = "You are not authorized to view this page.";
} }
@ -240,4 +249,4 @@ $sTemplateParameters = array_merge($sTemplateParameters, array(
'generation' => "<!-- page generated in " . (round(microtime(true) - $timing_start, 6)) . " seconds. -->" 'generation' => "<!-- page generated in " . (round(microtime(true) - $timing_start, 6)) . " seconds. -->"
)); ));
echo(Templater::AdvancedParse("main", $locale->strings, $sTemplateParameters)); echo(Templater::AdvancedParse("{$sTheme}/shared/main", $locale->strings, $sTemplateParameters));

@ -27,21 +27,29 @@ try
$sContainer->Start(); $sContainer->Start();
$sContainer->sCurrentStatus = CVM_STATUS_STARTED; $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 .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-stop-restart-success'],
'message' => $locale->strings['error-stop-restart-success']
));
} }
catch (ContainerSuspendedException $e) catch (ContainerSuspendedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-restart-suspended-title'], $locale->strings['error-restart-suspended-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-restart-suspended-title'],
'message' => $locale->strings['error-restart-suspended-text']
));
} }
catch (ContainerTerminatedException $e) catch (ContainerTerminatedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-restart-terminated-title'], $locale->strings['error-restart-terminated-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-restart-terminated-title'],
'message' => $locale->strings['error-restart-terminated-text']
));
} }
catch(ContainerStartException $e) catch(ContainerStartException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-restart-start-title'], $locale->strings['error-restart-start-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-restart-start-title'],
'message' => $locale->strings['error-restart-start-text']
));
} }

@ -20,27 +20,37 @@ if($sContainer->sCurrentStatus != CVM_STATUS_STARTED)
$sContainer->Start(); $sContainer->Start();
$sContainer->sCurrentStatus = CVM_STATUS_STARTED; $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 .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-start-success-title'],
'message' => $locale->strings['error-start-success-text']
));
} }
catch (ContainerSuspendedException $e) catch (ContainerSuspendedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-start-suspended-title'], $locale->strings['error-start-suspended-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-start-suspended-title'],
'message' => $locale->strings['error-start-suspended-text']
));
} }
catch (ContainerTerminatedException $e) catch (ContainerTerminatedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-start-terminated-title'], $locale->strings['error-start-terminated-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-start-terminated-title'],
'message' => $locale->strings['error-start-terminated-text']
));
} }
catch (ContainerStartException $e) catch (ContainerStartException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-start-failed-title'], $locale->strings['error-start-failed-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-start-failed-title'],
'message' => $locale->strings['error-start-failed-text']
));
} }
} }
else else
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-start-running-title'], $locale->strings['error-start-running-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-start-running-title'],
'message' => $locale->strings['error-start-running-text']
));
} }

@ -20,27 +20,37 @@ if($sContainer->sCurrentStatus != CVM_STATUS_STOPPED)
$sContainer->Stop(); $sContainer->Stop();
$sContainer->sCurrentStatus = CVM_STATUS_STOPPED; $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 .= NewTemplater::Render("{$sTheme}/shared/error/success", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-stop-success-title'],
'message' => $locale->strings['error-stop-success-text']
));
} }
catch (ContainerSuspendedException $e) catch (ContainerSuspendedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-stop-suspended-title'], $locale->strings['error-stop-suspended-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-stop-suspended-title'],
'message' => $locale->strings['error-stop-suspended-text']
));
} }
catch (ContainerTerminatedException $e) catch (ContainerTerminatedException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-stop-terminated-title'], $locale->strings['error-stop-terminated-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-stop-terminated-title'],
'message' => $locale->strings['error-stop-terminated-text']
));
} }
catch(ContainerStopException $e) catch(ContainerStopException $e)
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-stop-failed-title'], $locale->strings['error-stop-failed-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-stop-failed-title'],
'message' => $locale->strings['error-stop-failed-text']
));
} }
} }
else else
{ {
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, $locale->strings['error-stop-stopped-title'], $locale->strings['error-stop-stopped-text']); $sError .= NewTemplater::Render("{$sTheme}/shared/error/error", $locale->strings, array(
$sError .= $err->Render(); 'title' => $locale->strings['error-stop-stopped-title'],
'message' => $locale->strings['error-stop-stopped-text']
));
} }

Loading…
Cancel
Save