public function __construct() { require_once VENDPATH . 'PHPTAL/PHPTAL.php'; $this->tmpl = new PHPTAL(); $this->tmpl->setTemplateRepository(Config::getVar('view_template_dir', VIEWSPATH)); if (Config::checkVar('view_cache_dir')) { $this->tmpl->setPhpCodeDestination(Config::getVar('view_cache_dir')); } }
protected function loadParam($name, array $params = null, $default = null) { if ($params && isset($params[$name])) { return $params[$name]; } $prefix = ($this->loader_prefix ? $this->loader_prefix : strtolower(get_class($this))) . '_'; if (Config::checkVar($prefix . $name)) { return Config::getVar($prefix . $name); } return $default; }
public function __construct() { require_once VENDPATH . 'Smarty/Smarty.class.php'; $this->smarty = new Smarty(); $this->smarty->setTemplateDir(Config::getVar('view_template_dir', VIEWSPATH)); if (Config::checkVar('view_compile_dir')) { $this->smarty->setCompileDir(Config::getVar('view_compile_dir')); } if (Config::checkVar('view_cache_dir')) { $this->smarty->caching = true; $this->smarty->setCacheDir(Config::getVar('view_cache_dir')); } if (Config::checkVar('view_cache_lifetime')) { $this->smarty->cache_lifetime = Config::getVar('view_cache_lifetime'); } if (Config::checkVar('view_debugging')) { $this->smarty->debugging = Config::getVar('view_debugging'); } }
/** * Connects to database * All the parameters could also be set in config file: * * 'db_dsn' => 'mysql:dbname=bakedcarrot;host=localhost', * 'db_username' => 'db_user', * 'db_password' => 'db_password', * 'db_charset' => 'utf8', * * @static * @param null $dsn DSN in PDO format * @param null $username username to connect to database server * @param null $password connection password * @param string $charset default character set * @return void * @throws BakedCarrotDbException */ public static function connect($dsn = null, $username = null, $password = null, $charset = 'utf8') { if (!is_null(self::$pdo) && !$dsn) { return; } elseif (!is_null(self::$pdo) && $dsn) { self::$pdo = null; } if (!$dsn) { if (!Config::checkVar('db_dsn')) { throw new BakedCarrotDbException('Database access parameters are not properly configured'); } $dsn = Config::getVar('db_dsn'); $username = Config::getVar('db_username'); $password = Config::getVar('db_password'); $charset = Config::getVar('db_charset', 'utf8'); } self::$pdo = new DbPDO($dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::MYSQL_ATTR_INIT_COMMAND => 'set names ' . $charset, PDO::ATTR_AUTOCOMMIT => true)); Log::out(__METHOD__ . ' Connected to: "' . $dsn . '"', Log::LEVEL_DEBUG); }