Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -12,16 +12,23 @@
namespace IPS\convert\Software\Cms;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\convert\Software;
use IPS\convert\Software\Exception;
use IPS\Task;
use OutOfRangeException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Joomla Pages Converter
*/
class _Joomla extends \IPS\convert\Software
class Joomla extends Software
{
/**
* Software Name
@@ -131,12 +138,12 @@ class _Joomla extends \IPS\convert\Software
try
{
$database = $this->app->getLink( 1, 'cms_databases' );
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\cms\Categories' . $database, 'count' => 0 ), 5, array( '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' ) );
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\cms\Categories' . $database, 'count' => 0 ), 5, array( 'class' ) );
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" );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
return array();
}
@@ -183,7 +190,7 @@ class _Joomla extends \IPS\convert\Software
) );
/* Throw an exception here to tell the library that we're done with this step */
throw new \IPS\convert\Software\Exception;
throw new Exception;
}
/**
@@ -12,16 +12,33 @@
namespace IPS\convert\Software\Cms;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use InvalidArgumentException;
use IPS\cms\Databases;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Core\Vbulletin as VbulletinClass;
use IPS\convert\Software\Exception;
use IPS\Db;
use IPS\Member;
use IPS\Task;
use OutOfRangeException;
use UnderflowException;
use function count;
use function defined;
use function is_null;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* vBulletin Pages Converter
*/
class _Vbulletin extends \IPS\convert\Software
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.
@@ -58,12 +75,12 @@ class _Vbulletin extends \IPS\convert\Software
/**
* Constructor
*
* @param \IPS\convert\App $app The application to reference for database and other information.
* @param App $app The application to reference for database and other information.
* @param bool $needDB Establish a DB connection
* @return void
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
public function __construct( App $app, $needDB=TRUE )
{
$return = parent::__construct( $app, $needDB );
@@ -82,13 +99,13 @@ class _Vbulletin extends \IPS\convert\Software
}
/* 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 )
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 )
catch( UnderflowException $e )
{
static::$_articleContentType = 24; # default
}
@@ -155,7 +172,7 @@ class _Vbulletin extends \IPS\convert\Software
try
{
$blocksWeCanConvert = array();
foreach( $this->db->select( 'widgettypeid', 'cms_widgettype', array( \IPS\Db::i()->in( 'class', array( 'Rss', 'Static' ) ) ) ) AS $typeid )
foreach( $this->db->select( 'widgettypeid', 'cms_widgettype', array( Db::i()->in( 'class', array( 'Rss', 'Static' ) ) ) ) AS $typeid )
{
$blocksWeCanConvert[] = $typeid;
}
@@ -163,7 +180,7 @@ class _Vbulletin extends \IPS\convert\Software
}
catch( \Exception $e )
{
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
throw new \IPS\convert\Exception( sprintf( Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
}
break;
@@ -198,14 +215,16 @@ class _Vbulletin extends \IPS\convert\Software
}
/**
* Fix Post Data
* Pre-process content for the Invision Community text parser
*
* @param string $post Post
* @return string Fixed Posts
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @return string The converted post
*/
public static function fixPostData( $post )
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
{
return \IPS\convert\Software\Core\Vbulletin::fixPostData( $post );
return VbulletinClass::fixPostData( $post, $className, $contentId );
}
/**
@@ -234,7 +253,7 @@ class _Vbulletin extends \IPS\convert\Software
$this->settingsCache[$key] = $setting['defaultvalue'];
}
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
/* If we failed to find it, we probably will fail again on later attempts */
$this->settingsCache[$key] = NULL;
@@ -257,7 +276,7 @@ class _Vbulletin extends \IPS\convert\Software
/* We CAN bring over some blocks, like static widgets */
$blocksWeCanConvert = array();
$rssTypeId = NULL;
foreach( $this->db->select( 'widgettypeid, class', 'cms_widgettype', array( \IPS\Db::i()->in( 'class', array( 'Rss', 'Static' ) ) ) ) AS $type )
foreach( $this->db->select( 'widgettypeid, class', 'cms_widgettype', array( Db::i()->in( 'class', array( 'Rss', 'Static' ) ) ) ) AS $type )
{
if ( $type['class'] == 'Rss' )
{
@@ -266,7 +285,7 @@ class _Vbulletin extends \IPS\convert\Software
$blocksWeCanConvert[] = $type['widgettypeid'];
}
foreach( $this->fetch( 'cms_widget', 'widgetid', array( \IPS\Db::i()->in( 'widgettypeid', $blocksWeCanConvert ) ) ) AS $block )
foreach( $this->fetch( 'cms_widget', 'widgetid', array( Db::i()->in( 'widgettypeid', $blocksWeCanConvert ) ) ) AS $block )
{
$config = array();
@@ -314,7 +333,7 @@ class _Vbulletin extends \IPS\convert\Software
'page_name' => 'vBulletin Articles',
) );
throw new \IPS\convert\Software\Exception;
throw new Exception;
}
/**
@@ -331,7 +350,7 @@ class _Vbulletin extends \IPS\convert\Software
$convertedForums = TRUE;
}
catch( \OutOfRangeException $e ) {}
catch( OutOfRangeException $e ) {}
$this->getLibrary()->convertCmsDatabase( array(
'database_id' => 1,
'database_name' => 'vBulletin Articles',
@@ -375,7 +394,7 @@ class _Vbulletin extends \IPS\convert\Software
)
) );
throw new \IPS\convert\Software\Exception;
throw new Exception;
}
/**
@@ -423,7 +442,7 @@ class _Vbulletin extends \IPS\convert\Software
$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 )
catch( UnderflowException $e )
{
$libraryClass->setLastKeyValue( $row['contentid'] );
continue;
@@ -432,7 +451,7 @@ class _Vbulletin extends \IPS\convert\Software
$categories = iterator_to_array( $this->db->select( 'categoryid', 'cms_nodecategory', array( "nodeid=?", $node['nodeid'] ) ) );
if( !\count( $categories ) )
if( !count( $categories ) )
{
/* Create one */
try
@@ -440,7 +459,7 @@ class _Vbulletin extends \IPS\convert\Software
$this->app->getLink( '__orphan__', 'cms_database_categories' );
$categories = array( '__orphan__' );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
$libraryClass->convertCmsDatabaseCategory( array(
'category_id' => '__orphan__',
@@ -491,7 +510,7 @@ class _Vbulletin extends \IPS\convert\Software
{
$database = $this->app->getLink( 1, 'cms_databases' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
/* Cannot find it, we can't convert tags */
$libraryClass->setLastKeyValue( $row['contentid'] );
@@ -499,7 +518,7 @@ class _Vbulletin extends \IPS\convert\Software
/* Convert extra unassigned categories as tags */
$convertedTags = array();
if( \count( $categories ) )
if( count( $categories ) )
{
foreach( $categories as $key )
{
@@ -569,17 +588,17 @@ class _Vbulletin extends \IPS\convert\Software
*/
public function finish()
{
foreach( \IPS\Db::i()->select( 'ipb_id', 'convert_link', array( 'type=? AND app=?', 'cms_databases', $this->app->app_id ) ) as $database )
foreach( Db::i()->select( 'ipb_id', 'convert_link', array( 'type=? AND app=?', 'cms_databases', $this->app->app_id ) ) as $database )
{
\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' ) );
\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' ) );
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\cms\Categories' . $database, 'count' => 0 ), 5, array( 'class' ) );
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\cms\Records'. $database ), 3, array( 'class' ) );
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' ) );
try
{
\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' ) );
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' ) );
}
catch ( \OutOfRangeException $e ) {}
catch ( OutOfRangeException $e ) {}
}
return array( "f_recount_cms_categories", "f_rebuild_cms_tags" );
@@ -599,7 +618,7 @@ class _Vbulletin extends \IPS\convert\Software
$where = NULL;
$column = NULL;
if ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) )
if ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) )
{
$where = array( "contenttypeid=?", static::$_articleContentType );
$column = 'contentid';
@@ -612,17 +631,17 @@ class _Vbulletin extends \IPS\convert\Software
{
$vbRecordId = $this->db->select( 'contentid', 'cms_node', array( "nodeid=? AND contenttypeid=?", $attachment[ $column ], static::$_articleContentType ) )->first();
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
/* Log this so that it's easier to diagnose */
$this->app->log( 'attachment_vbcms_missing_parent', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['attachmentid'] );
$this->app->log( 'attachment_vbcms_missing_parent', __METHOD__, 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 ) )
if ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) )
{
$filedata = $this->db->select( '*', 'filedata', array( "filedataid=?", $attachment['filedataid'] ) )->first();
}
@@ -661,7 +680,7 @@ class _Vbulletin extends \IPS\convert\Software
$dbName = "cms_custom_database_" . $dbId;
/* Get the database object */
$ipsDb = \IPS\cms\Databases::load( $dbId );
$ipsDb = Databases::load( $dbId );
$map = array(
'id1' => $vbRecordId,
@@ -676,15 +695,15 @@ class _Vbulletin extends \IPS\convert\Software
{
$recordId = $this->app->getLink( $vbRecordId, 'cms_custom_database_' . $dbId );
$post = \IPS\Db::i()->select( 'field_' . $ipsDb->field_content, $dbName, array( "primary_id_field=?", $recordId ) )->first();
$post = Db::i()->select( 'field_' . $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_' . $ipsDb->field_content => $post ), array( "primary_id_field=?", $recordId ) );
Db::i()->update( $dbName, array( 'field_' . $ipsDb->field_content => $post ), array( "primary_id_field=?", $recordId ) );
}
}
catch( \OutOfRangeException $e ) { }
catch( OutOfRangeException $e ) { }
$libraryClass->setLastKeyValue( $attachment['attachmentid'] );
}
@@ -719,13 +738,13 @@ class _Vbulletin extends \IPS\convert\Software
'field_required' => TRUE,
'field_extra' => array(
'options' => array(
'database' => \IPS\Member::loggedIn()->language()->addToStack( 'conv_store_database' ),
'file_system' => \IPS\Member::loggedIn()->language()->addToStack( 'conv_store_file_system' ),
'database' => Member::loggedIn()->language()->addToStack( 'conv_store_database' ),
'file_system' => Member::loggedIn()->language()->addToStack( 'conv_store_file_system' ),
),
'userSuppliedInput' => 'file_system',
),
'field_hint' => NULL,
'field_validation' => function( $value ) { if ( $value != 'database' AND !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
'field_validation' => function( $value ) { if ( $value != 'database' AND !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
)
);
break;
@@ -12,16 +12,27 @@
namespace IPS\convert\Software\Cms;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use IPS\convert\Software;
use IPS\convert\Software\Exception;
use IPS\DateTime;
use IPS\Member;
use IPS\Task;
use OutOfRangeException;
use UnderflowException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Wordpress Pages Converter
*/
class _Wordpress extends \IPS\convert\Software
class Wordpress extends Software
{
/**
* Software Name
@@ -154,8 +165,8 @@ class _Wordpress extends \IPS\convert\Software
'field_required' => TRUE,
'field_default' => NULL,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack( 'convert_wp_typical_path' ),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
'field_hint' => Member::loggedIn()->language()->addToStack( 'convert_wp_typical_path' ),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
);
break;
@@ -165,8 +176,8 @@ class _Wordpress extends \IPS\convert\Software
'field_required' => TRUE,
'field_default' => NULL,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack( 'convert_wp_typical_path' ),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
'field_hint' => Member::loggedIn()->language()->addToStack( 'convert_wp_typical_path' ),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
);
break;
}
@@ -184,16 +195,16 @@ class _Wordpress extends \IPS\convert\Software
try
{
$database = $this->app->getLink( 1, 'cms_databases' );
\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' ) );
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\cms\Categories' . $database, 'count' => 0 ), 5, array( 'class' ) );
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\cms\Records' . $database ), 3, array( 'class' ) );
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'cms_records', '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' ) );
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'cms_database_comments', 'class' => 'IPS\cms\Records\Comment' . $database ), 2, array( 'app', 'link', 'class' ) );
Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'cms_records', 'class' => 'IPS\cms\Records' . $database ), 3, array( 'app', 'link', 'class' ) );
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' ) );
Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'cms_database_comments', 'class' => 'IPS\cms\Records\Comment' . $database ), 2, array( 'app', 'link', 'class' ) );
return array( "f_recount_cms_categories", "f_rebuild_cms_tags" );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
return array();
}
@@ -264,7 +275,7 @@ class _Wordpress extends \IPS\convert\Software
) );
/* Throw an exception here to tell the library that we're done with this step */
throw new \IPS\convert\Software\Exception;
throw new Exception;
}
/**
@@ -353,7 +364,7 @@ class _Wordpress extends \IPS\convert\Software
$imagePath = rtrim( $this->app->_session['more_info']['convertCmsDatabaseRecords']['file_location'], '/' ) . '/' . $location;
$filename = basename( $imagePath );
}
catch( \UnderflowException $e ) {}
catch( UnderflowException $e ) {}
}
$info = array(
@@ -363,13 +374,13 @@ class _Wordpress extends \IPS\convert\Software
'record_locked' => ( $row['comment_status'] == 'closed' ) ? 1 : 0,
'record_comments' => $row['comment_count'],
'record_allow_comments' => 1,
'record_saved' => new \IPS\DateTime( $row['post_date'] ),
'record_updated' => $row['post_modified'] !== '0000-00-00 00:00:00' ? new \IPS\DateTime( $row['post_modified'] ) : NULL, # Older WordPress installs may be missing a modified date
'record_saved' => new DateTime( $row['post_date'] ),
'record_updated' => $row['post_modified'] !== '0000-00-00 00:00:00' ? new DateTime( $row['post_modified'] ) : NULL, # Older WordPress installs may be missing a modified date
'category_id' => $category,
'record_approved' => $approved,
'record_dynamic_furl' => $row['post_name'],
'record_static_furl' => $row['post_name'],
'record_publish_date' => new \IPS\DateTime( $row['post_date'] ),
'record_publish_date' => new DateTime( $row['post_date'] ),
'record_image' => $filename,
);
@@ -408,7 +419,7 @@ class _Wordpress extends \IPS\convert\Software
'tag_meta_id' => $row['ID'],
'tag_text' => $tag,
'tag_member_id' => $row['post_author'],
'tag_added' => new \IPS\DateTime( $row['post_date'] ),
'tag_added' => new DateTime( $row['post_date'] ),
'tag_prefix' => 0,
'tag_meta_link' => 'cms_custom_database_' . $database,
'tag_meta_parent_link' => 'cms_database_categories',
@@ -452,7 +463,7 @@ class _Wordpress extends \IPS\convert\Software
'comment_id' => $row['comment_ID'],
'comment_database_id' => 1,
'comment_record_id' => $row['comment_post_ID'],
'comment_date' => new \IPS\DateTime( $row['comment_date'] ),
'comment_date' => new DateTime( $row['comment_date'] ),
'comment_ip_address' => $row['comment_author_IP'],
'comment_user' => $row['user_id'],
'comment_author' => $row['comment_author'],
@@ -522,7 +533,7 @@ class _Wordpress extends \IPS\convert\Software
$info = array(
'attach_id' => $row['ID'],
'attach_file' => basename( $meta['_wp_attached_file'] ),
'attach_date' => new \IPS\DateTime( $row['post_date'] ),
'attach_date' => new DateTime( $row['post_date'] ),
'attach_member_id' => $row['post_author']
);
@@ -12,16 +12,21 @@
namespace IPS\convert\Software\Cms;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\convert\Software;
use UnderflowException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Xenforo Pages Converter
*/
class _Xenforo extends \IPS\convert\Software
class Xenforo extends Software
{
/**
* Software Name
@@ -107,7 +112,7 @@ class _Xenforo extends \IPS\convert\Software
{
$template = $this->db->select( 'template', 'xf_template', array( "title=?", "_page_node.{$row['node_id']}" ) )->first();
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
$template = '';
}
@@ -12,16 +12,26 @@
namespace IPS\convert\Software\Cms;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use InvalidArgumentException;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Exception;
use IPS\Db;
use IPS\Task;
use OutOfRangeException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Xenforo (resource manager) Pages Converter
*/
class _Xenfororm extends \IPS\convert\Software
class Xenfororm extends Software
{
/**
* @brief The similarities between XF1 and XF2 are close enough that we can use the same converter
@@ -47,12 +57,12 @@ class _Xenfororm extends \IPS\convert\Software
/**
* Constructor
*
* @param \IPS\convert\App $app The application to reference for database and other information.
* @param App $app The application to reference for database and other information.
* @param bool $needDB Establish a DB connection
* @return void
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
public function __construct( App $app, $needDB=TRUE )
{
$return = parent::__construct( $app, $needDB );
@@ -63,7 +73,7 @@ class _Xenfororm extends \IPS\convert\Software
/* Is this XF1 or XF2 */
if ( static::$isLegacy === NULL )
{
$version = $this->db->select( 'MAX(version_id)', 'xf_template', array( \IPS\Db::i()->in( 'addon_id', array( 'XF', 'XenForo' ) ) ) )->first();
$version = $this->db->select( 'MAX(version_id)', 'xf_template', array( Db::i()->in( 'addon_id', array( 'XF', 'XenForo' ) ) ) )->first();
if ( $version < 2000010 )
{
@@ -217,7 +227,7 @@ class _Xenfororm extends \IPS\convert\Software
) );
/* Throw an exception here to tell the library that we're done with this step */
throw new \IPS\convert\Software\Exception;
throw new Exception;
}
/**
@@ -316,12 +326,12 @@ class _Xenfororm extends \IPS\convert\Software
try
{
$database = $this->app->getLink( 1, 'cms_databases' );
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\cms\Categories' . $database, 'count' => 0 ), 5, array( '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' ) );
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\cms\Categories' . $database, 'count' => 0 ), 5, array( 'class' ) );
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" );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
return array();
}