function index($params) { // Prepare the View $view = new View($this); $view->setSource(Config::get('core.dir.views') . '/index/index.tpl.php'); // Result return $view; }
/** * This is the default version of the 'unknown' action (triggered when an * unknown action is requested in the url command). * Your controllers should override this to handle it to suit your needs. * * @param array $params Url parameters * @param string $actionCommand The originally requested action * @return View */ public function unknown($params, $actionCommand) { // Generate the default 404 page $view = new View(); $view->setSource(Config::get('core.dir.views') . '/errorPages/404.tpl'); // Result return $view; }
function unknown($params, $actionCommand) { // Prepare the View $view = new View(); $view->setSource(Config::get('core.dir.views') . '/unknown/unknown.tpl.php'); // Result return $view; }
/** * Returns the "Global View", which is the View object that sits above all * others in the View hierarchy. * * @param array * @return Buan\View */ public function index($params) { // Create the View $view = new View(); $view->setSource(Config::get('core.dir.views') . '/global-view/index.tpl.php'); // Return return $view; }
/** * All core actions should pass their view through this method in order wrap * some common elements around it. * * @param Buan\View * @return Buan\View */ private function wrapper($slotView) { // Prepare the GlobalView // We want to use our own template, overriding the application author's // own GlobalViewController. // Because we can't guarantee that the author is not caching their GlobalView // instance, we'll need to store a reference to it in the $slotView. // Any subsequent calls to View::getGlobalView() in child slots should be // replaced with $GV $GV = View::getGlobalView(); $GV->setSource(Config::get('core.dir.views') . '/global-view/index.tpl.php'); $GV->html = new HtmlView($GV); $slotView->GV = $GV; // Create a View for rendering the SystemLog $slView = new View(); $slView->setSource(Config::get('core.dir.views') . '/system-log.tpl.php'); $GV->attachViewToSlot($slView, 'system-log'); // Result return $slotView; }
<?php /* $Id$ */ use Buan\Config; $GV->html->addJavascripts(Config::get('core.url.resources') . '/js/core/extension-manager.js', Config::get('core.url.resources') . '/js/core/json.js'); ?> <h1>Extension Manager</h1> <table> <caption>The following extensions are available</caption> <thead> <tr> <th>Extension title</th> <th>Description</th> <th>Version</th> <th>Options</th> </tr> </thead> <tbody> <?php foreach ($extensions as $name => $ext) { ?> <tr> <td><?php echo $ext->title; ?> </td> <td><?php echo htmlspecialchars($ext->description); ?> </td>
# - Prepare global functions and variables # # It does NOT operate on any passed parameters (in particular, $_REQUEST['do']) # - this is left to the application in order to provide as much freedom from the # core as possible. The core is only here to provide the code framework, not # overly-enforce routines on the programmer. */ /* # Set some global configuration values. # Try to work out the url on which the app is running. */ use Buan\Config; /* # Enable output buffering (if it's not too late!) */ $ini_ob = (int) ini_get('output_buffering'); if ($ini_ob <= 0) { ob_start(); } /* # Setup the class auto-loader and other common classes */ $cwd = str_replace("\\", "/", dirname(__FILE__)); $dr = isset($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['DOCUMENT_ROOT']) ? str_replace("\\", "/", $_SERVER['DOCUMENT_ROOT']) : dirname($cwd); $cwu = strpos(dirname($cwd), $dr) !== false ? str_replace($dr, '', dirname($cwd)) : ''; Config::set('timeStarted', microtime(true)); Config::set('core', ['customUrlRoutes' => [], 'dir' => ['controllers' => $cwd . '/controllers', 'resources' => $cwd . '/buan-pub', 'views' => $cwd . '/views'], 'docRoot' => $cwd, 'url' => ['resources' => "{$cwu}/buan/buan-pub"], 'version' => ['major' => 1, 'minor' => 1, 'revision' => 3]]); /* # Clean up */ unset($cwd, $dr, $cwu);
*/ Config::set('app.command.urlPrefix', 'do'); Config::set('app.command.parameter', 'do'); Config::set('app.command.default', ''); Config::set('app.dir.controllers', dirname(dirname(__FILE__)) . '/controllers'); Config::set('app.dir.ignored', array('.', '..', '.svn', 'cvs')); Config::set('app.docRoot', dirname(dirname(__FILE__))); Config::set('app.domain', 'localhost'); Config::set('app.password', 'password'); Config::set('app.dir.databases', dirname(dirname(__FILE__)) . '/db'); AutoLoader::addClassPath(dirname(dirname(__FILE__)) . '/models'); AutoLoader::addClassPath(dirname(dirname(__FILE__)) . '/models/managers'); /* # Database */ Database::addConnection(array('name' => 'default', 'driver' => 'sqlite', 'dsn' => 'sqlite:' . Config::get('app.dir.databases') . '/model.s3db')); /* Alternative for testing whilst building test on dev machine Database::addConnection(array( 'name'=>'default', 'driver'=>'mysql', 'dsn'=>'mysql:host=localhost;dbname=buan_test', 'username'=>'root', 'password'=>'' ));*/ /* # Model relationships */ ModelRelation::define('Person(1):PersonAddress(M):Address(1)'); ModelRelation::define('Person(1):Account(1)'); ModelRelation::define('Person(1):PersonAlias(M,2)'); ModelRelation::define('Person(1):PersonBook(M):Book(1)');
# the "app.password" setting. # # MOD_REWRITE: # If you do not have mod_rewrite available on your apache installation then set # the [app.command.urlPrefix] config variable to "/index.php" */ $__pwd = dirname(dirname(__FILE__)); Config::set('app.command.default', '/core'); Config::set('app.command.parameter', 'do'); Config::set('app.command.urlPrefix', ''); Config::set('app.dir.controllers', "{$__pwd}/app/controllers"); Config::set('app.dir.ignored', array('.', '..', '.svn', 'cvs')); Config::set('app.docRoot', "{$__pwd}"); Config::set('app.domain', isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost'); Config::set('app.password', 'admin'); Config::set('app.urlRoot', ''); /* # Model and ModelManager class paths # If you use Models and ModelManagers then add their locations to the global # class path. */ AutoLoader::addClassPath("{$__pwd}/models"); AutoLoader::addClassPath("{$__pwd}/models/managers"); /* # Database connections. # You may add any number of database connections using Database::addConnection(). # If you are going to use databases at all, you MUST define one named "default". # # See documentation for "Database::addConnection()". */ /*
/** * Returns a database connection resource (PDO) or FALSE and a thrown * exception if no such connection exists, or could not be achieved. * * @param string $connectionName Name of connection to retrieve, or "default" if not specified * @return false|PdoWrapper * @throws Exception */ public static function getConnection($connectionName = 'default') { // Check that the connection exists if (!isset(self::$connections[$connectionName])) { throw new Exception('The Database connection "' . $connectionName . '" does not exist.'); } $connection = self::$connections[$connectionName]; // If the requested connection is already open then return that connection // resource if (isset(self::$openConnections[$connection['name']])) { return self::$openConnections[$connection['name']]; } // Check that the PDO extension has been loaded into PHP // We'll assume, for reasons of good practice, that extensions can only be // loaded via the "extension" directive in "php.ini" if (!in_array($connection['driver'], PDO::getAvailableDrivers())) { // Halt throw new Exception('Required PDO driver "pdo_' . $connection['driver'] . '" has not been enabled in php.ini'); } // Establish a connection with the database try { // Construct DSN if it hasn't been explicitly defined in $connection if (isset($connection['dsn'])) { if (preg_match("/dbname=([a-z0-9_]+)?\$/i", $connection['dsn'], $m)) { $connection['database'] = $m[1]; } } else { if ($connection['driver'] == 'mysql') { $connection['dsn'] = 'mysql:host=' . $connection['host'] . ';dbname=' . $connection['database']; } else { if ($connection['driver'] == 'sqlite') { if (is_dir(Config::get('app.dir.temp'))) { $connection['dsn'] = 'sqlite:' . Config::get('app.dir.temp') . '/' . $connection['database'] . '.db'; } else { throw new Exception('Invalid folder defined in [app.dir.temp]'); } } else { throw new Exception('Database DSN cannot be resolved.'); } } } self::$connections[$connectionName] = $connection; // Attempt connection $connResource = new PdoWrapper($connection['dsn'], @$connection['username'], @$connection['password'], @$connection['options']); // Set PDO attributes $connResource->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if ($connection['driver'] == 'mysql') { $connResource->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); // see http://bugs.php.net/bug.php?id=35793 } } catch (Exception $e) { // Log throw new Exception('Failed to establish "' . $connection['name'] . '" connection: ' . $e->getMessage()); } // Store the resource in memory and return it self::$openConnections[$connection['name']] = $connResource; return $connResource; }
<?php /* $Id: diagnostic.tpl 155 2007-09-17 10:48:30Z james $ */ use Buan\Config; $GV->html->addStylesheets(Config::get('core.url.resources') . '/css/core/diagnostic.css'); ?> <h1>Diagnostics</h1> <h3>Folder path/permission checks:</h3> <ul class="test"> <?php foreach ($permissionDirs as $dir) { ?> <li> <?php echo $dir['name']; ?> ... <?php echo $dir['passed'] ? '<span class="passed">OK</span>' : '<span class="failed">FAIL</span> (' . $dir['testMessage'] . ')'; ?> <pre> <?php echo $dir['path']; ?> </pre> </li> <?php } ?> </ul>
use Buan\Config; ?> <!-- Buan JavaScript --> <script type="text/javascript" src="<?php echo Config::get('core.url.resources'); ?> /js/Buan.Config.js"></script> <script type="text/javascript" src="<?php echo Config::get('core.url.resources'); ?> /js/Buan.UrlCommand.js"></script> <script type="text/javascript"> Buan.Config.set('app.command.urlPrefix', '<?php echo Config::get('app.command.urlPrefix'); ?> '); Buan.Config.set('app.command.parameter', '<?php echo Config::get('app.command.parameter'); ?> '); Buan.Config.set('app.domain', '<?php echo Config::get('app.domain'); ?> '); Buan.Config.set('app.urlRoot', '<?php echo Config::get('app.urlRoot'); ?> '); </script> <!-- end -->