Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JFormFieldComponentlayout
+ Graphe d'héritage de JFormFieldComponentlayout:
+ Graphe de collaboration de JFormFieldComponentlayout:

Liste de tous les membres

Fonctions membres protégées

 getInput ()
- Fonctions membres protégées inherited from JFormField
 getId ($fieldId, $fieldName)
 getTitle ()
 getLabel ()
 getName ($fieldName)
 getFieldName ($fieldName)

Attributs protégés

 $type = 'ComponentLayout'
- Attributs protégés inherited from JFormField
 $description
 $hint
 $autocomplete = 'on'
 $spellcheck = true
 $autofocus = false
 $element
 $form
 $formControl
 $hidden = false
 $translateLabel = true
 $translateDescription = true
 $translateHint = true
 $id
 $input
 $label
 $multiple = false
 $pattern
 $name
 $fieldname
 $group
 $required = false
 $disabled = false
 $readonly = false
 $validate
 $value
 $default
 $size
 $class
 $labelClass
 $onchange
 $onclick

Additional Inherited Members

- Fonctions membres publiques inherited from JFormField
 __construct ($form=null)
 __get ($name)
 __set ($name, $value)
 setForm (JForm $form)
 setup (SimpleXMLElement $element, $value, $group=null)
 setValue ($value)
 getAttribute ($name, $default=null)
 getControlGroup ()
- Attributs publics inherited from JFormField
 $repeat = false
- Attributs protégés statiques inherited from JFormField
static $count = 0
static $generated_fieldname = '__field'

Description détaillée

Définition à la ligne 22 du fichier componentlayout.php.


Documentation des fonctions membres

JFormFieldComponentlayout::getInput ( )
protected

Method to get the field input for a component layout field.

Renvoie:
string The field input.
Depuis:
11.1

Réimplémentée à partir de JFormField.

Définition à la ligne 39 du fichier componentlayout.php.

Références JText\_(), JPath\clean(), JFolder\files(), JFactory\getDbo(), JFactory\getLanguage(), et JText\sprintf().

{
// Get the client id.
$clientId = $this->element['client_id'];
if (is_null($clientId) && $this->form instanceof JForm)
{
$clientId = $this->form->getValue('client_id');
}
$clientId = (int) $clientId;
$client = JApplicationHelper::getClientInfo($clientId);
// Get the extension.
$extn = (string) $this->element['extension'];
if (empty($extn) && ($this->form instanceof JForm))
{
$extn = $this->form->getValue('extension');
}
$extn = preg_replace('#\W#', '', $extn);
// Get the template.
$template = (string) $this->element['template'];
$template = preg_replace('#\W#', '', $template);
// Get the style.
if ($this->form instanceof JForm)
{
$template_style_id = $this->form->getValue('template_style_id');
}
$template_style_id = preg_replace('#\W#', '', $template_style_id);
// Get the view.
$view = (string) $this->element['view'];
$view = preg_replace('#\W#', '', $view);
// If a template, extension and view are present build the options.
if ($extn && $view && $client)
{
// Load language file
$lang->load($extn . '.sys', JPATH_ADMINISTRATOR, null, false, false)
|| $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, null, false, false)
|| $lang->load($extn . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|| $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, $lang->getDefault(), false, false);
// Get the database object and a new query object.
$query = $db->getQuery(true);
// Build the query.
$query->select('e.element, e.name')
->from('#__extensions as e')
->where('e.client_id = ' . (int) $clientId)
->where('e.type = ' . $db->quote('template'))
->where('e.enabled = 1');
if ($template)
{
$query->where('e.element = ' . $db->quote($template));
}
if ($template_style_id)
{
$query->join('LEFT', '#__template_styles as s on s.template=e.element')
->where('s.id=' . (int) $template_style_id);
}
// Set the query and load the templates.
$db->setQuery($query);
$templates = $db->loadObjectList('element');
// Build the search paths for component layouts.
$component_path = JPath::clean($client->path . '/components/' . $extn . '/views/' . $view . '/tmpl');
// Prepare array of component layouts
$component_layouts = array();
// Prepare the grouped list
$groups = array();
// Add a Use Global option if useglobal="true" in XML file
if ($this->element['useglobal'] == 'true')
{
$groups[JText::_('JOPTION_FROM_STANDARD')]['items'][] = JHtml::_('select.option', '', JText::_('JGLOBAL_USE_GLOBAL'));
}
// Add the layout options from the component path.
if (is_dir($component_path) && ($component_layouts = JFolder::files($component_path, '^[^_]*\.xml$', false, true)))
{
// Create the group for the component
$groups['_'] = array();
$groups['_']['id'] = $this->id . '__';
$groups['_']['text'] = JText::sprintf('JOPTION_FROM_COMPONENT');
$groups['_']['items'] = array();
foreach ($component_layouts as $i => $file)
{
// Attempt to load the XML file.
if (!$xml = simplexml_load_file($file))
{
unset($component_layouts[$i]);
continue;
}
// Get the help data from the XML file if present.
if (!$menu = $xml->xpath('layout[1]'))
{
unset($component_layouts[$i]);
continue;
}
$menu = $menu[0];
// Add an option to the component group
$value = basename($file, '.xml');
$component_layouts[$i] = $value;
$text = isset($menu['option']) ? JText::_($menu['option']) : (isset($menu['title']) ? JText::_($menu['title']) : $value);
$groups['_']['items'][] = JHtml::_('select.option', '_:' . $value, $text);
}
}
// Loop on all templates
if ($templates)
{
foreach ($templates as $template)
{
// Load language file
$lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, false)
|| $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, false)
|| $lang->load('tpl_' . $template->element . '.sys', $client->path, $lang->getDefault(), false, false)
|| $lang->load(
'tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, $lang->getDefault(), false, false
);
$template_path = JPath::clean($client->path . '/templates/' . $template->element . '/html/' . $extn . '/' . $view);
// Add the layout options from the template path.
if (is_dir($template_path) && ($files = JFolder::files($template_path, '^[^_]*\.php$', false, true)))
{
// Files with corresponding XML files are alternate menu items, not alternate layout files
// so we need to exclude these files from the list.
$xml_files = JFolder::files($template_path, '^[^_]*\.xml$', false, true);
for ($j = 0, $count = count($xml_files); $j < $count; $j++)
{
$xml_files[$j] = basename($xml_files[$j], '.xml');
}
foreach ($files as $i => $file)
{
// Remove layout files that exist in the component folder or that have XML files
if ((in_array(basename($file, '.php'), $component_layouts))
|| (in_array(basename($file, '.php'), $xml_files)))
{
unset($files[$i]);
}
}
if (count($files))
{
// Create the group for the template
$groups[$template->name] = array();
$groups[$template->name]['id'] = $this->id . '_' . $template->element;
$groups[$template->name]['text'] = JText::sprintf('JOPTION_FROM_TEMPLATE', $template->name);
$groups[$template->name]['items'] = array();
foreach ($files as $file)
{
// Add an option to the template group
$value = basename($file, '.php');
$text = $lang
->hasKey($key = strtoupper('TPL_' . $template->name . '_' . $extn . '_' . $view . '_LAYOUT_' . $value))
? JText::_($key) : $value;
$groups[$template->name]['items'][] = JHtml::_('select.option', $template->element . ':' . $value, $text);
}
}
}
}
}
// Compute attributes for the grouped list
$attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
// Prepare HTML code
$html = array();
// Compute the current selected values
$selected = array($this->value);
// Add a grouped list
$html[] = JHtml::_(
'select.groupedlist', $groups, $this->name,
array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected)
);
return implode($html);
}
else
{
return '';
}
}

+ Voici le graphe d'appel pour cette fonction :


Documentation des données membres

JFormFieldComponentlayout::$type = 'ComponentLayout'
protected

Réimplémentée à partir de JFormField.

Définition à la ligne 30 du fichier componentlayout.php.


La documentation de cette classe a été générée à partir du fichier suivant :