die('Please create the config.php file from config.sample.php!'); } require './config.php'; require './includes/forms.php'; require './components/base.php'; require './components/input.php'; require './components/textarea.php'; try { $tpl = new Opt_Class(); // Load the configuration $tpl->loadConfig($config['opt']); // Register the components $tpl->register(Opt_Class::OPT_COMPONENT, 'opt:input', 'InputComponent'); $tpl->register(Opt_Class::OPT_COMPONENT, 'opt:textarea', 'TextareaComponent'); $tpl->setup(); Opt_View::assignGlobal('baseHref', $config['script']['baseHref']); // Connect to the database. $pdo = new PDO($config['db']['dsn'], $config['db']['user'], $config['db']['password']); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->query('SET NAMES `' . $config['db']['charset'] . '`'); // Load and execute the action. $action = 'list'; if (isset($_GET['action']) && ctype_alpha($_GET['action'])) { $action = $_GET['action']; } require './actions/' . $action . '.php'; $view = action($pdo, $config); // Render the returned view to the browser. $output = new Opt_Output_Http(); $output->setContentType(Opt_Output_Http::XHTML, 'utf-8'); $output->render($view);
/** * @covers Opt_View::assignGlobal * @covers Opt_View::getGlobal */ public function testAssignGlobalVars() { Opt_View::assignGlobal('variable', 'Foo'); $this->assertEquals('Foo', Opt_View::getGlobal('variable')); }