Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -48,6 +48,11 @@ class _convert extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'conversion_app_not_found', '2V101/2', 404 );
}
if ( $app->finished )
{
\IPS\Output::i()->error( 'conversion_app_finished', '2V368/1', 403, '' );
}
$softwareClass = $app->getSource();
$libraryClass = $softwareClass->getLibrary();
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'converting_x_to_x', FALSE, array( 'sprintf' => array( $softwareClass::softwareName(), \IPS\Application::load( $app->sw )->_title ) ) );
@@ -56,6 +61,26 @@ class _convert extends \IPS\Dispatcher\Controller
try
{
$menuRows = $libraryClass->menuRows();
/* "Extra steps" should not show in the list of things to convert, but still need to be defined in menu rows */
$extraSteps = array();
foreach( $softwareClass::canConvert() as $row )
{
if( isset( $row['extra_steps'] ) )
{
$extraSteps = array_merge( $extraSteps, $row['extra_steps'] );
}
}
$menuRows = array_filter( $menuRows, function( $row ) use ( $extraSteps ) {
if( in_array( $row['step_method'], $extraSteps ) )
{
return FALSE;
}
return TRUE;
});
}
catch( \IPS\convert\Exception $e )
{
@@ -151,6 +176,48 @@ class _convert extends \IPS\Dispatcher\Controller
{
\IPS\Output::i()->error( 'conversion_app_not_found', '2V101/7', 404 );
}
/* If we decided to truncate, we need to do so before getMoreInfo() is generated */
if ( isset( \IPS\Request::i()->empty_local_data ) AND \IPS\Request::i()->empty_local_data == 1 )
{
$app->getSource()->getLibrary()->emptyLocalData( \IPS\Request::i()->method );
/* If this step has extra steps, we need to unset the completed flag. */
$canConvert = $app->getSource()->getLibrary()->getConvertableItems();
$session = $app->_session;
if ( isset( $canConvert[ \IPS\Request::i()->method ]['extra_steps'] ) )
{
$next = NULL;
foreach( $canConvert[ \IPS\Request::i()->method ]['extra_steps'] as $next )
{
if( $key = array_search( $next, $session['completed'] ) )
{
unset( $session['completed'][ $key ] );
}
}
}
/* Since we're emptying everything, remove the main step from the completed list
so that 'continue' functionality can be used on the next run. */
if( $key = array_search( \IPS\Request::i()->method, $session['completed'] ) )
{
unset( $session['completed'][ $key ] );
}
/* Set the new session data */
$app->_session = $session;
/* Reset finish flag if they're reconverting an area that uses rebuilds */
foreach( $app->getSource()->getLibrary()->menuRows() as $v )
{
if( isset( $v['requires_rebuild'] ) AND $v['requires_rebuild'] )
{
$app->finished = FALSE;
$app->save();
break;
}
}
}
/* Do we need more information? */
$softwareClass = $app->getSource();
@@ -164,17 +231,12 @@ class _convert extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form( \IPS\Request::i()->method . '_more_info', 'continue' );
$form->hiddenValues['per_cycle'] = \IPS\Request::i()->per_cycle;
if ( isset( \IPS\Request::i()->empty_local_data ) AND \IPS\Request::i()->empty_local_data == 1 )
{
$form->hiddenValues['empty_local_data'] = 1;
}
if ( isset( \IPS\Request::i()->reconfigure ) )
{
$form->hiddenValues['reconfigure'] = 1;
}
$hints = array();
/* Show the 'more info' fields */
foreach( $getMoreInfo as $key => $input )
{
$fieldClass = $input['field_class'];
@@ -191,12 +253,8 @@ class _convert extends \IPS\Dispatcher\Controller
unset( $values['per_cycle'] );
$app->saveMoreInfo( \IPS\Request::i()->method, $values );
$extra = '';
if ( isset( \IPS\Request::i()->empty_local_data ) AND \IPS\Request::i()->empty_local_data == 1 )
{
$extra .= "&empty_local_data=1";
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&do=runStep&id={$app->app_id}&per_cycle={$per_cycle}&method=" . \IPS\Request::i()->method . $extra ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&do=runStep&id={$app->app_id}&per_cycle={$per_cycle}&method=" . \IPS\Request::i()->method ) );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'more_info_needed' );
@@ -206,30 +264,6 @@ class _convert extends \IPS\Dispatcher\Controller
}
}
/* If we decided to truncate, do so now */
if ( isset( \IPS\Request::i()->empty_local_data ) AND \IPS\Request::i()->empty_local_data == 1 )
{
$app->getSource()->getLibrary()->emptyLocalData( \IPS\Request::i()->method );
/* If this step has extra steps, we need to unset the completed flag. */
$canConvert = $app->getSource()->getLibrary()->getConvertableItems();
if ( isset( $canConvert[ \IPS\Request::i()->method ]['extra_steps'] ) )
{
$next = NULL;
$session = $app->_session;
foreach( $canConvert[ \IPS\Request::i()->method ]['extra_steps'] as $next )
{
if( $key = array_search( $next, $session['completed'] ) )
{
unset( $session['completed'][ $key ] );
}
}
/* Set the new session data */
$app->_session = $session;
}
}
/* Are we continuing? We need to tell the library that, but we need to use sessions to do it so it only does it on the first cycle. */
if ( isset( \IPS\Request::i()->continue ) )
{
@@ -352,7 +386,7 @@ class _convert extends \IPS\Dispatcher\Controller
if ( $values = $form->values() )
{
$softwareClass->convertSettings( $values );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->clearCache();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&id={$app->app_id}" ), 'saved' );
}
@@ -372,7 +406,7 @@ class _convert extends \IPS\Dispatcher\Controller
{
\IPS\Output::i()->error( 'no_conversion_app', '2V101/E' );
}
try
{
$app = \IPS\convert\App::load( \IPS\Request::i()->id );
@@ -386,7 +420,7 @@ class _convert extends \IPS\Dispatcher\Controller
\IPS\Request::i()->confirmedDelete( 'convert_finish_confirm_title', 'convert_finish_confirm', 'finish' );
$softwareClass = $app->getSource();
$messages = array();
/* If we have a parent, run them. */
@@ -395,31 +429,43 @@ class _convert extends \IPS\Dispatcher\Controller
if ( $app->parent )
{
$parent = \IPS\convert\App::load( $app->parent );
if ( method_exists( $parent->getSource(), 'finish' ) )
if ( method_exists( $parent->getSource(), 'finish' ) AND !$parent->finished )
{
$return = $parent->getSource()->finish();
$parent->app->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
$parent->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
$parent->finished = TRUE;
$parent->save();
if ( is_array( $return ) )
{
$messages = array_merge( $messages, $return );
}
}
elseif( $parent->finished )
{
$parent->log( 'app_finished_skipped', __METHOD__, \IPS\convert\App::LOG_NOTICE );
}
/* Run siblings if need be */
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'convert_apps', array( "parent=? AND app_id!=?", $parent->app_id, $app->app_id ) ), 'IPS\convert\App' ) AS $sibling )
{
if ( method_exists( $sibling->getSource(), 'finish' ) )
if ( method_exists( $sibling->getSource(), 'finish' ) AND !$sibling->finished )
{
$return = $sibling->getSource()->finish();
$sibling->app->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
$sibling->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
$sibling->finished = TRUE;
$sibling->save();
if ( is_array( $return ) )
{
$messages = array_merge( $messages, $return );
}
}
elseif( $sibling->finished )
{
$sibling->log( 'app_finished_skipped', __METHOD__, \IPS\convert\App::LOG_NOTICE );
}
}
}
else
@@ -434,32 +480,50 @@ class _convert extends \IPS\Dispatcher\Controller
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'convert_apps', array( "parent=?", $app->app_id ) ), 'IPS\convert\App' ) AS $child )
{
$childSoftwareClass = $child->getSource();
if ( method_exists( $childSoftwareClass, 'finish' ) )
if ( method_exists( $childSoftwareClass, 'finish' ) AND !$child->finished )
{
$return = $childSoftwareClass->finish();
$childSoftwareClass->app->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
$child->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
$child->finished = TRUE;
$child->save();
if ( is_array( $return ) )
{
$messages = array_merge( $messages, $return );
}
}
elseif( $child->finished )
{
$child->log( 'app_finished_skipped', __METHOD__, \IPS\convert\App::LOG_NOTICE );
}
}
}
/* And finally, run this one */
if ( method_exists( $softwareClass, 'finish' ) )
if ( method_exists( $softwareClass, 'finish' ) AND !$app->finished )
{
$return = $softwareClass->finish();
$softwareClass->app->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
$app->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
$app->finished = TRUE;
$app->save();
if ( is_array( $return ) )
{
$messages = array_merge( $messages, $return );
}
}
elseif( $app->finished )
{
$app->log( 'app_finished_skipped', __METHOD__, \IPS\convert\App::LOG_NOTICE );
}
/* Any Messages? */
if( !count( $messages ) )
{
$messages = array( 'nothing_to_finish' );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=manage" ), implode( ', ', array_map( function( $key ) {
return \IPS\Member::loggedIn()->language()->addToStack( $key );
}, $messages ) ) );