<?php

// OPL Initialization
$config = parse_ini_file('../paths.ini', true);
require $config['libraries']['Opl'] . 'Base.php';
Opl_Loader::loadPaths($config);
Opl_Loader::setCheckFileExists(false);
Opl_Loader::register();
Opl_Registry::setState('opl_debug_console', false);
Opl_Registry::setState('opl_extended_errors', true);
try {
    Opl_Loader::setHandleUnknownLibraries(false);
    $viewSettings = array('sourceDir' => './templates/', 'compileDir' => './templates_c/', 'prologRequired' => true, 'stripWhitespaces' => false, 'gzipCompression' => true, 'contentType' => 0, 'charset' => 'utf-8');
    $tpl = new Opt_Class();
    $tpl->setup($viewSettings);
    $opc = new Opc_Class();
    $viewCacheOptions = array('cacheDir' => './cache/', 'expiryTime' => 120, 'key' => null);
    $viewCache = new Opc_View_Cache($viewCacheOptions);
    $tpl->setCache($viewCache);
    $view = new Opt_View('caching_test_dynamic.tpl');
    $view->pagetitle = 'Caching system test';
    $view->dynamic = 'Dynamic3';
    $out = new Opt_Output_Http();
    $out->setContentType();
    $out->render($view);
} catch (Opc_Exception $exception) {
    $handler = new Opc_ErrorHandler();
    $handler->display($exception);
}
Esempio n. 2
0
        }
        $view->results = $results;
    }
}
// end GeneralForm;
try {
    $tpl = new Opt_Class();
    $opf = new Opf_Class($tpl);
    $tpl->sourceDir = './templates/';
    $tpl->compileDir = './templates_c/';
    $tpl->compileMode = Opt_Class::CM_REBUILD;
    $tpl->stripWhitespaces = false;
    $tpl->gzipCompression = false;
    $tpl->register(Opt_Class::PHP_FUNCTION, 'dump', 'var_dump');
    $tpl->setup();
    $translate = new Opc_Translate(new Opc_Translate_Adapter_Ini(array('directory' => './lang/')));
    $translate->setLanguage('en');
    $opf->setTranslationInterface($translate);
    $view = new Opt_View('situation_5.tpl');
    $view->devFile = 'situation_5.php';
    $form = new GeneralForm('form5');
    $form->setView($view);
    $form->execute();
    $output = new Opt_Output_Http();
    $output->render($view);
} catch (Exception $e) {
    var_dump($e);
} catch (Opl_Exception $exception) {
    $handler = new Opl_ErrorHandler();
    $handler->display($exception);
}
Esempio n. 3
0
    // 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);
} catch (PDOException $exception) {
    die('PDO Exception occured: ' . $exception->getMessage());
} catch (Opt_Exception $exception) {
    $handler = new Opt_ErrorHandler();
    $handler->display($exception);
} catch (Opl_Exception $exception) {
    $handler = new Opl_ErrorHandler();
    $handler->display($exception);
}
Esempio n. 4
0
Opl_Registry::setState('opl_debug_console', false);
Opl_Registry::setState('opl_extended_errors', true);
try {
    $tpl = new Opt_Class();
    $tpl->sourceDir = './templates/';
    $tpl->compileDir = './templates_c/';
    $tpl->charset = 'utf-8';
    $tpl->compileMode = Opt_Class::CM_REBUILD;
    $tpl->stripWhitespaces = false;
    //$tpl->register(Opt_Class::OPT_FORMAT, 'Paginator', 'Opc_Paginator_DataFormat');
    $tpl->setup();
    $opc = new Opc_Class();
    $pager = Opc_Paginator::create(1000, 13);
    // returns Opc_Paginator_Pager;
    $pager->all = 1000;
    $pager->page = isset($_GET['page']) ? $_GET['page'] : 1;
    $view = new Opt_View('paginator_opt.tpl');
    $view->pager = $pager;
    //$view->setFormat('pager', 'Paginator');
    $view->setFormat('pager', 'Objective/Array');
    $view->setFormat('pager.decorator', 'Objective');
    $out = new Opt_Output_Http();
    $out->setContentType(Opt_Output_Http::HTML);
    $out->render($view);
} catch (Opc_Exception $exception) {
    $handler = new Opc_ErrorHandler();
    $handler->display($exception);
} catch (Opt_Exception $exception) {
    $handler = new Opt_ErrorHandler();
    $handler->display($exception);
}
Esempio n. 5
0
 /**
  * Check if the Http output requests to throw the exceptions.
  */
 public function testHttpOutputException()
 {
     $view = new Opt_View('fake.tpl');
     try {
         $output = new Opt_Output_Http();
         $output->render($view);
     } catch (Opt_TemplateNotFound_Exception $exception) {
         return true;
     }
     $this->fail('Exception not returned for the template that does not exist.');
 }