[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 /** DokuWiki Plugin extension (Action Component) 3 * 4 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 5 * @author Andreas Gohr <andi@splitbrain.org> 6 */ 7 8 class action_plugin_extension extends DokuWiki_Action_Plugin 9 { 10 11 /** 12 * Registers a callback function for a given event 13 * 14 * @param Doku_Event_Handler $controller DokuWiki's event controller object 15 * @return void 16 */ 17 public function register(Doku_Event_Handler $controller) 18 { 19 $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'info'); 20 } 21 22 /** 23 * Create the detail info for a single plugin 24 * 25 * @param Doku_Event $event 26 * @param $param 27 */ 28 public function info(Doku_Event $event, $param) 29 { 30 global $USERINFO; 31 global $INPUT; 32 33 if ($event->data != 'plugin_extension') return; 34 $event->preventDefault(); 35 $event->stopPropagation(); 36 37 /** @var admin_plugin_extension $admin */ 38 $admin = plugin_load('admin', 'extension'); 39 if (!$admin->isAccessibleByCurrentUser()) { 40 http_status(403); 41 echo 'Forbidden'; 42 exit; 43 } 44 45 $ext = $INPUT->str('ext'); 46 if (!$ext) { 47 http_status(400); 48 echo 'no extension given'; 49 return; 50 } 51 52 /** @var helper_plugin_extension_extension $extension */ 53 $extension = plugin_load('helper', 'extension_extension'); 54 $extension->setExtension($ext); 55 56 $act = $INPUT->str('act'); 57 switch ($act) { 58 case 'enable': 59 case 'disable': 60 if(getSecurityToken() != $INPUT->str('sectok')) { 61 http_status(403); 62 echo 'Security Token did not match. Possible CSRF attack.'; 63 return; 64 } 65 66 $extension->$act(); //enables/disables 67 $reverse = ($act == 'disable') ? 'enable' : 'disable'; 68 69 $return = array( 70 'state' => $act.'d', // isn't English wonderful? :-) 71 'reverse' => $reverse, 72 'label' => $extension->getLang('btn_'.$reverse) 73 ); 74 75 header('Content-Type: application/json'); 76 echo json_encode($return); 77 break; 78 79 case 'info': 80 default: 81 /** @var helper_plugin_extension_list $list */ 82 $list = plugin_load('helper', 'extension_list'); 83 header('Content-Type: text/html; charset=utf-8'); 84 echo $list->makeInfo($extension); 85 } 86 } 87 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body