Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -54,7 +54,7 @@ class _activeUsers extends \IPS\Widget
|
||||
$memberCount = 0;
|
||||
|
||||
/* Build WHERE clause */
|
||||
$parts = parse_url( (string) \IPS\Request::i()->url()->stripQueryString( array( 'page' ) ) );
|
||||
$parts = parse_url( (string) \IPS\Request::i()->url()->setPage() );
|
||||
|
||||
if ( \IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
{
|
||||
@@ -72,12 +72,12 @@ class _activeUsers extends \IPS\Widget
|
||||
unset( $members[ \IPS\Member::loggedIn()->member_id ] );
|
||||
}
|
||||
|
||||
$memberCount = count( $members );
|
||||
$memberCount = \count( $members );
|
||||
|
||||
/* If it's on the sidebar (rather than at the bottom), we want to limit it to 60 so we don't take too much space */
|
||||
if ( $this->orientation === 'vertical' and count( $members ) >= 60 )
|
||||
if ( $this->orientation === 'vertical' and \count( $members ) >= 60 )
|
||||
{
|
||||
$members = array_slice( $members, 0, 60 );
|
||||
$members = \array_slice( $members, 0, 60 );
|
||||
}
|
||||
|
||||
if( \IPS\Member::loggedIn()->member_id )
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -45,10 +45,7 @@ class _clubs extends \IPS\Widget
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'widget_feed_title', isset( $this->configuration['language_key'] ) ? NULL : \IPS\Member::loggedIn()->language()->addToStack( 'my_clubs' ), FALSE, array( 'app' => 'core', 'key' => ( isset( $this->configuration['language_key'] ) ? $this->configuration['language_key'] : NULL ) ) ) );
|
||||
|
||||
@@ -121,7 +118,7 @@ class _clubs extends \IPS\Widget
|
||||
{
|
||||
case 'Checkbox':
|
||||
case 'YesNo':
|
||||
if ( count( $values[ 'field_' . $field->id ] ) === 1 )
|
||||
if ( \count( $values[ 'field_' . $field->id ] ) === 1 )
|
||||
{
|
||||
$values['filters'][ $field->id ] = array_pop( $values[ 'field_' . $field->id ] );
|
||||
}
|
||||
@@ -132,7 +129,7 @@ class _clubs extends \IPS\Widget
|
||||
case 'Radio':
|
||||
case 'Select':
|
||||
$options = json_decode( $field->extra, TRUE );
|
||||
if ( count( $values[ 'field_' . $field->id ] ) > 0 and count( $values[ 'field_' . $field->id ] ) < count( $options ) )
|
||||
if ( \count( $values[ 'field_' . $field->id ] ) > 0 and \count( $values[ 'field_' . $field->id ] ) < \count( $options ) )
|
||||
{
|
||||
$values['filters'][ $field->id ] = array();
|
||||
foreach ( $values[ 'field_' . $field->id ] as $v )
|
||||
@@ -158,16 +155,26 @@ class _clubs extends \IPS\Widget
|
||||
{
|
||||
if ( \IPS\Settings::i()->clubs and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'clubs', 'front' ) ) )
|
||||
{
|
||||
$clubs = \IPS\Member\Club::clubs(
|
||||
$clubsCount = \IPS\Member\Club::clubs(
|
||||
\IPS\Member::loggedIn(),
|
||||
isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 10,
|
||||
isset( $this->configuration['sort_by'] ) ? $this->configuration['sort_by'] : 'last_activity',
|
||||
!isset( $this->configuration['club_filter_type'] ) or $this->configuration['club_filter_type'] == 'mine',
|
||||
isset( $this->configuration['filters'] ) ? $this->configuration['filters'] : array()
|
||||
isset( $this->configuration['filters'] ) ? $this->configuration['filters'] : array(),
|
||||
NULL,
|
||||
TRUE
|
||||
);
|
||||
|
||||
if ( is_object( $clubs ) AND $clubs->count( TRUE ) )
|
||||
if ( $clubsCount )
|
||||
{
|
||||
$clubs = \IPS\Member\Club::clubs(
|
||||
\IPS\Member::loggedIn(),
|
||||
isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 10,
|
||||
isset( $this->configuration['sort_by'] ) ? $this->configuration['sort_by'] : 'last_activity',
|
||||
!isset( $this->configuration['club_filter_type'] ) or $this->configuration['club_filter_type'] == 'mine',
|
||||
isset( $this->configuration['filters'] ) ? $this->configuration['filters'] : array()
|
||||
);
|
||||
|
||||
return $this->output(
|
||||
$clubs,
|
||||
isset( $this->configuration['language_key'] ) ? \IPS\Member::loggedIn()->language()->addToStack( $this->configuration['language_key'], FALSE, array( 'escape' => TRUE ) ) : \IPS\Member::loggedIn()->language()->addToStack( 'my_clubs' ),
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -32,6 +32,11 @@ class _guestSignUp extends \IPS\Widget
|
||||
*/
|
||||
public static $editorKey = 'block_guestsignup_message';
|
||||
|
||||
/**
|
||||
* @brief Language Key used to save the content
|
||||
*/
|
||||
public static $editorLangKey = 'widget_guestsignup_text';
|
||||
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
@@ -46,7 +51,7 @@ class _guestSignUp extends \IPS\Widget
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param String $uniqueKey Unique key for this specific instance
|
||||
* @param string $uniqueKey Unique key for this specific instance
|
||||
* @param array $configuration Widget custom configuration
|
||||
* @param null|string|array $access Array/JSON string of executable apps (core=sidebar only, content=IP.Content only, etc)
|
||||
* @param null|string $orientation Orientation (top, bottom, right, left)
|
||||
@@ -66,20 +71,17 @@ class _guestSignUp extends \IPS\Widget
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'block_guestsignup_title', NULL, TRUE, array( 'app'=>'core', 'key' =>'widget_guestsignup_title' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'block_guestsignup_message', NULL, TRUE, array(
|
||||
'app' => 'core',
|
||||
'key' => 'widget_guestsignup_text',
|
||||
'key' => static::$editorLangKey,
|
||||
'editor' => array(
|
||||
'app' => 'core',
|
||||
'key' => 'Widget',
|
||||
'autoSaveKey' => 'widget-' . $this->uniqueKey,
|
||||
'attachIds' => isset( $this->configuration['content'] ) ? array( 0, 0, 'widget_guestsignup_text' ) : NULL
|
||||
'attachIds' => isset( $this->configuration['content'] ) ? array( 0, 0, static::$editorLangKey ) : NULL
|
||||
),
|
||||
) ) );
|
||||
return $form;
|
||||
@@ -124,7 +126,7 @@ class _guestSignUp extends \IPS\Widget
|
||||
public function preConfig( $values )
|
||||
{
|
||||
\IPS\File::claimAttachments( 'widget-' . $this->uniqueKey, 0, 0, 'widget_guestsignup_text' );
|
||||
\IPS\Lang::saveCustom( 'core', 'widget_guestsignup_text', $values[ 'block_guestsignup_message' ] );
|
||||
\IPS\Lang::saveCustom( 'core', static::$editorLangKey, $values[ 'block_guestsignup_message' ] );
|
||||
\IPS\Lang::saveCustom( 'core', 'widget_guestsignup_title', $values[ 'block_guestsignup_title' ] );
|
||||
return $values;
|
||||
}
|
||||
@@ -151,7 +153,7 @@ class _guestSignUp extends \IPS\Widget
|
||||
}
|
||||
|
||||
$login = new \IPS\Login( \IPS\Http\Url::internal( 'app=core&module=system&controller=login', 'front', 'login' ) );
|
||||
return $this->output( $login, $title, $text );
|
||||
return $this->output( $login, $text, $title );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief invite Widget
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 06 Aug 2019
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* invite Widget
|
||||
*/
|
||||
class _invite extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'invite';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Initialise this widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
// Use this to perform any set up and to assign a template that is not in the following format:
|
||||
$this->template( array( \IPS\Theme::i()->getTemplate( 'widgets', $this->app, 'front' ), $this->key ) );
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ran before saving widget configuration
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$subject = \IPS\Member::loggedIn()->language()->addToStack('block_invite_subject', FALSE, array( 'sprintf' => array( \IPS\Settings::i()->board_name ), 'rawurlencode' => TRUE ) );
|
||||
$url = \IPS\Http\Url::internal( "" );
|
||||
|
||||
if( \IPS\Settings::i()->ref_on and \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$url = $url->setQueryString( array( '_rid' => \IPS\Member::loggedIn()->member_id ) );
|
||||
}
|
||||
|
||||
return $this->output( $subject, urlencode( $url ) );
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -40,14 +40,12 @@ class _members extends \IPS\Widget\StaticCache
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param \IPS\Helpers\Form|NULL $form Form helper
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
/* Block title */
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'widget_member_title', isset( $this->configuration['widget_member_title'] ) ? $this->configuration['widget_member_title'] : \IPS\Member::loggedIn()->language()->addToStack( 'widget_member_title_default' ) ) );
|
||||
@@ -120,7 +118,7 @@ class _members extends \IPS\Widget\StaticCache
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$where = array( array( '(name<>? and email<>?)', '', '' ) );
|
||||
$where = array( array( 'completed=?', true ) );
|
||||
$joins = array();
|
||||
|
||||
if ( ! empty( $this->configuration['widget_member_groups'] ) AND $this->configuration['widget_member_groups'] !== '*' )
|
||||
@@ -145,7 +143,7 @@ class _members extends \IPS\Widget\StaticCache
|
||||
$where[] = array( 'pp_reputation_points >= ?', $this->configuration['widget_member_rep'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $this->configuration['widget_member_online'] ) )
|
||||
if ( ! empty( $this->configuration['widget_member_online'] ) OR !isset( $this->configuration['widget_member_online'] ) )
|
||||
{
|
||||
$where[] = array( 'last_activity > ?', \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() );
|
||||
}
|
||||
@@ -221,7 +219,7 @@ class _members extends \IPS\Widget\StaticCache
|
||||
( isset( $this->configuration['widget_member_show'] ) and $this->configuration['widget_member_show'] !== -1 ) ? array( 0, $this->configuration['widget_member_show'] ) : 100
|
||||
);
|
||||
|
||||
if ( count( $joins ) )
|
||||
if ( \count( $joins ) )
|
||||
{
|
||||
foreach( $joins as $join )
|
||||
{
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief mostContributions Widget
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 19 Jul 2018
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* mostContributions Widget
|
||||
*/
|
||||
class _mostContributions extends \IPS\Widget\StaticCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'mostContributions';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Initialise this widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
/* Block title */
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'widget_feed_title', isset( $this->configuration['language_key'] ) ? NULL : \IPS\Member::loggedIn()->language()->addToStack( 'block_mostContributions' ), FALSE, array( 'app' => 'core', 'key' => ( isset( $this->configuration['language_key'] ) ? $this->configuration['language_key'] : NULL ) ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE, array( 'max' => 25 ) ) );
|
||||
|
||||
/* What are we showing? */
|
||||
$classes = array();
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'ContentRouter' ) as $contentRouter )
|
||||
{
|
||||
foreach ( $contentRouter->classes as $class )
|
||||
{
|
||||
$exploded = explode( '\\', $class );
|
||||
if ( \in_array( 'IPS\Content\Item', class_parents( $class ) ) )
|
||||
{
|
||||
if ( $class::incrementPostCount() )
|
||||
{
|
||||
$classes[ $exploded[1] ][] = $class;
|
||||
}
|
||||
if ( isset( $class::$commentClass ) )
|
||||
{
|
||||
$commentClass = $class::$commentClass;
|
||||
if ( $commentClass::incrementPostCount() )
|
||||
{
|
||||
$classes[ $exploded[1] ][] = $commentClass;
|
||||
}
|
||||
}
|
||||
if ( isset( $class::$reviewClass ) )
|
||||
{
|
||||
$reviewClass = $class::$reviewClass;
|
||||
if ( $reviewClass::incrementPostCount() )
|
||||
{
|
||||
$classes[ $exploded[1] ][] = $class::$reviewClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ( \in_array( 'IPS\Content\Comment', class_parents( $class ) ) )
|
||||
{
|
||||
if ( $class::incrementPostCount() )
|
||||
{
|
||||
$classes[ $exploded[1] ][] = $class;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$options = array();
|
||||
if( !empty ( $classes ) )
|
||||
{
|
||||
foreach ( $classes as $app => $areas )
|
||||
{
|
||||
if ( $app == 'core' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$options[ '__app_' . $app ] = array();
|
||||
foreach ( $areas as $item )
|
||||
{
|
||||
$options[ '__app_' . $app ][ $item ] = $item::$title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'most_contributions_area', isset( $this->configuration['most_contributions_area'] ) ? $this->configuration['most_contributions_area'] : "0", FALSE, array( 'options' => $options, 'multiple' => FALSE, 'unlimited' => '0', 'unlimitedLang' => "everything" ), NULL, NULL, NULL, 'most_contributions_area' ) );
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ran before saving widget configuration
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
if ( !isset( $this->configuration['language_key'] ) )
|
||||
{
|
||||
$this->configuration['language_key'] = 'widget_title_' . md5( mt_rand() );
|
||||
}
|
||||
$values['language_key'] = $this->configuration['language_key'];
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', $this->configuration['language_key'], $values['widget_feed_title'] );
|
||||
unset( $values['widget_feed_title'] );
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$members = array();
|
||||
$area = isset( $this->configuration['most_contributions_area'] ) ? $this->configuration['most_contributions_area'] : NULL;
|
||||
|
||||
/* If we're showing everything that's easy just show the content count */
|
||||
if( !$area )
|
||||
{
|
||||
$contributions = array( 'members' => new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_members', array( "member_posts > ?", 0 ), "member_posts DESC", array( 0,5 ) ), 'IPS\Member' ) );
|
||||
}
|
||||
/* A specific content type? That's more work */
|
||||
else
|
||||
{
|
||||
$contributions = $area::mostContributions( $this->configuration['number_to_show'] );
|
||||
}
|
||||
|
||||
if( !\count( $contributions['members'] ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['language_key'] ) )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $this->configuration['language_key'], FALSE, array( 'escape' => TRUE ) );
|
||||
}
|
||||
elseif ( isset( $this->configuration['widget_feed_title'] ) )
|
||||
{
|
||||
$title = $this->configuration['widget_feed_title'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'block_mostContributions' );
|
||||
}
|
||||
|
||||
return $this->output( $contributions, $area, $title );
|
||||
}
|
||||
|
||||
/**
|
||||
* Before the widget is removed, we can do some clean up
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
\IPS\Lang::deleteCustom( 'core', $this->configuration['language_key'] );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief mostSolved Widget
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 09 Mar 2020
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* mostSolved Widget
|
||||
*/
|
||||
class _mostSolved extends \IPS\Widget\StaticCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'mostSolved';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Initialise this widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE, array( 'max' => 25 ) ) );
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
/* How many? */
|
||||
$limit = isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5;
|
||||
|
||||
/* Work out who has got the most reputation this week... */
|
||||
$topSolvedThisWeek = array();
|
||||
foreach ( \IPS\Db::i()->select( 'member_id', 'core_solved_index', array( 'member_id > 0 AND solved_date>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1W' ) )->getTimestamp() ) ) as $memberId )
|
||||
{
|
||||
if ( !isset( $topSolvedThisWeek[ $memberId ] ) )
|
||||
{
|
||||
$topSolvedThisWeek[ $memberId ] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$topSolvedThisWeek[ $memberId ]++;
|
||||
}
|
||||
}
|
||||
arsort( $topSolvedThisWeek );
|
||||
$topSolvedThisWeek = \array_slice( $topSolvedThisWeek, 0, $limit, TRUE );
|
||||
|
||||
/* Load their data */
|
||||
if( \count( $topSolvedThisWeek ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_members', \IPS\Db::i()->in( 'member_id', array_keys( $topSolvedThisWeek ) ) ) as $member )
|
||||
{
|
||||
\IPS\Member::constructFromData( $member );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $this->output( $topSolvedThisWeek, $limit );
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -31,6 +31,11 @@ class _newsletter extends \IPS\Widget
|
||||
* @brief Language String Key used to store the editor content
|
||||
*/
|
||||
public static $editorKey = 'block_newsletter_signup';
|
||||
|
||||
/**
|
||||
* @brief Language Key used to save the content
|
||||
*/
|
||||
public static $editorLangKey = 'block_newsletter_signup';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
@@ -51,19 +56,16 @@ class _newsletter extends \IPS\Widget
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'block_newsletter_signup_text', NULL, TRUE, array(
|
||||
'app' => 'core',
|
||||
'key' => 'block_newsletter_signup',
|
||||
'key' => static::$editorLangKey,
|
||||
'editor' => array(
|
||||
'app' => 'core',
|
||||
'key' => 'Widget',
|
||||
'autoSaveKey' => 'widget-' . $this->uniqueKey,
|
||||
'attachIds' => isset( $this->configuration['content'] ) ? array( 0, 0, 'block_newsletter_signup' ) : NULL
|
||||
'attachIds' => isset( $this->configuration['content'] ) ? array( 0, 0, static::$editorLangKey ) : NULL
|
||||
),
|
||||
) ) );
|
||||
return $form;
|
||||
@@ -76,7 +78,7 @@ class _newsletter extends \IPS\Widget
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
\IPS\Lang::deleteCustom( 'core', 'block_newsletter_signup' );
|
||||
\IPS\Lang::deleteCustom( 'core', static::$editorLangKey );
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_attachments_map', array( array( 'location_key=?', 'core_Newsletterwidget' ) ) ) as $map )
|
||||
{
|
||||
@@ -133,7 +135,6 @@ class _newsletter extends \IPS\Widget
|
||||
$url = (string) \IPS\Request::i()->url();
|
||||
}
|
||||
|
||||
$ref = base64_encode( $url );
|
||||
return $this->output( $ref );
|
||||
return $this->output( $url );
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -62,10 +62,7 @@ class _promoted extends \IPS\Widget\PermissionCache
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'toshow', isset( $this->configuration['toshow'] ) ? $this->configuration['toshow'] : 5, TRUE ) );
|
||||
|
||||
@@ -82,7 +79,7 @@ class _promoted extends \IPS\Widget\PermissionCache
|
||||
$limit = isset ( $this->configuration['toshow'] ) ? $this->configuration['toshow'] : 5;
|
||||
$stream = \IPS\core\Promote::internalStream( $limit );
|
||||
|
||||
if ( ! count( $stream ) )
|
||||
if ( ! \count( $stream ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -20,7 +20,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* recentStatusUpdates Widget
|
||||
*/
|
||||
class _recentStatusUpdates extends \IPS\Widget\PermissionCache
|
||||
class _recentStatusUpdates extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
@@ -37,6 +37,28 @@ class _recentStatusUpdates extends \IPS\Widget\PermissionCache
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* @brief cacheKey
|
||||
*/
|
||||
public $cacheKey = "";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param String $uniqueKey Unique key for this specific instance
|
||||
* @param array $configuration Widget custom configuration
|
||||
* @param null|string|array $access Array/JSON string of executable apps (core=sidebar only, content=IP.Content only, etc)
|
||||
* @param null|string $orientation Orientation (top, bottom, right, left)
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $uniqueKey, array $configuration, $access=null, $orientation=null )
|
||||
{
|
||||
parent::__construct( $uniqueKey, $configuration, $access, $orientation );
|
||||
|
||||
/* We need to adjust the key for profile posts setting */
|
||||
$this->cacheKey = "widget_{$this->key}_" . $this->uniqueKey . '_' . md5( json_encode( $configuration ) . "_" . \IPS\Member::loggedIn()->language()->id . "_" . \IPS\Member::loggedIn()->skin . "_" . json_encode( \IPS\Member::loggedIn()->groups ) . "_" . $orientation . "_" . \IPS\core\Statuses\Status::canCreateFromCreateMenu() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
@@ -45,10 +67,7 @@ class _recentStatusUpdates extends \IPS\Widget\PermissionCache
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE ) );
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -46,10 +46,7 @@ class _relatedContent extends \IPS\Widget
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'toshow', isset( $this->configuration['toshow'] ) ? $this->configuration['toshow'] : 5, TRUE ) );
|
||||
|
||||
@@ -72,7 +69,7 @@ class _relatedContent extends \IPS\Widget
|
||||
|
||||
$related = \IPS\Dispatcher::i()->dispatcherController->getSimilarContent( $limit );
|
||||
|
||||
if( $related === NULL or !count( $related ) )
|
||||
if( $related === NULL or !\count( $related ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -40,14 +40,12 @@ class _stats extends \IPS\Widget\StaticCache
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param \IPS\Helpers\Form|NULL $form Form helper
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$mostOnline = json_decode( \IPS\Settings::i()->most_online, TRUE );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'stats_most_online', $mostOnline['count'], TRUE ) );
|
||||
@@ -87,7 +85,7 @@ class _stats extends \IPS\Widget\StaticCache
|
||||
$mostOnline = json_decode( \IPS\Settings::i()->most_online, TRUE );
|
||||
|
||||
/* fetch only successful registered members ; if this needs to be changed, please review the other areas where we have the name<>? AND email<>? condition */
|
||||
$where = array( 'name<>? AND email<>?', '', '' );
|
||||
$where = array( 'completed=?', true );
|
||||
|
||||
/* Member count */
|
||||
$stats['member_count'] = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', $where )->first();
|
||||
@@ -102,7 +100,7 @@ class _stats extends \IPS\Widget\StaticCache
|
||||
$stats['most_online'] = $mostOnline;
|
||||
|
||||
/* Last Registered Member */
|
||||
$where = array( array( "name IS NOT NULL AND name != '' AND temp_ban != -1 AND email != ''" ) );
|
||||
$where = array( array( "completed=1 AND temp_ban != -1" ) );
|
||||
$where[] = array( '( ! ' . \IPS\Db::i()->bitwiseWhere( \IPS\Member::$bitOptions['members_bitoptions'], 'bw_is_spammer' ) . ' )' );
|
||||
$where[] = array( 'member_id NOT IN(?)', \IPS\Db::i()->select( 'member_id', 'core_validating', array( 'new_reg=1' ) ) );
|
||||
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief stream Widget
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 26 Nov 2019
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* stream Widget
|
||||
*/
|
||||
class _stream extends \IPS\Widget\PermissionCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'stream';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Initialise this widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init(); //outputCss
|
||||
|
||||
/* Necessary CSS/JS */
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_streams.js', 'core' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_statuses.js', 'core' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/streams.css' ) );
|
||||
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/streams_responsive.css', 'core', 'front' ) );
|
||||
}
|
||||
|
||||
$apps = array();
|
||||
if( isset( $this->configuration['content'] ) and \strstr( $this->configuration['content'], ',' ) )
|
||||
{
|
||||
foreach( explode( ',', $this->configuration['content'] ) as $content )
|
||||
{
|
||||
$class = explode( '\\', $content );
|
||||
$apps[] = $class[1];
|
||||
}
|
||||
}
|
||||
|
||||
/* We will need specific CSS */
|
||||
foreach( \IPS\Application::enabledApplications() as $appDir => $app )
|
||||
{
|
||||
if ( isset( $this->configuration['content'] ) and $this->configuration['content'] === 0 or \in_array( $appDir, $apps ) )
|
||||
{
|
||||
if ( method_exists( $app, 'outputCss' ) )
|
||||
{
|
||||
$app::outputCss();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
$options = array();
|
||||
foreach( \IPS\Content::routedClasses( FALSE, FALSE, TRUE ) AS $class )
|
||||
{
|
||||
if ( \in_array( 'IPS\Content\Searchable', \class_implements( $class ) ) )
|
||||
{
|
||||
$options[ $class ] = \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' );
|
||||
}
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'title', $this->configuration['title'] ?? NULL, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'content', ( isset( $this->configuration['content'] ) AND $this->configuration['content'] !== 0 ) ? explode( ',', $this->configuration['content'] ) : 0, FALSE, array(
|
||||
'options' => $options,
|
||||
'multiple' => TRUE,
|
||||
'unlimited' => 0,
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'date', ( isset( $this->configuration['date'] ) ) ? $this->configuration['date'] : 'year', FALSE, array(
|
||||
'options' => array(
|
||||
'today' => 'today',
|
||||
'week' => 'week',
|
||||
'month' => 'month',
|
||||
'year' => 'year'
|
||||
)
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'max_results', $this->configuration['max_results'] ?? 5, TRUE, array( 'max' => 20 ) ) );
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ran before saving widget configuration
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
if ( \is_array( $values['content'] ) )
|
||||
{
|
||||
$save = [];
|
||||
foreach( $values['content'] AS $class )
|
||||
{
|
||||
$save[] = $class;
|
||||
}
|
||||
$values['content'] = implode( ',', $save );
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ( !isset( $this->configuration['content'] ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/* Set our content */
|
||||
if ( $this->configuration['content'] === 0 )
|
||||
{
|
||||
$stream = \IPS\core\Stream::allActivityStream();
|
||||
}
|
||||
else
|
||||
{
|
||||
$stream = new \IPS\core\Stream;
|
||||
$stream->classes = $this->configuration['content'];
|
||||
}
|
||||
|
||||
/* Set our date range */
|
||||
$stream->date_type = 'relative';
|
||||
$stream->date_relative_days = 365;
|
||||
if ( isset( $this->configuration['date'] ) )
|
||||
{
|
||||
switch( $this->configuration['date'] )
|
||||
{
|
||||
case 'today':
|
||||
$stream->date_relative_days = 1;
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$stream->date_relative_days = 7;
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$stream->date_relative_days = 30;
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
default:
|
||||
$stream->date_relative_days = 365;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set some defaults */
|
||||
$stream->id = 0;
|
||||
$stream->include_comments = TRUE;
|
||||
$stream->baseUrl = \IPS\Http\Url::internal( "app=core&module=discover&controller=streams", 'front', 'discover_all' );
|
||||
|
||||
/* Query */
|
||||
$query = $stream->query()->setLimit( $this->configuration['max_results'] ?? 5 );
|
||||
$results = $query->search();
|
||||
|
||||
if ( !\count( $results ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->output( $stream, $results, $this->configuration['title'] ?? \IPS\Member::loggedIn()->language()->addToStack( 'block_stream' ), $this->orientation );
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -45,10 +45,7 @@ class _topContributors extends \IPS\Widget\PermissionCache
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE, array( 'max' => 25 ) ) );
|
||||
return $form;
|
||||
@@ -78,10 +75,10 @@ class _topContributors extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
}
|
||||
arsort( $topContributorsThisWeek );
|
||||
$topContributorsThisWeek = array_slice( $topContributorsThisWeek, 0, $limit, TRUE );
|
||||
$topContributorsThisWeek = \array_slice( $topContributorsThisWeek, 0, $limit, TRUE );
|
||||
|
||||
/* Load their data */
|
||||
if( count( $topContributorsThisWeek ) )
|
||||
if( \count( $topContributorsThisWeek ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_members', \IPS\Db::i()->in( 'member_id', array_keys( $topContributorsThisWeek ) ) ) as $member )
|
||||
{
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief twitter Widget
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 30 Sep 2019
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* twitter Widget
|
||||
*/
|
||||
class _twitter extends \IPS\Widget\StaticCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'twitter';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'twitter_name', ( isset( $this->configuration['twitter_name'] ) ) ? $this->configuration['twitter_name'] : NULL, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'twitter_style', ( isset( $this->configuration['twitter_style'] ) ) ? $this->configuration['twitter_style'] : 'light', FALSE, array( 'options' => array(
|
||||
'light' => 'twitter_light',
|
||||
'dark' => 'twitter_dark'
|
||||
) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Color( 'twitter_color', ( isset( $this->configuration['twitter_color'] ) ) ? $this->configuration['twitter_color'] : NULL ), FALSE );
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ran before saving widget configuration
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ( isset( $this->configuration['twitter_name'] ) )
|
||||
{
|
||||
$locale = explode( \IPS\Member::loggedIn()->language()->bcp47(), '-' );
|
||||
return $this->output( $this->configuration['twitter_name'], $locale[0], $this->configuration['twitter_style'] ?? 'light', $this->configuration['twitter_color'] ?? NULL );
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -52,11 +52,9 @@ class _whosOnline extends \IPS\Widget
|
||||
|
||||
/* Init */
|
||||
$members = array();
|
||||
$memberCount = 0;
|
||||
$guests = 0;
|
||||
$anonymous = 0;
|
||||
|
||||
$users = \IPS\Session\Store::i()->getOnlineUsers( 0, 'desc', NULL, NULL, TRUE );
|
||||
$users = \IPS\Session\Store::i()->getOnlineUsers( \IPS\Session\Store::ONLINE_MEMBERS, 'desc', NULL, NULL, TRUE );
|
||||
foreach( $users as $row )
|
||||
{
|
||||
switch ( $row['login_type'] )
|
||||
@@ -69,10 +67,6 @@ class _whosOnline extends \IPS\Widget
|
||||
{
|
||||
$members[ $row['member_id'] ] = $row;
|
||||
}
|
||||
else
|
||||
{
|
||||
$guests += 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -80,20 +74,17 @@ class _whosOnline extends \IPS\Widget
|
||||
case \IPS\Session\Front::LOGIN_TYPE_ANONYMOUS:
|
||||
$anonymous += 1;
|
||||
break;
|
||||
|
||||
/* Guest */
|
||||
case \IPS\Session\Front::LOGIN_TYPE_GUEST:
|
||||
case \IPS\Session\Front::LOGIN_TYPE_INCOMPLETE:
|
||||
$guests += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$memberCount = count( $members );
|
||||
$memberCount = \count( $members );
|
||||
|
||||
/* Get an accurate guest count */
|
||||
$guests = \IPS\Session\Store::i()->getOnlineUsers( \IPS\Session\Store::ONLINE_GUESTS | \IPS\Session\Store::ONLINE_COUNT_ONLY, 'desc', NULL, NULL, TRUE );
|
||||
|
||||
/* If it's on the sidebar (rather than at the bottom), we want to limit it to 60 so we don't take too much space */
|
||||
if ( $this->orientation === 'vertical' and count( $members ) >= 60 )
|
||||
if ( $this->orientation === 'vertical' and \count( $members ) >= 60 )
|
||||
{
|
||||
$members = array_slice( $members, 0, 60 );
|
||||
$members = \array_slice( $members, 0, 60 );
|
||||
}
|
||||
|
||||
/* Add ourselves at the top of the list */
|
||||
|
||||
Reference in new issue
Block a user