1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-25 20:45:16 +02:00

[feature/template-events] Changes per imkingdavid's review.

PHPBB3-9550
This commit is contained in:
Oleg Pudeyev
2012-11-14 17:31:05 -05:00
parent da7d888448
commit 47a90f815d
5 changed files with 17 additions and 5 deletions

View File

@ -97,7 +97,7 @@ class phpbb_style
{
$names[] = $dir;
}
// Add 'all' path, used as last fallback path by hooks and extensions
// Add 'all' path, used as last fallback path by events and extensions
//$names[] = 'all';
$paths = array();

View File

@ -39,7 +39,7 @@ class phpbb_template_compile
* @param array $style_names Name of style to which the template being compiled belongs and parents in style tree order
* @param phpbb_style_resource_locator $locator Resource locator
* @param string $phpbb_root_path Path to phpBB root directory
* @param phpbb_extension_manager $extension_manager Extension manager to use for finding template fragments in extensions; if null, template hooks will not be invoked
* @param phpbb_extension_manager $extension_manager Extension manager to use for finding template fragments in extensions; if null, template events will not be invoked
* @param phpbb_user $user Current user
*/
public function __construct($allow_php, $style_names, $locator, $phpbb_root_path, $extension_manager = null, $user = null)

View File

@ -106,6 +106,7 @@ class phpbb_template_filter extends php_user_filter
/**
* Current user
*
* @var phpbb_user
*/
private $user;
@ -170,6 +171,8 @@ class phpbb_template_filter extends php_user_filter
*
* Get the allow_php option, style_names, root directory and locator from params,
* which are passed to stream_filter_append.
*
* @return boolean Returns true
*/
public function onCreate()
{
@ -902,12 +905,13 @@ class phpbb_template_filter extends php_user_filter
* such template fragments would have no effect.
*
* @param string $tag_args EVENT tag arguments, as a string - for EVENT this is the event name
* @return string compiled template code
*/
private function compile_tag_event($tag_args)
{
if (!preg_match('/^\w+$/', $tag_args))
{
// The hook location is improperly formatted,
// The event location is improperly formatted,
if ($this->user)
{
trigger_error($this->user->lang('ERR_TEMPLATE_EVENT_LOCATION', $tag_args), E_USER_ERROR);
@ -950,7 +954,14 @@ class phpbb_template_filter extends php_user_filter
if ($compiled === false)
{
trigger_error(sprintf('The file could not be compiled: %s', phpbb_filter_root_path($file)), E_USER_ERROR);
if ($this->user)
{
trigger_error($this->user->lang('ERR_TEMPLATE_COMPILATION', phpbb_filter_root_path($file)), E_USER_ERROR);
}
else
{
trigger_error(sprintf('The file could not be compiled: %s', phpbb_filter_root_path($file)), E_USER_ERROR);
}
}
$all_compiled .= $compiled;

View File

@ -98,7 +98,7 @@ class phpbb_template
* @param user $user current user
* @param phpbb_template_locator $locator template locator
* @param phpbb_template_context $context template context
* @param phpbb_extension_manager $extension_manager extension manager, if null then template hooks will not be invoked
* @param phpbb_extension_manager $extension_manager extension manager, if null then template events will not be invoked
*/
public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template_locator $locator, phpbb_template_context $context, phpbb_extension_manager $extension_manager = null)
{

View File

@ -187,6 +187,7 @@ $lang = array_merge($lang, array(
'ERR_JAB_AUTH' => 'Could not authorise on Jabber server.',
'ERR_JAB_CONNECT' => 'Could not connect to Jabber server.',
'ERR_TEMPLATE_EVENT_LOCATION' => 'The specified template event location <em>[%s]</em> is improperly formatted.',
'ERR_TEMPLATE_COMPILATION' => 'The file could not be compiled: %s',
'ERR_UNABLE_TO_LOGIN' => 'The specified username or password is incorrect.',
'ERR_UNWATCHING' => 'An error occured while trying to unsubscribe.',
'ERR_WATCHING' => 'An error occured while trying to subscribe.',