Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -20,6 +20,31 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
class _Vanilla extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
* @brief Store the result of the check for reaction support
|
||||
*/
|
||||
protected static $_supportsReactions = FALSE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\convert\App The application to reference for database and other information.
|
||||
* @param bool Establish a DB connection
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
|
||||
{
|
||||
$return = parent::__construct( $app, $needDB );
|
||||
|
||||
/* Check for reaction support - This is a Vanilla2 addon, so it may not be installed */
|
||||
if ( $needDB )
|
||||
{
|
||||
static::$_supportsReactions = $this->db->checkForTable( 'Action' );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
/**
|
||||
* Software Name
|
||||
*
|
||||
@@ -28,7 +53,7 @@ class _Vanilla extends \IPS\convert\Software
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "Vanilla 2";
|
||||
return "Vanilla 2 (2.2.x/2.3.x)";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +119,20 @@ class _Vanilla extends \IPS\convert\Software
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows software to add additional menu row options
|
||||
*
|
||||
* @param array $rows Existing rows
|
||||
* @return array
|
||||
*/
|
||||
public function extraMenuRows( $rows )
|
||||
{
|
||||
$rows['convertForumsPosts2'] = $rows['convertForumsPosts'];
|
||||
$rows['convertForumsPosts2']['step_method'] = 'convertForumsPosts2';
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count Source Rows for a specific step
|
||||
*
|
||||
@@ -170,30 +209,33 @@ class _Vanilla extends \IPS\convert\Software
|
||||
);
|
||||
break;
|
||||
case 'convertForumsPosts':
|
||||
/* 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 )
|
||||
/* Get our reactions to let the admin map them - this is a Vanilla2 addon so it may not be installed */
|
||||
if( static::$_supportsReactions )
|
||||
{
|
||||
$options[ $reaction->id ] = $reaction->_icon->url;
|
||||
$descriptions[ $reaction->id ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_title_' . $reaction->id ) . '<br>' . $reaction->_description;
|
||||
}
|
||||
$options = array();
|
||||
$descriptions = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\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;
|
||||
}
|
||||
|
||||
$return['convertForumsPosts'] = array();
|
||||
$return['convertForumsPosts'] = array();
|
||||
|
||||
foreach( $this->db->select( '*', 'action' ) as $reaction )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['reaction_' . $reaction['ActionID'] ] = $reaction['Name'];
|
||||
\IPS\Member::loggedIn()->language()->words['reaction_' . $reaction['ActionID'] . '_desc' ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_convert_help');
|
||||
foreach( $this->db->select( '*', 'Action' ) as $reaction )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['reaction_' . $reaction['ActionID'] ] = $reaction['Name'];
|
||||
\IPS\Member::loggedIn()->language()->words['reaction_' . $reaction['ActionID'] . '_desc' ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_convert_help');
|
||||
|
||||
$return['convertForumsPosts']['reaction_' . $reaction['ActionID'] ] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
);
|
||||
$return['convertForumsPosts']['reaction_' . $reaction['ActionID'] ] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'convertAttachments':
|
||||
@@ -246,16 +288,21 @@ class _Vanilla extends \IPS\convert\Software
|
||||
public static function fixPostData( $post )
|
||||
{
|
||||
/**
|
||||
* Vanilla actually only supports plaintext posts out of the box, but there is a popular quotes plugin I think
|
||||
* we should accommodate for.
|
||||
* Vanilla has a quotes plugin that seems to have changed formats quite often. - We'll try to match as many formats as we can
|
||||
*/
|
||||
$quoted = preg_replace_callback( '#<blockquote class="Quote" rel="([^"]+)">(.+)</blockquote>#', function( $match )
|
||||
{
|
||||
$match[1] = str_replace( '"', '', $match[1] );
|
||||
return "[quote name=\"{$match[1]}\"]{$match[2]}[/quote]";
|
||||
}, $post );
|
||||
$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 );
|
||||
|
||||
return $quoted ?: $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 );
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,16 +421,24 @@ class _Vanilla extends \IPS\convert\Software
|
||||
|
||||
foreach( $discussions AS $row )
|
||||
{
|
||||
$row['DateLastComment'] = 0;
|
||||
$row['LastCommentUserID'] = 0;
|
||||
$row['LastCommentUserName'] = '';
|
||||
|
||||
/* If last post info is empty, fetch it */
|
||||
if( $row['DateLastComment'] === NULL )
|
||||
{
|
||||
$data = $this->db->select( 'Comment.InsertUserID, Comment.DateInserted, User.Name', 'Comment', array( 'DiscussionID=?', $row['DiscussionID'] ), 'CommentID DESC', array( 0, 1 ) )
|
||||
->join( 'User', 'Comment.InsertUserID=User.UserID' )
|
||||
->first();
|
||||
try
|
||||
{
|
||||
$data = $this->db->select( 'Comment.InsertUserID, Comment.DateInserted, User.Name', 'Comment', array( 'DiscussionID=?', $row['DiscussionID'] ), 'CommentID DESC', array( 0, 1 ) )
|
||||
->join( 'User', 'Comment.InsertUserID=User.UserID' )
|
||||
->first();
|
||||
|
||||
$row['DateLastComment'] = $data['DateInserted'];
|
||||
$row['LastCommentUserID'] = $data['InsertUserId'];
|
||||
$row['LastCommentUserName'] = $data['Name'];
|
||||
$row['DateLastComment'] = $data['DateInserted'];
|
||||
$row['LastCommentUserID'] = $data['InsertUserId'];
|
||||
$row['LastCommentUserName'] = $data['Name'];
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
}
|
||||
|
||||
$info = array(
|
||||
@@ -472,21 +527,24 @@ class _Vanilla extends \IPS\convert\Software
|
||||
$libraryClass->convertForumsPost( $info );
|
||||
$libraryClass->setLastKeyValue( $row['DiscussionID'] );
|
||||
|
||||
/* Reputation */
|
||||
foreach( $this->db->select( '*', 'reaction', array( "ParentType=? AND ParentID=?", 'comment', $row['DiscussionID'] ) ) AS $rep )
|
||||
/* Reputation - Reactions are only supported if the YAGA addon was used. */
|
||||
if( static::$_supportsReactions )
|
||||
{
|
||||
$reaction = $this->app->_session['more_info']['convertForumsPosts']['reaction_' . $rep['ActionID'] ];
|
||||
foreach( $this->db->select( '*', 'Reaction', array( "ParentType=? AND ParentID=?", 'comment', $row['DiscussionID'] ) ) AS $rep )
|
||||
{
|
||||
$reaction = $this->app->_session['more_info']['convertForumsPosts']['reaction_' . $rep['ActionID'] ];
|
||||
|
||||
$libraryClass->convertReputation( array(
|
||||
'id' => $rep['ReactionID'],
|
||||
'app' => 'forums',
|
||||
'type' => 'pid',
|
||||
'type_id' => 'fp-' . $row['DiscussionID'],
|
||||
'member_id' => $rep['InsertUserID'],
|
||||
'member_received' => $rep['ParentAuthorID'],
|
||||
'rep_date' => VanillaCore::mysqlToDateTime( $row['DateInserted'] ),
|
||||
'reaction' => $reaction
|
||||
) );
|
||||
$libraryClass->convertReputation( array(
|
||||
'id' => $rep['ReactionID'],
|
||||
'app' => 'forums',
|
||||
'type' => 'pid',
|
||||
'type_id' => 'fp-' . $row['DiscussionID'],
|
||||
'member_id' => $rep['InsertUserID'],
|
||||
'member_received' => $rep['ParentAuthorID'],
|
||||
'rep_date' => VanillaCore::mysqlToDateTime( $row['DateInserted'] ),
|
||||
'reaction' => $reaction
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user