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

@@ -19,7 +19,7 @@ use InvalidArgumentException;
use IPS\Content;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Tools\Xenforo;
use IPS\convert\Tools\Xenforo as XenforoTrait;
use IPS\Db;
use IPS\Http\Url;
use IPS\Member;
@@ -44,22 +44,22 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class Xenforo extends Software
{
use Xenforo;
use XenforoTrait;
/**
* @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 = '';
/**
* @brief XF2.1 changed serialized data to json decoded
*/
public static $useJson = FALSE;
public static bool $useJson = FALSE;
/**
* Constructor
@@ -69,9 +69,9 @@ class Xenforo 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 )
{
@@ -101,16 +101,14 @@ class Xenforo extends Software
}
catch( Exception $e ) {} # If we can't query, we won't be able to do anything anyway
}
return $return;
}
/**
* 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 (1.5.x/2.0.x/2.1.x/2.2.x)";
@@ -119,9 +117,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";
@@ -130,9 +128,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(
'convertDownloadsCfields' => array(
@@ -157,13 +155,13 @@ class Xenforo 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 )
{
@@ -177,21 +175,21 @@ class Xenforo extends Software
{
return $this->db->select( 'COUNT(*)', 'xf_rm_resource_field' )->first();
}
break;
default:
return parent::countRows( $table, $where, $recache );
break;
}
return 0;
}
/**
* Requires Parent
*
* @return boolean
* @return boolean
*/
public static function requiresParent()
public static function requiresParent(): bool
{
return TRUE;
}
@@ -199,9 +197,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' ) );
}
@@ -209,9 +207,9 @@ class Xenforo 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(
'convertDownloadsFiles',
@@ -222,9 +220,9 @@ class Xenforo extends Software
/**
* Finish
*
* @return array Messages to display
* @return array Messages to display
*/
public function finish()
public function finish(): array
{
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\downloads\File', 'count' => 0 ), 4, array( 'class' ) );
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\downloads\Category', 'count' => 0 ), 5, array( 'class' ) );
@@ -237,10 +235,10 @@ class Xenforo 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 )
@@ -276,7 +274,7 @@ class Xenforo extends Software
* @param string $xfTwoTitle XF2 Phrase Title
* @return string|null
*/
protected function getPhrase( $xfOneTitle, $xfTwoTitle )
protected function getPhrase( string $xfOneTitle, string $xfTwoTitle ) : ?string
{
try
{
@@ -294,7 +292,7 @@ class Xenforo extends Software
*
* @return void
*/
public function convertDownloadsCfields()
public function convertDownloadsCfields() : void
{
$libraryClass = $this->getLibrary();
@@ -303,7 +301,7 @@ class Xenforo extends Software
$inputFormat = '';
if( $row['match_type'] == 'regex' AND static::$isLegacy === FALSE )
{
$inputFormat = ( $row['match_type'] == 'regex' ) ? '/' . $row['match_regex'] .'/i' : '';
$inputFormat = '/' . $row['match_regex'] .'/i';
}
elseif( $row['match_type'] == 'regex' )
{
@@ -331,9 +329,9 @@ class Xenforo extends Software
*
* @param string $type Custom field type
* @param string $match Match type
* @return void
* @return string
*/
protected function _mapFieldType( $type, $match )
protected function _mapFieldType( string $type, string $match ) : string
{
switch( $type )
{
@@ -343,39 +341,32 @@ class Xenforo extends Software
{
case 'email':
return 'Email';
break;
case 'url':
return 'Url';
break;
case 'number':
return 'Number';
break;
default:
return 'Text';
break;
}
break;
case 'textarea':
return 'TextArea';
break;
case 'bbcode':
return 'Editor';
break;
case 'multiselect':
case 'select':
return 'Select';
break;
case 'checkbox':
return 'CheckboxSet';
break;
}
return '';
}
/**
@@ -383,7 +374,7 @@ class Xenforo extends Software
*
* @return void
*/
public function convertDownloadsCategories()
public function convertDownloadsCategories() : void
{
$libraryClass = $this->getLibrary();
@@ -413,8 +404,8 @@ class Xenforo extends Software
$info = array(
'cid' => $row['resource_category_id'],
'cparent' => $row['parent_category_id'],
'cname' => isset( $row['category_title'] ) ? $row['category_title'] : $row['title'],
'cdesc' => isset( $row['category_description'] ) ? $row['category_description'] : $row['description'],
'cname' => $row['category_title'] ?? $row['title'],
'cdesc' => $row['category_description'] ?? $row['description'],
'copen' => ( $row['allow_local'] OR $row['allow_external'] ) ? 1 : 0,
'cposition' => $row['display_order'],
'ccfields' => $ccfields,
@@ -452,7 +443,7 @@ class Xenforo extends Software
*
* @return void
*/
public function convertDownloadsFiles()
public function convertDownloadsFiles() : void
{
$libraryClass = $this->getLibrary();
@@ -614,7 +605,7 @@ class Xenforo extends Software
*
* @return void
*/
public function convertDownloadsReviews()
public function convertDownloadsReviews() : void
{
$libraryClass = $this->getLibrary();
@@ -673,9 +664,9 @@ class Xenforo extends 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
{
$url = Request::i()->url();