Permalink
Browse files

Upgrading trunk to be PHP 5.2+ compatible:

 * index.php check upgraded to 5.2
 * All checks for PHP < 5.2 in libraries and helpers removed
 * Removed unnecessary examples
 * Re-organized Bootstrap pre-initialization setup
 * Updated module path handling to define MODPATH in index.php
 * Updated module paths in config.php to use MODPATH for default modules
 * Removed Loader and core.preload configuration setting
  • Loading branch information...
1 parent 6decd8e commit e81233eb173f25c803b007b45875c991ea58c9d4 Shadowhand committed Feb 9, 2008
View
18 application/config/config.php
@@ -61,18 +61,8 @@
*/
$config['modules'] = array
(
- // 'modules/auth', // Authentication
- // 'modules/forge', // Form generation
- // 'modules/kodoc', // Self-generating documentation
- // 'modules/media', // Media caching and compression
+ // MODPATH.'auth', // Authentication
+ // MODPATH.'forge', // Form generation
+ // MODPATH.'kodoc', // Self-generating documentation
+ // MODPATH.'media', // Media caching and compression
);
-
-/**
- * Libraries and models to be automatically preloaded into every controller. Use
- * a comma-separated list to set multiple items.
- */
-$config['preload'] = array
-(
- 'libraries' => '',
- 'models' => '',
-);
View
45 application/controllers/additional_examples/paypal.php
@@ -1,45 +0,0 @@
-<?php
-
-class Paypal_Controller extends Controller {
-
- // This will demo a simple paypal transaction. It really only comes down to two steps.
- function __construct()
- {
- parent::__construct();
-
- $this->paypal = new Payment();
- }
-
- // This will set up the transaction and redirect the user to paypal to login
- function index()
- {
- $this->paypal->amount = 5;
- $this->paypal->process();
- }
-
- // Once the user logs in, paypal redirects them here (set in the config file), which processes the payment
- function return_test()
- {
- $this->paypal->amount = 5;
- $this->paypment->payerid = $this->input->get('payerid');
- echo ($this->paypal->process()) ? "WORKED" : "FAILED";
- }
-
- // This is the cancel URL (set from the config file)
- function cancel_test()
- {
- echo 'cancelled';
- }
-
- // Just some utility functions.
- function reset_session()
- {
- $this->session->destroy();
- url::redirect('paypal/index');
- }
-
- function session_status()
- {
- echo '<pre>'.print_r($this->session->get(), true);
- }
-}
View
5 application/views/viewinview/container.php
@@ -1,5 +0,0 @@
-<?php echo $header ?>
-<div id="content">
-<?php echo $content ?>
-</div>
-<?php echo $this->load->view('viewinview/footer', array('copyright' => $copyright )) ?>
View
5 application/views/viewinview/footer.php
@@ -1,5 +0,0 @@
-<div id="footer">
-<?php echo $copyright ?>
-</div>
-</body>
-</html>
View
10 application/views/viewinview/header.php
@@ -1,10 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
-
-<title><?php echo $title ?></title>
-
-</head>
-<body>
View
27 index.php
@@ -1,8 +1,8 @@
<?php
/**
* This file acts as the "front controller" to your application. You can
- * configure your application and system directories here, as well as error
- * reporting and error display.
+ * configure your application, modules, and system directories here.
+ * PHP error_reporting level may also be changed.
*
* @package Core
* @author Kohana Team
@@ -11,21 +11,31 @@
*/
/**
- * Kohana website application directory. This directory should contain your
- * application configuration, controllers, models, views, and other resources.
+ * Website application directory. This directory should contain your application
+ * configuration, controllers, models, views, and other resources.
*
* This path can be absolute or relative to this file.
*/
$kohana_application = 'application';
/**
- * Kohana package files. This directory should contain the core/ directory, and
- * the resources you included in your download of Kohana.
+ * Kohana modules directory. This directory should contain all the modules used
+ * by your application. Modules are enabled and disabled by the application
+ * configuration file.
+ *
+ * This path can be absolute or relative to this file.
+ */
+$kohana_modules = 'modules';
+
+/**
+ * Kohana system directory. This directory should contain the core/ directory,
+ * and the resources you included in your download of Kohana.
*
* This path can be absolute or relative to this file.
*/
$kohana_system = 'system';
+
/**
* Set the error reporting level. Unless you have a special need, E_ALL is a
* good level for error reporting.
@@ -49,7 +59,7 @@
* Test to make sure that Kohana is running on PHP 5.1.3 or newer. Once you are
* sure that your environment is compatible with Kohana, you can disable this.
*/
-version_compare(PHP_VERSION, '5.1.3', '<') and exit('Kohana requires PHP 5.1.3 or newer.');
+version_compare(PHP_VERSION, '5.2', '<') and exit('Kohana requires PHP 5.2 or newer.');
//
// DO NOT EDIT BELOW THIS LINE, UNLESS YOU FULLY UNDERSTAND THE IMPLICATIONS.
@@ -63,10 +73,11 @@
// Define application and system paths
define('APPPATH', str_replace('\\', '/', realpath($kohana_application)).'/');
+define('MODPATH', str_replace('\\', '/', realpath($kohana_modules)).'/');
define('SYSPATH', str_replace('\\', '/', realpath($kohana_system)).'/');
// Clean up
-unset($kohana_application, $kohana_system);
+unset($kohana_application, $kohana_modules, $kohana_system);
(is_dir(APPPATH) AND is_dir(APPPATH.'/config')) or die
(
View
25 system/core/Bootstrap.php
@@ -10,46 +10,41 @@
* @license http://kohanaphp.com/license.html
*/
-define('KOHANA_VERSION', '2.1');
-define('KOHANA_CODENAME', 'Schneefeier');
+define('KOHANA_VERSION', '2.2');
+define('KOHANA_CODENAME', 'efímera');
// Kohana benchmarks are prefixed by a random string to prevent collisions
define('SYSTEM_BENCHMARK', uniqid());
// Load benchmarking support
require SYSPATH.'core/Benchmark'.EXT;
-// Start: total_execution
+// Start total_execution
Benchmark::start(SYSTEM_BENCHMARK.'_total_execution');
-// Start: kohana_loading
+// Start kohana_loading
Benchmark::start(SYSTEM_BENCHMARK.'_kohana_loading');
-// Define Kohana error constant
-defined('E_KOHANA') or define('E_KOHANA', 42);
-// Define 404 error constant
-defined('E_PAGE_NOT_FOUND') or define('E_PAGE_NOT_FOUND', 43);
-// Define database error constant
-defined('E_DATABASE_ERROR') or define('E_DATABASE_ERROR', 44);
-// Define extra E_RECOVERABLE_ERROR for PHP < 5.2
-defined('E_RECOVERABLE_ERROR') or define('E_RECOVERABLE_ERROR', 4096);
// Load core files
require SYSPATH.'core/utf8'.EXT;
require SYSPATH.'core/Config'.EXT;
require SYSPATH.'core/Log'.EXT;
require SYSPATH.'core/Event'.EXT;
require SYSPATH.'core/Kohana'.EXT;
-// End: kohana_loading
+// Prepare the environment
+Kohana::setup();
+
+// End kohana_loading
Benchmark::stop(SYSTEM_BENCHMARK.'_kohana_loading');
-// Start: system_initialization
+// Start system_initialization
Benchmark::start(SYSTEM_BENCHMARK.'_system_initialization');
Event::run('system.ready');
Event::run('system.routing');
-// End: system_initialization
+// End system_initialization
Benchmark::stop(SYSTEM_BENCHMARK.'_system_initialization');
Event::run('system.execute');
View
14 system/core/Kohana.php
@@ -51,6 +51,15 @@ class Kohana {
// Start the environment setup benchmark
Benchmark::start(SYSTEM_BENCHMARK.'_environment_setup');
+ // Define Kohana error constant
+ defined('E_KOHANA') or define('E_KOHANA', 42);
+
+ // Define 404 error constant
+ defined('E_PAGE_NOT_FOUND') or define('E_PAGE_NOT_FOUND', 43);
+
+ // Define database error constant
+ defined('E_DATABASE_ERROR') or define('E_DATABASE_ERROR', 44);
+
// Disable error reporting
$ER = error_reporting(0);
@@ -1104,8 +1113,3 @@ public function sendHeaders()
}
} // End Kohana 404 Exception
-
-/**
- * Run Kohana setup to prepare the environment.
- */
-Kohana::setup();
View
5 system/helpers/cookie.php
@@ -46,10 +46,7 @@ public static function set($name, $value = NULL, $expire = NULL, $path = NULL, $
// Expiration timestamp
$expire = ($expire == 0) ? 0 : time() + (int) $expire;
- // Only set httponly if possible
- return (version_compare(PHP_VERSION, '5.2', '>='))
- ? setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, $httponly)
- : setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
+ return setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, $httponly);
}
/**
View
3 system/libraries/Controller.php
@@ -24,9 +24,6 @@ public function __construct()
Kohana::$instance = $this;
// Loader should always be available
- $this->load = new Loader;
-
- // Loader should always be available
$this->uri = new URI;
// Input should always be available
View
152 system/libraries/Loader.php
@@ -1,152 +0,0 @@
-<?php defined('SYSPATH') or die('No direct script access.');
-/**
- * Loader.
- *
- * $Id$
- *
- * @package Core
- * @author Kohana Team
- * @copyright (c) 2007-2008 Kohana Team
- * @license http://kohanaphp.com/license.html
- */
-class Loader_Core {
-
- /**
- * Autoloads libraries and models specified in config file.
- */
- public function __construct()
- {
- foreach(Config::item('core.preload') as $type => $load)
- {
- if ($load == FALSE) continue;
-
- foreach(explode(',', $load) as $name)
- {
- if (($name = trim($name)) == FALSE) continue;
-
- switch($type)
- {
- case 'libraries':
- if ($name == 'database')
- {
- $this->database();
- }
- else
- {
- $this->library($name);
- }
- break;
- case 'models':
- $this->model($name);
- break;
- }
- }
- }
- }
-
- /**
- * Load library.
- *
- * @param string library name
- * @param array custom configuration
- * @param boolean return library instance instead of adding to Kohana instance
- * @return FALSE|Object FALSE if library is already loaded, instance of library if return is TRUE
- */
- public function library($name, $config = array(), $return = FALSE)
- {
- if (isset(Kohana::instance()->$name) AND $return == FALSE)
- return FALSE;
-
- if ($name == 'database')
- {
- return $this->database($config, $return);
- }
- else
- {
- $class = ucfirst($name);
- $class = new $class($config);
-
- if ($return == TRUE)
- return $class;
-
- Kohana::instance()->$name = $class;
- }
- }
-
- /**
- * Load database.
- *
- * @param string Database config group to use
- * @param boolean return database instance instead of adding to Kohana instance
- * @return void|Database database instance if return is TRUE
- */
- public function database($group = 'default', $return = FALSE)
- {
- $db = new Database($group);
-
- // Return the new database object
- if ($return == TRUE)
- return $db;
-
- Kohana::instance()->db = $db;
- }
-
- /**
- * Load helper. Deprecated.
- *
- * @param string helper name
- */
- public function helper($name)
- {
- // Just don't do this... there's no point.
- Log::add('debug', 'Using $this->load->helper() is deprecated. See Kohana::auto_load().');
- }
-
- /**
- * Load model.
- *
- * @param string model name
- * @param string custom name for accessing model, or TRUE to return instance of model
- * @return void|FALSE|Object FALSE if model is already loaded, instance of model if alias is TRUE
- */
- public function model($name, $alias = FALSE)
- {
- // The alias is used for Controller->alias
- $alias = ($alias == FALSE) ? $name : $alias;
- $class = ucfirst($name).'_Model';
-
- if (isset(Kohana::instance()->$alias))
- return FALSE;
-
- if (strpos($name, '/') !== FALSE)
- {
- // Handle models in subdirectories
- require_once Kohana::find_file('models', $name);
-
- // Reset the class name
- $class = end(explode('/', $class));
- }
-
- // Load the model
- $model = new $class();
-
- // Return the model
- if ($alias === TRUE)
- return $model;
-
- Kohana::instance()->$alias = $model;
- }
-
- /**
- * Load view.
- *
- * @param string view name
- * @param array data to make accessible within view
- * @return View
- */
- public function view($name, $data = array())
- {
- return new View($name, $data);
- }
-
-} // End Loader Class
View
30 system/libraries/Session.php
@@ -129,28 +129,14 @@ public function create($vars = NULL)
session_name(self::$config['name']);
// Set the session cookie parameters
- // Note: the httponly parameter was added in PHP 5.2.0
- if (version_compare(PHP_VERSION, '5.2', '>='))
- {
- session_set_cookie_params
- (
- self::$config['expiration'],
- Config::item('cookie.path'),
- Config::item('cookie.domain'),
- Config::item('cookie.secure'),
- Config::item('cookie.httponly')
- );
- }
- else
- {
- session_set_cookie_params
- (
- self::$config['expiration'],
- Config::item('cookie.path'),
- Config::item('cookie.domain'),
- Config::item('cookie.secure')
- );
- }
+ session_set_cookie_params
+ (
+ self::$config['expiration'],
+ Config::item('cookie.path'),
+ Config::item('cookie.domain'),
+ Config::item('cookie.secure'),
+ Config::item('cookie.httponly')
+ );
// Register non-native driver as the session handler
if (self::$config['driver'] != 'native')

0 comments on commit e81233e

Please sign in to comment.