Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,41 +12,53 @@
|
||||
namespace IPS\cms\Records;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\cms\Records;
|
||||
use IPS\cms\Theme;
|
||||
use IPS\Content\Item;
|
||||
use IPS\core\Reports\Report;
|
||||
use IPS\forums\Topic\Post;
|
||||
use IPS\Member;
|
||||
use IPS\Request;
|
||||
use OutOfRangeException;
|
||||
use UnexpectedValueException;
|
||||
use function defined;
|
||||
|
||||
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 Records Model
|
||||
*/
|
||||
class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
class CommentTopicSync extends Comment
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] ID Database Column
|
||||
*/
|
||||
public static $databaseColumnId = 'pid';
|
||||
public static string $databaseColumnId = 'pid';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'forums_posts';
|
||||
public static ?string $databaseTable = 'forums_posts';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = '';
|
||||
public static string $databasePrefix = '';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
public static array $databaseColumnMap = array(
|
||||
'item' => 'topic_id',
|
||||
'author' => 'author_id',
|
||||
'author_name' => 'author_name',
|
||||
@@ -64,27 +76,27 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'forums';
|
||||
public static string $application = 'forums';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'comment';
|
||||
public static string $icon = 'comment';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'post';
|
||||
public static ?string $hideLogKey = 'post';
|
||||
|
||||
/**
|
||||
* @brief [Content\Comment] Comment Template
|
||||
*/
|
||||
public static $commentTemplate = array( array( 'display', 'cms', 'database' ), 'commentContainer' );
|
||||
public static array $commentTemplate = array( array( 'display', 'cms', 'database' ), 'commentContainer' );
|
||||
|
||||
/**
|
||||
* @brief Bitwise values for post_bwoptions field
|
||||
*/
|
||||
public static $bitOptions = array(
|
||||
public static array $bitOptions = array(
|
||||
'post_bwoptions' => array(
|
||||
'post_bwoptions' => array(
|
||||
'best_answer' => 1
|
||||
@@ -95,11 +107,12 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
/**
|
||||
* Get containing item
|
||||
*
|
||||
* @return \IPS\cms\Record
|
||||
* @return Item
|
||||
*/
|
||||
public function item()
|
||||
public function item(): Item
|
||||
{
|
||||
$itemClass = static::$itemClass;
|
||||
/* @var $itemClass Records */
|
||||
$lookFor = 'IPS\cms\Records\RecordsTopicSync';
|
||||
|
||||
if ( mb_substr( $itemClass, 0, mb_strlen( $lookFor ) ) === $lookFor )
|
||||
@@ -108,7 +121,7 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = \IPS\Request::i()->id;
|
||||
$id = Request::i()->id;
|
||||
}
|
||||
|
||||
return $itemClass::load( $id );
|
||||
@@ -117,24 +130,24 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
/**
|
||||
* Delete Comment
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete(): void
|
||||
{
|
||||
/* We need the classname to be \IPS\forums\Topic\Post so topic/forum sync occur and to ensure post is removed from search index */
|
||||
$comment = \IPS\forums\Topic\Post::load( $this->pid );
|
||||
$comment = Post::load( $this->pid );
|
||||
$comment->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit Comment Contents - Note: does not add edit log
|
||||
*
|
||||
* @param string $newContent New content
|
||||
* @return string|NULL
|
||||
* @param string $newContent New content
|
||||
* @return void
|
||||
*/
|
||||
public function editContents( $newContent )
|
||||
public function editContents( string $newContent ): void
|
||||
{
|
||||
$comment = \IPS\forums\Topic\Post::load( $this->pid );
|
||||
$comment = Post::load( $this->pid );
|
||||
$comment->editContents( $newContent );
|
||||
}
|
||||
|
||||
@@ -143,19 +156,19 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function html()
|
||||
public function html(): string
|
||||
{
|
||||
if ( ! empty( $this->pid ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$comment = \IPS\forums\Topic\Post::load( $this->pid );
|
||||
$comment = Post::load( $this->pid );
|
||||
$template = static::$commentTemplate[1];
|
||||
static::$commentTemplate[0][0] = $this->item()->database()->template_display;
|
||||
|
||||
return \IPS\cms\Theme::i()->getTemplate( static::$commentTemplate[0][0], static::$commentTemplate[0][1], static::$commentTemplate[0][2] )->$template( $comment->item(), $comment );
|
||||
return Theme::i()->getTemplate( static::$commentTemplate[0][0], static::$commentTemplate[0][1], static::$commentTemplate[0][2] )->$template( $comment->item(), $comment );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
return parent::html();
|
||||
}
|
||||
@@ -165,20 +178,19 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
return parent::html();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Report
|
||||
*
|
||||
* @param string $reportContent Report content message from member
|
||||
* @param int $reportType Report type (see constants in \IPS\core\Reports\Report)
|
||||
* @param \IPS\Member|NULL $member Member making the report (or NULL for loggedIn())
|
||||
* @param array $guestDetails Details for a guest report
|
||||
* @return \IPS\core\Reports\Report
|
||||
* @throws \UnexpectedValueException If there is a permission error - you should only call this method after checking canReport
|
||||
* @param string $reportContent Report content message from member
|
||||
* @param int $reportType Report type (see constants in \IPS\core\Reports\Report
|
||||
* @param Member|null $member Member making the report (or NULL for loggedIn())
|
||||
* @return Report
|
||||
* @throws UnexpectedValueException If there is a permission error - you should only call this method after checking canReport
|
||||
*/
|
||||
public function report( $reportContent, $reportType=1, $member=NULL, $guestDetails=array() )
|
||||
public function report( string $reportContent, int $reportType=1, Member|null $member=null ): Report
|
||||
{
|
||||
$comment = \IPS\forums\Topic\Post::load( $this->pid );
|
||||
$comment = Post::load( $this->pid );
|
||||
return $comment->report( $reportContent, $reportType, $member );
|
||||
}
|
||||
|
||||
@@ -187,7 +199,7 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
*
|
||||
* @return array|NULL
|
||||
*/
|
||||
public static function commentWhere()
|
||||
public static function commentWhere(): ?array
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -198,7 +210,7 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
* @param int $id Content item to delete from
|
||||
* @return array
|
||||
*/
|
||||
public static function deleteWhereSql( $id )
|
||||
public static function deleteWhereSql( int $id ): array
|
||||
{
|
||||
return array( array( static::$databasePrefix . static::$databaseColumnMap['item'] . '=?', $id ) );
|
||||
}
|
||||
@@ -206,12 +218,12 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
/**
|
||||
* Post count for member
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @param bool $includeNonPostCountIncreasing If FALSE, will skip any posts which would not cause the user's post count to increase
|
||||
* @param bool $includeHiddenAndPendingApproval If FALSE, will skip any hidden posts, or posts pending approval
|
||||
* @return int
|
||||
*/
|
||||
public static function memberPostCount( \IPS\Member $member, bool $includeNonPostCountIncreasing = FALSE, bool $includeHiddenAndPendingApproval = TRUE )
|
||||
public static function memberPostCount( Member $member, bool $includeNonPostCountIncreasing = FALSE, bool $includeHiddenAndPendingApproval = TRUE ): int
|
||||
{
|
||||
return 0; // We explicitely return 0 because any posts will be counted via the forums application inherently already
|
||||
}
|
||||
@@ -221,7 +233,7 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
public static function reactionType(): string
|
||||
{
|
||||
return 'pid';
|
||||
}
|
||||
@@ -231,7 +243,7 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionClass()
|
||||
public static function reactionClass() : string
|
||||
{
|
||||
return 'IPS\forums\Topic\Post';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user