Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,16 +12,36 @@
|
||||
namespace IPS\convert\Software\Gallery;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\convert\App;
|
||||
use IPS\convert\Software;
|
||||
use IPS\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Task;
|
||||
use IPS\Text\Parser;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
use function is_null;
|
||||
use function json_decode;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Xenforo Gallery Converter
|
||||
*/
|
||||
class _Xenforo extends \IPS\convert\Software
|
||||
class Xenforo extends Software
|
||||
{
|
||||
/**
|
||||
* @brief The similarities between XF1 and XF2 are close enough that we can use the same converter
|
||||
@@ -41,12 +61,12 @@ class _Xenforo 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 );
|
||||
|
||||
@@ -57,7 +77,7 @@ class _Xenforo 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 )
|
||||
{
|
||||
@@ -75,7 +95,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) {} # If we can't query, we won't be able to do anything anyway
|
||||
catch( Exception $e ) {} # If we can't query, we won't be able to do anything anyway
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -218,7 +238,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
case 'convertGalleryAlbums':
|
||||
$options = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'gallery_categories' ), 'IPS\gallery\Category' ) AS $category )
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'gallery_categories' ), 'IPS\gallery\Category' ) AS $category )
|
||||
{
|
||||
$options[$category->_id] = $category->_title;
|
||||
}
|
||||
@@ -239,25 +259,25 @@ class _Xenforo extends \IPS\convert\Software
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_xf_attach_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_hint' => Member::loggedIn()->language()->addToStack('convert_xf_attach_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
$return['convertGalleryImages']['media_thumb_location'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_xf_gal_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_hint' => Member::loggedIn()->language()->addToStack('convert_xf_gal_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
|
||||
/* Get our reactions to let the admin map them */
|
||||
$options = array();
|
||||
$descriptions = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_reactions' ), 'IPS\Content\Reaction' ) AS $reaction )
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_reactions' ), 'IPS\Content\Reaction' ) AS $reaction )
|
||||
{
|
||||
$options[ $reaction->id ] = $reaction->_icon->url;
|
||||
$descriptions[ $reaction->id ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_title_' . $reaction->id ) . '<br>' . $reaction->_description;
|
||||
$descriptions[ $reaction->id ] = Member::loggedIn()->language()->addToStack('reaction_title_' . $reaction->id ) . '<br>' . $reaction->_description;
|
||||
}
|
||||
|
||||
$return['convertGalleryImages']['rep_like'] = array(
|
||||
@@ -282,14 +302,14 @@ class _Xenforo extends \IPS\convert\Software
|
||||
public function finish()
|
||||
{
|
||||
/* Content Rebuilds */
|
||||
\IPS\Task::queue( 'convert', 'RebuildGalleryImages', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'gallery_comments', 'class' => 'IPS\gallery\Image\Comment' ), 2, array( 'app', 'link', 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\gallery\Image' ), 3, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Album', 'count' => 0 ), 4, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Category', 'count' => 0 ), 5, array( 'class' ) );
|
||||
Task::queue( 'convert', 'RebuildGalleryImages', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
|
||||
Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'gallery_comments', 'class' => 'IPS\gallery\Image\Comment' ), 2, array( 'app', 'link', 'class' ) );
|
||||
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\gallery\Image' ), 3, array( 'class' ) );
|
||||
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Album', 'count' => 0 ), 4, array( 'class' ) );
|
||||
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Category', 'count' => 0 ), 5, array( 'class' ) );
|
||||
|
||||
/* Caches */
|
||||
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'gallery_images', 'class' => 'IPS\gallery\Image' ), 3, array( 'app', 'link', 'class' ) );
|
||||
Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'gallery_images', 'class' => 'IPS\gallery\Image' ), 3, array( 'app', 'link', 'class' ) );
|
||||
|
||||
return array( "f_gallery_images_rebuild", "f_gallery_cat_recount", "f_gallery_album_recount", "f_gallery_image_recount", "f_image_tags_recount" );
|
||||
}
|
||||
@@ -305,10 +325,10 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
try
|
||||
{
|
||||
$title = ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) ? $xfTwoTitle : $xfOneTitle;
|
||||
$title = ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) ? $xfTwoTitle : $xfOneTitle;
|
||||
return $this->db->select( 'phrase_text', 'xf_phrase', array( "title=?", $title ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -375,9 +395,9 @@ class _Xenforo extends \IPS\convert\Software
|
||||
try
|
||||
{
|
||||
$perm = $this->db->select( '*', 'xengallery_album_permission', array( "album_id=? AND permission=?", $row['album_id'], 'view' ) )->first();
|
||||
$perm['share_users'] = \unserialize( $perm['share_users'] );
|
||||
$perm['share_users'] = unserialize( $perm['share_users'] );
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
/* If the permission row is missing for some reason, err on the side of caution and set this album private */
|
||||
$perm = array(
|
||||
@@ -407,7 +427,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
$users = $perm['share_users'];
|
||||
$socialgroup['members'] = array();
|
||||
|
||||
if ( \count( $users ) )
|
||||
if ( count( $users ) )
|
||||
{
|
||||
foreach( $users AS $key => $user )
|
||||
{
|
||||
@@ -532,7 +552,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
$ip = $this->db->select( '*', 'xf_ip', array( "ip_id=?", $row['ip_id'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
@@ -549,7 +569,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
->join( 'xf_attachment_data', 'xf_attachment.data_id = xf_attachment_data.data_id' )
|
||||
->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
/* If the file data is missing, we can't do anything. */
|
||||
$libraryClass->setLastKeyValue( $row['media_id'] );
|
||||
@@ -581,9 +601,9 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
$memberId = $this->app->getLink( $row['user_id'], 'core_members', TRUE );
|
||||
|
||||
$em = \IPS\Text\Parser::embeddableMedia( \IPS\Http\Url::createFromString( $row['media_embed_url'] ), FALSE, \IPS\Member::load( $memberId ) );
|
||||
$em = Parser::embeddableMedia( Url::createFromString( $row['media_embed_url'] ), FALSE, Member::load( $memberId ) );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
/* If anything went wrong, back out */
|
||||
$libraryClass->setlastKeyValue( $row['media_id'] );
|
||||
@@ -646,13 +666,13 @@ class _Xenforo extends \IPS\convert\Software
|
||||
/* Reputation */
|
||||
if ( !static::$useJson )
|
||||
{
|
||||
$likes = \unserialize( $row['like_users'] );
|
||||
$likes = unserialize( $row['like_users'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$likes = \json_decode( $row['reaction_score'], TRUE );
|
||||
$likes = json_decode( $row['reaction_score'], TRUE );
|
||||
}
|
||||
if ( \is_array( $likes ) AND \count( $likes ) )
|
||||
if ( is_array( $likes ) AND count( $likes ) )
|
||||
{
|
||||
foreach( $likes AS $like )
|
||||
{
|
||||
@@ -691,15 +711,15 @@ class _Xenforo extends \IPS\convert\Software
|
||||
/* Tags 1.0.x */
|
||||
if( isset( $row['media_content_tag_cache'] ) )
|
||||
{
|
||||
$tags = \unserialize( $row['media_content_tag_cache'] );
|
||||
$tags = unserialize( $row['media_content_tag_cache'] );
|
||||
}
|
||||
/* Tags 1.1.x */
|
||||
elseif( isset( $row['tags'] ) )
|
||||
{
|
||||
$tags = \unserialize( $row['tags'] );
|
||||
$tags = unserialize( $row['tags'] );
|
||||
}
|
||||
|
||||
if ( \is_array( $tags ) and \count( $tags ) )
|
||||
if ( is_array( $tags ) and count( $tags ) )
|
||||
{
|
||||
foreach( $tags AS $k => $tag )
|
||||
{
|
||||
@@ -738,7 +758,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
$ip = $this->db->select( 'ip', 'xf_ip', array( "ip_id=?", $row['ip_id'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
@@ -773,13 +793,13 @@ class _Xenforo extends \IPS\convert\Software
|
||||
/* Reputation */
|
||||
if ( !static::$useJson )
|
||||
{
|
||||
$likes = \unserialize( $row['like_users'] );
|
||||
$likes = unserialize( $row['like_users'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$likes = \json_decode( $row['reaction_score'], TRUE );
|
||||
$likes = json_decode( $row['reaction_score'], TRUE );
|
||||
}
|
||||
if ( \is_array( $likes ) AND \count( $likes ) )
|
||||
if ( is_array( $likes ) AND count( $likes ) )
|
||||
{
|
||||
foreach( $likes AS $like )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user