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,34 @@
namespace IPS\convert\Software\Forums;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use Exception;
use IPS\Content;
use IPS\convert\Software;
use IPS\convert\Software\Core\Expressionengine;
use IPS\Db;
use IPS\Http\Url;
use IPS\Member;
use IPS\Node\Model;
use IPS\Request;
use IPS\Task;
use OutOfRangeException;
use UnderflowException;
use function defined;
use function strtolower;
use function unserialize;
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;
}
/**
* ExpressionEngine Forums Converter
*/
class _Expressionengine extends \IPS\convert\Software
class Expressionengine extends Software
{
/**
* Software Name
@@ -88,7 +106,7 @@ class _Expressionengine extends \IPS\convert\Software
$rows['convertOtherPosts'] = array(
'step_title' => 'convert_forums_posts',
'step_method' => 'convertOtherPosts',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts' ),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'forums_posts' ),
'source_rows' => array( 'table' => static::canConvert()['convertOtherPosts']['table'], 'where' => static::canConvert()['convertOtherPosts']['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertForumsPosts' ),
@@ -149,8 +167,8 @@ class _Expressionengine extends \IPS\convert\Software
'field_default' => NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_ee_forum_at_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
'field_hint' => Member::loggedIn()->language()->addToStack('convert_ee_forum_at_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
)
);
break;
@@ -167,24 +185,26 @@ class _Expressionengine extends \IPS\convert\Software
public function finish()
{
/* Content Rebuilds */
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\forums\Forum', 'count' => 0 ), 4, array( 'class' ) );
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\forums\Topic' ), 3, array( 'class' ) );
\IPS\Task::queue( 'convert', 'RebuildFirstPostIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
\IPS\Task::queue( 'convert', 'DeleteEmptyTopics', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\forums\Forum', 'count' => 0 ), 4, array( 'class' ) );
Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\forums\Topic' ), 3, array( 'class' ) );
Task::queue( 'convert', 'RebuildFirstPostIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
Task::queue( 'convert', 'DeleteEmptyTopics', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
return array( "f_forum_last_post_data", "f_rebuild_posts", "f_recounting_forums", "f_recounting_topics" );
}
/**
* Fix post data
* Pre-process content for the Invision Community text parser
*
* @param string $post Raw post data
* @return string Parsed post data
* @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\Expressionengine::fixPostData( $post );
return Expressionengine::fixPostData( $post, $className, $contentId );
}
/**
@@ -247,7 +267,7 @@ class _Expressionengine extends \IPS\convert\Software
$pollData = $this->db->select( '*', 'exp_forum_polls', array( 'topic_id=?', $row['topic_id'] ) )->first();
foreach( \unserialize( $pollData['poll_answers'] ) as $value )
foreach( unserialize( $pollData['poll_answers'] ) as $value )
{
$choices[ $index ] = $value['answer'];
$votes[ $index ] = $value['votes'];
@@ -301,7 +321,7 @@ class _Expressionengine extends \IPS\convert\Software
$lastPoster = $this->db->select( 'screen_name', 'exp_members', array( 'member_id=?', $row['last_post_author_id'] ) )->first();
}
}
catch( \UnderflowException $e ) { }
catch( UnderflowException $e ) { }
$info = array(
'tid' => $row['topic_id'],
@@ -349,7 +369,7 @@ class _Expressionengine extends \IPS\convert\Software
$editName = $this->db->select( 'screen_name', 'exp_members', array( 'member_id=?', $row['topic_edit_author'] ) )->first();
}
}
catch( \UnderflowException $e ) { }
catch( UnderflowException $e ) { }
$info = array(
'pid' => 't' . $row['topic_id'],
@@ -391,7 +411,7 @@ class _Expressionengine extends \IPS\convert\Software
$editName = $this->db->select( 'screen_name', 'exp_members', array( 'member_id=?', $row['post_edit_author'] ) )->first();
}
}
catch( \UnderflowException $e ) { }
catch( UnderflowException $e ) { }
$info = array(
'pid' => $row['post_id'],
@@ -437,7 +457,7 @@ class _Expressionengine extends \IPS\convert\Software
'attach_date' => $row['attachment_date'],
'attach_member_id' => $row['member_id'],
'attach_hits' => $row['hits'],
'attach_ext' => \strtolower( trim( $row['extension'], '.' ) ),
'attach_ext' => strtolower( trim( $row['extension'], '.' ) ),
'attach_filesize' => ( $row['filesize'] * 1000 ), //convert to kb
);
@@ -453,13 +473,13 @@ class _Expressionengine extends \IPS\convert\Software
/**
* Check if we can redirect the legacy URLs from this software to the new locations
*
* @return NULL|\IPS\Http\Url
* @return NULL|Url
*/
public function checkRedirects()
{
$url = \IPS\Request::i()->url();
$url = Request::i()->url();
if( preg_match( '#/(viewforum|viewthread|viewreply)/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
if( preg_match( '#/(viewforum|viewthread|viewreply)/([0-9]+)#i', $url->data[ Url::COMPONENT_PATH ], $matches ) )
{
switch( $matches[1] )
{
@@ -491,20 +511,20 @@ class _Expressionengine extends \IPS\convert\Software
{
$data = (string) $this->app->getLink( (int) $matches[2], $types );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$data = (string) $this->app->getLink( (int) $matches[2], $types, FALSE, TRUE );
}
$item = $class::load( $data );
if( $item instanceof \IPS\Content )
if( $item instanceof Content )
{
if( $item->canView() )
{
return $item->url();
}
}
elseif( $item instanceof \IPS\Node\Model )
elseif( $item instanceof Model )
{
if( $item->can( 'view' ) )
{
@@ -512,7 +532,7 @@ class _Expressionengine extends \IPS\convert\Software
}
}
}
catch( \Exception $e )
catch( Exception $e )
{
return NULL;
}