Version 5.0.0 release
This commit is contained in:
1 parent
90e8c7e903
commit
a3a4a9ccbd
651 files changed
+7275
-9481
No files matched your search
@@ -42,7 +42,6 @@ use IPS\Platform\Bridge;
|
||||
use IPS\Theme\CustomTemplate;
|
||||
use IPS\Theme\Editor\Category;
|
||||
use IPS\Theme\Editor\Setting;
|
||||
use IPS\Widget\Area;
|
||||
use IPS\Widget\Polymorphic;
|
||||
use IPS\Xml\SimpleXML;
|
||||
use OutOfRangeException;
|
||||
@@ -220,7 +219,7 @@ class Application extends Model
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( PHPException $e )
|
||||
{
|
||||
if( Dispatcher::hasInstance() and Dispatcher::i()->controllerLocation == 'setup' )
|
||||
{
|
||||
@@ -1526,7 +1525,7 @@ EOF;
|
||||
* Install database changes from the schema.json file
|
||||
*
|
||||
* @param bool $skipInserts Skip inserts
|
||||
* @throws \Exception
|
||||
* @throws PHPException
|
||||
*/
|
||||
public function installDatabaseSchema( bool $skipInserts=FALSE ) : void
|
||||
{
|
||||
@@ -1633,7 +1632,7 @@ EOF;
|
||||
$params = $instruction['params'];
|
||||
Db::i()->$method( ...$params );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( PHPException $e )
|
||||
{
|
||||
if( $instruction['method'] == 'insert' )
|
||||
{
|
||||
@@ -2588,10 +2587,6 @@ EOF;
|
||||
$category['cat_parent'] = $currentCategories[ $category['cat_parent' ] ]['cat_id'] ?? 0;
|
||||
}
|
||||
|
||||
/* Remove the name, this will be a language string */
|
||||
$name = $category['cat_name'];
|
||||
unset( $category['cat_name'] );
|
||||
|
||||
$category['cat_app'] = $this->directory;
|
||||
|
||||
/* Restructure the icon data */
|
||||
@@ -2618,8 +2613,6 @@ EOF;
|
||||
Db::i()->update( 'core_theme_editor_categories', $category, [ 'cat_key=?', $key ] );
|
||||
}
|
||||
|
||||
Lang::saveCustom( 'core', 'themeeditor_cat_' . $key, $name, false, $name );
|
||||
|
||||
$category['cat_id'] = $categoryId;
|
||||
$currentCategories[ $key ] = $category;
|
||||
}
|
||||
@@ -2663,6 +2656,8 @@ EOF;
|
||||
$position = (int) Db::i()->select( 'max(setting_position)', 'core_theme_editor_settings', [ 'setting_category_id=?', $categoryId ] )->first();
|
||||
|
||||
$insert = [
|
||||
'setting_name' => $setting['name'],
|
||||
'setting_desc' => $setting['desc'],
|
||||
'setting_key' => $key,
|
||||
'setting_type' => $setting['type'],
|
||||
'setting_data' => ( count( $data ) ? json_encode( $data ) : null ),
|
||||
@@ -2681,6 +2676,8 @@ EOF;
|
||||
{
|
||||
$settingId = $currentSettings[ $key ]['setting_id'];
|
||||
Db::i()->update( 'core_theme_editor_settings', [
|
||||
'setting_name' => $setting['name'],
|
||||
'setting_desc' => $setting['desc'],
|
||||
'setting_type' => $setting['type'],
|
||||
'setting_data' => ( count( $data ) ? json_encode( $data ) : null ),
|
||||
'setting_default' => ( is_array( $default ) ? json_encode( $default ) : $default ),
|
||||
@@ -2688,12 +2685,6 @@ EOF;
|
||||
'setting_refresh' => (int) ( $setting['refresh'] ?? 0 )
|
||||
], [ 'setting_key=?', $key ] );
|
||||
}
|
||||
|
||||
Lang::saveCustom( 'core', 'themeeditor_var_' . $key, $setting['name'], false, $setting['name'] );
|
||||
if( isset( $setting['desc'] ) )
|
||||
{
|
||||
Lang::saveCustom( 'core', 'themeeditor_var_' . $key . '_desc', $setting['desc'], false, $setting['desc'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4137,7 +4128,7 @@ EOF;
|
||||
{
|
||||
$mapping[ $row['cat_id'] ] = $row['cat_key'];
|
||||
$categoryData = [
|
||||
'cat_name' => $lang->get( 'themeeditor_cat_' . $row['cat_key'] ),
|
||||
'cat_name' => $row['cat_name'],
|
||||
'cat_key' => $row['cat_key'],
|
||||
'cat_icon' => Category::constructFromData( $row )->icon()
|
||||
];
|
||||
@@ -4178,8 +4169,8 @@ EOF;
|
||||
$settingData = [
|
||||
'key' => $row['setting_key'],
|
||||
'type' => $row['setting_type'],
|
||||
'name' => $lang->get( 'themeeditor_var_' . $row['setting_key'] ),
|
||||
'desc' => ( $lang->checkKeyExists( 'themeeditor_var_' . $row['setting_key'] . '_desc' ) ? $lang->get( 'themeeditor_var_' . $row['setting_key'] . '_desc' ) : '' ),
|
||||
'name' => $row['setting_name'],
|
||||
'desc' => $row['setting_desc'],
|
||||
'refresh' => (bool) $row['setting_refresh']
|
||||
];
|
||||
|
||||
@@ -5297,6 +5288,11 @@ EOF;
|
||||
return $blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array Prevent multiple queries for valid widget keys
|
||||
*/
|
||||
private ?array $validWidgetKeys = null;
|
||||
|
||||
/**
|
||||
* Return a list of all valid widget keys for this application
|
||||
*
|
||||
@@ -5304,18 +5300,21 @@ EOF;
|
||||
*/
|
||||
public function getValidWidgetKeys() : array
|
||||
{
|
||||
$keys = [];
|
||||
foreach( Db::i()->select( '*', 'core_widgets', [ 'app=?', $this->directory ] ) as $widget )
|
||||
if ( $this->validWidgetKeys === null )
|
||||
{
|
||||
$class = 'IPS\\' . $this->directory . '\\widgets\\' . $widget['key'];
|
||||
$keys[] = $widget['key'];
|
||||
if( in_array( Polymorphic::class, class_implements( $class ) ) )
|
||||
$this->validWidgetKeys = [];
|
||||
foreach ( Db::i()->select( '*', 'core_widgets', ['app=?', $this->directory] ) as $widget )
|
||||
{
|
||||
/* @var Polymorphic $class */
|
||||
$keys = array_merge( $keys, $class::getWidgetKeys() );
|
||||
$class = 'IPS\\' . $this->directory . '\\widgets\\' . $widget['key'];
|
||||
$this->validWidgetKeys[] = $widget['key'];
|
||||
if ( in_array( Polymorphic::class, class_implements( $class ) ) )
|
||||
{
|
||||
/* @var Polymorphic $class */
|
||||
$this->validWidgetKeys = array_merge( $this->validWidgetKeys, $class::getWidgetKeys() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $keys;
|
||||
return $this->validWidgetKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5554,7 +5553,7 @@ EOF;
|
||||
{
|
||||
$extension->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( PHPException $e ){}
|
||||
}
|
||||
|
||||
/* Delete any upload settings */
|
||||
@@ -5566,7 +5565,7 @@ EOF;
|
||||
{
|
||||
File::get( 'core_Theme', Settings::i()->$setting )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( PHPException $e ){}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6150,7 +6149,7 @@ EOF;
|
||||
{
|
||||
File::get( 'core_Theme', Settings::i()->editor_plugin_js )->delete();
|
||||
}
|
||||
catch( \Exception ){}
|
||||
catch( PHPException ){}
|
||||
Settings::i()->changeValues( [ 'editor_plugin_js' => null ] );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user