<?php

/**
*<BR>
/**-----------------------------------------------
*
* Rooty, 2018 <rooty@rooty.me>
*
*
* This software is protected by copyright, please
* read the file COPYRIGHT.
* This program is distributed in the hope that it
* will be useful, but without any warranty; without
* even the implied warranty of merchantability or
* fitness for a particular purpose. Please
* read the file LICENCE.
*
* Fichier bb.php
*
*Ce fichier contient la classe bb
*
* @author Rooty <www.rooty.me|rooty@rooty.me>
* @since 2005/03/09
* @link www.rooty.me
* @version 0.3
* @package package
* @subpackage bb
* @copyright Copyright &copy; 2009-2018, Rooty
*/
if ( !defined('SYSTEM_IN') )
{
 die("Hacking attempt");
}

/**
* Classe bb
*
* Permet la gestion du wyziwig de phpBB.
* @package package
* @subpackage bb
*/
class BB
{
/**
* @var chaine
* @access private
* @desc nom du rep
*/
var $dir  = "";

/**#@+
* @access private
*/

/**
* @var chaine
* @desc nom de l'élément du formulaire
*/
var $name  = null;

/**
* @var chaine
* @desc nom du formulaire
*/
var $form  = null;

/**
* @var chaine
* @desc valeur de la chaine html
*/
var $string  = null;

/**
* @var booleen
* @desc affichage des smiles oui/non
*/
var $smile  = null;

/**#@-*/
	//
	// Constructor
	//
/**
* Constructeur de la classe bb
*
* @param chaine nom du champ
* @param chaine nom du formulaire
* @param chaine valeur de la chaine à afficher
* @param chaine vrai ou faux pour l'utilisation des icones
*/
	function bb($name, $form, $string, $smile=true)

	{

		global $CONF_LIB_PATH;



		require_once($CONF_LIB_PATH."lib/package/wysi/bb/bbcode.php");

		require_once($CONF_LIB_PATH."lib/package/wysi/bb/functions_post.php");



		$this->name		=$name;

		$this->form		=$form;

		$this->string	=$string;

		$this->smile	=$smile;

		$this->dir	=$GLOBALS["SYSTEM_TEMPLATE_PATH"].$GLOBALS['SYSTEM_TEMPLATE_DIR']."/media/";

	}



/**

* Display retourne la chaine d'affichage du wizi wig

*/

	function Display()

	{

		global $CONF_DATA_PATH;



		$name		=$this->name;

		$form		=$this->form;

		$string		=$this->string;

		$smile		=$this->smile;



		$element=$form.".".$name;

		$html='

<script language="javascript" src="'.$CONF_DATA_PATH.'data/javascript/bb.js"></script>

<style>

#data .fieldset .bbTD

{

	font-size: 11px;

	font-family: \'Microsoft Sans Serif\' , Tahoma, Arial, Verdana, Sans-Serif;

}



#data .fieldset .bbFont

{

	background-color: #efefde;

}



#data .fieldset .bbSELECT

{

	font-size: 11px;

	font-family: \'Microsoft Sans Serif\' , Tahoma, Arial, Verdana, Sans-Serif;

	vertical-align: middle;

}

#data .fieldset .bbTable

{

	width: 99%;

	background-color: #FFFFFFF;

	border: 1px solid #0000000;

	vertical-align: middle;

}

#data .fieldset .bbTable tr

{

	background-color: #FFFFFFF;

}

#data .fieldset .bbTable td

{

	background-color: #FFFFFFF;

}



</style>

<table border="0" cellpadding="0" cellspacing="0" class="bbTable">

<tr>

  <td class="bbFont">

	<table border="0" cellspacing="0" cellpadding="2">

	  <tr align="center" valign="middle">

		<td><span class="bbTD">

		  <input type="button" class="ButtonOut" name="'.$name.'addbbcode0" value=" B " style="font-weight:bold; width: 30px" onClick="bbstyle(0, '.$element.', '.$form.', \''.$name.'\')" onMouseOver="TBButtonOver(this,\''.$name.'addbbcode0\');helpline(\'b\', '.$form.'.helpline'.$name.')" onmouseout="TBButtonOut(this,\''.$name.'addbbcode0\');"	ondrag="return false;" />

		  </span></td>

		<td><span class="bbTD">

		  <input type="button" class="ButtonOut" name="'.$name.'addbbcode2" value=" i " style="font-style:italic; width: 30px" onClick="bbstyle(2, '.$element.', '.$form.', \''.$name.'\')" onMouseOver="TBButtonOver(this,\''.$name.'addbbcode2\');helpline(\'i\', '.$form.'.helpline'.$name.')" onmouseout="TBButtonOut(this,\''.$name.'addbbcode2\');"	ondrag="return false;" />

		  </span></td>

		<td><span class="bbTD">

		  <input type="button" class="ButtonOut" name="'.$name.'addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onClick="bbstyle(4, '.$element.', '.$form.', \''.$name.'\')" onMouseOver="TBButtonOver(this,\''.$name.'addbbcode4\');helpline(\'u\', '.$form.'.helpline'.$name.')" onmouseout="TBButtonOut(this,\''.$name.'addbbcode4\');"	ondrag="return false;" />

		  </span></td>

		<td><span class="bbTD">

		  <img src="'. $this->dir.'image/separator.gif" border="0">

		  </span></td>

		<td><span class="bbTD">

		  <input type="button" class="ButtonOut" name="'.$name.'addbbcode6" value="Quote" style="width: 50px" onClick="bbstyle(6, '.$element.', '.$form.', \''.$name.'\')" onMouseOver="TBButtonOver(this,\''.$name.'addbbcode6\');helpline(\'q\', '.$form.'.helpline'.$name.')" onmouseout="TBButtonOut(this,\''.$name.'addbbcode6\');"	ondrag="return false;" />

		  </span></td>

		<td><span class="bbTD">

		  <input type="button" class="ButtonOut" name="'.$name.'addbbcode8" value="Code" style="width: 40px" onClick="bbstyle(8, '.$element.', '.$form.', \''.$name.'\')" onMouseOver="TBButtonOver(this,\''.$name.'addbbcode8\');helpline(\'c\', '.$form.'.helpline'.$name.')" onmouseout="TBButtonOut(this,\''.$name.'addbbcode8\');"	ondrag="return false;" />

		  </span></td>

		<td><span class="bbTD">

		  <img src="'. $this->dir.'image/separator.gif" border="0">

		  </span></td>

		<td><span class="bbTD">

		  <input type="button" class="ButtonOut" name="'.$name.'addbbcode10" value="List" style="width: 40px" onClick="bbstyle(10, '.$element.', '.$form.', \''.$name.'\')" onMouseOver="TBButtonOver(this,\''.$name.'addbbcode10\');helpline(\'l\', '.$form.'.helpline'.$name.')" onmouseout="TBButtonOut(this,\''.$name.'addbbcode10\');"	ondrag="return false;" />

		  </span></td>

		<td><span class="bbTD">

		  <input type="button" class="ButtonOut" name="'.$name.'addbbcode12" value="List=" style="width: 40px" onClick="bbstyle(12, '.$element.', '.$form.', \''.$name.'\')" onMouseOver="TBButtonOver(this,\''.$name.'addbbcode12\');helpline(\'o\', '.$form.'.helpline'.$name.')" onmouseout="TBButtonOut(this,\''.$name.'addbbcode12\');"	ondrag="return false;" />

		  </span></td>

		<td><span class="bbTD">

		  <img src="'. $this->dir.'image/separator.gif" border="0">

		  </span></td>

		<td><span class="bbTD">

		  <input type="button" class="ButtonOut" name="'.$name.'addbbcode14" value="Img" style="width: 40px"  onClick="bbstyle(14, '.$element.', '.$form.', \''.$name.'\')" onMouseOver="TBButtonOver(this,\''.$name.'addbbcode14\');helpline(\'p\', '.$form.'.helpline'.$name.')" onmouseout="TBButtonOut(this,\''.$name.'addbbcode14\');"	ondrag="return false;" />

		  </span></td>

		<td><span class="bbTD">

		  <input type="button" class="ButtonOut" name="'.$name.'addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onClick="bbstyle(16, '.$element.', '.$form.', \''.$name.'\')" onMouseOver="TBButtonOver(this,\''.$name.'addbbcode16\');helpline(\'w\', '.$form.'.helpline'.$name.')" onmouseout="TBButtonOut(this,\''.$name.'addbbcode16\');"	ondrag="return false;" />

		  </span></td>

	  </tr>

	  <tr>

		<td colspan="12">

		  <table width="100%" border="0" cellspacing="0" cellpadding="0">

			<tr>

			  <td><span class="bbTD"> &nbsp;Couleur:

				<select class="bbSELECT" name="'.$name.'addbbcode18" onChange="bbfontstyle(\'[color=\' + this.form.'.$name.'addbbcode18.options[this.form.'.$name.'addbbcode18.selectedIndex].value + \']\', \'[/color]\', '.$element.', '.$form.', \''.$name.'\');this.selectedIndex=0;" onMouseOver="helpline(\'s\', '.$form.'.helpline'.$name.')">

				  <option style="color:black; background-color: #FAFAFA" value="#444444" class="genmed">Défaut</option>

				  <option style="color:darkred; background-color: #FAFAFA" value="darkred" class="genmed">Rouge foncé</option>

				  <option style="color:red; background-color: #FAFAFA" value="red" class="genmed">Rouge</option>

				  <option style="color:orange; background-color: #FAFAFA" value="orange" class="genmed">Orange</option>

				  <option style="color:brown; background-color: #FAFAFA" value="brown" class="genmed">Marron</option>

				  <option style="color:yellow; background-color: #FAFAFA" value="yellow" class="genmed">Jaune</option>

				  <option style="color:green; background-color: #FAFAFA" value="green" class="genmed">Vert</option>

				  <option style="color:olive; background-color: #FAFAFA" value="olive" class="genmed">Olive</option>

				  <option style="color:cyan; background-color: #FAFAFA" value="cyan" class="genmed">Cyan</option>

				  <option style="color:blue; background-color: #FAFAFA" value="blue" class="genmed">Bleu</option>

				  <option style="color:darkblue; background-color: #FAFAFA" value="darkblue" class="genmed">Bleu foncé</option>

				  <option style="color:indigo; background-color: #FAFAFA" value="indigo" class="genmed">Indigo</option>

				  <option style="color:violet; background-color: #FAFAFA" value="violet" class="genmed">Violet</option>

				  <option style="color:white; background-color: #FAFAFA" value="white" class="genmed">Blanc</option>

				  <option style="color:black; background-color: #FAFAFA" value="black" class="genmed">Noir</option>

				</select> &nbsp;Taille:<select class="bbSELECT" name="'.$name.'addbbcode20" onChange="bbfontstyle(\'[size=\' + this.form.'.$name.'addbbcode20.options[this.form.'.$name.'addbbcode20.selectedIndex].value + \']\', \'[/size]\', '.$element.', '.$form.', \''.$name.'\')" onMouseOver="helpline(\'f\', '.$form.'.helpline'.$name.')">

				  <option value="7" class="genmed">Très petit</option>

				  <option value="9" class="genmed">Petit</option>

				  <option value="12" selected class="genmed">Normal</option>

				  <option value="18" class="genmed">Grand</option>

				  <option  value="24" class="genmed">Très grand</option>

				</select>

				</span></td>

			  <td nowrap="nowrap" align="right"><span class="bbTD"><a href="javascript:bbstyle(-1, '.$element.', '.$form.', \''.$name.'\')" class="tdBB" onMouseOver="helpline(\'a\', '.$form.'.helpline'.$name.')"><font color="#000000"><b>Fermer les Balises</b></font></a></span></td>

			</tr>

		  </table>

		</td>

	  </tr>

	  <tr>

		<td colspan="12"> <span class="bbTD">

		  <input type="text" name="helpline'.$name.'" size="45" maxlength="100" style="width:590px; font-size:10px; color:#888888; background-color:#efefde; border:0px;" class="ButtonOver" value="Astuce: Une mise en forme peut être appliquée au texte sélectionné." />

		  </span></td>

	  </tr>

	  <tr>

		<td colspan="12"><span class="bbTD">

		  <textarea name=\''.$name.'\' rows="15" cols="35" wrap="virtual" style="width:590px" tabindex="3" class="post" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">'.$string.'</textarea>

		  </span></td>

	  </tr>

	</table>

	</td>';



if ($smile==true)

{

$html.='

   <td>

	  <table width="100%" border="0" cellspacing="0" cellpadding="1">

	  <tr>

		<td valign="middle" align="center"> <br />'.$this->DisplaySmile().'

		</td>

	  </tr>

	</table>

   </td>';

}

$html.='

 </tr>

</table>';



	  return $html;



	}



/**

* ReturnData : retourne les données à partir de la chaine postée

* @return chaine au format html

*/

	function ReturnData()

	{

		global $_POST, $CONF_LIB_PATH;

		$name		=$this->name;

		$form		=$this->form;

		$message	=$this->string;

		$smile		=$this->smile;

//		$message=isset($_POST[$name])?$_POST[$name]:"";

/*

		$html_on=1;

		$bbcode_on=1;

		$smilies_on=1;



		$bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';

		$preview_message = stripslashes(prepare_message(addslashes(unprepare_message($message)), $html_on, $bbcode_on, $smilies_on, $bbcode_uid));



		$preview_message = bbencode_second_pass($preview_message, $bbcode_uid);

		$preview_message = make_clickable($preview_message);



		$preview_message = $preview_message;

		$preview_message = str_replace("\n", '<br />', $preview_message);



		if ($this->smile)

		{

			$preview_message=$this->ReplaceSmile($preview_message);

		}

		return $preview_message;*/



		/* adjust include_path to include PEAR */

//		ini_set('include_path', ini_get('include_path').':'.$GLOBALS["CONF_LIB_PATH"].'lib/PEAR');



		/* require PEAR and the parser */

		require_once('PEAR.php');

		require_once('HTML/BBCodeParser.php');



		/* get options from the ini file */

		$config = parse_ini_file($CONF_LIB_PATH.'lib/package/wysi/bb/bbcodeparser.ini', true);

		$options = &PEAR::getStaticProperty('HTML_BBCodeParser', '_options');

		$options = $config['HTML_BBCodeParser'];

		unset($options);



		/* do yer stuff! */

		$parser = new HTML_BBCodeParser();

		$parser->setText($message);

		$parser->parse();

		$parsed = $parser->getParsed();



		$parsed = str_replace(chr(10), "<br/>", $parsed);

//		$parsed = str_replace(" ", "&nbsp;", $parsed);

		$parsed = $this->ReplaceSmile($parsed);

		return $parsed;

	}



/**

* ReturnDependancy : retourne la chaine d'appel aux javascript indispenssable

*

*<p>Retourne la chaine Javascript Avec le bon chemin (en fonction de SYSTEM_PATH)</p>

* @return chaine chaine d'appel javascript

*/

	function ReturnDependency()

	{

		return 'bb.js';

	}



/**

* DisplaySmile : retourne la chaine des smile pour la saisie

* @return chaine

*/

	function DisplaySmile()

	{

	$name		=$this->name;

	$form		=$this->form;

	$string		=$this->string;

	$smile		=$this->smile;



	$element=$form.".".$name;



	$html='<table width="100" border="0" cellspacing="0" cellpadding="5">

			<tr align="center" valign="middle">

			  <td><a ondrag="return false;" href="javascript:emoticon(\':D\', '.$element.')"><img src="'.$this->dir.'smiles/icon_biggrin.gif" border="0" alt="Very Happy" title="Very Happy"  /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':)\', '.$element.')"><img src="'.$this->dir.'smiles/icon_smile.gif" border="0" alt="Smile" title="Smile" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':(\', '.$element.')"><img src="'.$this->dir.'smiles/icon_sad.gif" border="0" alt="Sad" title="Sad" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':o\', '.$element.')"><img src="'.$this->dir.'smiles/icon_surprised.gif" border="0" alt="Surprised" title="Surprised" /></a></td>

			</tr>

			<tr align="center" valign="middle">

			  <td><a ondrag="return false;" href="javascript:emoticon(\':shock:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_eek.gif" border="0" alt="Shocked" title="Shocked" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':?\', '.$element.')"><img src="'.$this->dir.'smiles/icon_confused.gif" border="0" alt="Confused" title="Confused" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\'8)\', '.$element.')"><img src="'.$this->dir.'smiles/icon_cool.gif" border="0" alt="Cool" title="Cool" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':lol:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_lol.gif" border="0" alt="Laughing" title="Laughing" /></a></td>

			</tr>

			<tr align="center" valign="middle">

			  <td><a ondrag="return false;" href="javascript:emoticon(\':x\', '.$element.')"><img src="'.$this->dir.'smiles/icon_mad.gif" border="0" alt="Mad" title="Mad" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':P\', '.$element.')"><img src="'.$this->dir.'smiles/icon_razz.gif" border="0" alt="Razz" title="Razz" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':oops:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_redface.gif" border="0" alt="Embarassed" title="Embarassed" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':cry:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_cry.gif" border="0" alt="Crying or Very sad" title="Crying or Very sad" /></a></td>

			</tr>

			<tr align="center" valign="middle">

			  <td><a ondrag="return false;" href="javascript:emoticon(\':evil:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_evil.gif" border="0" alt="Evil or Very Mad" title="Evil or Very Mad" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':twisted:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_twisted.gif" border="0" alt="Twisted Evil" title="Twisted Evil" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':roll:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_rolleyes.gif" border="0" alt="Rolling Eyes" title="Rolling Eyes" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':wink:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_wink.gif" border="0" alt="Wink" title="Wink" /></a></td>

			</tr>

			<tr align="center" valign="middle">

			  <td><a ondrag="return false;" href="javascript:emoticon(\':!:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_exclaim.gif" border="0" alt="Exclamation" title="Exclamation" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':?:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_question.gif" border="0" alt="Question" title="Question" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':idea:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_idea.gif" border="0" alt="Idea" title="Idea" /></a></td>

			  <td><a ondrag="return false;" href="javascript:emoticon(\':arrow:\', '.$element.')"><img src="'.$this->dir.'smiles/icon_arrow.gif" border="0" alt="Arrow" title="Arrow" /></a></td>

			</tr>

	  </table>';

	  return $html;

	}



/**

* ReplaceSmile() : remplasse les smile par leur image

*

*<p>Retourne la chaine Javascript Avec le bon chemin (en fonction de SYSTEM_PATH)</p>

* @param chaine

* @return chaine

*/

	function ReplaceSmile($string)

	{

		$string=str_replace(":!:", '<img src="'.$this->dir.'smiles/icon_exclaim.gif" border="0" alt="Exclamation" title="Exclamation" />', $string);

		$string=str_replace(":?:", '<img src="'.$this->dir.'smiles/icon_question.gif" border="0" alt="Question" title="Question" />', $string);

		$string=str_replace(":oops:", '<img src="'.$this->dir.'smiles/icon_redface.gif" border="0" alt="Embarassed" title="Embarassed" />', $string);

		$string=str_replace(":D", '<img src="'.$this->dir.'smiles/icon_biggrin.gif" border="0" alt="Very Happy" title="Very Happy" />', $string);

		$string=str_replace(":)", '<img src="'.$this->dir.'smiles/icon_smile.gif" border="0" alt="Smile" title="Smile" />', $string);

		$string=str_replace(":(", '<img src="'.$this->dir.'smiles/icon_sad.gif" border="0" alt="Sad" title="Sad" />', $string);

		$string=str_replace(":o", '<img src="'.$this->dir.'smiles/icon_surprised.gif" border="0" alt="Surprised" title="Surprised" />', $string);

		$string=str_replace(":shock:", '<img src="'.$this->dir.'smiles/icon_eek.gif" border="0" alt="Shocked" title="Shocked" />', $string);

		$string=str_replace(":?", '<img src="'.$this->dir.'smiles/icon_confused.gif" border="0" alt="Confused" title="Confused" />', $string);

		$string=str_replace("8)", '<img src="'.$this->dir.'smiles/icon_cool.gif" border="0" alt="Cool" title="Cool" />', $string);

		$string=str_replace(":lol:", '<img src="'.$this->dir.'smiles/icon_lol.gif" border="0" alt="Laughing" title="Laughing" />', $string);

		$string=str_replace(":x", '<img src="'.$this->dir.'smiles/icon_mad.gif" border="0" alt="Mad" title="Mad" />', $string);

		$string=str_replace(":P", '<img src="'.$this->dir.'smiles/icon_razz.gif" border="0" alt="Razz" title="Razz" />', $string);

		$string=str_replace(":cry:", '<img src="'.$this->dir.'smiles/icon_cry.gif" border="0" alt="Crying or Very sad" title="Crying or Very sad" />', $string);

		$string=str_replace(":evil:", '<img src="'.$this->dir.'smiles/icon_evil.gif" border="0" alt="Evil or Very Mad" title="Evil or Very Mad" />', $string);

		$string=str_replace(":twisted:", '<img src="'.$this->dir.'smiles/icon_twisted.gif" border="0" alt="Twisted Evil" title="Twisted Evil" />', $string);

		$string=str_replace(":roll:", '<img src="'.$this->dir.'smiles/icon_rolleyes.gif" border="0" alt="Rolling Eyes" title="Rolling Eyes" />', $string);

		$string=str_replace(":wink:", '<img src="'.$this->dir.'smiles/icon_wink.gif" border="0" alt="Wink" title="Wink" />', $string);

		$string=str_replace(":idea:", '<img src="'.$this->dir.'smiles/icon_idea.gif" border="0" alt="Idea" title="Idea" />', $string);

		$string=str_replace(":arrow:", '<img src="'.$this->dir.'smiles/icon_arrow.gif" border="0" alt="Arrow" title="Arrow" />', $string);



		return $string;

	}

/**

* HtmlToBBSmile : remplasse les images par leur smile

* @param chaine

* @return chaine

*/

	function HtmlToBBSmile($string)

	{

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_biggrin.gif" border="0" alt="Very Happy" title="Very Happy" />', ":D", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_smile.gif" border="0" alt="Smile" title="Smile" />', ":)",$string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_sad.gif" border="0" alt="Sad" title="Sad" />', ":(", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_surprised.gif" border="0" alt="Surprised" title="Surprised" />', ":o", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_eek.gif" border="0" alt="Shocked" title="Shocked" />', ":shock:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_confused.gif" border="0" alt="Confused" title="Confused" />', ":?", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_cool.gif" border="0" alt="Cool" title="Cool" />', "8)", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_lol.gif" border="0" alt="Laughing" title="Laughing" />', ":lol:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_mad.gif" border="0" alt="Mad" title="Mad" />', ":x", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_razz.gif" border="0" alt="Razz" title="Razz" />', ":P", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_redface.gif" border="0" alt="Embarassed" title="Embarassed" />', ":oops:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_cry.gif" border="0" alt="Crying or Very sad" title="Crying or Very sad" />', ":cry:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_evil.gif" border="0" alt="Evil or Very Mad" title="Evil or Very Mad" />', ":evil:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_twisted.gif" border="0" alt="Twisted Evil" title="Twisted Evil" />', ":twisted:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_rolleyes.gif" border="0" alt="Rolling Eyes" title="Rolling Eyes" />', ":roll:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_wink.gif" border="0" alt="Wink" title="Wink" />', ":wink:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_exclaim.gif" border="0" alt="Exclamation" title="Exclamation" />', ":!:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_question.gif" border="0" alt="Question" title="Question" />', ":?:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_idea.gif" border="0" alt="Idea" title="Idea" />', ":idea:", $string);

		$string=str_replace('<img src="'.$this->dir.'smiles/icon_arrow.gif" border="0" alt="Arrow" title="Arrow" />', ":arrow:", $string);



		return $string;

	}

/**

* HtmlToBB : remplasse les images par leur smile

* @param chaine

* @return chaine

*/

	function HtmlToBB($string)

	{

		# Gestion des bold

		$string=str_replace("<b>", "[b]", $string);

		$string=str_replace("</b>", "[/b]", $string);



		# Gestion des italic

		$string=str_replace("<i>", "[i]", $string);

		$string=str_replace("</i>", "[/i]", $string);



		# Gestion des underline

		$string=str_replace("<u>", "[u]", $string);

		$string=str_replace("</u>", "[/u]", $string);



		# Gestion des smile

		if ($this->smile)

		{

			$string=$this->HtmlToBBSmile($string);

		}



		# Gestion des images

		$string=str_replace('<img src="', "[img]", $string);

		$string=str_replace(' border="0" />', "[/img]", $string);



		# Gestion des images

		$string=str_replace('<a href="', "[url=", $string);

		$string=str_replace(' target="_blank" >', "]", $string);



		# Gestion des couleurs

		$string=str_replace('<span style="font-size: ', "[size=", $string);

		$string=str_replace('px; line-height: normal">', "]", $string);

		$string=str_replace('</span>', "[size]", $string);



		# Gestion des couleurs

		$string=str_replace('<span style="color: ', "[color=", $string);

		$string=str_replace('">', "]", $string);

		$string=str_replace('</span >', "[color]", $string);



		return $string;

	}



/**

* IsVideJs :permet de savoir en javascript si le champ est vide

*

*<p>donne le nom de la fonction ou l'appel permettant de determiner si vide en js</p>

*

* @return chaine chaine d'appel javascript

*/

	function IsVideJs()

	{

		return '(document.'.$this->form.'.'.$this->name.'.value=="")?true:false;';

	}



}

?>
