2005-10-09 01:56:21 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
|
|
|
|
/**
|
2005-12-27 03:33:44 +00:00
|
|
|
*
|
2005-10-09 01:56:21 +00:00
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
2006-01-20 07:46:14 +00:00
|
|
|
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
2005-12-23 21:57:26 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
2005-10-09 01:56:21 +00:00
|
|
|
*
|
2005-12-23 21:57:26 +00:00
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
2005-10-09 01:56:21 +00:00
|
|
|
*
|
2005-12-27 03:33:44 +00:00
|
|
|
* @filesource
|
2006-01-20 07:46:14 +00:00
|
|
|
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
2005-12-23 21:57:26 +00:00
|
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
2005-10-09 01:56:21 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.libs.controller
|
|
|
|
* @since CakePHP v TBD
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.libs.controller
|
|
|
|
* @since CakePHP v TBD
|
|
|
|
*/
|
|
|
|
class Component extends Object
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
|
|
|
var $components = array();
|
2005-12-27 03:33:44 +00:00
|
|
|
|
2005-10-09 01:56:21 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
|
|
|
var $controller = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @return Component
|
|
|
|
*/
|
|
|
|
function Component(&$controller)
|
|
|
|
{
|
|
|
|
$this->controller =& $controller;
|
2005-10-29 05:11:20 +00:00
|
|
|
if ($this->controller->components !== false)
|
|
|
|
{
|
|
|
|
$loaded = array();
|
|
|
|
$loaded = $this->_loadComponents($loaded,$this->controller->components);
|
|
|
|
foreach(array_keys($loaded) as $component)
|
|
|
|
{
|
|
|
|
$tempComponent =& $loaded[$component];
|
|
|
|
if(isset($tempComponent->components) && is_array($tempComponent->components))
|
|
|
|
{
|
|
|
|
foreach($tempComponent->components as $subComponent)
|
|
|
|
{
|
|
|
|
$this->controller->{$component}->{$subComponent} =& $loaded[$subComponent];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-10-09 01:56:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $loaded
|
|
|
|
* @param unknown_type $components
|
|
|
|
* @return unknown
|
|
|
|
*/
|
|
|
|
function &_loadComponents(&$loaded, $components)
|
|
|
|
{
|
|
|
|
foreach ($components as $component)
|
|
|
|
{
|
|
|
|
if(in_array($component, array_keys($loaded)) !== true)
|
|
|
|
{
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
$componentFn = Inflector::underscore($component).'.php';
|
2005-12-27 03:33:44 +00:00
|
|
|
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
if(file_exists(COMPONENTS.$componentFn))
|
2005-10-09 01:56:21 +00:00
|
|
|
{
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
$componentFn = COMPONENTS.$componentFn;
|
2005-10-09 01:56:21 +00:00
|
|
|
}
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
else if(file_exists(LIBS.'controller'.DS.'components'.DS.$componentFn))
|
2005-10-09 01:56:21 +00:00
|
|
|
{
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
$componentFn = LIBS.'controller'.DS.'components'.DS.$componentFn;
|
2005-10-09 01:56:21 +00:00
|
|
|
}
|
2005-12-27 03:33:44 +00:00
|
|
|
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
$componentCn = $component.'Component';
|
2005-12-27 03:33:44 +00:00
|
|
|
|
2005-10-09 01:56:21 +00:00
|
|
|
if (is_file($componentFn))
|
|
|
|
{
|
|
|
|
require_once $componentFn;
|
2005-12-27 03:33:44 +00:00
|
|
|
|
2005-12-27 17:14:32 +00:00
|
|
|
if(class_exists($componentCn)===true)
|
2005-10-09 01:56:21 +00:00
|
|
|
{
|
2005-12-27 03:33:44 +00:00
|
|
|
if($componentCn == 'SessionComponent')
|
|
|
|
{
|
|
|
|
$param = $this->controller->base.'/';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$param = null;
|
|
|
|
}
|
|
|
|
$this->controller->{$component} =& new $componentCn($param);
|
2005-10-09 01:56:21 +00:00
|
|
|
$loaded[$component] =& $this->controller->{$component};
|
|
|
|
if (isset($this->controller->{$component}->components) && is_array($this->controller->{$component}->components))
|
|
|
|
{
|
|
|
|
$loaded =& $this->_loadComponents($loaded, $this->controller->{$component}->components);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-01-13 23:53:23 +00:00
|
|
|
return $this->cakeError('missingComponentClass',
|
|
|
|
array(array('className' => $this->controller->name,
|
|
|
|
'component' => $component,
|
|
|
|
'file' => $componentFn)));
|
2005-10-09 01:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-01-13 23:53:23 +00:00
|
|
|
return $this->cakeError('missingComponentFile',
|
|
|
|
array(array('className' => $this->controller->name,
|
|
|
|
'component' => $component,
|
|
|
|
'file' => $componentFn)));
|
2005-10-09 01:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $loaded;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|