mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge remote-tracking branch 'imkingdavid/ticket/10586' into develop
* imkingdavid/ticket/10586: [ticket/10586] Added space in if statement [ticket/10586] Tidy up comments [ticket/10586] Tests finally work (thanks naderman) [ticket/10586] Correctly purge board cache and don't rename install directory [ticket/10586] trying to get tests to work [ticket/10586] more work on getting tests to pass [ticket/10586] Tests are coming along, just a little more to go [ticket/10586] Rename install directory back to install/ after tests [ticket/10586] browse tests now work, but mine dont. at least we are making progress [ticket/10586] initial work on copying fixtures. Note that this depends on 10706 [ticket/10586] Adding the extensions used by the tests [ticket/10586] Now tests run, but fail. But here is what I have. [ticket/10586] some bootstrap additions and test changes to try and make it work [ticket/10586] test stuff. does not work yet, still need to put phpBB objects in bootstrap.php [ticket/10586] Copy/paste fail fixed [ticket/10586] Sanitize periods from class names, use manager to get path. [ticket/10586] Removed file_exists() check because class_exists() covers that. [ticket/10586] Extension front controller
This commit is contained in:
31
phpBB/includes/extension/controller_interface.php
Normal file
31
phpBB/includes/extension/controller_interface.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package extension
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* The interface that extension classes have to implement to run front pages
|
||||
*
|
||||
* @package extension
|
||||
*/
|
||||
interface phpbb_extension_controller_interface
|
||||
{
|
||||
/**
|
||||
* handle the request to display a page from an extension
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function handle();
|
||||
}
|
@@ -432,6 +432,28 @@ class phpbb_extension_manager
|
||||
}
|
||||
return $disabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a given extension is available on the filesystem
|
||||
*
|
||||
* @param string $name Extension name to check NOTE: Can be user input
|
||||
* @return bool Depending on whether or not the extension is available
|
||||
*/
|
||||
public function available($name)
|
||||
{
|
||||
return file_exists($this->get_extension_path($name, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a given extension is enabled
|
||||
*
|
||||
* @param string $name Extension name to check
|
||||
* @return bool Depending on whether or not the extension is enabled
|
||||
*/
|
||||
public function enabled($name)
|
||||
{
|
||||
return isset($this->extensions[$name]) && $this->extensions[$name]['ext_active'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a phpbb_extension_finder.
|
||||
|
@@ -24,6 +24,39 @@ $user->session_begin();
|
||||
$auth->acl($user->data);
|
||||
$user->setup('viewforum');
|
||||
|
||||
// Handle the display of extension front pages
|
||||
if ($ext = $request->variable('ext', ''))
|
||||
{
|
||||
$class = 'phpbb_ext_' . str_replace('/', '_', $ext) . '_controller';
|
||||
|
||||
if (!$phpbb_extension_manager->available($ext))
|
||||
{
|
||||
send_status_line(404, 'Not Found');
|
||||
trigger_error($user->lang('EXTENSION_DOES_NOT_EXIST', $ext));
|
||||
}
|
||||
else if (!$phpbb_extension_manager->enabled($ext))
|
||||
{
|
||||
send_status_line(404, 'Not Found');
|
||||
trigger_error($user->lang('EXTENSION_DISABLED', $ext));
|
||||
}
|
||||
else if (!class_exists($class))
|
||||
{
|
||||
send_status_line(404, 'Not Found');
|
||||
trigger_error($user->lang('EXTENSION_CONTROLLER_MISSING', $ext));
|
||||
}
|
||||
|
||||
$controller = new $class;
|
||||
|
||||
if (!($controller instanceof phpbb_extension_controller_interface))
|
||||
{
|
||||
send_status_line(500, 'Internal Server Error');
|
||||
trigger_error($user->lang('EXTENSION_CLASS_WRONG_TYPE', $class));
|
||||
}
|
||||
|
||||
$controller->handle();
|
||||
exit_handler();
|
||||
}
|
||||
|
||||
display_forums('', $config['load_moderators']);
|
||||
|
||||
$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend';
|
||||
|
@@ -185,7 +185,11 @@ $lang = array_merge($lang, array(
|
||||
'ERR_WRONG_PATH_TO_PHPBB' => 'The phpBB path specified appears to be invalid.',
|
||||
'EXPAND_VIEW' => 'Expand view',
|
||||
'EXTENSION' => 'Extension',
|
||||
'EXTENSION_CONTROLLER_MISSING' => 'The extension <strong>%s</strong> is missing a controller class and cannot be accessed through the front-end.',
|
||||
'EXTENSION_CLASS_WRONG_TYPE' => 'The extension controller class <strong>%s</strong> is not an instance of the phpbb_extension_controller_interface.',
|
||||
'EXTENSION_DISABLED' => 'The extension <strong>%s</strong> is not enabled.',
|
||||
'EXTENSION_DISABLED_AFTER_POSTING' => 'The extension <strong>%s</strong> has been deactivated and can no longer be displayed.',
|
||||
'EXTENSION_DOES_NOT_EXIST' => 'The extension <strong>%s</strong> does not exist.',
|
||||
|
||||
'FAQ' => 'FAQ',
|
||||
'FAQ_EXPLAIN' => 'Frequently Asked Questions',
|
||||
|
Reference in New Issue
Block a user