Adding FUDcode tags for (WoW) ItemStats [message #36426] |
Thu, 22 March 2007 23:45 |
Marticus
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 #36721 is a reply to message #36720] |
Mon, 02 April 2007 17:26 |
Marticus
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 #36730 is a reply to message #36426] |
Tue, 03 April 2007 05:27 |
Ernesto
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? =)
Ginnunga Gaming
|
|
|
Re: Adding FUDcode tags [message #36733 is a reply to message #36730] |
Tue, 03 April 2007 13:59 |
Marticus
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 |
angryowl
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 |
angryowl
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 |
Marticus
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 #36781 is a reply to message #36740] |
Mon, 09 April 2007 20:15 |
Marticus
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 |
Marticus
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 |
Marticus
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 |
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
|
|
|
|