Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions redaxo/src/addons/structure/plugins/history/assets/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
this.currentFrame = $('#content-history-iframe-1', this.el);
this.targetFrame = $('#content-history-iframe-2', this.el);
this.submit = $('[data-history-layer="snap"]', this.el);
this.submitDraft = $('[data-history-layer="snap_draft"]', this.el);
this.cancel = $('[data-history-layer="cancel"]', this.el);

// fix layout for browsers having flexbox issues (Safari < 11 most notably)
Expand Down Expand Up @@ -255,6 +256,7 @@
this.selectPrev.on('click', $.proxy(this.onSelectPrev, this));
this.selectNext.on('click', $.proxy(this.onSelectNext, this));
this.submit.on('click', $.proxy(this.onSubmit, this));
this.submitDraft.on('click', $.proxy(this.onSubmitDraft, this));
this.cancel.on('click', $.proxy(this.onCancel, this));

if (this.sliderSelect) {
Expand Down Expand Up @@ -315,6 +317,33 @@
}));
},

/**
* on submit draft button toggle
*/
onSubmitDraft: function () {
var that = this;
var historyDate = that.dates.getCurrent().historyDate;
var confirmMsg = this.submitDraft.data('draft-warning');
if (confirmMsg && !window.confirm(confirmMsg)) {
return;
}
if (!historyDate) { // "Current live version" is selected: copy live → draft via version addon
that.remove();
var url = 'index.php?page=content/edit&article_id=' + that.articleId + '&clang=' + that.clangId + '&ctype=' + that.ctypeId + '&rex_version_func=copy_live_to_work';
debug.log('copy live to draft: ' + url);
$.pjax({url: url, container: '#rex-js-page-main-content', fragment: '#rex-js-page-main-content'});
return;
}
debug.log('submit draft: ' + historyDate);
$.when(this.snapDraftVersion(historyDate).then(function () {
that.remove();

// reload redaxo page
var url = 'index.php?page=content/edit&article_id=' + that.articleId + '&clang_id=' + that.clangId + '&ctype=' + that.ctypeId;
$.pjax({url: url, container: '#rex-js-page-main-content', fragment: '#rex-js-page-main-content'})
}));
},

/**
* on cancel button toggle
*/
Expand Down Expand Up @@ -450,6 +479,25 @@
}).fail(function (jqXHR, textStatus) {
debug.error('snap failure: ' + textStatus);
});
},

/**
* snap history to draft version
*
* @param date
* @returns {*}
*/
snapDraftVersion: function (date) {
var url = 'index.php?rex_history_function=snap_draft&history_article_id=' + this.articleId + '&history_clang_id=' + this.clangId + '&history_date=' + date;
debug.info('snap draft version: ' + url);
return $.ajax({
url: url,
context: document.body
}).done(function () {
debug.info('snap draft success');
}).fail(function (jqXHR, textStatus) {
debug.error('snap draft failure: ' + textStatus);
});
}
};

Expand Down
34 changes: 29 additions & 5 deletions redaxo/src/addons/structure/plugins/history/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

$historyDate = rex_request('rex_history_date', 'string');

rex_perm::register('history[read]', null, rex_perm::OPTIONS);
rex_perm::register('history[article_rollback]', null, rex_perm::OPTIONS);
if (rex_plugin::get('structure', 'version')->isAvailable()) {
rex_perm::register('history[article_draft_rollback]', null, rex_perm::OPTIONS);
}

if ('' != $historyDate) {
$historySession = rex_request('rex_history_session', 'string');
Expand Down Expand Up @@ -40,7 +44,7 @@
throw new rex_http_exception(new rex_exception('no permission'), rex_response::HTTP_UNAUTHORIZED);
}

if (!$user->hasPerm('history[article_rollback]')) {
if (!$user->hasPerm('history[read]')) {
throw new rex_http_exception(new rex_exception('no permission for the slice version'), rex_response::HTTP_FORBIDDEN);
}

Expand Down Expand Up @@ -105,33 +109,50 @@ static function (rex_extension_point $ep) {
},
);

if (rex::isBackend() && rex::getUser()?->hasPerm('history[article_rollback]')) {
if (rex::isBackend() && rex::getUser()?->hasPerm('history[read]')) {
rex_view::addCssFile($plugin->getAssetsUrl('noUiSlider/nouislider.css'));
rex_view::addJsFile($plugin->getAssetsUrl('noUiSlider/nouislider.js'), [rex_view::JS_IMMUTABLE => true]);
rex_view::addCssFile($plugin->getAssetsUrl('history.css'));
rex_view::addJsFile($plugin->getAssetsUrl('history.js'), [rex_view::JS_IMMUTABLE => true]);

switch (rex_request('rex_history_function', 'string')) {
case 'snap':
if (!rex::requireUser()->hasPerm('history[article_rollback]')) {
throw new rex_http_exception(new rex_exception('no permission for article rollback'), rex_response::HTTP_FORBIDDEN);
}
$articleId = rex_request('history_article_id', 'int');
$clangId = rex_request('history_clang_id', 'int');
$historyDate = rex_request('history_date', 'string');
rex_article_slice_history::restoreSnapshot($historyDate, $articleId, $clangId);

// no break
case 'snap_draft':
if ('snap_draft' === rex_request('rex_history_function', 'string')) {
if (!rex::requireUser()->hasPerm('history[article_draft_rollback]')) {
throw new rex_http_exception(new rex_exception('no permission for draft rollback'), rex_response::HTTP_FORBIDDEN);
}
$articleId = rex_request('history_article_id', 'int');
$clangId = rex_request('history_clang_id', 'int');
$historyDate = rex_request('history_date', 'string');
rex_article_slice_history::restoreDraftSnapshot($historyDate, $articleId, $clangId);
}

// no break
case 'layer':
$articleId = rex_request('history_article_id', 'int');
$clangId = rex_request('history_clang_id', 'int');
$versions = rex_article_slice_history::getSnapshots($articleId, $clangId);

$select1 = [];
$select1[] = '<option value="0" selected="selected" data-revision="0">' . $plugin->i18n('current_version') . '</option>';
if (rex_plugin::get('structure', 'version')->isAvailable()) {
$versionAvailable = rex_plugin::get('structure', 'version')->isAvailable();
$currentVersionLabel = $versionAvailable ? $plugin->i18n('current_live_version') : $plugin->i18n('current_version');
$select1[] = '<option value="0" selected="selected" data-revision="0">' . $currentVersionLabel . '</option>';
if ($versionAvailable) {
$select1[] = '<option value="1" data-revision="1">' . rex_i18n::msg('version_workingversion') . '</option>';
}

$select2 = [];
$select2[] = '<option value="" selected="selected">' . $plugin->i18n('current_version') . '</option>';
$select2[] = '<option value="" selected="selected">' . $currentVersionLabel . '</option>';
foreach ($versions as $version) {
$historyInfo = $version['history_date'];
if ('' != $version['history_user']) {
Expand All @@ -152,6 +173,9 @@ static function (rex_extension_point $ep) {
$fragment->setVar('content1iframe', $content1iframe, false);
$fragment->setVar('content2select', $content2select, false);
$fragment->setVar('content2iframe', $content2iframe, false);
$fragment->setVar('allow_rollback', rex::requireUser()->hasPerm('history[article_rollback]'));
$fragment->setVar('allow_draft_rollback', $versionAvailable && rex::requireUser()->hasPerm('history[article_draft_rollback]'));
$fragment->setVar('version_available', $versionAvailable);

echo $fragment->parse('history/layer.php');
exit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@
<div class="history-layer-panel-4">
<div class="row">
<div class="col-lg-6 col-lg-push-6 text-center">
<button class="btn btn-apply" data-history-layer="snap"><?= rex_i18n::msg('structure_history_snapshot_reactivate') ?></button>
<?php if ($this->getVar('allow_draft_rollback')): ?>
<button class="btn btn-apply" data-history-layer="snap_draft" data-draft-warning="<?= rex_escape(rex_i18n::msg('structure_history_draft_warning')) ?>"><?= rex_i18n::msg('structure_history_snapshot_draft_reactivate') ?></button>
<?php endif ?>
<?php if ($this->getVar('allow_rollback')): ?>
<button class="btn btn-apply" data-history-layer="snap"><?= rex_i18n::msg($this->getVar('version_available') ? 'structure_history_snapshot_live_reactivate' : 'structure_history_snapshot_reactivate') ?></button>
<?php endif ?>
<button class="btn btn-abort" data-history-layer="cancel"><?= rex_i18n::msg('structure_history_close') ?></button>
</div>
</div>
Expand Down
8 changes: 7 additions & 1 deletion redaxo/src/addons/structure/plugins/history/lang/de_de.lang
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
structure_history = Historie
structure_history_title_info = Kurzerklärung
structure_history_snapshot_reactivate = Diese Version übernehmen
structure_history_snapshot_live_reactivate = Diese Version in Liveversion übernehmen
structure_history_snapshot_draft_reactivate = Diese Version in Arbeitsversion übernehmen
structure_history_draft_warning = Achtung: Die Arbeitsversion ist nicht versioniert. Wenn Sie die rechts ausgewählte Version in die Arbeitsversion wiederherstellen, geht der Inhalt der aktuellen Arbeitsversion unwiderruflich verloren. Sind Sie sicher?
structure_history_snapshot_reactivated = Version wurde übernommen
structure_history_overview_versions = history_overview_versions
structure_history_current_version = Aktuelle Version
structure_history_current_live_version = Aktuelle Liveversion
structure_history_info_content = <p>Ein History PlugIn mit welchem man Änderungen in den Artikelinhalten aufnehmen kann. Es wird jeweils ein Snapshot der Version erstellt und mit einem Datum versehen. Nachträglich können dann ältere Versionen wieder aktiviert werden.</p>
structure_history_todos = Todos
structure_history_todos_content = <ul><li>cronjob vorbereiten</li><li>History deaktivierbar machen</li><li>Einstellungen einbauen, um die Anzahl der Version einzuschränken. Z.B. nach einer Woche nur eine Version/Tag behalten. nach einem Monat nur noch eine Version/Monat behalten..</li><li>Skalierungswerte der Webseite setzen</li><li>Darstellung aufhübschen ala Time Machine ?</li></ul>

perm_options_history[article_rollback] = Artikel wiederherstellen (Historie)
perm_options_history[read] = Artikel-Historie anzeigen
perm_options_history[article_rollback] = Frühere Artikel-Snapshots wiederherstellen (Historie)
perm_options_history[article_draft_rollback] = Frühere Artikel-Snapshots in Arbeitsversion wiederherstellen (Historie)

structure_history_button_delete_history = Historie komplett löschen
structure_history_deleted = Historie wurde komplett gelöscht.
Expand Down
8 changes: 7 additions & 1 deletion redaxo/src/addons/structure/plugins/history/lang/en_gb.lang
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
structure_history = History
structure_history_title_info = Short explanation
structure_history_snapshot_reactivate = Revert to this version
structure_history_snapshot_live_reactivate = Revert live version to this version
structure_history_snapshot_draft_reactivate = Revert draft version to this version
structure_history_draft_warning = Warning: The draft version is not versioned. Restoring the selected version to the draft will permanently overwrite the current draft content. Are you sure?
structure_history_snapshot_reactivated = Version has been revertet
structure_history_overview_versions = History overview
structure_history_current_version = Current version
structure_history_current_live_version = Current live version
structure_history_info_content = <p>The History PlugIn records all changes made to an article and creates snapshots which can later be used to restore a specific article to a previous state.</p>
structure_history_todos = To do
structure_history_todos_content = <ul><li>prepare cronjob</li><li>allow History to be turned off</li><li>Build settings, to reduce the number of version. Example: keep only one version after a month/week/day.</li><li>set scaling values for the website</li><li>make the visual appearance prettier similar to Time Machine?</li></ul>

perm_options_history[article_rollback] = Restore article (History)
perm_options_history[read] = View article history
perm_options_history[article_rollback] = Restore previous article snapshots (History)
perm_options_history[article_draft_rollback] = Restore previous article snapshots to draft version (History)

structure_history_button_delete_history = Delete all snapshots from History
structure_history_deleted = All snapshots have been deleted.
Expand Down
8 changes: 7 additions & 1 deletion redaxo/src/addons/structure/plugins/history/lang/es_es.lang
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
structure_history = Historia
structure_history_title_info = Breve explicación
structure_history_snapshot_reactivate = Aceptar esta versión
structure_history_snapshot_live_reactivate = Aceptar esta versión en la versión en vivo
structure_history_snapshot_draft_reactivate = Aceptar esta versión en la versión de trabajo
structure_history_draft_warning = Atención: La versión de trabajo no está versionada. Si restaura la versión seleccionada a la versión de trabajo, el contenido actual de la versión de trabajo se perderá de forma irrecuperable. ¿Está seguro?
structure_history_snapshot_reactivated = Se adoptó la versión
structure_history_overview_versions = Versiones generales de la historia
structure_history_current_version = Versión actual
structure_history_current_live_version = Versión en vivo actual
structure_history_info_content = <p>Un plug-in de la historia con la que puede registrar los cambios en el contenido del artículo. En cada caso, una versión instantánea y dado una fecha. Posteriormente versiones anteriores pueden entonces ser re-activados.</p>
structure_history_todos = Todos
structure_history_todos_content = <ul><li>cronjob preparar </li> <li> Historia hacer desactivado </li><li>Instalar las opciones para restringir el número de versiones. Por ejemplo, mantener sólo una versión / día después de una semana. retener meses después de un mes sólo una versión /.. </li><li> Los valores escalados el sitio web creado </li><li> representación aufhübschen ala máquina del tiempo? </li> </ul>

perm_options_history[article_rollback] = Restablecimiento del artículo (Historia)
perm_options_history[read] = Ver historial del artículo
perm_options_history[article_rollback] = Restaurar instantáneas anteriores del artículo (Historia)
perm_options_history[article_draft_rollback] = Restaurar instantáneas anteriores del artículo en versión de trabajo (Historia)

structure_history_button_delete_history = Borrar por completo la historia
structure_history_deleted = La historia ha sido completamente borrada.
Expand Down
35 changes: 20 additions & 15 deletions redaxo/src/addons/structure/plugins/history/lang/it_it.lang
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
structure_history =
structure_history_title_info =
structure_history_snapshot_reactivate =
structure_history_snapshot_reactivated =
structure_history_overview_versions =
structure_history_current_version =
structure_history_info_content =
structure_history_todos =
structure_history_todos_content =
structure_history =
structure_history_title_info =
structure_history_snapshot_reactivate =
structure_history_snapshot_live_reactivate =
structure_history_snapshot_draft_reactivate =
structure_history_draft_warning =
structure_history_snapshot_reactivated =
structure_history_overview_versions =
structure_history_current_version =
structure_history_current_live_version =
structure_history_info_content =
structure_history_todos =
structure_history_todos_content =

perm_options_history[article_rollback] =

structure_history_button_delete_history =
structure_history_deleted =
structure_history_savedby =
structure_history_close =
perm_options_history[read] = Visualizza cronologia articolo
perm_options_history[article_rollback] =
perm_options_history[article_draft_rollback] =
structure_history_button_delete_history =
structure_history_deleted =
structure_history_savedby =
structure_history_close =
8 changes: 7 additions & 1 deletion redaxo/src/addons/structure/plugins/history/lang/pt_br.lang
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
structure_history = História
structure_history_title_info = Explicação curta
structure_history_snapshot_reactivate = Reverter para essa versão
structure_history_snapshot_live_reactivate = Reverter versão ao vivo para esta versão
structure_history_snapshot_draft_reactivate = Reverter versão de rascunho para esta versão
structure_history_draft_warning = Atenção: A versão de rascunho não é versionada. Restaurar a versão selecionada para o rascunho irá substituir permanentemente o conteúdo atual do rascunho. Tem certeza?
structure_history_snapshot_reactivated = Versão foi revertida
structure_history_overview_versions = Panorama da história
structure_history_current_version = Versão atual
structure_history_current_live_version = Versão ao vivo atual
structure_history_info_content = <p> O PlugIn história grava todas as alterações feitas em um produto e cria snapshots que podem ser utilizados posteriormente para restaurar um status anterior de produto específico. <p>
structure_history_todos = A ser feito
structure_history_todos_content = <ul><li>preparar cronjob</li><li>permite que o PlugIn "história" seja desligado</li><li>Criar configurações, para reduzir o número de versão. Exemplo: mantenha apenas uma versão após um mês / semana / diaLi> <li> definir valores de escala para o site </ li> <li>Tornar a aparência mais bonita, semelhante ao Time Machine? </ Li> </ ul>

perm_options_history[article_rollback] = Restaurar produto (história)
perm_options_history[read] = Ver histórico do artigo
perm_options_history[article_rollback] = Restaurar snapshots anteriores do artigo (história)
perm_options_history[article_draft_rollback] = Restaurar snapshots anteriores do artigo para versão de rascunho (história)

structure_history_button_delete_history = Deletar todos os snapshots do História
structure_history_deleted = Todos os snapshots foram deletados
Expand Down
Loading
Loading