[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
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\feed; 15 16 use Symfony\Component\DependencyInjection\ContainerInterface; 17 18 /** 19 * Factory class to return correct object 20 */ 21 class factory 22 { 23 /** 24 * Service container object 25 * @var ContainerInterface 26 */ 27 protected $container; 28 29 /** @var \phpbb\config\config */ 30 protected $config; 31 32 /** @var \phpbb\db\driver\driver_interface */ 33 protected $db; 34 35 /** 36 * Constructor 37 * 38 * @param ContainerInterface $container Container object 39 * @param \phpbb\config\config $config Config object 40 * @param \phpbb\db\driver\driver_interface $db Database connection 41 */ 42 public function __construct(ContainerInterface $container, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db) 43 { 44 $this->container = $container; 45 $this->config = $config; 46 $this->db = $db; 47 } 48 49 /** 50 * Return correct object for specified mode 51 * 52 * @param string $mode The feeds mode. 53 * @param int $forum_id Forum id specified by the script if forum feed provided. 54 * @param int $topic_id Topic id specified by the script if topic feed provided. 55 * 56 * @return object Returns correct feeds object for specified mode. 57 */ 58 function get_feed($mode, $forum_id, $topic_id) 59 { 60 switch ($mode) 61 { 62 case 'forums': 63 if (!$this->config['feed_overall_forums']) 64 { 65 return false; 66 } 67 68 return $this->container->get('feed.forums'); 69 break; 70 71 case 'topics': 72 case 'topics_new': 73 if (!$this->config['feed_topics_new']) 74 { 75 return false; 76 } 77 78 return $this->container->get('feed.topics'); 79 break; 80 81 case 'topics_active': 82 if (!$this->config['feed_topics_active']) 83 { 84 return false; 85 } 86 87 return $this->container->get('feed.topics_active'); 88 break; 89 90 case 'news': 91 // Get at least one news forum 92 $sql = 'SELECT forum_id 93 FROM ' . FORUMS_TABLE . ' 94 WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); 95 $result = $this->db->sql_query_limit($sql, 1, 0, 600); 96 $s_feed_news = (int) $this->db->sql_fetchfield('forum_id'); 97 $this->db->sql_freeresult($result); 98 99 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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |