Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Matrix Builder
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 26 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -83,6 +83,11 @@ class _Matrix extends \IPS\Helpers\Form
|
||||
* @brief Manageable? (Rows can be added and deleted)
|
||||
*/
|
||||
public $manageable = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Squash fields? (values in the matrix are json_encode'd as a single value to get around max_post_vars limits)
|
||||
*/
|
||||
public $squashFields = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Added rows
|
||||
@@ -116,6 +121,11 @@ class _Matrix extends \IPS\Helpers\Form
|
||||
* @brief Show tooltips in each cell?
|
||||
*/
|
||||
public $showTooltips = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Form Id, Set it Matrix is part of a form
|
||||
*/
|
||||
public $formId = NULL;
|
||||
|
||||
/**
|
||||
* Get HTML
|
||||
@@ -126,12 +136,16 @@ class _Matrix extends \IPS\Helpers\Form
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->matrix( $this->id, array_keys( $this->columns ), $this->elements(), $this->action, $this->hiddenValues, $this->actionButtons, $this->langPrefix, $this->calculateWidths(), $this->manageable, $this->checkAlls, $this->checkAllRows, $this->classes, $this->showTooltips );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->matrix( $this->id, array_keys( $this->columns ), $this->elements(), $this->action, $this->hiddenValues, $this->actionButtons, $this->langPrefix, $this->calculateWidths(), $this->manageable, $this->checkAlls, $this->checkAllRows, $this->classes, $this->showTooltips, $this->squashFields );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\IPS::exceptionHandler( $e );
|
||||
}
|
||||
catch ( \Throwable $e )
|
||||
{
|
||||
\IPS\IPS::exceptionHandler( $e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,7 +155,7 @@ class _Matrix extends \IPS\Helpers\Form
|
||||
*/
|
||||
public function nested()
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->matrixNested( $this->id, array_keys( $this->columns ), $this->elements(), $this->action, $this->hiddenValues, $this->actionButtons, $this->langPrefix, $this->calculateWidths(), $this->manageable, $this->checkAlls, $this->checkAllRows, $this->classes, $this->showTooltips );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->matrixNested( $this->id, array_keys( $this->columns ), $this->elements(), $this->action, $this->hiddenValues, $this->actionButtons, $this->langPrefix, $this->calculateWidths(), $this->manageable, $this->checkAlls, $this->checkAllRows, $this->classes, $this->showTooltips, $this->squashFields );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,21 +185,22 @@ class _Matrix extends \IPS\Helpers\Form
|
||||
* @return array
|
||||
*/
|
||||
public function elements( $getValues=TRUE )
|
||||
{
|
||||
{
|
||||
if ( $this->elements === NULL )
|
||||
{
|
||||
/* Stuff about our form */
|
||||
$name = "{$this->id}_submitted";
|
||||
$formName = $this->formId ? "{$this->formId}_submitted" : NULL;
|
||||
$matrixName = "{$this->id}_matrixRows";
|
||||
$matrixValues = \IPS\Request::i()->$matrixName;
|
||||
|
||||
|
||||
/* Loop our defined rows */
|
||||
$this->elements = array();
|
||||
$this->elements = array();
|
||||
foreach ( $this->rows as $rowId => $data )
|
||||
{
|
||||
/* Have we deleted this row? */
|
||||
$deleteKey = "{$rowId}_delete";
|
||||
if ( $this->manageable and isset( \IPS\Request::i()->$name ) and ( isset( \IPS\Request::i()->$deleteKey ) or !isset( $matrixValues[ $rowId ] ) or !$matrixValues[ $rowId ] ) )
|
||||
if ( $this->manageable and ( isset( \IPS\Request::i()->$name ) or ( $formName and isset( \IPS\Request::i()->$formName ) ) ) and ( isset( \IPS\Request::i()->$deleteKey ) or !isset( $matrixValues[ $rowId ] ) or !$matrixValues[ $rowId ] ) )
|
||||
{
|
||||
$this->removedRows[] = $rowId;
|
||||
continue;
|
||||
@@ -300,6 +315,25 @@ class _Matrix extends \IPS\Helpers\Form
|
||||
$name = "{$this->id}_submitted";
|
||||
if( $force or ( isset( \IPS\Request::i()->$name ) and \IPS\Request::i()->csrfKey === \IPS\Session::i()->csrfKey ) )
|
||||
{
|
||||
|
||||
// Do we need to unsquash any values?
|
||||
// Squashed values are json_encoded by javascript to prevent us exceeding max_post_vars
|
||||
$squashedField = $this->id . '_squashed';
|
||||
|
||||
// If 'squashedField' isn't in the request it might indicate the user didn't have JS enabled
|
||||
if ( $this->squashFields && isset( \IPS\Request::i()->$squashedField ) )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->$squashedField ) )
|
||||
{
|
||||
$unsquashed = json_decode( \IPS\Request::i()->$squashedField, TRUE );
|
||||
|
||||
foreach( $unsquashed as $key => $value )
|
||||
{
|
||||
\IPS\Request::i()->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $this->elements( FALSE ) as $rowId => $columns )
|
||||
{
|
||||
if ( is_array( $columns ) )
|
||||
|
||||
Reference in new issue
Block a user