Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -30,7 +30,7 @@ class _Vanilla extends \IPS\convert\Software
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "Vanilla 2 (2.2.x/2.3.x)";
|
||||
return "Vanilla (3.x)";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,14 +144,14 @@ class _Vanilla extends \IPS\convert\Software
|
||||
// Deprecated "plugin based" path
|
||||
elseif ( preg_match( '`^~([^/]*)/(.*)$`', $location, $matches ) )
|
||||
{
|
||||
return $uploadsPath.'/'.$matches[2];
|
||||
return rtrim( $uploadsPath, '/' ) . '/' . $matches[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$parts = parse_url( $location );
|
||||
if ( empty( $parts['scheme'] ) )
|
||||
{
|
||||
return $uploadsPath.'/'.$location;
|
||||
return rtrim( $uploadsPath, '/' ) . '/' . $location;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -167,6 +167,8 @@ class _Vanilla extends \IPS\convert\Software
|
||||
'domain' => $parts['host']
|
||||
);
|
||||
|
||||
return rtrim( $uploadsPath, '/' ) . '/' . ltrim( $parts['path'], '/' );
|
||||
|
||||
// @TODO: This is deprecated, and I'm not sure what it was for.
|
||||
#$format = "{$result['type']}://{$result['domain']}/%s";
|
||||
#return sprintf( $format, $result['name'] );
|
||||
@@ -199,7 +201,7 @@ class _Vanilla extends \IPS\convert\Software
|
||||
),
|
||||
'convertMembers' => array(
|
||||
'table' => 'User',
|
||||
'where' => NULL,
|
||||
'where' => array( "Deleted<>?", 1 ),
|
||||
),
|
||||
'convertStatuses' => array(
|
||||
'table' => 'Activity',
|
||||
@@ -335,6 +337,11 @@ class _Vanilla extends \IPS\convert\Software
|
||||
return array( "f_search_index_rebuild", "f_clear_caches", "f_rebuild_pms", "f_signatures_rebuild", "f_rebuild_attachments" );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Store parsedown object
|
||||
*/
|
||||
protected static $_parseDown = NULL;
|
||||
|
||||
/**
|
||||
* Fix post data
|
||||
*
|
||||
@@ -343,6 +350,80 @@ class _Vanilla extends \IPS\convert\Software
|
||||
*/
|
||||
public static function fixPostData( $post )
|
||||
{
|
||||
/* Is this Markdown? */
|
||||
if( mb_substr( $post, 0, 15 ) == '<!--Markdown-->' )
|
||||
{
|
||||
/* Load parser */
|
||||
if( static::$_parseDown === NULL )
|
||||
{
|
||||
\IPS\IPS::$PSR0Namespaces['erusev'] = \IPS\ROOT_PATH . "/applications/convert/sources/Tools/Vanilla/Parsedown";
|
||||
static::$_parseDown = new \erusev\Parsedown();
|
||||
}
|
||||
|
||||
$post = str_replace( '<!--Markdown-->', '', $post );
|
||||
$post = static::$_parseDown->text( $post );
|
||||
}
|
||||
elseif( mb_substr( $post, 0, 3 ) == '[{"' ) // Probably a delta
|
||||
{
|
||||
$postData = str_replace( [ "\r\n","\n" ], '', $post );
|
||||
$postData = json_decode( $postData, TRUE );
|
||||
|
||||
$post = '';
|
||||
foreach( $postData as $data )
|
||||
{
|
||||
if( \is_array( $data['insert'] ) )
|
||||
{
|
||||
switch ( $data['insert']['embed-external']['data']['embedType'] )
|
||||
{
|
||||
case 'quote':
|
||||
$post .= '[quote name="' . $data['insert']['embed-external']['data']['insertUser']['name'] . '" timestamp="' . strtotime( $data['insert']['embed-external']['data']['dateInserted'] ) . '"]' . $data['insert']['embed-external']['data']['body'] . "[/quote]";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$post .= $data['insert'] . "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Mentions */
|
||||
$matches = [];
|
||||
preg_match_all( '/@("|")([^@"]+)("|")/i', $post, $matches );
|
||||
|
||||
if( \count( $matches ) )
|
||||
{
|
||||
foreach( $matches[0] as $key => $tag )
|
||||
{
|
||||
$member = \IPS\Member::load( $matches[2][ $key ], 'name' );
|
||||
if( !$member->member_id )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$post = str_replace( $tag, "[mention={$member->member_id}]{$member->name}[/mention]", $post );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vanilla has a quotes plugin that seems to have changed formats quite often. - We'll try to match as many formats as we can
|
||||
*/
|
||||
$post = preg_replace( '/(?:<blockquote\s+(?:class=\"(?:User)?Quote\")?(?:\s+rel=\"(?:[^\"]+)\")?>)(?:\s+)?<div class=\"QuoteAuthor\">([^\"]+)<\/div>(?:\s+)?<div class=\"QuoteText\">(?:<p>)?(.*?)(?:<\/p>)?<\/div>(?:\s+)?<\/blockquote>/i',
|
||||
'[quote name="$1"]$2[/quote]' ,
|
||||
$post );
|
||||
|
||||
$post = preg_replace( '/(?:<blockquote\s+(?:class=\"Quote (?:User)?Quote\")?(?:\s+rel=\"(?:[^\"]+)\")?>)(?:\s+)?<div class=\"QuoteText\">(?:<p>)?(.*?)(?:<\/p>)?<\/div>(?:\s+)?<\/blockquote>/i',
|
||||
'[quote]$1[/quote]' ,
|
||||
$post );
|
||||
|
||||
$post = preg_replace( '/<blockquote\s+rel=\"([^\"]+)\"?>(.*?)<\/blockquote>/i',
|
||||
'[quote name="$1"]$2[/quote]' ,
|
||||
$post );
|
||||
|
||||
$post = preg_replace( '/<blockquote>(.*?)<\/blockquote>/ims',
|
||||
'[quote]$1[/quote]' ,
|
||||
$post );
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
@@ -356,12 +437,8 @@ class _Vanilla extends \IPS\convert\Software
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'r.RoleID' );
|
||||
|
||||
/* Ready Roles */
|
||||
$roles = $this->fetch( array( 'Role', 'r' ), 'RoleID' );
|
||||
//$roles->join( array( 'Permission', 'p' ), 'r.RoleID=p.PermissionID' );
|
||||
|
||||
/* Run conversions */
|
||||
foreach ( $roles as $row )
|
||||
foreach ( $this->fetch( array( 'Role', 'r' ), 'RoleID' ) as $row )
|
||||
{
|
||||
$info = array(
|
||||
'g_id' => $row['RoleID'],
|
||||
@@ -397,9 +474,13 @@ class _Vanilla extends \IPS\convert\Software
|
||||
|
||||
$uploadsPath = $this->app->_session['more_info']['convertMembers']['attach_location'];
|
||||
|
||||
$users = $this->fetch( array( 'User', 'u' ), 'u.UserID', array( "u.Deleted<>?", 1 ) );
|
||||
$users = $this->fetch( array( 'User', 'u' ), 'u.UserID', array( "u.Deleted<>?", 1 ), 'u.*, ur.RoleID' );
|
||||
$users->join( array( 'UserRole', 'ur' ), 'ur.UserID=u.UserID' );
|
||||
foreach( $users AS $row )
|
||||
|
||||
$data = iterator_to_array( $users );
|
||||
$this->app->preCacheLinks( $data, [ 'core_groups' => 'RoleID' ] );
|
||||
|
||||
foreach( $data AS $row )
|
||||
{
|
||||
/* Work out birthday */
|
||||
$bdayDay = NULL;
|
||||
@@ -479,10 +560,11 @@ class _Vanilla extends \IPS\convert\Software
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'ActivityID' );
|
||||
|
||||
$statuses = $this->fetch( 'Activity', 'ActivityID', array( 'ActivityTypeID=?', static::$activityStatusType ) );
|
||||
$data = iterator_to_array( $this->fetch( 'Activity', 'ActivityID', array( 'ActivityTypeID=?', static::$activityStatusType ) ) );
|
||||
$this->app->preCacheLinks( $data, [ 'core_members' => 'ActivityUserID' ] );
|
||||
|
||||
/* Run conversions */
|
||||
foreach ( $statuses as $row )
|
||||
foreach ( $data as $row )
|
||||
{
|
||||
$info = array(
|
||||
'status_id' => $row['ActivityID'],
|
||||
@@ -509,10 +591,11 @@ class _Vanilla extends \IPS\convert\Software
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'ConversationID' );
|
||||
|
||||
$messages = $this->fetch( 'Conversation', 'ConversationID' );
|
||||
$data = iterator_to_array( $this->fetch( 'Conversation', 'ConversationID' ) );
|
||||
$this->app->preCacheLinks( $data, [ 'core_members' => 'InsertUserID' ] );
|
||||
|
||||
/* Run conversions */
|
||||
foreach ( $messages as $row )
|
||||
foreach ( $data as $row )
|
||||
{
|
||||
/* Message topic information */
|
||||
//$firstMessageId = $row['FirstMessageID'];
|
||||
@@ -528,8 +611,8 @@ class _Vanilla extends \IPS\convert\Software
|
||||
|
||||
/* Message maps */
|
||||
$maps = array();
|
||||
$rows = $this->fetch( 'UserConversation', 'UserID', array( 'ConversationID=?', $row['ConversationID'] ) );
|
||||
|
||||
$rows = iterator_to_array( $this->db->select( '*', 'UserConversation', array( 'ConversationID=?', $row['ConversationID'] ) ) );
|
||||
$this->app->preCacheLinks( $rows, [ 'core_members' => 'UserID' ] );
|
||||
foreach ( $rows as $row )
|
||||
{
|
||||
$maps[ $row['UserID'] ] = array(
|
||||
@@ -554,11 +637,19 @@ class _Vanilla extends \IPS\convert\Software
|
||||
public function convertPrivateMessageReplies()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'MessageID' );
|
||||
|
||||
foreach( $this->fetch( 'ConversationMessage', 'MessageID' ) AS $row )
|
||||
$data = iterator_to_array( $this->fetch( 'ConversationMessage', 'MessageID' ) );
|
||||
$this->app->preCacheLinks( $data, [ 'core_members' => 'InsertUserID', 'core_message_topics' => 'ConversationID' ] );
|
||||
|
||||
foreach( $data AS $row )
|
||||
{
|
||||
// Add Format Type (for later processing) if Markdown
|
||||
if( $row['Format'] == 'Markdown' )
|
||||
{
|
||||
$row['Body'] = '<!--Markdown-->' . $row['Body'];
|
||||
}
|
||||
|
||||
$libraryClass->convertPrivateMessageReply( array(
|
||||
'msg_id' => $row['MessageID'],
|
||||
'msg_topic_id' => $row['ConversationID'],
|
||||
|
||||
Reference in new issue
Block a user