Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+199 -83
View File
@@ -11,7 +11,7 @@
namespace IPS;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -81,6 +81,11 @@ abstract class _CustomField extends \IPS\Node\Model
return parent::__set( $key, $value );
}
/**
* @brief Field ID controlling formatting that we should show/hide depending upon field type selection
*/
protected $fieldFormattingId = 'pf_format';
/**
* [Node] Add/Edit Form
@@ -124,25 +129,25 @@ abstract class _CustomField extends \IPS\Node\Model
), static::$additionalFieldTypes );
$toggles = array(
'CheckboxSet' => array( 'pf_content', 'pf_not_null', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Codemirror' => array( 'pf_not_null', 'pf_max_input', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Email' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', 'pf_search_type', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Member' => array( 'pf_not_null', 'pf_multiple', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Password' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Select' => array( 'pf_not_null', 'pf_content', 'pf_multiple', 'pf_search_type_on_off', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Tel' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', 'pf_search_type', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Text' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', 'pf_search_type', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'TextArea' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', 'pf_search_type', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Url' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', 'pf_search_type', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Radio' => array( 'pf_content', "{$form->id}_header_pfield_displayoptions", 'pf_search_type_on_off', 'pf_format' ),
'Address' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Color' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Date' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Editor' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", 'pf_format', 'pf_search_type', 'pf_allow_attachments' ),
'Number' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'CheckboxSet' => array( 'pf_content', 'pf_not_null', 'pf_search_type_on_off', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Codemirror' => array( 'pf_not_null', 'pf_max_input', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Email' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', 'pf_search_type', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Member' => array( 'pf_not_null', 'pf_multiple', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Password' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Select' => array( 'pf_not_null', 'pf_content', 'pf_multiple', 'pf_search_type_on_off', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Tel' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', 'pf_search_type', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Text' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', 'pf_search_type', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'TextArea' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', 'pf_search_type', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Url' => array( 'pf_not_null', 'pf_max_input', 'pf_input_format', 'pf_search_type', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Radio' => array( 'pf_content', "{$form->id}_header_pfield_displayoptions", 'pf_search_type_on_off', $this->fieldFormattingId ),
'Address' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Color' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Date' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Editor' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId, 'pf_search_type', 'pf_allow_attachments' ),
'Number' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Poll' => array( 'pf_not_null' ),
'Rating' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Upload' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", 'pf_format' ),
'Rating' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
'Upload' => array( 'pf_not_null', "{$form->id}_header_pfield_displayoptions", $this->fieldFormattingId ),
);
foreach ( static::$additionalFieldTypes as $k => $v )
{
@@ -200,7 +205,6 @@ abstract class _CustomField extends \IPS\Node\Model
$form->addHeader( 'pfield_displayoptions' );
$form->add( new \IPS\Helpers\Form\Select( 'pf_search_type', $this->id ? $this->search_type : 'loose', FALSE, array( 'options' => array( 'exact' => 'pf_search_type_exact', 'loose' => 'pf_search_type_loose', '' => 'pf_search_type_none' ) ), NULL, NULL, NULL, 'pf_search_type' ) );
$form->add( new \IPS\Helpers\Form\Select( 'pf_search_type_on_off', $this->id ? $this->search_type : 'exact', FALSE, array( 'options' => array( 'exact' => 'pf_search_type_exact', '' => 'pf_search_type_none' ) ), NULL, NULL, NULL, 'pf_search_type_on_off' ) );
}
/**
@@ -211,7 +215,7 @@ abstract class _CustomField extends \IPS\Node\Model
*/
protected function canKeepValueOnChange( $newType )
{
if ( in_array( $newType, array_keys( static::$additionalFieldTypes ) ) )
if ( \in_array( $newType, array_keys( static::$additionalFieldTypes ) ) )
{
return $newType === $this->type;
}
@@ -219,71 +223,71 @@ abstract class _CustomField extends \IPS\Node\Model
switch ( $this->type )
{
case 'Address':
return in_array( $newType, array( 'Address' ) );
return \in_array( $newType, array( 'Address' ) );
case 'Checkbox':
return in_array( $newType, array( 'Checkbox', 'YesNo' ) );
return \in_array( $newType, array( 'Checkbox', 'YesNo' ) );
case 'CheckboxSet':
return in_array( $newType, array( 'CheckboxSet', 'Select' ) );
return \in_array( $newType, array( 'CheckboxSet', 'Select' ) );
case 'Code':
case 'Codemirror':
return in_array( $newType, array( 'Code', 'Codemirror', 'Editor', 'TextArea' ) );
return \in_array( $newType, array( 'Code', 'Codemirror', 'Editor', 'TextArea' ) );
case 'Color':
return in_array( $newType, array( 'Color', 'Text' ) );
return \in_array( $newType, array( 'Color', 'Text' ) );
case 'Date':
return in_array( $newType, array( 'Date', 'Text' ) );
return \in_array( $newType, array( 'Date', 'Text' ) );
case 'Editor':
return in_array( $newType, array( 'Code', 'Editor', 'TextArea' ) );
return \in_array( $newType, array( 'Code', 'Editor', 'TextArea' ) );
case 'Email':
return in_array( $newType, array( 'Email', 'Password', 'Text' ) );
return \in_array( $newType, array( 'Email', 'Password', 'Text' ) );
case 'Item':
return in_array( $newType, array( 'Item', 'TextArea' ) );
return \in_array( $newType, array( 'Item', 'TextArea' ) );
case 'Member':
return in_array( $newType, array( 'Member', 'Text', 'TextArea', 'Editor' ) );
return \in_array( $newType, array( 'Member', 'Text', 'TextArea', 'Editor' ) );
case 'Number':
return in_array( $newType, array( 'Number', 'Password', 'Rating', 'Text', 'Tel' ) );
return \in_array( $newType, array( 'Number', 'Password', 'Rating', 'Text', 'Tel' ) );
case 'Password':
return in_array( $newType, array( 'Number', 'Password', 'Text', 'Tel' ) );
return \in_array( $newType, array( 'Number', 'Password', 'Text', 'Tel' ) );
case 'Poll':
return in_array( $newType, array( 'Poll' ) );
return \in_array( $newType, array( 'Poll' ) );
case 'Radio':
return in_array( $newType, array( 'Radio', 'Select' ) );
return \in_array( $newType, array( 'Radio', 'Select' ) );
case 'Rating':
return in_array( $newType, array( 'Number', 'Password', 'Rating', 'Text', 'Tel' ) );
return \in_array( $newType, array( 'Number', 'Password', 'Rating', 'Text', 'Tel' ) );
case 'Select':
return in_array( $newType, array( 'Select', 'CheckboxSet' ) );
return \in_array( $newType, array( 'Select', 'CheckboxSet' ) );
case 'Tel':
return in_array( $newType, array( 'Password', 'Rating', 'Text', 'Tel' ) );
return \in_array( $newType, array( 'Password', 'Rating', 'Text', 'Tel' ) );
case 'Text':
return in_array( $newType, array( 'Email', 'Password', 'Text', 'Tel', 'Url', 'Editor', 'TextArea', 'Code', 'Codemirror' ) );
return \in_array( $newType, array( 'Email', 'Password', 'Text', 'Tel', 'Url', 'Editor', 'TextArea', 'Code', 'Codemirror' ) );
case 'TextArea':
return in_array( $newType, array( 'Code', 'Editor', 'TextArea' ) );
return \in_array( $newType, array( 'Code', 'Editor', 'TextArea' ) );
case 'Upload':
return in_array( $newType, array( 'Upload' ) );
return \in_array( $newType, array( 'Upload' ) );
case 'Url':
return in_array( $newType, array( 'Text', 'Url' ) );
return \in_array( $newType, array( 'Text', 'Url' ) );
case 'YesNo':
return in_array( $newType, array( 'Checkbox', 'YesNo' ) );
return \in_array( $newType, array( 'Checkbox', 'YesNo' ) );
}
return FALSE;
@@ -378,7 +382,7 @@ abstract class _CustomField extends \IPS\Node\Model
if ( $values['pf_type'] != 'Upload' )
{
if ( in_array( $columnDefinition['type'], array( 'TEXT', 'MEDIUMTEXT' ) ) )
if ( \in_array( $columnDefinition['type'], array( 'TEXT', 'MEDIUMTEXT' ) ) )
{
\IPS\Db::i()->addIndex( static::$contentDatabaseTable, array( 'type' => 'fulltext', 'name' => $columnDefinition['name'], 'columns' => array( $columnDefinition['name'] ) ) );
}
@@ -404,7 +408,7 @@ abstract class _CustomField extends \IPS\Node\Model
if ( $values['pf_type'] != 'Upload' )
{
if ( in_array( $columnDefinition['type'], array( 'TEXT', 'MEDIUMTEXT' ) ) )
if ( \in_array( $columnDefinition['type'], array( 'TEXT', 'MEDIUMTEXT' ) ) )
{
\IPS\Db::i()->addIndex( static::$contentDatabaseTable, array( 'type' => 'fulltext', 'name' => $column, 'columns' => array( $column ) ) );
}
@@ -420,7 +424,7 @@ abstract class _CustomField extends \IPS\Node\Model
\IPS\Db::i()->changeColumn( static::$contentDatabaseTable, $column, $columnDefinition );
if ( in_array( $columnDefinition['type'], array( 'TEXT', 'MEDIUMTEXT' ) ) )
if ( \in_array( $columnDefinition['type'], array( 'TEXT', 'MEDIUMTEXT' ) ) )
{
\IPS\Db::i()->addIndex( static::$contentDatabaseTable, array( 'type' => 'fulltext', 'name' => $column, 'columns' => array( $column ) ) );
}
@@ -451,16 +455,16 @@ abstract class _CustomField extends \IPS\Node\Model
/* And the other fields */
if ( isset( static::$parentNodeClass ) AND isset( $values['pf_group_id'] ) )
{
$values['group_id'] = is_object( $values['pf_group_id'] ) ? $values['pf_group_id']->_id : $values['pf_group_id'];
$values['group_id'] = \is_object( $values['pf_group_id'] ) ? $values['pf_group_id']->_id : $values['pf_group_id'];
}
/* "Required" means nothing for radio and checkbox */
if( isset( $values['pf_type'] ) and in_array( $values['pf_type'], array( 'Radio', 'Checkbox' ) ) )
if( isset( $values['pf_type'] ) and \in_array( $values['pf_type'], array( 'Radio', 'Checkbox' ) ) )
{
$values['pf_not_null'] = FALSE;
}
if ( array_key_exists( 'pf_search_type_on_off', $values ) and isset( $values['pf_type'] ) and ( $values['pf_type'] == 'Select' or $values['pf_type'] == 'Radio' ) )
if ( array_key_exists( 'pf_search_type_on_off', $values ) and isset( $values['pf_type'] ) and ( \in_array( $values['pf_type'], array( 'Select', 'Radio', 'CheckboxSet') ) ) )
{
$values['pf_search_type'] = (string) $values['pf_search_type_on_off'];
}
@@ -531,22 +535,23 @@ abstract class _CustomField extends \IPS\Node\Model
return;
}
$oldId = $this->id;
$oldId = $this->id;
$oldColumn = isset( $this->column ) ? $this->column : "field_{$oldId}";
parent::__clone();
$column = isset( $this->column ) ? $this->column : "field_{$this->id}";
$column = isset( $this->column ) ? $this->column : "field_{$this->id}";
if ( isset( static::$contentDatabaseTable ) )
{
$definition = \IPS\Db::i()->getTableDefinition( static::$contentDatabaseTable, TRUE );
$fieldDefinition = $definition['columns']["field_" . $oldId];
$fieldDefinition = $definition['columns'][ $oldColumn ];
$fieldDefinition['name'] = $column;
\IPS\Db::i()->addColumn( static::$contentDatabaseTable, $fieldDefinition );
if ( $this->type != 'Upload' )
{
if ( in_array( $fieldDefinition['type'], array( 'TEXT', 'MEDIUMTEXT' ) ) )
if ( \in_array( $fieldDefinition['type'], array( 'TEXT', 'MEDIUMTEXT' ) ) )
{
\IPS\Db::i()->addIndex( static::$contentDatabaseTable, array( 'type' => 'fulltext', 'name' => $column, 'columns' => array( $column ) ) );
}
@@ -557,6 +562,11 @@ abstract class _CustomField extends \IPS\Node\Model
}
}
if ( isset( $this->column ) )
{
$this->column = NULL;
}
\IPS\Lang::saveCustom( 'core', static::$langKey . '_' . $this->id, iterator_to_array( \IPS\Db::i()->select( 'word_custom, lang_id', 'core_sys_lang_words', array( 'word_key=?', static::$langKey . '_' . $oldId ) )->setKeyField( 'lang_id' )->setValueField( 'word_custom' ) ) );
\IPS\Lang::saveCustom( 'core', static::$langKey . '_' . $this->id . '_desc', iterator_to_array( \IPS\Db::i()->select( 'word_custom, lang_id', 'core_sys_lang_words', array( 'word_key=?', static::$langKey . '_' . $oldId . '_desc' ) )->setKeyField( 'lang_id' )->setValueField( 'word_custom' ) ) );
}
@@ -584,11 +594,12 @@ abstract class _CustomField extends \IPS\Node\Model
/**
* Build Form Helper
*
* @param mixed $value The value
* @param callback $customValidationCode Custom validation code
* @param mixed $value The value
* @param callback $customValidationCode Custom validation code
* @param \IPS\Content|NULL $content The associated content, if editing
* @return \IPS\Helpers\Form\FormAbstract
*/
public function buildHelper( $value=NULL, $customValidationCode=NULL )
public function buildHelper( $value=NULL, $customValidationCode=NULL, \IPS\Content $content = NULL )
{
$class = '\IPS\Helpers\Form\\' . $this->type;
@@ -608,7 +619,7 @@ abstract class _CustomField extends \IPS\Node\Model
// displayValue will then not apply the viewing user's timestamp.
$options['timezone'] = new \DateTimeZone('UTC');
if ( is_numeric( $value ) )
if ( \is_numeric( $value ) )
{
$value = \IPS\DateTime::ts( $value );
}
@@ -660,9 +671,9 @@ abstract class _CustomField extends \IPS\Node\Model
$value = array();
foreach( $values as $val )
{
if ( is_numeric( $val ) and intval( $val ) == $val )
if ( \is_numeric( $val ) and \intval( $val ) == $val )
{
$value[] = intval( $val );
$value[] = \intval( $val );
}
else
{
@@ -675,9 +686,9 @@ abstract class _CustomField extends \IPS\Node\Model
}
else
{
if ( is_numeric( $value ) and intval( $value ) == $value )
if ( \is_numeric( $value ) and \intval( $value ) == $value )
{
$value = intval( $value );
$value = \intval( $value );
}
}
@@ -708,9 +719,9 @@ abstract class _CustomField extends \IPS\Node\Model
if ( !isset( $options['autoSaveKey'] ) )
{
$options['autoSaveKey'] = md5( get_class( $this ) . '-' . $this->id );
$options['autoSaveKey'] = md5( \get_class( $this ) . '-' . $this->id . '-' . ( $content ? $content->id : 'new' ) );
}
$options['allowAttachments'] = $this->allow_attachments;
break;
@@ -762,22 +773,134 @@ abstract class _CustomField extends \IPS\Node\Model
/**
* Claim attachments for an editor field
*
* @param int|NULL $id1 ID 1 (ID 2 will be the field ID)
* @param mixed $id3 ID 3
* @param int|NULL $id1 ID 1 (ID 2 will be the field ID)
* @param mixed $id3 ID 3
* @param \IPS\Content|NULL $contentBeingEdited If you passed $content to buildHelpers(), pass that same object here. ONLY if editing, don't pass a newly created piece of content
* @return void
*/
public function claimAttachments( $id1 = NULL, $id3 = NULL )
public function claimAttachments( $id1 = NULL, $id3 = NULL, $contentBeingEdited = NULL )
{
$options = static::$editorOptions;
if ( !isset( $options['autoSaveKey'] ) )
{
$options['autoSaveKey'] = md5( get_class( $this ) . '-' . $this->id );
$options['autoSaveKey'] = md5( \get_class( $this ) . '-' . $this->id . '-' . ( $contentBeingEdited ? $contentBeingEdited->id : 'new' ) );
}
\IPS\File::claimAttachments( $options['autoSaveKey'], $id1, $this->id, $id3 );
}
/**
* Return values in API-suitable format
*
* @param mixed $value The value
* @param bool $showSensitiveInformation If TRUE, potentially sensitive data (like passwords) will be displayed - otherwise will be blanked out
* @return string|int|array|boolean Must return a value that can be JSON serialized
*/
public function apiValue( $value=NULL, $showSensitiveInformation=FALSE )
{
switch( $this->type )
{
case 'Address':
return json_decode( $value );
case 'CheckboxSet':
case 'Select':
if ( \is_array( $this->extra ) AND isset( $this->extra[ $value ] ) )
{
$value = $this->extra[ $value ];
}
else
{
$options = json_decode( $this->content, TRUE );
/* Options are based on numeric indices, however when creating the original form field we may have added
a dummy option to the beginning - we need to do the same here or else index '5' is not the same index '5'
we originally selected from the form element */
if( $this->type == 'Select' )
{
$requiredColumn = ( isset( $this::$databaseColumnMap['not_null'] ) and $this::$databaseColumnMap['not_null'] ) ? $this::$databaseColumnMap['not_null'] : NULL;
if ( !$this->$requiredColumn AND !$this->multiple )
{
array_unshift( $options, '' );
}
}
$values = array();
if( $this->multiple )
{
foreach( explode( ',', $value ) as $_value )
{
$values[] = ( isset( $options[ $_value ] ) ) ? $options[ $_value ] : $_value;
}
}
else
{
$values[] = ( isset( $options[ $value ] ) ) ? $options[ $value ] : $value;
}
}
return $values;
case 'Member':
return array_map( function( $id )
{
$member = \IPS\Member::load( $id );
$group = \IPS\Member\Group::load( $member->group['g_id'] );
return array(
'id' => $member->member_id,
'name' => $member->name,
'photo' => $member->photo,
'groupName' => $group->name
);
}, explode( "\n", $value ) );
case 'Password':
if ( $value )
{
return $showSensitiveInformation ? $value : '********';
}
return '';
case 'Poll':
case 'Ftp':
return FALSE; // Not implemented in API yet
case 'Upload':
if( $value )
{
$file = \IPS\File::get( static::$uploadStorageExtension, $value );
$downloadUrl = \IPS\Http\Url::internal( 'applications/core/interface/file/cfield.php', 'none' )->setqueryString( array(
'storage' => $file->storageExtension,
'path' => (string) $file->originalFilename,
'fileKey' => base64_encode( \IPS\Text\Encrypt::fromPlaintext( (string) $file )->cipher )
) );
return (string) $downloadUrl;
}
else
{
return '';
}
case 'YesNo':
return (bool) $value;
case 'Color':
return ( $value AND $value !== '#' ) ? $value : '';
case 'Url':
return ( $value ) ? (string) \IPS\Http\Url::external( $value ) : NULL;
case 'Rating':
return array(
'value' => $value,
'max' => 5
);
// These types can just return value as-is
case 'Checkbox':
case 'CodeMirror':
case 'Date':
case 'Editor':
case 'TextArea':
default:
return $value;
}
}
/**
* Display Value
*
@@ -798,13 +921,13 @@ abstract class _CustomField extends \IPS\Node\Model
case 'CheckboxSet':
case 'Select':
if ( is_array( $this->extra ) AND isset( $this->extra[ $value ] ) )
if ( \is_array( $this->extra ) AND isset( $this->extra[ $value ] ) )
{
$value = $this->extra[ $value ];
}
else
{
$options = json_decode( $this->content, TRUE );
$options = json_decode( $this->content, TRUE );
/* Options are based on numeric indices, however when creating the original form field we may have added
a dummy option to the beginning - we need to do the same here or else index '5' is not the same index '5'
@@ -848,20 +971,13 @@ abstract class _CustomField extends \IPS\Node\Model
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->prettyprint( $value );
case 'Color':
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->colorDisplay( $value );
return ( $value AND $value !== '#' ) ? \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->colorDisplay( $value ) : '';
case 'Date':
return \IPS\DateTime::ts( $value, TRUE )->localeDate(); // See buildHelper for why we ignore the timezone
case 'Editor':
if ( \IPS\Dispatcher::hasInstance() AND \IPS\Dispatcher::i()->controllerLocation === 'admin' )
{
return \IPS\Text\Parser::mungeResources( $value, TRUE );
}
else
{
return $value;
}
return $value;
case 'Member':
return implode( '<br>', array_map( function( $id )
@@ -880,14 +996,13 @@ abstract class _CustomField extends \IPS\Node\Model
return $value ? ( (string) \IPS\Poll::load( $value ) ) : NULL;
case 'Rating':
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->rating( $this->options['max'], $value );
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->rating( $this->options['max'] ?? null, $value );
case 'TextArea':
return nl2br( htmlspecialchars( $value, ENT_DISALLOWED | ENT_QUOTES, 'UTF-8', FALSE ) );
case 'Url':
$munged = ( $value ) ? \IPS\Http\Url::external( $value )->makeSafeForAcp() : NULL;
return ( $value ) ? \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $munged, TRUE, $value, TRUE, TRUE ) : NULL;
return ( $value ) ? \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $value, TRUE, $value, TRUE, TRUE, TRUE ) : NULL;
case 'Upload':
if( $value )
@@ -895,7 +1010,8 @@ abstract class _CustomField extends \IPS\Node\Model
$file = \IPS\File::get( static::$uploadStorageExtension, $value );
$downloadUrl = \IPS\Http\Url::internal( 'applications/core/interface/file/cfield.php', 'none' )->setqueryString( array(
'storage' => $file->storageExtension,
'path' => (string) $file,
'path' => (string) $file->originalFilename,
'fileKey' => \IPS\Text\Encrypt::fromPlaintext( (string) $file )->tag()
) );
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->uploadDisplay( $file, $downloadUrl );
}
@@ -905,7 +1021,7 @@ abstract class _CustomField extends \IPS\Node\Model
}
case 'Ftp':
$value = is_array( $value ) ? $value : json_decode( \IPS\Text\Encrypt::fromTag( $value )->decrypt(), TRUE );
$value = \is_array( $value ) ? $value : json_decode( \IPS\Text\Encrypt::fromTag( $value )->decrypt(), TRUE );
if ( $showSensitiveInformation )
{
$url = \IPS\Http\Url::createFromComponents( $value['server'], $value['protocol'] ? ( $value['protocol'] == 'ssl_ftp' ? 'ftps': $value['protocol'] ) : 'ftp', $value['path'] ?: NULL, NULL, $value['port'] ?: 21, $value['un'] ?: NULL, $value['pw'] ?: NULL );