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

@@ -12,38 +12,51 @@
namespace IPS\convert\Software\Blog;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use InvalidArgumentException;
use IPS\Application;
use IPS\convert\App;
use IPS\convert\Library;
use IPS\convert\Software;
use IPS\Db;
use IPS\Db\Exception as DbException;
use IPS\Member;
use IPS\Task;
use UnderflowException;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class Invisioncommunity extends \IPS\convert\Software
class Invisioncommunity extends Software
{
/**
* @brief Whether the versions of IPS4 match
*/
public static $versionMatch = FALSE;
public static bool $versionMatch = FALSE;
/**
* @brief Whether the database has been required
*/
public static $dbNeeded = FALSE;
public static bool $dbNeeded = FALSE;
/**
* 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, bool $needDB=TRUE )
{
/* Set filename obscuring flag */
\IPS\convert\Library::$obscureFilenames = FALSE;
Library::$obscureFilenames = FALSE;
$return = parent::__construct( $app, $needDB );
parent::__construct( $app, $needDB );
if( $needDB )
{
@@ -54,37 +67,35 @@ class Invisioncommunity extends \IPS\convert\Software
$version = $this->db->select( 'app_version', 'core_applications', array( 'app_directory=?', 'core' ) )->first();
/* We're matching against the human version since the long version can change with patches */
if ( $version == \IPS\Application::load( 'core' )->version )
if ( $version == Application::load( 'core' )->version )
{
static::$versionMatch = TRUE;
}
}
catch( \IPS\Db\Exception $e ) {}
catch( DbException $e ) {}
/* Get parent sauce */
$this->parent = $this->app->_parent->getSource();
}
return $return;
}
/**
* Software Name
*
* @return string
* @return string
*/
public static function softwareName()
public static function softwareName(): string
{
/* Child classes must override this method */
return 'Invision Community (' . \IPS\Application::load( 'core' )->version . ')';
return 'Invision Community (' . Application::load( 'core' )->version . ')';
}
/**
* Software Key
*
* @return string
* @return string
*/
public static function softwareKey()
public static function softwareKey(): string
{
/* Child classes must override this method */
return "invisioncommunity";
@@ -93,9 +104,9 @@ class Invisioncommunity extends \IPS\convert\Software
/**
* Requires Parent
*
* @return boolean
* @return boolean
*/
public static function requiresParent()
public static function requiresParent(): bool
{
return TRUE;
}
@@ -103,9 +114,9 @@ class Invisioncommunity extends \IPS\convert\Software
/**
* Possible Parent Conversions
*
* @return array
* @return array|null
*/
public static function parents()
public static function parents(): ?array
{
return array( 'core' => array( 'invisioncommunity' ) );
}
@@ -113,10 +124,10 @@ class Invisioncommunity extends \IPS\convert\Software
/**
* Content we can convert from this software.
*
* @return array|NULL
* @return array|NULL
* @note NULL indicates this converter cannot be used yet, useful to move redirect scripts into the 4.x framework
*/
public static function canConvert()
public static function canConvert(): ?array
{
return array(
'convertBlogCategories' => array(
@@ -141,7 +152,7 @@ class Invisioncommunity extends \IPS\convert\Software
),
'convertAttachments' => array(
'table' => 'core_attachments_map',
'where' => array( \IPS\Db::i()->in( 'location_key', array( 'blog_Blogs', 'blog_Entries' ) ) )
'where' => array( Db::i()->in( 'location_key', array( 'blog_Blogs', 'blog_Entries' ) ) )
)
);
}
@@ -149,9 +160,9 @@ class Invisioncommunity extends \IPS\convert\Software
/**
* Can we convert passwords from this software.
*
* @return boolean
* @return boolean
*/
public static function loginEnabled()
public static function loginEnabled(): bool
{
return FALSE;
}
@@ -159,9 +170,9 @@ class Invisioncommunity extends \IPS\convert\Software
/**
* Can we convert settings?
*
* @return boolean
* @return boolean
*/
public static function canConvertSettings()
public static function canConvertSettings(): bool
{
return FALSE;
}
@@ -169,9 +180,9 @@ class Invisioncommunity extends \IPS\convert\Software
/**
* Settings Map
*
* @return array
* @return array
*/
public function settingsMap()
public function settingsMap(): array
{
return array();
}
@@ -179,9 +190,9 @@ class Invisioncommunity extends \IPS\convert\Software
/**
* Settings Map Listing
*
* @return array
* @return array
*/
public function settingsMapList()
public function settingsMapList(): array
{
return array();
}
@@ -189,9 +200,9 @@ class Invisioncommunity extends \IPS\convert\Software
/**
* Returns a block of text, or a language string, that explains what the admin must do to start this conversion
*
* @return string|NULL
* @return string|NULL
*/
public static function getPreConversionInformation()
public static function getPreConversionInformation(): ?string
{
return NULL;
}
@@ -199,9 +210,9 @@ class Invisioncommunity extends \IPS\convert\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'
@@ -211,26 +222,26 @@ class Invisioncommunity extends \IPS\convert\Software
/**
* Get More Information
*
* @param string $method Method name
* @return array
* @param string $method Method name
* @return array|null
*/
public function getMoreInfo( $method )
public function getMoreInfo( string $method ): ?array
{
$return = array();
switch( $method )
{
case 'convertAttachments':
\IPS\Member::loggedIn()->language()->words["upload_path"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input' );
\IPS\Member::loggedIn()->language()->words["upload_path_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input_desc' );
Member::loggedIn()->language()->words["upload_path"] = Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input' );
Member::loggedIn()->language()->words["upload_path_desc"] = Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input_desc' );
$return[ $method ] = array(
'upload_path' => array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => isset( $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] ) ? $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] : NULL,
'field_default' => $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] ?? NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_invision_upload_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
'field_hint' => Member::loggedIn()->language()->addToStack('convert_invision_upload_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
)
);
break;
@@ -242,36 +253,25 @@ class Invisioncommunity extends \IPS\convert\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
{
/* Content Rebuilds */
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\blog\Entry\Category', 'count' => 0 ), 4, array( 'class' ) );
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'link' => 'blog_entries', 'class' => 'IPS\blog\Entry' ), 2, array( 'app', 'link', 'class' ) );
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'link' => 'blog_comments', 'class' => 'IPS\blog\Entry\Comment' ), 2, array( 'app', 'link', 'class' ) );
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'blog_entries', 'class' => 'IPS\blog\Entry' ), 3, array( 'app', 'link', 'class' ) );
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\blog\Entry\Category', 'count' => 0 ), 4, array( 'class' ) );
Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'link' => 'blog_entries', 'class' => 'IPS\blog\Entry' ), 2, array( 'app', 'link', 'class' ) );
Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'link' => 'blog_comments', 'class' => 'IPS\blog\Entry\Comment' ), 2, array( 'app', 'link', 'class' ) );
Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'blog_entries', 'class' => 'IPS\blog\Entry' ), 3, array( 'app', 'link', 'class' ) );
return array( "f_blog_entries_rebuilding", "f_entry_comments_rebuilding", "f_blogs_recounting", "f_entry_tags_cache" );
}
/**
* Fix post data
*
* @param string raw post data
* @return string parsed post data
*/
public static function fixPostData( $post )
{
return $post;
}
/**
* Convert Blog Categories
*
* @return void
*/
public function convertBlogCategories()
public function convertBlogCategories() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'category_id' );
@@ -291,7 +291,7 @@ class Invisioncommunity extends \IPS\convert\Software
*
* @return void
*/
public function convertBlogs()
public function convertBlogs() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'blog_id' );
@@ -306,7 +306,7 @@ class Invisioncommunity extends \IPS\convert\Software
{
$socialgroup = iterator_to_array( $this->db->select( 'member_id', 'core_sys_social_group_members', array( "group_id=?", $row['blog_social_group'] ) ) );
}
catch( \UnderflowException ) { }
catch( UnderflowException ) { }
}
$cover = NULL;
@@ -333,7 +333,7 @@ class Invisioncommunity extends \IPS\convert\Software
*
* @return void
*/
public function convertBlogEntryCategories()
public function convertBlogEntryCategories() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'entry_category_id' );
@@ -350,7 +350,7 @@ class Invisioncommunity extends \IPS\convert\Software
*
* @return void
*/
public function convertBlogEntries()
public function convertBlogEntries() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'entry_id' );
@@ -387,7 +387,7 @@ class Invisioncommunity extends \IPS\convert\Software
$libraryClass->convertReputation( $rep );
}
$libraryClass->setLasyKeyValue( $row['entry_id'] );
$libraryClass->setLastKeyValue( $row['entry_id'] );
}
}
@@ -396,7 +396,7 @@ class Invisioncommunity extends \IPS\convert\Software
*
* @return void
*/
public function convertBlogComments()
public function convertBlogComments() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'comment_id' );
@@ -422,7 +422,7 @@ class Invisioncommunity extends \IPS\convert\Software
*
* @return void
*/
public function convertAttachments()
public function convertAttachments() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'attach_id' );
@@ -431,9 +431,9 @@ class Invisioncommunity extends \IPS\convert\Software
{
try
{
$attachmentMap = $this->db->select( '*', 'core_attachments_map', array( 'attachment_id=? AND ' . \IPS\Db::i()->in( 'location_key', array( 'blog_Blogs', 'blog_Entries' ) ), $row['attach_id'] ) )->first();
$attachmentMap = $this->db->select( '*', 'core_attachments_map', array( 'attachment_id=? AND ' . Db::i()->in( 'location_key', array( 'blog_Blogs', 'blog_Entries' ) ), $row['attach_id'] ) )->first();
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
$libraryClass->setLastKeyValue( $row['attach_id'] );
continue;
@@ -45,12 +45,12 @@ class Vbulletin extends Software
/**
* @brief vBulletin 4 Stores all attachments under one table - this will store the content type for the blog app.
*/
protected static $entryContentType = NULL;
protected static mixed $entryContentType = NULL;
/**
* @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;
/**
* Constructor
@@ -60,9 +60,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
@@ -89,16 +89,14 @@ class Vbulletin extends Software
}
}
catch( Exception $e ) {}
return $return;
}
/**
* Software Name
*
* @return string
* @return string
*/
public static function softwareName()
public static function softwareName(): string
{
/* Child classes must override this method */
return "vBulletin Blog (3.8.x/4.x)";
@@ -107,9 +105,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";
@@ -118,9 +116,9 @@ class Vbulletin extends Software
/**
* Content we can convert from this software.
*
* @return array
* @return array|null
*/
public static function canConvert()
public static function canConvert(): ?array
{
$attachmentTable = 'blog_attachment';
$attachmentWhere = NULL;
@@ -157,32 +155,30 @@ class Vbulletin 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 )
{
default:
return parent::countRows( $table, $where );
break;
case 'blog_text':
return $this->db->select( 'COUNT(*)', 'blog_text', array( 'blogtextid NOT IN (' . (string) $this->db->select( 'firstblogtextid', 'blog' ) . ')' ) )->first();
break;
return $this->db->select( 'COUNT(*)', 'blog_text', array( 'blogtextid NOT IN (' . $this->db->select( 'firstblogtextid', 'blog' ) . ')' ) )->first();
}
}
/**
* Requires Parent
*
* @return boolean
* @return boolean
*/
public static function requiresParent()
public static function requiresParent(): bool
{
return TRUE;
}
@@ -190,9 +186,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' ) );
}
@@ -200,9 +196,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
{
/* Content Rebuilds */
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\blog\Entry\Category', 'count' => 0 ), 4, array( 'class' ) );
@@ -216,22 +212,22 @@ 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 The 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
{
return CalendarClass::fixPostData( $post, $className, $contentId );
return VbulletinClass::fixPostData( $post, $className, $contentId );
}
/**
* List of conversion methods that require additional information
*
* @return array
* @return array
*/
public static function checkConf()
public static function checkConf(): array
{
return array( 'convertAttachments' );
}
@@ -239,10 +235,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 )
@@ -275,7 +271,7 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertBlogs()
public function convertBlogs() : void
{
$libraryClass = $this->getLibrary();
@@ -361,7 +357,7 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertBlogEntryCategories()
public function convertBlogEntryCategories() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'blogcategoryid' );
@@ -385,7 +381,7 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertBlogEntries()
public function convertBlogEntries() : void
{
$libraryClass = $this->getLibrary();
@@ -447,7 +443,7 @@ class Vbulletin extends Software
'entry_edit_time' => $edittime,
'entry_edit_name' => $editname,
'entry_edit_reason' => $editReason,
'entry_append_edit' => $edittime ? TRUE : FALSE,
'entry_append_edit' => (bool)$edittime,
'entry_ip_address' => long2ip( (int) $text['ipaddress'] ),
'entry_category_id' => $mainCategory
);
@@ -526,14 +522,14 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertBlogComments()
public function convertBlogComments() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'blogtextid' );
// Exclude text of blog entry from iterator
foreach( $this->fetch( 'blog_text', 'blogtextid', array( 'blogtextid NOT IN (' . (string) $this->db->select( 'firstblogtextid', 'blog' ) . ')' ) ) AS $comment )
foreach( $this->fetch( 'blog_text', 'blogtextid', array( 'blogtextid NOT IN (' . $this->db->select( 'firstblogtextid', 'blog' ) . ')' ) ) AS $comment )
{
$edittime = $editname = NULL;
try
@@ -583,7 +579,7 @@ class Vbulletin extends Software
*
* @return void
*/
public function convertAttachments()
public function convertAttachments() : void
{
$libraryClass = $this->getLibrary();
@@ -679,8 +675,7 @@ class Vbulletin extends Software
Db::i()->update( 'blog_entries', array( 'entry_content' => $post ), array( "entry_id=?", $entry_id ) );
}
}
catch( UnderflowException $e ) {}
catch( OutOfRangeException $e ) {}
catch( UnderflowException|OutOfRangeException $e ) {}
}
$libraryClass->setLastKeyValue( $attachment['attachmentid'] );
@@ -690,9 +685,9 @@ class Vbulletin 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();