Source for file helper.php
Documentation is available at helper.php
* @package FrameworkOnFramework
* @copyright Copyright (C) 2010 - 2012 Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
// Protect from unauthorized access
* FOFForm's helper class.
* Provides a storage for filesystem's paths where FOFForm's entities reside and
* methods for creating those entities. Also stores objects with entities'
* prototypes for further reusing.
* @package FrameworkOnFramework
* Method to load a form field object given a type.
* @param string $type The field type.
* @param boolean $new Flag to toggle whether we should get a new instance of the object.
* @return mixed JFormField object on success, false otherwise.
return self::loadType('field', $type, $new);
* Method to load a form field object given a type.
* @param string $type The field type.
* @param boolean $new Flag to toggle whether we should get a new instance of the object.
* @return mixed JFormField object on success, false otherwise.
return self::loadType('header', $type, $new);
* Method to load a form entity object given a type.
* Each type is loaded only once and then used as a prototype for other objects of same type.
* Please, use this method only with those entities which support types (forms don't support them).
* @param string $entity The entity.
* @param string $type The entity type.
* @param boolean $new Flag to toggle whether we should get a new instance of the object.
* @return mixed Entity object on success, false otherwise.
protected static function loadType($entity, $type, $new =
true)
// Reference to an array with current entity's type instances
$types =
&self::$entities[$entity];
// Return an entity object if it already exists and we don't need a new one.
if (isset
($types[$key]) &&
$new ===
false)
$class =
self::loadClass($entity, $type);
// Instantiate a new type object.
$types[$key] =
new $class;
* Attempt to import the JFormField class file if it isn't already imported.
* You can use this method outside of JForm for loading a field for inheritance or composition.
* @param string $type Type of a field whose class should be loaded.
* @return mixed Class name on success or false otherwise.
return self::loadClass('field', $type);
* Attempt to import the FOFFormHeader class file if it isn't already imported.
* You can use this method outside of JForm for loading a field for inheritance or composition.
* @param string $type Type of a field whose class should be loaded.
* @return mixed Class name on success or false otherwise.
return self::loadClass('header', $type);
* Load a class for one of the form's entities of a particular type.
* Currently, it makes sense to use this method for the "field" and "rule" entities
* (but you can support more entities in your subclass).
* @param string $entity One of the form entities (field or rule).
* @param string $type Type of an entity.
* @return mixed Class name on success or false otherwise.
public static function loadClass($entity, $type)
list
($prefix, $type) =
explode('.', $type);
// Get the field search path array.
$paths =
self::addPath($entity);
// If the type is complex, add the base type to the paths.
if ($pos =
strpos($type, '_'))
// Add the complex type prefix to the paths.
for ($i =
0, $n =
count($paths); $i <
$n; $i++
)
// If the path does not exist, add it.
// Break off the end of the complex type.
$type =
substr($type, $pos +
1);
// Try to find the class file.
foreach ($paths as $path)
// Check for all if the class exists.
* Method to add a path to the list of header include paths.
* @param mixed $new A path or array of paths to add.
* @return array The list of paths that have been added.
return self::addPath('header', $new);
Documentation generated on Tue, 19 Nov 2013 15:04:39 +0100 by phpDocumentor 1.4.3