FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » Adding FUDcode tags for (WoW) ItemStats
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Adding FUDcode tags for (WoW) ItemStats [message #36426] Thu, 22 March 2007 23:45 Go to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
Working Code at the End of This Thread. The popup item descriptions also work.

original discussion in which I was seeking assistance with implementing this patch

I am attempting to integrate some software into the forums and the only thing I think I really need is to edit post_proc.inc.t and another file having to do with editing (replacing the html code with its FUDcode counterpart). I have a few questions regarding this task.

First, I thought I completed the code in post_proc.inc.t to allow the use of a new tag, but it does not create the end_tag like I thought it should. Why is it giving me a [/notag] instead? I will include the code below.

Secondly, which file do I need to modify in order to convert the html back to FUDcode for editing?

Thirdly, where is the data between the tags stored in case I wish to modify it? For instance, if the user provides an index number between the tags, I want the number replaced with an associated name.

Lastly, the javascript is nonfunctional. Is it being hindered in any way? If so, what must I do to make it work? Note that I have included the referenced stylesheet and the javascript in the header. I confirmed this with firebug.

removed code to prevent confusion

[Updated on: Sat, 28 April 2007 21:35]

Report message to a moderator

Re: Adding FUDcode tags [message #36506 is a reply to message #36426] Mon, 26 March 2007 23:31 Go to previous messageGo to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
*bump* Anyone know anything about this?
Re: Adding FUDcode tags [message #36578 is a reply to message #36426] Sun, 01 April 2007 08:19 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
you have to add it in the end of the file also

Re: Adding FUDcode tags [message #36720 is a reply to message #36578] Mon, 02 April 2007 16:15 Go to previous messageGo to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
Thanks.It looks like this might take care of the notag issue.

[Updated on: Mon, 02 April 2007 16:18]

Report message to a moderator

Re: Adding FUDcode tags [message #36721 is a reply to message #36720] Mon, 02 April 2007 17:26 Go to previous messageGo to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
Okay, I have tested my code further and found that it replaces all sets of item tags with the last one in post. If I include four item tags, the first three will be removed. Any thoughts?

Update: This was resolved. See final message with code for details.

removed code to prevent confusion


[Updated on: Sat, 28 April 2007 21:35]

Report message to a moderator

Re: Adding FUDcode tags [message #36729 is a reply to message #36426] Mon, 02 April 2007 23:46 Go to previous messageGo to next message
angryowl   United States
Messages: 7
Registered: October 2006
Karma: 0
Junior Member
Dirty post removed from thread starter's clean thread. Cross post removed since that's bad forum etiquette.

For a fast and simple solution that works go here:

http://fudforum.org/forum/index.php?t=msg&th=6298&start=6&

For a solution that hasn't yet been posted but is much more efficient and FUDforum friendly, please continue reading and hope that his patch gets posted some day.

[Updated on: Tue, 03 April 2007 22:46]

Report message to a moderator

Re: Adding FUDcode tags [message #36730 is a reply to message #36426] Tue, 03 April 2007 05:27 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
And if the user would go back and EDIT his post, will your code here above parse stuff back into [item] or will it display <javascript jadda yadda blaha lah 23 45 89 82314982> etc etc? =)

Re: Adding FUDcode tags [message #36733 is a reply to message #36730] Tue, 03 April 2007 13:59 Go to previous messageGo to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
[Update: Yes, to his credit, his code is written in such a way that the server never stores anything other than the open and close item tags and that which they contain. Javascript is used to modify how it is displayed to the client. While that may work in most cases, it is left up to the client to support it. My code, therefore, stores the html formatting and strips it when the post is opened for editing.]

removed code to prevent confusion


It may be ugly, but it works for me.

There is, however, the nagging issue of the first part of my code only working on one set of tags, the last set in the post. All others are removed. It would seem that my code is being greedy. How can I make it not so greedy?

angryowl - While I appreciate your having a patch for this already, I wanted to let fud do its own parsing to reduce the overhead cost of running a second parsing routine. Thus I decided to rewrite the routine you called and drop it into post_proc. Also, I don't appreciate your having dirtied up my post with a duplicate of your patch. Next time please make a link to your post instead. In fact, it would be nice if you did that anyway.

[Updated on: Sat, 28 April 2007 21:41]

Report message to a moderator

Re: Adding FUDcode tags [message #36734 is a reply to message #36730] Tue, 03 April 2007 22:37 Go to previous messageGo to next message
angryowl   United States
Messages: 7
Registered: October 2006
Karma: 0
Junior Member
Ernesto wrote on Tue, 03 April 2007 01:27

And if the user would go back and EDIT his post, will your code here above parse stuff back into [item] or will it display <javascript jadda yadda blaha lah 23 45 89 82314982> etc etc? =)


In all of my tests, it shows up again as [item] blah blah [/item ] because it never gets stored as anything but [item]. The Javascript is generated AFTER the contents of the message are pulled out of the database when the drawmsg.php runs.

So fancy regex isn't required. All of the floating text work is done at draw time, not at store time.

Thank you, drive through.

[Updated on: Tue, 03 April 2007 22:38]

Report message to a moderator

Re: Adding FUDcode tags [message #36735 is a reply to message #36733] Tue, 03 April 2007 22:42 Go to previous messageGo to next message
angryowl   United States
Messages: 7
Registered: October 2006
Karma: 0
Junior Member
Quote:


angryowl - While I appreciate your having a patch for this already, I wanted to let fud do its own parsing to reduce the overhead cost of running a second parsing routine. Thus I decided to rewrite the routine you called and drop it into post_proc. Also, I don't appreciate your having dirtied up my post with a duplicate of your patch. Next time please make a link to your post instead. In fact, it would be nice if you did that anyway.



Are you insane?

I dirtied up your post? I posted a solution that the majority of FUDforum users can do with very little effort and very little understanding of the underpinnings of the templating system, and you call it dirtying?

Dude, I bow to your FUDforum template system mightiness. I don't pretend to know how the system works. This forum is called "Code Hacks" and that's what I did, a HACK. It just happens to be an extremely useful hack for people trying to do what I did who don't care about multiple parsing routines for text or dirty solutions.

Some thanks I get for hours of forehead pinching exertion.
Re: Adding FUDcode tags [message #36736 is a reply to message #36735] Tue, 03 April 2007 22:55 Go to previous messageGo to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
Thank you. For the record, I never said I had a solution for the masses. If you will notice, my post began as a request for assistance. I am working on this as a little pet project. Also, while your solution may work in most situations, it does require that javascript be enabled for it to function. Relying on client-side scripting for an important feature such as this is not necessarily a good thing. Thank you for fixing the thread and thank you for posting your code hack. I am certain people are quite happy with it. I, however, am happy coding something of my own as a learning venture. When I have completed this, I will make note of it in the first post and provide a full patch. I hope you will come to understand my point of view as I do understand yours.

[Updated on: Tue, 03 April 2007 23:05]

Report message to a moderator

Re: Adding FUDcode tags [message #36740 is a reply to message #36736] Wed, 04 April 2007 03:30 Go to previous messageGo to next message
angryowl   United States
Messages: 7
Registered: October 2006
Karma: 0
Junior Member
Man, it's hard to be offended by someone so level headed and equivocal. I guess I was sort of shocked by your initial response, thinking that maybe I had something you might want and was greeted with criticism and suspicion. I'm all for code exploration and learning to expand understanding. This is my first foray into PHP and Javascript and the FUDforum templating system so it was all a crash course in brain surgery for me. I was pleased that I not only worked up a solution, but could reduce it to a very small delta and retain all of the functionality.

So forgive my inflammatory tone. I'm clearly picking the right fight with the wrong guy. Cool
Re: Adding FUDcode tags [message #36781 is a reply to message #36740] Mon, 09 April 2007 20:15 Go to previous messageGo to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
I've played around with this for a while now and I can't seem to figure out why it replaces all item tags with the last one in post, leaving only the one. I thought the containing function was called for each set of tags. Perhaps my regexp is too greedy? Any thoughts?
Re: Adding FUDcode tags [message #36886 is a reply to message #36781] Sun, 15 April 2007 23:08 Go to previous messageGo to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
The item tags and the popup item descriptions are now functional. I will consider adding support for the item icons at a later time.

See last post for updated patch


--- header.tmpl.dist    2007-04-15 17:13:57.000000000 -0600
+++ header.tmpl 2007-04-15 17:17:29.000000000 -0600
@@ -17,6 +17,8 @@
 <BASE HREF="{FULL_ROOT}">
 <script language="javascript" src="lib.js" type="text/javascript"></script>
 <link rel="StyleSheet" href="{THEME_ROOT}/forum.css" type="text/css" media="screen" title="Default FUDforum Theme">
+<link rel="stylesheet" href="http://www.faevictus.org/itemstats/templates/itemstats.css" type="text/css">
+<script type="text/javascript" src="http://www.faevictus.org/itemstats/overlib/overlib.js"><!-- overLIB (c) Erik Bosrup --></script>
 </head>
 <body>
 <table class="wa" border="0" cellspacing="3" cellpadding="5"><tr><td class="ForumBackground">

[Updated on: Thu, 19 March 2009 08:21]

Report message to a moderator

Re: Adding FUDcode tags [message #38573 is a reply to message #36886] Wed, 15 August 2007 19:43 Go to previous messageGo to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
Added the following patch to the code block above. This will filter out the onmouseover and onmouseout elements that I previously overlooked.
See last post for updated patch



Also note that some items do not display correctly, e.g., Tome of Conjured Food VIII. It breaks the rendering of the post. While I'm not certain why this happens, simply removing the tags from the items that are broken will resolve this.

[Updated on: Thu, 19 March 2009 08:22]

Report message to a moderator

Re: Adding FUDcode tags [message #158767 is a reply to message #38573] Thu, 19 March 2009 08:15 Go to previous messageGo to next message
Marticus
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
Fixed a bug where missing data appears linked to previous successfully linked item. The resulting browser-parsed text looks like this. It kept wrapping items inside items until it found another good item. The outermost set of brackets is the real link to the first epic item. The rest are the offwhite colored brackets assigned to nonexistent items.
[Epic Item] - [[Not a real Item]] - [[[Another fake Item]]]


Also added support for changing bad item names to grey item instead of appearing as a standard css formatted url without brackets.

Anyway, here is the patch for a previously patched item stats system.
--- post_proc.inc.t.orig    2009-03-08 13:31:37.000000000 -0600
+++ post_proc.inc.t 2009-03-19 02:00:21.000000000 -0600
@@ -346,6 +346,10 @@
                    if (!empty($item_link) && $item_link != "") {
                        $ostr_tmp = "<a class='forumitemlink' target='_blank' href='" . $item_link . "'>";
                        $end_tag_tmp = "</a>";
+                   } else {
+                       $item_link = 'http://www.faevictus.org/itemstats/updateitem.php?item=' . urlencode(urlencode($item_name));
+                       $ostr_tmp = "<a class='forumitemlink' href='$item_link'>";
+                       $end_tag_tmp = "</a>";
                    }
                    $item_tooltip = $item_stats->getItemTooltipHtmlBB($item_info);
                    $item_color = $item_info['item_color'];


Here is the full patch to post_proc.php.t
--- post_proc.inc.t.dist    2007-04-15 17:04:24.000000000 -0600
+++ post_proc.inc.t 2009-03-19 02:52:01.000000000 -0600
@@ -323,6 +328,42 @@
                    }
                    $ostr .= '<a href="http://'.$parms.'wikipedia.com/wiki/'.$url.'" target="_blank" name="WikiPediaLink">';
                    break;
+               /* Begin WoW loot link support */
+               case 'item':
+                   include_once $GLOBALS['WWW_ROOT_DISK'].'../itemstats/itemstats.php';
+                   $item_stats = new ItemStats();
+                   $param = substr($str, $epos+1, ($cpos-$epos)-1);
+                   if (is_numeric(trim($param))) {
+                       $item_id = trim($param);
+                       $item_info = $item_stats->getItemInfoById($item_id, 1);
+                   } else {
+                       $item_name = trim($param);
+                       $item_info = $item_stats->getItemInfo($item_name, 1);
+                   }
+                   $item_name = (!empty($item_info['item_name']) && $item_info['item_name'] != "") ? $item_info['item_name'] : $item_name;
+                   $item_id = (!empty($item_info['item_id']) && $item_info['item_id'] != "") ? $item_info['item_id'] : 0;
+                   $item_link = $item_info['item_link'];
+                   if (!empty($item_link) && $item_link != "") {
+                       $ostr_tmp = "<a class='forumitemlink' target='_blank' href='" . $item_link . "'>";
+                       $end_tag_tmp = "</a>";
+                   } else {
+                       $item_link = '/itemstats/updateitem.php?item=' . urlencode(urlencode($item_name));
+                       $ostr_tmp = "<a class='forumitemlink' target='_blank' href='" . $item_link . "'>";
+                       $end_tag_tmp = "</a>";
+                   }
+                   $item_tooltip = $item_stats->getItemTooltipHtmlBB($item_info);
+                   $item_color = $item_info['item_color'];
+                   if (!empty($item_color) && $item_color != "") {
+                       $ostr_tmp = $ostr_tmp . "<span class='" . $item_color . "' " . $item_tooltip . ">[";
+                       $end_tag_tmp = "]</span>" . $end_tag_tmp;
+                   } else {
+                       $ostr_tmp = $ostr_tmp . "<span class='greyname' " . $item_tooltip . ">[";
+                       $end_tag_tmp = "]</span>" . $end_tag_tmp;
+                   }
+                   $ostr = $ostr . $ostr_tmp;
+                   $end_tag[$cpos] = $end_tag_tmp;
+                   break;
+               /* End WoW loot link support */
            }

            $str[$pos] = '<';
@@ -563,6 +611,25 @@
        $fudml = preg_replace('!<(o|u)l type="(.+?)">(.*?)</\\1l>!is', '[list type=\2]\3[/list]', $fudml);
    }

+    /* Begin WoW loot link support */
+   /* Change item links first to avoid </span> -> [/notag] problem */
+   while (preg_match('!(.+?)onmouseover="[^"]+"(.+?)!is', $fudml)) {
+       $fudml = preg_replace('!(.+?)onmouseover="[^"]+"(.+?)!is', '\1\2', $fudml);
+   }
+   while (preg_match('!(.+?)onmouseout="[^"]+"(.+?)!is', $fudml)) {
+       $fudml = preg_replace('!(.+?)onmouseout="[^"]+"(.+?)!is', '\1\2', $fudml);
+   }
+   while (preg_match('!<a class=\'forumitemlink\' target=\'_blank\' href=\'.+?\'>.+</a>!is', $fudml)) {
+       $fudml = preg_replace('!<a class=\'forumitemlink\' target=\'_blank\' href=\'.+?\'>(.+?)</a>!is', '[item]\1[/item]', $fudml);
+   }
+   while (preg_match('!<a class=\'forumitemlink\' target=\'_blank\' href=\'.+?\'>.+</a>!is', $fudml)) {
+       $fudml = preg_replace('!<a class=\'forumitemlink\' target=\'_blank\' href=\'.+?\'>(.+?)</a>!is', '[item]\1[/item]', $fudml);
+   }
+   while (preg_match('!<span class=\'.+?name\'[^>]*>\[.+?\]</span>!is', $fudml)) {
+       $fudml = preg_replace('!<span class=\'.+?name\'[^>]*>\[(.+?)\]</span>!is', '\1', $fudml);
+   }
+    /* End WoW loot link support */
+
    $fudml = str_replace(
    array(
        '<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<s>', '</s>', '<sub>', '</sub>', '<sup>', '</sup>', '<del>', '</del>',

[Updated on: Thu, 19 March 2009 09:44]

Report message to a moderator

Re: Adding FUDcode tags [message #158768 is a reply to message #158767] Thu, 19 March 2009 08:18 Go to previous message
Marticus
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
Also note, allakhazam changed their xml info engine. Please update your itemstats/config.php accordingly.

define('AKZITEMXMLPATH', 'http://wow.allakhazam.com/cluster/item-xml.pl?witem=');

Also update the itemlist_akz.xml with the latest information from http://wow.allakhazam.com/itemlist.xml because for some reason, the list isn't auto updating like it is supposed to.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: select all and deselect all in thread view [For 2.7.7]
Next Topic: Hacks for files in /src directory must get compiled before run!
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 13:15:42 GMT 2024

Total time taken to generate the page: 0.04488 seconds