[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Plugins/Litedown/Parser/ -> LinkAttributesSetter.php (source)

   1  <?php
   2  
   3  /**
   4  * @package   s9e\TextFormatter
   5  * @copyright Copyright (c) 2010-2022 The s9e authors
   6  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
   7  */
   8  namespace s9e\TextFormatter\Plugins\Litedown\Parser;
   9  
  10  use s9e\TextFormatter\Parser\Tag;
  11  
  12  trait LinkAttributesSetter
  13  {
  14      /**
  15      * Set a URL or IMG tag's attributes
  16      *
  17      * @param  Tag    $tag      URL or IMG tag
  18      * @param  string $linkInfo Link's info: an URL optionally followed by spaces and a title
  19      * @param  string $attrName Name of the URL attribute
  20      * @return void
  21      */
  22  	protected function setLinkAttributes(Tag $tag, $linkInfo, $attrName)
  23      {
  24          $url   = trim($linkInfo);
  25          $title = '';
  26          $pos   = strpos($url, ' ');
  27          if ($pos !== false)
  28          {
  29              $title = substr(trim(substr($url, $pos)), 1, -1);
  30              $url   = substr($url, 0, $pos);
  31          }
  32          if (preg_match('/^<.+>$/', $url))
  33          {
  34              $url = str_replace('\\>', '>', substr($url, 1, -1));
  35          }
  36  
  37          $tag->setAttribute($attrName, $this->text->decode($url));
  38          if ($title > '')
  39          {
  40              $tag->setAttribute('title', $this->text->decode($title));
  41          }
  42      }
  43  }


Generated: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1