| 1 | {capture assign='pageTitle'}{$object->getTitle()} - {lang}wcf.edit.versions{/lang}{/capture} |
| 2 | |
| 3 | {capture assign='contentTitle'}{lang}wcf.edit.versions{/lang}: {$object->getTitle()}{/capture} |
| 4 | |
| 5 | {capture assign='contentHeaderNavigation'}<li><a href="{$object->getLink()}" class="button buttonPrimary">{icon name='arrow-right'} <span>{lang}wcf.edit.button.goToContent{/lang}</span></a></li>{/capture} |
| 6 | |
| 7 | {capture assign='contentInteractionButtons'} |
| 8 | <a href="{link controller='EditHistory' objectType=$objectType->objectType objectID=$objectID newID=$newID oldID=$oldID mode='html'}{/link}" class="contentInteractionButton button small{if $mode == 'html'} active{/if}">{icon name='align-left' type='solid'} <span>{lang}wcf.edit.mode.html{/lang}</span></a> |
| 9 | <a href="{link controller='EditHistory' objectType=$objectType->objectType objectID=$objectID newID=$newID oldID=$oldID mode='raw'}{/link}" class="contentInteractionButton button small{if $mode == 'raw'} active{/if}">{icon name='code' type='solid'} <span>{lang}wcf.edit.mode.raw{/lang}</span></a> |
| 10 | {/capture} |
| 11 | |
| 12 | {include file='header'} |
| 13 | |
| 14 | {if $mode == 'html'} |
| 15 | <template id="oldMessage"><div>{unsafe:$old->getMessage()}<div></template> |
| 16 | <template id="newMessage"><div>{unsafe:$new->getMessage()}<div></template> |
| 17 | <div class="section editHistoryDiff"> |
| 18 | <div class="htmlContent" id="results"></div> |
| 19 | </div> |
| 20 | <script data-relocate="true"> |
| 21 | require(['@woltlab/visual-dom-diff'], ({ visualDomDiff }) => { |
| 22 | const fragment = visualDomDiff(document.getElementById('oldMessage').content.cloneNode(true).firstChild, document.getElementById('newMessage').content.cloneNode(true).firstChild); |
| 23 | document.getElementById('results').append(fragment); |
| 24 | }); |
| 25 | </script> |
| 26 | {elseif $diff} |
| 27 | <div class="section editHistoryDiff"> |
| 28 | <table class="table"> |
| 29 | <thead> |
| 30 | <tr> |
| 31 | <th>{lang}wcf.edit.headline.old{/lang}</th> |
| 32 | <th>{lang}wcf.edit.headline.new{/lang}</th> |
| 33 | </tr> |
| 34 | </thead> |
| 35 | |
| 36 | <tbody> |
| 37 | {assign var='prevType' value=''} |
| 38 | {assign var='colspan' value=false} |
| 39 | {foreach from=$diff item='line'} |
| 40 | {if $line[0] !== $prevType} |
| 41 | {if $prevType !== ''}</td>{/if} |
| 42 | |
| 43 | {* unmodified, after deletion needs a "fake" insertion *} |
| 44 | {if $line[0] === ' ' && $prevType === '-'}<td></td>{/if} |
| 45 | |
| 46 | {* unmodified and deleted start a new container *} |
| 47 | {if $prevType !== '' && ($line[0] === ' ' || $line[0] === '-')}</tr>{/if} |
| 48 | |
| 49 | {* adding, without deleting needs a "fake" deletion *} |
| 50 | {if $line[0] === '+' && $prevType !== '-'} |
| 51 | {if $prevType !== ''}</tr>{/if} |
| 52 | <tr> |
| 53 | <td></td> |
| 54 | {/if} |
| 55 | |
| 56 | {if $line[0] === ' '} |
| 57 | <tr> |
| 58 | {assign var='colspan' value=true} |
| 59 | {/if} |
| 60 | {if $line[0] === '-'} |
| 61 | <tr> |
| 62 | {/if} |
| 63 | <td{if $line[0] === '+'} class="diffAdded"{elseif $line[0] === '-'} class="diffRemoved"{/if}{if $colspan} colspan="2"{assign var='colspan' value=false}{/if}> |
| 64 | {/if} |
| 65 | {if $line[0] === ' '}{@$line[1]}<br>{/if} |
| 66 | {if $line[0] === '-'}{@$line[1]}<br>{/if} |
| 67 | {if $line[0] === '+'}{@$line[1]}<br>{/if} |
| 68 | {assign var='prevType' value=$line[0]} |
| 69 | {/foreach} |
| 70 | </tbody> |
| 71 | </table> |
| 72 | </div> |
| 73 | {/if} |
| 74 | |
| 75 | <form action="{link controller='EditHistory'}{/link}" method="post"> |
| 76 | <section class="section tabularBox editHistoryVersionList"> |
| 77 | {assign var='versionCount' value=$objects|count} |
| 78 | <h2 class="sectionTitle"> |
| 79 | {lang}wcf.edit.versions{/lang} <span class="badge">{#$versionCount+1}</span> |
| 80 | </h2> |
| 81 | |
| 82 | <table class="table"> |
| 83 | <thead> |
| 84 | <tr> |
| 85 | <th class="columnID columnEditID" colspan="2">{lang}wcf.edit.version{/lang}</th> |
| 86 | <th class="columnText columnUser">{lang}wcf.user.username{/lang}</th> |
| 87 | <th class="columnText columnEditReason">{lang}wcf.edit.reason{/lang}</th> |
| 88 | <th class="columnDate columnTime">{lang}wcf.edit.time{/lang}</th> |
| 89 | |
| 90 | {event name='columnHeads'} |
| 91 | </tr> |
| 92 | </thead> |
| 93 | |
| 94 | <tbody> |
| 95 | <tr> |
| 96 | <td class="columnIcon"> |
| 97 | <span class="disabled"> |
| 98 | {icon name='rotate-left'} |
| 99 | </span> |
| 100 | <input type="radio" name="oldID" value="current"{if $oldID === 'current'} checked{/if}> <input type="radio" name="newID" value="current"{if $newID === 'current'} checked{/if}> |
| 101 | {event name='rowButtons'} |
| 102 | </td> |
| 103 | <td class="columnID"><strong>{lang}wcf.edit.currentVersion{/lang}</strong></td> |
| 104 | <td class="columnText columnUser"><a href="{link controller='User' id=$object->getUserID() title=$object->getUsername()}{/link}">{$object->getUsername()}</a></td> |
| 105 | <td class="columnText columnEditReason">{$object->getEditReason()}</td> |
| 106 | <td class="columnDate columnTime">{@$object->getTime()|time}</td> |
| 107 | |
| 108 | {event name='columns'} |
| 109 | </tr> |
| 110 | {foreach from=$objects item=edit name=edit} |
| 111 | <tr class="jsEditRow"> |
| 112 | <td class="columnIcon"> |
| 113 | <button type="button" class="jsRevertButton jsTooltip" title="{lang}wcf.edit.revert{/lang}" data-object-id="{@$edit->entryID}" data-confirm-message="{lang __encode=true}wcf.edit.revert.sure{/lang}"> |
| 114 | {icon name='rotate-left'} |
| 115 | </button> |
| 116 | <input type="radio" name="oldID" value="{$edit->entryID}"{if $oldID == $edit->entryID} checked{/if}> <input type="radio" name="newID" value="{$edit->entryID}"{if $newID == $edit->entryID} checked{/if}> |
| 117 | {event name='rowButtons'} |
| 118 | </td> |
| 119 | <td class="columnID">{#($tpl[foreach][edit][total] - $tpl[foreach][edit][iteration] + 1)}</td> |
| 120 | <td class="columnText columnUser"><a href="{link controller='User' id=$edit->userID title=$edit->username}{/link}">{$edit->username}</a></td> |
| 121 | <td class="columnText columnEditReason">{$edit->editReason}</td> |
| 122 | <td class="columnDate columnTime">{@$edit->time|time}</td> |
| 123 | |
| 124 | {event name='columns'} |
| 125 | </tr> |
| 126 | {/foreach} |
| 127 | </tbody> |
| 128 | <script data-relocate="true"> |
| 129 | $(function () { |
| 130 | new WCF.Message.EditHistory($('input[name=oldID]'), $('input[name=newID]'), '.jsEditRow'); |
| 131 | }); |
| 132 | </script> |
| 133 | </table> |
| 134 | </section> |
| 135 | |
| 136 | <div class="formSubmit"> |
| 137 | <input type="hidden" name="objectID" value="{$objectID}"> |
| 138 | <input type="hidden" name="objectType" value="{$objectType->objectType}"> |
| 139 | <input type="hidden" name="mode" value="{$mode}"> |
| 140 | <button type="submit" class="button buttonPrimary">{lang}wcf.edit.button.compare{/lang}</button> |
| 141 | </div> |
| 142 | </form> |
| 143 | |
| 144 | {include file='footer'} |