Tutorials

Create the logon screen

In the last version of the Rialto PHP lib, you can design your screen in a class. In this tutorial you will learn how to create a screen and how to print it.

Create a folder named : screens.

In this folder create a new file named : DefaultScreen.php.

<?php
 
class DefaultScreen extends RialtoPHPScreen {
 
	public function doPrint($writer){
		return '';
	}
}
?>

Create a window

<?php
 
class DefaultScreen extends RialtoPHPScreen {
 
	public $DIV	= "document.body";
	public $WINDOW 	= "myWindow";
	public $WINDOW_TITLE = "My Title";
	public $ICON = "images/imgFenSimple/picto-gr_recherchepatients.gif";
 
	public function doPrint($writer){
		$out.= $writer->windowTag($this->WINDOW,$this->WINDOW_TITLE, $this->DIV);
		return $out;
	}
}
?>
  • A screenshot of the result

tuto_php_1.jpg

Create a Frame

  • This exemple is based on the on before.
<?php
 
class DefaultScreen extends RialtoPHPScreen {
 
	public $DIV	     = "document.body";
	public $WINDOW 	     = "myWindow";
	public $WINDOW_TITLE = "My Title";
	public $CADRE        = "boxDemo";
	public $ICON         = "images/imgFenSimple/picto-gr_recherchepatients.gif";
 
	public function doPrint($writer){
		$out.= $writer->windowTag($this->WINDOW,$this->WINDOW_TITLE, $this->DIV);
		$out.= $writer->frameTag($this->CADRE, "30", "30", "300", "120", "Box Title", "false", "false", "relative", "false", $this->WINDOW);
		return $out;
	}
}
?>
  • A screenshot of the result

tuto_php_2.jpg

Add a text field

  • Add a form to post your datas
<?php
 
class DefaultScreen extends RialtoPHPScreen {
 
	public $DIV	     = "document.body";
	public $WINDOW 	     = "myWindow";
	public $WINDOW_TITLE = "My Title";
	public $CADRE        = "boxDemo";
	public $FORM         = "myForm";
	public $URL	     = "do.php";
	public $ICON         = "images/imgFenSimple/picto-gr_recherchepatients.gif";
 
	public function doPrint($writer){
 
		$out.= $writer->windowTag($this->WINDOW,$this->WINDOW_TITLE, $this->DIV);
		$out.= $writer->frameTag($this->CADRE, "30", "30", "300", "120", "Box Title", "false", "false", "relative", "false", $this->WINDOW);
		$out.= $writer->formTag($this->FORM,$this->URL,$this->CADRE);
		return $out;
	}
}
?>
  • Add a label
<?php
 
class DefaultScreen extends RialtoPHPScreen {
 
	public $DIV	= "document.body";
	public $WINDOW 	= "myWindow";
	public $WINDOW_TITLE = "My Title";
	public $CADRE = "boxDemo";
	public $FORM = "myForm";
	public $URL	= "do.php";
	public $ICON = "images/imgFenSimple/picto-gr_recherchepatients.gif";
 
	public function doPrint($writer){
 
		$out.= $writer->windowTag($this->WINDOW,$this->WINDOW_TITLE, $this->DIV);
		$out.= $writer->frameTag($this->CADRE, "30", "30", "300", "120", "Box Title", "false", "false", "relative", "false", $this->WINDOW);
		$out.= $writer->formTag($this->FORM,$this->URL,$this->CADRE);
		$out.= $writer->labelTag("lib1", "25", "10", "Username :", $this->FORM);
		$out.= $writer->buttonTag("doLogon", "Logon", "90", "50", "", array('FORM',$this->FORM), $this->FORM);
		$out.= $writer->buttonTag("default", "Cancel", "90", "170", "", "", $this->FORM);
		return $out;
	}
}
?>
  • Add a field
<?php
 
class DefaultScreen extends RialtoPHPScreen {
 
	public $DIV	= "document.body";
	public $WINDOW 	= "myWindow";
	public $WINDOW_TITLE = "My Title";
	public $CADRE = "boxDemo";
	public $FORM = "myForm";
	public $URL	= "do.php";
	public $ICON = "images/imgFenSimple/picto-gr_recherchepatients.gif";
 
	public function doPrint($writer){
 
		$out.= $writer->windowTag($this->WINDOW,$this->WINDOW_TITLE, $this->DIV);
		$out.= $writer->frameTag($this->CADRE, "30", "30", "300", "120", "Box Title", "false", "false", "relative", "false", $this->WINDOW);
		$out.= $writer->formTag($this->FORM,$this->URL,$this->CADRE);
		$out.= $writer->labelTag("lib1", "25", "10", "Username :", $this->FORM);
		$out.= $writer->textTag("login","25", "90", "200", "A", $this->FORM,"false", "true", "");
		$out.= $writer->buttonTag("doLogon", "Logon", "90", "50", "", array('FORM',$this->FORM), $this->FORM);
		$out.= $writer->buttonTag("default", "Cancel", "90", "170", "", "", $this->FORM);
		return $out;
	}
}
?>
  • See the result

tuto_php_3.jpg

Add a button

  • Add a button to submit the form
<?php
 
class DefaultScreen extends RialtoPHPScreen {
 
	public $DIV	= "document.body";
	public $WINDOW 	= "myWindow";
	public $WINDOW_TITLE = "My Title";
	public $CADRE = "boxDemo";
	public $FORM = "myForm";
	public $URL	= "do.php";
	public $ICON = "images/imgFenSimple/picto-gr_recherchepatients.gif";
 
	public function doPrint($writer){
 
		$out.= $writer->windowTag($this->WINDOW,$this->WINDOW_TITLE, $this->DIV);
		$out.= $writer->frameTag($this->CADRE, "30", "30", "300", "120", "Box Title", "false", "false", "relative", "false", $this->WINDOW);
		$out.= $writer->formTag($this->FORM,$this->URL,$this->CADRE);
		$out.= $writer->labelTag("lib1", "25", "10", "Username :", $this->FORM);
		$out.= $writer->textTag("login","25", "90", "200", "A", $this->FORM,"false", "true", "");
		$out.= $writer->labelTag("lib2", "55", "10", "Password :", $this->FORM);
		$out.= $writer->textTag("pass","55", "90", "200", "P", $this->FORM, "false", "true", "");
		$out.= $writer->buttonTag("doLogon", "Logon", "90", "50", "", array('FORM',$this->FORM), $this->FORM);
		$out.= $writer->buttonTag("default", "Cancel", "90", "170", "", "", $this->FORM);
		return $out;
	}
}
?>
  • See the result

tuto_php_4.jpg

Sumit the form

  • The form is submited in a iframe. In our sample this iframe is name “do.php”. You have to send the correct response in this iframe. To do that, you can use the RialtoPHPServer object.
<?php
// +----------------------------------------------------------------------+
// | RIALTO PHP 1.0                                                       |
// +----------------------------------------------------------------------+
// | Authors: Damien VIEL (damien.viel@improve.fr)                        |
// +----------------------------------------------------------------------+
 
session_start();
include "../rialtoPHP/RialtoPHPConfig.php";
include "../rialtoPHP/RialtoPHPWriter.php";
include "../rialtoPHP/RialtoPHPTag.php";
include "../rialtoPHP/RialtoPHPScreen.php";
 
include "../rialtoPHP/tags/AlertTag.php";
include "../rialtoPHP/tags/ButtonTag.php";
include "../rialtoPHP/tags/FrameTag.php";
include "../rialtoPHP/tags/ComboTag.php";
include "../rialtoPHP/tags/FormTag.php";
include "../rialtoPHP/tags/GridTag.php";
include "../rialtoPHP/tags/ImportTag.php";
include "../rialtoPHP/tags/LayoutTag.php";
include "../rialtoPHP/tags/LabelTag.php";
include "../rialtoPHP/tags/PopUpTag.php";
include "../rialtoPHP/tags/TextTag.php";
include "../rialtoPHP/tags/CheckBoxTag.php";
include "../rialtoPHP/tags/WindowTag.php";
include "../rialtoPHP/tags/SplitterTag.php";
include "../rialtoPHP/tags/TreeviewTag.php";
include "../rialtoPHP/tags/TreeNodeTag.php";
include "../rialtoPHP/tags/CallBackTag.php";
include "../rialtoPHP/tags/RadioTag.php";
include "../rialtoPHP/tags/ImageTag.php";
include "../rialtoPHP/tags/CodeLabelTag.php";
include "../rialtoPHP/tags/TabFolderTag.php";
include "../rialtoPHP/tags/TabItemTag.php";
 
$writer = new RialtoPHPWriter(true,"");
 
switch ($_GET[RIALTO_REQCODE]) {
	case doLogon :
		$error_msg = array ();
		if ($_GET["login"] == "") {
			array_push($error_msg, "Empty Username");
		}
		if ($_GET["pass"] == "") {
			array_push($error_msg, "Empty password");
		}
 
		if (sizeof($error_msg) == 0) {
			if ($_GET["login"] == "user" && $_GET["pass"] == "pass") {
				$_SESSION['isLog'] = true;
				$out.=$writer->getScreen("SuccessScreen");
 
			} else {
				array_push($error_msg, "Unknown username/password");
			}
		}
		if (sizeof($error_msg) > 0) {
			$out.=$writer->showAlert("",implode(",",$error_msg),"");
		}
 
		break;
 
	default:
		$out.= $writer->getScreen("DefaultScreen");
		break;
}
echo $out;
?>
 

* Here is the index file

<?php
// +----------------------------------------------------------------------+
// | RIALTO PHP 1.0                                                       |
// +----------------------------------------------------------------------+
// | Authors: Damien VIEL (damien.viel@improve.fr)                        |
// +----------------------------------------------------------------------+
session_start();
 
include "../rialtoPHP/RialtoPHPConfig.php";
include "../rialtoPHP/RialtoPHPWriter.php";
include "../rialtoPHP/RialtoPHPTag.php";
include "../rialtoPHP/RialtoPHPScreen.php";
 
include "../rialtoPHP/tags/AlertTag.php";
include "../rialtoPHP/tags/ButtonTag.php";
include "../rialtoPHP/tags/FrameTag.php";
include "../rialtoPHP/tags/ComboTag.php";
include "../rialtoPHP/tags/FormTag.php";
include "../rialtoPHP/tags/GridTag.php";
include "../rialtoPHP/tags/ImportTag.php";
include "../rialtoPHP/tags/LayoutTag.php";
include "../rialtoPHP/tags/LabelTag.php";
include "../rialtoPHP/tags/PopUpTag.php";
include "../rialtoPHP/tags/TextTag.php";
include "../rialtoPHP/tags/CheckBoxTag.php";
include "../rialtoPHP/tags/WindowTag.php";
include "../rialtoPHP/tags/SplitterTag.php";
include "../rialtoPHP/tags/TreeviewTag.php";
include "../rialtoPHP/tags/TreeNodeTag.php";
include "../rialtoPHP/tags/CallBackTag.php";
include "../rialtoPHP/tags/RadioTag.php";
include "../rialtoPHP/tags/ImageTag.php";
include "../rialtoPHP/tags/CodeLabelTag.php";
include "../rialtoPHP/tags/TabFolderTag.php";
include "../rialtoPHP/tags/TabItemTag.php";
 
$writer = new RialtoPHPWriter(false,'myWindow');
echo $writer->addImport();
 
?>
  • See the result

tuto_php_5.jpg

Download

You can dowload the complete tutorial in the download page

php/tutorial.txt · Last modified: 2007/10/23 11:48 by cbalit
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0