Translations of this page:

Customizing

phpFreeChat was developed with an aim of simplicity and flexibility.

Setting it up is relatively simple. All parameters are centralized in an array and passed as parameters on the instantiation of the phpFreeChat object.

Customization of the overall appearance (colors, sizes ...)

You need to create a new theme (for example “mytheme”) :

  1. Create a directory: “phpfreechat/themes/mytheme/”
  2. Create a new CSS stylesheet: “phpfreechat/themes/mytheme/style.css”
  3. Now insert CSS rules into this file, for example, to change the date/hours color to red:
    span.pfc_heure, span.pfc_date {
          color: red;
        }
  4. Setup the “theme” parameter in your chat script:
    $params["theme"] = "mytheme";

As an examples, see these demos: 1, 2

Customization of the smileys list

Follow the above instructions for the theme creation. Then I suppose you have a directory “phpfreechat/themes/mytheme/”.

  1. Create a new smileys directory: “phpfreechat/themes/mytheme/smileys/”
  2. Insert ping, jpeg or gif smileys images in the folder for example : “smiley1.png”, “smiley2.gif”, and “smiley3.jpg”
  3. Create a file “phpfreechat/themes/mytheme/smileys/theme” and enter the keyboard to image mapping smileys description, for example :
       smiley1.png :) :-)
        smiley2.gif :( :-(
        smiley3.jpg :D :-D :o)

    Each line begins with the image filename followed by the list of the string characters to replace by that image. Only use spaces to separate the smileys string matches.

  4. Setup the “theme” parameter in your chat script:
    $params["theme"] = "mytheme";

As an examples, see these demos: 1, 2, 3, 4

Write a new command

A command is a php class. So, to write your own command, you need to write a new php class (as an example look at the “src/commands/nick.class.php” file).

Each command class inherit from a virtual “pfcCommand” class. This virtual class define the command interface. Currently the only virtual method to implement is: “function run(…)”

You have some API you can use to write your command:

  • pfcResponse (see “src/pfcresponse.class.php”)
  • container (see “src/pfccontainer.class.php”)
  • tools (see “src/pfctools.php”)

FIXME

As an examples, have a look to this demo: 1 (try to type ”/roll 2d6”)

Write a new proxy

A phpfreechat proxy is a class that will be instantiated each time a command is run. The proxy can stop and modify the handled commands. It can also create and run new commands. Thanks to the proxies, the chat default behavior can be customized a lot.

To start understanding the proxy mechanism, have a look to the easier proxy: the log proxy. This proxy write down in a file all the posted message on each channels.

Write your own container

FIXME

As an examples, have a look to the default file container source code or to the mysql container source code.

customize.txt · Last modified: 2008/07/26 12:00 by kerphi
 
 

Many thanks to our contributors

  1. Silver Jewelry - $280 USD
  2. Best web hosting - $110 USD
  3. Ramiro Portillo G - $100 USD
Recent changes RSS feed Valid XHTML 1.0 Valid CSS Powered by PHP Driven by DokuWiki
©2006-2008 phpFreeChat