1<?php 2 3// must be run within Dokuwiki 4 5if(!defined('DOKU_INC')) die(); 6 7class action_plugin_ireadit_move extends DokuWiki_Action_Plugin { 8 9 /** 10 * Registers a callback function for a given event 11 * 12 * @param Doku_Event_Handler $controller DokuWiki's event controller object 13 * @return void 14 */ 15 public function register(Doku_Event_Handler $controller) { 16 $controller->register_hook('PLUGIN_MOVE_PAGE_RENAME', 'AFTER', $this, 'handle_move', true); 17 } 18 19 /** 20 * Renames all occurances of a page ID in the database 21 * 22 * @param Doku_Event $event event object by reference 23 * @param bool $ispage is this a page move operation? 24 */ 25 public function handle_move(Doku_Event $event, $ispage) { 26 $old = $event->data['src_id']; 27 $new = $event->data['dst_id']; 28 29 try { 30 /** @var \helper_plugin_ireadit_db $db_helper */ 31 $db_helper = plugin_load('helper', 'ireadit_db'); 32 $sqlite = $db_helper->getDB(); 33 } catch (Exception $e) { 34 msg($e->getMessage(), -1); 35 return; 36 } 37 38 //move revision history 39 $sqlite->query('UPDATE ireadit SET page=? WHERE page=?', $new, $old); 40 } 41 42} 43