Version 5.0.6
This commit is contained in:
1 parent
a3a4a9ccbd
commit
b89858b2ff
1214 files changed
+92828
-14859
No files matched your search
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace IPS\convert\Tools\Vanilla\QuillListeners;
|
||||
|
||||
use IPS\Db;
|
||||
use nadar\quill\InlineListener;
|
||||
use nadar\quill\Line;
|
||||
|
||||
class EmbedExternal extends InlineListener
|
||||
{
|
||||
private $contentType;
|
||||
private $contentId;
|
||||
private $commentId;
|
||||
|
||||
public function __construct( ?string $contentType=null, ?int $contentId=null, ?int $commentId=null )
|
||||
{
|
||||
$this->contentType = $contentType;
|
||||
$this->contentId = $contentId;
|
||||
$this->commentId = $commentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function process(Line $line)
|
||||
{
|
||||
$embed = $line->insertJsonKey('embed-external');
|
||||
|
||||
if( $embed )
|
||||
{
|
||||
$return = match( $embed['data']['embedType'] )
|
||||
{
|
||||
'quote' => $this->processQuote( $embed ),
|
||||
'image', 'file', 'imgur', 'giphy' => $this->processMedia( $embed ),
|
||||
'youtube', 'twitter', 'instagram', 'twitch', 'vimeo' => $this->processOembed( $embed ),
|
||||
'link' => $this->processLink( $embed ),
|
||||
default => $this->processMedia( $embed )
|
||||
};
|
||||
|
||||
if ( $return !== NULL ) {
|
||||
$this->updateInput( $line, $return );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function processLink( array $data ):? string
|
||||
{
|
||||
return ' ' . $data['data']['url'] . " \n";
|
||||
}
|
||||
|
||||
public function processMedia( array $data ):? string
|
||||
{
|
||||
if( isset( $data['data']['mediaID'] ) )
|
||||
{
|
||||
// dump($this->contentType, $this->commentId);
|
||||
if( $this->contentType AND $this->commentId )
|
||||
{
|
||||
Db::i()->insert( 'convert_vanilla_temp', [ 'media_id' => $data['data']['mediaID'], 'link_type' => $this->contentType, 'content_id' => $this->contentId, 'post_id' => $this->commentId ] );
|
||||
}
|
||||
return "[ATTACH={$data['data']['mediaID']}] <br>\n";
|
||||
}
|
||||
elseif( !empty( $data['data']['url'] ) )
|
||||
{
|
||||
return "[img]{$data['data']['url']}[/img] <br>\n";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function processOembed( array $data ):? string
|
||||
{
|
||||
return $data['data']['url'] . " \n";
|
||||
}
|
||||
|
||||
public function processQuote( array $data ):? string
|
||||
{
|
||||
return '[quote name="' . $data['data']['insertUser']['name'] . '" timestamp="' . strtotime( $data['data']['dateInserted'] ) . '"]' . $data['data']['body'] . "[/quote]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace IPS\convert\Tools\Vanilla\QuillListeners;
|
||||
|
||||
use nadar\quill\InlineListener;
|
||||
use nadar\quill\Line;
|
||||
|
||||
class Emoji extends InlineListener
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function process(Line $line)
|
||||
{
|
||||
$emoji = $line->insertJsonKey('emoji');
|
||||
if ( !empty( $emoji['emojiChar'] ) ) {
|
||||
$this->updateInput( $line, $emoji['emojiChar'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace IPS\convert\Tools\Vanilla\QuillListeners;
|
||||
|
||||
use IPS\convert\App;
|
||||
use nadar\quill\InlineListener;
|
||||
use nadar\quill\Line;
|
||||
|
||||
class Mention extends InlineListener
|
||||
{
|
||||
private $app;
|
||||
|
||||
public function __construct( ?App $app=null )
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function process(Line $line)
|
||||
{
|
||||
$mention = $line->insertJsonKey('mention');
|
||||
if ( $this->app AND !empty( $mention['userID'] ) ) {
|
||||
|
||||
$ipsId = $this->app->getLink( $mention['userID'], 'core_members', true );
|
||||
$return = "[mention={$ipsId}]{$mention['name']}[/mention]";
|
||||
$this->updateInput( $line, $return );
|
||||
}
|
||||
elseif ( $mention )
|
||||
{
|
||||
$this->updateInput( $line, '@' . $mention['name'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user