Making WordPress.org

Changeset 2025


Ignore:
Timestamp:
11/01/2015 09:19:58 PM (11 years ago)
Author:
ocean90
Message:

Slack: Fix whitespace and indentation in the comment handler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/common/includes/slack/trac/comment-handler.php

    r1210 r2025  
    3030        function process_message() {
    3131                $lines = array_map( 'rtrim', $this->lines );
    32                
     32
    3333                // Trim off headers.
    3434                while ( $lines && '' !== current( $lines ) ) {
     
    3939                                list( $ticket_url, $comment_id ) = explode( '#comment:', $comment_url );
    4040                                list( $trac_url, $ticket_id ) = explode( '/ticket/', $ticket_url );
    41        
     41
    4242                                $trac = Trac::get( $trac_url );
    4343                                if ( ! $trac ) {
    4444                                        return false;
    4545                                }
    46                         } elseif ( 0 === strpos( $line, 'Content-Transfer-Encoding: base64' ) ) {
    47                                 $base64 = true;
     46                        } elseif ( 0 === strpos( $line, 'Content-Transfer-Encoding: base64' ) ) {
     47                                $base64 = true;
    4848                        }
    4949                }
    5050
    51                 if ( ! empty( $base64 ) ) {
    52                         $lines = explode( "\n", base64_decode( implode( "\n", $lines ) ) );
    53                 }
     51                if ( ! empty( $base64 ) ) {
     52                        $lines = explode( "\n", base64_decode( implode( "\n", $lines ) ) );
     53                }
    5454
    5555                // Remove empty line between headers and body.
    5656                array_shift( $lines );
    57                
     57
    5858                $title = '';
    5959                while ( $lines && 0 !== strpos( current( $lines ), '------' ) ) {
     
    8080                // Remove bottom border of table.
    8181                array_shift( $lines );
    82                
     82
    8383                // Remove empty line if present. (It is when it's a comment without changes.)
    8484                if ( current( $lines ) === '' ) {
    8585                        array_shift( $lines );
    8686                }
    87                
     87
    8888                // Remove Trac email footer.
    8989                while ( $lines && end( $lines ) !== '--' ) {
     
    9494                // Remove empty line before footer.
    9595                array_pop( $lines );
    96                
     96
    9797                preg_match( '/^(Comment|Changes) \(by (.*)\):$/', array_shift( $lines ), $matches );
    9898                $has_changes = $matches[1] === 'Changes';
     
    101101                // Remove blank line after 'Comment|Changes (by author):'
    102102                array_shift( $lines );
    103                
     103
    104104                $changes = $comment = array();
    105105                if ( $has_changes ) {
     
    108108                        }
    109109                }
    110                
     110
    111111                // Remove blank lines (should be two if it had changes).
    112112                while ( $lines && '' === current( $lines ) ) {
    113113                        array_shift( $lines );
    114114                }
    115                
     115
    116116                // Next line should start with 'Comment' if there is one.
    117117                if ( $has_changes && 0 === strpos( current( $lines ), 'Comment' ) ) {
     
    151151                $this->send->set_icon( $this->trac->get_icon() );
    152152                $this->send->set_username( $this->trac->get_ticket_username() );
    153                        
     153
    154154                $comment         = $this->format_comment_for_slack();
    155155                $main_attachment = $this->changes ? implode( "\n", $this->changes ) : $comment;
     
    164164                );
    165165
    166                 // Ensure the comment uses a darker gray color, even when alone.       
     166                // Ensure the comment uses a darker gray color, even when alone.
    167167                if ( ! $this->changes ) {
    168168                        $attachment['color'] = '#999';
Note: See TracChangeset for help on using the changeset viewer.