Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Content\Search;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -30,7 +30,7 @@ class _ApiResponse extends \IPS\Api\PaginatedResponse
|
||||
public function getOutput()
|
||||
{
|
||||
/* Get the query object from the stored select */
|
||||
$queryObject = $this->select[0];
|
||||
$queryObject = $this->iterator[0];
|
||||
|
||||
/* Set pagination */
|
||||
$queryObject->setLimit( $this->resultsPerPage );
|
||||
@@ -38,20 +38,44 @@ class _ApiResponse extends \IPS\Api\PaginatedResponse
|
||||
|
||||
/* Run query */
|
||||
$searchResults = $queryObject->search(
|
||||
$this->select[2],
|
||||
$this->select[3],
|
||||
$this->select[1] + \IPS\Content\Search\Query::TAGS_MATCH_ITEMS_ONLY,
|
||||
$this->select[4]
|
||||
$this->iterator[2],
|
||||
$this->iterator[3],
|
||||
$this->iterator[1] + \IPS\Content\Search\Query::TAGS_MATCH_ITEMS_ONLY,
|
||||
$this->iterator[4]
|
||||
);
|
||||
|
||||
$this->count = $searchResults->count( TRUE );
|
||||
|
||||
/* Search tracking, only if there's a term for a non-member search and we're on the first page */
|
||||
if( \IPS\Request::i()->q AND $this->page == 1 AND ( !isset( \IPS\Request::i()->doNotTrack ) OR \IPS\Request::i()->doNotTrack != 1 ) )
|
||||
{
|
||||
$memberPermissions = $this->authorizedMember;
|
||||
|
||||
if( !$this->authorizedMember AND isset( \IPS\Request::i()->search_as ) )
|
||||
{
|
||||
$memberPermissions = \IPS\Member::load( \IPS\Request::i()->search_as );
|
||||
|
||||
if( !$memberPermissions->member_id )
|
||||
{
|
||||
$memberPermissions = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'core_statistics', array(
|
||||
'type' => 'search',
|
||||
'time' => time(),
|
||||
'value_4' => \IPS\Request::i()->q,
|
||||
'value_2' => $this->count,
|
||||
'extra_data' => $memberPermissions ? md5( $memberPermissions->email . $memberPermissions->joined ) : md5( 'rest-api' ) // Intentionally anonymized
|
||||
) );
|
||||
}
|
||||
|
||||
$results = array();
|
||||
foreach ( $searchResults as $result )
|
||||
{
|
||||
$resultData = $result->asArray();
|
||||
$indexClass = $resultData['indexData']['index_class'];
|
||||
$itemClass = ( in_array( 'IPS\Content\Comment', class_parents( $indexClass ) ) ) ? $indexClass::$itemClass : $indexClass;
|
||||
$itemClass = ( \in_array( 'IPS\Content\Comment', class_parents( $indexClass ) ) ) ? $indexClass::$itemClass : $indexClass;
|
||||
|
||||
/* Container details */
|
||||
$containerUrl = NULL;
|
||||
@@ -78,7 +102,7 @@ class _ApiResponse extends \IPS\Api\PaginatedResponse
|
||||
}
|
||||
else
|
||||
{
|
||||
$repCount = count( $resultData['reputationData'] );
|
||||
$repCount = \count( $resultData['reputationData'] );
|
||||
}
|
||||
|
||||
$commentCount = NULL;
|
||||
@@ -99,9 +123,9 @@ class _ApiResponse extends \IPS\Api\PaginatedResponse
|
||||
{
|
||||
$reviewCount = $resultData['itemData'][ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_reviews'] ];
|
||||
}
|
||||
|
||||
|
||||
$results[] = array(
|
||||
'title' => $resultData['itemData'][ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['title'] ],
|
||||
'title' => ( isset( $itemClass::$databaseColumnMap['title'] ) and isset( $resultData['itemData'][ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['title'] ] ) ) ? $resultData['itemData'][ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['title'] ] : $resultData['indexData']['index_title'],
|
||||
'content' => $resultData['indexData']['index_content'],
|
||||
'class' => $indexClass,
|
||||
'objectId' => $resultData['indexData']['index_object_id'],
|
||||
|
||||
Reference in new issue
Block a user