date('YmdHi', $cgWoWItem_version + 3600), 'name' => 'WoWItem', 'author' => '[http://wow.curse.com/members/egingell.aspx Eric Gingell]', 'url' => 'http://wow.curseforge.com/projects/wiki-wow-item-tooltip/', 'description' => '[[Special:WoWItemInfo|More information...]]', ); $tmpWoWItem_site = ""; $wgWoWItem_aliases = array(); function wfWoWItem($input, $argv, &$parser) { global $wgWoWItem_aliases, $IP; if (!$argv['site']) { $argv['site'] = false; } if (!$argv['img']) { $argv['img'] = false; } if (!$argv['html']) { $argv['html'] = false; } static $wlwowitem; global $tmpWoWItem_site, $wgParser, $wgRequest, $WoWItem_site, $wgOut, $IP, $wgMessageCache, $wgHooks, $wgGroupPermissions, $wgSpecialPages, $wgUser; $wow = $wgRequest->getVal( 'wow' ); if ($wow) { $use = $wow; } else { $use = $WoWItem_site; } if ($argv && $argv['site']) { $use = $wgWoWItem_aliases[$argv['site']]; } if (!class_exists($use, false)) { $use = 'wowarmory'; } // echo $use . "
\n"; if (!is_object($wlwowitem[$use])) { $wlwowitem[$use] = new $use; } $wcwowitem = $wlwowitem[$use]; if ($argv && (strtolower($argv['html']) == "true" || $argv['html'] == '1')) { $func = 'getiteminfo'; } else { $func = 'showpopup'; } $no_span_tag = false; if ($argv && (strtolower($argv['img']) == "true" || $argv['img'] == '1')) { $ret = $wcwowitem->$func($input, '__IMG__'); $no_span_tag = true; } else if ($argv && is_string($argv['img']) && strlen($argv['img']) > 0) { $ret = $wcwowitem->$func($input, $argv['img']); } else { $ret = $wcwowitem->$func($input); } return (is_array($ret) ? $ret['displayitemhtml'] : ($ret ? (!$no_span_tag ? '' : '') . $ret . (!$no_span_tag ? '' : '') : htmlspecialchars('' . $input . ''))); } /** * $c is the name of your class * $aliases is an array of aliases in the form, * array( * "alias1", * "alias2", * ..., * "aliasN" * ) * you don't need to include the class name, it will be automatically added to the alias list. * The alias list will look like this: * array( * "className" => "className", * "alias1" => "className", * "alias2" => "className", * ..., * "aliasN" => "className" * ) **/ function wfWoWItem_RegisterClass($c, $aliases = array()) { global $wgWoWItem_aliases; $wgWoWItem_aliases[$c] = $c; foreach ($aliases AS $v) { $wgWoWItem_aliases[strtolower($v)] = $c; } } $cgCurseLinks = array(); function wfWoWItemSetup() { global $wgWoWItem_aliases, $wgParser, $wgRequest, $WoWItem_site, $wgOut, $IP, $wgMessageCache, $wgHooks, $wgGroupPermissions, $wgSpecialPages, $wgUser; $dp = opendir($IP . '/extensions/WoWItem/includes/sites'); while ($f = readdir($dp)) { if (!($f == '.' || $f == '..')) { require_once($IP . '/extensions/WoWItem/includes/sites/' . $f); } } if ($WoWItem_site) { $WoWItem_site = $wgWoWItem_aliases[$WoWItem_site]; } else { $WoWItem_site = 'wowarmory'; } if (!$WoWItem_site) { $WoWItem_site = 'wowarmory'; // Seems kinda redundant, but ''$WoWItem_site = "blah";'' will cause problems without this check. } $wgParser->setHook( 'item', 'wfWoWItem' ); $wgParser->ot['item'] = true; // Default system messages $wgMessageCache->addMessage('wowitem', "Wow Item Link"); $wgMessageCache->addMessage('wowitempage', "Wow Item Page"); $wgMessageCache->addMessage('wowiteminfo', "Wow Item Information"); $wgMessageCache->addMessage('wowitem-fgcolor', '#FFFFFF'); $wgMessageCache->addMessage('wowitem-bgcolor', '#000000'); $wgMessageCache->addMessage('wowitem-border', '0'); $wgMessageCache->addMessage('wowitem-opacity', '80'); $wgMessageCache->addMessage('wowitem-fadetime', '1'); $wgMessageCache->addMessage('wowitem-fadein', '6'); $wgMessageCache->addMessage('wowitem-fadeout', '6'); $wgMessageCache->addMessage('wowitem-styles', file_get_contents("$IP/extensions/WoWItem/includes/StyleA.css")); $wgGroupPermissions['sysop']['WoWItem'] = true; $wgGroupPermissions['*']['WoWItemInfo'] = true; $wgGroupPermissions['*']['WoWItemPage'] = true; $wgSpecialPages['wowitem'] = "WoWItemSpecial"; $wgSpecialPages['wowitempage'] = "WoWItemSpecialItem"; $wgSpecialPages['wowiteminfo'] = "WoWItemSpecialInfo"; $wgOut->addHTML(wfWoWItemJS()); require_once( "$IP/includes/SpecialPage.php" ); class WoWItemSpecialItem extends SpecialPage { function __construct() { SpecialPage::SpecialPage( 'WoWItemPage' ); $this->includable( true ); } function execute( $par = null ) { $fname = __CLASS__ . '::execute'; global $wgOut, $wgRequest, $wgUser, $IP, $wgWoWItem_aliases, $wgScriptPath; $skin = $wgUser->getSkin(); $this->setHeaders(); $wgOut->setPagetitle( wfMsg("wowitempage") ); // Some common checks $selfTitle = Title::makeTitle( NS_SPECIAL, 'WoWItemPage' ); if (!$s = $wgRequest->getVal( 's' )) { $s = 'wowarmory'; } $selectedNo = ' selected'; if ($h = $wgRequest->getVal( 'h' )) { $h = 1; $selectedYes = $selectedNo; $selectedNo = ''; } else { $h = ''; } $m = $wgRequest->getVal( 'm' ); $selectedOther = ' selected'; if (!$m || $m == 'other') { $o = $wgRequest->getVal( 'o' ); $m = $o; } else { $selectedSite = $selectedOther; $selectedOther = ''; } if ($i = $wgRequest->getVal( 'i' )) { if (!$wgWoWItem_aliases[$s]) { $s = 'wowarmory'; } $wgOut->setPagetitle( $i ); $linkback = "{{fullurl:Special:{$selfTitle->gettext()}}}&i=" . urlencode($i) . "&s=$s&h=$h&m=" . urlencode($m); $wgOut->addwikitext( "$i" ); $wgOut->addwikitext("

$linkback

"); } $wgOut->addhtml('
'); $wgOut->addhtml(''); $wgOut->addhtml('Site:
'); $wgOut->addhtml('Icon:
'); $wgOut->addhtml('HTML:
'); $wgOut->addhtml('Other:
'); $wgOut->addhtml('Item:
'); $wgOut->addhtml('
'); if ($i) $wgOut->addhtml('$i") .'" />'); $wgOut->addhtml('
'); } } class WoWItemSpecialInfo extends SpecialPage { function __construct() { SpecialPage::SpecialPage( 'WoWItemInfo' ); $this->includable( true ); } function execute( $par = null ) { $fname = __CLASS__ . '::execute'; global $wgOut, $wgRequest, $wgUser, $IP, $wgWoWItem_aliases, $wgScriptPath, $cgCurseLinks; $skin = $wgUser->getSkin(); $this->setHeaders(); $wgOut->setPagetitle( wfMsg("wowiteminfo") ); if (!$wgUser->isAllowed( 'WoWItemInfo' )) return; // Some common checks $selfTitle = Title::makeTitle( NS_SPECIAL, 'WoWItemInfo' ); foreach(array( 'fgcolor', 'bgcolor', 'border', 'opacity', 'fadetime', 'fadein', 'fadeout' ) AS $opt) { $o = wfMsg('wowitem-' . $opt); $$opt = wfEmptyMsg('wowitem-' . $opt, $o) ? 'At default value' : $o; } $wowitem = wfMsg('wowitem'); $wowitempage = wfMsg('wowitempage'); $wowiteminfo = wfMsg('wowiteminfo'); cfWikiItemGetCurseProjects(); $wgOut->addwikitext(<< ;[[Special:WoWItem/Convert]]:Import images from $IP/wowitemdirtemp ([[Project:Administrators|sysops]] only)
;[[Special:WoWItemPage]]:Test various settings or make a copy-n-paste snipit to paste into an article
== Parameters == ;html : Boolean true or integer 1 will display an inline popup (no mouse over required). ;img : Specify an URL to an icon to display. Any valid image will work. : Boolean true or integer 1 will either switch from plain text to icon link or add the icon to the inline popup text. ;site : Valid values: New in 7.10 :* '''allakhazam''' or '''alla''': use Allakhazam :* '''wowhead''' or '''head''': use WoWHead :* '''curse''': use Curse :* any other value: use WoWArmory == Files == * Cache files are located in $IP/wowitemcache * Icon files are located in $IP/wowitemimages == System Messages of Interest == : Current values in parentheses. Click the name to go to the associated page to edit it. ([[Project:Administrators|sysops]] only) ;[[MediaWiki:wowitem|wowitem]]: The title of [[Special:WoWItem]]. ($wowitem) ;[[MediaWiki:wowitempage|wowitempage]]: The title of [[Special:WoWItemPage]]. ($wowitempage) ;[[MediaWiki:wowiteminfo|wowiteminfo]]: The title of [[Special:WoWItemInfo]]. ($wowiteminfo) ;[[MediaWiki:wowitem-fgcolor|wowitem-fgcolor]]: The foreground color (text) of the tooltip. ($fgcolor) ;[[MediaWiki:wowitem-bgcolor|wowitem-bgcolor]]: The background color of the tooltip. ($bgcolor) ;[[MediaWiki:wowitem-border|wowitem-border]]: The border color of the tooltip. ($border) ;[[MediaWiki:wowitem-opacity|wowitem-opacity]]: The opacity (transparency) of the tooltip. ($opacity) ;[[MediaWiki:wowitem-fadetime|wowitem-fadetime]]: The fade time of the tooltip. ($fadetime) ;[[MediaWiki:wowitem-fadein|wowitem-fadein]]: The fade in time of the tooltip. ($fadein) ;[[MediaWiki:wowitem-fadeout|wowitem-fadeout]]: The fade out time of the tooltip. ($fadeout) ;[[MediaWiki:wowitem-styles|wowitem-styles]]: The CSS for the popups. WIKI ); $wgOut->addWikiText('== Other Projects by Egingell =='); foreach((array)$cgCurseLinks AS $id => $ary) { $wgOut->addwikitext('* [http://my.curse.com/downloads/wow-addons/details/'. $id .'.aspx '. $ary['name'] .'] ('. $ary['updated'] .')'); } } } class WoWItemSpecial extends SpecialPage { function __construct() { SpecialPage::SpecialPage( 'WoWItem', 'WoWItem' ); $this->includable( true ); } function execute( $par = null ) { $fname = __CLASS__ . '::execute'; global $wgOut, $wgRequest, $wgUser, $IP, $cgWoWItem_version; $skin = $wgUser->getSkin(); $this->setHeaders(); $wgOut->setPagetitle( wfMsg("wowitem") ); $do = $wgRequest->getVal( 'do' ); // Some common checks if (!$wgUser->isAllowed( 'WoWItem' )) return; $selfTitle = Title::makeTitle( NS_SPECIAL, 'WoWItem' ); $out = $wgOut->addwikitext(' == Navigation == [[Special:'. $selfTitle->gettext() .'/Test|Click here to test the settings]]
[[Special:'. $selfTitle->gettext() .'/Import|Click here to import images from a local directory]]
---- ', true); $fopen = ini_get('allow_url_fopen'); // Check for Alpha on the official site. $alphaVersion = unserialize(itemstats_read_url('http://test.wowkoe.com/wiki/extensions/WoWItem/version.txt')); $alphaAvailable = ($cgWoWItem_version != $alphaVersion); $out .= $alphaAvailable ? 'A new version is in the works or is available. Check Curse to see if there\'s a new version available or click here to download the latest alpha version ('. date('YmdHi', $alphaVersion + 3600) .').

' : ''; if ($par == "Test") { $out .= "
\nChecking directory permissions...
\n"; if (!is_dir("$IP/" . 'wowitemimages')) { $out .= "Can't find ''wowitemimages''. Trying to make it...
\n"; @mkdir("$IP/" . 'wowitemimages'); if (!is_dir("$IP/" . 'wowitemimages')) { $out .= "Can't find ''wowitemimages''. It's possible that you do not have permission to create folders on your server?
\n"; } else { $out .= "''wowitemimages'' written successfully.
\n"; } } else { $out .= "''wowitemimages'' found.
\n"; } $out .= "
\nChecking remote access...
\n"; if (function_exists('curl_init')) { $out .= "cURL exists. Trying...
\n"; $ch = curl_init('http://www.example.com'); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if (curl_exec($ch)) { $out .= "cURL success.
\n"; } else { $out .= "cURL failed.
\n"; } curl_close($ch); } elseif ($fopen == 1) { if (file_get_contents('http://www.example.com')) { $out .= "fopen success.
\n"; } else { $out .= "fopen failed.
\n"; } } else { $out .= "You cannot use this, cURL is not installed and allow_url_fopen is $fopen.
\n"; } } elseif ($par == "Version") { $confirm = $wgRequest->getVal( 'confirm' ); if ($confirm) { global $cgWoWItem_version, $cgWoWItemVersionFile; WoWItem_Recurse("$IP/extensions/WoWItem"); file_put_contents($cgWoWItemVersionFile, serialize($cgWoWItem_version)); $wgOut->addhtml(nl2br(`cd "$IP/extensions"; zip -f WoWItem`)); $wgOut->addhtml('Completed at version ' . date('YmdHi', $cgWoWItem_version + 3600) . '
'); } else { $wgOut->addhtml('Are you sure you want to do this? This is mainly for Eric, the writer of this software? '. $skin->makeLink ( 'Special:'. $selfTitle->gettext() . '/' . $par, 'Yes', 'confirm=1' )); } } elseif ($par == "Import" or $do == "Import") { $iconDir = 'wowitemimages'; $path = $wgRequest->getVal( 'path' ); $actionURL = $selfTitle->escapeLocalURL( "do=Import" ); $properDir = "wowitemdirtemp"; $out .= $wgOut->addwikitext(" == Various Places to get Icon Packs == * [http://wow.allakhazam.com/db/guides.html?guide=502 Allakhazam] * [http://www.rpgoutfitter.com/addons/wowinterface.cfm RPGOutfitter] == Notes == * Icon files must be in the proper format with the appropriate extension (.jpg, .png, etc.). ** [http://wow.allakhazam.com/ Allakhazam] uses PNG's in proper case based on texture names in-game. ** [http://www.wowarmory.com/ WoWArmory] (default probe site) uses JPG's in all lower case letters. * Icon files '''must''' be in the \"$IP/$properDir\" directory. * ZIP and TAR files can be anywhere and will be extracted to \"$IP/$properDir\" before processing. * Icon files that are not used by any item will be wasting space. * It may take a '''long time''' to process all of the files. * unzip and tar require access to the shell (see: [http://www.php.net/shell_exec shell_exec()]). ** If your PHP user doesn't have access to the shell, you should extract the files to \"$IP/$properDir\" yourself. ** tar requires extensions .tar or .tgz (.tar.gz, while a valid compressed TAR ball, is not supported because I don't have the patience to make it work). * All files will be moved regardless of type, extension, or size (even executables). Shouldn't be a problem as long as you get a real icon pack from a reputable site. * This Special page is restricted to sysops, but that does not mean it can't be hacked. == The Form == ", true); $out .= '
Path: "'. $IP .'/"
'; if ($path) { if (!file_exists($IP . '/' . $path)) { $out .= "$IP/$path is not valid!
\n"; } else { $oldTime = time(); if (!is_dir($IP . '/' . $path)) { $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); if ($extension == "zip") { `unzip "$IP/$path" -d "$IP/$properDir"`; $path = $properDir; } elseif ($extension == "tar" || $extension == "tgz") { @mkdir("$IP/$properDir"); if (!is_dir("$IP/$properDir")) { $out .= "Could not create $IP/$properDir
\n"; } else { if ($extension == "tar") { `tar -xf "$IP/$path" -C "$IP/$properDir"`; $path = $properDir; } elseif ($extension == "tgz") { `tar -xzf "$IP/$path" -C "$IP/$properDir"`; $path = $properDir; } } } else { $out .= "$IP/$path is not a valid file or the extension is not proper!
\n"; } } if (!is_dir($IP . '/' . $path)) { $out .= "$IP/$path is not valid because it is an invalid file.
\n"; } else { $out .= "$IP/$path is not valid!
\n"; @mkdir("$IP/$iconDir"); if (!is_dir("$IP/$iconDir")) { $out .= "Could not create $IP/$iconDir
\n"; } else { cfWikiItemImportFiles($IP . '/' . $path, $iconDir); @rmdir($IP . '/' . $path); if (is_dir($IP . '/' . $path)) { $out .= "No files were moved!
\n"; } else { $out .= 'Import completed in ' . (time() - $oldTime) . ' seconds.' . "
\n"; } } } } } } $wgOut->addhtml($out); } } } function cfWikiItemImportFiles($dir, $iconDir = null) { global $IP; static $icon; if (!$icon) $icon = $iconDir; $dp = opendir($dir); while($f = readdir($dp)) { if ($f == "." || $f == "..") continue; if (is_dir($dir . '/' . $f)) { cfWikiItemImportFiles($dir . '/' . $f); @rmdir($dir . '/' . $f); } else { $hash = md5(basename($f)); $dir1 = $hash{0} . $hash{1}; $dir2 = $hash{0}; @mkdir("$IP/$icon/$dir1"); @mkdir("$IP/$icon/$dir1/$dir2"); @rename($dir . '/' . $f, "$IP/$icon/$dir1/$dir2/$f"); } } } // to do: Use http://www.curseforge.com/profiles/egingell/projects/ instead and link to Curse instead of CurseForge. // still have to go to each project page, but it cuts out 1+ pages do to the CurseForge page not being pagenated. function cfWikiItemGetCurseProjects($page = null) { global $cgCurseLinks, $wgOut; $rawData = itemstats_read_url('http://www.curseforge.com/profiles/egingell/projects/'); $begin = false; $name = ""; foreach (explode("\n", $rawData) AS $line) { $line = trim($line); if (preg_match('(

(.*?)

)', $line, $match)) { $begin = true; $name = $match[1]; $cgCurseLinks[$name]['name'] = $match[2]; } if ($begin) { if (preg_match('(.*?)', $line, $match)) { $cgCurseLinks[$name]['updated'] = '\'\'\'' . date("D, M d Y H:i", $match[1]) . '\'\'\''; $begin = false; continue; } } } } function wfWoWItemJS() { global $IP; $output = '' . "\n"; $output .= '' . "\n"; return $output; } /** function WoWItem_EditPage_showEditForm_initial(&$edit) { global $wgRequest, $tmpWoWItem_site; switch ($tmpWoWItem_site) { case 'allakhazam': case 'alla': $site = 'alla'; break; case 'wowhead': case 'head': $site = 'head'; break; case 'thottbot': case 'thott': $site = 'thott'; // break; case 'wowarmory': // a little redundant, but whatever. case 'anything else!': default: $site = 'wowarmory'; break; } $wow = $wgRequest->getVal( 'wow' ); if ($wow) { $selected[$wow] = ' selected'; } else { $selected[$site] = ' selected'; } $default[$site] = ' (Default)'; $edit->editFormTextAfterWarn .= 'Use: for item links.
'; return true; } **/ ?>