Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -32,29 +32,28 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/* Init stuff for the output */
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/streams.css' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/search.css' ) );
|
||||
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/search_responsive.css' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_search.js', 'core' ) );
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex'; // Tell search engines not to index search pages
|
||||
|
||||
/* Get the form */
|
||||
$baseUrl = \IPS\Http\Url::internal( 'app=core&module=search&controller=search', 'front', 'search' );
|
||||
$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' ) )
|
||||
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 !\IPS\Request::i()->q and !\IPS\Request::i()->tags and \IPS\Request::i()->type !== 'core_members' )
|
||||
if ( !\IPS\Request::i()->isAjax() and !\IPS\Request::i()->q and !\IPS\Request::i()->tags and \IPS\Request::i()->type !== 'core_members' and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members', 'front' ) ) )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->csrfKey ) )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('no_search_term');
|
||||
$form->hiddenValues['__advanced'] = true;
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'advanced_search' );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'advancedSearchForm' ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( $this->_splitTermsForDisplay(), FALSE, FALSE, FALSE, $baseUrl, FALSE, $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, NULL ), 0, TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -68,8 +67,10 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
/* Otherwise, show the advanced search form */
|
||||
else
|
||||
{
|
||||
$form->hiddenValues['__advanced'] = true;
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'advanced_search' );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'advancedSearchForm' ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( $this->_splitTermsForDisplay(), FALSE, FALSE, FALSE, $baseUrl, FALSE, $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, NULL ), 0, TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +87,10 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'q', \IPS\Request::i()->q );
|
||||
}
|
||||
elseif ( \IPS\Request::i()->tags )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'tags', \IPS\Request::i()->tags );
|
||||
}
|
||||
|
||||
$types = $this->_contentTypes();
|
||||
|
||||
@@ -93,7 +98,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
\IPS\Request::floodCheck();
|
||||
|
||||
/* Are we searching members? */
|
||||
if ( isset( \IPS\Request::i()->type ) and \IPS\Request::i()->type === 'core_members' )
|
||||
if ( isset( \IPS\Request::i()->type ) and \IPS\Request::i()->type === 'core_members' and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members', 'front' ) ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', \IPS\Request::i()->type );
|
||||
if ( \IPS\Request::i()->q )
|
||||
@@ -111,7 +116,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$$l = NULL;
|
||||
$key = "start_{$l}";
|
||||
if ( isset( \IPS\Request::i()->$key ) )
|
||||
if ( isset( \IPS\Request::i()->$key ) AND \IPS\Request::i()->$key != 'any' )
|
||||
{
|
||||
switch ( \IPS\Request::i()->$key )
|
||||
{
|
||||
@@ -252,8 +257,8 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array(
|
||||
'filters' => $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ) ),
|
||||
'content' => \IPS\Theme::i()->getTemplate( 'search' )->results( \IPS\Request::i()->q, $title, $results, $pagination, $baseUrl, $count ),
|
||||
'filters' => $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, $count ),
|
||||
'content' => \IPS\Theme::i()->getTemplate( 'search' )->results( $this->_splitTermsForDisplay(), $title, $results, $pagination, $baseUrl, $count ),
|
||||
'title' => $title,
|
||||
'css' => array()
|
||||
) );
|
||||
@@ -261,63 +266,16 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = $title;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( \IPS\Request::i()->q, $title, $results, $pagination, $baseUrl, $types, $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ) ), $count );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( $this->_splitTermsForDisplay(), $title, $results, $pagination, $baseUrl, $types, $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, $count ), $count );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Init */
|
||||
$query = \IPS\Content\Search\Query::init();
|
||||
|
||||
/* Work out the title */
|
||||
if ( \IPS\Request::i()->tags and !\IPS\Request::i()->q )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'tags', \IPS\Request::i()->tags );
|
||||
$tagList = array_map( function( $val )
|
||||
{
|
||||
return '\'' . htmlentities( $val, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '\'';
|
||||
}, explode( ',', \IPS\Request::i()->tags ) );
|
||||
$term = \IPS\Member::loggedIn()->language()->formatList( $tagList, \IPS\Member::loggedIn()->language()->get('or_list_format') );
|
||||
|
||||
$titleKey = 'search_results_title_tag';
|
||||
}
|
||||
else
|
||||
{
|
||||
$term = urldecode( \IPS\Request::i()->q );
|
||||
$titleKey = 'search_results_title_term';
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->type ) and array_key_exists( \IPS\Request::i()->type, $types ) )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $titleKey . '_area', FALSE, array( 'sprintf' => array( $term, \IPS\Member::loggedIn()->language()->addToStack( \IPS\Request::i()->type . '_pl' ) ) ) );
|
||||
|
||||
if ( isset( \IPS\Request::i()->item ) )
|
||||
{
|
||||
$class = $types[ \IPS\Request::i()->type ];
|
||||
try
|
||||
{
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->item );
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $titleKey . '_area', FALSE, array( 'sprintf' => array( $term, $item->mapped('title') ) ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->nodes ) and mb_strstr( \IPS\Request::i()->nodes, ',' ) === FALSE )
|
||||
{
|
||||
$class = $types[ \IPS\Request::i()->type ];
|
||||
$nodeClass = $class::$containerNodeClass;
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::loadAndCheckPerms( \IPS\Request::i()->nodes );
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $titleKey . '_area', FALSE, array( 'sprintf' => array( $term, $node->_title ) ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $titleKey, FALSE, array( 'sprintf' => array( $term ) ) );
|
||||
}
|
||||
|
||||
$titleConditions = array();
|
||||
$titleType = 'search_blurb_all_content';
|
||||
|
||||
/* Set content type */
|
||||
if ( isset( \IPS\Request::i()->type ) and array_key_exists( \IPS\Request::i()->type, $types ) )
|
||||
{
|
||||
@@ -326,41 +284,58 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$class = $types[ \IPS\Request::i()->type ];
|
||||
try
|
||||
{
|
||||
$query->filterByItem( $class::load( \IPS\Request::i()->item ) );
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->item );
|
||||
$query->filterByContent( array( \IPS\Content\Search\ContentFilter::init( $class )->onlyInItems( array( \IPS\Request::i()->item ) ) ) );
|
||||
$baseUrl = $baseUrl->setQueryString( 'item', intval( \IPS\Request::i()->item ) );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_in', FALSE, array( 'sprintf' => array( $item->mapped('title') ) ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
else
|
||||
{
|
||||
$nodes = NULL;
|
||||
$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 ) )
|
||||
{
|
||||
$nodes = explode( ',', \IPS\Request::i()->nodes );
|
||||
$nodeClass = $types[ \IPS\Request::i()->type ]::$containerNodeClass;
|
||||
$node = $nodeClass::loadAndCheckPerms( \IPS\Request::i()->nodes );
|
||||
$filter->onlyInContainers( explode( ',', \IPS\Request::i()->nodes ) );
|
||||
$baseUrl = $baseUrl->setQueryString( 'nodes', \IPS\Request::i()->nodes );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_in', FALSE, array( 'sprintf' => array( $node->_title ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$titleType = $types[ \IPS\Request::i()->type ]::$title . '_pl_lc';
|
||||
}
|
||||
|
||||
$query->filterByContent( $types[ \IPS\Request::i()->type ], $nodes, isset( \IPS\Request::i()->comments ) ? \IPS\Request::i()->comments : ( isset( \IPS\Request::i()->replies ) ? ( \IPS\Request::i()->replies + 1 ) : NULL ), isset( \IPS\Request::i()->reviews ) ? \IPS\Request::i()->reviews : NULL, isset( \IPS\Request::i()->views ) ? \IPS\Request::i()->views : NULL );
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', \IPS\Request::i()->type );
|
||||
if ( $nodes )
|
||||
if ( isset( \IPS\Request::i()->search_min_comments ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'nodes', \IPS\Request::i()->nodes );
|
||||
$filter->minimumComments( \IPS\Request::i()->search_min_comments );
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_min_comments', \IPS\Request::i()->search_min_comments );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_min_comments', FALSE, array( 'sprintf' => array( \IPS\Request::i()->search_min_comments ) ) );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->comments ) )
|
||||
if ( isset( \IPS\Request::i()->search_min_replies ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'comments', \IPS\Request::i()->comments );
|
||||
$filter->minimumComments( \IPS\Request::i()->search_min_replies + 1 );
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_min_replies', \IPS\Request::i()->search_min_replies );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_min_replies', FALSE, array( 'sprintf' => array( \IPS\Request::i()->search_min_replies ) ) );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->replies ) )
|
||||
if ( isset( \IPS\Request::i()->search_min_reviews ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'replies', \IPS\Request::i()->replies );
|
||||
$filter->minimumReviews( \IPS\Request::i()->search_min_reviews );
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_min_reviews', \IPS\Request::i()->search_min_reviews );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_min_reviews', FALSE, array( 'sprintf' => array( \IPS\Request::i()->search_min_reviews ) ) );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->reviews ) )
|
||||
if ( isset( \IPS\Request::i()->search_min_views ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'reviews', \IPS\Request::i()->reviews );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->views ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'views', \IPS\Request::i()->views );
|
||||
$filter->minimumViews( \IPS\Request::i()->search_min_views );
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_min_views', \IPS\Request::i()->search_min_views );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_min_views', FALSE, array( 'sprintf' => array( \IPS\Request::i()->search_min_views ) ) );
|
||||
}
|
||||
|
||||
$query->filterByContent( array( $filter ) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,6 +347,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$query->filterByAuthor( $author );
|
||||
$baseUrl = $baseUrl->setQueryString( 'author', $author->name );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_author', FALSE, array( 'sprintf' => array( $author->name ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,28 +368,36 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
case 'day':
|
||||
$$l = \IPS\DateTime::create()->sub( new \DateInterval( 'P1D' ) );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_rel_{$l}", FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_date_rel_day' ) ) ) );
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$$l = \IPS\DateTime::create()->sub( new \DateInterval( 'P1W' ) );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_rel_{$l}", FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_date_rel_week' ) ) ) );
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$$l = \IPS\DateTime::create()->sub( new \DateInterval( 'P1M' ) );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_rel_{$l}", FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_date_rel_month' ) ) ) );
|
||||
break;
|
||||
|
||||
case 'six_months':
|
||||
$$l = \IPS\DateTime::create()->sub( new \DateInterval( 'P6M' ) );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_rel_{$l}", FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_date_rel_6months' ) ) ) );
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$$l = \IPS\DateTime::create()->sub( new \DateInterval( 'P1Y' ) );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_rel_{$l}", FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_date_rel_year' ) ) ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
$$l = \IPS\DateTime::ts( \IPS\Request::i()->$$key );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_{$l}", FALSE, array( 'sprintf' => array( $$l->localeDate() ) ) );
|
||||
break;
|
||||
}
|
||||
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_{$k}", FALSE, array( 'sprintf' => array( $dateCondition ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,6 +405,51 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/* Work out the title */
|
||||
if ( \IPS\Request::i()->tags )
|
||||
{
|
||||
$tagList = array_map( function( $val )
|
||||
{
|
||||
return '\'' . htmlentities( $val, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '\'';
|
||||
}, explode( ',', \IPS\Request::i()->tags ) );
|
||||
}
|
||||
$title = '';
|
||||
if ( \IPS\Request::i()->q )
|
||||
{
|
||||
if ( \IPS\Request::i()->tags )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->eitherTermsOrTags ) and \IPS\Request::i()->eitherTermsOrTags === 'and' )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_term', FALSE, array( 'sprintf' => array( urldecode( \IPS\Request::i()->q ) ) ) );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_tag_condition', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $tagList, \IPS\Member::loggedIn()->language()->get('or_list_format') ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_term_or_tag', FALSE, array( 'sprintf' => array( urldecode( \IPS\Request::i()->q ), \IPS\Member::loggedIn()->language()->formatList( $tagList, \IPS\Member::loggedIn()->language()->get('or_list_format') ) ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_term', FALSE, array( 'sprintf' => array( urldecode( \IPS\Request::i()->q ) ) ) );
|
||||
}
|
||||
}
|
||||
elseif ( \IPS\Request::i()->tags )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_tag', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $tagList, \IPS\Member::loggedIn()->language()->get('or_list_format') ) ) ) );
|
||||
}
|
||||
if ( count( $titleConditions ) )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_conditions', FALSE, array( 'sprintf' => array( $title, \IPS\Member::loggedIn()->language()->addToStack( $titleType ), \IPS\Member::loggedIn()->language()->formatList( $titleConditions ) ) ) );
|
||||
}
|
||||
elseif ( $titleType != 'search_blurb_all_content' )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_with_type', FALSE, array( 'sprintf' => array( $title, \IPS\Member::loggedIn()->language()->addToStack( $titleType ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_no_conditions', FALSE, array( 'sprintf' => array( $title ) ) );
|
||||
}
|
||||
|
||||
/* Set page */
|
||||
if ( isset( \IPS\Request::i()->page ) AND intval( \IPS\Request::i()->page ) > 0 )
|
||||
{
|
||||
@@ -446,15 +475,30 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_CREATED );
|
||||
$baseUrl = $baseUrl->setQueryString( 'sortby', 'newest' );
|
||||
/* Default to relevancy which is a total score of relevancy + date + title weighted search */
|
||||
$query->setOrder( \IPS\Content\Search\Query::ORDER_RELEVANCY );
|
||||
$baseUrl = $baseUrl->setQueryString( 'sortby', 'relevancy' );
|
||||
}
|
||||
|
||||
$flags = ( isset( \IPS\Request::i()->eitherTermsOrTags ) and \IPS\Request::i()->eitherTermsOrTags === 'and' ) ? \IPS\Content\Search\Query::TERM_AND_TAGS : \IPS\Content\Search\Query::TERM_OR_TAGS;
|
||||
|
||||
if ( isset( \IPS\Request::i()->search_and_or ) and \IPS\Request::i()->search_and_or === 'or' )
|
||||
{
|
||||
$flags = $flags | \IPS\Content\Search\Query::TERM_OR_MODE;
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_and_or', \IPS\Request::i()->search_and_or );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->search_in ) and \IPS\Request::i()->search_in === 'titles' )
|
||||
{
|
||||
$flags = $flags | \IPS\Content\Search\Query::TERM_TITLES_ONLY;
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_in', \IPS\Request::i()->search_in );
|
||||
}
|
||||
|
||||
/* Run query */
|
||||
$results = $query->excludeDisabledApps()->search(
|
||||
$results = $query->search(
|
||||
isset( \IPS\Request::i()->q ) ? ( \IPS\Request::i()->q ) : NULL,
|
||||
isset( \IPS\Request::i()->tags ) ? explode( ',', \IPS\Request::i()->tags ) : NULL,
|
||||
( isset( \IPS\Request::i()->eitherTermsOrTags ) and \IPS\Request::i()->eitherTermsOrTags === 'and' ) ? \IPS\Content\Search\Query::TERM_AND_TAGS : \IPS\Content\Search\Query::TERM_OR_TAGS
|
||||
$flags
|
||||
);
|
||||
|
||||
/* Get pagination */
|
||||
@@ -466,13 +510,15 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
$pagination = trim( \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl, ceil( $results->count( TRUE ) / $query->resultsToGet ), $page, $query->resultsToGet ) );
|
||||
|
||||
|
||||
/* Display results */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
$count = $results->count( TRUE );
|
||||
\IPS\Output::i()->json( array(
|
||||
'filters' => $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ) ),
|
||||
'content' => \IPS\Theme::i()->getTemplate( 'search' )->results( htmlentities( $term, \IPS\HTMLENTITIES, 'UTF-8', FALSE ), $title, $results, $pagination, $baseUrl, $results->count( TRUE ) ),
|
||||
'filters' => $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, $count ),
|
||||
'hints' => \IPS\Theme::i()->getTemplate( 'search' )->hints( $baseUrl, $count ),
|
||||
'content' => \IPS\Theme::i()->getTemplate( 'search' )->results( $this->_splitTermsForDisplay(), $title, $results, $pagination, $baseUrl, $count ),
|
||||
'title' => $title,
|
||||
'css' => array()
|
||||
) );
|
||||
@@ -483,9 +529,10 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
'Cache-Control' => "max-age=" . 30 * 60 . ", public" );
|
||||
|
||||
\IPS\Output::i()->httpHeaders += $httpHeaders;
|
||||
|
||||
\IPS\Output::i()->title = $title;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( htmlentities( $term, \IPS\HTMLENTITIES, 'UTF-8', FALSE ), $title, $results, $pagination, $baseUrl, $types, $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ) ), $results->count( TRUE ) );
|
||||
|
||||
$count = $results->count( TRUE );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('search_results_title');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( $this->_splitTermsForDisplay(), $title, $results, $pagination, $baseUrl, $types, $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, $count ), $count );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,12 +555,26 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
/* Types */
|
||||
$types = array( '' => 'search_everything' );
|
||||
$contentTypes = $this->_contentTypes();
|
||||
$contentToggles = array( 'tags', 'eitherTermsOrTags', 'author', 'elAdvancedSearch_dateFilters', 'startDate', 'updatedDate' );
|
||||
$contentToggles = array();
|
||||
$typeFields = array();
|
||||
$typeFieldToggles = array( '' => $contentToggles );
|
||||
$typeFieldToggles = array( '' => array( 'search_min_views', 'search_min_reviews', 'search_min_comments' ) );
|
||||
$haveCommentClass = FALSE;
|
||||
$haveReplyClass = FALSE;
|
||||
$haveReviewClass = FALSE;
|
||||
$dateOptions = array(
|
||||
'any' => 'any',
|
||||
'day' => 'last_24hr',
|
||||
'week' => 'last_week',
|
||||
'month' => 'last_month',
|
||||
'six_months' => 'six_months',
|
||||
'year' => 'year',
|
||||
'custom' => 'custom'
|
||||
);
|
||||
|
||||
/* Form tabs */
|
||||
$form->addTab( 'search_tab_all' );
|
||||
$form->addTab( 'search_tab_content' );
|
||||
$form->addTab( 'search_tab_member' );
|
||||
|
||||
/* Figure out member fields to set toggles */
|
||||
$memberToggles = array( 'joinedDate', 'core_members_group' );
|
||||
@@ -540,10 +601,6 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Type select */
|
||||
if ( isset( \IPS\Request::i()->type ) and isset( $contentTypes[ \IPS\Request::i()->type ] ) )
|
||||
{
|
||||
$contentTypes = array( $contentTypes[ \IPS\Request::i()->type ] );
|
||||
}
|
||||
foreach ( $contentTypes as $k => $class )
|
||||
{
|
||||
$types[ $k ] = $k . '_pl';
|
||||
@@ -569,36 +626,27 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$typeFieldToggles[ $k ][] = 'search_min_reviews';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$typeFieldToggles[ $k ] = $memberToggles;
|
||||
}
|
||||
$typeFieldToggles[ $k ][] = 'elAdvancedSearch_appFilters';
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'searchType', '', FALSE, array( 'options' => $types, 'toggles' => $typeFieldToggles ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'type', '', FALSE, array( 'options' => $types, 'toggles' => $typeFieldToggles ) ), NULL, 'search_tab_content' );
|
||||
|
||||
/* Term */
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'q' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'tags', \IPS\Request::i()->tags, FALSE, array( 'autocomplete' => array() ), NULL, NULL, NULL, 'tags' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'eitherTermsOrTags', \IPS\Request::i()->eitherTermsOrTags, FALSE, array( 'options' => array( 'or' => 'termsortags_or_desc', 'and' => 'termsortags_and_desc' ) ), NULL, NULL, NULL, 'eitherTermsOrTags' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'q' ), NULL, 'search_tab_all' );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'tags', \IPS\Request::i()->tags, FALSE, array( 'autocomplete' => array() ), NULL, NULL, NULL, 'tags' ), NULL, 'search_tab_content' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'eitherTermsOrTags', \IPS\Request::i()->eitherTermsOrTags, FALSE, array( 'options' => array( 'or' => 'termsortags_or_desc', 'and' => 'termsortags_and_desc' ) ), NULL, NULL, NULL, 'eitherTermsOrTags' ), NULL, 'search_tab_content' );
|
||||
|
||||
/* Author */
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'author', NULL, FALSE, array(), NULL, NULL, NULL, 'author' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'author', NULL, FALSE, array(), NULL, NULL, NULL, 'author' ), NULL, 'search_tab_content' );
|
||||
|
||||
/* Dates */
|
||||
$dateOptions = array(
|
||||
'any' => 'any',
|
||||
'day' => 'last_24hr',
|
||||
'week' => 'last_week',
|
||||
'month' => 'last_month',
|
||||
'six_months' => 'six_months',
|
||||
'year' => 'year',
|
||||
'custom' => 'custom'
|
||||
);
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'startDate', ( isset( \IPS\Request::i()->start_before ) or ( isset( \IPS\Request::i()->start_after ) and is_numeric( \IPS\Request::i()->start_after ) ) ) ? 'custom' : \IPS\Request::i()->start_after, FALSE, array( 'options' => $dateOptions, 'toggles' => array( 'custom' => array( 'elCustomDate_startDate' ) ) ), NULL, NULL, NULL, 'startDate' ) );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'startDateCustom', array( 'start' => ( isset( \IPS\Request::i()->start_after ) and is_numeric( \IPS\Request::i()->start_after ) ) ? \IPS\DateTime::ts( \IPS\Request::i()->start_after ) : NULL, 'end' => isset( \IPS\Request::i()->start_before ) ? \IPS\DateTime::ts( \IPS\Request::i()->start_before ) : NULL ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'updatedDate', ( isset( \IPS\Request::i()->updated_before ) or ( isset( \IPS\Request::i()->updated_after ) and is_numeric( \IPS\Request::i()->updated_after ) ) ) ? 'custom' : \IPS\Request::i()->updated_after, FALSE, array( 'options' => $dateOptions, 'toggles' => array( 'custom' => array( 'elCustomDate_updatedDate' ) ) ), NULL, NULL, NULL, 'updatedDate' ) );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'updatedDateCustom', array( 'start' => ( isset( \IPS\Request::i()->updated_after ) and is_numeric( \IPS\Request::i()->updated_after ) ) ? \IPS\DateTime::ts( \IPS\Request::i()->updated_after ) : NULL, 'end' => isset( \IPS\Request::i()->updated_before ) ? \IPS\DateTime::ts( \IPS\Request::i()->updated_before ) : NULL ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'startDate', ( isset( \IPS\Request::i()->start_before ) or ( isset( \IPS\Request::i()->start_after ) and is_numeric( \IPS\Request::i()->start_after ) ) ) ? 'custom' : \IPS\Request::i()->start_after, FALSE, array( 'options' => $dateOptions, 'toggles' => array( 'custom' => array( 'elCustomDate_startDate' ) ) ), NULL, NULL, NULL, 'startDate' ), NULL, 'search_tab_content' );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'startDateCustom', array( 'start' => ( isset( \IPS\Request::i()->start_after ) and is_numeric( \IPS\Request::i()->start_after ) ) ? \IPS\DateTime::ts( \IPS\Request::i()->start_after ) : NULL, 'end' => isset( \IPS\Request::i()->start_before ) ? \IPS\DateTime::ts( \IPS\Request::i()->start_before ) : NULL ) ), NULL, 'search_tab_content' );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'updatedDate', ( isset( \IPS\Request::i()->updated_before ) or ( isset( \IPS\Request::i()->updated_after ) and is_numeric( \IPS\Request::i()->updated_after ) ) ) ? 'custom' : \IPS\Request::i()->updated_after, FALSE, array( 'options' => $dateOptions, 'toggles' => array( 'custom' => array( 'elCustomDate_updatedDate' ) ) ), NULL, NULL, NULL, 'updatedDate' ), NULL, 'search_tab_content' );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'updatedDateCustom', array( 'start' => ( isset( \IPS\Request::i()->updated_after ) and is_numeric( \IPS\Request::i()->updated_after ) ) ? \IPS\DateTime::ts( \IPS\Request::i()->updated_after ) : NULL, 'end' => isset( \IPS\Request::i()->updated_before ) ? \IPS\DateTime::ts( \IPS\Request::i()->updated_before ) : NULL ) ), NULL, 'search_tab_content' );
|
||||
|
||||
/* Other filters */
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'search_in', \IPS\Request::i()->search_in, FALSE, array( 'options' => array( 'all' => 'titles_and_body', 'titles' => 'titles_only' ) ), NULL, NULL, NULL, 'searchIn' ), NULL, 'search_tab_content' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'search_and_or', \IPS\Request::i()->search_and_or, FALSE, array( 'options' => array( 'and' => 'search_and', 'or' => 'search_or' ) ), NULL, NULL, NULL, 'andOr' ), NULL, 'search_tab_content' );
|
||||
|
||||
/* Nodes */
|
||||
foreach ( $contentTypes as $k => $class )
|
||||
@@ -608,36 +656,34 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$nodeClass = $class::$containerNodeClass;
|
||||
$field = new \IPS\Helpers\Form\Node( 'nodes', ( isset( \IPS\Request::i()->nodes ) ) ? \IPS\Request::i()->nodes : NULL, FALSE, array( 'class' => $nodeClass, 'multiple' => TRUE, 'permissionCheck' => 'view', ), NULL, NULL, NULL, $k . '_node' );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack( $nodeClass::$nodeTitle );
|
||||
$form->add( $field );
|
||||
$form->add( $field, NULL, 'search_tab_content' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Member group and joined */
|
||||
if( ( isset( \IPS\Request::i()->searchType ) and \IPS\Request::i()->searchType === 'core_members' ) or !isset( \IPS\Request::i()->q ) )
|
||||
{
|
||||
$form->add(new \IPS\Helpers\Form\CheckboxSet('group', (isset(\IPS\Request::i()->group)) ? array_keys(\IPS\Request::i()->group) : array(), FALSE, array('options' => \IPS\Member\Group::groups(TRUE, FALSE), 'parse' => 'normal'), NULL, NULL, NULL, 'core_members_group'));
|
||||
$form->add(new \IPS\Helpers\Form\Select('joinedDate', (isset(\IPS\Request::i()->start_before) or (isset(\IPS\Request::i()->start_after) and is_numeric(\IPS\Request::i()->start_after))) ? 'custom' : \IPS\Request::i()->start_after, FALSE, array('options' => $dateOptions, 'toggles' => array('custom' => array('elCustomDate_joinedDate'))), NULL, NULL, NULL, 'joinedDate'));
|
||||
$form->add(new \IPS\Helpers\Form\DateRange('joinedDateCustom', array('start' => (isset(\IPS\Request::i()->start_after) and is_numeric(\IPS\Request::i()->start_after)) ? \IPS\DateTime::ts(\IPS\Request::i()->start_after) : NULL, 'end' => isset(\IPS\Request::i()->start_before) ? \IPS\DateTime::ts(\IPS\Request::i()->start_before) : NULL)));
|
||||
}
|
||||
|
||||
/* Comments/Views */
|
||||
$queryClass = \IPS\Content\Search\Query::init();
|
||||
if ( $queryClass::SUPPORTS_JOIN_FILTERS )
|
||||
{
|
||||
if ( $haveCommentClass )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_comments', isset( \IPS\Request::i()->comments ) ? \IPS\Request::i()->comments : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_comments' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_comments', isset( \IPS\Request::i()->search_min_comments ) ? \IPS\Request::i()->search_min_comments : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_comments' ), NULL, 'search_tab_content' );
|
||||
}
|
||||
if ( $haveReplyClass )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_replies', isset( \IPS\Request::i()->replies ) ? \IPS\Request::i()->replies : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_replies' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_replies', isset( \IPS\Request::i()->search_min_replies ) ? \IPS\Request::i()->search_min_replies : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_replies' ), NULL, 'search_tab_content' );
|
||||
}
|
||||
if ( $haveReviewClass )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_reviews', isset( \IPS\Request::i()->reviews ) ? \IPS\Request::i()->reviews : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_reviews' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_reviews', isset( \IPS\Request::i()->search_min_reviews ) ? \IPS\Request::i()->search_min_reviews : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_reviews' ), NULL, 'search_tab_content' );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_views', isset( \IPS\Request::i()->views ) ? \IPS\Request::i()->views : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_views' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_views', isset( \IPS\Request::i()->search_min_views ) ? \IPS\Request::i()->search_min_views : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_views' ), NULL, 'search_tab_content' );
|
||||
}
|
||||
|
||||
/* Member group and joined */
|
||||
$groups = \IPS\Member\Group::groups(TRUE, FALSE);
|
||||
$form->add(new \IPS\Helpers\Form\CheckboxSet('group', (isset(\IPS\Request::i()->group)) ? array_keys(\IPS\Request::i()->group) : array_keys( $groups ), FALSE, array('options' => $groups, 'parse' => 'normal'), NULL, NULL, NULL, 'core_members_group'), NULL, 'search_tab_member' );
|
||||
$form->add(new \IPS\Helpers\Form\Select('joinedDate', (isset(\IPS\Request::i()->start_before) or (isset(\IPS\Request::i()->start_after) and is_numeric(\IPS\Request::i()->start_after))) ? 'custom' : \IPS\Request::i()->start_after, FALSE, array('options' => $dateOptions, 'toggles' => array('custom' => array('elCustomDate_joinedDate'))), NULL, NULL, NULL, 'joinedDate'), NULL, 'search_tab_member' );
|
||||
$form->add(new \IPS\Helpers\Form\DateRange('joinedDateCustom', array('start' => (isset(\IPS\Request::i()->start_after) and is_numeric(\IPS\Request::i()->start_after)) ? \IPS\DateTime::ts(\IPS\Request::i()->start_after) : NULL, 'end' => isset(\IPS\Request::i()->start_before) ? \IPS\DateTime::ts(\IPS\Request::i()->start_before) : NULL)), NULL, 'search_tab_member' );
|
||||
|
||||
/* Profile fields for member searches */
|
||||
$memberFields = array();
|
||||
@@ -697,15 +743,15 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
foreach( $fieldsToAdd as $field )
|
||||
{
|
||||
$form->add( $field );
|
||||
$form->add( $field, NULL, 'search_tab_member' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If they submitted the advanced search form, redirect back (searching is a GET not a POST) */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if( !\IPS\Request::i()->isAjax() AND ( ( $values['q'] or $values['tags'] ) or $values['searchType'] == 'core_members' ) )
|
||||
if( !\IPS\Request::i()->isAjax() AND ( ( $values['q'] or $values['tags'] ) or $values['type'] == 'core_members' ) )
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( 'app=core&module=search&controller=search', 'front', 'search' );
|
||||
|
||||
@@ -721,13 +767,13 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$url = $url->setQueryString( 'eitherTermsOrTags', $values['eitherTermsOrTags'] );
|
||||
}
|
||||
if ( $values['searchType'] )
|
||||
if ( $values['type'] )
|
||||
{
|
||||
$url = $url->setQueryString( 'type', $values['searchType'] );
|
||||
$url = $url->setQueryString( 'type', $values['type'] );
|
||||
|
||||
if ( isset( $values[ $values['searchType'] . '_node' ] ) and !empty( $values[ $values['searchType'] . '_node' ] ) )
|
||||
if ( isset( $values[ $values['type'] . '_node' ] ) and !empty( $values[ $values['type'] . '_node' ] ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'nodes', implode( ',', array_keys( $values[ $values['searchType'] . '_node' ] ) ) );
|
||||
$url = $url->setQueryString( 'nodes', implode( ',', array_keys( $values[ $values['type'] . '_node' ] ) ) );
|
||||
}
|
||||
|
||||
if ( isset( $values['search_min_comments'] ) and $values['search_min_comments'] )
|
||||
@@ -771,7 +817,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$url = $url->setQueryString( $fieldName, $values[ $fieldName ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( isset( $values['joinedDate'] ) AND $values['joinedDate'] != 'custom' )
|
||||
{
|
||||
$url = $url->setQueryString( 'start_after', $values['joinedDate'] );
|
||||
@@ -825,19 +871,34 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$types = array();
|
||||
foreach ( \IPS\Content::routedClasses( TRUE, FALSE, TRUE ) as $class )
|
||||
{
|
||||
if( is_subclass_of( $class, 'IPS\Content\Searchable' ) )
|
||||
if( is_subclass_of( $class, 'IPS\Content\Searchable' ) and $class::$includeInSiteSearch )
|
||||
{
|
||||
$key = mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) );
|
||||
$types[ $key ] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
if ( \IPS\Application\Module::get( 'core', 'members', 'front' )->can('view') )
|
||||
{
|
||||
$types['core_members'] = 'IPS\Member';
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the search term into distinct matches
|
||||
* e.g. one "two three" beccomes ['one', 'two three']
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _splitTermsForDisplay()
|
||||
{
|
||||
if( !isset( \IPS\Request::i()->q ) ){
|
||||
return json_encode( array() );
|
||||
}
|
||||
|
||||
return $types;
|
||||
$words = preg_split("/[\s]*\\\"([^\\\"]+)\\\"[\s]*|[\s]*'([^']+)'[\s]*|[\s]+/", \IPS\Request::i()->q, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
foreach( $words as $idx => $word ){
|
||||
$words[ $idx ] = htmlentities( $word, \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
}
|
||||
|
||||
return json_encode( $words );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -847,6 +908,6 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function globalFilterOptions()
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'search' )->globalSearchMenuOptions() );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'search' )->globalSearchMenuOptions( \IPS\Request::i()->checked ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user