Dotclear

Changeset 3878:fd5264175804


Ignore:
Timestamp:
09/17/18 16:46:35 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Harmonize scripts used to display entries/comments/trackbacks content in lists - Spam content is displayed as HTML code only, meta key may be used to display other content HTML code (meta key = cmd key on MacOS, windows key on Windows, ...) - Server errors are now basically reported (more info in console log, as timeout, offline, …) to the user

Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_comments.js

    r3706 r3878  
    22'use strict'; 
    33 
    4 dotclear.viewCommentContent = function(line, action) { 
     4dotclear.viewCommentContent = function(line, action, e) { 
    55  action = action || 'toggle'; 
     6  if ($(line).attr('id') == undefined) { 
     7    return; 
     8  } 
     9 
    610  var commentId = $(line).attr('id').substr(1); 
    711  var tr = document.getElementById('ce' + commentId); 
     12  var spam = (e.metaKey || $(line).hasClass('sts-junk')); 
    813 
    9   if (!tr && (action == 'toggle' || action == 'open')) { 
    10     tr = document.createElement('tr'); 
    11     tr.id = 'ce' + commentId; 
    12     var td = document.createElement('td'); 
    13     td.colSpan = 6; 
    14     td.className = 'expand'; 
    15     tr.appendChild(td); 
    16  
    17     // Get comment content 
    18     $.get('services.php', { 
    19       f: 'getCommentById', 
    20       id: commentId 
    21     }, function(data) { 
    22       var rsp = $(data).children('rsp')[0]; 
    23  
    24       if (rsp.attributes[0].value == 'ok') { 
    25         var comment = $(rsp).find('comment_display_content').text(); 
    26  
    27         if (comment) { 
    28           $(td).append(comment); 
    29           var comment_email = $(rsp).find('comment_email').text(); 
    30           var comment_site = $(rsp).find('comment_site').text(); 
    31           var comment_ip = $(rsp).find('comment_ip').text(); 
    32           var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); 
    33  
    34           $(td).append('<p><strong>' + dotclear.msg.website + 
    35             '</strong> ' + comment_site + '<br />' + 
    36             '<strong>' + dotclear.msg.email + '</strong> ' + comment_email + '<br />' + 
    37             '<strong>' + dotclear.msg.ip_address + 
    38             '</strong> <a href="comments.php?ip=' + comment_ip + '">' + comment_ip + '</a>' + 
    39             '<br />' + comment_spam_disp + '</p>'); 
    40         } 
     14  if (!tr) { 
     15    // Get comment content if possible 
     16    dotclear.getCommentContent(commentId, function(content) { 
     17      if (content) { 
     18        // Content found 
     19        tr = document.createElement('tr'); 
     20        tr.id = 'ce' + commentId; 
     21        var td = document.createElement('td'); 
     22        td.colSpan = $(line).children('td').length; 
     23        td.className = 'expand'; 
     24        tr.appendChild(td); 
     25        $(td).append(content); 
     26        $(line).addClass('expand'); 
     27        line.parentNode.insertBefore(tr, line.nextSibling); 
    4128      } else { 
    42         window.alert($(rsp).find('message').text()); 
     29        // No content, content not found or server error 
     30        $(line).removeClass('expand'); 
    4331      } 
     32    }, { 
     33      clean: spam 
    4434    }); 
    45  
     35  } else { 
     36    $(tr).toggle(); 
    4637    $(line).toggleClass('expand'); 
    47     line.parentNode.insertBefore(tr, line.nextSibling); 
    48   } else if (tr && tr.style.display == 'none' && (action == 'toggle' || action == 'open')) { 
    49     $(tr).css('display', 'table-row'); 
    50     $(line).addClass('expand'); 
    51   } else if (tr && tr.style.display != 'none' && (action == 'toggle' || action == 'close')) { 
    52     $(tr).css('display', 'none'); 
    53     $(line).removeClass('expand'); 
    5438  } 
    5539}; 
  • admin/js/_post.js

    r3706 r3878  
    22'use strict'; 
    33 
    4 dotclear.viewCommentContent = function(line) { 
     4dotclear.viewCommentContent = function(line, action, e) { 
     5  action = action || 'toggle'; 
     6  if ($(line).attr('id') == undefined) { 
     7    return; 
     8  } 
     9 
    510  var commentId = $(line).attr('id').substr(1); 
    611  var tr = document.getElementById('ce' + commentId); 
     12  var spam = (e.metaKey || $(line).hasClass('sts-junk')); 
    713 
    814  if (!tr) { 
    9     tr = document.createElement('tr'); 
    10     tr.id = 'ce' + commentId; 
    11     var td = document.createElement('td'); 
    12     td.colSpan = 6; 
    13     td.className = 'expand'; 
    14     tr.appendChild(td); 
    15  
    1615    // Get comment content 
    17     $.get('services.php', { 
    18       f: 'getCommentById', 
    19       id: commentId 
    20     }, function(data) { 
    21       var rsp = $(data).children('rsp')[0]; 
    22  
    23       if (rsp.attributes[0].value == 'ok') { 
    24         var comment = $(rsp).find('comment_display_content').text(); 
    25  
    26         if (comment) { 
    27           $(td).append(comment); 
    28           var comment_email = $(rsp).find('comment_email').text(); 
    29           var comment_site = $(rsp).find('comment_site').text(); 
    30           //          var comment_ip = $(rsp).find('comment_ip').text(); 
    31           var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); 
    32  
    33           $(td).append('<p><strong>' + dotclear.msg.website + 
    34             '</strong> ' + comment_site + '<br />' + 
    35             '<strong>' + dotclear.msg.email + '</strong> ' + 
    36             comment_email + '<br />' + comment_spam_disp + '</p>'); 
    37         } 
     16    dotclear.getCommentContent(commentId, function(content) { 
     17      if (content) { 
     18        // Content found 
     19        tr = document.createElement('tr'); 
     20        tr.id = 'ce' + commentId; 
     21        var td = document.createElement('td'); 
     22        td.colSpan = $(line).children('td').length; 
     23        td.className = 'expand'; 
     24        tr.appendChild(td); 
     25        $(td).append(content); 
     26        $(line).addClass('expand'); 
     27        line.parentNode.insertBefore(tr, line.nextSibling); 
    3828      } else { 
    39         window.alert($(rsp).find('message').text()); 
     29        // No content, content not found or server error 
     30        $(line).removeClass('expand'); 
    4031      } 
     32    }, { 
     33      ip: false, 
     34      clean: spam 
    4135    }); 
    42  
    43     $(line).toggleClass('expand'); 
    44     line.parentNode.insertBefore(tr, line.nextSibling); 
    45   } else if (tr.style.display == 'none') { 
    46     $(tr).toggle(); 
    47     $(line).toggleClass('expand'); 
    4836  } else { 
    4937    $(tr).toggle(); 
     
    164152  $('#comments').onetabload(function() { 
    165153    $.expandContent({ 
     154      line: $('#form-comments .comments-list tr:not(.line)'), 
    166155      lines: $('#form-comments .comments-list tr.line'), 
    167156      callback: dotclear.viewCommentContent 
     
    176165  $('#trackbacks').onetabload(function() { 
    177166    $.expandContent({ 
     167      line: $('#form-trackbacks .comments-list tr:not(.line)'), 
    178168      lines: $('#form-trackbacks .comments-list tr.line'), 
    179169      callback: dotclear.viewCommentContent 
  • admin/js/_posts_list.js

    r3706 r3878  
    22'use strict'; 
    33 
    4 dotclear.viewPostContent = function(line, action) { 
     4dotclear.viewPostContent = function(line, action, e) { 
    55  action = action || 'toggle'; 
     6  if ($(line).attr('id') == undefined) { 
     7    return; 
     8  } 
     9 
    610  var postId = $(line).attr('id').substr(1); 
    711  var tr = document.getElementById('pe' + postId); 
    812 
    9   if (!tr && (action == 'toggle' || action == 'open')) { 
    10     tr = document.createElement('tr'); 
    11     tr.id = 'pe' + postId; 
    12     var td = document.createElement('td'); 
    13     td.colSpan = 8; 
    14     td.className = 'expand'; 
    15     tr.appendChild(td); 
    16  
    17     // Get post content 
    18     $.get('services.php', { 
    19       f: 'getPostById', 
    20       id: postId, 
    21       post_type: '' 
    22     }, function(data) { 
    23       var rsp = $(data).children('rsp')[0]; 
    24  
    25       if (rsp.attributes[0].value == 'ok') { 
    26         var post = $(rsp).find('post_display_content').text(); 
    27         var post_excerpt = $(rsp).find('post_display_excerpt').text(); 
    28         var res = ''; 
    29  
    30         if (post) { 
    31           if (post_excerpt) { 
    32             res += post_excerpt + '<hr />'; 
    33           } 
    34           res += post; 
    35           $(td).append(res); 
    36         } 
     13  if (!tr) { 
     14    // Get post content if possible 
     15    dotclear.getEntryContent(postId, function(content) { 
     16      if (content) { 
     17        // Content found 
     18        tr = document.createElement('tr'); 
     19        tr.id = 'pe' + postId; 
     20        var td = document.createElement('td'); 
     21        td.colSpan = $(line).children('td').length; 
     22        td.className = 'expand'; 
     23        tr.appendChild(td); 
     24        $(td).append(content); 
     25        $(line).addClass('expand'); 
     26        line.parentNode.insertBefore(tr, line.nextSibling); 
    3727      } else { 
    38         window.alert($(rsp).find('message').text()); 
     28        $(line).toggleClass('expand'); 
    3929      } 
     30    }, { 
     31      clean: (e.metaKey) 
    4032    }); 
    41  
    42     $(line).addClass('expand'); 
    43     line.parentNode.insertBefore(tr, line.nextSibling); 
    44   } else if (tr && tr.style.display == 'none' && (action == 'toggle' || action == 'open')) { 
    45     $(tr).css('display', 'table-row'); 
    46     $(line).addClass('expand'); 
    47   } else if (tr && tr.style.display != 'none' && (action == 'toggle' || action == 'close')) { 
    48     $(tr).css('display', 'none'); 
    49     $(line).removeClass('expand'); 
     33  } else { 
     34    $(tr).toggle(); 
     35    $(line).toggleClass('expand'); 
    5036  } 
    5137}; 
  • admin/js/common.js

    r3870 r3878  
    173173    $('<button type="button" class="details-cmd" aria-label="' + dotclear.img_plus_alt + '">' + dotclear.img_plus_txt + '</button>').click(function(e) { 
    174174      toggleArrow(this); 
    175       callback(line); 
     175      callback(line, '', e); 
    176176      e.preventDefault(); 
    177177    }).prependTo($(line).children().get(0)); // first td 
     
    182182      lines.each(function() { 
    183183        toggleArrow(this.firstChild.firstChild, action); 
    184         callback(this, action); 
     184        callback(this, action, e); 
    185185      }); 
    186186      e.preventDefault(); 
  • admin/post.php

    r3874 r3878  
    498498        $comment_url = $core->adminurl->get("admin.comment", ['id' => $rs->comment_id]); 
    499499 
    500         $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     500        $img       = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     501        $sts_class = ''; 
    501502        switch ($rs->comment_status) { 
    502503            case 1: 
    503504                $img_status = sprintf($img, __('Published'), 'check-on.png'); 
     505                $sts_class  = 'sts-online'; 
    504506                break; 
    505507            case 0: 
    506508                $img_status = sprintf($img, __('Unpublished'), 'check-off.png'); 
     509                $sts_class  = 'sts-offline'; 
    507510                break; 
    508511            case -1: 
    509512                $img_status = sprintf($img, __('Pending'), 'check-wrn.png'); 
     513                $sts_class  = 'sts-pending'; 
    510514                break; 
    511515            case -2: 
    512516                $img_status = sprintf($img, __('Junk'), 'junk.png'); 
     517                $sts_class  = 'sts-junk'; 
    513518                break; 
    514519        } 
    515520 
    516521        echo 
    517         '<tr class="line' . ($rs->comment_status != 1 ? ' offline' : '') . '"' . 
     522        '<tr class="line ' . ($rs->comment_status != 1 ? ' offline ' : '') . $sts_class . '"' . 
    518523        ' id="c' . $rs->comment_id . '">' . 
    519524 
  • inc/admin/lib.dc.page.php

    r3874 r3878  
    765765        self::jsLoad('js/jquery/jquery.biscuit.js') . 
    766766        self::jsLoad('js/common.js') . 
     767        self::jsLoad('js/services.js') . 
    767768        self::jsLoad('js/prelude.js') . 
    768769 
  • plugins/pages/js/list.js

    r3709 r3878  
    22'use strict'; 
    33 
    4 dotclear.viewPostContent = function(line, action) { 
     4dotclear.viewPostContent = function(line, action, e) { 
    55  action = action || 'toggle'; 
    66  if ($(line).attr('id') == undefined) { 
     
    1111  var tr = document.getElementById('pe' + postId); 
    1212 
    13   if (!tr && (action == 'toggle' || action == 'open')) { 
    14     tr = document.createElement('tr'); 
    15     tr.id = 'pe' + postId; 
    16     var td = document.createElement('td'); 
    17     td.colSpan = 8; 
    18     td.className = 'expand'; 
    19     tr.appendChild(td); 
    20  
    21     // Get post content 
    22     $.get('services.php', { 
    23       f: 'getPostById', 
    24       id: postId, 
    25       post_type: '' 
    26     }, function(data) { 
    27       var rsp = $(data).children('rsp')[0]; 
    28  
    29       if (rsp.attributes[0].value == 'ok') { 
    30         var post = $(rsp).find('post_display_content').text(); 
    31         var post_excerpt = $(rsp).find('post_display_excerpt').text(); 
    32         var res = ''; 
    33  
    34         if (post) { 
    35           if (post_excerpt) { 
    36             res += post_excerpt + '<hr />'; 
    37           } 
    38           res += post; 
    39           $(td).append(res); 
    40         } 
     13  if (!tr) { 
     14    // Get post content if possible 
     15    dotclear.getEntryContent(postId, function(content) { 
     16      if (content) { 
     17        // Content found 
     18        tr = document.createElement('tr'); 
     19        tr.id = 'pe' + postId; 
     20        var td = document.createElement('td'); 
     21        td.colSpan = $(line).children('td').length; 
     22        td.className = 'expand'; 
     23        tr.appendChild(td); 
     24        $(td).append(content); 
     25        $(line).addClass('expand'); 
     26        line.parentNode.insertBefore(tr, line.nextSibling); 
    4127      } else { 
    42         window.alert($(rsp).find('message').text()); 
     28        $(line).toggleClass('expand'); 
    4329      } 
     30    }, { 
     31      type: 'page', 
     32      clean: (e.metaKey) 
    4433    }); 
    45  
    46     $(line).addClass('expand'); 
    47     line.parentNode.insertBefore(tr, line.nextSibling); 
    48   } else if (tr && tr.style.display == 'none' && (action == 'toggle' || action == 'open')) { 
    49     $(tr).css('display', 'table-row'); 
    50     $(line).addClass('expand'); 
    51   } else if (tr && tr.style.display != 'none' && (action == 'toggle' || action == 'close')) { 
    52     $(tr).css('display', 'none'); 
    53     $(line).removeClass('expand'); 
     34  } else { 
     35    $(tr).toggle(); 
     36    $(line).toggleClass('expand'); 
    5437  } 
    5538}; 
  • plugins/pages/page.php

    r3874 r3878  
    299299dcPage::jsModal() . 
    300300dcPage::jsLoad('js/_post.js') . 
     301dcPage::jsLoad(dcPage::getPF('pages/js/page.js')) . 
    301302$admin_post_behavior . 
    302303dcPage::jsConfirmClose('entry-form', 'comment-form') . 
     
    731732        $comment_url = $core->adminurl->get('admin.comment', ['id' => $rs->comment_id]); 
    732733 
    733         $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     734        $img       = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     735        $sts_class = ''; 
    734736        switch ($rs->comment_status) { 
    735737            case 1: 
    736738                $img_status = sprintf($img, __('Published'), 'check-on.png'); 
     739                $sts_class  = 'sts-online'; 
    737740                break; 
    738741            case 0: 
    739742                $img_status = sprintf($img, __('Unpublished'), 'check-off.png'); 
     743                $sts_class  = 'sts-offline'; 
    740744                break; 
    741745            case -1: 
    742746                $img_status = sprintf($img, __('Pending'), 'check-wrn.png'); 
     747                $sts_class  = 'sts-pending'; 
    743748                break; 
    744749            case -2: 
    745750                $img_status = sprintf($img, __('Junk'), 'junk.png'); 
     751                $sts_class  = 'sts-junk'; 
    746752                break; 
    747753        } 
    748754 
    749755        echo 
    750         '<tr class="line' . ($rs->comment_status != 1 ? ' offline' : '') . '"' . 
     756        '<tr class="line ' . ($rs->comment_status != 1 ? ' offline ' : '') . $sts_class . '"' . 
    751757        ' id="c' . $rs->comment_id . '">' . 
    752758 
Note: See TracChangeset for help on using the changeset viewer.

Sites map