* @brief CSS-based one-word toltips * @version 1.8 * * This plugin allows to insert "tooltips" in DokuWiki text, so that * hovering the mouse over the mrked text will reveal the tooltip. * The wikitext that composes the tooltip is parsed for basic * formatting only (underlines, italics and bolds). Otherwise, * the plugin is perfectly usable. * This plugin uses CSS only; no JavaScript or server side help * (beyond the actual tag parsing) is used to harm any animal, * in any way. * * For a live demo check instructions in the lugin page. * * Greetings. * - Luis Machuca Bezzaza ('ryan.chappelle' at the Wiki) */ if(!defined('DW_LF')) define('DW_LF',"\n"); if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); class syntax_plugin_tooltip_short extends DokuWiki_Syntax_Plugin { function getInfo() { return array ( 'author' => 'Luis Machuca Bezzaza', 'email' => 'luis.machuca [at] gulix.cl', 'date' => @file_get_contents(DOKU_PLUGIN . 'tooltip/VERSION'), 'name' => 'Tooltip Plugin ('. $this->getLang('comp.short'). ')', 'desc' => $this->getLang('descr.short'). ': {!word:description}}.', 'url' => 'http://www.dokuwiki.org/plugin:tooltip', ); } function getType() { return 'formatting'; } function getAllowedTypes() { return array('substition','disabled','formatting'); } function getPType() { return 'normal'; } function getSort() { return 400; } // get by exp function connectTo($mode) { $this->Lexer->addEntryPattern( '\{\![^:]+:(?=.*?\}\})', $mode, 'plugin_tooltip_short' ); } function postConnect() { $this->Lexer->addExitPattern( '\}\}', 'plugin_tooltip_short'); } function handle($match, $state, $pos, &$handler) { $data= array(); $data['state']= $state; switch ($state) { case DOKU_LEXER_ENTER: { $match= substr($match, 2, -1); $data['mark']= $match; break; } case DOKU_LEXER_UNMATCHED: { $data['content']= $match; break; } } // end switch ($state) return $data; } // end function function render($mode, &$renderer, $data) { static $counter= 0; $state= $data['state']; $style= "tooltip_inline"; $mark= $data['mark']; $content= $data['content']; if($mode == 'xhtml') { /* let's do the jon thingie, that is, create the HTML code that reveals the tooltip */ switch ($state) { case DOKU_LEXER_ENTER: { $renderer->doc.= ''; $renderer->doc.= $renderer->_xmlEntities($mark); $renderer->doc.= ''; break; } case DOKU_LEXER_UNMATCHED: { $renderer->doc.= $renderer->_xmlEntities($content); break; } case DOKU_LEXER_EXIT: { $renderer->doc.= ' '; $renderer->doc.= ''. DW_LF; break; } } // end switch return true; } // end if (xhtml) else if ($mode == 'text') { // simple for the plaintext renderer (for things like search) switch ($state) { case DOKU_LEXER_ENTER: { $renderer->doc.= $mark. ' '; break; } case DOKU_LEXER_UNMATCHED: { $renderer->doc.= '[Tooltip: '. $content. '] '; break; } case DOKU_LEXER_EXIT: { break; } } // end switch return true; } // end if (text) // no more renderers return false; } }