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
@@ -11,46 +11,67 @@
|
||||
namespace IPS\Content\Search\Result;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Content\Comment;
|
||||
use IPS\Content\Search\Result;
|
||||
use IPS\Content\Search\SearchContent;
|
||||
use IPS\DateTime;
|
||||
use IPS\File;
|
||||
use IPS\Xml\Rss;
|
||||
use OutOfRangeException;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Result
|
||||
*/
|
||||
class _Content extends \IPS\Content\Search\Result
|
||||
class Content extends Result
|
||||
{
|
||||
/**
|
||||
* Index Data
|
||||
*/
|
||||
protected $indexData;
|
||||
protected array $indexData;
|
||||
|
||||
/**
|
||||
* Author Data
|
||||
*/
|
||||
protected $authorData;
|
||||
protected array $authorData;
|
||||
|
||||
/**
|
||||
* Item Data
|
||||
*/
|
||||
protected $itemData;
|
||||
protected array $itemData;
|
||||
|
||||
/**
|
||||
* Author Data
|
||||
*/
|
||||
protected $containerData;
|
||||
protected array|null $containerData;
|
||||
|
||||
/**
|
||||
* Reputation Data
|
||||
*/
|
||||
protected array|null $reputationData;
|
||||
|
||||
/**
|
||||
* Review Rating
|
||||
*/
|
||||
protected $reviewRating;
|
||||
protected int|null $reviewRating;
|
||||
|
||||
/**
|
||||
* If the user has posted in the item
|
||||
*/
|
||||
protected $iPostedIn;
|
||||
protected mixed $iPostedIn = array();
|
||||
|
||||
/**
|
||||
* Reactions
|
||||
*/
|
||||
protected array $reactions;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -65,10 +86,10 @@ class _Content extends \IPS\Content\Search\Result
|
||||
* @param array $reactions Reaction Data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( array $indexData, array $authorData, array $itemData, ?array $containerData, array $reputationData, $reviewRating = NULL, $iPostedIn = FALSE, $reactions=array() )
|
||||
public function __construct( array $indexData, array $authorData, array $itemData, array|null $containerData, array $reputationData, int|null $reviewRating = NULL, bool $iPostedIn = FALSE, array $reactions=array() )
|
||||
{
|
||||
$this->createdDate = \IPS\DateTime::ts( $indexData['index_date_created'] );
|
||||
$this->lastUpdatedDate = \IPS\DateTime::ts( $indexData['index_date_updated'] );
|
||||
$this->createdDate = DateTime::ts( $indexData['index_date_created'] );
|
||||
$this->lastUpdatedDate = DateTime::ts( $indexData['index_date_updated'] );
|
||||
$this->indexData = $indexData;
|
||||
$this->authorData = $authorData;
|
||||
$this->itemData = $itemData;
|
||||
@@ -88,10 +109,14 @@ class _Content extends \IPS\Content\Search\Result
|
||||
* @param array|NULL $template Optional custom template
|
||||
* @return string
|
||||
*/
|
||||
public function html( $view = 'expanded', $asItem = FALSE, $canIgnoreComments=FALSE, $template=NULL )
|
||||
public function html( string $view = 'expanded', bool $asItem = FALSE, bool $canIgnoreComments=FALSE, array|null $template=NULL ): string
|
||||
{
|
||||
$searchResultTemplate = array( $this->indexData['index_class'], 'searchResult' );
|
||||
return $searchResultTemplate( $this->indexData, $this->authorData, $this->itemData, $this->containerData, $this->reputationData, $this->reviewRating, $this->iPostedIn, $view, $asItem, $canIgnoreComments, $template, $this->reactions );
|
||||
if( $extension = SearchContent::extension( $this->indexData['index_class'] ) )
|
||||
{
|
||||
$searchResultTemplate = array( $extension, 'searchResult' );
|
||||
return $searchResultTemplate( $this->indexData, $this->authorData, $this->itemData, $this->containerData, $this->reputationData, $this->reviewRating, $this->iPostedIn, $view, $asItem, $canIgnoreComments, $template, $this->reactions );
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,8 +124,10 @@ class _Content extends \IPS\Content\Search\Result
|
||||
*
|
||||
* @return array( 'indexData' => array() ... )
|
||||
*/
|
||||
public function asArray()
|
||||
public function asArray(): array
|
||||
{
|
||||
$extension = SearchContent::extension( $this->indexData['index_class'] );
|
||||
|
||||
return array(
|
||||
'indexData' => $this->indexData,
|
||||
'authorData' => $this->authorData,
|
||||
@@ -108,17 +135,20 @@ class _Content extends \IPS\Content\Search\Result
|
||||
'containerData' => $this->containerData,
|
||||
'reputationData' => $this->reputationData,
|
||||
'reviewRating' => $this->reviewRating,
|
||||
'iPostedIn' => $this->iPostedIn
|
||||
'iPostedIn' => $this->iPostedIn,
|
||||
'template' => $extension ? $extension::searchResultBlock() : null,
|
||||
'url' => $extension ? $extension::urlFromIndexData( $this->indexData, $this->itemData ) : null,
|
||||
'searchResultClassName' => $extension ? $extension::$searchResultClassName : ''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to RSS feed
|
||||
*
|
||||
* @param \IPS\Xml\Rss $document Document to add to
|
||||
* @return string
|
||||
* @param Rss $document Document to add to
|
||||
* @return void
|
||||
*/
|
||||
public function addToRssFeed( \IPS\Xml\Rss $document )
|
||||
public function addToRssFeed( Rss $document ): void
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -133,14 +163,14 @@ class _Content extends \IPS\Content\Search\Result
|
||||
|
||||
try
|
||||
{
|
||||
$enclosure = \IPS\File::get( $key, $data[ $key ] );
|
||||
$enclosure = File::get( $key, $data[ $key ] );
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
catch( Exception ) { }
|
||||
}
|
||||
|
||||
$document->addItem( $object instanceof \IPS\Content\Comment ? $object->item()->searchIndexTitle() : $object->searchIndexTitle(), $object->url(), \IPS\Content\Search\Result::preDisplay( $this->indexData['index_content'] ), \IPS\DateTime::ts( $this->indexData['index_date_created'] ), NULL, $enclosure );
|
||||
$document->addItem( $object instanceof Comment ? $object->item()->mapped( 'title' ) : $object->mapped( 'title' ), $object->url(), Result::preDisplay( $this->indexData['index_content'] ), DateTime::ts( $this->indexData['index_date_created'] ), NULL, $enclosure );
|
||||
}
|
||||
/* If the search result was orphaned, let us continue */
|
||||
catch( \OutOfRangeException $e ){}
|
||||
catch( OutOfRangeException ){}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user