Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
+101
-11
@@ -66,7 +66,8 @@ class _Editor extends FormAbstract
|
||||
'maxLength' => 16777215, // The default for MEDIUMTEXT */
|
||||
'editorId' => NULL,
|
||||
'allowAttachments' => TRUE,
|
||||
'ipsPlugins' => "ipsautolink,ipsautosave,ipsctrlenter,ipscode,ipscontextmenu,ipsemoticon,ipsimage,ipslink,ipsmentions,ipspage,ipspaste,ipspreview,ipsquote,ipsspoiler,ipsautogrow,ipssource,removeformat"
|
||||
'ipsPlugins' => "ipsautolink,ipsautosave,ipsctrlenter,ipscode,ipscontextmenu,ipsemoticon,ipsimage,ipslink,ipsmentions,ipspage,ipspaste,ipsquote,ipsspoiler,ipsautogrow,ipssource,removeformat",
|
||||
'profanityBlock' => TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -103,7 +104,34 @@ class _Editor extends FormAbstract
|
||||
|
||||
if ( \IPS\Settings::i()->giphy_enabled )
|
||||
{
|
||||
$this->defaultOptions['ipsPlugins'] .= ',ipsgiphy';
|
||||
$this->defaultOptions['ipsPlugins'] .= ',ipsgiphy';
|
||||
}
|
||||
|
||||
if( \IPS\Dispatcher::hasInstance() and ( \IPS\Dispatcher::i()->controllerLocation == 'front' OR ( \IPS\Dispatcher::i()->controllerLocation == 'admin' AND \IPS\Dispatcher::i()->module->key === 'editor' AND \IPS\Dispatcher::i()->controller == 'toolbar' )))
|
||||
{
|
||||
$this->defaultOptions['ipsPlugins'] .= ',ipspreview';
|
||||
}
|
||||
|
||||
if ( isset( $options['allButtons'] ) AND $options['allButtons'] )
|
||||
{
|
||||
$showStockReplies = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$showStockReplies = FALSE;
|
||||
foreach ( \IPS\core\StoredReplies::getStore() as $reply )
|
||||
{
|
||||
$reply = \IPS\core\StoredReplies::constructFromData( $reply );
|
||||
if ( $reply->enabled and $reply->can( 'view' ) )
|
||||
{
|
||||
$showStockReplies = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $showStockReplies )
|
||||
{
|
||||
$this->defaultOptions['ipsPlugins'] .= ',ipsstockreplies';
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->usingEditor ) and \IPS\Request::i()->isAjax() and \IPS\Dispatcher::hasInstance() and \IPS\Dispatcher::i()->controllerLocation == 'front' )
|
||||
@@ -309,6 +337,23 @@ class _Editor extends FormAbstract
|
||||
$attachmentArea = \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->editorAttachmentsPlaceholder( $this->name, $this->postKey, $this->noUploaderError, $this->canUseMediaExtension() );
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->group['g_bypass_badwords'] )
|
||||
{
|
||||
$this->options['profanityBlock'] = FALSE;
|
||||
}
|
||||
|
||||
if ( $this->options['profanityBlock'] )
|
||||
{
|
||||
$this->options['profanityBlock'] = [];
|
||||
foreach( \IPS\core\Profanity::getProfanity() AS $profanity )
|
||||
{
|
||||
if ( $profanity->action == 'block' )
|
||||
{
|
||||
$this->options['profanityBlock'][] = [ 'word' => $profanity->type, 'type' => $profanity->m_exact ? 'exact' : 'loose' ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
$template = $raw ? 'editorRaw' : 'editor';
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->$template( $this->name, $value, $this->options, $allowed, md5( $this->options['autoSaveKey'] . ':' . session_id() ), $attachmentArea, json_encode( array() ), $this->options['tags'] );
|
||||
@@ -339,7 +384,12 @@ class _Editor extends FormAbstract
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Save on queries and fetch the alt label would just the once
|
||||
*/
|
||||
protected $_altLabelWord = NULL;
|
||||
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
@@ -381,9 +431,22 @@ class _Editor extends FormAbstract
|
||||
if ( !isset( $parser ) or !\in_array( $attachment['attach_id'], $parser->mappedAttachments ) or array_key_exists( $attachment['attach_id'], $parser->existingAttachments ) )
|
||||
{
|
||||
$ext = mb_substr( $attachment['attach_file'], mb_strrpos( $attachment['attach_file'], '.' ) + 1 );
|
||||
if ( \in_array( mb_strtolower( $ext ), \IPS\File::$videoExtensions ) )
|
||||
if ( \in_array( mb_strtolower( $ext ), \IPS\File::$videoExtensions ) or \in_array( mb_strtolower( $ext ), \IPS\File::$audioExtensions ) )
|
||||
{
|
||||
$value .= \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedVideo( $attachment['attach_location'], \IPS\Http\Url::baseUrl( \IPS\Http\Url::PROTOCOL_RELATIVE ) . "applications/core/interface/file/attachment.php?id=" . $attachment['attach_id'], $attachment['attach_file'], \IPS\File::getMimeType( $attachment['attach_file'] ), $attachment['attach_id'] );
|
||||
$url = \IPS\Http\Url::baseUrl( \IPS\Http\Url::PROTOCOL_RELATIVE ) . "applications/core/interface/file/attachment.php?id=" . $attachment['attach_id'];
|
||||
if ( $attachment['attach_security_key'] )
|
||||
{
|
||||
$url .= "&key={$attachment['attach_security_key']}";
|
||||
}
|
||||
|
||||
if ( \in_array( mb_strtolower( $ext ), \IPS\File::$videoExtensions ) )
|
||||
{
|
||||
$value .= \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedVideo( $attachment['attach_location'], $url, $attachment['attach_file'], \IPS\File::getMimeType( $attachment['attach_file'] ), $attachment['attach_id'] );
|
||||
}
|
||||
elseif ( \in_array( mb_strtolower( $ext ), \IPS\File::$audioExtensions ) )
|
||||
{
|
||||
$value .= \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedAudio( $attachment['attach_location'], $url, $attachment['attach_file'], \IPS\File::getMimeType( $attachment['attach_file'] ), $attachment['attach_id'] );
|
||||
}
|
||||
}
|
||||
elseif ( $attachment['attach_is_image'] )
|
||||
{
|
||||
@@ -397,8 +460,21 @@ class _Editor extends FormAbstract
|
||||
$ratio = round( ( $attachment['attach_img_height'] / $attachment['attach_img_width'] ) * 100, 2 );
|
||||
$width = $attachment['attach_img_width'];
|
||||
}
|
||||
|
||||
$value .= \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedImage( $attachment['attach_location'], $attachment['attach_thumb_location'] ? $attachment['attach_thumb_location'] : $attachment['attach_location'], $attachment['attach_file'], $attachment['attach_id'], $width, $ratio );
|
||||
|
||||
$altText = NULL;
|
||||
|
||||
if ( ! empty( $attachment['attach_labels'] ) )
|
||||
{
|
||||
if ( $this->_altLabelWord === NULL )
|
||||
{
|
||||
/* This is stored with the post, so it cannot be the user's language */
|
||||
$this->_altLabelWord = \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'alt_label_could_be' );
|
||||
}
|
||||
|
||||
$altText = $this->_altLabelWord . ' ' . implode( ', ', \IPS\Text\Parser::getAttachmentLabels( $attachment ) );
|
||||
}
|
||||
|
||||
$value .= \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedImage( $attachment['attach_location'], $attachment['attach_thumb_location'] ? $attachment['attach_thumb_location'] : $attachment['attach_location'], $attachment['attach_file'], $attachment['attach_id'], $width, $ratio, $altText );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -409,7 +485,7 @@ class _Editor extends FormAbstract
|
||||
}
|
||||
$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 ) )
|
||||
{
|
||||
$inserts[] = array(
|
||||
@@ -435,7 +511,7 @@ class _Editor extends FormAbstract
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_attachments_map', $inserts, TRUE );
|
||||
}
|
||||
|
||||
|
||||
/* Clear out the post key for attachments that are claimed automatically */
|
||||
if ( $this->options['attachIds'] )
|
||||
{
|
||||
@@ -457,7 +533,7 @@ class _Editor extends FormAbstract
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
|
||||
|
||||
/* Throw any errors */
|
||||
if ( $error )
|
||||
{
|
||||
@@ -638,10 +714,24 @@ class _Editor extends FormAbstract
|
||||
'totalMaxSize' => $maxTotalSize,
|
||||
'maxFileSize' => \IPS\Member::loggedIn()->group['g_attach_per_post'] ? ( \IPS\Member::loggedIn()->group['g_attach_per_post'] * 1024 ) / 1048576 : NULL,
|
||||
'allowStockPhotos' => $allowStockPhotos,
|
||||
'canBeModerated' => ($this->extension AND method_exists( $this->extension, 'canBeModerated' ) and $this->extension->canBeModerated( \IPS\Member::loggedIn(), $this ) ),
|
||||
'callback' => function( $file ) use ( $postKey )
|
||||
{
|
||||
try
|
||||
{
|
||||
$fileInfo = \IPS\Db::i()->select( 'requires_moderation, labels', 'core_files_temp', array( 'contents=?', (string) $file ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$requiresModeration = (bool) $fileInfo['requires_moderation'];
|
||||
$labels = $fileInfo['labels'];
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
$requiresModeration = FALSE;
|
||||
$labels = NULL;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'core_files_temp', array( 'contents=?', (string) $file ) );
|
||||
$attachment = $file->makeAttachment( $postKey, \IPS\Member::loggedIn() );
|
||||
|
||||
$attachment = $file->makeAttachment( $postKey, \IPS\Member::loggedIn(), $requiresModeration, $labels );
|
||||
return $attachment['attach_id'];
|
||||
}
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user