Smileys for Forum and Guestbook
It is a fact that people like smileys - basically because they use them all the time (in emails, forums, guestbooks and even in wikis :P ). To make one thing clear at the beginning: We did not implement a auto-search-and-replace-:)-with-a-smiley-gif function. As you found out or not while implementing with corinis, we do not take the responsibility away from the one who implements a page, we are here to allow implementation to be quick and easy, with as much freedom a possible (you can choose to have a phpbb like forum, or you may have a fully threadable forum, you may use taglibs to implement or jsp or do everything with cms templates - the freedom of choice).
So how do you get those neat smileys on your forum then? do it with java :)
When parsing a function result with Core.parseDom you get a return string (which you normally put directly on the page using out.write or <%= %>), if you want to modify the string a little to add something like smileys, you are free to do so.
get the images and put the smileys in the content
There are tons of smiley packages floating around the net on pages like http://www.phpbb-design.com or just google around. Download a package and put them in your images folder (I put them in iamges/smiley/...).
In the code below I used the official phpbb smiley pack (and only a few to give you the right hint).
All you need to do now is put this in your jsp that displays the forum/guestbook/... and modify your output function a little bit:
<%! // search for smileys String putsmile (String text) { StringBuffer out = new StringBuffer(text.length()); for (int i=0; i < text.length()-2; i++) { char c = text.charAt(i); char c2 = text.charAt(i+1); char c3 = text.charAt(i+2); int skip = 0; if (c2 == '-') { c2 = c3; skip++; } switch(c) { case ':': i+= skip + 1; switch(c2) { case ')': out.append("<img src=\"images/smiley/icon_smile.gif\" alt=\":)\"/>"); break; case '(': out.append("<img src=\"images/smiley/icon_sad.gif\" alt=\":(\"/>"); break; case 'P': case 'p': out.append("<img src=\"images/smiley/icon_razz.gif\" alt=\":P\"/>"); break; case 'D': out.append("<img src=\"images/smiley/icon_biggrin.gif\" alt=\":D\"/>"); break; case '|': out.append("<img src=\"images/smiley/icon_neutral.gif\" alt=\":|\"/>"); break; default: out.append(c); i-= skip + 1; } break; case ';': i+= skip + 1; switch(c2) { case ')': out.append("<img src=\"images/smiley/icon_wink.gif\" alt=\";)\"/>"); break; default: out.append(c); i-= skip + 1; } break; case 'B': i+= skip + 1; switch(c2) { case ')': out.append("<img src=\"images/smiley/icon_cool.gif\" alt=\"B)\"/>"); break; default: out.append(c); i-=skip + 1; } break; case '8': i+=skip + 1; switch(c2) { case '|': out.append("<img src=\"images/smiley/icon_eek.gif\" alt=\"8|\"/>"); break; default: out.append(c); i-=skip+1; } break; default: out.append(c); } } // add the last char out.append(text.charAt(text.length()-2)); out.append(text.charAt(text.length()-1)); return out.toString(); } %>
You can then include this function in your output:
... <%=putsmile(core.parseDom(forum.getEntries(), "getPostings.xsl")))%> ...
and you are ready to go...
