* * Plugin Glossary: manage forms for glossary */ 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'); require_once (dirname (__FILE__).'/../glossary.class.php'); // ============================================================ class syntax_plugin_glossary_span extends DokuWiki_Syntax_Plugin { // ============================================================ function getType () { return 'formatting'; } function getPType () { return 'normal'; } function getAllowedTypes() { return array ('formatting', 'substition', 'disabled'); } function getSort () { return 195; } function accepts ($mode) { if ($mode == substr (get_class ($this), 7)) return true; return parent::accepts ($mode); } function connectTo ($mode) { $this->Lexer->addSpecialPattern ('', $mode, 'plugin_glossary_span'); $this->Lexer->addEntryPattern ('(?=.*?)', $mode, 'plugin_glossary_span'); } function postConnect() { $this->Lexer->addExitPattern ('', 'plugin_glossary_span'); } // ============================================================ function handle ($match, $state, $pos, Doku_Handler $handler) { switch ($state) { case DOKU_LEXER_SPECIAL : $data = strtolower (trim (substr ($match, 9, -2))); return array ($state, $data); case DOKU_LEXER_ENTER: $data = strtolower (trim (substr ($match, 9, -1))); return array ($state, $data); case DOKU_LEXER_UNMATCHED : $handler->_addCall ('cdata', array ($match), $pos); return false; case DOKU_LEXER_EXIT : return array ($state, ''); } return false; } // ============================================================ function render ($mode, Doku_Renderer $renderer, $indata) { if (empty ($indata)) return false; if ($mode != 'xhtml') false; list ($state, $data) = $indata; $data = trim ($data); switch ($state) { case DOKU_LEXER_SPECIAL : $imgDir = DOKU_REL.'lib/plugins/glossary/images/'; if ($data == "help") $renderer->doc .= ''; elseif ($data == "clock") $renderer->doc .= ''; elseif ($data == "face-smile") $renderer->doc .= ''; elseif ($data == "face-sad") $renderer->doc .= ''; elseif ($data == "stop") $renderer->doc .= ''; elseif ($data == "one-way") $renderer->doc .= ''; elseif ($data == "eye") $renderer->doc .= ''; elseif ($data == "score") $renderer->doc .= ''; elseif ($data == "search") $renderer->doc .= ''; elseif (preg_match_all ("#(?.*)\s+(?definition|proposal|poll)#", $data, $dumy) > 0) { global $ID; $ns = getNS ($ID); if (count ($dumy ['ns']) > 0) { $ns = $dumy['ns'][0]; if (($ns == '*') || ($ns == ':')) $ns = ''; elseif ($ns == '.') $ns = getNS ($ID); else $ns = cleanID ($ns); } $glossary = new glossary ($this, $ns); switch ($dumy['type'][0]) { case "definition": $renderer->doc .= $glossary->getDefinitionSize (); break; case "proposal": $renderer->doc .= $glossary->getProposalSize (); break; case "poll": $renderer->doc .= $glossary->getPollSize (); break; } } break; case DOKU_LEXER_ENTER: if ($data == "word") $renderer->doc .= ''; elseif ($data == "translate") $renderer->doc .= ''; else $renderer->doc .= ''; break; case DOKU_LEXER_EXIT: $renderer->doc .= ""; break; } return true; } // ============================================================ } // syntax_plugin_GLOSSARY ?>