Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,35 +11,52 @@
|
||||
namespace IPS\core\modules\admin\activitystats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\Statistics\Chart;
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Interval;
|
||||
use IPS\Helpers\Table\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Statistics
|
||||
*/
|
||||
class _search extends \IPS\Dispatcher\Controller
|
||||
class search extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'search_stats_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'search_stats_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -48,34 +65,34 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* Show button to adjust settings */
|
||||
\IPS\Output::i()->sidebar['actions']['settings'] = array(
|
||||
Output::i()->sidebar['actions']['settings'] = array(
|
||||
'icon' => 'cog',
|
||||
'primary' => TRUE,
|
||||
'title' => 'manage_searchstats',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=search&do=settings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('settings') )
|
||||
'link' => Url::internal( 'app=core&module=activitystats&controller=search&do=settings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('settings') )
|
||||
);
|
||||
|
||||
\IPS\Output::i()->sidebar['actions']['log'] = array(
|
||||
Output::i()->sidebar['actions']['log'] = array(
|
||||
'icon' => 'search',
|
||||
'title' => 'searchstats_log',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=search&do=log' ),
|
||||
'link' => Url::internal( 'app=core&module=activitystats&controller=search&do=log' ),
|
||||
);
|
||||
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'core', 'Search' )->getChart( \IPS\Http\Url::internal( "app=core&module=activitystats&controller=search" ) );
|
||||
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
$chart = Chart::loadFromExtension( 'core', 'Search' )->getChart( Url::internal( "app=core&module=activitystats&controller=search" ) );
|
||||
|
||||
if( \IPS\Request::i()->noheader AND \IPS\Request::i()->isAjax() )
|
||||
Output::i()->output = (string) $chart;
|
||||
|
||||
if( Request::i()->noheader AND Request::i()->isAjax() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_activitystats_search');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_activitystats_search');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,20 +100,20 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function settings()
|
||||
protected function settings() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'stats_search_prune', \IPS\Settings::i()->stats_search_prune, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL ) );
|
||||
$form = new Form;
|
||||
$form->add( new Interval( 'stats_search_prune', Settings::i()->stats_search_prune, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('after'), NULL ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$form->saveAsSettings( $values );
|
||||
\IPS\Session::i()->log( 'acplog__statssearch_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=search' ), 'saved' );
|
||||
Session::i()->log( 'acplog__statssearch_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=activitystats&controller=search' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('settings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'settings', $form, FALSE );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('settings');
|
||||
Output::i()->output = Theme::i()->getTemplate('global')->block( 'settings', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,10 +121,10 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function log()
|
||||
protected function log() : void
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_statistics', \IPS\Http\Url::internal( 'app=core&module=activitystats&controller=search&do=log' ), array( array( 'type=?', 'search' ) ) );
|
||||
$table = new Db( 'core_statistics', Url::internal( 'app=core&module=activitystats&controller=search&do=log' ), array( array( 'type=?', 'search' ) ) );
|
||||
$table->langPrefix = 'searchstats_';
|
||||
$table->quickSearch = 'value_4';
|
||||
|
||||
@@ -122,14 +139,14 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$table->parsers = array(
|
||||
'time' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val );
|
||||
return DateTime::ts( $val );
|
||||
}
|
||||
);
|
||||
|
||||
/* The table filters won't without this */
|
||||
\IPS\Output::i()->bypassCsrfKeyCheck = true;
|
||||
Output::i()->bypassCsrfKeyCheck = true;
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('searchstats_log');
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('searchstats_log');
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user