cvs: pear /HTML_OOH_Form/examples/wizard form_wizard_simple.php session_helper.php
| From: | Ulf Wendel | Date: | Sun, 14 Oct 2001 18:55:02 +0000 |
| Subject: | cvs: pear /HTML_OOH_Form/examples/wizard form_wizard_simple.php session_helper.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1021@lists.php.net to get a copy of this message | ||
uw Sun Oct 14 14:55:02 2001 EDT
Added files:
/pear/HTML_OOH_Form/examples/wizard form_wizard_simple.php
session_helper.php
Log:
Simple wizard example.
Index: pear/HTML_OOH_Form/examples/wizard/form_wizard_simple.php
+++ pear/HTML_OOH_Form/examples/wizard/form_wizard_simple.php
<?php
define('FORM_INCLUDE_DIR', $DOCUMENT_ROOT . 'projekte/form/');
include_once(FORM_INCLUDE_DIR . 'form_wizard.php');
include_once(FORM_INCLUDE_DIR . 'tests/session_helper.php');
#include_once(FORM_INCLUDE_DIR . 'tests/form_adress.php');
#include_once(FORM_INCLUDE_DIR . 'tests/form_page_adress.php');
#include_once(FORM_INCLUDE_DIR . 'tests/form_page_finish.php')
class form_wizard_simple extends form_wizard {
function handleNext($last) {
if (1 == count($this->pages)) {
if ($this->validation_flags['ice']) {
// user selected the correct icecream...
include_once(FORM_INCLUDE_DIR . 'tests/form_adress.php');
include_once(FORM_INCLUDE_DIR . 'tests/form_page_adress.php');
$this->addPage('adr', new form_page_adress(new form_adress()));
return 'adr';
} else {
// bad boy...
include_once(FORM_INCLUDE_DIR . 'tests/form_page_finish.php');
$this->addPage('fin', new form_page_finish());
return 'fin';
}
}
// bad boy - no way out
if (isset($this->pages['fin']))
return 'fin';
return parent::handleNext($last);
}
function handleBack($last) {
// bad boy - no way out
if (isset($this->pages['fin']))
return 'fin';
return parent::handleBack($last);
}
}
if (!is_object($w)) {
include_once(FORM_INCLUDE_DIR . 'tests/form_icecream.php');
include_once(FORM_INCLUDE_DIR . 'tests/form_page_icecream.php');
$w = new form_wizard_simple;
$w->addPage('ice', new form_page_icecream(new form_icecream()));
}
$total_inc = session_pre_include();
session_register('w');
$w->show();
print "Size of included files: $total_inc Bytes<br>";
session_save_include();
?>
Index: pear/HTML_OOH_Form/examples/wizard/session_helper.php
+++ pear/HTML_OOH_Form/examples/wizard/session_helper.php
<?php
function session_pre_include() {
// I hate sessions
if (file_exists(FORM_INCLUDE_DIR . 'wizard_simple.tmp')) {
$inc_files = unserialize(implode('', file(FORM_INCLUDE_DIR .
'wizard_simple.tmp')));
$size = 0;
foreach ($inc_files as $k => $file) {
include_once($file);
$size += filesize($file);
}
}
return $size;
}
function session_save_include() {
$inc_files = serialize(get_included_files());
$fp = fopen(FORM_INCLUDE_DIR . 'wizard_simple.tmp', 'w');
fwrite($fp, $inc_files);
fclose($fp);
}
?>