From 8b94d199d025d9465bea293f266b95dbe4905af6 Mon Sep 17 00:00:00 2001 From: buddha87 Date: Tue, 16 Feb 2016 00:24:09 +0100 Subject: [PATCH] Fixed #1416: Show video link on edit view --- protected/humhub/models/UrlOembed.php | 4 +++- .../humhub/modules/comment/views/comment/edit.php | 2 +- protected/humhub/modules/post/views/post/edit.php | 2 +- protected/humhub/widgets/RichText.php | 13 +++++++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/protected/humhub/models/UrlOembed.php b/protected/humhub/models/UrlOembed.php index 1caff688d2..1de91afe12 100644 --- a/protected/humhub/models/UrlOembed.php +++ b/protected/humhub/models/UrlOembed.php @@ -56,6 +56,8 @@ public function attributeLabels() public static function GetOEmbed($url) { + $url = trim($url); + // Check if the given URL has OEmbed Support if (UrlOembed::HasOEmbedSupport($url)) { @@ -111,7 +113,7 @@ public static function loadUrl($url) try { $data = \yii\helpers\Json::decode($jsonOut); if (isset($data['type']) && ($data['type'] === "video" || $data['type'] === 'rich' || $data['type'] === 'photo')) { - $html = "
" . $data['html'] . "
"; + $html = "
" . $data['html'] . "
"; } } catch (\yii\base\InvalidParamException $ex) { Yii::warning($ex->getMessage()); diff --git a/protected/humhub/modules/comment/views/comment/edit.php b/protected/humhub/modules/comment/views/comment/edit.php index 927fb9652f..484f5fe532 100644 --- a/protected/humhub/modules/comment/views/comment/edit.php +++ b/protected/humhub/modules/comment/views/comment/edit.php @@ -14,7 +14,7 @@
$comment->message]); ?>
+ contenteditable="true"> $comment->message, 'edit' => true]); ?>
$post->message]); ?>
+ contenteditable="true"> $post->message, 'edit' => true]); ?> 'post_input_' . $post->id, 'inputContent' => $post->message, 'record' => $post]); ?> diff --git a/protected/humhub/widgets/RichText.php b/protected/humhub/widgets/RichText.php index c3968585fc..362e375842 100644 --- a/protected/humhub/widgets/RichText.php +++ b/protected/humhub/widgets/RichText.php @@ -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 @@ public function run() 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 @@ public function run() return $oembed; } } - return Html::a($match[1], Html::decode($match[1]), array('target' => '_blank')) . $match[2]; }, $this->text); }