Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Search
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 18 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -34,10 +34,19 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
\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
|
||||
|
||||
|
||||
if( !\IPS\Settings::i()->tags_enabled and isset( \IPS\Request::i()->tags ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'page_doesnt_exist', '2C205/4', 404, '' );
|
||||
}
|
||||
|
||||
/* Get the form */
|
||||
$baseUrl = \IPS\Http\Url::internal( 'app=core&module=search&controller=search', 'front', 'search' );
|
||||
$form = $this->_form();
|
||||
@@ -73,6 +82,11 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
\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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Number of member search results to retrieve
|
||||
*/
|
||||
protected $memberSearchResults = 24;
|
||||
|
||||
/**
|
||||
* Get Results
|
||||
@@ -81,6 +95,15 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function _results()
|
||||
{
|
||||
/* Make sure we are not doing anything nefarious like passing an array the the "q" parameter, which generates errors */
|
||||
foreach( array( 'q', 'type' ) AS $parameter )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->$parameter ) AND is_array( \IPS\Request::i()->$parameter ) )
|
||||
{
|
||||
\IPS\Request::i()->$parameter = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Init */
|
||||
$baseUrl = \IPS\Http\Url::internal( 'app=core&module=search&controller=search', 'front', 'search' );
|
||||
if( \IPS\Request::i()->q )
|
||||
@@ -103,13 +126,17 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', \IPS\Request::i()->type );
|
||||
if ( \IPS\Request::i()->q )
|
||||
{
|
||||
$where = array( array( 'LOWER(core_members.name) LIKE ?', '%' . mb_strtolower( \IPS\Request::i()->q ) . '%' ) );
|
||||
$where = array( array( 'LOWER(core_members.name) LIKE ?', '%' . mb_strtolower( trim( \IPS\Request::i()->q ) ) . '%' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = array( array( 'core_members.name<>?', '' ) );
|
||||
}
|
||||
|
||||
|
||||
if ( isset( \IPS\Request::i()->joinedDate ) and !isset( \IPS\Request::i()->start_after ) )
|
||||
{
|
||||
\IPS\Request::i()->start_after = \IPS\Request::i()->joinedDate;
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->start_before ) or isset( \IPS\Request::i()->start_after ) )
|
||||
{
|
||||
foreach ( array( 'before', 'after' ) as $l )
|
||||
@@ -162,20 +189,29 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
/* Only exclude by group if the only value isn't __EMPTY **/
|
||||
if( !is_array( \IPS\Request::i()->group ) OR ( count( \IPS\Request::i()->group ) > 1 OR !isset( \IPS\Request::i()->group['__EMPTY'] ) ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'group', \IPS\Request::i()->group );
|
||||
$where[] = \IPS\Db::i()->in( 'core_members.member_group_id', ( is_array( \IPS\Request::i()->group ) ) ? array_filter( array_keys( \IPS\Request::i()->group ), function( $val ){
|
||||
$groups = ( is_array( \IPS\Request::i()->group ) ) ? array_filter( array_keys( \IPS\Request::i()->group ), function( $val ){
|
||||
if( $val == '__EMPTY' )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} ) : explode( ',', \IPS\Request::i()->group ) );
|
||||
} ) : explode( ',', \IPS\Request::i()->group );
|
||||
|
||||
foreach( $groups as $_idx => $groupId )
|
||||
{
|
||||
if( \IPS\Member\Group::load( $groupId )->g_bitoptions['gbw_hide_group'] )
|
||||
{
|
||||
unset( $groups[ $_idx ] );
|
||||
}
|
||||
}
|
||||
$baseUrl = $baseUrl->setQueryString( 'group', \IPS\Request::i()->group );
|
||||
$where[] = \IPS\Db::i()->in( 'core_members.member_group_id', $groups );
|
||||
}
|
||||
}
|
||||
|
||||
/* Figure out member custom field filters */
|
||||
foreach ( \IPS\core\ProfileFields\Field::fields( array(), \IPS\core\ProfileFields\PROFILE ) as $group => $fields )
|
||||
foreach ( \IPS\core\ProfileFields\Field::fields( array(), \IPS\core\ProfileFields\Field::SEARCH ) as $group => $fields )
|
||||
{
|
||||
/* Fields */
|
||||
foreach ( $fields as $id => $field )
|
||||
@@ -193,13 +229,21 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
case 'IPS\Helpers\Form\Url':
|
||||
case 'IPS\Helpers\Form\Date':
|
||||
case 'IPS\Helpers\Form\Number':
|
||||
$fieldName = 'core_pfield_' . $id;
|
||||
|
||||
if( isset( \IPS\Request::i()->$fieldName ) )
|
||||
{
|
||||
$where[] = array( 'LOWER(core_pfields_content.field_' . $id . ') LIKE ?', '%' . mb_strtolower( \IPS\Request::i()->$fieldName ) . '%' );
|
||||
$baseUrl = $baseUrl->setQueryString( $fieldName, \IPS\Request::i()->$fieldName );
|
||||
}
|
||||
break;
|
||||
case 'IPS\Helpers\Form\Select':
|
||||
case 'IPS\Helpers\Form\Radio':
|
||||
$fieldName = 'core_pfield_' . $id;
|
||||
|
||||
if( isset( \IPS\Request::i()->$fieldName ) )
|
||||
{
|
||||
$where[] = array( 'LOWER(core_pfields_content.field_' . $id . ') LIKE ?', '%' . mb_strtolower( \IPS\Request::i()->$fieldName ) . '%' );
|
||||
$where[] = array( 'core_pfields_content.field_' . $id . ' = ?', mb_strtolower( \IPS\Request::i()->$fieldName ) );
|
||||
$baseUrl = $baseUrl->setQueryString( $fieldName, \IPS\Request::i()->$fieldName );
|
||||
}
|
||||
break;
|
||||
@@ -238,13 +282,13 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$select = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', $where );
|
||||
$select->join( 'core_pfields_content', 'core_pfields_content.member_id=core_members.member_id' );
|
||||
$count = $select->first();
|
||||
|
||||
$select = \IPS\Db::i()->select( 'core_members.*', 'core_members', $where, $order, array( ( $page - 1 ) * 25, 25 ) );
|
||||
|
||||
$select = \IPS\Db::i()->select( 'core_members.*', 'core_members', $where, $order, array( ( $page - 1 ) * $this->memberSearchResults, $this->memberSearchResults ) );
|
||||
$select->join( 'core_pfields_content', 'core_pfields_content.member_id=core_members.member_id' );
|
||||
|
||||
$results = new \IPS\Patterns\ActiveRecordIterator( $select, 'IPS\Member' );
|
||||
|
||||
$pagination = trim( \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl, ceil( $count / 25 ), $page, 1 ) );
|
||||
$pagination = trim( \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl, ceil( $count / $this->memberSearchResults ), $page, $this->memberSearchResults, TRUE, 'page', ( $count > \IPS\UPGRADE_MANUAL_THRESHOLD ? TRUE : FALSE ) ) );
|
||||
if ( !\IPS\Request::i()->q )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'members' );
|
||||
@@ -288,6 +332,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$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') ) ) );
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', \IPS\Request::i()->type );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
@@ -298,11 +343,27 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( isset( \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 ) ) );
|
||||
|
||||
$nodes = array();
|
||||
$nodeClass = $types[ \IPS\Request::i()->type ]::$containerNodeClass;
|
||||
foreach ( explode( ',', \IPS\Request::i()->nodes ) as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$nodes[] = $nodeClass::loadAndCheckPerms( $id )->_title;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
if ( !$nodes )
|
||||
{
|
||||
\IPS\Output::i()->error( 'search_invalid_nodes', '2C205/5', 404, '' );
|
||||
}
|
||||
|
||||
$nodes = \IPS\Member::loggedIn()->language()->formatList( $nodes );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_in', FALSE, array( 'sprintf' => array( $nodes ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -362,7 +423,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$$l = NULL;
|
||||
$key = "{$l}Key";
|
||||
if ( isset( \IPS\Request::i()->$$key ) )
|
||||
if ( isset( \IPS\Request::i()->$$key ) AND \IPS\Request::i()->$$key != 'any' )
|
||||
{
|
||||
switch ( \IPS\Request::i()->$$key )
|
||||
{
|
||||
@@ -408,9 +469,15 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
/* Work out the title */
|
||||
if ( \IPS\Request::i()->tags )
|
||||
{
|
||||
/* @todo Remove when we fix \Http\Url as there are issues with urlencode/decoding */
|
||||
if ( ! \IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
{
|
||||
\IPS\Request::i()->tags = urldecode( \IPS\Request::i()->tags );
|
||||
}
|
||||
|
||||
$tagList = array_map( function( $val )
|
||||
{
|
||||
return '\'' . htmlentities( $val, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '\'';
|
||||
return '\'' . htmlentities( $val, \IPS\HTMLENTITIES | ENT_QUOTES, 'UTF-8', FALSE ) . '\'';
|
||||
}, explode( ',', \IPS\Request::i()->tags ) );
|
||||
}
|
||||
$title = '';
|
||||
@@ -458,28 +525,24 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Set Order */
|
||||
if ( isset( \IPS\Request::i()->sortby ) )
|
||||
if ( ! isset( \IPS\Request::i()->sortby ) )
|
||||
{
|
||||
switch( \IPS\Request::i()->sortby )
|
||||
{
|
||||
case 'newest':
|
||||
$query->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_CREATED );
|
||||
break;
|
||||
\IPS\Request::i()->sortby = $query->getDefaultSortMethod();
|
||||
}
|
||||
|
||||
switch( \IPS\Request::i()->sortby )
|
||||
{
|
||||
case 'newest':
|
||||
$query->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_CREATED );
|
||||
break;
|
||||
|
||||
case 'relevancy':
|
||||
$query->setOrder( \IPS\Content\Search\Query::ORDER_RELEVANCY );
|
||||
break;
|
||||
}
|
||||
|
||||
$baseUrl = $baseUrl->setQueryString( 'sortby', \IPS\Request::i()->sortby );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 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' );
|
||||
case 'relevancy':
|
||||
$query->setOrder( \IPS\Content\Search\Query::ORDER_RELEVANCY );
|
||||
break;
|
||||
}
|
||||
|
||||
$baseUrl = $baseUrl->setQueryString( 'sortby', \IPS\Request::i()->sortby );
|
||||
|
||||
$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' )
|
||||
@@ -498,23 +561,31 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$results = $query->search(
|
||||
isset( \IPS\Request::i()->q ) ? ( \IPS\Request::i()->q ) : NULL,
|
||||
isset( \IPS\Request::i()->tags ) ? explode( ',', \IPS\Request::i()->tags ) : NULL,
|
||||
$flags
|
||||
$flags + \IPS\Content\Search\Query::TAGS_MATCH_ITEMS_ONLY
|
||||
);
|
||||
|
||||
/* Get pagination */
|
||||
$page = isset( \IPS\Request::i()->page ) ? intval( \IPS\Request::i()->page ) : 1;
|
||||
$count = $results->count( TRUE );
|
||||
$pages = ceil( $results->count( TRUE ) / $query->resultsToGet );
|
||||
|
||||
if( $page < 1 )
|
||||
if ( ! $count )
|
||||
{
|
||||
/* Enforce that we're on page 1 if there are no results to prevent page tampering */
|
||||
$page = 1;
|
||||
}
|
||||
else if( $count and ( $page < 1 or $page > $pages ) )
|
||||
{
|
||||
/* There's no point resetting the page at this point as the search query has been run and no results have been found */
|
||||
$_SESSION['lastSearch'] = 0;
|
||||
\IPS\Output::i()->redirect( $baseUrl->setQueryString( 'page', 1 ) );
|
||||
}
|
||||
|
||||
$pagination = trim( \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl, ceil( $results->count( TRUE ) / $query->resultsToGet ), $page, $query->resultsToGet ) );
|
||||
$pagination = trim( \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl, $pages, $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' ), $baseUrl, $count ),
|
||||
'hints' => \IPS\Theme::i()->getTemplate( 'search' )->hints( $baseUrl, $count ),
|
||||
@@ -526,11 +597,10 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
$httpHeaders = array( 'Expires' => \IPS\DateTime::create()->add( new \DateInterval( 'PT3M' ) )->rfc1123() ,
|
||||
'Cache-Control' => "max-age=" . 30 * 60 . ", public" );
|
||||
'Cache-Control' => "max-age=" . 30 * 60 . ", private" );
|
||||
|
||||
\IPS\Output::i()->httpHeaders += $httpHeaders;
|
||||
|
||||
$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 );
|
||||
}
|
||||
@@ -552,12 +622,34 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$form->hiddenValues['item'] = \IPS\Request::i()->item;
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->sortby ) )
|
||||
{
|
||||
$form->hiddenValues['sortby'] = \IPS\Request::i()->sortby;
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->sortdirection ) )
|
||||
{
|
||||
$form->hiddenValues['sortdirection'] = \IPS\Request::i()->sortdirection;
|
||||
}
|
||||
|
||||
/* 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' )
|
||||
{
|
||||
\IPS\Request::i()->type = '';
|
||||
}
|
||||
|
||||
/* Set up some sensible defaults */
|
||||
if ( ! isset( \IPS\Request::i()->updated_after ) )
|
||||
{
|
||||
\IPS\Request::i()->updated_after = \IPS\Content\Search\Query::init()->getDefaultDateCutOff();
|
||||
}
|
||||
|
||||
/* Types */
|
||||
$types = array( '' => 'search_everything' );
|
||||
$contentTypes = $this->_contentTypes();
|
||||
$contentToggles = array();
|
||||
$typeFields = array();
|
||||
$typeFieldToggles = array( '' => array( 'search_min_views', 'search_min_reviews', 'search_min_comments' ) );
|
||||
$typeFieldToggles = array('' => array() );
|
||||
$haveCommentClass = FALSE;
|
||||
$haveReplyClass = FALSE;
|
||||
$haveReviewClass = FALSE;
|
||||
@@ -566,8 +658,8 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
'day' => 'last_24hr',
|
||||
'week' => 'last_week',
|
||||
'month' => 'last_month',
|
||||
'six_months' => 'six_months',
|
||||
'year' => 'year',
|
||||
'six_months' => 'last_six_months',
|
||||
'year' => 'last_year',
|
||||
'custom' => 'custom'
|
||||
);
|
||||
|
||||
@@ -578,7 +670,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Figure out member fields to set toggles */
|
||||
$memberToggles = array( 'joinedDate', 'core_members_group' );
|
||||
foreach ( \IPS\core\ProfileFields\Field::fields( array(), \IPS\core\ProfileFields\PROFILE ) as $group => $fields )
|
||||
foreach ( \IPS\core\ProfileFields\Field::fields( array(), \IPS\core\ProfileFields\Field::SEARCH ) as $group => $fields )
|
||||
{
|
||||
foreach ( $fields as $id => $field )
|
||||
{
|
||||
@@ -632,7 +724,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
/* Term */
|
||||
$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\Text( 'tags', \IPS\Request::i()->tags, FALSE, array( 'autocomplete' => TRUE ), 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 */
|
||||
@@ -647,16 +739,16 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
/* 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 )
|
||||
{
|
||||
if ( isset( $class::$containerNodeClass ) and isset( \IPS\Request::i()->type ) and \IPS\Request::i()->type === $k )
|
||||
if ( isset( $class::$containerNodeClass ) )
|
||||
{
|
||||
$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 = new \IPS\Helpers\Form\Node( $k . '_node', ( isset( \IPS\Request::i()->nodes ) ) ? \IPS\Request::i()->nodes : NULL, FALSE, array( 'class' => $nodeClass, 'multiple' => TRUE, 'permissionCheck' => $nodeClass::searchableNodesPermission(), 'forceOwner' => FALSE ), NULL, NULL, NULL, $k . '_node' );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack( $nodeClass::$nodeTitle );
|
||||
$form->add( $field, NULL, 'search_tab_content' );
|
||||
$form->add( $field, NULL, 'search_tab_nodes' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,14 +772,15 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* 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' );
|
||||
$groups = \IPS\Member\Group::groups( TRUE, FALSE, TRUE );
|
||||
|
||||
$form->add(new \IPS\Helpers\Form\CheckboxSet('group', ( isset( \IPS\Request::i()->group ) ) ? is_array( \IPS\Request::i()->group) ? array_keys( \IPS\Request::i()->group) : array( \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();
|
||||
foreach ( \IPS\core\ProfileFields\Field::fields( array(), \IPS\core\ProfileFields\SEARCH ) as $group => $fields )
|
||||
foreach ( \IPS\core\ProfileFields\Field::fields( array(), \IPS\core\ProfileFields\Field::SEARCH ) as $group => $fields )
|
||||
{
|
||||
$fieldsToAdd = array();
|
||||
/* Fields */
|
||||
@@ -717,15 +810,18 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$memberFields[] = 'core_pfield_' . $id;
|
||||
break;
|
||||
case 'IPS\Helpers\Form\Number':
|
||||
$helper = new \IPS\Helpers\Form\Number( 'core_pfield_' . $id, NULL, FALSE, array(), NULL, NULL, NULL, 'core_pfield_' . $id );
|
||||
$helper = new \IPS\Helpers\Form\Number( 'core_pfield_' . $id, -1, FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'member_number_anyvalue' ), NULL, NULL, NULL, 'core_pfield_' . $id );
|
||||
$memberFields[] = 'core_pfield_' . $id;
|
||||
break;
|
||||
case 'IPS\Helpers\Form\Select':
|
||||
case 'IPS\Helpers\Form\Radio':
|
||||
$options = array( '' => "" );
|
||||
foreach ( $field->options['options'] as $option )
|
||||
if( count( $field->options['options'] ) )
|
||||
{
|
||||
$options[ $option ] = $option;
|
||||
foreach ($field->options['options'] as $option)
|
||||
{
|
||||
$options[$option] = $option;
|
||||
}
|
||||
}
|
||||
|
||||
$helper = new \IPS\Helpers\Form\Select( 'core_pfield_' . $id, NULL, FALSE, array( 'options' => $options ), NULL, NULL, NULL, 'core_pfield_' . $id );
|
||||
@@ -871,7 +967,7 @@ 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' ) and $class::$includeInSiteSearch )
|
||||
if( is_subclass_of( $class, 'IPS\Content\Searchable' ) and $class::includeInSiteSearch() )
|
||||
{
|
||||
$key = mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) );
|
||||
$types[ $key ] = $class;
|
||||
@@ -894,8 +990,9 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
|
||||
$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 );
|
||||
foreach( $words as $idx => $word )
|
||||
{
|
||||
$words[ $idx ] = htmlentities( $word, \IPS\HTMLENTITIES | ENT_QUOTES, 'UTF-8', FALSE ); // ENT_QUOTES is because this will go in a HTML attribute (data-term="$value") so if you include a single quote in your search query, it can break
|
||||
}
|
||||
|
||||
return json_encode( $words );
|
||||
|
||||
Reference in new issue
Block a user