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 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
{
	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',
		);
	}
 
	function getType()
	{
		return 'substition';
	}
 
	/* Optionnel
	function getAllowedTypes()
	{
		return array();
	}
	*/
 
	/* Optionnel
	function getPType()
	{
		return 'normal';
	}
	*/
 
	function getSort()
	{
		return 400;
	}
 
	function connectTo($mode)
	{
		$this->Lexer->addSpecialPattern("~~WoW [qisn]:\d+~~", $mode, "plugin_wow");
/*		$this->Lexer->addEntryPattern("<WoW [qisn]:\d+(:[hj])?>(?=.*</WoW>)", $mode, "plugin_wow"); */
	}
 
	/*
	function postConnect()
	{
		$this->Lexer->addExitPattern("</WoW>","plugin_wow");
	}
	*/
 
	function handle($match, $state, $pos, &$handler)
	{
		preg_match("#~~WoW ([qisn]):(\d+)~~#", $match, $matches);
		return array($matches[1], $matches[2], $matches[3]);
	}
 
	function render($mode, &$renderer, $data)
	{
		if( $mode == "xhtml" )
		{
			list($type, $id) = $data;
			$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;
			$page = http_get($link);
 
			preg_match('#<title>(.+) - (?:Sort|Quête|PNJ|Objet) - World of Warcraft</title>#', $page, $matches);
			//~ preg_match('#<title>([^<]+)</title>#', $pageText, $matches);
			$name = $matches[1];
 
			preg_match("#^(.+/)(?:[^/]+).(?:php|html?)$#", preg_quote($_SERVER["SCRIPT_NAME"]), $matches);
 
			$renderer->doc .= '<a href="' . $link . '"><img src="' . $matches[1] . 'lib/images/smileys/wowhead.png" alt="Wowead" />' . $name . '</a>';
			return true;
		}
		return false;
	}
}
?>
plugin/wow.1252103914.txt.gz · Last modified: 2009-09-05 00:38 by 90.2.178.187

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