Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+40 -10
View File
@@ -11,37 +11,67 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\Application;
use IPS\Data\Cache;
use IPS\IPS;
use IPS\Member;
use IPS\Theme;
use function array_pop;
use function count;
use function defined;
use function explode;
use function implode;
use function in_array;
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;
}
/**
* Template Plugin - Theme Resource (image, font, theme-specific JS, etc)
*/
class _Resource
class Resource
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = TRUE;
public static bool $canBeUsedInCss = TRUE;
/**
* Run the plug-in
*
* @param string $data The initial data from the tag
* @param array $options Array of options
* @param string $context The name of the calling function
* @param string $data The initial data from the tag
* @param array $options Array of options
* @param string $context The name of the calling function
* @return string Code to eval
*/
public static function runPlugin( $data, $options, $context )
public static function runPlugin( string $data, array $options, string $context ): string
{
$exploded = explode( '_', $context );
$app = ( isset( $options['app'] ) ? $options['app'] : ( isset( $exploded[1] ) ? $exploded[1] : '' ) );
$location = ( isset( $options['location'] ) ? $options['location'] : ( isset( $exploded[2] ) ? $exploded[2] : '' ) );
$app = ( $options['app'] ?? ( $exploded[1] ?? 'core' ) );
$location = ( $options['location'] ?? ( $exploded[2] ?? 'front' ) );
$noProtocol = ( isset( $options['noprotocol'] ) ) ? $options['noprotocol'] : "false";
if ( ( ! \IPS\IN_DEV or Application::areWeBuilding() ) and isset( $options['inCss'] ) and $options['inCss'] and $app and in_array( $app, IPS::$ipsApps ) )
{
/* We can use a relative path */
$paths = explode( '/', $data );
$name = array_pop( $paths );
$path = ( count( $paths ) ) ? ( '/' . implode( '/', $paths ) . '/' ) : '/';
$hash = Theme::makeBuiltTemplateLookupHash( $app, $location, $path );
if ( $location === 'interface' )
{
return '"../../applications/' . $app . '/interface/' . $data . '"';
}
return '"../resources/' . $app . '_' . $hash . '_' . $name . '"';
}
return "\\IPS\\Theme::i()->resource( \"{$data}\", \"{$app}\", '{$location}', {$noProtocol} )";
}
}