Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
+72
-21
@@ -258,6 +258,11 @@ class Output
|
||||
* @brief Additional CSS classes to add to body tag
|
||||
*/
|
||||
public array $bodyClasses = array();
|
||||
|
||||
/**
|
||||
* @brief Additional data attributes to add to body tag
|
||||
*/
|
||||
public array $bodyAttributes = array();
|
||||
|
||||
/**
|
||||
* @brief Elements that can be hidden from view
|
||||
@@ -279,11 +284,6 @@ class Output
|
||||
*/
|
||||
public ?string $base = NULL;
|
||||
|
||||
/**
|
||||
* @brief Allow default widgets with this output
|
||||
*/
|
||||
public bool $allowDefaultWidgets = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow page caching. This can be set at any point during controller execution to override defaults
|
||||
*/
|
||||
@@ -313,6 +313,9 @@ class Output
|
||||
{
|
||||
if ( Dispatcher::hasInstance() and Dispatcher::i()->controllerLocation !== 'setup' )
|
||||
{
|
||||
/* Additional security: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cross-Origin-Opener-Policy */
|
||||
$this->httpHeaders['Cross-Origin-Opener-Policy'] = "same-origin";
|
||||
|
||||
if ( Settings::i()->clickjackprevention == 'csp' )
|
||||
{
|
||||
$this->httpHeaders['Content-Security-Policy'] = Settings::i()->csp_header;
|
||||
@@ -380,6 +383,7 @@ class Output
|
||||
* @li admin.js or front.js (these are controllers, templates and models which are used everywhere for that location)
|
||||
* @li app.js (this is all models for a single application)
|
||||
* @li {location}_{section}.js (this is all controllers and templates for this section called ad-hoc when needed)
|
||||
* @li {component}.js - Load a Web Component from the Web Component files; Must set $location to "components" when using this option
|
||||
*
|
||||
* @param string $file Filename
|
||||
* @param string|null $app Application
|
||||
@@ -391,7 +395,7 @@ class Output
|
||||
$file = trim( $file, '/' );
|
||||
|
||||
/* Legacy code support. The following directories were moved to /static */
|
||||
if ( ( $app === "core" or $app === null) and $location === "interface" and preg_match( "/^(?:codemirror|fontawesome|themeeditor)/", $file ) )
|
||||
if ( ( $app === "core" or $app === null) and $location === "interface" and preg_match( "/^(?:codemirror|fontawesome)/", $file ) )
|
||||
{
|
||||
$file = "static/" . $file;
|
||||
}
|
||||
@@ -412,7 +416,12 @@ class Output
|
||||
}
|
||||
|
||||
$fileObj = null;
|
||||
if ( $app === null OR $app === 'global' )
|
||||
if ( $location === 'components' )
|
||||
{
|
||||
$fileName = "component_" . $file;
|
||||
$fileObj = static::_getJavascriptFileObject( 'global', 'root', $fileName );
|
||||
}
|
||||
else if ( $app === null OR $app === 'global' )
|
||||
{
|
||||
if ( in_array( $file, static::$globalJavascript ) )
|
||||
{
|
||||
@@ -894,15 +903,6 @@ class Output
|
||||
$faulty = Member::loggedIn()->language()->addToStack( 'faulty_app', FALSE, array( 'sprintf' => array( $app->_title, Url::internal( 'app=core&module=applications&controller=applications', 'admin' ) ) ) );
|
||||
}
|
||||
|
||||
/* Send default Cache Headers if this is a front-end page. */
|
||||
if ( !isset( $httpHeaders['Cache-Control'] ) AND ( $httpStatusCode == 404 OR $httpStatusCode == 403 ) )
|
||||
{
|
||||
if ( CACHE_PAGE_TIMEOUT AND $this->pageCaching AND Dispatcher::hasInstance() AND Dispatcher::i()->controllerLocation === 'front' AND !Member::loggedIn()->member_id )
|
||||
{
|
||||
$httpHeaders += static::getCacheHeaders( time(), CACHE_PAGE_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
/* Send output */
|
||||
if ( Application::appIsEnabled( 'cms' ) and isset( Settings::i()->cms_error_page ) and Settings::i()->cms_error_page )
|
||||
{
|
||||
@@ -910,6 +910,7 @@ class Output
|
||||
}
|
||||
else
|
||||
{
|
||||
Output::i()->setBodyAttributes();
|
||||
Output::i()->sidebar['enabled'] = FALSE;
|
||||
$this->sendOutput(Theme::i()->getTemplate('global', 'core')->globalTemplate($title, Theme::i()->getTemplate('global', 'core')->error($title, $message, $code, $extra, $member, $faulty, $httpStatusCode), array('app' => Dispatcher::i()->application ? Dispatcher::i()->application->directory : NULL, 'module' => Dispatcher::i()->module ? Dispatcher::i()->module->key : NULL, 'controller' => Dispatcher::i()->controller)), $httpStatusCode, 'text/html', $httpHeaders, FALSE );
|
||||
}
|
||||
@@ -1422,7 +1423,13 @@ JS;
|
||||
*/
|
||||
public function redirect( Url|string $url, ?string $message='', int $httpStatusCode=301, bool $forceScreen=FALSE ) : void
|
||||
{
|
||||
if( Request::i()->isAjax() )
|
||||
/* We have to cache here instead of waiting for sendOutput because this method can close the session */
|
||||
if ( DataLayer::hasInstance() and !$this->bypassDataLayer and Dispatcher::hasInstance() and Dispatcher::i()->controllerLocation == 'front' )
|
||||
{
|
||||
DataLayer::i()->cache();
|
||||
}
|
||||
|
||||
if( Request::i()->isAjax() and !Request::i()->bypassAjaxRedirect() )
|
||||
{
|
||||
if( !empty( $message ) )
|
||||
{
|
||||
@@ -1519,6 +1526,7 @@ JS;
|
||||
$this->title = Settings::i()->board_name;
|
||||
|
||||
Output::i()->sidebar['enabled'] = FALSE;
|
||||
Output::i()->setBodyAttributes();
|
||||
|
||||
DispatcherFront::i()->checkMfa();
|
||||
|
||||
@@ -1569,6 +1577,7 @@ JS;
|
||||
$this->title = Settings::i()->board_name;
|
||||
|
||||
Output::i()->sidebar['enabled'] = FALSE;
|
||||
Output::i()->setBodyAttributes();
|
||||
|
||||
/* Unset page token */
|
||||
unset( Output::i()->jsVars['page_token'] );
|
||||
@@ -1618,13 +1627,12 @@ JS;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( isset( $this->sidebar['widgets']['sidebar'] ) and count( $this->sidebar['widgets']['sidebar'] ) )
|
||||
if( isset( $this->sidebar['widgetareas']['sidebar'] ) and !empty( $this->sidebar['widgetareas']['sidebar'] ) )
|
||||
{
|
||||
return true;
|
||||
return (bool) $this->sidebar['widgetareas']['sidebar']->totalVisibleWidgets();
|
||||
}
|
||||
|
||||
|
||||
if( isset( $this->sidebar['widgetareas']['sidebar'] ) and !empty( $this->sidebar['widgetareas']['sidebar'] ) )
|
||||
if( isset( $this->sidebar['widgets']['sidebar'] ) and count( $this->sidebar['widgets']['sidebar'] ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1945,6 +1953,49 @@ JS;
|
||||
$this->jsonLd = array_merge( $this->jsonLd, $jsonLd );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the data attributes that will be applied to the body tag
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setBodyAttributes() : void
|
||||
{
|
||||
if( !empty( $this->globalControllers ) )
|
||||
{
|
||||
$this->bodyAttributes['controller'] = implode( ",", $this->globalControllers );
|
||||
}
|
||||
|
||||
if( $this->inlineMessage )
|
||||
{
|
||||
$this->bodyAttributes['message'] = $this->inlineMessage;
|
||||
}
|
||||
|
||||
$this->bodyAttributes['pageApp'] = Dispatcher::i()->application->directory;
|
||||
$this->bodyAttributes['pageLocation'] = 'front';
|
||||
|
||||
/* The module may not necessarily be set, in the event of an error (for example) */
|
||||
if( isset( Dispatcher::i()->module ) )
|
||||
{
|
||||
$this->bodyAttributes['pageModule'] = Dispatcher::i()->module->key;
|
||||
}
|
||||
|
||||
$this->bodyAttributes['pageController'] = Dispatcher::i()->controller;
|
||||
if( isset( Request::i()->id ) )
|
||||
{
|
||||
$this->bodyAttributes['id'] = (int) Request::i()->id;
|
||||
}
|
||||
|
||||
if( isset( Dispatcher::i()->dispatcherController ) and !Dispatcher::i()->dispatcherController->isContentPage )
|
||||
{
|
||||
$this->bodyAttributes['nocontent'] = '';
|
||||
}
|
||||
|
||||
if( $this->pageName )
|
||||
{
|
||||
$this->bodyAttributes['pageName'] = $this->pageName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Global search menu options
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user