Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -34,6 +34,7 @@ class _Editor extends FormAbstract
|
||||
2,
|
||||
'foo'
|
||||
),
|
||||
'attachIdsLang' => NULL, // Language ID number if this Editor is part of a Translatable field.
|
||||
'minimize' => 'clickme', // Language string to use for minimized view. NULL will mean editor is not minimized.
|
||||
'minimizeIcon' => 'flag-us', // Icon to use for minimized view
|
||||
'allButtons' => FALSE, // Only used for the customisation ACP page. Do not use.
|
||||
@@ -53,6 +54,7 @@ class _Editor extends FormAbstract
|
||||
'key' => NULL,
|
||||
'autoSaveKey' => NULL,
|
||||
'attachIds' => NULL,
|
||||
'attachIdsLang' => NULL,
|
||||
'minimize' => NULL,
|
||||
'minimizeIcon' => 'fa fa-comment-o',
|
||||
'allButtons' => FALSE,
|
||||
@@ -400,7 +402,12 @@ class _Editor extends FormAbstract
|
||||
}
|
||||
else
|
||||
{
|
||||
$fileAttachments[] = \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedFile( \IPS\Http\Url::baseUrl() . "applications/core/interface/file/attachment.php?id=" . $attachment['attach_id'], $attachment['attach_file'], FALSE, $attachment['attach_ext'], $attachment['attach_id'] );
|
||||
$url = \IPS\Http\Url::baseUrl() . "applications/core/interface/file/attachment.php?id=" . $attachment['attach_id'];
|
||||
if ( $attachment['attach_security_key'] )
|
||||
{
|
||||
$url .= "&key={$attachment['attach_security_key']}";
|
||||
}
|
||||
$fileAttachments[] = \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedFile( $url, $attachment['attach_file'], FALSE, $attachment['attach_ext'], $attachment['attach_id'], $attachment['attach_security_key'] );
|
||||
}
|
||||
|
||||
if ( !isset( $parser ) or !\in_array( $attachment['attach_id'], $parser->mappedAttachments ) )
|
||||
@@ -411,7 +418,8 @@ class _Editor extends FormAbstract
|
||||
'id1' => ( \is_array( $this->options['attachIds'] ) and isset( $this->options['attachIds'][0] ) ) ? $this->options['attachIds'][0] : NULL,
|
||||
'id2' => ( \is_array( $this->options['attachIds'] ) and isset( $this->options['attachIds'][1] ) ) ? $this->options['attachIds'][1] : NULL,
|
||||
'id3' => ( \is_array( $this->options['attachIds'] ) and isset( $this->options['attachIds'][2] ) ) ? $this->options['attachIds'][2] : NULL,
|
||||
'temp' => \is_string( $this->options['attachIds'] ) ? $this->options['attachIds'] : ( $this->options['attachIds'] === NULL ? md5( $this->options['autoSaveKey'] ) : $this->options['attachIds'] )
|
||||
'temp' => \is_string( $this->options['attachIds'] ) ? $this->options['attachIds'] : ( $this->options['attachIds'] === NULL ? md5( $this->options['autoSaveKey'] ) : $this->options['attachIds'] ),
|
||||
'lang' => $this->options['attachIdsLang'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -488,7 +496,7 @@ class _Editor extends FormAbstract
|
||||
*/
|
||||
protected function _getParser()
|
||||
{
|
||||
return new \IPS\Text\Parser( TRUE, ( $this->options['attachIds'] === NULL ? md5( $this->options['autoSaveKey'] ) : $this->options['attachIds'] ), NULL, "{$this->options['app']}_{$this->options['key']}", !$this->bypassFilterProfanity(), !$this->canUseHtml(), method_exists( $this->extension, 'htmlPurifierConfig' ) ? array( $this->extension, 'htmlPurifierConfig' ) : NULL );
|
||||
return new \IPS\Text\Parser( TRUE, ( $this->options['attachIds'] === NULL ? md5( $this->options['autoSaveKey'] ) : $this->options['attachIds'] ), NULL, "{$this->options['app']}_{$this->options['key']}", !$this->bypassFilterProfanity(), !$this->canUseHtml(), method_exists( $this->extension, 'htmlPurifierConfig' ) ? array( $this->extension, 'htmlPurifierConfig' ) : NULL, TRUE, $this->options['attachIdsLang'] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -589,6 +597,7 @@ class _Editor extends FormAbstract
|
||||
/* 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 */
|
||||
$file->originalFilename = $attachment['attach_file'];
|
||||
$file->securityKey = $attachment['attach_security_key'];
|
||||
|
||||
$existing[ $attachment['attach_id'] ] = $file;
|
||||
|
||||
@@ -690,6 +699,10 @@ class _Editor extends FormAbstract
|
||||
$where[] = array( "id{$i}=?", $id );
|
||||
$i++;
|
||||
}
|
||||
if ( $this->options['attachIdsLang'] )
|
||||
{
|
||||
$where[] = array( "lang=?", $this->options['attachIdsLang'] );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'core_attachments_map', $where );
|
||||
}
|
||||
@@ -759,8 +772,44 @@ class _Editor extends FormAbstract
|
||||
{
|
||||
$where[] = array( "id{$i}=?", $id );
|
||||
$i++;
|
||||
}
|
||||
|
||||
/* If we only want ones for particular languages, filter them out. We don't do this in the WHERE clause for backwards compatibility */
|
||||
if ( $this->options['attachIdsLang'] )
|
||||
{
|
||||
$setToAllLangs = [];
|
||||
$_existingAttachments = [];
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_attachments_map', $where ) as $existingAttachment )
|
||||
{
|
||||
if ( $existingAttachment['lang'] === NULL )
|
||||
{
|
||||
$existingAttachment['lang'] = $this->options['attachIdsLang'];
|
||||
if ( !\in_array( $existingAttachment['attachment_id'], $setToAllLangs ) )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_attachments_map', [ 'attachment_id=? AND location_key=? AND id1=? AND id2=? AND id3=? and lang IS NULL', $existingAttachment['attachment_id'], $existingAttachment['location_key'], $existingAttachment['id1'], $existingAttachment['id2'], $existingAttachment['id3'] ] );
|
||||
foreach ( \IPS\Lang::languages() as $lang )
|
||||
{
|
||||
$newRow = $existingAttachment;
|
||||
$newRow['lang'] = $lang->id;
|
||||
\IPS\Db::i()->insert( 'core_attachments_map', $newRow );
|
||||
}
|
||||
$setToAllLangs[] = $existingAttachment['attachment_id'];
|
||||
}
|
||||
}
|
||||
if ( $existingAttachment['lang'] == $this->options['attachIdsLang'] )
|
||||
{
|
||||
$_existingAttachments[] = $existingAttachment['attachment_id'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$_existingAttachments = iterator_to_array( \IPS\Db::i()->select( 'attachment_id', 'core_attachments_map', $where ) );
|
||||
else
|
||||
{
|
||||
$_existingAttachments = iterator_to_array( \IPS\Db::i()->select( 'attachment_id', 'core_attachments_map', $where ) );
|
||||
}
|
||||
|
||||
if ( !empty( $_existingAttachments ) )
|
||||
{
|
||||
$existingAttachments = \IPS\Db::i()->in( 'attach_id', $_existingAttachments ) . ' OR ';
|
||||
@@ -836,11 +885,11 @@ class _Editor extends FormAbstract
|
||||
}
|
||||
elseif ( \IPS\Settings::i()->attach_allowed_types == 'media' )
|
||||
{
|
||||
return array_merge( \IPS\Image::$imageExtensions, \IPS\File::$videoExtensions );
|
||||
return array_merge( \IPS\Image::supportedExtensions(), \IPS\File::$videoExtensions );
|
||||
}
|
||||
elseif ( \IPS\Settings::i()->attach_allowed_types == 'images' )
|
||||
{
|
||||
return \IPS\Image::$imageExtensions;
|
||||
return \IPS\Image::supportedExtensions();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user