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,16 +11,25 @@
|
||||
namespace IPS\Content\Search;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use IPS\DateTime;
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
use IPS\Text\Parser;
|
||||
use function defined;
|
||||
use function preg_replace;
|
||||
|
||||
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
|
||||
*/
|
||||
abstract class _Result
|
||||
abstract class Result
|
||||
{
|
||||
/**
|
||||
* Pre-Display logic for search index content
|
||||
@@ -28,7 +37,7 @@ abstract class _Result
|
||||
* @param string $content The search result content
|
||||
* @return string
|
||||
*/
|
||||
public static function preDisplay( $content )
|
||||
public static function preDisplay( string $content ): string
|
||||
{
|
||||
/* We cannot use images (or *anything* other than text) in search results as it messes with the truncation
|
||||
logic. All HTML (including emoticons) are already stripped before they go into the search index
|
||||
@@ -36,23 +45,24 @@ abstract class _Result
|
||||
with one of the alternative Emoji style images though because that re-introduces images, so we
|
||||
just strip them out (making them behave like emoticons) */
|
||||
|
||||
if ( \IPS\Settings::i()->emoji_style == 'twemoji' )
|
||||
if ( Settings::i()->emoji_style == 'twemoji' )
|
||||
{
|
||||
$content = preg_replace( '/(?:' . \IPS\Text\Parser::EMOJI_REGEX . '|\x{200d})+/u', '', $content );
|
||||
$content = preg_replace( '/(?:' . Parser::getEmojiRegex() . '|\x{200d})+/u', '', $content );
|
||||
}
|
||||
|
||||
return $content;
|
||||
/* We need to strip the image labels as returned by the AI image scanner */
|
||||
return preg_replace('#<i\s+?l="([^<]+?)</i>#', '', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Created Date
|
||||
*/
|
||||
public $createdDate;
|
||||
public DateTime $createdDate;
|
||||
|
||||
/**
|
||||
* @brief Last Updated Date
|
||||
*/
|
||||
public $lastUpdatedDate;
|
||||
public DateTime $lastUpdatedDate;
|
||||
|
||||
/**
|
||||
* Separator for activity streams - "past hour", "today", etc.
|
||||
@@ -60,13 +70,13 @@ abstract class _Result
|
||||
* @param bool $createdDate If TRUE, uses $createdDate, otherwise uses $lastUpdatedDate
|
||||
* @return string
|
||||
*/
|
||||
public function streamSeparator( $createdDate=TRUE )
|
||||
public function streamSeparator( bool $createdDate=TRUE ): string
|
||||
{
|
||||
$date = $createdDate ? $this->createdDate : $this->lastUpdatedDate;
|
||||
|
||||
$now = \IPS\DateTime::ts( time() );
|
||||
$now = DateTime::ts( time() );
|
||||
$yesterday = clone $now;
|
||||
$yesterday = $yesterday->sub( new \DateInterval('P1D') );
|
||||
$yesterday = $yesterday->sub( new DateInterval('P1D') );
|
||||
$diff = $date->diff( $now );
|
||||
|
||||
if ( $date->format('Y-m-d') == $yesterday->format('Y-m-d') )
|
||||
@@ -94,7 +104,7 @@ abstract class _Result
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @param Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse string title Title of search result
|
||||
* @apiresponse string content Content of search result
|
||||
@@ -117,8 +127,9 @@ abstract class _Result
|
||||
* @apiresponse string authorPhotoThumbnail URL to author's profile photo thumbnail
|
||||
* @apiresponse array tags Array of tags associated with the search result
|
||||
*/
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
public function apiOutput( Member|null $authorizedMember = NULL ): array
|
||||
{
|
||||
/* @note This is only here to populate the AdminCP reference tab - the array of search result entries is built manually */
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user