Version 5.0.0 beta 4
This commit is contained in:
1 parent
e86153356a
commit
2f24f9de48
276 files changed
+8614
-6044
No files matched your search
+84
-27
@@ -29,6 +29,7 @@ use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Db\Exception;
|
||||
use IPS\Db\Select;
|
||||
use IPS\Dispatcher\Front;
|
||||
use IPS\Events\Event;
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form\Captcha;
|
||||
@@ -39,6 +40,7 @@ use IPS\IPS;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Notification;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Platform\Bridge;
|
||||
use IPS\Redis;
|
||||
@@ -57,6 +59,7 @@ use function in_array;
|
||||
use function intval;
|
||||
use function is_array;
|
||||
use function substr;
|
||||
use function ucfirst;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
@@ -151,27 +154,31 @@ abstract class Comment extends Content
|
||||
break;
|
||||
|
||||
case 'approved':
|
||||
if ( $first ) // If this is the first post within an item, don't mark it hidden, otherwise the count of unapproved comments/items will include both the comment and the item when really only the item is hidden
|
||||
if( IPS::classUsesTrait( $obj, Hideable::class ) )
|
||||
{
|
||||
$val = TRUE;
|
||||
}
|
||||
elseif ( $hiddenStatus === NULL )
|
||||
{
|
||||
$permissionCheckFunction = in_array( 'IPS\Content\Review', class_parents( get_called_class() ) ) ? 'canReview' : 'canComment';
|
||||
if ( !$member->member_id and !$item->$permissionCheckFunction( $member, FALSE ) )
|
||||
if ( $first ) // If this is the first post within an item, don't mark it hidden, otherwise the count of unapproved comments/items will include both the comment and the item when really only the item is hidden
|
||||
{
|
||||
$val = -3;
|
||||
$val = TRUE;
|
||||
}
|
||||
elseif ( in_array( 'IPS\Content\Review', class_parents( get_called_class() ) ) )
|
||||
elseif ( $hiddenStatus === NULL )
|
||||
{
|
||||
$val = $item->moderateNewReviews( $member ) ? 0 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$val = $item->moderateNewComments( $member ) ? 0 : 1;
|
||||
$permissionCheckFunction = in_array( 'IPS\Content\Review', class_parents( get_called_class() ) ) ? 'canReview' : 'canComment';
|
||||
if ( !$member->member_id and !$item->$permissionCheckFunction( $member, FALSE ) )
|
||||
{
|
||||
$val = -3;
|
||||
}
|
||||
elseif ( in_array( 'IPS\Content\Review', class_parents( get_called_class() ) ) )
|
||||
{
|
||||
$val = $item->moderateNewReviews( $member ) ? 0 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$val = $item->moderateNewComments( $member ) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if( $val === null or !IPS::classUsesTrait( $obj, Hideable::class ) )
|
||||
{
|
||||
switch ( $hiddenStatus )
|
||||
{
|
||||
@@ -189,11 +196,15 @@ abstract class Comment extends Content
|
||||
break;
|
||||
|
||||
case 'hidden':
|
||||
if( !IPS::classUsesTrait( $obj, Hideable::class ) )
|
||||
{
|
||||
$val = $hiddenStatus;
|
||||
}
|
||||
if ( $first )
|
||||
{
|
||||
$val = FALSE; // If this is the first post within an item, don't mark it hidden, otherwise the count of unapproved comments/items will include both the comment and the item when really only the item is hidden
|
||||
}
|
||||
elseif ( $item->approvedButHidden() )
|
||||
elseif ( IPS::classUsesTrait( $item, Hideable::class ) and $item->approvedButHidden() )
|
||||
{
|
||||
$val = 2;
|
||||
}
|
||||
@@ -602,6 +613,49 @@ abstract class Comment extends Content
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array Shareable URLs
|
||||
*/
|
||||
protected static $shareableUrls = array();
|
||||
/**
|
||||
* Get a shareable URL
|
||||
*
|
||||
* @return Url
|
||||
*/
|
||||
public function shareableUrl( string $type='comment' ): Url
|
||||
{
|
||||
$currentPage = Front::i()->currentPage ?? 1;
|
||||
$idColumn = static::$databaseColumnId;
|
||||
$item = $this->item();
|
||||
$itemIdColumn = $item::$databaseColumnId;
|
||||
|
||||
/* Avoid building a single item's URL multiple times, such as when viewing a topic */
|
||||
if ( isset( static::$shareableUrls[ $type ][ $item->$itemIdColumn ] ) )
|
||||
{
|
||||
$url = static::$shareableUrls[ $type ][ $item->$itemIdColumn ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = $item->url()->setPage( 'page', $currentPage );
|
||||
|
||||
/* if we can do both comments and reviews, just return the findCommment url as we have tabs to navigate anyway */
|
||||
if ( isset( $item::$reviewClass ) and isset( $item::$commentClass ) )
|
||||
{
|
||||
if ( method_exists( $item, 'commentReviewTabs' ) )
|
||||
{
|
||||
if ( count( $item->commentReviewTabs() ) > 1 )
|
||||
{
|
||||
$url = $url->setQueryString( ['tab' => $type . 's'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static::$shareableUrls[ $type ][ $item->$itemIdColumn ] = $url;
|
||||
}
|
||||
|
||||
return $url->setFragment( 'find' . ucfirst( $type ) . '-' . $this->$idColumn );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get containing item
|
||||
*
|
||||
@@ -1868,28 +1922,31 @@ abstract class Comment extends Content
|
||||
}
|
||||
}
|
||||
|
||||
if( $this->mapped('first') )
|
||||
if ( ! Output::i()->reduceLinks() )
|
||||
{
|
||||
$share = new ContentMenuLink( url: $this->item()->url('share' ), languageString: Member::loggedIn()->language()->addToStack( $contentType === 'Comment' ? 'share_this_post' : 'share_this_review' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $contentType === 'Comment' )
|
||||
if ( $this->mapped( 'first' ) )
|
||||
{
|
||||
$share = new ContentMenuLink( url: $this->item()->url( )->setQueryString( array( 'do' => 'findComment', 'comment' => $this->$idField )), languageString: Member::loggedIn()->language()->addToStack( 'share_this_post' ) );
|
||||
$share = new ContentMenuLink( url: $this->item()->url( 'share' ), languageString: Member::loggedIn()->language()->addToStack( $contentType === 'Comment' ? 'share_this_post' : 'share_this_review' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$share = new ContentMenuLink( url: $this->item()->url( )->setQueryString( array( 'do' => 'findReview', 'review' => $this->$idField )), languageString: Member::loggedIn()->language()->addToStack( 'share_this_review' ) );
|
||||
if ( $contentType === 'Comment' )
|
||||
{
|
||||
$share = new ContentMenuLink( url: $this->shareableUrl(), languageString: Member::loggedIn()->language()->addToStack( 'share_this_post' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$share = new ContentMenuLink( url: $this->shareableUrl('review'), languageString: Member::loggedIn()->language()->addToStack( 'share_this_review' ) );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$share->opensDialog( title: Member::loggedIn()->language()->addToStack('share'), size: 'narrow', contentSelector: '#elShare' . ucfirst( static::$moderationMenuIdPrefix ) . $this->$idField . '_menu' )
|
||||
$share->opensDialog( title: Member::loggedIn()->language()->addToStack('share'), size: 'narrow', contentSelector: '#elShare' . ucfirst( static::$moderationMenuIdPrefix ) . $this->$idField . '_menu' )
|
||||
->addAttribute( 'data-role', 'share' . $contentType )
|
||||
->addAttribute( 'id', 'elShare' . ucfirst( static::$moderationMenuIdPrefix ) . $this->$idField )
|
||||
->addAttribute( 'rel', 'nofollow' );
|
||||
$menu->add( $share );
|
||||
$menu->add( $share );
|
||||
}
|
||||
|
||||
if( method_exists( $this, 'canRecognize') )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user