Version 5.0.0 beta 4
This commit is contained in:
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;
|
||||
|
||||
Reference in new issue
Block a user