DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:wow

This is an old revision of the document!


WoW plugin

Compatible with DokuWiki

No compatibility info given!

plugin Allow to automatic link or name extract from Wowhead or JudgeHypde with an ID

Last updated on
2009-09-04
Provides
Syntax

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with french, wow

Download and Installation

Refer to Plugins on how to install plugins manually.

The code for french name extract.

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
{
	/**
	* 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 or JudgeHypde 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';
	}
	*/
 
	/**
	* 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+(:[hj])?~~",$mode,"plugin_wow");
/*		$this->Lexer->addEntryPattern("<WoW [qisn]:\d+(:[hj])?>(?=.*</WoW>)", $mode, "plugin_wow"); */
	}
 
	/*
	function postConnect()
	{
		$this->Lexer->addExitPattern("</WoW>","plugin_wow");
	}
	*/
 
	/**
	* 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+)(?::([hj]))?~~/", $match, $matches);
		return array($state, array($matches[4], $matches[4], $matches[3]));
	}
 
	/**
	* 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;
			$name = getName($type, $id, $site);
		}
		return false;
	}
 
	function getName($type, $id, $site = "w")
	{
		$page = "http://";
		switch ( $site )
		{
			case "j" :
				$page .= "worldofwarcraft.judgehype.com/index.php?page=bc-";
				switch ( $type )
				{
					case "q" :
						$page .= "quete";
						break;
					case "i" :
						$page .= "objs";
						break;
					case "s" :
						$page .= "sorts";
						break;
					case "n" :
						$page .= "pnjs";
						break;
				}
				$page .= "&w=";
				break;
			default :
				$page .= "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 .= "=";
		}
		$page .= $id;
 
		require_once(DOKU_INC.'/inc/HTTPClient.php');
		$http = new DokuHTTPClient();
		$pageText = http->get($page);
 
		switch ( $site )
		{
			case "j" :
				preg_match('#<td class="contenu"><font class="titre">&nbsp;<b><font size="3">([^<]+)</font></b><br>&nbsp;[^<]+</font></td>#', $pageText, $matches);
				$name = $matches[1];
				break;
			default :
				preg_match('#<title>(\w+) - (?:Sort|Quête|PNJ|Objet) - World of Warcraft</title>#', $pageText, $matches);
				$name = $matches[1];
		}
 
		return $name;
	}
}
?>
plugin/wow.1252057231.txt.gz · Last modified: 2009-09-04 11:40 by andi

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