Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

+80 -13
View File
@@ -37,8 +37,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
{
if( static::$instance === NULL )
{
$classname = '\\IPS\\Content\\Search\\' . ucfirst( \IPS\Settings::i()->search_engine ) . '\\Index';
static::$instance = new $classname;
static::$instance = new \IPS\Content\Search\Mysql\Index;
}
return static::$instance;
@@ -64,7 +63,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
{
if( is_subclass_of( $class, 'IPS\Content\Searchable' ) )
{
\IPS\Task::queue( 'core', 'RebuildSearchIndex', array( 'class' => $class ) );
\IPS\Task::queue( 'core', 'RebuildSearchIndex', array( 'class' => $class ), 5, TRUE );
}
}
catch( \OutOfRangeException $ex ) {}
@@ -111,10 +110,37 @@ abstract class _Index extends \IPS\Patterns\Singleton
}
/* Get the last updated date */
$dateUpdated = ( $object instanceof \IPS\Content\Item ) ? $object->mapped('last_comment') : $object->mapped('edit_time');
if ( $isForItem )
{
$dateUpdated = $object->item()->mapped('last_comment');
}
else
{
$dateUpdated = ( $object instanceof \IPS\Content\Item ) ? $object->mapped('last_comment') : $object->mapped('edit_time');
}
/* Take the HTML out of the content */
$content = trim( strip_tags( preg_replace( "#<blockquote(.*?)>(.*)</blockquote>#ui", "", preg_replace( "#<script(.*?)>(.*)</script>#ui", "", ' ' . $object->mapped('content') . ' ' ) ) ) );
/* Is the the latest content? */
$isLastComment = 0;
if ( $object instanceof \IPS\Content\Comment )
{
$item = $object->item();
$latestThing = 0;
foreach ( array( 'updated', 'last_comment', 'last_review' ) as $k )
{
if ( isset( $item::$databaseColumnMap[ $k ] ) and ( $item->mapped( $k ) < time() AND $item->mapped( $k ) > $latestThing ) )
{
$latestThing = $item->mapped( $k );
}
}
if ( $object->mapped('date') >= $latestThing )
{
$isLastComment = 1;
}
}
/* Take the HTML out of the content */
$content = trim( strip_tags( preg_replace( "/(<br(?: \/)?>|<\/p>)/i", ' ', preg_replace( "#<blockquote(.*?)>(.*)</blockquote>#uis", "", preg_replace( "#<script(.*?)>(.*)</script>#uis", "", ' ' . $object->mapped('content') . ' ' ) ) ) ) );
/* Work out the hidden status */
$hiddenStatus = $object->hidden();
@@ -122,26 +148,47 @@ abstract class _Index extends \IPS\Patterns\Singleton
{
$hiddenStatus = $isForItem ? 1 : 2;
}
if ( $hiddenStatus !== 0 and method_exists( $object, 'item' ) and $object->item()->isFutureDate() )
{
$hiddenStatus = 0;
}
/* Get the item index ID */
$itemIndexId = NULL;
if ( $object instanceof \IPS\Content\Comment )
{
$itemClass = $object::$itemClass;
if ( $itemClass::$firstCommentRequired )
{
try
{
$itemIndexId = $this->getIndexId( $object::load( $object->item()->mapped('first_comment_id') ) );
}
catch ( \Exception $e ) { }
}
else
{
$itemIndexId = $this->getIndexId( $object->item() );
}
}
/* 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_id' => ( $object instanceof \IPS\Content\Item ) ? (int) $object->mapped('container') : (int) $object->item()->mapped('container'),
'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' => $object->mapped('date'),
'index_date_updated' => $dateUpdated ?: $object->mapped('date'),
'index_date_created' => intval( $object->mapped('date') ),
'index_date_updated' => intval( $dateUpdated ?: $object->mapped('date') ),
'index_author' => (int) $object->mapped('author'),
'index_tags' => $tags,
'index_hidden' => $hiddenStatus
'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_is_last_comment' => $isLastComment
);
}
@@ -153,6 +200,14 @@ abstract class _Index extends \IPS\Patterns\Singleton
*/
abstract public function index( \IPS\Content\Searchable $object );
/**
* Retrieve the search ID for an item
*
* @param \IPS\Content\Searchable $object Item to add
* @return void
*/
abstract public function getIndexId( \IPS\Content\Searchable $object );
/**
* Remove item
*
@@ -217,9 +272,21 @@ abstract class _Index extends \IPS\Patterns\Singleton
* @param string|NULL $newPermissions New permissions (if applicable)
* @param int|NULL $newHiddenStatus New hidden status (if applicable) special value 2 can be used to indicate hidden only by parent
* @param int|NULL $newContainer New container ID (if applicable)
* @param int|NULL $authorId The author ID to update, or NULL
* @param int|NULL $newItemId The new item ID (if applicable)
* @param int|NULL $$newItemAuthorId The new item author ID (if applicable)
* @return void
*/
abstract public function massUpdate( $class, $containerId = NULL, $itemId = NULL, $newPermissions = NULL, $newHiddenStatus = NULL, $newContainer = NULL );
abstract public function massUpdate( $class, $containerId = NULL, $itemId = NULL, $newPermissions = NULL, $newHiddenStatus = NULL, $newContainer = NULL, $authorId = NULL, $newItemId = NULL, $newItemAuthorId = NULL );
/**
* Update data for the first and last comment after a merge
* Sets index_is_last_comment on the last comment, and, if this is an item where the first comment is indexed rather than the item, sets index_title and index_tags on the first comment
*
* @param \IPS\Content\Item $item The item
* @return void
*/
abstract public function rebuildAfterMerge( \IPS\Content\Item $item );
/**
* Prune search index