Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -141,7 +141,6 @@ class _Editor extends FormAbstract
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, array( \IPS\Http\Url::internal( 'applications/core/interface/ckeditor/ckeditor/ckeditor.js', 'none', NULL, array(), \IPS\Http\Url::PROTOCOL_RELATIVE ) ) );
|
||||
}
|
||||
}
|
||||
\IPS\Output::i()->jsVars['strip_quotes'] = \IPS\Settings::i()->strip_quotes;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,7 +268,7 @@ class _Editor extends FormAbstract
|
||||
|
||||
/* If it was made without JS, convert linebreaks to <br>s */
|
||||
$noJsKey = $this->name . '_noscript';
|
||||
if ( isset( \IPS\Request::i()->$noJsKey ) AND !$value )
|
||||
if ( isset( \IPS\Request::i()->$noJsKey ) )
|
||||
{
|
||||
$value = nl2br( \IPS\Request::i()->$noJsKey, FALSE );
|
||||
}
|
||||
@@ -297,9 +296,9 @@ class _Editor extends FormAbstract
|
||||
if ( $this->uploader )
|
||||
{
|
||||
$inserts = array();
|
||||
foreach ( static::getAttachments( NULL, $this->postKey ) as $attachment )
|
||||
foreach ( $this->getAttachments() as $attachment )
|
||||
{
|
||||
if ( !isset( $parser ) or !in_array( $attachment['attach_id'], $parser->mappedAttachments ) )
|
||||
if ( !isset( $parser ) or !in_array( $attachment['attach_id'], $parser->mappedAttachments ) or array_key_exists( $attachment['attach_id'], $parser->existingAttachments ) )
|
||||
{
|
||||
if ( $attachment['attach_is_image'] )
|
||||
{
|
||||
@@ -309,21 +308,30 @@ class _Editor extends FormAbstract
|
||||
{
|
||||
$value .= \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedFile( \IPS\Settings::i()->base_url . "applications/core/interface/file/attachment.php?id=" . $attachment['attach_id'], $attachment['attach_file'] );
|
||||
}
|
||||
|
||||
$inserts[] = array(
|
||||
'attachment_id' => $attachment['attach_id'],
|
||||
'location_key' => "{$this->options['app']}_{$this->options['key']}",
|
||||
'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'] )
|
||||
);
|
||||
|
||||
if ( !isset( $parser ) or !in_array( $attachment['attach_id'], $parser->mappedAttachments ) )
|
||||
{
|
||||
$inserts[] = array(
|
||||
'attachment_id' => $attachment['attach_id'],
|
||||
'location_key' => "{$this->options['app']}_{$this->options['key']}",
|
||||
'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'] )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( count( $inserts ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_attachments_map', $inserts, TRUE );
|
||||
}
|
||||
|
||||
/* Clear out the post key for attachments that are claimed automatically */
|
||||
if ( $this->options['attachIds'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_attachments', array( 'attach_post_key' => '' ), array( 'attach_post_key=?', $this->postKey ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove abandoned attachments */
|
||||
@@ -416,26 +424,8 @@ class _Editor extends FormAbstract
|
||||
}
|
||||
|
||||
/* Load existing attachments */
|
||||
$existingAttachments = '';
|
||||
$counts = array();
|
||||
$where = array();
|
||||
if ( isset( $this->options['attachIds'] ) and is_array( $this->options['attachIds'] ) and count( $this->options['attachIds'] ) )
|
||||
{
|
||||
$where = array( array( 'location_key=?', "{$this->options['app']}_{$this->options['key']}" ) );
|
||||
$i = 1;
|
||||
foreach ( $this->options['attachIds'] as $id )
|
||||
{
|
||||
$where[] = array( "id{$i}=?", $id );
|
||||
$i++;
|
||||
}
|
||||
$_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 ';
|
||||
}
|
||||
}
|
||||
$existing = array();
|
||||
foreach ( static::getAttachments( $existingAttachments, $this->postKey ) as $attachment )
|
||||
foreach ( $this->getAttachments() as $attachment )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -519,7 +509,7 @@ class _Editor extends FormAbstract
|
||||
try
|
||||
{
|
||||
$attachment = \IPS\Db::i()->select( '*', 'core_attachments', array( 'attach_id=?', \IPS\Request::i()->deleteFile ) )->first();
|
||||
\IPS\Db::i()->delete( 'core_attachments_map', array_merge( $where, array( array( 'attachment_id=?', $attachment['attach_id'] ) ) ) );
|
||||
\IPS\Db::i()->delete( 'core_attachments_map', array( array( 'location_key=?', "{$this->options['app']}_{$this->options['key']}" ), array( 'attachment_id=?', $attachment['attach_id'] ) ) );
|
||||
$otherMaps = \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments_map', array( 'attachment_id=?', $attachment['attach_id'] ) )->first();
|
||||
if ( !$otherMaps )
|
||||
{
|
||||
@@ -551,13 +541,17 @@ class _Editor extends FormAbstract
|
||||
*/
|
||||
public static function getEmoticons()
|
||||
{
|
||||
|
||||
if( !isset( \IPS\Data\Store::i()->emoticons ) )
|
||||
{
|
||||
$emoticons = iterator_to_array( \IPS\Db::i()->select( '*', 'core_emoticons', array( 'typed<>?', '' ) )->setKeyField('typed')->setValueField('image') );
|
||||
$emoticons = iterator_to_array( \IPS\Db::i()->select( '*', 'core_emoticons', array( 'typed<>?', '' ) )->setKeyField('typed') );
|
||||
foreach( $emoticons as $key => $emoticon )
|
||||
{
|
||||
$emoticons[ $key ] = (string) \IPS\File::get( "core_Emoticons", $emoticon )->url;
|
||||
$emoticons[ $key ] = array(
|
||||
'image' => (string) \IPS\File::get( "core_Emoticons", $emoticon['image'] )->url,
|
||||
'image_2x' => $emoticon['image_2x'] ? (string) \IPS\File::get( "core_Emoticons", $emoticon['image_2x'] )->url . ' 2x' : FALSE,
|
||||
'height' => $emoticon['height'] ?: FALSE,
|
||||
'width' => $emoticon['width'] ?: FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->emoticons = $emoticons;
|
||||
@@ -565,27 +559,53 @@ class _Editor extends FormAbstract
|
||||
|
||||
return \IPS\Data\Store::i()->emoticons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachments
|
||||
*/
|
||||
protected $attachments;
|
||||
|
||||
/**
|
||||
* Fetch existing attachments - abstracted to a static method for caching
|
||||
* Fetch existing attachments
|
||||
*
|
||||
* @param string $existing Existing attachments limiter
|
||||
* @param string $postKey Post key
|
||||
* @return array
|
||||
*/
|
||||
public static function getAttachments( $existing, $postKey )
|
||||
protected function getAttachments()
|
||||
{
|
||||
static $attachments = array();
|
||||
|
||||
$_key = md5( $existing . $postKey );
|
||||
|
||||
if( isset( $attachments[ $_key ] ) )
|
||||
if ( $this->attachments === NULL )
|
||||
{
|
||||
return $attachments[ $_key ];
|
||||
$existingAttachments = '';
|
||||
$where = array();
|
||||
if ( isset( $this->options['attachIds'] ) and is_array( $this->options['attachIds'] ) and count( $this->options['attachIds'] ) )
|
||||
{
|
||||
$where = array( array( 'location_key=?', "{$this->options['app']}_{$this->options['key']}" ) );
|
||||
$i = 1;
|
||||
foreach ( $this->options['attachIds'] as $id )
|
||||
{
|
||||
$where[] = array( "id{$i}=?", $id );
|
||||
$i++;
|
||||
}
|
||||
$_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 ';
|
||||
}
|
||||
}
|
||||
|
||||
$this->attachments = \IPS\Db::i()->select( '*', 'core_attachments', array( $existingAttachments . 'attach_post_key=?', $this->postKey ) );
|
||||
}
|
||||
|
||||
$attachments[ $_key ] = \IPS\Db::i()->select( '*', 'core_attachments', array( $existing . 'attach_post_key=?', $postKey ) );
|
||||
|
||||
return $attachments[ $_key ];
|
||||
|
||||
return $this->attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get CKEditor Version
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function ckeditorVersion()
|
||||
{
|
||||
preg_match( '/CKEditor\s+Included version: (.+?)\s/', file_get_contents( \IPS\ROOT_PATH . '/Credits.txt' ), $matches );
|
||||
return $matches[1];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user