1<?php 2/** 3 * WebDAV Action Plugin 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com> 7 * @copyright (C) 2019-2020, Giuseppe Di Terlizzi 8 */ 9 10class action_plugin_webdav extends DokuWiki_Action_Plugin 11{ 12 public function register(Doku_Event_Handler $controller) 13 { 14 $enabled_collections = explode(',', $this->getConf('collections')); 15 16 if (in_array('odt', $enabled_collections) && plugin_load('renderer', 'odt_book')) { 17 $controller->register_hook('PLUGIN_WEBDAV_WIKI_COLLECTIONS', 'BEFORE', $this, 'odtPlugin'); 18 } 19 20 if (in_array('tags', $enabled_collections) && plugin_load('helper', 'tag')) { 21 $controller->register_hook('PLUGIN_WEBDAV_WIKI_COLLECTIONS', 'BEFORE', $this, 'tagPlugin'); 22 } 23 24 if ($this->getConf('show_button')) { 25 $controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addMenu'); 26 } 27 28 $controller->register_hook('MEDIA_DELETE_FILE', 'AFTER', $this, 'deleteMeta'); 29 } 30 31 public function odtPlugin(Doku_Event $event, $param) 32 { 33 $event->data[] = new dokuwiki\plugin\webdav\core\DAV\Collection\ODT\Directory(); 34 } 35 36 public function tagPlugin(Doku_Event $event, $param) 37 { 38 $event->data[] = new dokuwiki\plugin\webdav\core\DAV\Collection\Tags\Directory(); 39 } 40 41 public function deleteMeta(Doku_Event $event) 42 { 43 $id = $event->data['id']; 44 $metafile = mediametaFN($id, '.filename'); 45 46 if (@unlink($metafile)) { 47 io_sweepNS($id, 'metadir'); 48 } 49 } 50 51 public function addMenu(Doku_Event $event) 52 { 53 if ($event->data['view'] != 'page') { 54 return; 55 } 56 57 array_splice($event->data['items'], -1, 0, [new \dokuwiki\plugin\webdav\MenuItem]); 58 } 59} 60