- md5
- c152a16c3daf4432f7db88942e0a3b94
- sha1
- e2e43f7161c943772dd453f60f1e91868eb27353
- sha256
- 5643e7a728c14be4439ab7230d46bbce09bf88e1021e6adca43e415c0585bfe7
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
<?php
/**
* @package Joomla.Plugin
* @subpackage System.privacyconsent
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\System\PrivacyConsent\Field;
\defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\RadioField;
use Joomla\CMS\Language\Text;
use Joomla\Component\Content\Site\Helper\RouteHelper;
use Joomla\Database\ParameterType;
/**
* Provides input for privacy
*
* @since 3.9.0
*/
class PrivacyField extends RadioField
{
/**
* The form field type.
*
* @var string
* @since 3.9.0
*/
protected $type = 'privacy';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.9.0
*/
protected function getInput()
{
// Display the message before the field
echo $this->getRenderer('plugins.system.privacyconsent.message')->render($this->getLayoutData());
return parent::getInput();
}
/**
* Method to get the field label markup.
*
* @return string The field label markup.
*
* @since 3.9.0
*/
protected function getLabel()
{
if ($this->hidden)
{
return '';
}
return $this->getRenderer('plugins.system.privacyconsent.label')->render($this->getLayoutData());
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.9.4
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
$article = false;
$privacyArticle = $this->element['article'] > 0 ? (int) $this->element['article'] : 0;
if ($privacyArticle && Factory::getApplication()->isClient('site'))
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName(['id', 'alias', 'catid', 'language']))
->from($db->quoteName('#__content'))
->where($db->quoteName('id') . ' = :id')
->bind(':id', $privacyArticle, ParameterType::INTEGER);
$db->setQuery($query);
$article = $db->loadObject();
$slug = $article->alias ? ($article->id . ':' . $article->alias) : $article->id;
$article->link = RouteHelper::getArticleRoute($slug, $article->catid, $article->language);
}
$extraData = [
'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);
}
}
The same content is in 4 releases, Joomla 4.0.0-beta to 4.0.0-beta4. See them all, or every version of this file.