DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:wow

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:wow [2009-09-04 14:10] 78.236.152.244plugin:wow [2018-06-06 09:08] (current) – [Download and Installation] Klap-in
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Allow to automatic link or name extract from Wowhead with an ID+description: Allow to automatic link and name extract from Wowhead with an ID
 author     : Sardem FF7 author     : Sardem FF7
 email      : sardemff7.pub@gmail.com email      : sardemff7.pub@gmail.com
 type       : Syntax type       : Syntax
-lastupdate : 2009-09-04 +lastupdate : 2010-03-08 
-tags       : WoW, french+tags       : embed 
 + 
 +downloadurl: http://sardemff7.free.fr/dokuwiki/wow.tar.gz
 ---- ----
  
 ===== Download and Installation ===== ===== Download and Installation =====
  
-Refer to [[:Plugins]] on how to install plugins manually. +Download and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
- +
- +
-The code for french name extract. +
- +
-<code php wow/syntax.php> +
-<?php +
-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_wow extends DokuWiki_Syntax_Plugin +  http://sardemff7.free.fr/dokuwiki/wow.tar.gz
-+
- /*+
- * Get an associative array with plugin info. +
-+
- * <p> +
- * The returned array holds the following fields: +
- * <dl> +
- * <dt>author</dt><dd>Author of the plugin</dd> +
- * <dt>email</dt><dd>Email address to contact the author</dd> +
- * <dt>date</dt><dd>Last modified date of the plugin in +
- * <tt>YYYY-MM-DD</tt> format</dd> +
- * <dt>name</dt><dd>Name of the plugin</dd> +
- * <dt>desc</dt><dd>Short description of the plugin (Text only)</dd> +
- * <dt>url</dt><dd>Website with more information on the plugin +
- * (eg. syntax description)</dd> +
- * </dl> +
- * @param none +
- * @return Array Information about this plugin class. +
- * @public +
- * @static +
- */ +
- function getInfo() +
-+
- return array( +
- 'author' => 'Sardem FF7', +
- 'email' => 'sardemff7.pub@gmail.com', +
- 'date' => '2009-09-04', +
- 'name' => 'WoW Plugin', +
- 'desc' => 'Allow to automatic link or name extract from Wowhead with an ID', +
- 'url' => 'http://www.dokuwiki.org/plugin:wow', +
- ); +
-+
- /** +
- * Get the type of syntax this plugin defines. +
-+
- * @param none +
- * @return String <tt>'substition'</tt> (i.e. 'substitution'). +
- * @public +
- * @static +
- */ +
- function getType() +
-+
- return 'substition'; +
-+
-  +
- /** +
- * What kind of syntax do we allow (optional) +
- */ +
- /* Optionnel +
- function getAllowedTypes() +
-+
- return array(); +
-+
- */ +
-  +
- /** +
- * Define how this plugin is handled regarding paragraphs. +
-+
- * <p> +
- * This method is important for correct XHTML nesting. It returns +
- * one of the following values: +
- * </p> +
- * <dl> +
- * <dt>normal</dt><dd>The plugin can be used inside paragraphs.</dd> +
- * <dt>block</dt><dd>Open paragraphs need to be closed before +
- * plugin output.</dd> +
- * <dt>stack</dt><dd>Special case: Plugin wraps other paragraphs.</dd> +
- * </dl> +
- * @param none +
- * @return String <tt>'block'</tt>+
- * @public +
- * @static +
- */ +
- /* Optionnel +
- function getPType() +
-+
- return 'normal'; +
-+
- */+
  
- /** +===== Features and Changelog =====
- * Where to sort in? +
-+
- * @param none +
- * @return Integer <tt>6</tt>+
- * @public +
- * @static +
- */ +
- function getSort() +
-+
- return 400; +
-+
-  +
-  +
- /** +
- * Connect lookup pattern to lexer. +
-+
- * @param $aMode String The desired rendermode. +
- * @return none +
- * @public +
- * @see render() +
- */ +
- function connectTo($mode) +
-+
- $this->Lexer->addSpecialPattern("~~WoW [qisn]:\d+~~", $mode, "plugin_wow"); +
-/* $this->Lexer->addEntryPattern("<WoW [qisn]:\d+(:[hj])?>(?=.*</WoW>)", $mode, "plugin_wow"); */ +
- }+
  
- /* +  [2010-03-08] Fix: the regular expression used to get names work only for French. (hope Russian work
- function postConnect() +  * [2010-03-08] Fix: little typo error (Wowead =Wowhead). 
- +  * [2009-09-22] Add a permanent cache. Will add a cache-clean option later. 
- $this->Lexer->addExitPattern("</WoW>","plugin_wow"); +  [2009-09-11] Search name of a spell, a NPC, a zone or a quest by ID, from Wowhead. 
- } +  * [2009-09-11] Can use all different Wowhead languages : French, English, German, Spanish and Russian.
- */+
  
- /** +===== Syntax Samples =====
- * Handler to prepare matched data for the rendering process. +
-+
- * <p> +
- * The <tt>$aState</tt> parameter gives the type of pattern +
- * which triggered the call to this method: +
- * </p> +
- * <dl> +
- * <dt>DOKU_LEXER_ENTER</dt> +
- * <dd>a pattern set by <tt>addEntryPattern()</tt></dd> +
- * <dt>DOKU_LEXER_MATCHED</dt> +
- * <dd>a pattern set by <tt>addPattern()</tt></dd> +
- * <dt>DOKU_LEXER_EXIT</dt> +
- * <dd> a pattern set by <tt>addExitPattern()</tt></dd> +
- * <dt>DOKU_LEXER_SPECIAL</dt> +
- * <dd>a pattern set by <tt>addSpecialPattern()</tt></dd> +
- * <dt>DOKU_LEXER_UNMATCHED</dt> +
- * <dd>ordinary text encountered within the plugin's syntax mode +
- * which doesn't match any pattern.</dd> +
- * </dl> +
- * @param $aMatch String The text matched by the patterns. +
- * @param $aState Integer The lexer state for the match. +
- * @param $aPos Integer The character position of the matched text. +
- * @param $aHandler Object Reference to the Doku_Handler object. +
- * @return Integer The current lexer state for the match. +
- * @public +
- * @see render() +
- * @static +
- */ +
- function handle($match, $state, $pos, &$handler) +
-+
- preg_match("#~~WoW ([qisn]):(\d+)~~#", $match, $matches); +
- return array($matches[1], $matches[2], $matches[3]); +
-+
-  +
- function getName($type, $id) +
-+
- $page "http://fr.wowhead.com/?"; +
- switch ( $type ) +
-+
- case "q"+
- $page ."quest"; +
- break; +
- case "i"+
- $page ."item"; +
- break; +
- case "s"+
- $page ."spell"; +
- break; +
- case "n"+
- $page ."npc"; +
- break; +
-+
- $page .= "=" . $id; +
-  +
- $pageText = http_get($page); +
-  +
- preg_match('#<title>(.+) - (?:Sort|Quête|PNJ|Objet) - World of Warcraft</title>#', $pageText, $matches); +
- //~ preg_match('#<title>([^<]+)</title>#', $pageText, $matches); +
- $name $matches[1]; +
-  +
- return $name; +
-+
-  +
- function getSiteURL($type, $id) +
-+
- $link "http://fr.wowhead.com/?"; +
- switch ( $type ) +
-+
- case "q"+
- $link ."quest"; +
- break; +
- case "i"+
- $link ."item"; +
- break; +
- case "s"+
- $link ."spell"; +
- break; +
- case "n"+
- $link .= "npc"; +
- break; +
-+
- $link .= "=" . $id; +
-  +
- $url = '<a href="' . $link . '">Wowhead</a>'; +
- return $url; +
-+
-  +
- /** +
- * Handle the actual output creation. +
-+
- * <p> +
- * The method checks for the given <tt>$aFormat</tt> and returns +
- * <tt>FALSE</tt> when a format isn't supported. <tt>$aRenderer</tt> +
- * contains a reference to the renderer object which is currently +
- * handling the rendering. The contents of <tt>$aData</tt> is the +
- * return value of the <tt>handle()</tt> method. +
- * </p> +
- * @param $aFormat String The output format to generate. +
- * @param $aRenderer Object A reference to the renderer object. +
- * @param $aData Array The data created by the <tt>handle()</tt> +
- * method. +
- * @return Boolean <tt>TRUE</tt> if rendered successfully, or +
- * <tt>FALSE</tt> otherwise. +
- * @public +
- * @see handle() +
- */ +
- function render($mode, &$renderer, $data) +
-+
- if( $mode == "xhtml"+
-+
- list($type, $id, $site) = $data; +
- if ( $site ) +
-+
- $renderer->doc .= $this->getSiteURL($type, $id, $site); +
-+
- else +
-+
- $name = $this->getName($type, $id); +
- $h = $this->getSiteURL($type, $id); +
- $renderer->doc .= $name . " (" . $h . ")"; +
-+
- return true; +
-+
- return false; +
-+
-+
-?> +
-</code>+
  
 +The syntax to use this plugin is very simple:
 +  ~~WoW type:number~~
 +With:
 +  * //type//:
 +    * **q** for a quest
 +    * **i** for an item
 +    * **s** for a spell
 +    * **n** for a NPC
 +    * **z** for a zone
 +    * **r** for a group of zone (''zones='' in Wowhead url)
 +  * //number//: the ID of the target on Wowhead (so after the ''item='' or ''quest='' or other)
plugin/wow.1252066242.txt.gz · Last modified: 2009-09-04 14:10 by 78.236.152.244

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki