Textpattern PHP Cross Reference Content Management Systems

Source: /textpattern/vendors/Textpattern/Textfilter/Base.php - 156 lines - 3448 bytes - Summary - Text - Print

Description: Textfilter base class.

   1  <?php
   2  
   3  /*
   4   * Textpattern Content Management System
   5   * http://textpattern.com
   6   *
   7   * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
  22   */
  23  
  24  /**
  25   * Textfilter base class.
  26   *
  27   * @since   4.6.0
  28   * @package Textfilter
  29   */
  30  
  31  namespace Textpattern\Textfilter;
  32  
  33  class Base implements TextfilterInterface
  34  {
  35      /**
  36       * The filter's title.
  37       *
  38       * @var string
  39       */
  40  
  41      public $title;
  42  
  43      /**
  44       * The filter's version.
  45       *
  46       * @var string
  47       */
  48  
  49      public $version;
  50  
  51      /**
  52       * The filter's identifier.
  53       *
  54       * @var string
  55       */
  56  
  57      protected $key;
  58  
  59      /**
  60       * The filter's options.
  61       *
  62       * @var array
  63       */
  64  
  65      protected $options;
  66  
  67      /**
  68       * General constructor for Textfilters.
  69       *
  70       * @param string $key   A globally unique, persistable identifier for this particular Textfilter class
  71       * @param string $title The human-readable title of this filter class
  72       */
  73  
  74      public function __construct($key, $title)
  75      {
  76          global $txpversion;
  77  
  78          $this->key = $key;
  79          $this->title = $title;
  80          $this->version = $txpversion;
  81          $this->options = array(
  82              'lite'       => false,
  83              'restricted' => false,
  84              'rel'        => '',
  85              'noimage'    => false,
  86          );
  87  
  88          register_callback(array($this, 'register'), 'textfilter', 'register');
  89      }
  90  
  91      /**
  92       * Sets filter's options.
  93       *
  94       * @param array $options Array of options: 'lite' => boolean, 'rel' => string, 'noimage' => boolean, 'restricted' => boolean
  95       */
  96  
  97      private function setOptions($options)
  98      {
  99          $this->options = lAtts(array(
 100              'lite'       => false,
 101              'restricted' => false,
 102              'rel'        => '',
 103              'noimage'    => false,
 104          ), $options);
 105      }
 106  
 107      /**
 108       * Event handler, registers Textfilter class with the core.
 109       *
 110       * @param string                           $step     Not used
 111       * @param string                           $event    Not used
 112       * @param \Textpattern\Textfilter\Registry $registry Maintains the set of known Textfilters
 113       */
 114  
 115      public function register($step, $event, $registry)
 116      {
 117          $registry[] = $this;
 118      }
 119  
 120      /**
 121       * Filters the given raw input value.
 122       *
 123       * @param  string $thing   The raw input string
 124       * @param  array  $options Options
 125       * @return string Filtered output text
 126       */
 127  
 128      public function filter($thing, $options)
 129      {
 130          $this->setOptions($options);
 131  
 132          return $thing;
 133      }
 134  
 135      /**
 136       * Gets this filter's help.
 137       *
 138       * @return string
 139       */
 140  
 141      public function getHelp()
 142      {
 143          return '';
 144      }
 145  
 146      /**
 147       * Gets this filter's identifier.
 148       *
 149       * @return string
 150       */
 151  
 152      public function getKey()
 153      {
 154          return $this->key;
 155      }
 156  }

title

Description

title

Description

title

Description

title

title

Body