Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+26 -14
View File
@@ -11,16 +11,28 @@
namespace IPS\Content\Api\GraphQL;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use IPS\Db;
use IPS\File;
use IPS\Helpers\Form\Editor;
use IPS\Http\Url;
use IPS\Member;
use IPS\Theme;
use function count;
use function defined;
use function in_array;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* @brief Base mutator class for comments
*/
abstract class _ContentMutator
abstract class ContentMutator
{
/**
* Add attachments to content
@@ -28,29 +40,29 @@ abstract class _ContentMutator
* @param string $postKey Post key
* @param string $content Post content
* @return void
* @throws \DomainException Size is too large
* @throws DomainException Size is too large
*/
protected function _addAttachmentsToContent( $postKey, &$content )
protected function _addAttachmentsToContent( string $postKey, string &$content ): void
{
$maxTotalSize = \IPS\Helpers\Form\Editor::maxTotalAttachmentSize( \IPS\Member::loggedIn(), 0 ); // @todo Currently set to 0 because editing is not supported. Once editing is supported by GraphQL, that will need to set the correct value
$maxTotalSize = Editor::maxTotalAttachmentSize( Member::loggedIn(), 0 ); // @todo Currently set to 0 because editing is not supported. Once editing is supported by GraphQL, that will need to set the correct value
$fileAttachments = array();
$totalSize = 0;
foreach ( \IPS\Db::i()->select( '*', 'core_attachments', array( 'attach_post_key=?', $postKey ) ) as $attachment )
foreach ( Db::i()->select( '*', 'core_attachments', array( 'attach_post_key=?', $postKey ) ) as $attachment )
{
if ( $maxTotalSize !== NULL )
{
$totalSize += $attachment['attach_filesize'];
if ( $totalSize > $maxTotalSize )
{
throw new \DomainException;
throw new DomainException;
}
}
$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 ), File::$videoExtensions ) )
{
$content .= \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'] );
$content .= Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedVideo( $attachment['attach_location'], Url::baseUrl( Url::PROTOCOL_RELATIVE ) . "applications/core/interface/file/attachment.php?id=" . $attachment['attach_id'], $attachment['attach_file'], File::getMimeType( $attachment['attach_file'] ), $attachment['attach_id'] );
}
elseif ( $attachment['attach_is_image'] )
{
@@ -65,19 +77,19 @@ abstract class _ContentMutator
$width = $attachment['attach_img_width'];
}
$content .= str_replace( '<fileStore.core_Attachment>', \IPS\File::getClass('core_Attachment')->baseUrl(), \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 ) );
$content .= str_replace( '<fileStore.core_Attachment>', File::getClass('core_Attachment')->baseUrl(), Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedImage( $attachment['attach_location'], $attachment['attach_thumb_location'] ?: $attachment['attach_location'], $attachment['attach_file'], $attachment['attach_id'], $width, $ratio ) );
}
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_security_key'] ? "&key={$attachment['attach_security_key']}" : '' ), $attachment['attach_file'], FALSE, $attachment['attach_ext'], $attachment['attach_id'], $attachment['attach_security_key'] );
$fileAttachments[] = Theme::i()->getTemplate( 'editor', 'core', 'global' )->attachedFile( Url::baseUrl() . "applications/core/interface/file/attachment.php?id=" . $attachment['attach_id'] . ( $attachment['attach_security_key'] ? "&key={$attachment['attach_security_key']}" : '' ), $attachment['attach_file'], FALSE, $attachment['attach_ext'], $attachment['attach_id'], $attachment['attach_security_key'] );
}
}
if( \count( $fileAttachments ) )
if( count( $fileAttachments ) )
{
$content .= "<p>" . implode( ' ', $fileAttachments ) . "</p>";
}
\IPS\Db::i()->update( 'core_attachments', array( 'attach_post_key' => '' ), array( 'attach_post_key=?', $postKey ) );
Db::i()->update( 'core_attachments', array( 'attach_post_key' => '' ), array( 'attach_post_key=?', $postKey ) );
}
}