Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -56,6 +56,11 @@ class _Results extends \ArrayIterator
|
||||
* @brief Reaction Data
|
||||
*/
|
||||
protected $reactions = array();
|
||||
|
||||
/**
|
||||
* @brief Attached Images
|
||||
*/
|
||||
protected $attachedImages = array();
|
||||
|
||||
/**
|
||||
* @brief Review Ratings
|
||||
@@ -100,7 +105,8 @@ class _Results extends \ArrayIterator
|
||||
$reviewRatings = array();
|
||||
$itemIndexIds = array();
|
||||
$indexIds = array();
|
||||
|
||||
$attachedImages = array();
|
||||
|
||||
/* Loop */
|
||||
foreach ( $this->getArrayCopy() as $result )
|
||||
{
|
||||
@@ -162,8 +168,10 @@ class _Results extends \ArrayIterator
|
||||
{
|
||||
$containersToLoad[ 'IPS\Member\Club' ][ $result['index_club_id'] ] = $result['index_club_id'];
|
||||
}
|
||||
|
||||
$attachedImages[ $result['index_class'] ][ $result['index_item_id'] ][] = $result['index_object_id'];
|
||||
}
|
||||
|
||||
|
||||
/* Load item data */
|
||||
foreach ( $itemsToLoad as $itemClass => $itemIds )
|
||||
{
|
||||
@@ -245,7 +253,47 @@ class _Results extends \ArrayIterator
|
||||
$this->tags = iterator_to_array( \IPS\Db::i()->select( 'index_id, GROUP_CONCAT(index_tag) 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') );
|
||||
}
|
||||
|
||||
|
||||
/* Load attached images */
|
||||
$clause = [];
|
||||
$binds = [];
|
||||
$locationKeyMap = [];
|
||||
foreach ( $attachedImages as $class => $ids )
|
||||
{
|
||||
$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 );
|
||||
$locationKeyMap[$locationKey] = $class;
|
||||
$clause[] = "( location_key=? AND id1=? AND id2=?)";
|
||||
$binds[] = $locationKey;
|
||||
$binds[] = $indexId;
|
||||
$binds[] = $commentId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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' )
|
||||
->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'] ) )
|
||||
{
|
||||
$this->attachedImages[ $locationKeyMap[ $row['location_key'] ] ][ $row['id2'] ][] = [
|
||||
'extension' => 'core_Attachment',
|
||||
'location' => $row['attach_location'],
|
||||
'thumb_location' => $row['attach_thumb_location'],
|
||||
'labels' => implode( ', ', \IPS\Text\Parser::getAttachmentLabels( $row ) )
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set that we're initiated */
|
||||
$this->initated = TRUE;
|
||||
}
|
||||
@@ -303,6 +351,11 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
}
|
||||
|
||||
if ( \is_array( $this->attachedImages ) and isset( $this->attachedImages[ $class ][ $data['index_object_id'] ] ) )
|
||||
{
|
||||
$itemData['attachedImages'] = $this->attachedImages[ $class ][ $data['index_object_id'] ];
|
||||
}
|
||||
|
||||
if ( isset( $this->tags[ $data['index_item_index_id'] ] ) )
|
||||
{
|
||||
$data['index_tags'] = $this->tags[ $data['index_item_index_id'] ]['index_tags'];
|
||||
|
||||
Reference in new issue
Block a user