[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Plugin 5 * @subpackage User.terms 6 * 7 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Plugin\User\Terms\Field; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Form\Field\RadioField; 15 use Joomla\CMS\Language\Associations; 16 use Joomla\CMS\Language\Text; 17 use Joomla\Component\Content\Site\Helper\RouteHelper; 18 use Joomla\Database\ParameterType; 19 20 // phpcs:disable PSR1.Files.SideEffects 21 \defined('JPATH_PLATFORM') or die; 22 // phpcs:enable PSR1.Files.SideEffects 23 24 /** 25 * Provides input for privacyterms 26 * 27 * @since 3.9.0 28 */ 29 class TermsField extends RadioField 30 { 31 /** 32 * The form field type. 33 * 34 * @var string 35 * @since 3.9.0 36 */ 37 protected $type = 'terms'; 38 39 /** 40 * Method to get the field input markup. 41 * 42 * @return string The field input markup. 43 * 44 * @since 3.9.0 45 */ 46 protected function getInput() 47 { 48 // Display the message before the field 49 echo $this->getRenderer('plugins.user.terms.message')->render($this->getLayoutData()); 50 51 return parent::getInput(); 52 } 53 54 /** 55 * Method to get the field label markup. 56 * 57 * @return string The field label markup. 58 * 59 * @since 3.9.0 60 */ 61 protected function getLabel() 62 { 63 if ($this->hidden) { 64 return ''; 65 } 66 67 return $this->getRenderer('plugins.user.terms.label')->render($this->getLayoutData()); 68 } 69 70 /** 71 * Method to get the data to be passed to the layout for rendering. 72 * 73 * @return array 74 * 75 * @since 3.9.4 76 */ 77 protected function getLayoutData() 78 { 79 $data = parent::getLayoutData(); 80 81 $article = false; 82 $termsArticle = $this->element['article'] > 0 ? (int) $this->element['article'] : 0; 83 84 if ($termsArticle && Factory::getApplication()->isClient('site')) { 85 $db = $this->getDatabase(); 86 $query = $db->getQuery(true) 87 ->select($db->quoteName(['id', 'alias', 'catid', 'language'])) 88 ->from($db->quoteName('#__content')) 89 ->where($db->quoteName('id') . ' = :id') 90 ->bind(':id', $termsArticle, ParameterType::INTEGER); 91 $db->setQuery($query); 92 $article = $db->loadObject(); 93 94 if (Associations::isEnabled()) { 95 $termsAssociated = Associations::getAssociations('com_content', '#__content', 'com_content.item', $termsArticle); 96 } 97 98 $currentLang = Factory::getLanguage()->getTag(); 99 100 if (isset($termsAssociated) && $currentLang !== $article->language && \array_key_exists($currentLang, $termsAssociated)) { 101 $article->link = RouteHelper::getArticleRoute( 102 $termsAssociated[$currentLang]->id, 103 $termsAssociated[$currentLang]->catid, 104 $termsAssociated[$currentLang]->language 105 ); 106 } else { 107 $slug = $article->alias ? ($article->id . ':' . $article->alias) : $article->id; 108 $article->link = RouteHelper::getArticleRoute($slug, $article->catid, $article->language); 109 } 110 } 111 112 $extraData = [ 113 'termsnote' => !empty($this->element['note']) ? $this->element['note'] : Text::_('PLG_USER_TERMS_NOTE_FIELD_DEFAULT'), 114 'options' => $this->getOptions(), 115 'value' => (string) $this->value, 116 'translateLabel' => $this->translateLabel, 117 'translateDescription' => $this->translateDescription, 118 'translateHint' => $this->translateHint, 119 'termsArticle' => $termsArticle, 120 'article' => $article, 121 ]; 122 123 return array_merge($data, $extraData); 124 } 125 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |