Add smaty modifier that can pass referenced variables to a smarty plugin api. Hurts to see that, but seems to be the only way
This commit is contained in:
parent
665e895dc0
commit
702c4f8d05
@ -496,6 +496,42 @@ function serendipity_smarty_hookPlugin($params, &$smarty) {
|
||||
serendipity_plugin_api::hook_event($params['hook'], $params['data'], $params['addData']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Modifier: Be able to execute the hook of an event plugin and return its output, uses a REFERENCED variable.
|
||||
*
|
||||
* Listens to specific serendipity global variables:
|
||||
* $serendipity['skip_smarty_hooks'] - If TRUE, no plugins will be executed at all
|
||||
* $serendipity['skip_smarty_hook'] - Can be set to an array of plugin hooks to NOT execute
|
||||
*
|
||||
* @access public
|
||||
* @param mixed EventData (referenced)
|
||||
* @param string Event hook name
|
||||
* @param mixed Additional data
|
||||
* @return null
|
||||
*/
|
||||
function serendipity_smarty_refhookPlugin(&$eventData, $hook, $addData = null) {
|
||||
global $serendipity;
|
||||
|
||||
if (!isset($hook)) {
|
||||
$smarty->trigger_error(__FUNCTION__ .": missing 'hook' parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
// Smarty hooks can be bypassed via an internal variable (temporarily)
|
||||
if (isset($serendipity['skip_smarty_hooks']) && $serendipity['skip_smarty_hooks']) {
|
||||
return;
|
||||
}
|
||||
|
||||
// A specific hook can also be bypassed by creating an associative array like this:
|
||||
// $serendipity['skip_smarty_hook'] = array('entries_header');
|
||||
// That would only skip the entries_header event hook, but allow all others.
|
||||
// Of course it cannot be used in conjunction with the all-blocking skip_smarty_hooks.
|
||||
if (isset($serendipity['skip_smarty_hook']) && is_array($serendipity['skip_smarty_hook']) && isset($serendipity['skip_smarty_hook'][$params['hook']])) {
|
||||
return;
|
||||
}
|
||||
|
||||
serendipity_plugin_api::hook_event($hook, $eventData, $addData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Function: Prints a list of sidebar plugins
|
||||
@ -745,6 +781,7 @@ function serendipity_smarty_init($vars = array()) {
|
||||
$serendipity['smarty']->register_modifier('serendipity_utf8_encode', 'serendipity_utf8_encode');
|
||||
$serendipity['smarty']->register_modifier('ifRemember', 'serendipity_ifRemember');
|
||||
$serendipity['smarty']->register_modifier('checkPermission', 'serendipity_checkPermission');
|
||||
$serendipity['smarty']->register_modifier('serendipity_refhookPlugin', 'serendipity_smarty_refhookPlugin');
|
||||
|
||||
$serendipity['smarty']->register_function('serendipity_printSidebar', 'serendipity_smarty_printSidebar');
|
||||
$serendipity['smarty']->register_function('serendipity_hookPlugin', 'serendipity_smarty_hookPlugin');
|
||||
|
@ -39,7 +39,7 @@ var $filter_defaults;
|
||||
'smarty' => '2.6.7',
|
||||
'php' => '4.1.0'
|
||||
));
|
||||
$propbag->add('version', '1.67');
|
||||
$propbag->add('version', '1.68');
|
||||
$propbag->add('event_hooks', array(
|
||||
'frontend_saveComment' => true,
|
||||
'external_plugin' => true,
|
||||
@ -683,6 +683,11 @@ var $filter_defaults;
|
||||
// of if kaptchas are activated for every entry
|
||||
$show_captcha = ($captchas && isset($eventData['timestamp']) && ($captchas_ttl < 1 || ($eventData['timestamp'] < (time() - ($captchas_ttl*60*60*24)))) ? true : false);
|
||||
|
||||
// Plugins can override with custom captchas
|
||||
if (isset($serendipity['plugins']['disable_internal_captcha'])) {
|
||||
$show_captcha = false;
|
||||
}
|
||||
|
||||
$forcemoderation = $this->get_config('forcemoderation', 60);
|
||||
$forcemoderation_treat = $this->get_config('forcemoderation_treat', 'moderate');
|
||||
$forcemoderationt = $this->get_config('forcemoderationt', 60);
|
||||
|
@ -198,7 +198,7 @@
|
||||
<fieldset>
|
||||
<legend><b>{$CONST.ADVANCED_OPTIONS}</b></legend>
|
||||
{*** EXTERNAL PLUGINS OUTPUT START ***}
|
||||
{serendipity_hookPlugin hook="backend_display" data=$entry_vars.entry hookAll="true"}
|
||||
{$entry_vars.entry|@serendipity_refhookPlugin:'backend_display'}
|
||||
{*** EXTERNAL PLUGINS OUTPUT END ***}
|
||||
</fieldset>
|
||||
</td>
|
||||
@ -218,7 +218,7 @@
|
||||
{foreach from=$entry_vars.wysiwyg_blocks item="wysiwyg_block_item" key="wysiwyg_block_jsname"}
|
||||
{$wysiwyg_block_item|emit_htmlarea_code:$wysiwyg_block_jsname}
|
||||
{/foreach}
|
||||
{serendipity_hookPlugin hook="backend_wysiwyg_finish" data=$entry_vars.wysiwyg_blocks hookAll="true"}
|
||||
{serendipity_refhookPlugin hook="backend_wysiwyg_finish" data=$entry_vars.wysiwyg_blocks}
|
||||
{/if}
|
||||
{*** SPAWN WYSIWYG EDITORS END ***}
|
||||
|
||||
|
@ -77,7 +77,7 @@
|
||||
{if NOT $admin_vars.is_logged_in}
|
||||
{*** LOGIN-AREA START ***}
|
||||
|
||||
{serendipity_hookPlugin hook="backend_header" data=$admin_vars.out hookAll="true"}
|
||||
{$admin_vars.out|@serendipity_refhookPlugin:'backend_login_page'}
|
||||
<td colspan="2" class="serendipityAdminContent">
|
||||
<div align="center">{$CONST.WELCOME_TO_ADMIN}<br />
|
||||
{$CONST.PLEASE_ENTER_CREDENTIALS}
|
||||
|
Loading…
x
Reference in New Issue
Block a user