Permalink
Browse files

Merge pull request #232 from LarsGit223/NewActionAndMenu

Adjustments for DokuWiki's new action and menu handling/design.
  • Loading branch information...
LarsGit223 committed Mar 31, 2018
2 parents fcdbf74 + 023ad58 commit 9396d1107fe5b98e3db36d9955cc8d0673d87666
Showing with 122 additions and 0 deletions.
  1. +40 −0 MenuItemODT.php
  2. +40 −0 MenuItemODTPDF.php
  3. +25 −0 action/export.php
  4. +9 −0 menu-odt-pdf.svg
  5. +8 −0 menu-odt.svg
View
@@ -0,0 +1,40 @@
<?php
namespace dokuwiki\plugin\odt;
use dokuwiki\Menu\Item\AbstractItem;
/**
* Class MenuItemODT
*
* Implements the ODT export button for DokuWiki's menu system
*
* @package dokuwiki\plugin\odt
*/
class MenuItemODT extends AbstractItem {
/** @var string do action for this plugin */
protected $type = 'export_odt';
/** @var string icon file */
protected $svg = DOKU_INC . 'lib/plugins/odt/menu-odt.svg';
/**
* MenuItem constructor.
*/
public function __construct() {
parent::__construct();
global $REV;
if($REV) $this->params['rev'] = $REV;
}
/**
* Get label from plugin language file
*
* @return string
*/
public function getLabel() {
$hlp = plugin_load('action', 'odt_export');
return $hlp->getLang('export_odt_button');
}
}
View
@@ -0,0 +1,40 @@
<?php
namespace dokuwiki\plugin\odt;
use dokuwiki\Menu\Item\AbstractItem;
/**
* Class MenuItemODT
*
* Implements the ODT export button for DokuWiki's menu system
*
* @package dokuwiki\plugin\odt
*/
class MenuItemODTPDF extends AbstractItem {
/** @var string do action for this plugin */
protected $type = 'export_odt_pdf';
/** @var string icon file */
protected $svg = DOKU_INC . 'lib/plugins/odt/menu-odt-pdf.svg';
/**
* MenuItem constructor.
*/
public function __construct() {
parent::__construct();
global $REV;
if($REV) $this->params['rev'] = $REV;
}
/**
* Get label from plugin language file
*
* @return string
*/
public function getLabel() {
$hlp = plugin_load('action', 'odt_export');
return $hlp->getLang('export_odt_pdf_button');
}
}
View
@@ -11,6 +11,9 @@
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
use dokuwiki\Action\Exception\ActionException;
use dokuwiki\Action\Exception\ActionAbort;
/**
* Class action_plugin_odt_export
*
@@ -35,6 +38,8 @@ public function register(Doku_Event_Handler $controller) {
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'convert', array());
$controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'addbutton_odt', array());
$controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'addbutton_pdf', array());
$controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addbutton_odt_new', array());
$controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addbutton_pdf_new', array());
}
/**
@@ -91,6 +96,26 @@ public function addbutton_pdf(Doku_Event $event) {
}
}
/**
* Add 'export odt' button to page tools, new SVG based mechanism
*
* @param Doku_Event $event
*/
public function addbutton_odt_new(Doku_Event $event) {
if($event->data['view'] != 'page') return;
array_splice($event->data['items'], -1, 0, [new \dokuwiki\plugin\odt\MenuItemODT()]);
}
/**
* Add 'export odt pdf' button to page tools, new SVG based mechanism
*
* @param Doku_Event $event
*/
public function addbutton_pdf_new(Doku_Event $event) {
if($event->data['view'] != 'page') return;
array_splice($event->data['items'], -1, 0, [new \dokuwiki\plugin\odt\MenuItemODTPDF()]);
}
/***********************************************************************************
* Book export *
***********************************************************************************/
View
@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M 0.77,0 L 10.06,0 C 10.06,0 10.28,0.1 10.58,0.1 L 19.35,8.25
C 19.35,8.25 19.41,8.75 19.61,9.03 L 19.61,23.22 C 19.61,23.22 19.3,24.13 18.58,24
L 0.77,24 C 0.77,24 0.35,23.85 0,23.22 L 0,0.77 C 0,0.77 0.35,0.15 0.77,0
M 2,2 L 2,22 L 17.61,22 L 17.61,9.7 L 10,2 z
M 13.93,0 L 18.83,0 C 18.83,0 19.3,-0.1 19.61,0.77 L 19.61,5.41
C 19.61,5.41 19.3,6 18.58,5.93 L 13.67,1.29 C 13.67,1.29 13.4,0.5 13.93,0 z"/>
<text x="3" y="15" font-size="7">PDF</text>
</svg>
View
@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M 0.77,0 L 10.06,0 C 10.06,0 10.28,0.1 10.58,0.1 L 19.35,8.25
C 19.35,8.25 19.41,8.75 19.61,9.03 L 19.61,23.22 C 19.61,23.22 19.3,24.13 18.58,24
L 0.77,24 C 0.77,24 0.35,23.85 0,23.22 L 0,0.77 C 0,0.77 0.35,0.15 0.77,0
M 2,2 L 2,22 L 17.61,22 L 17.61,9.7 L 10,2 z
M 13.93,0 L 18.83,0 C 18.83,0 19.3,-0.1 19.61,0.77 L 19.61,5.41
C 19.61,5.41 19.3,6 18.58,5.93 L 13.67,1.29 C 13.67,1.29 13.4,0.5 13.93,0 z"/>
</svg>

0 comments on commit 9396d11

Please sign in to comment.