Source for file component.php
Documentation is available at component.php
* @package FrameworkOnFramework
* @copyright Copyright (c)2010-2012 Nicholas K. Dionysopoulos
* @license GNU General Public License version 2, or later
* An autoloader for FOF-powered components. It allows the autoloading of
* various classes related to the operation of a component, from Controllers
* and Models to Helpers and Fields. If a class doesn't exist, it will be
* @package FrameworkOnFramework
* An instance of this autoloader
* @var FOFAutoloaderComponent
public static $autoloader =
null;
* The path to the FOF root directory
public static $fofPath =
null;
* An array holding component names and their FOF-ness status
protected static $fofComponents =
array();
* Initialise this autoloader
* @return FOFAutoloaderComponent
public static function init()
if (self::$autoloader ==
null)
self::$autoloader =
new self;
return self::$autoloader;
* Public constructor. Registers the autoloader with PHP.
self::$fofPath =
realpath(__DIR__ .
'/../');
* Returns true if this is a FOF-powered component, i.e. if it has a fof.xml
* file in its main directory.
* @param string $component The component's name
if (!isset
($fofComponents[$component]))
$fofComponents[$component] =
file_exists($componentPaths['admin'] .
'/fof.xml');
return $fofComponents[$component];
* Creates class aliases. On systems where eval() is enabled it creates a
* real class. On other systems it merely creates an alias. The eval()
* method is preferred as class_aliases result in the name of the class
* being instanciated not being available, making it impossible to create
* a class instance without passing a $config array :(
* @param string $original The name of the original (existing) class
* @param string $alias The name of the new (aliased) class
* @param boolean $autoload Should I try to autoload the $original class?
private function class_alias($original, $alias, $autoload =
true)
if (function_exists('ini_get'))
$disabled_functions =
ini_get('disabled_functions');
if (!is_string($disabled_functions))
$disabled_functions =
explode(',', $disabled_functions);
$hasEval =
!in_array('eval', $disabled_functions);
$phpCode =
"class $alias extends $original {}";
* @param string $class_name The name of the class to load
JLog::add(__METHOD__ .
"() autoloading $class_name", JLog::DEBUG, 'fof');
static $isCli =
null, $isAdmin =
null;
if (is_null($isCli) &&
is_null($isAdmin))
list
($isCli, $isAdmin) =
FOFDispatcher::isCliAdmin();
if (strpos($class_name, 'Controller') ===
false)
// Change from camel cased into a lowercase array
$class_modified =
preg_replace('/(\s)+/', '_', $class_name);
$parts =
explode('_', $class_modified);
// We need three parts in the name
// We need the second part to be "controller"
if ($parts[1] !=
'controller')
// Get the information about this class
$component_raw =
$parts[0];
$component =
'com_' .
$parts[0];
// Is this an FOF 2.1 or later component?
// Get the alternate view and class name (opposite singular/plural name)
// Get the component's paths
// Get the proper and alternate paths and file names
$file =
"/controllers/$view.php";
$altFile =
"/controllers/$alt_view.php";
$path =
$componentPaths['main'];
$altPath =
$componentPaths['alt'];
// Try to find the proper class in the proper path
@include_once $path .
$file;
// Try to find the proper class in the alternate path
@include_once $altPath .
$file;
// Try to find the alternate class in the proper path
@include_once $path .
$altFile;
// Try to find the alternate class in the alternate path
@include_once $altPath .
$altFile;
// If the alternate class exists just map the class to the alternate
// No class found? Map to FOFController
* @param string $class_name The name of the class to load
JLog::add(__METHOD__ .
"() autoloading $class_name", JLog::DEBUG, 'fof');
static $isCli =
null, $isAdmin =
null;
if (is_null($isCli) &&
is_null($isAdmin))
list
($isCli, $isAdmin) =
FOFDispatcher::isCliAdmin();
if (strpos($class_name, 'Model') ===
false)
// Change from camel cased into a lowercase array
$class_modified =
preg_replace('/(\s)+/', '_', $class_name);
$parts =
explode('_', $class_modified);
// We need three parts in the name
// We need the second part to be "model"
if ($parts[1] !=
'model')
// Get the information about this class
$component_raw =
$parts[0];
$component =
'com_' .
$parts[0];
// Is this an FOF 2.1 or later component?
// Get the alternate view and class name (opposite singular/plural name)
// Get the proper and alternate paths and file names
$file =
"/models/$view.php";
$altFile =
"/models/$alt_view.php";
$path =
$componentPaths['main'];
$altPath =
$componentPaths['alt'];
// Try to find the proper class in the proper path
@include_once $path .
$file;
// Try to find the proper class in the alternate path
@include_once $altPath .
$file;
// Try to find the alternate class in the proper path
@include_once $path .
$altFile;
// Try to find the alternate class in the alternate path
@include_once $altPath .
$altFile;
// If the alternate class exists just map the class to the alternate
// No class found? Map to FOFModel
* @param string $class_name The name of the class to load
JLog::add(__METHOD__ .
"() autoloading $class_name", JLog::DEBUG, 'fof');
static $isCli =
null, $isAdmin =
null;
if (is_null($isCli) &&
is_null($isAdmin))
list
($isCli, $isAdmin) =
FOFDispatcher::isCliAdmin();
if (strpos($class_name, 'View') ===
false)
// Change from camel cased into a lowercase array
$class_modified =
preg_replace('/(\s)+/', '_', $class_name);
$parts =
explode('_', $class_modified);
// We need at least three parts in the name
// We need the second part to be "view"
// Get the information about this class
$component_raw =
$parts[0];
$component =
'com_' .
$parts[0];
$format =
$input->getCmd('format', 'html', 'cmd');
// Is this an FOF 2.1 or later component?
// Get the alternate view and class name (opposite singular/plural name)
// Get the proper and alternate paths and file names
$protoFile =
"/models/$view";
$protoAltFile =
"/models/$alt_view";
$path =
$componentPaths['main'];
$altPath =
$componentPaths['alt'];
$formats =
array($format);
foreach ($formats as $currentFormat)
$file =
$protoFile .
'.' .
$currentFormat .
'.php';
$altFile =
$protoAltFile .
'.' .
$currentFormat .
'.php';
// Try to find the proper class in the proper path
@include_once $path .
$file;
// Try to find the proper class in the alternate path
@include_once $altPath .
$file;
// Try to find the alternate class in the proper path
@include_once $path .
$altFile;
// Try to find the alternate class in the alternate path
@include_once $altPath .
$altFile;
// If the alternate class exists just map the class to the alternate
// No class found? Map to FOFModel
if (!file_exists(self::$fofPath .
'/view/' .
$format .
'.php'))
$default_class =
'FOFView';
$default_class =
'FOFView' .
ucfirst($format);
* @param string $class_name The name of the class to load
JLog::add(__METHOD__ .
"() autoloading $class_name", JLog::DEBUG, 'fof');
static $isCli =
null, $isAdmin =
null;
if (is_null($isCli) &&
is_null($isAdmin))
list
($isCli, $isAdmin) =
FOFDispatcher::isCliAdmin();
if (strpos($class_name, 'Table') ===
false)
// Change from camel cased into a lowercase array
$class_modified =
preg_replace('/(\s)+/', '_', $class_name);
$parts =
explode('_', $class_modified);
// We need three parts in the name
// We need the second part to be "model"
if ($parts[1] !=
'table')
// Get the information about this class
$component_raw =
$parts[0];
$component =
'com_' .
$parts[0];
// Is this an FOF 2.1 or later component?
// Get the alternate view and class name (opposite singular/plural name)
// Get the proper and alternate paths and file names
$file =
"/tables/$view.php";
$altFile =
"/tables/$alt_view.php";
$path =
$componentPaths['admin'];
// Try to find the proper class in the proper path
@include_once $path .
$file;
// Try to find the alternate class in the proper path
@include_once $path .
$altFile;
// If the alternate class exists just map the class to the alternate
// No class found? Map to FOFModel
* @param string $class_name The name of the class to load
JLog::add(__METHOD__ .
"() autoloading $class_name", JLog::DEBUG, 'fof');
static $isCli =
null, $isAdmin =
null;
if (is_null($isCli) &&
is_null($isAdmin))
list
($isCli, $isAdmin) =
FOFDispatcher::isCliAdmin();
if (strpos($class_name, 'Helper') ===
false)
// Change from camel cased into a lowercase array
$class_modified =
preg_replace('/(\s)+/', '_', $class_name);
$parts =
explode('_', $class_modified);
// We need three parts in the name
// We need the second part to be "model"
if ($parts[1] !=
'helper')
// Get the information about this class
$component_raw =
$parts[0];
$component =
'com_' .
$parts[0];
// Is this an FOF 2.1 or later component?
// Get the alternate view and class name (opposite singular/plural name)
// Get the proper and alternate paths and file names
$file =
"/helpers/$view.php";
$altFile =
"/helpers/$alt_view.php";
$path =
$componentPaths['main'];
$altPath =
$componentPaths['alt'];
// Try to find the proper class in the proper path
@include_once $path .
$file;
// Try to find the proper class in the alternate path
@include_once $altPath .
$file;
// Try to find the alternate class in the proper path
@include_once $path .
$altFile;
// Try to find the alternate class in the alternate path
@include_once $altPath .
$altFile;
// If the alternate class exists just map the class to the alternate
* @param string $class_name The name of the class to load
JLog::add(__METHOD__ .
"() autoloading $class_name", JLog::DEBUG, 'fof');
static $isCli =
null, $isAdmin =
null;
if (is_null($isCli) &&
is_null($isAdmin))
list
($isCli, $isAdmin) =
FOFDispatcher::isCliAdmin();
if (strpos($class_name, 'Toolbar') ===
false)
// Change from camel cased into a lowercase array
$class_modified =
preg_replace('/(\s)+/', '_', $class_name);
$parts =
explode('_', $class_modified);
// We need two parts in the name
// We need the second part to be "model"
if ($parts[1] !=
'toolbar')
// Get the information about this class
$component_raw =
$parts[0];
$component =
'com_' .
$parts[0];
// Get the proper and alternate paths and file names
$file =
"/components/$component/toolbar.php";
// Try to find the proper class in the proper path
@include_once $path .
$file;
// Try to find the proper class in the alternate path
@include_once $altPath .
$file;
// No class found? Map to FOFToolbar
* @param string $class_name The name of the class to load
JLog::add(__METHOD__ .
"() autoloading $class_name", JLog::DEBUG, 'fof');
Documentation generated on Tue, 19 Nov 2013 14:56:13 +0100 by phpDocumentor 1.4.3