Skip to content

Commit

Permalink
[FEATURE] WOPI Configurable Saving Interval
Browse files Browse the repository at this point in the history
  • Loading branch information
chfsx committed Oct 25, 2024
1 parent d4c1d09 commit e8f78d0
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

/**
* @author Fabian Schmid <[email protected]>
*
* @ilCtrl_isCalledBy ilWOPIAdministrationGUI: ilObjExternalToolsSettingsGUI
*/
class ilWOPISettingsForm
{
Expand Down Expand Up @@ -64,15 +62,17 @@ private function getSection(): Section
{
$wopi_activated = (bool) $this->settings->get("wopi_activated", '0');
$wopi_discovery_url = $this->settings->get("wopi_discovery_url");
$saving_interval_value = (int) $this->settings->get("saving_interval", '0');
$saving_interval_value = $saving_interval_value === 0 ? null : $saving_interval_value;

$wopi_url = $this->ui_factory->input()->field()->text(
$this->lng->txt("wopi_url"),
$this->lng->txt("wopi_url_byline")
/*. $this->renderLink(
" ➜︎ Wikipedia",
"https://en.wikipedia.org/wiki/Web_Application_Open_Platform_Interface",
true
)*/
/*. $this->renderLink(
" ➜︎ Wikipedia",
"https://en.wikipedia.org/wiki/Web_Application_Open_Platform_Interface",
true
)*/
)->withAdditionalTransformation(
$this->refinery->custom()->transformation(function ($v) {
return $v === '' ? null : $v;
Expand All @@ -94,13 +94,56 @@ private function getSection(): Section
$wopi_discovery_url ?? ''
);

$saving_interval = $this->ui_factory->input()->field()->optionalGroup(
[
$this->ui_factory
->input()
->field()
->numeric(
$this->lng->txt("saving_interval"),
$this->lng->txt("saving_interval_byline")
)
->withAdditionalTransformation(
$this->refinery->custom()->transformation(function ($v) {
return $v === '' ? null : $v;
})
)->withAdditionalTransformation(
$this->refinery->custom()->transformation(function ($v) {
if ($v === null || $v === 0) {
$this->settings->delete("saving_interval");
return true;
}

$this->settings->set("saving_interval", (string) $v);

return true;
})
)->withValue(
$saving_interval_value
)
],
$this->lng->txt("activate_saving_interval")
)->withValue(
$saving_interval_value === null ? null : [$saving_interval_value]
)->withAdditionalTransformation(
$this->refinery->custom()->transformation(function ($v) {
if ($v === null || $v === [null]) {
$this->settings->delete("saving_interval");
}
return $v;
})
);

return $this->ui_factory->input()->field()->section(
[
$this->ui_factory->input()->field()->optionalGroup(
[$wopi_url],
[$wopi_url, $saving_interval],
$this->lng->txt("activate_wopi")
)->withValue(
$wopi_discovery_url === null ? null : [$wopi_discovery_url]
$wopi_discovery_url === null ? null : [
$wopi_discovery_url,
$saving_interval_value === null ? null : [$saving_interval_value]
]
)->withAdditionalTransformation(
$this->refinery->custom()->transformation(function ($v) {
if ($v === null || $v === [null]) {
Expand Down
48 changes: 48 additions & 0 deletions components/ILIAS/WOPI/classes/Setup/class.ilWOPIDB100.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

/**
* @author Fabian Schmid <[email protected]>
*/
class ilWOPIDB100 implements \ilDatabaseUpdateSteps
{
private ?ilDBInterface $db = null;

public function prepare(ilDBInterface $db): void
{
$this->db = $db;
}

public function step_1(): void
{
if (!$this->db->tableColumnExists('wopi_action', 'target_text')) {
$this->db->addTableColumn(
'wopi_action',
'target_text',
[
'type' => 'text',
'length' => 256,
'notnull' => false,
],
);
}
}

}
16 changes: 13 additions & 3 deletions components/ILIAS/WOPI/classes/Setup/class.ilWOPISetupAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
*********************************************************************/

declare(strict_types=1);

use ILIAS\Setup\Objective\NullObjective;
use ILIAS\Setup\Metrics\Storage;
use ILIAS\Setup\Agent;
use ILIAS\Setup\Objective;
use ILIAS\Refinery\Transformation;
use ILIAS\Setup\Metrics;
use ILIAS\Setup\Config;
use ILIAS\Setup\ObjectiveCollection;
use ILIAS\BookingManager\Setup\AccessRBACOperationClonedObjective;

/**
* @author Fabian Schmid <[email protected]>
Expand All @@ -46,15 +49,22 @@ public function getInstallObjective(Config $config = null): Objective

public function getUpdateObjective(Config $config = null): Objective
{
return new ObjectiveCollection(
"WOPI Updates",
true,
new ilDatabaseUpdateStepsExecutedObjective(new ilWOPIDB90()),
new ilDatabaseUpdateStepsExecutedObjective(new ilWOPIDB100()),
);

return new \ilDatabaseUpdateStepsExecutedObjective(new ilWOPIDB90());
}

public function getBuildObjective(): Objective
{
return new Objective\NullObjective();
return new NullObjective();
}

public function getStatusObjective(Metrics\Storage $storage): Objective
public function getStatusObjective(Storage $storage): Objective
{
return new ilDatabaseUpdateStepsMetricsCollectedObjective($storage, new ilWOPIDB90());
}
Expand Down
10 changes: 9 additions & 1 deletion lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -17669,13 +17669,21 @@ wiki#:#wiki_whole_wiki#:#Gesamtes Wiki
wiki#:#wiki_wiki_page#:#Wiki-Seite
wiki#:#wiki_wiki_search#:#Suche im Wiki
wiki#:#wiki_wpg#:#Wiki-Seite
wopi#:#action_edit#:#Editieren
wopi#:#action_view#:#Anzeigen
wopi#:#activate_saving_interval#:#Speicherintervall aktivieren
wopi#:#activate_wopi#:#WOPI aktivieren
wopi#:#close_wopi_editor#:#Editor schliessen
wopi#:#close_wopi_editor_info#:#Es kann bis zu mehreren Minuten dauern, bis der externe Editor die Änderungen an ILIAS übertragen hat. Besuchen Sie diese Seite zu einem späteren Zeitpunkt wieder, wenn die gemachten Änderungen noch nicht ersichtlich sind.
wopi#:#currently_supported#:#Derzeit unterstützte Dateiendungen: %s
wopi#:#currently_supported#:#Derzeit unterstützte Dateiendungen
wopi#:#msg_error_wopi_invalid_discorvery_url#:#Die eingegebene Discovery-URL ist ungültig oder kann nicht erreicht werden.
wopi#:#msg_wopi_settings_modified#:#Einstellungen gespeichert
wopi#:#open_external_editor#:#In externem Editor öffnen
wopi#:#open_external_viewer#:#Inhalt anzeigen
wopi#:#save_on_exit#:#Beim Beenden des Editors automatisch speichern
wopi#:#save_on_exit_info#:#Bei aktiviertem Speicherintervall wird nach Möglichkeit nach der festgelegten Sekundenanzahl eine neue Verison veröffentlicht. Bitte beachten Sie, dass eine tiefer Wert zu sehr vielen Dateiversionen führen kann und damit ein Vielfaches des Festplattenspeichers beanspr
wopi#:#saving_interval#:#Speicherintervall
wopi#:#saving_interval_byline#:#Standardmässig fügt ILIAS alle durch einen Externen Editor erhaltenen Änderungen in einer Entwurfs-Version hinzu, bis diese Version manuell veröffentlicht wird. Durch das Aktivieren des Speicherintervall wird nach Möglichkeit nach der festgelegten Sekundenanzahl eine neue Verison veröffentlicht. Bitte beachten Sie, dass eine tiefer Wert zu sehr vielen Dateiversionen führen kann und damit ein Vielfaches des Festplattenspeichers beansprucht.
wopi#:#wopi_crawler_cronjob_description#:#Aktualisiert die Informationen des angebundenen WOPI-Dienstes.
wopi#:#wopi_crawler_cronjob_no_apps#:#Es wurden keine WOPI-Apps in der Discovery gefunden.
wopi#:#wopi_crawler_cronjob_not_activated#:#WOPI ist nicht aktiviert.
Expand Down
8 changes: 7 additions & 1 deletion lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -17649,13 +17649,19 @@ wiki#:#wiki_whole_wiki#:#Whole Wiki
wiki#:#wiki_wiki_page#:#Wiki Page
wiki#:#wiki_wiki_search#:#Wiki Search
wiki#:#wiki_wpg#:#Wiki Page
wopi#:#action_edit#:#Edit
wopi#:#action_view#:#View
wopi#:#activate_saving_interval#:#Activate Saving Interval
wopi#:#activate_wopi#:#Activate WOPI
wopi#:#close_wopi_editor#:#Close Editor
wopi#:#close_wopi_editor_info#:#It can take up to several minutes for the external editor to transfer the changes to ILIAS. Visit this page again at a later time if the changes you have made are not yet visible.
wopi#:#currently_supported#:#Currently supported Suffixes: %s
wopi#:#currently_supported#:#Currently supported Suffixes
wopi#:#msg_error_wopi_invalid_discorvery_url#:#The Discovery URL entered is invalid or cannot be accessed.
wopi#:#msg_wopi_settings_modified#:#Settings stored
wopi#:#open_external_editor#:#Open in external Editor
wopi#:#open_external_viewer#:#Show Content
wopi#:#saving_interval#:#Interval
wopi#:#saving_interval_byline#:#By default, ILIAS adds all changes made by an external editor to a draft version until this version is published manually. Activating the save interval causes a new version to be published after the specified number of seconds, if possible. Please note that a low value can lead to a large number of file versions, which in turn takes up a multiple of the hard disk space.
wopi#:#wopi_crawler_cronjob_description#:#Updates the information of the connected WOPI service.
wopi#:#wopi_crawler_cronjob_no_apps#:#No WOPI apps were found in the discovery.
wopi#:#wopi_crawler_cronjob_not_activated#:#WOPI is not activated.
Expand Down

0 comments on commit e8f78d0

Please sign in to comment.