XML Applications

From FiFormsWiki

Jump to: navigation, search

FiForms allows developers to create user interface definitions in XML, making for easier development and more maintainable applications. Using a combination of XML for defining the user interface, XSLT stylesheets for formatting reports, and SQL embedded in the XML user interface documents, complete database applications can be developed in the FiForms Framework without having to use a scripting language like PHP.


Contents

Application Structure

All FiForms applications for an installation of FiForms are located at the path specified in the %APP_BASE% Configuration element. This is normally the apps/ folder located in the FiForms installation directory. Inside this folder is a separate folder for each application installed. For example, if %APP_BASE% is "C:/xampp/FiForms/apps/" and you have an application called "books" then there will be a subfolder "C:/xampp/FiForms/apps/books/". From now on, we will refer to this folder, in the example "C:/xampp/FiForms/apps/books/", simply as the application folder.

Directory Structure

Inside each application folder are several subfolders:

  • forms
  • menus
  • reports
  • sql

Each of the first three folders contain the XML definitions of the application forms, menus, and reports, respectively. The sql folder could contain an SQL dump of the database, to be imported when the application is installed.

Note: On Windows, FiForms comes with a bin directory in the apps directory. This is not really an application--it is just a collection of executables used by FiForms for working with XML.

Application Registration

Each application folder also contains a special file named appreg.php. This and appconfig.php are the only PHP scripts that may be found in the application folders. appreg.php contains meta data about your application, in the form of assignments to the $FIFORMS_CONFIG global configuration array. appreg.php will be generated automatically when you create your application using the application wizard.

Following is an example appreg.php file for the books application:

 <?php
   $FIFORMS_CONFIG['AVAILABLE_APPS'][] = "books";          // The application name must be the same as the directory name
   $FIFORMS_CONFIG['AVAILABLE_APP_INFO']['books'] = array(
       apptitle    => "Example Bookshelf Application",
       appsummary  => "Application designed to demonstrate the capabilities of FiForms.",
       appdatabase => "fiforms_sample"
   );
   
  ?>

Application-Specific Configuration

The application-specific configuration file appconfig.php follows the same syntax and can contain all the same configuration elements as localconfig.php. This file is located in the application directory, and of course, applies only to one application. Any configuration in appconfig.php overrides configuration in localconfig.php.

Custom PHP Scripts

Applications can also include custom PHP scripts, HTML pages, graphics, and other files as part of the application. By convention, these are placed at the path

%SCRIPT_PATH%/apps/%APP_NAME%

In other words, assuming %SCRIPT_PATH% is

C:/xampp/htdocs/scripts 

and your application name (%APP_NAME%) is books, then your PHP script path would be

C:/xampp/htdocs/scripts/app/books

User Interface Menus

The FiForms Framework provides a method for creating user interface menus dynamically, using a list of links stored in XML. Every application should have at least one menu, named main.xml. Following is an example main.xml menu:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE reports PUBLIC "-//FIFORMS//DTD FIFORMSIMPLE 1.1//EN" 
      "http://xml.fiforms.org/dtd/11/FiFormMenuSimple.dtd">
<reports>
    <title>Bookshelf Collection Main Menu</title>
    <summary>
        Main Menu for the Bookshelf Collection Database, a
        demo application included with the FiForms Framework.
    </summary>
    <form href="books.xml"/>
    <form href="authors.xml"/>
    <rpt href="print_collection.xml"/>
    <rpt href="list_cat.xml"/>
    <list href="maintenance.xml"/>
    <link href="index.php" title="Return to FiForms Applications Menu"/>
</reports>

This example generates a complete main menu for the Bookshelf Collection program. It links to:

  • Forms ( <form /> element)
  • Reports ( <rpt /> element)
  • Other Menus ( <list /> element)
  • Other URL's ( <link /> element)

More documentation can be found at http://xml.fiforms.org/FiFormsMenu/

Data Entry Forms

Data entry forms can be relatively simple, or very complex, depending on what is needed. All of the properties of the form are described in XML, along with data-bound controls, links, queries, and dynamically updated lists.

Here is a very simple example of a form which updates four fields in the table authors:

<fiform xmlns="http://xml.fiforms.org/FiForms/">
    <title>Authors</title>
    <connect db="fiforms_sample" id="1" update="authors" />
    <iText caption="First Name" field="AUTHOR_FIRSTNAME"/>
    <iText caption="Last Name" field="AUTHOR_LASTNAME"/>
    <iDateText caption="Birthdate" field="AUTHOR_BIRTHDATE"/>
    <iTextArea caption="Biographical Info" field="AUTHOR_BIO" rows="6" cols="50"/>
</fiform>

Here is a more complex example, with a couple drop-down lists and an embedded subform. Also, all of the window properties and FiForms behavior are specified as attributes of the root <fiform /> element.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE fiform PUBLIC "-//FIFORMS//DTD FIFORMDEF 1.1//EN" 
         "http://xml.fiforms.org/dtd/11/fi.dtd">
<fiform xmlns="http://xml.fiforms.org/FiForms/"
       allowInsert="yes" 
       ctlPosition="bottom" 
       height="700" 
       insert="current" 
       location="no" 
       menubar="no" 
       resizable="yes" 
       scrollbars="yes" 
       svctlPosition="both" 
       toolbar="no" 
       viewsAllowed="both" 
       whichControls="all" 
       width="700" 
       window="books" 
       defaultView="sheet" 
       >
 <title>Edit Book Collection</title>
 <summary>
   A form to list and modify books in a collection.
 </summary>
 <connect db="fiforms_sample" 
          id="1" 
          server="localhost" 
          type="MySQL" 
          update="books" />
 <iText caption="Title" field="BOOK_TITLE" size="60"/>
 <iDBSelect caption="Author" field="AUTHOR_ID" 
            rowQuery="SELECT AUTHOR_ID, 
                      concat(AUTHOR_FIRSTNAME,' ',AUTHOR_LASTNAME) as AUTHOR_NAME 
                      FROM authors" />
 <iDBSelect caption="Publisher" field="PUB_ID" 
            rowQuery="SELECT PUB_ID, PUB_NAME FROM PUBLISHERS" />
 <iText caption="Copyright Year" field="BOOK_COPYRIGHT" size="10"/>
 <iText caption="ISBN #" field="BOOK_ISBN"/>
 <iText caption="Call #" field="BOOK_CALLNUM"/>
 <iSubform caption="Categories" 
           href="book_categories.xml" 
           params="BOOK_ID=%BOOK_ID%" 
           view="sheet" 
           width="400"
           height="300" />
</fiform>

More information and complete documentation based on the XML Schema are available at http://xml.fiforms.org/FiForms/

Simple SQL/XML Reports

Custom Reports with XSLT

Personal tools