Source for file header.php
Documentation is available at header.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
* An interface for FOFFormHeader fields, used to define the filters and the
* elements of the header row in repeatable (browse) views
* @package FrameworkOnFramework
* The description text for the form field. Usually used in tooltips.
* The SimpleXMLElement object of the <field /> XML element that describes the header field.
* The FOFForm object of the form attached to the header field.
* The label for the header field.
* The options for a drop-down filter.
* The name of the form field.
* The group of the field.
* The value of the filter.
* The intended table data width (in pixels or percent).
* The key of the filter value in the model state.
* Is this a sortable column?
* Method to instantiate the form field object.
* @param FOFForm $form The form to attach to the form field object.
// If there is a form passed into the constructor set the form and form control properties.
* 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)
* Method to attach a JForm object to the field.
* @param FOFForm $form The JForm object to attach to the form field.
* @return FOFFormHeader The form field object so that the method can be used in a chain.
public function setForm(FOFForm $form)
* Method to attach a FOFForm object to the field.
* @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @return boolean True on success.
public function setup(SimpleXMLElement $element, $value, $group =
null)
// Make sure there is a valid JFormField XML element.
if ((string)
$element->getName() !=
'header')
// Reset the internal fields
// Set the XML element object.
// Get some important attributes from the form field element.
$class = (string)
$element['class'];
$id = (string)
$element['id'];
$name = (string)
$element['name'];
$filterSource = (string)
$element['filter_source'];
$tdwidth = (string)
$element['tdwidth'];
// Set the field description text.
// Set the group of the field.
// Set the td width of the field.
// Set the field name and id.
// Set the field default value.
* Method to get the id used for the field input tag.
* @param string $fieldId The field element id.
* @param string $fieldName The field element name.
* @return string The id to be used for the field input tag.
protected function getId($fieldId, $fieldName)
// If the field is in a group add the group control to the field id.
// If we already have an id segment add the group control as another level.
// If we already have an id segment add the field id/name as another level.
$id .=
'_' .
($fieldId ?
$fieldId :
$fieldName);
$id .=
($fieldId ?
$fieldId :
$fieldName);
// Clean up any invalid characters.
* Method to get the name used for the field input tag.
* @param string $fieldName The field element name.
* @return string The name to be used for the field input tag.
protected function getName($fieldName)
// If the field is in a group add the group control to the field name.
// If we already have a name segment add the group control as another level.
foreach ($groups as $group)
$name .=
'[' .
$group .
']';
foreach ($groups as $group)
$name .=
'[' .
$group .
']';
// If we already have a name segment add the field name as another level.
$name .=
'[' .
$fieldName .
']';
* Method to get the field name used.
* @param string $fieldName The field element name.
* @return string The field name
* Method to get the field label.
* @return string The field label.
// Get the label text from the XML element, defaulting to the element name.
$title =
$this->element['label'] ? (string)
$this->element['label'] :
'';
$params =
$view->getViewOptionAndName();
$title =
$params['option'] .
'_' .
* Get the filter value for this header field
* @return mixed The filter value
* Return the key of the filter value in the model state or, if it's not set,
* @param string $filterSource The filter source value to return
* Is this a sortable field?
* @return boolean True if it's sortable
$sortable =
($this->element['sortable'] !=
'false');
$sortable =
!empty($this->header);
* Returns the HTML for the header row, or null if this element should
* render no header element
* @return string|null HTML code or null if nothing is to be rendered
* Returns the HTML for a text filter to be rendered in the filter row,
* or null if this element should render no text input filter.
* @return string|null HTML code or null if nothing is to be rendered
* Returns the HTML for the buttons to be rendered in the filter row,
* next to the text input filter, or null if this element should render no
* text input filter buttons.
* @return string|null HTML code or null if nothing is to be rendered
* Returns the JHtml options for a drop-down filter. Do not include an
* empty option, it is added automatically.
* @return array The JHtml options for a drop-down filter
Documentation generated on Tue, 19 Nov 2013 15:04:14 +0100 by phpDocumentor 1.4.3