Textpattern PHP Cross Reference Content Management Systems

Source: /textpattern/vendors/Textpattern/Validator/CategoryConstraint.php - 58 lines - 1604 bytes - Summary - Text - Print

Description: Tests against existing or blank category names.

   1  <?php
   2  
   3  /*
   4   * Textpattern Content Management System
   5   * https://textpattern.com/
   6   *
   7   * Copyright (C) 2020 The Textpattern Development Team
   8   *
   9   * This file is part of Textpattern.
  10   *
  11   * Textpattern is free software; you can redistribute it and/or
  12   * modify it under the terms of the GNU General Public License
  13   * as published by the Free Software Foundation, version 2.
  14   *
  15   * Textpattern is distributed in the hope that it will be useful,
  16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18   * GNU General Public License for more details.
  19   *
  20   * You should have received a copy of the GNU General Public License
  21   * along with Textpattern. If not, see <https://www.gnu.org/licenses/>.
  22   */
  23  
  24  /**
  25   * Tests against existing or blank category names.
  26   *
  27   * @since   4.6.0
  28   * @package Validator
  29   */
  30  
  31  namespace Textpattern\Validator;
  32  
  33  class CategoryConstraint extends ChoiceConstraint
  34  {
  35      /**
  36       * Constructor.
  37       *
  38       * @param mixed $value
  39       * @param array $options
  40       */
  41  
  42      public function __construct($value, $options = array())
  43      {
  44          static $choices = null;
  45          $options = lAtts(array(
  46              'allow_blank' => true,
  47              'type'        => '',
  48              'message'     => 'unknown_category',
  49          ), $options, false);
  50  
  51          if (null === $choices) {
  52              $choices = safe_column('name', 'txp_category', $options['type'] !== '' ? 'type=\''.doSlash($options['type']).'\'' : '1=1');
  53          }
  54  
  55          $options['choices'] = $choices;
  56          parent::__construct($value, $options);
  57      }
  58  }

title

Description

title

Description

title

Description

title

title

Body