Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,21 +12,51 @@
|
||||
namespace IPS\convert\modules\admin\manage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\convert\App;
|
||||
use IPS\convert\Exception;
|
||||
use IPS\convert\Library;
|
||||
use IPS\convert\Software;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Checkbox;
|
||||
use IPS\Helpers\MultipleRedirect;
|
||||
use IPS\Helpers\Table\Custom;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use const IPS\CONVERTERS_DEV_UI;
|
||||
use const IPS\DEMO_MODE;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run conversion
|
||||
*/
|
||||
class _convert extends \IPS\Dispatcher\Controller
|
||||
class convert extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
@@ -37,11 +67,11 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( \IPS\CIC )
|
||||
{
|
||||
\IPS\Output::i()->error( 'module_no_permission', '2V368/2', 403, '' );
|
||||
Output::i()->error( 'module_no_permission', '2V368/2', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->responsive = FALSE;
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'convert_manage' );
|
||||
Output::i()->responsive = FALSE;
|
||||
Dispatcher::i()->checkAcpPermission( 'convert_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -53,19 +83,19 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
protected function manage()
|
||||
{
|
||||
/* Do we have an id? */
|
||||
if ( ! isset( \IPS\Request::i()->id ) )
|
||||
if ( ! isset( Request::i()->id ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_conversion_app', '2V101/1' );
|
||||
Output::i()->error( 'no_conversion_app', '2V101/1' );
|
||||
}
|
||||
|
||||
/* Load the app */
|
||||
try
|
||||
{
|
||||
$app = \IPS\convert\App::load( \IPS\Request::i()->id );
|
||||
$app = App::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'conversion_app_not_found', '2V101/2', 404 );
|
||||
Output::i()->error( 'conversion_app_not_found', '2V101/2', 404 );
|
||||
}
|
||||
|
||||
/* Do a quick parent storage check */
|
||||
@@ -78,12 +108,12 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Are we using the legacy UI? If not, then start converting as we already have everything we need. */
|
||||
if( !\IPS\CONVERTERS_DEV_UI )
|
||||
if( !CONVERTERS_DEV_UI )
|
||||
{
|
||||
$configurationNeeded = FALSE;
|
||||
|
||||
/* If we have not yet configured the app, go there first */
|
||||
if( !\count( $app->_session['more_info'] ) )
|
||||
if( !count( $app->_session['more_info'] ) )
|
||||
{
|
||||
$configurationNeeded = TRUE;
|
||||
}
|
||||
@@ -91,7 +121,7 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
/* Check child apps also have more_info */
|
||||
foreach( $app->children() as $childApp )
|
||||
{
|
||||
if( !\count( $childApp->_session['more_info'] ) )
|
||||
if( !count( $childApp->_session['more_info'] ) )
|
||||
{
|
||||
$configurationNeeded = TRUE;
|
||||
break;
|
||||
@@ -101,32 +131,32 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
/* Do we need to configure? */
|
||||
if( $configurationNeeded )
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( "app=convert&module=manage&controller=create&_moveToStep=convert_start_conversion_details&id=" . ( $app->parent ?: $app->app_id ) );
|
||||
$url = Url::internal( "app=convert&module=manage&controller=create&_moveToStep=convert_start_conversion_details&id=" . ( $app->parent ?: $app->app_id ) );
|
||||
}
|
||||
/* Otherwise start converting! */
|
||||
else
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&do=runStep&id=" . $app->app_id )->csrf();
|
||||
$url = Url::internal( "app=convert&module=manage&controller=convert&do=runStep&id=" . $app->app_id )->csrf();
|
||||
|
||||
if( isset( \IPS\Request::i()->continue ) )
|
||||
if( isset( Request::i()->continue ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'continue', \IPS\Request::i()->continue );
|
||||
$url = $url->setQueryString( 'continue', Request::i()->continue );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
Output::i()->redirect( $url );
|
||||
}
|
||||
|
||||
/* Get our details */
|
||||
$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 ), 'striptags' => true ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'converting_x_to_x', FALSE, array( 'sprintf' => array( $softwareClass::softwareName(), Application::load( $app->sw )->_title ), 'striptags' => true ) );
|
||||
|
||||
/* Build our table. If I can do this using only the Table helper, I'll be impressed */
|
||||
$menuRows = static::getMenuRows( $softwareClass );
|
||||
|
||||
$table = new \IPS\Helpers\Table\Custom( $menuRows, \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert" ) );
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'table' ), 'convertMenuRow' );
|
||||
$table = new Custom( $menuRows, Url::internal( "app=convert&module=manage&controller=convert" ) );
|
||||
$table->rowsTemplate = array( Theme::i()->getTemplate( 'table' ), 'convertMenuRow' );
|
||||
$table->extra = array( 'sessionData' => $app->_session, 'appClass' => $app, 'softwareClass' => $softwareClass, 'libraryClass' => $libraryClass, 'menuRows' => $menuRows );
|
||||
$table->mainColumn = 'step_title';
|
||||
$table->showAdvancedSearch = FALSE;
|
||||
@@ -135,29 +165,29 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
$table->parsers = array(
|
||||
'step_title' => function( $row )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( $row );
|
||||
return Member::loggedIn()->language()->addToStack( $row );
|
||||
},
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = '';
|
||||
Output::i()->output = '';
|
||||
|
||||
if ( $softwareClass::canConvertSettings() !== FALSE )
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'table' )->settingsMessage( $app );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'table' )->settingsMessage( $app );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output .= $table;
|
||||
Output::i()->output .= $table;
|
||||
|
||||
if ( $libraryClass->getPostConversionInformation() != NULL )
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'table' )->postConversionInformation( $libraryClass->getPostConversionInformation() );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'table' )->postConversionInformation( $libraryClass->getPostConversionInformation() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the appropriate menu rows for the library
|
||||
*
|
||||
* @param \IPS\convert\Software $softwareClass Library class
|
||||
* @param Software $softwareClass Library class
|
||||
* @param bool $filter Filter out extra steps
|
||||
* @param bool $return Let exception bubble instead of outputting it
|
||||
* @param bool $count Count database rows
|
||||
@@ -185,7 +215,7 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
if( $filter === TRUE )
|
||||
{
|
||||
$menuRows = array_filter( $menuRows, function( $row ) use ( $extraSteps ) {
|
||||
if( \in_array( $row['step_method'], $extraSteps ) )
|
||||
if( in_array( $row['step_method'], $extraSteps ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -194,14 +224,14 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
});
|
||||
}
|
||||
}
|
||||
catch( \IPS\convert\Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
if( $return )
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->error( $e->getMessage(), '1V101/3', 500 );
|
||||
Output::i()->error( $e->getMessage(), '1V101/3', 500 );
|
||||
}
|
||||
|
||||
return $menuRows;
|
||||
@@ -210,7 +240,7 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Figure out the next steps for converting
|
||||
*
|
||||
* @param \IPS\convert\App $app Application we are converting
|
||||
* @param App $app Application we are converting
|
||||
* @return array
|
||||
*/
|
||||
protected function _getNextStep( $app )
|
||||
@@ -246,7 +276,7 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Loop over all applications */
|
||||
if( \count( $applicationsToCheck ) )
|
||||
if( count( $applicationsToCheck ) )
|
||||
{
|
||||
foreach( $applicationsToCheck as $appToCheck )
|
||||
{
|
||||
@@ -259,7 +289,7 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
$_SESSION['convertCountRows'][ $masterAppId ][ $appToCheck->app_id ] = array();
|
||||
}
|
||||
|
||||
if( !$appToCheck->parent AND $softwareClass::canConvertSettings() AND isset( $appToCheck->_session['more_info']['convertSettings'] ) AND $appToCheck->_session['more_info']['convertSettings']['convert_settings'] AND !\count( $appToCheck->_session['completed'] ) )
|
||||
if( !$appToCheck->parent AND $softwareClass::canConvertSettings() AND isset( $appToCheck->_session['more_info']['convertSettings'] ) AND $appToCheck->_session['more_info']['convertSettings']['convert_settings'] AND !count( $appToCheck->_session['completed'] ) )
|
||||
{
|
||||
$method = 'convertSettings';
|
||||
$_SESSION['convertCountRows'][ $masterAppId ][ $appToCheck->app_id ][ $method ] = 1;
|
||||
@@ -294,9 +324,9 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* We chose to convert a specific step and it's not complete */
|
||||
if( isset( \IPS\Request::i()->method ) AND $row['step_method'] == \IPS\Request::i()->method )
|
||||
if( isset( Request::i()->method ) AND $row['step_method'] == Request::i()->method )
|
||||
{
|
||||
if( !\in_array( $row['step_method'], $appToCheck->_session['completed'] ) )
|
||||
if( !in_array( $row['step_method'], $appToCheck->_session['completed'] ) )
|
||||
{
|
||||
$method = $row['step_method'];
|
||||
}
|
||||
@@ -315,19 +345,19 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* If this step has any dependencies not yet converted, skip for now */
|
||||
if( \count( array_filter( $row['dependencies'], array( $appToCheck, 'dependencies' ) ) ) )
|
||||
if( count( array_filter( $row['dependencies'], array( $appToCheck, 'dependencies' ) ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If this step is already completed, also skip */
|
||||
if( \in_array( $row['step_method'], $appToCheck->_session['completed'] ) )
|
||||
if( in_array( $row['step_method'], $appToCheck->_session['completed'] ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If we don't want this converted, also skip */
|
||||
if( empty( $appToCheck->_session['more_info'][ $row['step_method'] ][ $row['step_title'] ] ) AND !\in_array( $row['step_method'], array_keys( $softwareClass->extraMenuRows() ) ) )
|
||||
if( empty( $appToCheck->_session['more_info'][ $row['step_method'] ][ $row['step_title'] ] ) AND !in_array( $row['step_method'], array_keys( $softwareClass->extraMenuRows() ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -348,38 +378,38 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function emptyData()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
if ( ! isset( \IPS\Request::i()->id ) )
|
||||
if ( ! isset( Request::i()->id ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_conversion_app', '2V101/4' );
|
||||
Output::i()->error( 'no_conversion_app', '2V101/4' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$app = \IPS\convert\App::load( \IPS\Request::i()->id );
|
||||
$app = App::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'conversion_app_not_found', '2V101/5' );
|
||||
Output::i()->error( 'conversion_app_not_found', '2V101/5' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'removing_data' );
|
||||
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&do=emptyData&id={$app->app_id}&method=" . \IPS\Request::i()->method ),
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'removing_data' );
|
||||
Output::i()->output = new MultipleRedirect( Url::internal( "app=convert&module=manage&controller=convert&do=emptyData&id={$app->app_id}&method=" . Request::i()->method ),
|
||||
function( $data ) use ( $app )
|
||||
{
|
||||
try
|
||||
{
|
||||
return $app->getSource()->getLibrary()->emptyData( $data, \IPS\Request::i()->method );
|
||||
return $app->getSource()->getLibrary()->emptyData( $data, Request::i()->method );
|
||||
}
|
||||
catch( \IPS\convert\Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&do=error&id={$app->app_id}" ) );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=convert&do=error&id={$app->app_id}" ) );
|
||||
}
|
||||
},
|
||||
function() use ( $app )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&id={$app->app_id}" ) );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=convert&id={$app->app_id}" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -390,35 +420,35 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function runStep()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Make sure we have our app id */
|
||||
if ( ! isset( \IPS\Request::i()->id ) )
|
||||
if ( ! isset( Request::i()->id ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_conversion_app', '2V101/6' );
|
||||
Output::i()->error( 'no_conversion_app', '2V101/6' );
|
||||
}
|
||||
|
||||
/* Load our app */
|
||||
try
|
||||
{
|
||||
$app = \IPS\convert\App::load( \IPS\Request::i()->id );
|
||||
$app = App::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'conversion_app_not_found', '2V101/7', 404 );
|
||||
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 ( \IPS\CONVERTERS_DEV_UI AND isset( \IPS\Request::i()->empty_local_data ) AND \IPS\Request::i()->empty_local_data == 1 )
|
||||
if ( CONVERTERS_DEV_UI AND isset( Request::i()->empty_local_data ) AND Request::i()->empty_local_data == 1 )
|
||||
{
|
||||
$app->getSource()->getLibrary()->emptyLocalData( \IPS\Request::i()->method );
|
||||
$app->getSource()->getLibrary()->emptyLocalData( 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'] ) )
|
||||
if ( isset( $canConvert[ Request::i()->method ]['extra_steps'] ) )
|
||||
{
|
||||
foreach( $canConvert[ \IPS\Request::i()->method ]['extra_steps'] as $next )
|
||||
foreach( $canConvert[ Request::i()->method ]['extra_steps'] as $next )
|
||||
{
|
||||
if( $key = array_search( $next, $session['completed'] ) )
|
||||
{
|
||||
@@ -429,7 +459,7 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* 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'] ) )
|
||||
if( $key = array_search( Request::i()->method, $session['completed'] ) )
|
||||
{
|
||||
unset( $session['completed'][ $key ] );
|
||||
}
|
||||
@@ -450,7 +480,7 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Do we need more information? */
|
||||
if ( \IPS\CONVERTERS_DEV_UI AND ! isset( $app->_session['more_info'][ \IPS\Request::i()->method ] ) OR ( isset( \IPS\Request::i()->reconfigure ) AND \IPS\Request::i()->reconfigure == 1 ) )
|
||||
if ( CONVERTERS_DEV_UI AND ! isset( $app->_session['more_info'][ Request::i()->method ] ) OR ( isset( Request::i()->reconfigure ) AND Request::i()->reconfigure == 1 ) )
|
||||
{
|
||||
if( $this->_checkMethodConfiguration( $app ) )
|
||||
{
|
||||
@@ -459,7 +489,7 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* 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 ) )
|
||||
if ( isset( Request::i()->continue ) )
|
||||
{
|
||||
/* Is it set? If not, just go ahead. */
|
||||
if ( !isset( $_SESSION['convertContinue'] ) )
|
||||
@@ -469,22 +499,22 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Generate our multiredirect URL */
|
||||
$redirectUrl = \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&do=runStep&id={$app->app_id}" )->csrf();
|
||||
$redirectUrl = Url::internal( "app=convert&module=manage&controller=convert&do=runStep&id={$app->app_id}" )->csrf();
|
||||
|
||||
/* Legacy URL parameters we won't need now, but will if using the developer UI */
|
||||
if( isset( \IPS\Request::i()->per_cycle ) )
|
||||
if( isset( Request::i()->per_cycle ) )
|
||||
{
|
||||
$redirectUrl = $redirectUrl->setQueryString( 'per_cycle', \IPS\Request::i()->per_cycle );
|
||||
$redirectUrl = $redirectUrl->setQueryString( 'per_cycle', Request::i()->per_cycle );
|
||||
}
|
||||
|
||||
if( isset( \IPS\Request::i()->method ) )
|
||||
if( isset( Request::i()->method ) )
|
||||
{
|
||||
$redirectUrl = $redirectUrl->setQueryString( 'method', \IPS\Request::i()->method );
|
||||
$redirectUrl = $redirectUrl->setQueryString( 'method', Request::i()->method );
|
||||
}
|
||||
|
||||
/* Output multiredirector */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'converting' );
|
||||
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect(
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'converting' );
|
||||
Output::i()->output = new MultipleRedirect(
|
||||
/* The multiredirect URL */
|
||||
$redirectUrl,
|
||||
|
||||
@@ -494,10 +524,10 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
/* Are we reconverting using the dev ui and this is the first iteration? */
|
||||
if( $data === NULL )
|
||||
{
|
||||
if( isset( \IPS\Request::i()->method ) )
|
||||
if( isset( Request::i()->method ) )
|
||||
{
|
||||
$session = $app->_session;
|
||||
if( $key = array_search( \IPS\Request::i()->method, $session['completed'] ) )
|
||||
if( $key = array_search( Request::i()->method, $session['completed'] ) )
|
||||
{
|
||||
unset( $session['completed'][ $key ] );
|
||||
$app->_session = $session;
|
||||
@@ -517,19 +547,19 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
/* If we are moving on to a different app, load it now */
|
||||
if( $convertData['id'] != $app->app_id )
|
||||
{
|
||||
$app = \IPS\convert\App::load( $convertData['id'] );
|
||||
$app = App::load( $convertData['id'] );
|
||||
}
|
||||
|
||||
/* Convert settings if that's what we're doing */
|
||||
if( $convertData['method'] == 'convertSettings' )
|
||||
{
|
||||
$app->getSource()->convertSettings( $app->_session['more_info']['convertSettings'] );
|
||||
\IPS\Settings::i()->clearCache();
|
||||
Settings::i()->clearCache();
|
||||
|
||||
/* A Software Exception indicates we are done */
|
||||
$completed = $app->_session['completed'];
|
||||
$more_info = $app->_session['more_info'];
|
||||
if ( !\in_array( $convertData['method'], $completed ) )
|
||||
if ( !in_array( $convertData['method'], $completed ) )
|
||||
{
|
||||
$completed[] = $convertData['method'];
|
||||
}
|
||||
@@ -540,12 +570,12 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
|
||||
$app->_session = array( 'working' => array(), 'more_info' => $more_info, 'completed' => $completed, 'running' => $running );
|
||||
|
||||
$percentage = 100 / \IPS\convert\Library::getTotalCachedRows( $app->getMasterConversionId() );
|
||||
$percentage = 100 / Library::getTotalCachedRows( $app->getMasterConversionId() );
|
||||
if ( $percentage > 100 )
|
||||
{
|
||||
$percentage = 100;
|
||||
}
|
||||
return array( 0, sprintf( \IPS\Member::loggedIn()->language()->get( 'converted_x_of_x' ), 1, 1, \IPS\Member::loggedIn()->language()->addToStack( '_convert_settings' ) ), $percentage );
|
||||
return array( 0, sprintf( Member::loggedIn()->language()->get( 'converted_x_of_x' ), 1, 1, Member::loggedIn()->language()->addToStack( '_convert_settings' ) ), $percentage );
|
||||
}
|
||||
|
||||
try
|
||||
@@ -558,22 +588,22 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
|
||||
return $app->getSource()->getLibrary()->process( $data, $convertData['method'], $app->getSource()->getLibrary()->getMethodFromMenuRows( $convertData['method'] )['per_cycle'] );
|
||||
}
|
||||
catch( \IPS\convert\Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&do=error&id={$app->app_id}" ) );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=convert&do=error&id={$app->app_id}" ) );
|
||||
}
|
||||
},
|
||||
|
||||
/* The final function to run */
|
||||
function() use ( $app )
|
||||
{
|
||||
if( \IPS\CONVERTERS_DEV_UI AND isset( \IPS\Request::i()->method ) )
|
||||
if( CONVERTERS_DEV_UI AND isset( Request::i()->method ) )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&do=manage&id=" . ( $app->parent ?: $app->app_id ) ) );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=convert&do=manage&id=" . ( $app->parent ?: $app->app_id ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&do=finish&wasConfirmed=1&id=" . ( $app->parent ?: $app->app_id ) )->csrf() );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=convert&do=finish&wasConfirmed=1&id=" . ( $app->parent ?: $app->app_id ) )->csrf() );
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -582,22 +612,22 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Check if we need to configure this conversion step
|
||||
*
|
||||
* @param \IPS\convert\App $app App we are converting
|
||||
* @param App $app App we are converting
|
||||
* @return bool
|
||||
*/
|
||||
protected function _checkMethodConfiguration( $app )
|
||||
{
|
||||
$softwareClass = $app->getSource();
|
||||
|
||||
if ( \in_array( \IPS\Request::i()->method, $softwareClass::checkConf() ) )
|
||||
if ( in_array( Request::i()->method, $softwareClass::checkConf() ) )
|
||||
{
|
||||
$getMoreInfo = $softwareClass->getMoreInfo( \IPS\Request::i()->method );
|
||||
if ( \is_array( $getMoreInfo ) AND \count( $getMoreInfo ) )
|
||||
$getMoreInfo = $softwareClass->getMoreInfo( Request::i()->method );
|
||||
if ( is_array( $getMoreInfo ) AND count( $getMoreInfo ) )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( \IPS\Request::i()->method . '_more_info', 'continue' );
|
||||
$form->hiddenValues['per_cycle'] = \IPS\Request::i()->per_cycle;
|
||||
$form = new Form( Request::i()->method . '_more_info', 'continue' );
|
||||
$form->hiddenValues['per_cycle'] = Request::i()->per_cycle;
|
||||
|
||||
if ( isset( \IPS\Request::i()->reconfigure ) )
|
||||
if ( isset( Request::i()->reconfigure ) )
|
||||
{
|
||||
$form->hiddenValues['reconfigure'] = 1;
|
||||
}
|
||||
@@ -609,7 +639,7 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
$form->add( new $fieldClass( $key, $input['field_default'], $input['field_required'], $input['field_extra'], isset( $input['field_validation'] ) ? $input['field_validation'] : NULL ) );
|
||||
if ( $input['field_hint'] !== NULL )
|
||||
{
|
||||
$form->addMessage( $input['field_hint'], 'ipsMessage ipsMessage_info' );
|
||||
$form->addMessage( $input['field_hint'], 'ipsMessage ipsMessage--info' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,13 +648,13 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
$per_cycle = $values['per_cycle'];
|
||||
unset( $values['per_cycle'] );
|
||||
|
||||
$app->saveMoreInfo( \IPS\Request::i()->method, $values );
|
||||
$app->saveMoreInfo( Request::i()->method, $values );
|
||||
|
||||
\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 )->csrf() );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=convert&do=runStep&id={$app->app_id}&per_cycle={$per_cycle}&method=" . Request::i()->method )->csrf() );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'more_info_needed' );
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'more_info_needed' );
|
||||
Output::i()->output = $form;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -639,25 +669,25 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
if ( !isset( \IPS\Request::i()->id ) )
|
||||
if ( !isset( Request::i()->id ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_conversion_app', '2V101/8' );
|
||||
Output::i()->error( 'no_conversion_app', '2V101/8' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$app = \IPS\convert\App::load( \IPS\Request::i()->id );
|
||||
$app = App::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'conversion_app_not_found', '2V101/9', 404 );
|
||||
Output::i()->error( 'conversion_app_not_found', '2V101/9', 404 );
|
||||
}
|
||||
|
||||
/* Load the last actual error logged */
|
||||
$error = \IPS\Db::i()->select( '*', 'convert_logs', array( 'log_app=?', $app->app_id ), 'log_id DESC', 1 )->first();
|
||||
$error = Db::i()->select( '*', 'convert_logs', array( 'log_app=?', $app->app_id ), 'log_id DESC', 1 )->first();
|
||||
|
||||
/* Just use generic error wrapper */
|
||||
\IPS\Output::i()->error( $error['log_method'] . ': ' . $error['log_message'], '2V101/A' );
|
||||
Output::i()->error( $error['log_method'] . ': ' . $error['log_message'], '2V101/A' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -667,49 +697,49 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function settings()
|
||||
{
|
||||
if ( !isset( \IPS\Request::i()->id ) )
|
||||
if ( !isset( Request::i()->id ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_conversion_app', '2V101/B' );
|
||||
Output::i()->error( 'no_conversion_app', '2V101/B' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$app = \IPS\convert\App::load( \IPS\Request::i()->id );
|
||||
$app = App::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'conversion_app_not_found', '2V101/C', 404 );
|
||||
Output::i()->error( 'conversion_app_not_found', '2V101/C', 404 );
|
||||
}
|
||||
|
||||
$softwareClass = $app->getSource();
|
||||
|
||||
if ( $softwareClass::canConvertSettings() === FALSE )
|
||||
{
|
||||
\IPS\Output::i()->error( 'settings_conversion_not_supported', '2V101/D' );
|
||||
Output::i()->error( 'settings_conversion_not_supported', '2V101/D' );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
foreach( $softwareClass->settingsMapList() as $key => $setting )
|
||||
{
|
||||
$value = $setting['value'];
|
||||
if ( \is_bool( ( $setting['value'] ) ) )
|
||||
if ( is_bool( ( $setting['value'] ) ) )
|
||||
{
|
||||
$value = $setting['value'] === TRUE ? 'On' : 'Off';
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Checkbox( $setting['our_key'], TRUE, FALSE, array( 'label' => $value ) ) );
|
||||
$form->add( new Checkbox( $setting['our_key'], TRUE, FALSE, array( 'label' => $value ) ) );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$softwareClass->convertSettings( $values );
|
||||
\IPS\Settings::i()->clearCache();
|
||||
Settings::i()->clearCache();
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&id={$app->app_id}" ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=convert&id={$app->app_id}" ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'converting_settings' );
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'converting_settings' );
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -719,22 +749,22 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
if ( !isset( \IPS\Request::i()->id ) )
|
||||
if ( !isset( Request::i()->id ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_conversion_app', '2V101/E' );
|
||||
Output::i()->error( 'no_conversion_app', '2V101/E' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$app = \IPS\convert\App::load( \IPS\Request::i()->id );
|
||||
$app = App::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\output::i()->error( 'conversion_app_not_found', '2V101/F', 404 );
|
||||
output::i()->error( 'conversion_app_not_found', '2V101/F', 404 );
|
||||
}
|
||||
|
||||
/* Make sure the user confirmed they want to finish */
|
||||
\IPS\Request::i()->confirmedDelete( 'convert_finish_confirm_title', 'convert_finish_confirm', 'finish' );
|
||||
Request::i()->confirmedDelete( 'convert_finish_confirm_title', 'convert_finish_confirm', 'finish' );
|
||||
|
||||
$softwareClass = $app->getSource();
|
||||
|
||||
@@ -745,53 +775,53 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( $app->parent )
|
||||
{
|
||||
$parent = \IPS\convert\App::load( $app->parent );
|
||||
$parent = App::load( $app->parent );
|
||||
|
||||
if ( method_exists( $parent->getSource(), 'finish' ) AND !$parent->finished )
|
||||
{
|
||||
$return = $parent->getSource()->finish();
|
||||
$parent->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
$parent->log( 'app_finished', __METHOD__, App::LOG_NOTICE );
|
||||
$parent->finished = TRUE;
|
||||
$parent->save();
|
||||
|
||||
if ( \is_array( $return ) )
|
||||
if ( is_array( $return ) )
|
||||
{
|
||||
$messages = array_merge( $messages, $return );
|
||||
}
|
||||
}
|
||||
elseif( $parent->finished )
|
||||
{
|
||||
$parent->log( 'app_finished_skipped', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
$parent->log( 'app_finished_skipped', __METHOD__, 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 )
|
||||
foreach( new ActiveRecordIterator( 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' ) AND !$sibling->finished )
|
||||
{
|
||||
$return = $sibling->getSource()->finish();
|
||||
$sibling->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
$sibling->log( 'app_finished', __METHOD__, App::LOG_NOTICE );
|
||||
$sibling->finished = TRUE;
|
||||
$sibling->save();
|
||||
|
||||
if ( \is_array( $return ) )
|
||||
if ( is_array( $return ) )
|
||||
{
|
||||
$messages = array_merge( $messages, $return );
|
||||
}
|
||||
}
|
||||
elseif( $sibling->finished )
|
||||
{
|
||||
$sibling->log( 'app_finished_skipped', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
$sibling->log( 'app_finished_skipped', __METHOD__, App::LOG_NOTICE );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No parent - bubble up to the exception */
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
/* This is a parent - run it's children */
|
||||
foreach( $app->children() AS $child )
|
||||
@@ -801,18 +831,18 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
if ( method_exists( $childSoftwareClass, 'finish' ) AND !$child->finished )
|
||||
{
|
||||
$return = $childSoftwareClass->finish();
|
||||
$child->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
$child->log( 'app_finished', __METHOD__, App::LOG_NOTICE );
|
||||
$child->finished = TRUE;
|
||||
$child->save();
|
||||
|
||||
if ( \is_array( $return ) )
|
||||
if ( is_array( $return ) )
|
||||
{
|
||||
$messages = array_merge( $messages, $return );
|
||||
}
|
||||
}
|
||||
elseif( $child->finished )
|
||||
{
|
||||
$child->log( 'app_finished_skipped', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
$child->log( 'app_finished_skipped', __METHOD__, App::LOG_NOTICE );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -821,30 +851,30 @@ class _convert extends \IPS\Dispatcher\Controller
|
||||
if ( method_exists( $softwareClass, 'finish' ) AND !$app->finished )
|
||||
{
|
||||
$return = $softwareClass->finish();
|
||||
$app->log( 'app_finished', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
$app->log( 'app_finished', __METHOD__, App::LOG_NOTICE );
|
||||
$app->finished = TRUE;
|
||||
$app->save();
|
||||
|
||||
if ( \is_array( $return ) )
|
||||
if ( is_array( $return ) )
|
||||
{
|
||||
$messages = array_merge( $messages, $return );
|
||||
}
|
||||
}
|
||||
elseif( $app->finished )
|
||||
{
|
||||
$app->log( 'app_finished_skipped', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
$app->log( 'app_finished_skipped', __METHOD__, App::LOG_NOTICE );
|
||||
}
|
||||
|
||||
/* Any Messages? */
|
||||
if( !\count( $messages ) )
|
||||
if( !count( $messages ) )
|
||||
{
|
||||
$messages = array( 'nothing_to_finish' );
|
||||
}
|
||||
|
||||
$messages = array_map( function( $key ) {
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( $key );
|
||||
return Member::loggedIn()->language()->addToStack( $key );
|
||||
}, $messages );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=manage" ), \IPS\Member::loggedIn()->language()->formatList( $messages ) );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=manage" ), Member::loggedIn()->language()->formatList( $messages ) );
|
||||
}
|
||||
}
|
||||
@@ -12,21 +12,54 @@
|
||||
namespace IPS\convert\modules\admin\manage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use InvalidArgumentException;
|
||||
use IPS\Application;
|
||||
use IPS\convert\App;
|
||||
use IPS\Convert\Exception;
|
||||
use IPS\convert\Library;
|
||||
use IPS\convert\Software;
|
||||
use IPS\DB;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Checkbox;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Password;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Helpers\Wizard;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use const IPS\DEMO_MODE;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new conversion session
|
||||
*/
|
||||
class _create extends \IPS\Dispatcher\Controller
|
||||
class create extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
@@ -37,13 +70,13 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( \IPS\CIC )
|
||||
{
|
||||
\IPS\Output::i()->error( 'module_no_permission', '2V391/3', 403, '' );
|
||||
Output::i()->error( 'module_no_permission', '2V391/3', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->responsive = FALSE;
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'create_manage' );
|
||||
Output::i()->responsive = FALSE;
|
||||
Dispatcher::i()->checkAcpPermission( 'create_manage' );
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'convert.css' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'convert.css' ) );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -55,27 +88,27 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
protected function manage()
|
||||
{
|
||||
/* We only use the Wizard helper for starting a conversion, so we need to make sure it is always starting new and not using old session data */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'convert_start' );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'convert_start' );
|
||||
|
||||
/* Let's call on the wizard to make some magic */
|
||||
\IPS\Output::i()->output = (string) new \IPS\Helpers\Wizard( array(
|
||||
Output::i()->output = (string) new Wizard( array(
|
||||
'convert_start_source_software' => array( $this, '_chooseSoftware' ),
|
||||
'convert_start_application' => array( $this, '_chooseApplications' ),
|
||||
'convert_start_database_details' => array( $this, '_setDatabaseDetails' ),
|
||||
'convert_start_conversion_details' => array( $this, '_setConversionDetails' ),
|
||||
), \IPS\Http\Url::internal( 'app=convert&module=manage&controller=create' ) );
|
||||
), Url::internal( 'app=convert&module=manage&controller=create' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose what software you want to convert from
|
||||
*
|
||||
* @param array $data Wizard data from previous steps
|
||||
* @return \IPS\Helpers\Form|array
|
||||
* @return Form|array
|
||||
*/
|
||||
public function _chooseSoftware( $data )
|
||||
{
|
||||
$options = array();
|
||||
foreach( \IPS\convert\Software::software()['core'] AS $key => $classname )
|
||||
foreach( Software::software()['core'] AS $key => $classname )
|
||||
{
|
||||
if ( class_exists( $classname ) AND $classname::canConvert() !== NULL )
|
||||
{
|
||||
@@ -83,8 +116,8 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'convert_source_software', 'choose_what_to_convert' );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'convert_start_source_software', NULL, TRUE, array( 'options' => $options ) ) );
|
||||
$form = new Form( 'convert_source_software', 'choose_what_to_convert' );
|
||||
$form->add( new Select( 'convert_start_source_software', NULL, TRUE, array( 'options' => $options ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -98,33 +131,33 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
* Choose which applications to convert
|
||||
*
|
||||
* @param array $data Wizard data from previous steps
|
||||
* @return \IPS\Helpers\Form|array
|
||||
* @return Form|array
|
||||
*/
|
||||
public function _chooseApplications( $data )
|
||||
{
|
||||
/* Figure out what converter libraries we have for the selected application */
|
||||
$software = $data['convert_start_source_software'];
|
||||
$applications = array( 'core' => \IPS\Member::loggedIn()->language()->addToStack( 'core_node_select' ) );
|
||||
$applications = array( 'core' => Member::loggedIn()->language()->addToStack( 'core_node_select' ) );
|
||||
|
||||
foreach( \IPS\convert\Library::libraries() AS $key => $class )
|
||||
foreach( Library::libraries() AS $key => $class )
|
||||
{
|
||||
/* Check app is installed and enabled */
|
||||
if( !\IPS\Application::appIsEnabled( $key ) )
|
||||
if( !Application::appIsEnabled( $key ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach( \IPS\convert\Software::software()[ $key ] AS $softwareKey => $softwareClass )
|
||||
foreach( Software::software()[ $key ] AS $softwareKey => $softwareClass )
|
||||
{
|
||||
if( $softwareKey == $software )
|
||||
{
|
||||
$applications[ $key ] = \IPS\Member::loggedIn()->language()->addToStack( $key . '_node_select' );
|
||||
$applications[ $key ] = Member::loggedIn()->language()->addToStack( $key . '_node_select' );
|
||||
}
|
||||
elseif( isset( $softwareClass::parents()['core'] ) )
|
||||
{
|
||||
if( \in_array( $software, $softwareClass::parents()['core'] ) )
|
||||
if( in_array( $software, $softwareClass::parents()['core'] ) )
|
||||
{
|
||||
$applications[ $key . '_' . $softwareKey ] = \IPS\Member::loggedIn()->language()->get( $key . '_node_select' ) . ' - ' . $softwareClass::softwareName();
|
||||
$applications[ $key . '_' . $softwareKey ] = Member::loggedIn()->language()->get( $key . '_node_select' ) . ' - ' . $softwareClass::softwareName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,13 +172,13 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
});
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'convert_application', 'enter_database_details' );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'choose_what_to_convert', array_keys( $preSelected ), FALSE, array( 'options' => $applications, 'disabled' => array( 'core' ) ) ) );
|
||||
$form = new Form( 'convert_application', 'enter_database_details' );
|
||||
$form->add( new CheckboxSet( 'choose_what_to_convert', array_keys( $preSelected ), FALSE, array( 'options' => $applications, 'disabled' => array( 'core' ) ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Core is required, and it was disabled on the form, so make sure it's in the array just to prevent people breaking stuff intentionally */
|
||||
if( !\in_array( 'core', $values['choose_what_to_convert'] ) )
|
||||
if( !in_array( 'core', $values['choose_what_to_convert'] ) )
|
||||
{
|
||||
$values['choose_what_to_convert'][] = 'core';
|
||||
}
|
||||
@@ -160,11 +193,11 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
* Allow the admin to supply the needed details
|
||||
*
|
||||
* @param array $data Wizard data from previous steps
|
||||
* @return \IPS\Helpers\Form|array
|
||||
* @return Form|array
|
||||
*/
|
||||
public function _setDatabaseDetails( $data )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'convert_database_details', 'enter_conversion_details' );
|
||||
$form = new Form( 'convert_database_details', 'enter_conversion_details' );
|
||||
|
||||
$usePrefix = NULL;
|
||||
|
||||
@@ -173,16 +206,16 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
if( mb_stristr( $application, '_' ) )
|
||||
{
|
||||
$converter = explode( '_', $application );
|
||||
$classname = \IPS\convert\Software::software()[ $converter[0] ] [ $converter[1] ];
|
||||
$classname = Software::software()[ $converter[0] ] [ $converter[1] ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$classname = \IPS\convert\Software::software()[ $application ] [ mb_strtolower( $data['convert_start_source_software'] ) ];
|
||||
$classname = Software::software()[ $application ] [ mb_strtolower( $data['convert_start_source_software'] ) ];
|
||||
}
|
||||
|
||||
if ( $classname::getPreConversionInformation() !== NULL )
|
||||
{
|
||||
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack( $classname::getPreConversionInformation() ), '', FALSE );
|
||||
$form->addMessage( Member::loggedIn()->language()->addToStack( $classname::getPreConversionInformation() ), '', FALSE );
|
||||
}
|
||||
|
||||
if( $application == 'core' )
|
||||
@@ -191,24 +224,24 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'convert_start_database_host', NULL, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'convert_start_database_port', 3306, FALSE, array( 'max' => 65535, 'min' => 1 ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'convert_start_database_name', NULL, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'convert_start_database_user', NULL, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Password( 'convert_start_database_pass', NULL, FALSE ) );
|
||||
$form->add( new Text( 'convert_start_database_host', NULL, FALSE ) );
|
||||
$form->add( new Number( 'convert_start_database_port', 3306, FALSE, array( 'max' => 65535, 'min' => 1 ) ) );
|
||||
$form->add( new Text( 'convert_start_database_name', NULL, FALSE ) );
|
||||
$form->add( new Text( 'convert_start_database_user', NULL, FALSE ) );
|
||||
$form->add( new Password( 'convert_start_database_pass', NULL, FALSE ) );
|
||||
|
||||
/* If the source software doesn't use a prefix, then we should not ask for one to avoid confusion. */
|
||||
if ( $usePrefix )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'convert_start_database_prefix', NULL, FALSE ) );
|
||||
$form->add( new Text( 'convert_start_database_prefix', NULL, FALSE ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'convert_start_database_charset', NULL, FALSE, array( 'placeholder' => 'utf8mb4' ) ) );
|
||||
$form->add( new Text( 'convert_start_database_charset', NULL, FALSE, array( 'placeholder' => 'utf8mb4' ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Start the (core) app object */
|
||||
$app = new \IPS\convert\App;
|
||||
$app = new App;
|
||||
$app->sw = 'core';
|
||||
$app->app_key = $data['convert_start_source_software'];
|
||||
$app->parent = 0;
|
||||
@@ -235,18 +268,18 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
$connectionSettings['sql_utf8mb4'] = TRUE;
|
||||
}
|
||||
|
||||
$db = \IPS\Db::i( 'convertertest', $connectionSettings );
|
||||
$db = Db::i( 'convertertest', $connectionSettings );
|
||||
$db->checkConnection();
|
||||
|
||||
/* Now test the charset */
|
||||
if ( $values['convert_start_database_charset'] AND !\in_array( $values['convert_start_database_charset'], array( 'utf8', 'utf8mb4' ) ) )
|
||||
if ( $values['convert_start_database_charset'] AND !in_array( $values['convert_start_database_charset'], array( 'utf8', 'utf8mb4' ) ) )
|
||||
{
|
||||
/* Get all db charsets and make sure the one we entered is valid */
|
||||
$charsets = \IPS\convert\Software::getDatabaseCharsets( $db );
|
||||
$charsets = Software::getDatabaseCharsets( $db );
|
||||
|
||||
if ( !\in_array( mb_strtolower( $values['convert_start_database_charset'] ), $charsets ) )
|
||||
if ( !in_array( mb_strtolower( $values['convert_start_database_charset'] ), $charsets ) )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'invalid_charset' );
|
||||
throw new InvalidArgumentException( 'invalid_charset' );
|
||||
}
|
||||
|
||||
$db->set_charset( $values['convert_start_database_charset'] );
|
||||
@@ -257,7 +290,7 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
|
||||
foreach( $data['choose_what_to_convert'] as $application )
|
||||
{
|
||||
$childApp = new \IPS\convert\App;
|
||||
$childApp = new App;
|
||||
|
||||
if( mb_stristr( $application, '_' ) )
|
||||
{
|
||||
@@ -291,12 +324,12 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$appClass->countRows( $testAgainst['table'] );
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'invalid_prefix' );
|
||||
throw new InvalidArgumentException( 'invalid_prefix' );
|
||||
}
|
||||
/* Can't find the table */
|
||||
catch( \IPS\convert\Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
if( $appToCheck->sw != 'core' )
|
||||
{
|
||||
@@ -310,16 +343,16 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
if( $e->getMessage() == 'invalid_charset' )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('convert_cant_connect_db_charset');
|
||||
$form->error = Member::loggedIn()->language()->addToStack('convert_cant_connect_db_charset');
|
||||
return $form;
|
||||
}
|
||||
else if( $e->getMessage() == 'invalid_prefix' )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('convert_cant_connect_db_prefix');
|
||||
$form->error = Member::loggedIn()->language()->addToStack('convert_cant_connect_db_prefix');
|
||||
return $form;
|
||||
}
|
||||
else
|
||||
@@ -329,7 +362,7 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('convert_cant_connect_db');
|
||||
$form->error = Member::loggedIn()->language()->addToStack('convert_cant_connect_db');
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -343,12 +376,12 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
/* Check for existing apps */
|
||||
try
|
||||
{
|
||||
$existingApp = \IPS\DB::i()->select( '*', 'convert_apps', array( 'sw=? AND app_key=? AND db_host=? AND db_db=? AND db_user=? AND db_pass=? AND db_prefix=?', $app->sw, $app->app_key, $app->db_host, $app->db_db, $app->db_user, $app->db_pass, $app->db_prefix ) )->first();
|
||||
$existingApp = DB::i()->select( '*', 'convert_apps', array( 'sw=? AND app_key=? AND db_host=? AND db_db=? AND db_user=? AND db_pass=? AND db_prefix=?', $app->sw, $app->app_key, $app->db_host, $app->db_db, $app->db_user, $app->db_pass, $app->db_prefix ) )->first();
|
||||
|
||||
/* App already exists */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&id={$existingApp['app_id']}" ), 'conversion_app_already_exists' );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=convert&id={$existingApp['app_id']}" ), 'conversion_app_already_exists' );
|
||||
}
|
||||
catch( \UnderflowException $e ) { }
|
||||
catch( UnderflowException $e ) { }
|
||||
|
||||
if ( !empty( $values['convert_start_database_charset'] ) )
|
||||
{
|
||||
@@ -369,7 +402,7 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
continue;
|
||||
}
|
||||
|
||||
if( \in_array( $application, $childAppsToRemove ) )
|
||||
if( in_array( $application, $childAppsToRemove ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -403,25 +436,25 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
* Allow the admin to supply the needed details
|
||||
*
|
||||
* @param array $data Wizard data from previous steps
|
||||
* @return \IPS\Helpers\Form
|
||||
* @return Form
|
||||
*/
|
||||
public function _setConversionDetails( $data )
|
||||
{
|
||||
/* We may be coming here from a previously incomplete conversion setup...detect and set the parent app ID appropriately */
|
||||
if( ( !isset( $data['_app_parent'] ) OR !$data['_app_parent'] ) AND isset( \IPS\Request::i()->id ) )
|
||||
if( ( !isset( $data['_app_parent'] ) OR !$data['_app_parent'] ) AND isset( Request::i()->id ) )
|
||||
{
|
||||
$data['_app_parent'] = \IPS\Request::i()->id;
|
||||
$data['_app_parent'] = Request::i()->id;
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'convert_other_details', 'start_conversion' );
|
||||
$form = new Form( 'convert_other_details', 'start_conversion' );
|
||||
|
||||
try
|
||||
{
|
||||
$parentApplication = \IPS\convert\App::load( $data['_app_parent'] );
|
||||
$parentApplication = App::load( $data['_app_parent'] );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'conversion_app_not_found', '3V391/1', 404, '' );
|
||||
Output::i()->error( 'conversion_app_not_found', '3V391/1', 404, '' );
|
||||
}
|
||||
|
||||
$this->_addConversionApplication( $parentApplication, $form );
|
||||
@@ -436,14 +469,14 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
/* We know the core/parent app is fine, but any child apps that don't have 'more_info' should be deleted as they cannot be converted */
|
||||
foreach( $parentApplication->children() as $childApplication )
|
||||
{
|
||||
if( !\count( $childApplication->_session['more_info'] ) )
|
||||
if( !count( $childApplication->_session['more_info'] ) )
|
||||
{
|
||||
$childApplication->delete();
|
||||
}
|
||||
}
|
||||
|
||||
/* We have already saved our custom configuration, so now we can head off to the races */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&id={$data['_app_parent']}" ) );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=convert&id={$data['_app_parent']}" ) );
|
||||
}
|
||||
|
||||
return $form;
|
||||
@@ -452,8 +485,8 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Add form elements for the specified application to the form
|
||||
*
|
||||
* @param \IPS\convert\App $app Conversion application
|
||||
* @param \IPS\Helpers\Form $form Form object
|
||||
* @param App $app Conversion application
|
||||
* @param Form $form Form object
|
||||
* @return void
|
||||
*/
|
||||
protected function _addConversionApplication( $app, &$form )
|
||||
@@ -462,16 +495,16 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
$libraryClass = $softwareClass->getLibrary();
|
||||
|
||||
/* Add a nice little header to the form */
|
||||
$form->addHeader( \IPS\Member::loggedIn()->language()->addToStack( 'converting_x_to_x', FALSE, array( 'sprintf' => array( $softwareClass::softwareName(), \IPS\Application::load( $app->sw )->_title ) ) ) );
|
||||
$form->addHeader( Member::loggedIn()->language()->addToStack( 'converting_x_to_x', FALSE, array( 'sprintf' => array( $softwareClass::softwareName(), Application::load( $app->sw )->_title ) ) ) );
|
||||
|
||||
/* Now fetch the details about this application we are converting so we can build the appropriate form elements */
|
||||
try
|
||||
{
|
||||
$menuRows = \IPS\convert\modules\admin\manage\convert::getMenuRows( $softwareClass, TRUE, TRUE );
|
||||
$menuRows = convert::getMenuRows( $softwareClass, TRUE, TRUE );
|
||||
}
|
||||
catch( \IPS\Convert\Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
$form->addMessage( 'nothing_convertable_found', 'ipsMessage ipsMessage_warning', TRUE );
|
||||
$form->addMessage( 'nothing_convertable_found', 'ipsMessage ipsMessage--warning', TRUE );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -483,17 +516,17 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
foreach( $softwareClass->settingsMapList() as $key => $setting )
|
||||
{
|
||||
$value = $setting['value'];
|
||||
if ( \is_bool( ( $setting['value'] ) ) )
|
||||
if ( is_bool( ( $setting['value'] ) ) )
|
||||
{
|
||||
$value = $setting['value'] === TRUE ? 'On' : 'Off';
|
||||
}
|
||||
|
||||
$settings[ $setting['our_key'] ] = new \IPS\Helpers\Form\Checkbox( $setting['our_key'], TRUE, FALSE, array( 'label' => $value ), NULL, NULL, NULL, $setting['our_key'] );
|
||||
$settings[ $setting['our_key'] ] = new Checkbox( $setting['our_key'], TRUE, FALSE, array( 'label' => $value ), NULL, NULL, NULL, $setting['our_key'] );
|
||||
}
|
||||
|
||||
/* Add a nice little header to the form */
|
||||
$form->addHeader( 'convert_settings' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'convert_settings', TRUE, TRUE, array( 'togglesOn' => array_keys( $settings ) ) ) );
|
||||
$form->add( new YesNo( 'convert_settings', TRUE, TRUE, array( 'togglesOn' => array_keys( $settings ) ) ) );
|
||||
|
||||
foreach( $settings as $settingFormField )
|
||||
{
|
||||
@@ -503,7 +536,7 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
/* Did we just submit? If so save our configuration */
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
$values = array_filter( $values, function( $key ) use ( $settings ) { return $key == 'convert_settings' OR \in_array( $key, array_keys( $settings ) ); }, ARRAY_FILTER_USE_KEY );
|
||||
$values = array_filter( $values, function( $key ) use ( $settings ) { return $key == 'convert_settings' OR in_array( $key, array_keys( $settings ) ); }, ARRAY_FILTER_USE_KEY );
|
||||
|
||||
$app->saveMoreInfo( 'convertSettings', $values );
|
||||
}
|
||||
@@ -515,10 +548,10 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
/* Determine if this step has any extra configuration questions */
|
||||
$formElements = array();
|
||||
|
||||
if ( \in_array( $row['step_method'], $softwareClass::checkConf() ) )
|
||||
if ( in_array( $row['step_method'], $softwareClass::checkConf() ) )
|
||||
{
|
||||
$getMoreInfo = $softwareClass->getMoreInfo( $row['step_method'] );
|
||||
if ( \is_array( $getMoreInfo ) AND \count( $getMoreInfo ) )
|
||||
if ( is_array( $getMoreInfo ) AND count( $getMoreInfo ) )
|
||||
{
|
||||
/* Show the 'more info' fields */
|
||||
foreach( $getMoreInfo as $key => $input )
|
||||
@@ -527,16 +560,16 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
$formElements[ $key ] = new $fieldClass( $key, $input['field_default'], $input['field_required'], $input['field_extra'], isset( $input['field_validation'] ) ? $input['field_validation'] : NULL, NULL, NULL, $key );
|
||||
if ( $input['field_hint'] !== NULL )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words[ $key . '_desc' ] = $input['field_hint'];
|
||||
Member::loggedIn()->language()->words[ $key . '_desc' ] = $input['field_hint'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form->addHeader( $row['step_title'] );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( $row['step_title'], TRUE, TRUE, array( 'togglesOn' => array_keys( $formElements ) ) ) );
|
||||
$form->add( new YesNo( $row['step_title'], TRUE, TRUE, array( 'togglesOn' => array_keys( $formElements ) ) ) );
|
||||
|
||||
if( \count( $formElements ) )
|
||||
if( count( $formElements ) )
|
||||
{
|
||||
foreach( $formElements as $key => $element )
|
||||
{
|
||||
@@ -547,22 +580,22 @@ class _create extends \IPS\Dispatcher\Controller
|
||||
/* Did we just submit? If so save our configuration */
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
$values = array_filter( $values, function( $key ) use ( $formElements, $row ) { return $key == $row['step_title'] OR \in_array( $key, array_keys( $formElements ) ); }, ARRAY_FILTER_USE_KEY );
|
||||
$values = array_filter( $values, function( $key ) use ( $formElements, $row ) { return $key == $row['step_title'] OR in_array( $key, array_keys( $formElements ) ); }, ARRAY_FILTER_USE_KEY );
|
||||
|
||||
$app->saveMoreInfo( $row['step_method'], $values );
|
||||
}
|
||||
}
|
||||
|
||||
/* If there was nothing to convert, show an appropriate message */
|
||||
if( $softwareClass::canConvertSettings() === FALSE AND !\count( $menuRows ) )
|
||||
if( $softwareClass::canConvertSettings() === FALSE AND !count( $menuRows ) )
|
||||
{
|
||||
$form->addMessage( 'nothing_convertable_found', 'ipsMessage ipsMessage_warning', TRUE );
|
||||
$form->addMessage( 'nothing_convertable_found', 'ipsMessage ipsMessage--warning', TRUE );
|
||||
}
|
||||
|
||||
/* If there is a message to show, go ahead and show it */
|
||||
if( $postConversionMessage = $libraryClass->getPostConversionInformation() )
|
||||
{
|
||||
$form->addMessage( $postConversionMessage, 'ipsMessage ipsMessage_info', FALSE );
|
||||
$form->addMessage( $postConversionMessage, 'ipsMessage ipsMessage--info', FALSE );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,21 +12,52 @@
|
||||
namespace IPS\convert\modules\admin\manage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Application;
|
||||
use IPS\convert\App;
|
||||
use IPS\convert\Software;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Password;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Http\Url;
|
||||
use IPS\IPS;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function file_put_contents;
|
||||
use function get_class;
|
||||
use function in_array;
|
||||
use const IPS\CONVERTERS_DEV_UI;
|
||||
use const IPS\DEMO_MODE;
|
||||
use const IPS\FOLDER_PERMISSION_NO_WRITE;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converter overview
|
||||
*/
|
||||
class _manage extends \IPS\Dispatcher\Controller
|
||||
class manage extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
@@ -35,13 +66,13 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if ( \IPS\DEMO_MODE === TRUE )
|
||||
if ( DEMO_MODE === TRUE )
|
||||
{
|
||||
\IPS\Output::i()->error( 'demo_mode_function_blocked', '2V407/1', 403, '' );
|
||||
Output::i()->error( 'demo_mode_function_blocked', '2V407/1', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->responsive = FALSE;
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'manage_manage' );
|
||||
Output::i()->responsive = FALSE;
|
||||
Dispatcher::i()->checkAcpPermission( 'manage_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -53,16 +84,16 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
protected function manage()
|
||||
{
|
||||
/* If mod_rewrite is not enabled, advise the administrator that old URLs will not redirect to the new locations automatically */
|
||||
if( !\IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
if( !Settings::i()->htaccess_mod_rewrite )
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( 'convert_mod_rewrite_urls', 'warning' );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->message( 'convert_mod_rewrite_urls', 'warning' );
|
||||
}
|
||||
|
||||
/* Remind the user that they must configure permissions after the conversion is complete */
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( 'convert_configure_permissions', 'info' );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->message( 'convert_configure_permissions', 'info' );
|
||||
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'convert_apps', \IPS\Http\Url::internal( 'app=convert&module=manage&controller=manage' ), array( 'parent=?', 0 ) );
|
||||
$table = new \IPS\Helpers\Table\Db( 'convert_apps', Url::internal( 'app=convert&module=manage&controller=manage' ), array( 'parent=?', 0 ) );
|
||||
$table->langPrefix = 'convert_';
|
||||
$table->include = array( 'app_key', 'sw', 'start_date', 'finished' );
|
||||
|
||||
@@ -86,48 +117,48 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
};
|
||||
|
||||
/* The main row will always be the core application (except for legacy conversions) */
|
||||
$applications = array( \IPS\Application::load( $translate( $val ) )->_title );
|
||||
$applications = array( Application::load( $translate( $val ) )->_title );
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'convert_apps', array( 'parent=?', $row['app_id'] ) ) as $software )
|
||||
foreach( Db::i()->select( '*', 'convert_apps', array( 'parent=?', $row['app_id'] ) ) as $software )
|
||||
{
|
||||
/* Translate the software key, if required */
|
||||
$software['sw'] = $translate( $software['sw'] );
|
||||
|
||||
try
|
||||
{
|
||||
if ( \IPS\CONVERTERS_DEV_UI === TRUE )
|
||||
if ( CONVERTERS_DEV_UI === TRUE )
|
||||
{
|
||||
$continueUrl = \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&id={$software['app_id']}&continue=1" )->csrf();
|
||||
$applications[] = "<a href='{$continueUrl}'>" . \IPS\Application::load( $software['sw'] )->_title . "</a>";
|
||||
$continueUrl = Url::internal( "app=convert&module=manage&controller=convert&id={$software['app_id']}&continue=1" )->csrf();
|
||||
$applications[] = "<a href='{$continueUrl}'>" . Application::load( $software['sw'] )->_title . "</a>";
|
||||
continue;
|
||||
}
|
||||
$applications[] = \IPS\Application::load( $software['sw'] )->_title;
|
||||
$applications[] = Application::load( $software['sw'] )->_title;
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$applications[] = mb_ucfirst( $software );
|
||||
$applications[] = IPS::mb_ucfirst( $software );
|
||||
}
|
||||
}
|
||||
|
||||
return \IPS\Member::loggedIn()->language()->formatList( $applications );
|
||||
return Member::loggedIn()->language()->formatList( $applications );
|
||||
},
|
||||
'app_key' => function( $val, $row )
|
||||
{
|
||||
$app = \IPS\convert\App::constructFromData( $row );
|
||||
$app = App::constructFromData( $row );
|
||||
|
||||
try
|
||||
{
|
||||
$classname = \get_class( $app->getSource(true,false) );
|
||||
$classname = get_class( $app->getSource() );
|
||||
return $classname::softwareName();
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
catch( Exception $ex )
|
||||
{
|
||||
return $val;
|
||||
}
|
||||
},
|
||||
'start_date' => function( $val )
|
||||
{
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
return (string) DateTime::ts( $val );
|
||||
},
|
||||
'finished' => function( $val )
|
||||
{
|
||||
@@ -144,27 +175,27 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
|
||||
if( !\IPS\CIC )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['start'] = array(
|
||||
Output::i()->sidebar['actions']['start'] = [
|
||||
'primary' => true,
|
||||
'icon' => 'plus',
|
||||
'title' => 'convert_start',
|
||||
'link' => \IPS\Http\Url::internal( "app=convert&module=manage&controller=create&_new=1" ),
|
||||
);
|
||||
'link' => Url::internal( "app=convert&module=manage&controller=create&_new=1" ),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
if ( \IPS\IN_DEV )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['software'] = array(
|
||||
Output::i()->sidebar['actions']['software'] = array(
|
||||
'icon' => 'plus',
|
||||
'title' => 'new_software',
|
||||
'link' => \IPS\Http\Url::internal( "app=convert&module=manage&controller=manage&do=software" ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('new_software') )
|
||||
'link' => Url::internal( "app=convert&module=manage&controller=manage&do=software" ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('new_software') )
|
||||
);
|
||||
\IPS\Output::i()->sidebar['actions']['library'] = array(
|
||||
Output::i()->sidebar['actions']['library'] = array(
|
||||
'icon' => 'plus',
|
||||
'title' => 'new_library',
|
||||
'link' => \IPS\Http\Url::internal( "app=convert&module=manage&controller=manage&do=library" ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('new_library') )
|
||||
'link' => Url::internal( "app=convert&module=manage&controller=manage&do=library" ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('new_library') )
|
||||
);
|
||||
}
|
||||
|
||||
@@ -173,29 +204,29 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
try
|
||||
{
|
||||
/* Try to load the application to make sure it's installed */
|
||||
\IPS\Application::load( $row['sw'] );
|
||||
Application::load( $row['sw'] );
|
||||
|
||||
/* Try to load the app class - if exception, the converter no longer exists */
|
||||
\IPS\convert\App::constructFromData( $row )->getSource();
|
||||
App::constructFromData( $row )->getSource();
|
||||
|
||||
$return = array();
|
||||
|
||||
if ( !$row['finished'] OR \IPS\CONVERTERS_DEV_UI === TRUE )
|
||||
if ( !$row['finished'] OR CONVERTERS_DEV_UI === TRUE )
|
||||
{
|
||||
$return[] = array(
|
||||
'icon' => 'chevron-circle-right',
|
||||
'title' => 'continue',
|
||||
'link' => \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&id={$row['app_id']}&continue=1" )->csrf()
|
||||
'link' => Url::internal( "app=convert&module=manage&controller=convert&id={$row['app_id']}&continue=1" )->csrf()
|
||||
);
|
||||
|
||||
if( \IPS\CONVERTERS_DEV_UI === TRUE AND !$row['finished'] )
|
||||
if( CONVERTERS_DEV_UI === TRUE AND !$row['finished'] )
|
||||
{
|
||||
$return[] = array(
|
||||
'icon' => 'check',
|
||||
'title' => 'finish',
|
||||
'link' => \IPS\Http\Url::internal( "app=convert&module=manage&controller=convert&do=finish&id={$row['app_id']}" )->csrf(),
|
||||
'link' => Url::internal( "app=convert&module=manage&controller=convert&do=finish&id={$row['app_id']}" )->csrf(),
|
||||
'data' => array(
|
||||
'confirm' => '', 'confirmSubMessage' => \IPS\Member::loggedIn()->language()->get( 'convert_finish_confirm' )
|
||||
'confirm' => '', 'confirmSubMessage' => Member::loggedIn()->language()->get( 'convert_finish_confirm' )
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -203,26 +234,26 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
$return[] = array(
|
||||
'icon' => 'pencil',
|
||||
'title' => 'edit',
|
||||
'link' => \IPS\Http\Url::internal( "app=convert&module=manage&controller=manage&do=edit&id={$row['app_id']}" ),
|
||||
'link' => Url::internal( "app=convert&module=manage&controller=manage&do=edit&id={$row['app_id']}" ),
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
/* Application has been uninstalled */
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
};
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'menu__convert_manage' );
|
||||
\IPS\Output::i()->output .= (string) $table;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'menu__convert_manage' );
|
||||
Output::i()->output .= (string) $table;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,11 +265,11 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( \IPS\IN_DEV === FALSE )
|
||||
{
|
||||
\IPS\Output::i()->error( 'new_sofware_not_in_dev', '1V100/1', 403 );
|
||||
Output::i()->error( 'new_sofware_not_in_dev', '1V100/1', 403 );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'classname', NULL, TRUE ) );
|
||||
$form = new Form;
|
||||
$form->add( new Text( 'classname', NULL, TRUE ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -266,24 +297,24 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
$code = str_replace( array( '<#NAMESPACE#>', '<#CLASS#>', '<#CLASS_LOWER#>' ), array( $namespace, $classname, mb_strtolower( $classname ) ), $default );
|
||||
|
||||
/* Check if we need to create a folder */
|
||||
if( \count( $copied ) > 1 )
|
||||
if( count( $copied ) > 1 )
|
||||
{
|
||||
$folder = \IPS\ROOT_PATH . "/applications/{$application}/sources/" . $copied[0];
|
||||
if( !file_exists( $folder ) )
|
||||
{
|
||||
@mkdir( $folder );
|
||||
@chmod( $folder, \IPS\FOLDER_PERMISSION_NO_WRITE );
|
||||
@chmod( $folder, FOLDER_PERMISSION_NO_WRITE );
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate the file */
|
||||
\file_put_contents( $filepath, $code );
|
||||
file_put_contents( $filepath, $code );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=manage" ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=manage" ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'new_software' );
|
||||
\IPS\Output::i()->output = (string) $form;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'new_software' );
|
||||
Output::i()->output = (string) $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,11 +326,11 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( \IPS\IN_DEV === FALSE )
|
||||
{
|
||||
\IPS\Output::i()->error( 'new_library_not_in_dev', '1V100/2', 403 );
|
||||
Output::i()->error( 'new_library_not_in_dev', '1V100/2', 403 );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'classname', NULL, TRUE ) );
|
||||
$form = new Form;
|
||||
$form->add( new Text( 'classname', NULL, TRUE ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -327,24 +358,24 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
$code = str_replace( array( '<#NAMESPACE#>', '<#CLASS#>', '<#CLASS_LOWER#>' ), array( $namespace, $classname, mb_strtolower( $classname ) ), $default );
|
||||
|
||||
/* Check if we need to create a folder */
|
||||
if( \count( $copied ) > 1 )
|
||||
if( count( $copied ) > 1 )
|
||||
{
|
||||
$folder = \IPS\ROOT_PATH . "/applications/{$application}/sources/" . $copied[0];
|
||||
if( !file_exists( $folder ) )
|
||||
{
|
||||
@mkdir( $folder );
|
||||
@chmod( $folder, \IPS\FOLDER_PERMISSION_NO_WRITE );
|
||||
@chmod( $folder, FOLDER_PERMISSION_NO_WRITE );
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate the file */
|
||||
\file_put_contents( $filepath, $code );
|
||||
file_put_contents( $filepath, $code );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=convert&module=manage&controller=manage' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=convert&module=manage&controller=manage' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'new_library' );
|
||||
\IPS\Output::i()->output = (string) $form;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'new_library' );
|
||||
Output::i()->output = (string) $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,38 +385,38 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
if ( !isset( \IPS\Request::i()->id ) )
|
||||
if ( !isset( Request::i()->id ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_conversion_app', '2V100/3' );
|
||||
Output::i()->error( 'no_conversion_app', '2V100/3' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$app = \IPS\convert\App::load( \IPS\Request::i()->id );
|
||||
$app = App::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'conversion_app_not_found', '2V100/4', 404 );
|
||||
Output::i()->error( 'conversion_app_not_found', '2V100/4', 404 );
|
||||
}
|
||||
|
||||
$classname = $app->getSource( FALSE );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
|
||||
if ( $classname::getPreConversionInformation() !== NULL )
|
||||
{
|
||||
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack( $classname::getPreConversionInformation() ), '', FALSE );
|
||||
$form->addMessage( Member::loggedIn()->language()->addToStack( $classname::getPreConversionInformation() ), '', FALSE );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'db_host', $app->db_host, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'db_port', $app->db_port, FALSE, array( 'max' => 65535, 'min' => 1 ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'db_db', $app->db_db, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'db_user', $app->db_user, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Password( 'db_pass', $app->db_pass, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'db_prefix', $app->db_prefix, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'db_charset', $app->db_charset, FALSE ) );
|
||||
$form->add( new Text( 'db_host', $app->db_host, FALSE ) );
|
||||
$form->add( new Number( 'db_port', $app->db_port, FALSE, array( 'max' => 65535, 'min' => 1 ) ) );
|
||||
$form->add( new Text( 'db_db', $app->db_db, FALSE ) );
|
||||
$form->add( new Text( 'db_user', $app->db_user, FALSE ) );
|
||||
$form->add( new Password( 'db_pass', $app->db_pass, FALSE ) );
|
||||
$form->add( new Text( 'db_prefix', $app->db_prefix, FALSE ) );
|
||||
$form->add( new Text( 'db_charset', $app->db_charset, FALSE ) );
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'edit_conversion' );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'edit_conversion' );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -406,17 +437,17 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
$connectionSettings['sql_utf8mb4'] = TRUE;
|
||||
}
|
||||
|
||||
$db = \IPS\Db::i( 'convertertest', $connectionSettings );
|
||||
$db = Db::i( 'convertertest', $connectionSettings );
|
||||
|
||||
/* Now test the charset */
|
||||
if ( $values['db_charset'] AND !\in_array( $values['db_charset'], array( 'utf8', 'utf8mb4' ) ) )
|
||||
if ( $values['db_charset'] AND !in_array( $values['db_charset'], array( 'utf8', 'utf8mb4' ) ) )
|
||||
{
|
||||
/* Get all db charsets and make sure the one we entered is valid */
|
||||
$charsets = \IPS\convert\Software::getDatabaseCharsets( $db );
|
||||
$charsets = Software::getDatabaseCharsets( $db );
|
||||
|
||||
if ( !\in_array( mb_strtolower( $values['db_charset'] ), $charsets ) )
|
||||
if ( !in_array( mb_strtolower( $values['db_charset'] ), $charsets ) )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'invalid_charset' );
|
||||
throw new InvalidArgumentException( 'invalid_charset' );
|
||||
}
|
||||
|
||||
$db->set_charset( $values['db_charset'] );
|
||||
@@ -430,21 +461,21 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
|
||||
if( !$db->checkForTable( $testAgainst['table'] ) )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'invalid_prefix' );
|
||||
throw new InvalidArgumentException( 'invalid_prefix' );
|
||||
}
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
if( $e->getMessage() == 'invalid_charset' )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('convert_cant_connect_db_charset');
|
||||
\IPS\Output::i()->output = $form;
|
||||
$form->error = Member::loggedIn()->language()->addToStack('convert_cant_connect_db_charset');
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
else if( $e->getMessage() == 'invalid_prefix' )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('convert_cant_connect_db_prefix');
|
||||
\IPS\Output::i()->output = $form;
|
||||
$form->error = Member::loggedIn()->language()->addToStack('convert_cant_connect_db_prefix');
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -452,10 +483,10 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('convert_cant_connect_db');
|
||||
\IPS\Output::i()->output = $form;
|
||||
$form->error = Member::loggedIn()->language()->addToStack('convert_cant_connect_db');
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -480,9 +511,9 @@ class _manage extends \IPS\Dispatcher\Controller
|
||||
$child->save();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=convert&module=manage&controller=manage" ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( "app=convert&module=manage&controller=manage" ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user