cvs: pear /HTML_OOH_Form/examples/pages form_icecream.php form_page_adress.php form_page_finish.php form_page_icecream.php

From: Date: Sun, 14 Oct 2001 19:00:56 +0000
Subject: cvs: pear /HTML_OOH_Form/examples/pages form_icecream.php form_page_adress.php form_page_finish.php form_page_icecream.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1022@lists.php.net to get a copy of this message
uw Sun Oct 14 15:00:56 2001 EDT Added files: /pear/HTML_OOH_Form/examples/pages form_icecream.php form_page_adress.php form_page_finish.php form_page_icecream.php Log: Page examples. Index: pear/HTML_OOH_Form/examples/pages/form_icecream.php +++ pear/HTML_OOH_Form/examples/pages/form_icecream.php <?php define('FORM_INCLUDE_DIR', $DOCUMENT_ROOT . 'projekte/form/'); include_once(FORM_INCLUDE_DIR . 'form.php'); // the classical way: derive from form, build the form using init() class form_icecream extends form { function init() { $this->setElementnamePrefix('i_'); $this->addElement( array( 'name' => 'ice', 'elname' => 'ice_straw', 'type' => 'radio', 'label' => 'Strawberry', // not shown by default but used by form_page 'value' => 'Strawberry' ) ); $this->addElement( array( 'name' => 'ice', 'elname' => 'ice_vanilla', 'type' => 'radio', 'label' => 'Vanilla', 'value' => 'Vanilla' ) ); $this->addElement( array( 'name' => 'ice', 'elname' => 'ice_other', 'type' => 'radio', 'label' => 'other', 'value' => 'other' ) ); $this->addElement( array( 'name' => 'other', 'type' => 'text', 'label' => 'I like... ' ) ); $this->addElement( array( 'name' => 'action', 'type' => 'submit', 'value' => 'save' ) ); } // end func init() } // end class form_icecream // just to be able to include the class definition without displaying it function show_form_icecream() { $ice = new form_icecream(); $ice->autoloadValues(); $ice->Start(); printf('%s %s ', $ice->getLabel('ice_straw'), $ice->getElement('ice_straw')); printf('%s %s ', $ice->getLabel('ice_vanilla'), $ice->getElement('ice_vanilla')); printf('%s %s<br>', $ice->getLabel('ice_other'), $ice->getElement('ice_other')); printf('%s %s<br>', $ice->getLabel('i_other'), $ice->getElement('i_other')); $ice->Finish(); } #show_form_icecream(); ?> Index: pear/HTML_OOH_Form/examples/pages/form_page_adress.php +++ pear/HTML_OOH_Form/examples/pages/form_page_adress.php <?php define('FORM_INCLUDE_DIR', $DOCUMENT_ROOT . 'projekte/form/'); include_once(FORM_INCLUDE_DIR . 'form_page_form.php'); include_once(FORM_INCLUDE_DIR . 'tests/form_adress.php'); include_once(FORM_INCLUDE_DIR . 'layoutmanager/form_grouplayout.php'); include_once(FORM_INCLUDE_DIR . 'layoutmanager/form_flowlayout.php'); include_once(FORM_INCLUDE_DIR . 'layoutmanager/form_gridlayout.php'); /** * Adress form page to be used with a wizard * * @author Ulf Wendel <ulf.wendel@phpdoc.de> * @version $Id: form_page_adress.php,v 1.1 2001/10/14 19:00:56 uw Exp $ * @access public * @package Form */ class form_page_adress extends form_page_form { /** * Dump one element. * * @param string element name * @param array validation results * @return string */ function dumpElement($el, &$valres) { if (isset($valres[$el])) { // show error message below the element itself $grid = new gridlayout(2, 1); $grid->addContent($this->form->getElement($el)); $grid->addContent($valres[$el]); return $grid->get(); } else { // no errors return $this->form->getElement($el); } } // end func dumpElement function get($startfinish = false) { // reload HTTP_[POST|GET]_VARS $this->form->autoloadValues(); // store validation flags $valres = $this->form->validate(); $valres = $valres[1]; // page frame $group = new grouplayout('Tell me more about you'); // page content $flow = new flowlayout(); if ($startfinish) { $flow->addContent($this->form->Start()); $flow->insertBreak(); } $grid = new gridlayout(3, 2); $grid->addContent($this->form->getLabel('a_title') . '&nbsp;'); $grid->addContent($this->dumpElement('a_title', &$valres)); $grid->addContent($this->form->getLabel('a_firstname') . '&nbsp;'); $flow2 = new flowlayout(); $flow2->addContent($this->dumpElement('a_firstname', &$valres)); $flow2->addContent($this->form->getLabel('a_lastname') . '&nbsp;'); $flow2->addContent($this->dumpElement('a_lastname', &$valres)); $grid->addItem(&$flow2); $flow->addItem(&$grid); if ($startfinish) { $flow->insertBreak(); $flow->addContent($this->form->Finish()); } $group->addContent($flow->get()); return $group->get(); } // end func get } // end class form_page_form #$p = new form_page_adress(new form_adress()); #print $p->get(true); ?> Index: pear/HTML_OOH_Form/examples/pages/form_page_finish.php +++ pear/HTML_OOH_Form/examples/pages/form_page_finish.php <?php define('FORM_INCLUDE_DIR', $DOCUMENT_ROOT . 'projekte/form/'); include_once(FORM_INCLUDE_DIR . 'form_page.php'); include_once(FORM_INCLUDE_DIR . 'layoutmanager/form_grouplayout.php'); class form_page_finish extends form_page { var $msg = 'I do not like your icecream, wizard finished.'; function get() { $group = new grouplayout('Finished'); $group->addContent($this->msg); return $group->get(); } // end func get function getValues() { return array($this->msg); } // end func getValues } // end class form_page_finish #$p = new form_page_finish; #$p->show(); ?> Index: pear/HTML_OOH_Form/examples/pages/form_page_icecream.php +++ pear/HTML_OOH_Form/examples/pages/form_page_icecream.php <?php define('FORM_INCLUDE_DIR', $DOCUMENT_ROOT . 'projekte/form/'); include_once(FORM_INCLUDE_DIR . 'form_page_form.php'); include_once(FORM_INCLUDE_DIR . 'tests/form_icecream.php'); include_once(FORM_INCLUDE_DIR . 'layoutmanager/form_grouplayout.php'); include_once(FORM_INCLUDE_DIR . 'layoutmanager/form_flowlayout.php'); include_once(FORM_INCLUDE_DIR . 'layoutmanager/form_gridlayout.php'); class form_page_icecream extends form_page_form { function get($startfinish = false) { $this->form->autoloadValues(); $group = new grouplayout('Your favourite icecream...'); $flow = new flowlayout(); if ($startfinish) { $flow->addContent($this->form->Start()); $flow->insertBreak(); } $grid = new gridlayout(5, 2); $elements = array('ice_straw', 'ice_vanilla', 'ice_other', 'i_other', 'i_action'); reset($elements); while (list($k, $element) = each($elements)) { $grid->addContent($this->form->getLabel($element) . '&nbsp;'); $grid->addContent($this->form->getElement($element)); } $flow->addItem(&$grid); if ($startfinish) { $flow->insertBreak(); $flow->addContent($this->form->Finish()); } $group->addContent($flow->get()); return $group->get(); } // end func get function isValid() { $this->form->autoloadValues(); return ('Vanilla' == $this->form->getValue('i_ice')) ? true : false; } // end func isValid } // end class form_page_form #$p = new form_page_icecream(new form_icecream()); #print $p->get(true); ?>

« previous php.pear.cvs (#1022) next »