great code, works like a charm. I had a go with it yesterday and changed/added some things that might be useful for other people too (didn't post last night, page was in maintenence mode):
- urlencode of realm, guildname und charname, and armory.wow-europe.com (already mentioned, possibly add a config file that asks if the realm is US or EU, didnt get around to that yet).
- password protection: I just shamelessly copy&pasted the password protection from siggen since it asks for the admin password.
- optionally updating a single player:
Added following code into the index.php:
- Code: Select all
if (isset($_REQUEST['syncplayer'])) {
synchPlayer(null, $_REQUEST['syncplayer']);
} else {
... password protection ...
... guild update ...
}
then added a icon before the player name like in
this thread that points to addon.php?roster_addon_name=ArmorySynch&syncplayer=Playername Now players can sync single chars by themself, or I can sync the whole guild (Syncing single chars is preferred since guild snycing overwrites charprofiler uploaded data).
- Since we have around 280 members, grabbing the iteminfo for each char was resulting in a major performance hit. I replaced the second "getArmoryContent" call in the function "parseEquipment" with following code. It's of course not as nice as a real tooltip, but it's pretty close, and it saves you one http request per item. (if a member complains, he can always use charprofiler :p
Original Code
functions.parsing.php - around line 87
- Code: Select all
$item["Tooltip"] = getArmoryContent("item-tooltip.xml", "i=" . $equipmentItem->id . "&r=" . $player["Server"] . "&n=". $player["Name"] ."&lang=" . $player["Locale"], "table", false);
$item["Tooltip"] = trim(str_replace("\n\n", "\n", str_replace("<br />", "\n", strip_tags(nl2br($item["Tooltip"]), "<br>"))));
Modified Code
- Code: Select all
$item["Tooltip"] = $item["Name"]."<br />\n";
$spelltrigger[0]='Use: ';
$spelltrigger[1]='Equip: ';
$spelltrigger[2]='Chance on hit: ';
foreach ($armoryItem->itemTooltip->properties as $key => $value) {
if ($key > 7 ) {
switch ($value) {
case 'equipData':
$tmpdata = $armoryItem->itemTooltip->$value->subclassName->_CDATA;
if (trim($tmpdata) != '') $item["Tooltip"] .= ucfirst(strtolower($tmpdata))."<br />";
break;
case 'requiredLevel':
$tmpdata = $armoryItem->itemTooltip->$value->_CDATA;
if (trim($tmpdata) != '') $item["Tooltip"] .= 'Requires Level '.$tmpdata."<br />";
break;
case 'spellData':
if (is_array($armoryItem->itemTooltip->spellData->spell)) {
foreach ($armoryItem->itemTooltip->spellData->spell as $value) {
$tmpdata = $value->desc->_CDATA;
if (trim($tmpdata) != '') $item["Tooltip"] .= $spelltrigger[$value->trigger->_CDATA].$tmpdata."<br />";
}
} else {
$tmpdata = $armoryItem->itemTooltip->spellData->spell->desc->_CDATA;
if (trim($tmpdata) != '') $item["Tooltip"] .= $spelltrigger[$armoryItem->itemTooltip->spellData->spell->trigger->_CDATA].$tmpdata."<br />";
}
break;
default:
$tmpdata = $armoryItem->itemTooltip->$value->_CDATA;
if (trim($tmpdata) != '') {
if (strstr($value,'bonus')) {
$value = substr($value, 5);
}
if (trim($tmpdata) != '') $item["Tooltip"] .= '+'.$tmpdata.' '. ucfirst(strtolower($value))."<br />";
}
}
}
}
It just takes the info and tries to make a nice tooltip out of it, would be shorter if the spelldata wasn't such a pain.
TODO: Enchants appear with two "+" as a prefix in the tooltips, didnt' get around to fixing that before I went to bed, can be easily checked and fixedwith a strstr()
Hope the posting was useful for someone. If anyone wants to have a look:
http://www.sun-tzu.info/roster/
Edit: fixed indents in php code