Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -145,7 +145,7 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
$table->sortDirection = $table->sortDirection ?: 'DESC';
|
||||
|
||||
/* Like or what? */
|
||||
if ( \IPS\Settings::i()->reputation_point_types == 'like' )
|
||||
if ( \IPS\Content\Reaction::isLikeMode() )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['leader_rep_total'] = \IPS\Member::loggedIn()->language()->addToStack( 'leader_rep_total_likes' );
|
||||
\IPS\Member::loggedIn()->language()->words['leaderboard_history__desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'leaderboard_history_desc', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'leaderboard_history_likes') ) ) );
|
||||
@@ -202,7 +202,7 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
$endDate = \IPS\DateTime::ts( time() )->setTimezone( $timezone );
|
||||
|
||||
$firstRepDate = \IPS\Db::i()->select( 'MIN(rep_date)', 'core_reputation_index' )->first();
|
||||
$firstIndexDate = \IPS\Db::i()->select( 'MIN(index_date_updated)', 'core_search_index' )->first();
|
||||
$firstIndexDate = \IPS\Content\Search\Index::i()->firstIndexDate();
|
||||
$appWhere = null;
|
||||
$descApp = \IPS\Member::loggedIn()->language()->addToStack( 'leaderboard_in_all_apps' );
|
||||
|
||||
@@ -320,13 +320,14 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/* Got an app? */
|
||||
$appWhere = '';
|
||||
/* Do we want results for a specific app */
|
||||
$customApp = FALSE;
|
||||
|
||||
if ( isset( \IPS\Request::i()->in ) and isset( $areas[ \IPS\Request::i()->in ] ) )
|
||||
{
|
||||
$appWhere = " AND rep_class='" . \IPS\Db::i()->escape_string( $areas[ \IPS\Request::i()->in ][ 0 ] ) . "'";
|
||||
$descApp = \IPS\Member::loggedIn()->language()->addToStack( 'leaderboard_in_app', NULL, array( 'sprintf' => array( $areas[ \IPS\Request::i()->in ][ 1 ] ) ) );
|
||||
$customApp = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -341,7 +342,7 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
|
||||
$storeKey = NULL;
|
||||
$hashes = NULL;
|
||||
if ( ! $customStart and ! $customEnd AND ! $appWhere )
|
||||
if ( ! $customStart and ! $customEnd AND ! $customApp )
|
||||
{
|
||||
$storeKey = 'leaderHashes_' . \IPS\Request::i()->time . '-' . md5( implode( ',', \IPS\Member::loggedIn()->groups ) );
|
||||
|
||||
@@ -368,9 +369,9 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
/* Get rep hashes */
|
||||
$inner = \IPS\Db::i()->select( 'class_type_id_hash, SUM(rep_rating) as total_rep', array( 'core_reputation_index', 'x' ), array( 'rep_date BETWEEN ' . $date->getTimeStamp() . ' AND ' . $endDate->getTimeStamp() . $appWhere ), NULL, NULL, 'class_type_id_hash' );
|
||||
$repHashes = iterator_to_array( \IPS\Db::i()->select( 'class_type_id_hash, total_rep', $inner, NULL, 'x.total_rep desc', array( 0, 500 ) )->setKeyField('class_type_id_hash') );
|
||||
|
||||
|
||||
/* Now filter through permissions */
|
||||
$searchHashes = iterator_to_array( \IPS\Db::i()->select( 'index_class_type_id_hash', array( 'core_search_index', 'si' ), array( array( "( si.index_permissions = '*' OR " . \IPS\Db::i()->findInSet( 'si.index_permissions', \IPS\Member::loggedIn()->groups ) . ' AND si.index_hidden=0 )' ), array( \IPS\Db::i()->in( 'si.index_class_type_id_hash', array_keys( $repHashes ) ) ) ) )->setKeyField('index_class_type_id_hash') );
|
||||
$searchHashes = \IPS\Content\Search\Index::i()->hashesWithPermission( array_keys( $repHashes ), \IPS\Member::loggedIn() );
|
||||
|
||||
/* Filter out rep hashes not in search results */
|
||||
$hashes = array_slice( array_intersect_key( $repHashes, $searchHashes ), 0, 50 );
|
||||
@@ -386,7 +387,7 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
$or = array();
|
||||
$results = array();
|
||||
$preLoadMembers = array();
|
||||
|
||||
|
||||
if ( count( $hashes ) )
|
||||
{
|
||||
/* Now get the reputation data */
|
||||
@@ -395,25 +396,15 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
$data['total_rep'] = $hashes[ $data['class_type_id_hash'] ]['total_rep'];
|
||||
$repData[ $data['rep_class'] . '-' . $data['type_id'] ] = $data;
|
||||
$classes[ $data['rep_class'] ][] = $data['type_id'];
|
||||
|
||||
if ( ! empty( $data['member_id'] ) )
|
||||
{
|
||||
$preLoadMembers[] = $data['member_id'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $classes as $class => $ids )
|
||||
{
|
||||
$or[] = '( index_class=\'' . \IPS\Db::i()->escape_string( $class ) . '\' AND ' . \IPS\Db::i()->in( 'index_object_id', $ids ) . ')';
|
||||
$or[] = \IPS\Content\Search\ContentFilter::init( $class )->onlyInIds( $ids );
|
||||
}
|
||||
|
||||
/* Construct the query */
|
||||
$query = \IPS\Db::i()->select( '*', array( 'core_search_index', 'main' ), array( implode( ' OR ', $or ) ), NULL, NULL, NULL, NULL );
|
||||
|
||||
$array = iterator_to_array( $query );
|
||||
$sorted = array();
|
||||
|
||||
/* Manually sort */
|
||||
/* Query and manually sort */
|
||||
$array = \IPS\Content\Search\Query::init()->filterByContent( $or )->search()->getArrayCopy();
|
||||
foreach( $array as $index => $data )
|
||||
{
|
||||
if ( isset( $repData[ $data['index_class'] . '-' . $data['index_object_id'] ] ) )
|
||||
@@ -433,8 +424,13 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Get top rated contributors */
|
||||
$topContributors = array();
|
||||
|
||||
$innerQuery = \IPS\Db::i()->select( 'core_reputation_index.member_received as member, SUM(rep_rating) as rep', 'core_reputation_index', array( 'member_received>0 ' . $appWhere . ' and rep_date BETWEEN ' . intval( $date->getTimeStamp() ) . ' AND ' . intval( $endDate->getTimeStamp() ) ), NULL, NULL, 'member' );
|
||||
|
||||
$innerQueryWhere = array();
|
||||
$innerQueryWhere[] = array( 'member_received>0 ' . $appWhere . ' and rep_date BETWEEN ' . intval( $date->getTimeStamp() ) . ' AND ' . intval( $endDate->getTimeStamp() ) );
|
||||
$innerQueryWhere[] = \IPS\Db::i()->in( 'member_group_id', \IPS\Settings::i()->leaderboard_excluded_groups, TRUE );
|
||||
|
||||
$innerQuery = \IPS\Db::i()->select( 'core_reputation_index.member_received as member, SUM(rep_rating) as rep', 'core_reputation_index', $innerQueryWhere, NULL, NULL, 'member' )->join( 'core_members', array( 'core_reputation_index.member_received = core_members.member_id' ) );
|
||||
|
||||
foreach( \IPS\Db::i()->select( 'member, rep', array( $innerQuery, 'in' ), NULL, 'rep DESC', 4 )->setKeyField('member')->setValueField('rep') as $member => $rep )
|
||||
{
|
||||
$topContributors[ $member ] = $rep;
|
||||
@@ -455,7 +451,7 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Work out the description for popular content */
|
||||
if ( \IPS\Settings::i()->reputation_point_types == 'like' )
|
||||
if ( \IPS\Content\Reaction::isLikeMode() )
|
||||
{
|
||||
$popularResultsSingle = 'popular_results_single_desc';
|
||||
$popularResultsMany = 'popular_results_desc';
|
||||
@@ -481,6 +477,12 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
|
||||
\IPS\Output::i()->linkTags['canonical'] = (string) \IPS\Http\Url::internal( "app=core&module=discover&controller=popular&tab=leaderboard", 'front', 'leaderboard_leaderboard' );
|
||||
|
||||
/* If there are no results tell search engines not to index the page */
|
||||
if( !count( $results ) )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex';
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return \IPS\Theme::i()->getTemplate('popular')->popularWrapper( $results, $areas, $topContributors, $dates, $description, $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) ), $tzOffsetDifference );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user