/** * 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 index($params) { // Prepare the View $view = new View($this); $view->setSource(Config::get('core.dir.views') . '/index/index.tpl.php'); // 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>
*/ 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)');
/** * 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 -->