CVS update: /cowiki/htdocs/setup/
[email protected] 14 May 2005 21:12:56 -0000
| Newsgroups | gmane.comp.php.cowiki.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: dgorski Date: 2005/05/14 14:12:56 Modified: cowiki/htdocs/setup/installer.php Log: Encapsulate main() controller to catch exceptions File Changes: Directory: /cowiki/htdocs/setup/ ================================ File [changed]: installer.php Url: http://cowiki.tigris.org/source/browse/cowiki/htdocs/setup/installer.php?r1=1.3&r2=1.4 Delta lines: +331 -306 ----------------------- --- installer.php 30 Apr 2005 00:20:25 -0000 1.3 +++ installer.php 14 May 2005 21:12:54 -0000 1.4 @@ -2,7 +2,7 @@ /** * - * $Id: installer.php,v 1.3 2005/04/30 00:20:25 dgorski Exp $ + * $Id: installer.php,v 1.4 2005/05/14 21:12:54 dgorski Exp $ * * This file is part of coWiki. coWiki is free software under the terms of * the GNU General Public License (GPL). Read the LICENSE file. If you did @@ -17,7 +17,7 @@ * @author Daniel T. Gorski, <[email protected]> * @copyright (C) Daniel T. Gorski, {@link http://www.develnet.org} * @license http://www.gnu.org/licenses/gpl.html - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * */ @@ -56,12 +56,32 @@ // -------------------------------------------------------------------- + // Start the main controller + try { + main(); + + } catch (Exception $e) { + + echo $e->getName() .' in '.$e->getFile().' in line '.$e->getLine(); + echo '<br />'; + echo $e->getMessage(); + echo '<pre>'; + echo $e->getTraceAsString(); + echo '</pre>'; + exit; + } + + // -------------------------------------------------------------------- + + function main() { + // Init StateHolder (session) $StateHolder = StateHolder::getInstance(); - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- - // Do not care about send data if a Location-redirection is required. + // Do not care about send data if a Location-redirection is + // required. ob_start(); // Trim all posted data @@ -69,7 +89,7 @@ $_POST[$k] = trim($v); } - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // Include and init required files include SETUP_PATH.'/function.php'; @@ -86,7 +106,7 @@ $sDir = preg_replace('#[^a-z]#', '', $_REQUEST['dir']); } - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // This script has been called with a reference, where we need to // return after we are finished or cancelled? @@ -97,19 +117,21 @@ // Check if "Cancel" or "Finish" has been triggered, leave script if (isset($_POST['submit'])) { - if ($_POST['submit'] == 'Cancel' || $_POST['submit'] == 'Finish') { + if ($_POST['submit'] == 'Cancel' + || $_POST['submit'] == 'Finish') { - // Check if we have a non-standard return target. E.g. if the - // installer has been called from the administration area. + // Check if we have a non-standard return target. E.g. if + // the installer has been called from the administration + // area. if ($StateHolder->getReturnReferenceScript() != '') { - redirectTo('../' . $StateHolder->getReturnReferenceScript()); + redirectTo('../'.$StateHolder->getReturnReferenceScript()); } else { redirectTo('../'); } } } - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // Get flow definition from flow.xml file $DomDoc = new DOMDocument(); @@ -122,7 +144,7 @@ // Init XPath $XPath = new DOMXPath($DomDoc); - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // Get all installer steps (the complete flow definition) $FlowList = $XPath->query('/setup/flow/installer'); @@ -133,10 +155,11 @@ // Check if we got a DOM NodeList returned if (!is_object($InstList->item(0))) { // FIX: better message/behaviour - die('Installer with id "'.$sInstId.'" not found in flow definition.'); + die('Installer with id "'.$sInstId.'" not found in + flow.xml definition.'); } - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // Get id of the target to jump to if a task is not required $sSkipTargetId = $InstList->item(0)->getAttribute('skip_id'); @@ -156,7 +179,7 @@ // Get button definitions $ButList = $XPath->query('button', $InstList->item(0)); - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // Init HTML template processor $Tpl = new InstallerTemplateProcessor(); @@ -177,7 +200,7 @@ $sStr = '<input type="hidden" name="id" value="'.$sInstId.'">'; $Tpl->assign('TPL_FORM_DATA', $sStr); - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // Fetch and generate setup step-by-step progress list @@ -244,8 +267,8 @@ $sStr .= ' alt="" border="0">'; $sStr .= '</td>'; $sStr .= '<td style="'.$sStyle.'"> </td>'; - $sStr .= '<td width="100%" style="padding-right:3px;'.$sStyle.'"'; - $sStr .= ' nowrap>'; + $sStr .= '<td width="100%"'; + $sStr .= ' style="padding-right:3px;'.$sStyle.'" nowrap>'; if ($v['status'] == 'complete') { $sStr .= '<a href="installer.php?id='.$v['id'].'">'; @@ -263,7 +286,7 @@ $Tpl->assign('TPL_SETUP_PROGRESS', $sStr); - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // Generate buttons $sStr = '<table width="100%" cellpadding="8" cellspacing="0"'; @@ -305,14 +328,14 @@ $Tpl->assign('BUTTONS', $sStr); - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // Instantiate task processor class $Task = new $sInstClass($Tpl); - // Check if it is required to execute the task. If not, go to the next - // task in the flow definition. If we are moving backwards in the - // wizard, go to the previous task. + // Check if it is required to execute the task. If not, go to the + // next task in the flow definition. If we are moving backwards in + // the wizard, go to the previous task. if (!$Task->isRequired()) { // We are not moving backwards, skip this task @@ -320,8 +343,8 @@ redirectToController('id='.$sSkipTargetId); } - // We are moving backwards, get the button target id of the button - // that points backwards. + // We are moving backwards, get the button target id of the + // button that points backwards. for ($i=0, $n=$ButList->length; $i<$n; $i++) { if ($ButList->item($i)->getAttribute('dir') == 'backward') { $sTargetId = $ButList->item($i)->getAttribute('target_id'); @@ -331,11 +354,11 @@ } } - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // If data has been posted, check if we need to validate it. If the - // validation fails redisplay the task. If everything is ok, go further - // to the next task. + // validation fails redisplay the task. If everything is ok, go + // further to the next task. if ($_SERVER['REQUEST_METHOD'] == 'POST') { $Button = null; @@ -384,10 +407,12 @@ } } - // -------------------------------------------------------------------- + // ---------------------------------------------------------------- // Render the installer task 'window' $Task->render(); + + } // of main() // === HELPER FUNCTIONS ===============================================