Skip to content

Commit

Permalink
Merge pull request #232 from LarsGit223/NewActionAndMenu
Browse files Browse the repository at this point in the history
Adjustments for DokuWiki's new action and menu handling/design.
  • Loading branch information
LarsGit223 committed Mar 31, 2018
2 parents fcdbf74 + 023ad58 commit 9396d11
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 0 deletions.
40 changes: 40 additions & 0 deletions MenuItemODT.php
@@ -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');
}
}
40 changes: 40 additions & 0 deletions MenuItemODTPDF.php
@@ -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');
}
}
25 changes: 25 additions & 0 deletions action/export.php
Expand Up @@ -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
*
Expand All @@ -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());
}

/**
Expand Down Expand Up @@ -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 *
***********************************************************************************/
Expand Down
9 changes: 9 additions & 0 deletions menu-odt-pdf.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions menu-odt.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9396d11

Please sign in to comment.