public function handleRequest() { $config = Registry::getInstance(); $scriptdir = str_replace($config->web_root, '', $config->site_root); $scriptname = basename($_SERVER['SCRIPT_FILENAME']); $request = trim(str_replace(join_path($scriptdir, $scriptname), '', $_SERVER['REQUEST_URI']), DIRECTORY_SEPARATOR); $config->base_dir = $scriptdir; $view = 'default'; if (strlen($request) > 0) { $args = explode(DIRECTORY_SEPARATOR, $request); if (count($args) > 0) { $controller = array_shift($args); } if (count($args) > 0) { $view = array_shift($args); } if (count($args) > 0) { foreach ($args as $k => $v) { $args[$k] = urldecode($v); } } } if (!isset($controller)) { $controller = $config->default_controller; $args = array(); } $controller = 'V7F\\Controller\\' . $controller; if (class_exists($controller)) { $active_controller = new $controller(); $active_controller->{$view}($args); } else { trigger_error('Controller not found - ' . $controller, E_USER_ERROR); } }
public final function __construct($instance = NULL) { $config = Registry::getInstance($instance); $dsn = $config->db_engine . ':dbname=' . $config->db_dbname . ';host=' . $config->db_host; $options = array(PDO::ATTR_EMULATE_PREPARES => FALSE); try { parent::__construct($dsn, $config->db_user, $config->db_pass, $options); $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('V7F\\Helpers\\DB_PDO_Statement', array($this))); } catch (PDOException $e) { trigger_error('DB: Connection failed: ' . $e->getMessage(), E_USER_ERROR); } }
public function render($template, $vars) { $registry = Registry::getInstance(); require_once join_path($registry->web_root, 'system/template/h2o.php'); $path = join_path($registry->web_root, 'view/' . $template . '.html'); if (!file_exists($path)) { trigger_error('Template: View ' . $path . ' not found!'); } $vars = array_merge($vars, array('config' => $registry)); $h2o = new h2o($path, array('cache' => 'apc', 'safeClass' => array('V7F\\Helpers\\Registry', 'V7F\\Template\\Template_Helpers'))); echo $h2o->render($vars); }
public function TextBox($name, $value = "") { $sBasePath = join_path(Registry::get('base_dir'), 'system/editor/fckeditor/'); $oFCKeditor = new \FCKeditor($name); $oFCKeditor->BasePath = $sBasePath; $oFCKeditor->Value = $value; $oFCKeditor->Width = 800; $oFCKeditor->Height = 700; ob_start(); $oFCKeditor->Create(); unset($oFCKeditor); return ob_get_clean(); }
public function __construct() { $this->template = Template::getInstance(); $this->config = Registry::getInstance(); }
<?php use V7F\Helpers\Registry, V7F\Helpers\ErrorHandler; require 'autoload.php'; require 'helpers.php'; // Setup config registry $config = Registry::getInstance(); $config->site_root = realpath(join_path(dirname(__FILE__), '..')); require 'siteconfig.php'; unset($config); // Setup error handler $errorhandler = ErrorHandler::getInstance(); set_error_handler(array($errorhandler, 'error_handler'));