Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

+42 -11
View File
@@ -1,12 +1,11 @@
<?php
/**
* @brief Wizard Helper
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 25 Jul 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\Helpers;
@@ -67,6 +66,11 @@ class _Wizard
*/
protected $dataKey = TRUE;
/**
* @brief Flag to reset session data when wizard completes
*/
public $resetWhenDone = FALSE;
/**
* @brief Template
*/
@@ -77,16 +81,20 @@ class _Wizard
*
* @param array $steps An array of callback functions. Each function should return either a string to output or (if the step is done) an array (which can be blank) of arbitrary data to retain between steps (which will be passed to each callback function). The keys should be langauge keys for the title of the step.
* @param \IPS\Http\Url $baseUrl The base URL (used when moving between steps)
* @param array $initialData The initial data
* @param bool $showSteps Whether or not to show the step bar
* @param array|NULL $initialData The initial data, if any
* @param bool $resetWhenDone Whether or not to reset the session data when the wizard completes
* @param string|array|null $ignoreQueryParams String or array of URL params to ignore. For example, the base URL may be /submit/ but your userland code adds params /submit/?foo=bar, this changes the baseUrl and creates a new wizard session
* @return void
*/
public function __construct( $steps, $baseUrl, $showSteps=TRUE, $initialData=NULL )
public function __construct( $steps, $baseUrl, $showSteps=TRUE, $initialData=NULL, $resetWhenDone=FALSE, $ignoreQueryParams=NULL )
{
$this->steps = $steps;
$this->baseUrl = $baseUrl;
$this->baseUrl = ( $ignoreQueryParams != NULL ) ? $baseUrl->stripQueryString( $ignoreQueryParams ) : $baseUrl;
$this->showSteps = $showSteps;
$this->resetWhenDone = $resetWhenDone;
$this->template = array( \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' ), 'wizard' );
if ( isset( \IPS\Request::i()->_new ) )
{
unset( $_SESSION[ 'wizard-' . md5( $this->baseUrl ) . '-step' ] );
@@ -153,6 +161,18 @@ class _Wizard
}
}
if ( isset( \IPS\Request::i()->_moveToStep ) and in_array( \IPS\Request::i()->_moveToStep, $stepKeys ) )
{
foreach ( $stepKeys as $key )
{
if ( $key == \IPS\Request::i()->_moveToStep )
{
$activeStep = $key;
break;
}
}
}
/* Get it's output */
$output = call_user_func( $this->steps[ $activeStep ], $data );
while ( is_array( $output ) )
@@ -178,10 +198,21 @@ class _Wizard
/* Update the Wizard session data */
$_SESSION[ 'wizard-' . md5( $this->baseUrl ) . '-step' ] = $activeStep;
$_SESSION[ 'wizard-' . md5( $this->baseUrl ) . '-data' ] = $data;
$copyOfStepKeys = $stepKeys;
$lastStep = array_pop( $copyOfStepKeys );
/* Last step? */
if ( $this->resetWhenDone and ( $lastStep === $activeStep ) )
{
/* Wipe session data */
unset( $_SESSION[ 'wizard-' . md5( $this->baseUrl ) . '-step' ] );
unset( $_SESSION[ 'wizard-' . md5( $this->baseUrl ) . '-data' ] );
}
$output = call_user_func( $this->steps[ $activeStep ], $data );
}
/* Display */
return call_user_func( $this->template, $stepKeys, $activeStep, $output, $this->baseUrl, $this->showSteps );
}