Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

@@ -274,7 +274,7 @@ class _themes extends \IPS\Node\Controller
else if ( $data['toImport'] )
{
$toImport = $_SESSION['theme_dev_import'];
reset( $toImport );
$themeId = key( $toImport );
$theme = \IPS\Theme::load( $themeId );
@@ -295,10 +295,18 @@ class _themes extends \IPS\Node\Controller
$languageIds = array_keys( \IPS\Lang::languages() );
$languageInserts = array();
$seen = array();
require \IPS\ROOT_PATH . "/themes/{$themeId}/lang.php";
foreach ( $lang as $k => $v )
{
if ( isset( $seen[ $k ] ) )
{
continue;
}
$seen[ $k ] = true;
if ( mb_substr( $k, 0, 17 ) === 'theme_custom_tab_' )
{
\IPS\Lang::deleteCustom( 'core', $k );
@@ -306,7 +314,7 @@ class _themes extends \IPS\Node\Controller
foreach ( $languageIds as $langId )
{
$languageInserts[] = array(
\IPS\Db::i()->insert( 'core_sys_lang_words', array(
'lang_id' => $langId,
'word_app' => NULL,
'word_plugin' => NULL,
@@ -318,14 +326,9 @@ class _themes extends \IPS\Node\Controller
'word_custom_version' => NULL,
'word_js' => FALSE,
'word_export' => TRUE
);
) );
}
}
if ( count( $languageInserts ) )
{
\IPS\Db::i()->insert( 'core_sys_lang_words', $languageInserts );
}
}
break;
case 'html':
@@ -605,8 +608,13 @@ class _themes extends \IPS\Node\Controller
return \IPS\Theme::i()->getTemplate( 'customization' )->resourceDisplay( $row );
},
'resource_name' => function( $val, $row )
'resource_name' => function( $val, $row ) use ($set)
{
if ( in_array( mb_substr( $row['resource_name'], mb_strrpos( $row['resource_name'], '.' ) + 1 ), \IPS\Image::$imageExtensions ) )
{
$row['resource_filename'] = $set->resource( ltrim( $row['resource_path'], '/' ) . $row['resource_name'], $row['resource_app'], $row['resource_location'] );
}
return \IPS\Theme::i()->getTemplate( 'customization' )->resourceName( $row );
},
'resource_filename' => function( $val, $row )
@@ -1029,9 +1037,9 @@ class _themes extends \IPS\Node\Controller
'set_author_name' => $xml->getAttribute('author_name'),
'set_author_url' => $xml->getAttribute('author_url'),
'set_version' => $xml->getAttribute('version'),
'set_long_version' => $xml->getAttribute('long_version'),
'set_long_version' => ( $xml->getAttribute('long_version') ) ? $xml->getAttribute('long_version') : \IPS\Application::load('core')->long_version,
'set_is_default' => $set->is_default,
'set_permissions' => implode( ',', $groups )
'set_permissions' => $set->id ? $set->permissions : implode( ',', $groups )
) );
if ( $xml->getAttribute('editor_skin') )
@@ -1064,6 +1072,7 @@ class _themes extends \IPS\Node\Controller
/* Move to correct app */
$appKey = NULL;
$version = \IPS\Theme::load( \IPS\Request::i()->id )->long_version;
$xml->read();
while ( $xml->read() )
{
@@ -1278,19 +1287,32 @@ class _themes extends \IPS\Node\Controller
$languageIds = isset( $languageIds ) ? $languageIds : array_keys( \IPS\Lang::languages() );
foreach ( $languageIds as $langId )
{
\IPS\Db::i()->insert( 'core_sys_lang_words', array(
'lang_id' => $langId,
'word_app' => NULL,
'word_plugin' => NULL,
'word_theme' => \IPS\Request::i()->id,
'word_key' => $xml->getAttribute('key'),
'word_default' => $xml->readString(),
'word_custom' => NULL,
'word_default_version' => $version,
'word_custom_version' => NULL,
'word_js' => FALSE,
'word_export' => TRUE
) );
$default = $xml->readString();
$exists = \IPS\Db::i()->select( 'COUNT(*)', 'core_sys_lang_words', array( array( 'lang_id=? and word_key=? and word_theme=?', $langId, $xml->getAttribute('key'), \IPS\Request::i()->id ) ) )->first();
if ( $exists )
{
\IPS\Db::i()->update( 'core_sys_lang_words', array(
'word_default' => $default,
'word_default_version' => $version,
), array( array( 'lang_id=? and word_key=? and word_theme=?', $langId, $xml->getAttribute('key'), \IPS\Request::i()->id ) ) );
}
else
{
\IPS\Db::i()->insert( 'core_sys_lang_words', array(
'lang_id' => $langId,
'word_app' => NULL,
'word_plugin' => NULL,
'word_theme' => \IPS\Request::i()->id,
'word_key' => $xml->getAttribute('key'),
'word_default' => $default,
'word_custom' => NULL,
'word_default_version' => $version,
'word_custom_version' => NULL,
'word_js' => FALSE,
'word_export' => TRUE
) );
}
}
$xml->next();
@@ -1332,6 +1354,8 @@ class _themes extends \IPS\Node\Controller
{
$set = \IPS\Theme::load( \IPS\Request::i()->id );
\IPS\Theme::deleteCompiledResources( null, null, null, null, $set->id );
\IPS\Theme::deleteCompiledTemplate( null, null, null, $set->id );
\IPS\Theme::deleteCompiledCss( null, null, null, null, $set->id );
\IPS\Data\Store::i()->delete( 'core_theme_import_' . md5_file( \IPS\Request::i()->file ) );
@@ -1377,9 +1401,9 @@ class _themes extends \IPS\Node\Controller
if ( isset( $conflicts['template'] ) AND count( $conflicts['template'] ) )
{
$templates = iterator_to_array( \IPS\Db::i()->select(
'*, MD5( CONCAT( template_app, ".", template_location, ".", template_group, ".", template_name ) ) as bit_key',
'*, MD5( CONCAT( template_app, \'.\', template_location, \'.\', template_group, \'.\', template_name ) ) as bit_key',
'core_theme_templates',
'template_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( template_app, ".", template_location, ".", template_group, ".", template_name ) )', array_keys( $conflicts['template'] ) )
'template_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( template_app, \'.\', template_location, \'.\', template_group, \'.\', template_name ) )', array_keys( $conflicts['template'] ) )
)->setKeyField( 'bit_key' ) );
}
else
@@ -1390,9 +1414,9 @@ class _themes extends \IPS\Node\Controller
if ( isset( $conflicts['css'] ) AND count( $conflicts['css'] ) )
{
$css = iterator_to_array( \IPS\Db::i()->select(
'*, MD5( CONCAT( css_app, ".", css_location, ".", css_path, ".", css_name ) ) as bit_key',
'*, MD5( CONCAT( css_app, \'.\', css_location, \'.\', css_path, \'.\', css_name ) ) as bit_key',
'core_theme_css',
'css_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( css_app, ".", css_location, ".", css_path, ".", css_name ) )', array_keys( $conflicts['css'] ) )
'css_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( css_app, \'.\', css_location, \'.\', css_path, \'.\', css_name ) )', array_keys( $conflicts['css'] ) )
)->setKeyField( 'bit_key' ) );
}
else
@@ -1458,18 +1482,18 @@ class _themes extends \IPS\Node\Controller
if ( isset( $conflicts['template'] ) AND count( $conflicts['template'] ) )
{
$templates = iterator_to_array( \IPS\Db::i()->select(
'*, MD5( CONCAT( template_app, ".", template_location, ".", template_group, ".", template_name ) ) as bit_key',
'*, MD5( CONCAT( template_app, \'.\', template_location, \'.\', template_group, \'.\', template_name ) ) as bit_key',
'core_theme_templates',
'template_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( template_app, ".", template_location, ".", template_group, ".", template_name ) )', array_keys( $conflicts['template'] ) )
'template_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( template_app, \'.\', template_location, \'.\', template_group, \'.\', template_name ) )', array_keys( $conflicts['template'] ) )
)->setKeyField( 'bit_key' ) );
}
if ( isset( $conflicts['css'] ) AND count( $conflicts['css'] ) )
{
$css = iterator_to_array( \IPS\Db::i()->select(
'*, MD5( CONCAT( css_app, ".", css_location, ".", css_path, ".", css_name ) ) as bit_key',
'*, MD5( CONCAT( css_app, \'.\', css_location, \'.\', css_path, \'.\', css_name ) ) as bit_key',
'core_theme_css',
'css_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( css_app, ".", css_location, ".", css_path, ".", css_name ) )', array_keys( $conflicts['css'] ) )
'css_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( css_app, \'.\', css_location, \'.\', css_path, \'.\', css_name ) )', array_keys( $conflicts['css'] ) )
)->setKeyField( 'bit_key' ) );
}
@@ -2034,7 +2058,30 @@ class _themes extends \IPS\Node\Controller
/* Language strings */
$xml->startElement('language');
foreach ( \IPS\Db::i()->select( '*', 'core_sys_lang_words', array( 'word_theme=?', $themeSet->id ) ) as $row )
$parents = array( $themeSet->id );
try
{
foreach( $themeSet->parents() as $parent )
{
$parents[] = $parent->_id;
}
}
catch( \OutOfRangeException $e ) { }
$words = array();
foreach ( \IPS\Db::i()->select(
'*, INSTR(\',' . implode( ',' , $parents ) . ',\', CONCAT(\',\',word_theme,\',\') ) as theorder',
'core_sys_lang_words',
array( 'word_theme IN(' . implode( ',' , $parents ) . ')' ),
'theorder desc'
) as $data )
{
$words[ $data['word_key'] ] = $data;
}
foreach ( $words as $row )
{
$xml->startElement( 'word' );
$xml->startAttribute('key');
@@ -2108,10 +2155,10 @@ class _themes extends \IPS\Node\Controller
$form = new \IPS\Helpers\Form();
$form->hiddenValues['id'] = $id;
$form->add( new \IPS\Helpers\Form\Text( 'theme_template_name', NULL, TRUE, array( 'regex' => '/^([A-Z0-9_\\-]+?)$/i' ),
$form->add( new \IPS\Helpers\Form\Text( 'theme_template_name', NULL, TRUE, array( 'regex' => '/^([A-Z0-9_]+?)$/i' ),
function( $val )
{
if ( ! preg_match( '/^([A-Z0-9_\-]+?)$/i', $val ) )
if ( ! preg_match( '/^([A-Z0-9_]+?)$/i', $val ) )
{
throw new \InvalidArgumentException( 'form_bad_value' );
}
@@ -2265,8 +2312,11 @@ class _themes extends \IPS\Node\Controller
if ( isset( $template['template_content'] ) )
{
$template['type'] = 'templates';
$template['name'] = $template['template_name'];
$template['type'] = 'templates';
$template['name'] = $template['template_name'];
$template['app'] = $template['template_app'];
$template['location'] = $template['template_location'];
$template['group'] = $template['template_group'];
}
}
else
@@ -2275,8 +2325,11 @@ class _themes extends \IPS\Node\Controller
if ( isset( $template['css_content'] ) )
{
$template['type'] = 'css';
$template['name'] = $template['css_name'];
$template['type'] = 'css';
$template['name'] = $template['css_name'];
$template['app'] = $template['css_app'];
$template['location'] = $template['css_location'];
$template['group'] = $template['css_path'];
}
}
}
@@ -2285,8 +2338,11 @@ class _themes extends \IPS\Node\Controller
\IPS\Output::i()->error( 'node_error', '3S121/1', 500, '' );
}
\IPS\Session::i()->log( 'acplogs__themetemplate_deleted', array( $template['name'] => FALSE ) );
if ( isset( $template['app'] ) )
{
\IPS\Session::i()->log( 'acplogs__themetemplate_deleted', array( $template['app'] => FALSE, $template['location'] => FALSE, $template['group'] => FALSE, $template['name'] => FALSE ) );
}
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
@@ -2363,7 +2419,7 @@ class _themes extends \IPS\Node\Controller
if ( in_array( $k, array( 'app', 'location', 'group', 'name' ) ) )
{
$url[] = 't_' . $k . '=' . $v;
$log[ $k ] = $v;
$log[ $v ] = FALSE;
}
}