Source for file model.php
Documentation is available at model.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
require_once JPATH_LIBRARIES .
'/joomla/form/fields/sql.php';
* Form Field class for FOF
* Generic list from a model's results
* @package FrameworkOnFramework
* Method to get certain otherwise inaccessible properties from the form field object.
* @param string $name The property name for which to the the value.
* @return mixed The property value or null.
public function __get($name)
return parent::__get($name);
* Get the rendering of this field type for static display, e.g. in a single
* item view (typically a "read" task).
* @return string The field HTML
$class =
$this->element['class'] ?
' class="' . (string)
$this->element['class'] .
'"' :
'';
return '<span id="' .
$this->id .
'" ' .
$class .
'>' .
* Get the rendering of this field type for a repeatable (grid) display,
* e.g. in a view listing many item (typically a "browse" task)
* @return string The field HTML
$class = (string)
$this->element['class'];
$format_string = (string)
$this->element['format'];
if ($this->element['show_link'] ==
'true')
// Replace [ITEM:ID] in the URL with the item's key value (usually:
// the auto-incrementing numeric ID)
$keyfield =
$this->item->getKeyName();
$replace =
$this->item->$keyfield;
$link_url =
str_replace('[ITEM:ID]', $replace, $link_url);
// Replace other field variables in the URL
$fields =
$this->item->getFields();
foreach ($fields as $fielddata)
$fieldname =
$fielddata->Field;
$fieldname =
$fielddata->column_name;
$search =
'[ITEM:' .
strtoupper($fieldname) .
']';
$replace =
$this->item->$fieldname;
if ($this->element['empty_replacement'])
$empty_replacement = (string)
$this->element['empty_replacement'];
// Get the (optionally formatted) value
if (!empty($empty_replacement) &&
empty($value))
$value =
JText::_($empty_replacement);
if (empty($format_string))
$value =
sprintf($format_string, $value);
$html =
'<span class="' .
$class .
'">';
$html .=
'<a href="' .
$link_url .
'">';
* Method to get the field options.
* @return array The field option objects.
// Initialize some field attributes.
$key =
$this->element['key_field'] ? (string)
$this->element['key_field'] :
'value';
$value =
$this->element['value_field'] ? (string)
$this->element['value_field'] : (string)
$this->element['name'];
$translate =
$this->element['translate'] ? (string)
$this->element['translate'] :
false;
$applyAccess =
$this->element['apply_access'] ? (string)
$this->element['apply_access'] :
'false';
$modelName = (string)
$this->element['model'];
$nonePlaceholder = (string)
$this->element['none'];
if (!empty($nonePlaceholder))
$options[] =
JHtml::_('select.option', JText::_($nonePlaceholder), null);
// Process field atrtibutes
$applyAccess =
in_array($applyAccess, array('yes', 'on', 'true', '1'));
// Explode model name into model name and prefix
$config =
array('savestate' =>
0);
$model->applyAccessFiltering();
// Process state variables
foreach ($this->element->children() as $stateoption)
// Only add <option /> elements.
if ($stateoption->getName() !=
'state')
$stateKey = (string)
$stateoption['key'];
$stateValue = (string)
$stateoption;
$model->setState($stateKey, $stateValue);
// Set the query and get the result list.
$items =
$model->getItemList(true);
// Build the field options.
foreach ($items as $item)
$options[] =
JHtml::_('select.option', $item->$key, JText::_($item->$value));
$options[] =
JHtml::_('select.option', $item->$key, $item->$value);
// Merge any additional options in the XML definition.
Documentation generated on Tue, 19 Nov 2013 15:08:36 +0100 by phpDocumentor 1.4.3