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

+9 -6
View File
@@ -11,25 +11,28 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Address formatting
*/
class _Address
class Address
{
/**
* Run the plug-in
*
* @param string $data The initial data from the tag
* @param array $options Array of options
* @param string $data The initial data from the tag
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
if( mb_substr( $data, 0, 1 ) === '\\' OR mb_substr( $data, 0, 1 ) === '$' )
{
+8 -5
View File
@@ -11,21 +11,24 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Advertisement
*/
class _Advertisement
class Advertisement
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = FALSE;
public static bool $canBeUsedInCss = FALSE;
/**
* Run the plug-in
@@ -34,7 +37,7 @@ class _Advertisement
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
return "\IPS\core\Advertisement::loadByLocation( '{$data}' )";
}
+54
View File
@@ -0,0 +1,54 @@
<?php
/**
* @brief Custom Template Plugin - Template
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 28 April 2023
*/
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
use function array_keys;
use function defined;
use function in_array;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Template Plugin - Template
*/
class Customtemplate
{
/**
* @brief Can be used when compiling CSS
*/
public static bool $canBeUsedInCss = FALSE;
/**
* Run the plug-in
*
* @param string $data The initial data from the tag
* @param array $options Array of options
* @return array Code to eval
*/
public static function runPlugin( string $data, array $options ): array
{
$params = ( in_array( 'params', array_keys( $options ) ) ) ? $options['params'] : '';
$hook = ( in_array( 'hook', array_keys( $options ) ) ) ? $options['hook'] : '';
if( mb_strpos( $data, '$' ) === 0 )
{
$data = '{' . $data . '}';
}
return [ 'return' => "\\IPS\\Theme\\CustomTemplate::getCustomTemplatesForHookPoint( \"{$data}\", \"{$hook}\", [ {$params} ] )" ];
}
}
+9 -6
View File
@@ -11,30 +11,33 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - DateTime
*/
class _Datetime
class Datetime
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = FALSE;
public static bool $canBeUsedInCss = FALSE;
/**
* 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 array Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): array
{
$return = array();
$return['pre'] = '$val = ( ' . $data . ' instanceof \IPS\DateTime ) ? ' . $data . ' : \IPS\DateTime::ts( ' . $data . ' );';
+11 -7
View File
@@ -11,21 +11,25 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Expression
*/
class _Expression
class Expression
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = TRUE;
public static bool $canBeUsedInCss = TRUE;
/**
* Run the plug-in
@@ -34,15 +38,15 @@ class _Expression
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
if( isset( $options['raw'] ) AND $options['raw'] )
{
return \IPS\Theme::expandShortcuts( $data );
return Theme::expandShortcuts( $data );
}
else
{
return 'htmlspecialchars( ' . \IPS\Theme::expandShortcuts( $data ) . ', ENT_QUOTES | ENT_DISALLOWED, \'UTF-8\', FALSE )';
return '\IPS\Theme\Template::htmlspecialchars( ' . Theme::expandShortcuts( $data ) . ', ENT_QUOTES | ENT_DISALLOWED, \'UTF-8\', FALSE )';
}
}
}
+16 -10
View File
@@ -11,21 +11,26 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\File as SystemFile;
use IPS\Request;
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;
}
/**
* Template Plugin - File
*/
class _File
class File
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = TRUE;
public static bool $canBeUsedInCss = TRUE;
/**
* Run the plug-in
@@ -34,16 +39,16 @@ class _File
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
$extension = ( isset( $options['extension'] ) ? $options['extension'] : 'core_Attachment' );
$scheme = ( isset( $options['scheme'] ) ? $options['scheme'] : NULL );
$cacheBust = ( isset( $options['cb'] ) ? $options['cb'] : NULL );
$extension = ( $options['extension'] ?? 'core_Attachment' );
$scheme = ( $options['scheme'] ?? NULL );
$cacheBust = ( $options['cb'] ?? NULL );
$schemeString = $cbString = '';
if ( $scheme )
{
$fullScheme = ( \IPS\Request::i()->isSecure() ) ? 'https' : 'http';
$fullScheme = ( Request::i()->isSecure() ) ? 'https' : 'http';
$schemeString = ( $scheme == 'full' ) ? '->setScheme("' . $fullScheme .'")' : '->setScheme(NULL)';
}
@@ -51,7 +56,8 @@ class _File
{
$cbString = "->setQueryString( 'v', " . $cacheBust . ")";
}
if ( $data instanceof \IPS\File )
if ( $data instanceof SystemFile )
{
return "(string) " . $data . "->url" . $schemeString . $cbString;
}
+18 -13
View File
@@ -11,30 +11,35 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Member;
use function defined;
use function floatval;
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 - Filesize
*/
class _Filesize
class Filesize
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = FALSE;
public static bool $canBeUsedInCss = FALSE;
/**
* Run the plug-in
*
* @param string $data The initial data from the tag
* @param array $options Array of options
* @return array array( 'pre' => Code to eval before 'return', 'return' => Code to eval to return desired value )
* @return string array( 'pre' => Code to eval before 'return', 'return' => Code to eval to return desired value )
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
return '\IPS\Output\Plugin\Filesize::humanReadableFilesize( ' . $data . ( ( isset( $options['decimal'] ) and $options['decimal'] ) ? ', TRUE' : '' ) . ' )';
}
@@ -42,15 +47,15 @@ class _Filesize
/**
* Get human readable filesize (to 2SF)
*
* @param int $sizeInBytes Size in bytes
* @param int|null $sizeInBytes Size in bytes
* @param bool $decimal If TRUE, will calculate based on decimal figures rather than binary
* @param bool $json If TRUE, will format for json
* @param bool $get If TRUE, will get the language string rather than add to stack
* @return string
*/
public static function humanReadableFilesize( $sizeInBytes, $decimal=FALSE, $json=FALSE, $get=FALSE )
public static function humanReadableFilesize( ?int $sizeInBytes, bool $decimal=FALSE, bool $json=FALSE, bool $get=FALSE ) : string
{
$sizeInBytes = \floatval( $sizeInBytes );
$sizeInBytes = floatval( $sizeInBytes );
foreach ( array( 'Y' => 80, 'Z' => 70, 'E' => 60, 'P' => 50, 'T' => 40, 'G' => 30, 'M' => 20, 'k' => 10 ) as $sig => $pow )
{
@@ -59,7 +64,7 @@ class _Filesize
{
if ( $get )
{
return sprintf( \IPS\Member::loggedIn()->language()->get( 'filesize_' . $sig ), round( ( $sizeInBytes / $raised ), 2 ) );
return sprintf( Member::loggedIn()->language()->get( 'filesize_' . $sig ), round( ( $sizeInBytes / $raised ), 2 ) );
}
else
{
@@ -70,14 +75,14 @@ class _Filesize
$format['json'] = TRUE;
}
return \IPS\Member::loggedIn()->language()->addToStack( 'filesize_' . $sig, FALSE, $format );
return Member::loggedIn()->language()->addToStack( 'filesize_' . $sig, FALSE, $format );
}
}
}
if ( $get )
{
return sprintf( \IPS\Member::loggedIn()->language()->get( 'filesize_b' ), $sizeInBytes );
return sprintf( Member::loggedIn()->language()->get( 'filesize_b' ), $sizeInBytes );
}
else
{
@@ -88,7 +93,7 @@ class _Filesize
$format['json'] = TRUE;
}
return \IPS\Member::loggedIn()->language()->addToStack( 'filesize_b', FALSE, $format );
return Member::loggedIn()->language()->addToStack( 'filesize_b', FALSE, $format );
}
}
}
+28 -9
View File
@@ -11,21 +11,26 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use function defined;
use function intval;
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 - Font size
* @note this is still required as the ACP relies on this
*/
class _Fontsize
class Fontsize
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = TRUE;
public static bool $canBeUsedInCss = TRUE;
/**
* Run the plug-in
@@ -34,21 +39,35 @@ class _Fontsize
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
$number = 14;
/* Create the array for the ACP based on v4 font-sizes @todo review this! */
$sizes = [
'font_base' => 16,
'font_large' => 18,
'font_medium' => 14,
'font_small' => 13,
'font_x_large' => 20,
'font_x_small' => 12,
'font_2x_large' => 24,
'font_3x_large' => 30,
'font_4x_large' => 36,
'font_size' => 100,
];
// Is this a theme setting or a number?
if( preg_match('/^[0-9]+?$/', $data ) )
{
$number = \intval( $data );
$number = intval( $data );
}
else if ( isset( \IPS\Theme::i()->settings[ 'font_' . $data ] ) )
else if ( isset( $sizes[ 'font_' . $data ] ) )
{
$number = \IPS\Theme::i()->settings[ 'font_' . $data ];
$number = $sizes[ 'font_' . $data ];
}
$scale = isset( \IPS\Theme::i()->settings['font_size'] ) ? \intval( \IPS\Theme::i()->settings['font_size'] ) : 100;
$scale = $sizes['font_size'];
// Should we be scaling?
if( $scale !== 100 && ( !isset( $options['scale'] ) || $options['scale'] !== false ) )
+33 -25
View File
@@ -11,21 +11,29 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Settings;
use IPS\Theme;
use function defined;
use function str_replace;
use function strlen;
use function 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 - hextorgb
*/
class _Hextorgb
class Hextorgb
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = TRUE;
public static bool $canBeUsedInCss = TRUE;
/**
* Run the plug-in. Take #ffffff and returns 255,255,255, for example
@@ -34,7 +42,7 @@ class _Hextorgb
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
if( $data[0] !== '$' ){
$data = "'" . $data . "'";
@@ -52,62 +60,62 @@ class _Hextorgb
/**
* Convert Hex value to RGB
*
* @param string $data Hex color code
* @param string $opacity Opacity (0-1) or Setting/Theme Setting name
* @param string $data Hex color code
* @param string $opacity Opacity (0-1) or Setting/Theme Setting name
* @return string
*/
public static function convertToRGB( $data, $opacity )
public static function convertToRGB( string $data, string $opacity ): string
{
$output = array();
/* If a theme setting key has been passed in, then use that as the value */
if ( isset( \IPS\Theme::i()->settings[ $data ] ) )
if ( isset( Theme::i()->settings[ $data ] ) )
{
$data = \IPS\Theme::i()->settings[ $data ];
$data = Theme::i()->settings[ $data ];
}
/* If a regular setting key has been passed in, then use that as the value */
if ( isset( \IPS\Settings::i()->$data ) )
if ( isset( Settings::i()->$data ) )
{
$data = \IPS\Settings::i()->$data;
$data = Settings::i()->$data;
}
/* If a theme setting key has been passed in, then use that as the opacity */
if ( isset( \IPS\Theme::i()->settings[ $opacity ] ) )
if ( isset( Theme::i()->settings[ $opacity ] ) )
{
$opacity = \IPS\Theme::i()->settings[ $opacity ];
$opacity = Theme::i()->settings[ $opacity ];
}
/* If a regular setting key has been passed in, then use that as the opacity */
if ( isset( \IPS\Settings::i()->$opacity ) )
if ( isset( Settings::i()->$opacity ) )
{
$opacity = \IPS\Settings::i()->$opacity;
$opacity = Settings::i()->$opacity;
}
/* Basic validation */
if( !preg_match( "/^#?[0-9a-fA-F]+$/", $data ) OR ( \strlen( str_replace( '#', '', $data ) ) !== 3 AND \strlen( str_replace( '#', '', $data ) ) !== 6 ) )
if( !preg_match( "/^#?[0-9a-fA-F]+$/", $data ) OR ( strlen( str_replace( '#', '', $data ) ) !== 3 AND strlen( str_replace( '#', '', $data ) ) !== 6 ) )
{
return "htmlspecialchars( '" . $data . "', ENT_QUOTES | ENT_DISALLOWED, 'UTF-8', FALSE )";
}
$data = str_replace( '#', '', $data );
if ( \strlen( $data ) == 3 )
if ( strlen( $data ) == 3 )
{
$output[] = hexdec( \substr( $data, 0, 1 ) . \substr( $data, 0, 1 ) ); // R
$output[] = hexdec( \substr( $data, 1, 1 ) . \substr( $data, 1, 1 ) ); // G
$output[] = hexdec( \substr( $data, 2, 1 ) . \substr( $data, 2, 1 ) ); // B
$output[] = hexdec( substr( $data, 0, 1 ) . substr( $data, 0, 1 ) ); // R
$output[] = hexdec( substr( $data, 1, 1 ) . substr( $data, 1, 1 ) ); // G
$output[] = hexdec( substr( $data, 2, 1 ) . substr( $data, 2, 1 ) ); // B
}
else
{
$output[] = hexdec( \substr( $data, 0, 2 ) ); // R
$output[] = hexdec( \substr( $data, 2, 2 ) ); // G
$output[] = hexdec( \substr( $data, 4, 2 ) ); // B
$output[] = hexdec( substr( $data, 0, 2 ) ); // R
$output[] = hexdec( substr( $data, 2, 2 ) ); // G
$output[] = hexdec( substr( $data, 4, 2 ) ); // B
}
if( isset( $opacity ) && $opacity !== '1' )
{
return "rgba(" . implode( ',', $output ) . "," . \str_replace( ',', '.', $opacity ) . ")";
return "rgba(" . implode( ',', $output ) . "," . str_replace( ',', '.', $opacity ) . ")";
}
else
{
+8 -5
View File
@@ -11,21 +11,24 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Include PHP file
*/
class _Insert
class Insert
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = FALSE;
public static bool $canBeUsedInCss = FALSE;
/**
* Run the plug-in
@@ -34,7 +37,7 @@ class _Insert
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
return '\IPS\Output::safeInclude( "' . $data . '" )';
}
+16 -9
View File
@@ -11,21 +11,28 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Theme;
use function count;
use function defined;
use function strpos;
use function 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 - Lang
*/
class _Lang
class Lang
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = FALSE;
public static bool $canBeUsedInCss = FALSE;
/**
* Run the plug-in
@@ -34,17 +41,17 @@ class _Lang
* @param array $options Array of options
* @return array array( 'pre' => Code to eval before 'return', 'return' => Code to eval to return desired value )
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): array
{
$return = array();
$return['pre'] = null;
$params = array();
$data = \IPS\Theme::expandShortcuts( $data );
$data = Theme::expandShortcuts( $data );
if( \substr( $data, 0, 1 ) !== '\\' and \strpos( $data, '$' ) !== FALSE )
if( substr( $data, 0, 1 ) !== '\\' and strpos( $data, '$' ) !== FALSE )
{
if ( \strpos( $data, '$' ) === 0 )
if ( strpos( $data, '$' ) === 0 )
{
$data = '{' . $data . '}';
@@ -109,7 +116,7 @@ class _Lang
$vle = 'TRUE';
if( \count( $params ) )
if( count( $params ) )
{
$vle = 'FALSE';
}
+9 -6
View File
@@ -11,21 +11,24 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Member Data
*/
class _Member
class Member
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = FALSE;
public static bool $canBeUsedInCss = FALSE;
/**
* Run the plug-in
@@ -34,14 +37,14 @@ class _Member
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
if ( $data !== 'link()' and isset( $options['group'] ) )
{
$data = "group['{$data}']";
}
$raw = ( isset( $options['raw'] ) AND $options['raw'] ) ? TRUE : FALSE;
$raw = ( isset( $options['raw'] ) AND $options['raw'] );
if ( isset( $options['id'] ) )
{
+8 -5
View File
@@ -11,21 +11,24 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Number
*/
class _Number
class Number
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = FALSE;
public static bool $canBeUsedInCss = FALSE;
/**
* Run the plug-in
@@ -34,7 +37,7 @@ class _Number
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
if ( isset( $options['format'] ) and $options['format'] === 'short' )
{
+12 -8
View File
@@ -11,35 +11,39 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use function defined;
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 - Vendor prefix
*/
class _Prefix
class Prefix
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = TRUE;
public static bool $canBeUsedInCss = TRUE;
/**
* Defined here so that we can remove names later as browser support for the non-prefixed version improves, without changing our css.
*
* @brief The styles this plugin will prefix
*/
protected static $supportedStyles = array(
protected static array $supportedStyles = array(
'user-select'
);
/**
* @brief Supported vendor prefixes
*/
protected static $prefixes = array( '-webkit-', '-moz-', '-ms-', '-o-', '' );
protected static array $prefixes = array( '-webkit-', '-moz-', '-ms-', '-o-', '' );
/**
* Run the plug-in
@@ -49,9 +53,9 @@ class _Prefix
* @return string Code to eval
* @note Occasionally a style isn't consistent between browsers, so simply adding a prefix isn't always sufficient - you may need other CSS to resolve browser inconsistencies
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
if ( \in_array( $data, static::$supportedStyles ) )
if ( in_array( $data, static::$supportedStyles ) )
{
$output = array();
+10 -7
View File
@@ -11,21 +11,24 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Request
*/
class _Request
class Request
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = FALSE;
public static bool $canBeUsedInCss = FALSE;
/**
* Run the plug-in
@@ -34,15 +37,15 @@ class _Request
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
if( isset( $options['raw'] ) AND $options['raw'] )
{
return "\IPS\Request::i()->$data";
return "isset( \IPS\Widget\Request::i()->$data ) ? \IPS\Widget\Request::i()->$data : NULL";
}
else
{
return "htmlspecialchars( \IPS\Request::i()->$data, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8', FALSE )";
return "isset( \IPS\Widget\Request::i()->$data ) ? htmlspecialchars( \IPS\Widget\Request::i()->$data, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8', FALSE ): NULL";
}
}
}
+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} )";
}
}
+8 -5
View File
@@ -11,22 +11,25 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Setting
*/
class _Setting
class Setting
{
/**
* @brief Can be used when compiling CSS
* @note Using setting in plugins will require a rebuild of the CSS file they're used in when the setting is changed
*/
public static $canBeUsedInCss = TRUE;
public static bool $canBeUsedInCss = TRUE;
/**
* Run the plug-in
@@ -35,7 +38,7 @@ class _Setting
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
if ( isset( $options['escape'] ) )
{
+8 -5
View File
@@ -11,21 +11,24 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Strip HTML tags
*/
class _Striptags
class Striptags
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = FALSE;
public static bool $canBeUsedInCss = FALSE;
/**
* Run the plug-in
@@ -34,7 +37,7 @@ class _Striptags
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
return "strip_tags( $data )";
}
+18 -11
View File
@@ -11,32 +11,39 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Theme;
use function defined;
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 - Template
*/
class _Template
class Template
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = FALSE;
public static bool $canBeUsedInCss = FALSE;
/**
* Run the plug-in
*
* @param string $data The initial data from the tag
* @param array $options Array of options
* @return string Code to eval
* @param string $data The initial data from the tag
* @param array $options Array of options
* @param string|null $functionName
* @param string $calledClass
* @return array|string Code to eval
*/
public static function runPlugin( $data, $options, $functionName=NULL, $calledClass='IPS\Theme' )
public static function runPlugin( string $data, array $options, ?string $functionName=NULL, string $calledClass='IPS\Theme' ): array|string
{
$params = ( \in_array( 'params', array_keys( $options ) ) ) ? $options['params'] : '';
$params = ( in_array( 'params', array_keys( $options ) ) ) ? $options['params'] : '';
if( mb_strpos( $data, '$' ) === 0 )
{
$data = '{' . $data . '}';
@@ -63,7 +70,7 @@ class _Template
if ( isset( $options['if'] ) )
{
$it['pre'] = "if ( " . \IPS\Theme::expandShortcuts( $options['if'] ) . " ):\n";
$it['pre'] = "if ( " . Theme::expandShortcuts( $options['if'] ) . " ):\n";
$it['post'] = "\nendif;";
}
+60 -15
View File
@@ -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 "";
}
}
}
+8 -5
View File
@@ -11,21 +11,24 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Truncate
*/
class _Truncate
class Truncate
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = TRUE;
public static bool $canBeUsedInCss = TRUE;
/**
* Run the plug-in
@@ -34,7 +37,7 @@ class _Truncate
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
if( !$options['length'] )
{
+14 -8
View File
@@ -11,21 +11,27 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Http\Url as HttpUrl;
use function defined;
use function in_array;
use function 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 - URL
*/
class _Url
class Url
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = TRUE;
public static bool $canBeUsedInCss = TRUE;
/**
* Run the plug-in
@@ -34,7 +40,7 @@ class _Url
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
$csrf = '';
@@ -43,7 +49,7 @@ class _Url
$csrf = ' . "&csrfKey=" . \IPS\Session::i()->csrfKey';
}
$location = ( \in_array( 'base', array_keys( $options ) ) ) ? '"' . $options['base'] . '"' : 'null';
$location = ( in_array( 'base', array_keys( $options ) ) ) ? '"' . $options['base'] . '"' : 'null';
if ( !isset( $options['seoTemplate'] ) )
{
@@ -60,7 +66,7 @@ class _Url
if ( !isset( $options['protocol'] ) )
{
$options['protocol'] = \IPS\Http\Url::PROTOCOL_AUTOMATIC;
$options['protocol'] = HttpUrl::PROTOCOL_AUTOMATIC;
}
$fragment = "";
@@ -74,7 +80,7 @@ class _Url
if ( isset( $options['ref'] ) )
{
/* Is this a variable or other dynamic thing? */
if ( \in_array( \substr( $options['ref'], 0, 1 ), array( '(', '$', '\\' ) ) )
if ( in_array( substr( $options['ref'], 0, 1 ), array( '(', '$', '\\' ) ) )
{
$ref = "->addRef(";
$ref .= $options['ref'];
+8 -5
View File
@@ -11,21 +11,24 @@
namespace IPS\Output\Plugin;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
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;
}
/**
* Template Plugin - Truncate
*/
class _Wordbreak
class Wordbreak
{
/**
* @brief Can be used when compiling CSS
*/
public static $canBeUsedInCss = TRUE;
public static bool $canBeUsedInCss = TRUE;
/**
* Run the plug-in
@@ -35,7 +38,7 @@ class _Wordbreak
* @param array $options Array of options
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
public static function runPlugin( string $data, array $options ): string
{
return "htmlspecialchars( {$data}, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8', FALSE )";
}