Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,13 +11,13 @@
|
||||
|
||||
/**
|
||||
*
|
||||
* @todo: Shared media field type
|
||||
* @todo Shared media field type
|
||||
*
|
||||
*/
|
||||
namespace IPS\cms;
|
||||
|
||||
/* 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;
|
||||
@@ -184,7 +184,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
/**
|
||||
* @brief Fields that can be filtered on the front end. These appear in \Table advanced search and also in the DatabaseFilters widget.
|
||||
*/
|
||||
protected static $filterableFields = array( 'CheckboxSet', 'Radio', 'Select', 'YesNo', 'Date' );
|
||||
protected static $filterableFields = array( 'CheckboxSet', 'Radio', 'Select', 'YesNo', 'Date', 'Member' );
|
||||
|
||||
/**
|
||||
* Load Record
|
||||
@@ -213,18 +213,19 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
* @param string|NULL $permissionCheck The permission key to check for or NULl to not check permissions
|
||||
* @param \IPS\Member|NULL $member The member to check permissions for or NULL for the currently logged in member
|
||||
* @param mixed $where Additional WHERE clause
|
||||
* @param array|NULL $limit Limit/offset to use, or NULL for no limit (default)
|
||||
* @return array
|
||||
*/
|
||||
public static function roots( $permissionCheck='view', $member=NULL, $where=array() )
|
||||
public static function roots( $permissionCheck='view', $member=NULL, $where=array(), $limit=NULL )
|
||||
{
|
||||
$permissionCheck = ( \IPS\Dispatcher::hasInstance() AND \IPS\Dispatcher::i()->controllerLocation === 'admin' ) ? NULL : $permissionCheck;
|
||||
|
||||
if ( ! isset( static::$cache[ static::$customDatabaseId ][ $permissionCheck ] ) )
|
||||
{
|
||||
$langToLoad = array();
|
||||
$where[] = array('field_database_id=?', static::$customDatabaseId );
|
||||
$where[] = array( 'field_database_id=?', static::$customDatabaseId );
|
||||
|
||||
static::$cache[ static::$customDatabaseId ][ $permissionCheck ] = parent::roots( $permissionCheck, $member, $where );
|
||||
static::$cache[ static::$customDatabaseId ][ $permissionCheck ] = parent::roots( $permissionCheck, $member, $where, $limit );
|
||||
|
||||
foreach( static::$cache[ static::$customDatabaseId ][ $permissionCheck ] as $id => $obj )
|
||||
{
|
||||
@@ -239,7 +240,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$langToLoad[] = static::$langKey . '_' . $obj->id . '_warning';
|
||||
}
|
||||
|
||||
if ( count( $langToLoad ) AND \IPS\Dispatcher::hasInstance() and \IPS\Dispatcher::i()->controllerLocation !== 'setup' )
|
||||
if ( \count( $langToLoad ) AND \IPS\Dispatcher::hasInstance() and \IPS\Dispatcher::i()->controllerLocation !== 'setup' )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->get( $langToLoad );
|
||||
}
|
||||
@@ -285,7 +286,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
if ( $container->fields !== '*' AND $container->fields !== NULL )
|
||||
{
|
||||
if ( ! in_array( $row->id, $container->fields ) AND $row->id != $database->field_title AND $row->id != $database->field_content )
|
||||
if ( ! \in_array( $row->id, $container->fields ) AND $row->id != $database->field_title AND $row->id != $database->field_content )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -337,7 +338,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
if ( $container->fields !== '*' AND $container->fields !== NULL )
|
||||
{
|
||||
if ( ! in_array( $row->id, $container->fields ) AND $row->id != $database->field_title AND $row->id != $database->field_content )
|
||||
if ( ! \in_array( $row->id, $container->fields ) AND $row->id != $database->field_title AND $row->id != $database->field_content )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -400,7 +401,19 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
$customValidationCode = function( $val ) use ( $database, $row, $record )
|
||||
{
|
||||
call_user_func_array( 'IPS\cms\Fields' . static::$customDatabaseId . '::validateUnique', array( $val, $row, $record ) );
|
||||
$class = 'IPS\cms\Fields' . static::$customDatabaseId;
|
||||
$class::validateUnique( $val, $row, $record );
|
||||
};
|
||||
}
|
||||
|
||||
if( $row->id == $database->field_title AND $row->type === 'Select' )
|
||||
{
|
||||
$customValidationCode = function( $val )
|
||||
{
|
||||
if( $val === NULL )
|
||||
{
|
||||
throw new \DomainException( 'form_required' );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -436,7 +449,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
if ( $container->fields !== '*' AND $container->fields !== NULL )
|
||||
{
|
||||
if ( ! in_array( $row->id, $container->fields ) AND $row->id != $database->field_title AND $row->id != $database->field_content )
|
||||
if ( ! \in_array( $row->id, $container->fields ) AND $row->id != $database->field_title AND $row->id != $database->field_content )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -479,7 +492,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
if ( $container->fields !== '*' AND $container->fields !== NULL )
|
||||
{
|
||||
if ( ! in_array( $row->id, $container->fields ) AND $row->id != $database->field_title AND $row->id != $database->field_content )
|
||||
if ( ! \in_array( $row->id, $container->fields ) AND $row->id != $database->field_title AND $row->id != $database->field_content )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -556,7 +569,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
* @param mixed $value Processed value
|
||||
* @param mixed $formValue Raw form value
|
||||
* @param string $type Type of display (listing/display/raw/processed).
|
||||
* @param NULL|\IPS\cms\Record $record Record showing this field
|
||||
* @param NULL|\IPS\cms\Records $record Record showing this field
|
||||
* @note Raw means the value saved from the input field, processed has the form display value method called. Listing and display take the options set by the field (badges, custom, etc)
|
||||
*
|
||||
* @return mixed|string
|
||||
@@ -584,7 +597,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
|
||||
if ( $this->type === 'Item' )
|
||||
{
|
||||
if ( ! is_array( $formValue ) and mb_strstr( $formValue, ',' ) )
|
||||
if ( ! \is_array( $formValue ) and mb_strstr( $formValue, ',' ) )
|
||||
{
|
||||
$value = explode( ',', $formValue );
|
||||
}
|
||||
@@ -593,7 +606,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$value = array( $formValue );
|
||||
}
|
||||
|
||||
if ( count( $value ) and isset( $this->extra['database'] ) and $this->extra['database'] )
|
||||
if ( \count( $value ) and isset( $this->extra['database'] ) and $this->extra['database'] )
|
||||
{
|
||||
$results = array();
|
||||
$class = '\IPS\cms\Records' . $this->extra['database'];
|
||||
@@ -652,7 +665,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
|
||||
if ( isset( $options[ $type ]['method'] ) AND $options[ $type ]['method'] !== 'simple' )
|
||||
{
|
||||
if ( in_array( $this->type, static::$mediaFields ) )
|
||||
if ( \in_array( $this->type, static::$mediaFields ) )
|
||||
{
|
||||
$template = mb_strtolower( $this->type );
|
||||
|
||||
@@ -747,7 +760,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
}
|
||||
|
||||
$parsed = array();
|
||||
foreach( $files as $file )
|
||||
foreach( $files as $idx => $file )
|
||||
{
|
||||
$file = \IPS\File::get( static::$uploadStorageExtension, (string) $file );
|
||||
|
||||
@@ -755,17 +768,44 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
\IPS\Output::i()->metaTags['og:image:url'][] = (string) $file->url;
|
||||
}
|
||||
|
||||
$downloadUrl = \IPS\Http\Url::internal( 'applications/core/interface/file/cfield.php', 'none' )->setqueryString( array(
|
||||
|
||||
$fileKey = \IPS\Text\Encrypt::fromPlaintext( (string) $file )->tag();
|
||||
$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' => $fileKey
|
||||
) );
|
||||
|
||||
$parsed[] = \IPS\Theme::i()->getTemplate( 'global', 'cms', 'front' )->uploadDisplay( \IPS\File::get( static::$uploadStorageExtension, $file ), $record, $downloadUrl );
|
||||
$parsed[] = \IPS\Theme::i()->getTemplate( 'global', 'cms', 'front' )->uploadDisplay( \IPS\File::get( static::$uploadStorageExtension, $file ), $record, $downloadUrl, $fileKey );
|
||||
}
|
||||
|
||||
$value = implode( " ", $parsed );
|
||||
}
|
||||
else if ( $this->type === 'Member' )
|
||||
{
|
||||
if ( mb_strstr( $value, "\n" ) )
|
||||
{
|
||||
$members = explode( "\n", $formValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
$members = array( $formValue );
|
||||
}
|
||||
|
||||
$parsed = array();
|
||||
|
||||
foreach( $members as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$parsed[] = \IPS\Member::load( $id )->link();
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
}
|
||||
|
||||
$value = implode( ", ", $parsed );
|
||||
|
||||
}
|
||||
|
||||
$value = \IPS\Theme::i()->getTemplate( 'records', 'cms', 'global' )->fieldBadge( $this->_title, $value, $class );
|
||||
}
|
||||
@@ -788,7 +828,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$files = array( $value );
|
||||
}
|
||||
|
||||
if ( count( $files ) )
|
||||
if ( \count( $files ) )
|
||||
{
|
||||
$parsed = array();
|
||||
foreach( $files AS $file )
|
||||
@@ -809,7 +849,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
/**
|
||||
* Parse custom HTML
|
||||
*
|
||||
* @parse string $type Type of display
|
||||
* @param string $type Type of display
|
||||
* @param string $template The HTML to parse
|
||||
* @param string $formValue The form value (key of select box, for example)
|
||||
* @param string $value The display value
|
||||
@@ -834,7 +874,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
if ( $this->type === 'Upload' )
|
||||
{
|
||||
if ( is_array( $value ) )
|
||||
if ( \is_array( $value ) )
|
||||
{
|
||||
foreach( $value as $idx => $val )
|
||||
{
|
||||
@@ -859,7 +899,8 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
|
||||
\IPS\Theme::runProcessFunction( $template, $functionName );
|
||||
|
||||
return call_user_func( 'IPS\\Theme\\'. $functionName, $value, $formValue, $this->_title, $record );
|
||||
$themeFunction = 'IPS\\Theme\\'. $functionName;
|
||||
return $themeFunction( $value, $formValue, $this->_title, $record );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -875,7 +916,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$fixedFields = \IPS\cms\Databases::load( static::$customDatabaseId )->fixed_field_perms;
|
||||
$perm = ( $where === 'form' ) ? 'perm_2' : 'perm_view';
|
||||
|
||||
if ( ! in_array( $field, array_keys( $fixedFields ) ) )
|
||||
if ( ! \in_array( $field, array_keys( $fixedFields ) ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -896,7 +937,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
/* Finally check permissions */
|
||||
if( $member instanceof \IPS\Member\Group )
|
||||
{
|
||||
return ( $permissions[ $perm ] === '*' or ( $permissions[ $perm ] and in_array( $member->g_id, explode( ',', $permissions[ $perm ] ) ) ) );
|
||||
return ( $permissions[ $perm ] === '*' or ( $permissions[ $perm ] and \in_array( $member->g_id, explode( ',', $permissions[ $perm ] ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -914,7 +955,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
$fixedFields = \IPS\cms\Databases::load( static::$customDatabaseId )->fixed_field_perms;
|
||||
|
||||
if ( $field !== NULL AND in_array( $field, array_keys( $fixedFields ) ) )
|
||||
if ( $field !== NULL AND \in_array( $field, array_keys( $fixedFields ) ) )
|
||||
{
|
||||
return $fixedFields[ $field ];
|
||||
}
|
||||
@@ -961,9 +1002,10 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
|
||||
/**
|
||||
* Magic method to capture validateInput_{id} callbacks
|
||||
* @param string $name Name of method called
|
||||
* @param mixed $arguments Args passed
|
||||
* @param string $name Name of method called
|
||||
* @param mixed $arguments Args passed
|
||||
* @throws \InvalidArgumentException
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
@@ -971,7 +1013,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
$id = mb_substr( $name, 14 );
|
||||
|
||||
if ( is_numeric( $id ) )
|
||||
if ( \is_numeric( $id ) )
|
||||
{
|
||||
$field = static::load( $id );
|
||||
}
|
||||
@@ -993,11 +1035,17 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
* @param string $val The value to check
|
||||
* @param \IPS\cms\Fields $field The field
|
||||
* @param \IPS\cms\Records $record The record (if any)
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public static function validateUnique( $val, $field, $record )
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( static::$customDatabaseId );
|
||||
|
||||
if( $field->type == 'Member' AND $val instanceof \IPS\Member )
|
||||
{
|
||||
$val = $val->member_id;
|
||||
}
|
||||
|
||||
$where = array( array( 'field_' . $field->id . '=?', $val ) );
|
||||
|
||||
@@ -1051,7 +1099,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
* Field custom template name
|
||||
*
|
||||
* @param string $type Type of name to fetch
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function fieldTemplateName( $type )
|
||||
{
|
||||
@@ -1061,12 +1109,12 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
/**
|
||||
* Set the "display json" field
|
||||
*
|
||||
* @param string|array $value
|
||||
* @param string|array $value Value
|
||||
* @return void
|
||||
*/
|
||||
public function set_display_json( $value )
|
||||
{
|
||||
$this->_data['display_json'] = ( is_array( $value ) ? json_encode( $value ) : $value );
|
||||
$this->_data['display_json'] = ( \is_array( $value ) ? json_encode( $value ) : $value );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1076,18 +1124,18 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
*/
|
||||
public function get_display_json()
|
||||
{
|
||||
return ( is_array( $this->_data['display_json'] ) ) ? $this->_data['display_json'] : json_decode( $this->_data['display_json'], TRUE );
|
||||
return ( \is_array( $this->_data['display_json'] ) ) ? $this->_data['display_json'] : json_decode( $this->_data['display_json'], TRUE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the "Format Options" field
|
||||
*
|
||||
* @param string|array $value
|
||||
* @param string|array $value Value
|
||||
* @return void
|
||||
*/
|
||||
public function set_format_opts( $value )
|
||||
{
|
||||
$this->_data['format_opts'] = ( is_array( $value ) ? json_encode( $value ) : $value );
|
||||
$this->_data['format_opts'] = ( \is_array( $value ) ? json_encode( $value ) : $value );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1103,23 +1151,23 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
/**
|
||||
* Set the "extra" field
|
||||
*
|
||||
* @param string|array $value
|
||||
* @param string|array $value Value
|
||||
* @return void
|
||||
*/
|
||||
public function set_extra( $value )
|
||||
{
|
||||
$this->_data['extra'] = ( is_array( $value ) ? json_encode( $value ) : $value );
|
||||
$this->_data['extra'] = ( \is_array( $value ) ? json_encode( $value ) : $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the "allowed_extensions" field
|
||||
*
|
||||
* @param string|array $value
|
||||
* @param string|array $value Value
|
||||
* @return void
|
||||
*/
|
||||
public function set_allowed_extensions( $value )
|
||||
{
|
||||
$this->_data['allowed_extensions'] = ( is_array( $value ) ? json_encode( $value ) : $value );
|
||||
$this->_data['allowed_extensions'] = ( \is_array( $value ) ? json_encode( $value ) : $value );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1283,6 +1331,12 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
switch( mb_ucfirst( $this->type ) )
|
||||
{
|
||||
case 'Upload':
|
||||
/* We need to return NULL if there's no value, File::get will return an URL object even if $value is empty */
|
||||
if ( empty( $value ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return \IPS\File::get( 'cms_Records', $value )->url;
|
||||
break;
|
||||
case 'Text':
|
||||
@@ -1320,12 +1374,12 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$this->extra = $extra;
|
||||
}
|
||||
|
||||
if ( ! is_array( $value ) )
|
||||
if ( ! \is_array( $value ) )
|
||||
{
|
||||
$value = explode( ',', $value );
|
||||
}
|
||||
|
||||
if ( is_array( $value ) )
|
||||
if ( \is_array( $value ) )
|
||||
{
|
||||
$return = array();
|
||||
foreach( $value as $key )
|
||||
@@ -1347,10 +1401,16 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
}
|
||||
else
|
||||
{
|
||||
return implode( ', ', array_map( function( $id )
|
||||
$links = array();
|
||||
|
||||
$value = \is_array( $value ) ? $value : ( ( $value instanceof \IPS\Member ) ? array( $value ) : explode( "\n", $value ) );
|
||||
|
||||
foreach( $value as $id )
|
||||
{
|
||||
return \IPS\Member::load( $id )->link();
|
||||
}, explode( "\n", $value ) ) );
|
||||
$links[] = ( $id instanceof \IPS\Member ) ? $id->link() : \IPS\Member::load( $id )->link();
|
||||
}
|
||||
|
||||
return implode( ', ', $links );
|
||||
}
|
||||
break;
|
||||
case 'Url':
|
||||
@@ -1361,7 +1421,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
break;
|
||||
case 'Date':
|
||||
case 'DateRange':
|
||||
if ( is_numeric( $value ) )
|
||||
if ( \is_numeric( $value ) )
|
||||
{
|
||||
$time = \IPS\DateTime::ts( $value );
|
||||
|
||||
@@ -1384,10 +1444,10 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
}
|
||||
}
|
||||
|
||||
return \IPS\Lang::wordbreak( $this->extra['time'] ? (string) $time : $time->localeDate() );
|
||||
return $this->extra['time'] ? (string) $time : $time->localeDate();
|
||||
}
|
||||
|
||||
if ( ! is_array( $value ) )
|
||||
if ( ! \is_array( $value ) )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('field_no_value_entered');
|
||||
}
|
||||
@@ -1398,7 +1458,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
if ( isset( $value[ $t ] ) )
|
||||
{
|
||||
$time = ( is_integer( $value[ $t ] ) ) ? \IPS\DateTime::ts( $value[ $t ], TRUE ) : $value[ $t ];
|
||||
$time = ( \is_integer( $value[ $t ] ) ) ? \IPS\DateTime::ts( $value[ $t ], TRUE ) : $value[ $t ];
|
||||
if ( isset( $this->extra['timezone'] ) and $this->extra['timezone'] )
|
||||
{
|
||||
try
|
||||
@@ -1430,7 +1490,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
}
|
||||
break;
|
||||
case 'Item':
|
||||
if ( ! is_array( $value ) and mb_strstr( $value, ',' ) )
|
||||
if ( ! \is_array( $value ) and mb_strstr( $value, ',' ) )
|
||||
{
|
||||
$value = explode( ',', $value );
|
||||
}
|
||||
@@ -1439,7 +1499,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$value = array( $value );
|
||||
}
|
||||
|
||||
if ( count( $value ) and isset( $this->extra['database'] ) and $this->extra['database'] )
|
||||
if ( \count( $value ) and isset( $this->extra['database'] ) and $this->extra['database'] )
|
||||
{
|
||||
$results = array();
|
||||
$class = '\IPS\cms\Records' . $this->extra['database'];
|
||||
@@ -1477,7 +1537,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
*/
|
||||
public function applyFormatter( $value )
|
||||
{
|
||||
if ( is_array( $this->format_opts ) and count( $this->format_opts ) )
|
||||
if ( \is_array( $this->format_opts ) and \count( $this->format_opts ) )
|
||||
{
|
||||
foreach( $this->format_opts as $id => $type )
|
||||
{
|
||||
@@ -1548,7 +1608,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$buttons['set_as_title'] = array(
|
||||
'icon' => 'list-ul',
|
||||
'title' => 'cms_set_field_as_title',
|
||||
'link' => $url->setQueryString( array( 'do' => 'setAsTitle', 'id' => $this->_id ) ),
|
||||
'link' => $url->setQueryString( array( 'do' => 'setAsTitle', 'id' => $this->_id ) )->csrf(),
|
||||
'data' => array()
|
||||
);
|
||||
}
|
||||
@@ -1558,7 +1618,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$buttons['set_as_content'] = array(
|
||||
'icon' => 'file-text-o',
|
||||
'title' => 'cms_set_field_as_content',
|
||||
'link' => $url->setQueryString( array( 'do' => 'setAsContent', 'id' => $this->_id ) ),
|
||||
'link' => $url->setQueryString( array( 'do' => 'setAsContent', 'id' => $this->_id ) )->csrf(),
|
||||
'data' => array()
|
||||
);
|
||||
}
|
||||
@@ -1575,7 +1635,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
*/
|
||||
public function canBeTitleField()
|
||||
{
|
||||
if ( $this->is_multiple or in_array( mb_ucfirst( $this->type ), static::$cannotBeTitleFields ) )
|
||||
if ( $this->is_multiple or \in_array( mb_ucfirst( $this->type ), static::$cannotBeTitleFields ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1592,7 +1652,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
$no = array();
|
||||
|
||||
if ( $this->is_multiple or in_array( mb_ucfirst( $this->type ), static::$cannotBeContentFields ) )
|
||||
if ( $this->is_multiple or \in_array( mb_ucfirst( $this->type ), static::$cannotBeContentFields ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1788,7 +1848,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$databases[ $db->id ] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_relational_with_name_disabled', NULL, array( 'sprintf' => array( $db->_title ) ) );
|
||||
}
|
||||
}
|
||||
if ( ! count( $databases ) )
|
||||
if ( ! \count( $databases ) )
|
||||
{
|
||||
$databases[0] = \IPS\Member::loggedIn()->language()->addToStack('cms_relational_field_no_dbs');
|
||||
$disabled[] = 0;
|
||||
@@ -1848,7 +1908,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$tzValue = 'UTC';
|
||||
if ( isset( $this->extra['timezone'] ) and $this->extra['timezone'] )
|
||||
{
|
||||
if ( ! in_array( $this->extra['timezone'], array( 'UTC', 'user' ) ) )
|
||||
if ( ! \in_array( $this->extra['timezone'], array( 'UTC', 'user' ) ) )
|
||||
{
|
||||
$tzValue = 'set';
|
||||
}
|
||||
@@ -1895,7 +1955,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'field_max_length', $this->id ? $this->max_length : NULL, FALSE, array( 'unlimited' => 0 ), NULL, NULL, NULL, 'field_max_length' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'field_validator', $this->id ? intval( $this->validator ) : 0, FALSE, array(
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'field_validator', $this->id ? \intval( $this->validator ) : 0, FALSE, array(
|
||||
'togglesOn' =>array( 'field_validator_custom', 'field_validator_error' )
|
||||
), NULL, NULL, NULL, 'field_validator' ) );
|
||||
|
||||
@@ -2046,7 +2106,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'field_display_listing', $this->id ? $this->display_listing : 1, FALSE, array( 'togglesOn' => array('field_truncate', 'field_display_listing_json_badge') ), NULL, NULL, NULL, 'field_display_listing' ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'field_display_listing_json_badge', $listingDefault, FALSE, array( 'options' => $listingOptions, 'toggles' => $listingToggles ), NULL, NULL, NULL, 'field_display_listing_json_badge' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'field_display_listing_json_badge', $listingDefault, FALSE, array( 'options' => $listingOptions, 'toggles' => $listingToggles, 'parse' => 'raw' ), NULL, NULL, NULL, 'field_display_listing_json_badge' ) );
|
||||
|
||||
if ( ! $isTitleOrContent )
|
||||
{
|
||||
@@ -2086,7 +2146,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'field_display_display', $this->id ? $this->display_display : 1, FALSE, array( 'togglesOn' => array( 'field_display_display_json_badge' ) ), NULL, NULL, NULL, 'field_display_display' ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'field_display_display_json_badge', $displayDefault, FALSE, array( 'options' => $displayOptions, 'toggles' => $displayToggles ), NULL, NULL, NULL, 'field_display_display_json_badge' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'field_display_display_json_badge', $displayDefault, FALSE, array( 'options' => $displayOptions, 'toggles' => $displayToggles, 'parse' => 'raw' ), NULL, NULL, NULL, 'field_display_display_json_badge' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'field_show_map_display', $mapDisplay, FALSE, array(), NULL, NULL, NULL, 'field_show_map_display' ) );
|
||||
$form->add( new \IPS\Helpers\Form\WidthHeight( 'field_show_map_display_dims', $mapDisplayDims, FALSE, array( 'resizableDiv' => FALSE ), NULL, NULL, NULL, 'field_show_map_display_dims' ) );
|
||||
@@ -2138,7 +2198,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
/**
|
||||
* [Node] Format form values from add/edit form for save
|
||||
*
|
||||
* @todo Separate out the need for $this->save() to be called by moving the database table field creation to postSaveForm()
|
||||
* @todo Separate out the need for `$this->save()` to be called by moving the database table field creation to postSaveForm()
|
||||
* @param array $values Values from the form
|
||||
* @return array
|
||||
*/
|
||||
@@ -2146,7 +2206,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
static::$contentDatabaseTable = 'cms_custom_database_' . static::$customDatabaseId;
|
||||
|
||||
$values['field_max_length'] = ( isset( $values['field_max_length'] ) ) ? intval( $values['field_max_length'] ) : 0;
|
||||
$values['field_max_length'] = ( isset( $values['field_max_length'] ) ) ? \intval( $values['field_max_length'] ) : 0;
|
||||
|
||||
/* Work out the column definition */
|
||||
if( isset( $values['field_type'] ) )
|
||||
@@ -2159,7 +2219,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
case 'Radio':
|
||||
case 'Select':
|
||||
/* Reformat keyValue pairs */
|
||||
if ( isset( $values['field_extra'] ) AND is_array( $values['field_extra'] ) )
|
||||
if ( isset( $values['field_extra'] ) AND \is_array( $values['field_extra'] ) )
|
||||
{
|
||||
$extra = array();
|
||||
foreach( $values['field_extra'] as $row )
|
||||
@@ -2170,7 +2230,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $extra ) )
|
||||
if ( \count( $extra ) )
|
||||
{
|
||||
$values['field_extra'] = $extra;
|
||||
}
|
||||
@@ -2189,7 +2249,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
case 'Spotify':
|
||||
case 'Soundcloud':
|
||||
/* Reformat keyValue pairs */
|
||||
if ( isset( $values['media_params'] ) AND is_array( $values['media_params'] ) )
|
||||
if ( isset( $values['media_params'] ) AND \is_array( $values['media_params'] ) )
|
||||
{
|
||||
$extra = array();
|
||||
foreach( $values['media_params'] as $row )
|
||||
@@ -2200,7 +2260,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $extra ) )
|
||||
if ( \count( $extra ) )
|
||||
{
|
||||
$values['field_extra'] = $extra;
|
||||
}
|
||||
@@ -2304,7 +2364,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
try
|
||||
{
|
||||
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' => "field_{$this->id}", 'columns' => array( "field_{$this->id}" ) ) );
|
||||
}
|
||||
@@ -2343,7 +2403,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
try
|
||||
{
|
||||
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' => "field_{$this->id}", 'columns' => array( "field_{$this->id}" ) ) );
|
||||
}
|
||||
@@ -2379,7 +2439,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
try
|
||||
{
|
||||
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' => "field_{$this->id}", 'columns' => array( "field_{$this->id}" ) ) );
|
||||
}
|
||||
@@ -2424,7 +2484,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
|
||||
if ( isset( $values['field_key'] ) AND ! $values['field_key'] )
|
||||
{
|
||||
if ( is_array( $values['field_title'] ) )
|
||||
if ( \is_array( $values['field_title'] ) )
|
||||
{
|
||||
/* We need to make sure the internal pointer on the array is on the first element */
|
||||
reset( $values['field_title'] );
|
||||
@@ -2459,7 +2519,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$displayJson = array( 'display' => array( 'method' => NULL ), 'listing' => array( 'method' => NULL ) );
|
||||
|
||||
/* Listing */
|
||||
if ( in_array( $values['field_type'], static::$mediaFields ) )
|
||||
if ( \in_array( $values['field_type'], static::$mediaFields ) )
|
||||
{
|
||||
$displayJson['listing']['method'] = $values['media_display_listing_method'];
|
||||
$displayJson['display']['method'] = $values['media_display_display_method'];
|
||||
@@ -2630,7 +2690,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
}
|
||||
|
||||
/* Remove the filter flag if this field cannot be filtered */
|
||||
if ( isset( $values['field_type'] ) AND isset( $values['field_filter'] ) AND $values['field_filter'] and ! in_array( $values['field_type'], static::$filterableFields ) )
|
||||
if ( isset( $values['field_type'] ) AND isset( $values['field_filter'] ) AND $values['field_filter'] and ! \in_array( $values['field_type'], static::$filterableFields ) )
|
||||
{
|
||||
$values['field_filter'] = false;
|
||||
}
|
||||
@@ -2682,7 +2742,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
$custom = array( 'Youtube', 'Spotify', 'Soundcloud', 'Relational' );
|
||||
|
||||
if ( ! in_array( $this->type, $custom ) )
|
||||
if ( ! \in_array( $this->type, $custom ) )
|
||||
{
|
||||
return parent::canKeepValueOnChange( $newType );
|
||||
}
|
||||
@@ -2690,13 +2750,13 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
switch ( $this->type )
|
||||
{
|
||||
case 'Youtube':
|
||||
return in_array( $newType, array( 'Youtube', 'Text', 'TextArea' ) );
|
||||
return \in_array( $newType, array( 'Youtube', 'Text', 'TextArea' ) );
|
||||
|
||||
case 'Spotify':
|
||||
return in_array( $newType, array( 'Spotify', 'Text', 'TextArea' ) );
|
||||
return \in_array( $newType, array( 'Spotify', 'Text', 'TextArea' ) );
|
||||
|
||||
case 'Soundcloud':
|
||||
return in_array( $newType, array( 'Soundcloud', 'Text', 'TextArea' ) );
|
||||
return \in_array( $newType, array( 'Soundcloud', 'Text', 'TextArea' ) );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@@ -2725,13 +2785,6 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->$functionName );
|
||||
}
|
||||
|
||||
$key = 'cms_fieldids_' . static::$customDatabaseId;
|
||||
|
||||
if ( isset( \IPS\Data\Store::i()->$key ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->$key );
|
||||
}
|
||||
|
||||
parent::save();
|
||||
}
|
||||
@@ -2746,20 +2799,10 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
static::$contentDatabaseTable = 'cms_custom_database_' . static::$customDatabaseId;
|
||||
static::$cache = array();
|
||||
|
||||
$key = 'cms_fieldids_' . static::$customDatabaseId;
|
||||
|
||||
if ( isset( \IPS\Data\Store::i()->$key ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->$key );
|
||||
}
|
||||
|
||||
/* Remove reciprocal map data */
|
||||
\IPS\Db::i()->delete( 'cms_database_fields_reciprocal_map', array( 'map_origin_database_id=? AND map_field_id=? ', static::$customDatabaseId, $this->id ) );
|
||||
|
||||
/* Best remove the stored data */
|
||||
unset( \IPS\Data\Store::i()->database_reciprocal_links );
|
||||
|
||||
parent::delete();
|
||||
|
||||
if( $skipDrop === TRUE )
|
||||
@@ -2785,11 +2828,11 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
*
|
||||
* @param mixed $value The value
|
||||
* @param callback $customValidationCode Custom validation code
|
||||
* @param \IPS\cms\Records|NULL $record The record
|
||||
* @param \IPS\cms\Records|NULL $content The record
|
||||
* @param int $flags Bit flags
|
||||
* @return \IPS\Helpers\Form\FormAbstract
|
||||
*/
|
||||
public function buildHelper( $value=NULL, $customValidationCode=NULL, \IPS\cms\Records $record = NULL, $flags=0 )
|
||||
public function buildHelper( $value=NULL, $customValidationCode=NULL, \IPS\Content $content = NULL, $flags=0 )
|
||||
{
|
||||
if ( class_exists( '\IPS\cms\Fields\\' . mb_ucfirst( $this->type ) ) )
|
||||
{
|
||||
@@ -2800,7 +2843,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
$class = '\IPS\Helpers\Form\\' . mb_ucfirst( $this->type );
|
||||
|
||||
if ( !is_array( $this->extra ) )
|
||||
if ( !\is_array( $this->extra ) )
|
||||
{
|
||||
if ( method_exists( $class, 'formatOptions' ) )
|
||||
{
|
||||
@@ -2826,8 +2869,8 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$options['app'] = 'cms';
|
||||
$options['key'] = 'Records' . static::$customDatabaseId;
|
||||
$options['allowAttachments'] = $this->allow_attachments;
|
||||
$options['autoSaveKey'] = 'RecordField_' . ( $record === NULL ? 'new' : $record->_id ) . '_' . $this->id;
|
||||
$options['attachIds'] = ( $record === NULL ) ? NULL : array( $record->_id, $this->id, static::$customDatabaseId );
|
||||
$options['autoSaveKey'] = 'RecordField_' . ( $content === NULL ? 'new' : $content->_id ) . '_' . $this->id;
|
||||
$options['attachIds'] = ( $content === NULL ) ? NULL : array( $content->_id, $this->id, static::$customDatabaseId );
|
||||
break;
|
||||
case 'Email':
|
||||
case 'Password':
|
||||
@@ -2845,6 +2888,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
if ( $this->extra['type'] === 'image' )
|
||||
{
|
||||
$options['allowStockPhotos'] = TRUE;
|
||||
$options['image'] = array( 'maxWidth' => $this->extra['maxsize'][0], 'maxHeight' => $this->extra['maxsize'][1] );
|
||||
}
|
||||
else
|
||||
@@ -2862,7 +2906,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$options['multiple'] = TRUE;
|
||||
}
|
||||
|
||||
if( $value and ! is_array( $value ) )
|
||||
if( $value and ! \is_array( $value ) )
|
||||
{
|
||||
if ( mb_strstr( $value, ',' ) )
|
||||
{
|
||||
@@ -2908,15 +2952,15 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
$this->required = false;
|
||||
}
|
||||
|
||||
if ( $options['multiple'] and ! is_array( $value ) )
|
||||
if ( $options['multiple'] and ! \is_array( $value ) )
|
||||
{
|
||||
$exp = explode( ',', $value );
|
||||
$value = array();
|
||||
foreach( $exp 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
|
||||
{
|
||||
@@ -2926,9 +2970,9 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( is_numeric( $value ) and intval( $value ) == $value )
|
||||
if ( \is_numeric( $value ) and \intval( $value ) == $value )
|
||||
{
|
||||
$value = intval( $value );
|
||||
$value = \intval( $value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2949,19 +2993,20 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
$value = NULL;
|
||||
}
|
||||
|
||||
|
||||
$options['multiple'] = $this->is_multiple ? NULL : 1;
|
||||
|
||||
if ( is_string( $value ) )
|
||||
|
||||
if ( \is_string( $value ) )
|
||||
{
|
||||
$value = array_map( function( $id )
|
||||
{
|
||||
return \IPS\Member::load( $id );
|
||||
return \IPS\Member::load( \intval( $id ) );
|
||||
}, explode( "\n", $value ) );
|
||||
}
|
||||
|
||||
break;
|
||||
case 'Date':
|
||||
if ( is_numeric( $value ) )
|
||||
if ( \is_numeric( $value ) )
|
||||
{
|
||||
/* We want to normalize based on user time zone here */
|
||||
$value = \IPS\DateTime::ts( $value );
|
||||
@@ -3006,6 +3051,12 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
$options['decimals'] = $this->extra['places'];
|
||||
}
|
||||
|
||||
if( !$this->required )
|
||||
{
|
||||
$options['unlimited'] = '';
|
||||
$options['unlimitedLang'] = 'cms_number_none';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3018,11 +3069,11 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
if ( $this->unique )
|
||||
{
|
||||
$field = $this;
|
||||
$customValidationCode = function( $val ) use ( $field, $record )
|
||||
$customValidationCode = function( $val ) use ( $field, $content )
|
||||
{
|
||||
call_user_func_array( 'IPS\cms\Fields' . static::$customDatabaseId . '::validateUnique', array( $val, $field, $record ) );
|
||||
\call_user_func_array( 'IPS\cms\Fields' . static::$customDatabaseId . '::validateUnique', array( $val, $field, $content ) );
|
||||
|
||||
return call_user_func( 'IPS\cms\Fields' . static::$customDatabaseId . '::validateInput_' . $field->id, $val );
|
||||
return \call_user_func( 'IPS\cms\Fields' . static::$customDatabaseId . '::validateInput_' . $field->id, $val );
|
||||
};
|
||||
}
|
||||
else
|
||||
@@ -3035,4 +3086,32 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
|
||||
return new $class( 'content_field_' . $this->id, $value, $this->required, $options, $customValidationCode );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string title Title
|
||||
* @apiresponse string|null description Description
|
||||
* @apiresponse string type The field type - e.g. "Text", "Editor", "Radio"
|
||||
* @apiresponse string|null default The default value
|
||||
* @apiresponse bool required If the field is required
|
||||
* @apiresponse object|null options If the field has certain options (for example, it is a select field), the possible values
|
||||
*/
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
return array(
|
||||
'id' => $this->_id,
|
||||
'title' => $this->_title,
|
||||
'description' => $this->_description ?: NULL,
|
||||
'type' => $this->type,
|
||||
'default' => $this->default_value ?: NULL,
|
||||
'required' => (bool) $this->required,
|
||||
'options' => $this->extra
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user