Translations of this page?:
Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
<?php /** * Action adding DW Edit button to page menu * Makes it possible to switch directly into the native Dokuwiki Editor * without first switching out of the ckgeditor * @author Myron Turner <mturnerATmturnerDOTorg> */ if (!defined('DOKU_INC')) { die(); } class action_plugin_dwedit extends DokuWiki_Action_Plugin { var $ckgedit_loaded = false; var $helper; function __construct() { /* is either ckgdoku or ckgedit enabled, if so get a reference to the helper */ $list = plugin_list('helper'); if(in_array('ckgedit',$list)) { $this->ckgedit_loaded=true; $this->helper = plugin_load('helper', 'ckgedit'); } else if(in_array('ckgdoku',$list)) { $this->ckgedit_loaded=true; $this->helper = plugin_load('helper', 'ckgdoku'); } } function register(Doku_Event_Handler $controller) { $controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addsvgbutton', array()); /* discontinued/deprecdated hooks */ $controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'dwedit_action_link', array('page_tools')); $controller->register_hook('TEMPLATE_DWEDITLINK_DISPLAY', 'BEFORE', $this,'dwedit_action_link', array('user')); } public function addsvgbutton(Doku_Event $event) { /* if this is not a page OR ckgedit/ckgedoku is not active -> return */ if($event->data['view'] != 'page' || !$this->ckgedit_loaded) return; // get the button's name from the currently enabled ckg_* plugin $btn = $this->helper->getLang('btn_dw_edit'); if(!$btn) $btn = 'DW Edit'; array_splice($event->data['items'], -1, 0, [new \dokuwiki\plugin\dwedit\MenuItem($btn)]); } function dwedit_action_link(&$event, $param) { /* code goes here for previous menu item protocol */ } }
<?php namespace dokuwiki\plugin\dwedit; use dokuwiki\Menu\Item\AbstractItem; /** * Class MenuItem * * @package dokuwiki\plugin\dwedit */ class MenuItem extends AbstractItem { /** @var string do action for this plugin */ protected $type = ''; private $btn_name; /** @var string icon file */ protected $svg = __DIR__ . '/edit_pencil.svg'; /** * MenuItem constructor. * @param string $btn_name (can be passed in from the event handler) */ public function __construct($btn_name = "") { parent::__construct(); global $REV, $INFO; if($btn_name) { $this->btn_name = $btn_name; } if($REV) $this->params['rev'] = $REV; /*switching over to the native dw editor rquires two additional http paramters */ $this->params['mode'] = 'dwiki'; $this->params['fck_preview_mode'] = 'nil'; // use alternate icon if user does not have edit permission if ($INFO['perm'] < AUTH_EDIT) { $this->svg = __DIR__ . '/dwedit_view.svg'; } } /** * Get label from plugin language file * * @return string */ public function getLabel() { if($this->btn_name) return $this->btn_name; /* if the button name has not been set up in the constructor you can get it now. */ $hlp = plugin_load('action', 'dwedit'); return $hlp->getLang('btn_dw_edit'); } }
<?php namespace dokuwiki\plugin\overlay; use dokuwiki\Menu\Item\AbstractItem; /** * Class MenuItem * * Implements the overlay button for DokuWiki's menu system * * @package dokuwiki\plugin\overlay */ class MenuItem extends AbstractItem { /** @var string do action for this plugin */ protected $type = ''; private $btn_name; /** @var string icon file */ protected $svg = __DIR__ . '/screen-frame.svg'; /** * MenuItem constructor. * @param string $btn_name (can be passed in from the event handler) */ public function __construct($btn_name = "") { parent::__construct(); $this->params['do']=""; if($btn_name) { $this->btn_name = $btn_name; } } /** * Get label from plugin language file * @return string */ public function getLabel() { if($this->btn_name) return $this->btn_name; $hlp = plugin_load('action', 'overlay'); return $hlp->getLang('btn_dw_edit'); } public function getLink() { return 'javascript:jQuery("#overlay").toggle();void(0)'; } }