<?php
class Formating {

  private $db;

  public function __construct() {
    $this->db = new Db_layer();
  }

  public function apply_on($text) {
    $text=str_replace("[b]", "<strong>", $text);
    $text=str_replace("[/b]", "</strong>", $text);

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

    $text=str_replace("[u]", "<span style=\"text-decoration: underline;\">", $text);
    $text=str_replace("[/u]", "</span>", $text);

    $text=str_replace("[code]", "<code>", $text);
    $text=str_replace("[/code]", "</code>", $text);

    $text=str_replace("[a]", "<a href=\"", $text);
    $text=str_replace("[*]", "\">", $text);
    $text=str_replace("[/a]", "</a>", $text);

    $text=str_replace(":)", "<img src=\"./components/images/emoticons/smile01.gif\" alt=\":)\" />", $text);
    $text=str_replace(":-)", "<img src=\"./components/images/emoticons/smile01.gif\" alt=\":-)\" />", $text);
    $text=str_replace(";)", "<img src=\"./components/images/emoticons/smile02.gif\" alt=\";)\" />", $text);
    $text=str_replace(";-)", "<img src=\"./components/images/emoticons/smile02.gif\" alt=\";-)\" />", $text);
    $text=str_replace(":D", "<img src=\"./components/images/emoticons/smile07.gif\" alt=\":D\" />", $text);
    $text=str_replace(":-D", "<img src=\"./components/images/emoticons/smile07.gif\" alt=\":-D\" />", $text);
    $text=str_replace("xD", "<img src=\"./components/images/emoticons/smile07.gif\" alt=\"xD\" />", $text);
    $text=str_replace(":(", "<img src=\"./components/images/emoticons/smile04.gif\" alt=\":(\" />", $text);
    $text=str_replace(":-(", "<img src=\"./components/images/emoticons/smile04.gif\" alt=\":-(\" />", $text);
    $text=str_replace(";(", "<img src=\"./components/images/emoticons/smile05.gif\" alt=\";(\" />", $text);
    $text=str_replace(";-(", "<img src=\"./components/images/emoticons/smile05.gif\" alt=\";-(\" />", $text);
    $text=str_replace(":'(", "<img src=\"./components/images/emoticons/smile05.gif\" alt=\":'(\" />", $text);
    $text=str_replace(":'-(", "<img src=\"./components/images/emoticons/smile05.gif\" alt=\":'-(\" />", $text);
    $text=str_replace(":p", "<img src=\"./components/images/emoticons/smile06.gif\" alt=\":p\" />", $text);
    $text=str_replace(":-p", "<img src=\"./components/images/emoticons/smile06.gif\" alt=\":-p\" />", $text);
    $text=str_replace(":P", "<img src=\"./components/images/emoticons/smile06.gif\" alt=\":P\" />", $text);
    $text=str_replace(":-P", "<img src=\"./components/images/emoticons/smile06.gif\" alt=\":-P\" />", $text);
    $text=str_replace("B)", "<img src=\"./components/images/emoticons/smile03.gif\" alt=\"B)\" />", $text);
    $text=str_replace("B-)", "<img src=\"./components/images/emoticons/smile03.gif\" alt=\"B-)\" />", $text);
    
    return $text;
  }

}
?>