Yannick Warnier 8 vuotta sitten
vanhempi
commit
044c052b74

+ 46 - 6
app/Resources/public/css/base.css

@@ -772,6 +772,32 @@ a.personal_agenda:hover, a.personal_agenda:hover {
 .social-home-anonymous-online {
     width: 200px;
 }
+.social-thumbnail {
+    padding: 0px;
+}
+.social-title {
+    font-size: 18px;
+    font-family: helvetica, arial, sans-serif;
+    color: #000;
+}
+.social-description {
+    padding: 8px;
+    color: #000;
+}
+.social-image {
+    max-height: 300px;
+}
+.social-post-answers {
+    padding-right: 0px;
+    padding-left: 0px;
+}
+.social-host p {;
+    padding: 10px;
+    margin-top: 5px;
+    margin-bottom: 5px;
+    line-height: 22px;
+    color: #999;
+}
 .menulist {
     margin: 0px;
     list-style: none;
@@ -3829,6 +3855,16 @@ i.size-32.icon-new-work{
   max-width: 50px;
   max-height: 50px;
 }
+.top-mediapost {
+    border-bottom: 1px solid #ECF0F1;
+}
+.popularity-mediapost {
+    margin-bottom: 30px;
+    font-size: 1.2em;
+}
+.popularity-vote-found {
+    color: #FFD700;
+}
 .top-mediapost .user-image,
 .sub-mediapost .user-image
 {
@@ -3856,13 +3892,13 @@ i.size-32.icon-new-work{
 }
 .top-mediapost .msg-content p,
 .sub-mediapost .rep-post .msg-content p{
-  border-top:1px solid #ECF0F1;
-  padding-top: 10px;
-  padding-bottom: 10px;
+  /* border-top:1px solid #ECF0F1; */
+  /* padding-top: 10px; */
+  /* padding-bottom: 20px; */
   margin-top: 5px;
-  margin-bottom: 5px;
+  margin-bottom: 20px;
   line-height: 22px;
-  padding-left: 10px;
+  /* padding-left: 10px; */
   padding-right: 10px;
   color: #666666;
 }
@@ -5985,4 +6021,8 @@ footer{
     border: 2px dashed #bbbbbb;
     font-size: 120%;
     margin-bottom: 0;
-}
+}
+
+#upload_form .fa-plus-square-o, #upload_form .fa-minus-square-o {
+    cursor:pointer;
+}

+ 5 - 2
main/inc/ajax/social.ajax.php

@@ -225,14 +225,17 @@ switch ($action) {
         // Read the Url using OpenGraph and returns the hyperlinks content
     case 'readUrlWithOpenGraph':
         $url = isset($_POST['social_wall_new_msg_main']) ? $_POST['social_wall_new_msg_main'] : '';
+        $url = trim($url);
         $html = '';
-        if (SocialManager::verifyUrl($url) == true){
+        if (SocialManager::verifyUrl($url) == true) {
             $html = Security::remove_XSS(
                 SocialManager::readContentWithOpenGraph($url)
             );
         }
-        echo utf8_decode($html);
+        echo $html;
         break;
+    case 'voteMsg':
+
     default:
         echo '';
 }

+ 33 - 27
main/inc/lib/social.lib.php

@@ -1424,23 +1424,28 @@ class SocialManager extends UserManager
             $url = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$userIdLoop;
             $media = '';
             $media .= '<div class="rep-post">';
-            if ($isOwnWall) {
-                $media .= '<div class="pull-right deleted-mgs">';
-                $media .= '<a title="'.get_lang("SocialMessageDelete").'" href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?messageId='.
-                    $message['id'].'">x</a>';
-                $media .= '</div>';
-            }
-            $media .= '<div class="user-image">';
+            $media .= '<div class="col-md-2 col-xs-2 social-post-answers">';
+            $media .= '<div class="user-image pull-right">';
             $media .= '<a href="'.$url.'" ><img src="'. $users[$userIdLoop]['avatar'] .
                        '" alt="'.$users[$userIdLoop]['complete_name'].'" class="avatar-thumb"></a>';
             $media .= '</div>';
+            $media .= '</div>';
+            $media .= '<div class="col-md-9 col-xs-9 social-post-answers">';
             $media .= '<div class="user-data">';
-            $media .= '<div class="username">' . '<a href="'.$url.'">'.$nameComplete.'</a></div>';
+            $media .= '<div class="username">' . '<a href="'.$url.'">'.$nameComplete.'</a> <span>'.Security::remove_XSS($message['content']).'</span></div>';
             $media .= '<div class="time timeago" title="'.$date.'">'.$date.'</div>';
+            $media .= '<br />';
+            $media .= '</div>';
+            $media .= '</div>';
             $media .= '</div>';
-            $media .= '<div class="msg-content">';
-            $media .= '<p>'.Security::remove_XSS($message['content']).'</p>';
-            $media .= '</div></div>';
+            if ($isOwnWall) {
+                $media .= '<div class="col-md-1 col-xs-1 social-post-answers">';
+                $media .= '<div class="pull-right deleted-mgs">';
+                $media .= '<a title="'.get_lang("SocialMessageDelete").'" href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?messageId='.
+                    $message['id'].'">x</a>';
+                $media .= '</div>';
+                $media .= '</div>';
+            }
 
             $formattedList .= $media;
         }
@@ -1573,6 +1578,9 @@ class SocialManager extends UserManager
         $html .= '</div>';
         $html .= '</div>'; // end mediaPost
 
+        // Popularity post functionality
+        $html .= '<div class="popularity-mediapost"></div>';
+
         return $html;
     }
 
@@ -1583,28 +1591,26 @@ class SocialManager extends UserManager
      */
     public static function readContentWithOpenGraph($link)
     {
+        if (strpos($link, "://") === false && substr($link, 0, 1) != "/") {
+            $link = "http://".$link;
+        }
         $graph = OpenGraph::fetch($link);
+        $link = parse_url($link);
+        $host = $link['host'] ? strtoupper($link['host']) : $link['path'];
         if (!$graph) {
             return false;
         }
         $url = $graph->url;
         $image = $graph->image;
-        $domain = empty($url) ? parse_url($link) : parse_url($url);
-        $domain = $domain['scheme'].'://'.$domain['host'];
-        // Trick to verify if the Image Url Exist because of some bad metatag dev
-        if (self::verifyUrl($image) == false){
-            if (!($image[0] == '/')){
-                $domain = $domain . '/';
-            }
-            $image = $domain . $image;
-        }
+        $description = $graph->description;
         $title = $graph->title;
-
-        $html  = '<div class="thumbnail">';
-        $html .= '<a target="_blank" href="'.$link.'"><h3>'.$title.'</h3>';
-        $html .= empty($image) ? '' : '<img alt="" src="'.$image.'" /></a>';
-        $html .= empty($graph->description) ? '' : '<p class="description">'.$graph->description.'</p>';
-        $html .= '<a href="'.$link.'">'.$link.'</a>';
+        $html  = '<div class="thumbnail social-thumbnail">';
+        $html .= empty($image) ? '' : '<a target="_blank" href="'.$url.'"><img class="img-responsive social-image" src="'.$image.'" /></a>';
+        $html .= '<div class="social-description">';
+        $html .= '<a target="_blank" href="'.$url.'"><h5 class="social-title"><b>'.$title.'</b></h5></a>';
+        $html .= empty($description) ? '' : '<span>'.$description.'</span>';
+        $html .= empty($host) ? '' : '<p>'.$host.'</p>';
+        $html .= '</div>';
         $html .= '</div>';
 
         return $html;
@@ -1927,7 +1933,7 @@ class SocialManager extends UserManager
             $post = $message['html'];
             $comment = SocialManager::getWallMessagesHTML($userId, $friendId, $message['id']);
 
-            $html .= $post.$comment;
+            $html .= Display::panel($post.$comment, '');
         }
 
         return $html;

+ 6 - 4
main/social/profile.php

@@ -286,8 +286,7 @@ $social_wall_block = $wallSocialAddPost;
 // Social Post Wall
 $posts = SocialManager::getWallMessagesByUser($my_user_id, $friendId) ;
 
-$posts = empty($posts) ? '<p>'.get_lang("NoPosts").'</p>' : $posts;
-$social_post_wall_block = Display::panel($posts, get_lang('Posts'));
+$social_post_wall_block = empty($posts) ? '<p>'.get_lang("NoPosts").'</p>' : $posts;
 
 $socialAutoExtendLink = Display::url(
     get_lang('SeeMore'),
@@ -300,8 +299,11 @@ $socialAutoExtendLink = Display::url(
 // Added a Jquery Function to return the Preview of OpenGraph URL Content
 $htmlHeadXtra[] = '<script>
 $(document).ready(function() {
-    
-    $("[name=\'social_wall_new_msg_main\']").on("paste", function(e) {
+
+    var getUrl = $("[name=\'social_wall_new_msg_main\']");
+    var matchUrl = /https?:\/\/w{0,3}\w*?\.(\w*?\.)?\w{2,3}\S*|www\.(\w*?\.)?\w*?\.\w{2,3}\S*|(\w*?\.)?\w*?\.\w{2,3}[\/\?]\S*/ ;
+
+    getUrl.on("paste", function(e) {
         $.ajax({
             contentType: "application/x-www-form-urlencoded",
             beforeSend: function() {

+ 30 - 0
src/Chamilo/CoreBundle/Entity/Message.php

@@ -75,6 +75,13 @@ class Message
      */
     private $updateDate;
 
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="votes", type="integer", nullable=true)
+     */
+    private $votes;
+
     /**
      * @var integer
      *
@@ -302,4 +309,27 @@ class Message
     {
         return $this->id;
     }
+
+    /**
+     * Set votes
+     *
+     * @param integer $votes
+     * @return integer
+     */
+    public function setVotes($votes)
+    {
+        $this->votes = $votes;
+
+        return $this;
+    }
+
+    /**
+     * Get votes
+     *
+     * @return integer
+     */
+    public function getVotes()
+    {
+        return $this->votes;
+    }
 }