Using the msgBox Class to create Message Boxes

msgBox by Vedanta Barooah < vedanta.barooah at gmail dot com >

Jack Said! 
s This is just a Message
OK Cancel 


Add the style sheet to the page <link href="msgbox_style.css" rel="stylesheet" type="text/css">
First you need to include the main class file. include("msgbox.inc.php");
Create the instance of the class $a=new msgBox("This is just a Message ","OKCancel","Jack Said!" );
The constructor takes three parameters:
The message to be displayed
,
The buttons in the message box and
The title of the message box
.
 
Following are the valid arguments for the 2nd parameter:
OKOnly: Displays only the OK Button
OKCancel
: Displays OK and Cancel Button
AbortRetryIgnore: Abort, Retry and Cancel
YesNoCancel: Yes, No, Cancel
YesNo: Yes and No
RetryCancel: Retry Cancel

// these are the valid args for the second param
# $a=new msgBox("This is just a Message ","OKOnly","Jack Said!" );
# $a=new msgBox("This is just a Message ","OKCancel","Jack Said!" );
# $a=new msgBox("This is just a Message ","AbortRetryIgnore","Jack Said!" );
# $a=new msgBox("This is just a Message ","YesNoCancel","Jack Said!" );
# $a=new msgBox("This is just a Message ","YesNo","Jack Said!" );
# $a=new msgBox("This is just a Message ","RetryCancel","Jack Said!" );

The class need an array of links to create the buttons. For each button it requires a page to which it creates the link. // define the links
$links=array("abort.php","retry.php","ignore.php");
// make the links
$a->makeLinks($links);
The final step draws the msgBox
Enjoy!
// draw the message box
$a->showMsg();
The Final Code  

<link href="msgbox_style.css" rel="stylesheet" type="text/css">
<?php
include("msgbox.inc.php");
$a=new msgBox("This is just a Message ","OKCancel","Jack Said!" );
// define the links
$links=array("ok.php","cancel.php");
// make the links
$a->makeLinks($links);
// draw the message box
$a->showMsg();
?>

Here are other samples!
$b=new msgBox("An unnamed file was not found","OKOnly","Setup");
# use the makeLinks() for the buttons to work
$b->showMsg();
Setup 
i An unnamed file was not found
OK 

$b=new msgBox("You need to spend more money on me before I'm going to do anything consistantly.","OKCancel");
# use the makeLinks() for the buttons to work
$b->showMsg();
Application Message 
s You need to spend more money on me before I'm going to do anything consistantly.
OK Cancel 

$b=new msgBox("Bad Command or File Name","AbortRetryIgnore");
# use the makeLinks() for the buttons to work
$b->showMsg();
Application Message 
x Bad Command or File Name
Abort Retry Ignore 
$b=new msgBox("FATAL system error #911","YesNoCancel","Call Him!!!!!!");
# use the makeLinks() for the buttons to work
$b->showMsg();
Call Him!!!!!! 
s FATAL system error #911
Yes No Cancel 

$b=new msgBox("Do you love me?","YesNo","Love me Love me Not?");
# use the makeLinks() for the buttons to work
$b->showMsg();
Love me Love me Not? 
s Do you love me?
Yes No 

$b=new msgBox("Out of order!!","RetryCancel","Damn!");
# use the makeLinks() for the buttons to work
$b->showMsg();
Damn! 
r Out of order!!
Retry Cancel