[ Index ]

PHP Cross Reference of phpBB-3.3.3-deutsch

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4  * @package   s9e\TextFormatter
   5  * @copyright Copyright (c) 2010-2020 The s9e authors
   6  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
   7  */
   8  namespace s9e\TextFormatter\Plugins\Emoji;
   9  
  10  use s9e\TextFormatter\Plugins\ParserBase;
  11  
  12  class Parser extends ParserBase
  13  {
  14      /**
  15      * @var string Regexp used to match shortnames
  16      */
  17      protected $shortnameRegexp = '/:[-+_a-z0-9]+(?=:)/';
  18  
  19      /**
  20      * @var string Regexp used to match UTF-8 emoji
  21      */
  22      protected $unicodeRegexp = '((?:[#*0-9]\\xEF\\xB8\\x8F(?:\\xE2\\x83\\xA3)?|\\xC2[\\xA9\\xAE]\\xEF\\xB8\\x8F|\\xE2(?:\\x80\\xBC\\xEF\\xB8\\x8F|\\x81\\x89\\xEF\\xB8\\x8F|\\x84[\\xA2\\xB9]\\xEF\\xB8\\x8F|\\x86[\\x94-\\x99\\xA9\\xAA]\\xEF\\xB8\\x8F|\\x8C(?:[\\x9A\\x9B]|\\xA8\\xEF\\xB8\\x8F)|\\x8F(?:[\\x8F\\xAD-\\xAF\\xB1\\xB2\\xB8-\\xBA]\\xEF\\xB8\\x8F|[\\xA9-\\xAC\\xB0\\xB3])|\\x93\\x82\\xEF\\xB8\\x8F|\\x96[\\xAA\\xAB\\xB6]\\xEF\\xB8\\x8F|\\x97(?:[\\x80\\xBB\\xBC]\\xEF\\xB8\\x8F|[\\xBD\\xBE])|\\x98(?:[\\x80-\\x84\\x8E\\x91\\x98\\xA0\\xA2\\xA3\\xA6\\xAA\\xAE\\xAF\\xB8-\\xBA]\\xEF\\xB8\\x8F|[\\x94\\x95]|\\x9D(?:\\xEF\\xB8\\x8F|\\xF0\\x9F\\x8F[\\xBB-\\xBF]))|\\x99(?:[\\x80\\x82\\x9F\\xA0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:\\x8C\\xBE|\\x8D[\\xB3\\xBC]|\\x8E[\\x84\\x93\\xA4\\xA8]|\\x8F[\\xAB\\xAD]|\\x92[\\xBB\\xBC]|\\x94[\\xA7\\xAC]|\\x9A[\\x80\\x92]|\\xA4\\x9D\\xE2\\x80\\x8D\\xF0\\x9F\\xA7\\x91\\xF0\\x9F\\x8F[\\xBB-\\xBF]|\\xA6[\\xAF-\\xB3\\xBC\\xBD])))?))?)|\\xA9[\\xB0-\\xB4\\xB8-\\xBA]|\\xAA[\\x80-\\x86\\x90-\\xA8\\xB0-\\xB6]|\\xAB[\\x80-\\x82\\x90-\\x96]))(?!\\xEF\\xB8\\x8E)(?:\\xEF\\xB8\\x8F)?)S';
  23  
  24      /**
  25      * {@inheritdoc}
  26      */
  27  	public function parse($text, array $matches)
  28      {
  29          $this->parseShortnames($text);
  30          $this->parseCustomAliases($text);
  31          $this->parseUnicode($text);
  32      }
  33  
  34      /**
  35      * Add an emoji tag for given sequence
  36      *
  37      * @param  integer $tagPos Position of the tag in the original text
  38      * @param  integer $tagLen Length of text consumed by the tag
  39      * @param  string  $hex    Full-qualified sequence of codepoints in hex
  40      * @return void
  41      */
  42  	protected function addTag($tagPos, $tagLen, $hex)
  43      {
  44          $tag = $this->parser->addSelfClosingTag($this->config['tagName'], $tagPos, $tagLen, 10);
  45  
  46          // Short sequence, only the relevant codepoints are kept
  47          $seq = str_replace(['-200d', '-fe0f'], '', $hex);
  48          $tag->setAttribute('seq', $seq);
  49  
  50          // Twemoji sequence, leading zeroes are removed and VS-16 are removed from non-ZWJ sequences
  51          $tseq = ltrim($hex, '0');
  52          if (strpos($tseq, '-200d') === false)
  53          {
  54              $tseq = str_replace('-fe0f', '', $tseq);
  55          }
  56          $tag->setAttribute('tseq', $tseq);
  57      }
  58  
  59      /**
  60      * Get the sequence of Unicode codepoints that corresponds to given emoji
  61      *
  62      * @param  string $str UTF-8 emoji
  63      * @return string      Codepoint sequence, e.g. "0023-20e3"
  64      */
  65  	protected function getHexSequence($str)
  66      {
  67          $seq = [];
  68          $i   = 0;
  69          do
  70          {
  71              $cp = ord($str[$i]);
  72              if ($cp >= 0xF0)
  73              {
  74                  $cp = ($cp << 18) + (ord($str[++$i]) << 12) + (ord($str[++$i]) << 6) + ord($str[++$i]) - 0x3C82080;
  75              }
  76              elseif ($cp >= 0xE0)
  77              {
  78                  $cp = ($cp << 12) + (ord($str[++$i]) << 6) + ord($str[++$i]) - 0xE2080;
  79              }
  80              elseif ($cp >= 0xC0)
  81              {
  82                  $cp = ($cp << 6) + ord($str[++$i]) - 0x3080;
  83              }
  84              $seq[] = sprintf('%04x', $cp);
  85          }
  86          while (++$i < strlen($str));
  87  
  88          return implode('-', $seq);
  89      }
  90  
  91      /**
  92      * Parse custom aliases in given text
  93      *
  94      * @param  string $text Original text
  95      * @return void
  96      */
  97  	protected function parseCustomAliases($text)
  98      {
  99          if (empty($this->config['customRegexp']))
 100          {
 101              return;
 102          }
 103  
 104          $matchPos = 0;
 105          if (isset($this->config['customQuickMatch']))
 106          {
 107              $matchPos = strpos($text, $this->config['customQuickMatch']);
 108              if ($matchPos === false)
 109              {
 110                  return;
 111              }
 112          }
 113  
 114          preg_match_all($this->config['customRegexp'], $text, $matches, PREG_OFFSET_CAPTURE, $matchPos);
 115          foreach ($matches[0] as list($alias, $tagPos))
 116          {
 117              if (isset($this->parser->registeredVars['Emoji.aliases'][$alias]))
 118              {
 119                  $hex = $this->getHexSequence($this->parser->registeredVars['Emoji.aliases'][$alias]);
 120                  $this->addTag($tagPos, strlen($alias), $hex);
 121              }
 122          }
 123      }
 124  
 125      /**
 126      * Parse shortnames in given text
 127      *
 128      * @param  string $text Original text
 129      * @return void
 130      */
 131  	protected function parseShortnames($text)
 132      {
 133          $matchPos = strpos($text, ':');
 134          if ($matchPos === false)
 135          {
 136              return;
 137          }
 138          preg_match_all($this->shortnameRegexp, $text, $matches, PREG_OFFSET_CAPTURE, $matchPos);
 139          foreach ($matches[0] as list($alias, $tagPos))
 140          {
 141              $alias .= ':';
 142              $tagLen = strlen($alias);
 143              if (isset($this->parser->registeredVars['Emoji.aliases'][$alias]))
 144              {
 145                  $hex = $this->getHexSequence($this->parser->registeredVars['Emoji.aliases'][$alias]);
 146                  $this->addTag($tagPos, $tagLen, $hex);
 147              }
 148              elseif (preg_match('/^:[0-3][0-9a-f]{3,4}(?:-[0-9a-f]{4,5})*:$/', $alias))
 149              {
 150                  $this->addTag($tagPos, $tagLen, substr($alias, 1, -1));
 151              }
 152          }
 153      }
 154  
 155      /**
 156      * Parse Unicode emoji in given text
 157      *
 158      * @param  string $text Original text
 159      * @return void
 160      */
 161  	protected function parseUnicode($text)
 162      {
 163          if (strpos($text, "\xE2") === false && strpos($text, "\xEF") === false && strpos($text, "\xF0") === false)
 164          {
 165              return;
 166          }
 167          preg_match_all($this->unicodeRegexp, $text, $matches, PREG_OFFSET_CAPTURE);
 168          foreach ($matches[0] as list($emoji, $tagPos))
 169          {
 170              $this->addTag($tagPos, strlen($emoji), $this->getHexSequence($emoji));
 171          }
 172      }
 173  }


Generated: Sun Feb 14 20:08:31 2021 Cross-referenced by PHPXref 0.7.1