Saturday, April 09, 2005

The Junkyard of Abandoned Php Code

If such a thing existed, this would end up there:

// id next stage
reset($STAGES);
while ( current($STAGES) != $stage_name ) {
if ( !next($STAGES) ) {
trigger_error(__FUNCTION__."stage name '$stage_name' not matched
", E_USER_ERROR);
}
}
$next_stage = next($STAGES);

// determine whether to skip this stage
/* going forward */
if ( $skip === TRUE ) { /* skip flag set, SUB_MEMO to fw_backend: skip the next stage */

$_SESSION['skip_stage'][$stage_name] = TRUE;
$SUB_MEMO = array('action' => 'redirect', 'target' => 'self', 'stage' => 1);
return $SUB_MEMO;

} elseif ( $skip === FALSE ) { /* if isset and !TRUE */

$_SESSION['skip_stage'][$stage_name] = FALSE; /* session SESSION skip_stage {$name} to FALSE */
return $SUB_MEMO;

}

/* going backward (from subsequent stage) */
if ( $_SESSION['form_wizard']['prev_stage'] == $next_stage && $_SESSION['skip_stage'][$stage_name] ) {

$_SESSION['form_wizard']['prev_stage'] = 'null';
$SUB_MEMO = array('action' => 'redirect', 'target' => 'self', 'stage' => -1);
return $SUB_MEMO;
}

return $SUB_MEMO;


Also this:

// SUB_MEMO (from Fx fw_substage() for optional wizard stages)
if ( $SUB_MEMO['action'] == 'redirect' ) {
if ( $SUB_MEMO['target'] == 'self' ) {
$_SESSION['form_wizard']['prev_stage'] = $STAGES[$stage_count]; /* update prev stage name */
$_SESSION['form_wizard']['counter'] = $_SESSION['form_wizard']['counter'] + $SUB_MEMO['stage']; /* update counter */
header("Location:{$_SERVER['PHP_SELF']}"); /* redirect */
} else { /* should never fire -- should always target self */
trigger_error('Backend firing non-self target from SUB_MEMO', E_USER_NOTICE);
$_SESSION['form_wizard']['prev_stage'] = $STAGES[$stage_count];
header("Location:{$SUB_MEMO['target']}");
}
}

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home