Version 4.7.0

This commit is contained in:
Neo committed 2025-12-19 16:00:35 -08:00
1 parent 517a5e1f70
commit 8ba7d43898
1933 files changed
+65613 -11332

No files matched your search

@@ -27,6 +27,17 @@ class _search extends \IPS\Dispatcher\Controller
*/
protected $_cacheTimeout = 30 * 60;
/**
* @brief These properties are used to specify datalayer context properties.
*
* @example array(
'community_area' => array( 'value' => 'search', 'odkUpdate' => 'true' )
)
*/
public static $dataLayerContext = array(
'community_area' => array( 'value' => 'search', 'odkUpdate' => 'true' )
);
/**
* Check if this was a cached result we should just return a 304 against
*
@@ -80,7 +91,7 @@ class _search extends \IPS\Dispatcher\Controller
$form = $this->_form();
/* If we have the term, show the results */
if ( \IPS\Request::i()->isAjax() or isset( \IPS\Request::i()->q ) or isset( \IPS\Request::i()->tags ) or ( \IPS\Request::i()->type == 'core_members' and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members', 'front' ) ) ) )
if ( ( \IPS\Request::i()->isAjax() and ! isset( \IPS\Request::i()->_nodeSelectName ) ) or isset( \IPS\Request::i()->q ) or isset( \IPS\Request::i()->tags ) or ( \IPS\Request::i()->type == 'core_members' and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members', 'front' ) ) ) )
{
$showForm = ( \IPS\Request::i()->type == 'core_members' ) ? FALSE : ( !\IPS\Request::i()->isAjax() and !\IPS\Request::i()->q and !\IPS\Request::i()->tags );
@@ -105,6 +116,12 @@ class _search extends \IPS\Dispatcher\Controller
}
return;
}
/* Data Layer Event */
if ( \IPS\Settings::i()->core_datalayer_enabled AND !\IPS\Request::i()->isAjax() AND \IPS\Request::i()->q )
{
\IPS\core\DataLayer::i()->addEvent( 'search', array( 'query' => \IPS\Request::i()->q, ) );
}
return $this->_results();
}
@@ -153,7 +170,12 @@ class _search extends \IPS\Dispatcher\Controller
{
$baseUrl = $baseUrl->setQueryString( 'eitherTermsOrTags', \IPS\Request::i()->eitherTermsOrTags );
}
if( isset( \IPS\Request::i()->quick ) )
{
$baseUrl = $baseUrl->setQueryString( 'quick', \IPS\Request::i()->quick );
}
$types = static::contentTypes();
/* Flood control */
@@ -178,7 +200,8 @@ class _search extends \IPS\Dispatcher\Controller
\IPS\Request::i()->start_after = \IPS\Request::i()->joinedDate;
}
if ( isset( \IPS\Request::i()->start_before ) or isset( \IPS\Request::i()->start_after ) )
if ( ( isset( \IPS\Request::i()->start_before ) ) or ( isset( \IPS\Request::i()->start_after ) ) )
{
foreach ( array( 'before', 'after' ) as $l )
{
@@ -428,7 +451,7 @@ class _search extends \IPS\Dispatcher\Controller
$filter = \IPS\Content\Search\ContentFilter::init( $types[ \IPS\Request::i()->type ] );
$baseUrl = $baseUrl->setQueryString( 'type', \IPS\Request::i()->type );
if ( isset( \IPS\Request::i()->nodes ) )
if ( isset( \IPS\Request::i()->nodes ) and isset( $types[ \IPS\Request::i()->type ]::$containerNodeClass ) )
{
/* It's ok to just pass the (potential) parent IDs into the URL */
$baseUrl = $baseUrl->setQueryString( 'nodes', \IPS\Request::i()->nodes );
@@ -748,24 +771,27 @@ class _search extends \IPS\Dispatcher\Controller
/* 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 $page == 1 )
{
try
if( !\IPS\Member::loggedIn()->inGroup( json_decode( \IPS\Settings::i()->searchlog_exclude_groups ) ) )
{
\IPS\Db::i()->insert( 'core_statistics', array(
'type' => 'search',
'time' => time(),
'value_4' => mb_substr( \IPS\Request::i()->q, 0, 255 ), // Some search queries can be unnecessarily long
'value_2' => $count,
'extra_data' => md5( \IPS\Member::loggedIn()->email . \IPS\Member::loggedIn()->joined ) // Intentionally anonymized
) );
try
{
\IPS\Db::i()->insert( 'core_statistics', array(
'type' => 'search',
'time' => time(),
'value_4' => mb_substr( \IPS\Request::i()->q, 0, 255 ), // Some search queries can be unnecessarily long
'value_2' => $count,
'extra_data' => md5( \IPS\Member::loggedIn()->email . \IPS\Member::loggedIn()->joined ) // Intentionally anonymized
) );
}
catch( \IPS\Db\Exception $e ) {}
}
catch( \IPS\Db\Exception $e ) {}
}
/* Enable caching for the search results request */
if ( !\IPS\Member::loggedIn()->member_id )
{
$httpHeaders = array( 'Expires' => \IPS\DateTime::create()->add( new \DateInterval( 'PT3M' ) )->rfc1123(),
'Cache-Control' => "max-age=" . $this->_cacheTimeout . ", s-maxage=" . $this->_cacheTimeout . ", public, stale-if-error, stale-while-revalidate" );
'Cache-Control' => 'no-cache="Set-Cookie", max-age=' . $this->_cacheTimeout . ", s-maxage=" . $this->_cacheTimeout . ", public, stale-if-error, stale-while-revalidate" );
\IPS\Output::i()->httpHeaders += $httpHeaders;
}
@@ -813,6 +839,16 @@ class _search extends \IPS\Dispatcher\Controller
{
$form->hiddenValues['sortdirection'] = \IPS\Request::i()->sortdirection;
}
if ( isset( \IPS\Request::i()->nodes ) )
{
$form->hiddenValues['nodes'] = \IPS\Request::i()->nodes;
}
if ( isset( \IPS\Request::i()->quick ) )
{
$form->hiddenValues['quick'] = \IPS\Request::i()->quick;
}
/* If we do a quick search the type is set to 'all' but we want it as '' for the form to work properly */
if( isset( \IPS\Request::i()->type ) AND \IPS\Request::i()->type === 'all' )