public function show($name, $vars = array()) { //$name es el nombre de nuestra plantilla, por ej, listado.php //$vars es el contenedor de nuestras variables, es un arreglo del tipo llave => valor, opcional. //Traemos una instancia de nuestra clase de configuracion. $config = Config::singleton(); //Armamos la ruta a la plantilla $path = dirname(__FILE__) . '/../views/' . $name; //Si no existe el fichero en cuestion, mostramos un 404 if (file_exists($path) == false) { trigger_error('Template `' . $path . '` does not exist.', E_USER_NOTICE); return false; } //Si hay variables para asignar, las pasamos una a una. if (is_array($vars)) { foreach ($vars as $key => $value) { $key = $value; } } require_once 'helpers.class.php'; $helper = new Helpers(); //incluimos la cabecera include dirname(__FILE__) . '/../views/templates/header.php'; //Finalmente, incluimos la plantilla. include $path; //incluimos el footer include dirname(__FILE__) . '/../views/templates/footer.php'; }
public static function getInstance() { if (is_null(self::$singleton)) { self::$singleton = new Config(); } return self::$singleton; }
public final function __get($index) { switch ($index) { case 'config': $this->config = Config::singleton(); return $this->config; case 'cache': $this->cache = new Cache($this->config->read('framework/cache/driver', Cache::DISABLED), array('host' => $this->config->read('framework/cache/host', null), 'port' => $this->config->read('framework/cache/port', null))); return $this->cache; case 'sql': $this->config->load('db'); $this->sql = new SQL($this->config->read('db/dsn', ''), $this->config->read('db/user', ''), $this->config->read('db/pass', ''), $this->config->read('db/pool', false)); $this->config->unload('db'); return $this->sql; case 'secure': $this->secure = new Secure($this->config->read('framework/secure/seed', 'sampa-framework')); return $this->secure; case 'log': $logfile = __SP_LOG__ . date('Ymd') . '-' . str_replace('_', '-', strtolower(get_class($this))) . '.log'; $this->log = new Log($logfile, $this->config->read('framework/log/level', Log::DISABLED), $this->config->read('framework/log/buffered', true)); return $this->log; case 'session': $this->session = Session::singleton($this->config); return $this->session; default: return null; } }
function __construct($path = null) { $this->path = $path === null ? Config::current()->plugins_dir : $path; $current = Config::current(); self::$config = Config::singleton($this->path); Config::setCurrent($current->path); parent::__construct($this->path, array('Sqlite3', 'Xml')); }
static function assets($url) { $root = Config::singleton()->get('root') . "/assets"; if ($url[0] == "/") { return $root . $url; } else { return $root . "/" . $url; } }
public function __construct() { $config = Config::singleton(); try { parent::__construct('mysql:host=' . $config->get('dbhost') . ';dbname=' . $config->get('dbname'), $config->get('dbuser'), $config->get('dbpass')); parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo 'ERROR: ' . $e->getMessage(); } }
public function __construct() { $config = Config::singleton(); // parent::__construct('mysql:host=' . $config->get('dbhost') . ';dbname=' . $config->get('dbname'),$config->get('dbuser'), $config->get('dbpass')); try { // $pdo = new PDO("mysql:host=".$config->get('dbhost').";dbname=".$config->get('dbname').";charset=utf8", $config->get('dbuser'), $config->get('dbpass')); parent::__construct('mysql:host=' . $config->get('dbhost') . ';dbname=' . $config->get('dbname'), $config->get('dbuser'), $config->get('dbpass')); $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo "Se ha producido un error al intentar conectar al servidor MySQL: " . $e->getMessage(); } }
public static function singleton() { if (self::$instance == null) { $config = Config::singleton(); if ($config->get('dbname') != '' or $config->get('dbuser') != '') { self::$instance = new self(); } else { return false; } } return self::$instance; }
private function build($name, $header, $footer, $css_PATH = 'css/', $js_PATH = 'js/') { $config = Config::singleton(); $folder = $config->get('viewsFolder_Default'); $this->data["header_path"] = $folder . $header; $this->data["body_path"] = $folder . $name; $this->data["footer_path"] = $folder . $footer; //extra paths $this->data["base"] = $config->get('baseURL'); $this->data["css_path"] = $folder . $css_PATH; $this->data["js_path"] = $folder . $js_PATH; $this->data["img_path"] = $config->get('imgFolder'); }
static function getEM() { if (is_null(self::$em)) { // the connection configuration $dbParams = array('driver' => 'pdo_mysql', 'user' => Config::singleton()->get("dbuser"), 'password' => Config::singleton()->get("dbpass"), 'dbname' => Config::singleton()->get("dbname"), 'database_host' => Config::singleton()->get("dbhost")); $config = Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array("app/models"), Config::singleton()->get("debug")); self::$em = Doctrine\ORM\EntityManager::create($dbParams, $config); $emConfig = self::$em->getConfiguration(); $emConfig->addCustomDatetimeFunction('YEAR', 'DoctrineExtensions\\Query\\Mysql\\Year'); $emConfig->addCustomDatetimeFunction('MONTH', 'DoctrineExtensions\\Query\\Mysql\\Month'); $emConfig->addCustomDatetimeFunction('DAY', 'DoctrineExtensions\\Query\\Mysql\\Day'); $emConfig->addCustomDatetimeFunction('Date', 'Date'); } return self::$em; }
public static function singleton() { if (!isset(self::$instance)) { $backend = Config::singleton()->Backend; if(!$backend) { throw new BackendNotSpecifiedException("Backend type not specified, please specify one in the config."); } // The backend type is supplied by the code, so we don't bother to check if the file exists // (it will simply throw an error if it doesn't). require_once($_SERVER["DOCUMENT_ROOT"] . 'includes/framework/backends/class.'.$backend.'Backend.php'); $c = $backend.'Backend'; self::$instance = new $c; } return self::$instance; }
public function get($str, $lang) { if (!array_key_exists($lang, $this->lang)) { $config = Config::singleton(); if (file_exists($config->get("translateDir") . $lang . '.txt')) { $strings = array_map(array($this, 'splitStrings'), file($config->get("translateDir") . $lang . '.txt')); foreach ($strings as $k => $v) { $this->lang[$lang][$v[0]] = $v[1]; } if (isset($this->lang[$lang])) { return $this->findString($str, $lang); } else { return $str; } } else { return $str; } } else { return $this->findString($str, $lang); } }
function return_html($template) { header('Content-Type: text/html'); $smarty = new Smarty(); $config = Config::singleton(); $root = $config->get('rootAbsolute') . "/app/views/"; /* Set config */ $smarty->template_dir = $root; $smarty->compile_dir = $root . 'templates_c/'; $smarty->config_dir = $root . 'configs/'; $smarty->cache_dir = $root . 'cache/'; $smarty->plugins_dir = $root . 'customplugins/'; /* Assign smarty vars */ foreach ($this->data as $name => $value) { $smarty->assign($name, $value); } $smarty->display($template); /* Clean data */ $this->data = array(); exit; }
public function show($name, $vars = array(), $include_menu = true) { //$name es el nombre de nuestra plantilla, por ej, listado.php //$vars es el contenedor de nuestras variables, es un arreglo del tipo llave => valor, opcional. //Traemos una instancia de nuestra clase de configuracion. $config = Config::singleton(); //Armamos la ruta a la plantilla $path = $config->get('viewsFolder') . $name; //Si no existe el fichero en cuestion, tiramos un 404 if (file_exists($path) == false) { trigger_error('Template `' . $path . '` does not exist.', E_USER_NOTICE); return false; } //Si hay variables para asignar, las pasamos una a una. if (is_array($vars)) { foreach ($vars as $key => $value) { ${$key} = $value; } } include $path; }
public function newshow($name, $vars = array()) { $config = Config::singleton(); $path = VIEWS . $name . ".phtml"; if (file_exists($path) == false) { trigger_error('PLantilla ' . $path . ' NO EXISTE.', E_USER_NOTICE); return false; } if (is_array($vars)) { foreach ($vars as $key => $value) { ${$key} = $value; } } $default = "views/plantillas/celestium.php"; if (isset($this->template) && !empty($this->template)) { $rutap = "views/plantillas/" . $this->template . ".phtml"; if (is_file($rutap)) { include $rutap; } } else { include $default; } }
<?php $config = Config::singleton(); $config->set('controllersFolder', 'controllers/'); $config->set('modelsFolder', 'models/'); $config->set('viewsFolder', 'views/'); $config->set('dbhost', 'localhost'); $config->set('dbname', 'star'); $config->set('dbuser', 'root'); $config->set('dbpass', '123456');
function render($template) { $this->assign('css', $this->css); $this->assign('js', $this->js); $this->assign('title', $this->title); $this->assign('metaTitle', $this->metaTitle); $this->assign('metaDescription', $this->metaDescription); $this->assign('metaKeywords', $this->metaKeywords); if (is_null($this->title)) { $opts = Config::singleton()->getModuleOptions(); $this->title = $opts['defaultPageTitle']; } $this->assign('title', $this->title); global $memory; global $startTime; $this->display($template); if (function_exists('memory_get_peak_usage') && function_exists('memory_get_usage')) { $memory .= 'Peak: ' . number_format(memory_get_peak_usage() / 1024, 0, '.', ',') . " KB \n"; $memory .= 'End: ' . number_format(memory_get_usage() / 1024, 0, '.', ',') . " KB \n"; $memory = 'Page generated in ' . (microtime(true) - $startTime) . ' seconds | Memory Usage: ' . $memory; if (DEBUG) { Debug::singleton()->addMessage('Load Time', $memory); } } if (DEBUG) { echo Debug::singleton(); } }
public function __construct() { $config = Config::singleton(); parent::__construct('mysql:host=' . $config->get('dbhost') . ';dbname=' . $config->get('dbname'), $config->get('dbuser'), $config->get('dbpass')); }
public function exampleAction() { $config = Config::singleton(); $this->data["fruit"] = "oranges"; $this->view->show("example.php", $this->data); }
<?php require_once($_SERVER["DOCUMENT_ROOT"] . 'includes/framework/class.Config.php'); require_once($_SERVER["DOCUMENT_ROOT"] . 'includes/framework/class.Dispatcher.php'); $config = Array( "Backend" => "Mysql", "Mysql_User" => "colorkey", "Mysql_Password" => "gjaH81ia9", "Mysql_Database" => "colorkey" ); Config::singleton()->Load($config); $dispatcher = new Dispatcher(); try { $dispatcher->Dispatch($_SERVER["REQUEST_URI"]); } catch (ControllerNotFoundException $e) { } exit; set_time_limit(1000); // example4: ?file=example4&cb=52&cr=34&a=60&b=100 // example: ?file=example&cb=81&cr=99&a=90&b=100 // example2: ?file=example2&cb=110&cr=46&a=90&b=100 // example3: ?file=example3&cb=115&cr=57&a=80&b=120
$debugger->debug("first call"); /* * Kicks things off with initiliziation of the general framework infrastructure. */ include_once 'include/Site.php'; error_reporting(E_ALL); /* * Assess whether we are logging in on this page request. */ if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) { $auth_container = new CMSAuthContainer(); $auth = new Auth($auth_container, null, 'authInlineHTML'); $auth->start(); } if (@(!isset($_REQUEST['module']))) { $options = Config::singleton()->options; $_REQUEST['module'] = 'Content'; $_REQUEST['page'] = $options['defaultPage']; } require_once 'HTML/AJAX/Helper.php'; $ajaxHelper = new HTML_AJAX_Helper(); if ($ajaxHelper->isAJAX()) { echo Module::factory($_REQUEST['module'], $smarty)->getUserInterface($_REQUEST); } else { //$smarty->addJS('/AJAX/server.php?client=all'); //$smarty->addJS('/js/login.js'); $smarty->addJS('/js/scriptaculous.js'); $smarty->addJS('/modules/Menu/js/sfMenus.js'); //$smarty->addJS('/js/frontend.js'); $smarty->content[$_REQUEST['module']] = Module::factory($_REQUEST['module'], $smarty)->getUserInterface($_REQUEST); $smarty->assign('module', $_REQUEST['module']);
public function __construct() { $config = Config::singleton(); parent::__construct('mysql:host=' . $config->get('dbhost') . ';dbname=' . $config->get('dbname'), $config->get('dbuser'), $config->get('dbpass'), array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . $config->get('dbchar'))); }
static function end() { if (Config::singleton()->get("debug")) { die; } }
function __construct() { $this->view = new View(); $this->config = Config::singleton(); $this->helper = new Helpers(); }