[ Index ]

PHP Cross Reference of phpBB-3.3.7-deutsch

title

Body

[close]

/phpbb/textformatter/s9e/ -> quote_helper.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\textformatter\s9e;
  15  
  16  class quote_helper
  17  {
  18      /**
  19      * @var string Base URL for a post link, uses {POST_ID} as placeholder
  20      */
  21      protected $post_url;
  22  
  23      /**
  24      * @var string Base URL for a private message link, uses {MSG_ID} as placeholder
  25      */
  26      protected $msg_url;
  27  
  28      /**
  29      * @var string Base URL for a profile link, uses {USER_ID} as placeholder
  30      */
  31      protected $profile_url;
  32  
  33      /**
  34      * @var \phpbb\user
  35      */
  36      protected $user;
  37  
  38      /**
  39      * Constructor
  40      *
  41      * @param \phpbb\user $user
  42      * @param string $root_path
  43      * @param string $php_ext
  44      */
  45  	public function __construct(\phpbb\user $user, $root_path, $php_ext)
  46      {
  47          $this->post_url = append_sid($root_path . 'viewtopic.' . $php_ext, 'p={POST_ID}#p{POST_ID}', false);
  48          $this->msg_url = append_sid($root_path . 'ucp.' . $php_ext, 'i=pm&mode=view&p={MSG_ID}', false);
  49          $this->profile_url = append_sid($root_path . 'memberlist.' . $php_ext, 'mode=viewprofile&u={USER_ID}', false);
  50          $this->user = $user;
  51      }
  52  
  53      /**
  54      * Inject dynamic metadata into QUOTE tags in given XML
  55      *
  56      * @param  string $xml Original XML
  57      * @return string      Modified XML
  58      */
  59  	public function inject_metadata($xml)
  60      {
  61          return \s9e\TextFormatter\Utils::replaceAttributes(
  62              $xml,
  63              'QUOTE',
  64              function ($attributes)
  65              {
  66                  if (isset($attributes['post_id']))
  67                  {
  68                      $attributes['post_url'] = str_replace('{POST_ID}', $attributes['post_id'], $this->post_url);
  69                  }
  70                  if (isset($attributes['msg_id']))
  71                  {
  72                      $attributes['msg_url'] = str_replace('{MSG_ID}', $attributes['msg_id'], $this->msg_url);
  73                  }
  74                  if (isset($attributes['time']))
  75                  {
  76                      $attributes['date'] = $this->user->format_date($attributes['time']);
  77                  }
  78                  if (isset($attributes['user_id']))
  79                  {
  80                      $attributes['profile_url'] = str_replace('{USER_ID}', $attributes['user_id'], $this->profile_url);
  81                  }
  82  
  83                  return $attributes;
  84              }
  85          );
  86      }
  87  }


Generated: Thu Mar 24 21:31:15 2022 Cross-referenced by PHPXref 0.7.1