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;
|
||||
@@ -112,17 +112,30 @@ abstract class _Index extends \IPS\Patterns\Singleton
|
||||
*/
|
||||
public function indexSingleItem( \IPS\Content\Searchable $object )
|
||||
{
|
||||
/* It is possible for some items to not have a valid URL */
|
||||
try
|
||||
{
|
||||
if( !$url = (string) $object->url() )
|
||||
{
|
||||
throw new \LogicException;
|
||||
}
|
||||
}
|
||||
catch( \LogicException $e )
|
||||
{
|
||||
$url = '';
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$idColumn = $object::$databaseColumnId;
|
||||
if ( isset( $object::$commentClass ) AND is_subclass_of( $object::$commentClass, 'IPS\Content\Searchable' ) )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'IndexSingleItem', array( 'class' => $object::$commentClass, 'id' => $object->$idColumn, 'title' => $object->mapped('title'), 'url' => (string) $object->url() ), 5, TRUE );
|
||||
\IPS\Task::queue( 'core', 'IndexSingleItem', array( 'class' => $object::$commentClass, 'id' => $object->$idColumn, 'title' => $object->mapped('title'), 'url' => $url ), 5, TRUE );
|
||||
}
|
||||
|
||||
if ( isset( $object::$reviewClass ) AND is_subclass_of( $object::$reviewClass, 'IPS\Content\Searchable' ) )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'IndexSingleItem', array( 'class' => $object::$reviewClass, 'id' => $object->$idColumn, 'title' => $object->mapped('title'), 'url' => (string) $object->url() ), 5, TRUE );
|
||||
\IPS\Task::queue( 'core', 'IndexSingleItem', array( 'class' => $object::$reviewClass, 'id' => $object->$idColumn, 'title' => $object->mapped('title'), 'url' => $url ), 5, TRUE );
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e ) {}
|
||||
@@ -137,7 +150,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
|
||||
public function indexData( \IPS\Content\Searchable $object )
|
||||
{
|
||||
/* Init */
|
||||
$class = get_class( $object );
|
||||
$class = \get_class( $object );
|
||||
$idColumn = $class::$databaseColumnId;
|
||||
$tags = ( $object instanceof \IPS\Content\Tags and \IPS\Settings::i()->tags_enabled ) ? implode( ',', array_filter( $object->tags() ) ) : NULL;
|
||||
$prefix = ( $object instanceof \IPS\Content\Tags and \IPS\Settings::i()->tags_enabled ) ? $object->prefix() : NULL;
|
||||
@@ -277,7 +290,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
|
||||
}
|
||||
|
||||
/* Take the HTML out of the content */
|
||||
$content = trim( str_replace( chr(0xC2) . chr(0xA0), ' ', strip_tags( preg_replace( "/(<br(?: \/)?>|<\/p>)/i", ' ', preg_replace( "#<blockquote(?:[^>]+?)>.+?(?<!<blockquote)</blockquote>#s", " ", preg_replace( "#<script(.*?)>(.*)</script>#uis", "", ' ' . $content . ' ' ) ) ) ) ) );
|
||||
$content = trim( str_replace( \chr(0xC2) . \chr(0xA0), ' ', strip_tags( preg_replace( "/(<br(?: \/)?>|<\/p>)/i", ' ', preg_replace( "#<blockquote(?:[^>]+?)>.+?(?<!<blockquote)</blockquote>#s", " ", preg_replace( "#<script(.*?)>(.*)</script>#uis", "", ' ' . $content . ' ' ) ) ) ) ) );
|
||||
|
||||
/* Work out the hidden status */
|
||||
$hiddenStatus = $object->hidden();
|
||||
@@ -289,6 +302,10 @@ abstract class _Index extends \IPS\Patterns\Singleton
|
||||
{
|
||||
$hiddenStatus = 0;
|
||||
}
|
||||
if ( $hiddenStatus === -3 )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Get the item index ID */
|
||||
$itemIndexId = NULL;
|
||||
@@ -363,25 +380,35 @@ abstract class _Index extends \IPS\Patterns\Singleton
|
||||
$clubId = $container->{$container::clubIdColumn()};
|
||||
}
|
||||
|
||||
/* Work out the container class */
|
||||
if( $object instanceof \IPS\Content\Item )
|
||||
{
|
||||
$containerClass = ( $object->searchIndexContainerClass() ) ? \get_class( $object->searchIndexContainerClass() ) : NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$containerClass = ( $object->item()->searchIndexContainerClass() ) ? \get_class( $object->item()->searchIndexContainerClass() ) : NULL;
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return array(
|
||||
'index_class' => $class,
|
||||
'index_object_id' => $object->$idColumn,
|
||||
'index_item_id' => ( $object instanceof \IPS\Content\Item ) ? $object->$idColumn : $object->mapped('item'),
|
||||
'index_container_class' => ( $object instanceof \IPS\Content\Item ) ? ( $object->searchIndexContainerClass() ? get_class( $object->searchIndexContainerClass() ) : NULL ) : get_class( $object->item()->searchIndexContainerClass() ),
|
||||
'index_container_class' => $containerClass,
|
||||
'index_container_id' => ( $object instanceof \IPS\Content\Item ) ? (int) $object->searchIndexContainer() : (int) $object->item()->mapped('container'),
|
||||
'index_title' => $title,
|
||||
'index_content' => $content,
|
||||
'index_permissions' => $object->searchIndexPermissions(),
|
||||
'index_date_created' => intval( $object->mapped('date') ),
|
||||
'index_date_updated' => intval( $dateUpdated ),
|
||||
'index_date_commented' => intval( $dateCommented ),
|
||||
'index_date_created' => \intval( $object->mapped('date') ),
|
||||
'index_date_updated' => \intval( $dateUpdated ),
|
||||
'index_date_commented' => \intval( $dateCommented ),
|
||||
'index_author' => (int) $object->mapped('author'),
|
||||
'index_tags' => $tags,
|
||||
'index_prefix' => $prefix,
|
||||
'index_hidden' => $hiddenStatus,
|
||||
'index_item_index_id' => $itemIndexId,
|
||||
'index_item_author' => intval( ( $object instanceof \IPS\Content\Item ) ? $object->mapped('author') : $object->item()->mapped('author') ),
|
||||
'index_item_author' => \intval( ( $object instanceof \IPS\Content\Item ) ? $object->mapped('author') : $object->item()->mapped('author') ),
|
||||
'index_is_last_comment' => $isLastComment,
|
||||
'index_club_id' => $clubId,
|
||||
'index_class_type_id_hash' => md5( $class . ':' . $object->$idColumn )
|
||||
@@ -397,19 +424,6 @@ abstract class _Index extends \IPS\Patterns\Singleton
|
||||
*/
|
||||
abstract public function index( \IPS\Content\Searchable $object );
|
||||
|
||||
/**
|
||||
* Update view count
|
||||
*
|
||||
* @param string $class Class to update
|
||||
* @param int $id ID of item
|
||||
* @param int $count Count to update
|
||||
* @throws \OutOfRangeException When table to update no longer exists
|
||||
*/
|
||||
public function updateViewCounts( $class, $id, $count )
|
||||
{
|
||||
// Do nothing by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear out any tasks associated with the search index method
|
||||
*
|
||||
@@ -523,9 +537,10 @@ abstract class _Index extends \IPS\Patterns\Singleton
|
||||
*
|
||||
* @param string $class The class
|
||||
* @param int|NULL $indexItemId The index item ID
|
||||
* @param int|NULL $ignoreId ID to ignore because it is being removed
|
||||
* @return void
|
||||
*/
|
||||
abstract public function resetLastComment( $class, $indexItemId );
|
||||
abstract public function resetLastComment( $class, $indexItemId, $ignoreId = NULL );
|
||||
|
||||
/**
|
||||
* Given a list of item index IDs, return the ones that a given member has participated in
|
||||
@@ -539,11 +554,12 @@ abstract class _Index extends \IPS\Patterns\Singleton
|
||||
/**
|
||||
* Given a list of "index_class_type_id_hash"s, return the ones that a given member has permission to view
|
||||
*
|
||||
* @param array $itemIndexIds Item index IDs
|
||||
* @param \IPS\Member $member The member
|
||||
* @param array $hashes Hashes
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|NULL $limit Number of results to return
|
||||
* @return array
|
||||
*/
|
||||
abstract public function hashesWithPermission( array $hashes, \IPS\Member $member );
|
||||
abstract public function hashesWithPermission( array $hashes, \IPS\Member $member, $limit = NULL );
|
||||
|
||||
/**
|
||||
* Get timestamp of oldest thing in index
|
||||
@@ -562,4 +578,14 @@ abstract class _Index extends \IPS\Patterns\Singleton
|
||||
{
|
||||
return $terms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports filtering by views?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function supportViewFiltering()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user