* @copyright 2007 Ilya Lebedev */ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_virtualkeyboard extends DokuWiki_Action_Plugin { /** * Flags to embed loader, if keyboard has been embedded somewhere, except the edit page * * @type Boolean * @access private */ var $injectKeyboard = false; /** * return some info */ function getInfo(){ return array( 'author' => 'Ilya Lebedev', 'email' => 'ilya@lebedev.net', 'date' => '$Date: 2007-01-04 05:08:26 +0300 (Чтв, 04 Янв 2007) $', 'name' => 'Virtual Keyboard', 'desc' => 'Adds the VirtualKeyboard control to the edit form.', 'url' => 'http://wiki.splitbrain.org/plugin:virtualkeyboard', ); } /* * plugin should use this method to register its handlers with the dokuwiki's event controller */ function register(&$controller) { $controller->register_hook('HTML_EDITFORM_INJECTION','AFTER', $this, '_inject_keyboard'); $controller->register_hook('TPL_METAHEADER_OUTPUT','BEFORE', $this, '_inject_loader'); } /** * Inject the virtual keyboard loaders * * @author Ilya Lebedev * @param $event object target event * @param $param mixed event parameters passed from register_hook */ function _inject_loader (&$event, $param) { global $INFO; global $ACT; // inject loader and styles $js_edit = ($ACT=='edit' || $ACT=='preview' || $ACT=='recover' || $ACT=='wordblock' ) ? 1 : 0; $js_write = ($INFO['writable']) ? 1 : 0; if ($js_edit && $js_write){ $this->injectKeyboard = true; $event->data['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', 'src' => DOKU_BASE.'lib/plugins/virtualkeyboard/vk/vk_loader.js' ,'_data'=>''); $event->data['link'][] = array( 'rel'=>'stylesheet', 'type'=>'text/css', 'title'=>'VirtualKeyboard' ,'href'=>DOKU_BASE.'lib/plugins/virtualkeyboard/vk/keyboard/keyboard.css' ,'_data'=>''); } } /** * Inject the virtual keyboard itself * * @author Ilya Lebedev * @param $event object target event * @param $param mixed event parameters passed from register_hook */ function _inject_keyboard (&$event, $param) { global $INFO; if (!$event->data['writable'] || !$this->injectKeyboard) return; //
//
// VirtualKeyboard //
//
echo <<< EOQ
VirtualKeyboard:
EOQ; } }