<?php
// Script: Copyright 2003 Janice Heinold, jmhdesign@att.net or 
// heinold@falcon.tamucc.edu
//
// Modified for PmWiki-0.6 by Patrick R. Michaud, 23-Feb-2004.
//
// Modified for PmWiki2 by Karl Loncarek, 09-Nov-2004 (Klonk)
// Fixed a bug with numbered lists 06-Dec-2004 (Klonk)
// Fixed bug to get valid XHMTL 18-Feb-2005 (Klonk)
// Modified for PmWiki2 by Christophe BARBIER, 08-March-2005 (sorry, I love smilies)
//     Added a class (smiley) for better wiki skinning
//     Added a title for browser mozilla like  (valid XHTML I think) ;-) 
//     Added a generic markup which permit to use smiley with its filename
// By Christophe BARBIER, 21-April-2005 :
//    General smileys : regexp simplified 
//    Markup for other smileys : Fixed bug in regexp and
//     delayed after "block" section.

// To make this script work, add the following line to your config.php:
// include("local/smileys.php");

// Configuration
// By default, this script looks for the smiley images
// in a folder called "smileys" in the "pub" folder for pmwiki.
// If your smiley images are elsewhere,
// you can set the path to the folder the smileys are in.
// It should end with the name of the directory with no ending slash.
// For example, you can set:
// $SmileysFolder = "http://www.yourdomain.com/smileys/gif";

$SmileysFolder = "$PubDirUrl/smileys";

// *************************************************** 
// You shouldn't need to edit anything below this line

// Create extended wiki markup with PmWiki2 "Markup" function
Markup("happy","block","/:-\)/","<img src='$SmileysFolder/happy.gif' border='0' width='15' height='15' alt='happy smiley' title='happy smiley' class='smiley' />");
Markup("wink","block","/;-\)/","<img src='$SmileysFolder/wink.gif' border='0' width='15' height='15' alt='winking smiley' title='winking smiley' class='smiley' />");
Markup("sad","block","/:-\(/","<img src='$SmileysFolder/sad.gif' border='0' width='15' height='15' alt='frowning smiley' title='frowning smiley' class='smiley' />");
Markup("tongue","block","/:-p/","<img src='$SmileysFolder/tongue.gif' border='0' width='15' height='15' alt='laughing smiley' title='laughing smiley' class='smiley' />");
Markup("redface","block","/:-o/","<img src='$SmileysFolder/redface.gif' border='0' width='15' height='15' alt='embarrassed smiley' title='embarrassed smiley' class='smiley' />");
Markup("cool","block","/\{cool\}/","<img src='$SmileysFolder/cool.gif' border='0' width='15' height='15' alt='cool smiley' title='cool smiley' class='smiley' />");
Markup("biggrin","block","/:-D\\b/","<img src='$SmileysFolder/biggrin.gif' border='0' width='15' height='15' alt='grinning smiley' title='grinning smiley' class='smiley' />");
Markup("confused","block","/\{confused\}/","<img src='$SmileysFolder/confused.gif' border='0' width='15' height='22' alt='confused smiley' title='confused smiley' class='smiley' />");
Markup("eek","block","/\{eek\}/","<img src='$SmileysFolder/eek.gif' border='0' width='15' height='15' alt='shrieking smiley' title='shrieking smiley' class='smiley' />");
Markup("mad","block","/\{angry\}/","<img src='$SmileysFolder/mad.gif' border='0' width='15' height='15' alt='angry smiley' title='angry smiley' class='smiley' />");
Markup("rolleyes","block","/\{rolleyes\}/","<img src='$SmileysFolder/rolleyes.gif' border='0' width='15' height='15' alt='rolling eyes smiley' title='rolling eyes smiley' class='smiley' />");

## Other smilies : called with their names inside "{" and "}" : {happy}
# ">block" to force this rule to be used after the other concerning smiley (give a chance to {angry} smiley to be linked with mad.gif)
# "/\{([^\}]+?)\}/" because the regexp must not catch text like {}
Markup('smiley_icon','>block','/\{([^\}]+?)\}/',"<img src='$SmileysFolder/\$1.gif' border='0' alt='$1 smiley' title='$1 smiley' class='smiley' />");

/* Experimental, don't work, needs pathname...
Markup('smiley_icon','>block','/\{([^\}]+?)\}/e',"Smiley_Exists(\"$1\")");
function Smiley_Exists($SmileyFile) {
	global $SmileysFolder;
	#Quoted from php.net : file_exists will have trouble finding your file if the file permissions are not read enabled for 'other' when not owned by your php user.
	if (file_exists("$SmileysFolder/$SmileyFile.gif")) {
		# Numbering format needs PHP 4.0.6 or higher
#		return sprintf("<img src=\'%1\$s/%2\$s.gif\' border=\'0\' alt=$SmileyFile title=$SmileyFile class=\'smiley\' />", $SmileysFolder, $SmileyFile);
		return "Yes";
	} else {
		return "No";
	}
}
*/
?>