devel:menus:example
Различия
Показаны различия между двумя версиями страницы.
| devel:menus:example [2023/08/17 13:11] – создано vladpolskiy | devel:menus:example [Дата неизвестна] (текущий) – удалено - внешнее изменение (Дата неизвестна) 127.0.0.1 | ||
|---|---|---|---|
| Строка 1: | Строка 1: | ||
| - | ~~NOTOC~~ | ||
| - | ===== The Event Handler ===== | ||
| - | |||
| - | <file php action.php> | ||
| - | |||
| - | <?php | ||
| - | |||
| - | /** | ||
| - | * Действие по добавлению кнопки DW Edit в меню страницы | ||
| - | * Позволяет напрямую переключаться в родной редактор «Докувики». | ||
| - | * без предварительного выхода из ckeditor | ||
| - | * @author Майрон Тернер < | ||
| - | */ | ||
| - | |||
| - | if (!defined(' | ||
| - | { | ||
| - | 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(' | ||
| - | | ||
| - | | ||
| - | | ||
| - | } | ||
| - | else if(in_array(' | ||
| - | $this-> | ||
| - | $this-> | ||
| - | } | ||
| - | } | ||
| - | |||
| - | function register(Doku_Event_Handler $controller) | ||
| - | { | ||
| - | | ||
| - | | ||
| - | /* discontinued/ | ||
| - | | ||
| - | | ||
| - | | ||
| - | $this,' | ||
| - | | ||
| - | } | ||
| - | |||
| - | | ||
| - | public function addsvgbutton(Doku_Event $event) { | ||
| - | /* если это не страница ИЛИ ckgedit/ | ||
| - | if($event-> | ||
| - | |||
| - | // получить имя кнопки из включенного в данный момент плагина ckg_* | ||
| - | $btn = $this-> | ||
| - | | ||
| - | | ||
| - | [new \dokuwiki\plugin\dwedit\MenuItem($btn)]); | ||
| - | } | ||
| - | | ||
| - | function dwedit_action_link(& | ||
| - | { | ||
| - | /* | ||
| - | код идет сюда для протокола предыдущего пункта меню | ||
| - | */ | ||
| - | } | ||
| - | } | ||
| - | |||
| - | </ | ||
| - | |||
| - | ===== The Menu Item ===== | ||
| - | |||
| - | <code php Menuitem.php> | ||
| - | <?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 | ||
| - | |||
| - | /** @var string icon file */ | ||
| - | protected $svg = __DIR__ . '/ | ||
| - | |||
| - | /** | ||
| - | * MenuItem constructor. | ||
| - | * @param string $btn_name (can be passed in from the event handler) | ||
| - | */ | ||
| - | public function __construct($btn_name = "" | ||
| - | parent:: | ||
| - | global $REV, $INFO; | ||
| - | |||
| - | | ||
| - | $this-> | ||
| - | | ||
| - | | ||
| - | if($REV) $this-> | ||
| - | | ||
| - | /*switching over to the native dw editor rquires | ||
| - | two additional http paramters */ | ||
| - | $this-> | ||
| - | $this-> | ||
| - | | ||
| - | // use alternate icon if user does not have edit permission | ||
| - | if ($INFO[' | ||
| - | $this-> | ||
| - | } | ||
| - | } | ||
| - | |||
| - | /** | ||
| - | * Get label from plugin language file | ||
| - | * | ||
| - | * @return string | ||
| - | */ | ||
| - | public function getLabel() { | ||
| - | if($this-> | ||
| - | /* | ||
| - | if the button name has not been set up in the constructor | ||
| - | you can get it now. | ||
| - | */ | ||
| - | $hlp = plugin_load(' | ||
| - | return $hlp-> | ||
| - | |||
| - | | ||
| - | } | ||
| - | } | ||
| - | |||
| - | </ | ||
| - | |||
| - | |||
| - | ===== Attaching a Javascript Url to link or button===== | ||
| - | <code php> | ||
| - | <?php | ||
| - | |||
| - | namespace dokuwiki\plugin\overlay; | ||
| - | |||
| - | use dokuwiki\Menu\Item\AbstractItem; | ||
| - | |||
| - | /** | ||
| - | * Class MenuItem | ||
| - | * | ||
| - | * Implements the overlay button for DokuWiki' | ||
| - | * | ||
| - | * @package dokuwiki\plugin\overlay | ||
| - | */ | ||
| - | class MenuItem extends AbstractItem { | ||
| - | |||
| - | /** @var string do action for this plugin */ | ||
| - | protected $type = ''; | ||
| - | private | ||
| - | |||
| - | /** @var string icon file */ | ||
| - | | ||
| - | /** | ||
| - | * MenuItem constructor. | ||
| - | * @param string $btn_name (can be passed in from the event handler) | ||
| - | */ | ||
| - | public function __construct($btn_name = "" | ||
| - | | ||
| - | | ||
| - | | ||
| - | $this-> | ||
| - | } | ||
| - | } | ||
| - | |||
| - | /** | ||
| - | * Get label from plugin language file | ||
| - | * @return string | ||
| - | */ | ||
| - | public function getLabel() { | ||
| - | if($this-> | ||
| - | $hlp = plugin_load(' | ||
| - | return $hlp-> | ||
| - | } | ||
| - | | ||
| - | public function getLink() { | ||
| - | return ' | ||
| - | } | ||
| - | } | ||
| - | </ | ||
devel/menus/example.1692267097.txt.gz · Последнее изменение: — vladpolskiy
