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
+165
-146
@@ -11,77 +11,110 @@
|
||||
namespace IPS\Content\Search;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use ArrayIterator;
|
||||
use IPS\Application;
|
||||
use IPS\Content\Item;
|
||||
use IPS\Content\Reaction;
|
||||
use IPS\Content\Review;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Db\Select;
|
||||
use IPS\IPS;
|
||||
use IPS\Log;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Club;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Text\Parser;
|
||||
use IPS\Theme;
|
||||
use LogicException;
|
||||
use OutOfRangeException;
|
||||
use function array_slice;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function in_array;
|
||||
use function is_integer;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Results
|
||||
*/
|
||||
class _Results extends \ArrayIterator
|
||||
class Results extends ArrayIterator
|
||||
{
|
||||
/**
|
||||
* @brief Count
|
||||
*/
|
||||
protected $countAllRows;
|
||||
protected mixed $countAllRows = null;
|
||||
|
||||
/**
|
||||
* @brief Has this been initated?
|
||||
*/
|
||||
protected $initated = FALSE;
|
||||
protected bool $initated = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Author data
|
||||
*/
|
||||
protected $authorData = array();
|
||||
protected array $authorData = array();
|
||||
|
||||
/**
|
||||
* @brief Item titles
|
||||
*/
|
||||
protected $itemData = array();
|
||||
protected array $itemData = array();
|
||||
|
||||
/**
|
||||
* @brief Container data
|
||||
*/
|
||||
protected $containerData = array();
|
||||
protected array $containerData = array();
|
||||
|
||||
/**
|
||||
* @brief Reputation data
|
||||
*/
|
||||
protected $reputationData = array();
|
||||
protected array $reputationData = array();
|
||||
|
||||
/**
|
||||
* @brief Reaction Data
|
||||
*/
|
||||
protected $reactions = array();
|
||||
protected array $reactions = array();
|
||||
|
||||
/**
|
||||
* @brief Attached Images
|
||||
*/
|
||||
protected $attachedImages = array();
|
||||
protected array $attachedImages = array();
|
||||
|
||||
/**
|
||||
* @brief Review Ratings
|
||||
*/
|
||||
protected $reviewRatings = array();
|
||||
protected array $reviewRatings = array();
|
||||
|
||||
/**
|
||||
* @brief Index IDs of items I have posted in
|
||||
*/
|
||||
protected $iPostedIn = array();
|
||||
protected array $iPostedIn = array();
|
||||
|
||||
/**
|
||||
* @brief Tag values for index_ids returned from search
|
||||
*/
|
||||
protected $tags = array();
|
||||
protected array $tags = array();
|
||||
|
||||
/**
|
||||
* @brief Prefixes for index_ids returned from search
|
||||
*/
|
||||
protected array $prefixes = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $results The results
|
||||
* @param \IPS\Db\Select|int $countAllRows Count for all rows query or int
|
||||
* @param Select|int $countAllRows Count for all rows query or int
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $results, $countAllRows )
|
||||
@@ -95,7 +128,7 @@ class _Results extends \ArrayIterator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init(): void
|
||||
{
|
||||
/* Init */
|
||||
$membersToLoad = array();
|
||||
@@ -104,7 +137,6 @@ class _Results extends \ArrayIterator
|
||||
$reputationIds = array();
|
||||
$reviewRatings = array();
|
||||
$itemIndexIds = array();
|
||||
$indexIds = array();
|
||||
$attachedImages = array();
|
||||
|
||||
/* Loop */
|
||||
@@ -115,7 +147,7 @@ class _Results extends \ArrayIterator
|
||||
$membersToLoad[ $result['index_author'] ] = $result['index_author'];
|
||||
}
|
||||
|
||||
if ( \in_array( 'IPS\Content\Comment', class_parents( $result['index_class'] ) ) )
|
||||
if ( in_array( 'IPS\Content\Comment', class_parents( $result['index_class'] ) ) )
|
||||
{
|
||||
$commentClass = $result['index_class'];
|
||||
$itemsToLoad[ $commentClass::$itemClass ][ $result['index_item_id'] ] = $result['index_item_id'];
|
||||
@@ -128,33 +160,23 @@ class _Results extends \ArrayIterator
|
||||
if ( $result['index_container_id'] )
|
||||
{
|
||||
$class = $result['index_class'];
|
||||
if ( $class == 'IPS\core\Statuses\Status' )
|
||||
$itemClass = in_array( 'IPS\Content\Comment', class_parents( $class ) ) ? $class::$itemClass : $class;
|
||||
if ( isset( $itemClass::$containerNodeClass ) )
|
||||
{
|
||||
if ( $result['index_container_id'] != $result['index_author'] )
|
||||
$containerClass = $itemClass::$containerNodeClass;
|
||||
if ( isset( $containerClass::$seoTitleColumn ) )
|
||||
{
|
||||
$membersToLoad[ $result['index_container_id'] ] = $result['index_container_id'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$itemClass = \in_array( 'IPS\Content\Comment', class_parents( $class ) ) ? $class::$itemClass : $class;
|
||||
if ( isset( $itemClass::$containerNodeClass ) )
|
||||
{
|
||||
$containerClass = $itemClass::$containerNodeClass;
|
||||
if ( isset( $containerClass::$seoTitleColumn ) )
|
||||
{
|
||||
$containersToLoad[ $itemClass::$containerNodeClass ][ $result['index_container_id'] ] = $result['index_container_id'];
|
||||
}
|
||||
$containersToLoad[ $itemClass::$containerNodeClass ][ $result['index_container_id'] ] = $result['index_container_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( \IPS\IPS::classUsesTrait( $result['index_class'], 'IPS\Content\Reactable' ) )
|
||||
if ( IPS::classUsesTrait( $result['index_class'], 'IPS\Content\Reactable' ) )
|
||||
{
|
||||
$reputationIds[ $result['index_class'] ][ $result['index_object_id'] ] = $result['index_object_id'];
|
||||
}
|
||||
|
||||
if ( \in_array( 'IPS\Content\Review', class_parents( $result['index_class'] ) ) )
|
||||
if ( in_array( 'IPS\Content\Review', class_parents( $result['index_class'] ) ) )
|
||||
{
|
||||
$reviewRatings[ $result['index_class'] ][ $result['index_object_id'] ] = $result['index_object_id'];
|
||||
}
|
||||
@@ -175,7 +197,9 @@ class _Results extends \ArrayIterator
|
||||
/* Load item data */
|
||||
foreach ( $itemsToLoad as $itemClass => $itemIds )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( $itemClass::basicDataColumns(), $itemClass::$databaseTable, \IPS\Db::i()->in( $itemClass::$databasePrefix . $itemClass::$databaseColumnId, $itemIds ) )->setKeyField( $itemClass::$databasePrefix . $itemClass::$databaseColumnId ) as $itemId => $itemData )
|
||||
/* @var Item $itemClass */
|
||||
/* @var array $databaseColumnMap */
|
||||
foreach ( Db::i()->select( $itemClass::basicDataColumns(), $itemClass::$databaseTable, Db::i()->in( $itemClass::$databasePrefix . $itemClass::$databaseColumnId, $itemIds ) )->setKeyField( $itemClass::$databasePrefix . $itemClass::$databaseColumnId ) as $itemId => $itemData )
|
||||
{
|
||||
$this->itemData[ $itemClass ][ $itemId ] = $itemData;
|
||||
|
||||
@@ -196,33 +220,34 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
/* Load author data */
|
||||
if( \count( $membersToLoad ) )
|
||||
if( count( $membersToLoad ) )
|
||||
{
|
||||
$this->authorData = iterator_to_array( \IPS\Db::i()->select( \IPS\Member::columnsForPhoto(), 'core_members', \IPS\Db::i()->in( 'member_id', $membersToLoad ) )->setKeyField( 'member_id' ) );
|
||||
$this->authorData = iterator_to_array( Db::i()->select( Member::columnsForPhoto(), 'core_members', Db::i()->in( 'member_id', $membersToLoad ) )->setKeyField( 'member_id' ) );
|
||||
}
|
||||
|
||||
/* Load container data */
|
||||
foreach ( $containersToLoad as $containerClass => $containerIds )
|
||||
{
|
||||
$this->containerData[ $containerClass ] = iterator_to_array( \IPS\Db::i()->select( $containerClass::basicDataColumns(), $containerClass::$databaseTable, \IPS\Db::i()->in( $containerClass::$databasePrefix . $containerClass::$databaseColumnId, $containerIds ) )->setKeyField( $containerClass::$databasePrefix . $containerClass::$databaseColumnId ) );
|
||||
/* @var string|Model $containerClass */
|
||||
$this->containerData[ $containerClass ] = iterator_to_array( Db::i()->select( $containerClass::basicDataColumns(), $containerClass::$databaseTable, Db::i()->in( $containerClass::$databasePrefix . $containerClass::$databaseColumnId, $containerIds ) )->setKeyField( $containerClass::$databasePrefix . $containerClass::$databaseColumnId ) );
|
||||
}
|
||||
|
||||
/* Load reputation data */
|
||||
$reputation = array();
|
||||
if ( \count( $reputationIds ) )
|
||||
if ( count( $reputationIds ) )
|
||||
{
|
||||
$clause = array();
|
||||
$binds = array();
|
||||
foreach ( $reputationIds as $class => $ids )
|
||||
{
|
||||
$clause[] = "( reaction_enabled=? AND app=? AND type=? AND " . \IPS\Db::i()->in( 'type_id', $ids ) . " )";
|
||||
/* @var Item $class */
|
||||
$clause[] = "( reaction_enabled=? AND app=? AND type=? AND " . Db::i()->in( 'type_id', $ids ) . " )";
|
||||
$binds[] = 1;
|
||||
$binds[] = $class::$application;
|
||||
$binds[] = $class::reactionType();
|
||||
}
|
||||
|
||||
$where = array( array_merge( array( implode( ' OR ', $clause ) ), $binds ) );
|
||||
foreach ( \IPS\Db::i()->select( array( 'app', 'type', 'type_id', 'member_id', 'rep_rating', 'reaction' ), 'core_reputation_index', $where )->join( 'core_reactions', 'reaction=reaction_id' ) as $rep )
|
||||
foreach ( Db::i()->select( array( 'app', 'type', 'type_id', 'member_id', 'rep_rating', 'reaction' ), 'core_reputation_index', $where )->join( 'core_reactions', 'reaction=reaction_id' ) as $rep )
|
||||
{
|
||||
$this->reputationData[ $rep['app'] ][ $rep['type'] ][ $rep['type_id'] ][ $rep['member_id'] ] = $rep['reaction'];
|
||||
|
||||
@@ -238,26 +263,23 @@ class _Results extends \ArrayIterator
|
||||
/* Load rating reviews */
|
||||
foreach ( $reviewRatings as $reviewClass => $reviewIds )
|
||||
{
|
||||
$this->reviewRatings[ $reviewClass ] = iterator_to_array( \IPS\Db::i()->select( array( $reviewClass::$databasePrefix . $reviewClass::$databaseColumnId, $reviewClass::$databasePrefix . $reviewClass::$databaseColumnMap['rating'] ), $reviewClass::$databaseTable, \IPS\Db::i()->in( $reviewClass::$databasePrefix . $reviewClass::$databaseColumnId, $reviewIds ) )->setKeyField( $reviewClass::$databasePrefix . $reviewClass::$databaseColumnId )->setValueField( $reviewClass::$databasePrefix . $reviewClass::$databaseColumnMap['rating'] ) );
|
||||
/* @var string|Review $reviewClass */
|
||||
/* @var array $databaseColumnMap */
|
||||
$this->reviewRatings[ $reviewClass ] = iterator_to_array( Db::i()->select( array( $reviewClass::$databasePrefix . $reviewClass::$databaseColumnId, $reviewClass::$databasePrefix . $reviewClass::$databaseColumnMap['rating'] ), $reviewClass::$databaseTable, Db::i()->in( $reviewClass::$databasePrefix . $reviewClass::$databaseColumnId, $reviewIds ) )->setKeyField( $reviewClass::$databasePrefix . $reviewClass::$databaseColumnId )->setValueField( $reviewClass::$databasePrefix . $reviewClass::$databaseColumnMap['rating'] ) );
|
||||
}
|
||||
|
||||
/* Load data for the "I posted in this" stars */
|
||||
if ( \count( $itemIndexIds ) and \IPS\Member::loggedIn()->member_id )
|
||||
if ( count( $itemIndexIds ) and Member::loggedIn()->member_id )
|
||||
{
|
||||
$this->iPostedIn = \IPS\Content\Search\Index::i()->iPostedIn( $itemIndexIds, \IPS\Member::loggedIn() );
|
||||
$this->iPostedIn = Index::i()->iPostedIn( $itemIndexIds, Member::loggedIn() );
|
||||
}
|
||||
|
||||
/* Load tags and prefixes */
|
||||
if ( \count( $itemIndexIds ) and \IPS\Settings::i()->search_method == 'mysql' and \IPS\Settings::i()->tags_enabled )
|
||||
if ( count( $itemIndexIds ) and Settings::i()->search_method == 'mysql' and Settings::i()->tags_enabled)
|
||||
{
|
||||
$orderBy = '';
|
||||
if ( \IPS\Settings::i()->tags_alphabetical )
|
||||
{
|
||||
$orderBy = ' ORDER BY index_tag ASC';
|
||||
}
|
||||
|
||||
$this->tags = iterator_to_array( \IPS\Db::i()->select( 'index_id, GROUP_CONCAT(index_tag' . $orderBy . ') as index_tags', 'core_search_index_tags', array( array( \IPS\Db::i()->in( 'index_id', $itemIndexIds ) ), array( 'index_is_prefix = 0' ) ), NULL, NULL, 'index_id' )->setKeyField('index_id') );
|
||||
$this->prefixes = iterator_to_array( \IPS\Db::i()->select( 'index_id, index_tag as index_prefix', 'core_search_index_tags', array( array( \IPS\Db::i()->in( 'index_id', $itemIndexIds ) ), array( 'index_is_prefix = 1' ) ) )->setKeyField('index_id') );
|
||||
$this->tags = iterator_to_array( Db::i()->select( 'index_id, GROUP_CONCAT(index_tag' . $orderBy . ') as index_tags', 'core_search_index_tags', array( array( Db::i()->in( 'index_id', $itemIndexIds ) ), array( 'index_is_prefix = 0' ) ), NULL, NULL, 'index_id' )->setKeyField('index_id') );
|
||||
$this->prefixes = iterator_to_array( Db::i()->select( 'index_id, index_tag as index_prefix', 'core_search_index_tags', array( array( Db::i()->in( 'index_id', $itemIndexIds ) ), array( 'index_is_prefix = 1' ) ) )->setKeyField('index_id') );
|
||||
}
|
||||
|
||||
/* Load attached images */
|
||||
@@ -266,12 +288,12 @@ class _Results extends \ArrayIterator
|
||||
$locationKeyMap = [];
|
||||
foreach ( $attachedImages as $class => $ids )
|
||||
{
|
||||
$itemClass = \in_array( 'IPS\Content\Comment', class_parents( $class ) ) ? $class::$itemClass : $class;
|
||||
$itemClass = in_array( 'IPS\Content\Comment', class_parents( $class ) ) ? $class::$itemClass : $class;
|
||||
foreach( $ids as $indexId => $commentIds )
|
||||
{
|
||||
foreach( $commentIds as $commentId )
|
||||
{
|
||||
$locationKey = $itemClass::$application . '_' . mb_ucfirst( $itemClass::$module );
|
||||
$locationKey = $itemClass::$application . '_' . IPS::mb_ucfirst( $itemClass::$module );
|
||||
$locationKeyMap[$locationKey] = $class;
|
||||
$clause[] = "( location_key=? AND id1=? AND id2=?)";
|
||||
$binds[] = $locationKey;
|
||||
@@ -281,11 +303,11 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
}
|
||||
|
||||
if ( \count( $attachedImages ) and \count( $clause ) )
|
||||
if ( count( $attachedImages ) and count( $clause ) )
|
||||
{
|
||||
/* As we need to join back onto the map table, 2 queries are much more efficient */
|
||||
$ids = iterator_to_array( \IPS\Db::i()->select( 'attachment_id', 'core_attachments_map', array( array_merge( array( implode( ' OR ', $clause ) ), $binds ) ) ) );
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_attachments', array( array( \IPS\Db::i()->in( 'attach_id', $ids ) ), array('attach_is_image=1') ), 'attach_id ASC' )
|
||||
$ids = iterator_to_array( Db::i()->select( 'attachment_id', 'core_attachments_map', array( array_merge( array( implode( ' OR ', $clause ) ), $binds ) ) ) );
|
||||
foreach ( Db::i()->select( '*', 'core_attachments', array( array( Db::i()->in( 'attach_id', $ids ) ), array('attach_is_image=1') ), 'attach_id ASC' )
|
||||
->join( 'core_attachments_map', 'core_attachments_map.attachment_id=core_attachments.attach_id' ) as $row )
|
||||
{
|
||||
if ( isset( $locationKeyMap[ $row['location_key'] ] ) and isset( $row['id2'] ) )
|
||||
@@ -294,7 +316,7 @@ class _Results extends \ArrayIterator
|
||||
'extension' => 'core_Attachment',
|
||||
'location' => $row['attach_location'],
|
||||
'thumb_location' => $row['attach_thumb_location'],
|
||||
'labels' => implode( ', ', \IPS\Text\Parser::getAttachmentLabels( $row ) )
|
||||
'labels' => implode( ', ', Parser::getAttachmentLabels( $row ) )
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -307,24 +329,24 @@ class _Results extends \ArrayIterator
|
||||
/**
|
||||
* Get current
|
||||
*
|
||||
* @return \IPS\Patterns\ActiveRecord
|
||||
* @return Result\Content
|
||||
*/
|
||||
public function current()
|
||||
public function current(): Result\Content
|
||||
{
|
||||
$data = parent::current();
|
||||
|
||||
$class = $data['index_class'];
|
||||
$itemClass = \in_array( 'IPS\Content\Comment', class_parents( $class ) ) ? $class::$itemClass : $class;
|
||||
$containerClass = isset( $itemClass::$containerNodeClass ) ? $itemClass::$containerNodeClass : NULL;
|
||||
$itemClass = in_array( 'IPS\Content\Comment', class_parents( $class ) ) ? $class::$itemClass : $class;
|
||||
$containerClass = $itemClass::$containerNodeClass ?? NULL;
|
||||
|
||||
$reputationData = array();
|
||||
if ( \IPS\IPS::classUsesTrait( $class, 'IPS\Content\Reactable' ) and isset( $this->reputationData[ $class::$application ][ $class::reactionType() ][ $data['index_object_id'] ] ) )
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\Reactable' ) and isset( $this->reputationData[ $class::$application ][ $class::reactionType() ][ $data['index_object_id'] ] ) )
|
||||
{
|
||||
$reputationData = $this->reputationData[ $class::$application ][ $class::reactionType() ][ $data['index_object_id'] ];
|
||||
}
|
||||
|
||||
$reactions = array();
|
||||
if ( \IPS\IPS::classUsesTrait( $class, 'IPS\Content\Reactable' ) and isset( $this->reactions[ $class::$application ][ $class::reactionType() ][ $data['index_object_id'] ] ) )
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\Reactable' ) and isset( $this->reactions[ $class::$application ][ $class::reactionType() ][ $data['index_object_id'] ] ) )
|
||||
{
|
||||
$reactions = $this->reactions[ $class::$application ][ $class::reactionType() ][ $data['index_object_id'] ];
|
||||
}
|
||||
@@ -333,10 +355,10 @@ class _Results extends \ArrayIterator
|
||||
if ( ! isset( $this->itemData[ $itemClass ][ $data['index_item_id'] ] ) )
|
||||
{
|
||||
/* This should not happen in production, so debug log */
|
||||
\IPS\Log::debug( "index_item_id ID " . $data['index_item_id'] . " for " . $itemClass . " has no itemData" , 'searchResults' );
|
||||
Log::debug( "index_item_id ID " . $data['index_item_id'] . " for " . $itemClass . " has no itemData" , 'searchResults' );
|
||||
|
||||
/* Then cleanup/remove the item now */
|
||||
\IPS\Content\Search\Index::i()->directIndexRemoval( $data['index_class'], $data['index_object_id'] );
|
||||
Index::i()->directIndexRemoval( $data['index_class'], $data['index_object_id'] );
|
||||
|
||||
/* And continue, moving on to the next item */
|
||||
static::next();
|
||||
@@ -344,10 +366,6 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
$itemData = $this->itemData[ $itemClass ][ $data['index_item_id'] ];
|
||||
if ( $class == 'IPS\core\Statuses\Status' and $data['index_container_id'] != $data['index_author'] )
|
||||
{
|
||||
$itemData['profile'] = $this->authorData[ $data['index_container_id'] ];
|
||||
}
|
||||
if ( isset( $itemClass::$databaseColumnMap['author'] ) and isset( $itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['author'] ] ) )
|
||||
{
|
||||
$memberId = $itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['author'] ];
|
||||
@@ -357,7 +375,7 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
}
|
||||
|
||||
if ( \is_array( $this->attachedImages ) and isset( $this->attachedImages[ $class ][ $data['index_object_id'] ] ) )
|
||||
if ( isset( $this->attachedImages[ $class ][ $data['index_object_id'] ] ) )
|
||||
{
|
||||
$itemData['attachedImages'] = $this->attachedImages[ $class ][ $data['index_object_id'] ];
|
||||
}
|
||||
@@ -384,12 +402,12 @@ class _Results extends \ArrayIterator
|
||||
|
||||
return new Result\Content(
|
||||
$data,
|
||||
isset( $this->authorData[ $data['index_author'] ] ) ? $this->authorData[ $data['index_author'] ] : array( 'member_id' => 0, 'name' => \IPS\Member::loggedIn()->language()->addToStack('guest'), 'members_seo_name' => '', 'pp_main_photo' => NULL, 'pp_photo_type' => 'none' ),
|
||||
$this->authorData[$data['index_author']] ?? array('member_id' => 0, 'name' => Member::loggedIn()->language()->addToStack('guest'), 'members_seo_name' => '', 'pp_main_photo' => NULL, 'pp_photo_type' => 'none'),
|
||||
$itemData,
|
||||
$containerData,
|
||||
$reputationData,
|
||||
isset( $this->reviewRatings[ $data['index_class'] ][ $data['index_object_id'] ] ) ? $this->reviewRatings[ $data['index_class'] ][ $data['index_object_id'] ] : NULL,
|
||||
\in_array( $data['index_item_index_id'], $this->iPostedIn ),
|
||||
$this->reviewRatings[$data['index_class']][$data['index_object_id']] ?? NULL,
|
||||
in_array( $data['index_item_index_id'], $this->iPostedIn ),
|
||||
$reactions
|
||||
);
|
||||
}
|
||||
@@ -399,13 +417,14 @@ class _Results extends \ArrayIterator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rewind()
|
||||
public function rewind(): void
|
||||
{
|
||||
if ( !$this->initated )
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
return parent::rewind();
|
||||
|
||||
parent::rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -414,15 +433,15 @@ class _Results extends \ArrayIterator
|
||||
* @param bool $allRows If TRUE, will get the number of rows ignoring the limit
|
||||
* @return int
|
||||
*/
|
||||
public function count( $allRows = FALSE )
|
||||
public function count( bool $allRows = FALSE ): int
|
||||
{
|
||||
if ( $allRows )
|
||||
{
|
||||
if ( \is_integer( $this->countAllRows ) )
|
||||
if ( is_integer( $this->countAllRows ) )
|
||||
{
|
||||
return $this->countAllRows;
|
||||
}
|
||||
else if ( \gettype( $this->countAllRows ) === 'object' and \get_class( $this->countAllRows ) === 'IPS\Db\Select' )
|
||||
else if ( gettype( $this->countAllRows ) === 'object' and get_class( $this->countAllRows ) === 'IPS\Db\Select' )
|
||||
{
|
||||
$this->countAllRows = $this->countAllRows->first();
|
||||
|
||||
@@ -430,7 +449,7 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \LogicException;
|
||||
throw new LogicException;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -443,13 +462,13 @@ class _Results extends \ArrayIterator
|
||||
* Add in "extra" items
|
||||
*
|
||||
* @param array $extra Types ('register', 'follow_member', 'follow_content', 'photo', 'votes', 'like', 'rep_neg')
|
||||
* @param \IPS\Member|NULL $author The author to limit extra items to
|
||||
* @param \IPS\DateTime|NULL $lastTime If provided, only items since this date is included. If NULL, it works out which to include based on what results are being shown
|
||||
* @param \IPS\DateTime|NULL $firstTime If provided, only items before this date is included. If NULL, it works out which to include based on what results are being shown
|
||||
* @param Member|NULL $author The author to limit extra items to
|
||||
* @param DateTime|NULL $lastTime If provided, only items since this date is included. If NULL, it works out which to include based on what results are being shown
|
||||
* @param DateTime|NULL $firstTime If provided, only items before this date is included. If NULL, it works out which to include based on what results are being shown
|
||||
* @return array
|
||||
* @note Each thing is limited to 10 items. Even though this may result in accuracies, the limit is necessary so that if there's more extra items that content it doesn't create lots of queries and slow loading
|
||||
*/
|
||||
public function addExtraItems( $extra, \IPS\Member $author = NULL, $lastTime=NULL, $firstTime = NULL )
|
||||
public function addExtraItems( array $extra, Member|null $author = NULL, DateTime|null $lastTime=NULL, DateTime|null $firstTime = NULL ): array
|
||||
{
|
||||
/* Work out the timestamps */
|
||||
$results = iterator_to_array( $this );
|
||||
@@ -457,7 +476,7 @@ class _Results extends \ArrayIterator
|
||||
{
|
||||
$firstTime = $firstTime->getTimestamp();
|
||||
}
|
||||
elseif ( isset( \IPS\Request::i()->page ) and \IPS\Request::i()->page != 1 )
|
||||
elseif ( isset( Request::i()->page ) and Request::i()->page != 1 )
|
||||
{
|
||||
foreach ( $results as $result )
|
||||
{
|
||||
@@ -495,7 +514,7 @@ class _Results extends \ArrayIterator
|
||||
if ( $lastTime )
|
||||
{
|
||||
/* Users registered */
|
||||
if ( \in_array( 'register', $extra ) )
|
||||
if ( in_array( 'register', $extra ) )
|
||||
{
|
||||
$where = array( array( 'joined>?', $lastTime ), array( 'completed=?', true ), array( 'temp_ban!=?', '-1' ) );
|
||||
if ( $firstTime )
|
||||
@@ -508,22 +527,22 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
foreach (
|
||||
\IPS\Db::i()->select( implode( ', ', array_merge( array_map( function( $c ) { return "core_members.{$c}"; }, \IPS\Member::columnsForPhoto() ), array( 'core_members.joined', 'core_validating.new_reg' ) ) ), 'core_members', $where, 'joined DESC', 10 )
|
||||
Db::i()->select( implode( ', ', array_merge( array_map( function( $c ) { return "core_members.{$c}"; }, Member::columnsForPhoto() ), array( 'core_members.joined', 'core_validating.new_reg' ) ) ), 'core_members', $where, 'joined DESC', 10 )
|
||||
->join( 'core_validating', 'core_validating.member_id=core_members.member_id' )
|
||||
as $member ) {
|
||||
if ( empty( $member['new_reg'] ) )
|
||||
{
|
||||
$extraItems[] = new Result\Custom(
|
||||
\IPS\DateTime::ts( $member['joined'] ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_member_joined', FALSE, array( 'htmlsprintf' => \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLinkFromData( $member['member_id'], $member['name'], $member['members_seo_name'], $member['member_group_id'] ) ) ),
|
||||
\IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userPhotoFromData( $member['member_id'], $member['name'], $member['members_seo_name'], \IPS\Member::photoUrl( $member ), 'tiny' )
|
||||
DateTime::ts( $member['joined'] ),
|
||||
Member::loggedIn()->language()->addToStack( 'activity_member_joined', FALSE, array( 'htmlsprintf' => Theme::i()->getTemplate( 'global', 'core', 'front' )->userLinkFromData( $member['member_id'], $member['name'], $member['members_seo_name'], $member['member_group_id'] ) ) ),
|
||||
Theme::i()->getTemplate( 'global', 'core', 'front' )->userPhotoFromData( $member['member_id'], $member['name'], $member['members_seo_name'], Member::photoUrl( $member ), 'fluid' )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Users changed photo */
|
||||
if ( \in_array( 'photo', $extra ) )
|
||||
if ( in_array( 'photo', $extra ) )
|
||||
{
|
||||
$where = array( array( 'photo_last_update>? AND photo_last_update>(joined+300)', $lastTime ), array( 'completed=?', true ) );
|
||||
if ( $firstTime )
|
||||
@@ -534,27 +553,27 @@ class _Results extends \ArrayIterator
|
||||
{
|
||||
$where[] = array( 'member_id=?', $author->member_id );
|
||||
}
|
||||
foreach ( \IPS\Db::i()->select( array_merge( \IPS\Member::columnsForPhoto(), array( 'photo_last_update' ) ), 'core_members', $where, 'photo_last_update DESC', 10 ) as $member )
|
||||
foreach ( Db::i()->select( array_merge( Member::columnsForPhoto(), array( 'photo_last_update' ) ), 'core_members', $where, 'photo_last_update DESC', 10 ) as $member )
|
||||
{
|
||||
$extraItems[] = new Result\Custom(
|
||||
\IPS\DateTime::ts( $member['photo_last_update'] ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_member_updated_photo', FALSE, array( 'htmlsprintf' => \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLinkFromData( $member['member_id'], $member['name'], $member['members_seo_name'], $member['member_group_id'] ) ) ),
|
||||
\IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userPhotoFromData( $member['member_id'], $member['name'], $member['members_seo_name'], \IPS\Member::photoUrl( $member ), 'tiny' )
|
||||
DateTime::ts( $member['photo_last_update'] ),
|
||||
Member::loggedIn()->language()->addToStack( 'activity_member_updated_photo', FALSE, array( 'htmlsprintf' => Theme::i()->getTemplate( 'global', 'core', 'front' )->userLinkFromData( $member['member_id'], $member['name'], $member['members_seo_name'], $member['member_group_id'] ) ) ),
|
||||
Theme::i()->getTemplate( 'global', 'core', 'front' )->userPhotoFromData( $member['member_id'], $member['name'], $member['members_seo_name'], Member::photoUrl( $member ), 'fluid' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Follow */
|
||||
if ( \in_array( 'follow_member', $extra ) or \in_array( 'follow_content', $extra ) )
|
||||
if ( in_array( 'follow_member', $extra ) or in_array( 'follow_content', $extra ) )
|
||||
{
|
||||
$where = array( array( 'follow_is_anon=0' ), array( 'follow_added>?', $lastTime ) );
|
||||
if ( $firstTime )
|
||||
{
|
||||
$where[] = array( 'follow_added<?', $firstTime );
|
||||
}
|
||||
if ( \in_array( 'follow_member', $extra ) xor \in_array( 'follow_content', $extra ) )
|
||||
if ( in_array( 'follow_member', $extra ) xor in_array( 'follow_content', $extra ) )
|
||||
{
|
||||
if ( \in_array( 'follow_member', $extra ) )
|
||||
if ( in_array( 'follow_member', $extra ) )
|
||||
{
|
||||
$where[] = array( 'follow_app=? AND follow_area=?', 'core', 'member' );
|
||||
}
|
||||
@@ -565,11 +584,11 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
if ( $author )
|
||||
{
|
||||
if ( \in_array( 'follow_member', $extra ) and \in_array( 'follow_content', $extra ) )
|
||||
if ( in_array( 'follow_member', $extra ) and in_array( 'follow_content', $extra ) )
|
||||
{
|
||||
$where[] = array( '( follow_id IN (?) )', \IPS\Db::i()->select( 'follow_id', 'core_follow', array( '( follow_member_id=? OR ( follow_app=? AND follow_area=? AND follow_rel_id=? ) )', $author->member_id, 'core', 'member', $author->member_id ) ) );
|
||||
$where[] = array( '( follow_id IN (?) )', Db::i()->select( 'follow_id', 'core_follow', array( '( follow_member_id=? OR ( follow_app=? AND follow_area=? AND follow_rel_id=? ) )', $author->member_id, 'core', 'member', $author->member_id ) ) );
|
||||
}
|
||||
elseif ( \in_array( 'follow_member', $extra ) )
|
||||
elseif ( in_array( 'follow_member', $extra ) )
|
||||
{
|
||||
$where[] = array( 'follow_rel_id=?', $author->member_id );
|
||||
}
|
||||
@@ -580,23 +599,23 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
/* If an application was not updated or is not installed, do not try to fetch it or we can get a class does not exist fatal error */
|
||||
$where[] = array( "follow_app IN('" . implode( "','", array_keys( \IPS\Application::enabledApplications() ) ) . "')" );
|
||||
$where[] = array( "follow_app IN('" . implode( "','", array_keys( Application::enabledApplications() ) ) . "')" );
|
||||
|
||||
$lastClass = NULL;
|
||||
$lastMember = NULL;
|
||||
|
||||
foreach ( \IPS\Db::i()->select( array( 'follow_app', 'follow_area', 'follow_rel_id', 'follow_member_id', 'follow_added' ), 'core_follow', $where, 'follow_added DESC', 10 ) as $follow )
|
||||
foreach ( Db::i()->select( array( 'follow_app', 'follow_area', 'follow_rel_id', 'follow_member_id', 'follow_added' ), 'core_follow', $where, 'follow_added DESC', 10 ) as $follow )
|
||||
{
|
||||
if ( $follow['follow_app'] == 'core' and $follow['follow_area'] == 'member' )
|
||||
{
|
||||
$extraItems[] = new Result\Custom(
|
||||
\IPS\DateTime::ts( $follow['follow_added'] ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_member_followed', FALSE, array( 'htmlsprintf' => array( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( \IPS\Member::load( $follow['follow_member_id'] ) ), \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( \IPS\Member::load( $follow['follow_rel_id'] ) ) ) ) )
|
||||
DateTime::ts( $follow['follow_added'] ),
|
||||
Member::loggedIn()->language()->addToStack( 'activity_member_followed', FALSE, array( 'htmlsprintf' => array( Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( Member::load( $follow['follow_member_id'] ) ), Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( Member::load( $follow['follow_rel_id'] ) ) ) ) )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'IPS\\' . $follow['follow_app'] . '\\' . mb_ucfirst( $follow['follow_area'] );
|
||||
$class = 'IPS\\' . $follow['follow_app'] . '\\' . IPS::mb_ucfirst( $follow['follow_area'] );
|
||||
|
||||
try
|
||||
{
|
||||
@@ -611,7 +630,7 @@ class _Results extends \ArrayIterator
|
||||
|
||||
if( $result['indexData']['index_class'] == $class AND $result['indexData']['index_object_id'] == $follow['follow_rel_id'] )
|
||||
{
|
||||
$urlToThing = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $class::urlFromIndexData( $result['indexData'], $result['itemData'] ), FALSE, $result['indexData']['index_title'], FALSE );
|
||||
$urlToThing = Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $result['url'], FALSE, $result['indexData']['index_title'], FALSE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -619,31 +638,31 @@ class _Results extends \ArrayIterator
|
||||
if( $urlToThing === NULL )
|
||||
{
|
||||
$thingBeingFollowed = $class::loadAndCheckPerms( $follow['follow_rel_id'] );
|
||||
$urlToThing = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $thingBeingFollowed->url(), FALSE, $thingBeingFollowed instanceof \IPS\Node\Model ? $thingBeingFollowed->_title : $thingBeingFollowed->mapped('title'), FALSE );
|
||||
$urlToThing = Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $thingBeingFollowed->url(), FALSE, $thingBeingFollowed instanceof Model ? $thingBeingFollowed->_title : $thingBeingFollowed->mapped('title'), FALSE );
|
||||
}
|
||||
|
||||
/* Do we need to merge with the last result? */
|
||||
if( $lastClass !== NULL AND $lastClass === $class AND $lastMember === $follow['follow_member_id'] AND \count( $extraItems ) )
|
||||
if( $lastClass !== NULL AND $lastClass === $class AND $lastMember === $follow['follow_member_id'] AND count( $extraItems ) )
|
||||
{
|
||||
$extraItem = array_pop( $extraItems );
|
||||
|
||||
$mergeList = array_filter( array_merge( array( $urlToThing ), $extraItem->getMergeData() ) );
|
||||
$listToDisplay = $mergeList;
|
||||
|
||||
if( \count( $mergeList ) > 3 )
|
||||
if( count( $mergeList ) > 3 )
|
||||
{
|
||||
$listToDisplay = \array_slice( $mergeList, 0, 3 );
|
||||
$listToDisplay[] = \IPS\Member::loggedIn()->language()->addToStack( 'x_others', FALSE, array( 'pluralize' => array( \count( $mergeList ) - 3 ) ) );
|
||||
$listToDisplay = array_slice( $mergeList, 0, 3 );
|
||||
$listToDisplay[] = Member::loggedIn()->language()->addToStack( 'x_others', FALSE, array( 'pluralize' => array( count( $mergeList ) - 3 ) ) );
|
||||
}
|
||||
|
||||
$extraItem->mergeInData( \IPS\Member::loggedIn()->language()->addToStack( 'activity_member_followed', FALSE, array( 'htmlsprintf' => array( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( \IPS\Member::load( $follow['follow_member_id'] ) ), \IPS\Member::loggedIn()->language()->formatList( $listToDisplay ) ) ) ), $urlToThing );
|
||||
$extraItem->mergeInData( Member::loggedIn()->language()->addToStack( 'activity_member_followed', FALSE, array( 'htmlsprintf' => array( Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( Member::load( $follow['follow_member_id'] ) ), Member::loggedIn()->language()->formatList( $listToDisplay ) ) ) ), $urlToThing );
|
||||
$extraItems[] = $extraItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
$extraItems[] = new Result\Custom(
|
||||
\IPS\DateTime::ts( $follow['follow_added'] ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_member_followed', FALSE, array( 'htmlsprintf' => array( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( \IPS\Member::load( $follow['follow_member_id'] ) ), $urlToThing ) ) ),
|
||||
DateTime::ts( $follow['follow_added'] ),
|
||||
Member::loggedIn()->language()->addToStack( 'activity_member_followed', FALSE, array( 'htmlsprintf' => array( Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( Member::load( $follow['follow_member_id'] ) ), $urlToThing ) ) ),
|
||||
NULL,
|
||||
$urlToThing
|
||||
);
|
||||
@@ -651,7 +670,7 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
|
||||
$lastClass = $class;
|
||||
$lastMember = $follow['follow_member_id'];
|
||||
@@ -660,7 +679,7 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
/* Likes */
|
||||
if ( \IPS\Settings::i()->reputation_enabled and \IPS\Member::loggedIn()->group['gbw_view_reps'] and ( \in_array( 'like', $extra ) or \in_array( 'react', $extra ) ) )
|
||||
if ( Settings::i()->reputation_enabled and Member::loggedIn()->group['gbw_view_reps'] and ( in_array( 'like', $extra ) or in_array( 'react', $extra ) ) )
|
||||
{
|
||||
$where = array( array( 'rep_date>?', $lastTime ) );
|
||||
$where[] = array( 'reaction_enabled=?', 1 );
|
||||
@@ -670,23 +689,23 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
/* get only the reputation data for installed applications */
|
||||
$where[] = \IPS\Db::i()->in( 'app', array_keys( \IPS\Application::applications() ) ) ;
|
||||
$where[] = Db::i()->in( 'app', array_keys( Application::applications() ) ) ;
|
||||
|
||||
if ( $author )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_reputation_index', array_merge( $where, array( array( 'member_id=?', $author->member_id ) ) ), 'rep_date DESC', 10 )->join( 'core_reactions', 'reaction=reaction_id' ) as $rep )
|
||||
foreach ( Db::i()->select( '*', 'core_reputation_index', array_merge( $where, array( array( 'member_id=?', $author->member_id ) ) ), 'rep_date DESC', 10 )->join( 'core_reactions', 'reaction=reaction_id' ) as $rep )
|
||||
{
|
||||
$this->addReputationExtraItem( $rep, $extraItems );
|
||||
}
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_reputation_index', array_merge( $where, array( array( 'member_received=?', $author->member_id ) ) ), 'rep_date DESC', 10 )->join( 'core_reactions', 'reaction=reaction_id' ) as $rep )
|
||||
foreach ( Db::i()->select( '*', 'core_reputation_index', array_merge( $where, array( array( 'member_received=?', $author->member_id ) ) ), 'rep_date DESC', 10 )->join( 'core_reactions', 'reaction=reaction_id' ) as $rep )
|
||||
{
|
||||
$this->addReputationExtraItem( $rep, $extraItems );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_reputation_index', $where, 'rep_date DESC', 10 )->join( 'core_reactions', 'reaction=reaction_id' ) as $rep )
|
||||
foreach ( Db::i()->select( '*', 'core_reputation_index', $where, 'rep_date DESC', 10 )->join( 'core_reactions', 'reaction=reaction_id' ) as $rep )
|
||||
{
|
||||
$this->addReputationExtraItem( $rep, $extraItems );
|
||||
}
|
||||
@@ -694,7 +713,7 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
/* Clubs */
|
||||
if ( \IPS\Settings::i()->clubs and \in_array( 'clubs', $extra ) )
|
||||
if ( Settings::i()->clubs and in_array( 'clubs', $extra ) )
|
||||
{
|
||||
$where = array( array( 'created>?', $lastTime ) );
|
||||
if ( $firstTime )
|
||||
@@ -706,24 +725,24 @@ class _Results extends \ArrayIterator
|
||||
$where[] = array( 'owner=?', $author->member_id );
|
||||
}
|
||||
|
||||
foreach ( \IPS\Member\Club::clubs( \IPS\Member::loggedIn(), NULL, 'created', FALSE, array(), $where ) as $club )
|
||||
foreach ( Club::clubs( Member::loggedIn(), NULL, 'created', FALSE, array(), $where ) as $club )
|
||||
{
|
||||
if ( $club->owner AND $club->owner->member_id )
|
||||
{
|
||||
$extraItems[] = new Result\Custom(
|
||||
$club->created,
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_club', FALSE, array( 'htmlsprintf' => array( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( $club->owner ), \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $club->url(), FALSE, $club->name, FALSE ) ) ) )
|
||||
Member::loggedIn()->language()->addToStack( 'activity_club', FALSE, array( 'htmlsprintf' => array( Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( $club->owner ), Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $club->url(), FALSE, $club->name, FALSE ) ) ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Extensions */
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'StreamItems', TRUE, 'core' ) as $key => $extension )
|
||||
foreach ( Application::allExtensions( 'core', 'StreamItems', TRUE, 'core' ) as $key => $extension )
|
||||
{
|
||||
$settingKey = "all_activity_" . mb_strtolower( $key );
|
||||
|
||||
if( method_exists( $extension, 'extraItems' ) and \IPS\Settings::i()->$settingKey )
|
||||
if( Settings::i()->$settingKey )
|
||||
{
|
||||
$extraItems = array_merge( $extraItems, $extension->extraItems( $author, $lastTime, $firstTime ) );
|
||||
}
|
||||
@@ -762,16 +781,16 @@ class _Results extends \ArrayIterator
|
||||
* @param array $extraItems Array of extra items (passed by reference)
|
||||
* @return void
|
||||
*/
|
||||
protected function addReputationExtraItem( $rep, &$extraItems )
|
||||
protected function addReputationExtraItem( array $rep, array &$extraItems ): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$thingBeingRepped = NULL;
|
||||
foreach ( \IPS\Application::load( $rep['app'] )->extensions( 'core', 'ContentRouter', TRUE, TRUE ) as $ext )
|
||||
foreach ( Application::load( $rep['app'] )->extensions( 'core', 'ContentRouter', TRUE, TRUE ) as $ext )
|
||||
{
|
||||
foreach ( $ext->classes as $class )
|
||||
{
|
||||
if ( \IPS\IPS::classUsesTrait( $class, 'IPS\Content\Reactable' ) and $class::reactionType() == $rep['type'] )
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\Reactable' ) and $class::reactionType() == $rep['type'] )
|
||||
{
|
||||
$thingBeingRepped = $class::loadAndCheckPerms( $rep['type_id'] );
|
||||
break;
|
||||
@@ -779,7 +798,7 @@ class _Results extends \ArrayIterator
|
||||
if ( isset( $class::$commentClass ) )
|
||||
{
|
||||
$commentClass = $class::$commentClass;
|
||||
if ( \IPS\IPS::classUsesTrait( $commentClass, 'IPS\Content\Reactable' ) and $commentClass::reactionType() == $rep['type'] )
|
||||
if ( IPS::classUsesTrait( $commentClass, 'IPS\Content\Reactable' ) and $commentClass::reactionType() == $rep['type'] )
|
||||
{
|
||||
$thingBeingRepped = $commentClass::loadAndCheckPerms( $rep['type_id'] );
|
||||
break;
|
||||
@@ -788,7 +807,7 @@ class _Results extends \ArrayIterator
|
||||
if ( isset( $class::$reviewClass ) )
|
||||
{
|
||||
$reviewClass = $class::$reviewClass;
|
||||
if ( \IPS\IPS::classUsesTrait( $reviewClass, 'IPS\Content\Reactable' ) and $reviewClass::reactionType() == $rep['type'] )
|
||||
if ( IPS::classUsesTrait( $reviewClass, 'IPS\Content\Reactable' ) and $reviewClass::reactionType() == $rep['type'] )
|
||||
{
|
||||
$thingBeingRepped = $reviewClass::loadAndCheckPerms( $rep['type_id'] );
|
||||
break;
|
||||
@@ -798,35 +817,35 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
if ( !$thingBeingRepped )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
if ( \IPS\Content\Reaction::isLikeMode() )
|
||||
if ( Reaction::isLikeMode() )
|
||||
{
|
||||
$extraItems[] = new Result\Custom(
|
||||
\IPS\DateTime::ts( $rep['rep_date'] ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_member_liked', FALSE, array( 'htmlsprintf' => array(
|
||||
\IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( \IPS\Member::load( $rep['member_id'] ) ),
|
||||
DateTime::ts( $rep['rep_date'] ),
|
||||
Member::loggedIn()->language()->addToStack( 'activity_member_liked', FALSE, array( 'htmlsprintf' => array(
|
||||
Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( Member::load( $rep['member_id'] ) ),
|
||||
$thingBeingRepped->indefiniteArticle(),
|
||||
\IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $thingBeingRepped->url(), FALSE, $thingBeingRepped instanceof \IPS\Content\Item ? $thingBeingRepped->mapped('title') : $thingBeingRepped->item()->mapped('title'), FALSE )
|
||||
Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $thingBeingRepped->url(), FALSE, $thingBeingRepped instanceof Item ? $thingBeingRepped->mapped('title') : $thingBeingRepped->item()->mapped('title'), FALSE )
|
||||
) ) )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$reaction = \IPS\Content\Reaction::load( $rep['reaction'] );
|
||||
$reaction = Reaction::load( $rep['reaction'] );
|
||||
$extraItems[] = new Result\Custom(
|
||||
\IPS\DateTime::ts( $rep['rep_date'] ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_member_reacted', FALSE, array( 'htmlsprintf' => array(
|
||||
(string) $reaction->_icon,
|
||||
DateTime::ts( $rep['rep_date'] ),
|
||||
Member::loggedIn()->language()->addToStack( 'activity_member_reacted', FALSE, array( 'htmlsprintf' => array(
|
||||
(string) $reaction->_icon->url,
|
||||
$reaction->_title,
|
||||
\IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( \IPS\Member::load( $rep['member_id'] ) ),
|
||||
Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( Member::load( $rep['member_id'] ) ),
|
||||
$thingBeingRepped->indefiniteArticle(),
|
||||
\IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $thingBeingRepped->url(), FALSE, $thingBeingRepped instanceof \IPS\Content\Item ? $thingBeingRepped->mapped('title') : $thingBeingRepped->item()->mapped('title'), FALSE )
|
||||
Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $thingBeingRepped->url(), FALSE, $thingBeingRepped instanceof Item ? $thingBeingRepped->mapped('title') : $thingBeingRepped->item()->mapped('title'), FALSE )
|
||||
) ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user