Source for file tag.php
Documentation is available at tag.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Form Field class for the Joomla Framework.
* @package Joomla.Libraries
* A flexible tag list that respects access controls
* Flag to work with nested tag field
* Method to get the field input for a tag field.
* @return string The field input.
// AJAX mode requires ajax-chosen
// Load the ajax-chosen customised field
if (empty($this->value->tags))
// String in format 2,5,4
* Method to get a list of tags
* @return array The field option objects.
$published =
$this->element['published']?
$this->element['published'] :
array(0,1);
$query =
$db->getQuery(true)
->select('a.id AS value, a.path, a.title AS text, a.level, a.published')
->join('LEFT', $db->quoteName('#__tags') .
' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
// Ajax tag only loads assigned values
// Only item assigned values
$values = (array)
$this->value;
$query->where('a.id IN (' .
implode(',', $values) .
')');
// Block the possibility to set a tag as it own parent
$id = (int)
$this->form->getValue('id', 0);
$name = (int)
$this->form->getValue('name', '');
if ($name ==
'com_tags.tag')
$query->where('a.id != ' .
$db->quote($id));
if (!empty($this->element['language']))
$query->where('a.language = ' .
$db->quote($this->element['language']));
$query->where($db->quoteName('a.alias') .
' <> ' .
$db->quote('root'));
// Filter on the published state
$query->where('a.published = ' . (int)
$published);
$query->where('a.published IN (' .
implode(',', $published) .
')');
$query->group('a.id, a.title, a.level, a.lft, a.rgt, a.parent_id, a.published, a.path')
$options =
$db->loadObjectList();
catch
(RuntimeException $e)
// Merge any additional options in the XML definition.
* Add "-" before nested tags, depending on level
* @param array &$options Array of tags
* @return array The field option objects.
foreach ($options as &$option)
$repeat =
(isset
($option->level) &&
$option->level -
1 >=
0) ?
$option->level -
1 :
0;
$option->text =
str_repeat('- ', $repeat) .
$option->text;
* Determine if the field has to be tagnested
// If mode="nested" || ( mode not set & config = nested )
if ((isset
($this->element['mode']) &&
$this->element['mode'] ==
'nested')
||
(!isset
($this->element['mode']) &&
$this->comParams->get('tag_field_ajax_mode', 1) ==
0))
* Determines if the field allows or denies custom values
if (isset
($this->element['custom']) &&
$this->element['custom'] ==
'deny')
Documentation generated on Tue, 19 Nov 2013 15:15:07 +0100 by phpDocumentor 1.4.3