]> git.mxchange.org Git - friendica.git/commitdiff
Display mentioned users and in the comment box by default
authorMichael <heluecht@pirati.ca>
Mon, 28 Jan 2019 21:22:03 +0000 (21:22 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 28 Jan 2019 21:22:03 +0000 (21:22 +0000)
src/Model/Item.php
src/Object/Post.php
view/templates/comment_item.tpl
view/theme/duepuntozero/templates/comment_item.tpl
view/theme/frio/templates/comment_item.tpl
view/theme/quattro/templates/comment_item.tpl
view/theme/vier/templates/comment_item.tpl

index 67071db31817d315b25b7a10b00d8f9b23cf3387..db9fbf44f65ce40d7996b255fd48e1377dd5bf2a 100644 (file)
@@ -559,10 +559,10 @@ class Item extends BaseObject
 
                $fields['permissionset'] = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
 
-               $fields['author'] = ['url' => 'author-link', 'name' => 'author-name',
+               $fields['author'] = ['url' => 'author-link', 'name' => 'author-name', 'addr' => 'author-addr',
                        'thumb' => 'author-avatar', 'nick' => 'author-nick', 'network' => 'author-network'];
 
-               $fields['owner'] = ['url' => 'owner-link', 'name' => 'owner-name',
+               $fields['owner'] = ['url' => 'owner-link', 'name' => 'owner-name', 'addr' => 'owner-addr',
                        'thumb' => 'owner-avatar', 'nick' => 'owner-nick', 'network' => 'owner-network'];
 
                $fields['contact'] = ['url' => 'contact-link', 'name' => 'contact-name', 'thumb' => 'contact-avatar',
index c9e5cddb699f6ebb950cf13870a95a2f4e114ede..1e3f5bd99d411aea1e17ead09cf96c5cbe97ad1a 100644 (file)
@@ -768,6 +768,35 @@ class Post extends BaseObject
                return $this->comment_box_template;
        }
 
+       /**
+        * Get default text for the comment box
+        *
+        * @param integer $parent_id ID of the parent item
+        *
+        * @return string
+        */
+       private function getDefaultText($parent_id)
+       {
+               $item = Item::selectFirst(['author-addr'], ['id' => $parent_id]);
+               if (!DBA::isResult($item) || empty($item['author-addr'])) {
+                       // Should not happen
+                       return '';
+               }
+
+               $text = '@'.$item['author-addr'].' ';
+
+               $terms = Term::tagArrayFromItemId($parent_id, TERM_MENTION);
+
+               foreach ($terms as $term) {
+                       $profile = Contact::getDetailsByURL($term['url']);
+                       if (!empty($profile['addr']) && !strstr($text, $profile['addr'])) {
+                               $text .= '@' . $profile['addr'] . ' ';
+                       }
+               }
+
+               return $text;
+       }
+
        /**
         * Get the comment box
         *
@@ -804,6 +833,8 @@ class Post extends BaseObject
                        $uid = $conv->getProfileOwner();
                        $parent_uid = $this->getDataValue('uid');
 
+                       $default_text = $this->getDefaultText($this->getId());
+
                        if (!is_null($parent_uid) && ($uid != $parent_uid)) {
                                $uid = $parent_uid;
                        }
@@ -817,6 +848,7 @@ class Post extends BaseObject
                                '$id'          => $this->getId(),
                                '$parent'      => $this->getId(),
                                '$qcomment'    => $qcomment,
+                               '$default'     => $default_text,
                                '$profile_uid' => $uid,
                                '$mylink'      => $a->removeBaseURL($a->contact['url']),
                                '$mytitle'     => L10n::t('This is you'),
index 6ad01b991b94dd31fad05118f08d3249db80765b..9412b681ebf55afb2bd0f547f00b16d47a19127b 100644 (file)
@@ -17,7 +17,7 @@
                                        <a class="comment-edit-photo-link" href="{{$mylink}}" title="{{$mytitle}}"><img class="my-comment-photo" src="{{$myphoto}}" alt="{{$mytitle}}" title="{{$mytitle}}" /></a>
                                </div>
                                <div class="comment-edit-photo-end"></div>
-                               <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});" onBlur="commentClose(this,{{$id}});"></textarea>
+                               <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});" onBlur="commentClose(this,{{$id}});">{{$default}}</textarea>
                                {{if $qcomment}}
                                        <select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});" >
                                        <option value=""></option>
index f1ef37f14bbab660a609ae54c31d491bdd1c3368..e6d81ac2bd69f2a2a2b3edb0f74015bcaa96c380 100644 (file)
@@ -44,7 +44,7 @@
                                                data-role="insert-formatting" data-bbcode="video" data-id="{{$id}}"></a></li>
                                </ul>
                                <div class="comment-edit-bb-end"></div>
-                               <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});cmtBbOpen(this, {{$id}});" onBlur="commentClose(this,{{$id}});cmtBbClose(this,{{$id}});"></textarea>
+                               <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});cmtBbOpen(this, {{$id}});" onBlur="commentClose(this,{{$id}});cmtBbClose(this,{{$id}});">{{$default}}</textarea>
                                {{if $qcomment}}
                                        <select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
                                        <option value=""></option>
index 4ef5f2caa1114d589ffa07798a63fdb616d83244..4edc8f473e5059a04df30de8f3c4d31794d20120 100644 (file)
@@ -14,7 +14,7 @@
                <input type="hidden" name="post_id_random" value="{{$rand_num}}" />
 
                <div class="bb form-group">
-                       <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty form-control text-autosize" name="body" placeholder="{{$comment}}" onFocus="commentOpenUI(this,{{$id}});"></textarea>
+                       <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty form-control text-autosize" name="body" placeholder="{{$comment}}" onFocus="commentOpenUI(this,{{$id}});">{{$default}}</textarea>
                </div>
                {{if $qcomment}}
                        <select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
index c314acc66cde55f94705817b5a9bca71d385d8c8..f1365035a473205fd300e4a6f0c0733bc0249dd1 100644 (file)
@@ -42,7 +42,7 @@
                                        class="comment-edit-text-empty"
                                        name="body"
                                        placeholder="{{$comment}}"
-                                       onFocus="commentOpen(this,{{$id}}) && cmtBbOpen({{$id}});"></textarea>
+                                       onFocus="commentOpen(this,{{$id}}) && cmtBbOpen({{$id}});">{{$default}}</textarea>
                                {{if $qcomment}}
                                        <select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
                                        <option value=""></option>
index 3e72df6dc6cf40d61640195dfa3902202b816af2..4ef31b7af807fe49393088a3ccedda1e325fe581 100644 (file)
@@ -17,7 +17,7 @@
                                        <a class="comment-edit-photo-link" href="{{$mylink}}" title="{{$mytitle}}"><img class="my-comment-photo" src="{{$myphoto}}" alt="{{$mytitle}}" title="{{$mytitle}}" /></a>
                                </div>
                                <div class="comment-edit-photo-end"></div>
-                               <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});"></textarea>
+                               <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});">{{$default}}</textarea>
                                {{if $qcomment}}
                                        <select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
                                        <option value=""></option>