Location: PHPKode > projects > FiForms Framework > FiForms/FiForms-includes/FiForms_genericHTML.inc.php
<?php
/*
*******************************************************************************

    FiForms -- A collection of PHP classes designed 
    to facilitate rapid development of web-database software

    Copyright (C) 2003-2008  Daniel McFeeters

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation; either
    version 2 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
    General Public License for more details.

    You should have received a copy of the GNU 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


    The original author of this library can be contacted at the following 
    address:

    Daniel McFeeters
    182 Baker Rd.
    Faubush, KY 42544-6526
    email:databases [at] fiforms [dot] org
    http://www.fiforms.org/

Project Started May 4, 2003
*******************************************************************************
FiForms_genericHTML.inc.php

HTML Code File

This file contains HTML clips used to wrap the actual FiForm code into an HTML
file.

*******************************************************************************
*/

if(!isset($FIFORMS_CONFIG))
{
        die('No Configuration found. Did you perhaps call an include file' .
                        ' directly instead of calling it as part of the FiForms' .
                        ' application?'); 
}


include_once($GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH']."themes/".$FIFORMS_CONFIG['ICON_SET']."/iconset.php");
/* ?><code><?php */

class genericHTML
{
    public $pageTitle;
    public $pageHeader;
    public $pageFooter;
    public $bodyProperties;
    public $htmlTemplate;
    public $htmlProperties;
    public $headerTags;
    public $stylesheetTags;
    public $errorMsg;
    public $icons;
    public $contentType;
    public $doctype;
    public $debugQueries;
    public $debugSection;
    
    function generateHeader()
    {
        if($GLOBALS['FIFORMS_CONFIG']['USE_XHTML'] === TRUE &&
           strpos($_SERVER['HTTP_ACCEPT'],
               'application/xhtml+xml') !== FALSE)
{
            $end = '?'.'>';
            $this->doctype = <<<EOD
<?xml version="1.0" encoding="ISO-8859-1"$end
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
EOD;
        $this->htmlProperties = 'xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" ';
            $this->metaClose = "/>";
            $contentType = "application/xhtml+xml; charset=iso-8859-1";
}
        else
{
            $this->doctype = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
EOD;
            $this->metaClose = ">";
            $contentType = "text/html; charset=iso-8859-1";
}
    $this->contentType = $contentType;
        $this->debug = $GLOBALS['FIFORMS_CONFIG']['QUERY_DEBUGGING'] !== TRUE ? "" : <<<EOD
<p><a href="#" onclick="document.getElementById('fiforms_query_debug').style.display=(document.getElementById('fiforms_query_debug').style.display == '' ? 'none': '');return false;">+ Debugging</a></p>
<div id="fiforms_query_debug" style="display:none;">
Query Log for Debugging. <br />
You can disable this feature in localconfig.php. <br /><br />
%debugQueries%
</div>
EOD;


    }  // function generateHeader
    
    function outputHTTPHeader()
    {   
    @header("Content-type: $this->contentType");
        @header("cache-control: private");
        @header("cache-control: no-cache");
        @header("cache-control: no-store");
        @header("pragma: no-cache");
        @header("expires: 0");
    }
    
    function getTemplate($filename = "")
    {
        if($filename)
        {
            $this->htmlTemplate = file_get_contents($filename);
        }
        else
        {
            $templateFile = $GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH']."themes/".$GLOBALS['FIFORMS_CONFIG']['ICON_SET']."/template.html";
            if(file_exists($templateFile))
            {
                $this->htmlTemplate = file_get_contents($templateFile);
            }
            else
            {
                $this->htmlTemplate = file_get_contents(dirname(__FILE__).'/template.html');
            }
        }
        $this->hasTemplate = TRUE;
    }
    
    function initialize()
    {
        $this->htmlProperties = "";
        $this->hasTemplate = FALSE;
        $this->generateHeader();
        $this->headerTags = $GLOBALS['FIFORMS_CONFIG']['DEFAULT_HEADER'];
            $this->headerTags .= "
        <script language=\"JavaScript\" type=\"text/javascript\" src=\"".$GLOBALS['FIFORMS_CONFIG']['URI']."/CalendarPopup.js\"></script>
        <script language=\"JavaScript1.2\" src=\"backgroundloader.js\" type=\"text/javascript\"></script>
        <script language=\"JavaScript1.2\" type=\"text/javascript\" src=\"".$GLOBALS['FIFORMS_CONFIG']['URI']."/fiform.js\"></script>";
        if(isset($GLOBALS['FIFORMS_CONFIG']['DEFAULT_STYLESHEET']))
{
            $this->stylesheetTags = $GLOBALS['FIFORMS_CONFIG']['DEFAULT_STYLESHEET'];
}
        else
{
            $stylesheet = $GLOBALS['FIFORMS_CONFIG']['URI']."/themes/".$GLOBALS['FIFORMS_CONFIG']['ICON_SET']."/fiform_style.css";
            $this->stylesheetTags = " <link rel=\"stylesheet\" href=\"$stylesheet\" /> ";
}  // if DEFAULT_STYLESHEET
        $this->icons = new iconset();
    }
    
    function genericHTML()
    {
        $this->initialize();
        $this->outputHTTPHeader();
    } // function genericHTML
    

    function returnHeader()
    {
        if(!$this->hasTemplate)
            {
                $this->getTemplate();
            }
            $this->themeHeaderTags = $this->icons->themeHeaderTags;
            $this->debug = fillVars($this,$this->debug);
            $pos = strpos($this->htmlTemplate,'%FiForm%');
            if($pos === false)
        {
                die($this->htmlTemplate);
        }
            $htmlHeader = substr($this->htmlTemplate,0,$pos);
            $filled = fillVars($this,$htmlHeader);
        return($filled);
    } // function genericHeader


    function returnFooter() 
    {
            $htmlFooter = substr($this->htmlTemplate,strpos($this->htmlTemplate,'%FiForm%')+8);
            $this->poweredBy = $this->icons->poweredBy;
        return(fillVars($this,$htmlFooter));

    } // function returnFooter

} // class genericHTML

/* ?></code><?php */

?>
Return current item: FiForms Framework