28
[irbot.git] / sources / TextFormat-class.inc.php
blobc03fe2ce4e3cce909dcb31a0543f2fe126c5ba4a
1 <?php
2 /**
3 * This file is part of IrBot, irc robot.
4 * Copyright (C) 2007 Bellière Ludovic
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 class text_format {
21 static public $instance = FALSE;
23 static function GetInstance() {
24 if (!text_format::$instance) {
25 text_format::$instance = new text_format();
27 return text_format::$instance;
30 /**
31 * Formate un texte pour la couleur
33 * @param unknown_type $msg Le message a formater
34 * @param unknown_type $text L'id de couleur du texte
35 * @param unknown_type $background L'id de couleur du background
36 * @return string
38 function colors($msg,$text,$background=false) {
39 $color_tag = chr(3);
40 $first = ($background)?$color_tag.$text.','.$background:$color_tag.$text;
41 return $first.$msg.$color_tag;
44 function bold($msg) {
45 return chr(2).$msg.chr(2);
48 function ctcp($msg) {
49 return chr(1).$msg.chr(1);
52 function reverse_color($msg) {
53 return chr(22).$msg.chr(22);
56 function underline($msg) {
57 return chr(31).$msg.chr(31);
60 function paragraphe($msg) {
61 return explode("\n",$msg);