Esempio n. 1
0
 function run($isAlreadyDone = false)
 {
     try {
         $this->readConfiguration();
         $this->initPath();
         $laststep = $this->initPrevious();
         $this->lang = $this->guessLanguage();
         if ($isAlreadyDone && !isset($_SESSION['__install__wizard'])) {
             if (isset($this->config['onalreadydone'])) {
                 $laststep = $this->config['onalreadydone'];
             }
             if ($laststep != '' && isset($this->pages[$laststep])) {
                 $this->stepName = $laststep;
             } else {
                 throw new Exception("Application is installed. The script cannot be runned.");
             }
         } else {
             if (!isset($_SESSION['__install__wizard']) && !$isAlreadyDone) {
                 $_SESSION['__install__wizard'] = true;
             }
             $this->stepName = $this->getStepName();
         }
         jTplConfig::$lang = $this->lang;
         jTplConfig::$localesGetter = array($this, 'getLocale');
         jTplConfig::$cachePath = $this->tempPath;
         $page = $this->loadPage();
         if (isset($_POST['doprocess']) && $_POST['doprocess'] == "1") {
             //if ($isAlreadyDone)
             //    $result = true;
             //else
             $result = $page->process();
             if ($result !== false) {
                 header("location: ?step=" . $this->getNextStep($page, $result));
                 exit(0);
             }
         }
         $tpl = new jTpl();
         $tpl->assign($page->config);
         $tpl->assign($page->getErrors());
         $tpl->assign('appname', isset($this->config['appname']) ? $this->config['appname'] : '');
         $continue = $page->show($tpl);
         $content = $tpl->fetch($this->stepName . '.tpl', 'html');
         $this->showMainTemplate($page, $content, $continue);
         if ($laststep == $this->stepName) {
             session_destroy();
         }
     } catch (Exception $e) {
         $error = $e->getMessage();
         header("HTTP/1.1 500 Application error");
         if ($this->customPath && file_exists($this->customPath . 'error.php')) {
             require $this->customPath . 'error.php';
         } else {
             require dirname(__FILE__) . '/error.php';
         }
         exit(1);
     }
 }
Esempio n. 2
0
<?php

require 'diff/difflib.php';
require 'diff/diffhtml.php';
if (!defined('SIMPLE_TEST')) {
    define('SIMPLE_TEST', 'simpletest/');
}
require_once SIMPLE_TEST . 'unit_tester.php';
require_once SIMPLE_TEST . 'reporter.php';
require_once SIMPLE_TEST . 'myhtmlreporter.class.php';
require_once SIMPLE_TEST . 'junittestcase.class.php';
require_once '../jtpl_standalone_prepend.php';
require_once 'compiler.php';
require_once 'expressions_parsing.php';
jTplConfig::$lang = 'fr';
$test = new GroupTest('All tests');
$test->addTestCase(new UTjtplcontent());
$test->addTestCase(new UTjtplexpr());
$test->run(new myHtmlReporter());