mirror of
https://github.com/humhub/humhub.git
synced 2025-03-04 07:08:58 +01:00
Fixed #1416: Show video link on edit view
This commit is contained in:
parent
3999596555
commit
8b94d199d0
@ -56,6 +56,8 @@ class UrlOembed extends \yii\db\ActiveRecord
|
||||
public static function GetOEmbed($url)
|
||||
{
|
||||
|
||||
$url = trim($url);
|
||||
|
||||
// Check if the given URL has OEmbed Support
|
||||
if (UrlOembed::HasOEmbedSupport($url)) {
|
||||
|
||||
@ -111,7 +113,7 @@ class UrlOembed extends \yii\db\ActiveRecord
|
||||
try {
|
||||
$data = \yii\helpers\Json::decode($jsonOut);
|
||||
if (isset($data['type']) && ($data['type'] === "video" || $data['type'] === 'rich' || $data['type'] === 'photo')) {
|
||||
$html = "<div class='oembed_snippet'>" . $data['html'] . "</div>";
|
||||
$html = "<div class='oembed_snippet' data-url='" . \yii\helpers\Html::encode($url) . "'>" . $data['html'] . "</div>";
|
||||
}
|
||||
} catch (\yii\base\InvalidParamException $ex) {
|
||||
Yii::warning($ex->getMessage());
|
||||
|
@ -14,7 +14,7 @@ use yii\helpers\Url;
|
||||
|
||||
<!-- create contenteditable div for HEditorWidget to place the data -->
|
||||
<div id="comment_input_<?php echo $comment->id; ?>_contenteditable" class="form-control atwho-input"
|
||||
contenteditable="true"><?php echo \humhub\widgets\RichText::widget(['text' => $comment->message]); ?></div>
|
||||
contenteditable="true"><?php echo \humhub\widgets\RichText::widget(['text' => $comment->message, 'edit' => true]); ?></div>
|
||||
|
||||
|
||||
<?php
|
||||
|
@ -12,7 +12,7 @@ use yii\helpers\Url;
|
||||
|
||||
<!-- create contenteditable div for HEditorWidget to place the data -->
|
||||
<div id="post_input_<?php echo $post->id; ?>_contenteditable" class="form-control atwho-input"
|
||||
contenteditable="true"><?php echo \humhub\widgets\RichText::widget(['text' => $post->message]); ?></div>
|
||||
contenteditable="true"><?php echo \humhub\widgets\RichText::widget(['text' => $post->message, 'edit' => true]); ?></div>
|
||||
|
||||
<?= \humhub\widgets\RichTextEditor::widget(['id' => 'post_input_' . $post->id, 'inputContent' => $post->message, 'record' => $post]); ?>
|
||||
|
||||
|
@ -36,6 +36,11 @@ class RichText extends \humhub\components\Widget
|
||||
*/
|
||||
public $minimal = false;
|
||||
|
||||
/**
|
||||
* @var boolean edit mode
|
||||
*/
|
||||
public $edit = false;
|
||||
|
||||
/**
|
||||
* @var \humhub\components\ActiveRecord this richtext belongs to
|
||||
*/
|
||||
@ -60,8 +65,13 @@ class RichText extends \humhub\components\Widget
|
||||
if (!$this->minimal) {
|
||||
$maxOembedCount = 3; // Maximum OEmbeds
|
||||
$oembedCount = 0; // OEmbeds used
|
||||
$that = $this;
|
||||
|
||||
$this->text = preg_replace_callback('/(https?:\/\/.*?)(\s|$)/i', function ($match) use (&$oembedCount, &$maxOembedCount) {
|
||||
$this->text = preg_replace_callback('/(https?:\/\/.*?)(\s|$)/i', function ($match) use (&$oembedCount, &$maxOembedCount, &$that) {
|
||||
|
||||
if ($that->edit) {
|
||||
return Html::a($match[0], Html::decode($match[0]), array('target' => '_blank'));
|
||||
}
|
||||
|
||||
// Try use oembed
|
||||
if ($maxOembedCount > $oembedCount) {
|
||||
@ -71,7 +81,6 @@ class RichText extends \humhub\components\Widget
|
||||
return $oembed;
|
||||
}
|
||||
}
|
||||
|
||||
return Html::a($match[1], Html::decode($match[1]), array('target' => '_blank')) . $match[2];
|
||||
}, $this->text);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user