Version 4.2.0

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

No files matched your search

+22 -15
View File
@@ -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;
+5 -6
View File
@@ -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()
+4 -5
View File
@@ -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;
+5 -6
View File
@@ -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>
+5 -6
View File
@@ -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;">
+6 -7
View File
@@ -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 )
{
+13 -7
View File
@@ -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 ) )
+5 -6
View File
@@ -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()
+5 -9
View File
@@ -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' ) );
}
/**
+4 -5
View File
@@ -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;
+7 -8
View File
@@ -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 */
+5 -6
View File
@@ -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() )
+33 -13
View File
@@ -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()
{
+22 -5
View File
@@ -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' );
}
}
}
}
}
+8 -10
View File
@@ -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
}
}
}
}
+5 -6
View File
@@ -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');
}
+32 -6
View File
@@ -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;
}
/**
+5 -6
View File
@@ -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()
{
+5 -6
View File
@@ -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() )
+15 -6
View File
@@ -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;
+23 -9
View File
@@ -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;
+24 -10
View File
@@ -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'] );
}
/**
+5 -6
View File
@@ -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?
+24 -8
View File
@@ -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'] );
}
}
+23 -7
View File
@@ -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 )
{
+5 -6
View File
@@ -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()
{
+4 -5
View File
@@ -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;
+4 -5
View File
@@ -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;
+9 -10
View File
@@ -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;
}
+7 -6
View File
@@ -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 ) );
}
}
+5 -6
View File
@@ -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?
+13 -6
View File
@@ -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();
}
}
File diff suppressed because it is too large. Load diff
+6 -8
View File
@@ -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|$))';
}
}
+6 -7
View File
@@ -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()
{
+53
View File
@@ -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 );
}
}
+6 -7
View File
@@ -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()
{
+6 -7
View File
@@ -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 )
{
+5 -5
View File
@@ -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,
+7 -6
View File
@@ -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'] );
}
/**
+4 -5
View File
@@ -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;