Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief Converter Joomla Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage Converter
* @since 21 Jan 2015
*/
@@ -2,9 +2,9 @@
/**
* @brief Converter vBulletin 4.x Pages Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage Converter
* @since 21 Jan 2015
*/
@@ -20,6 +20,16 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
class _Vbulletin extends \IPS\convert\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;
/**
* @brief Cached article content type
*/
protected static $_articleContentType = NULL;
/**
* Software Name
*
@@ -41,6 +51,52 @@ class _Vbulletin extends \IPS\convert\Software
/* Child classes must override this method */
return "vbulletin";
}
/**
* Constructor
*
* @param \IPS\convert\App $app The application to reference for database and other information.
* @param bool $needDB Establish a DB connection
* @return void
* @throws \InvalidArgumentException
*/
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
{
$return = parent::__construct( $app, $needDB );
/* Is this vB3 or vB4? */
try
{
if ( static::$isLegacy === NULL AND $needDB )
{
$version = $this->db->select('value', 'setting', array("varname=?", 'templateversion'))->first();
if (mb_substr($version, 0, 1) == '3') {
static::$isLegacy = TRUE;
} else {
static::$isLegacy = FALSE;
}
}
/* If this is vB4, what is the content type ID for the cms? */
if ( static::$_articleContentType === NULL AND ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) AND $needDB )
{
try
{
static::$_articleContentType = $this->db->select( 'contenttypeid', 'contenttype', array( "class=?", 'Article' ) )->first();
}
catch( \UnderflowException $e )
{
static::$_articleContentType = 24; # default
}
}
}
catch( \Exception $e ) {}
return $return;
}
/**
* Content we can convert from this software.
@@ -70,6 +126,10 @@ class _Vbulletin extends \IPS\convert\Software
'table' => 'cms_article',
'where' => NULL,
),
'convertAttachments' => array(
'table' => 'attachment',
'where' => array( "contenttypeid=?", static::$_articleContentType )
)
);
return $return;
@@ -101,7 +161,6 @@ class _Vbulletin extends \IPS\convert\Software
case 'database':
return 1;
break;
default:
return parent::countRows( $table, $where, $recache );
break;
@@ -355,7 +414,7 @@ class _Vbulletin extends \IPS\convert\Software
{
try
{
$node = $this->db->select( '*', 'cms_node', array( "contenttypeid=? AND contentid=?", $this->_articleContentType(), $row['contentid'] ) )->first();
$node = $this->db->select( '*', 'cms_node', array( "contenttypeid=? AND contentid=?", static::$_articleContentType, $row['contentid'] ) )->first();
$nodeinfo = $this->db->select( '*', 'cms_nodeinfo', array( "nodeid=?", $node['nodeid'] ) )->first();
}
catch( \UnderflowException $e )
@@ -436,38 +495,160 @@ class _Vbulletin extends \IPS\convert\Software
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\cms\Categories' . $database, 'count' => 0 ), 5, array( 'class' ) );
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\cms\Records'. $database ), 3, array( 'class' ) );
// This converter doesn't support tags at this time, uncomment when it does.
//\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'cms_custom_database_' . $database, 'class' => 'IPS\cms\Records' . $database ), 3, array( 'app', 'link', 'class' ) );
// Uncomment this once Tags are implemented for the cms;
# \IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'cms_custom_database_' . $database, 'class' => 'IPS\cms\Records' . $database ), 3, array( 'app', 'link', 'class' ) );
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'cms_custom_database_' . $database, 'class' => 'IPS\cms\Records' . $database ), 2, array( 'app', 'link', 'class' ) );
}
return array( "f_recount_cms_categories", "f_rebuild_cms_tags" );
}
/**
* @brief Cached article content type
*/
protected $_articleContentType = NULL;
/**
* Return the article content type
* Convert attachments
*
* @return void
*/
protected function _articleContentType()
public function convertAttachments()
{
if ( $this->_articleContentType === NULL )
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'attachmentid' );
$where = NULL;
$column = NULL;
if ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) )
{
$where = array( "contenttypeid=?", static::$_articleContentType );
$column = 'contentid';
$table = 'attachment';
}
foreach( $this->fetch( $table, 'attachmentid', $where ) as $attachment )
{
try
{
$this->_articleContentType = $this->db->select( 'contenttypeid', 'contenttype', array( "class=?", 'Article' ) )->first();
{
$vbRecordId = $this->db->select( 'contentid', 'cms_article', array( "contentid=?", $attachment[ $column ] ) )->first();
}
catch( \UnderflowException $e )
{
$this->_articleContentType = 24; # default
/* Log this so that it's easier to diagnose */
$this->app->log( 'attachment_vbcms_missing_parent', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['attachmentid'] );
/* If the record is missing, there isn't much we can do. */
$libraryClass->setLastKeyValue( $attachment['attachmentid'] );
continue;
}
if ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) )
{
$filedata = $this->db->select( '*', 'filedata', array( "filedataid=?", $attachment['filedataid'] ) )->first();
}
else
{
$filedata = $attachment;
$filedata['filedataid'] = $attachment['attachmentid'];
}
$map = array(
'id1' => $vbRecordId,
'id2' => NULL,
'id3' => 1
);
$info = array(
'attach_id' => $attachment['attachmentid'],
'attach_file' => $attachment['filename'],
'attach_date' => $attachment['dateline'],
'attach_member_id' => $attachment['userid'],
'attach_hits' => $attachment['counter'],
'attach_ext' => $filedata['extension'],
'attach_filesize' => $filedata['filesize'],
);
if ( $this->app->_session['more_info']['convertAttachments']['file_location'] == 'database' )
{
/* Simples! */
$data = $filedata['filedata'];
$path = NULL;
}
else
{
$data = NULL;
$path = implode( '/', preg_split( '//', $filedata['userid'], -1, PREG_SPLIT_NO_EMPTY ) );
$path = rtrim( $this->app->_session['more_info']['convertAttachments']['file_location'], '/' ) . '/' . $path . '/' . $attachment['filedataid'] . '.attach';
}
$attach_id = $libraryClass->convertAttachment( $info, $map, $path, $data );
/* Do some re-jiggery on the post itself to make sure attachment displays */
/* The database is hardcoded to 1 while the conversion, so we have to use 1 here */
$dbId = $this->app->getLink( 1, 'cms_databases' );
$dbName = "cms_custom_database_" . $dbId;
try
{
$recordId = $this->app->getLink( $attachment[ $column ], 'cms_custom_database_' . $dbId );
/* Get the database object */
$ipsDb = \IPS\cms\Databases::load( $dbId);
$post = \IPS\Db::i()->select( $ipsDb->field_content, $dbName, array( "primary_id_field=?", $recordId ) )->first();
if ( preg_match( "/\[ATTACH(.+?)?\]" . $attachment['attachmentid'] . "\[\/ATTACH\]/i", $post ) )
{
$post = preg_replace( "/\[ATTACH=(.+?)?\]" . $attachment['attachmentid'] . "\[\/ATTACH\]/i", '[attachment=' . $attach_id . ':name]', $post );
\IPS\Db::i()->update( $dbName, array( 'field_2' => $post ), array( "primary_id_field=?", $recordId ) );
}
}
catch( \OutOfRangeException $e ) { }
$libraryClass->setLastKeyValue( $attachment['attachmentid'] );
}
return $this->_articleContentType;
}
/**
* List of conversion methods that require additional information
*
* @return array
*/
public static function checkConf()
{
return array( 'convertAttachments' );
}
/**
* Get More Information
*
* @param string $method Conversion method
* @return array
*/
public function getMoreInfo( $method )
{
$return = array();
switch( $method )
{
case 'convertAttachments':
$return['convertAttachments'] = array(
'file_location' => array(
'field_class' => 'IPS\\Helpers\\Form\\Radio',
'field_default' => 'database',
'field_required' => TRUE,
'field_extra' => array(
'options' => array(
'database' => \IPS\Member::loggedIn()->language()->addToStack( 'database' ),
'file_system' => \IPS\Member::loggedIn()->language()->addToStack( 'file_system' ),
),
'userSuppliedInput' => 'file_system',
),
'field_hint' => NULL,
'field_validation' => function( $value ) { if ( $value != 'database' AND !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
)
);
break;
}
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
}
}
@@ -2,9 +2,9 @@
/**
* @brief Converter Wordpress Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage Converter
* @since 21 Jan 2015
*/
@@ -2,9 +2,9 @@
/**
* @brief Converter XenForo Page Nodes Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage Converter
* @since 21 Jan 2015
*/
@@ -2,9 +2,9 @@
/**
* @brief Converter XenForoRm Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage Converter
* @since 21 Jan 2015
*/
Whitespace-only changes.