Improve generated HTML of edit history diffs
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 30 Mar 2017 13:14:52 +0000 (15:14 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 30 Mar 2017 13:14:52 +0000 (15:14 +0200)
com.woltlab.wcf/templates/editHistory.tpl
wcfsetup/install/files/acp/templates/versionTrackerList.tpl
wcfsetup/install/files/lib/page/EditHistoryPage.class.php

index 697a8f8f3f9d13f63473c2e9f8494cdfd7f21405..0f956f07584cfd1ee8c7f21b7ecad736b54066b7 100644 (file)
                </thead>
                
                <tbody>
-                       <tr><td>{*
-*}{assign var='prevType' value=''}{*
-*}{assign var='colspan' value=false}{*
-*}{foreach from=$diff item='line'}{*
-*}{if $line[0] !== $prevType}{*
-       *}</td>
-       
-       {* unmodified, after deletion needs a "fake" insertion *}
-       {if $line[0] === ' ' && $prevType === '-'}<td></td>{/if}
-       
-       {* unmodified and deleted start a new container *}
-       {if $line[0] === ' ' || $line[0] === '-'}</tr>{/if}
-       
-       {* adding, without deleting needs a "fake" deletion *}
-       {if $line[0] === '+' && $prevType !== '-'}
-               </tr>
-               <tr>
-                       {assign var='colspan' value=true}
-       {/if}
-       
-       {if $line[0] === ' '}
-               <tr>
-               {assign var='colspan' value=true}
-       {/if}
-       {if $line[0] === '-'}
-               <tr>
-       {/if}
-       <td{if $line[0] === '+'} class="diffAdded"{elseif $line[0] === '-'} class="diffRemoved"{/if}{if $colspan} colspan="2"{assign var='colspan' value=false}{/if}>
-{/if}
-{if $line[0] === ' '}{@$line[1]}<br>{/if}
-{if $line[0] === '-'}{@$line[1]}<br>{/if}
-{if $line[0] === '+'}{@$line[1]}<br>{/if}
-{assign var='prevType' value=$line[0]}
-{/foreach}
-</td></tr></table>
+                       {assign var='prevType' value=''}
+                       {assign var='colspan' value=false}
+                       {foreach from=$diff item='line'}
+                               {if $line[0] !== $prevType}
+                                       {if $prevType !== ''}</td>{/if}
+                                       
+                                       {* unmodified, after deletion needs a "fake" insertion *}
+                                       {if $line[0] === ' ' && $prevType === '-'}<td></td>{/if}
+                                       
+                                       {* unmodified and deleted start a new container *}
+                                       {if $prevType !== '' && ($line[0] === ' ' || $line[0] === '-')}</tr>{/if}
+                                       
+                                       {* adding, without deleting needs a "fake" deletion *}
+                                       {if $line[0] === '+' && $prevType !== '-'}
+                                               {if $prevType !== ''}</tr>{/if}
+                                               <tr>
+                                                       <td></td>
+                                       {/if}
+                                       
+                                       {if $line[0] === ' '}
+                                               <tr>
+                                               {assign var='colspan' value=true}
+                                       {/if}
+                                       {if $line[0] === '-'}
+                                               <tr>
+                                       {/if}
+                                       <td{if $line[0] === '+'} class="diffAdded"{elseif $line[0] === '-'} class="diffRemoved"{/if}{if $colspan} colspan="2"{assign var='colspan' value=false}{/if}>
+                               {/if}
+                               {if $line[0] === ' '}{@$line[1]}<br>{/if}
+                               {if $line[0] === '-'}{@$line[1]}<br>{/if}
+                               {if $line[0] === '+'}{@$line[1]}<br>{/if}
+                               {assign var='prevType' value=$line[0]}
+                       {/foreach}
+               </tbody>
+       </table>
+</div>
 {/if}
 
 <form action="{link controller='EditHistory'}{/link}" method="post">
index ce56e34009accdf39738826fe9c0405ae6fb4141..c9f00acdaf6c14896d7979e91a469016755c73b9 100644 (file)
                </thead>
                
                <tbody>
-{foreach from=$properties key=property item=diff}
+               {foreach from=$properties key=property item=diff}
                        <tr>
                                <td class="diffSection" colspan="2">{lang}wcf.edit.headline.comparison{/lang}: {$objectTypeProcessor->getPropertyLabel($property)}</td>
                        </tr>
        
-                       <tr><td>{*
-*}{assign var='prevType' value=''}{*
-*}{assign var='colspan' value=false}{*
-*}{foreach from=$diff item='line'}{*
-*}{if $line[0] !== $prevType}{*
-       *}</td>
-       
-       {* unmodified, after deletion needs a "fake" insertion *}
-       {if $line[0] === ' ' && $prevType === '-'}<td></td>{/if}
-       
-       {* unmodified and deleted start a new container *}
-       {if $line[0] === ' ' || $line[0] === '-'}</tr>{/if}
-       
-       {* adding, without deleting needs a "fake" deletion *}
-       {if $line[0] === '+' && $prevType !== '-'}
-               </tr>
-               <tr>
-                       {assign var='colspan' value=true}
-       {/if}
-       
-       {if $line[0] === ' '}
-               <tr>
-               {assign var='colspan' value=true}
-       {/if}
-       {if $line[0] === '-'}
-               <tr>
-       {/if}
-       <td{if $line[0] === '+'} class="diffAdded"{elseif $line[0] === '-'} class="diffRemoved"{/if}{if $colspan} colspan="2"{assign var='colspan' value=false}{/if}>
-{/if}
-{if $line[0] === ' '}{@$line[1]}<br>{/if}
-{if $line[0] === '-'}{@$line[1]}<br>{/if}
-{if $line[0] === '+'}{@$line[1]}<br>{/if}
-{assign var='prevType' value=$line[0]}
-{/foreach}
-{/foreach}
-</td></tr></tbody></table>
-
+                       {assign var='prevType' value=''}
+                       {assign var='colspan' value=false}
+                       {foreach from=$diff item='line'}
+                               {if $line[0] !== $prevType}
+                                       {if $prevType !== ''}</td>{/if}
+                                       
+                                       {* unmodified, after deletion needs a "fake" insertion *}
+                                       {if $line[0] === ' ' && $prevType === '-'}<td></td>{/if}
+                                       
+                                       {* unmodified and deleted start a new container *}
+                                       {if $prevType !== '' && ($line[0] === ' ' || $line[0] === '-')}</tr>{/if}
+                                       
+                                       {* adding, without deleting needs a "fake" deletion *}
+                                       {if $line[0] === '+' && $prevType !== '-'}
+                                               {if $prevType !== ''}</tr>{/if}
+                                               <tr>
+                                                       <td></td>
+                                       {/if}
+                                       
+                                       {if $line[0] === ' '}
+                                               <tr>
+                                               {assign var='colspan' value=true}
+                                       {/if}
+                                       {if $line[0] === '-'}
+                                               <tr>
+                                       {/if}
+                                       <td{if $line[0] === '+'} class="diffAdded"{elseif $line[0] === '-'} class="diffRemoved"{/if}{if $colspan} colspan="2"{assign var='colspan' value=false}{/if}>
+                               {/if}
+                               {if $line[0] === ' '}{@$line[1]}<br>{/if}
+                               {if $line[0] === '-'}{@$line[1]}<br>{/if}
+                               {if $line[0] === '+'}{@$line[1]}<br>{/if}
+                               {assign var='prevType' value=$line[0]}
+                       {/foreach}
+               {/foreach}
+               </tbody>
+       </table>
 </div>
 {if $languageID}</div>{/if}
 {/foreach}
index 9920425f3aa47e35b6389e458d43eee9e7a47c41..8e704b8adf2a16f9402a350b134ec12c07f0728d 100644 (file)
@@ -159,8 +159,8 @@ class EditHistoryPage extends AbstractPage {
                
                // valid IDs were given, calculate diff
                if ($this->old && $this->new) {
-                       $a = explode("\n", StringUtil::unifyNewlines($this->old->getMessage()));
-                       $b = explode("\n", StringUtil::unifyNewlines($this->new->getMessage()));
+                       $a = explode("\n", StringUtil::unifyNewlines(StringUtil::trim($this->old->getMessage())));
+                       $b = explode("\n", StringUtil::unifyNewlines(StringUtil::trim($this->new->getMessage())));
                        $diff = new Diff($a, $b);
                        $this->diff = $diff->getRawDiff();