[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/content/confirmconsent/ -> confirmconsent.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  Content.confirmconsent
   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   * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
  11   */
  12  
  13  use Joomla\CMS\Form\Form;
  14  use Joomla\CMS\Language\Text;
  15  use Joomla\CMS\Plugin\CMSPlugin;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * The Joomla Core confirm consent plugin
  23   *
  24   * @since  3.9.0
  25   */
  26  class PlgContentConfirmConsent extends CMSPlugin
  27  {
  28      /**
  29       * @var    \Joomla\CMS\Application\SiteApplication
  30       *
  31       * @since  3.9.0
  32       */
  33      protected $app;
  34  
  35      /**
  36       * Load the language file on instantiation.
  37       *
  38       * @var    boolean
  39       *
  40       * @since  3.9.0
  41       */
  42      protected $autoloadLanguage = true;
  43  
  44      /**
  45       * The supported form contexts
  46       *
  47       * @var    array
  48       *
  49       * @since  3.9.0
  50       */
  51      protected $supportedContext = [
  52          'com_contact.contact',
  53          'com_privacy.request',
  54      ];
  55  
  56      /**
  57       * Add additional fields to the supported forms
  58       *
  59       * @param   Form   $form  The form to be altered.
  60       * @param   mixed  $data  The associated data for the form.
  61       *
  62       * @return  boolean
  63       *
  64       * @since   3.9.0
  65       */
  66      public function onContentPrepareForm(Form $form, $data)
  67      {
  68          if ($this->app->isClient('administrator') || !in_array($form->getName(), $this->supportedContext)) {
  69              return true;
  70          }
  71  
  72          // Get the consent box Text & the selected privacyarticle
  73          $consentboxText  = (string) $this->params->get('consentbox_text', Text::_('PLG_CONTENT_CONFIRMCONSENT_FIELD_NOTE_DEFAULT'));
  74          $privacyArticle  = $this->params->get('privacy_article', false);
  75          $privacyType     = $this->params->get('privacy_type', 'article');
  76          $privacyMenuItem = $this->params->get('privacy_menu_item', false);
  77  
  78          $form->load('
  79              <form>
  80                  <fieldset name="default" addfieldprefix="Joomla\\Plugin\\Content\\ConfirmConsent\\Field">
  81                      <field
  82                          name="consentbox"
  83                          type="ConsentBox"
  84                          articleid="' . $privacyArticle . '"
  85                          menu_item_id="' . $privacyMenuItem . '"
  86                          privacy_type="' . $privacyType . '"
  87                          label="PLG_CONTENT_CONFIRMCONSENT_CONSENTBOX_LABEL"
  88                          required="true"
  89                          >
  90                          <option value="0">' . htmlspecialchars($consentboxText, ENT_COMPAT, 'UTF-8') . '</option>
  91                      </field>
  92                  </fieldset>
  93              </form>');
  94  
  95          return true;
  96      }
  97  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer