diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | phpBB/common.php | 8 | ||||
-rw-r--r-- | phpBB/composer.json | 5 | ||||
-rw-r--r-- | phpBB/composer.lock | 10 | ||||
-rw-r--r-- | phpBB/docs/AUTHORS | 3 | ||||
-rw-r--r-- | phpBB/download/file.php | 2 | ||||
-rw-r--r-- | phpBB/includes/event/data.php | 58 | ||||
-rw-r--r-- | phpBB/includes/event/extension_subscriber_loader.php | 45 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 5 | ||||
-rw-r--r-- | phpBB/install/database_update.php | 2 | ||||
-rw-r--r-- | phpBB/install/index.php | 2 | ||||
-rw-r--r-- | tests/bootstrap.php | 2 |
12 files changed, 143 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index d875beb784..eb7b546445 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /phpBB/images/avatars/gallery/* /phpBB/images/avatars/upload/* /phpBB/store/* +/phpBB/vendor /tests/phpbb_unit_tests.sqlite2 /tests/test_config.php /tests/tmp/* diff --git a/phpBB/common.php b/phpBB/common.php index b308037a0e..c48418276a 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -15,6 +15,8 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\EventDispatcher\EventDispatcher; + require($phpbb_root_path . 'includes/startup.' . $phpEx); if (file_exists($phpbb_root_path . 'config.' . $phpEx)) @@ -70,6 +72,8 @@ if (!empty($load_extensions) && function_exists('dl')) } } +require($phpbb_root_path . 'vendor/.composer/autoload.php'); + // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); @@ -98,6 +102,7 @@ $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes +$phpbb_dispatcher = new EventDispatcher(); $request = new phpbb_request(); $user = new user(); $auth = new auth(); @@ -124,6 +129,9 @@ $phpbb_template_locator = new phpbb_template_locator(); $phpbb_template_path_provider = new phpbb_template_extension_path_provider($phpbb_extension_manager, new phpbb_template_path_provider()); $template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_template_locator, $phpbb_template_path_provider); +$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); +$phpbb_subscriber_loader->load(); + // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); diff --git a/phpBB/composer.json b/phpBB/composer.json new file mode 100644 index 0000000000..1059b97f84 --- /dev/null +++ b/phpBB/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "symfony/event-dispatcher": "2.0.*" + } +} diff --git a/phpBB/composer.lock b/phpBB/composer.lock new file mode 100644 index 0000000000..062ad4b3aa --- /dev/null +++ b/phpBB/composer.lock @@ -0,0 +1,10 @@ +{ + "hash": "9bada3748ec2933fe0864dcfafbcd671", + "packages": [ + { + "package": "symfony/event-dispatcher", + "version": "v2.0.10" + } + ], + "aliases": [] +} diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS index 4fe0af6e28..8be261706e 100644 --- a/phpBB/docs/AUTHORS +++ b/phpBB/docs/AUTHORS @@ -79,3 +79,6 @@ Pear (c) 2001-2004 PHP Group, http://pear.php.net Text_Diff-0.2.1 http://pear.php.net/package/Text_Diff +MIT licenced: +Symfony2 (c) 2004-2011 Fabien Potencier, http://symfony.com/ + diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 2baa9d6c8a..3f14a9cb82 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -38,6 +38,8 @@ if (isset($_GET['avatar'])) exit; } + require($phpbb_root_path . 'vendor/.composer/autoload.php'); + require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); diff --git a/phpBB/includes/event/data.php b/phpBB/includes/event/data.php new file mode 100644 index 0000000000..62e2f2312e --- /dev/null +++ b/phpBB/includes/event/data.php @@ -0,0 +1,58 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +use Symfony\Component\EventDispatcher\Event; + +class phpbb_event_data extends Event implements ArrayAccess +{ + private $data; + + public function __construct(array $data = array()) + { + $this->set_data($data); + } + + public function set_data(array $data = array()) + { + $this->data = $data; + } + + public function get_data() + { + return $this->data; + } + + public function offsetExists($offset) + { + return isset($this->data[$offset]); + } + + public function offsetGet($offset) + { + return isset($this->data[$offset]) ? $this->data[$offset] : null; + } + + public function offsetSet($offset, $value) + { + $this->data[$offset] = $value; + } + + public function offsetUnset($offset) + { + unset($this->data[$offset]); + } +} diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php new file mode 100644 index 0000000000..aa32ca9686 --- /dev/null +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -0,0 +1,45 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +use Symfony\Component\EventDispatcher\EventDispatcher; + +class phpbb_event_extension_subscriber_loader +{ + private $dispatcher; + private $extension_manager; + + public function __construct(EventDispatcher $dispatcher, phpbb_extension_manager $extension_manager) + { + $this->dispatcher = $dispatcher; + $this->extension_manager = $extension_manager; + } + + public function load() + { + $finder = $this->extension_manager->get_finder(); + $subscriber_classes = $finder + ->extension_directory('/event') + ->suffix('subscriber') + ->core_path('event/') + ->get_classes(); + + foreach ($subscriber_classes as $class) { + $subscriber = new $class(); + $this->dispatcher->addSubscriber($subscriber); + } + } +} diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9913a80a70..024fa612f0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4478,6 +4478,7 @@ function phpbb_http_login($param) function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; + global $phpbb_dispatcher; if (defined('HEADER_INC')) { @@ -4761,6 +4762,10 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); + $event = new phpbb_event_data(); + $event->set_data(compact('page_title', 'display_online_list', 'item_id', 'item')); + $phpbb_dispatcher->dispatch('core.page_header', $event); + // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 843e8c2f23..a1c8fe1ef9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -82,6 +82,8 @@ if (!empty($load_extensions) && function_exists('dl')) } } +require($phpbb_root_path . 'vendor/.composer/autoload.php'); + // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 9d003ba6ab..7e150c2519 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -69,6 +69,8 @@ else } @ini_set('memory_limit', $mem_limit); +require($phpbb_root_path . 'vendor/.composer/autoload.php'); + // Include essential scripts require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 302701e3b3..3544c66c3d 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,6 +12,8 @@ $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; require_once $phpbb_root_path . 'includes/startup.php'; +require_once $phpbb_root_path . 'vendor/.composer/autoload.php'; + $table_prefix = 'phpbb_'; require_once $phpbb_root_path . 'includes/constants.php'; require_once $phpbb_root_path . 'includes/class_loader.' . $phpEx; |