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

factory.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 2.83 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  use Symfony\Component\DependencyInjection\ContainerInterface;
 017   
 018  /**
 019  * Factory class to return correct object
 020  */
 021  class factory
 022  {
 023      /**
 024      * Service container object
 025      * @var ContainerInterface
 026      */
 027      protected $container;
 028   
 029      /** @var \phpbb\config\config */
 030      protected $config;
 031   
 032      /** @var \phpbb\db\driver\driver_interface */
 033      protected $db;
 034   
 035      /**
 036      * Constructor
 037      *
 038      * @param ContainerInterface                    $container    Container object
 039      * @param \phpbb\config\config                $config        Config object
 040      * @param \phpbb\db\driver\driver_interface    $db            Database connection
 041      */
 042      public function __construct(ContainerInterface $container, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db)
 043      {
 044          $this->container = $container;
 045          $this->config = $config;
 046          $this->db = $db;
 047      }
 048   
 049      /**
 050      * Return correct object for specified mode
 051      *
 052      * @param string    $mode        The feeds mode.
 053      * @param int    $forum_id    Forum id specified by the script if forum feed provided.
 054      * @param int    $topic_id    Topic id specified by the script if topic feed provided.
 055      *
 056      * @return object    Returns correct feeds object for specified mode.
 057      */
 058      function get_feed($mode, $forum_id, $topic_id)
 059      {
 060          switch ($mode)
 061          {
 062              case 'forums':
 063                  if (!$this->config['feed_overall_forums'])
 064                  {
 065                      return false;
 066                  }
 067   
 068                  return $this->container->get('feed.forums');
 069              break;
 070   
 071              case 'topics':
 072              case 'topics_new':
 073                  if (!$this->config['feed_topics_new'])
 074                  {
 075                      return false;
 076                  }
 077   
 078                  return $this->container->get('feed.topics');
 079              break;
 080   
 081              case 'topics_active':
 082                  if (!$this->config['feed_topics_active'])
 083                  {
 084                      return false;
 085                  }
 086   
 087                  return $this->container->get('feed.topics_active');
 088              break;
 089   
 090              case 'news':
 091                  // Get at least one news forum
 092                  $sql = 'SELECT forum_id
 093                      FROM ' . FORUMS_TABLE . '
 094                      WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0');
 095                  $result = $this->db->sql_query_limit($sql, 1, 0, 600);
 096                  $s_feed_news = (int) $this->db->sql_fetchfield('forum_id');
 097                  $this->db->sql_freeresult($result);
 098   
 099                  if (!$s_feed_news)
 100                  {
 101                      return false;
 102                  }
 103   
 104                  return $this->container->get('feed.news');
 105              break;
 106   
 107              default:
 108                  if ($topic_id && $this->config['feed_topic'])
 109                  {
 110                      return $this->container->get('feed.topic')
 111                                  ->set_topic_id($topic_id);
 112                  }
 113                  else if ($forum_id && $this->config['feed_forum'])
 114                  {
 115                      return $this->container->get('feed.forum')
 116                                  ->set_forum_id($forum_id);
 117                  }
 118                  else if ($this->config['feed_overall'])
 119                  {
 120                  return $this->container->get('feed.overall');
 121                  }
 122   
 123                  return false;
 124              break;
 125          }
 126      }
 127  }
 128