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,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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user