Bladeren bron

fix open graph CT#7539

aragonc 9 jaren geleden
bovenliggende
commit
7e6e093717
3 gewijzigde bestanden met toevoegingen van 14 en 10 verwijderingen
  1. BIN
      main/img/icons/16/vcard.png
  2. 12 9
      main/inc/lib/social.lib.php
  3. 2 1
      main/social/profile.php

BIN
main/img/icons/16/vcard.png


+ 12 - 9
main/inc/lib/social.lib.php

@@ -1544,12 +1544,13 @@ class SocialManager extends UserManager
         $regExUrl = "/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
         $newText = '';
         if (preg_match($regExUrl, $text, $url)) {
-            // make the urls hyper links
-            $newText .= preg_replace($regExUrl, "<a target=\"_blank\" href=" . $url[0] . ">".$url[0]."</a> ", $text);
             // Comment this line to disable OpenGraph
             $newText .= self::getHtmlByLink($url[0]);
+            // make the urls hyper links
+            //$newText .= preg_replace($regExUrl, "<a target=\"_blank\" href=" . $url[0] . ">".$url[0]."</a> ", $text);
+            
         } else {
-            $newText .= $text;
+            $newText = $text;
         }
         return $newText;
     }
@@ -1564,8 +1565,9 @@ class SocialManager extends UserManager
         $graph = OpenGraph::fetch($link);
         $url = $graph->url;
         $image = $graph->image;
-        $domain = empty($url) ? parse_url($link) : parse_url($url);
+        $domain = empty($url) ? '' : parse_url($url);
         $domain = $domain['scheme'].'://'.$domain['host'];
+        $html = '';
         // Trick to verify if the Image Url Exist because of some bad metatag dev
         if (self::verifyUrl($image) == false){
             if (!($image[0] == '/')){
@@ -1574,10 +1576,11 @@ class SocialManager extends UserManager
             $image = $domain . $image;
         }
         $title = $graph->title;
-        $html = '<div class="thumbnail">';
-        $html .= '<a target="_blank" href="'.$link.'"><h3>'.$title.'</h3>';
-        $html .= empty($image) ? '' : '<img alt="" src="'.$image.'" height="160" ></a>';
-        $html .= empty($graph->description) ? '' : '<div>'.$graph->description.'</div>';
+        
+        $html .= '<div class="post-open-graph">';
+        $html .= '<h4><a target="_blank" href="'.$link.'">'.$title.'</a></h4>';
+        $html .= empty($image) ? '' : '<img alt="" src="'.$image.'" />';
+        $html .= empty($graph->description) ? '' : '<p class="description">'.$graph->description.'<a href="'.$link.'">'.$link.'</a></p>';
         $html .= "</div>";
         return $html;
     }
@@ -1855,7 +1858,7 @@ class SocialManager extends UserManager
                 'cols-size' => [1, 10, 1]
             ]
         );
-        $form->addHtml('<div class="form-group "><div class="url_preview col-md-9 panel-body"></div></div>');
+        $form->addHtml('<div class="url_preview"></div>');
         $form->addHidden('url_content', '');
         $form->addButtonSend(get_lang('Post'), null, false, ['cols-size' => [1, 10, 1]]);
         $html = Display::panel($form->returnForm(), get_lang('SocialWall'));

+ 2 - 1
main/social/profile.php

@@ -294,7 +294,7 @@ $socialAutoExtendLink = Display::url(
 // Added a Jquery Function to return the Preview of OpenGraph URL Content
 $htmlHeadXtra[] = '<script>
 $(document).ready(function() {
-    /* $("label").remove(); */
+    
     $("[name=\'social_wall_new_msg_main\']").on("paste", function(e) {
         $.ajax({
             contentType: "application/x-www-form-urlencoded",
@@ -307,6 +307,7 @@ $(document).ready(function() {
             success: function(response) {
                 $(".url_preview").html(response);
                 $("[name=\'url_content\']").val(response);
+                $(".url_preview img").addCSS("img-responsive");
             }
         });
     });