diff --git a/layouts/plugins/system/privacyconsent/label.php b/layouts/plugins/system/privacyconsent/label.php new file mode 100644 index 0000000000000..5f57123c65a3c --- /dev/null +++ b/layouts/plugins/system/privacyconsent/label.php @@ -0,0 +1,102 @@ + section in form XML. + * @var boolean $hidden Is this field hidden in the form? + * @var string $hint Placeholder for the field. + * @var string $id DOM id of the field. + * @var string $label Label of the field. + * @var string $labelclass Classes to apply to the label. + * @var boolean $multiple Does this field support multiple values? + * @var string $name Name of the input field. + * @var string $onchange Onchange attribute for the field. + * @var string $onclick Onclick attribute for the field. + * @var string $pattern Pattern (Reg Ex) of value of the form field. + * @var boolean $readonly Is this field read only? + * @var boolean $repeat Allows extensions to duplicate elements. + * @var boolean $required Is this field required? + * @var integer $size Size attribute of the input. + * @var boolean $spellcheck Spellcheck state for the form field. + * @var string $validate Validation rules to apply. + * @var string $value Value attribute of the field. + * @var array $options Options available for this field. + * @var array $privacynote The privacy note that needs to be displayed + * @var array $translateLabel Should the label be translated? + * @var array $translateDescription Should the description be translated? + * @var array $translateHint Should the hint be translated? + * @var array $privacyArticle The Article ID holding the Privancy Article + * $var object $article The Article object + */ + +// Get the label text from the XML element, defaulting to the element name. +$text = $label ? (string) $label : (string) $name; +$text = $translateLabel ? Text::_($text) : $text; + +// Set required to true as this field is not displayed at all if not required. +$required = true; + +JHtml::_('behavior.modal'); + +// Build the class for the label. +$class = !empty($description) ? 'hasPopover' : ''; +$class = $class . ' required'; +$class = !empty($labelclass) ? $class . ' ' . $labelclass : $class; + +// Add the opening label tag and main attributes. +$label = ''; + +echo $label; diff --git a/layouts/plugins/system/privacyconsent/message.php b/layouts/plugins/system/privacyconsent/message.php new file mode 100644 index 0000000000000..24dcb7756f888 --- /dev/null +++ b/layouts/plugins/system/privacyconsent/message.php @@ -0,0 +1,49 @@ + section in form XML. + * @var boolean $hidden Is this field hidden in the form? + * @var string $hint Placeholder for the field. + * @var string $id DOM id of the field. + * @var string $label Label of the field. + * @var string $labelclass Classes to apply to the label. + * @var boolean $multiple Does this field support multiple values? + * @var string $name Name of the input field. + * @var string $onchange Onchange attribute for the field. + * @var string $onclick Onclick attribute for the field. + * @var string $pattern Pattern (Reg Ex) of value of the form field. + * @var boolean $readonly Is this field read only? + * @var boolean $repeat Allows extensions to duplicate elements. + * @var boolean $required Is this field required? + * @var integer $size Size attribute of the input. + * @var boolean $spellcheck Spellcheck state for the form field. + * @var string $validate Validation rules to apply. + * @var string $value Value attribute of the field. + * @var array $options Options available for this field. + * @var array $privacynote The privacy note that needs to be displayed + * @var array $translateLabel Should the label be translated? + * @var array $translateDescription Should the description be translated? + * @var array $translateHint Should the hint be translated? + * @var array $privacyArticle The Article ID holding the Privancy Article + */ + +echo '
' . $privacynote . '
'; + diff --git a/plugins/system/privacyconsent/field/privacy.php b/plugins/system/privacyconsent/field/privacy.php index ebca3cd25fb22..05e516ae70e21 100644 --- a/plugins/system/privacyconsent/field/privacy.php +++ b/plugins/system/privacyconsent/field/privacy.php @@ -38,9 +38,8 @@ class JFormFieldprivacy extends JFormFieldRadio */ protected function getInput() { - $privacynote = !empty($this->element['note']) ? $this->element['note'] : Text::_('PLG_SYSTEM_PRIVACYCONSENT_NOTE_FIELD_DEFAULT'); - - echo '
' . $privacynote . '
'; + // Display the message before the field + echo $this->getRenderer('plugins.system.privacyconsent.message')->render($this->getLayoutData()); return parent::getInput(); } @@ -59,49 +58,26 @@ protected function getLabel() return ''; } - // Get the label text from the XML element, defaulting to the element name. - $text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name']; - $text = $this->translateLabel ? Text::_($text) : $text; - - // Set required to true as this field is not displayed at all if not required. - $this->required = true; - - JHtml::_('behavior.modal'); + return $this->getRenderer('plugins.system.privacyconsent.label')->render($this->getLayoutData()); - // Build the class for the label. - $class = !empty($this->description) ? 'hasPopover' : ''; - $class = $class . ' required'; - $class = !empty($this->labelClass) ? $class . ' ' . $this->labelClass : $class; - - // Add the opening label tag and main attributes. - $label = ''; - return $label; + $extraData = array( + 'privacynote' => !empty($this->element['note']) ? $this->element['note'] : Text::_('PLG_SYSTEM_PRIVACYCONSENT_NOTE_FIELD_DEFAULT'), + 'options' => $this->getOptions(), + 'value' => (string) $this->value, + 'translateLabel' => $this->translateLabel, + 'translateDescription' => $this->translateDescription, + 'translateHint' => $this->translateHint, + 'privacyArticle' => $privacyArticle, + 'article' => $article, + ); + + return array_merge($data, $extraData); } }