diff --git a/application/configs/help/metadata.en.txt b/application/configs/help/metadata.en.txt index a8988a321..d8956859d 100644 --- a/application/configs/help/metadata.en.txt +++ b/application/configs/help/metadata.en.txt @@ -1,7 +1,7 @@ Metadata can be defined as
This repository is using metadata in the Dublin
-Core Metedata Element Set (short Dublin Core (DC)) which has fifteen basic elements. Dublin
+Core Metadata Element Set (short Dublin Core (DC)) which has fifteen basic elements. Dublin
Core is the result of international efforts to reach a collective consensus in describing electronic
objects (in the broadest sense). The Library of Congress (LoC), the Online Cataloging Library Center (OCLC)
and several national libraries are dealing with Dublin Core in many projects and are close to introduce the
diff --git a/application/configs/help/publicationprocess.en.txt b/application/configs/help/publicationprocess.en.txt
index 6eeda1416..0562ad475 100644
--- a/application/configs/help/publicationprocess.en.txt
+++ b/application/configs/help/publicationprocess.en.txt
@@ -2,7 +2,7 @@ Please click on the publication link on the start page.
This repository is using metadata in the Dublin
-Core Metedata Element Set (short Dublin Core (DC)) which has fifteen basic elements. Dublin
+Core Metadata Element Set (short Dublin Core (DC)) which has fifteen basic elements. Dublin
Core is the result of international efforts to reach a collective consensus in describing electronic
objects (in the broadest sense). The Library of Congress (LoC), the Online Cataloging Library Center (OCLC)
and several national libraries are dealing with Dublin Core in many projects and are close to introduce the
diff --git a/tests/library/Application/Update/ImportHelpFilesTest.php b/tests/library/Application/Update/ImportHelpFilesTest.php
index d9b1f8d79..b91dc10be 100644
--- a/tests/library/Application/Update/ImportHelpFilesTest.php
+++ b/tests/library/Application/Update/ImportHelpFilesTest.php
@@ -306,4 +306,96 @@ public function testGetHelpFilesForDefaultSetup()
}
}
}
+
+ /**
+ * OPUSVIER-4304
+ *
+ * Sometimes help files have been changed directly without copying the keys to `language_custom`. In that case,
+ * it is not possible to detect the customization during the update. However we should assume that this might
+ * have happened and import the files anyway.
+ */
+ public function testImportChangedHelpFilesWithoutCustomizedKeys()
+ {
+ $database = new Opus_Translate_Dao();
+ $database->removeAll();
+
+ $helpPath = $this->createTestFolder();
+
+ $generalDe = $this->createTestFile('general.de.txt', 'Allgemein', $helpPath);
+ $generalEn = $this->createTestFile('general.en.txt', 'General', $helpPath);
+ $policiesDe = $this->createTestFile('policies.de.txt', 'Leitlinien', $helpPath);
+ $policiesEn = $this->createTestFile('policies.en.txt', 'Policies', $helpPath);
+
+ $helpConfig = 'help_index_general[] = \'general\'' . PHP_EOL;
+ $helpConfig .= 'help_index_misc[] = \'policies\'' . PHP_EOL;
+ $helpIni = $this->createTestFile('help.ini', $helpConfig, $helpPath);
+
+ $database->setTranslation('help_content_general', [
+ 'en' => 'general.en.txt',
+ 'de' => 'general.de.txt'
+ ], 'help');
+ // no custom key for `help_content_policies`
+
+ $update = new Application_Update_ImportHelpFiles();
+ $update->setHelpPath($helpPath);
+ $update->setQuietMode(true);
+ $update->run();
+
+ $this->assertFileNotExists($generalDe);
+ $this->assertFileExists($generalDe . '.imported');
+ $this->assertFileNotExists($generalEn);
+ $this->assertFileExists($generalEn . '.imported');
+ $this->assertFileNotExists($policiesDe);
+ $this->assertFileExists($policiesDe . '.imported');
+ $this->assertFileNotExists($policiesEn);
+ $this->assertFileExists($policiesEn . '.imported');
+
+ $translations = $database->getTranslations();
+ $this->assertArrayHasKey('help_content_general', $translations);
+ $this->assertArrayHasKey('help_content_policies', $translations);
+
+ $translations = $database->getTranslation('help_content_general');
+ $this->assertEquals([
+ 'en' => 'General',
+ 'de' => 'Allgemein'
+ ], $translations);
+
+ $translations = $database->getTranslation('help_content_policies');
+ $this->assertEquals([
+ 'en' => 'Policies',
+ 'de' => 'Leitlinien'
+ ], $translations);
+ }
+
+ /**
+ * The help content in txt files and defined in TMX files needs to match perfectly, so the default
+ * content will not be imported into the database.
+ */
+ public function testTmxContentMatchesHelpFiles()
+ {
+ $database = new Opus_Translate_Dao();
+ $database->removeAll();
+
+ $update = new Application_Update_ImportHelpFiles();
+ $update->setRemoveFilesEnabled(false);
+ $update->setQuietMode(true);
+
+ $files = $update->getHelpFiles();
+ $helpPath = $update->getHelpPath();
+ $prefix = 'help_content_';
+
+ foreach ($files as $key => $translations) {
+ foreach ($translations as $lang => $value) {
+ if (substr($key, 0, strlen($prefix)) == $prefix) {
+ $baseName = substr($key, strlen($prefix));
+ $fileName = "$baseName.{$lang}.txt";
+ $path = $helpPath . $fileName;
+ if (is_readable($path)) {
+ $fileContent = trim(file_get_contents($path));
+ }
+ }
+ $this->assertEquals($fileContent, $value, "File and TMX for '$key' in '$lang' do not match.");
+ }
+ }
+ }
}
First you are requested to choose a document type. Right beneath that you can upload your document files. Having done
so you may click on "send". What follows now is the actual form.
You have to fill in data about your publication here (so called metadata), which is used to describe your work in
-catalouges and other bibliographic
+cataloges and other bibliographic
directories. Describe the document you want to upload using the categories and fields on the publication form.
Depending on the document type, some of
these fields are mandatory and therefore have to be filled in. Please describe your
diff --git a/library/Application/Update/ImportHelpFiles.php b/library/Application/Update/ImportHelpFiles.php
index b3f5ab856..1d0a00fe1 100644
--- a/library/Application/Update/ImportHelpFiles.php
+++ b/library/Application/Update/ImportHelpFiles.php
@@ -184,6 +184,23 @@ public function importFiles($key, $files, $module)
$content = file_get_contents($path);
$values[$lang] = $content;
$this->removeFile($path);
+ } else {
+ // OPUSVIER-4304 Try to see if there is a file after all.
+ $this->log("Trying to resolve default file for key '$key' in language '$lang'.");
+ $prefix = 'help_content_';
+ if (substr($key, 0, strlen($prefix)) == $prefix) {
+ $baseName = substr($key, strlen($prefix));
+ $fileName = "$baseName.{$lang}.txt";
+ $path = $helpPath . $fileName;
+ if (is_readable($path)) {
+ $this->log("Default file '$fileName' found.");
+ $content = trim(file_get_contents($path));
+ $values[$lang] = $content;
+ $this->removeFile($path);
+ } else {
+ $this->log("Default file '$fileName' not found.");
+ }
+ }
}
}
diff --git a/modules/help/language/help.tmx b/modules/help/language/help.tmx
index 29b3c695a..97a510648 100644
--- a/modules/help/language/help.tmx
+++ b/modules/help/language/help.tmx
@@ -137,7 +137,7 @@ gestattet! Dies können Sie zum Beispiel mit Hilfe der
First you are requested to choose a document type. Right beneath that you can upload your document files. Having done
so you may click on "send". What follows now is the actual form.
You have to fill in data about your publication here (so called metadata), which is used to describe your work in
-catalouges and other bibliographic
+cataloges and other bibliographic
directories. Describe the document you want to upload using the categories and fields on the publication form.
Depending on the document type, some of
these fields are mandatory and therefore have to be filled in. Please describe your
@@ -197,7 +197,7 @@ Cookies müssen im Webbrowser eingeschaltet sein, um Dokumente über das Veröff