Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

+34 -8
View File
@@ -1,12 +1,11 @@
<?php
/**
* @brief Template Plugin - Hex to RGB. Takes a CSS hex code and returns an RGB string
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 05 Jan 2016
* @version SVN_VERSION_NUMBER
*/
namespace IPS\Output\Plugin;
@@ -36,6 +35,15 @@ class _Hextorgb
* @return string Code to eval
*/
public static function runPlugin( $data, $options )
{
if( $data[0] !== '$' ){
$data = "'" . $data . "'";
}
return '\IPS\Output\Plugin\Hextorgb::convertToRGB(' . $data . ', ' . ( isset( $options['opacity'] ) ? $options['opacity'] : '1' ) . ')';
}
public static function convertToRGB( $data, $opacity )
{
$output = array();
@@ -45,6 +53,24 @@ class _Hextorgb
$data = \IPS\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 ) )
{
$data = \IPS\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 ] ) )
{
$opacity = \IPS\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 ) )
{
$opacity = \IPS\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 ) )
{
@@ -66,13 +92,13 @@ class _Hextorgb
$output[] = hexdec( \substr( $data, 4, 2 ) ); // B
}
if( isset( $options['opacity'] ) )
if( isset( $opacity ) && $opacity !== '1' )
{
return "'rgba(" . implode( ',', $output ) . "," . $options['opacity'] . ")'";
return "rgba(" . implode( ',', $output ) . "," . \str_replace( ',', '.', $opacity ) . ")";
}
else
{
return "'rgb(" . implode( ',', $output ) . ")'";
return "rgb(" . implode( ',', $output ) . ")";
}
}
}