privacy.php
2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* @package Joomla.Plugin
* @subpackage System.privacyconsent
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
JFormHelper::loadFieldClass('radio');
/**
* Provides input for privacy
*
* @since 3.9.0
*/
class JFormFieldprivacy extends JFormFieldRadio
{
/**
* 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(array('id', 'alias', 'catid', 'language')))
->from($db->quoteName('#__content'))
->where($db->quoteName('id') . ' = ' . (int) $privacyArticle);
$db->setQuery($query);
$article = $db->loadObject();
JLoader::register('ContentHelperRoute', JPATH_BASE . '/components/com_content/helpers/route.php');
$slug = $article->alias ? ($article->id . ':' . $article->alias) : $article->id;
$article->link = ContentHelperRoute::getArticleRoute($slug, $article->catid, $article->language);
}
$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);
}
}