Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

helper.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 5.51 KiB


 001  <?php
 002  /**
 003  *
 004  * This file is part of the phpBB Forum Software package.
 005  *
 006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
 007  * @license GNU General Public License, version 2 (GPL-2.0)
 008  *
 009  * For full copyright and license information, please see
 010  * the docs/CREDITS.txt file.
 011  *
 012  */
 013   
 014  namespace phpbb\feed;
 015   
 016  /**
 017  * Class with some helpful functions used in feeds
 018  */
 019  class helper
 020  {
 021      /** @var \phpbb\config\config */
 022      protected $config;
 023   
 024      /** @var \phpbb\user */
 025      protected $user;
 026   
 027      /** @var string */
 028      protected $phpbb_root_path;
 029   
 030      /** @var string */
 031      protected $phpEx;
 032   
 033      /**
 034      * Constructor
 035      *
 036      * @param    \phpbb\config\config    $config        Config object
 037      * @param    \phpbb\user        $user        User object
 038      * @param    string    $phpbb_root_path    Root path
 039      * @param    string    $phpEx                PHP file extension
 040      */
 041      public function __construct(\phpbb\config\config $config, \phpbb\user $user, $phpbb_root_path, $phpEx)
 042      {
 043          $this->config = $config;
 044          $this->user = $user;
 045          $this->phpbb_root_path = $phpbb_root_path;
 046          $this->phpEx = $phpEx;
 047      }
 048   
 049      /**
 050      * Run links through append_sid(), prepend generate_board_url() and remove session id
 051      */
 052      public function get_board_url()
 053      {
 054          static $board_url;
 055   
 056          if (empty($board_url))
 057          {
 058              $board_url = generate_board_url();
 059          }
 060   
 061          return $board_url;
 062      }
 063   
 064      /**
 065      * Run links through append_sid(), prepend generate_board_url() and remove session id
 066      */
 067      public function append_sid($url, $params)
 068      {
 069          return append_sid($this->get_board_url() . '/' . $url, $params, true, '');
 070      }
 071   
 072      /**
 073      * Generate ISO 8601 date string (RFC 3339)
 074      */
 075      public function format_date($time)
 076      {
 077          static $zone_offset;
 078          static $offset_string;
 079   
 080          if (empty($offset_string))
 081          {
 082              $zone_offset = $this->user->create_datetime()->getOffset();
 083              $offset_string = phpbb_format_timezone_offset($zone_offset);
 084          }
 085   
 086          return gmdate("Y-m-d\TH:i:s", $time + $zone_offset) . $offset_string;
 087      }
 088   
 089      /**
 090      * Generate text content
 091      *
 092      * @param string $content is feed text content
 093      * @param string $uid is bbcode_uid
 094      * @param string $bitfield is bbcode bitfield
 095      * @param int $options bbcode flag options
 096      * @param int $forum_id is the forum id
 097      * @param array $post_attachments is an array containing the attachments and their respective info
 098      * @return string the html content to be printed for the feed
 099      */
 100      public function generate_content($content, $uid, $bitfield, $options, $forum_id, $post_attachments)
 101      {
 102          if (empty($content))
 103          {
 104              return '';
 105          }
 106   
 107          // Prepare some bbcodes for better parsing
 108          $content    = preg_replace("#\[quote(=&quot;.*?&quot;)?:$uid\]\s*(.*?)\s*\[/quote:$uid\]#si", "[quote$1:$uid]<br />$2<br />[/quote:$uid]", $content);
 109   
 110          $content = generate_text_for_display($content, $uid, $bitfield, $options);
 111   
 112          // Add newlines
 113          $content = str_replace('<br />', '<br />' . "\n", $content);
 114   
 115          // Convert smiley Relative paths to Absolute path, Windows style
 116          $content = str_replace($this->phpbb_root_path . $this->config['smilies_path'], $this->get_board_url() . '/' . $this->config['smilies_path'], $content);
 117   
 118          // Remove "Select all" link and mouse events
 119          $content = str_replace('<a href="#" onclick="selectCode(this); return false;">' . $this->user->lang['SELECT_ALL_CODE'] . '</a>', '', $content);
 120          $content = preg_replace('#(onkeypress|onclick)="(.*?)"#si', '', $content);
 121   
 122          // Firefox does not support CSS for feeds, though
 123   
 124          // Remove font sizes
 125      //    $content = preg_replace('#<span style="font-size: [0-9]+%; line-height: [0-9]+%;">([^>]+)</span>#iU', '\1', $content);
 126   
 127          // Make text strong :P
 128      //    $content = preg_replace('#<span style="font-weight: bold?">(.*?)</span>#iU', '<strong>\1</strong>', $content);
 129   
 130          // Italic
 131      //    $content = preg_replace('#<span style="font-style: italic?">([^<]+)</span>#iU', '<em>\1</em>', $content);
 132   
 133          // Underline
 134      //    $content = preg_replace('#<span style="text-decoration: underline?">([^<]+)</span>#iU', '<u>\1</u>', $content);
 135   
 136          // Remove embed Windows Media Streams
 137          $content    = preg_replace( '#<\!--\[if \!IE\]>-->([^[]+)<\!--<!\[endif\]-->#si', '', $content);
 138   
 139          // Do not use &lt; and &gt;, because we want to retain code contained in [code][/code]
 140   
 141          // Remove embed and objects
 142          $content    = preg_replace( '#<(object|embed)(.*?) (value|src)=(.*?) ([^[]+)(object|embed)>#si',' <a href=$4 target="_blank"><strong>$1</strong></a> ',$content);
 143   
 144          // Remove some specials html tag, because somewhere there are a mod to allow html tags ;)
 145          $content    = preg_replace( '#<(script|iframe)([^[]+)\1>#siU', ' <strong>$1</strong> ', $content);
 146   
 147          // Parse inline images to display with the feed
 148          if (!empty($post_attachments))
 149          {
 150              $update_count = array();
 151              parse_attachments($forum_id, $content, $post_attachments, $update_count);
 152              $post_attachments = implode('<br />', $post_attachments);
 153   
 154              // Convert attachments' relative path to absolute path
 155              $post_attachments = str_replace($this->phpbb_root_path . 'download/file.' . $this->phpEx, $this->get_board_url() . '/download/file.' . $this->phpEx, $post_attachments);
 156   
 157              $content .= $post_attachments;
 158          }
 159   
 160          // Remove Comments from inline attachments [ia]
 161          $content = preg_replace('#<dd>(.*?)</dd>#','',$content);
 162   
 163          // Replace some entities with their unicode counterpart
 164          $entities = array(
 165              '&nbsp;'    => "\xC2\xA0",
 166              '&bull;'    => "\xE2\x80\xA2",
 167              '&middot;'    => "\xC2\xB7",
 168              '&copy;'    => "\xC2\xA9",
 169          );
 170   
 171          $content = str_replace(array_keys($entities), array_values($entities), $content);
 172   
 173          // Remove CDATA blocks. ;)
 174          $content = preg_replace('#\<\!\[CDATA\[(.*?)\]\]\>#s', '', $content);
 175   
 176          // Other control characters
 177          $content = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $content);
 178   
 179          return $content;
 180      }
 181  }
 182