diff options
Diffstat (limited to 'lib/plugins/styler/action.php')
-rw-r--r-- | lib/plugins/styler/action.php | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/lib/plugins/styler/action.php b/lib/plugins/styler/action.php index e2385e739..88e2d0912 100644 --- a/lib/plugins/styler/action.php +++ b/lib/plugins/styler/action.php @@ -9,6 +9,14 @@ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); +/** + * Class action_plugin_styler + * + * This handles all the save actions and loading the interface + * + * All this usually would be done within an admin plugin, but we want to have this available outside + * the admin interface using our floating dialog. + */ class action_plugin_styler extends DokuWiki_Action_Plugin { /** @@ -18,10 +26,8 @@ class action_plugin_styler extends DokuWiki_Action_Plugin { * @return void */ public function register(Doku_Event_Handler $controller) { - $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax'); $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_action'); - } /** @@ -33,6 +39,8 @@ class action_plugin_styler extends DokuWiki_Action_Plugin { * @return void */ public function handle_action(Doku_Event &$event, $param) { + if(!auth_isadmin()) return; + $event->data = act_clean($event->data); if($event->data === 'styler_plugin_preview') { $event->data = 'show'; @@ -50,6 +58,26 @@ class action_plugin_styler extends DokuWiki_Action_Plugin { } /** + * [Custom event handler which performs action] + * + * @param Doku_Event $event event object by reference + * @param mixed $param [the parameters passed as fifth argument to register_hook() when this + * handler was registered] + * @return void + */ + + public function handle_ajax(Doku_Event &$event, $param) { + if(!auth_isadmin()) return; + if($event->data != 'plugin_styler') return; + $event->preventDefault(); + $event->stopPropagation(); + + /** @var admin_plugin_styler $hlp */ + $hlp = plugin_load('admin', 'styler'); + $hlp->form(); + } + + /** * saves the preview.ini */ protected function preview() { @@ -119,24 +147,6 @@ class action_plugin_styler extends DokuWiki_Action_Plugin { io_saveFile($ini, "$old\n\n$new"); } - /** - * [Custom event handler which performs action] - * - * @param Doku_Event $event event object by reference - * @param mixed $param [the parameters passed as fifth argument to register_hook() when this - * handler was registered] - * @return void - */ - - public function handle_ajax(Doku_Event &$event, $param) { - if($event->data != 'plugin_styler') return; - $event->preventDefault(); - $event->stopPropagation(); - - /** @var admin_plugin_styler $hlp */ - $hlp = plugin_load('admin', 'styler'); - $hlp->html(); - } } |