Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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

base.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 7.18 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   * Base class with some generic functions and settings.
 018   */
 019  abstract class base implements feed_interface
 020  {
 021      /**
 022       * Feed helper object
 023       * @var \phpbb\feed\helper
 024       */
 025      protected $helper;
 026   
 027      /** @var \phpbb\config\config */
 028      protected $config;
 029   
 030      /** @var \phpbb\db\driver\driver_interface */
 031      protected $db;
 032   
 033      /** @var \phpbb\cache\driver\driver_interface */
 034      protected $cache;
 035   
 036      /** @var \phpbb\user */
 037      protected $user;
 038   
 039      /** @var \phpbb\auth\auth */
 040      protected $auth;
 041   
 042      /** @var \phpbb\content_visibility */
 043      protected $content_visibility;
 044   
 045      /** @var \phpbb\event\dispatcher_interface */
 046      protected $phpbb_dispatcher;
 047   
 048      /** @var string */
 049      protected $phpEx;
 050   
 051      /**
 052       * SQL Query to be executed to get feed items
 053       */
 054      protected $sql = array();
 055   
 056      /**
 057       * Keys specified for retrieval of title, content, etc.
 058       */
 059      protected $keys = array();
 060   
 061      /**
 062       * Number of items to fetch. Usually overwritten by $config['feed_something']
 063       */
 064      protected $num_items = 15;
 065   
 066      /**
 067       * Separator for title elements to separate items (for example forum / topic)
 068       */
 069      protected $separator = "\xE2\x80\xA2"; // &bull;
 070   
 071      /**
 072       * Separator for the statistics row (Posted by, post date, replies, etc.)
 073       */
 074      protected $separator_stats = "\xE2\x80\x94"; // &mdash;
 075   
 076      /** @var mixed Query result handle */
 077      protected $result;
 078   
 079      /**
 080       * Constructor
 081       *
 082       * @param \phpbb\feed\helper                    $helper        Feed helper
 083       * @param \phpbb\config\config                $config        Config object
 084       * @param \phpbb\db\driver\driver_interface    $db            Database connection
 085       * @param \phpbb\cache\driver\driver_interface    $cache    Cache object
 086       * @param \phpbb\user                        $user        User object
 087       * @param \phpbb\auth\auth                    $auth        Auth object
 088       * @param \phpbb\content_visibility            $content_visibility        Auth object
 089       * @param \phpbb\event\dispatcher_interface    $phpbb_dispatcher        Event dispatcher object
 090       * @param string                                $phpEx        php file extension
 091       */
 092      public function __construct(
 093          \phpbb\feed\helper $helper,
 094          \phpbb\config\config $config,
 095          \phpbb\db\driver\driver_interface $db,
 096          \phpbb\cache\driver\driver_interface $cache,
 097          \phpbb\user $user,
 098          \phpbb\auth\auth $auth,
 099          \phpbb\content_visibility $content_visibility,
 100          \phpbb\event\dispatcher_interface $phpbb_dispatcher,
 101          $phpEx
 102      )
 103      {
 104          $this->config = $config;
 105          $this->helper = $helper;
 106          $this->db = $db;
 107          $this->cache = $cache;
 108          $this->user = $user;
 109          $this->auth = $auth;
 110          $this->content_visibility = $content_visibility;
 111          $this->phpbb_dispatcher = $phpbb_dispatcher;
 112          $this->phpEx = $phpEx;
 113   
 114          $this->set_keys();
 115   
 116          // Allow num_items to be string
 117          if (is_string($this->num_items))
 118          {
 119              $this->num_items = (int) $this->config[$this->num_items];
 120   
 121              // A precaution
 122              if (!$this->num_items)
 123              {
 124                  $this->num_items = 10;
 125              }
 126          }
 127      }
 128   
 129      /**
 130       * {@inheritdoc}
 131       */
 132      public function set_keys()
 133      {
 134      }
 135   
 136      /**
 137       * {@inheritdoc}
 138       */
 139      public function open()
 140      {
 141      }
 142   
 143      /**
 144       * {@inheritdoc}
 145       */
 146      public function close()
 147      {
 148          if (!empty($this->result))
 149          {
 150              $this->db->sql_freeresult($this->result);
 151          }
 152      }
 153   
 154      /**
 155       * {@inheritdoc}
 156       */
 157      public function set($key, $value)
 158      {
 159          $this->keys[$key] = $value;
 160      }
 161   
 162      /**
 163       * {@inheritdoc}
 164       */
 165      public function get($key)
 166      {
 167          return (isset($this->keys[$key])) ? $this->keys[$key] : null;
 168      }
 169   
 170      /**
 171       * {@inheritdoc}
 172       */
 173      public function get_item()
 174      {
 175          if (!isset($this->result))
 176          {
 177              if (!$this->get_sql())
 178              {
 179                  return false;
 180              }
 181   
 182              $sql_ary = $this->sql;
 183   
 184              /**
 185               * Event to modify the feed item sql
 186               *
 187               * @event core.feed_base_modify_item_sql
 188               * @var    array    sql_ary        The SQL array to get the feed item data
 189               *
 190               * @since 3.1.10-RC1
 191               */
 192              $vars = array('sql_ary');
 193              extract($this->phpbb_dispatcher->trigger_event('core.feed_base_modify_item_sql', compact($vars)));
 194              $this->sql = $sql_ary;
 195              unset($sql_ary);
 196   
 197              // Query database
 198              $sql = $this->db->sql_build_query('SELECT', $this->sql);
 199              $this->result = $this->db->sql_query_limit($sql, $this->num_items);
 200          }
 201   
 202          return $this->db->sql_fetchrow($this->result);
 203      }
 204   
 205      /**
 206       * Returns the ids of the forums readable by the current user.
 207       *
 208       * @return int[]
 209       */
 210      protected function get_readable_forums()
 211      {
 212          static $forum_ids;
 213   
 214          if (!isset($forum_ids))
 215          {
 216              $forum_ids = array_keys($this->auth->acl_getf('f_read', true));
 217          }
 218   
 219          return $forum_ids;
 220      }
 221   
 222      /**
 223       * Returns the ids of the forum for which the current user can approve the post in the moderation queue.
 224       *
 225       * @return int[]
 226       */
 227      protected function get_moderator_approve_forums()
 228      {
 229          static $forum_ids;
 230   
 231          if (!isset($forum_ids))
 232          {
 233              $forum_ids = array_keys($this->auth->acl_getf('m_approve', true));
 234          }
 235   
 236          return $forum_ids;
 237      }
 238   
 239      /**
 240       * Returns true if the current user can approve the post of the given forum
 241       *
 242       * @param int $forum_id Forum id to check
 243       * @return bool
 244       */
 245      protected function is_moderator_approve_forum($forum_id)
 246      {
 247          static $forum_ids;
 248   
 249          if (!isset($forum_ids))
 250          {
 251              $forum_ids = array_flip($this->get_moderator_approve_forums());
 252          }
 253   
 254          return (isset($forum_ids[$forum_id])) ? true : false;
 255      }
 256   
 257      /**
 258       * Returns the ids of the forum excluded from the feeds
 259       *
 260       * @return int[]
 261       */
 262      protected function get_excluded_forums()
 263      {
 264          static $forum_ids;
 265   
 266          // Matches acp/acp_board.php
 267          $cache_name    = 'feed_excluded_forum_ids';
 268   
 269          if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false)
 270          {
 271              $sql = 'SELECT forum_id
 272                  FROM ' . FORUMS_TABLE . '
 273                  WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '<> 0');
 274              $result = $this->db->sql_query($sql);
 275   
 276              $forum_ids = array();
 277              while ($forum_id = (int) $this->db->sql_fetchfield('forum_id'))
 278              {
 279                  $forum_ids[$forum_id] = $forum_id;
 280              }
 281              $this->db->sql_freeresult($result);
 282   
 283              $this->cache->put('_' . $cache_name, $forum_ids);
 284          }
 285   
 286          return $forum_ids;
 287      }
 288   
 289      /**
 290       * Returns true if the given id is in the excluded forums list.
 291       *
 292       * @param int $forum_id Id to check
 293       * @return bool
 294       */
 295      protected function is_excluded_forum($forum_id)
 296      {
 297          $forum_ids = $this->get_excluded_forums();
 298   
 299          return isset($forum_ids[$forum_id]) ? true : false;
 300      }
 301   
 302      /**
 303       * Returns all password protected forum ids the current user is currently NOT authenticated for.
 304       *
 305       * @return array     Array of forum ids
 306       */
 307      protected function get_passworded_forums()
 308      {
 309          return $this->user->get_passworded_forums();
 310      }
 311   
 312      /**
 313       * Returns the link to the user profile.
 314       *
 315       * @return string
 316       */
 317      protected function user_viewprofile($row)
 318      {
 319          $author_id = (int) $row[$this->get('author_id')];
 320   
 321          if ($author_id == ANONYMOUS)
 322          {
 323              // Since we cannot link to a profile, we just return GUEST
 324              // instead of $row['username']
 325              return $this->user->lang['GUEST'];
 326          }
 327   
 328          return '<a href="' . $this->helper->append_sid('memberlist.' . $this->phpEx, 'mode=viewprofile&amp;u=' . $author_id) . '">' . $row[$this->get('creator')] . '</a>';
 329      }
 330   
 331      /**
 332       * Returns the SQL query used to retrieve the posts of the feed.
 333       *
 334       * @return string SQL SELECT query
 335       */
 336      protected abstract function get_sql();
 337  }
 338