Version 5.0.0 beta 4

This commit is contained in:
Neo committed 2025-12-19 16:57:00 -08:00
1 parent e86153356a
commit 2f24f9de48
276 files changed
+8614 -6044

No files matched your search

@@ -33,9 +33,9 @@ class Joomla extends Software
/**
* Software Name
*
* @return string
* @return string
*/
public static function softwareName()
public static function softwareName(): string
{
/* Child classes must override this method */
return "Joomla";
@@ -44,9 +44,9 @@ class Joomla extends Software
/**
* Software Key
*
* @return string
* @return string
*/
public static function softwareKey()
public static function softwareKey(): string
{
/* Child classes must override this method */
return "joomla";
@@ -55,9 +55,9 @@ class Joomla extends Software
/**
* Content we can convert from this software.
*
* @return array
* @return array|null
*/
public static function canConvert()
public static function canConvert(): ?array
{
return array(
'convertCmsDatabases' => array(
@@ -78,32 +78,30 @@ class Joomla extends 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 integer
* @throws \IPS\convert\Exception
*/
public function countRows( $table, $where=NULL, $recache=FALSE )
public function countRows( string $table, string|array|null $where=NULL, bool $recache=FALSE ): int
{
switch( $table )
{
case 'cms_database':
return 1;
break;
default:
return parent::countRows( $table, $where, $recache );
break;
}
}
/**
* Can we convert passwords from this software.
*
* @return boolean
* @return boolean
*/
public static function loginEnabled()
public static function loginEnabled(): bool
{
return TRUE;
}
@@ -111,9 +109,9 @@ class Joomla extends Software
/**
* Requires Parent?
*
* @return bool
* @return bool
*/
public static function requiresParent()
public static function requiresParent(): bool
{
return TRUE;
}
@@ -121,9 +119,9 @@ class Joomla extends Software
/**
* Available Parents
*
* @return array
* @return array|null
*/
public static function parents()
public static function parents(): ?array
{
return array( 'core' => array( 'joomla' ) );
}
@@ -131,9 +129,9 @@ class Joomla extends 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
{
try
{
@@ -154,7 +152,7 @@ class Joomla extends Software
*
* @return void
*/
public function convertCmsDatabases()
public function convertCmsDatabases() : void
{
$libraryClass = $this->getLibrary();
@@ -198,13 +196,13 @@ class Joomla extends Software
*
* @return void
*/
public function convertCmsDatabaseCategories()
public function convertCmsDatabaseCategories() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id' );
foreach( $this->fetch( 'categories', 'id' ) as $row )
foreach( $this->fetch( 'categories' ) as $row )
{
$info = array(
'category_id' => $row['id'],
@@ -225,13 +223,13 @@ class Joomla extends Software
*
* @return void
*/
public function convertCmsDatabaseRecords()
public function convertCmsDatabaseRecords() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id' );
foreach( $this->fetch( 'content', 'id' ) as $row )
foreach( $this->fetch( 'content' ) as $row )
{
/* Set the basic details */
$info = array(
@@ -43,19 +43,19 @@ class Vbulletin extends Software
/**
* @brief The schematic for vB3 and vB4 is similar enough that we can make specific concessions in a single converter for either version.
*/
protected static $isLegacy = NULL;
protected static ?bool $isLegacy = NULL;
/**
* @brief Cached article content type
*/
protected static $_articleContentType = NULL;
protected static mixed $_articleContentType = NULL;
/**
* Software Name
*
* @return string
* @return string
*/
public static function softwareName()
public static function softwareName(): string
{
/* Child classes must override this method */
return "vBulletin CMS (4.x only)";
@@ -64,9 +64,9 @@ class Vbulletin extends Software
/**
* Software Key
*
* @return string
* @return string
*/
public static function softwareKey()
public static function softwareKey(): string
{
/* Child classes must override this method */
return "vbulletin";
@@ -80,9 +80,9 @@ class Vbulletin extends Software
* @return void
* @throws InvalidArgumentException
*/
public function __construct( App $app, $needDB=TRUE )
public function __construct( App $app, bool $needDB=TRUE )
{
$return = parent::__construct( $app, $needDB );
parent::__construct( $app, $needDB );
/* Is this vB3 or vB4? */
try
@@ -113,19 +113,16 @@ class Vbulletin extends Software
}
catch( \Exception $e ) {}
return $return;
}
/**
* Content we can convert from this software.
*
* @return array
* @return array|null
*/
public static function canConvert()
public static function canConvert(): ?array
{
$return = array(
return array(
'convertCmsBlocks' => array(
'table' => 'cms_widget',
'where' => NULL,
@@ -151,20 +148,18 @@ class Vbulletin extends Software
'where' => array( "contenttypeid=?", static::$_articleContentType )
)
);
return $return;
}
/**
* 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 integer
* @throws \IPS\convert\Exception
*/
public function countRows( $table, $where=NULL, $recache=FALSE )
public function countRows( string $table, string|array|null $where=NULL, bool $recache=FALSE ): int
{
switch( $table )
{
@@ -182,24 +177,22 @@ class Vbulletin extends Software
{
throw new \IPS\convert\Exception( sprintf( Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
}
break;
case 'page':
case 'database':
return 1;
break;
default:
return parent::countRows( $table, $where, $recache );
break;
}
}
/**
* Requires Parent
*
* @return boolean
* @return boolean
*/
public static function requiresParent()
public static function requiresParent(): bool
{
return TRUE;
}
@@ -207,9 +200,9 @@ class Vbulletin extends Software
/**
* Possible Parent Conversions
*
* @return array
* @return array|null
*/
public static function parents()
public static function parents(): ?array
{
return array( 'core' => array( 'vbulletin' ) );
}
@@ -217,9 +210,9 @@ class Vbulletin extends 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 post
* @param string|null $className 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
@@ -233,7 +226,7 @@ class Vbulletin extends Software
* @param string $key The setting key
* @return mixed
*/
protected function _setting( $key )
protected function _setting( string $key ) : mixed
{
if ( isset( $this->settingsCache[$key] ) )
{
@@ -267,7 +260,7 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertCmsBlocks()
public function convertCmsBlocks() : void
{
$libraryClass = $this->getLibrary();
@@ -326,7 +319,7 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertCmsPages()
public function convertCmsPages() : void
{
$this->getLibrary()->convertCmsPage( array(
'page_id' => 1,
@@ -341,7 +334,7 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertCmsDatabases()
public function convertCmsDatabases() : void
{
$convertedForums = FALSE;
try
@@ -402,7 +395,7 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertCmsDatabaseCategories()
public function convertCmsDatabaseCategories() : void
{
$libraryClass = $this->getLibrary();
@@ -428,7 +421,7 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertCmsDatabaseRecords()
public function convertCmsDatabaseRecords() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'contentid' );
@@ -584,9 +577,9 @@ class Vbulletin extends 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
{
foreach( Db::i()->select( 'ipb_id', 'convert_link', array( 'type=? AND app=?', 'cms_databases', $this->app->app_id ) ) as $database )
{
@@ -609,7 +602,7 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertAttachments()
public function convertAttachments() : void
{
$libraryClass = $this->getLibrary();
@@ -712,9 +705,9 @@ class Vbulletin extends Software
/**
* List of conversion methods that require additional information
*
* @return array
* @return array
*/
public static function checkConf()
public static function checkConf(): array
{
return array( 'convertAttachments' );
}
@@ -722,10 +715,10 @@ class Vbulletin extends Software
/**
* Get More Information
*
* @param string $method Conversion method
* @return array
* @param string $method Conversion method
* @return array|null
*/
public function getMoreInfo( $method )
public function getMoreInfo( string $method ): ?array
{
$return = array();
switch( $method )
@@ -14,11 +14,15 @@ namespace IPS\convert\Software\Cms;
/* To prevent PHP errors (extending class does not exist) revealing path */
use DomainException;
use DOMXPath;
use IPS\convert\Software;
use IPS\convert\Software\Exception;
use IPS\DateTime;
use IPS\Db;
use IPS\Member;
use IPS\Task;
use IPS\Text\DOMParser;
use IPS\Xml\DOMDocument;
use OutOfRangeException;
use UnderflowException;
use function defined;
@@ -30,16 +34,16 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
}
/**
* Wordpress Pages Converter
* WordPress Pages Converter
*/
class Wordpress extends Software
{
/**
* Software Name
*
* @return string
* @return string
*/
public static function softwareName()
public static function softwareName(): string
{
/* Child classes must override this method */
return "WordPress (5.x)";
@@ -48,9 +52,9 @@ class Wordpress extends Software
/**
* Software Key
*
* @return string
* @return string
*/
public static function softwareKey()
public static function softwareKey(): string
{
/* Child classes must override this method */
return "wordpress";
@@ -59,9 +63,9 @@ class Wordpress extends Software
/**
* Content we can convert from this software.
*
* @return array
* @return array|null
*/
public static function canConvert()
public static function canConvert(): ?array
{
return array(
'convertCmsPages' => array(
@@ -94,32 +98,30 @@ class Wordpress extends 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 integer
* @throws \IPS\convert\Exception
*/
public function countRows( $table, $where=NULL, $recache=FALSE )
public function countRows( string $table, string|array|null $where=NULL, bool $recache=FALSE ): int
{
switch( $table )
{
case 'cms_database':
return 1;
break;
default:
return parent::countRows( $table, $where, $recache );
break;
}
}
/**
* Requires Parent?
*
* @return bool
* @return bool
*/
public static function requiresParent()
public static function requiresParent(): bool
{
return TRUE;
}
@@ -127,9 +129,9 @@ class Wordpress extends Software
/**
* Available Parents
*
* @return array
* @return array|null
*/
public static function parents()
public static function parents(): ?array
{
return array( 'core' => array( 'wordpress', 'wpforo' ) );
}
@@ -137,9 +139,9 @@ class Wordpress extends Software
/**
* List of conversion methods that require additional information
*
* @return array
* @return array
*/
public static function checkConf()
public static function checkConf(): array
{
return array(
'convertAttachments',
@@ -150,10 +152,10 @@ class Wordpress extends Software
/**
* Get More Information
*
* @param string $method Conversion method
* @return array
* @param string $method Conversion method
* @return array|null
*/
public function getMoreInfo( $method )
public function getMoreInfo( string $method ): ?array
{
$return = array();
@@ -188,9 +190,9 @@ class Wordpress extends 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
{
try
{
@@ -215,7 +217,7 @@ class Wordpress extends Software
*
* @return void
*/
public function convertCmsPages()
public function convertCmsPages() : void
{
$libraryClass = $this->getLibrary();
@@ -239,7 +241,7 @@ class Wordpress extends Software
*
* @return void
*/
public function convertCmsDatabases()
public function convertCmsDatabases() : void
{
$libraryClass = $this->getLibrary();
@@ -283,7 +285,7 @@ class Wordpress extends Software
*
* @return void
*/
public function convertCmsDatabaseCategories()
public function convertCmsDatabaseCategories() : void
{
$libraryClass = $this->getLibrary();
@@ -309,7 +311,7 @@ class Wordpress extends Software
*
* @return void
*/
public function convertCmsDatabaseRecords()
public function convertCmsDatabaseRecords() : void
{
$libraryClass = $this->getLibrary();
@@ -435,7 +437,7 @@ class Wordpress extends Software
*
* @return void
*/
public function convertCmsDatabaseComments()
public function convertCmsDatabaseComments() : void
{
$libraryClass = $this->getLibrary();
@@ -475,14 +477,14 @@ class Wordpress extends Software
}
}
protected $postContent = [];
protected array $postContent = [];
/**
* Convert attachments
*
* @return void
*/
public function convertAttachments()
public function convertAttachments() : void
{
$database = $this->app->getLink( 1, 'cms_databases' );
$contentField = $this->app->getLink( 2, 'cms_database_fields' );
@@ -499,7 +501,7 @@ class Wordpress extends Software
$libraryClass->setLastKeyValue( $row['ID'] );
continue;
}
catch( \UnderflowException $e ) {}
catch( UnderflowException $e ) {}
try
{
@@ -507,10 +509,10 @@ class Wordpress extends Software
$postId = $this->app->getLink( $wpPost['ID'], "cms_custom_database_" . $database );
if( !isset( $this->postContent[ $postId ] ) )
{
$this->postContent[ $postId ] = \IPS\Db::i()->select( 'field_' . $contentField, 'cms_custom_database_' . $database, array( "primary_id_field=?", $postId ) )->first();
$this->postContent[ $postId ] = Db::i()->select( 'field_' . $contentField, 'cms_custom_database_' . $database, array( "primary_id_field=?", $postId ) )->first();
}
}
catch( \UnderflowException | \OutOfRangeException $e )
catch( UnderflowException|OutOfRangeException $e )
{
$libraryClass->setLastKeyValue( $row['ID'] );
continue;
@@ -541,9 +543,9 @@ class Wordpress extends Software
if( $attachId !== FALSE AND mb_stristr( $this->postContent[ $postId ], $meta['_wp_attached_file'] ) )
{
$dom = new \IPS\Xml\DOMDocument( '1.0', 'UTF-8' );
$dom->loadHTML( \IPS\Xml\DOMDocument::wrapHtml( $this->postContent[ $postId ] ) );
$xPath = new \DOMXPath( $dom );
$dom = new DOMDocument( '1.0', 'UTF-8' );
$dom->loadHTML( DOMDocument::wrapHtml( $this->postContent[ $postId ] ) );
$xPath = new DOMXPath( $dom );
foreach ( $xPath->query( "//img[contains(@src, '" . $meta['_wp_attached_file'] ."')] | //a[contains(@href, '" . $meta['_wp_attached_file'] ."')]" ) as $tag )
{
@@ -552,7 +554,7 @@ class Wordpress extends Software
}
/* Get DOMDocument output */
$content = \IPS\Text\DOMParser::getDocumentBodyContents( $dom );
$content = DOMParser::getDocumentBodyContents( $dom );
/* Replace file storage tags */
$content = preg_replace( '/&lt;fileStore\.([\d\w\_]+?)&gt;/i', '<fileStore.$1>', $content );
@@ -567,7 +569,7 @@ class Wordpress extends Software
/* Do the updates */
foreach( $this->postContent as $pid => $content )
{
\IPS\Db::i()->update( 'cms_custom_database_' . $database, array( 'field_' . $contentField => $content ), array( 'primary_id_field=?', $pid ) );
Db::i()->update( 'cms_custom_database_' . $database, array( 'field_' . $contentField => $content ), array( 'primary_id_field=?', $pid ) );
}
}
}
@@ -31,9 +31,9 @@ class Xenforo extends Software
/**
* Software Name
*
* @return string
* @return string
*/
public static function softwareName()
public static function softwareName(): string
{
/* Child classes must override this method */
return "XenForo Page Nodes (1.5.x/2.0.x/2.1.x/2.2.x)";
@@ -42,9 +42,9 @@ class Xenforo extends Software
/**
* Software Key
*
* @return string
* @return string
*/
public static function softwareKey()
public static function softwareKey(): string
{
/* Child classes must override this method */
return "xenforo";
@@ -53,9 +53,9 @@ class Xenforo extends Software
/**
* Content we can convert from this software.
*
* @return array
* @return array|null
*/
public static function canConvert()
public static function canConvert(): ?array
{
return array(
'convertCmsPages' => array(
@@ -68,9 +68,9 @@ class Xenforo extends Software
/**
* Uses Prefix
*
* @return bool
* @return bool
*/
public static function usesPrefix()
public static function usesPrefix(): bool
{
return FALSE;
}
@@ -78,9 +78,9 @@ class Xenforo extends Software
/**
* Requires Parent
*
* @return boolean
* @return boolean
*/
public static function requiresParent()
public static function requiresParent(): bool
{
return TRUE;
}
@@ -88,9 +88,9 @@ class Xenforo extends Software
/**
* Possible Parent Conversions
*
* @return array
* @return array|null
*/
public static function parents()
public static function parents(): ?array
{
return array( 'core' => array( 'xenforo' ) );
}
@@ -100,7 +100,7 @@ class Xenforo extends Software
*
* @return void
*/
public function convertCmsPages()
public function convertCmsPages() : void
{
$libraryClass = $this->getLibrary();
@@ -36,19 +36,19 @@ class Xenfororm extends Software
/**
* @brief The similarities between XF1 and XF2 are close enough that we can use the same converter
*/
public static $isLegacy = NULL;
public static ?bool $isLegacy = NULL;
/**
* @brief XF2 Has prefixes on RM tables
*/
public static $tablePrefix = '';
public static string $tablePrefix = '';
/**
* Software Name
*
* @return string
* @return string
*/
public static function softwareName()
public static function softwareName(): string
{
/* Child classes must override this method */
return "XenForo Resource Manager Articles (1.5.x/2.0.x/2.1.x/2.2.x)";
@@ -62,9 +62,9 @@ class Xenfororm extends Software
* @return void
* @throws InvalidArgumentException
*/
public function __construct( App $app, $needDB=TRUE )
public function __construct( App $app, bool $needDB=TRUE )
{
$return = parent::__construct( $app, $needDB );
parent::__construct( $app, $needDB );
if ( $needDB )
{
@@ -88,16 +88,14 @@ class Xenfororm extends Software
}
catch( \Exception $e ) {} # If we can't query, we won't be able to do anything anyway
}
return $return;
}
/**
* Software Key
*
* @return string
* @return string
*/
public static function softwareKey()
public static function softwareKey(): string
{
/* Child classes must override this method */
return "xenfororm";
@@ -106,9 +104,9 @@ class Xenfororm extends Software
/**
* Content we can convert from this software.
*
* @return array
* @return array|null
*/
public static function canConvert()
public static function canConvert(): ?array
{
return array(
'convertCmsDatabases' => array(
@@ -129,32 +127,30 @@ class Xenfororm extends 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 integer
* @throws \IPS\convert\Exception
*/
public function countRows( $table, $where=NULL, $recache=FALSE )
public function countRows( string $table, string|array|null $where=NULL, bool $recache=FALSE ): int
{
switch( $table )
{
case 'cms_databases':
return 1;
break;
default:
return parent::countRows( $table, $where, $recache );
break;
}
}
/**
* Uses Prefix
*
* @return bool
* @return bool
*/
public static function usesPrefix()
public static function usesPrefix(): bool
{
return FALSE;
}
@@ -162,9 +158,9 @@ class Xenfororm extends Software
/**
* Requires Parent
*
* @return boolean
* @return boolean
*/
public static function requiresParent()
public static function requiresParent(): bool
{
return TRUE;
}
@@ -172,9 +168,9 @@ class Xenfororm extends Software
/**
* Possible Parent Conversions
*
* @return array
* @return array|null
*/
public static function parents()
public static function parents(): ?array
{
return array( 'core' => array( 'xenforo' ) );
}
@@ -184,7 +180,7 @@ class Xenfororm extends Software
*
* @return void
*/
public function convertCmsDatabases()
public function convertCmsDatabases() : void
{
$libraryClass = $this->getLibrary();
@@ -235,7 +231,7 @@ class Xenfororm extends Software
*
* @return void
*/
public function convertCmsDatabaseCategories()
public function convertCmsDatabaseCategories() : void
{
$libraryClass = $this->getLibrary();
@@ -254,7 +250,7 @@ class Xenfororm extends Software
$info = array(
'category_id' => $row['resource_category_id'],
'category_database_id' => 1,
'category_name' => isset( $row['category_title'] ) ? $row['category_title'] : $row['title'],
'category_name' => $row['category_title'] ?? $row['title'],
'category_parent_id' => $row['parent_category_id'],
'category_position' => $row['display_order'],
'category_fields' => array( 'resource_title', 'resource_tagline', 'resource_content' ),
@@ -271,7 +267,7 @@ class Xenfororm extends Software
*
* @return void
*/
public function convertCmsDatabaseRecords()
public function convertCmsDatabaseRecords() : void
{
$libraryClass = $this->getLibrary();
@@ -319,9 +315,9 @@ class Xenfororm extends 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
{
try
{