Location: PHPKode > projects > interface preprocessor for php > ippfp-0.2.10/ippfp/packages/html/html_application.php
<?php

    /**
     *	ippfp - interface preprocessor for php
     *
     *	Copyright 2004 Thomas Moenicke
     *
     *	This library is free software; you can redistribute it and/or
     *	modify it under the terms of the GNU Lesser General Public
     *	License as published by the Free Software Foundation; either
     *	version 2.1 of the License, or (at your option) any later
     *	version.
     *	This library is distributed in the hope that it will be useful,
     *	but WITHOUT ANY WARRANTY; without even the implied warranty of
     *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
     *	Lesser General Public License for more details.
     *	You should have received a copy of the GNU Lesser General Public
     *	License along with this library; if not, write to the Free
     *	Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     *	02111-1307 USA
     *
     */

require_once(dirname(__FILE__).'/../../application.php');
require_once(dirname(__FILE__).'/../../packages/html/html_password.php');
require_once(dirname(__FILE__).'/../../packages/html/html_grid.php');
require_once(dirname(__FILE__).'/../../packages/html/html_view.php');
require_once(dirname(__FILE__).'/../../packages/html/html_fopen.php');

class ippfp_html_application extends ippfp_application {

    /* global variables */
    
    var $format = "XHTML";
    var $cssstyle = "css/style.css";
    var $status_ = "init";
    var $stat_array = array();
    var $stat_;
    var $view;

    var $idc = 1;
    
    function ippfp_html_application() {

	$this->type = "XHTML";
    }

    function process(&$view){
	if($view->app->format != "XHTML") 
	    if($view->app->process) $view->app->process(&$view);
	    else {
		echo "ippfp runtime error: element ".$view->name." could not be processed, stopped.";
		exit(EXIT_FAILURE);
	    }
	else $view->display();
    }

    
    function setStatus($status_){ $this->status = $status_; }
    function getStatus(){ /*if($_POST["status"]) $this->status = $_POST["status"];*/ return $this->status; }

    function &createButton($status_, $value, $src = null, $name = null){
	if($name) return new ippfp_html_button($name, $status_, $value, $src, &$this);
	else return new ippfp_html_button("button_".$this->getId(), $status_, $value, $src, &$this);
    }

    function &createCheckbox($text, $checked, $name = null){
	if($name) return new ippfp_html_checkbox($name, $text, $checked);
	else return new ippfp_html_checkbox("checkbox_".$this->getId(), $text, $checked);
    }

    function &createChoice($value, $array, $name = null, $status = null){
	if($name) $choice = new ippfp_html_choice($name, $value, $array, $status);
	else $choice = new ippfp_html_choice("choice_".$this->getId(), $value, $array, $status);
	return $choice;
    }

    function &createFopen($status_, $value, $name = null){
	if($name) return new ippfp_html_fopen($name, $status_, $value, &$this);
	else return new ippfp_html_fopen("button_".$this->getId(), $status_, $value, &$this);
    }

    function &createGrid($text, $array, $name = null){
	if($name) return new ippfp_html_grid($name, $text, $array, &$this);
	else return new ippfp_html_grid("grid_".$this->getId(), $text, $array, &$this);
    }

    function &createImage($text, $src, $name = null){
	if($name) return new ippfp_html_image($name, $text, $src);
	else return new ippfp_html_image("image_".$this->getId(), $text, $src);
    }

    function &createLabel($text, $cols = null, $name = null, $formatting = null){
	if($name) {
	    $return = new ippfp_html_label($name, $text, $cols, $formatting);
	    $return->span = true;
	    return $return;
	}
	else return new ippfp_html_label("label_".$this->getId(), $text, $cols, $formatting);
    }

    function &createLink($text, $target, $src = null, $name = null){
	if($name) return new ippfp_html_link($name, $text, $target, $src);
	else return new ippfp_html_link("link_".$this->getId(), $text, $target, $src);
    }

    function &createMultipleChoice($value, $array, $name = null, $status = null){
	if($name) $choice = new ippfp_html_multiplechoice($name, $value, $array, $status);
	else $choice = new ippfp_html_multiplechoice("choice_".$this->getId(), $value, $array, $status);
	return $choice;
    }

    function &createPassword($text = null, $size, $name = null){
	if($name) return new ippfp_html_password($name, $text, $size);
	else return new ippfp_html_password("password_".$this->getId(), $text, $size);
    }

    function &createRadio($text, $checked, $name = null, $group = null){
	if($name) return new ippfp_html_radio($name, $text, $checked, $group);
	else return new ippfp_html_radio("radio_".$this->getId(), $text, $checked, $group);
    }

    function &createTable($head, $array, $name = null){
	if($name) return new ippfp_html_table($name, $head, $array, &$this);
	else return new ippfp_html_table("table_".$this->getId(), $head, $array, &$this);
    }

    function &createText($text, $size, $name = null){
	if($name) return new ippfp_html_text($name, $text, $size);
	else return new ippfp_html_text("text_".$this->getId(), $text, $size);
    }

    function &createTextarea($text, $cols, $name = null){
	if($name) return new ippfp_html_textarea($name, $text, $cols);
	else return new ippfp_html_textarea("textarea_".$this->getId(), $text, $cols);
    }

    function &createView($title){ $this->view = new ippfp_html_view("view_".$this->getId(), $title, $this->cssstyle, &$this); return $this->view; }

    /* automatical generation of internal names, can be overrided */
    
    function getId(){
	return $this->idc++/*.rand()*/."_xhtml";
    }
    
    function addError($msg){
     if($msg){
	$_SESSION["errormsg"] .= "<br/>".$msg;
	return true;
     } else return false;
    }
    
    function delError(){
	unset($_SESSION["errormsg"]);
    }

    function getError(){
	return $_SESSION["errormsg"];
    }

}

?>
Return current item: interface preprocessor for php