public function __construct() { $this->_cs = cs::getInstance(); $this->_template =& $this->_cs->smarty; $this->_session =& $this->_cs->session; $this->_view = false; }
public function __construct() { $this->_cs = cs::getInstance(); $this->_db =& $this->_cs->db; if (Config::get('useSession') !== false) { $this->_session =& $this->_cs->session; } }
/** * Framework instance factory. Will return the active framework instance, or create one if it doesn't exist * @static getInstance * @return cs Instance object */ public static function getInstance($cli = false) { if (!isset(self::$_instance)) { $c = __CLASS__; self::$_instance = new $c($cli); self::$_instance->init($cli); } return self::$_instance; }
<?php error_reporting(E_ALL ^ E_NOTICE); ini_set('display_errors', 1); define('DS', DIRECTORY_SEPARATOR); define('ROOT_PATH', dirname(dirname(__FILE__))); define('CORNERSTONE_PATH', ROOT_PATH . '/cornerstone'); define('APP_PATH', ROOT_PATH); define('STORAGE_PATH', APP_PATH . '/storage/'); define('LIBRARY_PATH', APP_PATH . '/libraries/'); define('HELPER_PATH', APP_PATH . '/helpers/'); define('CONFIG_FILE', APP_PATH . '/config.php'); define('ROUTES_FILE', APP_PATH . '/routes.php'); define('BOOTSTRAP_FILE', APP_PATH . '/bootstrap.php'); define('CONTROLLER_PATH', APP_PATH . '/pages/'); define('ERROR_PATH', CONTROLLER_PATH . '/errors/'); $path = str_replace('webRoot/index.php', '', $_SERVER['SCRIPT_NAME']); require CORNERSTONE_PATH . '/cs.php'; $cs = cs::getInstance(); $cs->dispatch();
/** * Returns the difference between the current timestamp, and the begining of code execution * as defined by the '$cs->startTime' property. * * @static executionTime * @return float Execution time in seconds, rounded to 2 decimal places. */ public static function executionTime() { $cs = cs::getInstance(); $now = microtime(true); return round($now - $cs->startTime, 2); }
* Console Animator Demo =) */ try { // set include paths ini_set('include_path', join(PATH_SEPARATOR, array('lib/php', ini_get('include_path')))); // require framework require_once 'Jm.php'; class cs extends Jm_Console { } Jm_Log::addObserver('syslog'); $sprites = array(); // create a sprite for every letter $sprites[] = new Jm_Console_Sprite(cs::colorize(' J ', cs::GREEN, cs::BOLD)); $sprites[] = new Jm_Console_Sprite(cs::colorize(' A ', cs::RED, cs::BOLD)); $sprites[] = new Jm_Console_Sprite(cs::colorize(' M ', cs::BLUE, cs::BOLD)); $sprites[] = new Jm_Console_Sprite(' '); $sprites[] = new Jm_Console_Sprite(' C '); $sprites[] = new Jm_Console_Sprite(' O '); $sprites[] = new Jm_Console_Sprite(' N '); $sprites[] = new Jm_Console_Sprite(' S '); $sprites[] = new Jm_Console_Sprite(' O '); $sprites[] = new Jm_Console_Sprite(' L '); $sprites[] = new Jm_Console_Sprite(' E '); for ($i = 0; $i < 100; $i++) { // $sprites []= new Jm_Console_Sprite(' ' . round(mt_rand(0, 1)) . ' '); } // add the sprites to the stage $stage = Jm_Console_Stage::instance(); foreach ($sprites as $sprite) { $stage->append($sprite);
/** * Queries database and returns the resulting data. Used for any queries that fetch data * * @param string $query The parameterized query to execute * @param array $params Array of parameters to fill query with * * @return boolean|array The resulting data, or false on error */ public function get($query, $params = array()) { try { $statement = $this->_connection->prepare($query); if (!is_array($params)) { $params = array($params); } $statement->execute($params); return $statement->fetchAll(PDO::FETCH_BOTH); } catch (PDOException $e) { $cs = cs::getInstance(); throw new Exception($e->getMessage()); return false; } }