Ejemplo n.º 1
0
function ext_view_init(UnPHP $app, UnPHP_Dispatcher $dispatcher)
{
    $conf = $app->getConfig();
    if (isset($conf['view'])) {
        $c = $conf['view'];
        if (isset($c['themespath']) && isset($c['cachemode'])) {
            $themesPath = $c['themespath'];
            $cachemodeList = explode(",", $c['cachemode']);
            foreach ($cachemodeList as $mode) {
                if (isset($c[$mode])) {
                    $modeConf = $c[$mode];
                    if (isset($modeConf['tempPath'])) {
                        $newSmarty = "Ext_View_" . ucfirst($mode) . "Smarty";
                        $view = new $newSmarty();
                        if ($view->init($modeConf)) {
                            $view->setScriptPath($themesPath);
                            $dispatcher->setView($view);
                            break;
                        }
                    }
                }
            }
        }
    }
}
Ejemplo n.º 2
0
function ext_databases_init(UnPHP $app, UnPHP_Dispatcher $dispatcher)
{
    $conf = $app->getConfig();
    if (isset($conf['databases'])) {
        $c = $conf['databases'];
        $bothDB = array();
        $otherDB = array();
        foreach ($c as $d) {
            if (isset($d['dsn']) && isset($d['user']) && isset($d['password']) && isset($d['tables']) && isset($d['action'])) {
                switch ($d['action']) {
                    case 'both':
                        $bothDB[] = $d;
                        break;
                    case 'read':
                        $otherDB[] = $d;
                        break;
                    case 'write':
                        $otherDB[] = $d;
                        break;
                }
            }
        }
        foreach ($bothDB as $d) {
            $tables = explode(",", $d['tables']);
            $dsn = $d['dsn'];
            $user = $d['user'];
            $password = $d['password'];
            foreach ($tables as $table) {
                Ext_Databases_Model::regionPool($table, $dsn, $user, $password, Ext_Databases_Model::ACTION_BOTH);
            }
        }
        foreach ($otherDB as $d) {
            $action = $d['action'] == "read" ? Ext_Databases_Model::ACTION_READ : Ext_Databases_Model::ACTION_WRITE;
            $tables = explode(",", $d['tables']);
            $dsn = $d['dsn'];
            $user = $d['user'];
            $password = $d['password'];
            foreach ($tables as $table) {
                Ext_Databases_Model::regionPool($table, $dsn, $user, $password, $action);
            }
        }
    }
}