* forked from post2wiki.php by riny [at] bk [dot] ru * To bookmark webpage using bookmarklet * The app will add the url, title and hightlighed text you want to the end of the content of the targeted namespace. It does not directly read/white the dokuwiki page folder. * Version 1.0 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author dodotori https://github.com/edwardcodelab **/ // TYPICAL USAGE : // Create bookmarklet as shown in the bookmarklet part below: // Change the window.open statement to reflect the location of the bookmark2wiki.php script. // Drag bookmarklet to your toolbar. // BOOKMARKLET : // javascript:Q=document.selection?document.selection.createRange().text:document.getSelection(); void(window.open('https://myserver/doku.php?do-bookmark2wiki&te='+escape(Q)+'&ur='+ escape(location.href)+'&ti='+escape(document.title),'dokuwikiadd','scrollbars=yes,resizable=yes,toolbars=yes,width=200,height=100,left=200,top=200,status=yes')); class action_plugin_bookmark2wiki extends \dokuwiki\Extension\ActionPlugin { /** @inheritDoc */ public function register(Doku_Event_Handler $controller) { $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'allowMyAction'); $controller->register_hook('TPL_ACT_UNKNOWN', 'BEFORE', $this, 'performMyAction'); } /** * FIXME Event handler for * * @param Doku_Event $event event object by reference * @param mixed $param optional parameter passed when event was registered * @return void */ public function allowMyAction(Doku_Event $event, $param) { if($event->data != 'bookmark2wiki') return; $event->preventDefault(); } public function performMyAction(Doku_Event $event, $param) { if($event->data != 'bookmark2wiki') return; $event->preventDefault(); echo''; // SETUP SECTION $namespace="new_bookmarks"; // default namespace for bookmark // POST TO WIKI $timestamp = date("Y:m:d:H:i:s"); //timestamp $wikitext=$_GET['te']; // things to log : Selected text $url=$_GET['ur']; // things to log : URL $title=$_GET['ti']; // things to log : title $string = preg_replace('/%u([0-9A-F]+)/', '&#x$1;', $title); // convert the unicode $title = html_entity_decode($string, ENT_COMPAT, 'UTF-8'); $string = preg_replace('/%u([0-9A-F]+)/', '&#x$1;', $wikitext); $wikitext = html_entity_decode($string, ENT_COMPAT, 'UTF-8'); $bookmarktext="$url"; $targeturl = DOKU_BASE."doku.php?id=".$namespace."&do=edit"; echo ''; echo ''; } }