Invision Power Services, Inc.
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 18 Feb 2013
*/
namespace IPS;
/* To prevent PHP errors (extending class does not exist) revealing path */
use Exception;
use IPS\Api\Exception as ApiException;
use IPS\Application\Module;
use IPS\Content\Controller;
use IPS\cms\Pages\Page;
use IPS\Content\Search\SearchContent;
use IPS\core\AdminNotification;
use IPS\core\Advertisement;
use IPS\core\DataLayer;
use IPS\Data\Cache;
use IPS\Data\Store;
use IPS\Dispatcher\Front as DispatcherFront;
use IPS\Helpers\Table\Content;
use IPS\Http\Url;
use IPS\Http\Url\Friendly;
use IPS\Http\Url\Internal;
use IPS\Output\Javascript;
use IPS\Output\System as SystemOutput;
use IPS\Session\Front;
use IPS\Widget\Area;
use OutOfRangeException;
use RuntimeException;
use UnderflowException;
use function array_merge;
use function array_slice;
use function count;
use function defined;
use function function_exists;
use function get_called_class;
use function in_array;
use function intval;
use function is_array;
use function json_encode;
use function ob_start;
use function stristr;
use function strlen;
use function strpos;
use function strstr;
use function substr;
use const JSON_HEX_AMP;
use const JSON_HEX_APOS;
use const JSON_HEX_TAG;
use const JSON_PRETTY_PRINT;
use const JSON_UNESCAPED_SLASHES;
use const LIVE_TOPICS_DEV;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Output Class
*/
class Output
{
/**
* @brief HTTP Statuses
* @see RFC 2616
*/
public static array $httpStatuses = array( 100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 429 => 'Too Many Requests', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported' );
/**
* @brief Singleton Instance
*/
protected static ?Output $instance = NULL;
/**
* @brief Global javascript bundles
*/
public static array $globalJavascript = array( 'admin.js', 'front.js', 'framework.js', 'library.js' );
/**
* @brief Javascript map of file object URLs
*/
protected static ?array $javascriptObjects = null;
/**
* @brief File object classes
*/
protected static array $fileObjectClasses = array();
/**
* @brief Meta tags for the current page
*/
public array $metaTags = array();
/**
* @brief Custom meta tags for the current page
*/
public array $customMetaTags = array();
/**
* @brief Automatic meta tags for the current page
*/
public array $autoMetaTags = array();
/**
* @brief Other `` tags
*/
public array $linkTags = array();
/**
* @brief RSS feeds for the current page
*/
public array $rssFeeds = array();
/**
* @brief Custom meta tag page title
*/
public string $metaTagsTitle = '';
/**
* @brief Requested URL fragment for meta tag editing
*/
public string $metaTagsUrl = '';
/**
* @brief Custom Header
*/
public ?string $customHeader = NULL;
/**
* @brief Custom Header
*/
public ?array $outputTemplate = NULL;
public string $headerMessage;
/**
* Get instance
*
* @return Output
*/
public static function i() : static
{
if( static::$instance === NULL )
{
$classname = get_called_class();
static::$instance = new $classname;
}
/* Inline Message */
if( $message = static::getInlineMessage() )
{
if( !Request::i()->isAjax() )
{
static::$instance->inlineMessage = $message;
static::setInlineMessage();
}
}
return static::$instance;
}
/**
* @brief Additional HTTP Headers
*/
public array $httpHeaders = array(
'X-XSS-Protection' => '0', // This is so when we post contents with scripts (which is possible in the editor, like when embedding a Twitter tweet) the broswer doesn't block it
);
/**
* @brief Stored Page Title
*/
public string $title = '';
/**
* @brief Default page title (may differ from $title if the meta tag editor was used)
*/
public string $defaultPageTitle = '';
/**
* @brief Should the title show in the header (ACP only)?
*/
public bool $showTitle = TRUE;
/**
* @brief Stored Content to output
*/
public string $output = '';
/**
* @brief URLs for CSS files to include
*/
public array $cssFiles = array();
/**
* @brief URLs for JS files to include
*/
public array $jsFiles = array();
/**
* @brief URLs for JS files to include with async="true"
*/
public array $jsFilesAsync = array();
/**
* @brief Other variables to hand to the JavaScript
*/
public array $jsVars = array();
/**
* @brief Other raw JS - this is included inside an existing `