Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -20,6 +20,16 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
class _Xenfororm extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
* @brief The similarities between XF1 and XF2 are close enough that we can use the same converter
|
||||
*/
|
||||
public static $isLegacy = NULL;
|
||||
|
||||
/**
|
||||
* @brief XF2 Has prefixes on RM tables
|
||||
*/
|
||||
public static $tablePrefix = '';
|
||||
|
||||
/**
|
||||
* Software Name
|
||||
*
|
||||
@@ -28,7 +38,45 @@ class _Xenfororm extends \IPS\convert\Software
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "XenForo Resource Manager Articles";
|
||||
return "XenForo Resource Manager Articles (1.5.x/2.0.x)";
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\convert\App The application to reference for database and other information.
|
||||
* @param bool Establish a DB connection
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
|
||||
{
|
||||
$return = parent::__construct( $app, $needDB );
|
||||
|
||||
if ( $needDB )
|
||||
{
|
||||
try
|
||||
{
|
||||
/* Is this XF1 or XF2 */
|
||||
if ( static::$isLegacy === NULL )
|
||||
{
|
||||
$version = $this->db->select( 'MAX(version_id)', 'xf_template', array( "addon_id=?", 'XF' ) )->first();
|
||||
|
||||
if ( $version < 2000010 )
|
||||
{
|
||||
static::$isLegacy = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
static::$tablePrefix = 'rm_';
|
||||
static::$isLegacy = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) {} # If we can't query, we won't be able to do anything anyway
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,12 +103,12 @@ class _Xenfororm extends \IPS\convert\Software
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertCmsDatabaseCategories' => array(
|
||||
'table' => 'xf_resource_category',
|
||||
'table' => ( static::$isLegacy ? 'xf_resource_category' : 'xf_rm_category' ),
|
||||
'where' => array( "allow_fileless=?", 1 )
|
||||
),
|
||||
'convertCmsDatabaseRecords' => array(
|
||||
'table' => 'xf_resource',
|
||||
'where' => array( "is_fileless=?", 1 )
|
||||
'table' => 'xf_' . static::$tablePrefix . 'resource',
|
||||
'where' => static::$isLegacy ? array( "is_fileless=?", 1 ) : array( 'resource_type=?', 'fileless' )
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -118,24 +166,6 @@ class _Xenfororm extends \IPS\convert\Software
|
||||
return array( 'core' => array( 'xenforo' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to fetch a xenforo phrase
|
||||
*
|
||||
* @param string $title Phrase
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getPhrase( $title )
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->db->select( 'phrase_text', 'xf_phrase', array( "title=?", $title ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert CMS databases
|
||||
*
|
||||
@@ -198,7 +228,7 @@ class _Xenfororm extends \IPS\convert\Software
|
||||
|
||||
$libraryClass::setKey( 'resource_category_id' );
|
||||
|
||||
foreach( $this->fetch( 'xf_resource_category', 'resource_category_id', array( 'allow_fileless=?', 1 ) ) AS $row )
|
||||
foreach( $this->fetch( ( static::$isLegacy ? 'xf_resource_category' : 'xf_rm_category' ), 'resource_category_id', array( 'allow_fileless=?', 1 ) ) AS $row )
|
||||
{
|
||||
$forumoverride = 0;
|
||||
$forumid = 0;
|
||||
@@ -211,7 +241,8 @@ class _Xenfororm extends \IPS\convert\Software
|
||||
$info = array(
|
||||
'category_id' => $row['resource_category_id'],
|
||||
'category_database_id' => 1,
|
||||
'category_name' => $row['category_title'],
|
||||
'category_name' => isset( $row['category_title'] ) ? $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' ),
|
||||
);
|
||||
@@ -233,9 +264,9 @@ class _Xenfororm extends \IPS\convert\Software
|
||||
|
||||
$libraryClass::setKey( 'resource_id' );
|
||||
|
||||
foreach( $this->fetch( 'xf_resource', 'resource_id', array( 'is_fileless=?', 1 ) ) AS $row )
|
||||
foreach( $this->fetch( 'xf_' . static::$tablePrefix . 'resource', 'resource_id', static::$isLegacy ? array( "is_fileless=?", 1 ) : array( 'resource_type=?', 'fileless' ) ) AS $row )
|
||||
{
|
||||
$post = $this->db->select( 'message, post_date', 'xf_resource_update', array( "resource_id=?", $row['resource_id'] ), "post_date DESC" )->first();
|
||||
$post = $this->db->select( 'message, post_date', 'xf_' . static::$tablePrefix . 'resource_update', array( "resource_id=?", $row['resource_id'] ), "post_date DESC" )->first();
|
||||
|
||||
switch( $row['resource_state'] )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user