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,49 +11,94 @@
|
||||
namespace IPS\Output\Plugin;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use InvalidArgumentException;
|
||||
use IPS\cloud\extensions\core\AccountSettings\Expert;
|
||||
use IPS\Log;
|
||||
use IPS\Theme as SystemTheme;
|
||||
use IPS\Theme\Editor\Setting;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function mb_substr;
|
||||
|
||||
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 settings
|
||||
*/
|
||||
class _Theme
|
||||
class Theme
|
||||
{
|
||||
/**
|
||||
* @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
|
||||
* @return string Code to eval
|
||||
* @return mixed Code to eval
|
||||
* @note Using this plugin to call the sharer logos or favicon is deprecated and will be removed in a future version
|
||||
*/
|
||||
public static function runPlugin( $data, $options )
|
||||
public static function runPlugin( string $data, array $options ): mixed
|
||||
{
|
||||
switch( $data )
|
||||
{
|
||||
case 'headerHtml':
|
||||
return \IPS\Theme::i()->getHeaderAndFooter()['header'];
|
||||
break;
|
||||
return "\IPS\Theme::i()->getHeaderAndFooter( 'header' )";
|
||||
|
||||
case 'footerHtml':
|
||||
return \IPS\Theme::i()->getHeaderAndFooter()['footer'];
|
||||
break;
|
||||
return "\IPS\Theme::i()->getHeaderAndFooter( 'footer' )";
|
||||
|
||||
case 'logo_front':
|
||||
return "\IPS\Theme::i()->logo_front";
|
||||
break;
|
||||
|
||||
case 'logo_height':
|
||||
return ( isset( \IPS\Theme::i()->logo['front']['height'] ) ) ? '\IPS\Theme::i()->logo[\'front\'][\'height\']' : 100;
|
||||
break;
|
||||
return ( isset( SystemTheme::i()->logo['front']['height'] ) ) ? '\IPS\Theme::i()->logo[\'front\'][\'height\']' : 100;
|
||||
|
||||
case 'custom_css_for_output':
|
||||
return "\IPS\Theme::i()->getCustomCssForOutput()";
|
||||
|
||||
case 'custom_css':
|
||||
return "\IPS\Theme::i()->custom_css";
|
||||
|
||||
case "scheme":
|
||||
return "\IPS\Theme::i()->getCurrentCSSScheme()";
|
||||
|
||||
case 'id':
|
||||
return "\IPS\Theme::i()->id";
|
||||
default:
|
||||
return ( isset( \IPS\Theme::i()->settings[ $data ] ) ) ? "\IPS\Theme::i()->settings['{$data}']" : '';
|
||||
break;
|
||||
try
|
||||
{
|
||||
if ( mb_substr( $data, 0, 4 ) === 'css.' or mb_substr( $data, 0, 4 ) === 'var.' )
|
||||
{
|
||||
$variable = mb_substr( $data, 4 );
|
||||
$cssVariables = SystemTheme::i()->getCssVariables();
|
||||
|
||||
if( array_key_exists( $variable, $cssVariables ) )
|
||||
{
|
||||
return "\IPS\Theme::i()->getParsedCssVariableFromKey( '{$variable}' )";
|
||||
}
|
||||
return '';
|
||||
}
|
||||
else if ( mb_substr( $data, 0, 5 ) === 'view.' )
|
||||
{
|
||||
$variable = mb_substr( $data, 5 );
|
||||
return "\IPS\Theme::i()->getLayoutValue('{$variable}')";
|
||||
}
|
||||
|
||||
return ( array_key_exists( $data, SystemTheme::i()->settings ) ) ? "\IPS\Theme::i()->settings['{$data}']" : '';
|
||||
}
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
Log::log( $e, 'template_error' );
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user