$additionalInstanceName = $object; } else { getInstance()->$class = $object; } return $object; } // This function will load the view file and display it public function view($viewName, $data, $displayView = false) { // Make sure our data is in an array format if(!is_array($data)) { showError('no_array', array('data', 'Loader::view'), E_WARNING); $data = array(); } // Set the filePath for the view $filePath = settings::getFilePath() . DS . settings::getApp() . DS . 'views' . DS . $viewName . DS . 'index.php'; // Set the viewPath for the view $viewPath = array('viewPath' => DS . 'views' . DS . $viewName); // Get the websiteURL for the view $websiteInformation = getUrlInformation(); $websiteInformation = array('websiteURL' => $websiteInformation['websiteURL']); // Set the websitePath $websitePath = array('websitePath' => $websiteInformation['websiteURL'] . settings::getApplicationPath() . "/" . settings::getApp()); // Get all the applications for the view $applications = settings::getApps(); $data = array_merge($data,$viewPath, $websiteInformation, $websitePath, $applications); // extract variables extract($data); // Get our page contents if(file_exists($filePath)) { ob_start(); include($filePath); $page = ob_get_contents(); $page = str_replace(""," " ,$page); ob_end_clean(); // Replace some Global values $Benchmark = loadClass("Benchmark"); $page = str_replace("{elapsed}", $Benchmark->elapsed('system', 4), $page); $page = str_replace("{usage}", $Benchmark->usage(), $page); $page = str_replace("", "\t\n", $page); preg_match('/]*?[^>]*>/i', $page, $body); $page = str_replace("$body[0]", "$body[0]\n
", $page); $page = str_replace("", "
\n", $page); $page = str_replace("\n", "\t\t
\n\t\t

Running on SuperSmash Framework © " . date("Y") . ", SuperSmash

\n\t\n\t", $page); // Spit out the page if(!$displayView) { echo $page; } return $page; } else { showError('view', array($viewName), E_ERROR); return false; } } // This function will be used to call in a class from either the APP library, or the system library folders public function library($name, $instance = true) { // Make sure periods are replaced with slahes if there is any if(strpos($name, ".")) { $name = str_replace('.', '\\', $name); } // Load the Class $class = loadClass($name, 'Library'); // Do we instance this class? if($instance) { // Allow for custom class naming (!$instance) ? $name = $instance : ''; // Instance $FB = getInstance(); if($FB) { (!isset($FB->$name)) ? $FB->$name = $class : ''; } } return $class; } // This function will be used to setup a database connection public function database($arguments, $instance = true) { // Load our connection settings. We can allow custom connection arguments if(!is_array($arguments)) { // Check our registry to see if we already loaded this connection $object = \Registry::singleton()->load("database".$arguments); if($object != null) { // Skip to the instancing part unless we set instance to false if($instance) { goto Instance; } return $object; } // Get the DB connection information $info = configuration($arguments, 'database'); if($info === null) { showError('db_key_not_found', array($arguments), E_ERROR); } } // Not in the registry, so establish a new connection $dispatch = $first ."Database\\Driver"; $object = new $dispatch($info); // Store the connection in the registry \Registry::singleton()->store("DBC_".$arguments, $object); // Here is our instance goto Instance: { // If user wants to instance this, then we do that if($instance && !is_numeric($arguments)) { if($instance) $instance = $arguments; // Easy way to instance the connection is like this $FB = getInstance(); if($FB) { (!isset($FB->$instance)) ? $FB->$instance = $object : ''; } } } return $object; } // This function is used to load in a helper file from either the application/helpers, or the SuperSmash/helpers folders public function helper($name) { // Check the application/helpers folder if(file_exists(settings::getFilePath() . DS . settings::getApp() . DS . 'helpers' . DS . $name . '.php')) { require_once(settings::getFilePath() . DS . settings::getApp() . DS . 'helpers' . DS . $name . '.php'); } // Check the core/helpers folder else { require_once(SYSTEM . DS . 'helpers' . DS . $name . '.php'); } } } ?>