Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -2,18 +2,18 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* Global Search
|
||||
* Last Updated: $Date: 2010-02-22 17:06:11 +0000 (Mon, 22 Feb 2010) $
|
||||
* Last Updated: $Date: 2011-09-09 08:14:40 -0400 (Fri, 09 Sep 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: matt $
|
||||
* @author $Author: mmecham $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @subpackage Core
|
||||
* @link http://www.invisionpower.com
|
||||
* @version $Rev: 5859 $
|
||||
* @link http://hatynka.in
|
||||
* @version $Rev: 9474 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
@@ -32,7 +32,7 @@ class IPSSearchRegistry {
|
||||
* Registry vars
|
||||
* @var array
|
||||
*/
|
||||
static private $_vars = array();
|
||||
static protected $_vars = array();
|
||||
|
||||
/**
|
||||
* Set var
|
||||
@@ -60,6 +60,36 @@ class IPSSearchRegistry {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get is title only
|
||||
*
|
||||
*/
|
||||
static public function searchTitleOnly()
|
||||
{
|
||||
if ( self::get('opt.searchType') == 'titles' )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( self::get('opt.searchType') == 'both' )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( self::get('opt.searchType') == 'content' )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( self::get('opt.noPostPreview') )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +111,9 @@ class IPSSearch
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
@@ -89,42 +121,42 @@ class IPSSearch
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private $SEARCH;
|
||||
protected $SEARCH;
|
||||
|
||||
/**
|
||||
* Plug in for formatting results
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private $FORMAT;
|
||||
protected $FORMAT;
|
||||
|
||||
/**
|
||||
* App
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_app;
|
||||
protected $_app;
|
||||
|
||||
/**
|
||||
* Engine
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_engine;
|
||||
protected $_engine;
|
||||
|
||||
/**
|
||||
* Result count
|
||||
*
|
||||
* @param int
|
||||
*/
|
||||
private $_count;
|
||||
protected $_count;
|
||||
|
||||
/**
|
||||
* Result array
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
private $_results;
|
||||
protected $_results;
|
||||
|
||||
static public $aso;
|
||||
static public $ask;
|
||||
@@ -134,7 +166,7 @@ class IPSSearch
|
||||
* Setup registry objects
|
||||
*
|
||||
* @param object ipsRegistry $registry
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry, $engine, $app )
|
||||
{
|
||||
@@ -156,14 +188,14 @@ class IPSSearch
|
||||
$this->_app = IPSText::alphanumericalClean( $app );
|
||||
|
||||
/* Quick check */
|
||||
if ( ! file_exists( IPS_ROOT_PATH . 'sources/classes/search/engines/' . $this->_engine . '.php' ) )
|
||||
if ( ! is_file( IPS_ROOT_PATH . 'sources/classes/search/engines/' . $this->_engine . '.php' ) )
|
||||
{
|
||||
/* Try SQL */
|
||||
if ( ! $this->_engine != 'sql' )
|
||||
{
|
||||
$this->_engine = 'sql';
|
||||
|
||||
if ( ! file_exists( IPS_ROOT_PATH . 'sources/classes/search/engines/' . $this->_engine . '.php' ) )
|
||||
if ( ! is_file( IPS_ROOT_PATH . 'sources/classes/search/engines/' . $this->_engine . '.php' ) )
|
||||
{
|
||||
throw new Exception( "NO_SUCH_ENGINE" );
|
||||
}
|
||||
@@ -184,43 +216,34 @@ class IPSSearch
|
||||
IPSSearchRegistry::set( 'global.app' , $this->_app );
|
||||
|
||||
/* Load up the relevant engines */
|
||||
$_className = 'search_' . $this->_engine;
|
||||
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/search/format.php' );
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/search/format.php' );/*noLibHook*/
|
||||
|
||||
/* Got an app specific file? Lets hope so */
|
||||
if ( file_exists( IPSLib::getAppDir( $this->_app ) . '/extensions/search/format.php' ) )
|
||||
{
|
||||
if ( is_file( IPSLib::getAppDir( $this->_app ) . '/extensions/search/format.php' ) )
|
||||
{
|
||||
/* We may not have sphinx specific stuff, so... */
|
||||
if ( ! file_exists( IPSLib::getAppDir( $this->_app ) . '/extensions/search/engines/' . $this->_engine . '.php' ) )
|
||||
if ( ! is_file( IPSLib::getAppDir( $this->_app ) . '/extensions/search/engines/' . $this->_engine . '.php' ) )
|
||||
{
|
||||
$this->_engine = 'sql';
|
||||
|
||||
if ( ! file_exists( IPSLib::getAppDir( $this->_app ) . '/extensions/search/engines/' . $this->_engine . '.php' ) )
|
||||
if ( ! is_file( IPSLib::getAppDir( $this->_app ) . '/extensions/search/engines/' . $this->_engine . '.php' ) )
|
||||
{
|
||||
throw new Exception( "NO_SUCH_APP_ENGINE" );
|
||||
}
|
||||
}
|
||||
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/search/engines/' . $this->_engine . '.php' );
|
||||
require_once( IPSLib::getAppDir( $this->_app ) . '/extensions/search/engines/' . $this->_engine . '.php' );
|
||||
|
||||
/* SEARCH classname */
|
||||
$_className = 'search_engine_' . $this->_app;
|
||||
|
||||
$this->SEARCH = new $_className( $registry );
|
||||
/* SEARCH file */
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/search/engines/' . $this->_engine . '.php' );/*noLibHook*/
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $this->_app ) . '/extensions/search/engines/' . $this->_engine . '.php', 'search_engine_' . $this->_app, $this->_app );
|
||||
$this->SEARCH = new $classToLoad( $registry );
|
||||
|
||||
/* FORMAT file */
|
||||
require_once( IPSLib::getAppDir( $this->_app ) . '/extensions/search/format.php' );
|
||||
|
||||
/* FORMAT classname */
|
||||
$_className = 'search_format_' . $this->_app;
|
||||
|
||||
$this->FORMAT = new $_className( $registry );
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $this->_app ) . '/extensions/search/format.php', 'search_format_' . $this->_app, $this->_app );
|
||||
$this->FORMAT = new $classToLoad( $registry );
|
||||
|
||||
/* Grab config */
|
||||
$CONFIG = array();
|
||||
require( IPSLib::getAppDir( $this->_app ) . '/extensions/search/config.php' );
|
||||
require( IPSLib::getAppDir( $this->_app ) . '/extensions/search/config.php' );/*noLibHook*/
|
||||
|
||||
if ( is_array( $CONFIG ) && count( $CONFIG ) )
|
||||
{
|
||||
@@ -239,7 +262,7 @@ class IPSSearch
|
||||
if ( IPSSearchRegistry::get( 'config.contentTypes' ) )
|
||||
{
|
||||
$c = IPSSearchRegistry::get( 'config.contentTypes' );
|
||||
|
||||
|
||||
if ( is_array( $c ) AND count( $c ) )
|
||||
{
|
||||
/* Set up default content type if supported */
|
||||
@@ -281,6 +304,11 @@ class IPSSearch
|
||||
case 'fetchSortDropDown':
|
||||
return $this->SEARCH->fetchSortDropDown();
|
||||
break;
|
||||
|
||||
/* Primarily shortcuts for 'Content I follow' */
|
||||
case 'fetchFollowedContentOutput':
|
||||
return $this->FORMAT->parseFollowedContentOutput( $args[0], $args[1] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,14 +325,13 @@ class IPSSearch
|
||||
/* results page? */
|
||||
$filter = ( ! IPSSearchRegistry::get('view.search_form') AND IPSSearchRegistry::get( $app . '.searchInKey' ) ) ? IPSSearchRegistry::get( $app . '.searchInKey' ) : '';
|
||||
|
||||
if ( file_exists( IPSLib::getAppDir( $app ) . '/extensions/search/form.php' ) )
|
||||
if ( is_file( IPSLib::getAppDir( $app ) . '/extensions/search/form.php' ) )
|
||||
{
|
||||
require_once( IPSLib::getAppDir( $app ) . '/extensions/search/form.php' );
|
||||
$_class = 'search_form_' . $app;
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app ) . '/extensions/search/form.php', 'search_form_' . $app, $app );
|
||||
|
||||
if ( class_exists( $_class ) )
|
||||
if ( class_exists( $classToLoad ) )
|
||||
{
|
||||
$_obj = new $_class();
|
||||
$_obj = new $classToLoad();
|
||||
$_dd = $_obj->fetchSortDropDown();
|
||||
|
||||
if ( $filter )
|
||||
@@ -331,14 +358,13 @@ class IPSSearch
|
||||
{
|
||||
$app = ( $app ) ? $app : $this->_app;
|
||||
|
||||
if ( file_exists( IPSLib::getAppDir( $app ) . '/extensions/search/form.php' ) )
|
||||
if ( is_file( IPSLib::getAppDir( $app ) . '/extensions/search/form.php' ) )
|
||||
{
|
||||
require_once( IPSLib::getAppDir( $app ) . '/extensions/search/form.php' );
|
||||
$_class = 'search_form_' . $app;
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app ) . '/extensions/search/form.php', 'search_form_' . $app, $app );
|
||||
|
||||
if ( class_exists( $_class ) )
|
||||
if ( class_exists( $classToLoad ) )
|
||||
{
|
||||
$_obj = new $_class();
|
||||
$_obj = new $classToLoad();
|
||||
|
||||
if ( method_exists( $_obj, 'fetchSortIn' ) )
|
||||
{
|
||||
@@ -370,17 +396,16 @@ class IPSSearch
|
||||
continue;
|
||||
}
|
||||
|
||||
if( IPSLib::appisSearchable( $app['app_directory'] ) )
|
||||
if( IPSLib::appIsSearchable( $app['app_directory'] ) )
|
||||
{
|
||||
/* got custom filter? */
|
||||
if ( file_exists( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/search/form.php' ) )
|
||||
if ( is_file( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/search/form.php' ) )
|
||||
{
|
||||
require_once( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/search/form.php' );
|
||||
$_class = 'search_form_' . $app['app_directory'];
|
||||
|
||||
if ( class_exists( $_class ) and method_exists( $_class, 'getHtml' ) )
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/search/form.php', 'search_form_' . $app['app_directory'], $app['app_directory'] );
|
||||
|
||||
if ( class_exists( $classToLoad ) and method_exists( $classToLoad, 'getHtml' ) )
|
||||
{
|
||||
$_obj = new $_class();
|
||||
$_obj = new $classToLoad();
|
||||
|
||||
$filtersHtml[ $app['app_directory'] ] = $_obj->getHtml();
|
||||
}
|
||||
@@ -508,14 +533,53 @@ class IPSSearch
|
||||
*/
|
||||
public function viewNewContent()
|
||||
{
|
||||
IPSSearchRegistry::set('display.onlyTitles', true);
|
||||
IPSSearchRegistry::set('opt.searchTitleOnly', true);
|
||||
IPSSearchRegistry::set('in.period_in_seconds', false );
|
||||
|
||||
/* Hard fix mobile app users to VNC based on unread content */
|
||||
/* Hard fix mobile app users to VNC based on ACP default VNC method */
|
||||
if ( $this->member->isMobileApp )
|
||||
{
|
||||
$this->memberData['bw_vnc_type'] = 1;
|
||||
IPSSearchRegistry::set( 'in.period', $this->settings['default_vnc_method'] );
|
||||
}
|
||||
|
||||
/* Do we have a period? */
|
||||
switch( IPSSearchRegistry::get('in.period') )
|
||||
{
|
||||
case 'today':
|
||||
default:
|
||||
$date = 86400; // 24 hours
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$date = 604800; // 1 week
|
||||
break;
|
||||
|
||||
case 'weeks':
|
||||
$date = 1209600; // 2 weeks
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$date = 2592000; // 30 days
|
||||
break;
|
||||
|
||||
case 'months':
|
||||
$date = 15552000; // 6 months
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$date = 31536000; // 365 days
|
||||
break;
|
||||
case 'lastvisit':
|
||||
$date = time() - intval( $this->memberData['last_visit'] );
|
||||
break;
|
||||
case 'unread':
|
||||
$date = false;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set date up */
|
||||
IPSSearchRegistry::set('in.period_in_seconds', $date );
|
||||
|
||||
/* Run the search */
|
||||
$results = $this->SEARCH->viewNewContent();
|
||||
|
||||
@@ -558,74 +622,12 @@ class IPSSearch
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform the search
|
||||
*
|
||||
* @return nothin'
|
||||
*/
|
||||
public function viewActiveContent()
|
||||
{
|
||||
/* Bit 'o set up */
|
||||
IPSSearchRegistry::set('opt.searchTitleOnly', IPSSearchRegistry::get('in.view_by_title') );
|
||||
IPSSearchRegistry::set('display.onlyTitles', true);
|
||||
IPSSearchRegistry::set('opt.searchTitleOnly', true);
|
||||
|
||||
/* Do we have a period? */
|
||||
switch( IPSSearchRegistry::get('in.period') )
|
||||
{
|
||||
case 'today':
|
||||
default:
|
||||
$date = 86400; // 24 hours
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$date = 604800; // 1 week
|
||||
break;
|
||||
|
||||
case 'weeks':
|
||||
$date = 1209600; // 2 weeks
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$date = 2592000; // 30 days
|
||||
break;
|
||||
|
||||
case 'months':
|
||||
$date = 15552000; // 6 months
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$date = 31536000; // 365 days
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set date up */
|
||||
IPSSearchRegistry::set('in.period_in_seconds', $date );
|
||||
|
||||
/* Run the search */
|
||||
$results = $this->SEARCH->viewActiveContent();
|
||||
|
||||
/* Set data */
|
||||
$this->_count = intval( $results['count'] );
|
||||
$this->_results = $results['resultSet'];
|
||||
|
||||
/* Now format results */
|
||||
if ( count( $this->_results ) )
|
||||
{
|
||||
$this->_results = $this->FORMAT->processResults( $this->_results );
|
||||
|
||||
/* Now generate HTML */
|
||||
$this->_results = $this->FORMAT->parseAndFetchHtmlBlocks( $this->_results );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag a search session
|
||||
*
|
||||
* @return int Process ID
|
||||
*/
|
||||
private function _startSession()
|
||||
protected function _startSession()
|
||||
{
|
||||
/**
|
||||
* If we've already run a search and it's not clear, kill it now
|
||||
@@ -655,7 +657,7 @@ class IPSSearch
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _endSession( $processId )
|
||||
protected function _endSession( $processId )
|
||||
{
|
||||
if ( $processId )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user