Version 4.3.6

This commit is contained in:
Neo committed 2025-12-19 05:49:12 -08:00
1 parent fe1acf984a
commit 1a0c7fd3c2
609 files changed
+14707 -5726

No files matched your search

+2 -1
View File
@@ -366,7 +366,7 @@ class _Theme extends \IPS\Theme\Dev\Theme
unlink( $dirToWrite . '/lang.php' );
}
$languageStrings = \IPS\Db::i()->select( 'word_key, word_default', 'core_sys_lang_words', array( 'word_theme=?', static::$currentThemeId ) )->setKeyField('word_key')->setValueField('word_default');
$languageStrings = \IPS\Db::i()->select( 'word_key, word_default', 'core_sys_lang_words', array( 'word_theme=? and lang_id=?', static::$currentThemeId, \IPS\Lang::defaultLanguage() ) )->setKeyField('word_key')->setValueField('word_default');
if( count( $languageStrings ) )
{
@@ -385,6 +385,7 @@ class _Theme extends \IPS\Theme\Dev\Theme
}
@\file_put_contents( $dirToWrite . '/lang.php', '<?' . "php\n\n{$langToWrite}\n" );
@chmod( $dirToWrite . '/lang.php', \IPS\IPS_FILE_PERMISSION );
return $dirToWrite;
}
+2 -2
View File
@@ -794,7 +794,7 @@ class _Theme extends \IPS\Theme
}
else
{
@chmod( $dirToWrite, IPS_FOLDER_PERMISSION );
@chmod( $dirToWrite, \IPS\IPS_FOLDER_PERMISSION );
}
}
@@ -830,7 +830,7 @@ class _Theme extends \IPS\Theme
}
else
{
@chmod( $dirToWrite, IPS_FOLDER_PERMISSION );
@chmod( $dirToWrite, \IPS\IPS_FOLDER_PERMISSION );
}
}
+20 -13
View File
@@ -45,22 +45,29 @@ class _SandboxedTemplate
*/
public function __call( $name, $args )
{
if ( !method_exists( $this->template, $name ) )
try
{
return "<span style='background:black;color:white;padding:6px;'>[[Template {$this->template->app}/{$this->template->templateLocation}/{$this->template->templateName}/{$name} does not exist. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]</span>";
if ( !method_exists( $this->template, $name ) )
{
return "<span style='background:black;color:white;padding:6px;'>[[Template {$this->template->app}/{$this->template->templateLocation}/{$this->template->templateName}/{$name} does not exist. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]</span>";
}
else
{
try
{
return $this->template->$name( ...$args );
}
catch ( \ErrorException $e )
{
throw new \Error( $e );
}
}
}
else
catch( \Throwable $e )
{
try
{
return $this->template->$name( ...$args );
}
catch ( \ErrorException $e )
{
\IPS\Log::log( $e, 'template_error' );
return "<span style='background:black;color:white;padding:6px;'>[[Template {$this->template->app}/{$this->template->templateLocation}/{$this->template->templateName}/{$name} is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]</span>";
}
\IPS\Log::log( $e, 'template_error' );
return "<span style='background:black;color:white;padding:6px;'>[[Template {$this->template->app}/{$this->template->templateLocation}/{$this->template->templateName}/{$name} is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]</span>";
}
}
}
+34 -8
View File
@@ -541,7 +541,7 @@ class _Theme extends \IPS\Node\Model
*/
public function css( $file, $app=NULL, $location=NULL )
{
$app = $app ?: \IPS\Request::i()->app;
$app = $app ?: \IPS\Dispatcher::i()->application->directory;
$location = $location ?: \IPS\Dispatcher::i()->controllerLocation;
$paths = explode( '/', $file );
$name = array_pop( $paths );
@@ -620,7 +620,7 @@ class _Theme extends \IPS\Node\Model
*/
public function resource( $path, $app=NULL, $location=NULL, $noProtocol=FALSE )
{
$app = $app ?: \IPS\Request::i()->app;
$app = $app ?: \IPS\Dispatcher::i()->application->directory;
$location = $location ?: \IPS\Dispatcher::i()->controllerLocation;
$paths = explode( '/', $path );
$name = array_pop( $paths );
@@ -672,7 +672,7 @@ class _Theme extends \IPS\Node\Model
$resource = \IPS\Db::i()->select( '*', 'core_theme_resources', array( 'resource_set_id=? AND resource_app=? AND resource_location=? AND resource_path=? AND resource_name=?', $this->id, $app, $location, $path, $name ) )->first();
$resourceMap[ $key ] = (string) \IPS\File::create( 'core_Theme', $key, $resource['resource_data'], 'set_resources_' . $this->id, FALSE, NULL, FALSE );
$resourceMap[ $key ] = (string) \IPS\File::create( 'core_Theme', $key, $resource['resource_data'], 'set_resources_' . $this->id, TRUE, NULL, FALSE );
\IPS\Db::i()->update( 'core_theme_resources', array( 'resource_added' => time(), 'resource_filename' => $resourceMap[ $key ] ), array( 'resource_id=?', $resource['resource_id'] ) );
@@ -775,7 +775,7 @@ class _Theme extends \IPS\Node\Model
if ( $attempts === 5 )
{
/* Rebuild in progress */
\IPS\Log::log( "Template store key: {$key} rebuilding and requested again ({$app}, {$location}, {$group})", "template_store_building" );
\IPS\Log::debug( "Template store key: {$key} rebuilding and requested again ({$app}, {$location}, {$group})", "template_store_building" );
/* Since we can't do anything else, this ends up just being an uncaught exception - show the error page right away to avoid the unnecessary logging */
\IPS\IPS::genericExceptionPage();
@@ -1287,6 +1287,14 @@ class _Theme extends \IPS\Node\Model
) );
}
/* Copy any language keys */
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', array( 'word_theme=?', $originalId ) ) AS $word )
{
$word['word_theme'] = $this->id;
unset( $word['word_id'] );
\IPS\Db::i()->insert( 'core_sys_lang_words', $word );
}
/* Copy across resources */
$this->copyResourcesFromSet( $originalId );
@@ -4879,11 +4887,15 @@ PHP;
* @param string|null $group Group
* @param int|null $plugin Plugin ID
* @param bool $doAll Delete all - by default only the master set is cleared
* @param string|null $template Template name if you just want to do one template. If specified, deleteCompiledTemplate is NOT called and must be done manually
* @return void
*/
public static function removeTemplates( $app, $location=NULL, $group=NULL, $plugin=NULL, $doAll=FALSE )
public static function removeTemplates( $app, $location=NULL, $group=NULL, $plugin=NULL, $doAll=FALSE, $template=NULL )
{
static::deleteCompiledTemplate( $app, $location, $group );
if ( !$template )
{
static::deleteCompiledTemplate( $app, $location, $group );
}
$where = array( array( 'template_app=?', $app ) );
@@ -4897,6 +4909,11 @@ PHP;
$where[] = array( 'template_group=?', $group );
}
if ( $template !== NULL )
{
$where[] = array( 'template_name=?', $template );
}
if ( $plugin !== NULL )
{
$where[] = array( 'template_plugin=?', $plugin );
@@ -4931,11 +4948,15 @@ PHP;
* @param string|null $path Group
* @param int|null $plugin Plugin ID
* @param bool $doAll Delete all - by default only the master set is cleared
* @param string|null $name CSS file name if you just want to do one file. If specified, deleteCompiledCss is NOT called and must be done manually
* @return void
*/
public static function removeCss( $app, $location=NULL, $path=NULL, $plugin=NULL, $doAll=FALSE )
public static function removeCss( $app, $location=NULL, $path=NULL, $plugin=NULL, $doAll=FALSE, $name=NULL )
{
static::deleteCompiledCss( $app, $location, $path );
if ( !$name )
{
static::deleteCompiledCss( $app, $location, $path );
}
$where = array( array( 'css_app=?', $app ) );
@@ -4949,6 +4970,11 @@ PHP;
$where[] = array( 'css_path=?', $path );
}
if ( $name !== NULL )
{
$where[] = array( 'css_name=?', $name );
}
if ( $plugin !== NULL )
{
$where[] = array( 'css_plugin=?', $plugin );