Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Dynamic Chart Helper with user-supplied results
|
||||
* @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 28 Mar 2017
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Chart;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic Chart Helper with user supplied results.
|
||||
* This is similar to \IPS\Helpers\Chart\Database but with results supplied manually in user-land code.
|
||||
* Useful when you need to merge results from multiple sources.
|
||||
*/
|
||||
class _Callback extends \IPS\Helpers\Chart\Dynamic
|
||||
{
|
||||
/**
|
||||
* @brief Callback to retrieve results
|
||||
*/
|
||||
public $callback;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Http\Url $url The URL the chart will be displayed on
|
||||
* @param callable $callback Callback to fetch results
|
||||
* @param string $title Title
|
||||
* @param array $options Options
|
||||
* @param string $defaultType The default chart type
|
||||
* @param string $defaultTimescale The default timescale to use
|
||||
* @param array $defaultTimes The default start/end times to use
|
||||
* @param string $identifier If there will be more than one chart per page, provide a unique identifier
|
||||
* @param \IPS\DateTime|NULL $minimumDate The earliest available date for this chart
|
||||
* @see <a href='https://google-developers.appspot.com/chart/interactive/docs/gallery'>Charts Gallery - Google Charts - Google Developers</a>
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Http\Url $url, $callback=NULL, $title='', $options=array(), $defaultType='AreaChart', $defaultTimescale='monthly', $defaultTimes=array( 'start' => 0, 'end' => 0 ), $identifier='', $minimumDate=NULL )
|
||||
{
|
||||
$this->identifier = \substr( md5( (string) $url ), 0, 6 ) . $identifier;
|
||||
$this->callback = $callback;
|
||||
|
||||
parent::__construct( $url, $title, $options, $defaultType, $defaultTimescale, $defaultTimes, $identifier, $minimumDate );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Series
|
||||
*
|
||||
* @param string $name Name
|
||||
* @param string $type Type of value
|
||||
* @li string
|
||||
* @li number
|
||||
* @li boolean
|
||||
* @li date
|
||||
* @li datetime
|
||||
* @li timeofday
|
||||
* @param bool $filterable If TRUE, will show as a filter option to be toggled on/off
|
||||
* @return void
|
||||
*/
|
||||
public function addSeries( $name, $type, $filterable=TRUE )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $name );
|
||||
$filterKey = $name;
|
||||
|
||||
if ( !$filterable or !isset( \IPS\Request::i()->filters[ $this->identifier ] ) or in_array( $filterKey, \IPS\Request::i()->filters[ $this->identifier ] ) )
|
||||
{
|
||||
if ( $this->type !== 'PieChart' and $this->type !== 'GeoChart' )
|
||||
{
|
||||
$this->addHeader( $name, $type );
|
||||
}
|
||||
|
||||
$this->series[ $filterKey ] = $filterKey;
|
||||
|
||||
if ( $filterable )
|
||||
{
|
||||
$this->currentFilters[] = $filterKey;
|
||||
|
||||
if ( isset( \IPS\Request::i()->filters[ $this->identifier ] ) )
|
||||
{
|
||||
$this->url = $this->url->setQueryString( 'filters', array( $this->identifier => $this->currentFilters ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $filterable )
|
||||
{
|
||||
$this->availableFilters[ $filterKey ] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the chart output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOutput()
|
||||
{
|
||||
/* Init data */
|
||||
$data = $this->initData();
|
||||
|
||||
/* Pie Chart */
|
||||
if ( $this->type === 'PieChart' or $this->type === 'GeoChart' )
|
||||
{
|
||||
$rows = call_user_func( $this->callback, $this );
|
||||
|
||||
foreach ( $rows as $k => $v )
|
||||
{
|
||||
if( count( $this->availableFilters ) and !in_array( $k, $this->currentFilters ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->addRow( array( 'key' => $this->availableFilters[ $k ], 'value' => $v ) );
|
||||
}
|
||||
|
||||
$output = $this->render( $this->type, $this->options, $this->format );
|
||||
}
|
||||
|
||||
/* Graph */
|
||||
else
|
||||
{
|
||||
$rows = call_user_func( $this->callback, $this );
|
||||
|
||||
foreach ( $rows as $row )
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach( $this->series as $column )
|
||||
{
|
||||
$result[ $column ] = $row[ $column ];
|
||||
}
|
||||
|
||||
$data[ $row['time'] ] = $result;
|
||||
}
|
||||
|
||||
ksort( $data, SORT_NATURAL );
|
||||
|
||||
/* Add to graph */
|
||||
$min = NULL;
|
||||
$max = NULL;
|
||||
foreach ( $data as $time => $d )
|
||||
{
|
||||
$datetime = new \IPS\DateTime;
|
||||
|
||||
if ( \IPS\Member::loggedIn()->timezone )
|
||||
{
|
||||
try
|
||||
{
|
||||
$datetime->setTimezone( new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Member::loggedIn()->timezone = null;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
}
|
||||
}
|
||||
|
||||
$datetime->setTime( 0, 0, 0 );
|
||||
$exploded = explode( '-', $time );
|
||||
switch ( $this->timescale )
|
||||
{
|
||||
case 'none':
|
||||
$datetime = \IPS\DateTime::ts( $time );
|
||||
break;
|
||||
|
||||
case 'daily':
|
||||
$datetime->setDate( (float) $exploded[0], $exploded[1], $exploded[2] );
|
||||
//$datetime = $datetime->localeDate();
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
$datetime->setISODate( (float) $exploded[0], $exploded[1] );
|
||||
//$datetime = $datetime->localeDate();
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
$datetime->setDate( (float) $exploded[0], $exploded[1], 1 );
|
||||
//$datetime = $datetime->format( 'F Y' );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( empty( $d ) )
|
||||
{
|
||||
if ( empty( $this->series ) )
|
||||
{
|
||||
$this->addRow( array( $datetime ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addRow( array_merge( array( $datetime ), array_fill( 0, count( $this->series ), 0 ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( count($d) < count($this->series) )
|
||||
{
|
||||
$this->addRow( array_merge( array( $datetime ), $d, array_fill( 0, count($this->series) - count($d), 0 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addRow( array_merge( array( $datetime ), $d ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $data ) === 1 )
|
||||
{
|
||||
$this->options['domainAxis']['type'] = 'category';
|
||||
}
|
||||
|
||||
$output = $this->render( $this->type, $this->options, $this->format );
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Chart 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 12 Jul 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers;
|
||||
|
||||
@@ -0,0 +1,372 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Dynamic Database Chart Helper
|
||||
* @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 27 Aug 2013
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Chart;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic Database Chart Helper
|
||||
*/
|
||||
class _Database extends \IPS\Helpers\Chart\Dynamic
|
||||
{
|
||||
/**
|
||||
* @brief Database Table
|
||||
*/
|
||||
protected $table;
|
||||
|
||||
/**
|
||||
* @brief Database column that contains date
|
||||
*/
|
||||
protected $dateField;
|
||||
|
||||
/**
|
||||
* @brief Where clauses
|
||||
*/
|
||||
public $where = array();
|
||||
|
||||
/**
|
||||
* @brief Extra column to group by (useful for multi-data line charts)
|
||||
*/
|
||||
public $groupBy = '';
|
||||
|
||||
/**
|
||||
* @brief Group by keys for the series
|
||||
*/
|
||||
protected $groupByKeys = array();
|
||||
|
||||
/**
|
||||
* @brief Table Columns
|
||||
*/
|
||||
public $tableInclude = array();
|
||||
|
||||
/**
|
||||
* @brief Table Column Formatters
|
||||
*/
|
||||
public $tableParsers = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Http\Url $url The URL the chart will be displayed on
|
||||
* @param string $table Database Table
|
||||
* @param string $dateField Database column that contains date
|
||||
* @param string $title Title
|
||||
* @param array $options Options
|
||||
* @param string $defaultType The default chart type
|
||||
* @param string $defaultTimescale The default timescale to use
|
||||
* @param array $defaultTimes The default start/end times to use
|
||||
* @param array $tableInclude Table columns to include in results
|
||||
* @param string $identifier If there will be more than one chart per page, provide a unique identifier
|
||||
* @param \IPS\DateTime|NULL $minimumDate The earliest available date for this chart
|
||||
* @see <a href='https://google-developers.appspot.com/chart/interactive/docs/gallery'>Charts Gallery - Google Charts - Google Developers</a>
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Http\Url $url, $table, $dateField, $title='', $options=array(), $defaultType='AreaChart', $defaultTimescale='monthly', $defaultTimes=array( 'start' => 0, 'end' => 0 ), $tableInclude=array(), $identifier='', $minimumDate=NULL )
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->dateField = $dateField;
|
||||
$this->identifier = \substr( md5( $table . $dateField ), 0, 6 ) . $identifier;
|
||||
|
||||
if ( !empty( $tableInclude ) )
|
||||
{
|
||||
$this->tableInclude = $tableInclude;
|
||||
$this->availableTypes[] = 'Table';
|
||||
}
|
||||
|
||||
parent::__construct( $url, $title, $options, $defaultType, $defaultTimescale, $defaultTimes, $identifier, $minimumDate );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Series
|
||||
*
|
||||
* @param string $name Name
|
||||
* @param string $type Type of value
|
||||
* @li string
|
||||
* @li number
|
||||
* @li boolean
|
||||
* @li date
|
||||
* @li datetime
|
||||
* @li timeofday
|
||||
* @param string $sql SQL expression to get value
|
||||
* @param bool $filterable If TRUE, will show as a filter option to be toggled on/off
|
||||
* @param string $groupByKey If $this->groupBy is set, the raw key value
|
||||
* @return void
|
||||
*/
|
||||
public function addSeries( $name, $type, $sql, $filterable=TRUE, $groupByKey=NULL )
|
||||
{
|
||||
if ( $groupByKey !== NULL )
|
||||
{
|
||||
$filterKey = $groupByKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $name );
|
||||
$filterKey = $name;
|
||||
}
|
||||
|
||||
if ( !$filterable or !isset( \IPS\Request::i()->filters[ $this->identifier ] ) or in_array( $filterKey, \IPS\Request::i()->filters[ $this->identifier ] ) )
|
||||
{
|
||||
if ( $this->type !== 'PieChart' and $this->type !== 'GeoChart' )
|
||||
{
|
||||
$this->addHeader( $name, $type );
|
||||
}
|
||||
|
||||
if( $this->groupBy )
|
||||
{
|
||||
$this->groupByKeys[] = $groupByKey;
|
||||
}
|
||||
|
||||
$this->series[ $filterKey ] = $sql;
|
||||
|
||||
if ( $filterable )
|
||||
{
|
||||
$this->currentFilters[] = $filterKey;
|
||||
|
||||
if ( isset( \IPS\Request::i()->filters[ $this->identifier ] ) )
|
||||
{
|
||||
$this->url = $this->url->setQueryString( 'filters', array( $this->identifier => $this->currentFilters ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $filterable )
|
||||
{
|
||||
$this->availableFilters[ $filterKey ] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the chart output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOutput()
|
||||
{
|
||||
/* Init data */
|
||||
$data = $this->initData();
|
||||
|
||||
/* Work out where clause */
|
||||
$where = $this->where;
|
||||
$where[] = array( "{$this->dateField}>?", 0 );
|
||||
if ( $this->start )
|
||||
{
|
||||
$where[] = array( "{$this->dateField}>?", $this->start->getTimestamp() );
|
||||
}
|
||||
if ( $this->end )
|
||||
{
|
||||
$where[] = array( "{$this->dateField}<?", $this->end->getTimestamp() );
|
||||
}
|
||||
|
||||
/* What's our SQL time? */
|
||||
switch ( $this->timescale )
|
||||
{
|
||||
case 'daily':
|
||||
$timescale = '%Y-%c-%e';
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
$timescale = '%Y-%u';
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
$timescale = '%Y-%c';
|
||||
break;
|
||||
}
|
||||
|
||||
/* Table... */
|
||||
if ( $this->type === 'Table' )
|
||||
{
|
||||
$table = new \IPS\Helpers\Table\Db( $this->table, $this->url, $where );
|
||||
$table->include = $this->tableInclude;
|
||||
$table->parsers = $this->tableParsers;
|
||||
$table->sortBy = $table->sortBy ?: $this->dateField;
|
||||
$output = (string) $table;
|
||||
}
|
||||
|
||||
/* Pie Chart */
|
||||
if ( $this->type === 'PieChart' or $this->type === 'GeoChart' )
|
||||
{
|
||||
$keys = array_unique( $this->series );
|
||||
$key = array_pop( $keys );
|
||||
|
||||
$stmt = \IPS\Db::i()->select(
|
||||
"{$key}" . ( $this->groupBy ? ", {$this->groupBy}" : '' ),
|
||||
$this->table,
|
||||
$where,
|
||||
NULL,
|
||||
NULL,
|
||||
$this->groupBy
|
||||
)->setKeyField( $this->groupBy )->setValueField( $key );
|
||||
|
||||
foreach ( $stmt as $k => $v )
|
||||
{
|
||||
if( count( $this->availableFilters ) and !in_array( $k, $this->currentFilters ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$this->addRow( array( 'key' => $this->availableFilters[ $k ], 'value' => $v ) );
|
||||
}
|
||||
|
||||
$output = $this->render( $this->type, $this->options, $this->format );
|
||||
}
|
||||
|
||||
/* Graph */
|
||||
else
|
||||
{
|
||||
/* Fetch */
|
||||
$fromUnixTime = "FROM_UNIXTIME( IFNULL( {$this->dateField}, 0 ) )";
|
||||
if ( !$this->timezoneError and \IPS\Member::loggedIn()->timezone and in_array( \IPS\Member::loggedIn()->timezone, \DateTimeZone::listIdentifiers() ) )
|
||||
{
|
||||
$fromUnixTime = "CONVERT_TZ( {$fromUnixTime}, @@session.time_zone, '" . \IPS\Db::i()->escape_string( \IPS\Member::loggedIn()->timezone ) . "' )";
|
||||
}
|
||||
$stmt = \IPS\Db::i()->select(
|
||||
"DATE_FORMAT( {$fromUnixTime}, '{$timescale}' ) AS time_as_alias, " . implode( ', ', array_unique( $this->series ) ) . ( $this->groupBy ? ", " . $this->groupBy : '' ),
|
||||
$this->table,
|
||||
$where,
|
||||
'time_as_alias ASC',
|
||||
NULL,
|
||||
$this->groupBy ? array( 'time_as_alias', $this->groupBy ) : 'time_as_alias'
|
||||
);
|
||||
|
||||
foreach ( $stmt as $row )
|
||||
{
|
||||
$result = array();
|
||||
|
||||
if( $this->groupBy )
|
||||
{
|
||||
if( count( $this->availableFilters ) AND !in_array( $row[ $this->groupBy ], $this->currentFilters ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $this->series as $column )
|
||||
{
|
||||
if( $this->groupBy )
|
||||
{
|
||||
if( empty( $data[ $row['time_as_alias'] ] ) )
|
||||
{
|
||||
$result = array( $row[ $this->groupBy ] => $row[ $column ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $data[ $row['time_as_alias'] ];
|
||||
$result[ $row[ $this->groupBy ] ] = $row[ $column ];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result[ $column ] = $row[ $column ];
|
||||
}
|
||||
}
|
||||
|
||||
$data[ $row['time_as_alias'] ] = $result;
|
||||
}
|
||||
|
||||
ksort( $data, SORT_NATURAL );
|
||||
|
||||
/* Add to graph */
|
||||
$min = NULL;
|
||||
$max = NULL;
|
||||
foreach ( $data as $time => $d )
|
||||
{
|
||||
$datetime = new \IPS\DateTime;
|
||||
|
||||
if ( \IPS\Member::loggedIn()->timezone )
|
||||
{
|
||||
try
|
||||
{
|
||||
$datetime->setTimezone( new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Member::loggedIn()->timezone = null;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
}
|
||||
}
|
||||
|
||||
$datetime->setTime( 0, 0, 0 );
|
||||
$exploded = explode( '-', $time );
|
||||
switch ( $this->timescale )
|
||||
{
|
||||
case 'none':
|
||||
$datetime = \IPS\DateTime::ts( $time );
|
||||
break;
|
||||
|
||||
case 'daily':
|
||||
$datetime->setDate( (float) $exploded[0], $exploded[1], $exploded[2] );
|
||||
//$datetime = $datetime->localeDate();
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
$datetime->setISODate( (float) $exploded[0], $exploded[1] );
|
||||
//$datetime = $datetime->localeDate();
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
$datetime->setDate( (float) $exploded[0], $exploded[1], 1 );
|
||||
//$datetime = $datetime->format( 'F Y' );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( empty( $d ) )
|
||||
{
|
||||
if ( empty( $this->series ) )
|
||||
{
|
||||
$this->addRow( array( $datetime ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addRow( array_merge( array( $datetime ), array_fill( 0, count( $this->series ), 0 ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $this->groupBy )
|
||||
{
|
||||
$_values = array();
|
||||
foreach ( $this->series as $id => $col )
|
||||
{
|
||||
$_values[ $id ] = ( isset( $d[ $id ] ) ) ? $d[ $id ] : ( $this->plotZeros ? 0 : NULL );
|
||||
}
|
||||
|
||||
$this->addRow( array_merge( array( $datetime ), $_values ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( count($d) < count($this->series) )
|
||||
{
|
||||
$this->addRow( array_merge( array( $datetime ), $d, array_fill( 0, count($this->series) - count($d), 0 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addRow( array_merge( array( $datetime ), $d ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $data ) === 1 )
|
||||
{
|
||||
$this->options['domainAxis']['type'] = 'category';
|
||||
}
|
||||
|
||||
$output = $this->render( $this->type, $this->options, $this->format );
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
+122
-378
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Dynamic Chart 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
|
||||
* @since 27 Aug 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
* @brief Dynamic Chart Builder Helper
|
||||
* @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 29 Mar 2017
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Chart;
|
||||
@@ -21,38 +20,13 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Dynamic Chart Helper
|
||||
*/
|
||||
class _Dynamic extends \IPS\Helpers\Chart
|
||||
abstract class _Dynamic extends \IPS\Helpers\Chart
|
||||
{
|
||||
/**
|
||||
* @brief URL
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* @brief Database Table
|
||||
*/
|
||||
protected $table;
|
||||
|
||||
/**
|
||||
* @brief Database column that contains date
|
||||
*/
|
||||
protected $dateField;
|
||||
|
||||
/**
|
||||
* @brief Where clauses
|
||||
*/
|
||||
public $where = array();
|
||||
|
||||
/**
|
||||
* @brief Extra column to group by (useful for multi-data line charts)
|
||||
*/
|
||||
public $groupBy = '';
|
||||
|
||||
/**
|
||||
* @brief Group by keys for the series
|
||||
*/
|
||||
protected $groupByKeys = array();
|
||||
|
||||
/**
|
||||
* @brief $timescale (daily, weekly, monthly)
|
||||
*/
|
||||
@@ -96,7 +70,7 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
/**
|
||||
* @brief Available Types
|
||||
*/
|
||||
public $availableTypes = array( 'LineChart', 'ColumnChart', 'BarChart', 'PieChart', 'Table' );
|
||||
public $availableTypes = array( 'AreaChart', 'LineChart', 'ColumnChart', 'BarChart', 'PieChart', 'Table' );
|
||||
|
||||
/**
|
||||
* @brief Available Filters
|
||||
@@ -107,17 +81,7 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
* @brief Current Filters
|
||||
*/
|
||||
public $currentFilters = array();
|
||||
|
||||
/**
|
||||
* @brief Table Columns
|
||||
*/
|
||||
public $tableInclude = array();
|
||||
|
||||
/**
|
||||
* @brief Table Column Formatters
|
||||
*/
|
||||
public $tableParsers = array();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Plot zeros
|
||||
*/
|
||||
@@ -127,23 +91,42 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
* @brief Value for number formatter
|
||||
*/
|
||||
public $format = NULL;
|
||||
|
||||
/**
|
||||
* @brief Allow user to adjust interval (group by daily, monthly, etc.)
|
||||
*/
|
||||
public $showIntervals = TRUE;
|
||||
|
||||
/**
|
||||
* @brief If a warning about timezones needs to be shown
|
||||
*/
|
||||
public $timezoneError = FALSE;
|
||||
|
||||
/**
|
||||
* @brief If set to an \IPS\DateTime instance, minimum time will be checked against this value
|
||||
*/
|
||||
public $minimumDate = NULL;
|
||||
|
||||
/**
|
||||
* @brief Error(s) to show on chart UI
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Http\Url $url The URL the chart will be displayed on
|
||||
* @param string $table Database Table
|
||||
* @param string $dateField Database column that contains date
|
||||
* @param string $title Title
|
||||
* @param array $options Options
|
||||
* @param string $defaultType The default chart type
|
||||
* @param string $defaultTimescale The default timescale to use
|
||||
* @param array $defaultTimes The default start/end times to use
|
||||
* @param string $identifier If there will be more than one chart per page, provide a unique identifier
|
||||
* @param \IPS\DateTime|NULL $minimumDate The earliest available date for this chart
|
||||
* @see <a href='https://google-developers.appspot.com/chart/interactive/docs/gallery'>Charts Gallery - Google Charts - Google Developers</a>
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Http\Url $url, $table, $dateField, $title='', $options=array(), $defaultType='LineChart', $defaultTimescale='monthly', $defaultTimes=array( 'start' => 0, 'end' => 0 ), $tableInclude=array(), $identifier='' )
|
||||
public function __construct( \IPS\Http\Url $url, $title='', $options=array(), $defaultType='AreaChart', $defaultTimescale='monthly', $defaultTimes=array( 'start' => 0, 'end' => 0 ), $identifier='', $minimumDate=NULL )
|
||||
{
|
||||
if ( !isset( $options['chartArea'] ) )
|
||||
{
|
||||
@@ -154,14 +137,12 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
}
|
||||
|
||||
$this->baseURL = $url;
|
||||
$this->table = $table;
|
||||
$this->dateField = $dateField;
|
||||
$this->title = $title;
|
||||
$this->options = $options;
|
||||
$this->timescale = $defaultTimescale;
|
||||
$this->start = $defaultTimes['start'];
|
||||
$this->end = $defaultTimes['end'];
|
||||
$this->identifier = \substr( md5( $table . $dateField ), 0, 6 ) . $identifier;
|
||||
$this->minimumDate = $minimumDate;
|
||||
|
||||
if ( isset( \IPS\Request::i()->type[ $this->identifier ] ) and in_array( \IPS\Request::i()->type[ $this->identifier ], $this->availableTypes ) )
|
||||
{
|
||||
@@ -172,16 +153,6 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
{
|
||||
$this->type = $defaultType;
|
||||
}
|
||||
|
||||
if ( $this->type === 'PieChart' or $this->type === 'GeoChart' )
|
||||
{
|
||||
$this->addHeader( 'key', 'string' );
|
||||
$this->addHeader( 'value', 'number' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addHeader( \IPS\Member::loggedIn()->language()->addToStack('date'), 'date' );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->timescale[ $this->identifier ] ) and in_array( \IPS\Request::i()->timescale[ $this->identifier ], array( 'daily', 'weekly', 'monthly' ) ) )
|
||||
{
|
||||
@@ -189,10 +160,22 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
$url = $url->setQueryString( 'timescale', array( $this->identifier => \IPS\Request::i()->timescale[ $this->identifier ] ) );
|
||||
}
|
||||
|
||||
if ( $this->type === 'PieChart' or $this->type === 'GeoChart' )
|
||||
{
|
||||
$this->addHeader( 'key', 'string' );
|
||||
$this->addHeader( 'value', 'number' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addHeader( \IPS\Member::loggedIn()->language()->addToStack('date'), ( $this->timescale == 'none' ) ? 'datetime' : 'date' );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->start[ $this->identifier ] ) and \IPS\Request::i()->start[ $this->identifier ] )
|
||||
{
|
||||
try
|
||||
{
|
||||
$originalStart = $this->start;
|
||||
|
||||
if ( is_numeric( \IPS\Request::i()->start[ $this->identifier ] ) )
|
||||
{
|
||||
$this->start = \IPS\DateTime::ts( \IPS\Request::i()->start[ $this->identifier ] );
|
||||
@@ -201,8 +184,21 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
{
|
||||
$this->start = new \IPS\DateTime( \IPS\Request::i()->start[ $this->identifier ], new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) );
|
||||
}
|
||||
|
||||
$url = $url->setQueryString( 'start', array( $this->identifier => $this->start->getTimestamp() ) );
|
||||
|
||||
if( $this->minimumDate > $this->start )
|
||||
{
|
||||
$this->errors[] = array( 'string' => 'minimum_chart_date', 'sprintf' => $this->minimumDate->localeDate() );
|
||||
$this->start = $originalStart;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $originalStart );
|
||||
}
|
||||
|
||||
if( $this->start )
|
||||
{
|
||||
$url = $url->setQueryString( 'start', array( $this->identifier => $this->start->getTimestamp() ) );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
@@ -227,81 +223,38 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
|
||||
if ( !empty( $tableInclude ) )
|
||||
{
|
||||
$this->tableInclude = $tableInclude;
|
||||
$this->availableTypes[] = 'Table';
|
||||
}
|
||||
|
||||
|
||||
if ( isset( \IPS\Request::i()->filters[ $this->identifier ] ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'filters', '' );
|
||||
}
|
||||
|
||||
$this->url = $url;
|
||||
|
||||
if ( \IPS\Member::loggedIn()->timezone and in_array( \IPS\Member::loggedIn()->timezone, \DateTimeZone::listIdentifiers() ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$r = \IPS\Db::i()->query( "SELECT TIMEDIFF( NOW(), CONVERT_TZ( NOW(), @@session.time_zone, '" . \IPS\Db::i()->escape_string( \IPS\Member::loggedIn()->timezone ) . "' ) );" )->fetch_row();
|
||||
if ( $r[0] === NULL )
|
||||
{
|
||||
$this->timezoneError = TRUE;
|
||||
}
|
||||
}
|
||||
catch ( \IPS\Db\Exception $e )
|
||||
{
|
||||
$this->timezoneError = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Series
|
||||
* Get the chart output
|
||||
*
|
||||
* @param string $name Name
|
||||
* @param string $type Type of value
|
||||
* @li string
|
||||
* @li number
|
||||
* @li boolean
|
||||
* @li date
|
||||
* @li datetime
|
||||
* @li timeofday
|
||||
* @param string $sql SQL expression to get value
|
||||
* @param bool $filterable If TRUE, will show as a filter option to be toggled on/off
|
||||
* @param string $groupByKey If $this->groupBy is set, the raw key value
|
||||
* @return void
|
||||
* @return string
|
||||
*/
|
||||
public function addSeries( $name, $type, $sql, $filterable=TRUE, $groupByKey=NULL )
|
||||
{
|
||||
$filterKey = $groupByKey ?: $name;
|
||||
if ( $groupByKey !== NULL )
|
||||
{
|
||||
$filterKey = $groupByKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $name );
|
||||
$filterKey = $name;
|
||||
}
|
||||
|
||||
if ( !$filterable or !isset( \IPS\Request::i()->filters[ $this->identifier ] ) or in_array( $filterKey, \IPS\Request::i()->filters[ $this->identifier ] ) )
|
||||
{
|
||||
if ( $this->type !== 'PieChart' and $this->type !== 'GeoChart' )
|
||||
{
|
||||
$this->addHeader( $name, $type );
|
||||
}
|
||||
abstract public function getOutput();
|
||||
|
||||
if( $this->groupBy )
|
||||
{
|
||||
$this->groupByKeys[] = $groupByKey;
|
||||
}
|
||||
|
||||
$this->series[ $filterKey ] = $sql;
|
||||
|
||||
if ( $filterable )
|
||||
{
|
||||
$this->currentFilters[] = $filterKey;
|
||||
|
||||
if ( isset( \IPS\Request::i()->filters[ $this->identifier ] ) )
|
||||
{
|
||||
$this->url = $this->url->setQueryString( 'filters', array( $this->identifier => $this->currentFilters ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $filterable )
|
||||
{
|
||||
$this->availableFilters[ $filterKey ] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML
|
||||
*
|
||||
@@ -311,262 +264,11 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
{
|
||||
try
|
||||
{
|
||||
/* Init data */
|
||||
$data = array();
|
||||
if ( $this->start )
|
||||
{
|
||||
$date = clone $this->start;
|
||||
while ( $date->getTimestamp() < ( $this->end ? $this->end->getTimestamp() : time() ) )
|
||||
{
|
||||
switch ( $this->timescale )
|
||||
{
|
||||
case 'daily':
|
||||
$data[ $date->format( 'Y-n-j' ) ] = array();
|
||||
|
||||
if( $this->groupBy )
|
||||
{
|
||||
foreach( $this->groupByKeys as $key )
|
||||
{
|
||||
$data[ $date->format( 'Y-n-j' ) ][ $key ] = 0;
|
||||
}
|
||||
}
|
||||
$date->add( new \DateInterval( 'P1D' ) );
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
/* o is the ISO year number, which we need when years roll over.
|
||||
@see http://php.net/manual/en/function.date.php#106974 */
|
||||
$data[ $date->format( 'o-W' ) ] = array();
|
||||
|
||||
if( $this->groupBy )
|
||||
{
|
||||
foreach( $this->groupByKeys as $key )
|
||||
{
|
||||
$data[ $date->format( 'o-W' ) ][ $key ] = 0;
|
||||
}
|
||||
}
|
||||
$date->add( new \DateInterval( 'P7D' ) );
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
$data[ $date->format( 'Y-n' ) ] = array();
|
||||
|
||||
if( $this->groupBy )
|
||||
{
|
||||
foreach( $this->groupByKeys as $key )
|
||||
{
|
||||
$data[ $date->format( 'Y-n' ) ][ $key ] = 0;
|
||||
}
|
||||
}
|
||||
$date->add( new \DateInterval( 'P1M' ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Get data */
|
||||
$output = '';
|
||||
if ( !empty( $this->series ) )
|
||||
{
|
||||
/* Work out where clause */
|
||||
$where = $this->where;
|
||||
$where[] = array( "{$this->dateField}>?", 0 );
|
||||
if ( $this->start )
|
||||
{
|
||||
$where[] = array( "{$this->dateField}>?", $this->start->getTimestamp() );
|
||||
}
|
||||
if ( $this->end )
|
||||
{
|
||||
$where[] = array( "{$this->dateField}<?", $this->end->getTimestamp() );
|
||||
}
|
||||
|
||||
/* What's our SQL time? */
|
||||
switch ( $this->timescale )
|
||||
{
|
||||
case 'daily':
|
||||
$timescale = '%Y-%c-%e';
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
$timescale = '%Y-%u';
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
$timescale = '%Y-%c';
|
||||
break;
|
||||
}
|
||||
|
||||
/* Table... */
|
||||
if ( $this->type === 'Table' )
|
||||
{
|
||||
$table = new \IPS\Helpers\Table\Db( $this->table, $this->url, $where );
|
||||
$table->include = $this->tableInclude;
|
||||
$table->parsers = $this->tableParsers;
|
||||
$table->sortBy = $table->sortBy ?: $this->dateField;
|
||||
$output = (string) $table;
|
||||
}
|
||||
|
||||
/* Pie Chart */
|
||||
if ( $this->type === 'PieChart' or $this->type === 'GeoChart' )
|
||||
{
|
||||
$keys = array_unique( $this->series );
|
||||
$key = array_pop( $keys );
|
||||
|
||||
$stmt = \IPS\Db::i()->select(
|
||||
"{$key}" . ( $this->groupBy ? ", {$this->groupBy}" : '' ),
|
||||
$this->table,
|
||||
$where,
|
||||
NULL,
|
||||
NULL,
|
||||
$this->groupBy
|
||||
)->setKeyField( $this->groupBy )->setValueField( $key );
|
||||
|
||||
foreach ( $stmt as $k => $v )
|
||||
{
|
||||
if( count( $this->availableFilters ) and !in_array( $k, $this->currentFilters ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$this->addRow( array( 'key' => $this->availableFilters[ $k ], 'value' => $v ) );
|
||||
}
|
||||
|
||||
$output = $this->render( $this->type, $this->options, $this->format );
|
||||
}
|
||||
|
||||
/* Graph */
|
||||
else
|
||||
{
|
||||
/* Fetch */
|
||||
$stmt = \IPS\Db::i()->select(
|
||||
"DATE_FORMAT( FROM_UNIXTIME( IFNULL( {$this->dateField}, 0 ) ), '{$timescale}' ) AS time, " . implode( ', ', array_unique( $this->series ) ) . ( $this->groupBy ? ", " . $this->groupBy : '' ),
|
||||
$this->table,
|
||||
$where,
|
||||
'time ASC',
|
||||
NULL,
|
||||
$this->groupBy ? array( 'time', $this->groupBy ) : 'time'
|
||||
);
|
||||
|
||||
foreach ( $stmt as $row )
|
||||
{
|
||||
$result = array();
|
||||
|
||||
if( $this->groupBy )
|
||||
{
|
||||
if( count( $this->availableFilters ) AND !in_array( $row[ $this->groupBy ], $this->currentFilters ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $this->series as $column )
|
||||
{
|
||||
if( $this->groupBy )
|
||||
{
|
||||
if( empty( $data[ $row['time'] ] ) )
|
||||
{
|
||||
$result = array( $row[ $this->groupBy ] => $row[ $column ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $data[ $row['time'] ];
|
||||
$result[ $row[ $this->groupBy ] ] = $row[ $column ];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result[ $column ] = $row[ $column ];
|
||||
}
|
||||
}
|
||||
|
||||
$data[ $row['time'] ] = $result;
|
||||
}
|
||||
|
||||
ksort( $data, SORT_NATURAL );
|
||||
|
||||
/* Add to graph */
|
||||
$min = NULL;
|
||||
$max = NULL;
|
||||
foreach ( $data as $time => $d )
|
||||
{
|
||||
$datetime = new \IPS\DateTime;
|
||||
|
||||
if ( \IPS\Member::loggedIn()->timezone )
|
||||
{
|
||||
try
|
||||
{
|
||||
$datetime->setTimezone( new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Member::loggedIn()->timezone = null;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
}
|
||||
}
|
||||
|
||||
$datetime->setTime( 0, 0, 0 );
|
||||
$exploded = explode( '-', $time );
|
||||
switch ( $this->timescale )
|
||||
{
|
||||
case 'daily':
|
||||
$datetime->setDate( (float) $exploded[0], $exploded[1], $exploded[2] );
|
||||
//$datetime = $datetime->localeDate();
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
$datetime->setISODate( (float) $exploded[0], $exploded[1] );
|
||||
//$datetime = $datetime->localeDate();
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
$datetime->setDate( (float) $exploded[0], $exploded[1], 1 );
|
||||
//$datetime = $datetime->format( 'F Y' );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( empty( $d ) )
|
||||
{
|
||||
if ( empty( $this->series ) )
|
||||
{
|
||||
$this->addRow( array( $datetime ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addRow( array_merge( array( $datetime ), array_fill( 0, count( $this->series ), 0 ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $this->groupBy )
|
||||
{
|
||||
$_values = array();
|
||||
foreach ( $this->series as $id => $col )
|
||||
{
|
||||
$_values[ $id ] = ( isset( $d[ $id ] ) ) ? $d[ $id ] : ( $this->plotZeros ? 0 : NULL );
|
||||
}
|
||||
|
||||
$this->addRow( array_merge( array( $datetime ), $_values ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( count($d) < count($this->series) )
|
||||
{
|
||||
$this->addRow( array_merge( array( $datetime ), $d, array_fill( 0, count($this->series) - count($d), 0 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addRow( array_merge( array( $datetime ), $d ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $data ) === 1 )
|
||||
{
|
||||
$this->options['domainAxis']['type'] = 'category';
|
||||
}
|
||||
|
||||
$output = $this->render( $this->type, $this->options, $this->format );
|
||||
}
|
||||
$output = $this->getOutput();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -614,4 +316,46 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
|
||||
return $this->url->setQueryString( 'filters', array( $this->identifier => $filters ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the data array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function initData()
|
||||
{
|
||||
/* Init data */
|
||||
$data = array();
|
||||
if ( $this->start AND $this->timescale !== 'none' )
|
||||
{
|
||||
$date = clone $this->start;
|
||||
while ( $date->getTimestamp() < ( $this->end ? $this->end->getTimestamp() : time() ) )
|
||||
{
|
||||
switch ( $this->timescale )
|
||||
{
|
||||
case 'daily':
|
||||
$data[ $date->format( 'Y-n-j' ) ] = array();
|
||||
|
||||
$date->add( new \DateInterval( 'P1D' ) );
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
/* o is the ISO year number, which we need when years roll over.
|
||||
@see http://php.net/manual/en/function.date.php#106974 */
|
||||
$data[ $date->format( 'o-W' ) ] = array();
|
||||
|
||||
$date->add( new \DateInterval( 'P7D' ) );
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
$data[ $date->format( 'Y-n' ) ] = array();
|
||||
|
||||
$date->add( new \DateInterval( 'P1M' ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Cover Photo Controller
|
||||
* @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 20 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\CoverPhoto;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Cover Photo 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 20 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Address input class for Form Builder
|
||||
* @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 11 Jul 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -48,14 +47,14 @@ class _Address extends FormAbstract
|
||||
if ( !$this->value OR ( $this->value instanceof \IPS\GeoLocation AND !$this->value->country ) )
|
||||
{
|
||||
$this->value = ( $this->value instanceof \IPS\GeoLocation ) ? $this->value : new \IPS\GeoLocation;
|
||||
if ( $defaultCountry = $this->_calculateDefaultCountry() )
|
||||
if ( $this->options['requireFullAddress'] and $defaultCountry = static::calculateDefaultCountry() )
|
||||
{
|
||||
$this->value->country = $defaultCountry;
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->address( $this->name, $this->value, \IPS\Settings::i()->googleplacesautocomplete ? \IPS\Settings::i()->google_maps_api_key : NULL, $this->options['minimize'] );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->address( $this->name, $this->value, \IPS\Settings::i()->googleplacesautocomplete ? \IPS\Settings::i()->google_maps_api_key : NULL, $this->options['minimize'], $this->options['requireFullAddress'] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +62,7 @@ class _Address extends FormAbstract
|
||||
*
|
||||
* @return string|NULL
|
||||
*/
|
||||
protected function _calculateDefaultCountry()
|
||||
public static function calculateDefaultCountry()
|
||||
{
|
||||
if ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) )
|
||||
{
|
||||
@@ -90,6 +89,17 @@ class _Address extends FormAbstract
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate default country
|
||||
*
|
||||
* @return string|NULL
|
||||
* @deprecated
|
||||
*/
|
||||
protected function _calculateDefaultCountry()
|
||||
{
|
||||
return static::calculateDefaultCountry();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
@@ -156,7 +166,7 @@ class _Address extends FormAbstract
|
||||
}
|
||||
if ( $value->country )
|
||||
{
|
||||
if ( $value->country != $this->_calculateDefaultCountry() )
|
||||
if ( $value->country != static::calculateDefaultCountry() )
|
||||
{
|
||||
$partiallyCompleted = TRUE;
|
||||
}
|
||||
@@ -212,14 +222,11 @@ class _Address extends FormAbstract
|
||||
}
|
||||
|
||||
/* Add in latitude and longitude if we can */
|
||||
if ( $fullyCompleted )
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
$value->getLatLong();
|
||||
}
|
||||
catch( \BadFunctionCallException $e ){}
|
||||
$value->getLatLong();
|
||||
}
|
||||
catch( \BadFunctionCallException $e ){}
|
||||
|
||||
/* Return */
|
||||
return $value;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Captcha class for Form Builder
|
||||
* @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 18 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -31,7 +30,7 @@ class _Captcha extends FormAbstract
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief keyCAPTCHA
|
||||
* @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 18 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form\Captcha;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief reCAPTCHA
|
||||
* @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 18 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form\Captcha;
|
||||
@@ -43,7 +42,7 @@ class _Recaptcha
|
||||
<div data-ipsCaptcha data-ipsCaptcha-service='recaptcha' data-ipsCaptcha-key="{$publicKey}" data-ipsCaptcha-lang="{$lang}" data-ipsCaptcha-theme="{$theme}">
|
||||
<noscript>
|
||||
<iframe src="//www.google.com/recaptcha/api/noscript?k={$publicKey}&hl={$lang}&error={$this->error}"
|
||||
height="300" width="500" frameborder="0"></iframe><br>
|
||||
height="300" width="500"></iframe><br>
|
||||
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
|
||||
<input type="hidden" name="recaptcha_response_field" value="manual_challenge">
|
||||
</noscript>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief reCAPTCHA
|
||||
* @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 5 Dec 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form\Captcha;
|
||||
@@ -45,7 +44,7 @@ class _Recaptcha2
|
||||
<div style="width: 302px; height: 352px;">
|
||||
<div style="width: 302px; height: 352px; position: relative;">
|
||||
<div style="width: 302px; height: 352px; position: absolute;">
|
||||
<iframe src="https://www.google.com/recaptcha/api/fallback?k={$publicKey}" frameborder="0" scrolling="no" style="width: 302px; height:352px; border-style: none;">
|
||||
<iframe src="https://www.google.com/recaptcha/api/fallback?k={$publicKey}" style="width: 302px; height:352px; border-style: none;">
|
||||
</iframe>
|
||||
</div>
|
||||
<div style="width: 250px; height: 80px; position: absolute; border-style: none; bottom: 21px; left: 25px; margin: 0px; padding: 0px; right: 25px;">
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Checkbox class for Form Builder
|
||||
* @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 26 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -70,7 +69,7 @@ class _Checkbox extends FormAbstract
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
* @return bool
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
@@ -89,7 +88,7 @@ class _Checkbox extends FormAbstract
|
||||
* String Value
|
||||
*
|
||||
* @param mixed $value The value
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public static function stringValue( $value )
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Checkbox Set class for Form Builder
|
||||
* @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 19 Jul 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -82,7 +81,7 @@ class _CheckboxSet extends Select
|
||||
|
||||
/* If the value is NULL or an empty string, i.e. from a custom field, then we should not convert it into an array because the
|
||||
value will evaluate to 0 with an == check and the first option in the checkbox set will always be selected erroneously */
|
||||
if ( ! is_array( $value ) AND $value !== NULL AND $value !== '' )
|
||||
if ( $this->options['unlimited'] === NULL and !is_array( $value ) AND $value !== NULL AND $value !== '' )
|
||||
{
|
||||
$value = array( $value );
|
||||
}
|
||||
@@ -97,9 +96,16 @@ class _CheckboxSet extends Select
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
$value = parent::getValue();
|
||||
|
||||
if ( $this->options['unlimited'] !== NULL and $value === $this->options['unlimited'] )
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
/* We need the array keys. For custom fields we will have 0 => 1, 1 => 1 if checkboxes 0 and 1 are checked, while for Content we will have
|
||||
customKey => 1, customOtherKey => 1 - we always need the array keys */
|
||||
$value = is_array( parent::getValue() ) ? array_keys( parent::getValue() ) : array();
|
||||
$value = is_array( $value ) ? array_keys( $value ) : array();
|
||||
if ( $this->options['returnLabels'] )
|
||||
{
|
||||
if ( is_array( $value ) )
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Codemirror class for Form Builder
|
||||
* @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 8 Jul 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -52,7 +51,7 @@ class _Codemirror extends TextArea
|
||||
* Constructor
|
||||
* Sets that the field is required if there is a minimum length and vice-versa
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Color input class for Form Builder
|
||||
* @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 11 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -38,16 +37,13 @@ class _Color extends FormAbstract
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
/* Call parent constructor */
|
||||
call_user_func_array( 'parent::__construct', func_get_args() );
|
||||
|
||||
/* Add the fallback for browsers that don't support the HTML5 color input type */
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'jscolor/jscolor.js', 'core', 'interface' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Custom input class for Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Date input class for Form Builder
|
||||
* @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 8 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -65,7 +64,7 @@ class _Date extends FormAbstract
|
||||
* Constructor
|
||||
* Formats the value appropriately
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @param string $name Name
|
||||
* @param mixed $defaultValue Default value
|
||||
* @param bool $required Required?
|
||||
@@ -90,7 +89,7 @@ class _Date extends FormAbstract
|
||||
call_user_func_array( 'parent::__construct', func_get_args() );
|
||||
|
||||
/* Set min/max - hardcoded to 32bit values rather than using PHP_INT_MAX because the MySQL server may be 32-bit even if the web server is 64 */
|
||||
if ( !isset( $this->options['min'] ) or $this->options['min']->getTimestamp() < 2147483648 )
|
||||
if ( !isset( $this->options['min'] ) or $this->options['min']->getTimestamp() < -2147483648 )
|
||||
{
|
||||
$this->options['min'] = \IPS\DateTime::ts( -2147483648 );
|
||||
}
|
||||
@@ -275,7 +274,7 @@ class _Date extends FormAbstract
|
||||
/* Unlimited is fine */
|
||||
if ( $this->options['unlimited'] !== NULL and $this->value === $this->options['unlimited'] )
|
||||
{
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Check it's valid */
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Date range input class for Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -70,7 +69,7 @@ class _DateRange extends FormAbstract
|
||||
* Constructor
|
||||
* Creates the two date objects
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array() )
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor class for Form Builder
|
||||
* @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 5 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -45,6 +44,7 @@ class _Editor extends FormAbstract
|
||||
'minimizeWithContent'=> FALSE, // If TRUE, the editor will be minimized even if there is default content
|
||||
'maxLength' => FALSE, // The maximum length. Note that the content is HTML, so this isn't the maximum number of visible characters, so should only be used for database limits. The database's max allowed packet will override if smaller
|
||||
'editorId' => NULL, // Passed to editorAttachments. Only necessary if the name may be changed
|
||||
'allowAttachments => TRUE, // Should the editor show upload options?
|
||||
);
|
||||
* @endcode
|
||||
*/
|
||||
@@ -63,6 +63,7 @@ class _Editor extends FormAbstract
|
||||
'minimizeWithContent' => FALSE,
|
||||
'maxLength' => 16777215, // The default for MEDIUMTEXT */
|
||||
'editorId' => NULL,
|
||||
'allowAttachments' => TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -84,7 +85,7 @@ class _Editor extends FormAbstract
|
||||
* Constructor
|
||||
* Sets that the field is required if there is a minimum length and vice-versa
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @note $name and $htmlId must be different
|
||||
* @return void
|
||||
* @throws \OutOfBoundsException
|
||||
@@ -272,7 +273,7 @@ class _Editor extends FormAbstract
|
||||
/* Or if the user can't attach, just show a bar */
|
||||
else
|
||||
{
|
||||
$attachmentArea = \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->editorAttachmentsPlaceholder( $this->name, $this->postKey );
|
||||
$attachmentArea = \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->editorAttachmentsPlaceholder( $this->name, $this->postKey, $this->noUploaderError );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
@@ -283,7 +284,7 @@ class _Editor extends FormAbstract
|
||||
/**
|
||||
* Convert the value to something that will look okay for the no-JS fallback
|
||||
*
|
||||
* @param string $value Valie
|
||||
* @param string $value Value
|
||||
* @return string
|
||||
*/
|
||||
public static function valueForNoJsFallback( $value )
|
||||
@@ -453,11 +454,16 @@ class _Editor extends FormAbstract
|
||||
return $canAttach;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Error message to display if we're not showing the uploader
|
||||
*/
|
||||
protected $noUploaderError = NULL;
|
||||
|
||||
/**
|
||||
* Get uploader
|
||||
*
|
||||
* @param string $name Form name
|
||||
* @return \IPS\Helpers\Form\Uploader
|
||||
* @return \IPS\Helpers\Form\Upload|NULL
|
||||
*/
|
||||
protected function getUploader( $name )
|
||||
{
|
||||
@@ -477,7 +483,7 @@ class _Editor extends FormAbstract
|
||||
$file->attachmentThumbnailUrl = $attachment['attach_thumb_location'] ? \IPS\File::get( 'core_Attachment', $attachment['attach_thumb_location'] )->url : $file->url;
|
||||
|
||||
/* Reset the original filename based on the attachment record as filenames can be renamed if they contain special characters as AWS being the lowest common denominator cannot
|
||||
handle special characters. @link https://community.invisionpower.com/4bugtrack/active-reports/408-wrong-name-for-uploaded-files-in-editor-r6519/ */
|
||||
handle special characters */
|
||||
$file->originalFilename = $attachment['attach_file'];
|
||||
|
||||
$existing[ $attachment['attach_id'] ] = $file;
|
||||
@@ -489,11 +495,21 @@ class _Editor extends FormAbstract
|
||||
$maxTotalSize = array();
|
||||
if ( \IPS\Member::loggedIn()->group['g_attach_max'] > 0 and \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$maxTotalSize[] = ( ( \IPS\Member::loggedIn()->group['g_attach_max'] * 1024 ) - \IPS\Db::i()->select( 'SUM(attach_filesize)', 'core_attachments', array( 'attach_member_id=?', \IPS\Member::loggedIn()->member_id ) )->first() ) / 1048576;
|
||||
$globalSpaceRemaining = ( ( \IPS\Member::loggedIn()->group['g_attach_max'] * 1024 ) - \IPS\Db::i()->select( 'SUM(attach_filesize)', 'core_attachments', array( 'attach_member_id=?', \IPS\Member::loggedIn()->member_id ) )->first() ) / 1048576;
|
||||
$maxTotalSize[] = $globalSpaceRemaining;
|
||||
if ( $globalSpaceRemaining <= 0 )
|
||||
{
|
||||
$this->noUploaderError = 'editor_used_global_space';
|
||||
}
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->group['g_attach_per_post'] )
|
||||
{
|
||||
$maxTotalSize[] = \IPS\Member::loggedIn()->group['g_attach_per_post'] / 1024;
|
||||
$perPostSpaceRemaining = \IPS\Member::loggedIn()->group['g_attach_per_post'] / 1024;
|
||||
$maxTotalSize[] = $perPostSpaceRemaining;
|
||||
if ( $perPostSpaceRemaining <= 0 )
|
||||
{
|
||||
$this->noUploaderError = 'editor_used_post_space';
|
||||
}
|
||||
}
|
||||
$maxTotalSize = count( $maxTotalSize ) ? min( $maxTotalSize ) : NULL;
|
||||
|
||||
@@ -544,7 +560,9 @@ class _Editor extends FormAbstract
|
||||
$options['image'] = TRUE;
|
||||
}
|
||||
|
||||
$uploader = new \IPS\Helpers\Form\Upload( str_replace( array( '[', ']' ), '_', $name ) . '_upload', $existing, FALSE, $options );
|
||||
$uploaderName = str_replace( array( '[', ']' ), '_', $name ) . '_upload';
|
||||
unset( \IPS\Request::i()->$uploaderName ); // We are setting the value here, so we don't want the normal form helper to overload, which will wipe out any attachments if there is an error elsewhere in the form
|
||||
$uploader = new \IPS\Helpers\Form\Upload( $uploaderName, $existing, FALSE, $options );
|
||||
$uploader->template = array( \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' ), 'editorAttachments' );
|
||||
|
||||
/* Handle delete calls */
|
||||
@@ -707,6 +725,8 @@ class _Editor extends FormAbstract
|
||||
|
||||
/**
|
||||
* Bypass the Profanity Check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function bypassFilterProfanity()
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Email input class for Form Builder
|
||||
* @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 11 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -79,6 +78,24 @@ class _Email extends Text
|
||||
throw new \DomainException( 'form_email_banned' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Check it's an allowed domain */
|
||||
if ( !\IPS\Member::loggedIn()->isAdmin() and \IPS\Settings::i()->allowed_reg_email !== '' AND $allowedEmailDomains = explode( ',', \IPS\Settings::i()->allowed_reg_email ) )
|
||||
{
|
||||
$matched = FALSE;
|
||||
foreach ( $allowedEmailDomains AS $domain )
|
||||
{
|
||||
if( \mb_stripos( $this->value, "@" . $domain ) !== FALSE )
|
||||
{
|
||||
$matched = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $allowedEmailDomains ) AND !$matched )
|
||||
{
|
||||
throw new \DomainException( 'form_email_banned' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers;
|
||||
@@ -310,9 +309,9 @@ class _Form
|
||||
/**
|
||||
* Add Input
|
||||
*
|
||||
* @param \IPS\Helpers\Form\Abstract $input Form element to add
|
||||
* @param string|NULL $after The key of element to insert after
|
||||
* @param string|NULL $tab The tab to insert onto
|
||||
* @param \IPS\Helpers\Form\FormAbstract $input Form element to add
|
||||
* @param string|NULL $after The key of element to insert after
|
||||
* @param string|NULL $tab The tab to insert onto
|
||||
* @return void
|
||||
*/
|
||||
public function add( $input, $after=NULL, $tab=NULL )
|
||||
@@ -495,7 +494,7 @@ class _Form
|
||||
$name = "{$this->id}_activeTab";
|
||||
if ( isset( \IPS\Request::i()->$name ) )
|
||||
{
|
||||
return \IPS\Request::i()->$name;
|
||||
return \IPS\Request::i()->$name;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -726,5 +725,4 @@ class _Form
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Abstract Class for input types for Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -348,7 +347,7 @@ abstract class _FormAbstract
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
if( $this->value === '' and $this->required )
|
||||
if( ( $this->value === '' OR ( is_array( $this->value ) AND empty( $this->value ) ) ) and $this->required )
|
||||
{
|
||||
throw new \InvalidArgumentException('form_required');
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief FTP Details input class for Form Builder
|
||||
* @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
|
||||
* @subpackage Nexus
|
||||
* @since 17 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -47,10 +46,35 @@ class _Ftp extends \IPS\Helpers\Form\FormAbstract
|
||||
public function html()
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'global_forms.js', 'nexus', 'global' ) );
|
||||
|
||||
$value = is_array( $this->value ) ? $this->value : json_decode( \IPS\Text\Encrypt::fromTag( $this->value )->decrypt(), TRUE );
|
||||
$defaultValue = is_array( $this->defaultValue ) ? $this->defaultValue : json_decode( \IPS\Text\Encrypt::fromTag( $this->defaultValue )->decrypt(), TRUE );
|
||||
if ( isset( $value['pw'] ) and isset( $defaultValue['pw'] ) and $value['pw'] and $value['pw'] === $defaultValue['pw'] and !$this->error )
|
||||
{
|
||||
$value['pw'] = '********';
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->ftp( $this->name, $value, $this->options['allowBypassValidation'] and $this->error );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
$value = parent::getValue();
|
||||
|
||||
if ( isset( $value['pw'] ) and $value['pw'] === '********' )
|
||||
{
|
||||
$defaultValue = is_array( $this->defaultValue ) ? $this->defaultValue : json_decode( \IPS\Text\Encrypt::fromTag( $this->defaultValue )->decrypt(), TRUE );
|
||||
$value['pw'] = $defaultValue['pw'];
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate
|
||||
*
|
||||
@@ -76,7 +100,7 @@ class _Ftp extends \IPS\Helpers\Form\FormAbstract
|
||||
/**
|
||||
* Validate
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
@@ -121,6 +145,8 @@ class _Ftp extends \IPS\Helpers\Form\FormAbstract
|
||||
{
|
||||
throw new \DomainException( 'form_required' );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Item selector for Form Builder
|
||||
* @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 12 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -112,7 +111,7 @@ class _Item extends FormAbstract
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
* @return mixed
|
||||
* @return array
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Key/Value input class for Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -74,7 +73,7 @@ class _KeyValue extends FormAbstract
|
||||
* Constructor
|
||||
* Creates the two date objects
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array() )
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Matrix Builder
|
||||
* @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 26 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -267,7 +266,7 @@ class _Matrix extends \IPS\Helpers\Form
|
||||
* @return array
|
||||
*/
|
||||
protected function buildRow( $rowId, $data )
|
||||
{
|
||||
{
|
||||
$row = array();
|
||||
if ( is_string( $data ) )
|
||||
{
|
||||
@@ -357,6 +356,16 @@ class _Matrix extends \IPS\Helpers\Form
|
||||
{
|
||||
$element->value = TRUE;
|
||||
}
|
||||
|
||||
/* If our element has an unlimited option, and that's set, set that. */
|
||||
if ( isset( $element->options['unlimited'] ) )
|
||||
{
|
||||
$unlimitedKey = "{$rowId}[{$columnName}_unlimited]";
|
||||
if ( $value = \IPS\Request::i()->valueFromArray( $unlimitedKey ) )
|
||||
{
|
||||
$element->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set value */
|
||||
$values[ $rowId ][ $columnName ] = $element->value;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Member input class for Form Builder
|
||||
* @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 11 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -40,7 +39,7 @@ class _Member extends Text
|
||||
* Constructor
|
||||
* Adds 'confirm' to the available options
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
@@ -90,14 +89,14 @@ class _Member extends Text
|
||||
}
|
||||
|
||||
/* 10/19/15 - adding htmlspecialchars around value if autocomplete is enabled so that html tag characters can be used (e.g. for members) */
|
||||
/* This value is decoded by the JS widget before use. See https://community.invisionpower.com/4bugtrack/active-reports/cannot-pm-certain-members-r6181/ */
|
||||
/* This value is decoded by the JS widget before use. */
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->text( $this->name, 'text', ( $this->options['autocomplete'] AND !is_null( $value ) ) ? htmlspecialchars( $value, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ) : $value, $this->required, $this->options['maxLength'], $this->options['size'], $this->options['disabled'], $this->options['autocomplete'], $this->options['placeholder'], NULL, $this->options['nullLang'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Format Value
|
||||
*
|
||||
* @return \IPS\Member|NULL|FALSE
|
||||
* @return \IPS\Member|array|NULL|FALSE
|
||||
*/
|
||||
public function formatValue()
|
||||
{
|
||||
@@ -150,6 +149,16 @@ class _Member extends Text
|
||||
{
|
||||
throw new \InvalidArgumentException('form_member_bad');
|
||||
}
|
||||
else if ( is_array( $this->value ) )
|
||||
{
|
||||
foreach( $this->value AS $value )
|
||||
{
|
||||
if ( $value !== '' AND !( $value instanceof \IPS\Member ) )
|
||||
{
|
||||
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack( 'form_member_bad_multiple', FALSE, array( 'sprintf' => array( $value ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -157,12 +166,17 @@ class _Member extends Text
|
||||
* String Value
|
||||
*
|
||||
* @param mixed $value The value
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public static function stringValue( $value )
|
||||
{
|
||||
if ( is_array( $value ) )
|
||||
{
|
||||
if ( !count( $value ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return implode( "\n", array_map( function( $v )
|
||||
{
|
||||
return $v->member_id;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Number input class for Form Builder
|
||||
* @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 12 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -42,6 +41,7 @@ class _Node extends FormAbstract
|
||||
'disabledIds' => array(), // Array of disabled IDs
|
||||
'noParentNodes' => 'Custom' // If a value is provided, subnodes of this class which have no parent node will be added into a pseudo-group with the title provided. e.g. custom packages in Nexus do not belong to any package group
|
||||
'autoPopulate' => FALSE // Whether or not to autopopulate children of root nodes (defaults to TRUE which means the children are loaded, use FALSE to only show the parent nodes by default until they are clicked on)
|
||||
'clubs' => TRUE, // If TRUE, will also show nodes inside clubs that the user can access. Defaults to FALSE.
|
||||
);
|
||||
* @endcode
|
||||
*/
|
||||
@@ -60,7 +60,8 @@ class _Node extends FormAbstract
|
||||
'where' => array(),
|
||||
'disabledIds' => array(),
|
||||
'noParentNodes' => NULL,
|
||||
'autoPopulate' => TRUE
|
||||
'autoPopulate' => TRUE,
|
||||
'clubs' => FALSE
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -77,6 +78,11 @@ class _Node extends FormAbstract
|
||||
$this->options['url'] = \IPS\Request::i()->url();
|
||||
}
|
||||
$this->options['url'] = $this->options['url']->setQueryString( '_nodeSelectName', $this->name );
|
||||
|
||||
if ( $this->options['clubs'] and ( !\IPS\Settings::i()->clubs or !\IPS\IPS::classUsesTrait( $this->options['class'], 'IPS\Content\ClubContainer' ) ) )
|
||||
{
|
||||
$this->options['clubs'] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +100,7 @@ class _Node extends FormAbstract
|
||||
{
|
||||
$permCheck = 'view';
|
||||
}
|
||||
|
||||
|
||||
/* Are we getting some AJAX stuff? */
|
||||
if ( isset( \IPS\Request::i()->_nodeSelectName ) and \IPS\Request::i()->_nodeSelectName === $this->name )
|
||||
{
|
||||
@@ -166,8 +172,16 @@ class _Node extends FormAbstract
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Recurse three levels in to allow for discoverability */
|
||||
foreach( $nodeClass::roots( NULL, NULL, $this->options['where'] ) AS $node )
|
||||
/* Recurse three levels in to allow for discoverability */
|
||||
if ( $this->options['clubs'] )
|
||||
{
|
||||
$nodes = $nodeClass::rootsWithClubs( 'view', NULL, $this->options['where'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$nodes = $nodeClass::roots( 'view', NULL, $this->options['where'] );
|
||||
}
|
||||
foreach( $nodes AS $node )
|
||||
{
|
||||
$this->_populate( $nodes, $disabled, 0, $node, $children, 3 );
|
||||
}
|
||||
@@ -266,7 +280,7 @@ class _Node extends FormAbstract
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->node( $this->name, $selected, $this->options['multiple'], $this->options['url'], $nodeClass::$nodeTitle, $nodes, $this->options['zeroVal'], $noJS, $permCheck, $this->options['subnodes'], $this->options['togglePerm'], $this->options['toggleIds'], $disabledCallback, $this->options['zeroValTogglesOn'], $this->options['zeroValTogglesOff'], $this->options['autoPopulate'], $children, $this->options['class'], $this->options['where'], is_array( $this->options['disabledIds'] ) ? $this->options['disabledIds'] : array(), $this->options['noParentNodes'], $noParentNodes );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->node( $this->name, $selected, $this->options['multiple'], $this->options['url'], $nodeClass::$nodeTitle, $nodes, $this->options['zeroVal'], $noJS, $permCheck, $this->options['subnodes'], $this->options['togglePerm'], $this->options['toggleIds'], $disabledCallback, $this->options['zeroValTogglesOn'], $this->options['zeroValTogglesOff'], $this->options['autoPopulate'], $children, $this->options['class'], $this->options['where'], is_array( $this->options['disabledIds'] ) ? $this->options['disabledIds'] : array(), $this->options['noParentNodes'], $noParentNodes, $this->options['clubs'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Number input class for Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -61,7 +60,7 @@ class _Number extends FormAbstract
|
||||
* Constructor
|
||||
* Formats the value appropriately
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @param string $name Name
|
||||
* @param mixed $defaultValue Default value
|
||||
* @param bool $required Required?
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Password input class for Form Builder
|
||||
* @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 11 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -42,6 +41,23 @@ class _Password extends Text
|
||||
'checkStrength' => FALSE
|
||||
);
|
||||
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
$value = parent::getValue();
|
||||
|
||||
if ( $value === '********' )
|
||||
{
|
||||
$value = $this->defaultValue;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate
|
||||
*
|
||||
@@ -127,7 +143,7 @@ class _Password extends Text
|
||||
public function html()
|
||||
{
|
||||
/* 10/19/15 - adding htmlspecialchars around value if autocomplete is enabled so that html tag characters can be used (e.g. for members) */
|
||||
/* This value is decoded by the JS widget before use. See https://community.invisionpower.com/4bugtrack/active-reports/cannot-pm-certain-members-r6181/ */
|
||||
/* This value is decoded by the JS widget before use. */
|
||||
if( $this->options['autocomplete'] and !empty( $this->value ) and is_array( $this->value ) )
|
||||
{
|
||||
foreach( $this->value as $key => $value )
|
||||
@@ -135,7 +151,7 @@ class _Password extends Text
|
||||
$this->value[ $key ] = htmlspecialchars( $value, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->text( $this->name, $this->formType, $this->value, $this->required, $this->options['maxLength'], $this->options['size'], $this->options['disabled'], $this->options['autocomplete'], $this->options['placeholder'], NULL, $this->options['nullLang'], $this->htmlId, $this->options['showMeter'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->text( $this->name, $this->formType, ( $this->value and $this->value === $this->defaultValue and !$this->error ) ? '********' : $this->value, $this->required, $this->options['maxLength'], $this->options['size'], $this->options['disabled'], $this->options['autocomplete'], $this->options['placeholder'], NULL, $this->options['nullLang'], $this->htmlId, $this->options['showMeter'] );
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Poll input class for Form Builder
|
||||
* @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 10 Jan 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -180,7 +179,24 @@ EOF;
|
||||
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack('form_poll_too_many_answers', FALSE, array( 'sprintf' => array( \IPS\Settings::i()->max_poll_choices ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Only validate if the timestamp is greater than zero */
|
||||
if( $this->value->poll_close_date instanceof \IPS\DateTime )
|
||||
{
|
||||
/* Check maximum date */
|
||||
$maximum = \IPS\DateTime::ts( 2147483647 );
|
||||
if ( $this->value->poll_close_date > $maximum )
|
||||
{
|
||||
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_date_max', FALSE, array( 'sprintf' => array( $maximum->localeDate() ) ) ) );
|
||||
}
|
||||
|
||||
/* Check minimum date and time */
|
||||
$minimum = \IPS\DateTime::ts( time() );
|
||||
if ( $this->value->poll_close_date < $minimum )
|
||||
{
|
||||
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_date_min', FALSE, array( 'sprintf' => array( $minimum->localeDate() . ' ' . $minimum->localeTime( FALSE ) ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -189,7 +205,7 @@ EOF;
|
||||
* String Value
|
||||
*
|
||||
* @param mixed $value The value
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public static function stringValue( $value )
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Radio Switch class for Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -134,7 +133,7 @@ class _Radio extends Select
|
||||
/**
|
||||
* Get value
|
||||
*
|
||||
* @return array
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Rating input Form Builder
|
||||
* @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 3 Oct 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Search input class for Form Builder
|
||||
* @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 11 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Select-box class for Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -125,9 +124,9 @@ class _Select extends FormAbstract
|
||||
{
|
||||
$name .= '[]';
|
||||
}
|
||||
|
||||
|
||||
/* Translate labels back to keys? */
|
||||
if ( $this->options['returnLabels'] )
|
||||
if ( $this->options['returnLabels'] and ( $this->options['unlimited'] === NULL or $this->value !== $this->options['unlimited'] ) )
|
||||
{
|
||||
$value = array();
|
||||
if ( is_array( $this->value ) )
|
||||
@@ -146,7 +145,7 @@ class _Select extends FormAbstract
|
||||
{
|
||||
$value = $this->value;
|
||||
}
|
||||
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core' )->select( $name, $value, $this->required, $this->parseOptions(), $this->options['multiple'], $this->options['class'], $this->options['disabled'], $this->options['toggles'], $this->htmlId, $this->options['unlimited'], $this->options['unlimitedLang'], $this->options['unlimitedToggles'], $this->options['unlimitedToggleOn'], $this->options['userSuppliedInput'], $this->options['sort'], $this->options['parse'] );
|
||||
}
|
||||
|
||||
@@ -240,12 +239,12 @@ class _Select extends FormAbstract
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
else
|
||||
elseif ( $this->options['unlimited'] === NULL )
|
||||
{
|
||||
return $this->options['options'][ $value ];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Form builder helper to allow user-created "groups" of other users
|
||||
* @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 10 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -46,7 +45,7 @@ class _SocialGroup extends Member
|
||||
* Constructor
|
||||
* Sets that the field is required if there is a minimum length and vice-versa
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
@@ -112,5 +111,7 @@ class _SocialGroup extends Member
|
||||
}
|
||||
|
||||
$this->value = $this->groupId;
|
||||
|
||||
\IPS\Db::i()->update( 'core_members', array( 'permission_array' => NULL ) );
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Sort items input class for Form Builder
|
||||
* @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 14 Oct 2016
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -26,7 +25,7 @@ class _Sort extends FormAbstract
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @param string $name Name
|
||||
* @param mixed $defaultValue Default value
|
||||
* @param bool $required Required?
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Stack input class for Form Builder
|
||||
* @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 11 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -36,7 +35,7 @@ class _Stack extends FormAbstract
|
||||
/**
|
||||
* Constructor: Store the form element to stack
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @param string $name Name
|
||||
* @param mixed $defaultValue Default value
|
||||
* @param bool $required Required?
|
||||
@@ -177,6 +176,14 @@ class _Stack extends FormAbstract
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_tags_min', FALSE, array( 'pluralize' => array( $this->options['minItems'] ) ) ) );
|
||||
}
|
||||
|
||||
$classType = mb_strpos( $this->options['stackFieldType'], '\\' ) === FALSE ? ( "\\IPS\\Helpers\\Form\\" . $this->options['stackFieldType'] ) : $this->options['stackFieldType'];
|
||||
|
||||
foreach( $this->value as $k => $v )
|
||||
{
|
||||
$class = new $classType( $this->name .'_validate', $v, FALSE, $this->options, $this->customValidationCode, $this->prefix, $this->suffix);
|
||||
$class->validate();
|
||||
}
|
||||
|
||||
parent::validate();
|
||||
}
|
||||
}
|
||||
+1015
-6
File diff suppressed because it is too large.
Load diff
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Text input class for Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -82,7 +81,7 @@ class _Text extends TextArea
|
||||
* Constructor
|
||||
* Sets that the field is required if there is a minimum length and vice-versa
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
@@ -127,7 +126,7 @@ class _Text extends TextArea
|
||||
public function html()
|
||||
{
|
||||
/* 10/19/15 - adding htmlspecialchars around value if autocomplete is enabled so that html tag characters can be used (e.g. for members) */
|
||||
/* This value is decoded by the JS widget before use. See https://community.invisionpower.com/4bugtrack/active-reports/cannot-pm-certain-members-r6181/ */
|
||||
/* This value is decoded by the JS widget before use */
|
||||
if( $this->options['autocomplete'] and !empty( $this->value ) and is_array( $this->value ) )
|
||||
{
|
||||
foreach( $this->value as $key => $value )
|
||||
@@ -289,7 +288,6 @@ class _Text extends TextArea
|
||||
$array[] = preg_quote( $entry, '/' );
|
||||
}
|
||||
|
||||
/* @note: We use \b because of http://community.invisionpower.com/resources/bugs.html/_/4-0-0/anacronym-doesnt-work-in-middle-of-a-phrase-r47612 */
|
||||
$exactProfanityBreakpoints[] = '((?=<^|\b)(?:' . implode( '|', $array ) . ')(?=\b|$))';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Text input class for Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -52,7 +51,7 @@ class _TextArea extends FormAbstract
|
||||
* Constructor
|
||||
* Sets that the field is required if there is a minimum length and vice-versa
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
@@ -90,7 +89,7 @@ class _TextArea extends FormAbstract
|
||||
/**
|
||||
* Get value
|
||||
*
|
||||
* @return array
|
||||
* @return string|null
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Timezone class for Form Builder
|
||||
* @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 16 Feb 2017
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timezone selector for Form Builder
|
||||
*/
|
||||
class _Timezone extends Select
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array(), $customValidationCode=NULL, $prefix=NULL, $suffix=NULL, $id=NULL )
|
||||
{
|
||||
if ( !isset( $options['options'] ) )
|
||||
{
|
||||
$timezones = array();
|
||||
foreach ( \DateTimeZone::listIdentifiers() as $tz )
|
||||
{
|
||||
if ( $pos = mb_strpos( $tz, '/' ) )
|
||||
{
|
||||
$timezones[ 'timezone__' . mb_substr( $tz, 0, $pos ) ][ $tz ] = 'timezone__' . $tz;
|
||||
}
|
||||
else
|
||||
{
|
||||
$timezones[ $tz ] = 'timezone__' . $tz;
|
||||
}
|
||||
}
|
||||
|
||||
$options['options'] = $timezones;
|
||||
$options['sort'] = TRUE;
|
||||
}
|
||||
|
||||
parent::__construct( $name, $defaultValue, $required, $options, $customValidationCode, $prefix, $suffix, $id );
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Translatable text input class for Form Builder
|
||||
* @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 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -52,7 +51,7 @@ class _Translatable extends FormAbstract
|
||||
* Constructor
|
||||
* Sets that the field is required if there is a minimum length and vice-versa
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
@@ -139,7 +138,7 @@ class _Translatable extends FormAbstract
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Upload class for Form Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -79,7 +78,7 @@ class _Upload extends FormAbstract
|
||||
* Constructor
|
||||
* Sets that the max file size based on PHP's limits as well as the specified one
|
||||
*
|
||||
* @see \IPS\Helpers\Form\Abstract::__construct
|
||||
* @see \IPS\Helpers\Form\FormAbstract::__construct
|
||||
* @param string $name Name
|
||||
* @param mixed $defaultValue Default value
|
||||
* @param bool $required Required?
|
||||
@@ -707,7 +706,7 @@ class _Upload extends FormAbstract
|
||||
* String Value
|
||||
*
|
||||
* @param mixed $value The value
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public static function stringValue( $value )
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief URL input class for Form Builder
|
||||
* @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 11 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -40,6 +39,7 @@ class _Url extends Text
|
||||
public $childDefaultOptions = array(
|
||||
'allowedProtocols' => array( 'http', 'https' ),
|
||||
'allowedMimes' => NULL,
|
||||
'image' => FALSE,
|
||||
'file' => FALSE,
|
||||
'maxFileSize' => NULL,
|
||||
'maxDimensions' => NULL,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Width/Height input class for Form Builder
|
||||
* @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 28 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
@@ -28,6 +27,7 @@ class _WidthHeight extends FormAbstract
|
||||
* @code
|
||||
$defaultOptions = array(
|
||||
'unlimited' => array( 0, 0 ), // If any value other than NULL is provided, an "Unlimited" checkbox will be displayed. If checked, the values specified will be sent.
|
||||
'unlimitedLang' => 'unlimited', // Language string to use for unlimited checkbox label
|
||||
'image' => NULL, // If an \IPS\File object is provided, the image will be shown for resizing rather than a div
|
||||
'resizableDiv' => FALSE, // If set to false, the resizable div will not be displayed (useful if you expect dimensions to be large)
|
||||
);
|
||||
@@ -35,6 +35,7 @@ class _WidthHeight extends FormAbstract
|
||||
*/
|
||||
protected $defaultOptions = array(
|
||||
'unlimited' => NULL,
|
||||
'unlimitedLang' => 'unlimited',
|
||||
'image' => NULL,
|
||||
'resizableDiv' => TRUE,
|
||||
);
|
||||
@@ -70,7 +71,7 @@ class _WidthHeight extends FormAbstract
|
||||
*/
|
||||
public function html()
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core' )->widthheight( $this->name, $this->value[0], $this->value[1], $this->options['unlimited'], $this->options['image'] ? $this->options['image'] : NULL, $this->options['resizableDiv'] );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core' )->widthheight( $this->name, $this->value[0], $this->value[1], $this->options['unlimited'], $this->options['unlimitedLang'], $this->options['image'] ? $this->options['image'] : NULL, $this->options['resizableDiv'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Yes/No Radio Switches class for Form Builder
|
||||
* @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 8 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Multiple Redirector
|
||||
* @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 3 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Table Builder using an \IPS\Content\Item class datasource
|
||||
* @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 16 Jul 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Table;
|
||||
@@ -56,7 +55,7 @@ class _Content extends Table
|
||||
/**
|
||||
* @brief Honor the pinned flag for sorting. Will be set to false in stream-like views
|
||||
*/
|
||||
protected $honorPinned = TRUE;
|
||||
public $honorPinned = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Show moved links in the result set. This is desirable in controller generated views but not streams or widgets, etc.
|
||||
@@ -139,7 +138,7 @@ class _Content extends Table
|
||||
$this->where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'] . '=?', $container->_id );
|
||||
$this->sortDirection = ( $this->sortDirection !== NULL ) ? $this->sortDirection : $container->_sortOrder;
|
||||
|
||||
if ( !$this->sortBy and $container->_sortBy !== NULL )
|
||||
if ( !$this->sortBy and ! empty( $container->_sortBy ) )
|
||||
{
|
||||
$this->sortBy = $class::$databaseTable . '.' . $class::$databasePrefix . $container->_sortBy;
|
||||
}
|
||||
@@ -154,9 +153,24 @@ class _Content extends Table
|
||||
}
|
||||
|
||||
/* Set breadcrumb */
|
||||
foreach ( $container->parents() as $parent )
|
||||
if ( \IPS\IPS::classUsesTrait( $container, 'IPS\Content\ClubContainer' ) and $club = $container->club() )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
|
||||
\IPS\Output::i()->breadcrumb = array();
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
|
||||
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
|
||||
|
||||
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $container, 'sidebar' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( $container->parents() as $parent )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
}
|
||||
}
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, $container->_title );
|
||||
|
||||
@@ -485,6 +499,11 @@ class _Content extends Table
|
||||
*/
|
||||
protected function multimod()
|
||||
{
|
||||
if ( $this->noModerate )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Basic check that we selected something */
|
||||
@@ -518,7 +537,8 @@ class _Content extends Table
|
||||
catch( \OutOfBoundsException $e ) { }
|
||||
|
||||
return false;
|
||||
}
|
||||
},
|
||||
'clubs' => TRUE
|
||||
) ) );
|
||||
if ( isset( $class::$databaseColumnMap['moved_to'] ) )
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Table Builder using an array datasource
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Table;
|
||||
@@ -125,7 +124,7 @@ class _Custom extends Table
|
||||
/* Limit */
|
||||
if ( $this->limit and $this->count > $this->limit )
|
||||
{
|
||||
$rows = array_slice( $rows, ( $this->limit * ( $this->page - 1 ) ), $this->limit );
|
||||
$rows = array_slice( $rows, ( $this->limit * ( $this->page - 1 ) ), $this->limit, TRUE );
|
||||
}
|
||||
|
||||
/* Apply parsers */
|
||||
|
||||
+21
-14
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Table Builder using a database table datasource
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Table;
|
||||
@@ -151,6 +150,10 @@ class _Db extends Table
|
||||
{
|
||||
$where[] = $clause;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $advancedSearchValues[ $k ] );
|
||||
}
|
||||
break;
|
||||
|
||||
case SEARCH_CONTAINS_TEXT:
|
||||
@@ -173,6 +176,11 @@ class _Db extends Table
|
||||
case SEARCH_DATE_RANGE:
|
||||
$timezone = ( \IPS\Member::loggedIn()->timezone ? new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) : NULL );
|
||||
|
||||
if( !$v['start'] AND !$v['end'] )
|
||||
{
|
||||
unset( $advancedSearchValues[ $k ] );
|
||||
}
|
||||
|
||||
if ( $v['start'] )
|
||||
{
|
||||
if( !( $v['start'] instanceof \IPS\DateTime ) )
|
||||
@@ -205,9 +213,13 @@ class _Db extends Table
|
||||
break;
|
||||
|
||||
case SEARCH_MEMBER:
|
||||
if( $v instanceof \IPS\Member )
|
||||
if ( $v )
|
||||
{
|
||||
$where[] = array( "{$k}=?", $v->member_id );
|
||||
$where[] = array( "{$k}=?", ( $v instanceof \IPS\Member ) ? $v->member_id : $v );
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $advancedSearchValues[ $k ] );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -312,7 +324,7 @@ class _Db extends Table
|
||||
$count = $count->first();
|
||||
|
||||
/* Now get column headers */
|
||||
$query = \IPS\Db::i()->select( $this->onlySelected ? implode( ', ', $selects ) : '*', $this->table, $where, NULL, array( 0, 1 ), $this->group );
|
||||
$query = \IPS\Db::i()->select( $this->onlySelected ? implode( ', ', $selects ) : '*', $this->table, NULL, NULL, array( 0, 1 ) );
|
||||
|
||||
if ( count( $this->joins ) )
|
||||
{
|
||||
@@ -321,11 +333,6 @@ class _Db extends Table
|
||||
$query->join( $join['from'], ( isset( $join['where'] ) ? $join['where'] : null ), ( isset( $join['type'] ) ) ? $join['type'] : 'LEFT' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->index )
|
||||
{
|
||||
$query->forceIndex( $this->index );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -403,7 +410,7 @@ class _Db extends Table
|
||||
$row[ $k ] = isset( $_row[ $k ] ) ? $_row[ $k ] : NULL;
|
||||
}
|
||||
|
||||
if( !empty( $advancedSearchValues ) )
|
||||
if( !empty( $advancedSearchValues ) AND !isset( \IPS\Request::i()->noColumn ) )
|
||||
{
|
||||
foreach ( $advancedSearchValues as $k => $v )
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Table Builder
|
||||
* @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 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Table;
|
||||
@@ -86,6 +85,11 @@ abstract class _Table
|
||||
*/
|
||||
public $showAdvancedSearch = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Whether to use the placeholder loading style with this table
|
||||
*/
|
||||
public $dummyLoading = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Fields to enable advanced sarch on
|
||||
* @note Keys are the field names. Values are a IPS\Helpers\Table\SEARCH_* constant
|
||||
@@ -113,6 +117,11 @@ abstract class _Table
|
||||
*/
|
||||
protected $paginationKey = 'page';
|
||||
|
||||
/**
|
||||
* @brief Use simple pagination
|
||||
*/
|
||||
public $simplePagination = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Table resort parameter
|
||||
*/
|
||||
@@ -149,9 +158,14 @@ abstract class _Table
|
||||
public $mainColumn = NULL;
|
||||
|
||||
/**
|
||||
* @brief Additional CSS classes to apply to columns
|
||||
* @brief Additional CSS classes to apply to the table
|
||||
*/
|
||||
public $classes = array();
|
||||
|
||||
/**
|
||||
* @brief Additional CSS classes to apply to individual columns
|
||||
*/
|
||||
public $rowClasses = array();
|
||||
|
||||
/**
|
||||
* @brief Buttons to show on the "root row"
|
||||
@@ -502,7 +516,16 @@ abstract class _Table
|
||||
$resortKey = $this->resortKey;
|
||||
if( \IPS\Request::i()->isAjax() and \IPS\Request::i()->$resortKey )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'rows' => call_user_func( $this->rowsTemplate, $this, $headers, $rows, $this->mainColumn, $this->rootButtons, array() ), 'pagination' => \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $this->baseUrl, $this->pages, $this->page, $this->limit, TRUE, $this->paginationKey ), 'extraHtml' => $this->extraHtml ) );
|
||||
if ( count( $rows ) )
|
||||
{
|
||||
$rowHtml = call_user_func( $this->rowsTemplate, $this, $headers, $rows, $this->mainColumn, $this->rootButtons, array() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$rowHtml = \IPS\Theme::i()->getTemplate( 'tables', 'core', 'front' )->noRows();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->json( array( 'rows' => $rowHtml, 'pagination' => \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $this->baseUrl, $this->pages, $this->page, $this->limit, TRUE, $this->paginationKey, $this->simplePagination ), 'extraHtml' => $this->extraHtml ) );
|
||||
}
|
||||
/* Otherwise, show the full table */
|
||||
else
|
||||
@@ -608,7 +631,7 @@ abstract class _Table
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !empty( $advancedSearchValues ) )
|
||||
if( !empty( $advancedSearchValues ) AND !isset( \IPS\Request::i()->noColumn ) )
|
||||
{
|
||||
$headers = array_combine( $this->include, $this->include );
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Tree Builder
|
||||
* @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 20 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Tree;
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user