Version 5.0.0 beta 4
This commit is contained in:
1 parent
e86153356a
commit
2f24f9de48
276 files changed
+8614
-6044
No files matched your search
@@ -18,6 +18,7 @@ use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Db\Exception as DbException;
|
||||
use IPS\Db\Select;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Log;
|
||||
@@ -42,32 +43,37 @@ abstract class Software
|
||||
/**
|
||||
* @brief \IPS\convert\App instance
|
||||
*/
|
||||
public $app = NULL;
|
||||
public ?App $app = NULL;
|
||||
|
||||
/**
|
||||
* @brief \IPS\Db instance to the source application
|
||||
*/
|
||||
public $db = NULL;
|
||||
public ?Db $db = NULL;
|
||||
|
||||
/**
|
||||
* @brief Is UTF8
|
||||
*/
|
||||
public $isUtfEight = TRUE;
|
||||
public bool $isUtfEight = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Flag to indicate the post data has been fixed during conversion, and we only need to use Legacy Parser
|
||||
*/
|
||||
public static $contentFixed = FALSE;
|
||||
public static bool $contentFixed = FALSE;
|
||||
|
||||
/**
|
||||
* @var Software|string|null
|
||||
*/
|
||||
public Software|string|null $parent = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param App $app The application to reference for database and other information.
|
||||
* @param bool $needDB If the database is needed or not.
|
||||
* @param bool $needDB If the database is needed or not.
|
||||
* @return void
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(App $app, $needDB=TRUE )
|
||||
public function __construct( App $app, bool $needDB=TRUE )
|
||||
{
|
||||
$this->app = $app;
|
||||
|
||||
@@ -125,7 +131,7 @@ abstract class Software
|
||||
$this->db->set_charset( $this->app->db_charset );
|
||||
}
|
||||
}
|
||||
catch( \IPS\Db\Exception $e )
|
||||
catch( DbException $e )
|
||||
{
|
||||
throw new InvalidArgumentException( "Database Connection Failed: " . $e->getMessage() );
|
||||
}
|
||||
@@ -139,7 +145,7 @@ abstract class Software
|
||||
* @param mixed $arguments Arguments to pass to the method
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call( $name, $arguments )
|
||||
public function __call( string $name, mixed $arguments )
|
||||
{
|
||||
if ( method_exists( $this, 'convert' . $name ) )
|
||||
{
|
||||
@@ -162,7 +168,7 @@ abstract class Software
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function software()
|
||||
public static function software() : array
|
||||
{
|
||||
return array(
|
||||
'core' => array(
|
||||
@@ -236,10 +242,10 @@ abstract class Software
|
||||
/**
|
||||
* Software Name
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
* @throws BadMethodCallException
|
||||
*/
|
||||
public static function softwareName()
|
||||
public static function softwareName(): string
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
throw new BadMethodCallException( 'no_name' );
|
||||
@@ -248,10 +254,10 @@ abstract class Software
|
||||
/**
|
||||
* Software Key
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
* @throws BadMethodCallException
|
||||
*/
|
||||
public static function softwareKey()
|
||||
public static function softwareKey(): string
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
throw new BadMethodCallException( 'no_key' );
|
||||
@@ -260,9 +266,9 @@ abstract class Software
|
||||
/**
|
||||
* Requires Parent
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function requiresParent()
|
||||
public static function requiresParent(): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -270,9 +276,9 @@ abstract class Software
|
||||
/**
|
||||
* Possible Parent Conversions
|
||||
*
|
||||
* @return NULL|array
|
||||
* @return array|NULL
|
||||
*/
|
||||
public static function parents()
|
||||
public static function parents(): ?array
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -280,9 +286,9 @@ abstract class Software
|
||||
/**
|
||||
* Uses Prefix
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public static function usesPrefix()
|
||||
public static function usesPrefix(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -290,10 +296,10 @@ abstract class Software
|
||||
/**
|
||||
* Content we can convert from this software.
|
||||
*
|
||||
* @return array|NULL
|
||||
* @return array|NULL
|
||||
* @throws BadMethodCallException
|
||||
*/
|
||||
public static function canConvert()
|
||||
public static function canConvert(): ?array
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
throw new BadMethodCallException( 'nothing_to_convert' );
|
||||
@@ -302,9 +308,9 @@ abstract class Software
|
||||
/**
|
||||
* Can we translate settings over to our Invision Community equivalents?
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function canConvertSettings()
|
||||
public static function canConvertSettings(): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -313,12 +319,12 @@ abstract class Software
|
||||
* Settings Map
|
||||
*
|
||||
* @code
|
||||
return array(
|
||||
'source_setting_key' => array( 'ips_setting_key' );
|
||||
* return array(
|
||||
* 'source_setting_key' => array( 'ips_setting_key' );
|
||||
* @endcode
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function settingsMap()
|
||||
public function settingsMap(): array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
@@ -327,15 +333,15 @@ abstract class Software
|
||||
* Settings Map List
|
||||
*
|
||||
* @code
|
||||
return array(
|
||||
'source_setting_key' => array(
|
||||
'title' => 'Human Readable Name as presented in the source',
|
||||
'value' => 'The value from the source',
|
||||
);
|
||||
* return array(
|
||||
* 'source_setting_key' => array(
|
||||
* 'title' => 'Human Readable Name as presented in the source',
|
||||
* 'value' => 'The value from the source',
|
||||
* );
|
||||
* @endcode
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function settingsMapList()
|
||||
public function settingsMapList():array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
@@ -343,9 +349,9 @@ abstract class Software
|
||||
/**
|
||||
* List of Conversion Methods that require more information
|
||||
*
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public static function checkConf()
|
||||
public static function checkConf(): array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
@@ -353,24 +359,24 @@ abstract class Software
|
||||
/**
|
||||
* An array of steps which require more information. This method should return array like below if any steps require additional information. Otherwise, it should return NULL.
|
||||
*
|
||||
* @param string $method Conversion method
|
||||
* @return array|NULL
|
||||
* @param string $method Conversion method
|
||||
* @return array|NULL
|
||||
*
|
||||
* @code
|
||||
return array(
|
||||
'convertAttachments' => array(
|
||||
'upload_path' => array( // The key is the name of the field, or the first parameter of the helper class constructor.
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text', // The form helper class for this field
|
||||
'field_default' => NULL, // The default value for this field.
|
||||
'field_required' => TRUE, // TRUE if this field is required.
|
||||
'field_extra' => array(), // Array of extra data that would normally go in $options for the form helper.
|
||||
'field_hint' => NULL, // A language key of hint text to display after the form (such as path to IPS Suite files). NULL for no additional text.
|
||||
),
|
||||
)
|
||||
);
|
||||
* return array(
|
||||
* 'convertAttachments' => array(
|
||||
* 'upload_path' => array( // The key is the name of the field, or the first parameter of the helper class constructor.
|
||||
* 'field_class' => 'IPS\\Helpers\\Form\\Text', // The form helper class for this field
|
||||
* 'field_default' => NULL, // The default value for this field.
|
||||
* 'field_required' => TRUE, // TRUE if this field is required.
|
||||
* 'field_extra' => array(), // Array of extra data that would normally go in $options for the form helper.
|
||||
* 'field_hint' => NULL, // A language key of hint text to display after the form (such as path to IPS Suite files). NULL for no additional text.
|
||||
* ),
|
||||
* )
|
||||
* );
|
||||
* @endcode
|
||||
*/
|
||||
public function getMoreInfo( $method )
|
||||
public function getMoreInfo( string $method ):?array
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -378,9 +384,9 @@ abstract class Software
|
||||
/**
|
||||
* Can we convert passwords from this software.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function loginEnabled()
|
||||
public static function loginEnabled(): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -388,13 +394,13 @@ abstract class Software
|
||||
/**
|
||||
* Count Source Rows for a specific step
|
||||
*
|
||||
* @param string $table The table containing the rows to count.
|
||||
* @param array|NULL $where WHERE clause to only count specific rows, or NULL to count all.
|
||||
* @param bool $recache Skip cache and pull directly (updating cache)
|
||||
* @return integer
|
||||
* @param string $table The table containing the rows to count.
|
||||
* @param string|array|NULL $where WHERE clause to only count specific rows, or NULL to count all.
|
||||
* @param bool $recache Skip cache and pull directly (updating cache)
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public function countRows( $table, $where=NULL, $recache=FALSE )
|
||||
public function countRows( string $table, string|array|null $where=NULL, bool $recache=FALSE ): int
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -416,11 +422,11 @@ abstract class Software
|
||||
/**
|
||||
* Get Library Class
|
||||
*
|
||||
* @param string|NULL $library Specific library to fetch
|
||||
* @param string|NULL $library Specific library to fetch
|
||||
* @return Library
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getLibrary( $library=NULL )
|
||||
public function getLibrary( ?string $library=NULL ): Library
|
||||
{
|
||||
$library = $library ?: $this->app->sw;
|
||||
|
||||
@@ -437,9 +443,9 @@ abstract class Software
|
||||
/**
|
||||
* Allows software to add additional menu row options
|
||||
*
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function extraMenuRows()
|
||||
public function extraMenuRows(): array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
@@ -447,9 +453,9 @@ abstract class Software
|
||||
/**
|
||||
* Returns a block of text, or a language string, that explains what the admin must do to start this conversion
|
||||
*
|
||||
* @return string|NULL
|
||||
* @return string|NULL
|
||||
*/
|
||||
public static function getPreConversionInformation()
|
||||
public static function getPreConversionInformation(): ?string
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -457,13 +463,13 @@ abstract class Software
|
||||
/**
|
||||
* Fetch Remote Data
|
||||
*
|
||||
* @param string $table The table to selected data from
|
||||
* @param string $idColumn The ID column to sort on, when not using keys.
|
||||
* @param string|array|NULL $where WHERE clause for specific data to fetch.
|
||||
* @param string $what What to fetch
|
||||
* @return Select An \IPS\Db\Select object that can be further manipulated if necessary (e.g. joins)
|
||||
* @param string|array $table The table to selected data from
|
||||
* @param string $idColumn The ID column to sort on, when not using keys.
|
||||
* @param string|array|NULL $where WHERE clause for specific data to fetch.
|
||||
* @param string $what What to fetch
|
||||
* @return Select An \IPS\Db\Select object that can be further manipulated if necessary (e.g. joins)
|
||||
*/
|
||||
public function fetch( $table, $idColumn='id', $where=NULL, $what='*' )
|
||||
public function fetch( string|array $table, string $idColumn='id', string|array|null $where=NULL, string $what='*' ): Select
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
if ( $libraryClass::$usingKeys === FALSE )
|
||||
@@ -500,9 +506,9 @@ abstract class Software
|
||||
/**
|
||||
* Finish - Adds everything it needs to the queues and clears data store
|
||||
*
|
||||
* @return array Messages to display
|
||||
* @return array Messages to display
|
||||
*/
|
||||
public function finish()
|
||||
public function finish(): array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
@@ -510,9 +516,9 @@ abstract class Software
|
||||
/**
|
||||
* Pre-process content for the Invision Community text parser
|
||||
*
|
||||
* @param string The post
|
||||
* @param string|null Content Classname passed by post-conversion rebuild
|
||||
* @param int|null Content ID passed by post-conversion rebuild
|
||||
* @param string $post The post
|
||||
* @param string|null $className Content Classname passed by post-conversion rebuild
|
||||
* @param int|null $contentId ID passed by post-conversion rebuild
|
||||
* @return string The converted post
|
||||
*/
|
||||
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
|
||||
@@ -526,7 +532,7 @@ abstract class Software
|
||||
* @param Db $database Database connection
|
||||
* @return array
|
||||
*/
|
||||
public static function getDatabaseCharsets( $database )
|
||||
public static function getDatabaseCharsets( Db $database ) : array
|
||||
{
|
||||
$charsets = array();
|
||||
$result = $database->query( "SHOW CHARACTER SET;" );
|
||||
@@ -542,9 +548,9 @@ abstract class Software
|
||||
/**
|
||||
* Check if we can redirect the legacy URLs from this software to the new locations
|
||||
*
|
||||
* @return NULL|Url
|
||||
* @return Url|NULL
|
||||
*/
|
||||
public function checkRedirects()
|
||||
public function checkRedirects(): ?Url
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user