[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/layouts/joomla/form/field/ -> password.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  Layout
   6   *
   7   * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Language\Text;
  15  
  16  extract($displayData);
  17  
  18  /**
  19   * Layout variables
  20   * -----------------
  21   * @var   string   $autocomplete    Autocomplete attribute for the field.
  22   * @var   boolean  $autofocus       Is autofocus enabled?
  23   * @var   string   $class           Classes for the input.
  24   * @var   string   $description     Description of the field.
  25   * @var   boolean  $disabled        Is this field disabled?
  26   * @var   string   $group           Group the field belongs to. <fields> section in form XML.
  27   * @var   boolean  $hidden          Is this field hidden in the form?
  28   * @var   string   $hint            Placeholder for the field.
  29   * @var   string   $id              DOM id of the field.
  30   * @var   string   $label           Label of the field.
  31   * @var   string   $labelclass      Classes to apply to the label.
  32   * @var   boolean  $multiple        Does this field support multiple values?
  33   * @var   string   $name            Name of the input field.
  34   * @var   string   $onchange        Onchange attribute for the field.
  35   * @var   string   $onclick         Onclick attribute for the field.
  36   * @var   string   $pattern         Pattern (Reg Ex) of value of the form field.
  37   * @var   boolean  $readonly        Is this field read only?
  38   * @var   boolean  $repeat          Allows extensions to duplicate elements.
  39   * @var   boolean  $required        Is this field required?
  40   * @var   boolean  $rules           Are the rules to be displayed?
  41   * @var   integer  $size            Size attribute of the input.
  42   * @var   boolean  $spellcheck      Spellcheck state for the form field.
  43   * @var   string   $validate        Validation rules to apply.
  44   * @var   string   $value           Value attribute of the field.
  45   * @var   array    $checkedOptions  Options that will be set as checked.
  46   * @var   boolean  $hasValue        Has this field a value assigned?
  47   * @var   array    $options         Options available for this field.
  48   * @var   array    $inputType       Options available for this field.
  49   * @var   string   $accept          File types that are accepted.
  50   * @var   string   $dataAttribute   Miscellaneous data attributes preprocessed for HTML output
  51   * @var   array    $dataAttributes  Miscellaneous data attribute for eg, data-*.
  52   * @var   boolean  $lock            Is this field locked.
  53   */
  54  
  55  $document = Factory::getApplication()->getDocument();
  56  
  57  /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
  58  $wa = $document->getWebAssetManager();
  59  
  60  if ($meter) {
  61      $wa->useScript('field.passwordstrength');
  62  
  63      $class = 'js-password-strength ' . $class;
  64  
  65      if ($forcePassword) {
  66          $class = $class . ' meteredPassword';
  67      }
  68  }
  69  
  70  $wa->useScript('field.passwordview');
  71  
  72  Text::script('JFIELD_PASSWORD_INDICATE_INCOMPLETE');
  73  Text::script('JFIELD_PASSWORD_INDICATE_COMPLETE');
  74  Text::script('JSHOWPASSWORD');
  75  Text::script('JHIDEPASSWORD');
  76  
  77  if ($lock) {
  78      Text::script('JMODIFY');
  79      Text::script('JCANCEL');
  80  
  81      $disabled = true;
  82      $hint = str_repeat('•', 10);
  83      $value = '';
  84  }
  85  
  86  $ariaDescribedBy = $rules ? $name . '-rules ' : '';
  87  $ariaDescribedBy .= !empty($description) ? (($id ?: $name) . '-desc') : '';
  88  
  89  $attributes = array(
  90      strlen($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : '',
  91      !empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : '',
  92      !empty($class) ? 'class="form-control ' . $class . '"' : 'class="form-control"',
  93      !empty($ariaDescribedBy) ? 'aria-describedby="' . trim($ariaDescribedBy) . '"' : '',
  94      $readonly ? 'readonly' : '',
  95      $disabled ? 'disabled' : '',
  96      !empty($size) ? 'size="' . $size . '"' : '',
  97      !empty($maxLength) ? 'maxlength="' . $maxLength . '"' : '',
  98      $required ? 'required' : '',
  99      $autofocus ? 'autofocus' : '',
 100      !empty($minLength) ? 'data-min-length="' . $minLength . '"' : '',
 101      !empty($minIntegers) ? 'data-min-integers="' . $minIntegers . '"' : '',
 102      !empty($minSymbols) ? 'data-min-symbols="' . $minSymbols . '"' : '',
 103      !empty($minUppercase) ? 'data-min-uppercase="' . $minUppercase . '"' : '',
 104      !empty($minLowercase) ? 'data-min-lowercase="' . $minLowercase . '"' : '',
 105      !empty($forcePassword) ? 'data-min-force="' . $forcePassword . '"' : '',
 106      $dataAttribute,
 107  );
 108  
 109  if ($rules) {
 110      $requirements = [];
 111  
 112      if ($minLength) {
 113          $requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_CHARACTERS', $minLength);
 114      }
 115  
 116      if ($minIntegers) {
 117          $requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_DIGITS', $minIntegers);
 118      }
 119  
 120      if ($minSymbols) {
 121          $requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_SYMBOLS', $minSymbols);
 122      }
 123  
 124      if ($minUppercase) {
 125          $requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_UPPERCASE', $minUppercase);
 126      }
 127  
 128      if ($minLowercase) {
 129          $requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_LOWERCASE', $minLowercase);
 130      }
 131  }
 132  ?>
 133  <?php if ($rules) : ?>
 134      <div id="<?php echo $name . '-rules'; ?>" class="small text-muted">
 135          <?php echo Text::sprintf('JFIELD_PASSWORD_RULES_MINIMUM_REQUIREMENTS', implode(', ', $requirements)); ?>
 136      </div>
 137  <?php endif; ?>
 138  
 139  <div class="password-group">
 140      <div class="input-group">
 141          <input
 142              type="password"
 143              name="<?php echo $name; ?>"
 144              id="<?php echo $id; ?>"
 145              value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>"
 146              <?php echo implode(' ', $attributes); ?>>
 147          <?php if (!$lock) : ?>
 148          <button type="button" class="btn btn-secondary input-password-toggle">
 149              <span class="icon-eye icon-fw" aria-hidden="true"></span>
 150              <span class="visually-hidden"><?php echo Text::_('JSHOWPASSWORD'); ?></span>
 151          </button>
 152          <?php else : ?>
 153              <button type="button" id="<?php echo $id; ?>_lock" class="btn btn-info input-password-modify locked">
 154                  <?php echo Text::_('JMODIFY'); ?>
 155              </button>
 156          <?php endif; ?>
 157      </div>
 158  </div>


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