|
ulf-wendel.de   
|
|
 Home < PHP Schulung  < OOH Forms  < Pages  < Form Page II    |       |  
Print Version    
---
|
|
 Home 
 PHP Projekte 
 PHP Schulung 
    Informationsquellen 
    Geschichte 
    Core PHP 
    Fortgeschrittenes PHP 
    Templates 
    Cache-Technologien 
    OOH Forms 
       Grundlagen 
       JavaScript 
       XML 
       Layoutmanager 
       Pages 
          Form Page 
          Form Page II 
          IT Manager Page 
       Wizards 
       Fazit 
 Technik der Site 
 Büchertipps 
 Fotografie 
 Airbrush 
 Kontakt 
 Stuff 

Quellcode von page_form

Es ist ratsam, sich mit dem Code der Klasse vertraut zu machen, wenn man beabsichtigt, das Wizard-Feature einzusetzen.


HTML_OOH_Form/form_page_form.php Top

<?php

/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4.0                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available at through the world-wide-web at                           |
// | http://www.php.net/license/2_02.txt.                                 |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: Ulf Wendel <ulf.wendel@phpdoc.de>                           |
// +----------------------------------------------------------------------+
//
// $Id: $

require_once('HTML_OOH_Form/form_page.php');
require_once(
'HTML_OOH_Form/layoutmanager/form_gridlayout.php');
require_once(
'HTML_OOH_Form/layoutmanager/form_flowlayout.php');
require_once(
'HTML_OOH_Form/layoutmanager/form_grouplayout.php');

/**
*  Dumps a form into html and offers the interface all wizards need.
*
* @access   public
* @version  $Id: $
* @author   Ulf Wendel <ulf.wendel@phpdoc.de>
* @package  HTML_OOH_Form
*/
class form_page_form extends form_page {
  
  
  var 
$type 'form';
  
  
/**
  * Form object
  *
  * @var  object  form
  * @see  form_page()
  */
  
var $form NULL;
  
  
  
/**
  * Stores the form object to work on.
  *
  * @var  object  form
  */  
  
function form_page_form(&$form$name '') {
    
$this->form = &$form;
    
$this->name $name;
  } 
// end constructor
  
  
  /**
  * Returns a html fragment containing the form.
  *
  * The form is layouted in a very basic way: one element per row
  * 
  */
  
function get($startfinish false$reload false) {
  
    if (
$reload)
      
$this->form->autoloadValues();
    
    if (
$startfinish)
      
$html $this->form->getStart();

    
$html.= $this->dumpFormElements();

    if (
$startfinish)
      
$html .= $this->form->getFinish();

    
$group = new grouplayout($this->name);
    
$group->addContent($html);

    return 
$group->get();
  } 
// end func get

  
  
function show($startfinish false) {
    
$ret $this->get($startfinish);
    print 
$ret;
    
    return 
$ret;
  } 
// end func show

  
  
function &getFormObject() {
    return 
$this->form;
  }  
// end func getFormObject
  
  
  /**
  * Returns true if the contained form object is valid, otherwise false
  */  
  
function isValid() {

    
$this->form->autoloadValues();
    
$valres $this->form->validate();

    return (
'' == $valres[0]) ? true false;
  } 
// end func isValid
  
  
  
function getValues() {
    
    
$ellist $this->form->getElements();
    
$values = array();
    
    
reset($ellist);
    while (list(
$k$name) = each($ellist))
      
$values[$name] = $this->form->getValue($name);
      
    return 
$values;
  } 
// end func getValues

  
  /**
  * Dumps all form elements using the simple rule: one element per row
  */
  
function dumpFormElements() {

    
$ellist $this->form->getElements();
    
$valresults $this->form->validate();
    
$valresults $valresults[1];
    if (!
is_array($valresults))
      
$valresults = array();
    
    
$grid = new gridlayout(count($ellist) * 22);

    
reset($ellist);
    while (list(
$k$name) = each($ellist)) {
      
$el = &$this->form->getElementObject($name);

      if (
is_array($el)) {
        
// radio elements
        
$flow = new flowlayout();

        
reset($el);
        while (list(
$_name, ) = each($el)) {
          
$flow->addContent($el[$_name]->get($_name));
        }
        
$grid->addContent($el[$name]->getLabel() . '&nbsp;');
        
        if (isset(
$valresults[$el[$name]->getName()])) {
          
// error
          
$error = new gridlayout(21);
          
$error->addContent($flow->get());
          
$error->addContent('<div style="color: maroon;">' $valresults[$el[$name]->getName()] . '</div>');
          
          
$grid->addContent($error->get());
          
        } else {
          
          
$grid->addContent($flow->get());
          
        }
        
        
$grid->addContent('<font size="-3">&nbsp;</font>');
        
$grid->addContent('<font size="-3">&nbsp;</font>');
        
      } else if (
'' != $el) {
        
        
$grid->addContent($el->getLabel() . '&nbsp;');
        
        if (isset(
$valresults[$el->getName()])) {
          
// error
          
$error = new gridlayout(21);
          
$error->addContent($el->get());
          
$error->addContent('<div style="color: maroon;">' $valresults[$el->getName()] . '</div>');
          
          
$grid->addContent($error->get());
          
        } else {
          
          
$grid->addContent($el->get());
          
        }
        
        
$grid->addContent('<font size="-3">&nbsp;</font>');
        
$grid->addContent('<font size="-3">&nbsp;</font>');
        
      }
      
    }

    return 
$grid->get();
  } 
// end func dumpFormElements
  
// end class form_page_form
?>
    

<  ^  >

 Neues

 XML/XSLT Menu
 OOH-Form Rewrite

 PEAR Cache:
  SHM Container

 Suchstring Parser
 Buchrezensionen
 PEAR Cache:
  OutputCompression

 PEAR Menu Browser
 PEAR Menu Tutorial 
 PEAR Cache


 Tipp

Download Version:
oben rechts,
Download *.tar.gz
|
| --- |
|
  Top   |   <  ^  >   |   phpOpenTracker Statistik   |   URL: http://www.ulf-wendel.de/schulung/ooh/pages/page_form2.php   |   Stand: 16.11.2001   |   © Ulf Wendel   
|
| --- |

0.019 s Bearbeitungszeit, 0.002 s IT[X], 0.004 s Menu 3