mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
some cleanup, wrapping uses() in class exists
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7172 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
273dff46f1
commit
1e231e9511
20 changed files with 100 additions and 68 deletions
|
@ -33,7 +33,9 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
|
|||
/**
|
||||
* Enter description here...
|
||||
*/
|
||||
if (!class_exists('File')) {
|
||||
uses('file');
|
||||
}
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
|
|
|
@ -44,7 +44,7 @@ if (!defined('PHP5')) {
|
|||
require LIBS . 'cache.php';
|
||||
|
||||
Configure::getInstance();
|
||||
|
||||
|
||||
$url = null;
|
||||
|
||||
App::import('Core', array('Session', 'Security', 'String', 'Dispatcher'));
|
||||
|
|
|
@ -194,7 +194,9 @@ class ProjectTask extends Shell {
|
|||
$File =& new File($path . 'config' . DS . 'core.php');
|
||||
$contents = $File->read();
|
||||
if (preg_match('/([\\t\\x20]*Configure::write\\(\\\'Security.salt\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
|
||||
uses('Security');
|
||||
if (!class_exists('Security')) {
|
||||
uses('Security');
|
||||
}
|
||||
$string = Security::generateAuthKey();
|
||||
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \''.$string.'\');', $contents);
|
||||
if ($File->write($result)) {
|
||||
|
|
|
@ -33,7 +33,9 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
|
|||
/**
|
||||
* Enter description here...
|
||||
*/
|
||||
if (!class_exists('File')) {
|
||||
uses('file');
|
||||
}
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
|
|
|
@ -118,15 +118,20 @@ class Cache extends Object {
|
|||
}
|
||||
|
||||
$engine = $settings['engine'];
|
||||
|
||||
|
||||
if ($name !== $_this->__name) {
|
||||
//pr('n' . $name);
|
||||
//pr('name' . $_this->__name);
|
||||
|
||||
if ($_this->engine($engine, $settings) === false) {
|
||||
return false;
|
||||
}
|
||||
$_this->__name = $name;
|
||||
|
||||
}
|
||||
|
||||
$settings = $_this->__config[$name] = $_this->settings($engine);
|
||||
|
||||
//pr($_this->__config);
|
||||
return compact('engine', 'settings');
|
||||
}
|
||||
/**
|
||||
|
|
4
cake/libs/cache/file.php
vendored
4
cake/libs/cache/file.php
vendored
|
@ -79,7 +79,9 @@ class FileEngine extends CacheEngine {
|
|||
function init($settings = array()) {
|
||||
parent::init(array_merge(array('engine' => 'File', 'path' => CACHE, 'prefix'=> 'cake_', 'lock'=> false, 'serialize'=> true), $settings));
|
||||
if(!isset($this->__File)) {
|
||||
uses('file');
|
||||
if (!class_exists('File')) {
|
||||
uses('file');
|
||||
}
|
||||
$this->__File =& new File($this->settings['path'] . DS . 'cake');
|
||||
}
|
||||
$this->settings['path'] = $this->__File->Folder->cd($this->settings['path']);
|
||||
|
|
|
@ -207,7 +207,9 @@ class Configure extends Object {
|
|||
* @return array List of directories or files in directory
|
||||
*/
|
||||
function __list($path, $suffix = false, $extension = false) {
|
||||
uses('folder');
|
||||
if (!class_exists('Folder')) {
|
||||
uses('folder');
|
||||
}
|
||||
$items = array();
|
||||
$Folder =& new Folder($path);
|
||||
$contents = $Folder->read(false, true);
|
||||
|
@ -274,9 +276,11 @@ class Configure extends Object {
|
|||
}
|
||||
|
||||
if (!class_exists('Debugger')) {
|
||||
require LIBS . 'debugger.php';
|
||||
uses('debugger');
|
||||
}
|
||||
if (!class_exists('CakeLog')) {
|
||||
uses('cake_log');
|
||||
}
|
||||
uses('cake_log');
|
||||
Configure::write('log', LOG_NOTICE);
|
||||
} else {
|
||||
error_reporting(0);
|
||||
|
@ -538,7 +542,9 @@ class Configure extends Object {
|
|||
}
|
||||
|
||||
if ($write === true) {
|
||||
uses('file');
|
||||
if (!class_exists('File')) {
|
||||
uses('file');
|
||||
}
|
||||
$fileClass = new File($file);
|
||||
|
||||
if ($fileClass->writable()) {
|
||||
|
|
|
@ -244,7 +244,7 @@ class DbAcl extends AclBase {
|
|||
*/
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
uses('model' . DS . 'db_acl');
|
||||
App::import('Model', 'DbAcl');
|
||||
$this->Aro =& ClassRegistry::init(array('class' => 'Aro', 'alias' => 'Aro'));
|
||||
$this->Aco =& ClassRegistry::init(array('class' => 'Aco', 'alias' => 'Aco'));
|
||||
}
|
||||
|
|
|
@ -29,9 +29,7 @@
|
|||
/**
|
||||
* Load Security class
|
||||
*/
|
||||
if (!class_exists('Security')) {
|
||||
uses('Security');
|
||||
}
|
||||
App::import('Core', 'Security');
|
||||
/**
|
||||
* Cookie Component.
|
||||
*
|
||||
|
@ -160,8 +158,9 @@ class CookieComponent extends Object {
|
|||
* @param object $controller A reference to the instantiating controller object
|
||||
* @access public
|
||||
*/
|
||||
function initialize(&$controller) {
|
||||
function initialize(&$controller, $settings) {
|
||||
$this->key = Configure::read('Security.salt');
|
||||
$this->_set($settings);
|
||||
}
|
||||
/**
|
||||
* Start CookieComponent for use in the controller
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
uses('session');
|
||||
if (!class_exists('cakesession')) {
|
||||
uses('session');
|
||||
}
|
||||
/**
|
||||
* Session Component.
|
||||
*
|
||||
|
|
|
@ -26,6 +26,22 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('Controller', 'App');
|
||||
class CakeErrorController extends AppController {
|
||||
|
||||
var $name = 'CakeError';
|
||||
|
||||
var $uses = array();
|
||||
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->_set(Router::getPaths());
|
||||
$this->params = Router::getParams();
|
||||
$this->constructClasses();
|
||||
$this->_set(array('cacheAction' => false, 'viewPath' => 'errors'));
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
|
@ -50,15 +66,9 @@ class ErrorHandler extends Object {
|
|||
* @param array $messages Error messages
|
||||
*/
|
||||
function __construct($method, $messages) {
|
||||
App::import('Controller', 'App');
|
||||
App::import('Core', 'Sanitize');
|
||||
|
||||
$this->controller =& new AppController();
|
||||
$this->controller->_set(Router::getPaths());
|
||||
$this->controller->params = Router::getParams();
|
||||
$this->controller->constructClasses();
|
||||
$this->controller->Component->initialize($this->controller);
|
||||
$this->controller->_set(array('cacheAction' => false, 'viewPath' => 'errors'));
|
||||
$this->controller =& new CakeErrorController();
|
||||
|
||||
$allow = array('.', '/', '_', ' ', '-', '~');
|
||||
if (substr(PHP_OS, 0, 3) == "WIN") {
|
||||
|
|
|
@ -33,7 +33,7 @@ if (!class_exists('Object')) {
|
|||
}
|
||||
|
||||
if (!class_exists('Folder')) {
|
||||
uses ('folder');
|
||||
uses('folder');
|
||||
}
|
||||
/**
|
||||
* Convenience class for reading, writing and appending to files.
|
||||
|
|
|
@ -30,10 +30,12 @@
|
|||
* Included libraries.
|
||||
*
|
||||
*/
|
||||
if (!class_exists('Object')) {
|
||||
uses('object');
|
||||
}
|
||||
uses('Set');
|
||||
if (!class_exists('Object')) {
|
||||
uses('object');
|
||||
}
|
||||
if (!class_exists('Set')) {
|
||||
uses('set');
|
||||
}
|
||||
/**
|
||||
* Pluralize and singularize English words.
|
||||
*
|
||||
|
@ -422,7 +424,7 @@ class Inflector extends Object {
|
|||
*/
|
||||
function slug($string, $replacement = '_') {
|
||||
if(!class_exists('String')) {
|
||||
App::import('Core', 'String');
|
||||
require_once LIBS . 'string.php';
|
||||
}
|
||||
$map = array(
|
||||
'/à|á|å|â/' => 'a',
|
||||
|
|
|
@ -24,8 +24,9 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
uses ('object', 'file');
|
||||
if (!class_exists('File')) {
|
||||
uses ('object', 'file');
|
||||
}
|
||||
/**
|
||||
* A class to parse and use the MagicDb for file type analysis
|
||||
*
|
||||
|
@ -110,7 +111,7 @@ class MagicDb extends Object {
|
|||
$format = array();
|
||||
while (!empty($lines)) {
|
||||
$line = array_shift($lines);
|
||||
if ($line[0] == '#' || empty($line)) {
|
||||
if (isset($line[0]) && $line[0] == '#' || empty($line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,14 +54,8 @@ class AclBehavior extends ModelBehavior {
|
|||
}
|
||||
$this->settings[$model->alias] = array_merge(array('type' => 'requester'), (array)$config);
|
||||
$type = $this->__typeMaps[$this->settings[$model->alias]['type']];
|
||||
|
||||
if (!ClassRegistry::isKeySet($type)) {
|
||||
uses('model' . DS . 'db_acl');
|
||||
$object =& new $type();
|
||||
} else {
|
||||
$object =& ClassRegistry::getObject($type);
|
||||
}
|
||||
$model->{$type} =& $object;
|
||||
App::import('Model', 'DbAcl');
|
||||
$model->{$type} =& ClassRegistry::init($type);;
|
||||
if (!method_exists($model, 'parentNode')) {
|
||||
trigger_error("Callback parentNode() not defined in {$model->alias}", E_USER_WARNING);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,9 @@
|
|||
* Database name for cake sessions.
|
||||
*
|
||||
*/
|
||||
App::import('Core', 'Set');
|
||||
if (!class_exists('Set')) {
|
||||
uses('set');
|
||||
}
|
||||
/**
|
||||
* Session class for Cake.
|
||||
*
|
||||
|
@ -486,7 +488,9 @@ class CakeSession extends Object {
|
|||
break;
|
||||
case 'cache':
|
||||
if (!isset($_SESSION)) {
|
||||
uses('Cache');
|
||||
if (!class_exists('Cache')) {
|
||||
uses('Cache');
|
||||
}
|
||||
if (function_exists('ini_set')) {
|
||||
ini_set('session.use_trans_sid', 0);
|
||||
ini_set('url_rewriter.tags', '');
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
*/
|
||||
uses('view' . DS . 'helpers' . DS . 'xml');
|
||||
App::import('Helper', 'Xml');
|
||||
|
||||
class RssHelper extends XmlHelper {
|
||||
|
||||
|
|
|
@ -35,9 +35,10 @@
|
|||
* @subpackage cake.cake.libs.view.helpers
|
||||
*
|
||||
*/
|
||||
if(!class_exists('cakesession')) {
|
||||
App::import('Core', 'Session');
|
||||
if (!class_exists('cakesession')) {
|
||||
uses('session');
|
||||
}
|
||||
|
||||
class SessionHelper extends CakeSession {
|
||||
/**
|
||||
* List of helpers used by this helper
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
if (!class_exists('HtmlHelper')) {
|
||||
uses('view' . DS . 'helpers' . DS . 'html');
|
||||
App::import('Helper', 'Html');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,21 +33,21 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
|||
}
|
||||
/**
|
||||
* ThemePostsController class
|
||||
*
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.view
|
||||
*/
|
||||
class ThemePostsController extends Controller {
|
||||
/**
|
||||
* name property
|
||||
*
|
||||
*
|
||||
* @var string 'ThemePosts'
|
||||
* @access public
|
||||
*/
|
||||
var $name = 'ThemePosts';
|
||||
/**
|
||||
* index method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -60,14 +60,14 @@ class ThemePostsController extends Controller {
|
|||
}
|
||||
/**
|
||||
* ThemeViewTestErrorHandler class
|
||||
*
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.view
|
||||
*/
|
||||
class ThemeViewTestErrorHandler extends ErrorHandler {
|
||||
/**
|
||||
* stop method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -77,16 +77,16 @@ class ThemeViewTestErrorHandler extends ErrorHandler {
|
|||
}
|
||||
/**
|
||||
* TestThemeView class
|
||||
*
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.view
|
||||
*/
|
||||
class TestThemeView extends ThemeView {
|
||||
/**
|
||||
* renderElement method
|
||||
*
|
||||
* @param mixed $name
|
||||
* @param array $params
|
||||
*
|
||||
* @param mixed $name
|
||||
* @param array $params
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -95,8 +95,8 @@ class TestThemeView extends ThemeView {
|
|||
}
|
||||
/**
|
||||
* getViewFileName method
|
||||
*
|
||||
* @param mixed $name
|
||||
*
|
||||
* @param mixed $name
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -105,8 +105,8 @@ class TestThemeView extends ThemeView {
|
|||
}
|
||||
/**
|
||||
* getLayoutFileName method
|
||||
*
|
||||
* @param mixed $name
|
||||
*
|
||||
* @param mixed $name
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -115,14 +115,14 @@ class TestThemeView extends ThemeView {
|
|||
}
|
||||
/**
|
||||
* cakeError method
|
||||
*
|
||||
* @param mixed $method
|
||||
* @param mixed $messages
|
||||
*
|
||||
* @param mixed $method
|
||||
* @param mixed $messages
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function cakeError($method, $messages) {
|
||||
$error =& new ViewTestErrorHandler($method, $messages);
|
||||
$error =& new ThemeViewTestErrorHandler($method, $messages);
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class TestThemeView extends ThemeView {
|
|||
class ThemeViewTest extends UnitTestCase {
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -150,7 +150,7 @@ class ThemeViewTest extends UnitTestCase {
|
|||
}
|
||||
/**
|
||||
* testPluginGetTemplate method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -175,7 +175,7 @@ class ThemeViewTest extends UnitTestCase {
|
|||
}
|
||||
/**
|
||||
* testGetTemplate method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -216,7 +216,7 @@ class ThemeViewTest extends UnitTestCase {
|
|||
}
|
||||
/**
|
||||
* testMissingView method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -240,7 +240,7 @@ class ThemeViewTest extends UnitTestCase {
|
|||
}
|
||||
/**
|
||||
* testMissingLayout method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -262,7 +262,7 @@ class ThemeViewTest extends UnitTestCase {
|
|||
}
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue