From cc0118c87aca84b800ddf17f97a326beed6eec7a Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Mon, 3 Feb 2020 02:59:41 +0100 Subject: [PATCH 001/270] OPUSVIER-4100 --- modules/admin/forms/Document/Enrichment.php | 41 +++++++++++++++++++-- public/layouts/opus4/css/admin.css | 11 +++++- public/layouts/opus4/js/validation.js | 26 +++++++++++++ 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index c9cd124de3..9fee6c827f 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -105,9 +105,9 @@ public function populateFromModel($enrichment) * Wurde ein Wert im zweiten Argument übergeben, so wird das neu eingefügte * Formularfeld mit diesem Wert initialisiert. * - * @param $enrichmentKey EnrichmentKey des Enrichments, für das ein - * Eingabeformularelement erzeugt werden soll - * @param null $value optionaler Wert für das erzeugte Formularfeld + * @param Opus_EnrichmentKey $enrichmentKey EnrichmentKey des Enrichments, für das ein + * Eingabeformularelement erzeugt werden soll + * @param null $value optionaler Wert für das erzeugte Formularfeld */ private function setEnrichmentValueFormElement($enrichmentKey, $value = null) { @@ -136,6 +136,15 @@ private function setEnrichmentValueFormElement($enrichmentKey, $value = null) $elements = $this->getElements(); $elements[self::ELEMENT_VALUE] = $element; $this->setElements($elements); + + if (! $enrichmentType->isStrictValidation()) { + // verstößt der im Enrichment gespeicherte Wert gegen die aktuelle Typkonfiguration + if (! is_null($value) && ! $element->isValid($value)) { + // Hinweistext anzeigen, der auf Verstoß hinweist + $element->markAsError(); + $this->handleValidationErrorNonStrict(); + } + } } /** @@ -327,10 +336,19 @@ public function initEnrichmentValueElement($enrichmentKeyName = null, $enrichmen * Bei der Anzeige des Formulars im Non-Edit-Mode soll auch eine Ausgabe erfolgen, * wenn der EnrichmentType als Checkbox dargestellt wird. In diesem Fall soll * der Text No/Nein erscheinen. + * + * Außerdem soll ein möglicher Verstoß des Enrichmentwerts gegen die Typkonfiguration + * des Enrichment-Keys nicht als Validierungsfehler im Non-Edit-Mode erscheinen. + * */ public function prepareRenderingAsView() { $this->setRemoveEmptyCheckbox(false); + + $element = $this->getElement(self::ELEMENT_VALUE); + $element->setAttrib('data-opusValidationError', 'false'); + $element->removeDecorator('Errors'); + parent::prepareRenderingAsView(); } @@ -383,6 +401,7 @@ public function isValid($data) // Wert des Enrichments wurde nicht geändert und es findet keine strikte Validierung statt // Validierungsergebnis wird daher auf "positiv" geändert $this->ignoreValueErrors = true; + $this->handleValidationErrorNonStrict(); return true; } } catch (Opus\Model\Exception $e) { @@ -412,4 +431,20 @@ public function getErrors($name = null, $suppressArrayNotation = false) return parent::getErrors($name, $suppressArrayNotation); } + + /** + * Verstößt der in einem Feld gespeicherte Enrichment-Wert gegen die aktuelle Typkonfiguration + * des Enrichment Keys, so wird im Validierungsmodus "non strict" nur ein Hinweis, aber keine + * Fehlermeldung angezeigt. Der unveränderte (aber bezüglich der aktuellen Typkonfiguration invalide) + * Wert lässt sicher weiterhin speichern. + * + * @throws Zend_Form_Exception + */ + private function handleValidationErrorNonStrict() + { + $element = $this->getElement(self::ELEMENT_VALUE); + $element->setAttrib('data-opusValidationError', 'true'); + $decorator = $element->getDecorator('Errors'); + $decorator->setOption('class', 'errors notice'); + } } diff --git a/public/layouts/opus4/css/admin.css b/public/layouts/opus4/css/admin.css index a39959c326..b01bd4e5f0 100644 --- a/public/layouts/opus4/css/admin.css +++ b/public/layouts/opus4/css/admin.css @@ -2581,4 +2581,13 @@ a.create-document-link { #enrichmentkeyTable span.strong { font-weight: bold; -} \ No newline at end of file +} + +/* Verstoß gegen Typkonfiguration eines Enrichment-Key nur als Hinweis anzeigen */ +.adminContainer ul.notice { + background-color: #E1E4E0 !important; + color: #595A56 !important; +} +.adminContainer ul.notice:before { + border-color: transparent transparent #E1E4E0 !important; +} diff --git a/public/layouts/opus4/js/validation.js b/public/layouts/opus4/js/validation.js index 0c5718c1a9..7e59706573 100644 --- a/public/layouts/opus4/js/validation.js +++ b/public/layouts/opus4/js/validation.js @@ -269,4 +269,30 @@ $(document).ready(function () { }; }); + /** + * Im Falle des Validierungsmodus "non strict" soll im Eingabeformular ein möglicher Hinweistext, der + * darauf hinweist, dass der aktuelle Formularwert gegen die Typkonfiguration des Enrichment-Keys verstößt, + * ausgeblendet werden, wenn der Formularwert geändert wird. Wird der Wert auf den ursprünglichen Formularwert + * zurückgesetzt, so soll der Hinweistext wieder eingeblendet werden (ohne Interaktion mit dem Server). + */ + $("input[data-opusValidationError='true']").on('input', function (event) { + var element = $(this); + var errorMessage = element.next(".errors"); + if (errorMessage) { + var oldValue = errorMessage.data('errorValue'); + if (typeof oldValue === "undefined") { + errorMessage.data('errorValue', event.target.defaultValue); + } + + if (errorMessage.is(":visible")) { + errorMessage.hide(); + } else { + if (element.val() === errorMessage.data('errorValue')) { + // beim Zurücksetzen auf den Ursprungswert Fehlermeldung wieder einblenden + errorMessage.show(); + } + } + } + }) + }); From 7df7475ada41b910dd0dc83adf4b9f984d0b61c4 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 16 Feb 2020 17:01:04 +0100 Subject: [PATCH 002/270] use class datahint instead of notice --- modules/admin/forms/Document/Enrichment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index 9fee6c827f..4b58d19619 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -148,7 +148,7 @@ private function setEnrichmentValueFormElement($enrichmentKey, $value = null) } /** - * Besondere Behandlung von Enrichment-Typen, die zur Wertauswahl ein Select-Formularfeld verweden. + * Besondere Behandlung von Enrichment-Typen, die zur Wertauswahl ein Select-Formularfeld verwenden. * Hier kann es erforderlich sein, dass im vorliegenden Dokument ein Enrichment-Wert genutzt wird, * der nicht in der konfigurierten Werteliste im Enrichment-Key enthalten ist. Ein solcher Wert * soll dennoch (als erster Eintrag) im Select-Formularfeld zur Auswahl angeboten werden. @@ -445,6 +445,6 @@ private function handleValidationErrorNonStrict() $element = $this->getElement(self::ELEMENT_VALUE); $element->setAttrib('data-opusValidationError', 'true'); $decorator = $element->getDecorator('Errors'); - $decorator->setOption('class', 'errors notice'); + $decorator->setOption('class', 'errors datahint'); } } From 3216a5e67e44204d0d4f1633e1ed3c6953c785f6 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 16 Feb 2020 22:47:11 +0100 Subject: [PATCH 003/270] added handling of validation error to select form element --- public/layouts/opus4/js/validation.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public/layouts/opus4/js/validation.js b/public/layouts/opus4/js/validation.js index 7e59706573..9840827e20 100644 --- a/public/layouts/opus4/js/validation.js +++ b/public/layouts/opus4/js/validation.js @@ -275,20 +275,23 @@ $(document).ready(function () { * ausgeblendet werden, wenn der Formularwert geändert wird. Wird der Wert auf den ursprünglichen Formularwert * zurückgesetzt, so soll der Hinweistext wieder eingeblendet werden (ohne Interaktion mit dem Server). */ - $("input[data-opusValidationError='true']").on('input', function (event) { + $("input[data-opusValidationError='true'], select[data-opusValidationError='true']").on('input', function (event) { var element = $(this); var errorMessage = element.next(".errors"); if (errorMessage) { var oldValue = errorMessage.data('errorValue'); - if (typeof oldValue === "undefined") { + if (typeof oldValue === 'undefined' && (typeof event.target.defaultValue !== 'undefined')) { + // Input-Element wird das erste Mal behandelt (beim Select-Element brauchen wir den Ursprungswert nicht speichern) errorMessage.data('errorValue', event.target.defaultValue); } if (errorMessage.is(":visible")) { errorMessage.hide(); } else { - if (element.val() === errorMessage.data('errorValue')) { + if (element.val() === errorMessage.data('errorValue') || + ((typeof errorMessage.data('errorValue') === 'undefined') && element.val() === '0')) { // beim Zurücksetzen auf den Ursprungswert Fehlermeldung wieder einblenden + // Sonderbehandlung für Select-Element: dort steht der Ursprungswert in der Auswahlliste immer an Position 0 errorMessage.show(); } } From 3f4c4ed0a743279173c2de49016db780a06cc51b Mon Sep 17 00:00:00 2001 From: BioFreak95 Date: Tue, 3 Mar 2020 19:37:58 +0100 Subject: [PATCH 004/270] OPUSVIER-4118 Add client-sided check for uploaded files in admin-mondule --- .../View/Helper/JavascriptMessages.php | 13 +++++ .../controllers/FilemanagerController.php | 10 ++++ .../views/helpers/JavascriptMessages.php | 53 ------------------- public/layouts/opus4/common.phtml | 1 + 4 files changed, 24 insertions(+), 53 deletions(-) delete mode 100644 modules/publish/views/helpers/JavascriptMessages.php diff --git a/library/Application/View/Helper/JavascriptMessages.php b/library/Application/View/Helper/JavascriptMessages.php index 5ad0a12431..af9cad4242 100644 --- a/library/Application/View/Helper/JavascriptMessages.php +++ b/library/Application/View/Helper/JavascriptMessages.php @@ -127,4 +127,17 @@ public function __toString() { return $this->toString(); } + + /** + * Default message-set + */ + public function getDefaultMessageSet() + { + $this->addMessage('uploadedFileHasErrorMessage'); + $this->addMessage('fileExtensionFalse'); + $this->addMessage('fileUploadErrorSize'); + $this->addMessage('filenameLengthError'); + $this->addMessage('filenameFormatError'); + $this->addMessage('chooseAnotherFile'); + } } diff --git a/modules/admin/controllers/FilemanagerController.php b/modules/admin/controllers/FilemanagerController.php index f7a88a2159..4f69150a9f 100644 --- a/modules/admin/controllers/FilemanagerController.php +++ b/modules/admin/controllers/FilemanagerController.php @@ -265,6 +265,16 @@ public function uploadAction() $this->_breadcrumbs->setDocumentBreadcrumb($document); $this->_breadcrumbs->setParameters('admin_filemanager_index', [self::PARAM_DOCUMENT_ID => $docId]); + $config = $this->getConfig(); + + if (isset($config->publish->filetypes->allowed)) { + $this->view->extensions = $config->publish->filetypes->allowed; + } + + // Adds translated messages for javascript files + $javascriptTranslations = $this->view->getHelper('javascriptMessages'); + $javascriptTranslations->getDefaultMessageSet(); + $this->renderForm($form); } diff --git a/modules/publish/views/helpers/JavascriptMessages.php b/modules/publish/views/helpers/JavascriptMessages.php deleted file mode 100644 index 2831bc2a48..0000000000 --- a/modules/publish/views/helpers/JavascriptMessages.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Copyright (c) 2019, OPUS 4 development team - * @license http://www.gnu.org/licenses/gpl.html General Public License - */ - -/** - * Class Publish_View_Helper_JavascriptMessages extends the generic view-helper with the default-message-set - * for the publish-module - */ -class Publish_View_Helper_JavascriptMessages extends Application_View_Helper_JavascriptMessages -{ - /** - * Default message-set for the publish-module - */ - public function getDefaultMessageSet() - { - $this->addMessage('uploadedFileHasErrorMessage'); - $this->addMessage('fileExtensionFalse'); - $this->addMessage('fileUploadErrorSize'); - $this->addMessage('filenameLengthError'); - $this->addMessage('filenameFormatError'); - $this->addMessage('chooseAnotherFile'); - } -} diff --git a/public/layouts/opus4/common.phtml b/public/layouts/opus4/common.phtml index cba46ab44e..bf86d50831 100644 --- a/public/layouts/opus4/common.phtml +++ b/public/layouts/opus4/common.phtml @@ -97,6 +97,7 @@ if (in_array($this->moduleName, ['admin', 'review', 'setup', 'account'])) { if (in_array($this->moduleName, ['admin'])) { $jsFiles[] = 'validation.js'; + $jsFiles[] = 'upload.js'; } if ($this->jQueryEnabled()) { From 95f734d4c86338ebb23c16cf794942ffb3c02f0f Mon Sep 17 00:00:00 2001 From: j3nsch Date: Sat, 25 Apr 2020 18:59:01 +0200 Subject: [PATCH 005/270] OPUSVIER-4118 Fixed forgotten test class. --- .../View/Helper/JavascriptMessagesTest.php | 19 +++++ .../View/Helper/JavascriptMessagesTest.php | 70 ------------------- 2 files changed, 19 insertions(+), 70 deletions(-) delete mode 100644 tests/modules/publish/View/Helper/JavascriptMessagesTest.php diff --git a/tests/library/Application/View/Helper/JavascriptMessagesTest.php b/tests/library/Application/View/Helper/JavascriptMessagesTest.php index 451f8d439c..57389fc024 100644 --- a/tests/library/Application/View/Helper/JavascriptMessagesTest.php +++ b/tests/library/Application/View/Helper/JavascriptMessagesTest.php @@ -115,4 +115,23 @@ public function testGetMessages() { $this->assertEquals([], $this->helper->getMessages()); } + + /** + * Tests if default translations for javascript in the publish module are set correctly. + */ + public function testGetDefaultMessageSet() + { + $this->helper->getDefaultMessageSet(); + + $expectation = ' ' . "\n"; + + $this->assertEquals($expectation, $this->helper->javascriptMessages()); + } } diff --git a/tests/modules/publish/View/Helper/JavascriptMessagesTest.php b/tests/modules/publish/View/Helper/JavascriptMessagesTest.php deleted file mode 100644 index 46b9583715..0000000000 --- a/tests/modules/publish/View/Helper/JavascriptMessagesTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Copyright (c) 2019, OPUS 4 development team - * @license http://www.gnu.org/licenses/gpl.html General Public License - */ - -class Publish_View_Helper_JavascriptMessagesTest extends ControllerTestCase -{ - - protected $additionalResources = ['view', 'translation']; - - private $helper; - - public function setUp() - { - parent::setUp(); - - $this->useEnglish(); - - $this->helper = new Publish_View_Helper_JavascriptMessages(); - - $this->helper->setView(Zend_Registry::get('Opus_View')); - } - - /** - * Tests if default translations for javascript in the publish module are set correctly. - */ - public function testGetDefaultMessageSet() - { - $this->helper->getDefaultMessageSet(); - - $expectation = ' ' . "\n"; - - $this->assertEquals($expectation, $this->helper->javascriptMessages()); - } -} From 6ddb9885fd722fd27dffde9ca748d87080763511 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 21 Jun 2020 12:21:09 +0200 Subject: [PATCH 006/270] OPUSVIER-4100 --- .../Form/Element/EnrichmentKey.php | 60 +- library/Application/Form/Element/Select.php | 42 +- modules/admin/forms/Document/Enrichment.php | 518 +++++++++++++----- .../forms/Document/MultiEnrichmentSubForm.php | 21 +- modules/admin/language/enrichments.tmx | 26 + public/layouts/opus4/js/validation.js | 2 +- .../admin/forms/Document/EnrichmentTest.php | 377 +++++++++---- 7 files changed, 751 insertions(+), 295 deletions(-) create mode 100644 modules/admin/language/enrichments.tmx diff --git a/library/Application/Form/Element/EnrichmentKey.php b/library/Application/Form/Element/EnrichmentKey.php index 5e40125922..b52a958c57 100644 --- a/library/Application/Form/Element/EnrichmentKey.php +++ b/library/Application/Form/Element/EnrichmentKey.php @@ -44,10 +44,6 @@ public function init() // load enrichment keys only once in order to save database queries $options = Opus_EnrichmentKey::getAll(false); - $values = []; - - $translator = $this->getTranslator(); - $this->setDisableTranslator(true); // keys are translated below if possible foreach ($options as $index => $option) { @@ -59,19 +55,57 @@ public function init() continue; } - $values[] = $keyName; + $this->addKeyNameAsOption($keyName); + } - $translationKey = 'Enrichment' . $keyName; + $this->resetValidator(); + } - if (! is_null($translator) && ($translator->isTranslated($translationKey))) { - $this->addMultiOption($keyName, $translator->translate($translationKey)); - } else { - $this->addMultiOption($keyName, $keyName); - } + private function addKeyNameAsOption($keyName) + { + $translationKey = 'Enrichment' . $keyName; + + $translator = Zend_Registry::get('Zend_Translate'); + if (! is_null($translator) && ($translator->isTranslated($translationKey))) { + $this->addMultiOption($keyName, $translator->translate($translationKey)); + } else { + $this->addMultiOption($keyName, $keyName); + } + } + + private function resetValidator() + { + $translator = Zend_Registry::get('Zend_Translate'); + $message = 'validation_error_unknown_enrichmentkey'; + if (! is_null($translator) && $translator->isTranslated($message)) { + $message = $translator->translate($message); } - $validator = new Zend_Validate_InArray($values); - $validator->setMessage('validation_error_unknown_enrichmentkey'); + $validator = new Zend_Validate_InArray(array_keys($this->getMultiOptions())); + $validator->setMessage($message); $this->addValidator($validator); } + + /** + * Prüft, ob der übergebene EnrichmentKey-Name bereits in der Auswahl existiert + * + * @param $keyName + */ + public function hasKeyName($keyName) + { + return array_key_exists($keyName, $this->getMultiOptions()); + } + + /** + * Fügt den übergebenen EnrichmentKey-Namen zur Auswahl hinzu, sofern es nicht bereits existiert. + * + * @param $keyName + */ + public function addKeyNameIfMissing($keyName) + { + if (! $this->hasKeyName($keyName)) { + $this->addKeyNameAsOption($keyName); + $this->resetValidator(); + } + } } diff --git a/library/Application/Form/Element/Select.php b/library/Application/Form/Element/Select.php index d2fea60fdf..b3948fb852 100644 --- a/library/Application/Form/Element/Select.php +++ b/library/Application/Form/Element/Select.php @@ -40,6 +40,11 @@ class Application_Form_Element_Select extends Zend_Form_Element_Select implements Application_Form_IElement { + /** + * @var string + */ + private $_hint; + /** * Initialisiert das Formularelement. * @@ -57,26 +62,26 @@ public function loadDefaultDecorators() if (! $this->loadDefaultDecoratorsIsDisabled() && count($this->getDecorators()) == 0) { $this->setDecorators( [ - 'ViewHelper', - 'Errors', - 'Description', - 'ElementHtmlTag', - ['LabelNotEmpty', ['tag' => 'div', 'tagClass' => 'label', 'placement' => 'prepend']], - [['dataWrapper' => 'HtmlTagWithId'], ['tag' => 'div', 'class' => 'data-wrapper']] + 'ViewHelper', + 'Errors', + 'Description', + 'ElementHint', + 'ElementHtmlTag', + ['LabelNotEmpty', ['tag' => 'div', 'tagClass' => 'label', 'placement' => 'prepend']], + [['dataWrapper' => 'HtmlTagWithId'], ['tag' => 'div', 'class' => 'data-wrapper']] ] ); } } /** - * Sorgt dafür, daß nur der Text ausgeben wird und kein INPUT-Tag. + * Setzt den Hinweis für das Formularelement. + * + * @param string $hint Hinweis */ - public function prepareRenderingAsView() + public function setHint($hint) { - $viewHelper = $this->getDecorator('ViewHelper'); - if ($viewHelper instanceof Application_Form_Decorator_ViewHelper) { - $viewHelper->setViewOnlyEnabled(true); - } + $this->_hint = $hint; } /** @@ -89,7 +94,18 @@ public function prepareRenderingAsView() */ public function getHint() { - return null; // TODO: Implement getHint() method. + return $this->_hint; + } + + /** + * Sorgt dafür, daß nur der Text ausgeben wird und kein INPUT-Tag. + */ + public function prepareRenderingAsView() + { + $viewHelper = $this->getDecorator('ViewHelper'); + if ($viewHelper instanceof Application_Form_Decorator_ViewHelper) { + $viewHelper->setViewOnlyEnabled(true); + } } public function getStaticViewHelper() diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index 4b58d19619..42b352af19 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -29,7 +29,7 @@ * @subpackage Form_Document * @author Jens Schwidder * @author Sascha Szott - * @copyright Copyright (c) 2013-2019, OPUS 4 development team + * @copyright Copyright (c) 2013-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ @@ -63,8 +63,8 @@ class Admin_Form_Document_Enrichment extends Admin_Form_AbstractModelSubForm * Erzeugt die Formularelemente. Das Formularelement für den Enrichment-Wert * wird erst in das Formular eingefügt, wenn der tatsächlich ausgewählte * Enrichment-Key (aus dem sich schließlich der Enrichment-Type ergibt) - * feststeht. Aus dem Enrichment-Type ergibt sich die Art des Formularelements - * für den Enrichment-Wert. + * feststeht. Aus dem Enrichment-Type ergibt sich schließlich die Art des + * Formularelements für den Enrichment-Wert, z.B. Textfeld oder Auswahlfeld. */ public function init() { @@ -80,55 +80,78 @@ public function init() } /** - * Initialisiert die Formularelemente mit den Werten aus dem übergebenen - * Enrichment-Model. Diese Methode wird beim ersten Formularaufruf (GET) - * aufgerufen. + * Initialisiert die Formularelemente mit den Werten aus dem übergebenen Enrichment-Model. Diese Methode wird beim + * initialen Formularaufruf (d.h. nur im Kontext eines GET-Requests) aufgerufen. * - * @param Opus_Enrichment $enrichment + * @param Opus_Enrichment $enrichment Enrichment aus der Datenbank, das im Formular angezeigt werden soll */ public function populateFromModel($enrichment) { $this->getElement(self::ELEMENT_ID)->setValue($enrichment->getId()); - $this->getElement(self::ELEMENT_KEY_NAME)->setValue($enrichment->getKeyName()); + + $keyNameElement = $this->getElement(self::ELEMENT_KEY_NAME); + $enrichmentKeyName = $enrichment->getKeyName(); + + // kommt der EnrichmentKey nicht in der EnrichmentKey-Auswahl vor, dann hinzufügen + // in diesem Fall handelt es sich um einen nicht registrierten EnrichmentKey + $keyNameElement->addKeyNameIfMissing($enrichmentKeyName); + $keyNameElement->setValue($enrichmentKeyName); $enrichmentKey = $enrichment->getEnrichmentKey(); - if (! is_null($enrichmentKey)) { - $this->setEnrichmentValueFormElement($enrichmentKey, $enrichment->getValue()); - } else { - $this->getLogger()->err('Enrichment ' . $enrichment->getId() . ' does not provide key object - unknown enrichment key'); + if (is_null($enrichmentKey)) { + $this->getLogger()->info('Enrichment ' . $enrichment->getId() . " does not provide key object - unknown / unregistered enrichment key name '$enrichmentKeyName'"); + // in diesem Fall wird der Wert des Enrichments in einem Textfeld ausgegeben } + + $this->createValueFormElement($enrichment->getValue(), $enrichmentKey); } /** - * Erzeugt ein für das Enrichment passendes Eingabeformularfeld (in Abhängigkeit - * des EnrichmentTypes, der dem EnrichmentKey des Enrichments zugeordnet wurde). - * Wurde ein Wert im zweiten Argument übergeben, so wird das neu eingefügte - * Formularfeld mit diesem Wert initialisiert. + * Erzeugt ein für das Enrichment passendes Eingabeformularfeld (in Abhängigkeit des EnrichmentTypes, der dem + * EnrichmentKey des Enrichments zugeordnet wurde). Ist kein EnrichmentType zugeordnet, so wird ein einfaches + * Texteingabefeld verwendet. * - * @param Opus_EnrichmentKey $enrichmentKey EnrichmentKey des Enrichments, für das ein - * Eingabeformularelement erzeugt werden soll - * @param null $value optionaler Wert für das erzeugte Formularfeld + * @param string $enrichmentValue Wert des anzuzeigenden Enrichments (in der Datenbank) + * @param Opus_EnrichmentKey|null $enrichmentKey EnrichmentKey des Enrichments, für das ein Eingabeformularelement + * erzeugt werden soll + * @param string|null $formValue aktueller Formularwert für das Enrichment (nur bei der Verarbeitung eines + * POST-Requests gesetzt) */ - private function setEnrichmentValueFormElement($enrichmentKey, $value = null) + private function createValueFormElement($enrichmentValue, $enrichmentKey = null, $formValue = null) { - $enrichmentType = $enrichmentKey->getEnrichmentType(); + $enrichmentType = null; + if (! is_null($enrichmentKey)) { + $enrichmentType = $enrichmentKey->getEnrichmentType(); + } + if (is_null($enrichmentType)) { // es handelt sich um ein Enrichment, das einen EnrichmentKey verwendet, - // der noch keinen zugeordneten Typ besitzt: in diesem Fall wird der + // der noch keinen zugeordneten Typ besitzt oder um ein Enrichment, das + // einen nicht registrierten EnrichmentKey verwendet: in diesem Fall wird der // EnrichmentType TextType angenommen (einfacher Text) $enrichmentType = new Opus_Enrichment_TextType(); } - if ($enrichmentType->getFormElementName() === 'Select') { - // Sonderbehandlung für Select-Formularfeld erforderlich: aktuellen Enrichment-Wert - // im vorliegenden Dokument in Auswahlliste eintragen, sofern er nicht bereits in der - // Auswahlliste enthalten ist - $element = $this->createSelectFormElement($enrichmentType, $value); - } else { - // neues Formularfeld für die Eingabe des Enrichment-Wertes erzeugen - $element = $enrichmentType->getFormElement($value); + $value = $enrichmentValue; + if (is_null($value)) { + // wird durch das Klicken auf den Hinzufügen-Button ein neue Formularzeile + // für die Eingabe eines Enrichments hinzugefügt und ist der Typ des Schlüssels + // der Select-Typ, so gilt der erste Auswahlwert als vorausgewählt + if ($enrichmentType->getFormElementName() === 'Select') { + $values = $enrichmentType->getValues(); + // zusätzliche Prüfung hier erforderlich, weil die Typkonfiguration (Werteliste) bei Select-Typ + // kein Pflichtfeld ist (TODO Jens angefragt, ob das geändert werden soll) + if (! empty($values)) { + $value = $values[0]; + } + } } + // neues Formularfeld für die Eingabe des Enrichment-Wertes erzeugen + // wenn $value bezüglich der Typkonfiguration nicht zulässig ist, + // wird $value durch den nachfolgenden Methodenaufruf nicht gesetzt + $element = $enrichmentType->getFormElement($value); + // neues Formularelement soll vor dem Entfernen-Button erscheinen $element->setOrder(2); @@ -137,14 +160,43 @@ private function setEnrichmentValueFormElement($enrichmentKey, $value = null) $elements[self::ELEMENT_VALUE] = $element; $this->setElements($elements); - if (! $enrichmentType->isStrictValidation()) { - // verstößt der im Enrichment gespeicherte Wert gegen die aktuelle Typkonfiguration - if (! is_null($value) && ! $element->isValid($value)) { - // Hinweistext anzeigen, der auf Verstoß hinweist - $element->markAsError(); - $this->handleValidationErrorNonStrict(); + if (! is_null($enrichmentValue)) { + if (! $enrichmentType->isStrictValidation()) { + // verstößt der im Enrichment gespeicherte Wert gegen die aktuelle Typkonfiguration? + // (Verstoß wird angezeigt, allerdings wird das Speichern zugelassen, sofern der Wert + // vom Benutzer nicht verändert wurde) + $elementValue = $element->getValue(); + $isValidValue = false; + if (! ($elementValue === false)) { + $isValidValue = $element->isValid($value); + + // der Aufruf der isValid-Methode hat einen Seiteneffekt, der bei Select-Elementen + // zum Ersetzen des Index durch den tatsächlichen Wert führt + $this->setDefault($element->getName(), $elementValue); + } + + if (! $isValidValue) { + // in einem Select-Feld kann nur der erste Wert gegen die Typkonfiguration verstoßen + if ($enrichmentType->getFormElementName() === 'Select' && $formValue == 0) { + // Hinweistext anzeigen, der auf Verstoß hinweist + $this->handleValidationErrorNonStrict($enrichmentKey); + } + else { + // wenn der Formularwert mit dem gespeicherten Wert übereinstimmt, + // dann im "Non Strict"-Mode Hinweis für den Benutzer anzeigen + if (is_null($formValue) || $enrichmentValue === $formValue) { + $this->handleValidationErrorNonStrict($enrichmentKey); + } + } + } } } + + if ($enrichmentType->getFormElementName() === 'Select') { + // Sonderbehandlung für Select-Formularfeld erforderlich: aktuellen Enrichment-Wert + // in Auswahlliste eintragen, sofern er nicht bereits in der Auswahlliste enthalten ist + $this->addOptionToSelectElement($element, $enrichmentType, $value); + } } /** @@ -153,45 +205,21 @@ private function setEnrichmentValueFormElement($enrichmentKey, $value = null) * der nicht in der konfigurierten Werteliste im Enrichment-Key enthalten ist. Ein solcher Wert * soll dennoch (als erster Eintrag) im Select-Formularfeld zur Auswahl angeboten werden. * - * @param Opus_Enrichment_SelectType $enrichmentType - * @param string $value + * @param Zend_Form_Element_Select $element Select-Formularfeld + * @param Opus_Enrichment_SelectType $enrichmentType Enrichment-Typ + * @param string $value Wert, der zur Auswahlliste hinzugefügt werden soll */ - private function createSelectFormElement($enrichmentType, $value) + private function addOptionToSelectElement($element, $enrichmentType, $value) { - if (is_null($value)) { - $enrichmentId = $this->getElement(self::ELEMENT_ID)->getValue(); - try { - $enrichment = new Opus_Enrichment($enrichmentId); - $value = $enrichment->getValue(); - } catch (\Opus\Model\Exception $e) { - // ignore exception silently - } - } - // Feldliste erweitern, wenn $value nicht bereits in der Feldliste auftritt - $addValueToOptions = ! is_null($value) && ! in_array($value, $enrichmentType->getValues()); - if ($addValueToOptions) { - // Erweiterung der Feldliste des Select-Elements erforderlich - $values = $enrichmentType->getValues(); - array_unshift($values, $value); // zusätzlichen Wert am Anfang hinzufügen - $enrichmentType->setValues($values); - } - - $element = $enrichmentType->getFormElement($value); - - if ($addValueToOptions && $enrichmentType->isStrictValidation()) { + if (! is_null($value) && ! in_array($value, $enrichmentType->getValues())) { // in diesem Fall muss sichergestellt werden, dass der ursprüngliche Wert des Enrichments // im vorliegenden Dokument nicht mehr als gültig betrachtet und daher nicht mehr gespeichert werden darf - $validator = $element->getValidator('Zend_Validate_InArray'); - - // erster Wert (der nach der EnrichmentKey-Konfiguration nun nicht mehr gültig ist) muss - // aus der Liste der als gültig akzeptierten Werte entfernt werden und der Validator aktualisiert werden - $haystack = $validator->getHaystack(); - array_shift($haystack); - $validator->setHaystack($haystack); + $values = $enrichmentType->getValues(); + array_unshift($values, $value); // zusätzlichen Wert am Anfang hinzufügen + $element->setMultiOptions($values); + $element->setValue(0); } - - return $element; } /** @@ -223,15 +251,18 @@ public function updateModel($enrichment) // auch dann gespeichert werden, wenn er gemäß der Konfiguration des Enrichment-Keys // eigentlich nicht gültig ist: in diesem Fall keinen neuen Wert im Enrichment setzen $indexOffset = 0; - if (! in_array($enrichment->getValue(), $enrichmentType->getValues())) { - if ($enrichmentValue == 0) { - return; // keine Änderung des Enrichment-Werts - } + if (! is_null($enrichment->getId())) { + // keine Behandlung von Enrichments, die noch nicht in der Datenbank gespeichert sind, + // (nach dem Hinzufügen von Enrichments über Hinzufügen-Button) + if (! in_array($enrichment->getValue(), $enrichmentType->getValues())) { + if ($enrichmentValue == 0) { + return; // keine Änderung des Enrichment-Werts + } - // beim Mapping von Select-Feldwertindex auf tatsächlichen Wert aus Typkonfiguration 1 abziehen - $indexOffset = -1; + // beim Mapping von Select-Feldwertindex auf tatsächlichen Wert aus Typkonfiguration 1 abziehen + $indexOffset = -1; + } } - $enrichmentValue = $enrichmentType->getValues()[$enrichmentValue + $indexOffset]; } } @@ -277,20 +308,21 @@ public function loadDefaultDecorators() } /** - * Initialisierung des Formularelements für den Enrichment-Wert in - * Abhängigkeit vom EnrichmentType des ausgewählten Enrichment-Keys. + * Initialisierung des Formularelements für den Enrichment-Wert in Abhängigkeit vom EnrichmentType des + * ausgewählten Enrichment-Keys. + * + * Der Name des Enrichment-Key kann als optionales Argument übergeben werden. Wird kein Enrichment-Key-Name übergeben, + * so wird der erste Enrichment-Key (in der nach Name sortierten Reihenfolge) betrachtet. * - * Der Name des Enrichment-Key kann als optionales Argument übergeben werden. - * Wird kein Name übergeben, so wird der erste Enrichment-Key (in der nach - * Name sortierten Reihenfolge) betrachtet. + * Diese Methode wird nur im Kontext der Verarbeitung eines POST-Requests aufgerufen. * * @param string|null $enrichmentKeyName Name eines Enrichment-Keys oder null - * @param string|null $enrichmentId ID des Enrichments + * @param string|null $enrichmentId ID des Enrichments, das in der Datenbank gespeichert ist oder null + * @param string|null $formValue aktueller Formularwert für den Enrichment-Wert oder null */ - public function initEnrichmentValueElement($enrichmentKeyName = null, $enrichmentId = null) + public function initValueFormElement($enrichmentKeyName = null, $enrichmentId = null, $formValue = null) { - // wurde kein Name eines Enrichment-Keys übergeben, so ermittle den Namen - // des ersten Enrichment-Keys im Auswahlfeld + // wurde kein EnrichmentKey-Name übergeben, so ermittle den Namen des ersten Enrichment-Keys im Auswahlfeld if (is_null($enrichmentKeyName)) { $enrichmentKeyElement = $this->getElement(self::ELEMENT_KEY_NAME); $allEnrichmentKeys = $enrichmentKeyElement->getMultiOptions(); @@ -301,37 +333,103 @@ public function initEnrichmentValueElement($enrichmentKeyName = null, $enrichmen } } + $enrichment = null; + if (! is_null($enrichmentId)) { + // Formularfeld zeigt den Wert eines in der Datenbank gespeicherten Enrichments + try { + $enrichment = new Opus_Enrichment($enrichmentId); + } catch (\Opus\Model\Exception $e) { + // ignore exception silently + } + } + $enrichmentKey = Opus_EnrichmentKey::fetchByName($enrichmentKeyName); - if (! is_null($enrichmentKey)) { - // hier braucht erstmal nur das Formularelement für die Eingabe des - // Enrichment-Wertes erzeugt und in das bestehende Formular eingebunden - // werden - der konkrete Wert des Enrichments wird später durch einen andere Methode - // gesetzt + if (is_null($enrichmentKey)) { + if (! is_null($enrichment) && ($enrichmentKeyName === $enrichment->getKeyName())) { + // der im Enrichment gespeicherte EnrichmentKey-Name ist nicht registriert + $this->getLogger()->info("processing of unregistered enrichment key name '$enrichmentKeyName'"); + } + else { + // der im POST übergebene EnrichmentKey-Name ist nicht registriert und stimmt nicht mit dem + // im Enrichment gespeicherten EnrichmentKey-Name überein: POST wurde manipuliert - Fallback auf + // den ersten Auswahlwert + $this->getLogger()->warn("could not find enrichment key with name '$enrichmentKeyName'"); + } + } - $valueToBeAdded = null; - if (! is_null($enrichmentId)) { - try { - $enrichment = new Opus_Enrichment($enrichmentId); - // besondere Überprüfung beim Select-Feld erforderlich: hier muss ggf. der aktuell - // im Enrichment gespeicherte Wert zur Werteliste des Select-Felds hinzugefügt werden, - // wenn er nicht bereits enthalten ist - $enrichmentType = $enrichment->getEnrichmentKey()->getEnrichmentType(); - if (! is_null($enrichmentType) && $enrichmentType->getFormElementName() == 'Select') { - $enrichmentValue = $enrichment->getValue(); - if (! in_array($enrichmentValue, $enrichmentType->getValues())) { - $valueToBeAdded = $enrichmentValue; - } - } - } catch (\Opus\Model\Exception $e) { - // ignore exception silently + $enrichmentValue = is_null($enrichment) ? null : $enrichment->getValue(); + $this->createValueFormElement($enrichmentValue, $enrichmentKey, $formValue); + } + + /** + * wenn ein Enrichment bereits in der Datenbank gespeichert ist und einen nicht registrierten + * EnrichmentKey verwendet, so muss der Name des EnrichmentKey als zusätzlcher Auswahlwert + * im Select-Element ELEMENT_KEY_NAME aufgenommen werden + * + * @param $enrichmentKeyName + * @param $enrichmentId + */ + private function initEnrichmentKeyNameElement($enrichmentKeyName, $enrichmentId) + { + if (is_null($enrichmentKeyName) || is_null($enrichmentId)) { + return; + } + + $enrichment = null; + try { + $enrichment = new Opus_Enrichment($enrichmentId); + } catch (\Opus\Model\Exception $e) { + // ignore silently + return; + } + + if (! is_null($enrichment)) { + $keyNameElement = $this->getElement(self::ELEMENT_KEY_NAME); + if (! $keyNameElement->hasKeyName($enrichmentKeyName)) { + // der nicht registrierte EnrichmentKey-Name wird nur dann zum Auswahlfeld + // hinzugefügt, wenn er mit dem KeyName des in der Datenbank gespeicherten + // Enrichments übereinstimmt (sonst könnte man durch Manipulationd des POST- + // Request beliebige EnrichmentKeys verwenden) + if ($enrichmentKeyName === $enrichment->getKeyName()) { + $keyNameElement->addKeyNameIfMissing($enrichmentKeyName); + $this->getLogger()->debug('added option ' . $enrichmentKeyName . ' to enrichment key name element'); } } - $this->setEnrichmentValueFormElement($enrichmentKey, $valueToBeAdded); - } else { - $this->getLogger()->err('could not find enrichment key with name ' . $enrichmentKey); } } + /** + * Initialisiert das Formularelement für die Eingabe des Enrichment-Wertes. + * Diese Methode wird nur im Kontext der Verarbeitung eines POST-Requests + * aufgerufen. + * + * @param array $post Array mit den im POST-Requests übergebenen Daten + */ + public function initValueElement($post) + { + $subFormName = $this->getName(); + $enrichmentKeyName = null; + if (array_key_exists($subFormName, $post)) { + $enrichmentKeyName = $post[$subFormName][self::ELEMENT_KEY_NAME]; + } + + $enrichmentId = null; + if (array_key_exists(self::ELEMENT_ID, $post[$subFormName])) { + $enrichmentId = $post[$subFormName][self::ELEMENT_ID]; + if ($enrichmentId == '') { + $enrichmentId = null; + } + } + + $enrichmentValue = null; + if (array_key_exists(self::ELEMENT_VALUE, $post[$subFormName])) { + $enrichmentValue = $post[$subFormName][self::ELEMENT_VALUE]; + } + + $this->initEnrichmentKeyNameElement($enrichmentKeyName, $enrichmentId); + $this->initValueFormElement($enrichmentKeyName, $enrichmentId, $enrichmentValue); + } + /** * Bei der Anzeige des Formulars im Non-Edit-Mode soll auch eine Ausgabe erfolgen, * wenn der EnrichmentType als Checkbox dargestellt wird. In diesem Fall soll @@ -346,20 +444,64 @@ public function prepareRenderingAsView() $this->setRemoveEmptyCheckbox(false); $element = $this->getElement(self::ELEMENT_VALUE); - $element->setAttrib('data-opusValidationError', 'false'); + $element->setAttrib('data-opusValidationError', 'false'); // wird vom JavaScript-Code ausgewertet $element->removeDecorator('Errors'); + $element->removeDecorator('Hint'); parent::prepareRenderingAsView(); } + private function handleSelectFieldStrict($enrichmentData, $enrichmentType, $parentValidationResult) { + if (array_key_exists(self::ELEMENT_VALUE, $enrichmentData)) { + $formValue = $enrichmentData[self::ELEMENT_VALUE]; // das ist nicht der ausgewählte Wert, sondern der Index des Wertes innerhalb der Select-Liste + if ($formValue == 0) { + // der ausgewählte Wert ist nicht zulässig, wenn der gespeicherte Enrichmentwert gegen + // die Typkonfiguration verstößt: in diesem Fall erscheint der ungültige Wert als erster + // Auswahlfeld im Select-Element + $enrichmentId = $enrichmentData[self::ELEMENT_ID]; + $enrichment = null; + try { + $enrichment = new Opus_Enrichment($enrichmentId); + } catch (Opus\Model\Exception $e) { + // ignore exception silently and do not change validation result + } + + if (! is_null($enrichment) && array_search($enrichment->getValue(), $enrichmentType->getValues()) === false) { + $this->getElement(self::ELEMENT_VALUE)->addError($this->handleEnrichmentKeySpecificTranslations('errorMessage', $enrichment->getKeyName())); + return false; // Auswahlwert ist nach Typkonfiguration nicht zulässig + } + } + else { + $options = $enrichmentType->getValues(); + if ($formValue == count($options)) { + // durch die Hinzufügung des aktuell im Enrichment gespeicherten Wertes (der nicht + // in der Typkonfiguration aufgeführt ist) verlängert sich die Select-Auswahlliste + // um einen Eintrag (weil der ungültige Wert aus dem Enrichment an die erste Stelle + // eingeführt wird, steht an der letzten Stelle ein gültiger Wert aus der Typkonfiguration) + + $this->ignoreValueErrors = true; + + // Fehlermeldung am Formularelement löschen + $this->getElement(self::ELEMENT_VALUE)->removeDecorator('Errors'); + + return true; + } + } + } + return $parentValidationResult; + } + + /** + * Diese Methode wird nur bei der Verarbeitung eines POST-Requests aufgerufen. + * + * @param array $data + * @return bool + * @throws Zend_Form_Exception + */ public function isValid($data) { $validationResult = parent::isValid($data); - if ($validationResult) { - return true; // keine Validierungsfehler gefunden - } - // ggf. kann das negative Validierungsergebnis noch auf "positiv" (true / valid) geändert werden, // wenn die Validation Policy des Enrichment Types des verwendeten Enrichment Keys auf "none" // gesetzt wurde und sich der Enrichment-Wert im POST-Request nicht vom ursprünglich im @@ -368,48 +510,95 @@ public function isValid($data) $enrichmentKey = Opus_EnrichmentKey::fetchByName($enrichmentData[self::ELEMENT_KEY_NAME]); if (! is_null($enrichmentKey)) { $enrichmentType = $enrichmentKey->getEnrichmentType(); - if (! is_null($enrichmentType) && ! $enrichmentType->isStrictValidation()) { - // hat sich der Enrichment-Wert nicht geändert, so ist der (nicht geänderte) - // Enrichment-Wert weiterhin gültig, auch wenn er gegen die Typkonfiguration verstößt + if (! is_null($enrichmentType)) { + if ($enrichmentType->isStrictValidation()) { + if ($enrichmentType->getFormElementName() == 'Select') { - if (! array_key_exists(self::ELEMENT_ID, $enrichmentData)) { - return false; // negatives Validierungsergebnis bleibt bestehen - } + // wenn der erste Auswahlwert im Select-Element gewählt wurde, so muss geprüft werden, ob + // dieser Wert möglicherweise gegen die Typkonfiguration verstößt (als erster Wert wird immer + // der aktuell im Enrichment gespeicherte Wert verwendet - dieser kann möglicherweise gegen + // die aktuell gültige Typkonfiguration verstoßen) + // in diesem Fall muss isValid den Wert false zurückliefern - $enrichmentId = $enrichmentData[self::ELEMENT_ID]; - try { - $enrichment = new Opus_Enrichment($enrichmentId); + $validationResult = $this->handleSelectFieldStrict($enrichmentData, $enrichmentType, $validationResult); + } + } + else { + // hat sich der Enrichment-Wert nicht geändert, so ist der (nicht geänderte) + // Enrichment-Wert weiterhin gültig, auch wenn er gegen die Typkonfiguration verstößt - if (! array_key_exists(self::ELEMENT_VALUE, $enrichmentData)) { + if (! array_key_exists(self::ELEMENT_ID, $enrichmentData)) { return false; // negatives Validierungsergebnis bleibt bestehen } - $formValue = $enrichmentData[self::ELEMENT_VALUE]; - if ($enrichmentType->getFormElementName() == 'Select') { - // bei Select-Formularfeldern wird im POST-Request nicht der ausgewählte Wert, - // sondern der Index des Wertes in der Auswahlliste zurückgeben: daher ist hier - // ein zusätzlicher Schritt zur Ermittlung des Formularwertes erforderlich - $options = $this->getElement(self::ELEMENT_VALUE)->getMultiOptions(); - $formValueAsInt = intval($formValue); - if (0 <= $formValueAsInt && $formValueAsInt < count($options)) { - $formValue = $options[$formValueAsInt]; - } else { - $formValue = null; + $enrichmentId = $enrichmentData[self::ELEMENT_ID]; + try { + $enrichment = new Opus_Enrichment($enrichmentId); + + if (! array_key_exists(self::ELEMENT_VALUE, $enrichmentData)) { + return false; // negatives Validierungsergebnis bleibt bestehen } + + $formValue = $enrichmentData[self::ELEMENT_VALUE]; + $formValueAsInt = -1; + if ($enrichmentType->getFormElementName() == 'Select') { + // bei Select-Formularfeldern wird im POST-Request nicht der ausgewählte Wert, + // sondern der Index des Wertes in der Auswahlliste zurückgeben: daher ist hier + // ein zusätzlicher Schritt zur Ermittlung des Formularwertes erforderlich + $options = $this->getElement(self::ELEMENT_VALUE)->getMultiOptions(); + $formValueAsInt = intval($formValue); + if (0 <= $formValueAsInt && $formValueAsInt < count($options)) { + $formValue = $options[$formValueAsInt]; + } else { + $formValue = null; + } + } + + if (! is_null($formValue) && $enrichment->getValue() === $formValue) { + // Wert des Enrichments wurde nicht geändert und es findet keine strikte Validierung statt + // Validierungsergebnis für das Gesamtformular wird daher auf "positiv" geändert + $this->ignoreValueErrors = true; + + // zusätzlicher Schritt: es könnte sein, dass der Ursprungswert gegn die Typkonfiguration + // verstößt: in diesem Fall einen grauen Hinweis anzeigen + + $valueElem = $this->getElement(self::ELEMENT_VALUE); + if ($enrichmentType->getFormElementName() == 'Select') { + $formElementValidation = in_array($formValue, $enrichmentType->getValues()); + } + else { + $formElementValidation = $valueElem->isValid($formValue); + } + if (! $formElementValidation) { + // grauen Hinweis auf Verstoß anzeigen, weil der ursprüngliche Feldwert gegen die + // Typkonfiguration verstößt + $this->handleValidationErrorNonStrict($enrichmentKey); + } + return true; + } + else { + // Sonderbehandlung bei Select-Feldern: hier ist der letzte Wert als gültig zu betrachten, + // wenn in die Select-Liste der bzgl. der Typkonfiguration ungültige Wert als erster Eintrag + // aufgenommen wurde + if ($enrichmentType->getFormElementName() == 'Select') { + $options = $enrichmentType->getValues(); + if ($formValueAsInt == count($options)) { + $this->ignoreValueErrors = true; + + // Fehlermeldung am Formularelement löschen + $this->getElement(self::ELEMENT_VALUE)->removeDecorator('Errors'); + + return true; + } + } + } + } catch (Opus\Model\Exception $e) { + // ignore exception silently: do not change validation result } - if (! is_null($formValue) && $enrichment->getValue() === $formValue) { - // Wert des Enrichments wurde nicht geändert und es findet keine strikte Validierung statt - // Validierungsergebnis wird daher auf "positiv" geändert - $this->ignoreValueErrors = true; - $this->handleValidationErrorNonStrict(); - return true; - } - } catch (Opus\Model\Exception $e) { - // ignore exception silently: do not change validation result } } } - return false; + return $validationResult; } /** @@ -438,13 +627,44 @@ public function getErrors($name = null, $suppressArrayNotation = false) * Fehlermeldung angezeigt. Der unveränderte (aber bezüglich der aktuellen Typkonfiguration invalide) * Wert lässt sicher weiterhin speichern. * + * Wichtig: diese Methode muss sowohl beim ersten Formularaufruf (GET-Request) als auch beim + * Speichern des Formulars (POST-Request) aufgerufen werden, wenn es Validierungsfehler gibt. + * + * @param Opus_EnrichmentKey $enrichmentKey Name des Enrichment-Keys + * * @throws Zend_Form_Exception */ - private function handleValidationErrorNonStrict() + private function handleValidationErrorNonStrict($enrichmentKey = null) { $element = $this->getElement(self::ELEMENT_VALUE); - $element->setAttrib('data-opusValidationError', 'true'); - $decorator = $element->getDecorator('Errors'); - $decorator->setOption('class', 'errors datahint'); + $element->setAttrib('data-opusValidationError', 'true'); // wird vom JavaScript-Code ausgewertet + + $enrichmentKeyName = null; + if (! is_null($enrichmentKey)) { + $enrichmentKeyName = $enrichmentKey->getName(); + } + $hint = $this->handleEnrichmentKeySpecificTranslations('validationMessage', $enrichmentKeyName); + $element->setHint($hint); + + $element->removeDecorator('Errors'); + + // FIXME kann weg -> Abhängigkeiten prüfen + //$decorator = $element->getDecorator('Errors'); + //$decorator->setOption('class', 'errors datahint'); } + + private function handleEnrichmentKeySpecificTranslations($keySuffix, $enrichmentKeyName = null) + { + $translator = $this->getTranslator(); + $translationPrefix = 'admin_enrichment_'; + if (! is_null($enrichmentKeyName)) { + $translationKey = $translationPrefix . $enrichmentKeyName . '_' . $keySuffix; + if ($translator->isTranslated($translationKey)) { + return $translator->translate($translationKey); + } + } + + return $translator->translate($translationPrefix . $keySuffix); + } + } diff --git a/modules/admin/forms/Document/MultiEnrichmentSubForm.php b/modules/admin/forms/Document/MultiEnrichmentSubForm.php index c6f180e633..2c2d2aab32 100644 --- a/modules/admin/forms/Document/MultiEnrichmentSubForm.php +++ b/modules/admin/forms/Document/MultiEnrichmentSubForm.php @@ -115,7 +115,9 @@ public function processPost($data, $context) // die Eingabe des Enrichmentwerts) auswählen und behandeln $newSubForm = end($subForms); if ($newSubForm instanceof Admin_Form_Document_Enrichment) { - $newSubForm->initEnrichmentValueElement(); + // expliziter Aufruf der nachfolgenden Methoden an dieser Stelle erforderlich, weil + // die Methode processPost erst nach der Methode constructFromPost aufgerufen wird + $newSubForm->initValueFormElement(); $this->prepareSubFormDecorators($newSubForm); } } @@ -177,23 +179,8 @@ public function constructFromPost($post, $document = null) foreach ($this->getSubForms() as $subForm) { if ($subForm instanceof Admin_Form_Document_Enrichment) { - $subFormName = $subForm->getName(); - $enrichmentKeyName = null; - if (array_key_exists($subFormName, $post)) { - $enrichmentKeyName = $post[$subFormName][Admin_Form_Document_Enrichment::ELEMENT_KEY_NAME]; - } - - // es ist zu prüfen, ob das Enrichment einen Wert verwendet, der in der - // Typkonfiguration nicht angegeben ist - $enrichmentId = null; - if (array_key_exists(Admin_Form_Document_Enrichment::ELEMENT_ID, $post[$subFormName])) { - $enrichmentId = $post[$subFormName][Admin_Form_Document_Enrichment::ELEMENT_ID]; - if ($enrichmentId == '') { - $enrichmentId = null; - } - } + $subForm->initValueElement($post); - $subForm->initEnrichmentValueElement($enrichmentKeyName, $enrichmentId); } $this->prepareSubFormDecorators($subForm); } diff --git a/modules/admin/language/enrichments.tmx b/modules/admin/language/enrichments.tmx new file mode 100644 index 0000000000..59f86e20ab --- /dev/null +++ b/modules/admin/language/enrichments.tmx @@ -0,0 +1,26 @@ + + + +
+
+ + + + The value provided is not valid. + + + Dieser Wert ist nicht gültig. + + + + + + The value provided is not valid. However, it can be left unchanged. + + + Dieser Wert ist nicht gültig. Er kann aber unverändert beibehalten werden. + + + + +
\ No newline at end of file diff --git a/public/layouts/opus4/js/validation.js b/public/layouts/opus4/js/validation.js index 9840827e20..a2fe76d94e 100644 --- a/public/layouts/opus4/js/validation.js +++ b/public/layouts/opus4/js/validation.js @@ -277,7 +277,7 @@ $(document).ready(function () { */ $("input[data-opusValidationError='true'], select[data-opusValidationError='true']").on('input', function (event) { var element = $(this); - var errorMessage = element.next(".errors"); + var errorMessage = element.next(".datahint"); if (errorMessage) { var oldValue = errorMessage.data('errorValue'); if (typeof oldValue === 'undefined' && (typeof event.target.defaultValue !== 'undefined')) { diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index 8ba8fdb2ad..dbf1910a90 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -37,7 +37,7 @@ class Admin_Form_Document_EnrichmentTest extends ControllerTestCase { - protected $additionalResources = ['database']; + protected $additionalResources = ['database', 'translation']; public function testCreateForm() { @@ -245,7 +245,7 @@ public function testUpdateModel() $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); - $form->initEnrichmentValueElement($keyName); + $form->initValueFormElement($keyName); $form->getElement('KeyName')->setValue($keyName); $form->getElement('Value')->setValue('Test Enrichment Value'); @@ -266,7 +266,7 @@ public function testUpdateModelWithSelectType() ); $form = new Admin_Form_Document_Enrichment(); - $form->initEnrichmentValueElement('select'); + $form->initValueFormElement('select'); $form->getElement('KeyName')->setValue('select'); $form->getElement('Value')->setValue(1); // Index des ausgewählten Werts @@ -281,7 +281,7 @@ public function testUpdateModelWithSelectType() $this->assertEquals('bar', $enrichment->getValue()); } - public function testUpdateModelWithSelectTypeWithInvalidValueAndNoValidationAndInvalidValue() + public function testUpdateModelWithSelectTypeWithInvalidValueAndNoValidation() { $enrichmentKey = $this->createTestEnrichmentKey( 'select', @@ -292,21 +292,21 @@ public function testUpdateModelWithSelectTypeWithInvalidValueAndNoValidationAndI ] ); - $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select', 'foobar'); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select'); $form = new Admin_Form_Document_Enrichment(); - $form->initEnrichmentValueElement('select', $enrichmentId); + $form->initValueFormElement('select', $enrichmentId); $form->getElement('KeyName')->setValue('select'); $form->getElement('Value')->setValue(0); // Index des ausgewählten Werts: der Ursprungswert des Enrichments (foobar) - $enrichment = new Opus_Enrichment(); - $enrichment->setValue('foobar'); // das Enrichment-Formular wird nur für Enrichments mit gesetztem Wert aufgerufen + $enrichment = new Opus_Enrichment($enrichmentId); $form->updateModel($enrichment); + // cleanup $enrichmentKey->delete(); $this->assertEquals('select', $enrichment->getKeyName()); - $this->assertEquals('foobar', $enrichment->getValue()); + $this->assertEquals('testvalue', $enrichment->getValue()); } public function testUpdateModelWithSelectTypeWithInvalidValueAndNoValidationAndValidValue() @@ -320,15 +320,14 @@ public function testUpdateModelWithSelectTypeWithInvalidValueAndNoValidationAndV ] ); - $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select', 'foobar'); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select'); $form = new Admin_Form_Document_Enrichment(); - $form->initEnrichmentValueElement('select', $enrichmentId); + $form->initValueFormElement('select', $enrichmentId); $form->getElement('KeyName')->setValue('select'); $form->getElement('Value')->setValue(1); // Index des ausgewählten Werts: foo - $enrichment = new Opus_Enrichment(); - $enrichment->setValue('foobar'); // das Enrichment-Formular wird nur für Enrichments mit gesetztem Wert aufgerufen + $enrichment = new Opus_Enrichment($enrichmentId); $form->updateModel($enrichment); $enrichmentKey->delete(); @@ -347,7 +346,7 @@ public function testGetModel() $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); - $form->initEnrichmentValueElement($keyName); + $form->initValueFormElement($keyName); $form->getElement('Id')->setValue($enrichment->getId()); $form->getElement('KeyName')->setValue($keyName); $form->getElement('Value')->setValue('Test Enrichment Value'); @@ -365,7 +364,7 @@ public function testGetNewModel() $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); - $form->initEnrichmentValueElement($keyName); + $form->initValueFormElement($keyName); $form->getElement('KeyName')->setValue($keyName); $form->getElement('Value')->setValue('Test Enrichment Value'); @@ -383,7 +382,7 @@ public function testGetModelUnknownId() $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); - $form->initEnrichmentValueElement($keyName); + $form->initValueFormElement($keyName); $logger = new MockLogger(); @@ -410,7 +409,7 @@ public function testGetModelBadId() $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); - $form->initEnrichmentValueElement($keyName); + $form->initValueFormElement($keyName); $form->getElement('Id')->setValue('bad'); $form->getElement('KeyName')->setValue($keyName); @@ -426,11 +425,11 @@ public function testGetModelBadId() public function testValidationWithoutType() { $keyNames = Opus_EnrichmentKey::getAll(); - $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren + $keyName = $keyNames[1]->getName(); // Test geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement($keyName); + $form->initValueFormElement($keyName); $post = [ 'Enrichment0' => [ @@ -449,49 +448,111 @@ public function testValidationWithoutType() $this->assertContains('isEmpty', $form->getErrors('Value')); } - public function testValidationWithSelectType() + private function createTestSelectType($options, $strictValidation = false) { - $options = ['foo', 'bar', 'baz']; $selectOptions = ['values' => $options]; + if ($strictValidation) { + $selectOptions['validation'] = 'strict'; + } + else { + $selectOptions['validation'] = 'none'; + } + $type = new Opus_Enrichment_SelectType(); $type->setOptions($selectOptions); + return $type; + } - $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); + private function createTestRegexType($regex, $strictValidation = false) + { + $options = ['regex' => $regex]; + if ($strictValidation) { + $options['validation'] = 'strict'; + } + else { + $options['validation'] = 'none'; + } + + $type = new Opus_Enrichment_RegexType(); + $type->setOptions($options); + return $type; + } + + public function testValidationNoneWithSelectTypeFirstOption() + { + $options = ['foo', 'bar', 'baz']; + $type = $this->createTestSelectType($options); + + $enrichmentKey = $this->createEnrichmentKey('select', $type); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select', $options[0]); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('select'); + $form->initValueFormElement('select'); $post = [ 'Enrichment0' => [ + 'Id' => $enrichmentId, 'KeyName' => 'select', - 'Value' => 1 + 'Value' => 0 // entspricht dem ersten Auswahlwert (foo) ] ]; $result = $form->isValid($post); + + // cleanup + $enrichmentKey->delete(); + $this->assertTrue($result); $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(0, $form->getErrors('Value')); + } + + public function testValidationNoneWithSelectTypeLastOption() + { + $options = ['foo', 'bar', 'baz']; + $type = $this->createTestSelectType($options); + + $enrichmentKey = $this->createEnrichmentKey('select', $type); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select', $options[count($options) - 1]); + + $form = new Admin_Form_Document_Enrichment(); + $form->setName('Enrichment0'); + $form->initValueFormElement('select'); + $post = [ + 'Enrichment0' => [ + 'Id' => $enrichmentId, + 'KeyName' => 'select', + 'Value' => count($options) - 1 // entspricht dem letzten Auswahlwert (baz) + ] + ]; + + $result = $form->isValid($post); + + // cleanup $enrichmentKey->delete(); + + $this->assertTrue($result); + + $this->assertCount(0, $form->getErrors('KeyName')); + $this->assertCount(0, $form->getErrors('Value')); } - public function testValidationWithSelectTypeMissingValue() + public function testValidationNoneWithSelectTypeAndMissingValue() { $options = ['foo', 'bar', 'baz']; - $selectOptions = ['values' => $options]; - $type = new Opus_Enrichment_SelectType(); - $type->setOptions($selectOptions); + $type = $this->createTestSelectType($options); - $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); + $enrichmentKey = $this->createEnrichmentKey('select', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('select'); + $form->initValueFormElement('select'); + // im POST-Request fehlt die Angabe des ausgewählten Wertes des Select-Formularfelds $post = [ 'Enrichment0' => [ 'Id' => $enrichmentId, @@ -499,126 +560,237 @@ public function testValidationWithSelectTypeMissingValue() ] ]; - $this->assertFalse($form->isValid($post)); + $result = $form->isValid($post); + + // cleanup + $enrichmentKey->delete(); + + $this->assertFalse($result); $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); $this->assertContains('isEmpty', $form->getErrors('Value')); - - $enrichmentKey->delete(); } - public function testValidationWithSelectTypeInvalidValue() + public function testValidationNoneWithSelectTypeAndInvalidValue() { $options = ['foo', 'bar', 'baz']; - $selectOptions = ['values' => $options]; - $type = new Opus_Enrichment_SelectType(); - $type->setOptions($selectOptions); + $type = $this->createTestSelectType($options); - $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); + $enrichmentKey = $this->createEnrichmentKey('select', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('select'); + $form->initValueFormElement('select'); $post = [ 'Enrichment0' => [ 'Id' => $enrichmentId, 'KeyName' => 'select', - 'Value' => 3 // es gibt keine 4. Option (nur Werte von 0 bis 2 erlaubt) + 'Value' => count($options) + 1 // diese Option nicht zulässig ] ]; - $this->assertFalse($form->isValid($post)); + $result = $form->isValid($post); + + // cleanup + $enrichmentKey->delete(); + + $this->assertFalse($result); $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); $this->assertContains('notInArray', $form->getErrors('Value')); + } + public function testValidationNoneWithSelectTypeAndValidValue() + { + $options = ['foo', 'bar', 'baz']; + $type = $this->createTestSelectType($options); + + $enrichmentKey = $this->createEnrichmentKey('select', $type); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select'); + + $form = new Admin_Form_Document_Enrichment(); + $form->setName('Enrichment0'); + $form->initValueFormElement('select', $enrichmentId, count($options)); + + $post = [ + 'Enrichment0' => [ + 'Id' => $enrichmentId, + 'KeyName' => 'select', + 'Value' => count($options) // Option ist zulässig (weil Select-Liste um ungültigen Wert ergänzt wurde) + ] + ]; + + $result = $form->isValid($post); + + $enrichment = new Opus_Enrichment($enrichmentId); + $form->updateModel($enrichment); + $enrichmentValue = $enrichment->getValue(); + + // cleanup $enrichmentKey->delete(); + + $this->assertTrue($result); + + $this->assertCount(0, $form->getErrors('KeyName')); + $this->assertCount(0, $form->getErrors('Value')); + + $this->assertEquals($options[count($options) - 1], $enrichmentValue); } - public function testValidationWithSelectTypeAndStrictValidationAndInvalidValue() + public function testValidationNoneWithSelectTypeAndAcceptedValue() { $options = ['foo', 'bar', 'baz']; - $selectOptions = ['values' => $options, 'validation' => 'strict']; - $type = new Opus_Enrichment_SelectType(); - $type->setOptions($selectOptions); + $type = $this->createTestSelectType($options); - $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); - $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select', 'foobar'); + $enrichmentKey = $this->createEnrichmentKey('select', $type); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('select', $enrichmentId); + $form->initValueFormElement('select', $enrichmentId, count($options)); $post = [ 'Enrichment0' => [ 'Id' => $enrichmentId, 'KeyName' => 'select', - 'Value' => 0 // wählt den im Enrichment gespeicherten Wert (foobar) aus + 'Value' => 0 // Option ist zulässig (weil Select-Liste um ungültigen Wert ergänzt wurde) ] ]; - $this->assertFalse($form->isValid($post)); + $result = $form->isValid($post); + + $enrichment = new Opus_Enrichment($enrichmentId); + $form->updateModel($enrichment); + $enrichmentValue = $enrichment->getValue(); + + // cleanup + $enrichmentKey->delete(); + + $this->assertTrue($result); $this->assertCount(0, $form->getErrors('KeyName')); + $this->assertCount(0, $form->getErrors('Value')); - $this->assertCount(1, $form->getErrors('Value')); - $this->assertContains('notInArray', $form->getErrors('Value')); + $this->assertEquals('testvalue', $enrichmentValue); + } + public function testValidationStrictWithSelectTypeAndInvalidValue() + { + $options = ['foo', 'bar', 'baz']; + $type = $this->createTestSelectType($options, true); + + $enrichmentKey = $this->createEnrichmentKey('select', $type); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select'); + + $form = new Admin_Form_Document_Enrichment(); + $form->setName('Enrichment0'); + $form->initValueFormElement('select', $enrichmentId); + + $post = [ + 'Enrichment0' => [ + 'Id' => $enrichmentId, + 'KeyName' => 'select', + 'Value' => 0 // wählt den im Enrichment gespeicherten Wert (foobar) aus, der aber nicht mehr zulässig ist + ] + ]; + + $result = $form->isValid($post); + + // cleanup $enrichmentKey->delete(); + + $this->assertFalse($result); + + $this->assertCount(0, $form->getErrors('KeyName')); + + $this->assertCount(1, $form->getElement('Value')->getErrorMessages()); } - public function testValidationWithSelectTypeAndStrictValidationAndValidValue() + public function testValidationStrictWithSelectTypeAndFirstValidValue() { $options = ['foo', 'bar', 'baz']; - $selectOptions = ['values' => $options, 'validation' => 'strict']; - $type = new Opus_Enrichment_SelectType(); - $type->setOptions($selectOptions); + $type = $this->createTestSelectType($options, true); - $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); - $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select', 'foobar'); + $enrichmentKey = $this->createEnrichmentKey('select', $type); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('select', $enrichmentId); + $form->initValueFormElement('select', $enrichmentId); $post = [ 'Enrichment0' => [ 'Id' => $enrichmentId, 'KeyName' => 'select', - 'Value' => 3 // wählt den baz aus + 'Value' => 1 // wählt den ersten Auswahlfeld aus Typkonfiguration (foo) aus ] ]; - $this->assertTrue($form->isValid($post)); + $result = $form->isValid($post); + + $this->assertTrue($result); $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(0, $form->getErrors('Value')); $enrichment = new Opus_Enrichment($enrichmentId); $form->updateModel($enrichment); - $this->assertEquals('baz', $enrichment->getValue()); + $this->assertEquals($options[0], $enrichment->getValue()); - $enrichmentKey->delete(); + // cleanup (darf erst nach dem Aufruf der updateModel-Methode passieren) + $enrichmentKey->delete(false); + } + + public function testValidationStrictWithSelectTypeAndLastValidValue() + { + $options = ['foo', 'bar', 'baz']; + $type = $this->createTestSelectType($options, true); + + $enrichmentKey = $this->createEnrichmentKey('select', $type); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select'); + + $form = new Admin_Form_Document_Enrichment(); + $form->setName('Enrichment0'); + $form->initValueFormElement('select', $enrichmentId); + + $post = [ + 'Enrichment0' => [ + 'Id' => $enrichmentId, + 'KeyName' => 'select', + 'Value' => count($options) // wählt den letzten Auswahlfeld aus Typkonfiguration (baz) aus + ] + ]; + + $result = $form->isValid($post); + + $this->assertTrue($result); + $this->assertCount(0, $form->getErrors('KeyName')); + $this->assertCount(0, $form->getErrors('Value')); + + $enrichment = new Opus_Enrichment($enrichmentId); + $form->updateModel($enrichment); + $this->assertEquals($options[count($options) - 1], $enrichment->getValue()); + + // cleanup (darf erst nach dem Aufruf der updateModel-Methode passieren) + $enrichmentKey->delete(false); } public function testValidationWithSelectTypeAndNoValidationAndInvalidValue() { $options = ['foo', 'bar', 'baz']; - $selectOptions = ['values' => $options, 'validation' => 'none']; - $type = new Opus_Enrichment_SelectType(); - $type->setOptions($selectOptions); + $type = $this->createTestSelectType($options); - $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); - $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select', 'foobar'); + $enrichmentKey = $this->createEnrichmentKey('select', $type); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('select'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('select', $enrichmentId); + $form->initValueFormElement('select', $enrichmentId); $post = [ 'Enrichment0' => [ @@ -634,7 +806,7 @@ public function testValidationWithSelectTypeAndNoValidationAndInvalidValue() $enrichment = new Opus_Enrichment($enrichmentId); $form->updateModel($enrichment); - $this->assertEquals('foobar', $enrichment->getValue()); + $this->assertEquals('testvalue', $enrichment->getValue()); $enrichmentKey->delete(); } @@ -644,12 +816,12 @@ public function testValidationWithRegexType() $type = new Opus_Enrichment_RegexType(); $type->setOptions(['regex' => '^abc$']); - $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); + $enrichmentKey = $this->createEnrichmentKey('regex', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('regex'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('regex'); + $form->initValueFormElement('regex'); $post = [ 'Enrichment0' => [ @@ -674,12 +846,12 @@ public function testValidationWithRegexTypeWithMissingValue() $type = new Opus_Enrichment_RegexType(); $type->setOptions(['regex' => '^.*$']); - $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); + $enrichmentKey = $this->createEnrichmentKey('regex', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('regex'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('regex'); + $form->initValueFormElement('regex'); $post = [ 'Enrichment0' => [ @@ -706,12 +878,12 @@ public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() // mit dem Namen soll sichergestellt werden, dass dieser Enrichment-Key // in der Auswahlliste als erster Eintrag auftritt - $enrichmentKey = $this->createEnrichmentKeyAndForm('aaaaaaaa', $type); + $enrichmentKey = $this->createEnrichmentKey('aaaaaaaa', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('aaaaaaaa'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement(); + $form->initValueFormElement(); $post = [ 'Enrichment0' => [ @@ -733,15 +905,14 @@ public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() public function testValidationWithRegexTypeAndStrictValidationWithInvalidOriginalValue() { - $type = new Opus_Enrichment_RegexType(); - $type->setOptions(['regex' => '^abc$', 'validation' => 'strict']); + $type = $this->createTestRegexType('^abc$', true); - $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); + $enrichmentKey = $this->createEnrichmentKey('regex', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('regex', 'invalidvalue'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('regex', $enrichmentId); + $form->initValueFormElement('regex', $enrichmentId); $post = [ 'Enrichment0' => [ @@ -763,15 +934,14 @@ public function testValidationWithRegexTypeAndStrictValidationWithInvalidOrigina public function testValidationWithRegexTypeAndStrictValidationWithInvalidChangedValue() { - $type = new Opus_Enrichment_RegexType(); - $type->setOptions(['regex' => '^abc$', 'validation' => 'strict']); + $type = $this->createTestRegexType('^abc$', true); - $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); + $enrichmentKey = $this->createEnrichmentKey('regex', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('regex', 'invalidvalue'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('regex', $enrichmentId); + $form->initValueFormElement('regex', $enrichmentId); $post = [ 'Enrichment0' => [ @@ -793,15 +963,14 @@ public function testValidationWithRegexTypeAndStrictValidationWithInvalidChanged public function testValidationWithRegexTypeAndStrictValidationWithValidValue() { - $type = new Opus_Enrichment_RegexType(); - $type->setOptions(['regex' => '^abc$', 'validation' => 'strict']); + $type = $this->createTestRegexType('^abc$', true); - $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); + $enrichmentKey = $this->createEnrichmentKey('regex', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('regex', 'abc'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('regex', $enrichmentId); + $form->initValueFormElement('regex', $enrichmentId); $post = [ 'Enrichment0' => [ @@ -821,15 +990,14 @@ public function testValidationWithRegexTypeAndStrictValidationWithValidValue() public function testValidationWithRegexTypeAndNoValidationWithInvalidOriginalValue() { - $type = new Opus_Enrichment_RegexType(); - $type->setOptions(['regex' => '^abc$', 'validation' => 'none']); + $type = $this->createTestRegexType('^abc$'); - $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); + $enrichmentKey = $this->createEnrichmentKey('regex', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('regex', 'invalidvalue'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('regex', $enrichmentId); + $form->initValueFormElement('regex', $enrichmentId); $post = [ 'Enrichment0' => [ @@ -849,15 +1017,14 @@ public function testValidationWithRegexTypeAndNoValidationWithInvalidOriginalVal public function testValidationWithRegexTypeAndNoValidationWithInvalidChangedValue() { - $type = new Opus_Enrichment_RegexType(); - $type->setOptions(['regex' => '^abc$', 'validation' => 'none']); + $type = $this->createTestRegexType('^abc$'); - $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); + $enrichmentKey = $this->createEnrichmentKey('regex', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('regex', 'invalidvalue'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('regex', $enrichmentId); + $form->initValueFormElement('regex', $enrichmentId); $post = [ 'Enrichment0' => [ @@ -879,15 +1046,14 @@ public function testValidationWithRegexTypeAndNoValidationWithInvalidChangedValu public function testValidationWithRegexTypeAndNoValidationWithValidValue() { - $type = new Opus_Enrichment_RegexType(); - $type->setOptions(['regex' => '^abc$', 'validation' => 'none']); + $type = $this->createTestRegexType('^abc$'); - $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); + $enrichmentKey = $this->createEnrichmentKey('regex', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('regex', 'abc'); $form = new Admin_Form_Document_Enrichment(); $form->setName('Enrichment0'); - $form->initEnrichmentValueElement('regex', $enrichmentId); + $form->initValueFormElement('regex', $enrichmentId); $post = [ 'Enrichment0' => [ @@ -925,11 +1091,11 @@ private function createTestEnrichmentKey($name, $type = null, $options = null) return $enrichmentKey; } - private function createEnrichmentKeyAndForm($name, $type) + private function createEnrichmentKey($name, $type) { $enrichmentKey = $this->createTestEnrichmentKey($name, $type->getName(), $type->getOptions()); - // Methodenaufruf hier erforderlich, damit der interne Cache, in dem + // Methodenaufruf des All-Finders hier erforderlich, damit der interne Cache, in dem // alle EnrichmentKeys gehalten werden, neu aufgesetzt wird Opus_EnrichmentKey::getAll(); @@ -938,8 +1104,15 @@ private function createEnrichmentKeyAndForm($name, $type) public function testPrepareRenderingAsView() { + $enrichmentKey = $this->createEnrichmentKey('text', new Opus_Enrichment_TextType()); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('text'); + $form = new Admin_Form_Document_Enrichment(); + $form->populateFromModel(new Opus_Enrichment($enrichmentId)); $form->prepareRenderingAsView(); + + $enrichmentKey->delete(); + $this->assertFalse($form->isRemoveEmptyCheckbox()); } From a979e62366ba5fd98950698778d3d73386c0f168 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 21 Jun 2020 12:32:50 +0200 Subject: [PATCH 007/270] removed obsolete CSS rules --- public/layouts/opus4/css/admin.css | 9 --------- 1 file changed, 9 deletions(-) diff --git a/public/layouts/opus4/css/admin.css b/public/layouts/opus4/css/admin.css index 4880e8b1ae..aa78831ecc 100644 --- a/public/layouts/opus4/css/admin.css +++ b/public/layouts/opus4/css/admin.css @@ -2539,15 +2539,6 @@ a.create-document-link { font-weight: bold; } -/* Verstoß gegen Typkonfiguration eines Enrichment-Key nur als Hinweis anzeigen */ -.adminContainer ul.notice { - background-color: #E1E4E0 !important; - color: #595A56 !important; -} -.adminContainer ul.notice:before { - border-color: transparent transparent #E1E4E0 !important; -} - .code { font-family: monospace; } From 70c10d049b331a0bb6894ed9bd66f17d06739c83 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 21 Jun 2020 12:34:50 +0200 Subject: [PATCH 008/270] fixed coding style conflicts --- modules/admin/forms/Document/Enrichment.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index 42b352af19..8f64f59c09 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -180,8 +180,7 @@ private function createValueFormElement($enrichmentValue, $enrichmentKey = null, if ($enrichmentType->getFormElementName() === 'Select' && $formValue == 0) { // Hinweistext anzeigen, der auf Verstoß hinweist $this->handleValidationErrorNonStrict($enrichmentKey); - } - else { + } else { // wenn der Formularwert mit dem gespeicherten Wert übereinstimmt, // dann im "Non Strict"-Mode Hinweis für den Benutzer anzeigen if (is_null($formValue) || $enrichmentValue === $formValue) { @@ -348,8 +347,7 @@ public function initValueFormElement($enrichmentKeyName = null, $enrichmentId = if (! is_null($enrichment) && ($enrichmentKeyName === $enrichment->getKeyName())) { // der im Enrichment gespeicherte EnrichmentKey-Name ist nicht registriert $this->getLogger()->info("processing of unregistered enrichment key name '$enrichmentKeyName'"); - } - else { + } else { // der im POST übergebene EnrichmentKey-Name ist nicht registriert und stimmt nicht mit dem // im Enrichment gespeicherten EnrichmentKey-Name überein: POST wurde manipuliert - Fallback auf // den ersten Auswahlwert @@ -451,7 +449,8 @@ public function prepareRenderingAsView() parent::prepareRenderingAsView(); } - private function handleSelectFieldStrict($enrichmentData, $enrichmentType, $parentValidationResult) { + private function handleSelectFieldStrict($enrichmentData, $enrichmentType, $parentValidationResult) + { if (array_key_exists(self::ELEMENT_VALUE, $enrichmentData)) { $formValue = $enrichmentData[self::ELEMENT_VALUE]; // das ist nicht der ausgewählte Wert, sondern der Index des Wertes innerhalb der Select-Liste if ($formValue == 0) { @@ -470,8 +469,7 @@ private function handleSelectFieldStrict($enrichmentData, $enrichmentType, $pare $this->getElement(self::ELEMENT_VALUE)->addError($this->handleEnrichmentKeySpecificTranslations('errorMessage', $enrichment->getKeyName())); return false; // Auswahlwert ist nach Typkonfiguration nicht zulässig } - } - else { + } else { $options = $enrichmentType->getValues(); if ($formValue == count($options)) { // durch die Hinzufügung des aktuell im Enrichment gespeicherten Wertes (der nicht From fc5e47781ce4472ab8d674cf72051935d5b66ac1 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 21 Jun 2020 12:40:09 +0200 Subject: [PATCH 009/270] fixed coding style conflicts --- modules/admin/forms/Document/MultiEnrichmentSubForm.php | 1 - tests/modules/admin/forms/Document/EnrichmentTest.php | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/admin/forms/Document/MultiEnrichmentSubForm.php b/modules/admin/forms/Document/MultiEnrichmentSubForm.php index 2c2d2aab32..12220bea56 100644 --- a/modules/admin/forms/Document/MultiEnrichmentSubForm.php +++ b/modules/admin/forms/Document/MultiEnrichmentSubForm.php @@ -180,7 +180,6 @@ public function constructFromPost($post, $document = null) foreach ($this->getSubForms() as $subForm) { if ($subForm instanceof Admin_Form_Document_Enrichment) { $subForm->initValueElement($post); - } $this->prepareSubFormDecorators($subForm); } diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index dbf1910a90..b65afd230c 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -453,8 +453,7 @@ private function createTestSelectType($options, $strictValidation = false) $selectOptions = ['values' => $options]; if ($strictValidation) { $selectOptions['validation'] = 'strict'; - } - else { + } else { $selectOptions['validation'] = 'none'; } @@ -468,8 +467,7 @@ private function createTestRegexType($regex, $strictValidation = false) $options = ['regex' => $regex]; if ($strictValidation) { $options['validation'] = 'strict'; - } - else { + } else { $options['validation'] = 'none'; } From 47a2825450ae2ed364d55d1316b53a0f1c817f16 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 21 Jun 2020 12:49:37 +0200 Subject: [PATCH 010/270] fixed coding style conflicts renamed test methods --- modules/admin/forms/Document/Enrichment.php | 11 +++------- .../admin/forms/Document/EnrichmentTest.php | 21 ++++++++----------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index 8f64f59c09..d7429bda4e 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -511,7 +511,6 @@ public function isValid($data) if (! is_null($enrichmentType)) { if ($enrichmentType->isStrictValidation()) { if ($enrichmentType->getFormElementName() == 'Select') { - // wenn der erste Auswahlwert im Select-Element gewählt wurde, so muss geprüft werden, ob // dieser Wert möglicherweise gegen die Typkonfiguration verstößt (als erster Wert wird immer // der aktuell im Enrichment gespeicherte Wert verwendet - dieser kann möglicherweise gegen @@ -520,8 +519,7 @@ public function isValid($data) $validationResult = $this->handleSelectFieldStrict($enrichmentData, $enrichmentType, $validationResult); } - } - else { + } else { // hat sich der Enrichment-Wert nicht geändert, so ist der (nicht geänderte) // Enrichment-Wert weiterhin gültig, auch wenn er gegen die Typkonfiguration verstößt @@ -563,8 +561,7 @@ public function isValid($data) $valueElem = $this->getElement(self::ELEMENT_VALUE); if ($enrichmentType->getFormElementName() == 'Select') { $formElementValidation = in_array($formValue, $enrichmentType->getValues()); - } - else { + } else { $formElementValidation = $valueElem->isValid($formValue); } if (! $formElementValidation) { @@ -573,8 +570,7 @@ public function isValid($data) $this->handleValidationErrorNonStrict($enrichmentKey); } return true; - } - else { + } else { // Sonderbehandlung bei Select-Feldern: hier ist der letzte Wert als gültig zu betrachten, // wenn in die Select-Liste der bzgl. der Typkonfiguration ungültige Wert als erster Eintrag // aufgenommen wurde @@ -664,5 +660,4 @@ private function handleEnrichmentKeySpecificTranslations($keySuffix, $enrichment return $translator->translate($translationPrefix . $keySuffix); } - } diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index b65afd230c..3d815f2b59 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -811,8 +811,7 @@ public function testValidationWithSelectTypeAndNoValidationAndInvalidValue() public function testValidationWithRegexType() { - $type = new Opus_Enrichment_RegexType(); - $type->setOptions(['regex' => '^abc$']); + $type = $this->createTestRegexType('^abc$'); $enrichmentKey = $this->createEnrichmentKey('regex', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('regex'); @@ -841,8 +840,7 @@ public function testValidationWithRegexType() public function testValidationWithRegexTypeWithMissingValue() { - $type = new Opus_Enrichment_RegexType(); - $type->setOptions(['regex' => '^.*$']); + $type = $this->createTestRegexType('^.*$'); $enrichmentKey = $this->createEnrichmentKey('regex', $type); $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('regex'); @@ -871,8 +869,7 @@ public function testValidationWithRegexTypeWithMissingValue() public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() { - $type = new Opus_Enrichment_RegexType(); - $type->setOptions(['regex' => '^abc$']); + $this->createTestRegexType('^abc$'); // mit dem Namen soll sichergestellt werden, dass dieser Enrichment-Key // in der Auswahlliste als erster Eintrag auftritt @@ -901,7 +898,7 @@ public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() $enrichmentKey->delete(); } - public function testValidationWithRegexTypeAndStrictValidationWithInvalidOriginalValue() + public function testValidationStrictWithRegexTypeAndInvalidOriginalValue() { $type = $this->createTestRegexType('^abc$', true); @@ -930,7 +927,7 @@ public function testValidationWithRegexTypeAndStrictValidationWithInvalidOrigina $enrichmentKey->delete(); } - public function testValidationWithRegexTypeAndStrictValidationWithInvalidChangedValue() + public function testValidationStrictWithRegexTypeAndInvalidChangedValue() { $type = $this->createTestRegexType('^abc$', true); @@ -959,7 +956,7 @@ public function testValidationWithRegexTypeAndStrictValidationWithInvalidChanged $enrichmentKey->delete(); } - public function testValidationWithRegexTypeAndStrictValidationWithValidValue() + public function testValidationStrictWithRegexTypeAndValidValue() { $type = $this->createTestRegexType('^abc$', true); @@ -986,7 +983,7 @@ public function testValidationWithRegexTypeAndStrictValidationWithValidValue() $enrichmentKey->delete(); } - public function testValidationWithRegexTypeAndNoValidationWithInvalidOriginalValue() + public function testValidationNoneWithRegexTypeAndInvalidOriginalValue() { $type = $this->createTestRegexType('^abc$'); @@ -1013,7 +1010,7 @@ public function testValidationWithRegexTypeAndNoValidationWithInvalidOriginalVal $enrichmentKey->delete(); } - public function testValidationWithRegexTypeAndNoValidationWithInvalidChangedValue() + public function testValidationNoneWithRegexTypeAndInvalidChangedValue() { $type = $this->createTestRegexType('^abc$'); @@ -1042,7 +1039,7 @@ public function testValidationWithRegexTypeAndNoValidationWithInvalidChangedValu $enrichmentKey->delete(); } - public function testValidationWithRegexTypeAndNoValidationWithValidValue() + public function testValidationNoneWithRegexTypeAndValidValue() { $type = $this->createTestRegexType('^abc$'); From 568f24050acf091b39dfb956769e1b37b61cfea7 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 21 Jun 2020 20:57:13 +0200 Subject: [PATCH 011/270] fixed broken unit tests --- modules/admin/forms/Document/Enrichment.php | 4 ---- .../Application/Form/Element/CollectionDisplayFormatTest.php | 4 ++-- tests/library/Application/Form/Element/DocumentTypeTest.php | 4 ++-- tests/library/Application/Form/Element/EnrichmentKeyTest.php | 5 +++-- tests/library/Application/Form/Element/GrantorTest.php | 4 ++-- tests/library/Application/Form/Element/IdentifierTest.php | 4 ++-- tests/library/Application/Form/Element/LanguageScopeTest.php | 4 ++-- tests/library/Application/Form/Element/LanguageTest.php | 4 ++-- tests/library/Application/Form/Element/LanguageTypeTest.php | 4 ++-- tests/library/Application/Form/Element/PositionTest.php | 4 ++-- tests/library/Application/Form/Element/PublisherTest.php | 4 ++-- tests/library/Application/Form/Element/SelectTest.php | 4 ++-- .../library/Application/Form/Element/SelectWithNullTest.php | 4 ++-- tests/library/Application/Form/Element/SeriesTest.php | 4 ++-- tests/library/Application/Form/Element/ThemeTest.php | 3 ++- 15 files changed, 29 insertions(+), 31 deletions(-) diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index d7429bda4e..d31385197a 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -641,10 +641,6 @@ private function handleValidationErrorNonStrict($enrichmentKey = null) $element->setHint($hint); $element->removeDecorator('Errors'); - - // FIXME kann weg -> Abhängigkeiten prüfen - //$decorator = $element->getDecorator('Errors'); - //$decorator->setOption('class', 'errors datahint'); } private function handleEnrichmentKeySpecificTranslations($keySuffix, $enrichmentKeyName = null) diff --git a/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php b/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php index 6f42d17c33..d2a5f9d395 100644 --- a/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php +++ b/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php @@ -46,9 +46,9 @@ public function setUp() $this->values = ['Name', 'Number', 'Name,Number', 'Number,Name']; $this->_formElementClass = 'Application_Form_Element_CollectionDisplayFormat'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = ['ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', - 'dataWrapper']; + 'dataWrapper', 'ElementHint']; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); diff --git a/tests/library/Application/Form/Element/DocumentTypeTest.php b/tests/library/Application/Form/Element/DocumentTypeTest.php index 4014a3b00a..5f598810c6 100644 --- a/tests/library/Application/Form/Element/DocumentTypeTest.php +++ b/tests/library/Application/Form/Element/DocumentTypeTest.php @@ -38,10 +38,10 @@ class Application_Form_Element_DocumentTypeTest extends FormElementTestCase public function setUp() { $this->_formElementClass = 'Application_Form_Element_DocumentType'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = [ - 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', 'dataWrapper' + 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', 'dataWrapper', 'ElementHint' ]; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/EnrichmentKeyTest.php b/tests/library/Application/Form/Element/EnrichmentKeyTest.php index df07a0183d..4c1065fb48 100644 --- a/tests/library/Application/Form/Element/EnrichmentKeyTest.php +++ b/tests/library/Application/Form/Element/EnrichmentKeyTest.php @@ -45,15 +45,16 @@ class Application_Form_Element_EnrichmentKeyTest extends FormElementTestCase public function setUp() { $this->_formElementClass = 'Application_Form_Element_EnrichmentKey'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = [ 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', - 'dataWrapper' + 'dataWrapper', + 'ElementHint' ]; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); diff --git a/tests/library/Application/Form/Element/GrantorTest.php b/tests/library/Application/Form/Element/GrantorTest.php index dde968f510..e0dd3f9822 100644 --- a/tests/library/Application/Form/Element/GrantorTest.php +++ b/tests/library/Application/Form/Element/GrantorTest.php @@ -39,10 +39,10 @@ class Application_Form_Element_GrantorTest extends FormElementTestCase public function setUp() { $this->_formElementClass = 'Application_Form_Element_Grantor'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = [ - 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', 'dataWrapper' + 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', 'dataWrapper', 'ElementHint' ]; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/IdentifierTest.php b/tests/library/Application/Form/Element/IdentifierTest.php index d58c26cef1..1fe78d3189 100644 --- a/tests/library/Application/Form/Element/IdentifierTest.php +++ b/tests/library/Application/Form/Element/IdentifierTest.php @@ -39,9 +39,9 @@ class Application_Form_Element_IdentifierTest extends FormElementTestCase public function setUp() { $this->_formElementClass = 'Application_Form_Element_Identifier'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = ['ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', - 'dataWrapper']; + 'dataWrapper', 'ElementHint']; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/LanguageScopeTest.php b/tests/library/Application/Form/Element/LanguageScopeTest.php index 07a5c18bde..b0311a94fa 100644 --- a/tests/library/Application/Form/Element/LanguageScopeTest.php +++ b/tests/library/Application/Form/Element/LanguageScopeTest.php @@ -43,9 +43,9 @@ public function setUp() $this->keys = ['Null', 'I', 'M', 'S']; $this->_formElementClass = 'Application_Form_Element_LanguageScope'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = ['ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', - 'dataWrapper']; + 'dataWrapper', 'ElementHint']; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/LanguageTest.php b/tests/library/Application/Form/Element/LanguageTest.php index 14c9e37364..9110d925c5 100644 --- a/tests/library/Application/Form/Element/LanguageTest.php +++ b/tests/library/Application/Form/Element/LanguageTest.php @@ -38,10 +38,10 @@ class Application_Form_Element_LanguageTest extends FormElementTestCase public function setUp() { $this->_formElementClass = 'Application_Form_Element_Language'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = [ - 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', 'dataWrapper' + 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', 'dataWrapper', 'ElementHint' ]; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/LanguageTypeTest.php b/tests/library/Application/Form/Element/LanguageTypeTest.php index c6da046a26..75526857d7 100644 --- a/tests/library/Application/Form/Element/LanguageTypeTest.php +++ b/tests/library/Application/Form/Element/LanguageTypeTest.php @@ -42,9 +42,9 @@ public function setUp() { $this->keys = ['Null', 'A', 'C', 'E', 'H', 'L', 'S']; $this->_formElementClass = 'Application_Form_Element_LanguageType'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = ['ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', - 'dataWrapper']; + 'dataWrapper', 'ElementHint']; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/PositionTest.php b/tests/library/Application/Form/Element/PositionTest.php index c0c5281042..68bab850d1 100644 --- a/tests/library/Application/Form/Element/PositionTest.php +++ b/tests/library/Application/Form/Element/PositionTest.php @@ -38,10 +38,10 @@ class Application_Form_Element_PositionTest extends FormElementTestCase public function setUp() { $this->_formElementClass = 'Application_Form_Element_Position'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = [ - 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', 'dataWrapper' + 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', 'dataWrapper', 'ElementHint' ]; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/PublisherTest.php b/tests/library/Application/Form/Element/PublisherTest.php index d0dc236717..778e62f0aa 100644 --- a/tests/library/Application/Form/Element/PublisherTest.php +++ b/tests/library/Application/Form/Element/PublisherTest.php @@ -39,10 +39,10 @@ class Application_Form_Element_PublisherTest extends FormElementTestCase public function setUp() { $this->_formElementClass = 'Application_Form_Element_Publisher'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = [ - 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', 'dataWrapper' + 'ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', 'dataWrapper', 'ElementHint' ]; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/SelectTest.php b/tests/library/Application/Form/Element/SelectTest.php index 792035dfd9..243bc8cebf 100644 --- a/tests/library/Application/Form/Element/SelectTest.php +++ b/tests/library/Application/Form/Element/SelectTest.php @@ -37,9 +37,9 @@ class Application_Form_Element_SelectTest extends FormElementTestCase public function setUp() { $this->_formElementClass = 'Application_Form_Element_Select'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = ['ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', - 'dataWrapper']; + 'dataWrapper', 'ElementHint']; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/SelectWithNullTest.php b/tests/library/Application/Form/Element/SelectWithNullTest.php index 410e9d4f05..b22fdd1c2b 100644 --- a/tests/library/Application/Form/Element/SelectWithNullTest.php +++ b/tests/library/Application/Form/Element/SelectWithNullTest.php @@ -37,9 +37,9 @@ class Application_Form_Element_SelectWithNullTest extends FormElementTestCase public function setUp() { $this->_formElementClass = 'Application_Form_Element_SelectWithNull'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = ['ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', - 'dataWrapper']; + 'dataWrapper', 'ElementHint']; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/SeriesTest.php b/tests/library/Application/Form/Element/SeriesTest.php index 68dc63a650..0e1b96f432 100644 --- a/tests/library/Application/Form/Element/SeriesTest.php +++ b/tests/library/Application/Form/Element/SeriesTest.php @@ -39,9 +39,9 @@ class Application_Form_Element_SeriesTest extends FormElementTestCase public function setUp() { $this->_formElementClass = 'Application_Form_Element_Series'; - $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = ['ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', - 'dataWrapper']; + 'dataWrapper', 'ElementHint']; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } diff --git a/tests/library/Application/Form/Element/ThemeTest.php b/tests/library/Application/Form/Element/ThemeTest.php index 393e9dc060..3961ccdc1f 100644 --- a/tests/library/Application/Form/Element/ThemeTest.php +++ b/tests/library/Application/Form/Element/ThemeTest.php @@ -40,7 +40,8 @@ public function setUp() $this->_formElementClass = 'Application_Form_Element_Theme'; $this->_expectedDecoratorCount = 6; $this->_expectedDecorators = ['ViewHelper', 'Errors', 'Description', 'ElementHtmlTag', 'LabelNotEmpty', - 'dataWrapper']; + 'dataWrapper', 'ElementHint']; + $this->_expectedDecoratorCount = count($this->_expectedDecorators); $this->_staticViewHelper = 'viewFormSelect'; parent::setUp(); } From 69ea950a1eac71e6332263cd302bed646aafcd03 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 21 Jun 2020 21:46:07 +0200 Subject: [PATCH 012/270] fixed broken tests --- tests/modules/admin/forms/Document/EnrichmentTest.php | 2 +- .../modules/admin/forms/Document/MultiEnrichmentSubFormTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index 3d815f2b59..e266d9efb7 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -869,7 +869,7 @@ public function testValidationWithRegexTypeWithMissingValue() public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() { - $this->createTestRegexType('^abc$'); + $type = $this->createTestRegexType('^abc$'); // mit dem Namen soll sichergestellt werden, dass dieser Enrichment-Key // in der Auswahlliste als erster Eintrag auftritt diff --git a/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php b/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php index 9de45dd833..a7b21a5678 100644 --- a/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php +++ b/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php @@ -38,7 +38,7 @@ class Admin_Form_Document_MultiEnrichmentSubFormTest extends ControllerTestCase { - protected $additionalResources = ['database']; + protected $additionalResources = ['database', 'translation']; // dieser Enrichment-Key Name stellt sicher, dass der Enrichment-Key // im Auswahlfeld aller Enrichment-Keys an der ersten Position steht From 585ecfcfd1c5d8031158136ffecdc5ec58aa6b71 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Mon, 22 Jun 2020 18:32:50 +0200 Subject: [PATCH 013/270] Revert commit 69ea950a (analysis of failed build) --- tests/modules/admin/forms/Document/EnrichmentTest.php | 2 +- .../modules/admin/forms/Document/MultiEnrichmentSubFormTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index e266d9efb7..3d815f2b59 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -869,7 +869,7 @@ public function testValidationWithRegexTypeWithMissingValue() public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() { - $type = $this->createTestRegexType('^abc$'); + $this->createTestRegexType('^abc$'); // mit dem Namen soll sichergestellt werden, dass dieser Enrichment-Key // in der Auswahlliste als erster Eintrag auftritt diff --git a/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php b/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php index a7b21a5678..9de45dd833 100644 --- a/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php +++ b/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php @@ -38,7 +38,7 @@ class Admin_Form_Document_MultiEnrichmentSubFormTest extends ControllerTestCase { - protected $additionalResources = ['database', 'translation']; + protected $additionalResources = ['database']; // dieser Enrichment-Key Name stellt sicher, dass der Enrichment-Key // im Auswahlfeld aller Enrichment-Keys an der ersten Position steht From 5fe481e8099c2e827f3a3a0913a20f8024c8bc3a Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Mon, 22 Jun 2020 19:54:34 +0200 Subject: [PATCH 014/270] Revert commit 585ecfcf (try to repeat build break) --- tests/modules/admin/forms/Document/EnrichmentTest.php | 2 +- .../modules/admin/forms/Document/MultiEnrichmentSubFormTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index 3d815f2b59..e266d9efb7 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -869,7 +869,7 @@ public function testValidationWithRegexTypeWithMissingValue() public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() { - $this->createTestRegexType('^abc$'); + $type = $this->createTestRegexType('^abc$'); // mit dem Namen soll sichergestellt werden, dass dieser Enrichment-Key // in der Auswahlliste als erster Eintrag auftritt diff --git a/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php b/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php index 9de45dd833..a7b21a5678 100644 --- a/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php +++ b/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php @@ -38,7 +38,7 @@ class Admin_Form_Document_MultiEnrichmentSubFormTest extends ControllerTestCase { - protected $additionalResources = ['database']; + protected $additionalResources = ['database', 'translation']; // dieser Enrichment-Key Name stellt sicher, dass der Enrichment-Key // im Auswahlfeld aller Enrichment-Keys an der ersten Position steht From 12f8d104c39d64682c20a53165f2e373a48ad686 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 5 Aug 2020 14:34:01 +0200 Subject: [PATCH 015/270] OPUSVIER-4279 Moved document type page to setup area --- application/configs/navigationModules.xml | 34 +++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/application/configs/navigationModules.xml b/application/configs/navigationModules.xml index 4cd3b7d23c..8502501dfd 100644 --- a/application/configs/navigationModules.xml +++ b/application/configs/navigationModules.xml @@ -644,6 +644,23 @@ index setup + + mvc + + group-cafelatte + admin + doctype + index + + + mvc + + admin + doctype + show + + + mvc @@ -965,23 +982,6 @@ index indexmaintenance - - mvc - - group-chocolate - admin - doctype - index - - - mvc - - admin - doctype - show - - - mvc From 1ad6c5ad1ebfc1f8d2dd5ee5fd36b7d4a20d17f0 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 5 Aug 2020 14:51:23 +0200 Subject: [PATCH 016/270] OPUSVIER-4279 Restrict access to document type page --- application/configs/navigationModules.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/application/configs/navigationModules.xml b/application/configs/navigationModules.xml index 8502501dfd..14dadf4cc5 100644 --- a/application/configs/navigationModules.xml +++ b/application/configs/navigationModules.xml @@ -651,6 +651,7 @@ admin doctype index + setup mvc From 5b6f8235e928f9669a611ef4fa4150a0fa2c126a Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 10 Aug 2020 08:41:54 +0200 Subject: [PATCH 017/270] OPUSVIER-4277 Spelling --- library/Application/Translate/TranslationManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Application/Translate/TranslationManager.php b/library/Application/Translate/TranslationManager.php index 13817b492e..7426b1f8c0 100644 --- a/library/Application/Translate/TranslationManager.php +++ b/library/Application/Translate/TranslationManager.php @@ -424,7 +424,7 @@ public function getTranslation($key) * Filtering by state happens outside this function because this depends on the presence of the * key in the TMX files and the database or just the database. * - * TODO should filting by module happen here + * TODO should filtering by module happen here * * @param $key string Name of translation key * @param $values array Translated texts for supported languages From 3c4aefd95cf64bf0b1cd8d144280aed60e6b11bc Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 14 Aug 2020 11:44:40 +0200 Subject: [PATCH 018/270] OPUSVIER-3657 Use dev versions --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index de6bf7a5aa..5b2501eda4 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ "zendframework/zendframework1": "1.12.*", "jpgraph/jpgraph": "dev-master", "solarium/solarium": "3.8.*", - "opus4-repo/opus4-common": "4.7", - "opus4-repo/framework": "4.7", + "opus4-repo/opus4-common": "dev-master", + "opus4-repo/framework": "dev-master", "opus4-repo/search": "4.7", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", From 87b2b3f0e5f90b0e51e10fd61520a905a968dca9 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 14 Aug 2020 11:46:32 +0200 Subject: [PATCH 019/270] OPUSVIER-3657 Use dev versions --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5b2501eda4..9cd406824a 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "solarium/solarium": "3.8.*", "opus4-repo/opus4-common": "dev-master", "opus4-repo/framework": "dev-master", - "opus4-repo/search": "4.7", + "opus4-repo/search": "dev-master", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", From 4404bfcc3dd3edf04ffcfb616910c3b8865456ba Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 27 Aug 2020 14:49:48 +0200 Subject: [PATCH 020/270] OPUSVIER-4304 Fixed spelling. --- library/Application/Update/ImportCustomTranslations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Application/Update/ImportCustomTranslations.php b/library/Application/Update/ImportCustomTranslations.php index ec7a638862..35b11a9673 100644 --- a/library/Application/Update/ImportCustomTranslations.php +++ b/library/Application/Update/ImportCustomTranslations.php @@ -75,7 +75,7 @@ public function run() } } - // Remove empry language_custom folders for all modules + // Remove empty language_custom folders for all modules $this->log(PHP_EOL . 'Remove empty \'language_custom\' directories...'); foreach ($modules as $module) { $path = "/modules/$module/language_custom"; From 429b7c0f8765383bd99b0cb5eee92be8a093b22e Mon Sep 17 00:00:00 2001 From: kaustabhbarman Date: Thu, 27 Aug 2020 17:19:46 +0200 Subject: [PATCH 021/270] OPUSVIER-4289 TODO comments for Logging --- library/Application/Bootstrap.php | 2 ++ library/Application/Update.php | 1 + 2 files changed, 3 insertions(+) diff --git a/library/Application/Bootstrap.php b/library/Application/Bootstrap.php index 664722e938..5db147c970 100644 --- a/library/Application/Bootstrap.php +++ b/library/Application/Bootstrap.php @@ -221,6 +221,7 @@ protected function _initTranslation() { $this->bootstrap(['Configuration', 'Session', 'Logging', 'ZendCache']); + // TODO OPUSVIER-4289 Use LogService // TODO temporary hack until LogService refactoring is finished (OPUSVIER-3657) $logger = $this->getTranslationLog('translation'); @@ -391,6 +392,7 @@ protected function _initIndexPlugin() } /** + * TODO OPUSVIER-4289 Remove this function * TODO this function should be remove once OPUSVIER-3657 is done * TODO log should be created using LogService * TOOD log needs to include unique ID from main log diff --git a/library/Application/Update.php b/library/Application/Update.php index 793505b33a..6018986e3c 100644 --- a/library/Application/Update.php +++ b/library/Application/Update.php @@ -74,6 +74,7 @@ public function bootstrap() $application = new Zend_Application(APPLICATION_ENV, ["config" => $configFiles]); + //TODO OPUSVIER-4289 use LogService function to log // setup logging for updates $options = $application->mergeOptions($application->getOptions(), [ 'log' => [ From 876da19a972e4936ef67e49bdc3eb1bbeced34d0 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 30 Aug 2020 23:27:39 +0200 Subject: [PATCH 022/270] fixed typo in array key name --- library/Application/Translate/TranslationManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Application/Translate/TranslationManager.php b/library/Application/Translate/TranslationManager.php index 13817b492e..ca054494a4 100644 --- a/library/Application/Translate/TranslationManager.php +++ b/library/Application/Translate/TranslationManager.php @@ -693,7 +693,7 @@ public function importTmxFile($tmxFile) // TODO write to log } - if (isset($old['transaltionsTmx'])) { + if (isset($old['translationsTmx'])) { $oldValues = $old['translationsTmx']; } else { $oldValues = $old['translations']; From 9f0baee6d10b612848c5ff7181d729bf04f5e3d3 Mon Sep 17 00:00:00 2001 From: kaustabhbarman Date: Tue, 1 Sep 2020 20:02:09 +0200 Subject: [PATCH 023/270] OPUSVIER-4289 Database cleaning for test --- tests/library/Application/Update/ImportHelpFilesTest.php | 6 ++++++ tests/modules/setup/forms/ImprintPageTest.php | 3 +++ 2 files changed, 9 insertions(+) diff --git a/tests/library/Application/Update/ImportHelpFilesTest.php b/tests/library/Application/Update/ImportHelpFilesTest.php index d9b1f8d791..0eb09140bc 100644 --- a/tests/library/Application/Update/ImportHelpFilesTest.php +++ b/tests/library/Application/Update/ImportHelpFilesTest.php @@ -36,6 +36,12 @@ class Application_Update_ImportHelpFilesTest extends ControllerTestCase protected $additionalResources = 'translation'; + public function tearDown() + { + $database = new Opus_Translate_Dao(); + $database->removeAll(); + } + public function testRun() { $database = new Opus_Translate_Dao(); diff --git a/tests/modules/setup/forms/ImprintPageTest.php b/tests/modules/setup/forms/ImprintPageTest.php index aab2238e89..8a8c19135c 100644 --- a/tests/modules/setup/forms/ImprintPageTest.php +++ b/tests/modules/setup/forms/ImprintPageTest.php @@ -40,6 +40,9 @@ class Setup_Form_ImprintPageTest extends ControllerTestCase public function testInit() { + $database = new Opus_Translate_Dao(); + $database->removeAll(); + $form = new Setup_Form_ImprintPage(); $element = $form->getElement('home_index_imprint_pagetitle'); From 0ddfa7e119abf9b4099abc4070e633ab34e300b6 Mon Sep 17 00:00:00 2001 From: kaustabhbarman Date: Thu, 3 Sep 2020 16:44:20 +0200 Subject: [PATCH 024/270] OPUSVIER-4289 Log Service implementation --- library/Application/Bootstrap.php | 25 ++----------------- library/Application/Update.php | 1 - .../MigrateSeriesCollections.php | 1 + .../MigrateSubjectsToCollections.php | 1 + .../Update/ImportHelpFilesTest.php | 1 + .../publish/models/FormElementTest.php | 3 +++ 6 files changed, 8 insertions(+), 24 deletions(-) diff --git a/library/Application/Bootstrap.php b/library/Application/Bootstrap.php index 5db147c970..f04277c074 100644 --- a/library/Application/Bootstrap.php +++ b/library/Application/Bootstrap.php @@ -223,7 +223,8 @@ protected function _initTranslation() // TODO OPUSVIER-4289 Use LogService // TODO temporary hack until LogService refactoring is finished (OPUSVIER-3657) - $logger = $this->getTranslationLog('translation'); + $logService = LogService::getInstance(); + $logger = $logService->createLog('translation', null, '%timestamp%: %message%' . PHP_EOL, null); if (is_null($logger)) { $logger = $this->getResource('logging'); @@ -390,26 +391,4 @@ protected function _initIndexPlugin() { \Opus_Model_Xml_Cache::setIndexPluginClass('Opus\Search\Plugin\Index'); } - - /** - * TODO OPUSVIER-4289 Remove this function - * TODO this function should be remove once OPUSVIER-3657 is done - * TODO log should be created using LogService - * TOOD log needs to include unique ID from main log - */ - protected function getTranslationLog($name) - { - $config = $this->getResource('configuration'); - - if (isset($config->workspacePath)) { - $filePath = $config->workspacePath . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . "$name.log"; - $logfile = @fopen($filePath, 'a', false); - $writer = new Zend_Log_Writer_Stream($logfile); - $formatter = new Zend_Log_Formatter_Simple('%timestamp%: %message%' . PHP_EOL); - $writer->setFormatter($formatter); - return new Zend_Log($writer); - } - - return null; - } } diff --git a/library/Application/Update.php b/library/Application/Update.php index 6018986e3c..793505b33a 100644 --- a/library/Application/Update.php +++ b/library/Application/Update.php @@ -74,7 +74,6 @@ public function bootstrap() $application = new Zend_Application(APPLICATION_ENV, ["config" => $configFiles]); - //TODO OPUSVIER-4289 use LogService function to log // setup logging for updates $options = $application->mergeOptions($application->getOptions(), [ 'log' => [ diff --git a/scripts/update_migration/MigrateSeriesCollections.php b/scripts/update_migration/MigrateSeriesCollections.php index 64f2c8084b..7dd719ff22 100755 --- a/scripts/update_migration/MigrateSeriesCollections.php +++ b/scripts/update_migration/MigrateSeriesCollections.php @@ -49,6 +49,7 @@ public function __construct($logfile) } /** + * TODO OPUSVIER-4289 Use LogService * Initialise the logger with the given file. */ private function initLogger($logfileName) diff --git a/scripts/update_migration/MigrateSubjectsToCollections.php b/scripts/update_migration/MigrateSubjectsToCollections.php index affea1db08..50db17c2f2 100755 --- a/scripts/update_migration/MigrateSubjectsToCollections.php +++ b/scripts/update_migration/MigrateSubjectsToCollections.php @@ -49,6 +49,7 @@ // Initialize logger. $logfileName = $argv[1]; +//TODO OPUSVIER-4289 Use LogService $logfile = @fopen($logfileName, 'a', false); $writer = new Zend_Log_Writer_Stream($logfile); $formatter = new Zend_Log_Formatter_Simple('%timestamp% %priorityName%: %message%' . PHP_EOL); diff --git a/tests/library/Application/Update/ImportHelpFilesTest.php b/tests/library/Application/Update/ImportHelpFilesTest.php index 0eb09140bc..1adf7ffc7a 100644 --- a/tests/library/Application/Update/ImportHelpFilesTest.php +++ b/tests/library/Application/Update/ImportHelpFilesTest.php @@ -40,6 +40,7 @@ public function tearDown() { $database = new Opus_Translate_Dao(); $database->removeAll(); + parent::tearDown(); } public function testRun() diff --git a/tests/modules/publish/models/FormElementTest.php b/tests/modules/publish/models/FormElementTest.php index 6be0d8f6bb..f8fd2766e7 100644 --- a/tests/modules/publish/models/FormElementTest.php +++ b/tests/modules/publish/models/FormElementTest.php @@ -38,6 +38,9 @@ class Publish_Model_FormElementTest extends ControllerTestCase protected $_logger; + /** + * TODO OPUSVIER-4289 Use LogService + */ public function setUp() { $writer = new Zend_Log_Writer_Null; From faa0bf10617b911bb6dbb031939d6bd6a3c84358 Mon Sep 17 00:00:00 2001 From: kaustabhbarman Date: Thu, 3 Sep 2020 19:18:49 +0200 Subject: [PATCH 025/270] OPUSVIER-4289 application.ini configs --- application/configs/application.ini | 5 +++++ library/Application/Bootstrap.php | 2 +- tests/modules/publish/models/FormElementTest.php | 3 --- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/application/configs/application.ini b/application/configs/application.ini index a5c125e76c..fc72ba7e71 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -237,6 +237,10 @@ admin.documents.linkToAuthorSearch = 0 ; LOGGING CONFIGURATION (OPTIONAL) ; Use names of Zend_Log constants (e.g. DEBUG, INFO, WARN, ERR) log.level = WARN +log.format = '%timestamp% %priorityName% (%priority%, ID %runId%): %message%' +logging.log.translation.format = '' ; TODO what should be the format? +logging.log.translation.file = 'translation.xml' +logging.log.translation.level = INFO ; LOGGING RELATED SETTINGS ; if set to true all xml that is generated while indexing is prepared for logging @@ -581,6 +585,7 @@ errorController.showException = 1 errorController.showRequest = 1 ; TODO not used yet resources.frontController.params.displayExceptions = 1 +; TODO log.level has already been set as WARN log.level = DEBUG log.untranslated = true diff --git a/library/Application/Bootstrap.php b/library/Application/Bootstrap.php index f04277c074..be0b680baa 100644 --- a/library/Application/Bootstrap.php +++ b/library/Application/Bootstrap.php @@ -224,7 +224,7 @@ protected function _initTranslation() // TODO OPUSVIER-4289 Use LogService // TODO temporary hack until LogService refactoring is finished (OPUSVIER-3657) $logService = LogService::getInstance(); - $logger = $logService->createLog('translation', null, '%timestamp%: %message%' . PHP_EOL, null); + $logger = $logService->getLog('translation'); if (is_null($logger)) { $logger = $this->getResource('logging'); diff --git a/tests/modules/publish/models/FormElementTest.php b/tests/modules/publish/models/FormElementTest.php index f8fd2766e7..6be0d8f6bb 100644 --- a/tests/modules/publish/models/FormElementTest.php +++ b/tests/modules/publish/models/FormElementTest.php @@ -38,9 +38,6 @@ class Publish_Model_FormElementTest extends ControllerTestCase protected $_logger; - /** - * TODO OPUSVIER-4289 Use LogService - */ public function setUp() { $writer = new Zend_Log_Writer_Null; From aaa35c8667f560bf6d99712844e7aa2caccbb0b5 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 7 Sep 2020 18:27:17 +0200 Subject: [PATCH 026/270] OPUSVIER-421 Moved SolrIndexBuilder code to search package --- composer.json | 8 +- scripts/SolrIndexBuilder.php | 324 +---------------------------------- 2 files changed, 11 insertions(+), 321 deletions(-) diff --git a/composer.json b/composer.json index 9cd406824a..505664ebb4 100644 --- a/composer.json +++ b/composer.json @@ -18,11 +18,12 @@ "solarium/solarium": "3.8.*", "opus4-repo/opus4-common": "dev-master", "opus4-repo/framework": "dev-master", - "opus4-repo/search": "dev-master", + "opus4-repo/search": "dev-OPUSVIER-421", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", - "robloach/component-installer": "*" + "robloach/component-installer": "*", + "symfony/console": "*" }, "require-dev": { "phpunit/phpunit": "4.8.*", @@ -66,6 +67,7 @@ "cs-analysis": "phpcs -n --report=checkstyle --report-file=build/checkstyle.xml", "phpmd": "phpmd library xml cleancode,unusedcode,design,naming --reportfile build/phpmd.xml --ignore-violations-on-exit", "phploc": "phploc --log-csv build/phploc.csv src", - "phpcpd": "phpcpd . --min-lines 3 --min-tokens 30 --log-pmd build/pmd-cpd.xml --progress || true" + "phpcpd": "phpcpd . --min-lines 3 --min-tokens 30 --log-pmd build/pmd-cpd.xml --progress || true", + "index": "php scripts/SolrIndexBuilder.php" } } diff --git a/scripts/SolrIndexBuilder.php b/scripts/SolrIndexBuilder.php index 6c39a796b7..7259b67b2c 100755 --- a/scripts/SolrIndexBuilder.php +++ b/scripts/SolrIndexBuilder.php @@ -28,331 +28,19 @@ * @category Application * @author Sascha Szott * @author Jens Schwidder - * @copyright Copyright (c) 2010-2019, OPUS 4 development team + * @copyright Copyright (c) 2010-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -// Bootstrapping require_once __DIR__ . '/common/bootstrap.php'; /** - * Indexes all or a range of documents. + * Script for indexing documents and index maintenance. * - * If all documents are indexed the index is cleared first. + * For more information run the `help` command. * - * TODO move to class and unit test + * $ ./SolrIndexBuilder.php help */ -class SolrIndexBuilder -{ - /** - * Start of document ID range for indexing (first command line parameter). - * @var int - */ - private $_start = null; - - /** - * End of document ID range for indexing (second command line parameter). - * @var int - */ - private $_end = null; - - /** - * Flag for deleting all documents from index before indexing. - * @var bool - */ - private $_deleteAllDocs = false; - - /** - * Temporary variable for storing sync mode. - * @var bool - */ - private $_syncMode = true; - - /** - * Flag for showing help information (command line parameter '--help' or '-h') - * @var bool - */ - private $_showHelp = false; - - /** - * Flag for deleting document xml cache before indexing. - * @var bool - */ - private $_clearCache = false; - - /** - * Flag for debug output. - * @var bool - */ - private $_debugEnabled = false; - - /** - * Prints a help message to the console. - */ - private function printHelpMessage($argv) - { - $text = <<write($text . PHP_EOL); - } - - /** - * Evaluates command line arguments. - */ - private function evaluateArguments($argc, $argv) - { - $options = getopt("cdh", ['help', 'debug']); - - if (array_key_exists('debug', $options) || array_key_exists('d', $options)) { - $this->_debugEnabled = true; - } - - if (array_key_exists('help', $options) || array_key_exists('h', $options)) { - $this->_showHelp = true; - return; - } - - if (true === array_key_exists('c', $options)) { - $this->_clearCache = true; - } - - if ($argc == 2) { - $start = $argv[$argc - 1]; - } elseif ($argc > 2) { - $start = $argv[$argc - 2]; - $end = $argv[$argc - 1]; - } - - if (is_numeric($start) && ctype_digit($start)) { - $this->_start = $start; - } - - if (is_numeric($end) && ctype_digit($end)) { - $this->_end = $end; - } - - // check if only end is set (happens when options are used) - if (is_null($this->_start) && ! is_null($this->_end)) { - $this->_start = $this->_end; - $this->_end = null; - } - - if (is_null($this->_start) && is_null($this->_end)) { - // TODO gesondertes Argument für Indexdeletion einführen - $this->_deleteAllDocs = true; - } - } - - /** - * Starts an Opus console. - */ - public function run($argc, $argv) - { - $this->evaluateArguments($argc, $argv); - - if ($this->_showHelp) { - $this->printHelpMessage($argv); - return; - } - - if (! is_null($this->_end)) { - echo PHP_EOL . "Indexing documents {$this->_start} to {$this->_end} ..." . PHP_EOL; - } elseif (! is_null($this->_start)) { - echo PHP_EOL . "Indexing documents starting at ID = {$this->_start} ..." . PHP_EOL; - } else { - echo PHP_EOL . 'Indexing all documents ...' . PHP_EOL; - } - - try { - $runtime = $this->index($this->_start, $this->_end); - echo PHP_EOL . "Operation completed successfully in $runtime seconds." . PHP_EOL; - } catch (Opus\Search\Exception $e) { - echo PHP_EOL . "An error occurred while indexing."; - echo PHP_EOL . "Error Message: " . $e->getMessage(); - if (! is_null($e->getPrevious())) { - echo PHP_EOL . "Caused By: " . $e->getPrevious()->getMessage(); - } - echo PHP_EOL . "Stack Trace:" . PHP_EOL . $e->getTraceAsString(); - echo PHP_EOL . PHP_EOL; - } - } - - private function index($startId, $endId) - { - $this->forceSyncMode(); - - $docIds = $this->getDocumentIds($startId, $endId); - - $indexer = Opus\Search\Service::selectIndexingService('indexBuilder'); - - if ($this->_deleteAllDocs) { - echo 'Removing all documents from the index ...' . PHP_EOL; - $indexer->removeAllDocumentsFromIndex(); - } - - echo date('Y-m-d H:i:s') . " Start indexing of " . count($docIds) . " documents.\n"; - $numOfDocs = 0; - $runtime = microtime(true); - - $docs = []; - - // measure time for each document - - $cache = new Opus_Model_Xml_Cache(); - - foreach ($docIds as $docId) { - $timeStart = microtime(true); - - if ($this->_clearCache) { - $cache->remove($docId); - } - - $doc = new Opus_Document($docId); - - // dirty hack: disable implicit reindexing of documents in case of cache misses - $doc->unregisterPlugin('Opus\Search\Plugin\Index'); - - $docs[] = $doc; - - $timeDelta = microtime(true) - $timeStart; - if ($timeDelta > 30) { - echo date('Y-m-d H:i:s') . " WARNING: Indexing document $docId took $timeDelta seconds.\n"; - } - - $numOfDocs++; - - if ($numOfDocs % 10 == 0) { - $this->addDocumentsToIndex($indexer, $docs); - $docs = []; - $this->outputProgress($runtime, $numOfDocs); - } - } - - // Index leftover documents - if (count($docs) > 0) { - $this->addDocumentsToIndex($indexer, $docs); - $this->outputProgress($runtime, $numOfDocs); - } - - $runtime = microtime(true) - $runtime; - echo PHP_EOL . date('Y-m-d H:i:s') . ' Finished indexing.' . PHP_EOL; - // new search API doesn't track number of indexed files, but issues are kept written to log file - //echo "\n\nErrors appeared in " . $indexer->getErrorFileCount() . " of " . $indexer->getTotalFileCount() - // . " files. Details were written to opus-console.log"; - echo PHP_EOL . PHP_EOL . 'Details were written to opus-console.log'; - - $this->resetMode(); - - return $runtime; - } - - /** - * Returns IDs for published documents in range. - * - * @param $start int Start of ID range - * @param $end int End of ID range - * @return array Array of document IDs - */ - private function getDocumentIds($start, $end) - { - $finder = new Opus_DocumentFinder(); - - if (isset($start)) { - $finder->setIdRangeStart($start); - } - - if (isset($end)) { - $finder->setIdRangeEnd($end); - } - - return $finder->ids(); - } - - /** - * Output current processing status and performance. - * - * @param $runtime long Time of start of processing - * @param $numOfDocs Number of processed documents - */ - private function outputProgress($runtime, $numOfDocs) - { - $memNow = round(memory_get_usage() / 1024 / 1024); - $memPeak = round(memory_get_peak_usage() / 1024 / 1024); - - $deltaTime = microtime(true) - $runtime; - $docPerSecond = round($deltaTime) == 0 ? 'inf' : round($numOfDocs / $deltaTime, 2); - $secondsPerDoc = round($deltaTime / $numOfDocs, 2); - - echo date('Y-m-d H:i:s') . " Stats after $numOfDocs documents -- memory $memNow MB," - . " peak memory $memPeak (MB), $docPerSecond docs/second, $secondsPerDoc seconds/doc" . PHP_EOL; - } - - private function addDocumentsToIndex($indexer, $docs) - { - try { - $indexer->addDocumentsToIndex($docs); - } catch (Opus\Search\Exception $e) { - // echo date('Y-m-d H:i:s') . " ERROR: Failed indexing document $docId.\n"; - echo date('Y-m-d H:i:s') . " {$e->getMessage()}\n"; - } catch (Opus_Storage_Exception $e) { - // echo date('Y-m-d H:i:s') . " ERROR: Failed indexing unavailable file on document $docId.\n"; - echo date('Y-m-d H:i:s') . " {$e->getMessage()}\n"; - } - } - - private function forceSyncMode() - { - $config = Zend_Registry::get('Zend_Config'); - if (isset($config->runjobs->asynchronous) && filter_var($config->runjobs->asynchronous, FILTER_VALIDATE_BOOLEAN)) { - $this->_syncMode = false; - $config->runjobs->asynchronous = ''; // false - Zend_Registry::set('Zend_Config', $config); - } - } - - private function resetMode() - { - if (! $this->_syncMode) { - $config = Zend_Registry::get('Zend_Config'); - $config->runjobs->asynchronous = '1'; // true - Zend_Registry::set('Zend_Config', $config); - } - } - - private function write($str) - { - echo $str; - } -} - -/** - * Main code of index builder script. - */ -global $argc, $argv; - -$builder = new SolrIndexBuilder(); -$builder->run($argc, $argv); +$builder = new Opus\Search\IndexBuilder(); +$builder->run(); From 2eaaa45720071211017bbe2e62c3d2d92e6d89d2 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 7 Sep 2020 19:22:39 +0200 Subject: [PATCH 027/270] OPUSVIER-421 Set version for command line app. --- scripts/SolrIndexBuilder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/SolrIndexBuilder.php b/scripts/SolrIndexBuilder.php index 7259b67b2c..71a84135f5 100755 --- a/scripts/SolrIndexBuilder.php +++ b/scripts/SolrIndexBuilder.php @@ -43,4 +43,5 @@ */ $builder = new Opus\Search\IndexBuilder(); +$builder->setVersion(Application_Configuration::getOpusVersion()); $builder->run(); From 14bed9d60c605047ce4aabbf7287a4119d8c6630 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 8 Sep 2020 16:00:14 +0200 Subject: [PATCH 028/270] OPUSVIER-4328 New opus4 script --- bin/opus4 | 46 ++++++++++++++++++++++++++++++++++++ scripts/SolrIndexBuilder.php | 1 + 2 files changed, 47 insertions(+) create mode 100755 bin/opus4 diff --git a/bin/opus4 b/bin/opus4 new file mode 100755 index 0000000000..3cc38a6126 --- /dev/null +++ b/bin/opus4 @@ -0,0 +1,46 @@ +#!/usr/bin/env php + + * @copyright Copyright (c) 2020, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +require_once __DIR__ . '/../scripts/common/bootstrap.php'; + +/** + * OPUS 4 maintenance tool. + * + * For more information run the `help` command. + * $ bin/opus4 help + */ + +$builder = new Opus\Search\IndexBuilder(); +$builder->setVersion(Application_Configuration::getOpusVersion()); +$builder->setDefaultCommand('list'); +$builder->run(); diff --git a/scripts/SolrIndexBuilder.php b/scripts/SolrIndexBuilder.php index 71a84135f5..e26644d7e3 100755 --- a/scripts/SolrIndexBuilder.php +++ b/scripts/SolrIndexBuilder.php @@ -44,4 +44,5 @@ $builder = new Opus\Search\IndexBuilder(); $builder->setVersion(Application_Configuration::getOpusVersion()); +$builder->setDefaultCommand('index:index', true); $builder->run(); From 0a4b81b3600d6dfc4dccb04a8986433b6bef1a74 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 8 Sep 2020 16:19:31 +0200 Subject: [PATCH 029/270] OPUSVIER-4328 New opus4 console app --- bin/opus4 | 6 ++-- library/Application/Console/App.php | 55 +++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 library/Application/Console/App.php diff --git a/bin/opus4 b/bin/opus4 index 3cc38a6126..69e05cbf86 100755 --- a/bin/opus4 +++ b/bin/opus4 @@ -40,7 +40,5 @@ require_once __DIR__ . '/../scripts/common/bootstrap.php'; * $ bin/opus4 help */ -$builder = new Opus\Search\IndexBuilder(); -$builder->setVersion(Application_Configuration::getOpusVersion()); -$builder->setDefaultCommand('list'); -$builder->run(); +$app = new Application_Console_App(); +$app->run(); diff --git a/library/Application/Console/App.php b/library/Application/Console/App.php new file mode 100644 index 0000000000..a6bacec004 --- /dev/null +++ b/library/Application/Console/App.php @@ -0,0 +1,55 @@ + + * @copyright Copyright (c) 2020, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +use Opus\Search\IndexBuilder\IndexCommand; +use Opus\Search\IndexBuilder\OptimizeCommand; +use Opus\Search\IndexBuilder\RemoveCommand; +use Symfony\Component\Console\Application; + +/** + * Command line application for OPUS 4 management tasks. + */ +class Application_Console_App extends Application +{ + + public function __construct() + { + parent::__construct('OPUS 4 Console Tool', Application_Configuration::getOpusVersion()); + + $this->add(new IndexCommand()); + $this->add(new RemoveCommand()); + $this->add(new OptimizeCommand()); + + $this->setDefaultCommand('list'); + } +} From 27a3e069e6eb8cec23e347df902f1d2f6ef02867 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 8 Sep 2020 16:29:09 +0200 Subject: [PATCH 030/270] OPUSVIER-4328 Removed SolrIndexBuilder.php script --- bin/install.sh | 2 +- build.xml | 6 ++--- composer.json | 2 +- scripts/SolrIndexBuilder.php | 48 ------------------------------------ scripts/update-instance.sh | 4 ++- 5 files changed, 8 insertions(+), 54 deletions(-) delete mode 100755 scripts/SolrIndexBuilder.php diff --git a/bin/install.sh b/bin/install.sh index 22e18ef5fd..364a607a63 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -299,7 +299,7 @@ then echo -e "Solr server is running under http://localhost:$SOLR_SERVER_PORT/solr\n" # start indexing of testdata - "$BASEDIR/scripts/SolrIndexBuilder.php" + "$BASEDIR/bin/opus4 index:index" fi cd "$BASEDIR" diff --git a/build.xml b/build.xml index 4281dd2bbe..34f6af2b00 100644 --- a/build.xml +++ b/build.xml @@ -134,7 +134,7 @@ - + @@ -261,8 +261,8 @@ - - + + diff --git a/composer.json b/composer.json index 505664ebb4..67621b2d4f 100644 --- a/composer.json +++ b/composer.json @@ -68,6 +68,6 @@ "phpmd": "phpmd library xml cleancode,unusedcode,design,naming --reportfile build/phpmd.xml --ignore-violations-on-exit", "phploc": "phploc --log-csv build/phploc.csv src", "phpcpd": "phpcpd . --min-lines 3 --min-tokens 30 --log-pmd build/pmd-cpd.xml --progress || true", - "index": "php scripts/SolrIndexBuilder.php" + "index": "bin/opus4 index:index" } } diff --git a/scripts/SolrIndexBuilder.php b/scripts/SolrIndexBuilder.php deleted file mode 100755 index e26644d7e3..0000000000 --- a/scripts/SolrIndexBuilder.php +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env php - - * @author Jens Schwidder - * @copyright Copyright (c) 2010-2020, OPUS 4 development team - * @license http://www.gnu.org/licenses/gpl.html General Public License - */ - -require_once __DIR__ . '/common/bootstrap.php'; - -/** - * Script for indexing documents and index maintenance. - * - * For more information run the `help` command. - * - * $ ./SolrIndexBuilder.php help - */ - -$builder = new Opus\Search\IndexBuilder(); -$builder->setVersion(Application_Configuration::getOpusVersion()); -$builder->setDefaultCommand('index:index', true); -$builder->run(); diff --git a/scripts/update-instance.sh b/scripts/update-instance.sh index 43b1ecddf2..3cd08eac3d 100755 --- a/scripts/update-instance.sh +++ b/scripts/update-instance.sh @@ -43,4 +43,6 @@ cd $INSTANCE_DIR/server/scripts # remove all fulltext associated with hhar test documents php opus-console.php snippets/delete_files.php -php SolrIndexBuilder.php \ No newline at end of file +cd $INSTANCE_DIR + +php bin/opus4 index:index \ No newline at end of file From fa8d01dc53e8312f00dee0b068d8b1b4521907c3 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 8 Sep 2020 16:48:00 +0200 Subject: [PATCH 031/270] OPUSVIER-4328 Updated release notes --- RELEASE_NOTES.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 870d8c0cf4..e17104dda9 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,33 @@ # OPUS 4 Release Notes +## Release 4.7.1 + +# Neues Kommandozeilen-Skript `bin/opus4` + +Es gibt das neue Skript `bin/opus4`, dass in Zukunft die Rolle des zentralen OPUS 4 +Werkzeugs auf der Kommandozeile übernehmen wird. Mit den Kommando `list` lassen sich +die bisher integrierten Kommandos anzeigen. Mit `help` lassen sich Informationen zu +einzelnen Kommandos abrufen. + + $ bin/opus4 list + $ bin/opus4 help index:index + +# Wartung des Solr-Index + +Das Skript `script/SolrIndexBuilder.php` wurde durch `bin/opus4` ersetzt. Dadurch +soll der Aufruf vereinfacht werden. Das neue Skript soll außerdem in Zukunft auch +andere Funktionen übernehmen, die nichts mit dem Index zu tun haben. + +Im OPUS 4 Handbuch gibt es eine neue Seite, die die Funktionen des Skripts für +den Index beschreibt. + + + +Es gibt jetzt die Möglichkeit einzelne Dokumente einfacher zu indexieren oder auch +aus dem Index zu entfernen. Es kann über eine Option bestimmt werden wie viele +Dokument gleichzeitig zum Solr-Server geschickt werden sollen. Das kann helfen, +wenn es Probleme bei der Indexierung gibt. + ## Release 4.7 2020-07-31 Die Änderungen in OPUS __4.7__, die hier aufgeführt sind, ergänzen was schon für From b2c33bdbfdc56fec2d5bad208a1b416239398226 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 9 Sep 2020 14:04:37 +0200 Subject: [PATCH 032/270] OPUSVIER-4326 Removed optimize command. Updated package names. --- library/Application/Console/App.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/Application/Console/App.php b/library/Application/Console/App.php index a6bacec004..959651a48b 100644 --- a/library/Application/Console/App.php +++ b/library/Application/Console/App.php @@ -31,9 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -use Opus\Search\IndexBuilder\IndexCommand; -use Opus\Search\IndexBuilder\OptimizeCommand; -use Opus\Search\IndexBuilder\RemoveCommand; +use Opus\Search\Console\IndexCommand; +use Opus\Search\Console\RemoveCommand; use Symfony\Component\Console\Application; /** @@ -48,7 +47,6 @@ public function __construct() $this->add(new IndexCommand()); $this->add(new RemoveCommand()); - $this->add(new OptimizeCommand()); $this->setDefaultCommand('list'); } From 3e708c885e646e473885697b9abb1486b478039c Mon Sep 17 00:00:00 2001 From: kaustabhbarman Date: Thu, 10 Sep 2020 13:09:06 +0200 Subject: [PATCH 033/270] OPUSVIER-4289 translation format --- application/configs/application.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/application/configs/application.ini b/application/configs/application.ini index fc72ba7e71..079a18b010 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -238,7 +238,7 @@ admin.documents.linkToAuthorSearch = 0 ; Use names of Zend_Log constants (e.g. DEBUG, INFO, WARN, ERR) log.level = WARN log.format = '%timestamp% %priorityName% (%priority%, ID %runId%): %message%' -logging.log.translation.format = '' ; TODO what should be the format? +logging.log.translation.format = '%timestamp% %priorityName%: %message%' logging.log.translation.file = 'translation.xml' logging.log.translation.level = INFO @@ -585,7 +585,6 @@ errorController.showException = 1 errorController.showRequest = 1 ; TODO not used yet resources.frontController.params.displayExceptions = 1 -; TODO log.level has already been set as WARN log.level = DEBUG log.untranslated = true From eb8a151ec8899614de57596aaf5a57dc161a1680 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 10 Sep 2020 18:03:05 +0200 Subject: [PATCH 034/270] OPUSVIER-421 Changes dependency for opus4-search --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 67621b2d4f..bd19637bbe 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "solarium/solarium": "3.8.*", "opus4-repo/opus4-common": "dev-master", "opus4-repo/framework": "dev-master", - "opus4-repo/search": "dev-OPUSVIER-421", + "opus4-repo/search": "dev-master", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", From c5c78b51d497a44e36ea742d7b381a8f5deea884 Mon Sep 17 00:00:00 2001 From: kaustabhbarman Date: Thu, 10 Sep 2020 18:28:08 +0200 Subject: [PATCH 035/270] OPUSVIER-4289 logService registered --- application/configs/application.ini | 2 +- library/Application/Bootstrap.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/application/configs/application.ini b/application/configs/application.ini index 079a18b010..76736433aa 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -238,7 +238,7 @@ admin.documents.linkToAuthorSearch = 0 ; Use names of Zend_Log constants (e.g. DEBUG, INFO, WARN, ERR) log.level = WARN log.format = '%timestamp% %priorityName% (%priority%, ID %runId%): %message%' -logging.log.translation.format = '%timestamp% %priorityName%: %message%' +logging.log.translation.format = '%timestamp% %priorityName% (%priority%, ID %runId%): %message%' logging.log.translation.file = 'translation.xml' logging.log.translation.level = INFO diff --git a/library/Application/Bootstrap.php b/library/Application/Bootstrap.php index be0b680baa..43a3b1e968 100644 --- a/library/Application/Bootstrap.php +++ b/library/Application/Bootstrap.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Log\LogService; + /** * Provide methods to setup and run the application. It also provides a couple of static * variables for quicker access to application components like the front controller. From 7b22fd03198fbc68a0c4efe37601c592abe26e59 Mon Sep 17 00:00:00 2001 From: kaustabhbarman Date: Thu, 10 Sep 2020 19:52:50 +0200 Subject: [PATCH 036/270] OPUSVIER-4289 More implementation of LogService --- library/Application/Bootstrap.php | 3 - .../MigrateSeriesCollections.php | 3 +- .../MigrateSubjectsToCollections.php | 5 +- tests/support/SimpleBootstrap.php | 66 +++---------------- 4 files changed, 14 insertions(+), 63 deletions(-) diff --git a/library/Application/Bootstrap.php b/library/Application/Bootstrap.php index 43a3b1e968..c2ec54b3de 100644 --- a/library/Application/Bootstrap.php +++ b/library/Application/Bootstrap.php @@ -222,9 +222,6 @@ protected function _setupPageCache() protected function _initTranslation() { $this->bootstrap(['Configuration', 'Session', 'Logging', 'ZendCache']); - - // TODO OPUSVIER-4289 Use LogService - // TODO temporary hack until LogService refactoring is finished (OPUSVIER-3657) $logService = LogService::getInstance(); $logger = $logService->getLog('translation'); diff --git a/scripts/update_migration/MigrateSeriesCollections.php b/scripts/update_migration/MigrateSeriesCollections.php index 7dd719ff22..c4e55db006 100755 --- a/scripts/update_migration/MigrateSeriesCollections.php +++ b/scripts/update_migration/MigrateSeriesCollections.php @@ -49,8 +49,9 @@ public function __construct($logfile) } /** - * TODO OPUSVIER-4289 Use LogService * Initialise the logger with the given file. + * + * LogService cannot be used here as the log is being written into the current folder, LogService would change that behaviour. */ private function initLogger($logfileName) { diff --git a/scripts/update_migration/MigrateSubjectsToCollections.php b/scripts/update_migration/MigrateSubjectsToCollections.php index 50db17c2f2..c965187f36 100755 --- a/scripts/update_migration/MigrateSubjectsToCollections.php +++ b/scripts/update_migration/MigrateSubjectsToCollections.php @@ -49,7 +49,10 @@ // Initialize logger. $logfileName = $argv[1]; -//TODO OPUSVIER-4289 Use LogService +/** + * LogService cannot be used here as the log is being written into the current folder, + * LogService would change that behaviour. + */ $logfile = @fopen($logfileName, 'a', false); $writer = new Zend_Log_Writer_Stream($logfile); $formatter = new Zend_Log_Formatter_Simple('%timestamp% %priorityName%: %message%' . PHP_EOL); diff --git a/tests/support/SimpleBootstrap.php b/tests/support/SimpleBootstrap.php index 8701c2b444..6290aef10e 100644 --- a/tests/support/SimpleBootstrap.php +++ b/tests/support/SimpleBootstrap.php @@ -32,6 +32,9 @@ * * TODO take care of duplicated code (from regular bootstrap) - maybe SimpleBootstrap is not needed anymore? */ + +use Opus\Log\LogService; + class SimpleBootstrap extends Zend_Application_Bootstrap_Bootstrap { @@ -61,75 +64,22 @@ protected function _initConfiguration() * Setup Logging * * @throws Exception If logging file couldn't be opened. - * @return void + * @return Zend_Log * */ protected function _initLogging() { $this->bootstrap('Configuration'); - $config = $this->getResource('Configuration'); - $logFilename = "opus-console.log"; - $logfilePath = $config->workspacePath . '/log/' . $logFilename; - - $logfile = @fopen($logfilePath, 'a', false); - - if ($logfile === false) { - $path = dirname($logfilePath); - - if (! is_dir($path)) { - throw new Exception('Directory for logging does not exist'); - } else { - throw new Exception("Failed to open logging file: $logfilePath"); - } - } - - // Write ID string to global variables, so we can identify/match individual runs. - $GLOBALS['id_string'] = uniqid(); - - $format = '%timestamp% %priorityName% (%priority%, ID '.$GLOBALS['id_string'].'): %message%' . PHP_EOL; - $formatter = new Zend_Log_Formatter_Simple($format); - - $writer = new Zend_Log_Writer_Stream($logfile); - $writer->setFormatter($formatter); + $logService = LogService::getInstance(); - $logger = new Zend_Log($writer); - $logLevelName = 'INFO'; - $logLevelNotConfigured = false; + $logger = $logService->createLog(LogService::DEFAULT_LOG, null, null, $logFilename); + $logLevel = $logService->getDefaultPriority(); - if (isset($config->log->level)) { - $logLevelName = strtoupper($config->log->level); - } else { - $logLevelNotConfigured = true; - } - - $zendLogRefl = new ReflectionClass('Zend_Log'); - - $invalidLogLevel = false; - - $logLevel = $zendLogRefl->getConstant($logLevelName); - - if (empty($logLevel)) { - $logLevel = Zend_Log::INFO; - $invalidLogLevel = true; - } - - // filter log output - $priorityFilter = new Zend_Log_Filter_Priority($logLevel); Zend_Registry::set('LOG_LEVEL', $logLevel); - $logger->addFilter($priorityFilter); - - if ($logLevelNotConfigured) { - $logger->warn("Log level not configured, using default '$logLevelName'."); - } - - if ($invalidLogLevel) { - $logger->err("Invalid log level '$logLevelName' configured."); - } - - Zend_Registry::set('Zend_Log', $logger); + Zend_Registry::set('LOG_LEVEL', $logLevel); $logger->debug('Logging initialized'); From a3f1c984818becd84371f43cfac60e798aada7b9 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 11 Sep 2020 08:58:26 +0200 Subject: [PATCH 037/270] OPUSVIER-4332 Removed unused indexing scripts. --- scripts/indexing/index-runner.php | 42 ------- scripts/indexing/solr_index_clear.php | 45 -------- scripts/indexing/solr_index_optimize.php | 44 -------- scripts/indexing/solr_indexing.php | 138 ----------------------- 4 files changed, 269 deletions(-) delete mode 100644 scripts/indexing/index-runner.php delete mode 100644 scripts/indexing/solr_index_clear.php delete mode 100644 scripts/indexing/solr_index_optimize.php delete mode 100644 scripts/indexing/solr_indexing.php diff --git a/scripts/indexing/index-runner.php b/scripts/indexing/index-runner.php deleted file mode 100644 index d4be862ab0..0000000000 --- a/scripts/indexing/index-runner.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @author Henning Gerhardt - * @copyright Copyright (c) 2010 - * Saechsische Landesbibliothek - Staats- und Universitaetsbibliothek Dresden (SLUB) - * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ - */ - -define('APPLICATION_ENV', 'production'); - -// basic bootstrapping -require_once dirname(__FILE__) . '/../common/bootstrap.php'; - -// set up job runner -$jobrunner = new Opus_Job_Runner; -$jobrunner->setLogger(Zend_Registry::get('Zend_Log')); -// no waiting between jobs -$jobrunner->setDelay(0); -// set a limit of 100 index jobs per run -$jobrunner->setLimit(100); - -$indexWorker = new Qucosa_Job_Worker_IndexOpusDocument; -$indexWorker->setIndex(Zend_Registry::get('Qucosa_Search_Index')); -$indexWorker->setFileBasePathPattern(Zend_Registry::get('Zend_Config')->file->destinationPath . '/$documentId'); -$jobrunner->registerWorker($indexWorker); - -// run processing -$jobrunner->run(); diff --git a/scripts/indexing/solr_index_clear.php b/scripts/indexing/solr_index_clear.php deleted file mode 100644 index 00778f26f8..0000000000 --- a/scripts/indexing/solr_index_clear.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Copyright (c) 2010 - * Saechsische Landesbibliothek - Staats- und Universitaetsbibliothek Dresden (SLUB) - * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ - */ - -define('APPLICATION_ENV', 'production'); - -// basic bootstrapping -require_once dirname(__FILE__) . '/../common/bootstrap.php'; - -$config = Zend_Registry::get('Zend_Config'); - -$host = $config->searchengine->solr->host; -$port = $config->searchengine->solr->port; -$baseUri = $config->searchengine->solr->path; -$EOL = "\n"; - -$solr = new Apache_Solr_Service($host, $port, $baseUri); - -if (false === $solr->ping()) { - echo 'Could not connect to solr service.' . $EOL; - return; -} - -$solr->deleteByQuery('*:*'); -$solr->commit(); -$solr->optimize(); - -echo 'Cleaning solr index on "' . $host . ':' . $port . $baseUri . '" done.' . $EOL; diff --git a/scripts/indexing/solr_index_optimize.php b/scripts/indexing/solr_index_optimize.php deleted file mode 100644 index 3ebd4285bd..0000000000 --- a/scripts/indexing/solr_index_optimize.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Copyright (c) 2010 - * Saechsische Landesbibliothek - Staats- und Universitaetsbibliothek Dresden (SLUB) - * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ - */ - -define('APPLICATION_ENV', 'production'); - -// basic bootstrapping -require_once dirname(__FILE__) . '/../common/bootstrap.php'; - -$config = Zend_Registry::get('Zend_Config'); - -$host = $config->searchengine->solr->host; -$port = $config->searchengine->solr->port; -$baseUri = $config->searchengine->solr->path; -$EOL = "\n"; - -$solr = new Apache_Solr_Service($host, $port, $baseUri); - -if (false === $solr->ping()) { - echo 'Could not connect to solr service.' . $EOL; - return; -} - -$solr->commit(); -$solr->optimize(); - -echo 'Optimizing solr index on "' . $host . ':' . $port . $baseUri . '" done.' . $EOL; diff --git a/scripts/indexing/solr_indexing.php b/scripts/indexing/solr_indexing.php deleted file mode 100644 index b84480fdfb..0000000000 --- a/scripts/indexing/solr_indexing.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @copyright Copyright (c) 2010 - * Saechsische Landesbibliothek - Staats- und Universitaetsbibliothek Dresden (SLUB) - * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ - */ - -function printMessage($message) -{ - echo strftime('%d.%m.%Y %H:%M:%S', time()) . $message . "\n"; -} - -define('APPLICATION_ENV', 'production'); - -// basic bootstrapping -require_once dirname(__FILE__) . '/../common/bootstrap.php'; - -$config = Zend_Registry::get('Zend_Config'); - -$host = $config->searchengine->solr->host; -$port = $config->searchengine->solr->port; -$baseUri = $config->searchengine->solr->path; -$EOL = "\n"; - -$commitRange = 100; - -$solr = new Apache_Solr_Service($host, $port, $baseUri); - -if (false === $solr->ping()) { - echo 'Could not connect to solr service.' . $EOL; - return; -} - -$startTime = time(); -$docIds = Opus_Document::getAllIds(); - -$documents = []; - -$conf = Zend_Registry::get('Zend_Config'); -$baseFilePath = null; -if ((true === isset($conf->file->destinationPath)) and - (true === is_dir($conf->file->destinationPath))) { - $baseFilePath = $conf->file->destinationPath; -} - -foreach ($docIds as $docId) { - printMessage(' Indexing document : ' . $docId); - - $opusDoc = new Opus_Document($docId); - - $solrDocument = Qucosa_Search_Solr_Document_OpusDocument::loadOpusDocument($opusDoc); - - if ((null !== $baseFilePath) and - ('published' === $opusDoc->getServerState())) { - $files = $opusDoc->getFile(); - - if (false === is_array($files)) { - $files = [$files]; - } - - foreach ($files as $file) { - $fileName = $file->getPathName(); - $filePath = $baseFilePath . DIRECTORY_SEPARATOR . $docId . DIRECTORY_SEPARATOR . $fileName; - - // skip files which are invisible on frontdoor - if (false == $file->getFrontdoorVisible()) { - printMessage(' Skipped file "' . $filePath . '". Reason: Not visible on frontdoor.'); - continue; - } - - if (true === is_readable($filePath)) { - $mimeType = mime_content_type($filePath); - switch ($mimeType) { - case 'application/pdf': - try { - $fileContent = Qucosa_Search_Solr_Document_Pdf::loadPdf($filePath); - $solrDocument->addField('fulltext', implode(' ', $fileContent->body)); - } catch (Exception $e) { - printMessage(' Skipped file "' . $filePath . '". Reason: ' . $e->getMessage()); - } - break; - - default: - printMessage( - ' Skipped file "' . $filePath . '". Reason: Mime type "' . $mimeType - . '" has no processor.' - ); - break; - } - } else { - printMessage(' Skipped file "' . $filePath . '". Reason: File not found.'); - } - } - } else { - printMessage( - ' Skipped indexing of document files. Reason: no base path to files or document is not published.' - ); - } - - $documents[] = $solrDocument; - - if (0 === (count($documents) % $commitRange)) { - printMessage(' Committing data set of ' . $commitRange . ' values.'); - $solr->addDocuments($documents); - $solr->commit(); - $documents = []; - printMessage(' Committing done.'); - } -} - -if (count($documents) > 0) { - printMessage(' Committing data set of ' . count($documents) . ' values.'); - $solr->addDocuments($documents); - $solr->commit(); - printMessage(' Committing done.'); -} - -printMessage(' Optimizing.'); -$solr->optimize(); -printMessage(' Optimizing done.'); - -$stopTime = time(); -$time = $stopTime - $startTime; -echo 'Time to index all documents: ' . gmstrftime('%H:%M:%S', $time) . $EOL; From 91ea3a10b1f26aee0627e7f88953e3272a0bdb41 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 11 Sep 2020 09:20:55 +0200 Subject: [PATCH 038/270] OPUSVIER-4332 Marked scripts for later review --- scripts/fix-permissions.sh | 2 ++ scripts/opus-console.php | 3 ++- scripts/opus-smtp-dumpserver.php | 2 ++ scripts/update-instance.sh | 2 ++ scripts/xslt.php | 3 +++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/fix-permissions.sh b/scripts/fix-permissions.sh index 3deaf08b72..047fdc90ae 100755 --- a/scripts/fix-permissions.sh +++ b/scripts/fix-permissions.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# TODO remove this file (compare function with set-file-permissions in bin folder) + set -e FILEOWNER="$1" diff --git a/scripts/opus-console.php b/scripts/opus-console.php index 8cf963a741..f3aa17a103 100644 --- a/scripts/opus-console.php +++ b/scripts/opus-console.php @@ -1,5 +1,4 @@ Date: Fri, 11 Sep 2020 11:16:10 +0200 Subject: [PATCH 039/270] OPUSVIER-4332 Added TODO for reviewed scripts --- scripts/common/console.php | 3 +++ scripts/snippets/OPUSHOSTING-481.php | 2 ++ scripts/snippets/change_document_type.php | 2 +- scripts/snippets/create_10000_documents.php | 2 ++ scripts/snippets/create_all_fields_document.php | 2 ++ scripts/snippets/create_doctype-phtml_from_xml.php | 2 ++ scripts/snippets/delete_all_docs.php | 2 ++ scripts/snippets/delete_files.php | 2 ++ scripts/snippets/delete_non-demo_docs.php | 1 + scripts/snippets/export_document.php | 2 ++ scripts/snippets/export_import_all_docs.php | 2 ++ .../snippets/find_docs_with_multiple_titles_or_abstracts.php | 1 + scripts/snippets/find_docs_without_titles_in_doclanguage.php | 1 + .../snippets/find_missing_published_docs_in_searchindex.php | 1 + scripts/snippets/find_modified_docs_in_searchindex.php | 1 + scripts/snippets/find_urns_for_docs_without_visible_files.php | 2 ++ scripts/snippets/get_nonextractable_docs.php | 2 ++ scripts/snippets/import_collections.php | 1 + scripts/snippets/import_document.php | 2 ++ scripts/snippets/publications-stats.php | 2 ++ scripts/snippets/release_all_unpublished_docs.php | 2 ++ scripts/snippets/split_firstname_academic_title.php | 2 ++ scripts/snippets/tmx_add_seg_cdata.sh | 2 ++ scripts/snippets/update-dnbinstitute.php | 3 ++- 24 files changed, 42 insertions(+), 2 deletions(-) diff --git a/scripts/common/console.php b/scripts/common/console.php index 24916af073..9491314097 100644 --- a/scripts/common/console.php +++ b/scripts/common/console.php @@ -36,6 +36,9 @@ * @version $Id$ */ +// TODO integrate as command in opus4 tool +// TODO add exit command + $config = Zend_Registry::get('Zend_Config'); if (isset($config->security) && filter_var($config->security, FILTER_VALIDATE_BOOLEAN)) { // setup realm diff --git a/scripts/snippets/OPUSHOSTING-481.php b/scripts/snippets/OPUSHOSTING-481.php index ae171577a5..6443a104b9 100644 --- a/scripts/snippets/OPUSHOSTING-481.php +++ b/scripts/snippets/OPUSHOSTING-481.php @@ -36,6 +36,8 @@ * Dieses Script gibt die IDs aller veröffentlichten Dokumente aus, bei denen * Jane Doe der Name des Autors ODER der Name einer sonstigen beteiligten * Personen (advisor, contributor, editor, other, translator) ist + * + * TODO very specific script (make generic command?) - problem analysis plugin */ $firstName = "Jane"; diff --git a/scripts/snippets/change_document_type.php b/scripts/snippets/change_document_type.php index ee8be1945e..c7551f22e3 100644 --- a/scripts/snippets/change_document_type.php +++ b/scripts/snippets/change_document_type.php @@ -34,7 +34,7 @@ * @version $Id: update-thesispublisher.php 11775 2013-06-25 14:28:41Z tklein $ */ /** - * + * TODO should this be part of administration, part of opus4 tool */ if (basename(__FILE__) !== basename($argv[0])) { echo "script must be executed directy (not via opus-console)\n"; diff --git a/scripts/snippets/create_10000_documents.php b/scripts/snippets/create_10000_documents.php index 5d78fedda3..62c2315f07 100644 --- a/scripts/snippets/create_10000_documents.php +++ b/scripts/snippets/create_10000_documents.php @@ -33,6 +33,8 @@ /** * script to create 10000 documents, e.g., for performance testing + * + * TODO move as command to opus4dev tool */ for ($i = 1; $i < 10000; $i++) { diff --git a/scripts/snippets/create_all_fields_document.php b/scripts/snippets/create_all_fields_document.php index 7d3a88a254..8c5b19376f 100644 --- a/scripts/snippets/create_all_fields_document.php +++ b/scripts/snippets/create_all_fields_document.php @@ -34,6 +34,8 @@ * TODO create test that verifies completeness (compare with describe function) */ +// TODO move script (is used for testing purposes) - also is probably out of date (since data model changes) + $doc = new Opus_Document(); $doc->setType('all'); $doc->setServerState('published'); diff --git a/scripts/snippets/create_doctype-phtml_from_xml.php b/scripts/snippets/create_doctype-phtml_from_xml.php index 2e99cb69c6..a56a42efbb 100644 --- a/scripts/snippets/create_doctype-phtml_from_xml.php +++ b/scripts/snippets/create_doctype-phtml_from_xml.php @@ -35,6 +35,8 @@ * This script takes a doctype XML-definition as input and spills out the * PHP instructions for use in the corresponding .phtml file. * It requires the file doctype.xslt to be in the same directory as this script. + * + * TODO move (is used for development and probably only of limited use) */ if ($argc == 2) { diff --git a/scripts/snippets/delete_all_docs.php b/scripts/snippets/delete_all_docs.php index 74737a1b96..cb74c3ea16 100644 --- a/scripts/snippets/delete_all_docs.php +++ b/scripts/snippets/delete_all_docs.php @@ -35,6 +35,8 @@ /** * Removes all documents * + * TODO convert to command (with confirmation check) + * */ $finder = new Opus_DocumentFinder(); diff --git a/scripts/snippets/delete_files.php b/scripts/snippets/delete_files.php index d6a72257b9..58de45d706 100644 --- a/scripts/snippets/delete_files.php +++ b/scripts/snippets/delete_files.php @@ -35,6 +35,8 @@ /** * Removes associated Opus_File objects for all HHAR test documents (id = 1..90) * since full text files do not exist in file system + * + * TODO move script (it is used for testing/development) */ $startId = 1; diff --git a/scripts/snippets/delete_non-demo_docs.php b/scripts/snippets/delete_non-demo_docs.php index 35c6d0e555..6fb65a1303 100644 --- a/scripts/snippets/delete_non-demo_docs.php +++ b/scripts/snippets/delete_non-demo_docs.php @@ -36,6 +36,7 @@ * Erstellt die Demoinstanz, in der nur die Testdokumente mit den IDs 91 bis 110 * enthalten sind. * + * TODO move script (it is used for demo instance) */ $finder = new Opus_DocumentFinder(); diff --git a/scripts/snippets/export_document.php b/scripts/snippets/export_document.php index 13cb1665f6..f2e88affce 100644 --- a/scripts/snippets/export_document.php +++ b/scripts/snippets/export_document.php @@ -34,6 +34,8 @@ /** * Returns the XML representation of the document with given id $id. + * + * TODO convert to command (overlaps with opus-dump-document-xml.php) */ if (isset($argv[2]) && ! empty($argv[2]) && is_numeric($argv[2])) { diff --git a/scripts/snippets/export_import_all_docs.php b/scripts/snippets/export_import_all_docs.php index e57f6e98f2..f1d174cdec 100644 --- a/scripts/snippets/export_import_all_docs.php +++ b/scripts/snippets/export_import_all_docs.php @@ -34,6 +34,8 @@ /** * Tries to export and import all documents. + * + * TODO move (this is a test script) */ $docFinder = new Opus_DocumentFinder(); diff --git a/scripts/snippets/find_docs_with_multiple_titles_or_abstracts.php b/scripts/snippets/find_docs_with_multiple_titles_or_abstracts.php index a82ce22e3b..cb90f8cbd2 100644 --- a/scripts/snippets/find_docs_with_multiple_titles_or_abstracts.php +++ b/scripts/snippets/find_docs_with_multiple_titles_or_abstracts.php @@ -40,6 +40,7 @@ * Diese Dokumente müssen aktuell manuell behandelt werden, da das Dokument * sonst nicht fehlerfrei indexiert werden kann (siehe OPUSVIER-2240). * + * TODO integrity check (where to put it?) - should be part of problem analysis package */ $updateRequired = 0; diff --git a/scripts/snippets/find_docs_without_titles_in_doclanguage.php b/scripts/snippets/find_docs_without_titles_in_doclanguage.php index 7b616fafb2..8b85057c54 100644 --- a/scripts/snippets/find_docs_without_titles_in_doclanguage.php +++ b/scripts/snippets/find_docs_without_titles_in_doclanguage.php @@ -36,6 +36,7 @@ * * Diese Dokumente werden in der Trefferansicht als "Unbekanntes Dokument" angezeigt. * + * TODO integrity check (where to put it?) - should be part of problem analysis package */ $updateRequired = 0; diff --git a/scripts/snippets/find_missing_published_docs_in_searchindex.php b/scripts/snippets/find_missing_published_docs_in_searchindex.php index 5be2b8c87d..1875b4624f 100644 --- a/scripts/snippets/find_missing_published_docs_in_searchindex.php +++ b/scripts/snippets/find_missing_published_docs_in_searchindex.php @@ -38,6 +38,7 @@ * * Siehe dazu auch die Story OPUSVIER-2368. * + * TODO convert to command for index analysis */ $numOfErrors = 0; diff --git a/scripts/snippets/find_modified_docs_in_searchindex.php b/scripts/snippets/find_modified_docs_in_searchindex.php index fcb30e8a89..c230ad12ce 100644 --- a/scripts/snippets/find_modified_docs_in_searchindex.php +++ b/scripts/snippets/find_modified_docs_in_searchindex.php @@ -39,6 +39,7 @@ * * Siehe dazu auch das Ticket OPUSVIER-2853. * + * TODO convert to command for index analysis */ $numOfModified = 0; $numOfErrors = 0; diff --git a/scripts/snippets/find_urns_for_docs_without_visible_files.php b/scripts/snippets/find_urns_for_docs_without_visible_files.php index aefc8dda09..d5696cbf4f 100644 --- a/scripts/snippets/find_urns_for_docs_without_visible_files.php +++ b/scripts/snippets/find_urns_for_docs_without_visible_files.php @@ -35,6 +35,8 @@ /** * Dieses Script sucht Dokumente ohne sichtbare Dateien, fuer die bereits * eine URN vergeben wurde. + * + * TODO integrity check - make part of tools (console, administration) */ $updateRequired = 0; diff --git a/scripts/snippets/get_nonextractable_docs.php b/scripts/snippets/get_nonextractable_docs.php index 769188ea71..1c15a151b9 100644 --- a/scripts/snippets/get_nonextractable_docs.php +++ b/scripts/snippets/get_nonextractable_docs.php @@ -34,6 +34,8 @@ /** * Finds all non-extractable full texts. + * + * TODO make part of diagnostic tools for index problems */ $host = 'opus4web.zib.de'; diff --git a/scripts/snippets/import_collections.php b/scripts/snippets/import_collections.php index d74d5470f1..2116bebec8 100644 --- a/scripts/snippets/import_collections.php +++ b/scripts/snippets/import_collections.php @@ -36,6 +36,7 @@ * file format: each collection (name and number) on a separate line * collection name and number are separated by | character * + * TODO make a command for importing collections in opus4 tool */ // ID of parent collection diff --git a/scripts/snippets/import_document.php b/scripts/snippets/import_document.php index fae063344f..af2364d7bf 100644 --- a/scripts/snippets/import_document.php +++ b/scripts/snippets/import_document.php @@ -35,6 +35,8 @@ /** * Imports the XML representation from stdin and creates a new OPUS 4 * document (with a new ID). + * + * TODO make part of opus4 tool */ $xml = ''; diff --git a/scripts/snippets/publications-stats.php b/scripts/snippets/publications-stats.php index b22fd46b15..54fdfc7e04 100644 --- a/scripts/snippets/publications-stats.php +++ b/scripts/snippets/publications-stats.php @@ -34,6 +34,8 @@ /** * Basic publication statistics (based on server_published_date) + * + * TODO make command in opus4 tool */ $df = new Opus_DocumentFinder(); diff --git a/scripts/snippets/release_all_unpublished_docs.php b/scripts/snippets/release_all_unpublished_docs.php index 505116708a..cb3a21c6ac 100644 --- a/scripts/snippets/release_all_unpublished_docs.php +++ b/scripts/snippets/release_all_unpublished_docs.php @@ -34,6 +34,8 @@ /** * Releases all documents in server state unpublished. + * + * TODO useful? should it be part of opus4 or opus4dev */ $docFinder = new Opus_DocumentFinder(); diff --git a/scripts/snippets/split_firstname_academic_title.php b/scripts/snippets/split_firstname_academic_title.php index 753da3c001..b2e1ed4856 100644 --- a/scripts/snippets/split_firstname_academic_title.php +++ b/scripts/snippets/split_firstname_academic_title.php @@ -41,6 +41,8 @@ * Dieses Problem tritt auf bei der Migration aus OPUS3, wo es noch kein * separates Feld für das Ablegen des akademischen Titels einer Person gab. * + * TODO fixing tool - where should it go? + * */ foreach (Opus_Person::getAll() as $person) { diff --git a/scripts/snippets/tmx_add_seg_cdata.sh b/scripts/snippets/tmx_add_seg_cdata.sh index f408dbb548..92c1e2f6d0 100644 --- a/scripts/snippets/tmx_add_seg_cdata.sh +++ b/scripts/snippets/tmx_add_seg_cdata.sh @@ -23,5 +23,7 @@ # 1. Files are ignored where a CDATA element is present in some but not all of the tags. # 2. ALL ".tmx" files within the current directory or any of it's subdirectories are parsed and possibly altered. +# TODO move this is a development script + find . -name *.tmx -exec grep -L '##]]>#g' \ No newline at end of file diff --git a/scripts/snippets/update-dnbinstitute.php b/scripts/snippets/update-dnbinstitute.php index bef771e7da..7ae16244f2 100644 --- a/scripts/snippets/update-dnbinstitute.php +++ b/scripts/snippets/update-dnbinstitute.php @@ -32,7 +32,8 @@ * @version $Id: update-thesispublisher.php 11775 2013-06-25 14:28:41Z tklein $ */ /** - * + * TODO find out what it does - make command? + * it adds ThesisPublisher to specified document types */ if (basename(__FILE__) !== basename($argv[0])) { echo "script must be executed directy (not via opus-console)\n"; From 1bbba1c72105ef1f181f384298a6355bbd5dde25 Mon Sep 17 00:00:00 2001 From: kaustabhbarman Date: Tue, 15 Sep 2020 18:06:26 +0200 Subject: [PATCH 040/270] OPUSVIER-4289 Comments --- application/configs/application.ini | 6 +++--- scripts/update_migration/MigrateSeriesCollections.php | 2 +- scripts/update_migration/MigrateSubjectsToCollections.php | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/application/configs/application.ini b/application/configs/application.ini index 76736433aa..d057eb714a 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -237,10 +237,10 @@ admin.documents.linkToAuthorSearch = 0 ; LOGGING CONFIGURATION (OPTIONAL) ; Use names of Zend_Log constants (e.g. DEBUG, INFO, WARN, ERR) log.level = WARN -log.format = '%timestamp% %priorityName% (%priority%, ID %runId%): %message%' -logging.log.translation.format = '%timestamp% %priorityName% (%priority%, ID %runId%): %message%' +log.format = '%timestamp% %priorityName% (ID %runId%): %message%' +logging.log.translation.format = '%timestamp% (ID %runId%): %message%' logging.log.translation.file = 'translation.xml' -logging.log.translation.level = INFO +logging.log.translation.level = DEBUG ; WARN for warning conditions ; LOGGING RELATED SETTINGS ; if set to true all xml that is generated while indexing is prepared for logging diff --git a/scripts/update_migration/MigrateSeriesCollections.php b/scripts/update_migration/MigrateSeriesCollections.php index c4e55db006..39958aa190 100755 --- a/scripts/update_migration/MigrateSeriesCollections.php +++ b/scripts/update_migration/MigrateSeriesCollections.php @@ -51,7 +51,7 @@ public function __construct($logfile) /** * Initialise the logger with the given file. * - * LogService cannot be used here as the log is being written into the current folder, LogService would change that behaviour. + * TODO OPUSVIER-4289 LogService cannot be used here as the log is being written into the current folder. */ private function initLogger($logfileName) { diff --git a/scripts/update_migration/MigrateSubjectsToCollections.php b/scripts/update_migration/MigrateSubjectsToCollections.php index c965187f36..f2be15e845 100755 --- a/scripts/update_migration/MigrateSubjectsToCollections.php +++ b/scripts/update_migration/MigrateSubjectsToCollections.php @@ -50,8 +50,7 @@ $logfileName = $argv[1]; /** - * LogService cannot be used here as the log is being written into the current folder, - * LogService would change that behaviour. + * TODO OPUSVIER-4289 LogService cannot be used here as the log is being written into the current folder. */ $logfile = @fopen($logfileName, 'a', false); $writer = new Zend_Log_Writer_Stream($logfile); From f8b4a67a6b968e087c3400d4cbf1288dd84f9fb4 Mon Sep 17 00:00:00 2001 From: Jens Schwidder Date: Wed, 16 Sep 2020 09:58:44 +0200 Subject: [PATCH 041/270] OPUSVIER-4289 Shortened comment --- scripts/update_migration/MigrateSubjectsToCollections.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_migration/MigrateSubjectsToCollections.php b/scripts/update_migration/MigrateSubjectsToCollections.php index f2be15e845..bf392261c5 100755 --- a/scripts/update_migration/MigrateSubjectsToCollections.php +++ b/scripts/update_migration/MigrateSubjectsToCollections.php @@ -50,7 +50,7 @@ $logfileName = $argv[1]; /** - * TODO OPUSVIER-4289 LogService cannot be used here as the log is being written into the current folder. + * TODO Not using LogService, because file is written to working directory (OPUSVIER-4289) */ $logfile = @fopen($logfileName, 'a', false); $writer = new Zend_Log_Writer_Stream($logfile); From 4813cb6967268163ac90d3c22e0ee47ba25c24d1 Mon Sep 17 00:00:00 2001 From: Jens Schwidder Date: Wed, 16 Sep 2020 09:59:49 +0200 Subject: [PATCH 042/270] OPUSVIER-4289 Shortened comment --- scripts/update_migration/MigrateSeriesCollections.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_migration/MigrateSeriesCollections.php b/scripts/update_migration/MigrateSeriesCollections.php index 39958aa190..2d7a2556e9 100755 --- a/scripts/update_migration/MigrateSeriesCollections.php +++ b/scripts/update_migration/MigrateSeriesCollections.php @@ -51,7 +51,7 @@ public function __construct($logfile) /** * Initialise the logger with the given file. * - * TODO OPUSVIER-4289 LogService cannot be used here as the log is being written into the current folder. + * TODO Not using LogService, because file is written to working directory (OPUSVIER-4289) */ private function initLogger($logfileName) { From b0e01e6b994f431078aced84950236f2190dbb71 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 16 Sep 2020 15:48:46 +0200 Subject: [PATCH 043/270] OPUSVIER-4344 Delete command --- composer.json | 2 +- library/Application/Console/App.php | 5 + .../Console/Document/DeleteCommand.php | 160 ++++++++++++ .../Console/Document/DeleteCommandTest.php | 235 ++++++++++++++++++ 4 files changed, 401 insertions(+), 1 deletion(-) create mode 100644 library/Application/Console/Document/DeleteCommand.php create mode 100644 tests/library/Application/Console/Document/DeleteCommandTest.php diff --git a/composer.json b/composer.json index bd19637bbe..ad8e845956 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "solarium/solarium": "3.8.*", "opus4-repo/opus4-common": "dev-master", "opus4-repo/framework": "dev-master", - "opus4-repo/search": "dev-master", + "opus4-repo/search": "dev-OPUSVIER-3544", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", diff --git a/library/Application/Console/App.php b/library/Application/Console/App.php index 959651a48b..9d1ac3d983 100644 --- a/library/Application/Console/App.php +++ b/library/Application/Console/App.php @@ -33,6 +33,7 @@ use Opus\Search\Console\IndexCommand; use Opus\Search\Console\RemoveCommand; +use Opus\Search\Console\ExtractCommand; use Symfony\Component\Console\Application; /** @@ -47,6 +48,10 @@ public function __construct() $this->add(new IndexCommand()); $this->add(new RemoveCommand()); + $this->add(new ExtractCommand()); + // $this->add(new Application_Console_Index_RepairCommand()); + // $this->add(new Application_Console_Index_CheckCommand()); + $this->add(new Application_Console_Document_DeleteCommand()); $this->setDefaultCommand('list'); } diff --git a/library/Application/Console/Document/DeleteCommand.php b/library/Application/Console/Document/DeleteCommand.php new file mode 100644 index 0000000000..0dfbed934f --- /dev/null +++ b/library/Application/Console/Document/DeleteCommand.php @@ -0,0 +1,160 @@ + + * @copyright Copyright (c) 2020, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ConfirmationQuestion; +use Opus\Console\BaseDocumentCommand; +use Opus\Console\Helper\ProgressBar; +use Opus\Search\Console\Helper\DocumentHelper; + +/** + * Class Application_Console_Document_Delete + * + * TODO use switch instead of singleDocument and removeAll (?) + */ +class Application_Console_Document_DeleteCommand extends BaseDocumentCommand +{ + + const OPTION_PERMANENT = 'permanent'; + + protected function configure() + { + parent::configure(); + + $help = <<document:delete command can be used to delete a single document or a +range of documents. It can set the status of documents to deleted or remove +the metadata and files of documents permanently (--permanent or -p). + +If no ID is provided, all documents will be deleted. You can use a dash (-) +as StartID or EndID, if you want to delete all documents up to or starting +from an ID. + +Examples: + will delete all documents + 50 will delete document 50 + 20 60 will delete documents 20 to 60 + 20 - will delete all documents starting from 20 + - 50 will delete all documents up to 50 + +Deleting a document will only set its ServerState to deleted. + +If a document is deleted permanently, it is removed from the database and +its files are deleted from the filesystem. This operation is not reversible. +EOT; + + $this->setName('document:delete') + ->setDescription('Deletes documents from database') + ->setHelp($help) + ->addOption( + self::OPTION_PERMANENT, + 'p', + null, + 'Permanently remove metadata and files or documents' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->processArguments($input); + + $startId = $this->startId; + $endId = $this->endId; + + $permanent = $input->getOption(self::OPTION_PERMANENT); + + $askHelper = $this->getHelper('question'); + + // TODO do not use IndexHelper to get document IDs (has nothing to do with index -> create new helper) + $helper = new DocumentHelper(); + + if ($this->isSingleDocument()) { + $docIds = [$startId]; + } else { + $docIds = $helper->getDocumentIds($startId, $endId); + } + + $docCount = count($docIds); + + if ($permanent) { + $permanentText = 'permanently (not reversible) '; + } else { + $permanentText = ''; + } + + if ($this->isSingleDocument()) { + $questionText = "Delete document $startId {$permanentText}[Y,n]? "; + } elseif ($this->isAllDocuments()) { + $questionText = "Delete all ($docCount) documents {$permanentText}[Y,n]? "; + } else { + $questionText = "Delete $docCount documents from $startId to $endId {$permanentText}[Y,n]? "; + } + + $question = new ConfirmationQuestion($questionText, true); + + if ($askHelper->ask($input, $output, $question)) { + $output->writeln('Deleting all documents ...'); + + if ($this->isSingleDocument()) { + $this->deleteDocument($startId, $permanent); + } else { + $progress = new ProgressBar($output, $docCount); + $this->deleteDocuments($docIds, $permanent, $progress); + } + } + else { + $output->writeln('Deletion cancelled'); + } + } + + protected function deleteDocuments($docIds, $permanent = false, $progress) + { + $progress->start(); + foreach ($docIds as $docId) { + $this->deleteDocument($docId, $permanent); + $progress->advance(); + } + $progress->finish(); + } + + protected function deleteDocument($docId, $permanent = false) + { + $doc = new Opus_Document($docId); + if ($permanent) { + $doc->deletePermanent(); + } else { + $doc->delete(); + } + } +} diff --git a/tests/library/Application/Console/Document/DeleteCommandTest.php b/tests/library/Application/Console/Document/DeleteCommandTest.php new file mode 100644 index 0000000000..e2c5b173fd --- /dev/null +++ b/tests/library/Application/Console/Document/DeleteCommandTest.php @@ -0,0 +1,235 @@ + + * @copyright Copyright (c) 2020, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Console\Application; + +class Application_Console_Document_DeleteCommandTest extends ControllerTestCase +{ + + protected $additionalResources = ['database']; + + /** + * @var int[] IDs of test documents + */ + protected $documents; + + public function setUp() + { + parent::setUp(); + + $documents = []; + + for ($i = 0; $i < 5; $i++) { + $doc = $this->createTestDocument(); + $docId = $doc->store(); + $documents[] = $docId; + } + + $this->documents = $documents; + } + + public function testDeleteSingleDocument() + { + $app = new Application(); + + $command = new Application_Console_Document_DeleteCommand(); + $command->setApplication($app); + + $tester = new CommandTester($command); + + $docId = $this->documents[2]; + $doc = new Opus_Document($docId); + + $this->assertEquals('unpublished', $doc->getServerState()); + + $tester->execute([ + '--no-interaction' => true, + $command::ARGUMENT_START_ID => $docId + ], [ + 'interactive' => false + ]); + + $doc = new Opus_Document($this->documents[0]); + $this->assertEquals('unpublished', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[1]); + $this->assertEquals('unpublished', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[2]); + $this->assertEquals('deleted', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[3]); + $this->assertEquals('unpublished', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[4]); + $this->assertEquals('unpublished', $doc->getServerState()); + } + + /** + * TODO implement this once test database can be rebuild automatically (smaller test set, empty like framework) + */ + public function testDeleteAllDocuments() + { + $this->markTestIncomplete('TODO application tests currently require test documents in database'); + } + + public function testDeleteDocumentRange() + { + $app = new Application(); + + $command = new Application_Console_Document_DeleteCommand(); + $command->setApplication($app); + + $tester = new CommandTester($command); + + $tester->execute([ + '--no-interaction' => true, + $command::ARGUMENT_START_ID => $this->documents[1], + $command::ARGUMENT_END_ID => $this->documents[3] + ], [ + 'interactive' => false + ]); + + $doc = new Opus_Document($this->documents[0]); + $this->assertEquals('unpublished', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[1]); + $this->assertEquals('deleted', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[2]); + $this->assertEquals('deleted', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[3]); + $this->assertEquals('deleted', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[4]); + $this->assertEquals('unpublished', $doc->getServerState()); + } + + public function testDeleteSingleDocumentPermanently() + { + $app = new Application(); + + $command = new Application_Console_Document_DeleteCommand(); + $command->setApplication($app); + + $tester = new CommandTester($command); + + $docId = $this->documents[2]; + $doc = new Opus_Document($docId); + + $this->assertEquals('unpublished', $doc->getServerState()); + + $tester->execute([ + '--no-interaction' => true, + '--permanent' => true, + $command::ARGUMENT_START_ID => $docId + ], [ + 'interactive' => false + ]); + + $doc = new Opus_Document($this->documents[0]); + $this->assertEquals('unpublished', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[1]); + $this->assertEquals('unpublished', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[3]); + $this->assertEquals('unpublished', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[4]); + $this->assertEquals('unpublished', $doc->getServerState()); + + $this->setExpectedException('Opus_Model_NotFoundException'); + new Opus_Document($this->documents[2]); + } + + public function testDeleteAllDocumentsPermanently() + { + $this->markTestIncomplete('TODO application tests currently require test documents in database'); + } + + public function testDeleteDocumentRangePermanently() + { + $app = new Application(); + + $command = new Application_Console_Document_DeleteCommand(); + $command->setApplication($app); + + $tester = new CommandTester($command); + + $tester->execute([ + '--no-interaction' => true, + '--permanent' => true, + $command::ARGUMENT_START_ID => $this->documents[1], + $command::ARGUMENT_END_ID => $this->documents[3] + ], [ + 'interactive' => false + ]); + + $doc = new Opus_Document($this->documents[0]); + $this->assertEquals('unpublished', $doc->getServerState()); + + $doc = new Opus_Document($this->documents[4]); + $this->assertEquals('unpublished', $doc->getServerState()); + + try { + new Opus_Document($this->documents[1]); + $this->fail('Document should have been deleted permanently.'); + } catch (Opus_Model_NotFoundException $e) { + } + + try { + new Opus_Document($this->documents[2]); + $this->fail('Document should have been deleted permanently.'); + } catch (Opus_Model_NotFoundException $e) { + } + + try { + new Opus_Document($this->documents[3]); + $this->fail('Document should have been deleted permanently.'); + } catch (Opus_Model_NotFoundException $e) { + } + } + + public function testCancelDeletion() + { + $this->markTestIncomplete('Version of Symfony Console does not support setInputs yet.'); + } + + public function testDeleteWithoutInteraction() + { + $this->markTestIncomplete('Currently all tests are without interaction.'); + } +} From 86df68d3f6520c03884eb52f4b9b1b41cad24348 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 16 Sep 2020 15:49:31 +0200 Subject: [PATCH 044/270] OPUSVIER-4345 Set old verbosity for rebuilding index. --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index 34f6af2b00..2c799ab5f9 100644 --- a/build.xml +++ b/build.xml @@ -262,7 +262,7 @@ - + From 283b9c0b6ef1e1804c67327aa71f047f7f439bdb Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 16 Sep 2020 15:55:10 +0200 Subject: [PATCH 045/270] OPUSVIER-4344 Cleanup console output --- library/Application/Console/Document/DeleteCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/Application/Console/Document/DeleteCommand.php b/library/Application/Console/Document/DeleteCommand.php index 0dfbed934f..3e892159cc 100644 --- a/library/Application/Console/Document/DeleteCommand.php +++ b/library/Application/Console/Document/DeleteCommand.php @@ -124,10 +124,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $question = new ConfirmationQuestion($questionText, true); if ($askHelper->ask($input, $output, $question)) { - $output->writeln('Deleting all documents ...'); - if ($this->isSingleDocument()) { $this->deleteDocument($startId, $permanent); + $output->writeln("Document $startId has been deleted"); } else { $progress = new ProgressBar($output, $docCount); $this->deleteDocuments($docIds, $permanent, $progress); From e41dfbbdfabbb2cb086e9c084d26447b62ea3d9b Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 16 Sep 2020 17:03:36 +0200 Subject: [PATCH 046/270] OPUSVIER-4344 Fixed coding style --- library/Application/Console/Document/DeleteCommand.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/Application/Console/Document/DeleteCommand.php b/library/Application/Console/Document/DeleteCommand.php index 3e892159cc..c8bd6dd568 100644 --- a/library/Application/Console/Document/DeleteCommand.php +++ b/library/Application/Console/Document/DeleteCommand.php @@ -129,15 +129,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln("Document $startId has been deleted"); } else { $progress = new ProgressBar($output, $docCount); - $this->deleteDocuments($docIds, $permanent, $progress); + $this->deleteDocuments($progress, $docIds, $permanent); } - } - else { + } else { $output->writeln('Deletion cancelled'); } } - protected function deleteDocuments($docIds, $permanent = false, $progress) + protected function deleteDocuments($progress, $docIds, $permanent = false) { $progress->start(); foreach ($docIds as $docId) { From 7deefcae4484ba3db0c98ee828fa54f4cc77b4f1 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 17 Sep 2020 09:12:25 +0200 Subject: [PATCH 047/270] OPUSVIER-4356 Delete command using ProgressMatrix --- library/Application/Console/Document/DeleteCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Application/Console/Document/DeleteCommand.php b/library/Application/Console/Document/DeleteCommand.php index c8bd6dd568..7f030a3ebd 100644 --- a/library/Application/Console/Document/DeleteCommand.php +++ b/library/Application/Console/Document/DeleteCommand.php @@ -35,7 +35,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Opus\Console\BaseDocumentCommand; -use Opus\Console\Helper\ProgressBar; +use Opus\Console\Helper\ProgressMatrix; use Opus\Search\Console\Helper\DocumentHelper; /** @@ -128,7 +128,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->deleteDocument($startId, $permanent); $output->writeln("Document $startId has been deleted"); } else { - $progress = new ProgressBar($output, $docCount); + $progress = new ProgressMatrix($output, $docCount); $this->deleteDocuments($progress, $docIds, $permanent); } } else { From a12d41c903694c21c10529e32a945b375bd15c0a Mon Sep 17 00:00:00 2001 From: kaustabhbarman Date: Thu, 17 Sep 2020 14:26:44 +0200 Subject: [PATCH 048/270] OPUSVIER-4289 Disabling translation logging by default --- application/configs/application.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/configs/application.ini b/application/configs/application.ini index d057eb714a..6641dac7b1 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -236,11 +236,12 @@ admin.documents.linkToAuthorSearch = 0 ; LOGGING CONFIGURATION (OPTIONAL) ; Use names of Zend_Log constants (e.g. DEBUG, INFO, WARN, ERR) +; Set translation level to DEBUG to enable translation logging by default log.level = WARN log.format = '%timestamp% %priorityName% (ID %runId%): %message%' logging.log.translation.format = '%timestamp% (ID %runId%): %message%' logging.log.translation.file = 'translation.xml' -logging.log.translation.level = DEBUG ; WARN for warning conditions +logging.log.translation.level = INFO ; LOGGING RELATED SETTINGS ; if set to true all xml that is generated while indexing is prepared for logging From 222cd5ad4fead28cda334abb37a8231b79b3b693 Mon Sep 17 00:00:00 2001 From: Jens Schwidder Date: Fri, 18 Sep 2020 07:54:51 +0200 Subject: [PATCH 049/270] OPUSVIER-4299 Disable translation log by default Also changed default level to ERR. This will allow to enable more output in multiple steps up to DEBUG. --- application/configs/application.ini | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/configs/application.ini b/application/configs/application.ini index 6641dac7b1..826e3c028e 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -236,12 +236,13 @@ admin.documents.linkToAuthorSearch = 0 ; LOGGING CONFIGURATION (OPTIONAL) ; Use names of Zend_Log constants (e.g. DEBUG, INFO, WARN, ERR) -; Set translation level to DEBUG to enable translation logging by default log.level = WARN log.format = '%timestamp% %priorityName% (ID %runId%): %message%' + +; Set translation.level to DEBUG to log failed translations ("Unable to translate") +logging.log.translation.level = ERR logging.log.translation.format = '%timestamp% (ID %runId%): %message%' logging.log.translation.file = 'translation.xml' -logging.log.translation.level = INFO ; LOGGING RELATED SETTINGS ; if set to true all xml that is generated while indexing is prepared for logging From e97f3d70d71788d9a697afc330368ff90f5c12f3 Mon Sep 17 00:00:00 2001 From: Jens Schwidder Date: Fri, 18 Sep 2020 08:42:55 +0200 Subject: [PATCH 050/270] OPUSVIER-4289 Fixed bug setting default logger --- tests/support/SimpleBootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/support/SimpleBootstrap.php b/tests/support/SimpleBootstrap.php index 6290aef10e..b21f562482 100644 --- a/tests/support/SimpleBootstrap.php +++ b/tests/support/SimpleBootstrap.php @@ -78,7 +78,7 @@ protected function _initLogging() $logger = $logService->createLog(LogService::DEFAULT_LOG, null, null, $logFilename); $logLevel = $logService->getDefaultPriority(); - Zend_Registry::set('LOG_LEVEL', $logLevel); + Zend_Registry::set('Zend_Log', $logger); Zend_Registry::set('LOG_LEVEL', $logLevel); $logger->debug('Logging initialized'); From 9be17e8324d413f3021de98568217630513414a6 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 18 Sep 2020 09:14:43 +0200 Subject: [PATCH 051/270] OPUSVIER-4358 Added more debug output. --- .../Application/Update/SetStatusOfExistingDoiTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php index d3a27c0212..a0f35a224d 100644 --- a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php +++ b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php @@ -57,7 +57,12 @@ public function testRunDoesNotModifyServerDateModified() $modified = $doc->getServerDateModified(); + $doc = new Opus_Document($docId); + $modified2 = $doc->getServerDateModified(); + + $time1 = Opus_Date::getNow(); sleep(2); + $time2 = Opus_Date::getNow(); $update = new Application_Update_SetStatusOfExistingDoi(); $update->setLogger(new MockLogger()); @@ -67,8 +72,10 @@ public function testRunDoesNotModifyServerDateModified() $doc = new Opus_Document($docId); - $message = "{$doc->getServerDateModified()}" . PHP_EOL; - $message .= "$modified"; + $message = "{$doc->getServerDateModified()} (after)" . PHP_EOL; + $message .= "$modified (before)" . PHP_EOL; + $message .= "$modified2 (before - from stored doc)" . PHP_EOL; + $message .= "$time1 - sleep(2) - $time2"; $this->assertEquals(0, $doc->getServerDateModified()->compare($modified), $message); $this->assertEquals('registered', $doc->getIdentifierDoi(0)->getStatus()); From ba8548b94af014af962ea0717817897514993ed8 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 18 Sep 2020 09:25:36 +0200 Subject: [PATCH 052/270] OPUSVIER-4358 Fixed SimpleBootstrap (again) --- tests/support/SimpleBootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/support/SimpleBootstrap.php b/tests/support/SimpleBootstrap.php index 6290aef10e..b21f562482 100644 --- a/tests/support/SimpleBootstrap.php +++ b/tests/support/SimpleBootstrap.php @@ -78,7 +78,7 @@ protected function _initLogging() $logger = $logService->createLog(LogService::DEFAULT_LOG, null, null, $logFilename); $logLevel = $logService->getDefaultPriority(); - Zend_Registry::set('LOG_LEVEL', $logLevel); + Zend_Registry::set('Zend_Log', $logger); Zend_Registry::set('LOG_LEVEL', $logLevel); $logger->debug('Logging initialized'); From 2daaaa2fc038ef00cf2651b828e25c59655302e6 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 18 Sep 2020 09:36:02 +0200 Subject: [PATCH 053/270] OPUSVIER-4358 Only run library for faster results. --- .github/workflows/php.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 30fc822c66..1f21aff3b5 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -35,16 +35,4 @@ jobs: run: php composer.phar cs-check - name: Test-library - run: php composer.phar test -- --testsuite library - - - name: Test-modules - run: php composer.phar test -- --testsuite modules - - - name: Test-admin - run: php composer.phar test -- --testsuite admin - - - name: Test-security - run: php composer.phar test -- --testsuite security - - - name: Test-scripts - run: php composer.phar test -- --testsuite scripts + run: php composer.phar test -- --testsuite library \ No newline at end of file From f04653027edf67fbe9c8284cbce2697b60734178 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 18 Sep 2020 09:48:27 +0200 Subject: [PATCH 054/270] OPUSVIER-4358 Experimenting with problem --- .../Application/Update/SetStatusOfExistingDoiTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php index a0f35a224d..69b9b0b64b 100644 --- a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php +++ b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php @@ -55,6 +55,8 @@ public function testRunDoesNotModifyServerDateModified() $doc->addIdentifier($doi); $docId = $doc->store(); + sleep(2); + $modified = $doc->getServerDateModified(); $doc = new Opus_Document($docId); @@ -64,12 +66,16 @@ public function testRunDoesNotModifyServerDateModified() sleep(2); $time2 = Opus_Date::getNow(); + // TODO check value in database + $update = new Application_Update_SetStatusOfExistingDoi(); $update->setLogger(new MockLogger()); $update->setQuietMode(true); $update->run(); + // TODO check value in database again + $doc = new Opus_Document($docId); $message = "{$doc->getServerDateModified()} (after)" . PHP_EOL; From 3b7445928950816dda876c997abbaa1608a40697 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 18 Sep 2020 10:03:39 +0200 Subject: [PATCH 055/270] OPUSVIER-4358 Even more debug output. --- .../Update/SetStatusOfExistingDoiTest.php | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php index 69b9b0b64b..81cf98e62b 100644 --- a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php +++ b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php @@ -59,14 +59,19 @@ public function testRunDoesNotModifyServerDateModified() $modified = $doc->getServerDateModified(); + $debug = "$modified (before)" . PHP_EOL; + $doc = new Opus_Document($docId); $modified2 = $doc->getServerDateModified(); + $debug .= "$modified2 (before - from new object)" . PHP_EOL; + $time1 = Opus_Date::getNow(); sleep(2); $time2 = Opus_Date::getNow(); - // TODO check value in database + $debug .= "$time1 - sleep(2) - $time2" . PHP_EOL; + $debug .= $this->getServerDateModifiedFromDatabase($docId) . ' (before - from database)' . PHP_EOL; $update = new Application_Update_SetStatusOfExistingDoi(); $update->setLogger(new MockLogger()); @@ -74,16 +79,24 @@ public function testRunDoesNotModifyServerDateModified() $update->run(); - // TODO check value in database again + $debug .= $this->getServerDateModifiedFromDatabase($docId) . ' (after - from database)' . PHP_EOL; $doc = new Opus_Document($docId); - $message = "{$doc->getServerDateModified()} (after)" . PHP_EOL; - $message .= "$modified (before)" . PHP_EOL; - $message .= "$modified2 (before - from stored doc)" . PHP_EOL; - $message .= "$time1 - sleep(2) - $time2"; + $debug .= "{$doc->getServerDateModified()} (after - from new object)" . PHP_EOL; - $this->assertEquals(0, $doc->getServerDateModified()->compare($modified), $message); + $this->assertEquals(0, $doc->getServerDateModified()->compare($modified), $debug); $this->assertEquals('registered', $doc->getIdentifierDoi(0)->getStatus()); } + + protected function getServerDateModifiedFromDatabase($docId) + { + $table = Opus_Db_TableGateway::getInstance('Opus_Db_Documents'); + $select = $table->select() + ->from($table, ['server_date_modified']) + ->where("id = $docId"); + $result = $table->getAdapter()->fetchCol($select); + + return $result[0]; + } } From dca2f66b445f42e34fa474eee9e70871b0ea21a8 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 18 Sep 2020 10:12:17 +0200 Subject: [PATCH 056/270] OPUSVIER-4358 Fixed coding style --- .../library/Application/Update/SetStatusOfExistingDoiTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php index 81cf98e62b..1a566dd4a4 100644 --- a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php +++ b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php @@ -71,7 +71,7 @@ public function testRunDoesNotModifyServerDateModified() $time2 = Opus_Date::getNow(); $debug .= "$time1 - sleep(2) - $time2" . PHP_EOL; - $debug .= $this->getServerDateModifiedFromDatabase($docId) . ' (before - from database)' . PHP_EOL; + $debug .= $this->getServerDateModifiedFromDatabase($docId) . ' (before - from database)' . PHP_EOL; $update = new Application_Update_SetStatusOfExistingDoi(); $update->setLogger(new MockLogger()); @@ -79,7 +79,7 @@ public function testRunDoesNotModifyServerDateModified() $update->run(); - $debug .= $this->getServerDateModifiedFromDatabase($docId) . ' (after - from database)' . PHP_EOL; + $debug .= $this->getServerDateModifiedFromDatabase($docId) . ' (after - from database)' . PHP_EOL; $doc = new Opus_Document($docId); From 784f2e95732c9dbea77ab0896f2772aebcadc17d Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 28 Sep 2020 10:33:10 +0200 Subject: [PATCH 057/270] OPUSVIER-4370 Patch for handling options. --- modules/publish/views/helpers/Group.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/publish/views/helpers/Group.php b/modules/publish/views/helpers/Group.php index aac195fc99..57e36ef04e 100644 --- a/modules/publish/views/helpers/Group.php +++ b/modules/publish/views/helpers/Group.php @@ -112,7 +112,12 @@ private function _renderGroup($group, $options = null, $name = null) break; case "Zend_Form_Element_Select": - $fieldset .= $this->renderHtmlSelect($field, $options); + if (is_array($options)) { + $selectOptions = $options; + } else { + $selectOptions = null; + } + $fieldset .= $this->renderHtmlSelect($field, $selectOptions); break; case 'Zend_Form_Element_Checkbox': From 529d95861dc7585276dad3779d3b9aad94b7e47f Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 29 Sep 2020 13:22:03 +0200 Subject: [PATCH 058/270] OPUSVIER-4073 Fix subfield handling for persons. --- modules/publish/models/FormElement.php | 70 +++++++++++++++++-------- modules/publish/views/helpers/Group.php | 6 +-- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/modules/publish/models/FormElement.php b/modules/publish/models/FormElement.php index e4f353555a..a5be39554e 100644 --- a/modules/publish/models/FormElement.php +++ b/modules/publish/models/FormElement.php @@ -165,30 +165,40 @@ private function implicitFields($workflow) { switch ($workflow) { case 'Person': + $fields = []; + $name = $this->_elementName . self::FIRST; + //creates two subfields for first and last name - $first = new Publish_Model_FormElement( - $this->form, - $this->_elementName . self::FIRST, - false, - 'text', - 'Person' - ); - $first->isSubField = true; - $first->setDefaultValue($this->_default, self::FIRST); - $elementFirst = $first->transform(); + if (! $this->isElementPresent($name)) { + $first = new Publish_Model_FormElement( + $this->form, + $name, + false, + 'text', + 'Person' + ); + $first->isSubField = true; + $first->setDefaultValue($this->_default, self::FIRST); + $elementFirst = $first->transform(); + $fields[] = $elementFirst; + } - $last = new Publish_Model_FormElement( - $this->form, - $this->_elementName . self::LAST, - $this->_required, - 'text', - 'Person' - ); - $last->isSubField = false; - $last->setDefaultValue($this->_default, self::LAST); - $elementLast = $last->transform(); + $name = $this->_elementName . self::LAST; + if (! $this->isElementPresent($name)) { + $last = new Publish_Model_FormElement( + $this->form, + $name, + $this->_required, + 'text', + 'Person' + ); + $last->isSubField = false; + $last->setDefaultValue($this->_default, self::LAST); + $elementLast = $last->transform(); + $fields[] = $elementLast; + } - return [$elementFirst, $elementLast]; + return $fields; break; case 'Series': @@ -701,6 +711,11 @@ public function getSubFormElements() return $this->_subFormElements; } + /** + * If elements are already present do not add again. + * + * @param $subFormElements + */ public function addSubFormElements($subFormElements) { $this->_subFormElements = array_merge($subFormElements, $this->_subFormElements); @@ -710,4 +725,17 @@ public function addSubFormElement($subField) { $this->_subFormElements[] = $subField; } + + protected function isElementPresent($name) + { + if (is_array($this->_subFormElements)) { + foreach ($this->_subFormElements as $element) { + if ($element->getLabel() === $name) { + return true; + } + } + } + + return false; + } } diff --git a/modules/publish/views/helpers/Group.php b/modules/publish/views/helpers/Group.php index 57e36ef04e..af4b1c531e 100644 --- a/modules/publish/views/helpers/Group.php +++ b/modules/publish/views/helpers/Group.php @@ -49,7 +49,7 @@ public function group($value, $options = null, $name = null) if ($name == null && $value == null) { $errorMessage = $this->view->translate('template_error_unknown_field'); // TODO move to CSS - return "
" . $errorMessage . "


"; + return "
$errorMessage


"; } return $this->_renderGroup($value, $options, $name); } @@ -70,7 +70,7 @@ private function _renderGroup($group, $options = null, $name = null) $fieldset .= ""; } - $fieldset .= "
"; + $fieldset .= "
"; $fieldset .= $this->getLegendFor($group['Name']); $fieldset .= $this->getFieldsetHint($group['Name']); @@ -82,7 +82,7 @@ private function _renderGroup($group, $options = null, $name = null) // besonderer Mechanismus erforderlich für Collection Roles (CRs sind erkennbar, weil nur bei ihnen // $group['Counter'] auf null gesetzt wurde) // dort kann jede Gruppe aus unterschiedlich vielen Select-Boxen aufgebaut sein - // daher greift der Mechanimus der Auswertung von $group['Counter'] hier nicht + // daher greift der Mechanismus der Auswertung von $group['Counter'] hier nicht if (is_null($group['Counter']) && $index > 0 && $field['label'] !== 'choose_collection_subcollection' && $field['label'] !== 'endOfCollectionTree') { $groupCount++; From a1f5639ff666c613c94d2a16380d287d355ebe1e Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 29 Sep 2020 17:38:49 +0200 Subject: [PATCH 059/270] OPUSVIER-4161 Fixed warning. Test cleanup. Some TODO comments. --- modules/admin/forms/EnrichmentKey.php | 4 ++-- modules/admin/models/EnrichmentKeys.php | 1 + tests/modules/admin/forms/EnrichmentKeyTest.php | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/admin/forms/EnrichmentKey.php b/modules/admin/forms/EnrichmentKey.php index 276297b5cd..6c62b72753 100644 --- a/modules/admin/forms/EnrichmentKey.php +++ b/modules/admin/forms/EnrichmentKey.php @@ -247,10 +247,10 @@ private function initEnrichmentType($enrichmentTypeName) return null; } + // TODO better way? - allow registering namespaces/types like in Zend for form elements? $enrichmentTypeName = 'Opus_Enrichment_' . $enrichmentTypeName; try { - // TODO OPUSVIER-4161 is this check necessary? - if (@class_exists($enrichmentTypeName)) { + if (class_exists($enrichmentTypeName, false)) { $enrichmentType = new $enrichmentTypeName(); return $enrichmentType; } diff --git a/modules/admin/models/EnrichmentKeys.php b/modules/admin/models/EnrichmentKeys.php index 369cea2692..036b1a536f 100644 --- a/modules/admin/models/EnrichmentKeys.php +++ b/modules/admin/models/EnrichmentKeys.php @@ -115,6 +115,7 @@ public function setProtectedEnrichmentKeys($keys) * @param null $oldName Optionally old name if it has been changed * * TODO create keys if they don't exist + * TODO what happens if renameKey into keys that already exist? */ public function createTranslations($name, $oldName = null) { diff --git a/tests/modules/admin/forms/EnrichmentKeyTest.php b/tests/modules/admin/forms/EnrichmentKeyTest.php index 2efe55e73e..af40d5bbcc 100644 --- a/tests/modules/admin/forms/EnrichmentKeyTest.php +++ b/tests/modules/admin/forms/EnrichmentKeyTest.php @@ -421,6 +421,7 @@ public function testChangeTranslationsKeysWithNameChange() $oldKey = 'EnrichmentTestKey'; $database = new Opus_Translate_Dao(); + $database->removeAll(); $database->setTranslation($oldKey, [ 'en' => 'English', 'de' => 'Deutsch' @@ -458,6 +459,7 @@ public function testEmptyTranslationRemovesKey() $key = 'EnrichmentTestKey'; $database = new Opus_Translate_Dao(); + $database->removeAll(); $database->setTranslation($key, [ 'en' => 'English', 'de' => 'Deutsch' From 58c1490fa3f2d9f8b1662c1e4ca9dcf91ce63f3e Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 7 Oct 2020 10:14:03 +0200 Subject: [PATCH 060/270] OPUSVIER-4360 Added default timeouts to config. --- application/configs/config.ini.template | 2 ++ application/configs/console.ini.template | 2 ++ 2 files changed, 4 insertions(+) diff --git a/application/configs/config.ini.template b/application/configs/config.ini.template index 54a96b78b5..c52858a6d8 100644 --- a/application/configs/config.ini.template +++ b/application/configs/config.ini.template @@ -56,12 +56,14 @@ db.params.dbname = @db.name@ searchengine.solr.default.service.default.endpoint.localhost.host = @searchengine.index.host@ searchengine.solr.default.service.default.endpoint.localhost.port = @searchengine.index.port@ searchengine.solr.default.service.default.endpoint.localhost.path = @searchengine.index.app@ +searchengine.solr.default.service.default.endpoint.localhost.timeout = 10 ; The text extraction can run on a different solr server as the metadata indexer ; does. You can also use the same solr server, then you would have to enter ; the same connection as above. searchengine.solr.default.service.extract.endpoint.localhost.host = @searchengine.extract.host@ searchengine.solr.default.service.extract.endpoint.localhost.port = @searchengine.extract.port@ searchengine.solr.default.service.extract.endpoint.localhost.path = @searchengine.extract.app@ +searchengine.solr.default.service.extract.endpoint.localhost.timeout = 10 ; Turn on to display document titles of search results in user interface language if possible search.result.display.preferUserInterfaceLanguage = 0 diff --git a/application/configs/console.ini.template b/application/configs/console.ini.template index da7f4a9825..398b82355b 100644 --- a/application/configs/console.ini.template +++ b/application/configs/console.ini.template @@ -37,6 +37,8 @@ opusdb.params.admin.name = @db.admin.name@ opusdb.params.admin.password = @db.admin.password@ +searchengine.solr.default.service.default.endpoint.localhost.timeout = 0 +searchengine.solr.default.service.extract.endpoint.localhost.timeout = 0 [staging : production] [testing : production] From 8e05495653326484edec51ec9b907c284ec3276a Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 7 Oct 2020 17:42:26 +0200 Subject: [PATCH 061/270] OPUSVIER-4393 Added extract file command. --- library/Application/Console/App.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/Application/Console/App.php b/library/Application/Console/App.php index 9d1ac3d983..d22e975ff6 100644 --- a/library/Application/Console/App.php +++ b/library/Application/Console/App.php @@ -34,6 +34,7 @@ use Opus\Search\Console\IndexCommand; use Opus\Search\Console\RemoveCommand; use Opus\Search\Console\ExtractCommand; +use Opus\Search\Console\ExtractFileCommand; use Symfony\Component\Console\Application; /** @@ -49,6 +50,7 @@ public function __construct() $this->add(new IndexCommand()); $this->add(new RemoveCommand()); $this->add(new ExtractCommand()); + $this->add(new ExtractFileCommand()); // $this->add(new Application_Console_Index_RepairCommand()); // $this->add(new Application_Console_Index_CheckCommand()); $this->add(new Application_Console_Document_DeleteCommand()); From af958b8b1b1941cb2fd2d354ecad937f7e29cba2 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 8 Oct 2020 08:25:07 +0200 Subject: [PATCH 062/270] OPUSVIER-4338 Removed old fulltext script. --- scripts/SolrFulltextCacheBuilder.php | 272 --------------------------- 1 file changed, 272 deletions(-) delete mode 100755 scripts/SolrFulltextCacheBuilder.php diff --git a/scripts/SolrFulltextCacheBuilder.php b/scripts/SolrFulltextCacheBuilder.php deleted file mode 100755 index 5f677c9317..0000000000 --- a/scripts/SolrFulltextCacheBuilder.php +++ /dev/null @@ -1,272 +0,0 @@ -#!/usr/bin/env php5 - - * @author Jens Schwidder - * @copyright Copyright (c) 2010-2015, OPUS 4 development team - * @license http://www.gnu.org/licenses/gpl.html General Public License - */ - -// Bootstrapping -require_once dirname(__FILE__) . '/common/bootstrap.php'; - -/** - * Populates cache for extracted full texts for all or a range of documents. - */ -class SolrFulltextCacheBuilder -{ - - /** - * Start of document ID range for indexing (first command line parameter). - * @var int - */ - private $_start = null; - - /** - * End of document ID range for indexing (second command line parameter). - * @var int - */ - private $_end = null; - - /** - * Temporary variable for storing sync mode. - * @var bool - */ - private $_syncMode = true; - - /** - * Flag for showing help information (command line parameter '--help' or '-h') - * @var bool - */ - private $_showHelp = false; - - /** - * Prints a help message to the console. - */ - private function printHelpMessage($argv) - { - $this->write( - PHP_EOL . - "This program can be used to build up the full text cache for OPUS 4 documents. This is useful for testing - full text extraction and speeding up subsequent indexing runs." . - PHP_EOL . - PHP_EOL . - "Usage: " . $argv[0] . " [starting with ID] [ending with ID]" . PHP_EOL . - PHP_EOL . - "[starting with ID] If system aborted indexing at some ID, you can restart this command by supplying" . - " this parameter." . PHP_EOL . - "It should be the ID where the program stopped before." . PHP_EOL . - "Default start value is 0." . PHP_EOL . - PHP_EOL . - "[ending with ID] You can also supply a second ID where the indexer should stop indexing." . PHP_EOL . - "If you omit this parameter or set it to -1, the indexer will index all remaining documents." . PHP_EOL . - PHP_EOL . - "In case both parameters are not specified the currently used index is deleted before insertion of new" . - " documents begins." . PHP_EOL . - PHP_EOL - ); - } - - /** - * Evaluates command line arguments. - */ - private function evaluateArguments($argc, $argv) - { - if (true === in_array('--help', $argv) || true === in_array('-h', $argv)) { - $this->_showHelp = true; - } else { - if ($argc >= 2) { - $this->_start = $argv[1]; - } - if ($argc >= 3) { - $this->_end = $argv[2]; - } - } - } - - /** - * Starts an Opus console. - */ - public function run($argc, $argv) - { - $this->evaluateArguments($argc, $argv); - - if ($this->_showHelp) { - $this->printHelpMessage($argv); - return; - } - - try { - $runtime = $this->extract($this->_start, $this->_end); - echo PHP_EOL . "Operation completed successfully in $runtime seconds." . PHP_EOL; - } catch (Opus\Search\Exception $e) { - echo PHP_EOL . "An error occurred while indexing."; - echo PHP_EOL . "Error Message: " . $e->getMessage(); - if (! is_null($e->getPrevious())) { - echo PHP_EOL . "Caused By: " . $e->getPrevious()->getMessage(); - } - echo PHP_EOL . "Stack Trace:" . PHP_EOL . $e->getTraceAsString(); - echo PHP_EOL . PHP_EOL; - } - } - - private function extract($startId, $endId) - { - $this->forceSyncMode(); - - $docIds = $this->getDocumentIds($startId, $endId); - - $extractor = Opus\Search\Service::selectIndexingService('indexBuilder'); - - - echo date('Y-m-d H:i:s') . " Start indexing of " . count($docIds) . " documents.\n"; - $numOfDocs = 0; - $runtime = microtime(true); - - // measure time for each document - - foreach ($docIds as $docId) { - $timeStart = microtime(true); - - $doc = new Opus_Document($docId); - - foreach ($doc->getFile() as $file) { - try { - $extractor->extractDocumentFile($file, $doc); - } catch (Opus\Search\Exception $e) { - echo date('Y-m-d H:i:s') . " ERROR: Failed extracting document $docId.\n"; - echo date('Y-m-d H:i:s') . " {$e->getMessage()}\n"; - } catch (Opus_Storage_Exception $e) { - echo date('Y-m-d H:i:s') . " ERROR: Failed extracting unavailable file on document $docId.\n"; - echo date('Y-m-d H:i:s') . " {$e->getMessage()}\n"; - } - } - - $timeDelta = microtime(true) - $timeStart; - if ($timeDelta > 30) { - echo date('Y-m-d H:i:s') . " WARNING: Extracting document $docId took $timeDelta seconds.\n"; - } - - $numOfDocs++; - - if ($numOfDocs % 10 == 0) { - $this->outputProgress($runtime, $numOfDocs); - } - } - - $runtime = microtime(true) - $runtime; - echo PHP_EOL . date('Y-m-d H:i:s') . ' Finished extracting.' . PHP_EOL; - // new search API doesn't track number of indexed files, but issues are kept written to log file - //echo "\n\nErrors appeared in " . $indexer->getErrorFileCount() . " of " . $indexer->getTotalFileCount() - // . " files. Details were written to opus-console.log"; - echo PHP_EOL . PHP_EOL . 'Details were written to opus-console.log'; - - $this->resetMode(); - - return $runtime; - } - - /** - * Returns IDs for published documents in range. - * - * @param $start Start of ID range - * @param $end End of ID range - * @return array Array of document IDs - */ - private function getDocumentIds($start, $end) - { - $finder = new Opus_DocumentFinder(); - - $finder->setServerState('published'); - - if (isset($start)) { - $finder->setIdRangeStart($start); - } - - if (isset($end)) { - $finder->setIdRangeEnd($end); - } - - return $finder->ids(); - } - - /** - * Output current processing status and performance. - * - * @param $runtime Time of start of processing - * @param $numOfDocs Number of processed documents - */ - private function outputProgress($runtime, $numOfDocs) - { - $memNow = round(memory_get_usage() / 1024 / 1024); - $memPeak = round(memory_get_peak_usage() / 1024 / 1024); - - $deltaTime = microtime(true) - $runtime; - $docPerSecond = round($deltaTime) == 0 ? 'inf' : round($numOfDocs / $deltaTime, 2); - $secondsPerDoc = round($deltaTime / $numOfDocs, 2); - - echo date('Y-m-d H:i:s') . " Stats after $numOfDocs documents -- memory $memNow MB," - . " peak memory $memPeak (MB), $docPerSecond docs/second, $secondsPerDoc seconds/doc" . PHP_EOL; - } - - private function addDocumentsToIndex($indexer, $docs) - { - } - - private function forceSyncMode() - { - $config = Zend_Registry::get('Zend_Config'); - if (isset($config->runjobs->asynchronous) && filter_var($config->runjobs->asynchronous, FILTER_VALIDATE_BOOLEAN)) { - $this->_syncMode = false; - $config->runjobs->asynchronous = ''; // false - Zend_Registry::set('Zend_Config', $config); - } - } - - private function resetMode() - { - if (! $this->_syncMode) { - $config = Zend_Registry::get('Zend_Config'); - $config->runjobs->asynchronous = '1'; // true - Zend_Registry::set('Zend_Config', $config); - } - } - - private function write($str) - { - echo $str; - } -} - -/** - * Main code of index builder script. - */ -global $argc, $argv; - -$builder = new SolrFulltextCacheBuilder(); -$builder->run($argc, $argv); From b3adc6f8ec22596048b76160234aba225d03f621 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 8 Oct 2020 12:38:58 +0200 Subject: [PATCH 063/270] OPUSVIER-4289 Fixed name of translation.log (use default). --- application/configs/application.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/application/configs/application.ini b/application/configs/application.ini index 826e3c028e..974bf9d808 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -242,7 +242,6 @@ log.format = '%timestamp% %priorityName% (ID %runId%): %message%' ; Set translation.level to DEBUG to log failed translations ("Unable to translate") logging.log.translation.level = ERR logging.log.translation.format = '%timestamp% (ID %runId%): %message%' -logging.log.translation.file = 'translation.xml' ; LOGGING RELATED SETTINGS ; if set to true all xml that is generated while indexing is prepared for logging From ca480bac2a9fd7e1b4710a7a602e8de3b76cccd5 Mon Sep 17 00:00:00 2001 From: Jens Schwidder Date: Mon, 12 Oct 2020 17:43:26 +0200 Subject: [PATCH 064/270] OPUSVIER-3554 Update search dependency --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ad8e845956..bd19637bbe 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "solarium/solarium": "3.8.*", "opus4-repo/opus4-common": "dev-master", "opus4-repo/framework": "dev-master", - "opus4-repo/search": "dev-OPUSVIER-3544", + "opus4-repo/search": "dev-master", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", From 7376135b11595c1a856529620525b7338e22a3cb Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 12 Oct 2020 18:59:57 +0200 Subject: [PATCH 065/270] OPUSVIER-4395 Depend on issue branch --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bd19637bbe..a41ecf5c7b 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "jpgraph/jpgraph": "dev-master", "solarium/solarium": "3.8.*", "opus4-repo/opus4-common": "dev-master", - "opus4-repo/framework": "dev-master", + "opus4-repo/framework": "dev-OPUSVIER-4395", "opus4-repo/search": "dev-master", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", From 0087fa5c83b7781948ee0f3879a77dc0544b3aa9 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 12 Oct 2020 19:08:11 +0200 Subject: [PATCH 066/270] OPUSVIER-4395 Depend on matching search branch --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a41ecf5c7b..2651cae2e8 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "solarium/solarium": "3.8.*", "opus4-repo/opus4-common": "dev-master", "opus4-repo/framework": "dev-OPUSVIER-4395", - "opus4-repo/search": "dev-master", + "opus4-repo/search": "dev-OPUSVIER-4395", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", From c9f502ca192db4bbe884673f50847a71b3f62282 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 20 Oct 2020 16:00:49 +0200 Subject: [PATCH 067/270] Revert "OPUSVIER-4358 Only run library for faster results." This reverts commit 2daaaa2f --- .github/workflows/php.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 1f21aff3b5..30fc822c66 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -35,4 +35,16 @@ jobs: run: php composer.phar cs-check - name: Test-library - run: php composer.phar test -- --testsuite library \ No newline at end of file + run: php composer.phar test -- --testsuite library + + - name: Test-modules + run: php composer.phar test -- --testsuite modules + + - name: Test-admin + run: php composer.phar test -- --testsuite admin + + - name: Test-security + run: php composer.phar test -- --testsuite security + + - name: Test-scripts + run: php composer.phar test -- --testsuite scripts From 3baa69239b034d5fa520af7204312336eb3e90a1 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 20 Oct 2020 17:44:10 +0200 Subject: [PATCH 068/270] OPUSVIER-4449 Added used PHP packages --- composer.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/composer.json b/composer.json index 2651cae2e8..457aec8624 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,13 @@ "ext-curl": "*", "ext-xml": "*", "ext-zip": "*", + "ext-libxml":"*", + "ext-json": "*", + "ext-dom": "*", + "ext-xsl": "*", + "ext-simplexml": "*", + "ext-fileinfo": "*", + "ext-readline": "*", "zendframework/zendframework1": "1.12.*", "jpgraph/jpgraph": "dev-master", "solarium/solarium": "3.8.*", From 1761a3fae6354fe8cf111a7a7828858168b369a7 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 20 Oct 2020 22:34:46 +0200 Subject: [PATCH 069/270] OPUSVIER-4415 Use Framework with namespaces --- application/configs/application.ini | 6 +- db/createdb.php | 9 +- library/Application/Bootstrap.php | 72 +++--- library/Application/Configuration.php | 30 +-- .../Configuration/MaxUploadSize.php | 4 +- library/Application/Configuration/Module.php | 4 +- .../Console/Document/DeleteCommand.php | 3 +- library/Application/Controller/Action.php | 9 +- .../Controller/Action/Helper/Abstract.php | 4 +- .../Action/Helper/AccessControl.php | 9 +- .../Controller/Action/Helper/Dates.php | 21 +- .../Action/Helper/DocumentTypes.php | 19 +- .../Controller/Action/Helper/Documents.php | 18 +- .../Controller/Action/Helper/Files.php | 7 +- .../Controller/Action/Helper/MainMenu.php | 5 +- .../Controller/Action/Helper/Redirector.php | 6 +- .../Controller/Action/Helper/RenderForm.php | 2 +- .../Controller/Action/Helper/ReturnParams.php | 9 +- .../Controller/Action/Helper/SendFile.php | 4 +- .../Controller/Action/Helper/Translation.php | 24 +- .../Controller/Action/Helper/Version.php | 3 +- .../Controller/Action/Helper/Workflow.php | 20 +- library/Application/Controller/ActionCRUD.php | 18 +- .../Controller/MessageTemplates.php | 1 - .../Application/Controller/ModuleAccess.php | 10 +- .../Controller/Plugin/LoadTranslation.php | 10 +- .../Controller/Plugin/Navigation.php | 13 +- .../Controller/Plugin/SecurityRealm.php | 35 +-- .../Controller/Plugin/ViewSetup.php | 7 +- .../Application/Controller/Route/Redirect.php | 4 +- library/Application/Controller/Xml.php | 13 +- library/Application/Data/SubjectProvider.php | 4 +- library/Application/Exception.php | 8 +- library/Application/Export/ExportPlugin.php | 16 +- .../Export/ExportPluginAbstract.php | 30 +-- library/Application/Export/ExportService.php | 4 +- library/Application/Export/Exporter.php | 4 +- library/Application/Form/Abstract.php | 12 +- library/Application/Form/AbstractViewable.php | 6 +- library/Application/Form/Confirmation.php | 15 +- library/Application/Form/Decorator/Button.php | 2 +- .../Form/Decorator/ElementHint.php | 2 +- .../Form/Decorator/ElementHtmlTag.php | 2 +- .../Form/Decorator/FieldsetWithButtons.php | 4 +- .../Application/Form/Decorator/FileHash.php | 4 +- .../Application/Form/Decorator/FormHelp.php | 2 +- .../Form/Decorator/HtmlTagWithId.php | 2 +- .../Form/Decorator/LabelNotEmpty.php | 2 +- .../Form/Decorator/Placeholder.php | 2 +- .../Form/Decorator/RemoveButton.php | 6 +- .../Form/Decorator/TableHeader.php | 4 +- .../Form/Decorator/TableWrapper.php | 2 +- .../Form/Decorator/UpdateField.php | 2 +- .../Application/Form/Decorator/ViewHelper.php | 4 +- library/Application/Form/Element/Checkbox.php | 5 +- library/Application/Form/Element/Combobox.php | 4 +- .../Application/Form/Element/DocumentType.php | 6 +- library/Application/Form/Element/Email.php | 3 +- .../Form/Element/EnrichmentKey.php | 6 +- library/Application/Form/Element/File.php | 7 +- library/Application/Form/Element/FileHash.php | 11 +- library/Application/Form/Element/FileLink.php | 18 +- library/Application/Form/Element/Grantor.php | 14 +- library/Application/Form/Element/Hash.php | 3 +- library/Application/Form/Element/Hidden.php | 4 +- .../Application/Form/Element/HitsPerPage.php | 3 +- library/Application/Form/Element/Html.php | 4 +- .../Application/Form/Element/Identifier.php | 5 +- .../Application/Form/Element/IpAddress.php | 6 +- library/Application/Form/Element/Language.php | 8 +- .../Form/Element/LanguageScope.php | 1 - .../Application/Form/Element/LanguageType.php | 1 - library/Application/Form/Element/Login.php | 2 +- .../Form/Element/MultiCheckbox.php | 4 +- library/Application/Form/Element/Number.php | 6 +- library/Application/Form/Element/Password.php | 4 +- .../Application/Form/Element/PersonRole.php | 1 - library/Application/Form/Element/Position.php | 10 +- .../Application/Form/Element/Publisher.php | 16 +- library/Application/Form/Element/Roles.php | 18 +- library/Application/Form/Element/Select.php | 5 +- library/Application/Form/Element/Series.php | 7 +- .../Application/Form/Element/SortOrder.php | 5 +- library/Application/Form/Element/Submit.php | 7 +- .../Form/Element/SupportedLanguages.php | 10 +- library/Application/Form/Element/Text.php | 4 +- library/Application/Form/Element/Textarea.php | 5 +- library/Application/Form/Element/Theme.php | 3 +- .../Application/Form/Element/Translation.php | 4 +- .../Form/Element/TranslationModules.php | 2 +- library/Application/Form/Element/Year.php | 23 +- .../Form/Filter/ReplaceNewlines.php | 5 +- library/Application/Form/IElement.php | 1 - library/Application/Form/IModel.php | 5 +- library/Application/Form/IViewable.php | 3 +- library/Application/Form/Model/Abstract.php | 7 +- library/Application/Form/Model/Table.php | 3 +- library/Application/Form/TableHeader.php | 1 - library/Application/Form/Translations.php | 6 +- .../Form/Validate/AtLeastOneNotEmpty.php | 7 +- .../Validate/CollectionRoleNameUnique.php | 14 +- .../Validate/CollectionRoleOaiNameUnique.php | 8 +- library/Application/Form/Validate/DOI.php | 9 +- library/Application/Form/Validate/Date.php | 25 +-- .../Form/Validate/DuplicateMultiValue.php | 4 +- .../Form/Validate/DuplicateValue.php | 7 +- .../Form/Validate/EmailAddress.php | 2 +- .../Form/Validate/EnrichmentKeyAvailable.php | 7 +- .../Application/Form/Validate/Filename.php | 2 +- library/Application/Form/Validate/Gnd.php | 2 +- .../Form/Validate/IMultiSubForm.php | 1 - .../Application/Form/Validate/Identifier.php | 12 +- .../Form/Validate/LanguageUsedOnceOnly.php | 9 +- .../Form/Validate/LoginAvailable.php | 7 +- .../MultiSubForm/RepeatedLanguages.php | 1 - .../Validate/MultiSubForm/RepeatedValues.php | 3 +- library/Application/Form/Validate/Orcid.php | 3 +- .../Application/Form/Validate/Password.php | 5 +- .../Application/Form/Validate/RequiredIf.php | 11 +- .../Form/Validate/RoleAvailable.php | 7 +- .../Form/Validate/SeriesNumberAvailable.php | 14 +- library/Application/Form/Validate/URN.php | 7 +- .../Form/Validate/ValuePresentInSubforms.php | 7 +- .../Import/AdditionalEnrichments.php | 5 +- library/Application/Import/ArrayImport.php | 4 +- library/Application/Import/BibtexImporter.php | 4 +- library/Application/Import/CsvImporter.php | 49 ++-- library/Application/Import/Importer.php | 156 +++++++------ .../MetadataImportInvalidXmlException.php | 2 +- ...etadataImportSkippedDocumentsException.php | 2 +- library/Application/Import/PackageReader.php | 14 +- library/Application/Model/Abstract.php | 4 +- library/Application/Search/Facet.php | 4 +- library/Application/Search/FacetManager.php | 2 +- library/Application/SearchException.php | 1 - library/Application/Security/AclProvider.php | 37 +-- .../Security/BasicAuthProtection.php | 2 +- .../Application/Security/HttpAuthAdapter.php | 2 +- .../Application/Security/HttpAuthResolver.php | 9 +- library/Application/Security/RoleConfig.php | 19 +- library/Application/Translate.php | 16 +- library/Application/Translate/Help.php | 2 +- library/Application/Translate/TmxFile.php | 2 +- .../Translate/TranslationManager.php | 16 +- library/Application/Update.php | 8 +- .../Update/AddCC30LicenceShortNames.php | 11 +- .../Update/AddImportCollection.php | 16 +- .../ConvertCollectionRoleTranslations.php | 7 +- .../Update/CreateDoiUrnEnrichments.php | 6 +- .../Update/CreateSourceEnrichmentKey.php | 6 +- library/Application/Update/Database.php | 5 +- library/Application/Update/Exception.php | 2 + .../Update/ImportCustomTranslations.php | 12 +- .../Application/Update/ImportStaticPages.php | 6 +- library/Application/Update/PluginAbstract.php | 4 +- .../Update/SetStatusOfExistingDoi.php | 7 +- library/Application/Util/Array.php | 1 - library/Application/Util/BrowsingParams.php | 1 - .../Util/BrowsingParamsException.php | 1 - library/Application/Util/Document.php | 23 +- library/Application/Util/DocumentAdapter.php | 31 +-- library/Application/Util/Notification.php | 18 +- library/Application/Util/ShellScript.php | 4 +- library/Application/Util/WorkspaceCache.php | 2 +- library/Application/View/Helper/Abstract.php | 2 +- .../Application/View/Helper/AccessAllowed.php | 9 +- library/Application/View/Helper/AdminMenu.php | 5 +- .../View/Helper/AssignCollectionAllowed.php | 2 +- .../Application/View/Helper/Breadcrumbs.php | 7 +- .../View/Helper/CustomFileSortingEnabled.php | 4 +- .../View/Helper/DocumentAbstract.php | 4 +- .../Application/View/Helper/DocumentTitle.php | 6 +- .../Application/View/Helper/DocumentUrl.php | 3 +- .../View/Helper/EmbargoHasPassed.php | 8 +- .../Application/View/Helper/ExportLinks.php | 2 +- .../View/Helper/ExportLinksEnabled.php | 2 +- .../View/Helper/FaqSectionEditLink.php | 2 +- .../View/Helper/FileAccessAllowed.php | 6 +- library/Application/View/Helper/FileLink.php | 7 +- library/Application/View/Helper/FileSize.php | 3 +- library/Application/View/Helper/FileUrl.php | 2 +- .../Application/View/Helper/FormCombobox.php | 2 +- .../Application/View/Helper/FormDocuments.php | 2 +- library/Application/View/Helper/FormHtml.php | 2 +- .../View/Helper/FormTranslation.php | 6 +- .../Application/View/Helper/FormatDate.php | 6 +- .../Application/View/Helper/FormatValue.php | 30 +-- library/Application/View/Helper/FullUrl.php | 7 +- .../Application/View/Helper/FulltextLogo.php | 4 +- library/Application/View/Helper/Highlight.php | 2 +- .../View/Helper/IsAuthenticated.php | 4 +- .../View/Helper/IsDisplayField.php | 2 +- .../Application/View/Helper/JQueryEnabled.php | 5 +- .../View/Helper/LanguageImageExists.php | 2 +- .../View/Helper/LanguageSelector.php | 9 +- .../View/Helper/LanguageWebForm.php | 6 +- .../Application/View/Helper/LayoutPath.php | 7 +- library/Application/View/Helper/LinkList.php | 1 - library/Application/View/Helper/Locale.php | 2 +- library/Application/View/Helper/LoginBar.php | 13 +- .../View/Helper/MimeTypeAsCssClass.php | 6 +- .../Application/View/Helper/ResultTitle.php | 4 +- .../Application/View/Helper/SeriesNumber.php | 10 +- .../Application/View/Helper/TransferUrl.php | 2 +- library/Application/View/Helper/Translate.php | 4 +- .../View/Helper/TranslateIdentifier.php | 8 +- .../View/Helper/TranslateLanguage.php | 4 +- .../View/Helper/TranslateWithDefault.php | 2 +- .../View/Helper/TranslationEditLink.php | 2 +- .../View/Helper/ViewFormDefault.php | 3 +- .../View/Helper/ViewFormMultiCheckbox.php | 2 +- .../View/Helper/ViewFormSelect.php | 2 +- .../View/Helper/ViewFormTextarea.php | 1 - library/Application/Xslt.php | 2 +- modules/account/Bootstrap.php | 3 +- .../account/controllers/IndexController.php | 15 +- modules/account/forms/Account.php | 6 +- modules/admin/Bootstrap.php | 3 +- .../admin/controllers/AccessController.php | 12 +- .../admin/controllers/AccountController.php | 11 +- .../controllers/AutocompleteController.php | 6 +- .../controllers/CollectionController.php | 17 +- .../controllers/CollectionrolesController.php | 12 +- .../admin/controllers/ConfigController.php | 2 +- .../admin/controllers/DoctypeController.php | 3 +- .../admin/controllers/DocumentController.php | 8 +- .../admin/controllers/DocumentsController.php | 14 +- .../controllers/EnrichmentkeyController.php | 38 ++-- .../controllers/FilebrowserController.php | 8 +- .../controllers/FilemanagerController.php | 12 +- modules/admin/controllers/IndexController.php | 1 - modules/admin/controllers/InfoController.php | 1 - modules/admin/controllers/JobController.php | 10 +- .../admin/controllers/ModuleController.php | 2 +- .../admin/controllers/PersonController.php | 31 +-- .../admin/controllers/ReportController.php | 22 +- .../admin/controllers/SeriesController.php | 13 +- .../admin/controllers/StatisticController.php | 11 +- .../admin/controllers/WorkflowController.php | 4 +- .../admin/forms/AbstractDocumentSubForm.php | 8 +- modules/admin/forms/AbstractModelSubForm.php | 8 +- modules/admin/forms/Account.php | 27 +-- modules/admin/forms/ActionBox.php | 8 +- modules/admin/forms/CollectionRole.php | 11 +- modules/admin/forms/Configuration.php | 5 +- modules/admin/forms/CopyDocument.php | 2 +- modules/admin/forms/DnbInstitute.php | 9 +- modules/admin/forms/Document.php | 5 +- modules/admin/forms/Document/Abstract.php | 10 +- modules/admin/forms/Document/Actions.php | 1 - .../admin/forms/Document/Bibliographic.php | 11 +- modules/admin/forms/Document/Collection.php | 11 +- modules/admin/forms/Document/Collections.php | 11 +- modules/admin/forms/Document/Enrichment.php | 42 ++-- modules/admin/forms/Document/File.php | 9 +- modules/admin/forms/Document/Files.php | 1 - modules/admin/forms/Document/General.php | 9 +- modules/admin/forms/Document/Grantor.php | 1 - modules/admin/forms/Document/Identifier.php | 17 +- .../forms/Document/IdentifierSpecific.php | 17 +- modules/admin/forms/Document/Institute.php | 21 +- modules/admin/forms/Document/Licences.php | 20 +- .../forms/Document/MultiEnrichmentSubForm.php | 6 +- .../Document/MultiIdentifierOtherSubForm.php | 4 +- .../forms/Document/MultiIdentifierSubForm.php | 34 +-- modules/admin/forms/Document/MultiSubForm.php | 14 +- modules/admin/forms/Document/Note.php | 5 +- modules/admin/forms/Document/Patent.php | 30 +-- modules/admin/forms/Document/Person.php | 29 +-- modules/admin/forms/Document/PersonMoves.php | 1 - modules/admin/forms/Document/PersonRole.php | 4 +- modules/admin/forms/Document/PersonRoles.php | 1 - modules/admin/forms/Document/Persons.php | 4 +- modules/admin/forms/Document/Publisher.php | 1 - .../admin/forms/Document/RegistrationNote.php | 11 +- modules/admin/forms/Document/Section.php | 3 +- modules/admin/forms/Document/Series.php | 17 +- modules/admin/forms/Document/Subject.php | 22 +- modules/admin/forms/Document/SubjectType.php | 7 +- modules/admin/forms/Document/Subjects.php | 5 +- modules/admin/forms/Document/Title.php | 13 +- modules/admin/forms/Document/Titles.php | 1 - modules/admin/forms/Document/TitlesMain.php | 5 +- modules/admin/forms/EnrichmentKey.php | 19 +- modules/admin/forms/EnrichmentTable.php | 12 +- modules/admin/forms/File.php | 24 +- modules/admin/forms/File/Hashes.php | 1 - modules/admin/forms/File/Upload.php | 8 +- modules/admin/forms/FileManager.php | 1 - modules/admin/forms/Files.php | 8 +- modules/admin/forms/InfoBox.php | 14 +- modules/admin/forms/IpRange.php | 10 +- modules/admin/forms/Language.php | 2 +- modules/admin/forms/Licence.php | 37 +-- modules/admin/forms/Notification.php | 7 +- modules/admin/forms/Person.php | 28 +-- modules/admin/forms/Person/Changes.php | 10 +- modules/admin/forms/Person/Documents.php | 7 +- modules/admin/forms/PersonLink.php | 18 +- modules/admin/forms/Persons.php | 25 ++- modules/admin/forms/PersonsConfirm.php | 4 +- modules/admin/forms/Role.php | 8 +- modules/admin/forms/Series.php | 3 +- modules/admin/forms/UserRoles.php | 18 +- modules/admin/forms/WorkflowNotification.php | 9 +- modules/admin/forms/Wrapper.php | 3 +- modules/admin/forms/YesNoForm.php | 6 +- modules/admin/models/Collection.php | 20 +- modules/admin/models/CollectionRole.php | 16 +- modules/admin/models/Collections.php | 4 +- modules/admin/models/DocumentEditSession.php | 5 +- modules/admin/models/DoiReport.php | 15 +- modules/admin/models/DoiStatus.php | 2 +- modules/admin/models/EnrichmentKeys.php | 5 +- modules/admin/models/Exception.php | 1 - modules/admin/models/FileImport.php | 19 +- modules/admin/models/Hash.php | 5 +- modules/admin/models/IndexMaintenance.php | 13 +- .../admin/models/IndexMaintenanceLogData.php | 1 - modules/admin/models/Option.php | 4 +- modules/admin/models/Options.php | 4 +- modules/admin/models/Statistics.php | 16 +- modules/admin/models/UrnGenerator.php | 10 +- modules/admin/views/scripts/actionbox.phtml | 2 +- .../views/scripts/collectionroles/index.phtml | 2 +- modules/admin/views/scripts/docinfo.phtml | 2 +- modules/admin/views/scripts/docstatus.phtml | 2 +- .../admin/views/scripts/form/personForm.phtml | 2 +- modules/admin/views/scripts/infobox.phtml | 2 +- modules/admin/views/scripts/job/index.phtml | 4 +- .../views/scripts/person/documents.phtml | 2 +- .../admin/views/scripts/person/index.phtml | 4 +- modules/citationExport/Bootstrap.php | 10 +- .../controllers/IndexController.php | 1 - modules/citationExport/models/Exception.php | 1 - modules/citationExport/models/Helper.php | 14 +- modules/crawlers/Bootstrap.php | 3 +- .../controllers/SitelinksController.php | 6 +- modules/default/Bootstrap.php | 7 +- .../default/controllers/AuthController.php | 35 +-- .../default/controllers/ErrorController.php | 21 +- .../default/controllers/IndexController.php | 1 - .../default/controllers/LicenseController.php | 8 +- modules/export/Bootstrap.php | 16 +- .../export/controllers/IndexController.php | 2 +- modules/export/models/DataciteExport.php | 15 +- modules/export/models/PublistExport.php | 16 +- modules/export/models/XmlExport.php | 18 +- modules/frontdoor/Bootstrap.php | 3 +- .../controllers/DeliverController.php | 5 +- .../frontdoor/controllers/IndexController.php | 15 +- .../frontdoor/controllers/MailController.php | 9 +- .../frontdoor/forms/AtLeastOneValidator.php | 4 +- modules/frontdoor/forms/MailForm.php | 21 +- modules/frontdoor/forms/ToauthorForm.php | 17 +- modules/frontdoor/models/Authors.php | 18 +- modules/frontdoor/models/DocumentBuilder.php | 2 +- modules/frontdoor/models/Exception.php | 3 +- modules/frontdoor/models/File.php | 21 +- modules/frontdoor/models/HtmlMetaTags.php | 58 ++--- modules/help/Bootstrap.php | 2 +- modules/home/Bootstrap.php | 2 +- modules/home/controllers/IndexController.php | 10 +- modules/home/models/HelpFiles.php | 12 +- modules/oai/Bootstrap.php | 3 +- modules/oai/models/AbstractFile.php | 1 - modules/oai/models/Configuration.php | 3 +- modules/oai/models/Container.php | 23 +- modules/oai/models/DocumentList.php | 8 +- modules/oai/models/Error.php | 1 - modules/oai/models/Exception.php | 1 - modules/oai/models/Request.php | 14 +- .../oai/models/ResumptionTokenException.php | 3 +- modules/oai/models/Resumptiontoken.php | 1 - modules/oai/models/Resumptiontokens.php | 1 - modules/oai/models/Server.php | 77 ++++--- modules/oai/models/SetSpec.php | 1 - modules/oai/models/Sets.php | 11 +- modules/oai/models/SingleFile.php | 1 - modules/oai/models/TarFile.php | 1 - .../scripts/index/prefixes/XMetaDissPlus.xslt | 8 +- .../views/scripts/index/prefixes/oai_dc.xslt | 8 +- modules/publish/Bootstrap.php | 3 +- .../publish/controllers/DepositController.php | 26 ++- .../publish/controllers/FormController.php | 16 +- .../publish/controllers/IndexController.php | 5 +- modules/publish/forms/PublishingAbstract.php | 8 +- modules/publish/forms/PublishingFirst.php | 10 +- modules/publish/forms/PublishingSecond.php | 13 +- modules/publish/models/Deposit.php | 103 +++++---- modules/publish/models/DisplayGroup.php | 7 +- modules/publish/models/DocumentWorkflow.php | 18 +- .../models/DocumentWorkflowSubmitterId.php | 3 +- modules/publish/models/DocumenttypeParser.php | 14 +- modules/publish/models/Exception.php | 1 - modules/publish/models/ExtendedValidation.php | 31 +-- .../models/FormDocumentNotFoundException.php | 1 - modules/publish/models/FormElement.php | 13 +- modules/publish/models/FormException.php | 1 - .../FormIncorrectEnrichmentKeyException.php | 1 - .../FormIncorrectFieldNameException.php | 1 - .../models/FormNoButtonFoundException.php | 1 - .../models/FormSessionTimeoutException.php | 1 - modules/publish/models/LoggedUser.php | 21 +- .../publish/models/NoViewFoundException.php | 1 - modules/publish/models/Validation.php | 63 +++--- modules/publish/models/ValidationEmail.php | 3 +- .../views/helpers/BibliographieOverview.php | 12 +- modules/publish/views/helpers/EndTemplate.php | 3 +- modules/publish/views/helpers/Fieldset.php | 3 +- .../publish/views/helpers/FileOverview.php | 12 +- modules/publish/views/helpers/Group.php | 1 - .../publish/views/helpers/LegalNotices.php | 5 +- modules/review/Bootstrap.php | 3 +- .../review/controllers/IndexController.php | 16 +- .../review/models/ClearDocumentsHelper.php | 22 +- .../review/views/scripts/index/index.phtml | 2 +- .../rewrite/controllers/IndexController.php | 7 +- modules/rss/Bootstrap.php | 3 +- modules/rss/controllers/IndexController.php | 14 +- modules/setup/Bootstrap.php | 2 +- .../setup/controllers/LanguageController.php | 6 +- modules/setup/forms/FaqItem.php | 4 +- modules/setup/forms/Translation.php | 4 +- modules/setup/forms/TranslationValues.php | 4 +- .../Validate/TranslationKeyAvailable.php | 2 +- .../forms/Validate/TranslationKeyFormat.php | 2 +- modules/setup/models/Exception.php | 1 - .../setup/models/FileNotFoundException.php | 1 - .../setup/models/FileNotReadableException.php | 1 - modules/solrsearch/Bootstrap.php | 3 +- .../controllers/DispatchController.php | 1 - .../controllers/IndexController.php | 4 +- modules/solrsearch/forms/AdvancedSearch.php | 1 - modules/solrsearch/models/CollectionList.php | 17 +- modules/solrsearch/models/CollectionRoles.php | 13 +- modules/solrsearch/models/Exception.php | 1 - modules/solrsearch/models/FacetMenu.php | 4 +- modules/solrsearch/models/PaginationUtil.php | 1 - .../solrsearch/models/Search/Collection.php | 2 +- modules/solrsearch/models/Search/Series.php | 2 +- modules/solrsearch/models/Series.php | 9 +- modules/solrsearch/models/SeriesUtil.php | 8 +- .../scripts/index/browsecollection.phtml | 2 +- .../views/scripts/index/result.phtml | 2 +- modules/statistic/Bootstrap.php | 3 +- .../statistic/controllers/GraphController.php | 13 +- .../statistic/controllers/IndexController.php | 12 +- modules/statistic/forms/Test.php | 3 +- modules/statistic/models/StatisticGraph.php | 12 +- .../statistic/models/StatisticGraphThumb.php | 8 +- modules/sword/Bootstrap.php | 2 +- .../sword/controllers/DepositController.php | 6 +- .../controllers/ServicedocumentController.php | 5 +- modules/sword/models/AtomEntryDocument.php | 9 +- modules/sword/models/ErrorDocument.php | 7 +- modules/sword/models/ImportCollection.php | 13 +- modules/sword/models/ServiceDocument.php | 3 +- public/index.php | 14 +- public/layouts/default/common.phtml | 8 +- public/layouts/opus4/common.phtml | 6 +- public/layouts/opus4/debug.phtml | 2 +- scripts/change-password.php | 5 +- scripts/common/bootstrap.php | 6 +- scripts/common/console.php | 5 +- scripts/common/snippets.php | 1 - scripts/common/update.php | 5 +- scripts/cron/cron-check-consistency.php | 10 +- scripts/cron/cron-db-clean-temporary.php | 9 +- scripts/cron/cron-embargo-update.php | 10 +- scripts/cron/cron-import-metadata.php | 12 +- scripts/cron/cron-php-runner.sh | 3 - scripts/cron/cron-register-local-dois.php | 4 +- scripts/cron/cron-send-notification.php | 12 +- scripts/cron/cron-send-review-request.php | 13 +- scripts/cron/cron-solr-update.php | 10 +- scripts/cron/cron-update-document-cache.php | 22 +- scripts/cron/cron-verify-local-dois.php | 6 +- scripts/cron/cron-workspace-files-check.php | 10 +- scripts/import/BibtexImporter.php | 31 ++- scripts/import/CSVImporter.php | 1 - scripts/import/MetadataImporter.php | 9 +- scripts/opus-console.php | 1 - scripts/opus-create-export-xml.php | 11 +- scripts/opus-create-xss-document.php | 32 ++- scripts/opus-dump-document-xml.php | 13 +- scripts/opus-import-document-xml.php | 5 +- scripts/opus-smtp-dumpserver.php | 1 - scripts/snippets/OPUSHOSTING-481.php | 4 +- .../snippets/change-doi-landing-page-url.php | 9 +- scripts/snippets/change_document_type.php | 12 +- scripts/snippets/create_10000_documents.php | 14 +- .../snippets/create_all_fields_document.php | 42 ++-- .../create_doctype-phtml_from_xml.php | 5 +- .../snippets/create_title_from_enrichment.php | 8 +- scripts/snippets/delete_all_docs.php | 9 +- scripts/snippets/delete_files.php | 9 +- scripts/snippets/delete_non-demo_docs.php | 9 +- scripts/snippets/export_document.php | 13 +- scripts/snippets/export_import_all_docs.php | 21 +- ...docs_with_multiple_titles_or_abstracts.php | 7 +- ...ind_docs_without_titles_in_doclanguage.php | 7 +- ..._missing_published_docs_in_searchindex.php | 11 +- .../find_modified_docs_in_searchindex.php | 8 +- ...nd_urns_for_docs_without_visible_files.php | 7 +- scripts/snippets/get_nonextractable_docs.php | 10 +- scripts/snippets/import_collections.php | 10 +- scripts/snippets/import_dnb_ddc.php | 13 +- scripts/snippets/import_document.php | 7 +- scripts/snippets/publications-stats.php | 6 +- scripts/snippets/reassign_doc_sort_order.php | 10 +- .../snippets/release_all_unpublished_docs.php | 13 +- .../split_firstname_academic_title.php | 5 +- scripts/snippets/update-dnbinstitute.php | 14 +- .../snippets/validate-oai-xmetadissplus.php | 1 - scripts/update/002-Add-CC-4.0-licences.php | 7 +- ...-zeros-from-GND-identifier-for-persons.php | 4 +- .../008-Convert-database-to-utf8mb4.php | 4 +- scripts/update/update.php | 5 +- .../MigrateSeriesCollections.php | 29 ++- .../MigrateSubjectsToCollections.php | 32 +-- scripts/xslt.php | 7 +- tests/Bootstrap.php | 6 +- tests/import-testdata.php | 11 +- .../Configuration/MaxUploadSizeTest.php | 2 +- .../library/Application/ConfigurationTest.php | 24 +- .../Console/Document/DeleteCommandTest.php | 54 ++--- .../Controller/Action/Helper/AbstractTest.php | 2 +- .../Action/Helper/AccessControlTest.php | 6 +- .../Action/Helper/BreadcrumbsTest.php | 19 +- .../Controller/Action/Helper/DatesTest.php | 8 +- .../Action/Helper/DocumentTypesTest.php | 16 +- .../Action/Helper/DocumentsTest.php | 8 +- .../Action/Helper/FileTypesTest.php | 8 +- .../Controller/Action/Helper/FilesTest.php | 2 +- .../Action/Helper/ResultScriptTest.php | 4 +- .../Action/Helper/TranslationTest.php | 73 +++--- .../Controller/Action/Helper/VersionTest.php | 4 +- .../Controller/Action/Helper/WorkflowTest.php | 10 +- .../Application/Controller/ActionCRUDTest.php | 26 ++- .../Controller/ModuleAccessTest.phtml | 2 +- .../Export/ExportPluginAbstractTest.php | 6 +- .../Application/Export/ExportServiceTest.php | 4 +- .../Application/Export/ExporterTest.php | 12 +- .../library/Application/Form/AbstractTest.php | 14 +- .../Application/Form/AbstractViewableTest.php | 22 +- .../Application/Form/ConfirmationTest.php | 34 ++- .../Form/Decorator/ElementHtmlTagTest.php | 4 +- .../Decorator/FieldsetWithButtonsTest.php | 4 +- .../Form/Decorator/FileHashTest.php | 21 +- .../Form/Decorator/FormHelpTest.php | 2 +- .../Form/Decorator/HtmlTagWithIdTest.php | 4 +- .../Form/Decorator/RemoveButtonTest.php | 4 +- .../Form/Decorator/TableHeaderTest.php | 14 +- .../Form/Decorator/UpdateFieldTest.php | 12 +- .../Element/CollectionDisplayFormatTest.php | 2 +- .../Form/Element/DocumentTypeTest.php | 2 +- .../Form/Element/EnrichmentKeyTest.php | 17 +- .../Application/Form/Element/FileHashTest.php | 4 +- .../Application/Form/Element/FileLinkTest.php | 10 +- .../Application/Form/Element/FileTest.php | 3 +- .../Application/Form/Element/GrantorTest.php | 12 +- .../Form/Element/HitsPerPageTest.php | 2 +- .../Form/Element/IdentifierTest.php | 5 +- .../Form/Element/LanguageScopeTest.php | 2 +- .../Application/Form/Element/LanguageTest.php | 1 + .../Form/Element/LanguageTypeTest.php | 2 +- .../Form/Element/MultiCheckboxTest.php | 2 +- .../Application/Form/Element/NumberTest.php | 2 +- .../Form/Element/PersonRoleTest.php | 1 - .../Application/Form/Element/PositionTest.php | 2 +- .../Form/Element/PublisherTest.php | 12 +- .../Application/Form/Element/RolesTest.php | 10 +- .../Application/Form/Element/SeriesTest.php | 8 +- .../Form/Element/SortOrderTest.php | 2 +- .../Application/Form/Element/SubmitTest.php | 1 - .../Application/Form/Element/ThemeTest.php | 1 - .../Form/Element/TranslationModulesTest.php | 4 +- .../Form/Element/TranslationTest.php | 8 +- .../Form_Filter_ReplaceNewlinesTest.php | 1 - .../Application/Form/Model/AbstractTest.php | 16 +- .../Application/Form/Model/TableTest.php | 22 +- .../CollectionRoleOaiNameUniqueTest.php | 8 +- .../Form/Validate/IdentifierTest.php | 8 +- .../Form/Validate/LoginAvailableTest.php | 4 +- .../MultiSubForm/RepeatedLanguagesTest.php | 6 +- .../MultiSubForm/RepeatedValuesTest.php | 12 +- .../Application/Form/Validate/OrcidTest.php | 1 - .../Form/Validate/RequiredIfTest.php | 1 - .../Form/Validate/RequiredIfValueTest.php | 1 - .../Validate/SeriesNumberAvailableTest.php | 2 +- .../Validate/ValuePresentInSubformsTest.php | 1 - .../Application/Import/ImporterTest.php | 9 +- .../Import/TarPackageReaderTest.php | 2 +- .../Import/ZipPackageReaderTest.php | 2 +- .../Application/Model/AbstractTest.php | 4 +- .../Application/Search/FacetManagerTest.php | 8 +- .../Application/Security/AclProviderTest.php | 24 +- .../Application/Security/RoleConfigTest.php | 7 +- .../Translate/TranslationManagerTest.php | 63 +++--- tests/library/Application/TranslateTest.php | 48 ++-- .../Update/AddCC30LicenceShortNamesTest.php | 39 ++-- .../Update/AddImportCollectionTest.php | 19 +- .../ConvertCollectionRoleTranslationsTest.php | 21 +- .../Update/ImportCustomTranslationsTest.php | 4 +- .../Update/ImportHelpFilesTest.php | 25 ++- .../Update/ImportStaticPagesTest.php | 8 +- .../Update/SetStatusOfExistingDoiTest.php | 20 +- .../Application/Util/DocumentAdapterTest.php | 54 ++--- .../Application/Util/NotificationTest.php | 33 +-- .../Util/PublicationNotificationTest.php | 23 +- .../View/Helper/AccessAllowedTest.php | 8 +- .../View/Helper/ActionCssClassTest.php | 2 +- .../View/Helper/AdminCssClassTest.php | 2 +- .../Application/View/Helper/AdminMenuTest.php | 6 +- .../Helper/AssignCollectionAllowedTest.php | 4 +- .../View/Helper/BreadcrumbsTest.php | 2 +- .../Helper/CustomFileSortingEnabledTest.php | 2 +- .../View/Helper/DocumentTitleTest.php | 4 +- .../View/Helper/EmbargoHasPassedTest.php | 6 +- .../View/Helper/EscapeValueTest.php | 2 +- .../View/Helper/ExportLinksEnabledTest.php | 2 +- .../View/Helper/ExportLinksTest.php | 2 +- .../View/Helper/FaqEditLinkTest.php | 8 +- .../Application/View/Helper/FileLinkTest.php | 22 +- .../Application/View/Helper/FileUrlTest.php | 4 +- .../View/Helper/FormDocumentsTest.php | 4 +- .../View/Helper/FormTranslationTest.php | 4 +- .../View/Helper/FormatDateTest.php | 6 +- .../View/Helper/FormatValueTest.php | 15 +- .../View/Helper/FrontdoorUrlTest.php | 2 +- .../Application/View/Helper/FullUrlTest.php | 5 +- .../View/Helper/FulltextLogoTest.php | 17 +- .../View/Helper/IsDisplayFieldTest.php | 2 +- .../View/Helper/JavascriptMessagesTest.php | 2 +- .../View/Helper/LanguageSelectorTest.php | 10 +- .../Application/View/Helper/MessagesTest.php | 10 +- .../View/Helper/OptionEnabledTest.php | 2 +- .../Application/View/Helper/OptionUrlTest.php | 8 +- .../View/Helper/OptionValueTest.php | 2 +- .../View/Helper/ResultAuthorsTest.php | 2 +- .../View/Helper/ResultTitleTest.php | 2 +- .../View/Helper/ResultYearTest.php | 2 +- .../View/Helper/SeriesNumberTest.php | 8 +- .../View/Helper/ShortenTextTest.php | 8 +- .../View/Helper/TransferUrlTest.php | 2 +- .../View/Helper/TranslationEditLinkTest.php | 8 +- .../View/Helper/ViewFormDefaultTest.php | 7 +- .../View/Helper/ViewFormMultiCheckboxTest.php | 4 +- .../View/Helper/ViewFormSelectTest.php | 5 +- .../View/Helper/ViewFormTextareaTest.php | 2 +- tests/library/Application/ZendBasicsTest.php | 2 +- tests/library/Mock/Opus/Document.php | 7 +- tests/modules/ControllerTestCaseTest.php | 43 ++-- tests/modules/LanguageTest.php | 2 +- .../controllers/IndexControllerTest.php | 34 +-- tests/modules/account/forms/AccountTest.php | 14 +- .../controllers/AccountControllerTest.php | 36 +-- .../controllers/CollectionControllerTest.php | 11 +- .../CollectionrolesControllerTest.php | 52 +++-- .../DnbinstituteControllerTest.php | 30 +-- .../controllers/DocumentControllerTest.php | 30 ++- .../controllers/DocumentsControllerTest.php | 20 +- .../EnrichmentkeyControllerTest.php | 210 +++++++++--------- .../controllers/FilemanagerControllerTest.php | 14 +- .../IndexmaintenanceControllerTest.php | 31 +-- .../admin/controllers/InfoControllerTest.php | 10 +- .../controllers/IprangeControllerTest.php | 19 +- .../admin/controllers/JobControllerTest.php | 22 +- .../controllers/LanguageControllerTest.php | 22 +- .../controllers/LicenceControllerTest.php | 22 +- .../controllers/PersonControllerTest.php | 17 +- .../controllers/ReportControllerTest.php | 19 +- .../admin/controllers/RoleControllerTest.php | 12 +- .../controllers/SeriesControllerTest.php | 22 +- .../controllers/WorkflowControllerTest.php | 27 ++- .../forms/AbstractDocumentSubFormTest.php | 4 +- tests/modules/admin/forms/AccountTest.php | 16 +- tests/modules/admin/forms/ActionBoxTest.php | 8 +- .../admin/forms/CollectionRoleTest.php | 10 +- tests/modules/admin/forms/CollectionTest.php | 12 +- .../modules/admin/forms/ConfigurationTest.php | 4 +- .../modules/admin/forms/DnbInstituteTest.php | 10 +- .../admin/forms/Document/AbstractTest.php | 9 +- .../forms/Document/BibliographicTest.php | 4 +- .../admin/forms/Document/CollectionTest.php | 10 +- .../admin/forms/Document/CollectionsTest.php | 10 +- .../admin/forms/Document/EnrichmentTest.php | 90 ++++---- .../modules/admin/forms/Document/FileTest.php | 5 +- .../admin/forms/Document/FilesTest.php | 8 +- .../admin/forms/Document/GeneralTest.php | 6 +- .../admin/forms/Document/IdentifierTest.php | 11 +- .../admin/forms/Document/InstituteTest.php | 9 +- .../admin/forms/Document/LicencesTest.php | 15 +- .../Document/MultiEnrichmentSubFormTest.php | 29 ++- .../admin/forms/Document/MultiSubFormTest.php | 35 +-- .../modules/admin/forms/Document/NoteTest.php | 11 +- .../admin/forms/Document/PatentTest.php | 13 +- .../admin/forms/Document/PersonMovesTest.php | 14 +- .../admin/forms/Document/PersonRoleTest.php | 40 ++-- .../admin/forms/Document/PersonTest.php | 4 +- .../admin/forms/Document/PersonsTest.php | 20 +- .../admin/forms/Document/SeriesTest.php | 11 +- .../admin/forms/Document/SubjectTest.php | 15 +- .../admin/forms/Document/SubjectTypeTest.php | 6 +- .../admin/forms/Document/SubjectsTest.php | 10 +- .../admin/forms/Document/TitleTest.php | 9 +- .../admin/forms/Document/TitlesMainTest.php | 7 +- tests/modules/admin/forms/DocumentTest.php | 23 +- .../modules/admin/forms/EnrichmentKeyTest.php | 63 +++--- tests/modules/admin/forms/File/HashesTest.php | 12 +- tests/modules/admin/forms/File/UploadTest.php | 12 +- tests/modules/admin/forms/FileManagerTest.php | 10 +- tests/modules/admin/forms/FileTest.php | 12 +- tests/modules/admin/forms/FilesTest.php | 14 +- tests/modules/admin/forms/InfoBoxTest.php | 11 +- tests/modules/admin/forms/IpRangeTest.php | 17 +- tests/modules/admin/forms/LanguageTest.php | 8 +- tests/modules/admin/forms/LicenceTest.php | 8 +- .../modules/admin/forms/NotificationTest.php | 4 +- .../admin/forms/Person/DocumentsTest.php | 2 +- tests/modules/admin/forms/PersonLinkTest.php | 14 +- tests/modules/admin/forms/PersonTest.php | 11 +- tests/modules/admin/forms/PersonsTest.php | 2 +- tests/modules/admin/forms/RoleTest.php | 9 +- tests/modules/admin/forms/SeriesTest.php | 10 +- tests/modules/admin/forms/UserRolesTest.php | 11 +- .../admin/forms/WorkflowNotificationTest.php | 19 +- .../admin/models/CollectionRoleTest.php | 19 +- .../modules/admin/models/CollectionsTest.php | 23 +- .../admin/models/DocumentEditSessionTest.php | 9 +- tests/modules/admin/models/DoiReportTest.php | 20 +- tests/modules/admin/models/DoiStatusTest.php | 15 +- .../admin/models/EnrichmentKeysTest.php | 18 +- tests/modules/admin/models/FileImportTest.php | 10 +- tests/modules/admin/models/HashTest.php | 4 +- .../admin/models/IndexMaintenanceTest.php | 30 +-- .../modules/admin/models/UrnGeneratorTest.php | 10 +- .../controller/IndexControllerTest.php | 43 ++-- .../citationExport/model/HelperTest.php | 23 +- .../controllers/AuthControllerTest.php | 8 +- tests/modules/export/BibtexExportTest.php | 8 +- tests/modules/export/BootstrapTest.php | 2 +- tests/modules/export/DataCiteExportTest.php | 79 ++++--- tests/modules/export/Marc21ExportTest.php | 60 ++--- tests/modules/export/RisExportTest.php | 2 +- .../controllers/IndexControllerTest.php | 73 +++--- .../export/models/DataciteExportTest.php | 32 +-- .../export/models/PublistExportTest.php | 4 +- tests/modules/export/models/XmlExportTest.php | 19 +- .../controllers/IndexControllerTest.php | 115 +++++----- .../controllers/MailControllerTest.php | 9 +- .../forms/AtLeastOneValidatorTest.php | 8 +- .../modules/frontdoor/models/AuthorsTest.php | 19 +- tests/modules/frontdoor/models/FileTest.php | 18 +- .../frontdoor/models/HtmlMetaTagsTest.php | 117 +++++----- .../home/controllers/IndexControllerTest.php | 8 +- tests/modules/home/models/HelpFilesTest.php | 4 +- .../controllers/ContainerControllerTest.php | 21 +- .../oai/controllers/IndexControllerTest.php | 178 ++++++++------- tests/modules/oai/models/ContainerTest.php | 33 +-- tests/modules/oai/models/DocumentListTest.php | 11 +- tests/modules/oai/models/XmlFactoryTest.php | 6 +- .../View/Helper/JavascriptMessagesTest.php | 2 +- .../controllers/DepositControllerTest.php | 14 +- .../controllers/FormControllerTest.php | 82 +++---- .../controllers/IndexControllerTest.php | 10 +- .../publish/forms/PublishingFirstTest.php | 8 +- .../publish/forms/PublishingSecondTest.php | 20 +- tests/modules/publish/models/DepositTest.php | 14 +- .../publish/models/DocumenttypeParserTest.php | 26 +-- .../publish/models/ExtendedValidationTest.php | 40 ++-- .../publish/models/FormElementTest.php | 6 +- .../modules/publish/models/LoggedUserTest.php | 11 +- .../modules/publish/models/ValidationTest.php | 31 +-- .../controllers/IndexControllerTest.php | 18 +- .../models/ClearDocumentsHelperTest.php | 23 +- .../rss/controllers/IndexControllerTest.php | 20 +- tests/modules/rss/models/FeedTest.php | 32 +-- .../controllers/LanguageControllerTest.php | 42 ++-- tests/modules/setup/forms/ImprintPageTest.php | 2 +- tests/modules/setup/forms/TranslationTest.php | 14 +- .../setup/forms/TranslationValuesTest.php | 2 +- .../Validate/TranslationKeyFormatTest.php | 2 +- .../controllers/BrowseControllerTest.php | 22 +- .../controllers/IndexControllerTest.php | 91 ++++---- .../solrsearch/models/CollectionListTest.php | 9 +- .../solrsearch/models/CollectionRolesTest.php | 12 +- .../solrsearch/models/ExceptionTest.php | 1 - .../solrsearch/models/FacetMenuTest.php | 14 +- .../solrsearch/models/PaginationUtilTest.php | 1 - .../modules/solrsearch/models/SearchTest.php | 2 +- .../modules/solrsearch/models/SeriesTest.php | 4 +- .../solrsearch/models/SeriesUtilTest.php | 10 +- .../solrsearch/models/search/BasicTest.php | 2 +- .../DepositControllerErrorCasesTest.php | 14 +- .../DepositControllerMultipleDocsTest.php | 5 +- .../controllers/DepositControllerTest.php | 27 ++- .../ServicedocumentControllerTest.php | 7 +- tests/rebuild-database.php | 9 +- tests/rebuilding_database.sh | 2 +- tests/scripts/cron/ConsistencyCheckTest.php | 13 +- tests/scripts/cron/CronTestCase.php | 9 +- tests/scripts/cron/DbCleanTemporaryTest.php | 17 +- tests/scripts/cron/EmbargoUpdateTest.php | 19 +- tests/scripts/cron/MetadataImportTest.php | 39 ++-- tests/scripts/cron/OpusDocumentMock.php | 5 +- tests/scripts/cron/SendNotificationTest.php | 13 +- tests/scripts/cron/SolrUpdateTest.php | 14 +- .../scripts/cron/UpdateDocumentCacheTest.php | 9 +- ...esAdminTests.php => LicencesAdminTest.php} | 0 tests/security/RefereeTest.php | 8 +- tests/security/SeriesAdminTest.php | 12 +- tests/support/AssumptionChecker.php | 4 +- tests/support/ControllerTestCase.php | 159 ++++++------- tests/support/CrudControllerTestCase.php | 6 +- tests/support/DepositTestHelper.php | 23 +- tests/support/DummyValidator.php | 2 +- tests/support/FormElementTestCase.php | 2 +- tests/support/LogFilter.php | 3 +- tests/support/MockAccessControl.php | 3 +- tests/support/MockLogger.php | 5 +- tests/support/MockRealm.php | 6 +- tests/support/SendMailMock.php | 3 +- tests/support/SimpleBootstrap.php | 10 +- tests/support/TestCase.php | 24 +- 826 files changed, 5317 insertions(+), 4324 deletions(-) rename tests/security/{LicencesAdminTests.php => LicencesAdminTest.php} (100%) diff --git a/application/configs/application.ini b/application/configs/application.ini index 974bf9d808..45e5e1a2c9 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -465,9 +465,9 @@ filetypes.html.mimeType = 'text/html' ; identifier.validation.issn.messageTemplates.checkdigit = 'validation_error_checkdigit' model.plugins.document[] = 'Opus\Search\Plugin\Index' -model.plugins.document[] = 'Opus_Document_Plugin_XmlCache' -model.plugins.document[] = 'Opus_Document_Plugin_IdentifierUrn' -model.plugins.document[] = 'Opus_Document_Plugin_IdentifierDoi' +model.plugins.document[] = 'Opus\Document\Plugin\XmlCache' +model.plugins.document[] = 'Opus\Document\Plugin\IdentifierUrn' +model.plugins.document[] = 'Opus\Document\Plugin\IdentifierDoi' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/db/createdb.php b/db/createdb.php index 69ad86000e..db01409d6c 100644 --- a/db/createdb.php +++ b/db/createdb.php @@ -57,7 +57,10 @@ require_once 'autoload.php'; -$application = new Zend_Application( +// TODO OPUSVIER-4420 remove after switching to Laminas/ZF3 +require_once APPLICATION_PATH . '/vendor/opus4-repo/framework/library/OpusDb/Mysqlutf8.php'; + +$application = new \Zend_Application( APPLICATION_ENV, [ "config" => [ @@ -68,14 +71,14 @@ ] ); -Zend_Registry::set('opus.disableDatabaseVersionCheck', true); +\Zend_Registry::set('opus.disableDatabaseVersionCheck', true); // Bootstrapping application $application->bootstrap('Backend'); $options = getopt('v:n:'); -$database = new Opus_Database(); +$database = new \Opus\Database(); $database->drop(); $database->create(); diff --git a/library/Application/Bootstrap.php b/library/Application/Bootstrap.php index c2ec54b3de..0d29187f26 100644 --- a/library/Application/Bootstrap.php +++ b/library/Application/Bootstrap.php @@ -27,6 +27,8 @@ use Opus\Log\LogService; +use Opus\Db\DatabaseBootstrap; + /** * Provide methods to setup and run the application. It also provides a couple of static * variables for quicker access to application components like the front controller. @@ -42,7 +44,7 @@ * * TODO unit test bootstrap */ -class Application_Bootstrap extends Opus_Bootstrap_Base +class Application_Bootstrap extends DatabaseBootstrap { /** @@ -57,7 +59,7 @@ protected function _initOpusFrontController() { $this->bootstrap(['frontController']); - $frontController = $this->getResource('frontController'); // Zend_Controller_Front::getInstance(); + $frontController = $this->getResource('frontController'); // \Zend_Controller_Front::getInstance(); /* * Add a custom front controller plugin for setting up an appropriate @@ -82,7 +84,7 @@ protected function _initOpusFrontController() $router->addDefaultRoutes(); // specity the SWORD module as RESTful - $restRoute = new Zend_Rest_Route($frontController, [], ['sword']); + $restRoute = new \Zend_Rest_Route($frontController, [], ['sword']); $router->addRoute('rest', $restRoute); $documentRoute = new Application_Controller_Route_Redirect( @@ -105,9 +107,9 @@ protected function _initOpusFrontController() /** * Configure view with UTF-8 options and ViewRenderer action helper. - * The Zend_Layout component also gets initialized here. + * The \Zend_Layout component also gets initialized here. * - * @return Zend_View + * @return \Zend_View */ protected function _initView() { @@ -125,14 +127,14 @@ protected function _initView() throw new Exception('Requested theme "' . $theme . '" not found.'); } - Zend_Layout::startMvc( + \Zend_Layout::startMvc( [ 'layoutPath' => $layoutpath, 'layout' => 'common'] ); // Initialize view with custom encoding and global view helpers. - $view = new Zend_View; + $view = new \Zend_View; $view->setEncoding('UTF-8'); // Set doctype to XHTML1 strict @@ -152,18 +154,18 @@ protected function _initView() $breadcrumbsHelper = new Application_View_Helper_Breadcrumbs(); $view->registerHelper($breadcrumbsHelper, 'breadcrumbs'); - $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view); + $viewRenderer = new \Zend_Controller_Action_Helper_ViewRenderer($view); - Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); + \Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); // Make View available to unit test (TODO maybe there is a better way?) - Zend_Registry::set('Opus_View', $view); + \Zend_Registry::set('Opus_View', $view); return $view; } /** - * Setup Zend_Cache for caching application data and register under 'Zend_Cache_Page'. + * Setup \Zend_Cache for caching application data and register under '\Zend_Cache_Page'. * * @return void */ @@ -196,15 +198,15 @@ protected function _setupPageCache() 'cache_dir' => $config->workspacePath . '/cache/' ]; - $pagecache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions); - Zend_Registry::set('Zend_Cache_Page', $pagecache); + $pagecache = \Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions); + \Zend_Registry::set('Zend_Cache_Page', $pagecache); } /** - * Setup Zend_Translate with language resources of all existent modules. + * Setup \Zend_Translate with language resources of all existent modules. * * It is assumed that all modules are stored under modules/. The search - * pattern Zend_Translate gets configured with is to look for a + * pattern \Zend_Translate gets configured with is to look for a * folder and file structure similar to: * * language/ @@ -217,7 +219,7 @@ protected function _setupPageCache() * - Locale (if supported) * - Default * - * @return Zend_Translate + * @return \Zend_Translate */ protected function _initTranslation() { @@ -235,7 +237,7 @@ protected function _initTranslation() 'route' => ['en' => 'de'] // TODO make configurable in administration AND/OR generate automatically (all lang -> default) ]); - Zend_Registry::set(Application_Translate::REGISTRY_KEY, $translate); + \Zend_Registry::set(Application_Translate::REGISTRY_KEY, $translate); $configHelper = new Application_Configuration(); @@ -245,7 +247,7 @@ protected function _initTranslation() // check if language is supported; if not, use language from locale if (! $configHelper->isLanguageSupported($language)) { - $locale = new Zend_Locale(); + $locale = new \Zend_Locale(); $language = $locale->getLanguage(); $logger->debug("Current locale = '$language'"); // check if locale is supported; if not, use default language @@ -265,12 +267,12 @@ protected function _initTranslation() /** * Setup session. * - * @return Zend_Session_Namespace + * @return \Zend_Session_Namespace */ protected function _initSession() { $this->bootstrap(['Database']); - return new Zend_Session_Namespace(); + return new \Zend_Session_Namespace(); } /** @@ -285,17 +287,17 @@ protected function _initNavigation() $this->bootstrap('Logging', 'View'); $log = $this->getResource('Logging'); - $log->debug('Initializing Zend_Navigation'); + $log->debug('Initializing \Zend_Navigation'); $navigationConfigFile = APPLICATION_PATH . '/application/configs/navigationModules.xml'; - $navConfig = new Zend_Config_Xml($navigationConfigFile, 'nav'); + $navConfig = new \Zend_Config_Xml($navigationConfigFile, 'nav'); $log->debug('Navigation config file is: ' . $navigationConfigFile); $container = null; try { - $container = new Zend_Navigation($navConfig); - } catch (Zend_Navigation_Exception $e) { + $container = new \Zend_Navigation($navConfig); + } catch (\Zend_Navigation_Exception $e) { /* TODO This suppresses the "Mystery Bug" that is producing errors * in unit tests sometimes. So far we haven't figured out the real * reason behind the errors. In regular Opus instances the error @@ -313,7 +315,7 @@ protected function _initNavigation() } /** - * Initialisiert Zend_Acl für die Authorization in OPUS. + * Initialisiert \Zend_Acl für die Authorization in OPUS. * * TODO use Application_Security_AclProvider */ @@ -326,14 +328,14 @@ protected function _initAuthz() if (isset($config->security) && filter_var($config->security, FILTER_VALIDATE_BOOLEAN)) { Application_Security_AclProvider::init(); } else { - Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl(null); - Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole(null); + \Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl(null); + \Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole(null); } } /** * Initializes navigation container for main menu. - * @return Zend_Navigation + * @return \Zend_Navigation */ protected function _initMainMenu() { @@ -341,16 +343,16 @@ protected function _initMainMenu() $navigationConfigFile = APPLICATION_PATH . '/application/configs/navigation.xml'; - $navConfig = new Zend_Config_Xml($navigationConfigFile, 'nav'); + $navConfig = new \Zend_Config_Xml($navigationConfigFile, 'nav'); - $container = new Zend_Navigation($navConfig); + $container = new \Zend_Navigation($navConfig); $view = $this->getResource('View'); $view->navigationMainMenu = $container; - // TODO Find better way without Zend_Registry - Zend_Registry::set('Opus_Navigation', $container); + // TODO Find better way without \Zend_Registry + \Zend_Registry::set('Opus_Navigation', $container); // return $container; } @@ -376,18 +378,18 @@ protected function _initExporter() $exporter = new Application_Export_Exporter(); - Zend_Registry::set('Opus_Exporter', $exporter); + \Zend_Registry::set('Opus_Exporter', $exporter); $exportService = new Application_Export_ExportService(); // TODO merge ExportService with Exporter class (?) - Zend_Registry::set('Opus_ExportService', $exportService); + \Zend_Registry::set('Opus_ExportService', $exportService); return $exporter; } protected function _initIndexPlugin() { - \Opus_Model_Xml_Cache::setIndexPluginClass('Opus\Search\Plugin\Index'); + \Opus\Model\Xml\Cache::setIndexPluginClass('Opus\Search\Plugin\Index'); } } diff --git a/library/Application/Configuration.php b/library/Application/Configuration.php index 8eec6fca3f..56db82f838 100644 --- a/library/Application/Configuration.php +++ b/library/Application/Configuration.php @@ -93,7 +93,7 @@ public static function getInstance() */ public function getConfig() { - return Zend_Registry::get('Zend_Config'); + return \Zend_Registry::get('Zend_Config'); } /** @@ -171,7 +171,7 @@ public function getDefaultLanguage() $this->defaultLanguage = $languages[0]; if ($this->isLanguageSelectionEnabled()) { - $locale = new Zend_Locale(); + $locale = new \Zend_Locale(); $language = $locale->getDefault(); if (is_array($language) and count($language) > 0) { reset($language); @@ -262,7 +262,7 @@ public function getFilesPath() */ public static function getOpusVersion() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $localVersion = $config->version; return (is_null($localVersion)) ? 'unknown' : $localVersion; } @@ -282,9 +282,9 @@ public static function getOpusInfo() * @param Zend_Config $config * @throws Zend_Config_Exception */ - public static function save(Zend_Config $config) + public static function save(\Zend_Config $config) { - $writer = new Zend_Config_Writer_Xml(); + $writer = new \Zend_Config_Writer_Xml(); $writer->write(APPLICATION_PATH . '/application/configs/config.xml', $config); } @@ -298,13 +298,13 @@ public static function load() * @param $option * @return mixed|Zend_Config */ - public static function getValueFromConfig(Zend_Config $config, $option) + public static function getValueFromConfig(\Zend_Config $config, $option) { $keys = explode('.', $option); $subconfig = $config; foreach ($keys as $key) { $subconfig = $subconfig->get($key); - if (! ($subconfig instanceof Zend_Config)) { + if (! ($subconfig instanceof \Zend_Config)) { break; } } @@ -323,17 +323,17 @@ public function getValue($key) /** * Updates a value in a Zend_Config object. * - * @param Zend_Config $config + * @param \Zend_Config $config * @param $option string Name of option * @param $value string New value for option - * @throws Zend_Exception + * @throws \Zend_Exception * * TODO review and if possible replace this code with something simpler */ - public static function setValueInConfig(Zend_Config $config, $option, $value) + public static function setValueInConfig(\Zend_Config $config, $option, $value) { if ($config->readOnly()) { - Zend_Registry::get('Zend_Log')->err('Zend_Config object is readonly.'); + \Zend_Registry::get('Zend_Log')->err('Zend_Config object is readonly.'); return; } @@ -368,17 +368,17 @@ public static function clearInstance() /** * Returns Zend_Translate instance for application. - * @return Zend_Translate - * @throws Zend_Exception + * @return \Zend_Translate + * @throws \Zend_Exception */ public function getTranslate() { - return Zend_Registry::get('Zend_Translate'); + return \Zend_Registry::get('Zend_Translate'); } public static function isUpdateInProgress() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); return isset($config->updateInProgress) && filter_var($config->updateInProgress, FILTER_VALIDATE_BOOLEAN); } diff --git a/library/Application/Configuration/MaxUploadSize.php b/library/Application/Configuration/MaxUploadSize.php index 63bd55b534..43e1ab490d 100644 --- a/library/Application/Configuration/MaxUploadSize.php +++ b/library/Application/Configuration/MaxUploadSize.php @@ -47,9 +47,9 @@ public function getMaxUploadSizeInKB() public function getMaxUploadSizeInByte() { - $logger = Zend_Registry::get('Zend_Log'); + $logger = \Zend_Registry::get('Zend_Log'); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $maxFileSizeInt = intval($config->publish->maxfilesize); $logger->debug('publish.maxfilesize (Byte) = ' . $maxFileSizeInt); diff --git a/library/Application/Configuration/Module.php b/library/Application/Configuration/Module.php index 18554339ea..9bbeb4b96d 100644 --- a/library/Application/Configuration/Module.php +++ b/library/Application/Configuration/Module.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\UserRole; + /** * Default descriptor for modules. * @@ -99,7 +101,7 @@ public function isRegistered() */ public function isPublic() { - $guest = Opus_UserRole::fetchByName('guest'); + $guest = UserRole::fetchByName('guest'); $guestModules = $guest->listAccessModules(); return in_array($this->getName(), $guestModules); diff --git a/library/Application/Console/Document/DeleteCommand.php b/library/Application/Console/Document/DeleteCommand.php index 7f030a3ebd..865284391e 100644 --- a/library/Application/Console/Document/DeleteCommand.php +++ b/library/Application/Console/Document/DeleteCommand.php @@ -36,6 +36,7 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; use Opus\Console\BaseDocumentCommand; use Opus\Console\Helper\ProgressMatrix; +use Opus\Document; use Opus\Search\Console\Helper\DocumentHelper; /** @@ -148,7 +149,7 @@ protected function deleteDocuments($progress, $docIds, $permanent = false) protected function deleteDocument($docId, $permanent = false) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); if ($permanent) { $doc->deletePermanent(); } else { diff --git a/library/Application/Controller/Action.php b/library/Application/Controller/Action.php index 94ea5b1c39..61b81ab8d3 100644 --- a/library/Application/Controller/Action.php +++ b/library/Application/Controller/Action.php @@ -33,9 +33,8 @@ * @author Felix Ostrowski * @author Sascha Szott * @author Jens schwidder - * @copyright Copyright (c) 2009-2013, OPUS 4 development team + * @copyright Copyright (c) 2009-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Controller_Action extends Application_Controller_ModuleAccess @@ -44,14 +43,14 @@ class Application_Controller_Action extends Application_Controller_ModuleAccess /** * Holds the Redirector Helper. * - * @var Zend_Controller_Action_Helper_Redirector + * @var \Zend_Controller_Action_Helper_Redirector */ private $_redirector = null; /** * Holds the FlashMessenger Helper. * - * @var Zend_Controller_Action_Helper_Messenger + * @var \Zend_Controller_Action_Helper_FlashMessenger */ private $_flashMessenger = null; @@ -95,7 +94,7 @@ protected function _forwardToAction($action) public function moduleAccessDeniedAction() { // we are not allowed to access this module -- but why? - $identity = Zend_Auth::getInstance()->getIdentity(); + $identity = \Zend_Auth::getInstance()->getIdentity(); $errorcode = 'no_identity_error'; if (! empty($identity)) { diff --git a/library/Application/Controller/Action/Helper/Abstract.php b/library/Application/Controller/Action/Helper/Abstract.php index e59af55c3e..9b790a35a1 100644 --- a/library/Application/Controller/Action/Helper/Abstract.php +++ b/library/Application/Controller/Action/Helper/Abstract.php @@ -34,7 +34,7 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -abstract class Application_Controller_Action_Helper_Abstract extends Zend_Controller_Action_Helper_Abstract +abstract class Application_Controller_Action_Helper_Abstract extends \Zend_Controller_Action_Helper_Abstract { use \Opus\LoggingTrait; @@ -48,7 +48,7 @@ abstract class Application_Controller_Action_Helper_Abstract extends Zend_Contro * * NOTE: This helps with unit tests. * - * @return null|Zend_View_Interface + * @return null|\Zend_View_Interface */ public function getView() { diff --git a/library/Application/Controller/Action/Helper/AccessControl.php b/library/Application/Controller/Action/Helper/AccessControl.php index 8a6b8ed690..8ec96bdbcf 100644 --- a/library/Application/Controller/Action/Helper/AccessControl.php +++ b/library/Application/Controller/Action/Helper/AccessControl.php @@ -36,9 +36,10 @@ * * Dieser Helper dient dazu die accessAllowed Funktion in den Controllern zur Verfügung zu stellen. * - * TODO weiter ausbauen und mit Opus_Security_IRealm konsolidieren (Framework vs. Application Security) + * TODO weiter ausbauen und mit Opus\Security\IRealm konsolidieren (Framework vs. Application Security) */ -class Application_Controller_Action_Helper_AccessControl extends Zend_Controller_Action_Helper_Abstract implements Application_Security_AccessControl +class Application_Controller_Action_Helper_AccessControl extends \Zend_Controller_Action_Helper_Abstract + implements Application_Security_AccessControl { private $_acl; @@ -51,7 +52,7 @@ public function direct($resource) /** * Prüft Zugriff auf Ressource. * - * Wenn die Security für OPUS abgeschaltet ist, gibt es kein Opus_Acl Objekt, daher ist in diesem Fall der Zugriff + * Wenn die Security für OPUS abgeschaltet ist, gibt es kein Acl Objekt, daher ist in diesem Fall der Zugriff * erlaubt. * * Wenn die übergebene Ressource NULL ist @@ -81,7 +82,7 @@ public function accessAllowed($resource) protected function getAcl() { if (is_null($this->_acl)) { - $this->_acl = Zend_Registry::isRegistered('Opus_Acl') ? Zend_Registry::get('Opus_Acl') : null; + $this->_acl = \Zend_Registry::isRegistered('Opus_Acl') ? \Zend_Registry::get('Opus_Acl') : null; } return $this->_acl; } diff --git a/library/Application/Controller/Action/Helper/Dates.php b/library/Application/Controller/Action/Helper/Dates.php index e1908e4b56..3dc2756fa4 100644 --- a/library/Application/Controller/Action/Helper/Dates.php +++ b/library/Application/Controller/Action/Helper/Dates.php @@ -29,13 +29,14 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Date; + /** - * Controller helper for handling conversion between Opus_Date and strings. + * Controller helper for handling conversion between Date and strings. */ -class Application_Controller_Action_Helper_Dates extends Zend_Controller_Action_Helper_Abstract +class Application_Controller_Action_Helper_Dates extends \Zend_Controller_Action_Helper_Abstract { /** @@ -74,18 +75,18 @@ public function isValid($datestr) } /** - * Converts string to Opus_Date depending on current language. + * Converts string to Date depending on current language. * @param string $datestr Date string - * @return Opus_Date + * @return Date */ public function getOpusDate($datestr) { if (! is_null($datestr) && $this->isValid($datestr)) { $dateFormat = $this->_validator->getDateFormat(); - $date = new Zend_Date($datestr, $dateFormat); + $date = new \Zend_Date($datestr, $dateFormat); - $dateModel = new Opus_Date($date); + $dateModel = new Date($date); return $dateModel; } else { // TODO throw exception @@ -94,9 +95,9 @@ public function getOpusDate($datestr) } /** - * Converts Opus_Date into string depending on current language. - * @param Opus_Date $date Date - * @return Date string for current language + * Converts Date into string depending on current language. + * @param Date $date Date + * @return string Date string for current language */ public function getDateString($date) { diff --git a/library/Application/Controller/Action/Helper/DocumentTypes.php b/library/Application/Controller/Action/Helper/DocumentTypes.php index caba0641e4..b5b8633b73 100644 --- a/library/Application/Controller/Action/Helper/DocumentTypes.php +++ b/library/Application/Controller/Action/Helper/DocumentTypes.php @@ -30,14 +30,13 @@ * @author Michael Lang * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Helper class for getting document types and template names. * */ -class Application_Controller_Action_Helper_DocumentTypes extends Zend_Controller_Action_Helper_Abstract +class Application_Controller_Action_Helper_DocumentTypes extends \Zend_Controller_Action_Helper_Abstract { /** @@ -76,7 +75,7 @@ class Application_Controller_Action_Helper_DocumentTypes extends Zend_Controller */ public function __construct() { - $this->_config = Zend_Registry::get('Zend_Config'); + $this->_config = \Zend_Registry::get('Zend_Config'); } /** @@ -142,7 +141,7 @@ public function isValid($documentType) * Returns DOMDocument for document type. * * @param string $documentType - * @return DOMDocument + * @return \DOMDocument * @throws Application_Exception if invalid documentType passed. */ public function getDocument($documentType) @@ -151,7 +150,7 @@ public function getDocument($documentType) throw new Application_Exception('Unable to load invalid document type "' . $documentType . '"'); } - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->load($this->getPathForDocumentType($documentType)); // clear libxml error buffer and enable user error handling @@ -208,7 +207,7 @@ public function getTemplates() $path = $this->_config->publish->path->documenttemplates; - if ($path instanceof Zend_Config) { + if ($path instanceof \Zend_Config) { $path = $path->toArray(); } @@ -266,7 +265,7 @@ public function getDocTypesPath() throw new Application_Exception('Path to document types not configured.'); } - if ($path instanceof Zend_Config) { + if ($path instanceof \Zend_Config) { return $path->toArray(); } else { return $path; @@ -402,7 +401,7 @@ public function validate($documentType) if (is_null($this->_errors)) { $this->_errors = []; } - $domDoc = new DOMDocument(); + $domDoc = new \DOMDocument(); $domDoc->load($this->getPathForDocumentType($documentType)); libxml_clear_errors(); @@ -411,7 +410,7 @@ public function validate($documentType) try { $isValid = $domDoc->schemaValidate($this->getXmlSchemaPath()); $this->_errors[$documentType] = libxml_get_errors(); - } catch (Exception $e) { + } catch (\Exception $e) { $this->_errors[$documentType] = $e->getMessage(); return 0; } @@ -435,7 +434,7 @@ public function getErrors() */ public function getXmlSchemaPath() { - $reflector = new ReflectionClass('Opus_Document'); + $reflector = new \ReflectionClass('Opus\Document'); return dirname($reflector->getFileName()) . DIRECTORY_SEPARATOR . 'Document' . DIRECTORY_SEPARATOR . 'documenttype.xsd'; } diff --git a/library/Application/Controller/Action/Helper/Documents.php b/library/Application/Controller/Action/Helper/Documents.php index aa6e90f68f..5f00a2ab3f 100644 --- a/library/Application/Controller/Action/Helper/Documents.php +++ b/library/Application/Controller/Action/Helper/Documents.php @@ -1,5 +1,4 @@ * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Model\NotFoundException; + /** * Helper for getting a list of document IDs used by admin and review module. */ -class Application_Controller_Action_Helper_Documents extends Zend_Controller_Action_Helper_Abstract +class Application_Controller_Action_Helper_Documents extends \Zend_Controller_Action_Helper_Abstract { /** @@ -53,9 +55,9 @@ public function direct($sortOrder = null, $sortReverse = 0, $state = 'published' } /** - * Returns Opus_Document for provided ID or throws exception. + * Returns Document for provided ID or throws exception. * @param string $docId Document identifier - * @return Opus_Document + * @return Document */ public function getDocumentForId($docId) { @@ -65,8 +67,8 @@ public function getDocumentForId($docId) } try { - $doc = new Opus_Document($docId); - } catch (Opus_Model_NotFoundException $omnfe) { + $doc = Document::get($docId); + } catch (NotFoundException $omnfe) { return null; } @@ -85,7 +87,7 @@ public function getDocumentForId($docId) */ public function getSortedDocumentIds($sortOrder = null, $sortReverse = true, $state = null) { - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); if (! is_null($state) && $state !== 'all') { $finder->setServerState($state); diff --git a/library/Application/Controller/Action/Helper/Files.php b/library/Application/Controller/Action/Helper/Files.php index 3604a2220d..632bc371b8 100644 --- a/library/Application/Controller/Action/Helper/Files.php +++ b/library/Application/Controller/Action/Helper/Files.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -39,7 +38,7 @@ * * TODO implement as Controller Helper (nicht soviel static) */ -class Application_Controller_Action_Helper_Files extends Zend_Controller_Action_Helper_Abstract +class Application_Controller_Action_Helper_Files extends \Zend_Controller_Action_Helper_Abstract { /** @@ -74,7 +73,7 @@ public function listFiles($folder, $ignoreAllowedTypes = false) private function getAllowedFileTypes() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (! isset($config->publish->filetypes->allowed)) { return null; @@ -87,7 +86,7 @@ private function getAllowedFileTypes() private function checkFile($file, $ignoreAllowedTypes) { - $log = Zend_Registry::get('Zend_Log'); + $log = \Zend_Registry::get('Zend_Log'); $logMessage = 'check for file: ' . $file->getPathname(); if (! $ignoreAllowedTypes) { diff --git a/library/Application/Controller/Action/Helper/MainMenu.php b/library/Application/Controller/Action/Helper/MainMenu.php index da0248e000..7dd53036fd 100644 --- a/library/Application/Controller/Action/Helper/MainMenu.php +++ b/library/Application/Controller/Action/Helper/MainMenu.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -41,7 +40,7 @@ * Zend_Controller_Action_HelperBroker::getStaticHelper('MainMenu')->setActive('home'); * {code} */ -class Application_Controller_Action_Helper_MainMenu extends Zend_Controller_Action_Helper_Abstract +class Application_Controller_Action_Helper_MainMenu extends \Zend_Controller_Action_Helper_Abstract { /** @@ -64,7 +63,7 @@ public function direct($entry) */ public function setActive($entry) { - $mainMenu = Zend_Registry::get('Opus_Navigation'); + $mainMenu = \Zend_Registry::get('Opus_Navigation'); foreach ($mainMenu as $page) { $label = $page->getLabel(); diff --git a/library/Application/Controller/Action/Helper/Redirector.php b/library/Application/Controller/Action/Helper/Redirector.php index 4654c45610..8e778be223 100644 --- a/library/Application/Controller/Action/Helper/Redirector.php +++ b/library/Application/Controller/Action/Helper/Redirector.php @@ -31,7 +31,7 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Controller_Action_Helper_Redirector extends Zend_Controller_Action_Helper_Redirector +class Application_Controller_Action_Helper_Redirector extends \Zend_Controller_Action_Helper_Redirector { use \Opus\LoggingTrait; @@ -42,7 +42,7 @@ public function init() { parent::init(); - $this->_flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger'); + $this->_flashMessenger = \Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger'); } /** @@ -156,7 +156,7 @@ public function performRedirect( $anchor = '#' . $params['anchor']; unset($params['anchor']); - $urlHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('url'); + $urlHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('url'); $gotoUrl = $urlHelper->url(array_merge([ 'action' => $action, 'controller' => $controller, 'module' => $module diff --git a/library/Application/Controller/Action/Helper/RenderForm.php b/library/Application/Controller/Action/Helper/RenderForm.php index cc08aa7d1e..a6995706fa 100644 --- a/library/Application/Controller/Action/Helper/RenderForm.php +++ b/library/Application/Controller/Action/Helper/RenderForm.php @@ -31,7 +31,7 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Controller_Action_Helper_RenderForm extends Zend_Controller_Action_Helper_Abstract +class Application_Controller_Action_Helper_RenderForm extends \Zend_Controller_Action_Helper_Abstract { public function direct($form) diff --git a/library/Application/Controller/Action/Helper/ReturnParams.php b/library/Application/Controller/Action/Helper/ReturnParams.php index e60508887b..bf34b260ea 100644 --- a/library/Application/Controller/Action/Helper/ReturnParams.php +++ b/library/Application/Controller/Action/Helper/ReturnParams.php @@ -28,7 +28,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -38,7 +37,7 @@ * * It is used by the LoginBar and the init.php files. */ -class Application_Controller_Action_Helper_ReturnParams extends Zend_Controller_Action_Helper_Abstract +class Application_Controller_Action_Helper_ReturnParams extends \Zend_Controller_Action_Helper_Abstract { /** @@ -49,10 +48,10 @@ class Application_Controller_Action_Helper_ReturnParams extends Zend_Controller_ public function getReturnParameters() { // TODO put into constructor - $log = Zend_Registry::get('Zend_Log'); + $log = \Zend_Registry::get('Zend_Log'); $params = []; - foreach (Zend_Controller_Front::getInstance()->getRequest()->getUserParams() as $key => $value) { + foreach (\Zend_Controller_Front::getInstance()->getRequest()->getUserParams() as $key => $value) { switch ($key) { case 'module': $params['rmodule'] = $value; @@ -82,7 +81,7 @@ public function getReturnParameters() } else { // ignore array values // TODO when do these values occur? - $output = Zend_Debug::dump($value, null, false); + $output = \Zend_Debug::dump($value, null, false); $log->debug("Login array param ignored: $key -> $output"); } break; diff --git a/library/Application/Controller/Action/Helper/SendFile.php b/library/Application/Controller/Action/Helper/SendFile.php index 006a486ea9..41649fb44e 100644 --- a/library/Application/Controller/Action/Helper/SendFile.php +++ b/library/Application/Controller/Action/Helper/SendFile.php @@ -61,12 +61,12 @@ public function sendFile($file, $method = self::FPASSTHRU, $mustResend = false) { $response = $this->getResponse(); if (! $response->canSendHeaders()) { - throw new Exception("Cannot send headers"); + throw new \Exception("Cannot send headers"); } $file = realpath($file); if (! is_readable($file)) { - throw new Exception("File is not readable"); + throw new \Exception("File is not readable"); } $modified = filemtime($file); diff --git a/library/Application/Controller/Action/Helper/Translation.php b/library/Application/Controller/Action/Helper/Translation.php index a40b0f5aec..61d777a4d5 100644 --- a/library/Application/Controller/Action/Helper/Translation.php +++ b/library/Application/Controller/Action/Helper/Translation.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -38,7 +37,7 @@ * This class keeps some of the special code generating translation keys out of * the controllers and view scripts. */ -class Application_Controller_Action_Helper_Translation extends Zend_Controller_Action_Helper_Abstract +class Application_Controller_Action_Helper_Translation extends \Zend_Controller_Action_Helper_Abstract { /** @@ -60,20 +59,22 @@ public function direct($modelName, $fieldName, $value) * @param string $fieldName * @param string $value * @return string Translation key + * + * TODO NAMESPACE translations depend on class names */ public function getKeyForValue($modelName, $fieldName, $value) { - // The 'Type' and the 'Language' field of Opus_Document currently need + // The 'Type' and the 'Language' field of Document currently need // to be handled separately, since their key don't have a prefix. - if ($modelName === 'Opus_Document' + if ($modelName === 'Opus\Document' && ($fieldName === 'Language' || $fieldName === 'Type' || $fieldName === 'PublicationState')) { return $value; - } elseif ($modelName === 'Opus_Enrichment' && $fieldName === 'KeyName') { + } elseif ($modelName === 'Opus\Enrichment' && $fieldName === 'KeyName') { return $value; } else { - return $modelName . '_' . $fieldName . '_Value_' . ucfirst($value); + return $this->normalizeModelName($modelName) . '_' . $fieldName . '_Value_' . ucfirst($value); } } @@ -90,14 +91,19 @@ public function getKeyForValue($modelName, $fieldName, $value) public function getKeyForField($modelName, $fieldName) { if ($fieldName === 'Type') { - return $modelName . '_' . $fieldName; + return $this->normalizeModelName($modelName) . '_' . $fieldName; } else { switch ($modelName) { - case 'Opus_Language': - return $modelName . '_' . $fieldName; + case 'Opus\Language': + return $this->normalizeModelName($modelName) . '_' . $fieldName; default: return $fieldName; } } } + + protected function normalizeModelName($name) + { + return preg_replace('/\\\\/', '_', $name); + } } diff --git a/library/Application/Controller/Action/Helper/Version.php b/library/Application/Controller/Action/Helper/Version.php index 9564c6345e..697f441e25 100644 --- a/library/Application/Controller/Action/Helper/Version.php +++ b/library/Application/Controller/Action/Helper/Version.php @@ -34,7 +34,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Controller_Action_Helper_Version extends Application_Controller_Action_Helper_Abstract { @@ -71,7 +70,7 @@ public function setVersion($version) */ public function getLatestReleaseFromServer() { - $latestUrl = Zend_Registry::get('Zend_Config')->update->latestVersionCheckUrl; + $latestUrl = \Zend_Registry::get('Zend_Config')->update->latestVersionCheckUrl; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); diff --git a/library/Application/Controller/Action/Helper/Workflow.php b/library/Application/Controller/Action/Helper/Workflow.php index ec6efc616e..6f3e0d9d01 100644 --- a/library/Application/Controller/Action/Helper/Workflow.php +++ b/library/Application/Controller/Action/Helper/Workflow.php @@ -31,12 +31,14 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Controller helper for providing workflow support. * * Implementiert den Workflow ohne Einschränkungen durch Rollen. */ -class Application_Controller_Action_Helper_Workflow extends Zend_Controller_Action_Helper_Abstract +class Application_Controller_Action_Helper_Workflow extends \Zend_Controller_Action_Helper_Abstract { /** @@ -49,7 +51,7 @@ class Application_Controller_Action_Helper_Workflow extends Zend_Controller_Acti /** * Gets called when helper is used like method of the broker. - * @param Opus_Document $document + * @param Document $document * @return array of strings - Allowed target states for document */ public function direct($document) @@ -71,7 +73,7 @@ public function isValidState($state) /** * Returns true if a transition is allowed for a document. - * @param Opus_Document $document + * @param Document $document * @param string $targetState * @return boolean - True only if transition is allowed */ @@ -84,12 +86,12 @@ public function isTransitionAllowed($document, $targetState) /** * Returns all allowed target states for a document. - * @param Opus_Document $document + * @param Document $document * @return array of strings - Possible target states for document */ public function getAllowedTargetStatesForDocument($document) { - $logger = Zend_Registry::get('Zend_Log'); + $logger = \Zend_Registry::get('Zend_Log'); $currentState = $document->getServerState(); @@ -105,7 +107,7 @@ public function getAllowedTargetStatesForDocument($document) foreach ($targetStates as $targetState) { $resource = 'workflow_' . $currentState . '_' . $targetState; - if (! $acl->has(new Zend_Acl_Resource($resource)) || $acl->isAllowed( + if (! $acl->has(new \Zend_Acl_Resource($resource)) || $acl->isAllowed( Application_Security_AclProvider::ACTIVE_ROLE, $resource )) { @@ -147,7 +149,7 @@ public static function getTargetStates($currentState) /** * Performs state change on document. - * @param Opus_Document $document + * @param Document $document * @param string $targetState * * TODO enforcing permissions and throwing exceptions (OPUSVIER-1959) @@ -207,7 +209,7 @@ public static function getWorkflowResources() public static function getWorkflowConfig() { if (empty(Application_Controller_Action_Helper_Workflow::$_workflowConfig)) { - Application_Controller_Action_Helper_Workflow::$_workflowConfig = new Zend_Config_Ini( + Application_Controller_Action_Helper_Workflow::$_workflowConfig = new \Zend_Config_Ini( APPLICATION_PATH . '/modules/admin/models/workflow.ini' ); } @@ -222,7 +224,7 @@ public static function getWorkflowConfig() public function getAcl() { if (is_null($this->_acl)) { - $this->_acl = Zend_Registry::isRegistered('Opus_Acl') ? Zend_Registry::get('Opus_Acl') : null; + $this->_acl = \Zend_Registry::isRegistered('Opus_Acl') ? \Zend_Registry::get('Opus_Acl') : null; } return $this->_acl; } diff --git a/library/Application/Controller/ActionCRUD.php b/library/Application/Controller/ActionCRUD.php index 18b5e81ab7..1c01e54a7b 100644 --- a/library/Application/Controller/ActionCRUD.php +++ b/library/Application/Controller/ActionCRUD.php @@ -124,7 +124,7 @@ class Application_Controller_ActionCRUD extends Application_Controller_Action /** * Klasse für OPUS Model. - * @var \Opus_Model_Abstract + * @var \Opus\Model\AbstractModel */ private $_modelClass = null; @@ -317,7 +317,7 @@ public function handleModelPost($post = null) try { $model->store(); - } catch (Opus_Model_Exception $ome) { + } catch (\Opus\Model\ModelException $ome) { // Speichern fehlgeschlagen return ['message' => self::SAVE_FAILURE]; } @@ -378,7 +378,7 @@ public function handleConfirmationPost($post = null) // Model löschen try { $this->deleteModel($model); - } catch (Opus_Model_Exception $ome) { + } catch (\Opus\Model\ModelException $ome) { $this->getLogger()->err(__METHOD__ . ' ' . $ome->getMessage()); return ['message' => self::DELETE_FAILURE]; } @@ -414,7 +414,7 @@ protected function renderResult($result) $this->_helper->Redirector->redirectTo($action, $message, null, null, $params); } else { // Ergebnis ist Formular - if (! is_null($result) && $result instanceof Zend_Form) { + if (! is_null($result) && $result instanceof \Zend_Form) { $this->renderForm($result); } } @@ -425,7 +425,7 @@ protected function renderResult($result) * * Die Funktion kann überschrieben werden, falls spezielle Schritte beim Löschen notwendig sind. * - * @param $model \Opus_Model_Abstract + * @param $model \Opus\Model\AbstractModel */ protected function deleteModel($model) { @@ -463,7 +463,7 @@ public function createCannotBeDeletedResult() * * Das Bestätigunsformular ohne Model wird für die Validierung verwendet. * - * @param Opus_Model_AbstractDb $model + * @param \Opus\Model\AbstractDb $model * @return Application_Form_Confirmation */ public function getConfirmationForm($model = null) @@ -512,7 +512,7 @@ public function getModel($modelId) if (strlen(trim($modelId)) !== 0) { try { return new $modelClass($modelId); - } catch (Opus_Model_NotFoundException $omnfe) { + } catch (\Opus\Model\NotFoundException $omnfe) { $this->getLogger()->err(__METHOD__ . ':' . $omnfe->getMessage()); } } @@ -585,7 +585,7 @@ public function setFormClass($formClass) /** * Liefert die Model-Klasse die verwaltet wird. - * @return null|Opus_Model_Abstract + * @return null|\Opus\Model\AbstractModel */ public function getModelClass() { @@ -627,7 +627,7 @@ public function setMessages($messages) /** * Liefert die Nachricht für den Schlüssel. - * @param $key Nachrichtenschlüssel + * @param $key string Nachrichtenschlüssel * @return null|string */ public function getMessage($key) diff --git a/library/Application/Controller/MessageTemplates.php b/library/Application/Controller/MessageTemplates.php index c41fb93100..ff5c4ee7ec 100644 --- a/library/Application/Controller/MessageTemplates.php +++ b/library/Application/Controller/MessageTemplates.php @@ -37,7 +37,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Controller_MessageTemplates { diff --git a/library/Application/Controller/ModuleAccess.php b/library/Application/Controller/ModuleAccess.php index 6124b116da..0999828edd 100644 --- a/library/Application/Controller/ModuleAccess.php +++ b/library/Application/Controller/ModuleAccess.php @@ -39,7 +39,7 @@ * @category Application * @package Controller */ -class Application_Controller_ModuleAccess extends Zend_Controller_Action +class Application_Controller_ModuleAccess extends \Zend_Controller_Action { use \Opus\LoggingTrait; @@ -48,7 +48,7 @@ class Application_Controller_ModuleAccess extends Zend_Controller_Action /** * Konfigurationsobjekt. - * @var Zend_Config + * @var \Zend_Config */ private $_config = null; @@ -88,7 +88,7 @@ protected function checkAccessModulePermissions() $logger->debug("starting authorization check for module '$module'"); - $realm = Opus_Security_Realm::getInstance(); + $realm = \Opus\Security\Realm::getInstance(); if (! $realm->skipSecurityChecks()) { // Check, if the user has accesss to the module... @@ -161,12 +161,12 @@ protected function findResourceForPage($activePage) { $resource = null; - if ($activePage instanceof Zend_Navigation_Page) { + if ($activePage instanceof \Zend_Navigation_Page) { $resource = $activePage->getResource(); $page = $activePage->getParent(); - while (! is_null($page) && $page instanceof Zend_Navigation_Page && is_null($resource)) { + while (! is_null($page) && $page instanceof \Zend_Navigation_Page && is_null($resource)) { $resource = $page->getResource(); $page = $page->getParent(); } diff --git a/library/Application/Controller/Plugin/LoadTranslation.php b/library/Application/Controller/Plugin/LoadTranslation.php index 23fc95d4ad..21dfb563ab 100644 --- a/library/Application/Controller/Plugin/LoadTranslation.php +++ b/library/Application/Controller/Plugin/LoadTranslation.php @@ -37,22 +37,22 @@ * Loads languages from modules. When registered as FrontController plugin * it hooks into dispatchLoopStartup(). */ -class Application_Controller_Plugin_LoadTranslation extends Zend_Controller_Plugin_Abstract +class Application_Controller_Plugin_LoadTranslation extends \Zend_Controller_Plugin_Abstract { /** * Hooks into preDispatch to setup include path for every request. * - * @param Zend_Controller_Request_Abstract $request The request passed to the FrontController. + * @param \Zend_Controller_Request_Abstract $request The request passed to the FrontController. * @return void */ - public function preDispatch(Zend_Controller_Request_Abstract $request) + public function preDispatch(\Zend_Controller_Request_Abstract $request) { $currentModule = $request->getModuleName(); // Add translation - if ($currentModule !== 'default' && Zend_Registry::isRegistered(Application_Translate::REGISTRY_KEY)) { - Zend_Registry::get(Application_Translate::REGISTRY_KEY)->loadModule($currentModule); + if ($currentModule !== 'default' && \Zend_Registry::isRegistered(Application_Translate::REGISTRY_KEY)) { + \Zend_Registry::get(Application_Translate::REGISTRY_KEY)->loadModule($currentModule); } } } diff --git a/library/Application/Controller/Plugin/Navigation.php b/library/Application/Controller/Plugin/Navigation.php index 7892a7d83e..20e12ac018 100644 --- a/library/Application/Controller/Plugin/Navigation.php +++ b/library/Application/Controller/Plugin/Navigation.php @@ -29,7 +29,6 @@ * @author Thoralf Klein * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -38,27 +37,27 @@ * @category Application * @package Controller */ -class Application_Controller_Plugin_Navigation extends Zend_Controller_Plugin_Abstract +class Application_Controller_Plugin_Navigation extends \Zend_Controller_Plugin_Abstract { /** - * Set up Opus_Navigation. + * Set up Navigation. * - * @param Zend_Controller_Request_Abstract $request The current request. + * @param \Zend_Controller_Request_Abstract $request The current request. * @return void */ - public function routeStartup(Zend_Controller_Request_Abstract $request) + public function routeStartup(\Zend_Controller_Request_Abstract $request) { // Hide menu entries based on privileges - $navigation = Zend_Registry::get('Opus_Navigation'); + $navigation = \Zend_Registry::get('Opus_Navigation'); if (empty($navigation)) { return; } // Create a Realm instance. - $realm = Opus_Security_Realm::getInstance(); + $realm = \Opus\Security\Realm::getInstance(); // Der folgende Code sorgt dafür, daß für Nutzer mit Zugriff auf das 'admin' und das 'review' Modul der Link // zu den Review Seiten in der Administration angezeigt wird. diff --git a/library/Application/Controller/Plugin/SecurityRealm.php b/library/Application/Controller/Plugin/SecurityRealm.php index c8898a2ba6..9d910cb8de 100644 --- a/library/Application/Controller/Plugin/SecurityRealm.php +++ b/library/Application/Controller/Plugin/SecurityRealm.php @@ -1,5 +1,4 @@ setUser(null); $realm->setIp(null); // Overwrite default user if current user is logged on. - $auth = Zend_Auth::getInstance(); + $auth = \Zend_Auth::getInstance(); $identity = $auth->getIdentity(); if (false === empty($identity)) { try { $realm->setUser($identity); - } catch (Opus_Security_Exception $e) { + } catch (SecurityException $e) { // unknown account -> clean identity (e.g. session of deleted user - OPUSVIER-3214) $auth->clearIdentity(); - } catch (Exception $e) { + } catch (\Exception $e) { // unexpected exception -> clear identity and throw $auth->clearIdentity(); - throw new Exception($e); + throw new \Exception($e); } } @@ -95,7 +96,7 @@ public function __construct($groups = []) private function getModuleMemberName($moduleName) { - $member = Zend_Auth_Storage_Session::MEMBER_DEFAULT; + $member = \Zend_Auth_Storage_Session::MEMBER_DEFAULT; // try to find group of module foreach ($this->groups as $id => $modules) { if (in_array($moduleName, $modules)) { @@ -107,11 +108,11 @@ private function getModuleMemberName($moduleName) return $member; } - public function preDispatch(Zend_Controller_Request_Abstract $request) + public function preDispatch(\Zend_Controller_Request_Abstract $request) { - $namespace = Zend_Auth_Storage_Session::NAMESPACE_DEFAULT; + $namespace = \Zend_Auth_Storage_Session::NAMESPACE_DEFAULT; $member = $this->getModuleMemberName($request->getModuleName()); - $storage = new Zend_Auth_Storage_Session($namespace, $member); - Zend_Auth::getInstance()->setStorage($storage); + $storage = new \Zend_Auth_Storage_Session($namespace, $member); + \Zend_Auth::getInstance()->setStorage($storage); } } diff --git a/library/Application/Controller/Plugin/ViewSetup.php b/library/Application/Controller/Plugin/ViewSetup.php index 75e2a6aff6..fa7cc5191d 100644 --- a/library/Application/Controller/Plugin/ViewSetup.php +++ b/library/Application/Controller/Plugin/ViewSetup.php @@ -29,7 +29,6 @@ * @author Gunar Maiwald (maiwald@zib.de) * @copyright Copyright (c) 2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -39,12 +38,12 @@ * */ -class Application_Controller_Plugin_ViewSetup extends Zend_Controller_Plugin_Abstract +class Application_Controller_Plugin_ViewSetup extends \Zend_Controller_Plugin_Abstract { - public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) + public function dispatchLoopStartup(\Zend_Controller_Request_Abstract $request) { - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); + $viewRenderer = \Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $viewRenderer->init(); // set up variables that the view want to know diff --git a/library/Application/Controller/Route/Redirect.php b/library/Application/Controller/Route/Redirect.php index 763f8ecf54..2c84c07592 100644 --- a/library/Application/Controller/Route/Redirect.php +++ b/library/Application/Controller/Route/Redirect.php @@ -34,13 +34,13 @@ /** * Route for automatic redirect for matching route. */ -class Application_Controller_Route_Redirect extends Zend_Controller_Router_Route_Regex +class Application_Controller_Route_Redirect extends \Zend_Controller_Router_Route_Regex { public function match($path, $partial = false) { if ($route = parent::match($path, $partial)) { - $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); + $helper = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $helper->setCode(301); $helper->gotoRoute($route); } diff --git a/library/Application/Controller/Xml.php b/library/Application/Controller/Xml.php index 3b7a0d2f99..2134896b5c 100644 --- a/library/Application/Controller/Xml.php +++ b/library/Application/Controller/Xml.php @@ -30,7 +30,6 @@ * @author Felix Ostrowski * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -45,21 +44,21 @@ class Application_Controller_Xml extends Application_Controller_ModuleAccess /** * Holds xml representation of document information to be processed. * - * @var DomDocument Defaults to null. + * @var \DomDocument Defaults to null. */ protected $_xml = null; /** * Holds the stylesheet for the transformation. * - * @var DomDocument Defaults to null. + * @var \DomDocument Defaults to null. */ protected $_xslt = null; /** * Holds the xslt processor. * - * @var XSLTProcessor Defaults to null. + * @var \XSLTProcessor Defaults to null. */ protected $_proc = null; @@ -74,8 +73,8 @@ public function init() $this->disableViewRendering(); // Initialize member variables. - $this->_xml = new DomDocument; - $this->_proc = new XSLTProcessor; + $this->_xml = new \DomDocument; + $this->_proc = new \XSLTProcessor; } /** @@ -104,7 +103,7 @@ public function postDispatch() */ protected function loadStyleSheet($stylesheet) { - $this->_xslt = new DomDocument; + $this->_xslt = new \DomDocument; $this->_xslt->load($stylesheet); $this->_proc->importStyleSheet($this->_xslt); if (isset($_SERVER['HTTP_HOST'])) { diff --git a/library/Application/Data/SubjectProvider.php b/library/Application/Data/SubjectProvider.php index fdb74305ac..bcee5a6988 100644 --- a/library/Application/Data/SubjectProvider.php +++ b/library/Application/Data/SubjectProvider.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Subject; + class Application_Data_SubjectProvider { @@ -46,6 +48,6 @@ class Application_Data_SubjectProvider */ public function getValues($term) { - return Opus_Subject::getMatchingSubjects($term); + return Subject::getMatchingSubjects($term); } } diff --git a/library/Application/Exception.php b/library/Application/Exception.php index 345858eb9c..7fbb15eeea 100644 --- a/library/Application/Exception.php +++ b/library/Application/Exception.php @@ -29,10 +29,14 @@ * @author Julian Heise * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_Exception extends Exception +/** + * Class Application_Exception + * + * TODO NAMESPACE change name + */ +class Application_Exception extends \Exception { protected $_httpResponseCode = null; diff --git a/library/Application/Export/ExportPlugin.php b/library/Application/Export/ExportPlugin.php index 4f1a9d460e..6639704911 100644 --- a/library/Application/Export/ExportPlugin.php +++ b/library/Application/Export/ExportPlugin.php @@ -49,27 +49,27 @@ public function getName(); /** * Sets the plugin configuration. - * @param Zend_Config $config + * @param \Zend_Config $config */ - public function setConfig(Zend_Config $config = null); + public function setConfig(\Zend_Config $config = null); /** * Sets the HTTP request being processed. - * @param Zend_Controller_Request_Http $request + * @param \Zend_Controller_Request_Http $request */ - public function setRequest(Zend_Controller_Request_Http $request); + public function setRequest(\Zend_Controller_Request_Http $request); /** * Sets the HTTP response. - * @param Zend_Controller_Response_Http $response + * @param \Zend_Controller_Response_Http $response */ - public function setResponse(Zend_Controller_Response_Http $response); + public function setResponse(\Zend_Controller_Response_Http $response); /** * Sets the view objekt for rendering the response. - * @param Zend_View $view + * @param \Zend_View $view */ - public function setView(Zend_View $view); + public function setView(\Zend_View $view); /** * Main function performing export. diff --git a/library/Application/Export/ExportPluginAbstract.php b/library/Application/Export/ExportPluginAbstract.php index 0951a8b3ca..b448dadd5c 100644 --- a/library/Application/Export/ExportPluginAbstract.php +++ b/library/Application/Export/ExportPluginAbstract.php @@ -46,17 +46,17 @@ abstract class Application_Export_ExportPluginAbstract extends Application_Model private $_name; /** - * @var Zend_Controller_Request_Http Current request. + * @var \Zend_Controller_Request_Http Current request. */ private $_request; /** - * @var Zend_Controller_Response_Http Response object. + * @var \Zend_Controller_Response_Http Response object. */ private $_response; /** - * @var Zend_View View object for rendering response. + * @var \Zend_View View object for rendering response. */ private $_view; @@ -80,7 +80,7 @@ public function setName($name) /** * Returns request object. - * @return Zend_Controller_Request_Http + * @return \Zend_Controller_Request_Http */ public function getRequest() { @@ -89,16 +89,16 @@ public function getRequest() /** * Sets request object. - * @param Zend_Controller_Request_Http $request + * @param \Zend_Controller_Request_Http $request */ - public function setRequest(Zend_Controller_Request_Http $request) + public function setRequest(\Zend_Controller_Request_Http $request) { $this->_request = $request; } /** * Returns response object. - * @return Zend_Controller_Response_Http + * @return \Zend_Controller_Response_Http */ public function getResponse() { @@ -107,16 +107,16 @@ public function getResponse() /** * Sets response object. - * @param Zend_Controller_Response_Http $response + * @param \Zend_Controller_Response_Http $response */ - public function setResponse(Zend_Controller_Response_Http $response) + public function setResponse(\Zend_Controller_Response_Http $response) { $this->_response = $response; } /** * Returns view object. - * @return Zend_View + * @return \Zend_View */ public function getView() { @@ -125,9 +125,9 @@ public function getView() /** * Sets view object. - * @param Zend_View $view + * @param \Zend_View $view */ - public function setView(Zend_View $view) + public function setView(\Zend_View $view) { $this->_view = $view; } @@ -136,13 +136,13 @@ public function setView(Zend_View $view) * Checks if access is restricted to adminstrators. * * @return bool true if access is restricted, otherwise false - * @throws Zend_Exception + * @throws \Zend_Exception */ public function isAccessRestricted() { if (isset($this->getConfig()->adminOnly) && filter_var($this->getConfig()->adminOnly, FILTER_VALIDATE_BOOLEAN)) { - return ! Opus_Security_Realm::getInstance()->checkModule('admin'); + return ! \Opus\Security\Realm::getInstance()->checkModule('admin'); } return false; // keine Einschränkung des Zugriffs } @@ -162,7 +162,7 @@ abstract public function execute(); */ public function isAllowExportOfUnpublishedDocs() { - $accessControl = Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); + $accessControl = \Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); if (is_null($accessControl)) { return false; } diff --git a/library/Application/Export/ExportService.php b/library/Application/Export/ExportService.php index 46b1a92693..7aae8d3476 100644 --- a/library/Application/Export/ExportService.php +++ b/library/Application/Export/ExportService.php @@ -123,7 +123,7 @@ public function setDefaults($config) /** * Returns default parameters for plugins. * - * @return array|Zend_Config + * @return array|\Zend_Config */ public function getDefaults() { @@ -133,7 +133,7 @@ public function getDefaults() if (isset($config->plugins->export->default)) { $this->_defaults = $config->plugins->export->default; } else { - $this->_defaults = new Zend_Config([]); + $this->_defaults = new \Zend_Config([]); } } diff --git a/library/Application/Export/Exporter.php b/library/Application/Export/Exporter.php index 090d73322c..4d82329ce2 100644 --- a/library/Application/Export/Exporter.php +++ b/library/Application/Export/Exporter.php @@ -47,7 +47,7 @@ public function addFormats($options) foreach ($options as $key => $option) { // TODO use addFormat function, get key from 'name' or use hash? - $format = new Zend_Navigation_Page_Mvc($option); + $format = new \Zend_Navigation_Page_Mvc($option); // TODO check if key is string $this->_formats[$key] = $format; @@ -73,7 +73,7 @@ public function getAllowedFormats() foreach ($formats as $format) { $module = $format->getModule(); - if (Opus_Security_Realm::getInstance()->checkModule($module)) { + if (\Opus\Security\Realm::getInstance()->checkModule($module)) { $allowed[] = $format; } } diff --git a/library/Application/Form/Abstract.php b/library/Application/Form/Abstract.php index 98b7ef3340..b3f08051df 100644 --- a/library/Application/Form/Abstract.php +++ b/library/Application/Form/Abstract.php @@ -34,7 +34,7 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -abstract class Application_Form_Abstract extends Zend_Form_SubForm +abstract class Application_Form_Abstract extends \Zend_Form_SubForm { use \Opus\LoggingTrait; @@ -64,7 +64,7 @@ public function init() { parent::init(); - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); // $this->addElementPrefixPath('Form_Decorator', 'Form/Decorator', Zend_Form::DECORATOR); $this->addPrefixPath('Form', 'Form'); // '_Element' wird anscheinend automatisch dran gehängt $this->addPrefixPath('Application_Form', 'Application/Form'); @@ -88,8 +88,8 @@ public function getElementValue($name) if (! is_null($element)) { $value = $element->getValue(); - if ($element instanceof Zend_Form_Element_Text || $element instanceof Zend_Form_Element_Textarea - || $element instanceof Zend_Form_Element_Hidden) { + if ($element instanceof \Zend_Form_Element_Text || $element instanceof \Zend_Form_Element_Textarea + || $element instanceof \Zend_Form_Element_Hidden) { return (trim($value) === '') ? null : $value; } else { return $value; @@ -139,7 +139,7 @@ protected function applyCustomMessages($element) if ($element->isRequired()) { // wenn Validator 'notEmpty' bereits gesetzt ist; nicht modifizieren if (! $element->getValidator('notEmpty') && $element->autoInsertNotEmptyValidator()) { - $notEmptyValidator = new Zend_Validate_NotEmpty(); + $notEmptyValidator = new \Zend_Validate_NotEmpty(); $notEmptyValidator->setMessage('admin_validate_error_notempty'); $element->addValidator($notEmptyValidator); } @@ -190,7 +190,7 @@ public function setLabelPrefix($prefix) public function getApplicationConfig() { if (is_null($this->_config)) { - $this->_config = Zend_Registry::get('Zend_Config'); + $this->_config = \Zend_Registry::get('Zend_Config'); } return $this->_config; diff --git a/library/Application/Form/AbstractViewable.php b/library/Application/Form/AbstractViewable.php index fc9d9a0392..1a1702b907 100644 --- a/library/Application/Form/AbstractViewable.php +++ b/library/Application/Form/AbstractViewable.php @@ -108,8 +108,8 @@ protected function _removeElements() foreach ($elements as $element) { $value = $element->getValue(); - if ($element instanceof Zend_Form_Element_Button - || $element instanceof Zend_Form_Element_Submit) { + if ($element instanceof \Zend_Form_Element_Button + || $element instanceof \Zend_Form_Element_Submit) { $this->removeElement($element->getName()); } elseif (is_array($value)) { if (count($value) === 0 && $this->isRemoveEmptyElements()) { @@ -117,7 +117,7 @@ protected function _removeElements() } } elseif (trim($value) === '' && $this->isRemoveEmptyElements()) { $this->removeElement($element->getName()); - } elseif ($element instanceof Zend_Form_Element_Checkbox) { + } elseif ($element instanceof \Zend_Form_Element_Checkbox) { if (($element->getValue() == 0) && $this->isRemoveEmptyCheckbox() && $this->isRemoveEmptyElements()) { $this->removeElement($element->getName()); } diff --git a/library/Application/Form/Confirmation.php b/library/Application/Form/Confirmation.php index c8c555c058..308296341d 100644 --- a/library/Application/Form/Confirmation.php +++ b/library/Application/Form/Confirmation.php @@ -25,6 +25,9 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Model\AbstractDb; +use Opus\Model\AbstractModel; + /** * Formular für Bestätigungsabfragen an den Nutzer, z.B. beim Löschen von Modellen. * @@ -70,7 +73,7 @@ class Application_Form_Confirmation extends Application_Form_Abstract /** * Model auf das sich die Frage bezieht. - * @var Opus_Model_Abstract + * @var AbstractModel */ private $_model = null; @@ -176,22 +179,22 @@ public function getModelId() * Eigentlich wird nur die ID benötigt, aber in abgeleiteten Klassen könnte das Model verwendet werden, um * specifischer Informationen anzuzeigen. * - * @param Opus_Abstract_Model $model + * @param AbstractDb $model * @throws Application_Exception */ public function setModel($model) { - if (! is_null($model) && $model instanceof Opus_Model_AbstractDb) { + if (! is_null($model) && $model instanceof AbstractDb) { $this->_model = $model; $this->getElement(self::ELEMENT_MODEL_ID)->setValue($model->getId()); } else { if (is_object($model)) { throw new Application_Exception( __METHOD__ . ' Parameter ' . get_class($model) - . ' not instance of Opus_Model_AbstractDb.' + . ' not instance of Opus\Model\AbstractDb.' ); } else { - throw new Application_Exception(__METHOD__ . ' Parameter must be Opus_Model_AbstractDb.'); + throw new Application_Exception(__METHOD__ . ' Parameter must be Opus\Model\AbstractDb.'); } } } @@ -211,7 +214,7 @@ public function getModelClass() */ public function getModelClassName() { - return $this->getTranslator()->translate($this->_modelClass); + return $this->getTranslator()->translate(preg_replace('/\\\\/', '_', $this->_modelClass)); } /** diff --git a/library/Application/Form/Decorator/Button.php b/library/Application/Form/Decorator/Button.php index 92625ed1c2..78fc14e61f 100644 --- a/library/Application/Form/Decorator/Button.php +++ b/library/Application/Form/Decorator/Button.php @@ -31,7 +31,7 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Form_Decorator_Button extends Zend_Form_Decorator_Abstract +class Application_Form_Decorator_Button extends \Zend_Form_Decorator_Abstract { private $_elementName; diff --git a/library/Application/Form/Decorator/ElementHint.php b/library/Application/Form/Decorator/ElementHint.php index 6ee8e7c632..5892c6941b 100644 --- a/library/Application/Form/Decorator/ElementHint.php +++ b/library/Application/Form/Decorator/ElementHint.php @@ -36,7 +36,7 @@ * * TODO customizable class */ -class Application_Form_Decorator_ElementHint extends Zend_Form_Decorator_Abstract +class Application_Form_Decorator_ElementHint extends \Zend_Form_Decorator_Abstract { public function render($content) diff --git a/library/Application/Form/Decorator/ElementHtmlTag.php b/library/Application/Form/Decorator/ElementHtmlTag.php index 076d0298d3..f429ffccd3 100644 --- a/library/Application/Form/Decorator/ElementHtmlTag.php +++ b/library/Application/Form/Decorator/ElementHtmlTag.php @@ -36,7 +36,7 @@ * * Die Klasse dient dazu die Decoratorkonfiguration für einzelne Elemente zu vereinfachen. */ -class Application_Form_Decorator_ElementHtmlTag extends Zend_Form_Decorator_HtmlTag +class Application_Form_Decorator_ElementHtmlTag extends \Zend_Form_Decorator_HtmlTag { /** diff --git a/library/Application/Form/Decorator/FieldsetWithButtons.php b/library/Application/Form/Decorator/FieldsetWithButtons.php index 250692874d..142c05832d 100644 --- a/library/Application/Form/Decorator/FieldsetWithButtons.php +++ b/library/Application/Form/Decorator/FieldsetWithButtons.php @@ -36,7 +36,7 @@ * * Wird im Metadaten-Formular und Filemanager verwendet, um die Add- und Import Buttons richtig zu positionieren. */ -class Application_Form_Decorator_FieldsetWithButtons extends Zend_Form_Decorator_Fieldset +class Application_Form_Decorator_FieldsetWithButtons extends \Zend_Form_Decorator_Fieldset { protected $_legendButtons = null; @@ -113,7 +113,7 @@ protected function renderButton($button) { $name = $button->getName(); $elementId = $button->getId(); - $decorator = new Zend_Form_Decorator_ViewHelper(); + $decorator = new \Zend_Form_Decorator_ViewHelper(); $decorator->setElement($button); $markup = "" diff --git a/library/Application/Form/Decorator/FileHash.php b/library/Application/Form/Decorator/FileHash.php index c9e3953cea..c7ae233037 100644 --- a/library/Application/Form/Decorator/FileHash.php +++ b/library/Application/Form/Decorator/FileHash.php @@ -36,7 +36,7 @@ * * TODO HIDDEN inputs mit Hash entfernen? Werden momentan nicht benötigt. */ -class Application_Form_Decorator_FileHash extends Zend_Form_Decorator_Abstract +class Application_Form_Decorator_FileHash extends \Zend_Form_Decorator_Abstract { public function render($content) @@ -49,7 +49,7 @@ public function render($content) $view = $element->getView(); - if (! $view instanceof Zend_View_Interface) { + if (! $view instanceof \Zend_View_Interface) { return $content; } diff --git a/library/Application/Form/Decorator/FormHelp.php b/library/Application/Form/Decorator/FormHelp.php index 58d0b83303..60daa9416c 100644 --- a/library/Application/Form/Decorator/FormHelp.php +++ b/library/Application/Form/Decorator/FormHelp.php @@ -38,7 +38,7 @@ * * TODO make tag more configurable */ -class Application_Form_Decorator_FormHelp extends Zend_Form_Decorator_Abstract +class Application_Form_Decorator_FormHelp extends \Zend_Form_Decorator_Abstract { protected $_placement = 'PREPEND'; diff --git a/library/Application/Form/Decorator/HtmlTagWithId.php b/library/Application/Form/Decorator/HtmlTagWithId.php index 02b178342e..2a9cfb06db 100644 --- a/library/Application/Form/Decorator/HtmlTagWithId.php +++ b/library/Application/Form/Decorator/HtmlTagWithId.php @@ -34,7 +34,7 @@ /** * TODO rename */ -class Application_Form_Decorator_HtmlTagWithId extends Zend_Form_Decorator_HtmlTag +class Application_Form_Decorator_HtmlTagWithId extends \Zend_Form_Decorator_HtmlTag { protected function _htmlAttribs(array $attribs) diff --git a/library/Application/Form/Decorator/LabelNotEmpty.php b/library/Application/Form/Decorator/LabelNotEmpty.php index bba6008fc0..4544f2c916 100644 --- a/library/Application/Form/Decorator/LabelNotEmpty.php +++ b/library/Application/Form/Decorator/LabelNotEmpty.php @@ -34,7 +34,7 @@ /** * If there is no label defined nothing is rendered in order to avoid empty LABEL-tags. */ -class Application_Form_Decorator_LabelNotEmpty extends Zend_Form_Decorator_Label +class Application_Form_Decorator_LabelNotEmpty extends \Zend_Form_Decorator_Label { public function render($content) diff --git a/library/Application/Form/Decorator/Placeholder.php b/library/Application/Form/Decorator/Placeholder.php index 30e8d255ba..21322eff54 100644 --- a/library/Application/Form/Decorator/Placeholder.php +++ b/library/Application/Form/Decorator/Placeholder.php @@ -31,7 +31,7 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Form_Decorator_Placeholder extends Zend_Form_Decorator_Abstract +class Application_Form_Decorator_Placeholder extends \Zend_Form_Decorator_Abstract { public function render($content) diff --git a/library/Application/Form/Decorator/RemoveButton.php b/library/Application/Form/Decorator/RemoveButton.php index f93d52c09c..1c4ecff2a4 100644 --- a/library/Application/Form/Decorator/RemoveButton.php +++ b/library/Application/Form/Decorator/RemoveButton.php @@ -39,7 +39,7 @@ * * TODO find better solution that is more generic */ -class Application_Form_Decorator_RemoveButton extends Zend_Form_Decorator_Abstract +class Application_Form_Decorator_RemoveButton extends \Zend_Form_Decorator_Abstract { private $_secondElement; @@ -48,7 +48,7 @@ public function render($content) { $button = $this->getElement(); - if ($button instanceof Zend_Form) { + if ($button instanceof \Zend_Form) { $button = $button->getElement(Admin_Form_Document_MultiSubForm::ELEMENT_REMOVE); } @@ -58,7 +58,7 @@ public function render($content) $view = $button->getView(); - if (! $view instanceof Zend_View_Interface) { + if (! $view instanceof \Zend_View_Interface) { return $content; } diff --git a/library/Application/Form/Decorator/TableHeader.php b/library/Application/Form/Decorator/TableHeader.php index 73ca335475..1f0f696eee 100644 --- a/library/Application/Form/Decorator/TableHeader.php +++ b/library/Application/Form/Decorator/TableHeader.php @@ -34,7 +34,7 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Form_Decorator_TableHeader extends Zend_Form_Decorator_Abstract +class Application_Form_Decorator_TableHeader extends \Zend_Form_Decorator_Abstract { private $_columns = null; @@ -48,7 +48,7 @@ public function render($content) $view = $this->getElement()->getView(); - if (! $view instanceof Zend_View_Interface) { + if (! $view instanceof \Zend_View_Interface) { return $content; } diff --git a/library/Application/Form/Decorator/TableWrapper.php b/library/Application/Form/Decorator/TableWrapper.php index 98008d69e3..c9db0d8211 100644 --- a/library/Application/Form/Decorator/TableWrapper.php +++ b/library/Application/Form/Decorator/TableWrapper.php @@ -31,7 +31,7 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Form_Decorator_TableWrapper extends Zend_Form_Decorator_Abstract +class Application_Form_Decorator_TableWrapper extends \Zend_Form_Decorator_Abstract { public function render($content) diff --git a/library/Application/Form/Decorator/UpdateField.php b/library/Application/Form/Decorator/UpdateField.php index 287b30f26a..8620fdcf30 100644 --- a/library/Application/Form/Decorator/UpdateField.php +++ b/library/Application/Form/Decorator/UpdateField.php @@ -36,7 +36,7 @@ * * TODO rename? */ -class Application_Form_Decorator_UpdateField extends Zend_Form_Decorator_Abstract +class Application_Form_Decorator_UpdateField extends \Zend_Form_Decorator_Abstract { public function render($content) diff --git a/library/Application/Form/Decorator/ViewHelper.php b/library/Application/Form/Decorator/ViewHelper.php index 9bb7209c89..755777fe89 100644 --- a/library/Application/Form/Decorator/ViewHelper.php +++ b/library/Application/Form/Decorator/ViewHelper.php @@ -37,7 +37,7 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Form_Decorator_ViewHelper extends Zend_Form_Decorator_ViewHelper +class Application_Form_Decorator_ViewHelper extends \Zend_Form_Decorator_ViewHelper { private $_viewOnlyEnabled = false; @@ -57,7 +57,7 @@ public function getHelper() $helper = 'viewForm' . ucfirst($type); try { $element->getView()->getHelper($helper); - } catch (Zend_Loader_PluginLoader_Exception $zlpe) { + } catch (\Zend_Loader_PluginLoader_Exception $zlpe) { $helper = 'viewFormDefault'; } } diff --git a/library/Application/Form/Element/Checkbox.php b/library/Application/Form/Element/Checkbox.php index 7078b431ea..080c6efac0 100644 --- a/library/Application/Form/Element/Checkbox.php +++ b/library/Application/Form/Element/Checkbox.php @@ -29,13 +29,12 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Angepasste Klasse für Checkbox Formularelemente. */ -class Application_Form_Element_Checkbox extends Zend_Form_Element_Checkbox implements Application_Form_IElement +class Application_Form_Element_Checkbox extends \Zend_Form_Element_Checkbox implements Application_Form_IElement { private $_viewCheckedValue = 'Field_Value_True'; @@ -44,7 +43,7 @@ class Application_Form_Element_Checkbox extends Zend_Form_Element_Checkbox imple public function init() { - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); } public function loadDefaultDecorators() diff --git a/library/Application/Form/Element/Combobox.php b/library/Application/Form/Element/Combobox.php index fa5de81929..92405684fd 100644 --- a/library/Application/Form/Element/Combobox.php +++ b/library/Application/Form/Element/Combobox.php @@ -40,7 +40,7 @@ * * A combobox has options like a select element, but it can also have a value that does not match any of the options. */ -class Application_Form_Element_Combobox extends Zend_Form_Element_Multi +class Application_Form_Element_Combobox extends \Zend_Form_Element_Multi { public $multiple = false; @@ -54,7 +54,7 @@ public function init() parent::init(); - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); } public function loadDefaultDecorators() diff --git a/library/Application/Form/Element/DocumentType.php b/library/Application/Form/Element/DocumentType.php index c0d637fd1b..e29191c2ae 100644 --- a/library/Application/Form/Element/DocumentType.php +++ b/library/Application/Form/Element/DocumentType.php @@ -45,13 +45,13 @@ public function init() $this->setLabel($this->getView()->translate($this->getName())); $this->setRequired(true); - $docTypeHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); + $docTypeHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); $options = $docTypeHelper->getDocumentTypes(); $this->setDisableTranslator(true); - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); foreach ($options as $index => $type) { if (! is_null($translator) && $translator->isTranslated($index)) { @@ -69,7 +69,7 @@ public function setValue($value) { $option = $this->getMultiOption($value); - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); if (! is_null($translator) && $translator->isTranslated($value)) { $label = $translator->translate($value); diff --git a/library/Application/Form/Element/Email.php b/library/Application/Form/Element/Email.php index 3cd0ace742..a1b821b4ac 100644 --- a/library/Application/Form/Element/Email.php +++ b/library/Application/Form/Element/Email.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -46,7 +45,7 @@ public function init() parent::init(); $this->setAttrib('placeholder', $this->getTranslator()->translate('email_format')); $this->setAttrib('size', 60); - $validator = new Zend_Validate_EmailAddress(); + $validator = new \Zend_Validate_EmailAddress(); $validator->setMessage('admin_validate_error_email'); $this->addValidator($validator); } diff --git a/library/Application/Form/Element/EnrichmentKey.php b/library/Application/Form/Element/EnrichmentKey.php index 5e40125922..c52d834077 100644 --- a/library/Application/Form/Element/EnrichmentKey.php +++ b/library/Application/Form/Element/EnrichmentKey.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\EnrichmentKey; + /** * Formularelement für die Auswahl eines EnrichmentKeys. */ @@ -42,7 +44,7 @@ public function init() parent::init(); // load enrichment keys only once in order to save database queries - $options = Opus_EnrichmentKey::getAll(false); + $options = EnrichmentKey::getAll(false); $values = []; @@ -70,7 +72,7 @@ public function init() } } - $validator = new Zend_Validate_InArray($values); + $validator = new \Zend_Validate_InArray($values); $validator->setMessage('validation_error_unknown_enrichmentkey'); $this->addValidator($validator); } diff --git a/library/Application/Form/Element/File.php b/library/Application/Form/Element/File.php index d0bbab1ed1..d4690b56d3 100644 --- a/library/Application/Form/Element/File.php +++ b/library/Application/Form/Element/File.php @@ -31,18 +31,17 @@ * @category Application * @package Form_Element * @author Jens Schwidder - * @copyright Copyright (c) 2008-2013, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_Form_Element_File extends Zend_Form_Element_File +class Application_Form_Element_File extends \Zend_Form_Element_File { public function init() { parent::init(); - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); } public function loadDefaultDecorators() diff --git a/library/Application/Form/Element/FileHash.php b/library/Application/Form/Element/FileHash.php index 2c2f085fd9..874dd6d4e2 100644 --- a/library/Application/Form/Element/FileHash.php +++ b/library/Application/Form/Element/FileHash.php @@ -25,17 +25,18 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\HashValues; + /** * Formularelement fuer Anzeige von File Hashes. * * @category Application * @package Application_Form_Element_FileHash * @author Jens Schwidder - * @copyright Copyright (c) 2008-2013, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_Form_Element_FileHash extends Zend_Form_Element_Xhtml +class Application_Form_Element_FileHash extends \Zend_Form_Element_Xhtml { private $_hash; @@ -46,7 +47,7 @@ public function init() { parent::init(); - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); $this->setLabel($this->getTranslator()->translate('admin_filemanager_checksum') . ' - '); } @@ -78,7 +79,7 @@ public function getFile() public function setValue($hash) { - if ($hash instanceof Opus_HashValues) { + if ($hash instanceof HashValues) { $this->_hash = $hash; } } diff --git a/library/Application/Form/Element/FileLink.php b/library/Application/Form/Element/FileLink.php index 542c085698..8a1d7ede8e 100644 --- a/library/Application/Form/Element/FileLink.php +++ b/library/Application/Form/Element/FileLink.php @@ -25,17 +25,19 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\File; +use Opus\Model\NotFoundException; + /** - * Formularelement für die Anzeige eines Download Links für ein Opus_File Objekt. + * Formularelement für die Anzeige eines Download Links für ein File Objekt. * - * Das Formularelement kann nur mit gültigen IDs für Opus_File verwendet werden. + * Das Formularelement kann nur mit gültigen IDs für File verwendet werden. * * @category Application * @package Form_Element * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Form_Element_FileLink extends Application_Form_Element_Text { @@ -62,10 +64,10 @@ public function setValue($file) throw new Application_Exception(__METHOD__ . " Value must not be null."); } - if (! $file instanceof Opus_File) { + if (! $file instanceof File) { try { - $file = new Opus_File($file); - } catch (Opus_Model_NotFoundException $omnfe) { + $file = new File($file); + } catch (NotFoundException $omnfe) { throw new Application_Exception("File with ID = $file not found."); } } @@ -77,7 +79,7 @@ public function setValue($file) } /** - * Validierung ist erfolgreich, wenn Opus_File mit ID existiert. + * Validierung ist erfolgreich, wenn File mit ID existiert. * * Wenn die ID nicht existiert wird in setValue eine Application_Exception geworfen. * @@ -89,7 +91,7 @@ public function isValid($value) $this->setValue($value); $file = $this->getValue(); - if ($file instanceof Opus_File) { + if ($file instanceof File) { return true; } else { return false; diff --git a/library/Application/Form/Element/Grantor.php b/library/Application/Form/Element/Grantor.php index 2db20ec3a4..d167d0706f 100644 --- a/library/Application/Form/Element/Grantor.php +++ b/library/Application/Form/Element/Grantor.php @@ -31,6 +31,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\DnbInstitute; +use Opus\Model\ModelException; +use Opus\Model\NotFoundException; + /** * Select Element für Thesis Grantor Institute. */ @@ -44,11 +48,11 @@ public function init() $this->setRequired(true); $this->setDisableTranslator(true); // Grantor institutes are not translated - $validator = new Zend_Validate_Int(); + $validator = new \Zend_Validate_Int(); $validator->setMessage('validation_error_int'); $this->addValidator($validator); - $options = Opus_DnbInstitute::getGrantors(); + $options = DnbInstitute::getGrantors(); foreach ($options as $option) { $this->addMultiOption($option->getId(), $option->getDisplayName()); @@ -62,13 +66,13 @@ public function init() * * @param mixed $value * @return void|Zend_Form_Element - * @throws Opus_Model_Exception + * @throws ModelException */ public function setValue($value) { try { - $institute = new Opus_DnbInstitute($value); - } catch (Opus_Model_NotFoundException $omne) { + $institute = new DnbInstitute($value); + } catch (NotFoundException $omne) { parent::setValue($value); // could be blocked, but keeping compatibility just in case return; } diff --git a/library/Application/Form/Element/Hash.php b/library/Application/Form/Element/Hash.php index 65e447ed00..81b5655877 100644 --- a/library/Application/Form/Element/Hash.php +++ b/library/Application/Form/Element/Hash.php @@ -29,13 +29,12 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * */ -class Application_Form_Element_Hash extends Zend_Form_Element_Hash +class Application_Form_Element_Hash extends \Zend_Form_Element_Hash { public function loadDefaultDecorators() diff --git a/library/Application/Form/Element/Hidden.php b/library/Application/Form/Element/Hidden.php index 0598956d8c..e734892ac3 100644 --- a/library/Application/Form/Element/Hidden.php +++ b/library/Application/Form/Element/Hidden.php @@ -34,12 +34,12 @@ * @copyright Copyright (c) 2013-2017, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Form_Element_Hidden extends Zend_Form_Element_Hidden +class Application_Form_Element_Hidden extends \Zend_Form_Element_Hidden { public function init() { - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); } public function loadDefaultDecorators() diff --git a/library/Application/Form/Element/HitsPerPage.php b/library/Application/Form/Element/HitsPerPage.php index 78d8c9b78e..7c63579be8 100644 --- a/library/Application/Form/Element/HitsPerPage.php +++ b/library/Application/Form/Element/HitsPerPage.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -49,7 +48,7 @@ public function init() $options = ['10', '20', '50', '100']; - $defaultRows = Opus\Search\Query::getDefaultRows(); + $defaultRows = \Opus\Search\Query::getDefaultRows(); if (! in_array($defaultRows, $options)) { $options[] = $defaultRows; diff --git a/library/Application/Form/Element/Html.php b/library/Application/Form/Element/Html.php index 76c2982d31..7420cc8e23 100644 --- a/library/Application/Form/Element/Html.php +++ b/library/Application/Form/Element/Html.php @@ -34,14 +34,14 @@ * @copyright Copyright (c) 2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Form_Element_Html extends Zend_Form_Element_Xhtml +class Application_Form_Element_Html extends \Zend_Form_Element_Xhtml { public $helper = 'formHtml'; public function init() { - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); } public function loadDefaultDecorators() diff --git a/library/Application/Form/Element/Identifier.php b/library/Application/Form/Element/Identifier.php index 70c568a70a..44a074be62 100644 --- a/library/Application/Form/Element/Identifier.php +++ b/library/Application/Form/Element/Identifier.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Identifier; + /** * Select Element für Identifier Type. * @@ -44,7 +45,7 @@ public function init() { parent::init(); - $identifier = new Opus_Identifier(); + $identifier = new Identifier(); $types = $identifier->getField('Type')->getDefault(); foreach ($types as $type) { diff --git a/library/Application/Form/Element/IpAddress.php b/library/Application/Form/Element/IpAddress.php index 006143fb59..68dbe69987 100644 --- a/library/Application/Form/Element/IpAddress.php +++ b/library/Application/Form/Element/IpAddress.php @@ -43,11 +43,11 @@ public function init() { parent::init(); - $validator = new Zend_Validate_Ip(['allowipv4' => true, 'allowipv6' => false]); + $validator = new \Zend_Validate_Ip(['allowipv4' => true, 'allowipv6' => false]); $validator->setMessages( [ - Zend_Validate_Ip::INVALID => 'validation_error_ip_invalid', - Zend_Validate_Ip::NOT_IP_ADDRESS => 'validation_error_ip_not_address', + \Zend_Validate_Ip::INVALID => 'validation_error_ip_invalid', + \Zend_Validate_Ip::NOT_IP_ADDRESS => 'validation_error_ip_not_address', ] ); $this->setValidators([$validator]); diff --git a/library/Application/Form/Element/Language.php b/library/Application/Form/Element/Language.php index e0392db2f7..edaac5ce48 100644 --- a/library/Application/Form/Element/Language.php +++ b/library/Application/Form/Element/Language.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Language; + /** * * TODO override setLabel for more robust translation @@ -68,13 +70,13 @@ public static function getLanguageList() */ public static function initLanguageList() { - $translate = Zend_Registry::get(Application_Translate::REGISTRY_KEY); + $translate = \Zend_Registry::get(Application_Translate::REGISTRY_KEY); $languages = []; - foreach (Opus_Language::getAllActiveTable() as $languageRow) { + foreach (Language::getAllActiveTable() as $languageRow) { $langId = $languageRow['part2_t']; $languages[$langId] = $translate->translateLanguage($langId); } self::$_languageList = $languages; - Zend_Registry::set('Available_Languages', $languages); + \Zend_Registry::set('Available_Languages', $languages); } } diff --git a/library/Application/Form/Element/LanguageScope.php b/library/Application/Form/Element/LanguageScope.php index 43b36193df..18aea6480d 100644 --- a/library/Application/Form/Element/LanguageScope.php +++ b/library/Application/Form/Element/LanguageScope.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Form_Element_LanguageScope extends Application_Form_Element_SelectWithNull diff --git a/library/Application/Form/Element/LanguageType.php b/library/Application/Form/Element/LanguageType.php index 4d1e0d402e..60e6c78135 100644 --- a/library/Application/Form/Element/LanguageType.php +++ b/library/Application/Form/Element/LanguageType.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Form_Element_LanguageType extends Application_Form_Element_SelectWithNull diff --git a/library/Application/Form/Element/Login.php b/library/Application/Form/Element/Login.php index 939a3d6516..dc90257a55 100644 --- a/library/Application/Form/Element/Login.php +++ b/library/Application/Form/Element/Login.php @@ -50,7 +50,7 @@ public function init() parent::init(); $this->setLabel('admin_account_label_login'); - // NOTE: This validation is also defined in Opus_Account. + // NOTE: This validation is also defined in Account. $this->addValidator('regex', false, ['/^[a-z0-9@._-]+$/']); $this->addValidator('stringLength', false, ['min' => 3, 'max' => 50]); diff --git a/library/Application/Form/Element/MultiCheckbox.php b/library/Application/Form/Element/MultiCheckbox.php index dd0acc9bc5..2bda289c63 100644 --- a/library/Application/Form/Element/MultiCheckbox.php +++ b/library/Application/Form/Element/MultiCheckbox.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2008-2017, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Form_Element_MultiCheckbox extends Zend_Form_Element_MultiCheckbox +class Application_Form_Element_MultiCheckbox extends \Zend_Form_Element_MultiCheckbox { public function init() @@ -40,7 +40,7 @@ public function init() $this->addPrefixPath( 'Application_Form_Decorator', 'Application/Form/Decorator', - Zend_Form::DECORATOR + \Zend_Form::DECORATOR ); } diff --git a/library/Application/Form/Element/Number.php b/library/Application/Form/Element/Number.php index dd480aa10a..c51d164e9f 100644 --- a/library/Application/Form/Element/Number.php +++ b/library/Application/Form/Element/Number.php @@ -47,7 +47,7 @@ public function init() $this->setAttrib('size', 6); } - $validator = new Zend_Validate_Int(); + $validator = new \Zend_Validate_Int(); $validator->setMessage('validation_error_int'); $this->addValidator($validator); @@ -63,13 +63,13 @@ public function init() $max = $this->getAttrib('max'); if (is_null($max)) { - $validator = new Zend_Validate_GreaterThan(['min' => $min - 1]); // inclusive not supported in ZF1 + $validator = new \Zend_Validate_GreaterThan(['min' => $min - 1]); // inclusive not supported in ZF1 $validator->setMessage('validation_error_number_tooSmall'); } else { $this->setAttrib('max', null); // remove from rendered attributes $options['max'] = $max; - $validator = new Zend_Validate_Between(['min' => $min, 'max' => $max]); + $validator = new \Zend_Validate_Between(['min' => $min, 'max' => $max]); $validator->setMessage('validation_error_number_notBetween'); } diff --git a/library/Application/Form/Element/Password.php b/library/Application/Form/Element/Password.php index 0342ef0860..85e58baf23 100644 --- a/library/Application/Form/Element/Password.php +++ b/library/Application/Form/Element/Password.php @@ -38,7 +38,7 @@ * * - must be at least 6 characters long */ -class Application_Form_Element_Password extends Zend_Form_Element_Password +class Application_Form_Element_Password extends \Zend_Form_Element_Password { /** @@ -48,7 +48,7 @@ public function init() { parent::init(); - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); $this->setAllowEmpty(false); $this->addValidator('stringLength', false, ['min' => 6]); diff --git a/library/Application/Form/Element/PersonRole.php b/library/Application/Form/Element/PersonRole.php index 0217d7f55c..0e0df79fcf 100644 --- a/library/Application/Form/Element/PersonRole.php +++ b/library/Application/Form/Element/PersonRole.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/library/Application/Form/Element/Position.php b/library/Application/Form/Element/Position.php index 3e2e7607a2..0b96defc4f 100644 --- a/library/Application/Form/Element/Position.php +++ b/library/Application/Form/Element/Position.php @@ -27,12 +27,14 @@ * @category Application * @package Form_Element * @author Jens Schwidder - * @copyright Copyright (c) 2008-2014, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ * * TODO rename to CollectionRolePosition or make generic */ + +use Opus\CollectionRole; + class Application_Form_Element_Position extends Application_Form_Element_Select { @@ -40,9 +42,9 @@ public function init() { parent::init(); - $allCollectionRoles = Opus_CollectionRole::fetchAll(); + $allCollectionRoles = CollectionRole::fetchAll(); - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); foreach ($allCollectionRoles as $collectionRole) { $position = $collectionRole->getPosition(); diff --git a/library/Application/Form/Element/Publisher.php b/library/Application/Form/Element/Publisher.php index cc99803ffb..ec66741d02 100644 --- a/library/Application/Form/Element/Publisher.php +++ b/library/Application/Form/Element/Publisher.php @@ -31,6 +31,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\DnbInstitute; +use Opus\Model\ModelException; +use Opus\Model\NotFoundException; + /** * Select Element für Thesis Publisher Institute. */ @@ -44,11 +48,11 @@ public function init() $this->setRequired(true); $this->setDisableTranslator(true); // publishing institutions are not translated - $validator = new Zend_Validate_Int(); + $validator = new \Zend_Validate_Int(); $validator->setMessage('validation_error_int'); $this->addValidator($validator); - $options = Opus_DnbInstitute::getPublishers(); + $options = DnbInstitute::getPublishers(); foreach ($options as $option) { $this->addMultiOption($option->getId(), $option->getDisplayName()); @@ -61,14 +65,14 @@ public function init() * If $value is a valid DNB institute a corresponding option is added to select if necessary. * * @param mixed $value - * @return void|Zend_Form_Element - * @throws Opus_Model_Exception + * @return void|\Zend_Form_Element + * @throws ModelException */ public function setValue($value) { try { - $institute = new Opus_DnbInstitute($value); - } catch (Opus_Model_NotFoundException $omne) { + $institute = new DnbInstitute($value); + } catch (NotFoundException $omne) { parent::setValue($value); // could be blocked, but keeping compatibility just in case return; } diff --git a/library/Application/Form/Element/Roles.php b/library/Application/Form/Element/Roles.php index 021102df14..9ac256bd19 100644 --- a/library/Application/Form/Element/Roles.php +++ b/library/Application/Form/Element/Roles.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\UserRole; + /** * Formularelement für Auswahl von Rollen über Checkboxen. * @@ -41,7 +43,7 @@ public function init() { parent::init(); - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); $this->setMultiOptions($this->getRolesMultiOptions()); } @@ -69,7 +71,7 @@ public function loadDefaultDecorators() */ public function getRolesMultiOptions() { - $roles = Opus_UserRole::getAll(); + $roles = UserRole::getAll(); $options = []; @@ -83,12 +85,12 @@ public function getRolesMultiOptions() /** * Sets selected roles. - * @param mixed $value Role names or Opus_UserRole objects + * @param mixed $value Role names or UserRole objects */ public function setValue($value) { if (is_array($value)) { - if (count($value) > 0 && $value[0] instanceof Opus_UserRole) { + if (count($value) > 0 && $value[0] instanceof UserRole) { $value = $this->getRoleNames($value); } } @@ -97,8 +99,8 @@ public function setValue($value) } /** - * Returns array of Opus_UserRole objects. - * @return array of Opus_UserRole + * Returns array of UserRole objects. + * @return array of UserRole */ public function getRoles() { @@ -108,7 +110,7 @@ public function getRoles() if (is_array($names)) { foreach ($names as $name) { - array_push($roles, Opus_UserRole::fetchByName($name)); + array_push($roles, UserRole::fetchByName($name)); } } @@ -117,7 +119,7 @@ public function getRoles() /** * Converts array with objects into array with role names. - * @param $roles array of Opus_UserRole objects + * @param $roles array of UserRole objects * @return array Role names */ public function getRoleNames($roles) diff --git a/library/Application/Form/Element/Select.php b/library/Application/Form/Element/Select.php index d2fea60fdf..c1921fca6c 100644 --- a/library/Application/Form/Element/Select.php +++ b/library/Application/Form/Element/Select.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -37,7 +36,7 @@ * * TODO IMPORTANT use setElementDecorators in form classes instead of adding decorators in element classes */ -class Application_Form_Element_Select extends Zend_Form_Element_Select implements Application_Form_IElement +class Application_Form_Element_Select extends \Zend_Form_Element_Select implements Application_Form_IElement { /** @@ -49,7 +48,7 @@ public function init() { parent::init(); - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); } public function loadDefaultDecorators() diff --git a/library/Application/Form/Element/Series.php b/library/Application/Form/Element/Series.php index 6fb618ca89..15ce752f84 100644 --- a/library/Application/Form/Element/Series.php +++ b/library/Application/Form/Element/Series.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Series; + /** * Formularelement für Auswahl einer Schriftenreihe. */ @@ -45,11 +46,11 @@ public function init() $this->setRequired(true); $this->setDisableTranslator(true); // Schriftenreihen werden nicht übersetzt - $validator = new Zend_Validate_Int(); + $validator = new \Zend_Validate_Int(); $validator->setMessage('validation_error_int'); $this->addValidator($validator); - $options = Opus_Series::getAll(); + $options = Series::getAll(); foreach ($options as $option) { $this->addMultiOption($option->getId(), $option->getTitle()); diff --git a/library/Application/Form/Element/SortOrder.php b/library/Application/Form/Element/SortOrder.php index 4084f69187..1e2a66cbbd 100644 --- a/library/Application/Form/Element/SortOrder.php +++ b/library/Application/Form/Element/SortOrder.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -48,11 +47,11 @@ public function init() $this->setAttrib('size', 6); } - $validator = new Zend_Validate_Int(); + $validator = new \Zend_Validate_Int(); $validator->setMessage('validation_error_int'); $this->addValidator($validator); - $validator = new Zend_Validate_GreaterThan(-1); + $validator = new \Zend_Validate_GreaterThan(-1); $validator->setMessage('validation_error_negative_number'); $this->addValidator($validator); } diff --git a/library/Application/Form/Element/Submit.php b/library/Application/Form/Element/Submit.php index 105476d213..86f817bced 100644 --- a/library/Application/Form/Element/Submit.php +++ b/library/Application/Form/Element/Submit.php @@ -33,9 +33,8 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_Form_Element_Submit extends Zend_Form_Element_Submit +class Application_Form_Element_Submit extends \Zend_Form_Element_Submit { /** @@ -47,12 +46,12 @@ public function init() { parent::init(); - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); } /** * Lädt die Dekoratoren für Button Element. - * @return $this|Zend_Form_Element_Submit + * @return $this|\Zend_Form_Element_Submit */ public function loadDefaultDecorators() { diff --git a/library/Application/Form/Element/SupportedLanguages.php b/library/Application/Form/Element/SupportedLanguages.php index 6c8a776574..e0b2305962 100644 --- a/library/Application/Form/Element/SupportedLanguages.php +++ b/library/Application/Form/Element/SupportedLanguages.php @@ -44,7 +44,7 @@ public function init() { parent::init(); - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); $this->setMultiOptions($this->getLanguageOptions()); @@ -59,7 +59,7 @@ public function init() true, [ 'messages' => [ - Zend_Validate_InArray::NOT_IN_ARRAY => 'validation_error_language_not_supported' + \Zend_Validate_InArray::NOT_IN_ARRAY => 'validation_error_language_not_supported' ], 'haystack' => array_keys($options) ] @@ -92,13 +92,13 @@ public function loadDefaultDecorators() * Returns available language options determined by translation resources. * * @return array - * @throws Zend_Exception + * @throws \Zend_Exception */ public function getLanguageOptions() { - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); - $currentLocale = new Zend_Locale($translator->getLocale()); + $currentLocale = new \Zend_Locale($translator->getLocale()); $translations = $translator->getList(); diff --git a/library/Application/Form/Element/Text.php b/library/Application/Form/Element/Text.php index 84a20dae09..a3c16a615f 100644 --- a/library/Application/Form/Element/Text.php +++ b/library/Application/Form/Element/Text.php @@ -36,7 +36,7 @@ * * Zur Zeit nur vom Metadaten-Formular genutzt. */ -class Application_Form_Element_Text extends Zend_Form_Element_Text implements Application_Form_IElement +class Application_Form_Element_Text extends \Zend_Form_Element_Text implements Application_Form_IElement { /** @@ -66,7 +66,7 @@ public function init() $this->addPrefixPath( 'Application_Form_Decorator', 'Application/Form/Decorator', - Zend_Form::DECORATOR + \Zend_Form::DECORATOR ); } diff --git a/library/Application/Form/Element/Textarea.php b/library/Application/Form/Element/Textarea.php index 9488af8190..6bd2cc776b 100644 --- a/library/Application/Form/Element/Textarea.php +++ b/library/Application/Form/Element/Textarea.php @@ -29,13 +29,12 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Angepasste Klasse für Textarea Formularelemente. */ -class Application_Form_Element_Textarea extends Zend_Form_Element_Textarea implements Application_Form_IElement +class Application_Form_Element_Textarea extends \Zend_Form_Element_Textarea implements Application_Form_IElement { /** @@ -56,7 +55,7 @@ public function init() $this->setAttrib('cols', 70); } - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); } public function loadDefaultDecorators() diff --git a/library/Application/Form/Element/Theme.php b/library/Application/Form/Element/Theme.php index 9c47bf2639..5d618b2a74 100644 --- a/library/Application/Form/Element/Theme.php +++ b/library/Application/Form/Element/Theme.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Form_Element_Theme extends Application_Form_Element_SelectWithNull @@ -88,7 +87,7 @@ private function getThemes() public static function findThemes($path) { if (is_dir($path) === false) { - throw new InvalidArgumentException("Argument should be a valid path."); + throw new \InvalidArgumentException("Argument should be a valid path."); } $themes = []; diff --git a/library/Application/Form/Element/Translation.php b/library/Application/Form/Element/Translation.php index 7086fe82e1..dbe58dbaf7 100644 --- a/library/Application/Form/Element/Translation.php +++ b/library/Application/Form/Element/Translation.php @@ -42,7 +42,7 @@ * TODO validation * TODO should translation functions be added at model level (in framework)? */ -class Application_Form_Element_Translation extends Zend_Form_Element_Multi +class Application_Form_Element_Translation extends \Zend_Form_Element_Multi { public $helper = 'formTranslation'; @@ -54,7 +54,7 @@ class Application_Form_Element_Translation extends Zend_Form_Element_Multi public function init() { parent::init(); - $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $this->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); $this->setRegisterInArrayValidator(false); $this->loadDefaultOptions(); } diff --git a/library/Application/Form/Element/TranslationModules.php b/library/Application/Form/Element/TranslationModules.php index 496dc0b99b..ae3729d87d 100644 --- a/library/Application/Form/Element/TranslationModules.php +++ b/library/Application/Form/Element/TranslationModules.php @@ -48,7 +48,7 @@ public function init() $modules = $manager->getModules(); - $translator = Zend_Registry::get('Zend_Translate'); // TODO bad design (external, hidden dependency) + $translator = \Zend_Registry::get('Zend_Translate'); // TODO bad design (external, hidden dependency) array_unshift($modules, $translator->translate('default_all')); diff --git a/library/Application/Form/Element/Year.php b/library/Application/Form/Element/Year.php index 174a3947ee..731b43451d 100644 --- a/library/Application/Form/Element/Year.php +++ b/library/Application/Form/Element/Year.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -46,24 +45,20 @@ public function init() $validators = []; - $validator = new Zend_Validate_Int(); + $validator = new \Zend_Validate_Int(); $validator->setMessage('validation_error_year_invalid_format'); $validators[] = $validator; - $validator = new Zend_Validate_GreaterThan(-1); - $validator->setMessages( - [ - Zend_Validate_GreaterThan::NOT_GREATER => 'validation_error_year_invalid_negative' - ] - ); + $validator = new \Zend_Validate_GreaterThan(-1); + $validator->setMessages([ + \Zend_Validate_GreaterThan::NOT_GREATER => 'validation_error_year_invalid_negative' + ]); $validators[] = $validator; - $validator = new Zend_Validate_LessThan(10000); - $validator->setMessages( - [ - Zend_Validate_LessThan::NOT_LESS => 'validation_error_year_too_large' - ] - ); + $validator = new \Zend_Validate_LessThan(10000); + $validator->setMessages([ + \Zend_Validate_LessThan::NOT_LESS => 'validation_error_year_too_large' + ]); $validators[] = $validator; $this->setAttrib('placeholder', $this->getTranslator()->translate('year_format')); diff --git a/library/Application/Form/Filter/ReplaceNewlines.php b/library/Application/Form/Filter/ReplaceNewlines.php index 3136a5abae..e00ac96eb0 100644 --- a/library/Application/Form/Filter/ReplaceNewlines.php +++ b/library/Application/Form/Filter/ReplaceNewlines.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -38,7 +37,7 @@ * This filter is used for document titles that are entered using a textarea, * since the titles can be rather long. */ -class Application_Form_Filter_ReplaceNewlines implements Zend_Filter_Interface +class Application_Form_Filter_ReplaceNewlines implements \Zend_Filter_Interface { /** @@ -48,7 +47,7 @@ class Application_Form_Filter_ReplaceNewlines implements Zend_Filter_Interface * line break. * * @param string $value Value that should be filtered - * @return Filtered string (newlines => whitespaces) + * @return string Filtered string (newlines => whitespaces) */ public function filter($value) { diff --git a/library/Application/Form/IElement.php b/library/Application/Form/IElement.php index f7592b1cdb..4d0d86d812 100644 --- a/library/Application/Form/IElement.php +++ b/library/Application/Form/IElement.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/library/Application/Form/IModel.php b/library/Application/Form/IModel.php index 6e458a5a39..6c2807ac58 100644 --- a/library/Application/Form/IModel.php +++ b/library/Application/Form/IModel.php @@ -34,7 +34,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2009-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ interface Application_Form_IModel { @@ -53,8 +52,8 @@ public function getModelClass(); /** * Verarbeitet POST Daten. - * @param $post POST Daten fuer Formular - * @param $context POST Daten fuer gesamten Request + * @param $post array Daten fuer Formular + * @param $context array Daten fuer gesamten Request * @return mixed */ public function processPost($post, $context); diff --git a/library/Application/Form/IViewable.php b/library/Application/Form/IViewable.php index d1d3e79fcf..40017156a2 100644 --- a/library/Application/Form/IViewable.php +++ b/library/Application/Form/IViewable.php @@ -35,9 +35,8 @@ * @category Application * @package Application_Form * @author Jens Schwidder - * @copyright Copyright (c) 2008-2013, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ interface Application_Form_IViewable { diff --git a/library/Application/Form/Model/Abstract.php b/library/Application/Form/Model/Abstract.php index 600f64393c..ab7bf14e53 100644 --- a/library/Application/Form/Model/Abstract.php +++ b/library/Application/Form/Model/Abstract.php @@ -25,6 +25,9 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Model\AbstractDb; +use Opus\Model\NotFoundException; + /** * Abstrakte Basisklasse für Model-Formulare. * @@ -149,7 +152,7 @@ public function processPost($post, $context) * Instanziert und aktualisiert vom Formular angezeigtes Model. * * @throws Application_Exception - * @return Opus_Model_AbbstractDb + * @return AbstractDb */ public function getModel() { @@ -167,7 +170,7 @@ public function getModel() try { $model = new $modelClass($modelId); - } catch (Opus_Model_NotFoundException $omnfe) { + } catch (NotFoundException $omnfe) { $this->getLogger()->err($omnfe->getMessage()); throw new Application_Exception(__METHOD__ . " Model with ID '$modelId' not found."); } diff --git a/library/Application/Form/Model/Table.php b/library/Application/Form/Model/Table.php index 7603f26092..8c10b91019 100644 --- a/library/Application/Form/Model/Table.php +++ b/library/Application/Form/Model/Table.php @@ -33,7 +33,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ * * TODO class is tied to Application_Controller_ActionCRUD - resolve */ @@ -109,7 +108,7 @@ public function setColumns($columns) /** * Liefert das Label für eine Spalte. - * @param $index Index der Spalte angefangen bei 0 + * @param $index int Index der Spalte angefangen bei 0 * @return string|null */ public function getColumnLabel($index) diff --git a/library/Application/Form/TableHeader.php b/library/Application/Form/TableHeader.php index f873dfc71f..63e89a42c6 100644 --- a/library/Application/Form/TableHeader.php +++ b/library/Application/Form/TableHeader.php @@ -33,7 +33,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Form_TableHeader extends Application_Form_Abstract { diff --git a/library/Application/Form/Translations.php b/library/Application/Form/Translations.php index 6784d87e05..085a0dbb77 100644 --- a/library/Application/Form/Translations.php +++ b/library/Application/Form/Translations.php @@ -143,7 +143,7 @@ public function populateFromTranslations() { $elements = $this->getTranslationElements(); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); foreach ($elements as $name => $element) { // TODO handle no translation @@ -162,9 +162,9 @@ public function updateTranslations() $element->updateTranslations($key); } - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $translate->clearCache(); - Zend_Translate::clearCache(); + \Zend_Translate::clearCache(); } /** diff --git a/library/Application/Form/Validate/AtLeastOneNotEmpty.php b/library/Application/Form/Validate/AtLeastOneNotEmpty.php index b97e960aae..17671aae9f 100644 --- a/library/Application/Form/Validate/AtLeastOneNotEmpty.php +++ b/library/Application/Form/Validate/AtLeastOneNotEmpty.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -38,7 +37,7 @@ * @category Application * @package Form_Validate */ -class Application_Form_Validate_AtLeastOneNotEmpty extends Zend_Validate_Abstract +class Application_Form_Validate_AtLeastOneNotEmpty extends \Zend_Validate_Abstract { const ALL_EMPTY = 'allElementsEmpty'; @@ -73,7 +72,7 @@ public function __construct($elements = null) public function isValid($value, $context = null) { if (is_array($this->_elements)) { - $notEmpty = new Zend_Validate_NotEmpty(); + $notEmpty = new \Zend_Validate_NotEmpty(); foreach ($this->_elements as $name) { if (isset($context[$name]) && $notEmpty->isValid($context[$name])) { return true; @@ -86,7 +85,7 @@ public function isValid($value, $context = null) /** * Adds a form element to group for validation. - * @param $element Zend_Form_Element + * @param $element \Zend_Form_Element */ public function addElement($element) { diff --git a/library/Application/Form/Validate/CollectionRoleNameUnique.php b/library/Application/Form/Validate/CollectionRoleNameUnique.php index 8f7573aa2f..522dd6a655 100644 --- a/library/Application/Form/Validate/CollectionRoleNameUnique.php +++ b/library/Application/Form/Validate/CollectionRoleNameUnique.php @@ -27,11 +27,13 @@ * @category Application * @package Form_Validate * @author Jens Schwidder - * @copyright Copyright (c) 2008-2014, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_Form_Validate_CollectionRoleNameUnique extends Zend_Validate_Abstract + +use Opus\CollectionRole; + +class Application_Form_Validate_CollectionRoleNameUnique extends \Zend_Validate_Abstract { const NAME_NOT_UNIQUE = 'notUnique'; @@ -49,7 +51,7 @@ class Application_Form_Validate_CollectionRoleNameUnique extends Zend_Validate_A * * @param mixed $value * @return boolean - * @throws Zend_Validate_Exception If validation of $value is impossible + * @throws \Zend_Validate_Exception If validation of $value is impossible */ public function isValid($value, $context = null) { @@ -77,10 +79,10 @@ public function isValid($value, $context = null) /** * Holt CollectionRole mit Identifier. * @param $identifier - * @return Opus_CollectionRole + * @return CollectionRole */ protected function _getModel($identifier) { - return Opus_CollectionRole::fetchByName($identifier); + return CollectionRole::fetchByName($identifier); } } diff --git a/library/Application/Form/Validate/CollectionRoleOaiNameUnique.php b/library/Application/Form/Validate/CollectionRoleOaiNameUnique.php index 38a0f4c8ee..b0c214581d 100644 --- a/library/Application/Form/Validate/CollectionRoleOaiNameUnique.php +++ b/library/Application/Form/Validate/CollectionRoleOaiNameUnique.php @@ -27,10 +27,12 @@ * @category Application * @package Form_Validate * @author Jens Schwidder - * @copyright Copyright (c) 2008-2013, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ + +use Opus\CollectionRole; + class Application_Form_Validate_CollectionRoleOaiNameUnique extends Application_Form_Validate_CollectionRoleNameUnique { @@ -39,6 +41,6 @@ class Application_Form_Validate_CollectionRoleOaiNameUnique extends Application_ */ protected function _getModel($identifier) { - return Opus_CollectionRole::fetchByOaiName($identifier); + return CollectionRole::fetchByOaiName($identifier); } } diff --git a/library/Application/Form/Validate/DOI.php b/library/Application/Form/Validate/DOI.php index 1f4503c05c..7207cd8e3a 100644 --- a/library/Application/Form/Validate/DOI.php +++ b/library/Application/Form/Validate/DOI.php @@ -26,12 +26,13 @@ * * @category Application * @author Sascha Szott - * @copyright Copyright (c) 2018, OPUS 4 development team + * @copyright Copyright (c) 2018-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_Form_Validate_DOI extends Zend_Validate_Abstract +use Opus\Identifier; + +class Application_Form_Validate_DOI extends \Zend_Validate_Abstract { const NOT_UNIQUE = 'notUnique'; @@ -51,7 +52,7 @@ public function isValid($value, $context = null) { $currentDocId = $context[Admin_Form_Document_IdentifierSpecific::ELEMENT_DOC_ID]; - $doi = new Opus_Identifier(); + $doi = new Identifier(); $doi->setType('doi'); $doi->setValue($value); diff --git a/library/Application/Form/Validate/Date.php b/library/Application/Form/Validate/Date.php index 159eb08847..c96430071e 100644 --- a/library/Application/Form/Validate/Date.php +++ b/library/Application/Form/Validate/Date.php @@ -27,15 +27,14 @@ * @category Application * @package Form_Validate * @author Jens Schwidder - * @copyright Copyright (c) 2008-2013, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Validiert Datumseingaben. */ -class Application_Form_Validate_Date extends Zend_Validate_Date +class Application_Form_Validate_Date extends \Zend_Validate_Date { /** @@ -61,7 +60,7 @@ class Application_Form_Validate_Date extends Zend_Validate_Date /** * Constructs Application_Form_Validate_Date class for validating date input. - * @param array $config Configuration options (see Zend_Validate_Date) + * @param array $config Configuration options (see \Zend_Validate_Date) */ public function __construct($config = null) { @@ -72,9 +71,9 @@ public function __construct($config = null) $this->setMessages( [ - Zend_Validate_Date::INVALID => 'validation_error_date_invalid', - Zend_Validate_Date::INVALID_DATE => 'validation_error_date_invaliddate', - Zend_Validate_Date::FALSEFORMAT => 'validation_error_date_falseformat' + \Zend_Validate_Date::INVALID => 'validation_error_date_invalid', + \Zend_Validate_Date::INVALID_DATE => 'validation_error_date_invaliddate', + \Zend_Validate_Date::FALSEFORMAT => 'validation_error_date_falseformat' ] ); } @@ -89,9 +88,9 @@ public function isValid($value) $this->_setValue($value); // Check first if input matches expected pattern $datePattern = $this->getInputPattern(); - $validator = new Zend_Validate_Regex($datePattern); + $validator = new \Zend_Validate_Regex($datePattern); if (! $validator->isValid($value)) { - $this->_error(Zend_Validate_Date::FALSEFORMAT); + $this->_error(\Zend_Validate_Date::FALSEFORMAT); return false; } @@ -123,12 +122,12 @@ public function setInputPattern($pattern) /** * Sets locale and updated input format automatically. - * @param Zend_Locale $locale + * @param \Zend_Locale $locale */ public function setLocale($locale = null) { parent::setLocale($locale); - if ($locale instanceof Zend_Locale) { + if ($locale instanceof \Zend_Locale) { $dateFormat = $this->getDateFormat($locale->getLanguage()); $inputPattern = $this->getDatePattern($locale->getLanguage()); } else { @@ -146,7 +145,7 @@ public function setLocale($locale = null) public function getDateFormat($locale = null) { if (empty($locale)) { - $session = new Zend_Session_Namespace(); + $session = new \Zend_Session_Namespace(); $language = $session->language; } else { $language = $locale; @@ -162,7 +161,7 @@ public function getDateFormat($locale = null) public function getDatePattern($locale = null) { if (empty($locale)) { - $session = new Zend_Session_Namespace(); + $session = new \Zend_Session_Namespace(); $language = $session->language; } else { $language = $locale; diff --git a/library/Application/Form/Validate/DuplicateMultiValue.php b/library/Application/Form/Validate/DuplicateMultiValue.php index c9c822660f..105e7b9264 100644 --- a/library/Application/Form/Validate/DuplicateMultiValue.php +++ b/library/Application/Form/Validate/DuplicateMultiValue.php @@ -27,12 +27,10 @@ * @category Application * @package Form_Validate * @author Jens Schwidder - * @copyright Copyright (c) 2008-2013, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ - class Application_Form_Validate_DuplicateMultiValue extends Application_Form_Validate_DuplicateValue { diff --git a/library/Application/Form/Validate/DuplicateValue.php b/library/Application/Form/Validate/DuplicateValue.php index 97970ad15a..56ba105b9c 100644 --- a/library/Application/Form/Validate/DuplicateValue.php +++ b/library/Application/Form/Validate/DuplicateValue.php @@ -28,7 +28,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -49,7 +48,7 @@ * * TODO Basisklasse mit getLogger */ -class Application_Form_Validate_DuplicateValue extends Zend_Validate_Abstract +class Application_Form_Validate_DuplicateValue extends \Zend_Validate_Abstract { /** @@ -113,7 +112,7 @@ public function isValid($value, $context = null) $valueCount = count($this->_values); if (! ($this->_position < $valueCount)) { - Zend_Registry::get('Zend_Log')->err( + \Zend_Registry::get('Zend_Log')->err( __CLASS__ . ' mit Position > count(values) konstruiert.' ); @@ -127,7 +126,7 @@ public function isValid($value, $context = null) } } } else { - Zend_Registry::get('Zend_Log')->err(__CLASS__ . ' mit Values = NULL konstruiert.'); + \Zend_Registry::get('Zend_Log')->err(__CLASS__ . ' mit Values = NULL konstruiert.'); } return true; diff --git a/library/Application/Form/Validate/EmailAddress.php b/library/Application/Form/Validate/EmailAddress.php index 31bf05cd66..8ea4e3f14b 100644 --- a/library/Application/Form/Validate/EmailAddress.php +++ b/library/Application/Form/Validate/EmailAddress.php @@ -34,7 +34,7 @@ /** * Email validator with custom messages. */ -class Application_Form_Validate_EmailAddress extends Zend_Validate_EmailAddress +class Application_Form_Validate_EmailAddress extends \Zend_Validate_EmailAddress { public function __construct($options = []) diff --git a/library/Application/Form/Validate/EnrichmentKeyAvailable.php b/library/Application/Form/Validate/EnrichmentKeyAvailable.php index 243b744edf..c26559272c 100644 --- a/library/Application/Form/Validate/EnrichmentKeyAvailable.php +++ b/library/Application/Form/Validate/EnrichmentKeyAvailable.php @@ -30,15 +30,16 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\EnrichmentKey; + /** * Checks if a enrichmentkey already exists. * * Enrichment key names are not case-sensitive. */ -class Application_Form_Validate_EnrichmentKeyAvailable extends Zend_Validate_Abstract +class Application_Form_Validate_EnrichmentKeyAvailable extends \Zend_Validate_Abstract { /** @@ -91,7 +92,7 @@ public function isValid($value, $context = null) */ protected function _isEnrichmentKeyUsed($name) { - $enrichmentkey = Opus_EnrichmentKey::fetchByName($name); + $enrichmentkey = EnrichmentKey::fetchByName($name); return ! is_null($enrichmentkey); } diff --git a/library/Application/Form/Validate/Filename.php b/library/Application/Form/Validate/Filename.php index 0eead4e84b..ee34eb3848 100644 --- a/library/Application/Form/Validate/Filename.php +++ b/library/Application/Form/Validate/Filename.php @@ -39,7 +39,7 @@ * * TODO don't add delimiter internally - just accept a complete regular expression */ -class Application_Form_Validate_Filename extends Zend_Validate_Abstract +class Application_Form_Validate_Filename extends \Zend_Validate_Abstract { /** * @var int maximal filename length diff --git a/library/Application/Form/Validate/Gnd.php b/library/Application/Form/Validate/Gnd.php index 3a6b9631c1..27c4086360 100644 --- a/library/Application/Form/Validate/Gnd.php +++ b/library/Application/Form/Validate/Gnd.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2008-2017, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Form_Validate_Gnd extends Zend_Validate_Abstract +class Application_Form_Validate_Gnd extends \Zend_Validate_Abstract { /** diff --git a/library/Application/Form/Validate/IMultiSubForm.php b/library/Application/Form/Validate/IMultiSubForm.php index 4c91c3e171..7432b0fdd4 100644 --- a/library/Application/Form/Validate/IMultiSubForm.php +++ b/library/Application/Form/Validate/IMultiSubForm.php @@ -28,7 +28,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/library/Application/Form/Validate/Identifier.php b/library/Application/Form/Validate/Identifier.php index b54dd3227b..b50bf6eaac 100644 --- a/library/Application/Form/Validate/Identifier.php +++ b/library/Application/Form/Validate/Identifier.php @@ -35,27 +35,27 @@ * * This validator is used in the document metadate form. */ -class Application_Form_Validate_Identifier extends Zend_Validate_Abstract +class Application_Form_Validate_Identifier extends \Zend_Validate_Abstract { /** * Form element for the type of identifier. - * @var Zend_Form_Element + * @var \Zend_Form_Element */ private $_element; /** * Application_Form_Validate_Identifier constructor. - * @param Zend_Form_Element $element + * @param \Zend_Form_Element $element */ public function __construct($element) { if ($element === null) { - throw new InvalidArgumentException('Argument must not be NULL'); - } elseif ($element instanceof Zend_Form_Element) { + throw new \InvalidArgumentException('Argument must not be NULL'); + } elseif ($element instanceof \Zend_Form_Element) { $this->_element = $element; } else { - throw new InvalidArgumentException('Object must be Zend_Form_Element'); + throw new \InvalidArgumentException('Object must be Zend_Form_Element'); } } diff --git a/library/Application/Form/Validate/LanguageUsedOnceOnly.php b/library/Application/Form/Validate/LanguageUsedOnceOnly.php index 2a918d9d9b..08477d0c1e 100644 --- a/library/Application/Form/Validate/LanguageUsedOnceOnly.php +++ b/library/Application/Form/Validate/LanguageUsedOnceOnly.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -41,7 +40,7 @@ * * TODO Redundanz mit DuplicateValue eliminieren */ -class Application_Form_Validate_LanguageUsedOnceOnly extends Zend_Validate_Abstract +class Application_Form_Validate_LanguageUsedOnceOnly extends \Zend_Validate_Abstract { /** @@ -81,7 +80,7 @@ public function __construct($languages, $position) { $this->_languages = $languages; $this->_position = $position; - $this->setTranslator(Zend_Registry::get(Application_Translate::REGISTRY_KEY)); + $this->setTranslator(\Zend_Registry::get(Application_Translate::REGISTRY_KEY)); } /** @@ -99,7 +98,7 @@ public function isValid($value, $context = null) $langCount = count($this->_languages); if (! ($this->_position < $langCount)) { - Zend_Registry::get('Zend_Log')->err(__CLASS__ . ' mit Position > count(Languages) konstruiert.'); + \Zend_Registry::get('Zend_Log')->err(__CLASS__ . ' mit Position > count(Languages) konstruiert.'); } if (! is_null($this->_languages)) { @@ -110,7 +109,7 @@ public function isValid($value, $context = null) } } } else { - Zend_Registry::get('Zend_Log')->err(__CLASS__ . ' mit Languages = NULL konstruiert.'); + \Zend_Registry::get('Zend_Log')->err(__CLASS__ . ' mit Languages = NULL konstruiert.'); } return true; diff --git a/library/Application/Form/Validate/LoginAvailable.php b/library/Application/Form/Validate/LoginAvailable.php index e93fa9e019..8431169d5e 100644 --- a/library/Application/Form/Validate/LoginAvailable.php +++ b/library/Application/Form/Validate/LoginAvailable.php @@ -28,13 +28,14 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Account; + /** * Checks if a login already exists. */ -class Application_Form_Validate_LoginAvailable extends Zend_Validate_Abstract +class Application_Form_Validate_LoginAvailable extends \Zend_Validate_Abstract { /** @@ -114,7 +115,7 @@ public function isValid($value, $context = null) protected function _isLoginUsed($login) { try { - $account = new Opus_Account(null, null, $login); + $account = new Account(null, null, $login); } catch (Exception $ex) { return false; } diff --git a/library/Application/Form/Validate/MultiSubForm/RepeatedLanguages.php b/library/Application/Form/Validate/MultiSubForm/RepeatedLanguages.php index 2be333e4ee..c43e345497 100644 --- a/library/Application/Form/Validate/MultiSubForm/RepeatedLanguages.php +++ b/library/Application/Form/Validate/MultiSubForm/RepeatedLanguages.php @@ -28,7 +28,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/library/Application/Form/Validate/MultiSubForm/RepeatedValues.php b/library/Application/Form/Validate/MultiSubForm/RepeatedValues.php index f8e5fb109f..353ff545de 100644 --- a/library/Application/Form/Validate/MultiSubForm/RepeatedValues.php +++ b/library/Application/Form/Validate/MultiSubForm/RepeatedValues.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ @@ -59,7 +58,7 @@ public function __construct($elementName, $message, $otherElements = null) $this->_elementName = $elementName; $this->_otherElements = $otherElements; - $translator = Zend_Registry::get(Application_Translate::REGISTRY_KEY); + $translator = \Zend_Registry::get(Application_Translate::REGISTRY_KEY); if ($translator->isTranslated($message)) { $this->_message = $translator->translate($message); diff --git a/library/Application/Form/Validate/Orcid.php b/library/Application/Form/Validate/Orcid.php index 3a8d68f330..f99db2fef4 100644 --- a/library/Application/Form/Validate/Orcid.php +++ b/library/Application/Form/Validate/Orcid.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -38,7 +37,7 @@ * @category Application * @package Form_Validate */ -class Application_Form_Validate_Orcid extends Zend_Validate_Abstract +class Application_Form_Validate_Orcid extends \Zend_Validate_Abstract { /** diff --git a/library/Application/Form/Validate/Password.php b/library/Application/Form/Validate/Password.php index df35a05aa5..94f0106da7 100644 --- a/library/Application/Form/Validate/Password.php +++ b/library/Application/Form/Validate/Password.php @@ -26,14 +26,13 @@ * * @category TODO * @author Jens Schwidder - * @copyright Copyright (c) 2008-2010, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * TODO if password is not set should the result be TRUE? */ -class Application_Form_Validate_Password extends Zend_Validate_Abstract +class Application_Form_Validate_Password extends \Zend_Validate_Abstract { const NOT_MATCH = 'notMatch'; diff --git a/library/Application/Form/Validate/RequiredIf.php b/library/Application/Form/Validate/RequiredIf.php index d7ce72d9c0..034de73abe 100644 --- a/library/Application/Form/Validate/RequiredIf.php +++ b/library/Application/Form/Validate/RequiredIf.php @@ -26,11 +26,10 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @category Application - * @package Opus_Form + * @package Opus\Form * @author Jens Schwidder - * @copyright Copyright (c) 2010, OPUS 4 development team + * @copyright Copyright (c) 2010-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -39,7 +38,7 @@ * The field becomes required, so it can't be empty, if another field meets a * certain condition. */ -class Application_Form_Validate_RequiredIf extends Zend_Validate_Abstract +class Application_Form_Validate_RequiredIf extends \Zend_Validate_Abstract { const FAILED = 'failed'; @@ -111,10 +110,10 @@ protected function _checkTargetField($context = null) if (empty($this->_expectedValue)) { // if no targetValue has been set check if notEmpty - $result = ! Zend_Validate::is($otherValue, "NotEmpty"); + $result = ! \Zend_Validate::is($otherValue, "NotEmpty"); } else { // check if targetValue is expected - $result = ! Zend_Validate::is($otherValue, "Identical", ['token' => $this->_expectedValue]); + $result = ! \Zend_Validate::is($otherValue, "Identical", ['token' => $this->_expectedValue]); } } else { // if value wasn't set diff --git a/library/Application/Form/Validate/RoleAvailable.php b/library/Application/Form/Validate/RoleAvailable.php index f76106876c..7f98b12ac8 100644 --- a/library/Application/Form/Validate/RoleAvailable.php +++ b/library/Application/Form/Validate/RoleAvailable.php @@ -28,13 +28,14 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\UserRole; + /** * Checks if a role already exists. */ -class Application_Form_Validate_RoleAvailable extends Zend_Validate_Abstract +class Application_Form_Validate_RoleAvailable extends \Zend_Validate_Abstract { /** @@ -93,7 +94,7 @@ public function isValid($value, $context = null) protected function _isRoleUsed($role) { try { - $role = Opus_UserRole::fetchByName($role); + $role = UserRole::fetchByName($role); if (empty($role)) { return false; diff --git a/library/Application/Form/Validate/SeriesNumberAvailable.php b/library/Application/Form/Validate/SeriesNumberAvailable.php index 967419c445..6236e984a0 100644 --- a/library/Application/Form/Validate/SeriesNumberAvailable.php +++ b/library/Application/Form/Validate/SeriesNumberAvailable.php @@ -28,15 +28,17 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Series; +use Opus\Model\NotFoundException; + /** * Checks if a number already exists in a series. * * TODO Basisklasse mit setLogger verwenden */ -class Application_Form_Validate_SeriesNumberAvailable extends Zend_Validate_Abstract +class Application_Form_Validate_SeriesNumberAvailable extends \Zend_Validate_Abstract { /** @@ -73,14 +75,14 @@ public function isValid($value, $context = null) } if (strlen(trim($seriesId)) == 0 && is_numeric($seriesId)) { - Zend_Registry::get('Zend_Log')->err(__METHOD__ . ' Context without \'SeriesId\'.'); + \Zend_Registry::get('Zend_Log')->err(__METHOD__ . ' Context without \'SeriesId\'.'); return true; // should be captured somewhere else } try { - $series = new Opus_Series($seriesId); - } catch (Opus_Model_NotFoundException $omnfe) { - Zend_Registry::get('Zend_Log')->err(__METHOD__ . $omnfe->getMessage()); + $series = new Series($seriesId); + } catch (NotFoundException $omnfe) { + \Zend_Registry::get('Zend_Log')->err(__METHOD__ . $omnfe->getMessage()); return true; } diff --git a/library/Application/Form/Validate/URN.php b/library/Application/Form/Validate/URN.php index 4a1695e5c3..31a1ee598c 100644 --- a/library/Application/Form/Validate/URN.php +++ b/library/Application/Form/Validate/URN.php @@ -28,10 +28,11 @@ * @author Sascha Szott * @copyright Copyright (c) 2018, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_Form_Validate_URN extends Zend_Validate_Abstract +use Opus\Identifier; + +class Application_Form_Validate_URN extends \Zend_Validate_Abstract { const NOT_UNIQUE = 'notUnique'; @@ -51,7 +52,7 @@ public function isValid($value, $context = null) { $currentDocId = $context[Admin_Form_Document_IdentifierSpecific::ELEMENT_DOC_ID]; - $urn = new Opus_Identifier(); + $urn = new Identifier(); $urn->setValue($value); if (! ($urn->isUrnUnique($currentDocId))) { diff --git a/library/Application/Form/Validate/ValuePresentInSubforms.php b/library/Application/Form/Validate/ValuePresentInSubforms.php index f8ca7ebbfd..52af725cfa 100644 --- a/library/Application/Form/Validate/ValuePresentInSubforms.php +++ b/library/Application/Form/Validate/ValuePresentInSubforms.php @@ -27,9 +27,8 @@ * @category Application * @package Form_Validate * @author Jens Schwidder - * @copyright Copyright (c) 2013, OPUS 4 development team + * @copyright Copyright (c) 2013-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -37,7 +36,7 @@ * * Wird für die Prüfung verwendet, ob ein TitleMain in der Dokumentensprache vorliegt. */ -class Application_Form_Validate_ValuePresentInSubforms extends Zend_Validate_Abstract +class Application_Form_Validate_ValuePresentInSubforms extends \Zend_Validate_Abstract { /** @@ -88,7 +87,7 @@ public function isValid($value, $context = null) } } } else { - Zend_Registry::get('Zend_Log')->err(__CLASS__ . '::' . __METHOD__ . ' mit $context = null aufgerufen.'); + \Zend_Registry::get('Zend_Log')->err(__CLASS__ . '::' . __METHOD__ . ' mit $context = null aufgerufen.'); } $this->_error(self::NOT_VALID); diff --git a/library/Application/Import/AdditionalEnrichments.php b/library/Application/Import/AdditionalEnrichments.php index 481a0ccdc4..caf011c0d2 100644 --- a/library/Application/Import/AdditionalEnrichments.php +++ b/library/Application/Import/AdditionalEnrichments.php @@ -44,6 +44,9 @@ * * */ + +use Opus\EnrichmentKey; + class Application_Import_AdditionalEnrichments { const OPUS_IMPORT_USER = 'opus.import.user'; @@ -82,7 +85,7 @@ private function checkKeysExist() private function keyExist($key) { - $enrichmentkey = Opus_EnrichmentKey::fetchByName($key); + $enrichmentkey = EnrichmentKey::fetchByName($key); return ! is_null($enrichmentkey); } diff --git a/library/Application/Import/ArrayImport.php b/library/Application/Import/ArrayImport.php index 6d91cde735..f369db8950 100644 --- a/library/Application/Import/ArrayImport.php +++ b/library/Application/Import/ArrayImport.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + class Application_Import_ArrayImport { @@ -41,6 +43,6 @@ class Application_Import_ArrayImport */ public function import($data) { - $document = Opus_Document::fromArray($data); + $document = Document::fromArray($data); } } diff --git a/library/Application/Import/BibtexImporter.php b/library/Application/Import/BibtexImporter.php index 77e07a1bba..c6b73123a5 100644 --- a/library/Application/Import/BibtexImporter.php +++ b/library/Application/Import/BibtexImporter.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Util\ConsoleColors; + /** * Performs command line import of BibTeX file. * @@ -52,7 +54,7 @@ public function run($arguments) { $filename = $arguments[1]; - $colors = new Opus_Util_ConsoleColors(); + $colors = new ConsoleColors(); if (! is_readable($filename)) { echo $colors->red('File not found or readable.' . PHP_EOL); diff --git a/library/Application/Import/CsvImporter.php b/library/Application/Import/CsvImporter.php index b3305bd291..4b197b68b6 100755 --- a/library/Application/Import/CsvImporter.php +++ b/library/Application/Import/CsvImporter.php @@ -29,8 +29,8 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ + /** * * TODO: dieses Skript wird aktuell nicht in den Tarball / Deb-Package aufgenommen @@ -41,6 +41,17 @@ * */ +use Opus\Collection; +use Opus\Document; +use Opus\EnrichmentKey; +use Opus\File; +use Opus\Identifier; +use Opus\Licence; +use Opus\Person; +use Opus\Series; +use Opus\UserRole; +use Opus\Model\NotFoundException; + class Application_Import_CsvImporter { // das ist aktuell nur eine Auswahl der Metadatenfelder (speziell für Fromm zugeschnitten) @@ -103,7 +114,7 @@ public function run($argv) echo "fulltext directory '" . $argv[2] . "' is not readable -- check path or permissions\n"; } else { $this->_fulltextDir = $argv[2]; - $this->_guestRole = Opus_UserRole::fetchByName('guest'); + $this->_guestRole = UserRole::fetchByName('guest'); } } @@ -153,7 +164,7 @@ public function run($argv) private function processRow($row) { - $doc = new Opus_Document(); + $doc = Document::new(); $oldId = $row[self::OLD_ID]; @@ -195,7 +206,7 @@ private function processRow($row) $doc->store(); - if (! is_null($file) && $file instanceof Opus_File && ! is_null($this->_guestRole)) { + if (! is_null($file) && $file instanceof File && ! is_null($this->_guestRole)) { $this->_guestRole->appendAccessFile($file->getId()); $this->_guestRole->store(); } @@ -304,7 +315,7 @@ private function processPersons($row, $doc, $oldId) private function addPerson($doc, $type, $firstname, $lastname, $oldId) { - $p = new Opus_Person(); + $p = new Person(); if (trim($firstname) == '') { echo "Datensatz $oldId ohne Wert für $type.firstname\n"; } else { @@ -352,7 +363,7 @@ private function processIdentifier($row, $doc, $oldId) private function addIdentifier($doc, $type, $value) { - $identifier = new Opus_Identifier(); + $identifier = new Identifier(); $identifier->setValue(trim($value)); $identifier->setType(trim($type)); $method = 'addIdentifier' . ucfirst(trim($type)); @@ -385,9 +396,9 @@ private function processCollections($row, $doc) $collectionId = trim($collId); // check if collection with given id exists try { - $c = new Opus_Collection($collectionId); + $c = new Collection($collectionId); $doc->addCollection($c); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { throw new Exception('collection id ' . $collectionId . ' does not exist: ' . $e->getMessage()); } } @@ -400,9 +411,9 @@ private function processLicence($row, $doc, $oldId) if (trim($row[self::LICENCE_ID]) != '') { $licenceId = trim($row[self::LICENCE_ID]); try { - $l = new Opus_Licence($licenceId); + $l = new Licence($licenceId); $doc->addLicence($l); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { throw new Exception('licence id ' . $licenceId . ' does not exist: ' . $e->getMessage()); } } else { @@ -410,31 +421,31 @@ private function processLicence($row, $doc, $oldId) $format = trim($row[self::ENRICHMENT_FORMAT]); if (! (strpos($format, 'no download') == false) || ! (strpos($format, 'no copy') == false)) { - $l = new Opus_Licence(11); + $l = new Licence(11); $doc->addLicence($l); return; } if (! (strpos($format, 'xerox') == false)) { - $l = new Opus_Licence(13); + $l = new Licence(13); $doc->addLicence($l); return; } if (! (strpos($format, 'to download') == false)) { - $l = new Opus_Licence(9); + $l = new Licence(9); $doc->addLicence($l); return; } if (! (strpos($format, 'upon request') == false)) { - $l = new Opus_Licence(10); + $l = new Licence(10); $doc->addLicence($l); return; } if (! (strpos($format, 'to purchase') == false)) { - $l = new Opus_Licence(12); + $l = new Licence(12); $doc->addLicence($l); return; } @@ -461,8 +472,8 @@ private function processEnrichment($enrichmentkey, $row, $doc, $oldId = null) $key = trim($matches[1]); // check if enrichment key exists try { - new Opus_EnrichmentKey($key); - } catch (Opus_Model_NotFoundException $e) { + new EnrichmentKey($key); + } catch (NotFoundException $e) { throw new Exception('enrichment key ' . $key . ' does not exist: ' . $e->getMessage()); } @@ -498,7 +509,7 @@ private function processSeries($row, $doc) $seriesIdTrimmed = trim($seriesId); // check if series with given id exists try { - $series = new Opus_Series($seriesIdTrimmed); + $series = new Series($seriesIdTrimmed); $seriesNumber = 0; if (array_key_exists($seriesIdTrimmed, $this->_seriesIdsMap)) { @@ -507,7 +518,7 @@ private function processSeries($row, $doc) $seriesNumber++; $doc->addSeries($series)->setNumber($seriesNumber); $this->_seriesIdsMap[$seriesIdTrimmed] = $seriesNumber; - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { throw new Exception('series id ' . $seriesIdTrimmed . ' does not exist: ' . $e->getMessage()); } } diff --git a/library/Application/Import/Importer.php b/library/Application/Import/Importer.php index 9f641a235b..15c09ad9c5 100644 --- a/library/Application/Import/Importer.php +++ b/library/Application/Import/Importer.php @@ -28,9 +28,23 @@ * @package Import * @author Sascha Szott * @author Jens Schwidder - * @copyright Copyright (c) 2016-2018 + * @copyright Copyright (c) 2016-2020 * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Collection; +use Opus\DnbInstitute; +use Opus\Document; +use Opus\EnrichmentKey; +use Opus\File; +use Opus\Licence; +use Opus\Person; +use Opus\Series; +use Opus\Subject; +use Opus\Model\ModelException; +use Opus\Model\NotFoundException; +use Opus\Security\SecurityException; + class Application_Import_Importer { @@ -64,7 +78,7 @@ class Application_Import_Importer * * Contains the document object if the import was successful. * - * @var Opus_Document + * @var Document */ private $document; @@ -111,7 +125,7 @@ public function setImportCollection($importCollection) private function initDocument() { - $doc = new Opus_Document(); + $doc = Document::new(); // since OPUS 4.5 attribute serverState is optional: if no attribute // value is given we set server state to unpublished $doc->setServerState('unpublished'); @@ -121,8 +135,8 @@ private function initDocument() /** * @throws Application_Import_MetadataImportInvalidXmlException * @throws Application_Import_MetadataImportSkippedDocumentsException - * @throws Opus_Model_Exception - * @throws Opus_Security_Exception + * @throws ModelException + * @throws SecurityException */ public function run() { @@ -150,7 +164,7 @@ public function run() } /* - * @var Opus_Document + * @var Document */ $doc = null; if ($opusDocumentElement->hasAttribute('docId')) { @@ -166,9 +180,9 @@ public function run() // with the given document are not deleted or updated $docId = $opusDocumentElement->getAttribute('docId'); try { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $opusDocumentElement->removeAttribute('docId'); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { $this->log('Could not load document #' . $docId . ' from database: ' . $e->getMessage()); $this->appendDocIdToRejectList($oldId); $numOfSkippedDocs++; @@ -306,7 +320,7 @@ public function keepFieldsOnUpdate($fields) /** * - * @param Opus_Document $doc + * @param Document $doc */ private function resetDocument($doc) { @@ -361,7 +375,7 @@ private function resetDocument($doc) /** * * @param DOMNamedNodeMap $attributes - * @param Opus_Document $doc + * @param Document $doc */ private function processAttributes($attributes, $doc) { @@ -381,8 +395,8 @@ private function processAttributes($attributes, $doc) /** * - * @param DOMNodeList $elements - * @param Opus_Document $doc + * @param \DOMNodeList $elements + * @param Document $doc * * @return boolean returns true if the import XML definition of the * currently processed document contains the first level @@ -393,7 +407,7 @@ private function processElements($elements, $doc) $filesElementPresent = false; foreach ($elements as $node) { - if ($node instanceof DOMElement) { + if ($node instanceof \DOMElement) { switch ($node->tagName) { case 'titlesMain': $this->handleTitleMain($node, $doc); @@ -451,13 +465,13 @@ private function processElements($elements, $doc) /** * - * @param DOMNode $node - * @param Opus_Document $doc + * @param \DOMNode $node + * @param Document $doc */ private function handleTitleMain($node, $doc) { foreach ($node->childNodes as $childNode) { - if ($childNode instanceof DOMElement) { + if ($childNode instanceof \DOMElement) { $t = $doc->addTitleMain(); $t->setValue(trim($childNode->textContent)); $t->setLanguage(trim($childNode->getAttribute('language'))); @@ -467,13 +481,13 @@ private function handleTitleMain($node, $doc) /** * - * @param DOMNode $node - * @param Opus_Document $doc + * @param \DOMNode $node + * @param Document $doc */ private function handleTitles($node, $doc) { foreach ($node->childNodes as $childNode) { - if ($childNode instanceof DOMElement) { + if ($childNode instanceof \DOMElement) { $method = 'addTitle' . ucfirst($childNode->getAttribute('type')); $t = $doc->$method(); $t->setValue(trim($childNode->textContent)); @@ -484,13 +498,13 @@ private function handleTitles($node, $doc) /** * - * @param DOMNode $node - * @param Opus_Document $doc + * @param \DOMNode $node + * @param Document $doc */ private function handleAbstracts($node, $doc) { foreach ($node->childNodes as $childNode) { - if ($childNode instanceof DOMElement) { + if ($childNode instanceof \DOMElement) { $t = $doc->addTitleAbstract(); $t->setValue(trim($childNode->textContent)); $t->setLanguage(trim($childNode->getAttribute('language'))); @@ -500,14 +514,14 @@ private function handleAbstracts($node, $doc) /** * - * @param DOMNode $node - * @param Opus_Document $doc + * @param \DOMNode $node + * @param Document $doc */ private function handlePersons($node, $doc) { foreach ($node->childNodes as $childNode) { - if ($childNode instanceof DOMElement) { - $p = new Opus_Person(); + if ($childNode instanceof \DOMElement) { + $p = new Person(); // mandatory fields $p->setFirstName(trim($childNode->getAttribute('firstName'))); @@ -545,15 +559,15 @@ private function handlePersons($node, $doc) /** * - * @param DOMNodeList $identifiers - * @param Opus_Person $person + * @param \DOMNodeList $identifiers + * @param Person $person */ private function handlePersonIdentifiers($identifiers, $person) { $identifiers = $identifiers->childNodes; $idTypesFound = []; // print log message if an identifier type is used more than once foreach ($identifiers as $identifier) { - if ($identifier instanceof DOMElement && $identifier->tagName == 'identifier') { + if ($identifier instanceof \DOMElement && $identifier->tagName == 'identifier') { $idType = $identifier->getAttribute('type'); if ($idType == 'intern') { $idType = 'misc'; @@ -572,14 +586,14 @@ private function handlePersonIdentifiers($identifiers, $person) /** * - * @param DOMNode $node - * @param Opus_Document $doc + * @param \DOMNode $node + * @param Document $doc */ private function handleKeywords($node, $doc) { foreach ($node->childNodes as $childNode) { - if ($childNode instanceof DOMElement) { - $s = new Opus_Subject(); + if ($childNode instanceof \DOMElement) { + $s = new Subject(); $s->setLanguage(trim($childNode->getAttribute('language'))); $s->setType($childNode->getAttribute('type')); $s->setValue(trim($childNode->textContent)); @@ -590,18 +604,18 @@ private function handleKeywords($node, $doc) /** * - * @param DOMNode $node - * @param Opus_Document $doc + * @param \DOMNode $node + * @param Document $doc */ private function handleDnbInstitutions($node, $doc) { foreach ($node->childNodes as $childNode) { - if ($childNode instanceof DOMElement) { + if ($childNode instanceof \DOMElement) { $instId = trim($childNode->getAttribute('id')); $instRole = $childNode->getAttribute('role'); // check if dnbInstitute with given id and role exists try { - $inst = new Opus_DnbInstitute($instId); + $inst = new DnbInstitute($instId); // check if dnbInstitute supports given role $method = 'getIs' . ucfirst($instRole); @@ -611,7 +625,7 @@ private function handleDnbInstitutions($node, $doc) } else { throw new Exception('given role ' . $instRole . ' is not allowed for dnbInstitution id ' . $instId); } - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { $msg = 'dnbInstitution id ' . $instId . ' does not exist: ' . $e->getMessage(); if ($this->swordContext) { $this->log($msg); @@ -625,13 +639,13 @@ private function handleDnbInstitutions($node, $doc) /** * - * @param DOMNode $node - * @param Opus_Document $doc + * @param \DOMNode $node + * @param Document $doc */ private function handleIdentifiers($node, $doc) { foreach ($node->childNodes as $childNode) { - if ($childNode instanceof DOMElement) { + if ($childNode instanceof \DOMElement) { $i = $doc->addIdentifier(); $i->setValue(trim($childNode->textContent)); $i->setType($childNode->getAttribute('type')); @@ -641,8 +655,8 @@ private function handleIdentifiers($node, $doc) /** * - * @param DOMNode $node - * @param Opus_Document $doc + * @param \DOMNode $node + * @param Document $doc */ private function handleNotes($node, $doc) { @@ -657,8 +671,8 @@ private function handleNotes($node, $doc) /** * - * @param DOMNode $node - * @param Opus_Document $doc + * @param \DOMNode $node + * @param Document $doc */ private function handleCollections($node, $doc) { @@ -667,9 +681,9 @@ private function handleCollections($node, $doc) $collectionId = trim($childNode->getAttribute('id')); // check if collection with given id exists try { - $c = new Opus_Collection($collectionId); + $c = new Collection($collectionId); $doc->addCollection($c); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { $msg = 'collection id ' . $collectionId . ' does not exist: ' . $e->getMessage(); if ($this->swordContext) { $this->log($msg); @@ -684,7 +698,7 @@ private function handleCollections($node, $doc) /** * * @param DOMNode $node - * @param Opus_Document $doc + * @param Document $doc */ private function handleSeries($node, $doc) { @@ -693,10 +707,10 @@ private function handleSeries($node, $doc) $seriesId = trim($childNode->getAttribute('id')); // check if document set with given id exists try { - $s = new Opus_Series($seriesId); + $s = new Series($seriesId); $link = $doc->addSeries($s); $link->setNumber(trim($childNode->getAttribute('number'))); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { $msg = 'series id ' . $seriesId . ' does not exist: ' . $e->getMessage(); if ($this->swordContext) { $this->log($msg); @@ -712,7 +726,7 @@ private function handleSeries($node, $doc) * Processes the enrichments in the document xml. * * @param DOMNode $node - * @param Opus_Document $doc + * @param Document $doc */ private function handleEnrichments($node, $doc) { @@ -721,8 +735,8 @@ private function handleEnrichments($node, $doc) $key = trim($childNode->getAttribute('key')); // check if enrichment key exists try { - new Opus_EnrichmentKey($key); - } catch (Opus_Model_NotFoundException $e) { + new EnrichmentKey($key); + } catch (NotFoundException $e) { $msg = 'enrichment key ' . $key . ' does not exist: ' . $e->getMessage(); if ($this->swordContext) { $this->log($msg); @@ -738,9 +752,9 @@ private function handleEnrichments($node, $doc) /** * Adds an enrichment to the document. - * @param $doc Opus_Document - * @param $key Name of enrichment - * @param $value Value of enrichment + * @param $doc Document + * @param $key string Name of enrichment + * @param $value string Value of enrichment */ private function addEnrichment($doc, $key, $value) { @@ -757,7 +771,7 @@ private function addEnrichment($doc, $key, $value) /** * * @param DOMNode $node - * @param Opus_Document $doc + * @param Document $doc */ private function handleLicences($node, $doc) { @@ -765,9 +779,9 @@ private function handleLicences($node, $doc) if ($childNode instanceof DOMElement) { $licenceId = trim($childNode->getAttribute('id')); try { - $l = new Opus_Licence($licenceId); + $l = new Licence($licenceId); $doc->addLicence($l); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { $msg = 'licence id ' . $licenceId . ' does not exist: ' . $e->getMessage(); if ($this->swordContext) { $this->log($msg); @@ -782,7 +796,7 @@ private function handleLicences($node, $doc) /** * * @param DOMNode $node - * @param Opus_Document $doc + * @param Document $doc */ private function handleDates($node, $doc) { @@ -816,7 +830,7 @@ private function handleDates($node, $doc) * Handling of files was introduced with OPUS 4.6. * * @param DOMNode $node - * @param Opus_Document $doc + * @param Document $doc * @param string $baseDir */ private function handleFiles($node, $doc, $baseDir) @@ -837,10 +851,10 @@ private function handleFiles($node, $doc, $baseDir) /** * - * Add a single file to the given Opus_Document. + * Add a single file to the given Document. * - * @param Opus_Document $doc the given document - * @param type $name name of the file that should be imported (relative to baseDir) + * @param Document $doc the given document + * @param $name string Name of the file that should be imported (relative to baseDir) * @param string $baseDir (optional) path of the file that should be imported (relative to the import directory) * @param string $path (optional) path (and name) of the file that should be imported (relative to baseDir) * @param DOMNodeList $childNode (optional) additional metadata of the file (taken from import XML) @@ -868,7 +882,7 @@ private function addSingleFile($doc, $name, $baseDir = '', $path = '', $childNod return; } - $file = new Opus_File(); + $file = new File(); if (! is_null($childNode)) { $this->handleFileAttributes($childNode, $file); } @@ -899,7 +913,7 @@ private function addSingleFile($doc, $name, $baseDir = '', $path = '', $childNod * Prüft, ob die übergebene Datei überhaupt importiert werden darf. * Dazu gibt es in der Konfiguration die Schlüssel filetypes.mimetypes.* * - * @param type $fullPath + * @param $fullPath string * * TODO move check to file types helper? */ @@ -909,7 +923,7 @@ private function validMimeType($fullPath) $finfo = new finfo(FILEINFO_MIME_TYPE); $mimeTypeFound = $finfo->file($fullPath); - $fileTypes = Zend_Controller_Action_HelperBroker::getStaticHelper('fileTypes'); + $fileTypes = \Zend_Controller_Action_HelperBroker::getStaticHelper('fileTypes'); return $fileTypes->isValidMimeType($mimeTypeFound, $extension); } @@ -941,8 +955,8 @@ private function checksumValidation($childNode, $fullPath) /** * - * @param DOMElement $node - * @param Opus_File $file + * @param \DOMElement $node + * @param File $file */ private function handleFileAttributes($node, $file) { @@ -980,7 +994,7 @@ private function handleFileAttributes($node, $file) * Add all files in the root level of the import package to the given * document. * - * @param Opus_Document $doc document + * @param Document $doc document */ private function importFilesDirectly($doc) { @@ -992,7 +1006,7 @@ private function importFilesDirectly($doc) /** * Returns the imported document. - * @return Opus_Document + * @return Document */ public function getDocument() { diff --git a/library/Application/Import/MetadataImportInvalidXmlException.php b/library/Application/Import/MetadataImportInvalidXmlException.php index 93132c38f3..05cee2b4b0 100644 --- a/library/Application/Import/MetadataImportInvalidXmlException.php +++ b/library/Application/Import/MetadataImportInvalidXmlException.php @@ -31,6 +31,6 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Import_MetadataImportInvalidXmlException extends Exception +class Application_Import_MetadataImportInvalidXmlException extends \Exception { } diff --git a/library/Application/Import/MetadataImportSkippedDocumentsException.php b/library/Application/Import/MetadataImportSkippedDocumentsException.php index 454cecdeec..650c99eb57 100644 --- a/library/Application/Import/MetadataImportSkippedDocumentsException.php +++ b/library/Application/Import/MetadataImportSkippedDocumentsException.php @@ -31,6 +31,6 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_Import_MetadataImportSkippedDocumentsException extends Exception +class Application_Import_MetadataImportSkippedDocumentsException extends \Exception { } diff --git a/library/Application/Import/PackageReader.php b/library/Application/Import/PackageReader.php index 6ce01e6d39..2c9413deec 100644 --- a/library/Application/Import/PackageReader.php +++ b/library/Application/Import/PackageReader.php @@ -36,6 +36,10 @@ * * Currently ZIP and TAR files are supported by extending classes. */ + +use Opus\Model\ModelException; +use Opus\Security\SecurityException; + abstract class Application_Import_PackageReader { const METADATA_FILENAME = 'opus.xml'; @@ -57,13 +61,13 @@ public function setAdditionalEnrichments($additionalEnrichments) * Verarbeitet das XML-Metadatendokument, dessen Inhalt in $xml übergeben wird. * Zugehörige Volltextdateien werden aus dem Verzeichnis $dirName gelesen. * - * @param $xml Ausgelesener Inhalt der XML-Metadatendatei - * @param $dirName Pfad zum Extraktionsverzeichnis + * @param $xml string Ausgelesener Inhalt der XML-Metadatendatei + * @param $dirName string Pfad zum Extraktionsverzeichnis * @return Application_Import_ImportStatusDocument Statusdokument mit Informationen zum Ergebnis des Imports * @throws Application_Import_MetadataImportInvalidXmlException * @throws Application_Import_MetadataImportSkippedDocumentsException - * @throws Opus_Model_Exception - * @throws Opus_Security_Exception + * @throws ModelException + * @throws SecurityException * @throws Zend_Exception */ private function processOpusXML($xml, $dirName) @@ -115,7 +119,7 @@ public function readPackage($dirName) public function getLogger() { - return Zend_Registry::get('Zend_Log'); + return \Zend_Registry::get('Zend_Log'); } /** diff --git a/library/Application/Model/Abstract.php b/library/Application/Model/Abstract.php index 73298d87df..d689f3aef6 100644 --- a/library/Application/Model/Abstract.php +++ b/library/Application/Model/Abstract.php @@ -49,7 +49,7 @@ abstract class Application_Model_Abstract * Sets configuration. * @param $config Zend_Config */ - public function setConfig(Zend_Config $config = null) + public function setConfig(\Zend_Config $config = null) { $this->_config = $config; } @@ -62,7 +62,7 @@ public function setConfig(Zend_Config $config = null) public function getConfig() { if (is_null($this->_config)) { - $this->_config = Zend_Registry::get('Zend_Config'); + $this->_config = \Zend_Registry::get('Zend_Config'); } return $this->_config; } diff --git a/library/Application/Search/Facet.php b/library/Application/Search/Facet.php index 39241b0f40..c305087398 100644 --- a/library/Application/Search/Facet.php +++ b/library/Application/Search/Facet.php @@ -172,7 +172,7 @@ public function getSize() /** * TODO Should probably move into Opus\Search\Result\Facet(Item) - * TODO $facetValue = $this->translate('Opus_Document_ServerState_Value_' . ucfirst($facetValue)); + * TODO $facetValue = $this->translate('Document_ServerState_Value_' . ucfirst($facetValue)); * */ public function getLabel($value) @@ -205,7 +205,7 @@ public function setTranslated($translated) public function getTranslator() { - return Zend_Registry::get('Zend_Translate'); + return \Zend_Registry::get('Zend_Translate'); } public function setTranslationPrefix($prefix) diff --git a/library/Application/Search/FacetManager.php b/library/Application/Search/FacetManager.php index ab2e0e30db..e2726125b1 100644 --- a/library/Application/Search/FacetManager.php +++ b/library/Application/Search/FacetManager.php @@ -82,7 +82,7 @@ public function getFacetConfig($name) // cache configuration $config = $this->getConfig(); - $default = new Zend_Config($config->search->facet->default->toArray(), true); + $default = new \Zend_Config($config->search->facet->default->toArray(), true); if (isset($config->search->facet->$name)) { $facetConfig = $default->merge($config->search->facet->$name); diff --git a/library/Application/SearchException.php b/library/Application/SearchException.php index a4c01c2d09..b8c2db6902 100644 --- a/library/Application/SearchException.php +++ b/library/Application/SearchException.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_SearchException extends Application_Exception diff --git a/library/Application/Security/AclProvider.php b/library/Application/Security/AclProvider.php index dbf27118ca..09e7670c0c 100644 --- a/library/Application/Security/AclProvider.php +++ b/library/Application/Security/AclProvider.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Security\Realm; +use Opus\Security\SecurityException; + /** * Erzeugt das Zend_Acl object für die Prüfung von Nutzerprivilegien. * @@ -94,10 +97,10 @@ public static function init() $aclProvider->getLogger()->debug('ACL: bootrapping'); - Zend_Registry::set('Opus_Acl', $acl); + \Zend_Registry::set('Opus_Acl', $acl); - Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl); - Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole( + \Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl); + \Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole( Application_Security_AclProvider::ACTIVE_ROLE ); } @@ -109,24 +112,24 @@ public function getAcls() { $logger = $this->getLogger(); - $acl = new Zend_Acl(); + $acl = new \Zend_Acl(); $this->loadResources($acl); - $realm = Opus_Security_Realm::getInstance(); + $realm = Realm::getInstance(); if (isset($_SERVER['REMOTE_ADDR']) and preg_match('/:/', $_SERVER['REMOTE_ADDR']) === 0) { $realm->setIp($_SERVER['REMOTE_ADDR']); } - $user = Zend_Auth::getInstance()->getIdentity(); + $user = \Zend_Auth::getInstance()->getIdentity(); if (! is_null($user)) { try { $realm->setUser($user); - } catch (Opus_Security_Exception $ose) { + } catch (SecurityException $ose) { // unknown user -> invalidate session (logout) - Zend_Auth::getInstance()->clearIdentity(); + \Zend_Auth::getInstance()->clearIdentity(); $user = null; } } @@ -136,14 +139,14 @@ public function getAcls() $this->loadRoles($acl, $parents); // create role for user on-the-fly with assigned roles as parents - if (Zend_Registry::get('LOG_LEVEL') >= Zend_LOG::DEBUG) { + if (\Zend_Registry::get('LOG_LEVEL') >= \Zend_LOG::DEBUG) { $logger->debug( "ACL: Create role '" . $user . "' with parents " . "(" . implode(", ", $parents) . ")" ); } // Add role for current user - $acl->addRole(new Zend_Acl_Role(self::ACTIVE_ROLE), $parents); + $acl->addRole(new \Zend_Acl_Role(self::ACTIVE_ROLE), $parents); return $acl; } @@ -156,9 +159,9 @@ public function loadResources($acl) $modules = Application_Security_AclProvider::$resourceNames; foreach ($modules as $module => $resources) { - $acl->addResource(new Zend_Acl_Resource($module)); + $acl->addResource(new \Zend_Acl_Resource($module)); foreach ($resources as $resource) { - $acl->addResource(new Zend_Acl_Resource($resource), $module); + $acl->addResource(new \Zend_Acl_Resource($resource), $module); } } @@ -169,10 +172,10 @@ public function loadWorkflowResources($acl) { $resources = Application_Controller_Action_Helper_Workflow::getWorkflowResources(); - $acl->addResource(new Zend_Acl_Resource('workflow')); + $acl->addResource(new \Zend_Acl_Resource('workflow')); foreach ($resources as $resource) { - $acl->addResource(new Zend_Acl_Resource($resource), 'workflow'); + $acl->addResource(new \Zend_Acl_Resource($resource), 'workflow'); } } @@ -197,14 +200,14 @@ public function getAllResources() public function loadRoles($acl, $roles) { // Feste Rollen, die immer existieren - $acl->addRole(new Zend_Acl_Role('guest')); - $acl->addRole(new Zend_Acl_Role('administrator')); + $acl->addRole(new \Zend_Acl_Role('guest')); + $acl->addRole(new \Zend_Acl_Role('administrator')); $acl->allow('administrator'); foreach ($roles as $role) { if (! $acl->hasRole($role)) { - $acl->addRole(new Zend_Acl_Role($role)); + $acl->addRole(new \Zend_Acl_Role($role)); } $roleConfig = new Application_Security_RoleConfig($role); diff --git a/library/Application/Security/BasicAuthProtection.php b/library/Application/Security/BasicAuthProtection.php index ae6392811a..1b0778c45e 100644 --- a/library/Application/Security/BasicAuthProtection.php +++ b/library/Application/Security/BasicAuthProtection.php @@ -44,7 +44,7 @@ public static function accessAllowed($request, $response) $adapter->setRequest($request); $adapter->setResponse($response); - $auth = Zend_Auth::getInstance(); + $auth = \Zend_Auth::getInstance(); $result = $auth->authenticate($adapter); if (! $result->isValid()) { diff --git a/library/Application/Security/HttpAuthAdapter.php b/library/Application/Security/HttpAuthAdapter.php index 8741f0ec86..302a01df92 100644 --- a/library/Application/Security/HttpAuthAdapter.php +++ b/library/Application/Security/HttpAuthAdapter.php @@ -36,7 +36,7 @@ * * This class is needed because the passwords in the database are hashed. */ -class Application_Security_HttpAuthAdapter extends Zend_Auth_Adapter_Http +class Application_Security_HttpAuthAdapter extends \Zend_Auth_Adapter_Http { /** diff --git a/library/Application/Security/HttpAuthResolver.php b/library/Application/Security/HttpAuthResolver.php index 462edc2a5d..c43f6b7324 100644 --- a/library/Application/Security/HttpAuthResolver.php +++ b/library/Application/Security/HttpAuthResolver.php @@ -31,10 +31,13 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Account; +use Opus\Security\Realm; + /** * HTTP auth resolver using OPUS accounts. */ -class Application_Security_HttpAuthResolver implements Zend_Auth_Adapter_Http_Resolver_Interface +class Application_Security_HttpAuthResolver implements \Zend_Auth_Adapter_Http_Resolver_Interface { /** @@ -48,10 +51,10 @@ class Application_Security_HttpAuthResolver implements Zend_Auth_Adapter_Http_Re */ public function resolve($username, $realm) { - $user = Opus_Account::fetchAccountByLogin($username); + $user = Account::fetchAccountByLogin($username); if (! is_null($user)) { - if (Opus_Security_Realm::checkModuleForUser('sword', $username)) { + if (Realm::checkModuleForUser('sword', $username)) { return $user->getPassword(); } } diff --git a/library/Application/Security/RoleConfig.php b/library/Application/Security/RoleConfig.php index 523a1cf6ff..3cae274a1e 100644 --- a/library/Application/Security/RoleConfig.php +++ b/library/Application/Security/RoleConfig.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\UserRole; + /** * Lädt die Konfigurationsdatei für eine Rolle. * @@ -62,10 +63,10 @@ public function applyPermissions($acl) public function getRolePermissions($acl, $roleName) { - $role = Opus_UserRole::fetchByName($roleName); + $role = UserRole::fetchByName($roleName); if (is_null($role)) { - Zend_Registry::get('Zend_Log')->err("Attempt to load unknown role '$roleName'."); + \Zend_Registry::get('Zend_Log')->err("Attempt to load unknown role '$roleName'."); return; } @@ -78,12 +79,12 @@ public function getRolePermissions($acl, $roleName) foreach ($resources as $resource) { if (! strncmp('resource_', $resource, 9)) { // resource (like languages); - $resource = new Zend_Acl_Resource(substr($resource, 9)); + $resource = new \Zend_Acl_Resource(substr($resource, 9)); $acl->allow($roleName, $resource); $resourcesConfigured = true; } elseif (! strncmp('workflow_', $resource, 9)) { // workflow permission - $resource = new Zend_Acl_Resource($resource); + $resource = new \Zend_Acl_Resource($resource); $acl->allow($roleName, $resource); } else { // module access @@ -93,7 +94,7 @@ public function getRolePermissions($acl, $roleName) if (! $resourcesConfigured) { foreach ($accessibleModules as $module) { - if ($acl->has(new Zend_Acl_Resource($module))) { + if ($acl->has(new \Zend_Acl_Resource($module))) { $acl->allow($roleName, $module); } } @@ -102,8 +103,8 @@ public function getRolePermissions($acl, $roleName) /** * - * @param type $role - * @return type + * @param $role string + * @return \Zend_Config|null * * TODO not used yet */ @@ -111,6 +112,6 @@ public function getRoleConfig($role) { $path = APPLICATION_PATH . '/application/configs/security/' . $role . '.ini'; - return is_readable($path) ? new Zend_Config_Ini($path) : null; + return is_readable($path) ? new \Zend_Config_Ini($path) : null; } } diff --git a/library/Application/Translate.php b/library/Application/Translate.php index a2bd6601fd..d93897f0a0 100644 --- a/library/Application/Translate.php +++ b/library/Application/Translate.php @@ -42,7 +42,7 @@ * modules. Loading the translations for a module only when a request is directed at that module might not load all the * necessary translations if this module uses resources from another module that has not been loaded. */ -class Application_Translate extends Zend_Translate +class Application_Translate extends \Zend_Translate { use \Opus\LoggingTrait; @@ -69,11 +69,11 @@ class Application_Translate extends Zend_Translate */ private $_options = [ 'logMessage' => "Unable to translate key '%message%' into locale '%locale%'", - 'logPriority' => Zend_Log::WARN, + 'logPriority' => \Zend_Log::WARN, 'adapter' => 'tmx', 'locale' => 'en', 'clear' => false, - 'scan' => Zend_Translate::LOCALE_FILENAME, + 'scan' => \Zend_Translate::LOCALE_FILENAME, 'ignore' => '.', 'disableNotices' => true ]; @@ -122,8 +122,8 @@ public function loadModules($reload = false) public function loadDatabase($reload = false) { // TODO use cache - $translate = new Zend_Translate([ - 'adapter' => 'Opus_Translate_DatabaseAdapter', + $translate = new \Zend_Translate([ + 'adapter' => 'Opus\Translate\DatabaseAdapter', 'content' => 'all', 'locale' => 'en', 'disableNotices' => true, @@ -216,7 +216,7 @@ public function getOptions() */ public function isLogUntranslatedEnabled() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); return (isset($config->log->untranslated)) ? filter_var($config->log->untranslated, FILTER_VALIDATE_BOOLEAN) : false; } @@ -268,7 +268,7 @@ public function getTranslations($key) */ public function setTranslations($key, $translations, $module = 'default') { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->setTranslation($key, $translations, $module); @@ -282,7 +282,7 @@ public function setTranslations($key, $translations, $module = 'default') */ public function clear() { - $translate = new Zend_Translate([ + $translate = new \Zend_Translate([ 'adapter' => 'array', 'content' => ['en' => [], 'de' => []], 'locale' => 'en', diff --git a/library/Application/Translate/Help.php b/library/Application/Translate/Help.php index 50dc5b59de..64ead65124 100644 --- a/library/Application/Translate/Help.php +++ b/library/Application/Translate/Help.php @@ -52,7 +52,7 @@ public static function getInstance() public function getConfig() { if (is_null($this->config)) { - $this->config = Zend_Registry::get('Zend_Config'); + $this->config = \Zend_Registry::get('Zend_Config'); } return $this->config; } diff --git a/library/Application/Translate/TmxFile.php b/library/Application/Translate/TmxFile.php index 2ee028f928..1e3a9455eb 100644 --- a/library/Application/Translate/TmxFile.php +++ b/library/Application/Translate/TmxFile.php @@ -213,7 +213,7 @@ public function setTranslation($key, $language, $text, $module = null) /** * Checks if a translation exists. * - * @param $key Translation key + * @param $key string Translation key * @param null $language Optionally what language to look for * @return bool */ diff --git a/library/Application/Translate/TranslationManager.php b/library/Application/Translate/TranslationManager.php index ca054494a4..2873dd087a 100644 --- a/library/Application/Translate/TranslationManager.php +++ b/library/Application/Translate/TranslationManager.php @@ -349,7 +349,7 @@ public function getMergedTranslations($sortKey = self::SORT_UNIT, $sortOrder = S // get translations from TMX files $translations = $this->getTranslations($sortKey, $sortOrder); - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $modules = $this->getModules(); @@ -570,7 +570,7 @@ public function addFolderName($name) */ public function keyExists($key) { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); return ! is_null($database->getTranslation($key)); } @@ -588,7 +588,7 @@ public function isEdited($key) */ public function reset($key) { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $translations = $this->getTranslations(); @@ -620,8 +620,8 @@ public function deleteAll() public function clearCache() { - if (Zend_Registry::isRegistered('Zend_Translate')) { - $translate = Zend_Registry::get('Zend_Translate'); + if (\Zend_Registry::isRegistered('Zend_Translate')) { + $translate = \Zend_Registry::get('Zend_Translate'); $translate->clearCache(); } } @@ -711,11 +711,11 @@ public function importTmxFile($tmxFile) } /** - * @return Opus_Translate_Dao $database + * @return \Opus\Translate\Dao $database */ public function getDatabase() { - return new Opus_Translate_Dao(); + return new \Opus\Translate\Dao(); } public function setState($state) @@ -738,7 +738,7 @@ public function setScope($scope) */ public function updateTranslation($key, $translations, $module = null, $oldKey = null) { - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); if ($key !== $oldKey && ! is_null($oldKey)) { $translation = $this->getTranslation($oldKey); diff --git a/library/Application/Update.php b/library/Application/Update.php index ed0abe882f..c76c426da0 100644 --- a/library/Application/Update.php +++ b/library/Application/Update.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Database; + /** * Class for performing updates of OPUS 4. * @@ -72,7 +74,7 @@ public function bootstrap() $configFiles[] = $consoleIniPath; } - $application = new Zend_Application(APPLICATION_ENV, ["config" => $configFiles]); + $application = new \Zend_Application(APPLICATION_ENV, ["config" => $configFiles]); // setup logging for updates $options = $application->mergeOptions($application->getOptions(), [ @@ -263,7 +265,7 @@ public function getUpdateScripts($version = null, $targetVersion = null) */ public function getVersion() { - $database = new Opus_Database(); + $database = new Database(); $pdo = $database->getPdo($database->getName()); @@ -300,7 +302,7 @@ public function setVersion($version) return; } - $database = new Opus_Database(); + $database = new Database(); try { $sql = "TRUNCATE TABLE `opus_version`; INSERT INTO `opus_version` (`version`) VALUES ($version);"; diff --git a/library/Application/Update/AddCC30LicenceShortNames.php b/library/Application/Update/AddCC30LicenceShortNames.php index 6d2a1cc38b..d7af39295c 100644 --- a/library/Application/Update/AddCC30LicenceShortNames.php +++ b/library/Application/Update/AddCC30LicenceShortNames.php @@ -35,6 +35,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Licence; +use Opus\Model\Xml\Cache; + /** * Added short names (labels) to licences that look like the old standard licences distributed with OPUS 4. */ @@ -57,9 +60,9 @@ class Application_Update_AddCC30LicenceShortNames extends Application_Update_Plu public function run() { - $cache = new Opus_Model_Xml_Cache(); + $cache = new Cache(); - $licences = Opus_Licence::getAll(); + $licences = Licence::getAll(); foreach ($licences as $licence) { $nameLong = $licence->getNameLong(); @@ -80,14 +83,14 @@ public function run() if (! is_null($name)) { // 'name' must be unique - check if already used - $existingLicence = Opus_Licence::fetchByName($name); + $existingLicence = Licence::fetchByName($name); if (is_null($existingLicence)) { $licence->setName($name); // prevent updates to ServerDateModified // TODO cache should be transparent - updating ServerDateModified is important - $licence->unregisterPlugin('Opus_Model_Plugin_InvalidateDocumentCache'); + $licence->unregisterPlugin('Opus\Model\Plugin\InvalidateDocumentCache'); $licence->store(); diff --git a/library/Application/Update/AddImportCollection.php b/library/Application/Update/AddImportCollection.php index 20fe0c8ab0..061fb4a722 100644 --- a/library/Application/Update/AddImportCollection.php +++ b/library/Application/Update/AddImportCollection.php @@ -25,6 +25,10 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Collection; +use Opus\CollectionRole; +use Opus\EnrichmentKey; + /** * Add import collection if necessary. * @@ -57,11 +61,11 @@ public function run() public function addEnrichmentKey($name) { - $enrichmentKey = Opus_EnrichmentKey::fetchByName($name); + $enrichmentKey = EnrichmentKey::fetchByName($name); if (is_null($enrichmentKey)) { $this->log("Creating enrichment key '$name' ... "); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName($name); $enrichmentKey->store(); } @@ -69,12 +73,12 @@ public function addEnrichmentKey($name) public function addCollection() { - $collectionRole = Opus_CollectionRole::fetchByName('Import'); + $collectionRole = CollectionRole::fetchByName('Import'); if (is_null($collectionRole)) { $this->log("Creating collection role 'Import' ... "); - $collectionRole = new Opus_CollectionRole(); + $collectionRole = new CollectionRole(); $collectionRole->setName('Import'); $collectionRole->setOaiName('import'); @@ -83,7 +87,7 @@ public function addCollection() $collectionRole->setDisplayBrowsing('Number'); $collectionRole->setDisplayFrontdoor('Number'); $collectionRole->setVisibleOai(0); - $collectionRole->setPosition(Opus_CollectionRole::getLastPosition() + 1); + $collectionRole->setPosition(CollectionRole::getLastPosition() + 1); $root = $collectionRole->addRootCollection(); $collectionRole->store(); } else { @@ -97,7 +101,7 @@ public function addCollection() if (is_null($collection)) { $this->log("Creating collection 'import' ... "); - $collection = new Opus_Collection(); + $collection = new Collection(); $collection->setName('Import'); $collection->setNumber('import'); $collection->setOaiSubset('import'); diff --git a/library/Application/Update/ConvertCollectionRoleTranslations.php b/library/Application/Update/ConvertCollectionRoleTranslations.php index 350a69b1db..7f04d0acc6 100644 --- a/library/Application/Update/ConvertCollectionRoleTranslations.php +++ b/library/Application/Update/ConvertCollectionRoleTranslations.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; +use Opus\Util\ConsoleColors; + /** * Handles update of "speaking" collection role names. * @@ -48,9 +51,9 @@ public function run() $validator = new Application_Form_Validate_CollectionRoleName(); - $roles = Opus_CollectionRole::fetchAll(); + $roles = CollectionRole::fetchAll(); - $colors = new Opus_Util_ConsoleColors(); + $colors = new ConsoleColors(); foreach ($roles as $role) { $name = $role->getName(); diff --git a/library/Application/Update/CreateDoiUrnEnrichments.php b/library/Application/Update/CreateDoiUrnEnrichments.php index 740a341635..b18bde90cb 100644 --- a/library/Application/Update/CreateDoiUrnEnrichments.php +++ b/library/Application/Update/CreateDoiUrnEnrichments.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\EnrichmentKey; + /** * Update step creates enrichment key supporting handling of DOI and URN identifiers. */ @@ -46,11 +48,11 @@ class Application_Update_CreateDoiUrnEnrichments extends Application_Update_Plug public function run() { foreach ($this->keyNames as $name) { - $enrichmentKey = Opus_EnrichmentKey::fetchByName($name); + $enrichmentKey = EnrichmentKey::fetchByName($name); if (is_null($enrichmentKey)) { $this->log("Creating enrichment key '$name' ..."); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName($name); $enrichmentKey->store(); $this->getLogger()->info("Enrichment key '$name' created."); diff --git a/library/Application/Update/CreateSourceEnrichmentKey.php b/library/Application/Update/CreateSourceEnrichmentKey.php index 8629414c6e..1e647e4418 100644 --- a/library/Application/Update/CreateSourceEnrichmentKey.php +++ b/library/Application/Update/CreateSourceEnrichmentKey.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\EnrichmentKey; + /** * Update step that adds enrichment key opus.source if it does not exist. */ @@ -40,11 +42,11 @@ class Application_Update_CreateSourceEnrichmentKey extends Application_Update_Pl public function run() { - $enrichmentKey = Opus_EnrichmentKey::fetchByName(self::ENRICHMENT_KEY_NAME); + $enrichmentKey = EnrichmentKey::fetchByName(self::ENRICHMENT_KEY_NAME); if (is_null($enrichmentKey)) { $this->log("Creating enrichment key '" . self::ENRICHMENT_KEY_NAME . "' …"); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName(self::ENRICHMENT_KEY_NAME); $enrichmentKey->store(); $this->getLogger()->info("Enrichment key '" . self::ENRICHMENT_KEY_NAME . "' created successfully."); diff --git a/library/Application/Update/Database.php b/library/Application/Update/Database.php index 13c623b995..7787598357 100644 --- a/library/Application/Update/Database.php +++ b/library/Application/Update/Database.php @@ -32,6 +32,9 @@ * * Updates database. */ + +use Opus\Database; + class Application_Update_Database extends Application_Update_PluginAbstract { @@ -42,7 +45,7 @@ public function run() { $this->log('Updating database ...'); - $database = new Opus_Database(); + $database = new Database(); $database->update(); diff --git a/library/Application/Update/Exception.php b/library/Application/Update/Exception.php index 8cdc204e44..482f61035d 100644 --- a/library/Application/Update/Exception.php +++ b/library/Application/Update/Exception.php @@ -33,6 +33,8 @@ /** * Exception class for problems during update. + * + * TODO NAMESPACE rename */ class Application_Update_Exception extends Exception { diff --git a/library/Application/Update/ImportCustomTranslations.php b/library/Application/Update/ImportCustomTranslations.php index ec7a638862..5f400f242c 100644 --- a/library/Application/Update/ImportCustomTranslations.php +++ b/library/Application/Update/ImportCustomTranslations.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Util\ConsoleColors; + class Application_Update_ImportCustomTranslations extends Application_Update_PluginAbstract { @@ -52,7 +54,7 @@ public function run() $files = $manager->getFiles(); - $colors = new Opus_Util_ConsoleColors(); + $colors = new ConsoleColors(); if (count($files) > 0) { // Iterate through modules und TMX files in 'language_custom' @@ -85,7 +87,7 @@ public function run() } $this->log(PHP_EOL . 'Clearing translation cache...' . PHP_EOL); - Zend_Translate::clearCache(); + \Zend_Translate::clearCache(); } /** @@ -95,7 +97,7 @@ public function run() */ public function importFolder($files, $module) { - $colors = new Opus_Util_ConsoleColors(); + $colors = new ConsoleColors(); foreach ($files as $filename) { $path = "/modules/$module/language_custom/$filename"; @@ -108,7 +110,7 @@ public function importFolder($files, $module) $translations = $tmx->toArray(); - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->addTranslations($translations, $module); @@ -128,7 +130,7 @@ public function importFolder($files, $module) */ public function removeFolder($path) { - $colors = new Opus_Util_ConsoleColors(); + $colors = new ConsoleColors(); if (! (new \FilesystemIterator(APPLICATION_PATH . $path))->valid()) { rmdir(APPLICATION_PATH . $path); $this->log("Removed folder '$path'"); diff --git a/library/Application/Update/ImportStaticPages.php b/library/Application/Update/ImportStaticPages.php index fdb64e4787..1b92f80a84 100644 --- a/library/Application/Update/ImportStaticPages.php +++ b/library/Application/Update/ImportStaticPages.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Util\ConsoleColors; + /** * Class Application_Update_ImportStaticPages * @@ -52,7 +54,7 @@ public function run() $this->log('Importing static pages from folder'); $this->log($path); - $colors = new Opus_Util_ConsoleColors(); + $colors = new ConsoleColors(); $this->log('Importing \'contact\' texts...'); if (count(array_intersect($files, ['contact.en.txt', 'contact.de.txt'])) > 0) { @@ -92,7 +94,7 @@ public function importFilesAsKey($name, $key, $module) $this->removeFiles($files); } } else { - $colors = new Opus_Util_ConsoleColors(); + $colors = new ConsoleColors(); $this->log($colors->red("No texts for '$name' found.")); } diff --git a/library/Application/Update/PluginAbstract.php b/library/Application/Update/PluginAbstract.php index 46a3bad58e..c8677a54e7 100644 --- a/library/Application/Update/PluginAbstract.php +++ b/library/Application/Update/PluginAbstract.php @@ -31,12 +31,14 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Update\Plugin\AbstractUpdatePlugin; + /** * Base class for update plugins. * * TODO eliminate this class? */ -abstract class Application_Update_PluginAbstract extends Opus_Update_Plugin_Abstract +abstract class Application_Update_PluginAbstract extends AbstractUpdatePlugin { /** diff --git a/library/Application/Update/SetStatusOfExistingDoi.php b/library/Application/Update/SetStatusOfExistingDoi.php index 35a1c9ef42..227ff0dc51 100644 --- a/library/Application/Update/SetStatusOfExistingDoi.php +++ b/library/Application/Update/SetStatusOfExistingDoi.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\DocumentFinder; + /** * Set registration status of all existing DOIs to "registered". * Only documents with server state "published" are considered. @@ -42,7 +45,7 @@ public function run() { $this->log('Set registration status of all DOIs to "registered"'); - $docFinder = new Opus_DocumentFinder(); + $docFinder = new DocumentFinder(); $docFinder->setIdentifierTypeExists('doi'); $docFinder->setServerState('published'); $ids = $docFinder->ids(); @@ -52,7 +55,7 @@ public function run() $numOfModifiedDocs = 0; foreach ($ids as $id) { - $doc = new Opus_Document($id); + $doc = Document::get($id); $dois = $doc->getIdentifierDoi(); foreach ($dois as $doi) { diff --git a/library/Application/Util/Array.php b/library/Application/Util/Array.php index a5136dbd3d..4e6c0138f7 100644 --- a/library/Application/Util/Array.php +++ b/library/Application/Util/Array.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/library/Application/Util/BrowsingParams.php b/library/Application/Util/BrowsingParams.php index 58c2a3869e..3a05d4f0ca 100644 --- a/library/Application/Util/BrowsingParams.php +++ b/library/Application/Util/BrowsingParams.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Util_BrowsingParams diff --git a/library/Application/Util/BrowsingParamsException.php b/library/Application/Util/BrowsingParamsException.php index 762f3b8abf..444f9ea752 100644 --- a/library/Application/Util/BrowsingParamsException.php +++ b/library/Application/Util/BrowsingParamsException.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Util_BrowsingParamsException extends Application_Search_QueryBuilderException diff --git a/library/Application/Util/Document.php b/library/Application/Util/Document.php index 1af130000c..8409ce6b50 100644 --- a/library/Application/Util/Document.php +++ b/library/Application/Util/Document.php @@ -29,21 +29,26 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Model\Xml; +use Opus\Model\Xml\Cache; +use Opus\Model\Xml\Version1; +use Opus\Security\Realm; + class Application_Util_Document { /** * - * @var Opus_Document + * @var Document */ private $_document; /** * - * @param Opus_Document $document + * @param Document $document * @throws Application_Exception */ public function __construct($document) @@ -62,23 +67,23 @@ private function checkPermission() if ($this->_document->getServerState() === 'published') { return true; } - $accessControl = Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); - return Opus_Security_Realm::getInstance()->checkDocument($this->_document->getId()) + $accessControl = \Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); + return Realm::getInstance()->checkDocument($this->_document->getId()) || $accessControl->accessAllowed('documents'); } /** * @param boolean $useCache - * @return DOMNode Opus_Document node + * @return DOMNode Document node */ public function getNode($useCache = true) { - $xmlModel = new Opus_Model_Xml(); + $xmlModel = new Xml(); $xmlModel->setModel($this->_document); $xmlModel->excludeEmptyFields(); // needed for preventing handling errors - $xmlModel->setStrategy(new Opus_Model_Xml_Version1); + $xmlModel->setStrategy(new Version1); if ($useCache) { - $xmlModel->setXmlCache(new Opus_Model_Xml_Cache); + $xmlModel->setXmlCache(new Cache); } $result = $xmlModel->getDomDocument(); return $result->getElementsByTagName('Opus_Document')->item(0); diff --git a/library/Application/Util/DocumentAdapter.php b/library/Application/Util/DocumentAdapter.php index 5453703962..5324af2d8b 100644 --- a/library/Application/Util/DocumentAdapter.php +++ b/library/Application/Util/DocumentAdapter.php @@ -29,11 +29,14 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Account; +use Opus\Date; +use Opus\Document; + /** - * Wrapper around Opus_Document to prepare presentation. + * Wrapper around Document to prepare presentation. * * TODO split off base class, URLs are controller specific * TODO move code to admin module (is used there as well and belongs there, or?) @@ -51,7 +54,7 @@ class Application_Util_DocumentAdapter /** * Wrapped document. - * @var Opus_Document + * @var Document */ public $document = null; @@ -75,23 +78,23 @@ class Application_Util_DocumentAdapter public function __construct($view, $value) { if (is_null($view)) { - $this->_view = Zend_Registry::get('Opus_View'); + $this->_view = \Zend_Registry::get('Opus_View'); } else { $this->_view = $view; } - if ($value instanceof Opus_Document) { + if ($value instanceof Document) { $this->document = $value; $this->docId = $this->document->getId(); } else { $this->docId = $value; - $this->document = new Opus_Document((int) $value); + $this->document = Document::get((int) $value); } } /** - * Returns the Opus_Document object for this adapter. - * @return Opus_Document + * Returns the Document object for this adapter. + * @return Document */ public function getDocument() { @@ -168,7 +171,7 @@ public function getDocType() */ public function getPublishedDate($yearOnly = false) { - $datesHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); + $datesHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); try { $date = $this->document->getPublishedDate(); @@ -177,7 +180,7 @@ public function getPublishedDate($yearOnly = false) $date = $this->document->getPublishedYear(); } - if (! empty($date) && $date instanceof Opus_Date) { + if (! empty($date) && $date instanceof Date) { if ($yearOnly) { $date = $date->getYear(); } else { @@ -192,7 +195,7 @@ public function getPublishedDate($yearOnly = false) public function getCompletedDate($yearOnly = false) { - $datesHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); + $datesHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); try { $date = $this->document->getCompletedDate(); @@ -201,7 +204,7 @@ public function getCompletedDate($yearOnly = false) $date = $this->document->getCompletedYear(); } - if (! empty($date) && $date instanceof Opus_Date) { + if (! empty($date) && $date instanceof Date) { if ($yearOnly) { $date = $date->getYear(); } else { @@ -340,7 +343,7 @@ public function getReviewer() continue; } $userId = $e->getValue(); - $account = new Opus_Account($userId); + $account = new Account($userId); $return[$account->getId()] = strtolower($account->getLogin()); } return $return; @@ -354,7 +357,7 @@ public function getSubmitter() continue; } $userId = $e->getValue(); - $account = new Opus_Account($userId); + $account = new Account($userId); $return[$account->getId()] = strtolower($account->getLogin()); } return $return; diff --git a/library/Application/Util/Notification.php b/library/Application/Util/Notification.php index 28600824b8..5d9f51d1a2 100644 --- a/library/Application/Util/Notification.php +++ b/library/Application/Util/Notification.php @@ -33,6 +33,12 @@ * * TODO remove concept of 'context' - class should not implement different context variations (use OO principles) */ + +use Opus\Document; +use Opus\Job; +use Opus\Job\Worker\MailNotification; +use Opus\Model\ModelException; + class Application_Util_Notification extends Application_Model_Abstract { @@ -44,7 +50,7 @@ public function __construct($logger = null, $config = null) /** * - * @param Opus_Document $document das Dokument auf das sich die Notifizierung bezieht + * @param Document $document das Dokument auf das sich die Notifizierung bezieht * @param String $url vollständiger Deeplink, der in der Mail angezeigt werden soll * @param boolean $notifySubmitter Wenn false, wird der Submitter nicht notifiziert * @param array $notifyAuthors Bitmaske, die für jeden Autor (über den Index referenziert) angibt, ob ihm/ihr eine @@ -149,7 +155,7 @@ public function getAuthors($document) } /** - * @param $document Opus_Document + * @param $document Document * @param $docId * @param $authors * @param $title @@ -283,7 +289,7 @@ public function isEnabled() * @param $subject * @param $message * @param $recipients - * @throws Opus_Model_Exception + * @throws ModelException * * TODO the code here should not decide if synchronous or asynchronous - create a job and go (either way) * TODO the code here should not filter recipients (that should have happened earlier) @@ -300,8 +306,8 @@ private function scheduleNotification($subject, $message, $recipients) foreach ($recipients as $recipient) { // only send if email address has not been used before if (! in_array($recipient['address'], $addressesUsed)) { - $job = new Opus_Job(); - $job->setLabel(Opus_Job_Worker_MailNotification::LABEL); + $job = new Job(); + $job->setLabel(MailNotification::LABEL); $job->setData([ 'subject' => $subject, 'message' => $message, @@ -320,7 +326,7 @@ private function scheduleNotification($subject, $message, $recipients) } else { // Execute job immediately (synchronously) try { - $mail = new Opus_Job_Worker_MailNotification($this->getLogger(), false); + $mail = new MailNotification($this->getLogger(), false); $mail->work($job); } catch (Exception $exc) { $this->getLogger()->err("Email notification failed: " . $exc); diff --git a/library/Application/Util/ShellScript.php b/library/Application/Util/ShellScript.php index 703fcb85e8..51d667895f 100644 --- a/library/Application/Util/ShellScript.php +++ b/library/Application/Util/ShellScript.php @@ -53,7 +53,7 @@ public function __construct($path) /** * Returns value for property if found in shell script. - * @param $name Property name + * @param $name string Property name * @return null|string */ public function getProperty($name) @@ -68,7 +68,7 @@ public function getProperty($name) /** * Read property values from shell script. * - * @param $path Path to shell script + * @param $path string Path to shell script * @return array Map with names and values of properties * @throws Exception */ diff --git a/library/Application/Util/WorkspaceCache.php b/library/Application/Util/WorkspaceCache.php index 1119465290..003160a7ca 100644 --- a/library/Application/Util/WorkspaceCache.php +++ b/library/Application/Util/WorkspaceCache.php @@ -41,7 +41,7 @@ class Application_Util_WorkspaceCache */ public function clearTranslations() { - $files = new DirectoryIterator(Application_Configuration::getInstance()->getWorkspacePath() . '/cache'); + $files = new \DirectoryIterator(Application_Configuration::getInstance()->getWorkspacePath() . '/cache'); foreach ($files as $file) { $basename = $file->getBasename(); diff --git a/library/Application/View/Helper/Abstract.php b/library/Application/View/Helper/Abstract.php index cf5ebe5f27..580d95ca93 100644 --- a/library/Application/View/Helper/Abstract.php +++ b/library/Application/View/Helper/Abstract.php @@ -34,7 +34,7 @@ /** * Abstract base class for view helpers. */ -class Application_View_Helper_Abstract extends Zend_View_Helper_Abstract +class Application_View_Helper_Abstract extends \Zend_View_Helper_Abstract { use \Opus\LoggingTrait; diff --git a/library/Application/View/Helper/AccessAllowed.php b/library/Application/View/Helper/AccessAllowed.php index cd52d852d3..144c75a1a8 100644 --- a/library/Application/View/Helper/AccessAllowed.php +++ b/library/Application/View/Helper/AccessAllowed.php @@ -29,13 +29,12 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Returns true is current user has access to a resource. */ -class Application_View_Helper_AccessAllowed extends Zend_View_Helper_Abstract +class Application_View_Helper_AccessAllowed extends \Zend_View_Helper_Abstract { /** @@ -45,7 +44,7 @@ class Application_View_Helper_AccessAllowed extends Zend_View_Helper_Abstract /** * Returns true if access to resource is allowed or resource does not exist. - * @param type $resource + * @param $resource string * @return boolean */ public function accessAllowed($resource) @@ -55,12 +54,12 @@ public function accessAllowed($resource) /** * Returns the Zend_Acl object or null. - * @return Zend_Acl + * @return \Zend_Acl */ protected function getAccessControl() { if (is_null($this->_accessControl)) { - $this->_accessControl = Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); + $this->_accessControl = \Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); } return $this->_accessControl; } diff --git a/library/Application/View/Helper/AdminMenu.php b/library/Application/View/Helper/AdminMenu.php index 3835c754c6..d865e0267c 100644 --- a/library/Application/View/Helper/AdminMenu.php +++ b/library/Application/View/Helper/AdminMenu.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -37,12 +36,12 @@ * * TODO better way to get ACL? */ -class Application_View_Helper_AdminMenu extends Zend_View_Helper_Abstract +class Application_View_Helper_AdminMenu extends \Zend_View_Helper_Abstract { /** * Returns current instance. - * @return View_Helper_Security + * @return Application_View_Helper_AdminMenu */ public function adminMenu() { diff --git a/library/Application/View/Helper/AssignCollectionAllowed.php b/library/Application/View/Helper/AssignCollectionAllowed.php index e11078427d..e4bb25f93d 100644 --- a/library/Application/View/Helper/AssignCollectionAllowed.php +++ b/library/Application/View/Helper/AssignCollectionAllowed.php @@ -36,7 +36,7 @@ * * TODO cleanup in connection with refactoring of Admin_CollectionController */ -class Application_View_Helper_AssignCollectionAllowed extends Zend_View_Helper_Abstract +class Application_View_Helper_AssignCollectionAllowed extends \Zend_View_Helper_Abstract { public function assignCollectionAllowed($collection, $docId = null) diff --git a/library/Application/View/Helper/Breadcrumbs.php b/library/Application/View/Helper/Breadcrumbs.php index 2944567fe0..5b3ab876cc 100644 --- a/library/Application/View/Helper/Breadcrumbs.php +++ b/library/Application/View/Helper/Breadcrumbs.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -38,7 +37,7 @@ * @category Application * @package View */ -class Application_View_Helper_Breadcrumbs extends Zend_View_Helper_Navigation_Breadcrumbs +class Application_View_Helper_Breadcrumbs extends \Zend_View_Helper_Navigation_Breadcrumbs { private $_suffixSeparatorDisabled = false; @@ -85,10 +84,10 @@ public function setReplacement($replacement) /** * Rendert den kompletten Breadcrumbs Pfad für die aktuelle Seite. * - * @param Zend_Navigation_Container $container + * @param \Zend_Navigation_Container $container * @return string */ - public function renderStraight(Zend_Navigation_Container $container = null) + public function renderStraight(\Zend_Navigation_Container $container = null) { if (null === $container) { $container = $this->getContainer(); diff --git a/library/Application/View/Helper/CustomFileSortingEnabled.php b/library/Application/View/Helper/CustomFileSortingEnabled.php index c79a26049f..048da27c50 100644 --- a/library/Application/View/Helper/CustomFileSortingEnabled.php +++ b/library/Application/View/Helper/CustomFileSortingEnabled.php @@ -32,7 +32,7 @@ */ -class Application_View_Helper_CustomFileSortingEnabled extends Zend_View_Helper_Abstract +class Application_View_Helper_CustomFileSortingEnabled extends \Zend_View_Helper_Abstract { /** * Check if custom file sorting based on sort order field is enabled. @@ -41,7 +41,7 @@ class Application_View_Helper_CustomFileSortingEnabled extends Zend_View_Helper_ */ public function customFileSortingEnabled() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); return isset($config->frontdoor->files->customSorting) && filter_var($config->frontdoor->files->customSorting, FILTER_VALIDATE_BOOLEAN); } diff --git a/library/Application/View/Helper/DocumentAbstract.php b/library/Application/View/Helper/DocumentAbstract.php index 74666c1f27..02cee7b94b 100644 --- a/library/Application/View/Helper/DocumentAbstract.php +++ b/library/Application/View/Helper/DocumentAbstract.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Language; + /** * Helper for printing the abstract of a OPUS document. * @@ -46,7 +48,7 @@ class Application_View_Helper_DocumentAbstract extends Application_View_Helper_D public function documentAbstract($document = null) { if ($this->isPreferUserInterfaceLanguage()) { - $language = Opus_Language::getPart2tForPart1(Zend_Registry::get('Zend_Translate')->getLocale()); + $language = Language::getPart2tForPart1(\Zend_Registry::get('Zend_Translate')->getLocale()); $abstract = $document->getMainAbstract($language); } else { diff --git a/library/Application/View/Helper/DocumentTitle.php b/library/Application/View/Helper/DocumentTitle.php index a5fb577a72..3ad4817f66 100644 --- a/library/Application/View/Helper/DocumentTitle.php +++ b/library/Application/View/Helper/DocumentTitle.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Language; + /** * Helper for printing the title of a OPUS document. * @@ -40,7 +42,7 @@ * The document could be stored in a view variable or it could be provides as * a parameter. * - * The document could by of type Opus_Document or it could be a result object + * The document could by of type Document or it could be a result object * of a Solr search. */ class Application_View_Helper_DocumentTitle extends Application_View_Helper_Document_HelperAbstract @@ -53,7 +55,7 @@ class Application_View_Helper_DocumentTitle extends Application_View_Helper_Docu public function documentTitle($document = null) { if ($this->isPreferUserInterfaceLanguage()) { - $language = Opus_Language::getPart2tForPart1(Zend_Registry::get('Zend_Translate')->getLocale()); + $language = Language::getPart2tForPart1(\Zend_Registry::get('Zend_Translate')->getLocale()); $title = $document->getMainTitle($language); } else { diff --git a/library/Application/View/Helper/DocumentUrl.php b/library/Application/View/Helper/DocumentUrl.php index a8d57c81ac..891a524f91 100644 --- a/library/Application/View/Helper/DocumentUrl.php +++ b/library/Application/View/Helper/DocumentUrl.php @@ -30,14 +30,13 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * This helper class defines only one method baseUrl() to retrieve the * application base url for absolute urls in views. */ -class Application_View_Helper_DocumentUrl extends Zend_View_Helper_Abstract +class Application_View_Helper_DocumentUrl extends \Zend_View_Helper_Abstract { public function documentUrl() diff --git a/library/Application/View/Helper/EmbargoHasPassed.php b/library/Application/View/Helper/EmbargoHasPassed.php index 3cc30ef695..178abedaaf 100644 --- a/library/Application/View/Helper/EmbargoHasPassed.php +++ b/library/Application/View/Helper/EmbargoHasPassed.php @@ -31,7 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_View_Helper_EmbargoHasPassed extends Zend_View_Helper_Abstract +use Opus\Document; + +class Application_View_Helper_EmbargoHasPassed extends \Zend_View_Helper_Abstract { /** @@ -43,8 +45,8 @@ class Application_View_Helper_EmbargoHasPassed extends Zend_View_Helper_Abstract */ public static function embargoHasPassed($doc) { - if (! $doc instanceof Opus_Document) { - $doc = new Opus_Document($doc); + if (! $doc instanceof Document) { + $doc = Document::get($doc); } return $doc->hasEmbargoPassed(); diff --git a/library/Application/View/Helper/ExportLinks.php b/library/Application/View/Helper/ExportLinks.php index cb43b754f5..c2b53e53b1 100644 --- a/library/Application/View/Helper/ExportLinks.php +++ b/library/Application/View/Helper/ExportLinks.php @@ -51,7 +51,7 @@ public function exportLinks($keys = null, $context = null) public function toString($keys = null, $context = null) { - $exporter = Zend_Registry::get('Opus_Exporter'); // TODO use constant + $exporter = \Zend_Registry::get('Opus_Exporter'); // TODO use constant $formats = $exporter->getAllowedFormats(); diff --git a/library/Application/View/Helper/ExportLinksEnabled.php b/library/Application/View/Helper/ExportLinksEnabled.php index c9eb28d4e6..a354bba561 100644 --- a/library/Application/View/Helper/ExportLinksEnabled.php +++ b/library/Application/View/Helper/ExportLinksEnabled.php @@ -35,7 +35,7 @@ class Application_View_Helper_ExportLinksEnabled extends Application_View_Helper public function exportLinksEnabled($context = null) { - $exporter = Zend_Registry::get('Opus_Exporter'); // TODO use constant + $exporter = \Zend_Registry::get('Opus_Exporter'); // TODO use constant $formats = $exporter->getAllowedFormats(); diff --git a/library/Application/View/Helper/FaqSectionEditLink.php b/library/Application/View/Helper/FaqSectionEditLink.php index 12d9db0b4a..bd20e95af0 100644 --- a/library/Application/View/Helper/FaqSectionEditLink.php +++ b/library/Application/View/Helper/FaqSectionEditLink.php @@ -60,7 +60,7 @@ public function faqSectionEditLink($key) */ public function isEditingEnabled() { - $accessControl = Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); + $accessControl = \Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); if (is_null($accessControl)) { return false; // just in case - deny editing if access control mechanism isn't available diff --git a/library/Application/View/Helper/FileAccessAllowed.php b/library/Application/View/Helper/FileAccessAllowed.php index 93ba38c143..018e056bf2 100644 --- a/library/Application/View/Helper/FileAccessAllowed.php +++ b/library/Application/View/Helper/FileAccessAllowed.php @@ -31,7 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_View_Helper_FileAccessAllowed extends Zend_View_Helper_Abstract +use Opus\Security\Realm; + +class Application_View_Helper_FileAccessAllowed extends \Zend_View_Helper_Abstract { /** @@ -46,7 +48,7 @@ public function fileAccessAllowed($fileId = null) return false; } - $realm = Opus_Security_Realm::getInstance(); + $realm = Realm::getInstance(); return $realm->checkFile($fileId); } } diff --git a/library/Application/View/Helper/FileLink.php b/library/Application/View/Helper/FileLink.php index a304a9054a..050efaea86 100644 --- a/library/Application/View/Helper/FileLink.php +++ b/library/Application/View/Helper/FileLink.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\File; + /** * View Helper fuer Link zu Datei. * @@ -35,15 +37,14 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_View_Helper_FileLink extends Zend_View_Helper_Abstract +class Application_View_Helper_FileLink extends \Zend_View_Helper_Abstract { /** * Rendert Link fuer Datei. * - * @param $file Opus_File + * @param $file File * @return string HTML output */ public function fileLink($name, $file, $options = null) diff --git a/library/Application/View/Helper/FileSize.php b/library/Application/View/Helper/FileSize.php index c03b85da36..8b731b9aa0 100644 --- a/library/Application/View/Helper/FileSize.php +++ b/library/Application/View/Helper/FileSize.php @@ -29,9 +29,8 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_View_Helper_FileSize extends Zend_View_Helper_Abstract +class Application_View_Helper_FileSize extends \Zend_View_Helper_Abstract { private $_labels = ["Byte", "KB", "MB", "GB"]; diff --git a/library/Application/View/Helper/FileUrl.php b/library/Application/View/Helper/FileUrl.php index 7cde00bfeb..e2233f2884 100644 --- a/library/Application/View/Helper/FileUrl.php +++ b/library/Application/View/Helper/FileUrl.php @@ -34,7 +34,7 @@ /** * Gibt die URL für den Zugriff auf eine spezifische Datei eines Dokuments zurück. */ -class Application_View_Helper_FileUrl extends Zend_View_Helper_Abstract +class Application_View_Helper_FileUrl extends \Zend_View_Helper_Abstract { public function fileUrl($docId, $pathName) diff --git a/library/Application/View/Helper/FormCombobox.php b/library/Application/View/Helper/FormCombobox.php index 152daa6c15..1cd31ade9a 100644 --- a/library/Application/View/Helper/FormCombobox.php +++ b/library/Application/View/Helper/FormCombobox.php @@ -34,7 +34,7 @@ /** * View helper for rendering a combobox (text input + select). */ -class Application_View_Helper_FormCombobox extends Zend_View_Helper_FormElement +class Application_View_Helper_FormCombobox extends \Zend_View_Helper_FormElement { public function formCombobox($name, $value = null, $attribs = null, $options = null, $listsep = "
\n") diff --git a/library/Application/View/Helper/FormDocuments.php b/library/Application/View/Helper/FormDocuments.php index be1972aaaf..ac093d466c 100644 --- a/library/Application/View/Helper/FormDocuments.php +++ b/library/Application/View/Helper/FormDocuments.php @@ -40,7 +40,7 @@ * TODO not sure if there isn't a better solution (partial iterate document.phtml - easier customization) * TODO much more testing after refactoring */ -class Application_View_Helper_FormDocuments extends Zend_View_Helper_FormElement +class Application_View_Helper_FormDocuments extends \Zend_View_Helper_FormElement { public function formDocuments($name, $value = null, $attribs = null, $options = null, $listsep = "
\n") diff --git a/library/Application/View/Helper/FormHtml.php b/library/Application/View/Helper/FormHtml.php index 1969e3221d..c6b5825706 100644 --- a/library/Application/View/Helper/FormHtml.php +++ b/library/Application/View/Helper/FormHtml.php @@ -31,7 +31,7 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_View_Helper_FormHtml extends Zend_View_Helper_FormElement +class Application_View_Helper_FormHtml extends \Zend_View_Helper_FormElement { public function formHtml($name, $value = null, array $attribs = null) diff --git a/library/Application/View/Helper/FormTranslation.php b/library/Application/View/Helper/FormTranslation.php index 557711430b..d64f8af057 100644 --- a/library/Application/View/Helper/FormTranslation.php +++ b/library/Application/View/Helper/FormTranslation.php @@ -34,7 +34,7 @@ * template, adapting it to the specific needs of displaying multiple input * elements label for the supported languages. */ -class Application_View_Helper_FormTranslation extends Zend_View_Helper_FormRadio +class Application_View_Helper_FormTranslation extends \Zend_View_Helper_FormRadio { protected $_inputType = 'text'; @@ -79,9 +79,9 @@ public function formTranslation($name, $value = null, $attribs = null, $options ? '/[^\p{L}\p{N}\-\_]/u' // Unicode : '/[^a-zA-Z0-9\-\_]/'; // No Unicode - $filter = new Zend_Filter_PregReplace($pattern, ''); + $filter = new \Zend_Filter_PregReplace($pattern, ''); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $name = $this->view->escape($name); diff --git a/library/Application/View/Helper/FormatDate.php b/library/Application/View/Helper/FormatDate.php index 157e6ad92a..52111ad4a3 100644 --- a/library/Application/View/Helper/FormatDate.php +++ b/library/Application/View/Helper/FormatDate.php @@ -33,7 +33,7 @@ * TODO clean up */ -class Application_View_Helper_FormatDate extends Zend_View_Helper_Abstract +class Application_View_Helper_FormatDate extends \Zend_View_Helper_Abstract { /** @@ -52,7 +52,7 @@ public function formatDate($day = null, $month = null, $year = null) $date = new DateTime(); $date->setDate($year, $month, $day); - $session = new Zend_Session_Namespace(); + $session = new \Zend_Session_Namespace(); // TODO aktuell werden nur zwei Sprachen unterstützt $formatPattern = ($session->language == 'de') ? 'd.m.Y' : 'Y/m/d'; @@ -66,7 +66,7 @@ public function formatOpusDate($date, $showTime = false) return ''; } - $session = new Zend_Session_Namespace(); + $session = new \Zend_Session_Namespace(); // TODO aktuell werden nur zwei Sprachen unterstützt if ($showTime) { diff --git a/library/Application/View/Helper/FormatValue.php b/library/Application/View/Helper/FormatValue.php index 87c04b7742..c002cf3176 100644 --- a/library/Application/View/Helper/FormatValue.php +++ b/library/Application/View/Helper/FormatValue.php @@ -31,6 +31,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Date; +use Opus\Model\AbstractModel; +use Opus\Model\Field; + /** * View Helper for formatting field values. * @@ -39,7 +43,7 @@ * TODO Explore options to remove overlap with ShowModel view helper * (ShowModel combines value formatting and layout). */ -class Application_View_Helper_FormatValue extends Zend_View_Helper_Abstract +class Application_View_Helper_FormatValue extends \Zend_View_Helper_Abstract { use \Opus\LoggingTrait; @@ -61,8 +65,8 @@ class Application_View_Helper_FormatValue extends Zend_View_Helper_Abstract */ public function __construct() { - $this->_translation = Zend_Controller_Action_HelperBroker::getStaticHelper('Translation'); - $this->_dates = Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); + $this->_translation = \Zend_Controller_Action_HelperBroker::getStaticHelper('Translation'); + $this->_dates = \Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); } /** @@ -75,14 +79,14 @@ public function formatValue() } /** - * Formats value that is instance of Opus_Model_Abstract. - * @param Opus_Model_Abstract $field + * Formats value that is instance of AbstractModel. + * @param AbstractModel $field * @param string Name of model for field (default = null) * @return string Formatted output */ public function formatModel($field, $model = null) { - if ($field instanceof Opus_Date) { + if ($field instanceof Date) { return $this->formatDate($field); } else { $modelClass = $field->getValueModelClass(); @@ -91,9 +95,9 @@ public function formatModel($field, $model = null) if (! empty($modelClass)) { switch ($modelClass) { - case 'Opus_Date': + case 'Opus\Date': return $this->formatDate($field->getValue()); - case 'Opus_DnbInstitute': + case 'Opus\DnbInstitute': $value = $field->getValue(); if (isset($value[0])) { return $value[0]->getName(); @@ -132,13 +136,13 @@ public function formatModel($field, $model = null) } /** - * Returns Opus_Date values formatted as string. - * @param Opus_Date $date + * Returns Opus\Date values formatted as string. + * @param Date $date * @return string Formatted date */ public function formatDate($date) { - if (! ($date instanceof Opus_Date)) { + if (! ($date instanceof Date)) { return $date; } else { return $this->_dates->getDateString($date); @@ -159,10 +163,10 @@ public function formatDate($date) */ public function format($value, $model = null) { - if ($value instanceof Opus_Model_Abstract) { + if ($value instanceof AbstractModel) { return $this->formatModel($value, $model); } - if ($value instanceof Opus_Model_Field) { + if ($value instanceof Field) { return $this->formatModel($value, $model); } else { $this->getLogger()->debug('Formatting ' . $value); diff --git a/library/Application/View/Helper/FullUrl.php b/library/Application/View/Helper/FullUrl.php index 65bfe10401..28a3b16cbb 100644 --- a/library/Application/View/Helper/FullUrl.php +++ b/library/Application/View/Helper/FullUrl.php @@ -30,7 +30,6 @@ * @author Michael Lang * @copyright Copyright (c) 2008 - 2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -39,15 +38,15 @@ * application base url for absolute urls in views. * */ -class Application_View_Helper_FullUrl extends Zend_View_Helper_Abstract +class Application_View_Helper_FullUrl extends \Zend_View_Helper_Abstract { /** * Return the full url (server name followed by base URL). * This method might by useful when constructing absolute URLs. * - * @param Zend_View $view instance of Zend_View - * @return Full url string. + * @param \Zend_View $view instance of \Zend_View + * @return string Full url string. */ public function fullUrl() { diff --git a/library/Application/View/Helper/FulltextLogo.php b/library/Application/View/Helper/FulltextLogo.php index 8aee082ea4..305b780b9b 100644 --- a/library/Application/View/Helper/FulltextLogo.php +++ b/library/Application/View/Helper/FulltextLogo.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * View helper for rendering the fulltext logo for documents in the search result list. */ @@ -43,7 +45,7 @@ public function fulltextLogo($doc = null) $doc = $this->getDocument(); } - if (! $doc instanceof Opus_Document) { + if (! $doc instanceof Document) { // TODO log return; } diff --git a/library/Application/View/Helper/Highlight.php b/library/Application/View/Helper/Highlight.php index 33a0b0b369..082566469a 100644 --- a/library/Application/View/Helper/Highlight.php +++ b/library/Application/View/Helper/Highlight.php @@ -35,7 +35,7 @@ * View helper for wrapping strings inside larger string in HTML for * highlighting search terms in results. */ -class Application_View_Helper_Highlight extends Zend_View_Helper_Abstract +class Application_View_Helper_Highlight extends \Zend_View_Helper_Abstract { public function highlight($subject, $needle, $prefix = null, $suffix = null) diff --git a/library/Application/View/Helper/IsAuthenticated.php b/library/Application/View/Helper/IsAuthenticated.php index 4d696dfe54..8b76d33db2 100644 --- a/library/Application/View/Helper/IsAuthenticated.php +++ b/library/Application/View/Helper/IsAuthenticated.php @@ -34,7 +34,7 @@ /** * Returns true if current user is authenticated (logged in). */ -class Application_View_Helper_IsAuthenticated extends Zend_View_Helper_Abstract +class Application_View_Helper_IsAuthenticated extends \Zend_View_Helper_Abstract { /** @@ -42,7 +42,7 @@ class Application_View_Helper_IsAuthenticated extends Zend_View_Helper_Abstract */ public function isAuthenticated() { - $identity = Zend_Auth::getInstance()->getIdentity(); + $identity = \Zend_Auth::getInstance()->getIdentity(); return empty($identity) === false; } } diff --git a/library/Application/View/Helper/IsDisplayField.php b/library/Application/View/Helper/IsDisplayField.php index 8e63fb3958..8a3558424d 100644 --- a/library/Application/View/Helper/IsDisplayField.php +++ b/library/Application/View/Helper/IsDisplayField.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2017, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_View_Helper_IsDisplayField extends Zend_View_Helper_Abstract +class Application_View_Helper_IsDisplayField extends \Zend_View_Helper_Abstract { /** diff --git a/library/Application/View/Helper/JQueryEnabled.php b/library/Application/View/Helper/JQueryEnabled.php index 10cb2bfbcb..d34c0bec70 100644 --- a/library/Application/View/Helper/JQueryEnabled.php +++ b/library/Application/View/Helper/JQueryEnabled.php @@ -30,18 +30,17 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Checks if JQuery Library is available. */ -class Application_View_Helper_JQueryEnabled extends Zend_View_Helper_Abstract +class Application_View_Helper_JQueryEnabled extends \Zend_View_Helper_Abstract { public function jQueryEnabled() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (! isset($config->javascript->jquery->path)) { return false; } diff --git a/library/Application/View/Helper/LanguageImageExists.php b/library/Application/View/Helper/LanguageImageExists.php index ba089a0496..4f30fdcf2e 100644 --- a/library/Application/View/Helper/LanguageImageExists.php +++ b/library/Application/View/Helper/LanguageImageExists.php @@ -31,7 +31,7 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_View_Helper_LanguageImageExists extends Zend_View_Helper_Abstract +class Application_View_Helper_LanguageImageExists extends \Zend_View_Helper_Abstract { /** diff --git a/library/Application/View/Helper/LanguageSelector.php b/library/Application/View/Helper/LanguageSelector.php index f88a6c8409..38151b4feb 100644 --- a/library/Application/View/Helper/LanguageSelector.php +++ b/library/Application/View/Helper/LanguageSelector.php @@ -31,14 +31,13 @@ * @author Sascha Szott * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Builds the language selection form. * */ -class Application_View_Helper_LanguageSelector extends Zend_View_Helper_Abstract +class Application_View_Helper_LanguageSelector extends \Zend_View_Helper_Abstract { /** @@ -51,14 +50,14 @@ public function languageSelector() if (isset($this->view->languageSelectorDisabled) && $this->view->languageSelectorDisabled === true) { return null; } - $returnParams = Zend_Controller_Action_HelperBroker::getStaticHelper('ReturnParams'); + $returnParams = \Zend_Controller_Action_HelperBroker::getStaticHelper('ReturnParams'); - $currentLocale = new Zend_Locale(Zend_Registry::get('Zend_Translate')->getLocale()); + $currentLocale = new \Zend_Locale(\Zend_Registry::get('Zend_Translate')->getLocale()); $configHelper = new Application_Configuration(); // only show languages that are present in resources and activated in configuration - $translations = Zend_Registry::get('Zend_Translate')->getList(); + $translations = \Zend_Registry::get('Zend_Translate')->getList(); $supportedLang = $configHelper->getActivatedLanguages(); $translations = array_intersect($translations, $supportedLang); diff --git a/library/Application/View/Helper/LanguageWebForm.php b/library/Application/View/Helper/LanguageWebForm.php index c38118eb11..d5d8f499b3 100644 --- a/library/Application/View/Helper/LanguageWebForm.php +++ b/library/Application/View/Helper/LanguageWebForm.php @@ -31,10 +31,12 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Language; + /** * View helper for tranform long language form in short language form (Part2 in Part1). */ -class Application_View_Helper_LanguageWebForm extends Zend_View_Helper_Abstract +class Application_View_Helper_LanguageWebForm extends \Zend_View_Helper_Abstract { /** * Array with transformed language-attributes. So they don't have been computed twice. @@ -55,7 +57,7 @@ class Application_View_Helper_LanguageWebForm extends Zend_View_Helper_Abstract public function languageWebForm($value) { if (! array_key_exists($value, $this->_langCache)) { - $lang = Opus_Language::getPropertiesByPart2T($value); + $lang = Language::getPropertiesByPart2T($value); $this->_langCache[$value] = $lang['part1']; } return $this->_langCache[$value]; diff --git a/library/Application/View/Helper/LayoutPath.php b/library/Application/View/Helper/LayoutPath.php index 858af9b606..5202821dee 100644 --- a/library/Application/View/Helper/LayoutPath.php +++ b/library/Application/View/Helper/LayoutPath.php @@ -29,20 +29,19 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_View_Helper_LayoutPath extends Zend_View_Helper_Abstract +class Application_View_Helper_LayoutPath extends \Zend_View_Helper_Abstract { public function layoutPath() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $theme = 'opus4'; if (isset($config->theme)) { $theme = $config->theme; } - $fc = Zend_Controller_Front::getInstance(); + $fc = \Zend_Controller_Front::getInstance(); $request = $fc->getRequest(); return $request->getBaseUrl() . '/layouts/' . $theme; } diff --git a/library/Application/View/Helper/LinkList.php b/library/Application/View/Helper/LinkList.php index 90ae05ff1c..b4b77d1bfe 100644 --- a/library/Application/View/Helper/LinkList.php +++ b/library/Application/View/Helper/LinkList.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_View_Helper_LinkList extends Application_View_Helper_Abstract { diff --git a/library/Application/View/Helper/Locale.php b/library/Application/View/Helper/Locale.php index 17af8707df..4e6878d500 100644 --- a/library/Application/View/Helper/Locale.php +++ b/library/Application/View/Helper/Locale.php @@ -42,6 +42,6 @@ class Application_View_Helper_Locale extends Application_View_Helper_Abstract */ public function locale() { - return Zend_Registry::get('Zend_Translate')->getLocale(); + return \Zend_Registry::get('Zend_Translate')->getLocale(); } } diff --git a/library/Application/View/Helper/LoginBar.php b/library/Application/View/Helper/LoginBar.php index ca5a6e40fa..936cff613f 100644 --- a/library/Application/View/Helper/LoginBar.php +++ b/library/Application/View/Helper/LoginBar.php @@ -31,9 +31,10 @@ * @author Jens Schwidder (schwidder@zib.de) * @copyright Copyright (c) 2008, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Security\Realm; + /** * The LoginBar View Helper returns a link to an actual logout controller and action * or to a login action respectivly. By default it uses "login" and "logout" actions of @@ -42,7 +43,7 @@ * @category Application * @package View */ -class Application_View_Helper_LoginBar extends Zend_View_Helper_Abstract +class Application_View_Helper_LoginBar extends \Zend_View_Helper_Abstract { /** @@ -115,8 +116,8 @@ public function loginBar() */ public function __toString() { - $returnParams = Zend_Controller_Action_HelperBroker::getStaticHelper('ReturnParams'); - $identity = Zend_Auth::getInstance()->getIdentity(); + $returnParams = \Zend_Controller_Action_HelperBroker::getStaticHelper('ReturnParams'); + $identity = \Zend_Auth::getInstance()->getIdentity(); if (empty($identity) === true) { $url = $this->view->url(array_merge($this->_loginUrl, $returnParams->getReturnParameters())); return '' . $this->view->translate('default_auth_index') . ''; @@ -126,11 +127,11 @@ public function __toString() $addAccountLink = false; // Prüfe, ob Nutzer Zugriff auf Account Modul hat - $realm = Opus_Security_Realm::getInstance(); + $realm = Realm::getInstance(); if ($realm->checkModule('account') == true) { // Prüfe, ob Nutzer ihren Account editieren dürfen - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (isset($config) and isset($config->account->editOwnAccount)) { $addAccountLink = filter_var($config->account->editOwnAccount, FILTER_VALIDATE_BOOLEAN); } diff --git a/library/Application/View/Helper/MimeTypeAsCssClass.php b/library/Application/View/Helper/MimeTypeAsCssClass.php index 2168af2477..eed8dbb0d3 100644 --- a/library/Application/View/Helper/MimeTypeAsCssClass.php +++ b/library/Application/View/Helper/MimeTypeAsCssClass.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\File; + /** * View Helper fuer Link zu Datei. * @@ -36,13 +38,13 @@ * @copyright Copyright (c) 2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_View_Helper_MimeTypeAsCssClass extends Zend_View_Helper_Abstract +class Application_View_Helper_MimeTypeAsCssClass extends \Zend_View_Helper_Abstract { /** * Rendert Link fuer Datei. * - * @param $file Opus_File + * @param $file File * @return string HTML output */ public function mimeTypeAsCssClass($mimeType) diff --git a/library/Application/View/Helper/ResultTitle.php b/library/Application/View/Helper/ResultTitle.php index d47bcb974f..aced9df096 100644 --- a/library/Application/View/Helper/ResultTitle.php +++ b/library/Application/View/Helper/ResultTitle.php @@ -34,7 +34,7 @@ /** * Helper for printing the title of a OPUS document in search results. * - * TODO use $result->getAsset('title') ??? Avoid using Opus_Document (?) + * TODO use $result->getAsset('title') ??? Avoid using Document (?) */ class Application_View_Helper_ResultTitle extends Application_View_Helper_Document_HelperAbstract { @@ -79,7 +79,7 @@ public function getFrontdoorUrl($document) // TODO hack - can this be avoided? $searchType = $this->view->searchType; if (is_null($searchType)) { - $searchType = Zend_Controller_Front::getInstance()->getRequest()->getParam('searchtype'); + $searchType = \Zend_Controller_Front::getInstance()->getRequest()->getParam('searchtype'); } return $this->view->url([ diff --git a/library/Application/View/Helper/SeriesNumber.php b/library/Application/View/Helper/SeriesNumber.php index d0415d67f5..2b2818cac7 100644 --- a/library/Application/View/Helper/SeriesNumber.php +++ b/library/Application/View/Helper/SeriesNumber.php @@ -29,19 +29,21 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Series; + /** * This view helper returns the escaped number of a document in a series. */ -class Application_View_Helper_SeriesNumber extends Zend_View_Helper_Abstract +class Application_View_Helper_SeriesNumber extends \Zend_View_Helper_Abstract { /** * Returns the number of a document in a series. - * @param Opus_Document $document - * @param Opus_Series $series + * @param Document $document + * @param Series $series * @return string */ public function seriesNumber($document, $series) diff --git a/library/Application/View/Helper/TransferUrl.php b/library/Application/View/Helper/TransferUrl.php index e0d82b8376..130d82fdfb 100644 --- a/library/Application/View/Helper/TransferUrl.php +++ b/library/Application/View/Helper/TransferUrl.php @@ -35,7 +35,7 @@ * Generiert die Transfer-URL für den OAI-Container (Archivdatei), in der alle * verfügbaren Dateien des Dokuments zusammengefasst werden. */ -class Application_View_Helper_TransferUrl extends Zend_View_Helper_Abstract +class Application_View_Helper_TransferUrl extends \Zend_View_Helper_Abstract { public function transferUrl($docId) diff --git a/library/Application/View/Helper/Translate.php b/library/Application/View/Helper/Translate.php index feab715e0b..6b5c550294 100644 --- a/library/Application/View/Helper/Translate.php +++ b/library/Application/View/Helper/Translate.php @@ -34,7 +34,7 @@ /** * View helper for translations modifying behaviour of base class. */ -class Application_View_Helper_Translate extends Zend_View_Helper_Translate +class Application_View_Helper_Translate extends \Zend_View_Helper_Translate { /** @@ -67,7 +67,7 @@ public function translate($messageid = -1.1) $locale = null; - if (($optCount > 1) and Zend_Locale::isLocale($options[$optCount - 1])) { + if (($optCount > 1) and \Zend_Locale::isLocale($options[$optCount - 1])) { $locale = array_pop($options); } diff --git a/library/Application/View/Helper/TranslateIdentifier.php b/library/Application/View/Helper/TranslateIdentifier.php index e4dcb79a2d..772e71f742 100644 --- a/library/Application/View/Helper/TranslateIdentifier.php +++ b/library/Application/View/Helper/TranslateIdentifier.php @@ -31,10 +31,12 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Identifier; + /** * */ -class Application_View_Helper_TranslateIdentifier extends Zend_View_Helper_Translate +class Application_View_Helper_TranslateIdentifier extends \Zend_View_Helper_Translate { /** @@ -45,9 +47,9 @@ public function translateIdentifier($type = null) return $this; } - $translator = Zend_Registry::get(Application_Translate::REGISTRY_KEY); + $translator = \Zend_Registry::get(Application_Translate::REGISTRY_KEY); // TODO map from Type to field name - $fieldname = Opus_Identifier::getFieldnameForType($type); + $fieldname = Identifier::getFieldnameForType($type); return $translator->translate($fieldname); } } diff --git a/library/Application/View/Helper/TranslateLanguage.php b/library/Application/View/Helper/TranslateLanguage.php index ad753ac509..670bd1a0a9 100644 --- a/library/Application/View/Helper/TranslateLanguage.php +++ b/library/Application/View/Helper/TranslateLanguage.php @@ -34,7 +34,7 @@ /** * View helper for translations modifying behaviour of base class. */ -class Application_View_Helper_TranslateLanguage extends Zend_View_Helper_Translate +class Application_View_Helper_TranslateLanguage extends \Zend_View_Helper_Translate { /** @@ -52,7 +52,7 @@ class Application_View_Helper_TranslateLanguage extends Zend_View_Helper_Transla */ public function translateLanguage($langId) { - $translator = Zend_Registry::get(Application_Translate::REGISTRY_KEY); + $translator = \Zend_Registry::get(Application_Translate::REGISTRY_KEY); return $translator->translateLanguage($langId); } } diff --git a/library/Application/View/Helper/TranslateWithDefault.php b/library/Application/View/Helper/TranslateWithDefault.php index 635ffacf6c..cd2da479b8 100644 --- a/library/Application/View/Helper/TranslateWithDefault.php +++ b/library/Application/View/Helper/TranslateWithDefault.php @@ -34,7 +34,7 @@ /** * View helper that translates key if translation is found or returns provided default value. */ -class Application_View_Helper_TranslateWithDefault extends Zend_View_Helper_Abstract +class Application_View_Helper_TranslateWithDefault extends \Zend_View_Helper_Abstract { public function translateWithDefault($messageId, $default = '') diff --git a/library/Application/View/Helper/TranslationEditLink.php b/library/Application/View/Helper/TranslationEditLink.php index 22b94e4fb2..3b9b2dac18 100644 --- a/library/Application/View/Helper/TranslationEditLink.php +++ b/library/Application/View/Helper/TranslationEditLink.php @@ -60,7 +60,7 @@ public function translationEditLink($key) */ public function isEditingEnabled() { - $accessControl = Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); + $accessControl = \Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); if (is_null($accessControl)) { return false; // just in case - deny editing if access control mechanism isn't available diff --git a/library/Application/View/Helper/ViewFormDefault.php b/library/Application/View/Helper/ViewFormDefault.php index da43b551e5..8f63de1238 100644 --- a/library/Application/View/Helper/ViewFormDefault.php +++ b/library/Application/View/Helper/ViewFormDefault.php @@ -29,9 +29,8 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Application_View_Helper_ViewFormDefault extends Zend_View_Helper_FormElement +class Application_View_Helper_ViewFormDefault extends \Zend_View_Helper_FormElement { public function viewFormDefault($name, $value = null, $attribs = null) diff --git a/library/Application/View/Helper/ViewFormMultiCheckbox.php b/library/Application/View/Helper/ViewFormMultiCheckbox.php index 3a8c0349c9..8e109b9bdd 100644 --- a/library/Application/View/Helper/ViewFormMultiCheckbox.php +++ b/library/Application/View/Helper/ViewFormMultiCheckbox.php @@ -34,7 +34,7 @@ * @copyright Copyright (c) 2008-2017, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_View_Helper_ViewFormMultiCheckbox extends Zend_View_Helper_FormMultiCheckbox +class Application_View_Helper_ViewFormMultiCheckbox extends \Zend_View_Helper_FormMultiCheckbox { public function viewFormMultiCheckbox($name, $value = null, $attribs = null, $options = null, $listsep = "
\n") diff --git a/library/Application/View/Helper/ViewFormSelect.php b/library/Application/View/Helper/ViewFormSelect.php index 15eee8c400..5bdb8f2909 100644 --- a/library/Application/View/Helper/ViewFormSelect.php +++ b/library/Application/View/Helper/ViewFormSelect.php @@ -34,7 +34,7 @@ * @copyright Copyright (c) 2008-2017, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Application_View_Helper_ViewFormSelect extends Zend_View_Helper_FormSelect +class Application_View_Helper_ViewFormSelect extends \Zend_View_Helper_FormSelect { public function viewFormSelect($name, $value = null, $attribs = null, $options = null, $listsep = "
\n") diff --git a/library/Application/View/Helper/ViewFormTextarea.php b/library/Application/View/Helper/ViewFormTextarea.php index d427aed416..8233571402 100644 --- a/library/Application/View/Helper/ViewFormTextarea.php +++ b/library/Application/View/Helper/ViewFormTextarea.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_View_Helper_ViewFormTextarea extends Application_View_Helper_ViewFormDefault { diff --git a/library/Application/Xslt.php b/library/Application/Xslt.php index b64b4337b6..ee0044747e 100644 --- a/library/Application/Xslt.php +++ b/library/Application/Xslt.php @@ -87,7 +87,7 @@ public static function __callStatic($method, $arguments) */ public function findHelper($method) { - $helper = Zend_Registry::get('Opus_View')->getHelper($method); + $helper = \Zend_Registry::get('Opus_View')->getHelper($method); return $helper; } diff --git a/modules/account/Bootstrap.php b/modules/account/Bootstrap.php index 4f8dd86e24..a58f28acad 100644 --- a/modules/account/Bootstrap.php +++ b/modules/account/Bootstrap.php @@ -29,12 +29,11 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Empty class seems to be necessary to setup autoloading for modules. */ -class Account_Bootstrap extends Zend_Application_Module_Bootstrap +class Account_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/account/controllers/IndexController.php b/modules/account/controllers/IndexController.php index 4663f99c70..6de407bcaa 100644 --- a/modules/account/controllers/IndexController.php +++ b/modules/account/controllers/IndexController.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Account; + /** * Controller for editing account of logged in user. */ @@ -64,11 +65,11 @@ protected function customAccessCheck() */ public function indexAction() { - $login = Zend_Auth::getInstance()->getIdentity(); + $login = \Zend_Auth::getInstance()->getIdentity(); if (! empty($login)) { $accountForm = new Account_Form_Account(); - $account = new Opus_Account(null, null, $login); + $account = new Account(null, null, $login); $accountForm->populateFromModel($account); $actionUrl = $this->view->url(['action' => 'save']); @@ -90,14 +91,14 @@ public function indexAction() */ public function saveAction() { - $login = Zend_Auth::getInstance()->getIdentity(); + $login = \Zend_Auth::getInstance()->getIdentity(); $config = $this->getConfig(); $logger = $this->getLogger(); if (! empty($login) && $this->getRequest()->isPost()) { $accountForm = new Account_Form_Account(); - $account = new Opus_Account(null, null, $login); + $account = new Account(null, null, $login); $accountForm->populateFromModel($account); $postData = $this->getRequest()->getPost(); @@ -122,7 +123,7 @@ public function saveAction() $postData['oldLogin'] = $login; if ($accountForm->isValid($postData)) { - $account = new Opus_Account(null, null, $login); + $account = new Account(null, null, $login); $newLogin = $postData['username']; $password = $postData['password']; @@ -156,7 +157,7 @@ public function saveAction() $account->store(); if ($isLoginChanged || $isPasswordChanged) { - Zend_Auth::getInstance()->clearIdentity(); + \Zend_Auth::getInstance()->clearIdentity(); } } else { $actionUrl = $this->view->url(['action' => 'save']); diff --git a/modules/account/forms/Account.php b/modules/account/forms/Account.php index 263e9b4624..2e79ca6340 100644 --- a/modules/account/forms/Account.php +++ b/modules/account/forms/Account.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Account; + class Account_Form_Account extends Application_Form_Model_Abstract { @@ -70,12 +72,12 @@ public function init() ); $this->getElement(self::ELEMENT_PASSWORD)->addErrorMessages( - [Zend_Validate_StringLength::TOO_SHORT => 'admin_account_error_password_tooshort'] + [\Zend_Validate_StringLength::TOO_SHORT => 'admin_account_error_password_tooshort'] ); } /** - * @param $account Opus_Account + * @param $account Account */ public function populateFromModel($account) { diff --git a/modules/admin/Bootstrap.php b/modules/admin/Bootstrap.php index 331d1682d0..a616402fcf 100644 --- a/modules/admin/Bootstrap.php +++ b/modules/admin/Bootstrap.php @@ -29,12 +29,11 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Empty class seems to be necessary to setup autoloading for modules. */ -class Admin_Bootstrap extends Zend_Application_Module_Bootstrap +class Admin_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/admin/controllers/AccessController.php b/modules/admin/controllers/AccessController.php index f92d6c1311..371e70bfa6 100644 --- a/modules/admin/controllers/AccessController.php +++ b/modules/admin/controllers/AccessController.php @@ -33,6 +33,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\UserRole; + /** * Controller for managing permissions for roles including module access. * @@ -47,7 +49,7 @@ class Admin_AccessController extends Application_Controller_Action public function listroleAction() { $id = $this->getRequest()->getParam('docid'); - $roles = Opus_UserRole::getAll(); + $roles = UserRole::getAll(); $this->view->docId = $id; $this->view->roles = $roles; $this->view->checkedRoles = $this->getCheckedRoles($id, $roles); @@ -88,11 +90,11 @@ public function listmoduleAction() throw new Exception('Role ID missing'); } - $role = new Opus_UserRole($id); + $role = new UserRole($id); $roleModules = $role->listAccessModules(); if ($role->getName() !== 'guest') { - $guest = Opus_UserRole::fetchByName('guest'); + $guest = UserRole::fetchByName('guest'); $guestModules = $guest->listAccessModules(); // Role 'guest' has always access to 'default' module if (! in_array('default', $guestModules)) { @@ -163,7 +165,7 @@ private function storeModules($request) { $id = $request->getParam('roleid'); - $role = new Opus_UserRole($id); + $role = new UserRole($id); $roleModules = $role->listAccessModules(); foreach ($roleModules as $module) { @@ -197,7 +199,7 @@ private function storeRoles($request) { $docId = $request->getParam('docid'); - $roles = Opus_UserRole::getAll(); + $roles = UserRole::getAll(); foreach ($roles as $role) { $roleName = $role->getName(); diff --git a/modules/admin/controllers/AccountController.php b/modules/admin/controllers/AccountController.php index 719edacd6f..cde556c12b 100644 --- a/modules/admin/controllers/AccountController.php +++ b/modules/admin/controllers/AccountController.php @@ -33,6 +33,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Account; +use Opus\UserRole; + /** * Controller for administration of user accounts. * @@ -77,7 +80,7 @@ public function isDeletable($account) { $login = $account->getLogin(); - return ((Zend_Auth::getInstance()->getIdentity() !== strtolower($login)) && ($login !== 'admin')); + return ((\Zend_Auth::getInstance()->getIdentity() !== strtolower($login)) && ($login !== 'admin')); } public function getEditModelForm($model) @@ -108,16 +111,16 @@ public function showAction() $this->view->allModules = $modules; - $account = new Opus_Account($id); + $account = new Account($id); $this->view->account = $account; - // Get all Opus_UserRoles for current Account *plus* 'guest' + // Get all UserRoles for current Account *plus* 'guest' $roles = []; foreach ($account->getRole() as $roleLinkModel) { $roles[] = $roleLinkModel->getModel(); } - $guestRole = Opus_UserRole::fetchByName('guest'); + $guestRole = UserRole::fetchByName('guest'); if (! is_null($guestRole)) { $roles[] = $guestRole; } diff --git a/modules/admin/controllers/AutocompleteController.php b/modules/admin/controllers/AutocompleteController.php index 8fc333ecef..59b809f28d 100644 --- a/modules/admin/controllers/AutocompleteController.php +++ b/modules/admin/controllers/AutocompleteController.php @@ -33,6 +33,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Enrichment\AbstractType; + /** * Controller for providing JSON formatted data used for autocomplete * functions in forms. @@ -72,8 +74,8 @@ public function enrichmenttypedescriptionAction() $typeName = $this->getRequest()->getParam('typeName'); if (! is_null($typeName) && $typeName !== '') { - $typeName = 'Opus_Enrichment_' . $typeName; - $allTypes = Opus_Enrichment_AbstractType::getAllEnrichmentTypes(true); + $typeName = 'Opus\\Enrichment\\' . $typeName; + $allTypes = AbstractType::getAllEnrichmentTypes(true); if (in_array($typeName, $allTypes)) { $typeObj = new $typeName(); $typeDescription = $typeObj->getDescription(); diff --git a/modules/admin/controllers/CollectionController.php b/modules/admin/controllers/CollectionController.php index 170ff42864..1adb9a156c 100644 --- a/modules/admin/controllers/CollectionController.php +++ b/modules/admin/controllers/CollectionController.php @@ -34,9 +34,12 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Collection; +use Opus\CollectionRole; +use Opus\Model\NotFoundException; + /** * Controller for administration of collections. * @@ -190,7 +193,7 @@ public function showAction() $roleId = $this->getRequest()->getParam('role'); $id = null; if (! is_null($roleId)) { - $collectionRole = new Opus_CollectionRole($roleId); + $collectionRole = new CollectionRole($roleId); $rootCollection = $collectionRole->getRootCollection(); if (is_null($rootCollection)) { // collection role without root collection: create a new root collection @@ -299,14 +302,14 @@ public function createAction() switch ($type) { case 'child': - $refCollection = new Opus_Collection($id); + $refCollection = new Collection($id); $refCollection->addFirstChild($collection); $refCollection->store(); $message = $this->view->translate('admin_collections_add', [$collectionModel->getName()]); break; case 'sibling': - $refCollection = new Opus_Collection($id); + $refCollection = new Collection($id); $refCollection->addNextSibling($collection); $refCollection->store(); $message = $this->view->translate('admin_collections_add', [$collectionModel->getName()]); @@ -387,7 +390,7 @@ public function sortAction() } try { - $collection = new Opus_Collection($collectionId); + $collection = new Collection($collectionId); if (is_null($sortBy)) { return $this->_helper->Redirector->redirectToAndExit( @@ -418,7 +421,7 @@ public function sortAction() ); break; } - } catch (Opus_Model_NotFoundException $omnfe) { + } catch (NotFoundException $omnfe) { return $this->_helper->Redirector->redirectToAndExit( 'index', ['failure' => "collection with id $collectionId not found"], @@ -515,7 +518,7 @@ private function prepareAssignStartPage($documentId) private function prepareAssignSubPage($documentId, $collectionId) { - $collection = new Opus_Collection($collectionId); + $collection = new Collection($collectionId); $children = $collection->getChildren(); if (count($children) === 0) { // zurück zur Ausgangsansicht diff --git a/modules/admin/controllers/CollectionrolesController.php b/modules/admin/controllers/CollectionrolesController.php index 8771495df0..85822f1fb6 100644 --- a/modules/admin/controllers/CollectionrolesController.php +++ b/modules/admin/controllers/CollectionrolesController.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; + /** * Controller for administration of collection roles. * @@ -45,7 +47,7 @@ class Admin_CollectionrolesController extends Application_Controller_Action */ public function indexAction() { - $this->view->collectionRoles = Opus_CollectionRole::fetchAll(); + $this->view->collectionRoles = CollectionRole::fetchAll(); } /** @@ -53,7 +55,7 @@ public function indexAction() */ public function newAction() { - Opus_CollectionRole::fixPositions(); + CollectionRole::fixPositions(); $collectionRoleModel = new Admin_Model_CollectionRole(); $this->view->form = $this->getRoleForm($collectionRoleModel->getObject()); } @@ -63,7 +65,7 @@ public function newAction() */ public function editAction() { - Opus_CollectionRole::fixPositions(); + CollectionRole::fixPositions(); try { $collectionRoleModel = new Admin_Model_CollectionRole($this->getRequest()->getParam('roleid', '')); $this->view->form = $this->getRoleForm($collectionRoleModel->getObject()); @@ -221,10 +223,10 @@ private function setTitle($collectionRole) /** * Erzeugt Formular für ein CollectionRole Objekt. * - * @param Opus_CollectionRole $collectionRole + * @param CollectionRole $collectionRole * @return mixed */ - private function getRoleForm(Opus_CollectionRole $collectionRole) + private function getRoleForm(CollectionRole $collectionRole) { $form = new Admin_Form_CollectionRole(); $form->populateFromModel($collectionRole); diff --git a/modules/admin/controllers/ConfigController.php b/modules/admin/controllers/ConfigController.php index 2c7715c6ce..6dfd2bedab 100644 --- a/modules/admin/controllers/ConfigController.php +++ b/modules/admin/controllers/ConfigController.php @@ -47,7 +47,7 @@ public function indexAction() switch ($result) { case Admin_Form_Configuration::RESULT_SAVE: if ($form->isValid($data)) { - $config = new Zend_Config([], true); + $config = new \Zend_Config([], true); $form->updateModel($config); Application_Configuration::save($config); } else { diff --git a/modules/admin/controllers/DoctypeController.php b/modules/admin/controllers/DoctypeController.php index 6d59f8f94c..cb4740811a 100644 --- a/modules/admin/controllers/DoctypeController.php +++ b/modules/admin/controllers/DoctypeController.php @@ -34,7 +34,6 @@ * @author Michael Lang * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_DoctypeController extends Application_Controller_Action { @@ -44,7 +43,7 @@ class Admin_DoctypeController extends Application_Controller_Action public function init() { parent::init(); - $this->_documentTypesHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); + $this->_documentTypesHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); } public function indexAction() diff --git a/modules/admin/controllers/DocumentController.php b/modules/admin/controllers/DocumentController.php index b946a42f43..b30cc9dbcc 100644 --- a/modules/admin/controllers/DocumentController.php +++ b/modules/admin/controllers/DocumentController.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Controller for showing and editing a document in the administration. * @@ -58,7 +60,7 @@ public function init() /** * Produces metadata overview page of a document. - * @return Opus_Document + * @return Document */ public function indexAction() { @@ -234,7 +236,7 @@ public function editAction() * Liefert ein Formular, dessen Elemente mit den Werten des übergebenen Dokuments * initialisiert sind. * - * @param $document Opus_Document + * @param $document Document * @param $editSession Admin_Model_DocumentEditSession * * @return Admin_Form_Document|null @@ -271,7 +273,7 @@ private function handleGet($document, $editSession) */ public function createAction() { - $doc = new Opus_Document(); + $doc = Document::new(); $docId = $doc->store(); diff --git a/modules/admin/controllers/DocumentsController.php b/modules/admin/controllers/DocumentsController.php index 2c9d84af7d..6ff346f1d9 100644 --- a/modules/admin/controllers/DocumentsController.php +++ b/modules/admin/controllers/DocumentsController.php @@ -34,6 +34,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Collection; +use Opus\Person; +use Opus\Series; + /** * Administrative work with document metadata. * @@ -122,7 +126,7 @@ public function indexAction() if (! empty($collectionId)) { // TODO add as filter facet - $collection = new Opus_Collection($collectionId); + $collection = new Collection($collectionId); $result = $collection->getDocumentIds(); $this->view->collection = $collection; if ($collection->isRoot()) { @@ -136,7 +140,7 @@ public function indexAction() } } elseif (! empty($seriesId)) { // TODO add as filter facet - $series = new Opus_Series($seriesId); + $series = new Series($seriesId); $this->view->series = $series; $result = $series->getDocumentIdsSortedBySortKey(); } else { @@ -166,7 +170,7 @@ public function indexAction() $role = $this->getParam('role', 'all'); - $result = Opus_Person::getPersonDocuments($person, $state, $role, $sortOrder, ! $sortReverse); + $result = Person::getPersonDocuments($person, $state, $role, $sortOrder, ! $sortReverse); $this->view->person = $person; @@ -194,7 +198,7 @@ public function indexAction() $this->prepareSortingLinks(); - $paginator = Zend_Paginator::factory($result); + $paginator = \Zend_Paginator::factory($result); $page = 1; if (array_key_exists('page', $data)) { // paginator @@ -334,7 +338,7 @@ protected function setOption($name, $value) protected function getSession() { if (is_null($this->_namespace)) { - $this->_namespace = new Zend_Session_Namespace('Admin'); + $this->_namespace = new \Zend_Session_Namespace('Admin'); } return $this->_namespace; diff --git a/modules/admin/controllers/EnrichmentkeyController.php b/modules/admin/controllers/EnrichmentkeyController.php index ba37ea20cd..38346a04f5 100644 --- a/modules/admin/controllers/EnrichmentkeyController.php +++ b/modules/admin/controllers/EnrichmentkeyController.php @@ -33,6 +33,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Enrichment; +use Opus\EnrichmentKey; +use Opus\Model\NotFoundException; + /** * Class Admin_EnrichmentkeyController * @@ -91,7 +95,7 @@ public function getIndexForm() * Checks if an enrichment key can be modified. All enrichment keys except protected ones * can be modified even if they are referenced in enrichments of documents. * - * @param $model Opus_EnrichmentKey + * @param $model EnrichmentKey * @return bool true if model can be edited and deleted, false if model is protected */ public function isModifiable($model) @@ -116,8 +120,8 @@ public function getNewModelForm() $name = $this->getRequest()->getParam(self::PARAM_MODEL_ID); if (! is_null($name) && trim($name) !== '') { // prüfe, ob bereits ein nicht registrierter Enrichment Key mit den Namen existiert, der in Benutzung ist - if (is_null(Opus_EnrichmentKey::fetchByName($name)) && - in_array($name, Opus_EnrichmentKey::getAllReferenced())) { + if (is_null(EnrichmentKey::fetchByName($name)) && + in_array($name, EnrichmentKey::getAllReferenced())) { $form->setNameElementValue($name); } } @@ -150,8 +154,8 @@ public function handleModelPost($post = null) $oldName = $this->getRequest()->getParam(self::PARAM_MODEL_ID); if (! is_null($oldName) && - is_null(Opus_EnrichmentKey::fetchByName($oldName)) && - in_array($oldName, Opus_EnrichmentKey::getAllReferenced())) { + is_null(EnrichmentKey::fetchByName($oldName)) && + in_array($oldName, EnrichmentKey::getAllReferenced())) { $newName = $post[Admin_Form_EnrichmentKey::ELEMENT_NAME]; if (! is_null($newName) && $oldName !== $newName) { // Neuregistrierung mit gleichzeitiger Umbenennung des Enrichment Keys @@ -164,7 +168,7 @@ public function handleModelPost($post = null) if ($renamingOfUnregisteredKey && is_array($result) && in_array(self::SAVE_SUCCESS, $result)) { // Enrichment Key wurde erfolgreich registriert: Umbenennung des EK in den Dokumenten durchführen - $enrichmentKey = Opus_EnrichmentKey::fetchByName($newName); + $enrichmentKey = EnrichmentKey::fetchByName($newName); if (! is_null($enrichmentKey)) { // es hat eine Umbenennung mit gleichzeitiger Registrierung stattgefunden: nach der erfolgreichen // Registrierung des Enrichment Key muss der Name des EK in allen Dokumenten geändert werden @@ -185,7 +189,7 @@ public function removefromdocsAction() $enrichmentKey = $this->getModel($this->getRequest()->getParam(self::PARAM_MODEL_ID)); // dem Enrichment Key muss mindestens ein Dokument zugeordnet sein, sonst ist die Operation nicht ausführbar - if (! is_null($enrichmentKey) && in_array($enrichmentKey->getName(), Opus_EnrichmentKey::getAllReferenced())) { + if (! is_null($enrichmentKey) && in_array($enrichmentKey->getName(), EnrichmentKey::getAllReferenced())) { if (is_null($enrichmentKey->getId())) { // Sonderbehandlung für nicht registrierte Enrichment Keys, die in Dokuemten verwendet werden $result = $this->initConfirmationForm($enrichmentKey, true); @@ -204,7 +208,7 @@ public function removefromdocsAction() } /** - * @param Opus_EnrichmentKey $model + * @param EnrichmentKey $model * @param bool $unregistered * @return Application_Form_Confirmation */ @@ -223,7 +227,7 @@ private function initConfirmationForm($model, $unregistered = false) } /** - * @param Opus_EnrichmentKey $model + * @param EnrichmentKey $model */ public function deleteModel($model) { @@ -242,7 +246,7 @@ public function deleteModel($model) public function getAllModels() { // determine names of all enrichment keys - $allKeyNames = Opus_Enrichment::getAllUsedEnrichmentKeyNames(); + $allKeyNames = Enrichment::getAllUsedEnrichmentKeyNames(); $registeredEnrichmentKeys = parent::getAllModels(); $mapNamesToEnrichmentKeys = []; @@ -261,7 +265,7 @@ public function getAllModels() if (key_exists($keyName, $mapNamesToEnrichmentKeys)) { $result[] = $mapNamesToEnrichmentKeys[$keyName]; } else { - $newEnrichmentKey = new Opus_EnrichmentKey(); + $newEnrichmentKey = new EnrichmentKey(); $newEnrichmentKey->setName($keyName); $result[] = $newEnrichmentKey; } @@ -270,13 +274,13 @@ public function getAllModels() } /** - * Liefert eine Instanz von Opus_Enrichment mit übergebenen $modelId, sofern diese existiert (andernfalls null). + * Liefert eine Instanz von Enrichment mit übergebenen $modelId, sofern diese existiert (andernfalls null). * Hier wird der Sonderfall behandelt, dass die Id (d.h. der EnrichmentKey Name) nicht registriert ist. * Wird der nicht registrierte EnrichmentKey Name in Dokumenten verwendet, so wird ebenfalls eine Instanz von - * Opus_Enrichment zurückgegeben, die allerdings nicht in der Datenbank persistiert ist. + * Enrichment zurückgegeben, die allerdings nicht in der Datenbank persistiert ist. * * @param $modelId - * @return Opus_EnrichmentKey|null + * @return EnrichmentKey|null */ public function getModel($modelId) { @@ -286,10 +290,10 @@ public function getModel($modelId) if (strlen(trim($modelId)) !== 0) { try { return new $modelClass($modelId); - } catch (Opus_Model_NotFoundException $omnfe) { - if (in_array($modelId, Opus_EnrichmentKey::getAllReferenced())) { + } catch (NotFoundException $omnfe) { + if (in_array($modelId, EnrichmentKey::getAllReferenced())) { // Sonderbehandlung: nicht registrierter, aber in Benutzung befindlicher Enrichment Key - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName($modelId); return $enrichmentKey; } diff --git a/modules/admin/controllers/FilebrowserController.php b/modules/admin/controllers/FilebrowserController.php index 455baba111..42140c72cd 100644 --- a/modules/admin/controllers/FilebrowserController.php +++ b/modules/admin/controllers/FilebrowserController.php @@ -29,9 +29,11 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Model\NotFoundException; + /** * Browsing of file import folder for adding files to documents. * @@ -53,8 +55,8 @@ public function indexAction() $document = null; try { - $document = new Opus_Document($docId); - } catch (Opus_Model_NotFoundException $e) { + $document = Document::get($docId); + } catch (NotFoundException $e) { throw new Application_Exception('no document found for id ' . $docId, null, $e); } diff --git a/modules/admin/controllers/FilemanagerController.php b/modules/admin/controllers/FilemanagerController.php index f7a88a2159..8c38d6f7fb 100644 --- a/modules/admin/controllers/FilemanagerController.php +++ b/modules/admin/controllers/FilemanagerController.php @@ -25,6 +25,9 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\File; +use Opus\Model\ModelException; + /** * Controller fuer die Verwaltung der Dateien eines Dokuments. * @@ -34,7 +37,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2009-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ * * TODO redundanter Code mit DocumentController */ @@ -80,7 +82,7 @@ public function indexAction() $form->updateModel($document); try { $document->store(); - } catch (Opus_Mode_Exception $ome) { + } catch (ModelException $ome) { $this->getLogger()->err( __METHOD__ . ' Error saving file metadata: ' . $ome->getMessage() @@ -206,7 +208,7 @@ public function uploadAction() $form->updateModel($document); try { $document->store(); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->getLogger()->err("Storing document with new files failed" . $e); return $this->_helper->Redirector->redirectTo( 'index', @@ -320,7 +322,7 @@ public function deleteAction() try { $fileHelper->deleteFile($docId, $fileId); - } catch (Opus_Model_Exception $ome) { + } catch (ModelException $ome) { $this->getLogger()->err(__METHOD__ . ' Error deleting file. (' . $ome->getMessage . ')'); return $this->_helper->Redirector->redirectTo( 'index', @@ -350,7 +352,7 @@ public function deleteAction() } } else { // Show confirmation page - $file = new Opus_File($fileId); + $file = new File($fileId); $form->setModel($file); $form->setModelDisplayName($file->getPathName()); diff --git a/modules/admin/controllers/IndexController.php b/modules/admin/controllers/IndexController.php index d79558dfdb..bd59aa31ee 100644 --- a/modules/admin/controllers/IndexController.php +++ b/modules/admin/controllers/IndexController.php @@ -31,7 +31,6 @@ * @author Jens Schwidder (schwidder@zib.de) * @copyright Copyright (c) 2008, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/admin/controllers/InfoController.php b/modules/admin/controllers/InfoController.php index 2b4e561034..32929d78c0 100644 --- a/modules/admin/controllers/InfoController.php +++ b/modules/admin/controllers/InfoController.php @@ -34,7 +34,6 @@ * @author Michael Lang * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_InfoController extends Application_Controller_Action { diff --git a/modules/admin/controllers/JobController.php b/modules/admin/controllers/JobController.php index bcf66a46b8..08972e02cd 100644 --- a/modules/admin/controllers/JobController.php +++ b/modules/admin/controllers/JobController.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Job; + /** * Controller für die Anzeige von Informationen über Background-Jobs. * @@ -44,8 +46,8 @@ public function indexAction() if (isset($config->runjobs->asynchronous) && filter_var($config->runjobs->asynchronous, FILTER_VALIDATE_BOOLEAN)) { $this->view->asyncjobs = true; - $this->view->failedJobCount = Opus_Job::getCountPerLabel(Opus_Job::STATE_FAILED); - $this->view->unprocessedJobCount = Opus_Job::getCountPerLabel(Opus_Job::STATE_UNDEFINED); + $this->view->failedJobCount = Job::getCountPerLabel(Job::STATE_FAILED); + $this->view->unprocessedJobCount = Job::getCountPerLabel(Job::STATE_UNDEFINED); } else { $this->view->asyncjobs = false; } @@ -65,7 +67,7 @@ public function workerMonitorAction() $config = $this->getConfig(); $this->_helper->layout()->disableLayout(); if (isset($config->runjobs->asynchronous) && filter_var($config->runjobs->asynchronous, FILTER_VALIDATE_BOOLEAN)) { - $this->view->failedJobCount = Opus_Job::getCount(Opus_Job::STATE_FAILED); + $this->view->failedJobCount = Job::getCount(Job::STATE_FAILED); } else { $this->view->failedJobCount = 0; } @@ -80,6 +82,6 @@ public function detailAction() throw new Application_Exception('Invalid arguments'); } - $this->view->jobs = Opus_Job::getByLabels([$this->view->label], null, $this->view->state); + $this->view->jobs = Job::getByLabels([$this->view->label], null, $this->view->state); } } diff --git a/modules/admin/controllers/ModuleController.php b/modules/admin/controllers/ModuleController.php index 26b47633ae..f5b7fd89bb 100644 --- a/modules/admin/controllers/ModuleController.php +++ b/modules/admin/controllers/ModuleController.php @@ -43,7 +43,7 @@ class Admin_ModuleController extends Application_Controller_Action /** * Displays table with all modules. * - * @throws Zend_Exception + * @throws \Zend_Exception */ public function indexAction() { diff --git a/modules/admin/controllers/PersonController.php b/modules/admin/controllers/PersonController.php index 7227c0f4e6..d9b4ecac5c 100644 --- a/modules/admin/controllers/PersonController.php +++ b/modules/admin/controllers/PersonController.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Person; +use Opus\Model\NotFoundException; + /** * Controller fuer die Verwaltung von Personen. * @@ -136,7 +139,7 @@ public function indexAction() // TODO only include 'limit' and 'start' if provided as URL parameters (not defaults) $form = new Admin_Form_PersonListControl(); - $form->setMethod(Zend_Form::METHOD_POST); + $form->setMethod(\Zend_Form::METHOD_POST); // TODO only include limit if not default $form->setAction($this->view->url( @@ -154,7 +157,7 @@ public function indexAction() $form->populate($params); // TODO move into replaceable model class - $personsTotal = Opus_Person::getAllPersonsCount($role, $filter); + $personsTotal = Person::getAllPersonsCount($role, $filter); if ($start > $personsTotal) { if ($personsTotal > 0 && ($personsTotal > $limit)) { @@ -166,7 +169,7 @@ public function indexAction() $page = intdiv($start, $limit) + 1; - $persons = Opus_Person::getAllPersons($role, $start - 1, $limit, $filter); + $persons = Person::getAllPersons($role, $start - 1, $limit, $filter); $this->view->headScript()->appendFile($this->view->layoutPath() . '/js/admin.js'); @@ -176,7 +179,7 @@ public function indexAction() $end = $personsTotal; } - $paginator = Zend_Paginator::factory(( int )$personsTotal); + $paginator = \Zend_Paginator::factory(( int )$personsTotal); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage($limit); @@ -198,7 +201,7 @@ public function documentsAction() { $person = $this->getPersonCrit(); - $documents = Opus_Person::getPersonDocuments($person); + $documents = Person::getPersonDocuments($person); $this->view->documents = $documents; } @@ -224,7 +227,7 @@ public function editAction() ); } - $personValues = Opus_Person::getPersonValues($person); + $personValues = Person::getPersonValues($person); if (is_null($personValues)) { $this->_helper->Redirector->redirectTo( @@ -244,7 +247,7 @@ public function editAction() $formId = $this->getParam('formId'); // check if the request is coming from the 'Back' button of the confirmation form - $session = new Zend_Session_Namespace(self::SESSION_NAMESPACE); + $session = new \Zend_Session_Namespace(self::SESSION_NAMESPACE); if (isset($session->{$formId})) { $data = $session->{$formId}; @@ -267,16 +270,16 @@ public function editAction() $formId = $form->getElement(Admin_Form_Persons::ELEMENT_FORM_ID)->getValue(); // TODO store data in session for back button - $personNamespace = new Zend_Session_Namespace(self::SESSION_NAMESPACE); + $personNamespace = new \Zend_Session_Namespace(self::SESSION_NAMESPACE); $personNamespace->{$formId} = $data; $changes = $form->getChanges(); $confirmForm = new Admin_Form_PersonsConfirm(); $confirmForm->getElement(Admin_Form_PersonsConfirm::ELEMENT_FORM_ID)->setValue($formId); - $confirmForm->setOldValues(Opus_Person::convertToFieldNames($personValues)); + $confirmForm->setOldValues(Person::convertToFieldNames($personValues)); $confirmForm->populateFromModel($person); - $confirmForm->setChanges(Opus_Person::convertToFieldNames($changes)); + $confirmForm->setChanges(Person::convertToFieldNames($changes)); $confirmForm->setAction($this->view->url([ 'module' => 'admin', 'controller' => 'person', 'action' => 'update' ], null, false)); @@ -338,7 +341,7 @@ public function updateAction() $formId = $form->getElementValue(Admin_Form_PersonsConfirm::ELEMENT_FORM_ID); // make changes in database and redirect to list of persons with success message - $session = new Zend_Session_Namespace(self::SESSION_NAMESPACE); + $session = new \Zend_Session_Namespace(self::SESSION_NAMESPACE); if (isset($session->{$formId})) { $formData = $session->{$formId}; @@ -350,7 +353,7 @@ public function updateAction() $changes = $personForm->getChanges(); $documents = $form->getDocuments(); - Opus_Person::updateAll($person, $changes, $documents); + Person::updateAll($person, $changes, $documents); $message = 'admin_person_bulk_update_success'; } @@ -543,8 +546,8 @@ public function editlinkedAction() } try { - $person = new Opus_Person($personId); - } catch (Opus_Model_NotFoundException $omnfe) { + $person = new Person($personId); + } catch (NotFoundException $omnfe) { $this->getLogger()->err(__METHOD__ . ' ' . $omnfe->getMessage()); return $this->returnToMetadataForm($docId); } diff --git a/modules/admin/controllers/ReportController.php b/modules/admin/controllers/ReportController.php index 7f1270de96..fe1fdc9c04 100644 --- a/modules/admin/controllers/ReportController.php +++ b/modules/admin/controllers/ReportController.php @@ -31,6 +31,12 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Doi\DoiException; +use Opus\Doi\DoiManager; +use Opus\Doi\DoiManagerStatus; +use Opus\Doi\RegistrationException; + + /** * Controller for generating reports. */ @@ -89,7 +95,7 @@ public function doiAction() private function handleDoiRegistration($docId) { try { - $doiManager = new Opus_Doi_DoiManager(); + $doiManager = new DoiManager(); $doiRegistered = $doiManager->register($docId, true); if (! is_null($doiRegistered)) { return $this->_helper->Redirector->redirectTo( @@ -100,7 +106,7 @@ private function handleDoiRegistration($docId) ) ); } - } catch (Opus_Doi_RegistrationException $e) { + } catch (RegistrationException $e) { return $this->_helper->Redirector->redirectTo( 'doi', ['failure' => @@ -110,7 +116,7 @@ private function handleDoiRegistration($docId) ) . ': ' . $e->getMessage() ] ); - } catch (Opus_Doi_DoiException $e) { + } catch (DoiException $e) { return $this->_helper->Redirector->redirectTo( 'doi', ['failure' => @@ -134,8 +140,8 @@ private function handleDoiRegistration($docId) */ private function handleDoiVerification($docId) { - $doiManager = new Opus_Doi_DoiManager(); - $status = new Opus_Doi_DoiManagerStatus(); + $doiManager = new DoiManager(); + $status = new DoiManagerStatus(); $verifiedDoi = $doiManager->verify($docId, true, null, $status); if (! is_null($verifiedDoi)) { @@ -169,14 +175,14 @@ private function handleDoiVerification($docId) private function handleBulkRegistration() { - $doiManager = new Opus_Doi_DoiManager(); + $doiManager = new DoiManager(); $status = $doiManager->registerPending(); return $this->handleBulkOperation($status, 'registration'); } private function handleBulkVerification() { - $doiManager = new Opus_Doi_DoiManager(); + $doiManager = new DoiManager(); $status = $doiManager->verifyRegistered(); return $this->handleBulkOperation($status, 'verification'); } @@ -186,7 +192,7 @@ private function handleBulkVerification() * Es wird die Registrierung ($mode == 'registration') sowie die Prüfung ($mode == 'verification') * als Operation unterstützt. * - * @param Opus_Doi_DoiManagerStatus $status + * @param DoiManagerStatus $status * @param string $mode */ private function handleBulkOperation($status, $mode) diff --git a/modules/admin/controllers/SeriesController.php b/modules/admin/controllers/SeriesController.php index 25ffe5e31b..22100f354f 100644 --- a/modules/admin/controllers/SeriesController.php +++ b/modules/admin/controllers/SeriesController.php @@ -29,14 +29,15 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Series; + /** - * Controller for management of Opus_Series models in database. + * Controller for management of Series models in database. * - * Creating, editing, deleting of Opus_Series models. Changing the order - * of Opus_Series models. + * Creating, editing, deleting of Series models. Changing the order + * of Series models. */ class Admin_SeriesController extends Application_Controller_ActionCRUD { @@ -53,13 +54,13 @@ public function init() /** * Setzt Defaultwerte für das Formular. - * @return Opus_Series + * @return Series */ public function getNewModel() { $series = parent::getNewModel(); $series->setVisible(1); - $series->setSortOrder(Opus_Series::getMaxSortKey() + 1); + $series->setSortOrder(Series::getMaxSortKey() + 1); return $series; } diff --git a/modules/admin/controllers/StatisticController.php b/modules/admin/controllers/StatisticController.php index 1997e4ea7a..00b2fb204d 100644 --- a/modules/admin/controllers/StatisticController.php +++ b/modules/admin/controllers/StatisticController.php @@ -33,6 +33,9 @@ * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Date; + class Admin_StatisticController extends Application_Controller_Action { @@ -52,7 +55,7 @@ public function indexAction() $highest = max($years); - $selectYear = new Zend_Form_Element_Select( + $selectYear = new \Zend_Form_Element_Select( 'selectedYear', ["multiOptions" => $years, "value" => $highest] ); @@ -60,10 +63,10 @@ public function indexAction() $selectYear->setRequired(true) ->setLabel($this->view->translate('Select_Year_Label')); - $submit = new Zend_Form_Element_Submit('submit'); + $submit = new \Zend_Form_Element_Submit('submit'); $submit->setLabel($this->view->translate('Submit_Button_Label')); - $form = new Zend_Form(); + $form = new \Zend_Form(); $form->setAction($this->view->url(["controller" => "statistic", "action" => "show"])); $form->addElements([$selectYear, $submit]); @@ -80,7 +83,7 @@ public function showAction() $this->view->languageSelectorDisabled = true; - $date = new Opus_Date(); + $date = new Date(); $date->setYear($selectedYear)->setMonth(12)->setDay(31); $this->view->dateThreshold = $this->getHelper('Dates')->getDateString($date); diff --git a/modules/admin/controllers/WorkflowController.php b/modules/admin/controllers/WorkflowController.php index 0edd238d00..e051d063ac 100644 --- a/modules/admin/controllers/WorkflowController.php +++ b/modules/admin/controllers/WorkflowController.php @@ -35,6 +35,8 @@ * TODO verify previous checkbox results */ +use Opus\Document; + /** * Controller handles transitions of documents between states. * @@ -238,7 +240,7 @@ private function _sendNotification($document, $form = null) /** * Returns form for asking yes/no question like 'Delete file?'. * - * @param Opus_Document $document + * @param Document $document * @param string $action Target action that needs to be confirmed * @return Admin_Form_YesNoForm */ diff --git a/modules/admin/forms/AbstractDocumentSubForm.php b/modules/admin/forms/AbstractDocumentSubForm.php index 89fc814226..9e6f5a0fa4 100644 --- a/modules/admin/forms/AbstractDocumentSubForm.php +++ b/modules/admin/forms/AbstractDocumentSubForm.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Document; + /** * Abstraktes Unterformular (SubForm) fuer Metadaten-Formular. * @@ -109,10 +111,10 @@ public function processPost($data, $context) } /** - * Aktualisiert die Instanz von Opus_Document durch Formularwerte. + * Aktualisiert die Instanz von Document durch Formularwerte. * * TODO consider options for ChangeLog - * @param Opus_Document $document + * @param Document $document */ public function updateModel($model) { @@ -164,7 +166,7 @@ public function isDependenciesValid($data, $globalContext) */ public function getDatesHelper() { - return Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); + return \Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); } /** diff --git a/modules/admin/forms/AbstractModelSubForm.php b/modules/admin/forms/AbstractModelSubForm.php index 349a44298d..f5533c3d04 100644 --- a/modules/admin/forms/AbstractModelSubForm.php +++ b/modules/admin/forms/AbstractModelSubForm.php @@ -34,12 +34,12 @@ /** * Abstrakte Klasse fuer Unterformulare fuer Model Klassen. * - * Diese Klassen aktualisieren Opus_Document nicht direkt, sondern geben das von ihnen angezeigte Model an das + * Diese Klassen aktualisieren Document nicht direkt, sondern geben das von ihnen angezeigte Model an das * übergeordnete Formular weiter. Dadurch kann Admin_Form_Document_MultiSubForm zum Beispiel die Modelle aller Patente - * im Formular einsammeln und dann die Funktion setPatent verwenden, um das Feld in Opus_Document zu setzen. + * im Formular einsammeln und dann die Funktion setPatent verwenden, um das Feld in Document zu setzen. * - * Die updateModel Funktionen in diesen Klassen erwarten nicht Opus_Document als Parameter, sondern das entsprechende - * Model wie zum Beispiel Opus_Identifier oder Opus_Title. + * Die updateModel Funktionen in diesen Klassen erwarten nicht Document als Parameter, sondern das entsprechende + * Model wie zum Beispiel Identifier oder Title. */ abstract class Admin_Form_AbstractModelSubForm extends Admin_Form_AbstractDocumentSubForm { diff --git a/modules/admin/forms/Account.php b/modules/admin/forms/Account.php index e97b31c4c7..fc0af01295 100644 --- a/modules/admin/forms/Account.php +++ b/modules/admin/forms/Account.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Account; + /** * Account administration form. * @@ -61,7 +62,7 @@ class Admin_Form_Account extends Application_Form_Model_Abstract private $mode; /** - * Constructs empty form or populates it with values from Opus_Account($id). + * Constructs empty form or populates it with values from Account($id). * @param mixed $id */ public function __construct($id = null) @@ -72,7 +73,7 @@ public function __construct($id = null) parent::__construct(); if ($this->getMode() === self::MODE_EDIT) { - $account = new Opus_Account($id); + $account = new Account($id); $this->populateFromModel($account); } @@ -88,7 +89,7 @@ public function init() $this->setLabelPrefix('admin_account_label_'); $this->setUseNameAsLabel(true); - $this->setModelClass('Opus_Account'); + $this->setModelClass('Opus\Account'); $this->addElement('login', self::ELEMENT_LOGIN); @@ -115,8 +116,8 @@ public function init() } /** - * Populate the form values from Opus_Account instance. - * @param $account + * Populate the form values from Account instance. + * @param $account Account */ public function populateFromModel($account) { @@ -133,7 +134,7 @@ public function populateFromModel($account) // current user cannot remode administrator permission // TODO does it make sense? $adminRoleElement = $rolesForm->getElement('administrator'); - if (Zend_Auth::getInstance()->getIdentity() === strtolower($account->getLogin())) { + if (\Zend_Auth::getInstance()->getIdentity() === strtolower($account->getLogin())) { $adminRoleElement->setAttrib('disabled', true); } } @@ -162,7 +163,7 @@ public function updateModel($account) // TODO storing of model happens in ActionCRUD controller class -> need way to move this into controller // logout current user if login or password has changed if ($this->isCurrentUser() && $logout) { - Zend_Auth::getInstance()->clearIdentity(); + \Zend_Auth::getInstance()->clearIdentity(); } } @@ -197,7 +198,7 @@ public function isValid($values) if (! empty($accountId)) { $this->setMode(self::MODE_EDIT); - $account = new Opus_Account($accountId); + $account = new Account($accountId); $values['oldLogin'] = $account->getLogin(); } } @@ -226,7 +227,7 @@ public function isLoginChanged() $accountId = $this->getElementValue(self::ELEMENT_MODEL_ID); if (! empty($accountId)) { - $account = new Opus_Account($accountId); + $account = new Account($accountId); $oldLogin = $account->getLogin(); } else { $oldLogin = null; @@ -237,12 +238,12 @@ public function isLoginChanged() public function isCurrentUser() { - $currentUser = Zend_Auth::getInstance()->getIdentity(); + $currentUser = \Zend_Auth::getInstance()->getIdentity(); $accountId = $this->getElementValue(self::ELEMENT_MODEL_ID); if (! empty($accountId)) { - $account = new Opus_Account($accountId); + $account = new Account($accountId); $oldLogin = $account->getLogin(); } else { $oldLogin = null; @@ -278,7 +279,7 @@ public function rest() { if (!$hasAdministratorRole && $isCurrentUser) { - $newRoles[] = Opus_UserRole::fetchByName('administrator'); + $newRoles[] = UserRole::fetchByName('administrator'); } $account->setRole($newRoles); diff --git a/modules/admin/forms/ActionBox.php b/modules/admin/forms/ActionBox.php index 75b0e22f94..a5121d223a 100644 --- a/modules/admin/forms/ActionBox.php +++ b/modules/admin/forms/ActionBox.php @@ -58,13 +58,13 @@ public function init() { parent::init(); - $element = new Zend_Form_Element_Submit(self::ELEMENT_SAVE); + $element = new \Zend_Form_Element_Submit(self::ELEMENT_SAVE); $element->setValue('save'); $element->removeDecorator('DtDdWrapper'); $element->setLabel('Save'); $this->addElement($element); - $element = new Zend_Form_Element_Submit(self::ELEMENT_CANCEL); + $element = new \Zend_Form_Element_Submit(self::ELEMENT_CANCEL); $element->setValue('cancel'); $element->removeDecorator('DtDdWrapper'); $element->setLabel('Cancel'); @@ -122,7 +122,7 @@ public function getJumpLinks() } } else { // Sollte niemals passieren - Zend_Registry::get('Zend_Log')->err('ActionBox without parent form'); + \Zend_Registry::get('Zend_Log')->err('ActionBox without parent form'); } return $links; @@ -132,7 +132,7 @@ public function getStateLinks() { $links = []; - $workflow = Zend_Controller_Action_HelperBroker::getStaticHelper('workflow'); + $workflow = \Zend_Controller_Action_HelperBroker::getStaticHelper('workflow'); $targetStates = $workflow->getAllowedTargetStatesForDocument($this->_document); diff --git a/modules/admin/forms/CollectionRole.php b/modules/admin/forms/CollectionRole.php index a745b03d78..072b174bd5 100644 --- a/modules/admin/forms/CollectionRole.php +++ b/modules/admin/forms/CollectionRole.php @@ -33,6 +33,9 @@ * TODO OaiName could be optional since it is usually the same as Name (which could be used as default) * */ + +use Opus\CollectionRole; + class Admin_Form_CollectionRole extends Application_Form_Model_Abstract { @@ -58,7 +61,7 @@ public function init() $this->setUseNameAsLabel(true); $this->addElement('text', self::ELEMENT_NAME, [ - 'required' => true, 'size' => 70, 'maxlength' => Opus_CollectionRole::getFieldMaxLength('Name') + 'required' => true, 'size' => 70, 'maxlength' => CollectionRole::getFieldMaxLength('Name') ]); $this->getElement(self::ELEMENT_NAME)->addValidators([ new Application_Form_Validate_CollectionRoleNameUnique(), @@ -70,7 +73,7 @@ public function init() ]); $this->addElement('text', self::ELEMENT_OAI_NAME, [ - 'required' => true, 'size' => 30, 'maxlength' => Opus_CollectionRole::getFieldMaxLength('OaiName') + 'required' => true, 'size' => 30, 'maxlength' => CollectionRole::getFieldMaxLength('OaiName') ]); $this->getElement(self::ELEMENT_OAI_NAME)->addValidator( new Application_Form_Validate_CollectionRoleOaiNameUnique() @@ -91,7 +94,7 @@ public function init() } /** - * @param $collectionRole Opus_CollectionRole + * @param $collectionRole CollectionRole */ public function populateFromModel($collectionRole) { @@ -116,7 +119,7 @@ public function populateFromModel($collectionRole) } /** - * @param $collectionRole Opus_CollectionRole + * @param $collectionRole CollectionRole */ public function updateModel($collectionRole) { diff --git a/modules/admin/forms/Configuration.php b/modules/admin/forms/Configuration.php index 301bd4baac..c10f36b8b2 100644 --- a/modules/admin/forms/Configuration.php +++ b/modules/admin/forms/Configuration.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -132,8 +131,8 @@ public function updateModel($config) * * If necessary a new display group is created. * - * @param $element Form element - * @param $section Name of section + * @param $element \Zend_Form_Element Form element + * @param $section string Name of section * @throws Zend_Form_Exception */ public function addElementToSection($element, $section) diff --git a/modules/admin/forms/CopyDocument.php b/modules/admin/forms/CopyDocument.php index 130ac8e0a1..f5225b16bc 100644 --- a/modules/admin/forms/CopyDocument.php +++ b/modules/admin/forms/CopyDocument.php @@ -35,7 +35,7 @@ * * TODO */ -class Admin_Form_CopyDocument extends Zend_Form +class Admin_Form_CopyDocument extends \Zend_Form { const ELEMENT_COPY = 'Copy'; diff --git a/modules/admin/forms/DnbInstitute.php b/modules/admin/forms/DnbInstitute.php index 8c4774967d..69d296e7a4 100644 --- a/modules/admin/forms/DnbInstitute.php +++ b/modules/admin/forms/DnbInstitute.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\DnbInstitute; + class Admin_Form_DnbInstitute extends Application_Form_Model_Abstract { @@ -51,13 +52,13 @@ public function init() $this->setRemoveEmptyCheckbox(false); $this->setLabelPrefix('Opus_DnbInstitute_'); $this->setUseNameAsLabel(true); - $this->setModelClass('Opus_DnbInstitute'); + $this->setModelClass('Opus\DnbInstitute'); $this->addElement('text', self::ELEMENT_NAME, [ - 'required' => true, 'size' => 70, 'maxlength' => Opus_DnbInstitute::getFieldMaxLength('Name') + 'required' => true, 'size' => 70, 'maxlength' => DnbInstitute::getFieldMaxLength('Name') ]); $this->addElement('text', self::ELEMENT_DEPARTMENT, [ - 'size' => 70, 'maxlength' => Opus_DnbInstitute::getFieldMaxLength('Department') + 'size' => 70, 'maxlength' => DnbInstitute::getFieldMaxLength('Department') ]); $this->addElement('textarea', self::ELEMENT_ADDRESS); $this->addElement('text', self::ELEMENT_CITY, ['required' => true, 'size' => 50]); diff --git a/modules/admin/forms/Document.php b/modules/admin/forms/Document.php index 156c3380a1..10af2116df 100644 --- a/modules/admin/forms/Document.php +++ b/modules/admin/forms/Document.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; + /** * Formular fuer Metadaten eines Dokuments. */ @@ -88,7 +89,7 @@ class Admin_Form_Document extends Admin_Form_AbstractDocumentSubForm private $_message = null; /** - * @var Opus_Document + * @var Document */ private $_document; diff --git a/modules/admin/forms/Document/Abstract.php b/modules/admin/forms/Document/Abstract.php index c2266aa033..2241d63c2e 100644 --- a/modules/admin/forms/Document/Abstract.php +++ b/modules/admin/forms/Document/Abstract.php @@ -29,9 +29,11 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\TitleAbstract; +use Opus\Model\NotFoundException; + /** * Unterformular zum Editieren einer Zusammenfassung (abstract). * @@ -88,10 +90,10 @@ public function getModel() } try { - $abstract = new Opus_TitleAbstract($abstractId); - } catch (Opus_Model_NotFoundException $omnfe) { + $abstract = new TitleAbstract($abstractId); + } catch (NotFoundException $omnfe) { $this->getLogger()->err(__METHOD__ . " Unknown ID = '$abstractId' (" . $omnfe->getMessage() . ').'); - $abstract = new Opus_TitleAbstract(); + $abstract = new TitleAbstract(); } $this->updateModel($abstract); diff --git a/modules/admin/forms/Document/Actions.php b/modules/admin/forms/Document/Actions.php index 31d756b2db..056faf4f60 100644 --- a/modules/admin/forms/Document/Actions.php +++ b/modules/admin/forms/Document/Actions.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/admin/forms/Document/Bibliographic.php b/modules/admin/forms/Document/Bibliographic.php index 25ae752f30..b64512e647 100644 --- a/modules/admin/forms/Document/Bibliographic.php +++ b/modules/admin/forms/Document/Bibliographic.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; + /** * Unterformular fuer weitere Metadaten eines Dokuments. * @@ -113,13 +114,13 @@ public function init() } /** - * @param Opus_Document $document + * @param Document $document */ public function populateFromModel($document) { parent::populateFromModel($document); - $datesHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); + $datesHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); $this->getElement(self::ELEMENT_CONTRIBUTING_CORPORATION)->setValue($document->getContributingCorporation()); $this->getElement(self::ELEMENT_CREATING_CORPORATION)->setValue($document->getCreatingCorporation()); @@ -140,13 +141,13 @@ public function populateFromModel($document) } /** - * @param Opus_Document $document + * @param Document $document */ public function updateModel($document) { parent::updateModel($document); - $datesHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); + $datesHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('Dates'); $document->setContributingCorporation($this->getElementValue(self::ELEMENT_CONTRIBUTING_CORPORATION)); $document->setCreatingCorporation($this->getElementValue(self::ELEMENT_CREATING_CORPORATION)); diff --git a/modules/admin/forms/Document/Collection.php b/modules/admin/forms/Document/Collection.php index f7bd4e4b21..644c01941d 100644 --- a/modules/admin/forms/Document/Collection.php +++ b/modules/admin/forms/Document/Collection.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Collection; + /** * Unterformular fuer eine zugewiesene Collection. * @@ -77,7 +78,7 @@ public function init() /** * Initialisiert das Formular mit einer Collection. - * @param Opus_Collection $collection + * @param Collection $collection */ public function populateFromModel($collection) { @@ -133,13 +134,13 @@ public function processPost($data, $context) /** * Liefert das Model für die angezeigte Collection. * - * @return \Opus_Collection + * @return Collection */ public function getModel() { $colId = $this->getElement(self::ELEMENT_ID)->getValue(); - return new Opus_Collection($colId); + return new Collection($colId); } /** @@ -156,7 +157,7 @@ public function getModel() public function populateFromPost($post) { $colId = $post[self::ELEMENT_ID]; - $collection = new Opus_Collection($colId); + $collection = new Collection($colId); $this->populateFromModel($collection); } diff --git a/modules/admin/forms/Document/Collections.php b/modules/admin/forms/Document/Collections.php index bc4187da9e..3b9e770e09 100644 --- a/modules/admin/forms/Document/Collections.php +++ b/modules/admin/forms/Document/Collections.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Collection; +use Opus\Document; + /** * Subform fuer Collections im Metadaten-Formular. * @@ -81,7 +84,7 @@ public function init() /** * Erzeugt und initialisiert Unterformulare entsprechend den Collections eines Dokuments. - * @param Opus_Document $document + * @param Document $document */ public function populateFromModel($document) { @@ -176,7 +179,7 @@ public function constructFromPost($post, $document = null) * Diese Funktion iteriert über alle Unterformulare und fragt die Collections ab. Die Collections werden in einem * Array gesammelt und dann dem Dokument zugewiesen. * - * @param Opus_Document $document + * @param Document $document */ public function updateModel($document) { @@ -241,7 +244,7 @@ protected function _addSubForm($roleName, $data) */ protected function _addCollection($colId) { - $collection = new Opus_Collection($colId); + $collection = new Collection($colId); $collectionRole = $collection->getRole(); @@ -286,7 +289,7 @@ public function createCollectionForm($position) $multiWrapper = $subform->getDecorator('multiWrapper'); - if (! is_null($multiWrapper) && $multiWrapper instanceof Zend_Form_Decorator_HtmlTag) { + if (! is_null($multiWrapper) && $multiWrapper instanceof \Zend_Form_Decorator_HtmlTag) { $multiClass = $multiWrapper->getOption('class'); $multiClass .= ($position % 2 == 0) ? ' even' : ' odd'; $multiWrapper->setOption('class', $multiClass); diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index c9cd124de3..3cd34c5ee5 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -33,6 +33,14 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Enrichment; +use Opus\EnrichmentKey; +use Opus\Enrichment\SelectType; +use Opus\Enrichment\TextType; +use Opus\Model\ModelException; +use Opus\Model\NotFoundException; + + /** * Unterformular für einzelne Enrichments im Metadaten-Formular. * @@ -84,7 +92,7 @@ public function init() * Enrichment-Model. Diese Methode wird beim ersten Formularaufruf (GET) * aufgerufen. * - * @param Opus_Enrichment $enrichment + * @param Enrichment $enrichment */ public function populateFromModel($enrichment) { @@ -116,7 +124,7 @@ private function setEnrichmentValueFormElement($enrichmentKey, $value = null) // es handelt sich um ein Enrichment, das einen EnrichmentKey verwendet, // der noch keinen zugeordneten Typ besitzt: in diesem Fall wird der // EnrichmentType TextType angenommen (einfacher Text) - $enrichmentType = new Opus_Enrichment_TextType(); + $enrichmentType = new TextType(); } if ($enrichmentType->getFormElementName() === 'Select') { @@ -144,7 +152,7 @@ private function setEnrichmentValueFormElement($enrichmentKey, $value = null) * der nicht in der konfigurierten Werteliste im Enrichment-Key enthalten ist. Ein solcher Wert * soll dennoch (als erster Eintrag) im Select-Formularfeld zur Auswahl angeboten werden. * - * @param Opus_Enrichment_SelectType $enrichmentType + * @param SelectType $enrichmentType * @param string $value */ private function createSelectFormElement($enrichmentType, $value) @@ -152,9 +160,9 @@ private function createSelectFormElement($enrichmentType, $value) if (is_null($value)) { $enrichmentId = $this->getElement(self::ELEMENT_ID)->getValue(); try { - $enrichment = new Opus_Enrichment($enrichmentId); + $enrichment = new Enrichment($enrichmentId); $value = $enrichment->getValue(); - } catch (\Opus\Model\Exception $e) { + } catch (ModelException $e) { // ignore exception silently } } @@ -188,12 +196,12 @@ private function createSelectFormElement($enrichmentType, $value) /** * Aktualisiert Enrichment Modell mit Werten im Formular. * - * @param Opus_Enrichment $enrichment + * @param Enrichment $enrichment */ public function updateModel($enrichment) { $enrichmentKeyName = $this->getElementValue(self::ELEMENT_KEY_NAME); - $enrichmentKey = Opus_EnrichmentKey::fetchByName($enrichmentKeyName); + $enrichmentKey = EnrichmentKey::fetchByName($enrichmentKeyName); $enrichmentValue = $this->getElementValue(self::ELEMENT_VALUE); @@ -233,7 +241,7 @@ public function updateModel($enrichment) /** * Liefert angezeigtes oder neues (hinzuzufügendes) Enrichment Modell. * - * @return \Opus_Enrichment + * @return Enrichment */ public function getModel() { @@ -244,12 +252,12 @@ public function getModel() } try { - $enrichment = new Opus_Enrichment($enrichmentId); - } catch (Opus_Model_NotFoundException $omnfe) { + $enrichment = new Enrichment($enrichmentId); + } catch (NotFoundException $omnfe) { $this->getLogger()->err( __METHOD__ . " Unknown enrichment ID = '$enrichmentId' (" . $omnfe->getMessage() . ').' ); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); } $this->updateModel($enrichment); @@ -292,7 +300,7 @@ public function initEnrichmentValueElement($enrichmentKeyName = null, $enrichmen } } - $enrichmentKey = Opus_EnrichmentKey::fetchByName($enrichmentKeyName); + $enrichmentKey = EnrichmentKey::fetchByName($enrichmentKeyName); if (! is_null($enrichmentKey)) { // hier braucht erstmal nur das Formularelement für die Eingabe des // Enrichment-Wertes erzeugt und in das bestehende Formular eingebunden @@ -302,7 +310,7 @@ public function initEnrichmentValueElement($enrichmentKeyName = null, $enrichmen $valueToBeAdded = null; if (! is_null($enrichmentId)) { try { - $enrichment = new Opus_Enrichment($enrichmentId); + $enrichment = new Enrichment($enrichmentId); // besondere Überprüfung beim Select-Feld erforderlich: hier muss ggf. der aktuell // im Enrichment gespeicherte Wert zur Werteliste des Select-Felds hinzugefügt werden, // wenn er nicht bereits enthalten ist @@ -313,7 +321,7 @@ public function initEnrichmentValueElement($enrichmentKeyName = null, $enrichmen $valueToBeAdded = $enrichmentValue; } } - } catch (\Opus\Model\Exception $e) { + } catch (ModelException $e) { // ignore exception silently } } @@ -347,7 +355,7 @@ public function isValid($data) // gesetzt wurde und sich der Enrichment-Wert im POST-Request nicht vom ursprünglich im // Dokument gespeicherten Enrichment-Wert unterscheidet $enrichmentData = $data[$this->getName()]; - $enrichmentKey = Opus_EnrichmentKey::fetchByName($enrichmentData[self::ELEMENT_KEY_NAME]); + $enrichmentKey = EnrichmentKey::fetchByName($enrichmentData[self::ELEMENT_KEY_NAME]); if (! is_null($enrichmentKey)) { $enrichmentType = $enrichmentKey->getEnrichmentType(); if (! is_null($enrichmentType) && ! $enrichmentType->isStrictValidation()) { @@ -360,7 +368,7 @@ public function isValid($data) $enrichmentId = $enrichmentData[self::ELEMENT_ID]; try { - $enrichment = new Opus_Enrichment($enrichmentId); + $enrichment = new Enrichment($enrichmentId); if (! array_key_exists(self::ELEMENT_VALUE, $enrichmentData)) { return false; // negatives Validierungsergebnis bleibt bestehen @@ -385,7 +393,7 @@ public function isValid($data) $this->ignoreValueErrors = true; return true; } - } catch (Opus\Model\Exception $e) { + } catch (ModelException $e) { // ignore exception silently: do not change validation result } } diff --git a/modules/admin/forms/Document/File.php b/modules/admin/forms/Document/File.php index 6e0b28377e..3a38b3db54 100644 --- a/modules/admin/forms/Document/File.php +++ b/modules/admin/forms/Document/File.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\File; + /** * Formular fuer die Anzeige einer Datei in der Metadaten-Uebersicht. * @@ -33,7 +35,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_Form_Document_File extends Admin_Form_AbstractDocumentSubForm { @@ -55,8 +56,8 @@ public function init() } /** - * Setzt die Instanz von Opus_File fuer das Formular. - * @param Opus_File $model + * Setzt die Instanz von File fuer das Formular. + * @param File $model */ public function populateFromModel($model) { @@ -64,7 +65,7 @@ public function populateFromModel($model) } /** - * Liefert die gesetzte Instanz von Opus_File fuer Formular. + * Liefert die gesetzte Instanz von File fuer Formular. * @return null */ public function getModel() diff --git a/modules/admin/forms/Document/Files.php b/modules/admin/forms/Document/Files.php index 1fd82dafb5..3c41c515d7 100644 --- a/modules/admin/forms/Document/Files.php +++ b/modules/admin/forms/Document/Files.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_Form_Document_Files extends Admin_Form_AbstractDocumentSubForm diff --git a/modules/admin/forms/Document/General.php b/modules/admin/forms/Document/General.php index 85b6162234..99dac425e5 100644 --- a/modules/admin/forms/Document/General.php +++ b/modules/admin/forms/Document/General.php @@ -30,11 +30,12 @@ * @author Michael Lang * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; + /** - * Formular fuer allgemeine Felder von Opus_Document. + * Formular fuer allgemeine Felder von Document. * * TODO validierung */ @@ -99,7 +100,7 @@ public function init() /** * Befuellt das Formular anhand der Metadaten eines Dokuments. - * @param Opus_Document $document + * @param Document $document */ public function populateFromModel($document) { @@ -122,7 +123,7 @@ public function populateFromModel($document) /** * Aktualisiert ein Dokument mit den Werten im Formular. - * @param Opus_Document $document + * @param Document $document */ public function updateModel($document) { diff --git a/modules/admin/forms/Document/Grantor.php b/modules/admin/forms/Document/Grantor.php index 7a6019d774..22f7436f75 100644 --- a/modules/admin/forms/Document/Grantor.php +++ b/modules/admin/forms/Document/Grantor.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/admin/forms/Document/Identifier.php b/modules/admin/forms/Document/Identifier.php index 38734be8c1..9d66cd567a 100644 --- a/modules/admin/forms/Document/Identifier.php +++ b/modules/admin/forms/Document/Identifier.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Identifier; +use Opus\Model\NotFoundException; + /** * Formular fuer einen Identifier eines Dokuments. * @@ -77,8 +80,8 @@ public function init() } /** - * Befuehlt Formularelement von Opus_Identifier Instanz. - * @param Opus_Identifier $identifier + * Befuehlt Formularelement von Identifier Instanz. + * @param Identifier $identifier */ public function populateFromModel($identifier) { @@ -88,8 +91,8 @@ public function populateFromModel($identifier) } /** - * Aktualisiert Opus_Identifier Instanz aus Formularelementen. - * @param Opus_Identifier $identifier + * Aktualisiert Identifier Instanz aus Formularelementen. + * @param Identifier $identifier */ public function updateModel($identifier) { @@ -108,14 +111,14 @@ public function getModel() if (strlen(trim($modelId)) > 0) { try { - $identifier = new Opus_Identifier($modelId); - } catch (Opus_Model_NotFoundException $omnfe) { + $identifier = new Identifier($modelId); + } catch (NotFoundException $omnfe) { $this->getLogger()->err(__METHOD__ . " Unknown identifier ID = '$modelId'."); } } if (is_null($identifier)) { - $identifier = new Opus_Identifier(); + $identifier = new Identifier(); } $this->updateModel($identifier); diff --git a/modules/admin/forms/Document/IdentifierSpecific.php b/modules/admin/forms/Document/IdentifierSpecific.php index 5f3dd282d6..70298e26cc 100644 --- a/modules/admin/forms/Document/IdentifierSpecific.php +++ b/modules/admin/forms/Document/IdentifierSpecific.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Identifier; +use Opus\Model\NotFoundException; + class Admin_Form_Document_IdentifierSpecific extends Admin_Form_AbstractModelSubForm { @@ -74,9 +77,9 @@ public function init() } /** - * Befüllt Formularelemente aus Opus_Identifier Instanz. + * Befüllt Formularelemente aus Identifier Instanz. * - * @param Opus_Identifier $identifier + * @param Identifier $identifier */ public function populateFromModel($identifier) { @@ -91,9 +94,9 @@ public function setValue($value) } /** - * Aktualisiert Opus_Identifier Instanz aus Formularelementen. + * Aktualisiert Identifier Instanz aus Formularelementen. * - * @param Opus_Identifier $identifier + * @param Identifier $identifier */ public function updateModel($identifier) { @@ -109,14 +112,14 @@ public function getModel() if (strlen(trim($modelId)) > 0) { try { - $identifier = new Opus_Identifier($modelId); - } catch (Opus_Model_NotFoundException $omnfe) { + $identifier = new Identifier($modelId); + } catch (NotFoundException $omnfe) { $this->getLogger()->err(__METHOD__ . " Unknown identifier ID = '$modelId'."); } } if (is_null($identifier)) { - $identifier = new Opus_Identifier(); + $identifier = new Identifier(); $identifier->setType($this->type); } diff --git a/modules/admin/forms/Document/Institute.php b/modules/admin/forms/Document/Institute.php index 5c727e3b49..11538b92d2 100644 --- a/modules/admin/forms/Document/Institute.php +++ b/modules/admin/forms/Document/Institute.php @@ -29,9 +29,13 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\DnbInstitute; +use Opus\Model\Dependent\Link\DocumentDnbInstitute; +use Opus\Model\NotFoundException; +use Opus\Model\Dependent\Link\AbstractLinkModel; + /** * Unterformular fuer Institute. * @@ -51,7 +55,7 @@ class Admin_Form_Document_Institute extends Admin_Form_AbstractModelSubForm const ELEMENT_INSTITUTE = 'Institute'; /** - * @var ROLE_GRANTOR or ROLE_PUBLISHER + * @var string ROLE_GRANTOR or ROLE_PUBLISHER */ private $_role; @@ -76,7 +80,6 @@ public function init() break; default: throw new Application_Exception(__METHOD__ . ' Unknown role \'' . $this->_role . '\'.'); - break; } } @@ -88,16 +91,16 @@ public function populateFromModel($link) } /** - * @param type $model + * @param $model AbstractLinkModel */ public function updateModel($link) { $instituteId = $this->getElement(self::ELEMENT_INSTITUTE)->getValue(); try { - $institute = new Opus_DnbInstitute($instituteId); + $institute = new DnbInstitute($instituteId); $link->setModel($institute); - } catch (Opus_Model_NotFoundException $omnfe) { + } catch (NotFoundException $omnfe) { $this->getLogger()->err(__METHOD__ . " Unknown institute ID = '$instituteId'."); } } @@ -114,9 +117,9 @@ public function getModel() } try { - $link = new Opus_Model_Dependent_Link_DocumentDnbInstitute($linkId); - } catch (Opus_Model_NotFoundException $omnfe) { - $link = new Opus_Model_Dependent_Link_DocumentDnbInstitute(); + $link = new DocumentDnbInstitute($linkId); + } catch (NotFoundException $omnfe) { + $link = new DocumentDnbInstitute(); } $this->updateModel($link); diff --git a/modules/admin/forms/Document/Licences.php b/modules/admin/forms/Document/Licences.php index b2812aad00..e7a66af4e0 100644 --- a/modules/admin/forms/Document/Licences.php +++ b/modules/admin/forms/Document/Licences.php @@ -29,9 +29,11 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Licence; + /** * Formular fuer das Editieren der Lizenzen eines Dokuments. * @@ -66,7 +68,7 @@ public function init() { parent::init(); - $licences = Opus_Licence::getAll(); + $licences = Licence::getAll(); foreach ($licences as $licence) { $element = new Application_Form_Element_Checkbox(self::ELEMENT_NAME_PREFIX . $licence->getId()); @@ -84,14 +86,14 @@ public function init() /** * Setzt die dem Dokument zugewiesenen Lizenzen als ausgewählt im Formular. - * @param Opus_Document $document + * @param Document $document */ public function populateFromModel($document) { $licences = $this->getElements(); foreach ($licences as $element) { - if ($element instanceof Zend_Form_Element_Checkbox) { + if ($element instanceof \Zend_Form_Element_Checkbox) { $licenceId = $element->getCheckedValue(); $element->setChecked($this->hasLicence($document, $licenceId)); } @@ -100,7 +102,7 @@ public function populateFromModel($document) /** * Aktualisiert die Liste der Lizenzen fuer ein Dokument. - * @param Opus_Document $document + * @param Document $document */ public function updateModel($document) { @@ -109,10 +111,10 @@ public function updateModel($document) $docLicences = []; foreach ($licences as $element) { - if ($element instanceof Zend_Form_Element_Checkbox) { + if ($element instanceof \Zend_Form_Element_Checkbox) { $licenceId = $element->getCheckedValue(); if ($element->getValue() !== '0') { - $docLicences[] = new Opus_Licence($licenceId); + $docLicences[] = new Licence($licenceId); } } } @@ -123,8 +125,8 @@ public function updateModel($document) /** * Prueft, ob eine Lizenz einem Dokument zugewiesen ist. * - * @param Opus_Document $document - * @param Opus_Licence $licence + * @param Document $document + * @param Licence $licence * @return boolean true - Lizenz zugewiesen; false - Lizenz nicht zugewiesen */ public function hasLicence($document, $licenceId) diff --git a/modules/admin/forms/Document/MultiEnrichmentSubForm.php b/modules/admin/forms/Document/MultiEnrichmentSubForm.php index c6f180e633..9dd37abb5f 100644 --- a/modules/admin/forms/Document/MultiEnrichmentSubForm.php +++ b/modules/admin/forms/Document/MultiEnrichmentSubForm.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Form for editing enrichments. * @@ -145,10 +147,10 @@ protected function processPostSelectionChanged() /** * Erzeugt und füllt die Enrichment-Unterformular mit Werten auf Basis des - * übergebenen Opus_Documents. Diese Methode wird immer dann aufgerufen, + * übergebenen Documents. Diese Methode wird immer dann aufgerufen, * wenn das Metadatenformular erstmalig (per GET) aufgerufen wird. * - * @param Opus_Document $document + * @param Document $document */ public function populateFromModel($document) { diff --git a/modules/admin/forms/Document/MultiIdentifierOtherSubForm.php b/modules/admin/forms/Document/MultiIdentifierOtherSubForm.php index ce2aac3e77..58122df944 100644 --- a/modules/admin/forms/Document/MultiIdentifierOtherSubForm.php +++ b/modules/admin/forms/Document/MultiIdentifierOtherSubForm.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + class Admin_Form_Document_MultiIdentifierOtherSubForm extends Admin_Form_Document_MultiSubForm { @@ -73,7 +75,7 @@ private function filterIdentifier($identifiers) * wir dürfen hier nicht die setIdentifier-Methode direkt verwenden, sonst löschen wir DOIs/URNs * die mit dem Dokument verknüpft sind * - * @param Opus_Document $document + * @param Document $document */ public function updateModel($document) { diff --git a/modules/admin/forms/Document/MultiIdentifierSubForm.php b/modules/admin/forms/Document/MultiIdentifierSubForm.php index ce044293de..6e68816448 100644 --- a/modules/admin/forms/Document/MultiIdentifierSubForm.php +++ b/modules/admin/forms/Document/MultiIdentifierSubForm.php @@ -31,6 +31,12 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Enrichment; +use Opus\Identifier; +use Opus\Doi\DoiException; +use Opus\Doi\DoiManager; + class Admin_Form_Document_MultiIdentifierSubForm extends Admin_Form_Document_MultiSubForm { @@ -131,7 +137,7 @@ private function addCheckbox() /** * Erzeugt Unterformulare abhängig von den Metadaten im Dokument. * - * @param Opus_Document $document + * @param Document $document */ public function populateFromModel($document) { @@ -173,7 +179,7 @@ public function populateFromModel($document) * @param int $position * @param null $disableGenerateButton * - * @return _subFormClass + * @return \Zend_Form _subFormClass */ protected function _addSubForm($position, $disableGenerateButton = null) { @@ -242,8 +248,8 @@ private function addGenerateAtPublishCheckbox($document) * bei bereits veröffentlichten Dokumenten soll die Checkbox zum automatischen * Setzen der ID nicht angezeigt werden * - * @param Opus_Document $document das zu editierende Dokument - * @return liefert true zurück, wenn die Checkbox entfernt wurde + * @param Document $document das zu editierende Dokument + * @return bool liefert true zurück, wenn die Checkbox entfernt wurde */ private function removeCheckboxForPublishedDocs($document) { @@ -257,8 +263,8 @@ private function removeCheckboxForPublishedDocs($document) /** * Filtert aus der übergebenen Liste von Identifiern nur die Identifier mit dem Typ aus. * - * @param array $identifiers Liste mit Elementen vom Typ Opus_Identifier - * @return array mit Elementen vom Typ Opus_Identifier (nach der Filterung auf Basis des Typs) + * @param array $identifiers Liste mit Elementen vom Typ Identifier + * @return array mit Elementen vom Typ Identifier (nach der Filterung auf Basis des Typs) */ private function filterIdentifier($identifiers) { @@ -372,7 +378,7 @@ protected function processPostGenerate($subform, $docId) switch ($this->_subFormClass) { case 'Admin_Form_Document_IdentifierDOI': try { - $doiManager = new Opus_Doi_DoiManager(); + $doiManager = new DoiManager(); $doiValue = $doiManager->generateNewDoi($docId); $subform->setValue($doiValue); if ($doiValue != '') { @@ -380,7 +386,7 @@ protected function processPostGenerate($subform, $docId) $button = $subform->getElement(self::ELEMENT_GENERATE); $button->setAttrib('disabled', 'disabled'); } - } catch (Opus_Doi_DoiException $e) { + } catch (DoiException $e) { // generation of DOI value failed: show error message } break; @@ -411,11 +417,11 @@ protected function processPostGenerate($subform, $docId) /** * Aktualisiert das in der Datenbank gespeicherte Dokument (hier: seine Identifier) * - * @param Opus_Document $document + * @param Document $document */ public function updateModel($document) { - // Array von Opus_Identifier Objekten eines Typs + // Array von Identifier Objekten eines Typs $values = $this->getSubFormModels($document); if (! empty($values)) { @@ -448,7 +454,7 @@ public function updateModel($document) } while ($identifierValuesIndex < $identifierValuesCount) { - $identifier = new Opus_Identifier(); + $identifier = new Identifier(); $identifier->setType($this->_typeShort); $identifier->setValue($identifierValues[$identifierValuesIndex]); $identifiers[] = $identifier; @@ -488,7 +494,7 @@ private function handleEnrichment($document) } if (! $enrichmentExists) { - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName($enrichmentKeyName); $enrichment->setValue($enrichmentValue); $newEnrichments[] = $enrichment; @@ -500,7 +506,7 @@ private function handleEnrichment($document) /** * Erzeugt neues Unterformular zum Hinzufügen. - * @return _subFormClass + * @return \Zend_Form _subFormClass */ public function createSubForm() { @@ -548,7 +554,7 @@ private function addGenerateButton($subform, $enabled = true) /** * Bereitet die Dekoratoren für das Unterformular vor. * - * @param type $subform + * @param $subform \Zend_Form */ protected function prepareSubFormDecorators($subform) { diff --git a/modules/admin/forms/Document/MultiSubForm.php b/modules/admin/forms/Document/MultiSubForm.php index 791e820746..d21919da1f 100644 --- a/modules/admin/forms/Document/MultiSubForm.php +++ b/modules/admin/forms/Document/MultiSubForm.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * SubForm um mehrere Unterformulare (z.B. Patente) zu verwalten. * @@ -65,7 +67,7 @@ class Admin_Form_Document_MultiSubForm extends Admin_Form_AbstractDocumentSubFor protected $_subFormClass; /** - * Opus_Document Feldname für Unterformulare. + * Document Feldname für Unterformulare. * @var type */ protected $_fieldName; @@ -84,7 +86,7 @@ class Admin_Form_Document_MultiSubForm extends Admin_Form_AbstractDocumentSubFor * Konstruiert Instanz von Fomular. * * @param string $subFormClass Name der Klasse für Unterformulare - * @param string $fieldName Name des Opus_Document Feldes, das angezeigt werden soll + * @param string $fieldName Name des Document Feldes, das angezeigt werden soll * @param string $validator Object für Validierungen über Unterformulare hinweg * @param multi $options */ @@ -154,7 +156,7 @@ protected function initButton() /** * Erzeugt Unterformulare abhängig von den Metadaten im Dokument. * - * @param Opus_Document $document + * @param Document $document */ public function populateFromModel($document) { @@ -178,7 +180,7 @@ public function populateFromModel($document) /** * Holt vom Dokument den Wert des konfigurierten Feldes. - * @param Opus_Document $document + * @param Document $document * @return array */ public function getFieldValues($document) @@ -285,7 +287,7 @@ protected function processPostAdd() /** * Aktualisiert das Dokument. * - * @param Opus_Document $document + * @param Document $document */ public function updateModel($document) { @@ -355,7 +357,7 @@ protected function _setOddEven($subForm) $multiWrapper = $subForm->getDecorator('multiWrapper'); - if (! is_null($multiWrapper) && $multiWrapper instanceof Zend_Form_Decorator_HtmlTag) { + if (! is_null($multiWrapper) && $multiWrapper instanceof \Zend_Form_Decorator_HtmlTag) { $multiClass = $multiWrapper->getOption('class'); $markerClass = ($position % 2 == 0) ? 'even' : 'odd'; diff --git a/modules/admin/forms/Document/Note.php b/modules/admin/forms/Document/Note.php index 717572ad2a..e39eeb4be3 100644 --- a/modules/admin/forms/Document/Note.php +++ b/modules/admin/forms/Document/Note.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Note; + /** * Unterformular fuer Bemerkungen/Notizen. * @@ -33,7 +35,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_Form_Document_Note extends Admin_Form_AbstractModelSubForm { @@ -88,7 +89,7 @@ public function getModel() $noteId = null; } - $note = new Opus_Note($noteId); + $note = new Note($noteId); $this->updateModel($note); diff --git a/modules/admin/forms/Document/Patent.php b/modules/admin/forms/Document/Patent.php index d21443d7de..5b8da304f7 100644 --- a/modules/admin/forms/Document/Patent.php +++ b/modules/admin/forms/Document/Patent.php @@ -26,8 +26,11 @@ * */ +use Opus\Patent; +use Opus\Model\NotFoundException; + /** - * Formular für Opus_Patent Objekte. + * Formular für Patent Objekte. * * Felder: * - Countries @@ -42,7 +45,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ * * @SuppressWarnings(PHPMD.DepthOfInheritance) */ @@ -50,7 +52,7 @@ class Admin_Form_Document_Patent extends Admin_Form_AbstractModelSubForm { /** - * Name fuer Formularelement fuer ID von Opus_Patent. + * Name fuer Formularelement fuer ID von Patent. */ const ELEMENT_ID = 'Id'; @@ -83,7 +85,7 @@ class Admin_Form_Document_Patent extends Admin_Form_AbstractModelSubForm * Präfix fuer Übersetzungsschlüssel (noch nicht verwendet). * @var string */ - protected $_translationPrefix = ''; // TODO OPUSVIER-1875 Sollte sein: 'Opus_Patent_'; + protected $_translationPrefix = ''; // TODO OPUSVIER-1875 Sollte sein: 'Patent_'; /** * Erzeugt die Formularelemente. @@ -105,8 +107,8 @@ public function init() } /** - * Setzt die Formularelement entsprechend der Instanz von Opus_Patent. - * @param Opus_Patent $patent + * Setzt die Formularelement entsprechend der Instanz von Patent. + * @param Patent $patent */ public function populateFromModel($patent) { @@ -123,8 +125,8 @@ public function populateFromModel($patent) } /** - * Aktualisiert Instanz von Opus_Patent mit Werten in Formular. - * @param Opus_Patent $patent + * Aktualisiert Instanz von Patent mit Werten in Formular. + * @param Patent $patent */ public function updateModel($patent) { @@ -141,12 +143,12 @@ public function updateModel($patent) } /** - * Liefert Opus_Patent Instanz fuer das Formular. + * Liefert Patent Instanz fuer das Formular. * - * Wenn das Formular eine existierende Opus_Patent Instanz repräsentiert (gesetztes ID Feld) wird diese Instanz + * Wenn das Formular eine existierende Patent Instanz repräsentiert (gesetztes ID Feld) wird diese Instanz * zurück geliefert und ansonsten eine neue Instanz erzeugt. * - * @return \Opus_Patent + * @return Patent */ public function getModel() { @@ -157,12 +159,12 @@ public function getModel() } try { - $patent = new Opus_Patent($patentId); - } catch (Opus_Model_NotFoundException $omnfe) { + $patent = new Patent($patentId); + } catch (NotFoundException $omnfe) { // kann eigentlich nur bei manipuliertem POST passieren $this->getLogger()->err($omnfe); // bei ungültiger ID wird Patentwie neu hinzugefügt behandelt - $patent = new Opus_Patent(); + $patent = new Patent(); } $this->updateModel($patent); diff --git a/modules/admin/forms/Document/Person.php b/modules/admin/forms/Document/Person.php index 27c88ed675..25deafc39c 100644 --- a/modules/admin/forms/Document/Person.php +++ b/modules/admin/forms/Document/Person.php @@ -29,9 +29,12 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Person; +use Opus\Model\Dependent\Link\DocumentPerson; +use Opus\Model\NotFoundException; + /** * Unterformular fuer eine einem Dokument zugewiesene Person im Metadaten-Formular. */ @@ -89,11 +92,11 @@ public function processPost($post, $context) /** * Liefert angezeigtes Model. * - * Die ID für ein Opus_Model_Dependent_Link_DocumentPerson Objekt setzt sich aus Dokument-ID, Person-ID und Rolle + * Die ID für ein DocumentPerson Objekt setzt sich aus Dokument-ID, Person-ID und Rolle * zusammen. * * @param int $documentId Identifier für das Dokument - * @return \Opus_Model_Dependent_Link_DocumentPerson + * @return DocumentPerson * * TODO rename in getModel() !!!Konflikt mit getModel in PersonLink auflösen * TODO personId darf nicht null sein @@ -103,29 +106,29 @@ public function getLinkModel($documentId, $role) $personId = $this->getElementValue(Admin_Form_Person::ELEMENT_PERSON_ID); try { - $personLink = new Opus_Model_Dependent_Link_DocumentPerson([$personId, $documentId, $role]); - } catch (Opus_Model_NotFoundException $opnfe) { - $personLink = new Opus_Model_Dependent_Link_DocumentPerson(); - $person = new Opus_Person($personId); + $personLink = new DocumentPerson([$personId, $documentId, $role]); + } catch (NotFoundException $opnfe) { + $personLink = new DocumentPerson(); + $person = new Person($personId); $personLink->setModel($person); } $this->updateModel($personLink); $personLink->setRole($role); - if (Zend_Registry::get('LOG_LEVEL') >= Zend_Log::DEBUG) { + if (\Zend_Registry::get('LOG_LEVEL') >= \Zend_Log::DEBUG) { $log = $this->getLogger(); - $log->debug(Zend_Debug::dump($personLink->getId(), 'DocumentPerson-ID', false)); - $log->debug(Zend_Debug::dump($personLink->getRole(), 'DocumentPerson-Role', false)); - $log->debug(Zend_Debug::dump($personLink->getSortOrder(), 'DocumentPerson-SortOrder', false)); + $log->debug(\Zend_Debug::dump($personLink->getId(), 'DocumentPerson-ID', false)); + $log->debug(\Zend_Debug::dump($personLink->getRole(), 'DocumentPerson-Role', false)); + $log->debug(\Zend_Debug::dump($personLink->getSortOrder(), 'DocumentPerson-SortOrder', false)); $log->debug( - Zend_Debug::dump( + \Zend_Debug::dump( $personLink->getAllowEmailContact(), 'DocumentPerson->AllowEmailContact', false ) ); - $log->debug(Zend_Debug::dump($personLink->getModel()->getId(), 'DocumentPerson-Model-ID', false)); + $log->debug(\Zend_Debug::dump($personLink->getModel()->getId(), 'DocumentPerson-Model-ID', false)); } return $personLink; diff --git a/modules/admin/forms/Document/PersonMoves.php b/modules/admin/forms/Document/PersonMoves.php index 81c7b45530..9d6836cf9b 100644 --- a/modules/admin/forms/Document/PersonMoves.php +++ b/modules/admin/forms/Document/PersonMoves.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/admin/forms/Document/PersonRole.php b/modules/admin/forms/Document/PersonRole.php index 44aaa3f2c0..4e9d332e02 100644 --- a/modules/admin/forms/Document/PersonRole.php +++ b/modules/admin/forms/Document/PersonRole.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Unterformular für die Personen in einer bestimmten Role für ein Dokument. */ @@ -269,7 +271,7 @@ public function getSortKey($subform, $maxSortOrder, $digitsSortOrder = 2, $digit /** * Überschreibt updateModel damit vorher die SortOrder berücksichtigt werden kann. - * @param \Opus_Document $document + * @param Document $document */ public function updateModel($document) { diff --git a/modules/admin/forms/Document/PersonRoles.php b/modules/admin/forms/Document/PersonRoles.php index 8c6255f373..00050a6e78 100644 --- a/modules/admin/forms/Document/PersonRoles.php +++ b/modules/admin/forms/Document/PersonRoles.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/admin/forms/Document/Persons.php b/modules/admin/forms/Document/Persons.php index 85ec0fc57d..66d918e0b1 100644 --- a/modules/admin/forms/Document/Persons.php +++ b/modules/admin/forms/Document/Persons.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Unterformular fuer die mit einem Dokument verknuepften Personen. */ @@ -89,7 +91,7 @@ public function init() /** * - * @param Opus_Document $model + * @param Document $model */ public function populateFromModel($document) { diff --git a/modules/admin/forms/Document/Publisher.php b/modules/admin/forms/Document/Publisher.php index ad0eabb388..5c235a87cf 100644 --- a/modules/admin/forms/Document/Publisher.php +++ b/modules/admin/forms/Document/Publisher.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/admin/forms/Document/RegistrationNote.php b/modules/admin/forms/Document/RegistrationNote.php index e582e1682f..461c5a96a6 100644 --- a/modules/admin/forms/Document/RegistrationNote.php +++ b/modules/admin/forms/Document/RegistrationNote.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Identifier; +use Opus\Model\NotFoundException; + /** * Anzeigefeld für den Registrierungsstatus von lokalen DOIs */ @@ -53,7 +56,7 @@ public function init() { parent::init(); - $statusNote = new Zend_Form_Element_Note(self::ELEMENT_REGISTRATION_NOTE); + $statusNote = new \Zend_Form_Element_Note(self::ELEMENT_REGISTRATION_NOTE); $this->addElement($statusNote); } @@ -62,14 +65,14 @@ public function populateFromModel($model) if (is_string($model) && is_numeric($model)) { // Identifier-ID übergeben try { - $model = new Opus_Identifier($model); - } catch (Opus_Model_NotFoundException $e) { + $model = new Identifier($model); + } catch (NotFoundException $e) { // ignore silently return; } } - if (! ($model instanceof Opus_Identifier)) { + if (! ($model instanceof Identifier)) { return; } if (! $model->isLocalDoi()) { diff --git a/modules/admin/forms/Document/Section.php b/modules/admin/forms/Document/Section.php index 8405be0ec4..8968b702e5 100644 --- a/modules/admin/forms/Document/Section.php +++ b/modules/admin/forms/Document/Section.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -120,7 +119,7 @@ public function setOddEven($subForm) $multiWrapper = $subForm->getDecorator('multiWrapper'); - if (! is_null($multiWrapper) && $multiWrapper instanceof Zend_Form_Decorator_HtmlTag) { + if (! is_null($multiWrapper) && $multiWrapper instanceof \Zend_Form_Decorator_HtmlTag) { $multiClass = $multiWrapper->getOption('class'); $markerClass = ($position % 2 == 0) ? 'even' : 'odd'; diff --git a/modules/admin/forms/Document/Series.php b/modules/admin/forms/Document/Series.php index e8b7903a8c..693d1b971d 100644 --- a/modules/admin/forms/Document/Series.php +++ b/modules/admin/forms/Document/Series.php @@ -29,9 +29,12 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Series; +use Opus\Model\Dependent\Link\DocumentSeries; +use Opus\Model\NotFoundException; + /** * Unterformular fuer das Editieren eines Serieneintrags. * @@ -84,7 +87,7 @@ public function init() /** * Initialisiert das Formular mit den Werten im Modell. * - * @param Opus_Model_Dependent_Link_DocumentSeries $seriesLink + * @param DocumentSeries $seriesLink */ public function populateFromModel($seriesLink) { @@ -103,7 +106,7 @@ public function populateFromModel($seriesLink) public function updateModel($seriesLink) { $seriesId = $this->getElementValue(self::ELEMENT_SERIES_ID); - $series = new Opus_Series($seriesId); + $series = new Series($seriesId); $seriesLink->setModel($series); $seriesLink->setNumber($this->getElementValue(self::ELEMENT_NUMBER)); $seriesLink->setDocSortOrder($this->getElementValue(self::ELEMENT_SORT_ORDER)); @@ -111,7 +114,7 @@ public function updateModel($seriesLink) /** * Liefert das angezeigte Modell oder ein neues für hinzugefügte Verknüpfungen. - * @return \Opus_Model_Dependent_Link_DocumentSeries + * @return DocumentSeries */ public function getModel() { @@ -125,9 +128,9 @@ public function getModel() } try { - $seriesLink = new Opus_Model_Dependent_Link_DocumentSeries($linkId); - } catch (Opus_Model_NotFoundException $omnfe) { - $seriesLink = new Opus_Model_Dependent_Link_DocumentSeries(); + $seriesLink = new DocumentSeries($linkId); + } catch (NotFoundException $omnfe) { + $seriesLink = new DocumentSeries(); } $this->updateModel($seriesLink); diff --git a/modules/admin/forms/Document/Subject.php b/modules/admin/forms/Document/Subject.php index 045fd1c914..021b393505 100644 --- a/modules/admin/forms/Document/Subject.php +++ b/modules/admin/forms/Document/Subject.php @@ -29,9 +29,11 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Subject; +use Opus\Model\NotFoundException; + /** * Unterformular fuer das Editieren eines Stichwortes. * @@ -121,8 +123,8 @@ public function init() } /** - * Initialisiert das Formular mit den Werten in einem Opus_Subject Objekt. - * @param \Opus_Subject $subject + * Initialisiert das Formular mit den Werten in einem Subject Objekt. + * @param Subject $subject */ public function populateFromModel($subject) { @@ -133,8 +135,8 @@ public function populateFromModel($subject) } /** - * Überträgt die Werte im Formular in ein Opus_Subject Objekt. - * @param \Opus_Subject $subject + * Überträgt die Werte im Formular in ein Subject Objekt. + * @param Subject $subject */ public function updateModel($subject) { @@ -147,9 +149,9 @@ public function updateModel($subject) /** * Liefert das angezeigt Model zurück. * - * Wenn ein neues Subject zum Formular hinzugefügt wurde wird ein new Opus_Subject Objekt ohne ID zurückgeliefert. + * Wenn ein neues Subject zum Formular hinzugefügt wurde wird ein new Subject Objekt ohne ID zurückgeliefert. * - * @return \Opus_Subject + * @return Subject */ public function getModel() { @@ -160,10 +162,10 @@ public function getModel() } try { - $subject = new Opus_Subject($subjectId); - } catch (Opus_Model_NotFoundException $omnfe) { + $subject = new Subject($subjectId); + } catch (NotFoundException $omnfe) { $this->getLogger()->err(__METHOD__ . " Unknown subject ID = '$subjectId'."); - $subject = new Opus_Subject(); + $subject = new Subject(); } $this->updateModel($subject); diff --git a/modules/admin/forms/Document/SubjectType.php b/modules/admin/forms/Document/SubjectType.php index d95126aeb8..7d4cef8a32 100644 --- a/modules/admin/forms/Document/SubjectType.php +++ b/modules/admin/forms/Document/SubjectType.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; + /** * Unterformular fuer Subjects eines bestimmten Typs im Metadaten-Formular. * @@ -108,7 +109,7 @@ public function getSubjectType() * Schlagwoertern nicht passieren soll, da die Werte aus mehreren MultiSubForm-Formularen zusammengesammelt werden * muessen. * - * @param Opus_Document $document + * @param Document $document */ public function updateModel($document) { @@ -131,7 +132,7 @@ public function createNewSubFormInstance() /** * Liefert die Schlagwoerter mit dem richtigen Typ. * - * @param Opus_Document $document + * @param Document $document * @return array */ public function getFieldValues($document) diff --git a/modules/admin/forms/Document/Subjects.php b/modules/admin/forms/Document/Subjects.php index ea20848231..4f3c8790b9 100644 --- a/modules/admin/forms/Document/Subjects.php +++ b/modules/admin/forms/Document/Subjects.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; + /** * Unterformular fuer Subjects im Metadaten-Formular. * @@ -87,7 +88,7 @@ public function init() /** * Sammelt Schlagwoerter von Unterformularen ein und aktualisiert Dokument. - * @param Opus_Document $document + * @param Document $document */ public function updateModel($document) { diff --git a/modules/admin/forms/Document/Title.php b/modules/admin/forms/Document/Title.php index 4e7ef4aa04..85da56a18a 100644 --- a/modules/admin/forms/Document/Title.php +++ b/modules/admin/forms/Document/Title.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Title; + /** * Unterformular fuer das Editieren von Titeln. * @@ -45,7 +46,7 @@ class Admin_Form_Document_Title extends Admin_Form_AbstractModelSubForm { /** - * Name von Formularelement fuer ID von Opus_Title Objekt. + * Name von Formularelement fuer ID von Title Objekt. */ const ELEMENT_ID = 'Id'; @@ -103,7 +104,7 @@ public function loadDefaultDecorators() /** * Initialisiert das Formular mit den Werten im Modell. * - * @param \Opus_Title $title + * @param Title $title */ public function populateFromModel($title) { @@ -116,7 +117,7 @@ public function populateFromModel($title) /** * Aktualisiert Modell mit den Werten im Formular. * - * @param \Opus_Title $title + * @param Title $title */ public function updateModel($title) { @@ -127,13 +128,13 @@ public function updateModel($title) /** * Liefert das angezeigte Objekt bzw. eine neue Instanz für Titel die im Formular hinzugefügt wurden. - * @return \Opus_Title + * @return Title */ public function getModel() { $titleId = $this->getElementValue(self::ELEMENT_ID); - $title = new Opus_Title($titleId); + $title = new Title($titleId); $this->updateModel($title); diff --git a/modules/admin/forms/Document/Titles.php b/modules/admin/forms/Document/Titles.php index 1bd3183a86..979be9fe5b 100644 --- a/modules/admin/forms/Document/Titles.php +++ b/modules/admin/forms/Document/Titles.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/admin/forms/Document/TitlesMain.php b/modules/admin/forms/Document/TitlesMain.php index d8bb2ada8d..cac71332e4 100644 --- a/modules/admin/forms/Document/TitlesMain.php +++ b/modules/admin/forms/Document/TitlesMain.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; + /** * Unterformular fuer Haupttitel eines Dokuments. * @@ -115,7 +116,7 @@ public function isDependenciesValid($data, $globalContext) * * Sorgt dafuer, dass der Titel in der Dokumentensprache zuerst im Array steht. * - * @param Opus_Document $document + * @param Document $document * @return array */ public function getFieldValues($document) diff --git a/modules/admin/forms/EnrichmentKey.php b/modules/admin/forms/EnrichmentKey.php index 6c62b72753..e4e0454f80 100644 --- a/modules/admin/forms/EnrichmentKey.php +++ b/modules/admin/forms/EnrichmentKey.php @@ -33,6 +33,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\EnrichmentKey; +use Opus\Enrichment\AbstractType; + /** * Form for creating and editing an enrichment key. * @@ -84,10 +87,10 @@ public function init() $this->setLabelPrefix('Opus_EnrichmentKey'); $this->setUseNameAsLabel(true); - $this->setModelClass('Opus_EnrichmentKey'); + $this->setModelClass('Opus\EnrichmentKey'); $this->setVerifyModelIdIsNumeric(false); - $nameMaxLength = Opus_EnrichmentKey::getFieldMaxLength('Name'); + $nameMaxLength = EnrichmentKey::getFieldMaxLength('Name'); $name = $this->createElement('text', self::ELEMENT_NAME, [ 'required' => true, @@ -117,7 +120,7 @@ public function init() // alle verfügbaren EnrichmentTypes ermitteln und als Auswahlfeld anzeigen $availableTypes[''] = ''; // Standardauswahl des Select-Felds soll leer sein - $availableTypes = array_merge($availableTypes, Opus_Enrichment_AbstractType::getAllEnrichmentTypes()); + $availableTypes = array_merge($availableTypes, AbstractType::getAllEnrichmentTypes()); $element->setMultiOptions($availableTypes); $this->addElement($element); @@ -155,7 +158,7 @@ public function init() /** * Initialisiert das Formular mit Werten einer Model-Instanz. - * @param $model Opus_Enrichmentkey + * @param $model Enrichmentkey */ public function populateFromModel($enrichmentKey) { @@ -201,7 +204,7 @@ public function setNameElementValue($value) /** * Aktualisiert Model-Instanz mit Werten im Formular. - * @param $enrichmentKey Opus_Enrichmentkey + * @param $enrichmentKey Enrichmentkey */ public function updateModel($enrichmentKey) { @@ -237,7 +240,7 @@ public function updateModel($enrichmentKey) * Erzeugt ein Enrichment-Type Objekt für den übergebenen Typ-Namen bzw. liefert * null, wenn der Typ-Name nicht aufgelöst werden kann. * - * @param $enrichmentTypeName Name des Enrichment-Typs + * @param $enrichmentTypeName string Name des Enrichment-Typs * * @return mixed */ @@ -248,7 +251,7 @@ private function initEnrichmentType($enrichmentTypeName) } // TODO better way? - allow registering namespaces/types like in Zend for form elements? - $enrichmentTypeName = 'Opus_Enrichment_' . $enrichmentTypeName; + $enrichmentTypeName = 'Opus\\Enrichment\\' . $enrichmentTypeName; try { if (class_exists($enrichmentTypeName, false)) { $enrichmentType = new $enrichmentTypeName(); @@ -265,7 +268,7 @@ private function initEnrichmentType($enrichmentTypeName) public function populate(array $values) { if (array_key_exists(parent::ELEMENT_MODEL_ID, $values)) { - $enrichmentKey = Opus_EnrichmentKey::fetchByName($values[parent::ELEMENT_MODEL_ID]); + $enrichmentKey = EnrichmentKey::fetchByName($values[parent::ELEMENT_MODEL_ID]); if (! is_null($enrichmentKey)) { $enrichmentType = $enrichmentKey->getEnrichmentType(); if (! is_null($enrichmentType)) { diff --git a/modules/admin/forms/EnrichmentTable.php b/modules/admin/forms/EnrichmentTable.php index 2d58c37802..4bb8a81221 100644 --- a/modules/admin/forms/EnrichmentTable.php +++ b/modules/admin/forms/EnrichmentTable.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\EnrichmentKey; + /** * Formular für die Anzeige der Enrichment-Tabelle. * @@ -48,7 +50,7 @@ public function init() /** * Liefert true, wenn es sich um einen geschützten EnrichmentKey handelt; andernfalls false. * - * @param Opus_EnrichmentKey $model + * @param EnrichmentKey $model * @return bool */ public function isProtected($model) @@ -60,18 +62,18 @@ public function isProtected($model) * Liefert true, wenn der EnrichmentKey in mindestens einem Enrichment eines Dokuments * verwendet wird; andernfalls false. * - * @param Opus_EnrichmentKey $model + * @param EnrichmentKey $model * @return bool */ public function isUsed($model) { - return in_array($model->getId(), Opus_EnrichmentKey::getAllReferenced()); + return in_array($model->getId(), EnrichmentKey::getAllReferenced()); } /** * Bestimmt die zu verwendene CSS-Klasse für den übergebenen EnrichmentKey in der Listenansicht. * - * @param Opus_EnrichmentKey $model + * @param EnrichmentKey $model * @return string Name der zu nutzenden CSS-Klasse */ public function getRowCssClass($model) @@ -98,7 +100,7 @@ public function getRowCssClass($model) * Bestimmt den Übersetzungsschlüssel des anzuzeigenden Tooltips für den übergebenen EnrichmentKey in * der Listenansicht. * - * @param Opus_EnrichmentKey $model + * @param EnrichmentKey $model * @return string Übersetzungsschlüssel für den Tooltip */ public function getRowTooltip($model) diff --git a/modules/admin/forms/File.php b/modules/admin/forms/File.php index 5fc74d1a32..7ab63b8696 100644 --- a/modules/admin/forms/File.php +++ b/modules/admin/forms/File.php @@ -25,6 +25,12 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\File; +use Opus\UserRole; +use Opus\Model\AbstractDb; +use Opus\Model\NotFoundException; + + /** * Formular fuer Anzeige/Editieren einer Datei. * @@ -118,7 +124,7 @@ public function init() /** * Initialisierung des Formulars mit den Werten in einer Model-Instanz. - * @param Opus_File $file + * @param File $file */ public function populateFromModel($file) { @@ -152,7 +158,7 @@ public function populateFromModel($file) * Sets default values for form. * * @param array $post - * @return Zend_Form + * @return \Zend_Form */ public function setDefaults(array $defaults) { @@ -160,7 +166,7 @@ public function setDefaults(array $defaults) if (isset($defaults[$this->getName()])) { $fileId = $defaults[$this->getName()][self::ELEMENT_ID]; - $file = new Opus_File($fileId); + $file = new File($fileId); $this->getSubForm(self::SUBFORM_HASHES)->populateFromModel($file); $this->getElement(self::ELEMENT_FILE_SIZE)->setValue($file->getFileSize()); } else { @@ -171,7 +177,7 @@ public function setDefaults(array $defaults) /** * Update einer Model-Instanz mit den Werten im Formular. - * @param Opus_Model_AbstractDb $model + * @param AbstractDb $model */ public function updateModel($file) { @@ -202,8 +208,8 @@ public function getModel() if (strlen(trim($fileId)) > 0 && is_numeric($fileId)) { try { - $file = new Opus_File($fileId); - } catch (Opus_Model_NotFoundException $omnfe) { + $file = new File($fileId); + } catch (NotFoundException $omnfe) { $this->getLogger()->err(__METHOD__ . " Unknown file ID = '$fileId'."); throw new Application_Exception("Unknown file ID = '$fileId'."); } @@ -223,7 +229,7 @@ public function getRolesForFile($fileId) { $checkedRoles = []; - $roles = Opus_UserRole::getAll(); + $roles = UserRole::getAll(); foreach ($roles as $role) { $files = $role->listAccessFiles(); @@ -246,7 +252,7 @@ public function updateFileRoles($file, $selectedRoles) // remove roles that are not selected foreach ($currentRoleNames as $index => $roleName) { if (! in_array($roleName, $selectedRoles)) { - $role = Opus_UserRole::fetchByName($roleName); + $role = UserRole::fetchByName($roleName); $role->removeAccessFile($fileId); $role->store(); $this->getLogger()->debug("File ID = $fileId access for role '$roleName' removed."); @@ -259,7 +265,7 @@ public function updateFileRoles($file, $selectedRoles) // add selected roles foreach ($selectedRoles as $roleName) { - $role = Opus_UserRole::fetchByName($roleName); + $role = UserRole::fetchByName($roleName); if (! is_null($role)) { if (! in_array($roleName, $currentRoleNames)) { $role->appendAccessFile($fileId); diff --git a/modules/admin/forms/File/Hashes.php b/modules/admin/forms/File/Hashes.php index be0f6d3239..b07bb80e3c 100644 --- a/modules/admin/forms/File/Hashes.php +++ b/modules/admin/forms/File/Hashes.php @@ -39,7 +39,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_Form_File_Hashes extends Admin_Form_AbstractDocumentSubForm { diff --git a/modules/admin/forms/File/Upload.php b/modules/admin/forms/File/Upload.php index 7ec1837422..00c98ec6da 100644 --- a/modules/admin/forms/File/Upload.php +++ b/modules/admin/forms/File/Upload.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Model\AbstractDb; + /** * Formular fuer den Upload von Dateien in der Administration. * @@ -64,7 +66,7 @@ public function init() $this->addSubForm(new Admin_Form_InfoBox(), self::SUBFORM_DOCINFO); - $this->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART); + $this->setAttrib('enctype', \Zend_Form::ENCTYPE_MULTIPART); $this->setLegend('admin_filemanager_upload'); $this->setLabelPrefix('Opus_File_'); $this->setUseNameAsLabel(true); @@ -112,7 +114,7 @@ public function populateFromModel($document) /** * Speichert Datei und verknüpft sie mit dem Dokument. * - * @param Opus_Model_AbstractDb $document + * @param AbstractDb $document */ public function updateModel($document) { @@ -142,7 +144,7 @@ public function updateModel($document) public function getFileInfo() { if (is_null($this->_fileInfo)) { - $upload = new Zend_File_Transfer_Adapter_Http(); + $upload = new \Zend_File_Transfer_Adapter_Http(); return $upload->getFileInfo(); } else { return $this->_fileInfo; diff --git a/modules/admin/forms/FileManager.php b/modules/admin/forms/FileManager.php index 3aecd1379f..c4a11ce7af 100644 --- a/modules/admin/forms/FileManager.php +++ b/modules/admin/forms/FileManager.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_Form_FileManager extends Application_Form_Model_Abstract { diff --git a/modules/admin/forms/Files.php b/modules/admin/forms/Files.php index 1b8795e509..3373e3b70f 100644 --- a/modules/admin/forms/Files.php +++ b/modules/admin/forms/Files.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Document; + /** * Formular fuer alle Dateien eines Dokuments. * @@ -158,9 +160,9 @@ public function getSubFormForId($fileId) } /** - * Liefert Opus_File objects for document through getFile function to get proper order of files. - * @param Opus_Document $document - * @return array Array of Opus_File objects + * Liefert File objects for document through getFile function to get proper order of files. + * @param Document $document + * @return array Array of File objects */ public function getFieldValues($document) { diff --git a/modules/admin/forms/InfoBox.php b/modules/admin/forms/InfoBox.php index ed9071c450..95f7fff158 100644 --- a/modules/admin/forms/InfoBox.php +++ b/modules/admin/forms/InfoBox.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Unterformular mit Haupttitel, ID, und Authoren eines Dokuments. * @@ -42,7 +44,7 @@ class Admin_Form_InfoBox extends Admin_Form_AbstractDocumentSubForm /** * Dokument das angezeigt wird. - * @var Opus_Document + * @var Document */ private $_document; @@ -66,11 +68,11 @@ public function init() /** * Initialisiert Formular mit Dokument. - * @param Opus_Document $document + * @param Document $document */ public function populateFromModel($document) { - if ($document instanceof Opus_Document) { + if ($document instanceof Document) { $this->_document = $document; } else { $objclass = ($document !== null) ? get_class($document) : 'null'; @@ -81,11 +83,11 @@ public function populateFromModel($document) /** * Initialisiert Formular nach POST. * @param array $post - * @param Opus_Document $document + * @param Document $document */ public function constructFromPost($post, $document = null) { - if ($document instanceof Opus_Document) { + if ($document instanceof Document) { $this->_document = $document; } else { $objclass = ($document !== null) ? get_class($document) : 'null'; @@ -97,7 +99,7 @@ public function constructFromPost($post, $document = null) * Liefert Dokument zurück. * * Wird vom ViewScript verwendet, um das Dokument zu holen. - * @return Opus_Document + * @return Document */ public function getDocument() { diff --git a/modules/admin/forms/IpRange.php b/modules/admin/forms/IpRange.php index 17103bb6d8..5ec94b8166 100644 --- a/modules/admin/forms/IpRange.php +++ b/modules/admin/forms/IpRange.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Iprange; + /** * Form for creating or editing IP ranges. */ @@ -59,7 +61,7 @@ public function init() $this->setUseNameAsLabel(true); $this->setLabelPrefix('admin_iprange_label_'); - $this->setModelClass('Opus_Iprange'); + $this->setModelClass('Opus\Iprange'); $name = $this->createElement('text', self::ELEMENT_NAME, ['required' => true]); $name->addValidator('regex', false, ['pattern' => self::NAME_PATTERN, 'messages' => [ @@ -80,8 +82,8 @@ public function init() } /** - * Populates form with values from Opus_Iprange instance. - * @param Opus_Iprange $ipRange + * Populates form with values from Iprange instance. + * @param $ipRange Iprange */ public function populateFromModel($ipRange) { @@ -94,7 +96,7 @@ public function populateFromModel($ipRange) /** * Updates object with values from form elements. - * @param $ipRange Opus_IpRange + * @param $ipRange Iprange */ public function updateModel($ipRange) { diff --git a/modules/admin/forms/Language.php b/modules/admin/forms/Language.php index c2360401ed..e79c14994f 100644 --- a/modules/admin/forms/Language.php +++ b/modules/admin/forms/Language.php @@ -46,7 +46,7 @@ public function init() $this->setRemoveEmptyCheckbox(false); $this->setLabelPrefix('Opus_Language_'); $this->setUseNameAsLabel(true); - $this->setModelClass('Opus_Language'); + $this->setModelClass('Opus\Language'); $this->addElement('checkbox', self::ELEMENT_ACTIVE); $this->addElement('text', self::ELEMENT_REFNAME, ['required' => true]); diff --git a/modules/admin/forms/Licence.php b/modules/admin/forms/Licence.php index 5bdfe769ee..317233d926 100644 --- a/modules/admin/forms/Licence.php +++ b/modules/admin/forms/Licence.php @@ -25,10 +25,13 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Licence; +use Opus\Model\AbstractDb; + /** * Formular fuer das Editieren und Anzeigen einer Lizenz. * - * Die Klasse Opus_Licence enthaelt auch noch das Feld 'LinkSign'. Es gibt Ticket OPUSVIER-1492 fuer das Entfernen + * Die Klasse Licence enthaelt auch noch das Feld 'LinkSign'. Es gibt Ticket OPUSVIER-1492 fuer das Entfernen * dieses Feldes, daher wurde es in diesem Formular nicht mehr verwendet. TODO Kommentar entfernen * * @category Application @@ -51,27 +54,27 @@ class Admin_Form_Licence extends Application_Form_Model_Abstract const ELEMENT_COMMENT_INTERNAL = 'CommentInternal'; /** - * Name von Formularelement fuer Feld 'DescMarkup' von Opus_Licence. + * Name von Formularelement fuer Feld 'DescMarkup' von Licence. */ const ELEMENT_DESC_MARKUP = 'DescMarkup'; /** - * Name von Formularelement fuer Feld 'DescText' von Opus_Licence. + * Name von Formularelement fuer Feld 'DescText' von Licence. */ const ELEMENT_DESC_TEXT = 'DescText'; /** - * Name von Formularelement fuer Feld 'Language' von Opus_Licence. + * Name von Formularelement fuer Feld 'Language' von Licence. */ const ELEMENT_LANGUAGE = 'Language'; /** - * Name von Formularelement fuer Feld 'LinkLicence' von Opus_Licence. + * Name von Formularelement fuer Feld 'LinkLicence' von Licence. */ const ELEMENT_LINK_LICENCE = 'LinkLicence'; /** - * Name von Formularelement fuer Feld 'LinkLogo' von Opus_Licence. + * Name von Formularelement fuer Feld 'LinkLogo' von Licence. */ const ELEMENT_LINK_LOGO = 'LinkLogo'; @@ -81,27 +84,27 @@ class Admin_Form_Licence extends Application_Form_Model_Abstract const ELEMENT_LINK_SIGN = 'LinkSign'; /** - * Name von Formularelement fuer Feld 'MimeType' von Opus_Licence. + * Name von Formularelement fuer Feld 'MimeType' von Licence. */ const ELEMENT_MIME_TYPE = 'MimeType'; /** - * Name von Formularelement fuer Feld 'Name' von Opus_Licence. + * Name von Formularelement fuer Feld 'Name' von Licence. */ const ELEMENT_NAME = 'Name'; /** - * Name von Formularelement fuer Feld 'NameLong' von Opus_Licence. + * Name von Formularelement fuer Feld 'NameLong' von Licence. */ const ELEMENT_NAME_LONG = 'NameLong'; /** - * Name von Formularelement fuer Feld 'SortOrder' von Opus_Licence. + * Name von Formularelement fuer Feld 'SortOrder' von Licence. */ const ELEMENT_SORT_ORDER = 'SortOrder'; /** - * Name von Formularelement fuer Feld 'PodAllowed' von Opus_Licence. + * Name von Formularelement fuer Feld 'PodAllowed' von Licence. */ const ELEMENT_POD_ALLOWED = 'PodAllowed'; @@ -114,11 +117,11 @@ public function init() $this->setRemoveEmptyCheckbox(false); $this->setUseNameAsLabel(true); - $this->setModelClass('Opus_Licence'); + $this->setModelClass('Opus\Licence'); $this->addElement('checkbox', self::ELEMENT_ACTIVE); $this->addElement('text', self::ELEMENT_NAME, [ - 'maxlength' => Opus_Licence::getFieldMaxLength('Name') + 'maxlength' => Licence::getFieldMaxLength('Name') ]); $this->addElement('text', self::ELEMENT_NAME_LONG, ['required' => true, 'size' => 70]); $this->addElement('Language', self::ELEMENT_LANGUAGE, ['required' => true]); @@ -133,8 +136,8 @@ public function init() } /** - * Initialisiert Formular von Opus_Licence Instanz. - * @param Opus_Model_Licence $licence + * Initialisiert Formular von Licence Instanz. + * @param Licence $licence */ public function populateFromModel($licence) { @@ -154,8 +157,8 @@ public function populateFromModel($licence) } /** - * Aktualisiert Instanz von Opus_Licence mit Werte aus Formular. - * @param Opus_Model_AbstractDb $licence + * Aktualisiert Instanz von Licence mit Werte aus Formular. + * @param AbstractDb $licence */ public function updateModel($licence) { diff --git a/modules/admin/forms/Notification.php b/modules/admin/forms/Notification.php index 521237b127..c850aef9f2 100644 --- a/modules/admin/forms/Notification.php +++ b/modules/admin/forms/Notification.php @@ -34,6 +34,9 @@ * TODO adjust styling of sub form * TODO unit testing */ + +use Opus\Document; + class Admin_Form_Notification extends Admin_Form_AbstractDocumentSubForm { @@ -62,8 +65,8 @@ public function init() * add a checkbox for each PersonSubmitter and PersonAuthor (used to select * recipients for publish notification email) * - * @param Opus_Document $document - * @param Zend_Form $form + * @param Document $document + * @param \Zend_Form $form * * * TODO css notification-option, option-not-available diff --git a/modules/admin/forms/Person.php b/modules/admin/forms/Person.php index 4991f9837e..65cc3b45be 100644 --- a/modules/admin/forms/Person.php +++ b/modules/admin/forms/Person.php @@ -32,8 +32,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Person; + /** - * Formular zum Editieren einer Person (Opus_Person). + * Formular zum Editieren einer Person (Person). * * Dieses Formular beruecksichtigt nicht die Felder, die bei der Verknuepfung einer Person mit einem Dokument in dem * Link Objekt hinzukommen. @@ -42,7 +44,7 @@ class Admin_Form_Person extends Admin_Form_AbstractDocumentSubForm { /** - * Name fuer Formularelement fuer Feld ID von Opus_Person. + * Name fuer Formularelement fuer Feld ID von Person. */ const ELEMENT_PERSON_ID = 'PersonId'; @@ -133,7 +135,7 @@ public function init() 'text', self::ELEMENT_LAST_NAME, ['label' => 'LastName', 'required' => true, - 'size' => 50, 'maxlength' => Opus_Person::getFieldMaxLength('LastName')] + 'size' => 50, 'maxlength' => Person::getFieldMaxLength('LastName')] ); $this->addElement('text', self::ELEMENT_FIRST_NAME, ['label' => 'FirstName', 'size' => 50]); $this->addElement('Email', self::ELEMENT_EMAIL, ['label' => 'Email']); @@ -188,8 +190,8 @@ public function init() } /** - * Setzt die Werte der Formularelmente entsprechend der uebergebenen Opus_Person Instanz. - * @param Opus_Person $model + * Setzt die Werte der Formularelmente entsprechend der uebergebenen Person Instanz. + * @param Person $model */ public function populateFromModel($person) { @@ -226,12 +228,12 @@ public function processPost($post, $context) } /** - * Setzt die Felder einer Opus_Person Instanz entsprechend dem Formularinhalt. - * @param Opus_Person $model + * Setzt die Felder einer Person Instanz entsprechend dem Formularinhalt. + * @param Person $model */ public function updateModel($model) { - if ($model instanceof Opus_Person) { + if ($model instanceof Person) { $model->setAcademicTitle($this->getElementValue(self::ELEMENT_ACADEMIC_TITLE)); $model->setLastName($this->getElementValue(self::ELEMENT_LAST_NAME)); $model->setFirstName($this->getElementValue(self::ELEMENT_FIRST_NAME)); @@ -243,22 +245,22 @@ public function updateModel($model) $datesHelper = $this->getDatesHelper(); $model->setDateOfBirth($datesHelper->getOpusDate($this->getElementValue(self::ELEMENT_DATE_OF_BIRTH))); } else { - $this->getLogger()->err(__METHOD__ . ' called with object that is not instance of Opus_Person'); + $this->getLogger()->err(__METHOD__ . ' called with object that is not instance of Opus\Person'); } } /** - * Liefert Instanz von Opus_Person zurueck. - * @return \Opus_Person + * Liefert Instanz von Person zurueck. + * @return Person */ public function getModel() { $personId = $this->getElementValue(self::ELEMENT_PERSON_ID); if (is_numeric($personId)) { - $person = new Opus_Person($personId); + $person = new Person($personId); } else { - $person = new Opus_Person(); + $person = new Person(); } $this->updateModel($person); diff --git a/modules/admin/forms/Person/Changes.php b/modules/admin/forms/Person/Changes.php index 868d0151a6..40e493d709 100644 --- a/modules/admin/forms/Person/Changes.php +++ b/modules/admin/forms/Person/Changes.php @@ -31,12 +31,14 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Date; + /** * Class Admin_Form_Person_Changes * * TODO merge old values and changes array (only set/getChanges with all values)? * TODO make generic to be usable with any model (incl. excluded fields) - * TODO work with model objects like Opus_Date for fields that use them + * TODO work with model objects like Opus\Date for fields that use them */ class Admin_Form_Person_Changes extends Application_Form_Abstract { @@ -90,13 +92,13 @@ public function getPreparedChanges() $helper = new Application_Controller_Action_Helper_Dates(); foreach ($oldValues as $field => $values) { - // TODO Opus_Person specific code that needs to be removed later + // TODO Person specific code that needs to be removed later if (in_array($field, ['Id', 'OpusId'])) { continue; } if (stripos($field, 'date') !== false) { - $preparedChanges[$field]['old'] = $this->forceArray($helper->getDateString(new Opus_Date($values))); + $preparedChanges[$field]['old'] = $this->forceArray($helper->getDateString(new Date($values))); } else { $preparedChanges[$field]['old'] = $this->forceArray($values); } @@ -106,7 +108,7 @@ public function getPreparedChanges() if (array_key_exists($field, $changes)) { if (stripos($field, 'date') !== false) { $preparedChanges[$field]['new'] = $this->forceArray($helper->getDateString( - new Opus_Date($changes[$field]) + new Date($changes[$field]) )); } else { $preparedChanges[$field]['new'] = $this->forceArray($changes[$field]); diff --git a/modules/admin/forms/Person/Documents.php b/modules/admin/forms/Person/Documents.php index dec8d359f6..ebdaacca4c 100644 --- a/modules/admin/forms/Person/Documents.php +++ b/modules/admin/forms/Person/Documents.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Person; + /** * TODO Move documents element code into this subform? (use smaller single document element) */ @@ -61,7 +64,7 @@ public function setDocuments($documentIds, $person = null) $options = []; foreach ($documentIds as $docId) { - $options[$docId] = new Opus_Document($docId); + $options[$docId] = Document::get($docId); } $documents = $this->getElement(self::ELEMENT_DOCUMENTS); @@ -69,7 +72,7 @@ public function setDocuments($documentIds, $person = null) $documents->setValue($documentIds); if (! is_null($person)) { - $documents->setAttrib('person', Opus_Person::convertToFieldNames($person)); + $documents->setAttrib('person', Person::convertToFieldNames($person)); } } diff --git a/modules/admin/forms/PersonLink.php b/modules/admin/forms/PersonLink.php index 1a29d9c2d0..a2cec11315 100644 --- a/modules/admin/forms/PersonLink.php +++ b/modules/admin/forms/PersonLink.php @@ -31,8 +31,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Model\Dependent\Link\DocumentPerson; + /** - * Formular für die Felder von Opus_Model_Dependent_Link_DocumentPerson. + * Formular für die Felder von DocumentPerson. * * Das sind folgende Felder. * @@ -47,7 +49,7 @@ class Admin_Form_PersonLink extends Admin_Form_AbstractDocumentSubForm /** * Nachricht für Funktionsaufruf mit falschem Model Parameter. */ - const BAD_MODEL_MESSAGE = ' Called with object that is not instance of Opus_Model_Dependent_Link_DocumentPerson'; + const BAD_MODEL_MESSAGE = ' Called with object that is not instance of Opus\Model\Dependent\Link\DocumentPerson'; /** * Name fuer Formularelement fuer Feld AllowEmailContact. @@ -66,7 +68,7 @@ class Admin_Form_PersonLink extends Admin_Form_AbstractDocumentSubForm /** * Link-Model das angezeigt wird. - * @var \Opus_Model_Dependent_Link_DocumentPerson + * @var DocumentPerson */ private $_model = null; @@ -90,11 +92,11 @@ public function init() /** * Initialisiert Formular mit Werten aus Model. - * @param Opus_Model_Dependent_Link_DocumentPerson $personLink + * @param DocumentPerson $personLink */ public function populateFromModel($personLink) { - if ($personLink instanceof Opus_Model_Dependent_Link_DocumentPerson) { + if ($personLink instanceof DocumentPerson) { $this->getElement(self::ELEMENT_ALLOW_CONTACT)->setValue($personLink->getAllowEmailContact()); $this->getElement(self::ELEMENT_SORT_ORDER)->setValue($personLink->getSortOrder()); $this->getElement(Admin_Form_Person::ELEMENT_PERSON_ID)->setValue($personLink->getModel()->getId()); @@ -107,11 +109,11 @@ public function populateFromModel($personLink) /** * Setzt Werte im Model mit dem Inhalt der Formularelemente. - * @param Opus_Model_Dependent_Link_DocumentPerson $personLink + * @param DocumentPerson $personLink */ public function updateModel($personLink) { - if ($personLink instanceof Opus_Model_Dependent_Link_DocumentPerson) { + if ($personLink instanceof DocumentPerson) { $personLink->setAllowEmailContact($this->getElementValue(self::ELEMENT_ALLOW_CONTACT)); $personLink->setSortOrder($this->getElementValue(self::ELEMENT_SORT_ORDER)); $personLink->setRole($this->getElementValue(self::ELEMENT_ROLE)); @@ -122,7 +124,7 @@ public function updateModel($personLink) /** * Liefert angezeigtes Model. - * @return \Opus_Model_Dependent_Link_DocumentPerson + * @return DocumentPerson */ public function getModel() { diff --git a/modules/admin/forms/Persons.php b/modules/admin/forms/Persons.php index 3d84aa0991..a2c31bc3c2 100644 --- a/modules/admin/forms/Persons.php +++ b/modules/admin/forms/Persons.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Date; +use Opus\Person; + /** * Form for editing a person across multiple objects. * @@ -46,7 +49,7 @@ class Admin_Form_Persons extends Application_Form_Model_Abstract { /** - * Name fuer Formularelement fuer Feld ID von Opus_Person. + * Name fuer Formularelement fuer Feld ID von Person. */ const ELEMENT_PERSON_ID = 'PersonId'; @@ -129,7 +132,7 @@ public function init() self::ELEMENT_LAST_NAME, [ 'label' => 'LastName', 'required' => true, 'size' => 50, - 'maxlength' => Opus_Person::getFieldMaxLength('LastName') + 'maxlength' => Person::getFieldMaxLength('LastName') ] ); $this->addElement('text', self::ELEMENT_FIRST_NAME, ['label' => 'FirstName', 'size' => 50]); @@ -229,8 +232,8 @@ public function getPerson() } /** - * Setzt die Werte der Formularelmente entsprechend der uebergebenen Opus_Person Instanz. - * @param Opus_Person $model + * Setzt die Werte der Formularelmente entsprechend der uebergebenen Person Instanz. + * @param Person $model */ public function populateFromModel($values) { @@ -265,10 +268,10 @@ public function populateFromModel($values) $formattedDates = []; - $datesHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('dates'); + $datesHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('dates'); foreach ($dates as $date) { - $opusDate = new Opus_Date($date); + $opusDate = new Date($date); array_push($formattedDates, $datesHelper->getDateString($opusDate)); } @@ -295,7 +298,7 @@ public function setIdentityValue($element, $value) $person = $this->getPerson(); if (! is_null($person)) { - $columnName = Opus_Person::convertFieldnameToColumn($element->getName()); + $columnName = Person::convertFieldnameToColumn($element->getName()); if (array_key_exists($columnName, $person)) { $displayValue = $person[$columnName]; } @@ -322,8 +325,8 @@ public function processPost($post, $context) } /** - * Setzt die Felder einer Opus_Person Instanz entsprechend dem Formularinhalt. - * @param Opus_Person $model + * Setzt die Felder einer Person Instanz entsprechend dem Formularinhalt. + * @param Person $model */ public function updateModel($model) { @@ -366,8 +369,8 @@ public function getChanges() } /** - * Liefert Instanz von Opus_Person zurueck. - * @return \Opus_Person + * Liefert Instanz von Person zurueck. + * @return Person */ public function getModel() { diff --git a/modules/admin/forms/PersonsConfirm.php b/modules/admin/forms/PersonsConfirm.php index 8d85bbcb9c..89886179fa 100644 --- a/modules/admin/forms/PersonsConfirm.php +++ b/modules/admin/forms/PersonsConfirm.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Person; + /** * Class Admin_Form_PersonsConfirm * @@ -99,7 +101,7 @@ public function setOldValues($oldValues) public function populateFromModel($person) { - $documentIds = Opus_Person::getPersonDocuments($person); + $documentIds = Person::getPersonDocuments($person); $docCount = count($documentIds); diff --git a/modules/admin/forms/Role.php b/modules/admin/forms/Role.php index d76199674d..4e4e14cf66 100644 --- a/modules/admin/forms/Role.php +++ b/modules/admin/forms/Role.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\UserRole; + /** * Form for creating and editing a role. */ @@ -52,7 +54,7 @@ public function __construct($id = null) $section = empty($id) ? 'new' : 'edit'; if (! empty($id)) { - $role = new Opus_UserRole($id); + $role = new UserRole($id); $this->populateFromModel($role); } } @@ -62,13 +64,13 @@ public function init() parent::init(); $this->setUseNameAsLabel(true); - $this->setModelClass('Opus_UserRole'); + $this->setModelClass('Opus\UserRole'); $name = $this->createElement('text', self::ELEMENT_NAME, [ 'required' => true ]); - $maxLength = Opus_UserRole::getFieldMaxLength('Name'); + $maxLength = UserRole::getFieldMaxLength('Name'); $name->addValidator('regex', false, ['pattern' => '/^[a-z][a-z0-9]/i']) ->addValidator('stringLength', false, ['min' => 3, 'max' => $maxLength]) diff --git a/modules/admin/forms/Series.php b/modules/admin/forms/Series.php index 32bcd24fee..8d296da0bb 100644 --- a/modules/admin/forms/Series.php +++ b/modules/admin/forms/Series.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_Form_Series extends Application_Form_Model_Abstract { @@ -45,7 +44,7 @@ public function init() $this->setRemoveEmptyCheckbox(false); $this->setUseNameAsLabel(true); - $this->setModelClass('Opus_Series'); + $this->setModelClass('Opus\Series'); $this->addElement('text', self::ELEMENT_TITLE, ['required' => true, 'size' => 70]); $this->addElement('textarea', self::ELEMENT_INFOBOX); diff --git a/modules/admin/forms/UserRoles.php b/modules/admin/forms/UserRoles.php index ed267f23ad..728f4ec976 100644 --- a/modules/admin/forms/UserRoles.php +++ b/modules/admin/forms/UserRoles.php @@ -29,9 +29,11 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Account; +use Opus\UserRole; + /** * Abstract class for supporting editing of Opus roles in form. */ @@ -68,7 +70,7 @@ public function init() */ protected function addRoleElements() { - $roles = Opus_UserRole::getAll(); + $roles = UserRole::getAll(); foreach ($roles as $role) { $roleName = $role->getDisplayName(); @@ -90,11 +92,11 @@ protected function addRoleElements() /** * Initialisiert das Formular mit Werten einer Model-Instanz. - * @param $model Opus_Account + * @param $model Account */ public function populateFromModel($model) { - if (! $model instanceof Opus_Account) { + if (! $model instanceof Account) { throw new Exception('Model must be of type Opus_Account'); } @@ -149,22 +151,22 @@ public function getSelectedRoles() */ public function updateModel($account) { - if (! $account instanceof Opus_Account) { + if (! $account instanceof Account) { throw new Exception('Model must be of type Opus_Account'); } - $currentUser = Zend_Auth::getInstance()->getIdentity(); + $currentUser = \Zend_Auth::getInstance()->getIdentity(); $selected = $this->getSelectedRoles(); $roles = []; foreach ($selected as $name) { - $role = Opus_UserRole::fetchByName($name); + $role = UserRole::fetchByName($name); $roles[] = $role; } - $adminRole = Opus_UserRole::fetchByName('administrator'); + $adminRole = UserRole::fetchByName('administrator'); if ($currentUser === $account->getLogin() && in_array($account->getId(), $adminRole->getAllAccountIds())) { $roles[] = $adminRole; diff --git a/modules/admin/forms/WorkflowNotification.php b/modules/admin/forms/WorkflowNotification.php index 832180c0c6..5ba52ccab4 100644 --- a/modules/admin/forms/WorkflowNotification.php +++ b/modules/admin/forms/WorkflowNotification.php @@ -32,6 +32,9 @@ * * TODO use getRecipients */ + +use Opus\Document; + class Admin_Form_WorkflowNotification extends Admin_Form_YesNoForm { @@ -64,7 +67,7 @@ public function getTargetState() public function isNotificationEnabled() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); return (isset($config->notification->document->published->enabled) && filter_var($config->notification->document->published->enabled, FILTER_VALIDATE_BOOLEAN)); } @@ -73,8 +76,8 @@ public function isNotificationEnabled() * add a checkbox for each PersonSubmitter and PersonAuthor (used to select * recipients for publish notification email) * - * @param Opus_Document $document - * @param Zend_Form $form + * @param Document $document + * @param \Zend_Form $form * */ public function populateFromModel($document) diff --git a/modules/admin/forms/Wrapper.php b/modules/admin/forms/Wrapper.php index e532861fe6..37d65ec2c1 100644 --- a/modules/admin/forms/Wrapper.php +++ b/modules/admin/forms/Wrapper.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -44,7 +43,7 @@ * Verarbeitung des POST wird die erste Ebene übersprungen ($post['Document']) und nur mit dem obersten Unterformular * weitergearbeitet. */ -class Admin_Form_Wrapper extends Zend_Form +class Admin_Form_Wrapper extends \Zend_Form { private $_subFormName; diff --git a/modules/admin/forms/YesNoForm.php b/modules/admin/forms/YesNoForm.php index 1a12c51ca1..0c0e2c0875 100644 --- a/modules/admin/forms/YesNoForm.php +++ b/modules/admin/forms/YesNoForm.php @@ -32,7 +32,7 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Admin_Form_YesNoForm extends Zend_Form +class Admin_Form_YesNoForm extends \Zend_Form { const ELEMENT_YES = 'sureyes'; @@ -46,10 +46,10 @@ class Admin_Form_YesNoForm extends Zend_Form */ public function init() { - $sureyes = new Zend_Form_Element_Submit(self::ELEMENT_YES); + $sureyes = new \Zend_Form_Element_Submit(self::ELEMENT_YES); $sureyes->setLabel('answer_yes'); - $sureno = new Zend_Form_Element_Submit(self::ELEMENT_NO); + $sureno = new \Zend_Form_Element_Submit(self::ELEMENT_NO); $sureno->setLabel('answer_no'); $this->addElements([$sureyes, $sureno]); diff --git a/modules/admin/models/Collection.php b/modules/admin/models/Collection.php index 101847248e..f8031db660 100644 --- a/modules/admin/models/Collection.php +++ b/modules/admin/models/Collection.php @@ -29,9 +29,13 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Collection; +use Opus\Model\ModelException; +use Opus\Model\NotFoundException; + class Admin_Model_Collection { @@ -47,22 +51,22 @@ public function __construct($id = null) return; } try { - $this->_collection = new Opus_Collection($id); - } catch (Opus_Model_NotFoundException $e) { + $this->_collection = new Collection($id); + } catch (NotFoundException $e) { throw new Admin_Model_Exception('id parameter value unknown'); } } private function initNewCollection() { - $this->_collection = new Opus_Collection(); + $this->_collection = new Collection(); $this->_collection->setVisible('1'); $this->_collection->setVisiblePublish('1'); } /** * - * @return Opus_Collection + * @return Collection */ public function getObject() { @@ -93,12 +97,12 @@ public function setVisiblity($visibility) public function addDocument($documentId) { if (is_null($documentId)) { - throw new Admin_ModelException('missing document id'); + throw new Admin_Model_Exception('missing document id'); } $document = null; try { - $document = new Opus_Document($documentId); - } catch (Opus_Model_Exception $e) { + $document = Document::get($documentId); + } catch (ModelException $e) { throw new Admin_Model_Exception('invalid document id'); } $document->addCollection($this->_collection); diff --git a/modules/admin/models/CollectionRole.php b/modules/admin/models/CollectionRole.php index f18eda87b2..be4014da0a 100644 --- a/modules/admin/models/CollectionRole.php +++ b/modules/admin/models/CollectionRole.php @@ -29,8 +29,12 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ - * + */ + +use Opus\CollectionRole; +use Opus\Model\NotFoundException; + +/** * TODO überarbeiten (entfernen?) */ class Admin_Model_CollectionRole @@ -48,8 +52,8 @@ public function __construct($id = null) return; } try { - $this->_collectionRole = new Opus_CollectionRole((int) $id); - } catch (Opus_Model_NotFoundException $e) { + $this->_collectionRole = new CollectionRole((int) $id); + } catch (NotFoundException $e) { throw new Admin_Model_Exception('roleid parameter value unknown'); } } @@ -59,7 +63,7 @@ public function __construct($id = null) */ private function initNewCollectionRole() { - $this->_collectionRole = new Opus_CollectionRole(); + $this->_collectionRole = new CollectionRole(); foreach (['Visible', 'VisibleBrowsingStart', 'VisibleFrontdoor', 'VisibleOai'] as $field) { $this->_collectionRole->getField($field)->setValue(1); } @@ -67,7 +71,7 @@ private function initNewCollectionRole() /** * Liefert CollectionRole. - * @return null|Opus_CollectionRole + * @return null|CollectionRole */ public function getObject() { diff --git a/modules/admin/models/Collections.php b/modules/admin/models/Collections.php index 982c045765..c5b504ca4d 100644 --- a/modules/admin/models/Collections.php +++ b/modules/admin/models/Collections.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; + class Admin_Model_Collections extends Application_Model_Abstract { @@ -46,7 +48,7 @@ public function getCollectionRolesInfo($documentId = null) { $collections = []; - $collectionRoles = Opus_CollectionRole::fetchAll(); + $collectionRoles = CollectionRole::fetchAll(); foreach ($collectionRoles as $collectionRole) { $rootCollection = $collectionRole->getRootCollection(); diff --git a/modules/admin/models/DocumentEditSession.php b/modules/admin/models/DocumentEditSession.php index 15cce339ed..3599a299b8 100644 --- a/modules/admin/models/DocumentEditSession.php +++ b/modules/admin/models/DocumentEditSession.php @@ -33,7 +33,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_Model_DocumentEditSession extends Application_Model_Abstract { @@ -179,7 +178,7 @@ public function retrievePost($name = null) public function getSessionNamespace() { if (null === $this->_session) { - $this->_session = new Zend_Session_Namespace($this->_namespace); + $this->_session = new \Zend_Session_Namespace($this->_namespace); } return $this->_session; @@ -194,7 +193,7 @@ public function getDocumentSessionNamespace() $key = 'doc' . $this->_docId; if (! array_key_exists($key, $this->_documentNamespaces)) { - $namespace = new Zend_Session_Namespace($key); + $namespace = new \Zend_Session_Namespace($key); $this->_documentNamespaces[$key] = $namespace; } else { $namespace = $this->_documentNamespaces[$key]; diff --git a/modules/admin/models/DoiReport.php b/modules/admin/models/DoiReport.php index 18867a2208..14ea3d2903 100644 --- a/modules/admin/models/DoiReport.php +++ b/modules/admin/models/DoiReport.php @@ -31,6 +31,11 @@ * @copyright Copyright (c) 2018, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Doi\DoiManager; + class Admin_Model_DoiReport { @@ -54,7 +59,7 @@ public function getDocList() { $result = []; - $doiManager = new Opus_Doi_DoiManager(); + $doiManager = new DoiManager(); $docs = $doiManager->getAll($this->filter); foreach ($docs as $doc) { @@ -80,11 +85,11 @@ public function getNumDoisForBulkRegistration() { $result = 0; - $docFinder = new Opus_DocumentFinder(); + $docFinder = new DocumentFinder(); $docFinder->setServerState('published'); $docFinder->setIdentifierTypeExists('doi'); foreach ($docFinder->ids() as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $dois = $doc->getIdentifierDoi(); if (! is_null($dois) && ! empty($dois)) { // es wird nur die erste DOI für die DOI-Registrierung berücksichtigt @@ -109,12 +114,12 @@ public function getNumDoisForBulkVerification() { $result = 0; - $docFinder = new Opus_DocumentFinder(); + $docFinder = new DocumentFinder(); $docFinder->setServerState('published'); $docFinder->setIdentifierTypeExists('doi'); foreach ($docFinder->ids() as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $dois = $doc->getIdentifierDoi(); if (! is_null($dois) && ! empty($dois)) { // es wird nur die erste DOI für die DOI-Prüfung berücksichtigt diff --git a/modules/admin/models/DoiStatus.php b/modules/admin/models/DoiStatus.php index 67d9255b98..e7cb7adbc9 100644 --- a/modules/admin/models/DoiStatus.php +++ b/modules/admin/models/DoiStatus.php @@ -44,7 +44,7 @@ class Admin_Model_DoiStatus /** * Admin_Model_DoiStatus constructor. * - * @param Opus_Document $doc + * @param Document $doc */ public function __construct($doc, $doi) { diff --git a/modules/admin/models/EnrichmentKeys.php b/modules/admin/models/EnrichmentKeys.php index 036b1a536f..85db22b1a8 100644 --- a/modules/admin/models/EnrichmentKeys.php +++ b/modules/admin/models/EnrichmentKeys.php @@ -30,7 +30,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -121,7 +120,7 @@ public function createTranslations($name, $oldName = null) { $patterns = $this->translationKeyPatterns; - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $manager = new Application_Translate_TranslationManager(); if (! is_null($oldName) && $name !== $oldName) { @@ -151,7 +150,7 @@ public function removeTranslations($name) { $patterns = $this->translationKeyPatterns; - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); foreach ($patterns as $pattern) { $key = sprintf($pattern, $name); diff --git a/modules/admin/models/Exception.php b/modules/admin/models/Exception.php index 0b1433fb8f..53de917fb1 100644 --- a/modules/admin/models/Exception.php +++ b/modules/admin/models/Exception.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_Model_Exception extends Application_Exception diff --git a/modules/admin/models/FileImport.php b/modules/admin/models/FileImport.php index b22d532548..b6595b647b 100644 --- a/modules/admin/models/FileImport.php +++ b/modules/admin/models/FileImport.php @@ -29,9 +29,12 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\File; +use Opus\Model\NotFoundException; + /** * Model for importing files from a specific folder. * @@ -61,8 +64,8 @@ public function addFilesToDocument($docId, $files) $document = null; try { - $document = new Opus_Document($docId); - } catch (Opus_Model_NotFoundException $e) { + $document = Document::get($docId); + } catch (NotFoundException $e) { throw new Application_Exception('no document found for id ' . $docId, null, $e); } @@ -99,7 +102,7 @@ public function addFilesToDocument($docId, $files) */ public function listFiles() { - return Zend_Controller_Action_HelperBroker::getStaticHelper('Files')->listFiles($this->_importFolder, true); + return \Zend_Controller_Action_HelperBroker::getStaticHelper('Files')->listFiles($this->_importFolder, true); } public function getNamesOfIncomingFiles() @@ -129,7 +132,7 @@ public function getImportFolder() */ public function deleteFile($docId, $fileId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $keepFiles = []; @@ -160,8 +163,8 @@ public function isValidFileId($fileId) $file = null; try { - $file = new Opus_File($fileId); - } catch (Opus_Model_NotFoundException $omnfe) { + $file = new File($fileId); + } catch (NotFoundException $omnfe) { return false; } @@ -180,7 +183,7 @@ public function isFileBelongsToDocument($docId, $fileId) return false; } - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $files = $doc->getFile(); diff --git a/modules/admin/models/Hash.php b/modules/admin/models/Hash.php index 221c11f301..a78e0fae53 100644 --- a/modules/admin/models/Hash.php +++ b/modules/admin/models/Hash.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\File; + /** * Klasse fuer die Handhabung von Datei-Hashes. * @@ -33,7 +35,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_Model_Hash { @@ -41,7 +42,7 @@ class Admin_Model_Hash private $_hash = null; /** - * @var Opus_File + * @var File */ private $_file = null; diff --git a/modules/admin/models/IndexMaintenance.php b/modules/admin/models/IndexMaintenance.php index e58f1a8500..e89dc9c039 100644 --- a/modules/admin/models/IndexMaintenance.php +++ b/modules/admin/models/IndexMaintenance.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Job; +use Opus\Search\Task\ConsistencyCheck; + class Admin_Model_IndexMaintenance { @@ -45,8 +48,8 @@ class Admin_Model_IndexMaintenance public function __construct($logger = null) { - $this->_config = Zend_Registry::get('Zend_Config'); - $this->_logger = (is_null($logger)) ? Zend_Registry::get('Zend_Log') : $logger; + $this->_config = \Zend_Registry::get('Zend_Config'); + $this->_logger = (is_null($logger)) ? \Zend_Registry::get('Zend_Log') : $logger; $this->setFeatureDisabled(); if ($this->_featureDisabled) { @@ -92,8 +95,8 @@ public function getFeatureDisabled() public function createJob() { - $job = new Opus_Job(); - $job->setLabel(Opus\Search\Task\ConsistencyCheck::LABEL); + $job = new Job(); + $job->setLabel(ConsistencyCheck::LABEL); if (! $this->_featureDisabled) { // Queue job (execute asynchronously) @@ -167,7 +170,7 @@ public function readLogFile() public function allowConsistencyCheck() { - return Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL) == 0; + return Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL) == 0; } public function allowFulltextExtractionCheck() diff --git a/modules/admin/models/IndexMaintenanceLogData.php b/modules/admin/models/IndexMaintenanceLogData.php index 8d8b959574..816e4c718a 100644 --- a/modules/admin/models/IndexMaintenanceLogData.php +++ b/modules/admin/models/IndexMaintenanceLogData.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Admin_Model_IndexMaintenanceLogData diff --git a/modules/admin/models/Option.php b/modules/admin/models/Option.php index 4dbc650cca..12568e6103 100644 --- a/modules/admin/models/Option.php +++ b/modules/admin/models/Option.php @@ -47,8 +47,8 @@ class Admin_Model_Option extends Application_Model_Abstract /** * Admin_Model_Option constructor. - * @param $name Name of option - * @param $config Parameters for option + * @param $name string Name of option + * @param $config array Parameters for option */ public function __construct($name, $config) { diff --git a/modules/admin/models/Options.php b/modules/admin/models/Options.php index 0ffc25a8dd..10ba136542 100644 --- a/modules/admin/models/Options.php +++ b/modules/admin/models/Options.php @@ -61,7 +61,7 @@ class Admin_Model_Options extends Application_Model_Abstract public function __construct($config = null) { if (! is_null($config) && is_array($config)) { - $this->config = new Zend_Config($config); + $this->config = new \Zend_Config($config); } } @@ -88,7 +88,7 @@ public function getOptions() public function getConfig() { if (is_null($this->config)) { - $this->config = new Zend_Config_Json(APPLICATION_PATH . self::OPTIONS_CONFIG_FILE); + $this->config = new \Zend_Config_Json(APPLICATION_PATH . self::OPTIONS_CONFIG_FILE); } return $this->config; diff --git a/modules/admin/models/Statistics.php b/modules/admin/models/Statistics.php index 2ddd85a43b..7cd9bcbed3 100644 --- a/modules/admin/models/Statistics.php +++ b/modules/admin/models/Statistics.php @@ -28,8 +28,12 @@ * @author Michael Lang * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ + +use Opus\CollectionRole; +use Opus\DocumentFinder; +use Opus\Db\Documents; + class Admin_Model_Statistics { @@ -37,7 +41,7 @@ class Admin_Model_Statistics public function __construct() { - $this->_documents = new Opus_Db_Documents(); + $this->_documents = new Documents(); } /** @@ -118,7 +122,7 @@ public function getTypeStatistics($selectedYear) */ public function getInstituteStatistics($selectedYear) { - $role = Opus_CollectionRole::fetchByName('institutes'); + $role = CollectionRole::fetchByName('institutes'); $instStat = []; if (isset($role)) { $query = "SELECT c.name name, COUNT(DISTINCT(d.id)) entries @@ -127,7 +131,7 @@ public function getInstituteStatistics($selectedYear) LEFT JOIN collections c ON ldc.collection_id=c.id WHERE c.role_id=? AND YEAR(server_date_published)=? AND server_state='published' group by name"; - $db = Zend_Registry::get('db_adapter'); + $db = \Zend_Registry::get('db_adapter'); $res = $db->query($query, [$role->getId(), $selectedYear])->fetchAll(); foreach ($res as $result) { @@ -143,7 +147,7 @@ public function getInstituteStatistics($selectedYear) */ public function getYears() { - $documents = new Opus_Db_Documents(); + $documents = new Documents(); $select = $documents->select()->from('documents', ['year' => 'YEAR(server_date_published)']) ->where('server_state = ?', 'published') ->where('server_date_published IS NOT NULL') @@ -161,7 +165,7 @@ public function getYears() */ public function getNumDocsUntil($thresholdYear) { - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setServerState('published'); $finder->setServerDatePublishedBefore($thresholdYear + 1); return $finder->count(); diff --git a/modules/admin/models/UrnGenerator.php b/modules/admin/models/UrnGenerator.php index 6078b45814..1037e727a4 100644 --- a/modules/admin/models/UrnGenerator.php +++ b/modules/admin/models/UrnGenerator.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Identifier\Urn; + class Admin_Model_UrnGenerator { @@ -47,7 +49,7 @@ class Admin_Model_UrnGenerator */ public function __construct() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (! isset($config->urn->nid) || $config->urn->nid == '') { throw new Application_Exception('missing configuration setting for urn.nid - is required for URN generation'); @@ -64,15 +66,15 @@ public function __construct() * Generiert eine URN für das Dokument mit der übergebenen ID. * Hierbei wird NICHT geprüft, ob das Dokument einen Volltext mit dem aktiven Flag visibleInOai besitzt. * - * @param $docId ID des OPUS-Dokuments für das URN generiert werden soll + * @param $docId int ID des OPUS-Dokuments für das URN generiert werden soll * @return string */ public function generateUrnForDocument($docId) { - $identifierUrn = new Opus_Identifier_Urn($this->nid, $this->nss); + $identifierUrn = new Urn($this->nid, $this->nss); $urn = $identifierUrn->getUrn($docId); - $log = Zend_Registry::get('Zend_Log'); + $log = \Zend_Registry::get('Zend_Log'); $log->debug('URN generation result for document ' . $docId . ' is ' . $urn); return $urn; diff --git a/modules/admin/views/scripts/actionbox.phtml b/modules/admin/views/scripts/actionbox.phtml index 6fa020ea92..60ee0594a5 100644 --- a/modules/admin/views/scripts/actionbox.phtml +++ b/modules/admin/views/scripts/actionbox.phtml @@ -119,6 +119,6 @@ -err('Use of partial \'actionbox.phtml\' without document.'); ?> +err('Use of partial \'actionbox.phtml\' without document.'); ?> diff --git a/modules/admin/views/scripts/collectionroles/index.phtml b/modules/admin/views/scripts/collectionroles/index.phtml index fee96eb1d2..a0dddf0073 100644 --- a/modules/admin/views/scripts/collectionroles/index.phtml +++ b/modules/admin/views/scripts/collectionroles/index.phtml @@ -52,7 +52,7 @@ collectionRoles as $i => $collectionRole) : $translatelabel = 'default_collection_role_' . $collectionRole->getName(); diff --git a/modules/admin/views/scripts/docinfo.phtml b/modules/admin/views/scripts/docinfo.phtml index 01e0eb434f..7b6b90a816 100644 --- a/modules/admin/views/scripts/docinfo.phtml +++ b/modules/admin/views/scripts/docinfo.phtml @@ -40,6 +40,6 @@ -err('Use of partial \'docinfo.phtml\' without document = null.'); ?> +err('Use of partial \'docinfo.phtml\' without document = null.'); ?> diff --git a/modules/admin/views/scripts/docstatus.phtml b/modules/admin/views/scripts/docstatus.phtml index 15e1044ce4..76a33f60c0 100644 --- a/modules/admin/views/scripts/docstatus.phtml +++ b/modules/admin/views/scripts/docstatus.phtml @@ -44,6 +44,6 @@ -err('Use of partial \'docstatus.phtml\' without document = null.'); ?> +err('Use of partial \'docstatus.phtml\' without document = null.'); ?> diff --git a/modules/admin/views/scripts/form/personForm.phtml b/modules/admin/views/scripts/form/personForm.phtml index 358416c684..362a8e509c 100644 --- a/modules/admin/views/scripts/form/personForm.phtml +++ b/modules/admin/views/scripts/form/personForm.phtml @@ -41,7 +41,7 @@ $personId = $this->element->getElement(Admin_Form_Person::ELEMENT_PERSON_ID)->getValue(); $person = $this->element->getModel(); if (is_null($person) && ! is_null($personId)) { - $person = new Opus_Person($personId); + $person = new \Opus\Person($personId); } else { // TODO err output } diff --git a/modules/admin/views/scripts/infobox.phtml b/modules/admin/views/scripts/infobox.phtml index 720557d390..a29c3a3520 100644 --- a/modules/admin/views/scripts/infobox.phtml +++ b/modules/admin/views/scripts/infobox.phtml @@ -43,6 +43,6 @@ -err('Use of partial \'docinfo.phtml\' without document = null.'); ?> +err('Use of partial \'docinfo.phtml\' without document = null.'); ?> diff --git a/modules/admin/views/scripts/job/index.phtml b/modules/admin/views/scripts/job/index.phtml index 0b20d11120..ca1d3157cb 100644 --- a/modules/admin/views/scripts/job/index.phtml +++ b/modules/admin/views/scripts/job/index.phtml @@ -51,7 +51,7 @@ - translate('admin_job_label_'.$label) ?> + translate('admin_job_label_'.$label) ?> @@ -76,7 +76,7 @@ - translate('admin_job_label_'.$label) ?> + translate('admin_job_label_'.$label) ?> diff --git a/modules/admin/views/scripts/person/documents.phtml b/modules/admin/views/scripts/person/documents.phtml index 42c276775c..13fe68de7c 100644 --- a/modules/admin/views/scripts/person/documents.phtml +++ b/modules/admin/views/scripts/person/documents.phtml @@ -33,7 +33,7 @@ ?> documents as $index => $docId) : ?> - +
documentTitle($document) ?> (getId() ?>)
diff --git a/modules/admin/views/scripts/person/index.phtml b/modules/admin/views/scripts/person/index.phtml index ce27bb8126..a732e6c1b2 100644 --- a/modules/admin/views/scripts/person/index.phtml +++ b/modules/admin/views/scripts/person/index.phtml @@ -67,9 +67,9 @@ [ 'module' => 'admin', 'controller' => 'documents', 'action' => 'index', 'state' => 'all'], $person - )) ?>"> + )) ?>"> - + getStorage()->write(strtolower($login)); + \Zend_Auth::getInstance()->getStorage()->write(strtolower($login)); // Redirect to post login url. $action = $this->_loginUrl['action']; @@ -185,45 +186,45 @@ public function loginAction() */ public function logoutAction() { - Zend_Auth::getInstance()->clearIdentity(); + \Zend_Auth::getInstance()->clearIdentity(); return $this->_helper->_redirector('index', 'index', 'home'); } /** * Assembles and returns a login form. * - * @return unknown + * @return \Zend_Form */ protected function getLoginForm() { - $form = new Zend_Form(); + $form = new \Zend_Form(); // Add hash element to detect counterfeit formular data via validation. - $hash = new Zend_Form_Element_Hash('hash'); + $hash = new \Zend_Form_Element_Hash('hash'); // Login name element. - $login = new Zend_Form_Element_Text('login'); - $login->addValidator(new Zend_Validate_Regex('/^[A-Za-z0-9@._-]+$/')) + $login = new \Zend_Form_Element_Text('login'); + $login->addValidator(new \Zend_Validate_Regex('/^[A-Za-z0-9@._-]+$/')) ->setRequired() ->setLabel('auth_field_login'); $login->addErrorMessages( [ - Zend_Validate_NotEmpty::IS_EMPTY => 'auth_error_no_username' + \Zend_Validate_NotEmpty::IS_EMPTY => 'auth_error_no_username' ] ); // Password element. - $password = new Zend_Form_Element_Password('password'); + $password = new \Zend_Form_Element_Password('password'); $password->setRequired() ->setLabel('auth_field_password'); $password->addErrorMessages( [ - Zend_Validate_NotEmpty::IS_EMPTY => 'auth_error_no_password' + \Zend_Validate_NotEmpty::IS_EMPTY => 'auth_error_no_password' ] ); // Submit button. - $submit = new Zend_Form_Element_Submit('SubmitCredentials'); + $submit = new \Zend_Form_Element_Submit('SubmitCredentials'); $submit->setLabel('Login'); $form->setMethod('POST'); diff --git a/modules/default/controllers/ErrorController.php b/modules/default/controllers/ErrorController.php index dbfe1f694b..94bbe70323 100644 --- a/modules/default/controllers/ErrorController.php +++ b/modules/default/controllers/ErrorController.php @@ -34,6 +34,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Mail\MailException; +use Opus\Mail\SendMail; + /** * This controller is called on every error or exception. * @@ -60,7 +63,7 @@ public function errorAction() $logger = $this->getLogger(); // log request URI if error occurs - $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); + $uri = \Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); $logger->err("Request '$uri'"); $errors = $this->_getParam('error_handler'); @@ -71,9 +74,9 @@ public function errorAction() } switch ($errors->type) { - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: + case \Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: + case \Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: + case \Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: // 404 error -- controller or action not found $this->getResponse()->setHttpResponseCode(404); $this->view->title = 'error_page_not_found'; @@ -122,7 +125,7 @@ public function errorAction() $errors->request, $errors->exception ); - } catch (Exception $e) { + } catch (\Exception $e) { $logger->err('ErrorController: Failed sending error email: ' . $e); } } @@ -144,7 +147,7 @@ private function setResponseCode($code) * @param $exception * @return bool * @throws Application_Exception - * @throws Opus_Mail_Exception + * @throws MailException * * TODO Escape exception messages, other stuff? Is it possible to inject javascript in E-Mail? */ @@ -158,7 +161,7 @@ public function _sendErrorMail($config, $responseCode, $view, $request, $excepti throw new Application_Exception('Invalid Exception object given.'); } - if (! is_object($request) or ! ($request instanceof Zend_Controller_Request_Abstract)) { + if (! is_object($request) or ! ($request instanceof \Zend_Controller_Request_Abstract)) { throw new Application_Exception('Invalid Zend_Controller_Request_Abstract object given.'); } @@ -190,7 +193,7 @@ public function _sendErrorMail($config, $responseCode, $view, $request, $excepti $body .= "\n"; // Add document ID for errors occuring during publish process - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); if (isset($session->documentId)) { $body .= "User Session (Namespace Publish):\n"; $body .= " Document ID: " . $session->documentId . "\n"; @@ -237,7 +240,7 @@ public function _sendErrorMail($config, $responseCode, $view, $request, $excepti 'name' => $config->errorController->mailTo->name, ]; - $mail = new Opus_Mail_SendMail(); + $mail = new SendMail(); $mail->sendMail( $config->mail->opus->address, $config->mail->opus->name, diff --git a/modules/default/controllers/IndexController.php b/modules/default/controllers/IndexController.php index 97527b18eb..b1d8f6b368 100644 --- a/modules/default/controllers/IndexController.php +++ b/modules/default/controllers/IndexController.php @@ -30,7 +30,6 @@ * @author Felix Ostrowski (ostrowski@hbz-nrw.de) * @copyright Copyright (c) 2008, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/default/controllers/LicenseController.php b/modules/default/controllers/LicenseController.php index 456c3b8de7..ade3691ad0 100644 --- a/modules/default/controllers/LicenseController.php +++ b/modules/default/controllers/LicenseController.php @@ -29,10 +29,12 @@ * @author Felix Ostrowski * @copyright Copyright (c) 2008, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ * */ +use Opus\Licence; +use Opus\Model\NotFoundException; + class LicenseController extends Application_Controller_Action { @@ -53,10 +55,10 @@ public function indexAction() // Load document $licId = $this->getRequest()->getParam('licId'); try { - $license = new Opus_Licence($licId); + $license = new Licence($licId); $this->view->license = $license; - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { throw new Exception($this->view->translate('license_id_not_found', [$licId])); } } diff --git a/modules/export/Bootstrap.php b/modules/export/Bootstrap.php index 5548847bf9..3eb48c2bf0 100644 --- a/modules/export/Bootstrap.php +++ b/modules/export/Bootstrap.php @@ -32,30 +32,32 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Export_Bootstrap extends Zend_Application_Module_Bootstrap +use Opus\Security\Realm; + +class Export_Bootstrap extends \Zend_Application_Module_Bootstrap { protected function _initExport() { $updateInProgress = Application_Configuration::isUpdateInProgress(); - if (! Zend_Registry::isRegistered('Opus_Exporter')) { + if (! \Zend_Registry::isRegistered('Opus_Exporter')) { if (! $updateInProgress) { - Zend_Registry::get('Zend_Log')->warn(__METHOD__ . ' exporter not found'); + \Zend_Registry::get('Zend_Log')->warn(__METHOD__ . ' exporter not found'); } return; } - $exporter = Zend_Registry::get('Opus_Exporter'); + $exporter = \Zend_Registry::get('Opus_Exporter'); if (is_null($exporter)) { if (! $updateInProgress) { - Zend_Registry::get('Zend_Log')->warn(__METHOD__ . ' exporter not found'); + \Zend_Registry::get('Zend_Log')->warn(__METHOD__ . ' exporter not found'); } return; } - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); // only add XML export if user has access and stylesheet is configured if (isset($config->export->stylesheet->frontdoor)) { @@ -104,7 +106,7 @@ protected function _initExport() ] ]); - if (Opus_Security_Realm::getInstance()->checkModule('admin')) { + if (Realm::getInstance()->checkModule('admin')) { // add admin-only format(s) to exporter // hiermit wird nur die Sichtbarkeit des Export-Buttons gesteuert $exporter->addFormats([ diff --git a/modules/export/controllers/IndexController.php b/modules/export/controllers/IndexController.php index f8f4ebc8b2..6e362de76e 100644 --- a/modules/export/controllers/IndexController.php +++ b/modules/export/controllers/IndexController.php @@ -63,7 +63,7 @@ public function init() // Controller outputs plain Xml, so rendering and layout are disabled. $this->disableViewRendering(); // TODO there could be plugins requiring rendering - $this->_exportService = Zend_Registry::get('Opus_ExportService'); + $this->_exportService = \Zend_Registry::get('Opus_ExportService'); $this->_exportService->loadPlugins(); } diff --git a/modules/export/models/DataciteExport.php b/modules/export/models/DataciteExport.php index d9f85072ea..c4d9567814 100644 --- a/modules/export/models/DataciteExport.php +++ b/modules/export/models/DataciteExport.php @@ -32,6 +32,11 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Model\ModelException; +use Opus\Doi\DataCiteXmlGenerator; +use Opus\Doi\DataCiteXmlGenerationException; + class Export_Model_DataciteExport extends Application_Export_ExportPluginAbstract { @@ -56,8 +61,8 @@ public function execute() } try { - $document = new Opus_Document($docId); - } catch (Opus\Model\Exception $e) { + $document = Document::get($docId); + } catch (ModelException $e) { throw new Application_Exception('could not retrieve document with given ID from OPUS database'); } @@ -70,7 +75,7 @@ public function execute() $skipValidation = (! is_null($validate) && $validate === 'no'); $requiredFieldsStatus = []; - $generator = new Opus_Doi_DataCiteXmlGenerator(); + $generator = new DataCiteXmlGenerator(); if (! $skipValidation) { // prüfe, ob das Dokument $document alle erforderlichen Pflichtfelder besitzt $requiredFieldsStatus = $generator->checkRequiredFields($document, false); @@ -81,7 +86,7 @@ public function execute() try { // generiere DataCite-XML, wobei Pflichtfeld-Überprüfung nicht erneut durchgeführt werden soll $output = $generator->getXml($document, $skipValidation, true); - } catch (Opus_Doi_DataCiteXmlGenerationException $e) { + } catch (DataCiteXmlGenerationException $e) { $errors = $e->getXmlErrors(); } @@ -109,7 +114,7 @@ public function postDispatch() /** * Setzt die View-Objekte für die Generierung der HTML-Statusseite mit den Fehlermeldungen der XML-Generierung. * - * @param Opus_Document $document das aktuell verarbeitete Dokument + * @param Document $document das aktuell verarbeitete Dokument * @param array $requiredFieldsStatus der Status (Existenz bzw. Nichtexistenz) der einzelnen Pflichtfelder * @param $errors die bei der DataCite-XML Generierung gefundenen Fehler */ diff --git a/modules/export/models/PublistExport.php b/modules/export/models/PublistExport.php index bc740f7893..ba9f904fef 100644 --- a/modules/export/models/PublistExport.php +++ b/modules/export/models/PublistExport.php @@ -29,9 +29,11 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Collection; +use Opus\CollectionRole; + /** * Export plugin for exporting collections based on role name and collection number. * @@ -75,7 +77,7 @@ public function execute() if (isset($config->stylesheetDirectory)) { $stylesheetDirectory = $config->stylesheetDirectory; } else { - $logger->debug(Zend_Debug::dump($config->toArray(), 'no stylesheet directory specified')); + $logger->debug(\Zend_Debug::dump($config->toArray(), 'no stylesheet directory specified')); } if (isset($config->stylesheet)) { @@ -122,7 +124,7 @@ public function execute() $this->_proc->setParameter('', 'groupBy', $groupBy); $this->_proc->setParameter('', 'pluginName', $this->getName()); - $urnResolverUrl = Zend_Registry::get('Zend_Config')->urn->resolverUrl; + $urnResolverUrl = \Zend_Registry::get('Zend_Config')->urn->resolverUrl; $this->_proc->setParameter('', 'urnResolverUrl', $urnResolverUrl); $this->loadStyleSheet($this->buildStylesheetPath($stylesheet, $view->getScriptPath('') . $stylesheetDirectory)); @@ -187,21 +189,21 @@ public static function getMimeTypeDisplayName($pluginName, $mimeType) */ public function mapQuery($roleParam, $numberParam) { - if (is_null(Opus_CollectionRole::fetchByName($roleParam))) { + if (is_null(CollectionRole::fetchByName($roleParam))) { throw new Application_Exception('specified role does not exist'); } - $role = Opus_CollectionRole::fetchByName($roleParam); + $role = CollectionRole::fetchByName($roleParam); if ($role->getVisible() != '1') { throw new Application_Exception('specified role is invisible'); } - if (count(Opus_Collection::fetchCollectionsByRoleNumber($role->getId(), $numberParam)) == 0) { + if (count(Collection::fetchCollectionsByRoleNumber($role->getId(), $numberParam)) == 0) { throw new Application_Exception('specified number does not exist for specified role'); } $collection = null; - foreach (Opus_Collection::fetchCollectionsByRoleNumber($role->getId(), $numberParam) as $coll) { + foreach (Collection::fetchCollectionsByRoleNumber($role->getId(), $numberParam) as $coll) { if ($coll->getVisible() == '1' && is_null($collection)) { $collection = $coll; } diff --git a/modules/export/models/XmlExport.php b/modules/export/models/XmlExport.php index af350f719a..bda2484547 100644 --- a/modules/export/models/XmlExport.php +++ b/modules/export/models/XmlExport.php @@ -32,6 +32,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Security\Realm; +use Opus\Db\DocumentXmlCache; + /** * Export plugin for exporting documents as XML. * @@ -233,7 +237,7 @@ public function execute() // parameter stylesheet is mandatory (only administrator is able to see raw output) // non-administrative users can only reference user-defined stylesheets - if (is_null($request->getParam('stylesheet')) && ! Opus_Security_Realm::getInstance()->checkModule('admin')) { + if (is_null($request->getParam('stylesheet')) && ! Realm::getInstance()->checkModule('admin')) { throw new Application_Exception('missing parameter stylesheet'); } @@ -305,8 +309,8 @@ public function getMaxRows() $config = $this->getConfig(); - if (! Opus_Security_Realm::getInstance()->skipSecurityChecks()) { - $identity = Zend_Auth::getInstance()->getIdentity(); + if (! Realm::getInstance()->skipSecurityChecks()) { + $identity = \Zend_Auth::getInstance()->getIdentity(); if (empty($identity) === true) { if (isset($config->maxDocumentsGuest)) { @@ -350,7 +354,7 @@ private function handleResults($resultIds, $numOfHits) $proc = $this->_proc; $xml = $this->_xml; - $proc->setParameter('', 'timestamp', str_replace('+00:00', 'Z', Zend_Date::now()->setTimeZone('UTC')->getIso())); + $proc->setParameter('', 'timestamp', str_replace('+00:00', 'Z', \Zend_Date::now()->setTimeZone('UTC')->getIso())); $proc->setParameter('', 'docCount', count($resultIds)); $proc->setParameter('', 'queryhits', $numOfHits); @@ -400,7 +404,7 @@ private function getAndValidateDocId($request) if (! is_null($docId)) { $doc = null; try { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); } catch (Exception $e) { // do nothing: return empty array } @@ -443,7 +447,7 @@ private function getDocumentsFromDatabase($documentIds) $documents = []; foreach ($documentIds as $docId) { - $document = new Opus_Document($docId); + $document = Document::get($docId); $documentXml = new Application_Util_Document($document); $documents[$docId] = $documentXml->getNode(); } @@ -460,7 +464,7 @@ private function getDocumentsFromCache($documentIds) { $documents = []; - $documentCacheTable = new Opus_Db_DocumentXmlCache(); + $documentCacheTable = new DocumentXmlCache(); $docXmlCache = $documentCacheTable->fetchAll( $documentCacheTable->select()->where( 'document_id IN (?)', diff --git a/modules/frontdoor/Bootstrap.php b/modules/frontdoor/Bootstrap.php index be0ddeaf7d..23d94a634f 100644 --- a/modules/frontdoor/Bootstrap.php +++ b/modules/frontdoor/Bootstrap.php @@ -29,9 +29,8 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Frontdoor_Bootstrap extends Zend_Application_Module_Bootstrap +class Frontdoor_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/frontdoor/controllers/DeliverController.php b/modules/frontdoor/controllers/DeliverController.php index 0f5e9c03b0..dfacd9f1f9 100644 --- a/modules/frontdoor/controllers/DeliverController.php +++ b/modules/frontdoor/controllers/DeliverController.php @@ -34,6 +34,9 @@ * * Controller for handling file downloads in the frontdoor. */ + +use Opus\Security\Realm; + class Frontdoor_DeliverController extends Application_Controller_Action { @@ -45,7 +48,7 @@ public function indexAction() $docId = $this->_getParam('docId', null); $path = $this->_getParam('file', null); - $realm = Opus_Security_Realm::getInstance(); + $realm = Realm::getInstance(); $fileModel = null; diff --git a/modules/frontdoor/controllers/IndexController.php b/modules/frontdoor/controllers/IndexController.php index 81fdb99370..0654007a41 100644 --- a/modules/frontdoor/controllers/IndexController.php +++ b/modules/frontdoor/controllers/IndexController.php @@ -33,6 +33,11 @@ * @copyright Copyright (c) 2014-2018, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Document; +use Opus\Model\NotFoundException; +use Opus\Statistic\LocalCounter; + class Frontdoor_IndexController extends Application_Controller_Action { @@ -66,8 +71,8 @@ public function indexAction() $document = null; try { - $document = new Opus_Document($docId); - } catch (Opus_Model_NotFoundException $e) { + $document = Document::get($docId); + } catch (NotFoundException $e) { $this->printDocumentError("frontdoor_doc_id_not_found", 404); return; } @@ -174,7 +179,7 @@ private function printDocumentError($message, $code) /** * - * @param Opus_Document $doc + * @param Document $doc */ private function isMailPossible($doc) { @@ -184,7 +189,7 @@ private function isMailPossible($doc) /** * - * @param Opus_Document $document + * @param Document $document * @return string */ private function getFrontdoorTitle($document) @@ -233,7 +238,7 @@ private function addMetaTagsForDocument($document) private function incrementStatisticsCounter($docId) { try { - $statistics = Opus_Statistic_LocalCounter::getInstance(); + $statistics = LocalCounter::getInstance(); $statistics->countFrontdoor($docId); } catch (Exception $e) { $this->getLogger()->err("Counting frontdoor statistics failed: " . $e); diff --git a/modules/frontdoor/controllers/MailController.php b/modules/frontdoor/controllers/MailController.php index a376cacb4b..98c20e47f3 100644 --- a/modules/frontdoor/controllers/MailController.php +++ b/modules/frontdoor/controllers/MailController.php @@ -31,9 +31,10 @@ * @author Sascha Szott * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Mail\SendMail; + /** * Controller for document recommendation starting from Frontdoor * @@ -55,7 +56,7 @@ public function indexAction() throw new Application_Exception('missing parameter docId'); } - $document = new Opus_Document($docId); + $document = new Document($docId); $this->view->docId = $docId; $this->view->type = $document->getType(); @@ -129,7 +130,7 @@ public function sendmailAction() $bodyText .= '\n' . $this->view->translate('frontdoor_sendersname') . ': ' . $fromName; $bodyText .= '\n' . $this->view->translate('frontdoor_sendersmail') . ': ' . $from; $recipient = array(1 => array('address' => $recipientMail, 'name' => $form->getValue('recipient'))); - $mailSendMail = new Opus_Mail_SendMail(); + $mailSendMail = new SendMail(); try { $mailSendMail->sendMail($from, $fromName, $subject, $bodyText, $recipient); $this->view->ok = '1'; @@ -198,7 +199,7 @@ public function toauthorAction() try { $authorsModel->sendMail( - new Opus_Mail_SendMail(), + new SendMail(), $form->getValue('sender_mail'), $form->getValue('sender'), $this->view->translate('mail_toauthor_subject'), diff --git a/modules/frontdoor/forms/AtLeastOneValidator.php b/modules/frontdoor/forms/AtLeastOneValidator.php index 2815be9a1c..6ce18c928d 100644 --- a/modules/frontdoor/forms/AtLeastOneValidator.php +++ b/modules/frontdoor/forms/AtLeastOneValidator.php @@ -33,13 +33,11 @@ * @copyright Copyright (c) 2009-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -require_once 'Zend/Validate/Abstract.php'; - /** * validator class to check if at least one of the given fields is not empty */ -class Frontdoor_Form_AtLeastOneValidator extends Zend_Validate_Abstract +class Frontdoor_Form_AtLeastOneValidator extends \Zend_Validate_Abstract { const REQUIRED_EMPTY = 'requiredFieldsEmpty'; diff --git a/modules/frontdoor/forms/MailForm.php b/modules/frontdoor/forms/MailForm.php index d572ec6149..5efa6d6086 100644 --- a/modules/frontdoor/forms/MailForm.php +++ b/modules/frontdoor/forms/MailForm.php @@ -30,13 +30,12 @@ * @author Simone Finkbeiner * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * class to built the mail mask for document recommendation via e-mail */ -class Frontdoor_Form_MailForm extends Zend_Form +class Frontdoor_Form_MailForm extends \Zend_Form { /** @@ -47,42 +46,42 @@ class Frontdoor_Form_MailForm extends Zend_Form public function init() { // Create and configure query field elements: - $recipient = new Zend_Form_Element_Text('recipient'); + $recipient = new \Zend_Form_Element_Text('recipient'); $recipient->setRequired(false); $recipient->setLabel('frontdoor_recipientname'); - $recipientMail = new Zend_Form_Element_Text('recipient_mail'); + $recipientMail = new \Zend_Form_Element_Text('recipient_mail'); $recipientMail->setRequired(true); $recipientMail->setLabel('frontdoor_recipientmail'); - $sender = new Zend_Form_Element_Text('sender'); + $sender = new \Zend_Form_Element_Text('sender'); $sender->setRequired(false); $sender->setLabel('frontdoor_sendername'); - $senderMail = new Zend_Form_Element_Text('sender_mail'); + $senderMail = new \Zend_Form_Element_Text('sender_mail'); $senderMail->setRequired(false); $senderMail->setLabel('frontdoor_sendermail'); - $message = new Zend_Form_Element_Textarea('message'); + $message = new \Zend_Form_Element_Textarea('message'); $message->setRequired(false); $message->setLabel('frontdoor_messagetext'); - $title = new Zend_Form_Element_Hidden('title'); + $title = new \Zend_Form_Element_Hidden('title'); $htmlTag = $title->getDecorator('htmlTag'); $htmlTag->setOption('tag', 'div'); $title->removeDecorator('label'); - $docId = new Zend_Form_Element_Hidden('doc_id'); + $docId = new \Zend_Form_Element_Hidden('doc_id'); $htmlTag = $docId->getDecorator('htmlTag'); $htmlTag->setOption('tag', 'div'); $docId->removeDecorator('label'); - $docType = new Zend_Form_Element_Hidden('doc_type'); + $docType = new \Zend_Form_Element_Hidden('doc_type'); $htmlTag = $docType->getDecorator('htmlTag'); $htmlTag->setOption('tag', 'div'); $docType->removeDecorator('label'); - $submit = new Zend_Form_Element_Submit('frontdoor_send_recommendation'); + $submit = new \Zend_Form_Element_Submit('frontdoor_send_recommendation'); $submit->setLabel('frontdoor_sendrecommendation'); // Add elements to form: diff --git a/modules/frontdoor/forms/ToauthorForm.php b/modules/frontdoor/forms/ToauthorForm.php index 03f267b4cd..2c40c26b7e 100644 --- a/modules/frontdoor/forms/ToauthorForm.php +++ b/modules/frontdoor/forms/ToauthorForm.php @@ -30,13 +30,12 @@ * @author Jens Schwidder * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * class to built the mail form for mail contact to author */ -class Frontdoor_Form_ToauthorForm extends Zend_Form +class Frontdoor_Form_ToauthorForm extends \Zend_Form { /** @@ -53,7 +52,7 @@ class Frontdoor_Form_ToauthorForm extends Zend_Form public function init() { $atLeastOne = new Frontdoor_Form_AtLeastOneValidator(); - $authorSub = new Zend_Form_SubForm('a'); + $authorSub = new \Zend_Form_SubForm('a'); if (! is_null($this->_authors)) { $authCheck = null; @@ -62,7 +61,7 @@ public function init() if (count($this->_authors) == 1) { $options['disabled'] = true; } - $authCheck = new Zend_Form_Element_Checkbox($author['id'], $options); + $authCheck = new \Zend_Form_Element_Checkbox($author['id'], $options); $atLeastOne->addField($authCheck); $authCheck->setLabel($author['name']); $authorSub->addElement($authCheck); @@ -76,20 +75,20 @@ public function init() $this->addSubForm($authorSub, 'authors'); } - $sender = new Zend_Form_Element_Text('sender'); + $sender = new \Zend_Form_Element_Text('sender'); $sender->setRequired(true); $sender->setLabel('frontdoor_sendername'); - $senderMail = new Zend_Form_Element_Text('sender_mail'); + $senderMail = new \Zend_Form_Element_Text('sender_mail'); $senderMail->setRequired(true); $senderMail->setLabel('frontdoor_sendermail'); $senderMail->addValidator('EmailAddress'); - $message = new Zend_Form_Element_Textarea('message'); + $message = new \Zend_Form_Element_Textarea('message'); $message->setRequired(true); $message->setLabel('frontdoor_messagetext'); - $captcha = new Zend_Form_Element_Captcha( + $captcha = new \Zend_Form_Element_Captcha( 'foo', [ 'label' => 'label_captcha', @@ -100,7 +99,7 @@ public function init() ]] ); - $submit = new Zend_Form_Element_Submit('frontdoor_send_mailtoauthor'); + $submit = new \Zend_Form_Element_Submit('frontdoor_send_mailtoauthor'); $submit->setLabel('frontdoor_send_mailtoauthor'); $this->addElements([$sender, $senderMail, $message, $captcha, $submit]); diff --git a/modules/frontdoor/models/Authors.php b/modules/frontdoor/models/Authors.php index 93902fdd11..960a21ae82 100644 --- a/modules/frontdoor/models/Authors.php +++ b/modules/frontdoor/models/Authors.php @@ -29,20 +29,22 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Model\NotFoundException; + class Frontdoor_Model_Authors { /** * - * @var Opus_Document + * @var Document */ private $_document; /** - * @param $arg either an instance of Opus_Document or an int that is interpreted + * @param $arg int|Document either an instance of Document or an int that is interpreted * as a document ID * @throws Frontdoor_Model_Exception throws Frontdoor_Model_Exception if * no document with id $docId exists @@ -50,12 +52,12 @@ class Frontdoor_Model_Authors */ public function __construct($arg) { - if ($arg instanceof Opus_Document) { + if ($arg instanceof Document) { $this->_document = $arg; } else { try { - $this->_document = new Opus_Document($arg); - } catch (Opus_Model_NotFoundException $e) { + $this->_document = Document::get($arg); + } catch (NotFoundException $e) { throw new Frontdoor_Model_Exception('invalid value for parameter docId given', null, $e); } } @@ -113,7 +115,7 @@ public function getContactableAuthors() /** * Returns the underlying document that was given at object creation time. * - * @return Opus_Document + * @return Document */ public function getDocument() { @@ -126,7 +128,7 @@ public function getDocument() * * @return array An array with elements of the form * array('address' => 'doe@example.org', 'name' => 'Doe') that can be used - * without conversion as input for the last argument of Opus_Mail_SendMail:sendMail(). + * without conversion as input for the last argument of SendMail:sendMail(). */ private function validateAuthorCheckboxInput($checkboxSelection) { diff --git a/modules/frontdoor/models/DocumentBuilder.php b/modules/frontdoor/models/DocumentBuilder.php index 8cb8f0d3aa..796f2e94aa 100644 --- a/modules/frontdoor/models/DocumentBuilder.php +++ b/modules/frontdoor/models/DocumentBuilder.php @@ -38,7 +38,7 @@ class Frontdoor_Model_DocumentBuilder public function buildDomDocument($xsltFileName) { - $xslt = new DomDocument(); + $xslt = new \DomDocument(); if (is_readable($xsltFileName . '_custom.xslt')) { $xslt->load($xsltFileName . '_custom.xslt'); } else { diff --git a/modules/frontdoor/models/Exception.php b/modules/frontdoor/models/Exception.php index c689354788..52c9a87e7e 100644 --- a/modules/frontdoor/models/Exception.php +++ b/modules/frontdoor/models/Exception.php @@ -29,10 +29,9 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Frontdoor_Model_Exception extends Exception +class Frontdoor_Model_Exception extends \Exception { } diff --git a/modules/frontdoor/models/File.php b/modules/frontdoor/models/File.php index f2d7c83250..6c645d9195 100644 --- a/modules/frontdoor/models/File.php +++ b/modules/frontdoor/models/File.php @@ -1,5 +1,4 @@ _doc = new Opus_Document($docId); - } catch (Opus_Model_NotFoundException $e) { + $this->_doc = Document::get($docId); + } catch (NotFoundException $e) { throw new Frontdoor_Model_DocumentNotFoundException(); } @@ -104,7 +109,7 @@ public function checkDocumentApplicableForFileDownload($realm) private function fetchFile($realm) { - $targetFile = Opus_File::fetchByDocIdPathName($this->_doc->getId(), $this->_filename); + $targetFile = File::fetchByDocIdPathName($this->_doc->getId(), $this->_filename); if (is_null($targetFile)) { throw new Frontdoor_Model_FileNotFoundException(); @@ -119,7 +124,7 @@ private function fetchFile($realm) private function isDocumentAccessAllowed($docId, $realm) { - if (! ($realm instanceof Opus_Security_IRealm)) { + if (! ($realm instanceof IRealm)) { return false; } return $realm->checkDocument($docId) || $this->getAclHelper()->accessAllowed('documents'); @@ -127,7 +132,7 @@ private function isDocumentAccessAllowed($docId, $realm) private function isFileAccessAllowed($file, $realm) { - if (is_null($file) or ! ($realm instanceof Opus_Security_IRealm)) { + if (is_null($file) or ! ($realm instanceof IRealm)) { return false; } @@ -140,7 +145,7 @@ private function isFileAccessAllowed($file, $realm) public function getAclHelper() { if (is_null($this->_accessControl)) { - $this->_accessControl = Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); + $this->_accessControl = \Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); } return $this->_accessControl; diff --git a/modules/frontdoor/models/HtmlMetaTags.php b/modules/frontdoor/models/HtmlMetaTags.php index 50a412bb0b..1038322542 100644 --- a/modules/frontdoor/models/HtmlMetaTags.php +++ b/modules/frontdoor/models/HtmlMetaTags.php @@ -28,9 +28,13 @@ * @package Module_Frontdoor * @author Sascha Szott * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * + */ + +use Opus\Document; + +/** * TODO new types have to be added as functions -> make extendable? how is it used when rendering? * Basically each type could be a separate class. Refactor for later so new types or metatags won't necessarily * require changing core classes (this class here). @@ -66,7 +70,7 @@ public function __construct($config, $fullUrl) } /** - * @param Opus_Document $document + * @param Document $document * @return array Array mit Metatag-Paaren */ public function createTags($document) @@ -131,7 +135,7 @@ public function createTags($document) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleAuthors($document, &$metas) @@ -154,7 +158,7 @@ private function handleAuthors($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleDates($document, &$metas) @@ -177,7 +181,7 @@ private function handleDates($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleTitles($document, &$metas) @@ -229,7 +233,7 @@ private function handleTitles($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleJournalTitle($document, &$metas) @@ -244,7 +248,7 @@ private function handleJournalTitle($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleAbstracts($document, &$metas) @@ -263,7 +267,7 @@ private function handleAbstracts($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleLicences($document, &$metas) @@ -274,7 +278,7 @@ private function handleLicences($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleIdentifierUrn($document, &$metas) @@ -291,7 +295,7 @@ private function handleIdentifierUrn($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleIdentifierDoi($document, &$metas) @@ -306,7 +310,7 @@ private function handleIdentifierDoi($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleIdentifierIssn($document, &$metas) @@ -321,7 +325,7 @@ private function handleIdentifierIssn($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleIdentifierIsbn($document, &$metas) @@ -336,7 +340,7 @@ private function handleIdentifierIsbn($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleFrontdoorUrl($document, &$metas) @@ -347,7 +351,7 @@ private function handleFrontdoorUrl($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleFulltextUrls($document, &$metas) @@ -389,7 +393,7 @@ private function handleFulltextUrls($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param $metas array Array mit Metatag-Paaren */ private function handleKeywords($document, &$metas) @@ -425,7 +429,7 @@ private function handleSimpleAttribute($value, $keys, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param array $metas Array mit Metatag-Paaren */ private function handleThesisPublisher($document, &$metas) @@ -440,7 +444,7 @@ private function handleThesisPublisher($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param array $metas Array mit Metatag-Paaren */ private function handleInstitution($document, &$metas) @@ -459,7 +463,7 @@ private function handleInstitution($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param array $metas Array mit Metatag-Paaren */ private function handleConferenceTitle($document, &$metas) @@ -474,7 +478,7 @@ private function handleConferenceTitle($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @param array $metas Array mit Metatag-Paaren */ private function handleBookTitle($document, &$metas) @@ -489,7 +493,7 @@ private function handleBookTitle($document, &$metas) } /** - * @param Opus_Document $document + * @param Document $document * @return bool */ public function isJournalPaper($document) @@ -498,7 +502,7 @@ public function isJournalPaper($document) } /** - * @param Opus_Document $document + * @param Document $document * @return bool */ public function isConferencePaper($document) @@ -507,7 +511,7 @@ public function isConferencePaper($document) } /** - * @param Opus_Document $document + * @param Document $document * @return bool */ public function isThesis($document) @@ -516,7 +520,7 @@ public function isThesis($document) } /** - * @param Opus_Document $document + * @param Document $document * @return bool */ public function isWorkingPaper($document) @@ -525,7 +529,7 @@ public function isWorkingPaper($document) } /** - * @param Opus_Document $document + * @param Document $document * @return bool */ public function isBook($document) @@ -534,7 +538,7 @@ public function isBook($document) } /** - * @param Opus_Document $document + * @param Document $document * @return bool */ public function isBookPart($document) @@ -543,7 +547,7 @@ public function isBookPart($document) } /** - * @param $document Opus_Document + * @param $document Document * @return bool */ public function isOther($document) diff --git a/modules/help/Bootstrap.php b/modules/help/Bootstrap.php index 707182adc6..52f65a00e0 100644 --- a/modules/help/Bootstrap.php +++ b/modules/help/Bootstrap.php @@ -34,6 +34,6 @@ /** * Empty class seems to be necessary to setup autoloading for modules. */ -class Help_Bootstrap extends Zend_Application_Module_Bootstrap +class Help_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/home/Bootstrap.php b/modules/home/Bootstrap.php index 06a635c830..f6c780f217 100644 --- a/modules/home/Bootstrap.php +++ b/modules/home/Bootstrap.php @@ -34,6 +34,6 @@ /** * Empty class seems to be necessary to setup autoloading for modules. */ -class Home_Bootstrap extends Zend_Application_Module_Bootstrap +class Home_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/home/controllers/IndexController.php b/modules/home/controllers/IndexController.php index 4fdecdb17b..c65072d800 100644 --- a/modules/home/controllers/IndexController.php +++ b/modules/home/controllers/IndexController.php @@ -33,6 +33,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\DocumentFinder; + class Home_IndexController extends Application_Controller_Action { @@ -126,8 +128,8 @@ public function languageAction() $appConfig = new Application_Configuration(); if ($appConfig->isLanguageSelectionEnabled() && ! is_null($language) - && Zend_Registry::get('Zend_Translate')->isAvailable($language)) { - $sessiondata = new Zend_Session_Namespace(); + && \Zend_Registry::get('Zend_Translate')->isAvailable($language)) { + $sessiondata = new \Zend_Session_Namespace(); $sessiondata->language = $language; } $this->_helper->Redirector->redirectTo($action, '', $controller, $module, $params); @@ -136,7 +138,7 @@ public function languageAction() public function indexAction() { $this->_helper->mainMenu('home'); - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setServerState('published'); $this->view->totalNumOfDocs = $finder->count(); } @@ -196,7 +198,7 @@ public function noticeAction() protected function getViewScripts() { $phtmlFilesAvailable = []; - $dir = new DirectoryIterator($this->view->getScriptPath('index')); + $dir = new \DirectoryIterator($this->view->getScriptPath('index')); foreach ($dir as $file) { if ($file->isFile() && $file->getFilename() != '.' && $file->getFilename() != '..' && $file->isReadable()) { array_push($phtmlFilesAvailable, $file->getBasename('.phtml')); diff --git a/modules/home/models/HelpFiles.php b/modules/home/models/HelpFiles.php index 182b72787c..82b1fd0542 100644 --- a/modules/home/models/HelpFiles.php +++ b/modules/home/models/HelpFiles.php @@ -71,7 +71,7 @@ public function getHelpPath() */ public function getContent($key) { - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $translationKey = "help_content_$key"; $translation = $translate->translate($translationKey); @@ -143,10 +143,10 @@ private function getHelpConfig() if (is_readable($filePath)) { try { - $config = new Zend_Config_Ini($filePath); - } catch (Zend_Config_Exception $zce) { + $config = new \Zend_Config_Ini($filePath); + } catch (\Zend_Config_Exception $zce) { // TODO einfachere Lösung? - $logger = Zend_Registry::get('Zend_Log'); + $logger = \Zend_Registry::get('Zend_Log'); if (! is_null($logger)) { $logger->err("could not load help configuration", $zce); } @@ -154,7 +154,7 @@ private function getHelpConfig() } if (is_null($config)) { - $config = new Zend_Config([]); + $config = new \Zend_Config([]); } $this->helpConfig = $config; @@ -177,7 +177,7 @@ public function setHelpPath($path) public function isContentAvailable($key) { - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $translationKey = "help_content_$key"; diff --git a/modules/oai/Bootstrap.php b/modules/oai/Bootstrap.php index 9e5b3f2196..009a42170d 100644 --- a/modules/oai/Bootstrap.php +++ b/modules/oai/Bootstrap.php @@ -29,9 +29,8 @@ * @author Thoralf Klein * @copyright Copyright (c) 2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Oai_Bootstrap extends Zend_Application_Module_Bootstrap +class Oai_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/oai/models/AbstractFile.php b/modules/oai/models/AbstractFile.php index 64dd7be8ab..f57b8d4bac 100644 --- a/modules/oai/models/AbstractFile.php +++ b/modules/oai/models/AbstractFile.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ abstract class Oai_Model_AbstractFile extends Application_Model_Abstract diff --git a/modules/oai/models/Configuration.php b/modules/oai/models/Configuration.php index bf6b4c5037..6e9bca9d8b 100644 --- a/modules/oai/models/Configuration.php +++ b/modules/oai/models/Configuration.php @@ -30,7 +30,6 @@ * @author Ralf Claußnitzer * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -102,7 +101,7 @@ class Oai_Model_Configuration * * @throws Exception Thrown if no oai section is set. */ - public function __construct(Zend_Config $config) + public function __construct(\Zend_Config $config) { if (false === isset($config->oai)) { throw new Exception('No configuration for module oai.'); diff --git a/modules/oai/models/Container.php b/modules/oai/models/Container.php index 0dcb91d5b0..e111757a69 100644 --- a/modules/oai/models/Container.php +++ b/modules/oai/models/Container.php @@ -33,6 +33,11 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\File; +use Opus\Model\NotFoundException; +use Opus\Security\Realm; + /** * Class Oai_Model_Container * @@ -48,7 +53,7 @@ class Oai_Model_Container extends Application_Model_Abstract private $_docId; /** - * @var Opus_Document + * @var Document */ private $_doc; @@ -81,7 +86,7 @@ private function logErrorMessage($message) /** * * @param string $docId - * @return Opus_Document returns valid Opus_Document if docId is valid, otherwise throws an Oai_Model_Exception + * @return Document returns valid Document if docId is valid, otherwise throws an Oai_Model_Exception * @throws Oai_Model_Exception throws Oai_Model_Exception if the given docId is invalid * * TODO centralize this function (is used in several controllers) @@ -99,23 +104,23 @@ private function validateId($docId) } try { - return new Opus_Document($docId); - } catch (Opus_Model_NotFoundException $e) { + return Document::get($docId); + } catch (NotFoundException $e) { $this->logErrorMessage('document with id ' . $docId . ' does not exist'); throw new Oai_Model_Exception('requested docId does not exist'); } } /** - * Returns all associated Opus_File objects that are visible in OAI and accessible by user - * @return array Accessible Opus_File objects + * Returns all associated File objects that are visible in OAI and accessible by user + * @return array Accessible File objects * * TODO check embargo date * TODO merge access checks with code for deliver controller */ public function getAccessibleFiles() { - $realm = Opus_Security_Realm::getInstance(); + $realm = Realm::getInstance(); // admins sollen immer durchgelassen werden, nutzer nur wenn das doc im publizierten Zustand ist if (! $realm->skipSecurityChecks()) { @@ -149,7 +154,7 @@ public function getAccessibleFiles() $files = []; $filesToCheck = $this->_doc->getFile(); - /* @var $file Opus_File */ + /* @var $file File */ foreach ($filesToCheck as $file) { $filename = $this->_appConfig->getFilesPath() . $this->_docId . DIRECTORY_SEPARATOR . $file->getPathName(); if (is_readable($filename)) { @@ -165,7 +170,7 @@ public function getAccessibleFiles() } $containerFiles = []; - /* @var $file Opus_File */ + /* @var $file File */ foreach ($files as $file) { if ($file->getVisibleInOai() && $realm->checkFile($file->getId())) { array_push($containerFiles, $file); diff --git a/modules/oai/models/DocumentList.php b/modules/oai/models/DocumentList.php index 93b192a51b..cfbe73e757 100644 --- a/modules/oai/models/DocumentList.php +++ b/modules/oai/models/DocumentList.php @@ -30,9 +30,11 @@ * @author Thoralf Klein * @copyright Copyright (c) 2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\CollectionRole; +use Opus\DocumentFinder; + class Oai_Model_DocumentList { @@ -67,7 +69,7 @@ public function query(array $oaiRequest) { $today = date('Y-m-d', time()); - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); // add server state restrictions $finder->setServerStateInList($this->deliveringDocumentStates); @@ -120,7 +122,7 @@ public function query(array $oaiRequest) } // Trying to locate collection role and filter documents. - $role = Opus_CollectionRole::fetchByOaiName($setarray[0]); + $role = CollectionRole::fetchByOaiName($setarray[0]); if (is_null($role)) { $msg = "Invalid SetSpec: Top level set does not exist."; throw new Oai_Model_Exception($msg); diff --git a/modules/oai/models/Error.php b/modules/oai/models/Error.php index c3dbc696cc..febec9ad2c 100644 --- a/modules/oai/models/Error.php +++ b/modules/oai/models/Error.php @@ -29,7 +29,6 @@ * @author Thoralf Klein * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Oai_Model_Error { diff --git a/modules/oai/models/Exception.php b/modules/oai/models/Exception.php index 9714372b32..a44369a42d 100644 --- a/modules/oai/models/Exception.php +++ b/modules/oai/models/Exception.php @@ -29,7 +29,6 @@ * @author Thoralf Klein * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Oai_Model_Exception extends Exception { diff --git a/modules/oai/models/Request.php b/modules/oai/models/Request.php index 23669aa4d9..fce281724b 100644 --- a/modules/oai/models/Request.php +++ b/modules/oai/models/Request.php @@ -30,9 +30,11 @@ * @author Henning Gerhardt (henning.gerhardt@slub-dresden.de) * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Date; +use Opus\Security\Realm; + /** * TODO * @@ -145,10 +147,10 @@ class Oai_Model_Request private function checkDate(&$date) { // simple proofing - $result = Zend_Date::isDate($date, $this->_dateFormat); + $result = \Zend_Date::isDate($date, $this->_dateFormat); if (true === $result) { - $zd = new Zend_Date($date, $this->_dateFormat); + $zd = new \Zend_Date($date, $this->_dateFormat); $result = $date === $zd->get($this->_dateFormat); } @@ -194,7 +196,7 @@ private function _validateMetadataPrefix($oaiMetadataPrefix) } // only adminstrators can request copy_xml format - if (! Opus_Security_Realm::getInstance()->checkModule('admin')) { + if (! Realm::getInstance()->checkModule('admin')) { $availableMetadataPrefixes = array_diff($availableMetadataPrefixes, ['copy_xml']); } @@ -254,7 +256,7 @@ private function _validateFromUntilRange($from, $until) $result = true; - $untilDate = new Zend_Date($until, $this->_dateFormat); + $untilDate = new \Zend_Date($until, $this->_dateFormat); $isEqual = $untilDate->equals($from, $this->_dateFormat); $isLater = $untilDate->isLater($from, $this->_dateFormat); @@ -391,7 +393,7 @@ public function setResumptionPath($path) */ public function validate(array $oaiRequest) { - $logger = Zend_Registry::get('Zend_Log'); + $logger = \Zend_Registry::get('Zend_Log'); $errorInformation = [ 'message' => 'General oai request validation error.', diff --git a/modules/oai/models/ResumptionTokenException.php b/modules/oai/models/ResumptionTokenException.php index bd930717ed..70d12c17a2 100644 --- a/modules/oai/models/ResumptionTokenException.php +++ b/modules/oai/models/ResumptionTokenException.php @@ -29,8 +29,7 @@ * @author Thoralf Klein * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Oai_Model_ResumptionTokenException extends Exception +class Oai_Model_ResumptionTokenException extends \Exception { } diff --git a/modules/oai/models/Resumptiontoken.php b/modules/oai/models/Resumptiontoken.php index 51b6083e3e..a350d3d805 100644 --- a/modules/oai/models/Resumptiontoken.php +++ b/modules/oai/models/Resumptiontoken.php @@ -30,7 +30,6 @@ * @author Henning Gerhardt * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/oai/models/Resumptiontokens.php b/modules/oai/models/Resumptiontokens.php index 207e720d08..a6c6b07988 100644 --- a/modules/oai/models/Resumptiontokens.php +++ b/modules/oai/models/Resumptiontokens.php @@ -30,7 +30,6 @@ * @author Henning Gerhardt * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/oai/models/Server.php b/modules/oai/models/Server.php index 5087e0ee5a..9c8b14318b 100644 --- a/modules/oai/models/Server.php +++ b/modules/oai/models/Server.php @@ -31,27 +31,34 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Model\NotFoundException; +use Opus\Model\Xml; +use Opus\Model\Xml\Cache; +use Opus\Model\Xml\Version1; + class Oai_Model_Server extends Application_Model_Abstract { /** * Holds xml representation of document information to be processed. * - * @var DomDocument Defaults to null. + * @var \DomDocument Defaults to null. */ protected $_xml = null; /** * Holds the stylesheet for the transformation. * - * @var DomDocument Defaults to null. + * @var \DomDocument Defaults to null. */ protected $_xslt = null; /** * Holds the xslt processor. * - * @var XSLTProcessor Defaults to null. + * @var \XSLTProcessor Defaults to null. */ protected $_proc = null; @@ -96,8 +103,8 @@ public function init() { $config = $this->getConfig(); - $this->_xml = new DomDocument; - $this->_proc = new XSLTProcessor; + $this->_xml = new \DomDocument; + $this->_proc = new \XSLTProcessor; $this->_configuration = new Oai_Model_Configuration($config); $this->_xmlFactory = new Oai_Model_XmlFactory(); } @@ -123,14 +130,14 @@ public function handleRequest(array $oaiRequest, $requestUri) 'An error occured while processing the resumption token.' ); $this->getResponse()->setHttpResponseCode(500); - } catch (Exception $e) { + } catch (\Exception $e) { $this->getLogger()->err($e); $this->_proc->setParameter('', 'oai_error_code', 'unknown'); $this->_proc->setParameter('', 'oai_error_message', 'An internal error occured.'); $this->getResponse()->setHttpResponseCode(500); } - $this->_xml = new DOMDocument(); + $this->_xml = new \DOMDocument(); return $this->_proc->transformToXML($this->_xml); } @@ -149,7 +156,7 @@ protected function handleRequestIntern(array $oaiRequest, $requestUri) // Setup stylesheet $this->loadStyleSheet($this->getScriptPath() . '/oai-pmh.xslt'); - $this->_proc->registerPHPFunctions('Opus_Language::getLanguageCode'); + $this->_proc->registerPHPFunctions('Opus\Language::getLanguageCode'); Application_Xslt::registerViewHelper( $this->_proc, [ @@ -169,7 +176,7 @@ protected function handleRequestIntern(array $oaiRequest, $requestUri) $this->_proc->setParameter( '', 'dateTime', - str_replace('+00:00', 'Z', Zend_Date::now()->setTimeZone('UTC')->getIso()) + str_replace('+00:00', 'Z', \Zend_Date::now()->setTimeZone('UTC')->getIso()) ); // set OAI base url @@ -197,7 +204,7 @@ protected function handleRequestIntern(array $oaiRequest, $requestUri) } foreach ($oaiRequest as $parameter => $value) { - Zend_Registry::get('Zend_Log')->debug("'oai_' . $parameter, $value"); + \Zend_Registry::get('Zend_Log')->debug("'oai_' . $parameter, $value"); $this->_proc->setParameter('', 'oai_' . $parameter, $value); } @@ -248,8 +255,8 @@ protected function _handleGetRecord(array &$oaiRequest) $document = null; try { - $document = new Opus_Document($docId); - } catch (Opus_Model_NotFoundException $ex) { + $document = Document::get($docId); + } catch (NotFoundException $ex) { throw new Oai_Model_Exception( 'The value of the identifier argument is unknown or illegal in this repository.', Oai_Model_Error::IDDOESNOTEXIST @@ -296,11 +303,11 @@ protected function _handleIdentify() $sampleIdentifier = $this->_configuration->getSampleIdentifier(); // Set backup date if database query does not return a date. - $earliestDate = new Zend_Date('1970-01-01', Zend_Date::ISO_8601); + $earliestDate = new \Zend_Date('1970-01-01', \Zend_Date::ISO_8601); - $earliestDateFromDb = Opus_Document::getEarliestPublicationDate(); + $earliestDateFromDb = Document::getEarliestPublicationDate(); if (! is_null($earliestDateFromDb)) { - $earliestDate = new Zend_Date($earliestDateFromDb, Zend_Date::ISO_8601); + $earliestDate = new \Zend_Date($earliestDateFromDb, \Zend_Date::ISO_8601); } $earliestDateIso = $earliestDate->get('yyyy-MM-dd'); @@ -467,7 +474,7 @@ private function _handlingOfLists(array &$oaiRequest, $maxRecords) $workIds = array_splice($restIds, 0, $maxRecords); foreach ($workIds as $docId) { - $document = new Opus_Document($docId); + $document = Document::get($docId); $this->createXmlRecord($document); } @@ -510,7 +517,7 @@ private function _handlingOfLists(array &$oaiRequest, $maxRecords) */ private function setParamResumption($res, $cursor, $totalIds) { - $tomorrow = str_replace('+00:00', 'Z', Zend_Date::now()->addDay(1)->setTimeZone('UTC')->getIso()); + $tomorrow = str_replace('+00:00', 'Z', \Zend_Date::now()->addDay(1)->setTimeZone('UTC')->getIso()); $this->_proc->setParameter('', 'dateDelete', $tomorrow); $this->_proc->setParameter('', 'res', $res); $this->_proc->setParameter('', 'cursor', $cursor); @@ -520,11 +527,11 @@ private function setParamResumption($res, $cursor, $totalIds) /** * Create xml structure for one record * - * @param Opus_Document $document + * @param Document $document * @param string $metadataPrefix * @return void */ - private function createXmlRecord(Opus_Document $document) + private function createXmlRecord(Document $document) { $docId = $document->getId(); $domNode = $this->getDocumentXmlDomNode($document); @@ -601,9 +608,9 @@ private function _addSpecInformation(DOMNode $document, $information) } /** - * Add the frontdoorurl attribute to Opus_Document XML output. + * Add the frontdoorurl attribute to Document XML output. * - * @param DOMNode $document Opus_Document XML serialisation + * @param DOMNode $document Document XML serialisation * @param string $docid Id of the document * @return void */ @@ -618,9 +625,9 @@ private function _addFrontdoorUrlAttribute(DOMNode $document, $docid) } /** - * Add download link url attribute to Opus_Document XML output. + * Add download link url attribute to Document XML output. * - * @param DOMNode $document Opus_Document XML serialisation + * @param DOMNode $document Document XML serialisation * @param string $docid Id of the document * @param string $filename File path name * @return void @@ -638,7 +645,7 @@ private function _addFileUrlAttribute(DOMNode $file, $docid, $filename) /** * Add element for ddb container file. * - * @param DOMNode $document Opus_Document XML serialisation + * @param DOMNode $document Document XML serialisation * @param string $docid Document ID * @return void */ @@ -654,10 +661,10 @@ private function _addDdbTransferElement(DOMNode $document, $docid) /** * Add rights element to output. * - * @param DOMNode $domNode - * @param Opus_Document $doc + * @param \DOMNode $domNode + * @param Document $doc */ - private function _addAccessRights(DOMNode $domNode, Opus_Document $doc) + private function _addAccessRights(DOMNode $domNode, Document $doc) { $fileElement = $domNode->ownerDocument->createElement('Rights'); $fileElement->setAttribute('Value', $this->_xmlFactory->getAccessRights($doc)); @@ -677,7 +684,7 @@ private function getDocumentIdByIdentifier($oaiIdentifier) $docId = null; switch ($identifierParts[0]) { case 'urn': - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setIdentifierTypeValue('urn', $oaiIdentifier); $finder->setServerStateInList($this->_deliveringDocumentStates); $docIds = $finder->ids(); @@ -708,7 +715,7 @@ private function getDocumentIdByIdentifier($oaiIdentifier) /** * - * @param Opus_Document $document + * @param Document $document * @return DOMNode * @throws Exception */ @@ -716,15 +723,15 @@ private function getDocumentXmlDomNode($document) { if (! in_array($document->getServerState(), $this->_deliveringDocumentStates)) { $message = 'Trying to get a document in server state "' . $document->getServerState() . '"'; - Zend_Registry::get('Zend_Log')->err($message); - throw new Exception($message); + \Zend_Registry::get('Zend_Log')->err($message); + throw new \Exception($message); } - $xmlModel = new Opus_Model_Xml(); + $xmlModel = new Xml(); $xmlModel->setModel($document); $xmlModel->excludeEmptyFields(); - $xmlModel->setStrategy(new Opus_Model_Xml_Version1); - $xmlModel->setXmlCache(new Opus_Model_Xml_Cache); + $xmlModel->setStrategy(new Version1); + $xmlModel->setXmlCache(new Cache); return $xmlModel->getDomDocument()->getElementsByTagName('Opus_Document')->item(0); } @@ -747,7 +754,7 @@ private function getOaiBaseUrl() */ protected function loadStyleSheet($stylesheet) { - $this->_xslt = new DomDocument; + $this->_xslt = new \DomDocument; $this->_xslt->load($stylesheet); $this->_proc->importStyleSheet($this->_xslt); if (isset($_SERVER['HTTP_HOST'])) { diff --git a/modules/oai/models/SetSpec.php b/modules/oai/models/SetSpec.php index 15f2034e94..ceb92c9e2a 100644 --- a/modules/oai/models/SetSpec.php +++ b/modules/oai/models/SetSpec.php @@ -29,7 +29,6 @@ * @author Thoralf Klein * @copyright Copyright (c) 2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Oai_Model_SetSpec { diff --git a/modules/oai/models/Sets.php b/modules/oai/models/Sets.php index 4b87f7602f..4ea6a49c8c 100644 --- a/modules/oai/models/Sets.php +++ b/modules/oai/models/Sets.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; +use Opus\DocumentFinder; + class Oai_Model_Sets extends Application_Model_Abstract { @@ -69,7 +72,7 @@ public function getSetsForDocumentTypes() $dcTypeHelper = new Application_View_Helper_DcType(); - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setServerState('published'); foreach ($finder->groupedTypesPlusCount() as $doctype => $row) { @@ -101,7 +104,7 @@ public function getSetsForCollections() $setSpecPattern = self::SET_SPEC_PATTERN; - $oaiRolesSets = Opus_CollectionRole::fetchAllOaiEnabledRoles(); + $oaiRolesSets = CollectionRole::fetchAllOaiEnabledRoles(); foreach ($oaiRolesSets as $result) { if ($result['oai_name'] == 'doc-type') { @@ -129,7 +132,7 @@ public function getSetsForCollections() /** * Returns sets for collections of a collection role. * @param $setSpec OAI name for collection role - * @param $roleId Database ID of role + * @param $roleId int Database ID of role * @return array */ public function getSetsForCollectionRole($setSpec, $roleId) @@ -140,7 +143,7 @@ public function getSetsForCollectionRole($setSpec, $roleId) $setSpecPattern = self::SET_SPEC_PATTERN; - $role = new Opus_CollectionRole($roleId); + $role = new CollectionRole($roleId); foreach ($role->getOaiSetNames() as $subset) { $subSetSpec = "$setSpec:" . $subset['oai_subset']; // $subSetCount = $subset['count']; diff --git a/modules/oai/models/SingleFile.php b/modules/oai/models/SingleFile.php index 53570a85f3..a955e8a2d0 100644 --- a/modules/oai/models/SingleFile.php +++ b/modules/oai/models/SingleFile.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Oai_Model_SingleFile extends Oai_Model_AbstractFile diff --git a/modules/oai/models/TarFile.php b/modules/oai/models/TarFile.php index 9de5fa6bac..3fcc40decf 100644 --- a/modules/oai/models/TarFile.php +++ b/modules/oai/models/TarFile.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Oai_Model_TarFile extends Oai_Model_AbstractFile diff --git a/modules/oai/views/scripts/index/prefixes/XMetaDissPlus.xslt b/modules/oai/views/scripts/index/prefixes/XMetaDissPlus.xslt index e95508ed35..b128af4b9f 100644 --- a/modules/oai/views/scripts/index/prefixes/XMetaDissPlus.xslt +++ b/modules/oai/views/scripts/index/prefixes/XMetaDissPlus.xslt @@ -154,7 +154,7 @@ - + @@ -256,7 +256,7 @@ - + @@ -272,7 +272,7 @@ - + @@ -352,7 +352,7 @@ - + diff --git a/modules/oai/views/scripts/index/prefixes/oai_dc.xslt b/modules/oai/views/scripts/index/prefixes/oai_dc.xslt index 811914cdee..dafe75ba11 100644 --- a/modules/oai/views/scripts/index/prefixes/oai_dc.xslt +++ b/modules/oai/views/scripts/index/prefixes/oai_dc.xslt @@ -143,7 +143,7 @@ - + @@ -187,7 +187,7 @@ - + @@ -203,7 +203,7 @@ - + @@ -327,7 +327,7 @@ - + diff --git a/modules/publish/Bootstrap.php b/modules/publish/Bootstrap.php index b246a34609..f7eecc409b 100644 --- a/modules/publish/Bootstrap.php +++ b/modules/publish/Bootstrap.php @@ -29,9 +29,8 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Publish_Bootstrap extends Zend_Application_Module_Bootstrap +class Publish_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/publish/controllers/DepositController.php b/modules/publish/controllers/DepositController.php index 26bc986619..960b5256a8 100644 --- a/modules/publish/controllers/DepositController.php +++ b/modules/publish/controllers/DepositController.php @@ -30,9 +30,13 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Enrichment; +use Opus\Model\ModelException; +use Opus\Security\Realm; + class Publish_DepositController extends Application_Controller_Action { @@ -41,12 +45,12 @@ class Publish_DepositController extends Application_Controller_Action public $session; public function __construct( - Zend_Controller_Request_Abstract $request, - Zend_Controller_Response_Abstract $response, + \Zend_Controller_Request_Abstract $request, + \Zend_Controller_Response_Abstract $response, array $invokeArgs = [] ) { $this->log = $this->getLogger(); - $this->session = new Zend_Session_Namespace('Publish'); + $this->session = new \Zend_Session_Namespace('Publish'); parent::__construct($request, $response, $invokeArgs); } @@ -70,9 +74,9 @@ public function depositAction() if (array_key_exists('abort', $post)) { if (isset($this->session->documentId)) { try { - $document = new Opus_Document($this->session->documentId); + $document = Document::get($this->session->documentId); $document->deletePermanent(); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->getLogger()->err( "deletion of document # " . $this->session->documentId . " was not successful", $e @@ -171,9 +175,9 @@ public function confirmAction() } $this->view->docId = $this->session->depositConfirmDocumentId; - $accessControl = Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); + $accessControl = \Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl'); - if (true === Opus_Security_Realm::getInstance()->check('clearance') + if (true === Realm::getInstance()->check('clearance') || true === $accessControl->accessAllowed('documents')) { $this->view->showFrontdoor = true; } @@ -184,12 +188,12 @@ public function confirmAction() /** * Fügt das interne Enrichment opus.import mit dem Wert 'publish' zum Dokument hinzu. * - * @param Opus_Document $document - * @throws \Opus\Model\Exception + * @param Document $document + * @throws ModelException */ private function addSourceEnrichment($document) { - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('opus.source'); $enrichment->setValue('publish'); $document->addEnrichment($enrichment); diff --git a/modules/publish/controllers/FormController.php b/modules/publish/controllers/FormController.php index 2bb7bd62ec..5c9b39d2ae 100644 --- a/modules/publish/controllers/FormController.php +++ b/modules/publish/controllers/FormController.php @@ -30,6 +30,10 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Document; +use Opus\Model\ModelException; + class Publish_FormController extends Application_Controller_Action { @@ -46,7 +50,7 @@ class Publish_FormController extends Application_Controller_Action public function init() { - $this->session = new Zend_Session_Namespace('Publish'); + $this->session = new \Zend_Session_Namespace('Publish'); parent::init(); } @@ -99,7 +103,7 @@ public function uploadAction() $this->view->subtitle = $this->view->translate('publish_controller_index_anotherFile'); } - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (isset($config->publish->filetypes->allowed)) { $this->view->extensions = $config->publish->filetypes->allowed; @@ -217,9 +221,9 @@ public function checkAction() if (array_key_exists('abort', $postData)) { if (isset($this->session->documentId)) { try { - $document = new Opus_Document($this->session->documentId); + $document = Document::get($this->session->documentId); $document->deletePermanent(); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->getLogger()->err( "deletion of document # " . $this->session->documentId . " was not successful", $e @@ -336,7 +340,7 @@ private function _initializeDocument($postData = null) private function _storeUploadedFiles($postData) { $comment = array_key_exists('uploadComment', $postData) ? $postData['uploadComment'] : ''; - $upload = new Zend_File_Transfer_Adapter_Http(); + $upload = new \Zend_File_Transfer_Adapter_Http(); $files = $upload->getFileInfo(); $uploadCount = 0; @@ -599,7 +603,7 @@ private function _updateCollectionField($field, $value, $post) private function renderDocumenttypeForm() { - $docTypeHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); + $docTypeHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); $templateName = $docTypeHelper->getTemplateName($this->session->documentType); if (is_null($templateName)) { diff --git a/modules/publish/controllers/IndexController.php b/modules/publish/controllers/IndexController.php index de3875e3fc..1f5af1dcb3 100644 --- a/modules/publish/controllers/IndexController.php +++ b/modules/publish/controllers/IndexController.php @@ -30,7 +30,6 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_IndexController extends Application_Controller_Action { @@ -52,7 +51,7 @@ public function init() */ public function indexAction() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); //unset all possible session content $session->unsetAll(); @@ -84,7 +83,7 @@ public function indexAction() } // Quick bug fix for OPUSVIER-3564 - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); if ($translate->isTranslated('tooltip_documentType')) { $this->view->documentType['hint'] = 'tooltip_documentType'; } diff --git a/modules/publish/forms/PublishingAbstract.php b/modules/publish/forms/PublishingAbstract.php index 9f9dc2b3a0..43b6478b12 100644 --- a/modules/publish/forms/PublishingAbstract.php +++ b/modules/publish/forms/PublishingAbstract.php @@ -31,7 +31,7 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ -abstract class Publish_Form_PublishingAbstract extends Zend_Form +abstract class Publish_Form_PublishingAbstract extends \Zend_Form { protected $_config; @@ -44,9 +44,9 @@ abstract class Publish_Form_PublishingAbstract extends Zend_Form public function __construct() { - $this->_session = new Zend_Session_Namespace('Publish'); - $this->_config = Zend_Registry::get('Zend_Config'); - $this->_documentTypesHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); + $this->_session = new \Zend_Session_Namespace('Publish'); + $this->_config = \Zend_Registry::get('Zend_Config'); + $this->_documentTypesHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); $this->view = $this->getView(); parent::__construct(); } diff --git a/modules/publish/forms/PublishingFirst.php b/modules/publish/forms/PublishingFirst.php index 708c409242..eb74de95f1 100644 --- a/modules/publish/forms/PublishingFirst.php +++ b/modules/publish/forms/PublishingFirst.php @@ -110,7 +110,7 @@ public function init() // TODO can be removed? //$this->addSubmitButton('Send', 'send'); - $this->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART); + $this->setAttrib('enctype', \Zend_Form::ENCTYPE_MULTIPART); $this->setViewValues(); } @@ -119,7 +119,7 @@ public function init() * shows selection: >1 Options * shows text field: =1 Option * - * @return + * @return \Zend_Form_Element */ private function _createDocumentTypeField() { @@ -143,7 +143,7 @@ private function _createDocumentTypeField() /** * Method shows the fields for file uploads by looking in config file - * @return + * @return \Zend_Form_Element */ private function _createFileuploadField() { @@ -175,7 +175,7 @@ private function _createFileuploadField() $filenameValidator = new Application_Form_Validate_Filename($filenameOptions); //file upload field(s) - $fileupload = new Zend_Form_Element_File('fileupload'); + $fileupload = new \Zend_Form_Element_File('fileupload'); $fileupload ->setDisableTranslator(true) ->setLabel('fileupload') @@ -214,7 +214,7 @@ private function _createFileuploadField() /** * Method shows bibliography field by looking in config file - * @return + * @return \Zend_Form_Element */ private function _createBibliographyField() { diff --git a/modules/publish/forms/PublishingSecond.php b/modules/publish/forms/PublishingSecond.php index 1b31812009..0e2614d0f6 100644 --- a/modules/publish/forms/PublishingSecond.php +++ b/modules/publish/forms/PublishingSecond.php @@ -29,7 +29,6 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -58,7 +57,7 @@ public function __construct($log, $postData = null) /** * Overwritten method isValid to support extended validation - * @param $data + * @param array $data */ public function isValid($data) { @@ -136,7 +135,7 @@ public function init() */ private function getExternalElements() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $externalFields = $session->DT_externals; // No external values found! @@ -186,8 +185,8 @@ public function prepareCheck() // (d) bei Collections erfolgt die Zuordnung zum Dokument nur die unterste Collection pro Gruppe // (e) additional externals fields (from view helpers) if ($element->getValue() == "" - || $element->getType() == "Zend_Form_Element_Submit" // Submit buttons - || $element->getType() == "Zend_Form_Element_Hidden" // Hidden fields + || $element->getType() == "\Zend_Form_Element_Submit" // Submit buttons + || $element->getType() == "\Zend_Form_Element_Hidden" // Hidden fields || $element->getAttrib('isRoot') == true // Root Nodes of Browsefields || $element->getAttrib('doNotStore') == true // (*d) || (! is_null($this->_session->DT_externals)) @@ -261,8 +260,8 @@ public function setViewValues() /** * Method to find out the element name stemming. - * @param $element element name - * @return $name + * @param string $element element name + * @return string $name */ private function _getRawElementName($element) { diff --git a/modules/publish/models/Deposit.php b/modules/publish/models/Deposit.php index 03561bbeba..44a4ab54cc 100644 --- a/modules/publish/models/Deposit.php +++ b/modules/publish/models/Deposit.php @@ -30,7 +30,26 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2017, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * + */ + +use Opus\Collection; +use Opus\Date; +use Opus\DnbInstitute; +use Opus\Document; +use Opus\Enrichment; +use Opus\Identifier; +use Opus\Licence; +use Opus\Note; +use Opus\Person; +use Opus\Series; +use Opus\Subject; +use Opus\Reference; +use Opus\Title; +use Opus\Model\ModelException; +use Opus\Model\NotFoundException; +use Opus\Model\Dependent\Link\DocumentPerson; + +/** * TODO get logger from Application_Configuration if not provided */ class Publish_Model_Deposit @@ -55,8 +74,8 @@ public function storeDocument($docId, $log = null, $documentData = null) $this->_docId = $docId; try { - $this->_document = new Opus_Document($this->_docId); - } catch (Opus_Model_NotFoundException $e) { + $this->_document = Document::get($this->_docId); + } catch (NotFoundException $e) { $this->_log->err('Could not find document ' . $this->_docId . ' in database'); throw new Publish_Model_FormDocumentNotFoundException(); } @@ -157,7 +176,7 @@ private function storeInternalValue($datasetType, $dataKey, $dataValue) try { $addedValue = $this->_document->$function(); $addedValue->setValue($dataValue); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not add field $dataKey with value $dataValue to document " . $this->_docId . " : " . $e->getMessage() @@ -176,7 +195,7 @@ private function storeInternalValue($datasetType, $dataKey, $dataValue) $function = "set" . $dataKey; try { $this->_document->$function($dataValue); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not set field $dataKey with value $dataValue to document " . $this->_docId . " : " . $e->getMessage() @@ -255,7 +274,7 @@ private function getTitleType($dataKey) /** * @param String $date - * @return Opus_Date + * @return Date */ public function castStringToOpusDate($date) { @@ -278,8 +297,8 @@ private function preparePersonObject($dataKey = null, $dataValue = null) $addFunction = 'add' . $type; try { - $person = $this->_document->$addFunction(new Opus_Person()); - } catch (Opus_Model_Exception $e) { + $person = $this->_document->$addFunction(new Person()); + } catch (ModelException $e) { $this->_log->err( "could not add person of type $type to document " . $this->_docId . " : " . $e->getMessage() ); @@ -303,11 +322,11 @@ private function preparePersonObject($dataKey = null, $dataValue = null) /** * Method stores attributes like name or email for a given person object. - * @param $person - given person object - * @param $personType - type of person (editor, author etc.) - * @param $attribute - the value to store - * @param $attributeType - type of attribute (first name, email etc.) - * @param $counter - number in case of more than one person per type + * @param DocumentPerson $person - given person object + * @param string $personType - type of person (editor, author etc.) + * @param string $attribute - the value to store + * @param string $attributeType - type of attribute (first name, email etc.) + * @param int $counter - number in case of more than one person per type */ private function storePersonAttribute($person, $personType, $attribute, $attributeType, $counter) { @@ -367,7 +386,7 @@ private function prepareTitleObject($dataKey, $dataValue) $type = 'Title' . $this->getTitleType($dataKey); $this->_log->debug("Title type:" . $type); $addFunction = 'add' . $type; - $title = new Opus_Title(); + $title = new Title(); $counter = $this->getCounter($dataKey); $this->_log->debug("counter: " . $counter); @@ -375,7 +394,7 @@ private function prepareTitleObject($dataKey, $dataValue) $this->storeTitleLanguage($title, $type, 'Language', $counter); try { $this->_document->$addFunction($title); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not add title of type $type to document " . $this->_docId . " : " . $e->getMessage() ); @@ -424,11 +443,11 @@ private function getSubjectType($dataKey) /** * method to prepare a subject object for storing - * @param $this->document - * @param $formValues - * @param $dataKey current Element of formValues - * @param $externalFields - * @return $formValues + * @param Document $this->document + * @param array $formValues + * @param string $dataKey current Element of formValues + * @param array $externalFields + * @return array $formValues */ private function storeSubjectObject($dataKey, $dataValue) { @@ -437,7 +456,7 @@ private function storeSubjectObject($dataKey, $dataValue) $counter = $this->getCounter($dataKey); $this->_log->debug("counter: " . $counter); - $subject = new Opus_Subject(); + $subject = new Subject(); if ($type === 'Swd') { $subject->setLanguage('deu'); @@ -453,7 +472,7 @@ private function storeSubjectObject($dataKey, $dataValue) $subject->setType(strtolower($type)); try { $this->_document->addSubject($subject); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not add subject of type $dataKey with value $dataValue to document " . $this->_docId . " : " . $e->getMessage() @@ -468,12 +487,12 @@ private function storeSubjectObject($dataKey, $dataValue) */ private function storeNoteObject($dataValue) { - $note = new Opus_Note(); + $note = new Note(); $note->setMessage($dataValue); $note->setVisibility("private"); try { $this->_document->addNote($note); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not add note with message $dataValue to document " . $this->_docId . " : " . $e->getMessage() ); @@ -488,15 +507,15 @@ private function storeNoteObject($dataValue) private function storeCollectionObject($dataValue) { try { - $collection = new Opus_Collection($dataValue); - } catch (Opus_Model_NotFoundException $e) { + $collection = new Collection($dataValue); + } catch (NotFoundException $e) { $this->_log->err('Could not find collection #' . $dataValue . ' in database'); throw new Publish_Model_Exception(); } try { $this->_document->addCollection($collection); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not add collection #$dataValue to document " . $this->_docId . " : " . $e->getMessage() ); @@ -517,15 +536,15 @@ private function storeSeriesObject($dataKey, $dataValue) $this->_log->debug('Deposit: ' . $dataKey . ' and ' . $id . ' = ' . $seriesId); try { - $s = new Opus_Series($seriesId); - } catch (Opus_Model_Exception $e) { + $s = new Series($seriesId); + } catch (ModelException $e) { $this->_log->err('Could not find series #' . $dataValue . ' in database'); throw new Publish_Model_Exception(); } try { $this->_document->addSeries($s)->setNumber($dataValue); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not add series #$seriesId with number $dataValue to document " . $this->_docId . " : " . $e->getMessage() @@ -541,15 +560,15 @@ private function storeSeriesObject($dataKey, $dataValue) private function storeLicenceObject($dataValue) { try { - $licence = new Opus_Licence($dataValue); - } catch (Opus_Model_Exception $e) { + $licence = new Licence($dataValue); + } catch (ModelException $e) { $this->_log->err('Could not find licence #' . $dataValue . ' in database'); throw new Publish_Model_Exception(); } try { $this->_document->addLicence($licence); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not add licence #$dataValue to document " . $this->_docId . " : " . $e->getMessage() ); @@ -565,8 +584,8 @@ private function storeLicenceObject($dataValue) private function storeThesisObject($dataValue, $grantor = false) { try { - $thesis = new Opus_DnbInstitute($dataValue); - } catch (Opus_Model_Exception $e) { + $thesis = new DnbInstitute($dataValue); + } catch (ModelException $e) { $this->_log->err('Could not find DnbInstitute #' . $dataValue . ' in database'); throw new Publish_Model_Exception(); } @@ -577,7 +596,7 @@ private function storeThesisObject($dataValue, $grantor = false) } else { $this->_document->addThesisPublisher($thesis); } - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $function = ($grantor) ? 'grantor' : 'publisher'; $this->_log->err( "could not add DnbInstitute #$dataValue as $function to document " . $this->_docId . " : " @@ -589,7 +608,7 @@ private function storeThesisObject($dataValue, $grantor = false) private function storeIdentifierObject($dataKey, $dataValue) { - $identifier = new Opus_Identifier(); + $identifier = new Identifier(); $identifier->setValue($dataValue); try { if (strstr($dataKey, 'Old')) { @@ -627,7 +646,7 @@ private function storeIdentifierObject($dataKey, $dataValue) } elseif (strstr($dataKey, 'Pubmed')) { $this->_document->addIdentifierPubmed($identifier); } - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not add identifier of type $dataKey with value $dataValue to document " . $this->_docId . " : " . $e->getMessage() @@ -645,7 +664,7 @@ private function storeReferenceObject($dataKey, $dataValue) //TODO: probably no valid storing possible because a label is missing //a reference should be a new datatype with implicit fields value and label - $reference = new Opus_Reference(); + $reference = new Reference(); $reference->setValue($dataValue); $reference->setLabel("no Label given"); try { @@ -668,7 +687,7 @@ private function storeReferenceObject($dataKey, $dataValue) } elseif (strstr($dataKey, 'SplashUrl')) { $this->_document->addReferenceSplashUrl($reference); } - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not add reference of type $dataKey with value $dataValue to document " . $this->_docId . " : " . $e->getMessage() @@ -688,13 +707,13 @@ private function storeEnrichmentObject($dataKey, $dataValue) $this->_log->debug("try to store " . $dataKey . " with id: " . $dataValue); $keyName = str_replace('Enrichment', '', $dataKey); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue($dataValue); $enrichment->setKeyName($keyName); try { $this->_document->addEnrichment($enrichment); - } catch (Opus_Model_Exception $e) { + } catch (ModelException $e) { $this->_log->err( "could not add enrichment key $keyName with value $dataValue to document " . $this->_docId . " : " . $e->getMessage() diff --git a/modules/publish/models/DisplayGroup.php b/modules/publish/models/DisplayGroup.php index 3d0d8b056e..12b2285e94 100644 --- a/modules/publish/models/DisplayGroup.php +++ b/modules/publish/models/DisplayGroup.php @@ -29,9 +29,10 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Collection; + class Publish_Model_DisplayGroup { @@ -235,7 +236,7 @@ private function browseButtons() //show browseDown button only for the last select field $level = (int) count($this->collectionIds); try { - $collection = new Opus_Collection($this->collectionIds[$level - 1]); + $collection = new Collection($this->collectionIds[$level - 1]); } catch (Exception $e) { // TODO improve exception handling return null; @@ -338,7 +339,7 @@ private function collectionStep($index = null) private function collectionEntries($id, $step, $fieldset) { try { - $collection = new Opus_Collection($id); + $collection = new Collection($id); } catch (Exception $e) { // TODO: improve exception handling! return null; diff --git a/modules/publish/models/DocumentWorkflow.php b/modules/publish/models/DocumentWorkflow.php index a9b5290eff..a84bf220de 100644 --- a/modules/publish/models/DocumentWorkflow.php +++ b/modules/publish/models/DocumentWorkflow.php @@ -30,27 +30,29 @@ * @author Thoralf Klein * @copyright Copyright (c) 2011-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ + +use Opus\Document; + class Publish_Model_DocumentWorkflow { const DOCUMENT_STATE = 'temporary'; /** - * @var Opus_Document + * @var Document */ private $_document; /** * Create and initialize document object. * - * @param type $documentType - * @return Opus_Document + * @param string $documentType + * @return Document */ public function createDocument($documentType) { - $this->_document = new Opus_Document(); + $this->_document = Document::new(); $this->_document->setServerState(self::DOCUMENT_STATE) ->setType($documentType); @@ -71,8 +73,8 @@ protected function initializeDocument() /** * Load initialized document object (and check document status). * - * @param type $documentId - * @return Opus_Document + * @param int $documentId + * @return Document * @throws Publish_Model_Exception */ public function loadDocument($documentId) @@ -81,7 +83,7 @@ public function loadDocument($documentId) throw new Publish_Model_Exception('Invalid document ID given'); } - $this->_document = new Opus_Document($documentId); + $this->_document = Document::get($documentId); if ($this->_document->getServerState() !== self::DOCUMENT_STATE) { throw new Publish_Model_Exception('Document->ServerState mismatch!'); } diff --git a/modules/publish/models/DocumentWorkflowSubmitterId.php b/modules/publish/models/DocumentWorkflowSubmitterId.php index b6e74ca166..15a5b6dc34 100644 --- a/modules/publish/models/DocumentWorkflowSubmitterId.php +++ b/modules/publish/models/DocumentWorkflowSubmitterId.php @@ -30,7 +30,6 @@ * @author Thoralf Klein * @copyright Copyright (c) 2011-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_Model_DocumentWorkflowMatheon extends Publish_Model_DocumentWorkflow { @@ -46,7 +45,7 @@ protected function initializeDocument() $userId = trim($loggedUserModel->getUserId()); if (empty($userId)) { - $logger = Zend_Registry::get('Zend_Log'); + $logger = \Zend_Registry::get('Zend_Log'); $logger->debug("No user logged in. Skipping enrichment."); return; } diff --git a/modules/publish/models/DocumenttypeParser.php b/modules/publish/models/DocumenttypeParser.php index c16710cc3d..13d0d83b0d 100644 --- a/modules/publish/models/DocumenttypeParser.php +++ b/modules/publish/models/DocumenttypeParser.php @@ -32,12 +32,14 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\EnrichmentKey; + class Publish_Model_DocumenttypeParser extends Application_Model_Abstract { /** * - * @var DOMDocument + * @var \DOMDocument */ public $dom; @@ -60,15 +62,15 @@ class Publish_Model_DocumenttypeParser extends Application_Model_Abstract /** * - * @param DOMDocument $dom + * @param \DOMDocument $dom * @param Publish_Form_PublishingSecond $form * @param array $additionalFields * @param array $postValues */ public function __construct($dom, $form, $additionalFields = [], $postValues = []) { - $this->_log = Zend_Registry::get('Zend_Log'); - $this->_session = new Zend_Session_Namespace('Publish'); + $this->_log = \Zend_Registry::get('Zend_Log'); + $this->_session = new \Zend_Session_Namespace('Publish'); $this->form = $form; $this->dom = $dom; if (is_array($additionalFields)) { @@ -322,7 +324,7 @@ public function getFormElements() private function zendConformElementName($string) { - $element = new Zend_Form_Element_Text($string); + $element = new \Zend_Form_Element_Text($string); $element->setName($string); if ($element->getName() !== $string) { @@ -334,7 +336,7 @@ private function zendConformElementName($string) private function isValidEnrichmentKey($elementName) { - $enrichment = Opus_EnrichmentKey::fetchByName($elementName); + $enrichment = EnrichmentKey::fetchByName($elementName); if (is_null($enrichment)) { throw new Publish_Model_FormIncorrectEnrichmentKeyException($elementName); } diff --git a/modules/publish/models/Exception.php b/modules/publish/models/Exception.php index 136ecc9885..726f259b43 100644 --- a/modules/publish/models/Exception.php +++ b/modules/publish/models/Exception.php @@ -29,7 +29,6 @@ * @author Thoralf Klein * @copyright Copyright (c) 2011-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_Model_Exception extends Exception diff --git a/modules/publish/models/ExtendedValidation.php b/modules/publish/models/ExtendedValidation.php index ffd6168dfa..0554a855b9 100644 --- a/modules/publish/models/ExtendedValidation.php +++ b/modules/publish/models/ExtendedValidation.php @@ -33,6 +33,11 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Collection; +use Opus\DocumentFinder; +use Opus\Series; +use Opus\Model\ModelException; + class Publish_Model_ExtendedValidation { @@ -210,7 +215,7 @@ private function _validateEmailNotification() /** * Retrieves all first names from form data - * @return of first names + * @return array Of first names */ private function _getPersonFirstNameFields() { @@ -413,7 +418,7 @@ private function _validateDocumentLanguageForMainTitles() /** * Retrieves all title language fields from form data - * @return of languages + * @return array Languages */ private function _getTitleLanguageFields() { @@ -430,7 +435,7 @@ private function _getTitleLanguageFields() /** * Retrieves all title fields from form data - * @return of titles + * @return array Titles */ private function _getTitleFields() { @@ -447,7 +452,7 @@ private function _getTitleFields() /** * Retrieves all title main fields from form data - * @return of main titles + * @return array Main titles */ private function _getTitleMainFields() { @@ -465,7 +470,7 @@ private function _getTitleMainFields() /** * Retrieves all title main language fields from form data - * @return of languages + * @return array Languages */ private function _getTitleMainLanguageFields() { @@ -554,7 +559,7 @@ private function _checkLanguageElement($languageKey) /** * Retrieves all language fields from form data - * @return of languages + * @return array Languages */ private function _getSubjectFields() { @@ -634,8 +639,8 @@ public function _validateCollectionLeafSelection() if (isset($collId)) { $coll = null; try { - $coll = new Opus_Collection($collId); - } catch (Opus_Model_Exception $e) { + $coll = new Collection($collId); + } catch (ModelException $e) { $this->log->err("could not instantiate Opus_Collection with id $collId", $e); $collectionLeafSelection = false; } @@ -710,9 +715,9 @@ private function _validateSeriesNumber() $seriesId = $matches[1]; $currSeries = null; try { - $currSeries = new Opus_Series($seriesId); - } catch (Opus_Model_Exception $e) { - $this->log->err(__METHOD__ . " could not instantiate Opus_Series with id $seriesId", $e); + $currSeries = new Series($seriesId); + } catch (ModelException $e) { + $this->log->err(__METHOD__ . " could not instantiate Opus\Series with id $seriesId", $e); $validSeries = false; } @@ -789,7 +794,7 @@ private function _validateURN() } // check URN $urn for collision - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setIdentifierTypeValue('urn', $value); if ($finder->count() == 0) { return true; @@ -820,7 +825,7 @@ private function _validateDoi() return true; } - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setIdentifierTypeValue('doi', $value); if ($finder->count() == 0) { diff --git a/modules/publish/models/FormDocumentNotFoundException.php b/modules/publish/models/FormDocumentNotFoundException.php index 5d3669e7ac..2ddbad2167 100644 --- a/modules/publish/models/FormDocumentNotFoundException.php +++ b/modules/publish/models/FormDocumentNotFoundException.php @@ -30,7 +30,6 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_Model_FormDocumentNotFoundException extends Publish_Model_FormException diff --git a/modules/publish/models/FormElement.php b/modules/publish/models/FormElement.php index a5be39554e..6660bec4cc 100644 --- a/modules/publish/models/FormElement.php +++ b/modules/publish/models/FormElement.php @@ -1,5 +1,4 @@ * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ + +use Opus\CollectionRole; + class Publish_Model_FormElement { @@ -74,9 +75,9 @@ public function __construct( $datatype = null, $multiplicity = null ) { - $this->session = new Zend_Session_Namespace('Publish'); - $this->sessionOpus = new Zend_Session_Namespace(); - $this->log = Zend_Registry::get('Zend_Log'); + $this->session = new \Zend_Session_Namespace('Publish'); + $this->sessionOpus = new \Zend_Session_Namespace(); + $this->log = \Zend_Registry::get('Zend_Log'); $this->form = $form; $this->_elementName = $name; @@ -581,7 +582,7 @@ public function getCollectionRole() public function setCurrentCollectionId($setRoot = false) { if (! $setRoot) { - $collectionRole = Opus_CollectionRole::fetchByName($this->_collectionRole); + $collectionRole = CollectionRole::fetchByName($this->_collectionRole); if (! is_null($collectionRole)) { $rootCollection = $collectionRole->getRootCollection(); if (! is_null($rootCollection)) { diff --git a/modules/publish/models/FormException.php b/modules/publish/models/FormException.php index f0e0d44871..8106499b36 100644 --- a/modules/publish/models/FormException.php +++ b/modules/publish/models/FormException.php @@ -29,7 +29,6 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_Model_FormException extends Publish_Model_Exception diff --git a/modules/publish/models/FormIncorrectEnrichmentKeyException.php b/modules/publish/models/FormIncorrectEnrichmentKeyException.php index 70bda733e7..1713232999 100644 --- a/modules/publish/models/FormIncorrectEnrichmentKeyException.php +++ b/modules/publish/models/FormIncorrectEnrichmentKeyException.php @@ -30,7 +30,6 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_Model_FormIncorrectEnrichmentKeyException extends Publish_Model_FormException diff --git a/modules/publish/models/FormIncorrectFieldNameException.php b/modules/publish/models/FormIncorrectFieldNameException.php index c67ff6c1cb..9a8d1a212e 100644 --- a/modules/publish/models/FormIncorrectFieldNameException.php +++ b/modules/publish/models/FormIncorrectFieldNameException.php @@ -30,7 +30,6 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_Model_FormIncorrectFieldNameException extends Publish_Model_FormException diff --git a/modules/publish/models/FormNoButtonFoundException.php b/modules/publish/models/FormNoButtonFoundException.php index 0f2d02cefa..3cf3d94ec7 100644 --- a/modules/publish/models/FormNoButtonFoundException.php +++ b/modules/publish/models/FormNoButtonFoundException.php @@ -30,7 +30,6 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_Model_FormNoButtonFoundException extends Publish_Model_FormException diff --git a/modules/publish/models/FormSessionTimeoutException.php b/modules/publish/models/FormSessionTimeoutException.php index b0c895313a..10e3cd3678 100644 --- a/modules/publish/models/FormSessionTimeoutException.php +++ b/modules/publish/models/FormSessionTimeoutException.php @@ -30,7 +30,6 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_Model_FormSessionTimeoutException extends Publish_Model_FormException diff --git a/modules/publish/models/LoggedUser.php b/modules/publish/models/LoggedUser.php index ea90a66cbd..093a770321 100644 --- a/modules/publish/models/LoggedUser.php +++ b/modules/publish/models/LoggedUser.php @@ -30,8 +30,11 @@ * @author Thoralf Klein * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ + +use Opus\Account; +use Opus\Person; + class Publish_Model_LoggedUser { @@ -41,14 +44,14 @@ class Publish_Model_LoggedUser public function __construct() { - $this->_log = Zend_Registry::get("Zend_Log"); + $this->_log = \Zend_Registry::get('Zend_Log'); - $login = Zend_Auth::getInstance()->getIdentity(); + $login = \Zend_Auth::getInstance()->getIdentity(); if (is_null($login) or trim($login) == '') { return; } - $account = Opus_Account::fetchAccountByLogin($login); + $account = Account::fetchAccountByLogin($login); if (is_null($account) or $account->isNewRecord()) { $this->_log->err("Error checking logged user: Invalid account returned for user '$login'!"); return; @@ -59,9 +62,9 @@ public function __construct() } /** - * Get ID of Opus_Account object. Return null if no account has been found. + * Get ID of Account object. Return null if no account has been found. * - * @return Opus_Person + * @return Person */ public function getUserId() { @@ -69,10 +72,10 @@ public function getUserId() } /** - * Create Opus_Person object for currently logged user. If no account + * Create Person object for currently logged user. If no account * has been found, return NULL. * - * @return Opus_Person + * @return Person */ public function createPerson() { @@ -80,7 +83,7 @@ public function createPerson() return; } - $person = new Opus_Person(); + $person = new Person(); $person->setFirstName(trim($this->_account->getFirstName())); $person->setLastName(trim($this->_account->getLastName())); $person->setEmail(trim($this->_account->getEmail())); diff --git a/modules/publish/models/NoViewFoundException.php b/modules/publish/models/NoViewFoundException.php index 9dad22b298..36e41c4cf2 100644 --- a/modules/publish/models/NoViewFoundException.php +++ b/modules/publish/models/NoViewFoundException.php @@ -30,7 +30,6 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_Model_NoViewFoundException extends Publish_Model_Exception diff --git a/modules/publish/models/Validation.php b/modules/publish/models/Validation.php index 7bba166b39..ae07f24de5 100644 --- a/modules/publish/models/Validation.php +++ b/modules/publish/models/Validation.php @@ -31,6 +31,13 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Collection; +use Opus\CollectionRole; +use Opus\DnbInstitute; +use Opus\Licence; +use Opus\Series; + class Publish_Model_Validation { @@ -144,9 +151,9 @@ private function _validateDate() $validator->setLocale($lang); $messages = [ - Zend_Validate_Date::INVALID => $this->translate('publish_validation_error_date_invalid'), - Zend_Validate_Date::INVALID_DATE => $this->translate('publish_validation_error_date_invaliddate'), - Zend_Validate_Date::FALSEFORMAT => $this->translate('publish_validation_error_date_falseformat') + \Zend_Validate_Date::INVALID => $this->translate('publish_validation_error_date_invalid'), + \Zend_Validate_Date::INVALID_DATE => $this->translate('publish_validation_error_date_invaliddate'), + \Zend_Validate_Date::FALSEFORMAT => $this->translate('publish_validation_error_date_falseformat') ]; $validator->setMessages($messages); @@ -159,15 +166,15 @@ private function _validateEmail() $validators = []; $validator = new Publish_Model_ValidationEmail(); $messages = [ - Zend_Validate_EmailAddress::INVALID => $this->translate('publish_validation_error_email_invalid'), - Zend_Validate_EmailAddress::INVALID_FORMAT => $this->translate('publish_validation_error_email_invalid'), - Zend_Validate_EmailAddress::INVALID_HOSTNAME => $this->translate('publish_validation_error_email_invalid'), - Zend_Validate_EmailAddress::INVALID_LOCAL_PART => $this->translate('publish_validation_error_email_invalid'), - Zend_Validate_EmailAddress::INVALID_MX_RECORD => $this->translate('publish_validation_error_email_invalid'), - Zend_Validate_EmailAddress::INVALID_SEGMENT => $this->translate('publish_validation_error_email_invalid'), - Zend_Validate_EmailAddress::LENGTH_EXCEEDED => $this->translate('publish_validation_error_email_invalid'), - Zend_Validate_EmailAddress::QUOTED_STRING => $this->translate('publish_validation_error_email_invalid'), - Zend_Validate_EmailAddress::DOT_ATOM => $this->translate('publish_validation_error_email_invalid'), + \Zend_Validate_EmailAddress::INVALID => $this->translate('publish_validation_error_email_invalid'), + \Zend_Validate_EmailAddress::INVALID_FORMAT => $this->translate('publish_validation_error_email_invalid'), + \Zend_Validate_EmailAddress::INVALID_HOSTNAME => $this->translate('publish_validation_error_email_invalid'), + \Zend_Validate_EmailAddress::INVALID_LOCAL_PART => $this->translate('publish_validation_error_email_invalid'), + \Zend_Validate_EmailAddress::INVALID_MX_RECORD => $this->translate('publish_validation_error_email_invalid'), + \Zend_Validate_EmailAddress::INVALID_SEGMENT => $this->translate('publish_validation_error_email_invalid'), + \Zend_Validate_EmailAddress::LENGTH_EXCEEDED => $this->translate('publish_validation_error_email_invalid'), + \Zend_Validate_EmailAddress::QUOTED_STRING => $this->translate('publish_validation_error_email_invalid'), + \Zend_Validate_EmailAddress::DOT_ATOM => $this->translate('publish_validation_error_email_invalid'), ]; $validator->setMessages($messages); @@ -178,8 +185,8 @@ private function _validateEmail() private function _validateInteger() { $validators = []; - $validator = new Zend_Validate_Int(); - $validator->setMessage($this->translate('publish_validation_error_int'), Zend_Validate_Int::NOT_INT); + $validator = new \Zend_Validate_Int(); + $validator->setMessage($this->translate('publish_validation_error_int'), \Zend_Validate_Int::NOT_INT); $validators[] = $validator; return $validators; @@ -199,9 +206,9 @@ private function _validateLanguage() private function validateSelect($set) { - $validator = new Zend_Validate_InArray($set); + $validator = new \Zend_Validate_InArray($set); $messages = [ - Zend_Validate_InArray::NOT_IN_ARRAY => $this->translate('publish_validation_error_inarray_notinarray') + \Zend_Validate_InArray::NOT_IN_ARRAY => $this->translate('publish_validation_error_inarray_notinarray') ]; $validator->setMessages($messages); @@ -258,17 +265,17 @@ private function _validateYear() { $validators = []; - $greaterThan = new Zend_Validate_GreaterThan('0000'); + $greaterThan = new \Zend_Validate_GreaterThan('0000'); $greaterThan->setMessage( $this->translate('publish_validation_error_year_greaterthan'), - Zend_Validate_GreaterThan::NOT_GREATER + \Zend_Validate_GreaterThan::NOT_GREATER ); $validators[] = $greaterThan; - $validInt = new Zend_Validate_Int(); + $validInt = new \Zend_Validate_Int(); $messages = [ - Zend_Validate_Int::INVALID => $this->translate('publish_validation_error_year_intinvalid'), - Zend_Validate_Int::NOT_INT => $this->translate('publish_validation_error_year_notint') + \Zend_Validate_Int::INVALID => $this->translate('publish_validation_error_year_intinvalid'), + \Zend_Validate_Int::NOT_INT => $this->translate('publish_validation_error_year_notint') ]; $validInt->setMessages($messages); $validators[] = $validInt; @@ -322,7 +329,7 @@ public function selectOptions($datatype = null) private function _collectionSelect() { - $collectionRole = Opus_CollectionRole::fetchByName($this->collectionRole); + $collectionRole = CollectionRole::fetchByName($this->collectionRole); if (is_null($collectionRole) || is_null($collectionRole->getRootCollection())) { return null; } @@ -331,7 +338,7 @@ private function _collectionSelect() && $this->hasVisiblePublishChildren($collectionRole)) { $children = []; $collectionId = $collectionRole->getRootCollection()->getId(); - $collection = new Opus_Collection($collectionId); + $collection = new Collection($collectionId); $colls = $collection->getVisiblePublishChildren(); @@ -401,7 +408,7 @@ private function getLicences() { $licences = []; if (empty($this->licences)) { - foreach ($dbLicences = Opus_Licence::getAll() as $lic) { + foreach ($dbLicences = Licence::getAll() as $lic) { if ($lic->getActive() == '1') { $name = $lic->getDisplayName(); $id = $lic->getId(); @@ -423,7 +430,7 @@ private function getSeries() { $sets = []; if (empty($this->series)) { - foreach ($dbSeries = Opus_Series::getAllSortedBySortKey() as $set) { + foreach ($dbSeries = Series::getAllSortedBySortKey() as $set) { if ($set->getVisible()) { $title = $set->getTitle(); $id = $set->getId(); @@ -431,7 +438,7 @@ private function getSeries() } } - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (isset($config->browsing->series->sortByTitle) && filter_var($config->browsing->series->sortByTitle, FILTER_VALIDATE_BOOLEAN)) { @@ -459,9 +466,9 @@ private function getThesis($grantors = null) { $thesises = []; if ($grantors === true) { - $thesises = Opus_DnbInstitute::getGrantors(); + $thesises = DnbInstitute::getGrantors(); } elseif (is_null($grantors)) { - $thesises = Opus_DnbInstitute::getPublishers(); + $thesises = DnbInstitute::getPublishers(); } if (empty($thesises)) { return null; diff --git a/modules/publish/models/ValidationEmail.php b/modules/publish/models/ValidationEmail.php index a53f63305e..f83eab0a31 100644 --- a/modules/publish/models/ValidationEmail.php +++ b/modules/publish/models/ValidationEmail.php @@ -29,9 +29,8 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Publish_Model_ValidationEmail extends Zend_Validate_EmailAddress +class Publish_Model_ValidationEmail extends \Zend_Validate_EmailAddress { public function getMessages() diff --git a/modules/publish/views/helpers/BibliographieOverview.php b/modules/publish/views/helpers/BibliographieOverview.php index 3df343a561..7e64ae8389 100644 --- a/modules/publish/views/helpers/BibliographieOverview.php +++ b/modules/publish/views/helpers/BibliographieOverview.php @@ -29,9 +29,11 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Publish_View_Helper_BibliographieOverview extends Zend_View_Helper_Abstract + +use Opus\Document; + +class Publish_View_Helper_BibliographieOverview extends \Zend_View_Helper_Abstract { public $view; @@ -46,13 +48,13 @@ class Publish_View_Helper_BibliographieOverview extends Zend_View_Helper_Abstrac */ public function bibliographieOverview() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (! isset($config->form->first->bibliographie) || (! filter_var($config->form->first->bibliographie, FILTER_VALIDATE_BOOLEAN))) { return; } - $this->session = new Zend_Session_Namespace('Publish'); + $this->session = new \Zend_Session_Namespace('Publish'); $fieldsetStart = "
" . $this->view->translate('header_bibliographie') . "\n\t\t\n\t\t"; @@ -62,7 +64,7 @@ public function bibliographieOverview() return ""; } - $this->document = new Opus_Document($this->session->documentId); + $this->document = Document::get($this->session->documentId); $bib = $this->document->getBelongsToBibliography(); if (empty($bib)) { diff --git a/modules/publish/views/helpers/EndTemplate.php b/modules/publish/views/helpers/EndTemplate.php index 8e587140bf..6bd4e6ec46 100644 --- a/modules/publish/views/helpers/EndTemplate.php +++ b/modules/publish/views/helpers/EndTemplate.php @@ -30,7 +30,6 @@ * @author Doreen Thiede * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -39,7 +38,7 @@ * * @author Susanne Gottwald */ -class Publish_View_Helper_EndTemplate extends Zend_View_Helper_Abstract +class Publish_View_Helper_EndTemplate extends \Zend_View_Helper_Abstract { public function endTemplate(Publish_Form_PublishingSecond $form, $elementCounter) diff --git a/modules/publish/views/helpers/Fieldset.php b/modules/publish/views/helpers/Fieldset.php index 1097d88191..278337a2dc 100644 --- a/modules/publish/views/helpers/Fieldset.php +++ b/modules/publish/views/helpers/Fieldset.php @@ -30,10 +30,9 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Publish_View_Helper_Fieldset extends Zend_View_Helper_Abstract +class Publish_View_Helper_Fieldset extends \Zend_View_Helper_Abstract { protected $_disable = false; diff --git a/modules/publish/views/helpers/FileOverview.php b/modules/publish/views/helpers/FileOverview.php index 3a8f57c663..95a6cd4c46 100644 --- a/modules/publish/views/helpers/FileOverview.php +++ b/modules/publish/views/helpers/FileOverview.php @@ -1,5 +1,4 @@ form->first->enable_upload) || (! filter_var($config->form->first->enable_upload, FILTER_VALIDATE_BOOLEAN))) { return; } - $this->session = new Zend_Session_Namespace('Publish'); + $this->session = new \Zend_Session_Namespace('Publish'); $fieldsetStart = "
" . $this->view->translate('already_uploaded_files') . "\n\t\t\n\t\t"; @@ -63,7 +65,7 @@ public function fileOverview() return ""; } - $this->document = new Opus_Document($this->session->documentId); + $this->document = Document::get($this->session->documentId); $files = $this->document->getFile(); if (empty($files)) { diff --git a/modules/publish/views/helpers/Group.php b/modules/publish/views/helpers/Group.php index af4b1c531e..6640b5bd94 100644 --- a/modules/publish/views/helpers/Group.php +++ b/modules/publish/views/helpers/Group.php @@ -30,7 +30,6 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Publish_View_Helper_Group extends Publish_View_Helper_Fieldset diff --git a/modules/publish/views/helpers/LegalNotices.php b/modules/publish/views/helpers/LegalNotices.php index ef7e60dc9c..f2a7696253 100644 --- a/modules/publish/views/helpers/LegalNotices.php +++ b/modules/publish/views/helpers/LegalNotices.php @@ -30,9 +30,8 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Publish_View_Helper_LegalNotices extends Zend_View_Helper_Abstract +class Publish_View_Helper_LegalNotices extends \Zend_View_Helper_Abstract { public $view; @@ -44,7 +43,7 @@ class Publish_View_Helper_LegalNotices extends Zend_View_Helper_Abstract */ public function legalNotices($form) { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); if (! is_null($form->getElement('LegalNotices'))) { $fieldset = new Publish_View_Helper_Element(); diff --git a/modules/review/Bootstrap.php b/modules/review/Bootstrap.php index fce35b183b..27993f7298 100644 --- a/modules/review/Bootstrap.php +++ b/modules/review/Bootstrap.php @@ -29,12 +29,11 @@ * @author Jens Schwidder * @copyright Copyright (c) 2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Empty class seems to be necessary to setup autoloading for modules. */ -class Review_Bootstrap extends Zend_Application_Module_Bootstrap +class Review_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/review/controllers/IndexController.php b/modules/review/controllers/IndexController.php index c91b8a667c..7e6e865817 100644 --- a/modules/review/controllers/IndexController.php +++ b/modules/review/controllers/IndexController.php @@ -29,9 +29,11 @@ * @author Thoralf Klein * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\DocumentFinder; +use Opus\Security\Realm; + /** * Main entry point for the review module. * @@ -61,7 +63,7 @@ public function init() parent::init(); // Highlight menu entries. - if (true === Opus_Security_Realm::getInstance()->checkModule('admin')) { + if (true === Realm::getInstance()->checkModule('admin')) { $this->getHelper('MainMenu')->setActive('admin'); } else { $this->getHelper('MainMenu')->setActive('review'); @@ -136,7 +138,7 @@ public function indexAction() } $currentPage = $this->_getParam('page', 1); - $paginator = Zend_Paginator::factory($result); + $paginator = \Zend_Paginator::factory($result); $paginator->setCurrentPageNumber($currentPage); $paginator->setItemCountPerPage(10); @@ -242,11 +244,11 @@ public function rejectAction() /** * Prepare document finder. * - * @return Opus_DocumentFinder + * @return DocumentFinder */ protected function _prepareDocumentFinder() { - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setServerState(self::$_reviewServerState); $logger = $this->getLogger(); @@ -254,10 +256,10 @@ protected function _prepareDocumentFinder() $onlyReviewerByUserId = false; // Add constraint for reviewer, if current user is *not* admin. - if (Opus_Security_Realm::getInstance()->checkModule('admin')) { + if (Realm::getInstance()->checkModule('admin')) { $message = "Review: Showing all unpublished documents to admin"; $logger->debug($message . " (user_id: $userId)"); - } elseif (Opus_Security_Realm::getInstance()->checkModule('review')) { + } elseif (Realm::getInstance()->checkModule('review')) { if ($onlyReviewerByUserId) { $message = "Review: Showing only documents belonging to reviewer"; $finder->setEnrichmentKeyValue('reviewer.user_id', $userId); diff --git a/modules/review/models/ClearDocumentsHelper.php b/modules/review/models/ClearDocumentsHelper.php index 5e21114ae9..0d729a2c08 100644 --- a/modules/review/models/ClearDocumentsHelper.php +++ b/modules/review/models/ClearDocumentsHelper.php @@ -30,9 +30,13 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Date; +use Opus\Document; +use Opus\Person; +use Opus\UserRole; + /** * Contains code for clearing documents (switching to published state). */ @@ -44,25 +48,25 @@ class Review_Model_ClearDocumentsHelper * * @param array $docIds * @param mixed $userId - * @param Opus_Person $person + * @param Person $person * * FIXME capture success or failure for display afterwards */ public function clear(array $docIds = null, $userId = null, $person = null) { - $logger = Zend_Registry::get('Zend_Log'); + $logger = \Zend_Registry::get('Zend_Log'); foreach ($docIds as $docId) { $logger->debug('Change state to "published" for document: ' . $docId); - $document = new Opus_Document($docId); + $document = Document::get($docId); $document->setServerState('published'); - $date = new Opus_Date(); + $date = new Date(); $date->setNow(); $document->setServerDatePublished($date); $document->setPublishedDate($date); - $guestRole = Opus_UserRole::fetchByName('guest'); + $guestRole = UserRole::fetchByName('guest'); foreach ($document->getFile() as $file) { $guestRole->appendAccessFile($file->getId()); } @@ -88,17 +92,17 @@ public function clear(array $docIds = null, $userId = null, $person = null) * * @param array $docIds * @param mixed $userId - * @param Opus_Person $person + * @param Person $person * * FIXME capture success or failure for display afterwards */ public function reject(array $docIds = null, $userId = null, $person = null) { - $logger = Zend_Registry::get('Zend_Log'); + $logger = \Zend_Registry::get('Zend_Log'); foreach ($docIds as $docId) { $logger->debug('Deleting document with id: ' . $docId); - $document = new Opus_Document($docId); + $document = Document::get($docId); if (isset($person)) { $document->addPersonReferee($person); diff --git a/modules/review/views/scripts/index/index.phtml b/modules/review/views/scripts/index/index.phtml index 39edda61af..2c016a3e8a 100644 --- a/modules/review/views/scripts/index/index.phtml +++ b/modules/review/views/scripts/index/index.phtml @@ -36,7 +36,7 @@ (' . $this->documentCount . ' ' . $this->translate('review_docs_found_short') . ')' ?> -check('administrate')) : ?> +check('administrate')) : ?> navigation()->breadcrumbs()->setSuffix($suffix)->setSuffixSeparatorDisabled(true) ?> navigation()->breadcrumbs()->setReplacement($this->translate('review_index_title') . $suffix) ?> diff --git a/modules/rewrite/controllers/IndexController.php b/modules/rewrite/controllers/IndexController.php index c1510e6602..4d4c62aca4 100644 --- a/modules/rewrite/controllers/IndexController.php +++ b/modules/rewrite/controllers/IndexController.php @@ -29,9 +29,10 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\DocumentFinder; + class Rewrite_IndexController extends Application_Controller_Action { @@ -52,7 +53,7 @@ public function idAction() 'home' ); } - $f = new Opus_DocumentFinder(); + $f = new DocumentFinder(); $ids = $f->setIdentifierTypeValue($type, $value)->ids(); if (count($ids) < 1) { return $this->_helper->Redirector->redirectToAndExit( @@ -95,7 +96,7 @@ public function opus3fileAction() 'home' ); } - $f = new Opus_DocumentFinder(); + $f = new DocumentFinder(); $ids = $f->setIdentifierTypeValue('opus3-id', $docid)->ids(); if (count($ids) < 1) { return $this->_helper->Redirector->redirectToAndExit( diff --git a/modules/rss/Bootstrap.php b/modules/rss/Bootstrap.php index 60e1bebe76..9ddf896176 100644 --- a/modules/rss/Bootstrap.php +++ b/modules/rss/Bootstrap.php @@ -29,10 +29,9 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Rss_Bootstrap extends Zend_Application_Module_Bootstrap +class Rss_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/rss/controllers/IndexController.php b/modules/rss/controllers/IndexController.php index 18c1224f7e..3c4f1978d7 100644 --- a/modules/rss/controllers/IndexController.php +++ b/modules/rss/controllers/IndexController.php @@ -36,6 +36,8 @@ * TODO move feed code into Rss_Model_Feed */ +use Opus\Document; + class Rss_IndexController extends Application_Controller_Xml { @@ -138,20 +140,20 @@ private function setDates($resultList) { if ($resultList->getNumberOfHits() > 0) { $latestDoc = $resultList->getResults(); - $document = new Opus_Document($latestDoc[0]->getId()); - $date = new Zend_Date($document->getServerDatePublished()); + $document = Document::get($latestDoc[0]->getId()); + $date = new \Zend_Date($document->getServerDatePublished()); } else { - $date = Zend_Date::now(); + $date = \Zend_Date::now(); } - $this->_proc->setParameter('', 'lastBuildDate', $date->get(Zend_Date::RFC_2822)); - $this->_proc->setParameter('', 'pubDate', $date->get(Zend_Date::RFC_2822)); + $this->_proc->setParameter('', 'lastBuildDate', $date->get(\Zend_Date::RFC_2822)); + $this->_proc->setParameter('', 'pubDate', $date->get(\Zend_Date::RFC_2822)); } private function setItems($resultList) { $this->_xml->appendChild($this->_xml->createElement('Documents')); foreach ($resultList->getResults() as $result) { - $document = new Opus_Document($result->getId()); + $document = Document::get($result->getId()); $documentXml = new Application_Util_Document($document); $domNode = $this->_xml->importNode($documentXml->getNode(), true); diff --git a/modules/setup/Bootstrap.php b/modules/setup/Bootstrap.php index 24ca179f33..eaa5930d0c 100644 --- a/modules/setup/Bootstrap.php +++ b/modules/setup/Bootstrap.php @@ -34,6 +34,6 @@ /** * Empty class seems to be necessary to setup autoloading for modules. */ -class Setup_Bootstrap extends Zend_Application_Module_Bootstrap +class Setup_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/setup/controllers/LanguageController.php b/modules/setup/controllers/LanguageController.php index 616da8c349..dbec35710c 100644 --- a/modules/setup/controllers/LanguageController.php +++ b/modules/setup/controllers/LanguageController.php @@ -241,7 +241,7 @@ public function editAction() if ($form->isValid($post)) { $form->updateTranslation(); $form = null; - Zend_Registry::get('Zend_Translate')->clearCache(); // TODO encapsulate + \Zend_Registry::get('Zend_Translate')->clearCache(); // TODO encapsulate } else { // TODO go back to form } @@ -454,7 +454,7 @@ public function importAction() if ($request->isPost()) { // TODO validate form - $upload = new Zend_File_Transfer_Adapter_Http(); + $upload = new \Zend_File_Transfer_Adapter_Http(); $files = $upload->getFileInfo(); foreach ($files as $file => $fileInfo) { @@ -516,7 +516,7 @@ public function settingsAction() switch ($result) { case Admin_Form_Configuration::RESULT_SAVE: if ($form->isValid($data)) { - $config = new Zend_Config([], true); + $config = new \Zend_Config([], true); $form->updateModel($config); Application_Configuration::save($config); } else { diff --git a/modules/setup/forms/FaqItem.php b/modules/setup/forms/FaqItem.php index 42a1379653..a5d7455b9d 100644 --- a/modules/setup/forms/FaqItem.php +++ b/modules/setup/forms/FaqItem.php @@ -63,7 +63,7 @@ public function setName($name) $this->getElement(self::ELEMENT_ID)->setValue($name); $this->getElement(self::ELEMENT_NAME)->setValue($name); - $manager = Zend_Registry::get('Zend_Translate'); + $manager = \Zend_Registry::get('Zend_Translate'); $translations = $manager->getTranslations("help_title_$name"); $this->getElement(self::ELEMENT_QUESTION)->setValue($translations); @@ -79,7 +79,7 @@ public function addKey($key, $textaread = false, $customOptions = null) public function updateEntry() { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $manager = new Application_Translate_TranslationManager(); $faqId = $this->getElementValue(self::ELEMENT_ID); diff --git a/modules/setup/forms/Translation.php b/modules/setup/forms/Translation.php index ef57b65449..26a2405135 100644 --- a/modules/setup/forms/Translation.php +++ b/modules/setup/forms/Translation.php @@ -93,7 +93,7 @@ public function init() 'label' => 'setup_language_key', 'size' => 80, 'maxlength' => 100, 'required' => true ]); - $lengthValidator = new Zend_Validate_StringLength(['max' => 100]); + $lengthValidator = new \Zend_Validate_StringLength(['max' => 100]); $lengthValidator->setMessage('setup_translation_error_key_too_long', $lengthValidator::TOO_LONG); // TODO test customized message @@ -251,6 +251,6 @@ public function disableKeyEditing() */ protected function getTranslationManager() { - return Zend_Registry::get('Zend_Translate'); + return \Zend_Registry::get('Zend_Translate'); } } diff --git a/modules/setup/forms/TranslationValues.php b/modules/setup/forms/TranslationValues.php index 786ad0531a..8c7db0970a 100644 --- a/modules/setup/forms/TranslationValues.php +++ b/modules/setup/forms/TranslationValues.php @@ -35,7 +35,7 @@ /** * SubForm used for editing translations for multiple languages. */ -class Setup_Form_TranslationValues extends Zend_Form_SubForm +class Setup_Form_TranslationValues extends \Zend_Form_SubForm { public function init() @@ -49,7 +49,7 @@ public function init() [['Wrapper' => 'HtmlTag'], ['class' => 'row']] ]); - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); $languages = $this->getLanguages(); diff --git a/modules/setup/forms/Validate/TranslationKeyAvailable.php b/modules/setup/forms/Validate/TranslationKeyAvailable.php index a593a51a9b..59fd45defa 100644 --- a/modules/setup/forms/Validate/TranslationKeyAvailable.php +++ b/modules/setup/forms/Validate/TranslationKeyAvailable.php @@ -36,7 +36,7 @@ * * Translation keys are not case-sensitive. */ -class Setup_Form_Validate_TranslationKeyAvailable extends Zend_Validate_Abstract +class Setup_Form_Validate_TranslationKeyAvailable extends \Zend_Validate_Abstract { /** diff --git a/modules/setup/forms/Validate/TranslationKeyFormat.php b/modules/setup/forms/Validate/TranslationKeyFormat.php index 07e20b06c0..27721f6716 100644 --- a/modules/setup/forms/Validate/TranslationKeyFormat.php +++ b/modules/setup/forms/Validate/TranslationKeyFormat.php @@ -36,7 +36,7 @@ * * Format: character, letters and underline, starting with a character */ -class Setup_Form_Validate_TranslationKeyFormat extends Zend_Validate_Regex +class Setup_Form_Validate_TranslationKeyFormat extends \Zend_Validate_Regex { /** diff --git a/modules/setup/models/Exception.php b/modules/setup/models/Exception.php index e7ae9a871e..86decd77c0 100644 --- a/modules/setup/models/Exception.php +++ b/modules/setup/models/Exception.php @@ -30,7 +30,6 @@ * @author Edouard Simon (edouard.simon@zib.de) * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/setup/models/FileNotFoundException.php b/modules/setup/models/FileNotFoundException.php index 7332608c61..0a00cbea60 100644 --- a/modules/setup/models/FileNotFoundException.php +++ b/modules/setup/models/FileNotFoundException.php @@ -30,7 +30,6 @@ * @author Edouard Simon (edouard.simon@zib.de) * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/setup/models/FileNotReadableException.php b/modules/setup/models/FileNotReadableException.php index f7d6c8fa5f..2c130e2277 100644 --- a/modules/setup/models/FileNotReadableException.php +++ b/modules/setup/models/FileNotReadableException.php @@ -30,7 +30,6 @@ * @author Edouard Simon (edouard.simon@zib.de) * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/solrsearch/Bootstrap.php b/modules/solrsearch/Bootstrap.php index 5d7f9f659c..19381b0fc7 100644 --- a/modules/solrsearch/Bootstrap.php +++ b/modules/solrsearch/Bootstrap.php @@ -29,9 +29,8 @@ * @author Sascha Szott * @copyright Copyright (c) 2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Solrsearch_Bootstrap extends Zend_Application_Module_Bootstrap +class Solrsearch_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/solrsearch/controllers/DispatchController.php b/modules/solrsearch/controllers/DispatchController.php index 3f96269794..f429cb5582 100644 --- a/modules/solrsearch/controllers/DispatchController.php +++ b/modules/solrsearch/controllers/DispatchController.php @@ -31,7 +31,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/solrsearch/controllers/IndexController.php b/modules/solrsearch/controllers/IndexController.php index b7930d7ff8..1b3d03427f 100644 --- a/modules/solrsearch/controllers/IndexController.php +++ b/modules/solrsearch/controllers/IndexController.php @@ -34,6 +34,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Security\Realm; + /** * Main controller for solrsearch module. * @@ -172,7 +174,7 @@ public function searchAction() // TODO does the following make sense after the above? // TODO move code somewhere else (encapsulate) $config = $this->getConfig(); - if (isset($config->export->stylesheet->search) && Opus_Security_Realm::getInstance()->checkModule('export')) { + if (isset($config->export->stylesheet->search) && Realm::getInstance()->checkModule('export')) { $this->view->stylesheet = $config->export->stylesheet->search; } diff --git a/modules/solrsearch/forms/AdvancedSearch.php b/modules/solrsearch/forms/AdvancedSearch.php index e61f7d1498..c6893b8dcd 100644 --- a/modules/solrsearch/forms/AdvancedSearch.php +++ b/modules/solrsearch/forms/AdvancedSearch.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2015, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/modules/solrsearch/models/CollectionList.php b/modules/solrsearch/models/CollectionList.php index 99bb95fcc8..8b624d4754 100644 --- a/modules/solrsearch/models/CollectionList.php +++ b/modules/solrsearch/models/CollectionList.php @@ -29,9 +29,12 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Collection; +use Opus\CollectionRole; +use Opus\Model\NotFoundException; + class Solrsearch_Model_CollectionList { @@ -47,8 +50,8 @@ public function __construct($collectionId) $collection = null; try { - $collection = new Opus_Collection((int) $collectionId); - } catch (Opus_Model_NotFoundException $e) { + $collection = new Collection((int) $collectionId); + } catch (NotFoundException $e) { throw new Solrsearch_Model_Exception("Collection with id '" . $collectionId . "' does not exist.", 404); } @@ -61,8 +64,8 @@ public function __construct($collectionId) $collectionRole = null; try { - $collectionRole = new Opus_CollectionRole($collection->getRoleId()); - } catch (Opus_Model_NotFoundException $e) { + $collectionRole = new CollectionRole($collection->getRoleId()); + } catch (NotFoundException $e) { throw new Solrsearch_Model_Exception( "Collection role with id '" . $collection->getRoleId() . "' does not exist." ); @@ -118,7 +121,7 @@ public function getParents() /** * - * @return array of Opus_Collection + * @return array of Collection */ public function getChildren() { @@ -126,7 +129,7 @@ public function getChildren() if ($this->_collectionRole->getHideEmptyCollections()) { // Collection ausblenden, wenn ihr selbst und den Kind-Collections keine Dokumente zugeordnet - $children = array_filter($children, function (Opus_Collection $collection) { + $children = array_filter($children, function (Collection $collection) { return $collection->getNumSubtreeEntries() > 0; }); } diff --git a/modules/solrsearch/models/CollectionRoles.php b/modules/solrsearch/models/CollectionRoles.php index 5f889a6909..aeafb8d75f 100644 --- a/modules/solrsearch/models/CollectionRoles.php +++ b/modules/solrsearch/models/CollectionRoles.php @@ -29,9 +29,10 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\CollectionRole; + class Solrsearch_Model_CollectionRoles { @@ -39,13 +40,13 @@ class Solrsearch_Model_CollectionRoles /** * Returns visible collection roles. - * @return array of Opus_CollectionRole objects + * @return array of CollectionRole objects */ public function getAllVisible() { if (is_null($this->_collectionRoles)) { $this->_collectionRoles = []; - foreach (Opus_CollectionRole::fetchAll() as $collectionRole) { + foreach (CollectionRole::fetchAll() as $collectionRole) { if ($this->isVisible($collectionRole) && ($this->hasVisibleChildren($collectionRole) || $this->hasPublishedDocs($collectionRole))) { @@ -61,7 +62,7 @@ public function getAllVisible() * Return true if the given collection role has at least one * first-level collection that is visible. * - * @param Opus_CollectionRole $collectionRole + * @param CollectionRole $collectionRole * @return bool */ private function hasVisibleChildren($collectionRole) @@ -77,7 +78,7 @@ private function hasVisibleChildren($collectionRole) * Returns true if the given collection role has at least one associated document * in server_state published. * - * @param Opus_CollectionRole $collectionRole + * @param CollectionRole $collectionRole * @return bool */ private function hasPublishedDocs($collectionRole) @@ -92,7 +93,7 @@ private function hasPublishedDocs($collectionRole) /** * Returns true if collection role is visible in browsing. - * @param $collectionRole Opus_CollectionRole + * @param $collectionRole CollectionRole * @return bool */ private function isVisible($collectionRole) diff --git a/modules/solrsearch/models/Exception.php b/modules/solrsearch/models/Exception.php index db1ea362b4..8fa62928b7 100644 --- a/modules/solrsearch/models/Exception.php +++ b/modules/solrsearch/models/Exception.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Solrsearch_Model_Exception extends Exception { diff --git a/modules/solrsearch/models/FacetMenu.php b/modules/solrsearch/models/FacetMenu.php index 1532092990..7d948dd5b4 100644 --- a/modules/solrsearch/models/FacetMenu.php +++ b/modules/solrsearch/models/FacetMenu.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; + /** * Class Solrsearch_Model_FacetMenu * @@ -103,7 +105,7 @@ public function getFacets($result, $request) } // Hide institutes facet if collection does not exist or is hidden TODO handle somewhere else - $institutes = Opus_CollectionRole::fetchByName('institutes'); + $institutes = CollectionRole::fetchByName('institutes'); if (is_null($institutes) || ! $institutes->getVisible()) { unset($facetArray['institute']); diff --git a/modules/solrsearch/models/PaginationUtil.php b/modules/solrsearch/models/PaginationUtil.php index a1dd9fb3be..8fa05a52a5 100644 --- a/modules/solrsearch/models/PaginationUtil.php +++ b/modules/solrsearch/models/PaginationUtil.php @@ -29,7 +29,6 @@ * @author Julian Heise * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Solrsearch_Model_PaginationUtil { diff --git a/modules/solrsearch/models/Search/Collection.php b/modules/solrsearch/models/Search/Collection.php index 25e73d5ae8..8d3eafe14f 100644 --- a/modules/solrsearch/models/Search/Collection.php +++ b/modules/solrsearch/models/Search/Collection.php @@ -81,7 +81,7 @@ public function prepareChildren($request) if (! is_null($usetheme) && 1 === (int) $usetheme) { $layoutPath = APPLICATION_PATH . '/public/layouts/' . $collectionList->getTheme(); if (is_readable($layoutPath . '/common.phtml')) { - $layout = Zend_Controller_Action_HelperBroker::getStaticHelper('layout'); + $layout = \Zend_Controller_Action_HelperBroker::getStaticHelper('layout'); $layout->setLayoutPath($layoutPath); } else { $this->getLogger()->debug( diff --git a/modules/solrsearch/models/Search/Series.php b/modules/solrsearch/models/Search/Series.php index 64aa6fb5bc..1d0c3d0853 100644 --- a/modules/solrsearch/models/Search/Series.php +++ b/modules/solrsearch/models/Search/Series.php @@ -51,7 +51,7 @@ public function prepareSeries($request) $series = new Solrsearch_Model_Series($request->getParam('id')); } catch (Solrsearch_Model_Exception $sme) { $this->getLogger()->debug($sme->getMessage()); - $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); + $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->redirectToAndExit('index', '', 'browse', null, [], true); return false; } diff --git a/modules/solrsearch/models/Series.php b/modules/solrsearch/models/Series.php index 9395f88fc3..eeca75b6f4 100644 --- a/modules/solrsearch/models/Series.php +++ b/modules/solrsearch/models/Series.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Series; +use Opus\Model\NotFoundException; + class Solrsearch_Model_Series { @@ -45,8 +48,8 @@ public function __construct($seriesId) $s = null; try { - $s = new Opus_Series($seriesId); - } catch (Opus_Model_NotFoundException $e) { + $s = new Series($seriesId); + } catch (NotFoundException $e) { throw new Solrsearch_Model_Exception("Series with id '" . $seriesId . "' does not exist.", 404); } @@ -83,7 +86,7 @@ public function getLogoFilename() $logoDir = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'series_logos' . DIRECTORY_SEPARATOR . $this->_series->getId(); if (is_readable($logoDir)) { - $iterator = new DirectoryIterator($logoDir); + $iterator = new \DirectoryIterator($logoDir); foreach ($iterator as $fileinfo) { if ($fileinfo->isFile()) { return $fileinfo->getFilename(); diff --git a/modules/solrsearch/models/SeriesUtil.php b/modules/solrsearch/models/SeriesUtil.php index dcf8f8390f..a80bf7fca7 100644 --- a/modules/solrsearch/models/SeriesUtil.php +++ b/modules/solrsearch/models/SeriesUtil.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Series; + /** */ class Solrsearch_Model_SeriesUtil extends Application_Model_Abstract @@ -46,14 +48,14 @@ public function hasDisplayableSeries() } /** - * Return all non-empty visible Opus_Series objects in sorted order. + * Return all non-empty visible Series objects in sorted order. * - * @return array an array of Opus_Series objects + * @return array an array of Series objects */ public function getVisibleNonEmptySeriesSortedBySortKey() { $visibleSeries = []; - foreach (Opus_Series::getAllSortedBySortKey() as $series) { + foreach (Series::getAllSortedBySortKey() as $series) { if ($series->getVisible() == '1' && $series->getNumOfAssociatedPublishedDocuments() > 0) { array_push($visibleSeries, $series); } diff --git a/modules/solrsearch/views/scripts/index/browsecollection.phtml b/modules/solrsearch/views/scripts/index/browsecollection.phtml index 928f099f83..207035e33a 100644 --- a/modules/solrsearch/views/scripts/index/browsecollection.phtml +++ b/modules/solrsearch/views/scripts/index/browsecollection.phtml @@ -69,7 +69,7 @@

title) ?>

disableEmptyCollections = isset($config->browsing->disableEmptyCollections) && filter_var($config->browsing->disableEmptyCollections, FILTER_VALIDATE_BOOLEAN); $collRoleName = htmlspecialchars($this->collectionRole->getName(), ENT_QUOTES); diff --git a/modules/solrsearch/views/scripts/index/result.phtml b/modules/solrsearch/views/scripts/index/result.phtml index 45a064b727..ac9f11cb00 100644 --- a/modules/solrsearch/views/scripts/index/result.phtml +++ b/modules/solrsearch/views/scripts/index/result.phtml @@ -37,7 +37,7 @@ result; $document = $result->getDocument(); -$view = Zend_Registry::get('Opus_View'); // TODO it is a bad hack to access variables in parent view (fix with ZF3?) +$view = \Zend_Registry::get('Opus_View'); // TODO it is a bad hack to access variables in parent view (fix with ZF3?) $seriesId = $view->seriesId; $this->start = $view->start; $this->rows = $view->rows; diff --git a/modules/statistic/Bootstrap.php b/modules/statistic/Bootstrap.php index 5829353846..f5bfdbed2a 100644 --- a/modules/statistic/Bootstrap.php +++ b/modules/statistic/Bootstrap.php @@ -29,9 +29,8 @@ * @author Thoralf Klein * @copyright Copyright (c) 2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Statistic_Bootstrap extends Zend_Application_Module_Bootstrap +class Statistic_Bootstrap extends \Zend_Application_Module_Bootstrap { } diff --git a/modules/statistic/controllers/GraphController.php b/modules/statistic/controllers/GraphController.php index 0b4dd526fa..c22bc31f52 100644 --- a/modules/statistic/controllers/GraphController.php +++ b/modules/statistic/controllers/GraphController.php @@ -29,9 +29,10 @@ * @author Birgit Dressler (b.dressler@sulb.uni-saarland.de) * @copyright Copyright (c) 2008, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Statistic\LocalCounter; + class Statistic_GraphController extends Application_Controller_Action { @@ -58,10 +59,10 @@ public function yearAction() if (isset($id) === false) { //TODO: create own exception - throw new Exception("Parameter id must be set."); + throw new \Exception("Parameter id must be set."); } - $dataPdf = Opus_Statistic_LocalCounter::getInstance()->readYears($id); - $dataFrontdoor = Opus_Statistic_LocalCounter::getInstance()->readYears($id, 'frontdoor'); + $dataPdf = LocalCounter::getInstance()->readYears($id); + $dataFrontdoor = LocalCounter::getInstance()->readYears($id, 'frontdoor'); $years = array_merge(array_keys($dataFrontdoor), array_keys($dataPdf)); if (count($years) == 0) { $years = [date('Y')]; @@ -105,8 +106,8 @@ public function monthAction() //TODO: create own exception throw new Exception("Parameter id must be set."); } - $dataPdf = Opus_Statistic_LocalCounter::getInstance()->readMonths($id); - $dataFrontdoor = Opus_Statistic_LocalCounter::getInstance()->readMonths($id, 'frontdoor'); + $dataPdf = LocalCounter::getInstance()->readMonths($id); + $dataFrontdoor = LocalCounter::getInstance()->readMonths($id, 'frontdoor'); for ($i = 1; $i < 13; $i++) { if (isset($dataPdf[$i]) === false) { diff --git a/modules/statistic/controllers/IndexController.php b/modules/statistic/controllers/IndexController.php index f65fc678c7..ab4138184c 100644 --- a/modules/statistic/controllers/IndexController.php +++ b/modules/statistic/controllers/IndexController.php @@ -29,9 +29,11 @@ * @author Birgit Dressler (b.dressler@sulb.uni-saarland.de) * @copyright Copyright (c) 2008, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Statistic\LocalCounter; + class Statistic_IndexController extends Application_Controller_Action { @@ -44,7 +46,7 @@ class Statistic_IndexController extends Application_Controller_Action public function testAction() { $this->view->title = 'statistic'; - $counter = Opus_Statistic_LocalCounter::getInstance(); + $counter = LocalCounter::getInstance(); $form = new Test(); print_r($_POST); $form->populate($_POST); @@ -81,12 +83,12 @@ public function indexAction() } $this->view->docId = $docId; - $document = new Opus_Document($docId); + $document = Document::get($docId); $titles = $document->getTitleMain(); $authors = $document->getPersonAuthor(); - $session = new Zend_Session_Namespace(); + $session = new \Zend_Session_Namespace(); if (isset($session->language)) { $language = $session->language; @@ -107,7 +109,7 @@ public function indexAction() $this->view->authors = implode(', ', $authorsArray); //get statistics from db for total count and for image tag (accessibility) - $statistic = Opus_Statistic_LocalCounter::getInstance(); + $statistic = LocalCounter::getInstance(); $totalAbstractPage = $statistic->readTotal($docId, 'frontdoor'); $totalFiles = $statistic->readTotal($docId, 'files'); diff --git a/modules/statistic/forms/Test.php b/modules/statistic/forms/Test.php index c845261a53..c127110897 100644 --- a/modules/statistic/forms/Test.php +++ b/modules/statistic/forms/Test.php @@ -30,11 +30,10 @@ * @author Tobias Leidinger * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Statistic_Form_Test extends Zend_Form +class Statistic_Form_Test extends \Zend_Form { public $elementDecorators = [ diff --git a/modules/statistic/models/StatisticGraph.php b/modules/statistic/models/StatisticGraph.php index 812608fb34..ba1a7344a2 100644 --- a/modules/statistic/models/StatisticGraph.php +++ b/modules/statistic/models/StatisticGraph.php @@ -1,7 +1,4 @@ _width, $this->_height, "auto"); + $graph = new \Graph($this->_width, $this->_height, "auto"); $graph->SetScale("textlin"); // add shadow @@ -99,11 +95,11 @@ public function drawGraph() $graph->img->SetMargin(40, 30, 20, 40); $graph->legend->Pos(0.05, 0.05, "right", "top"); // generate bars - $bplot = new BarPlot(array_values($this->_dataPdf)); + $bplot = new \BarPlot(array_values($this->_dataPdf)); $bplot->SetLegend($this->_filesLabel); - $bplotFrontdoor = new BarPlot(array_values($this->_dataFrontdoor)); + $bplotFrontdoor = new \BarPlot(array_values($this->_dataFrontdoor)); $bplotFrontdoor->SetLegend($this->_frontdoorLabel); - $gbplot = new GroupBarPlot([$bplot ,$bplotFrontdoor]); + $gbplot = new \GroupBarPlot([$bplot ,$bplotFrontdoor]); $graph->Add($gbplot); // format bars diff --git a/modules/statistic/models/StatisticGraphThumb.php b/modules/statistic/models/StatisticGraphThumb.php index 00e903c47c..eefb96554c 100644 --- a/modules/statistic/models/StatisticGraphThumb.php +++ b/modules/statistic/models/StatisticGraphThumb.php @@ -1,7 +1,4 @@ _width, $this->_height, "auto"); + $graph = new \Graph($this->_width, $this->_height, "auto"); $graph->SetScale("textlin"); $graph->img->SetMargin(0, 0, 1, 0); //$graph->SetFrame(true); // generate bars - $bplot = new BarPlot($this->_data); + $bplot = new \BarPlot($this->_data); $graph->Add($bplot); diff --git a/modules/sword/Bootstrap.php b/modules/sword/Bootstrap.php index 879998d608..230d4d3b5b 100644 --- a/modules/sword/Bootstrap.php +++ b/modules/sword/Bootstrap.php @@ -32,7 +32,7 @@ * @copyright Copyright (c) 2016-2017 * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class Sword_Bootstrap extends Zend_Application_Module_Bootstrap +class Sword_Bootstrap extends \Zend_Application_Module_Bootstrap { protected function _initSwordModule() diff --git a/modules/sword/controllers/DepositController.php b/modules/sword/controllers/DepositController.php index a91a8f34af..f33dc2735b 100644 --- a/modules/sword/controllers/DepositController.php +++ b/modules/sword/controllers/DepositController.php @@ -33,7 +33,7 @@ * * TODO use OPUS 4 base class? */ -class Sword_DepositController extends Zend_Rest_Controller +class Sword_DepositController extends \Zend_Rest_Controller { public function init() @@ -154,7 +154,7 @@ private function maxUploadSizeExceeded($payload) $maxUploadSize = (new Application_Configuration_MaxUploadSize())->getMaxUploadSizeInByte(); if ($size > $maxUploadSize) { - $log = Zend_Registry::get('Zend_Log'); + $log = \Zend_Registry::get('Zend_Log'); $log->warn('current package size ' . $size . ' exceeds the maximum upload size ' . $maxUploadSize); return true; } @@ -183,7 +183,7 @@ private function getAdditionalEnrichments($userName, $request) private function getFullUrl() { $fullUrlHelper = new Application_View_Helper_FullUrl(); - $fullUrlHelper->setView(new Zend_View()); + $fullUrlHelper->setView(new \Zend_View()); return $fullUrlHelper->fullUrl(); } diff --git a/modules/sword/controllers/ServicedocumentController.php b/modules/sword/controllers/ServicedocumentController.php index bafb3a6d83..8c878bbccc 100644 --- a/modules/sword/controllers/ServicedocumentController.php +++ b/modules/sword/controllers/ServicedocumentController.php @@ -29,9 +29,8 @@ * @author Sascha Szott * @copyright Copyright (c) 2016 * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ -class Sword_ServicedocumentController extends Zend_Rest_Controller +class Sword_ServicedocumentController extends \Zend_Rest_Controller { public function init() @@ -75,7 +74,7 @@ private function setServiceDocument($response) $serviceDocument = new Sword_Model_ServiceDocument($fullUrl); $domDocument = $serviceDocument->getDocument(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $prettyPrinting = isset($config->prettyXml) && filter_var($config->prettyXml, FILTER_VALIDATE_BOOLEAN); if ($prettyPrinting) { $domDocument->preserveWhiteSpace = false; diff --git a/modules/sword/models/AtomEntryDocument.php b/modules/sword/models/AtomEntryDocument.php index c57ed55f0b..ee7d6b8162 100644 --- a/modules/sword/models/AtomEntryDocument.php +++ b/modules/sword/models/AtomEntryDocument.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2016 * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Sword_Model_AtomEntryDocument { @@ -56,7 +55,7 @@ public function setResponse($request, $response, $fullUrl, $userName) $this->fullUrl = $fullUrl; if (! empty($this->entries)) { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $prettyPrinting = isset($config->prettyXml) && filter_var($config->prettyXml, FILTER_VALIDATE_BOOLEAN); if ($prettyPrinting) { $dom = new DOMDocument; @@ -98,7 +97,7 @@ private function buildAtomEntryDocPart($doc, $root, $userName) private function handleSingleEntry($userName, $request) { - $root = new SimpleXMLElement(''); + $root = new \SimpleXMLElement(''); $doc = $this->entries[0]; $this->buildAtomEntryDocPart($doc, $root, $userName); $this->addSwordElements($root, $request); @@ -111,7 +110,7 @@ private function handleSingleEntry($userName, $request) */ private function handleMultipleEntries($userName, $request) { - $root = new SimpleXMLElement(''); + $root = new \SimpleXMLElement(''); foreach ($this->entries as $doc) { $entryRoot = $root->addChild('entry', null, 'http://www.w3.org/2005/Atom'); $this->buildAtomEntryDocPart($doc, $entryRoot, $userName); @@ -122,7 +121,7 @@ private function handleMultipleEntries($userName, $request) private function addSwordElements($rootElement, $request) { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $generator = $config->sword->generator; $rootElement->addChild('generator', $generator); diff --git a/modules/sword/models/ErrorDocument.php b/modules/sword/models/ErrorDocument.php index 54681b4f3a..51ee27765c 100644 --- a/modules/sword/models/ErrorDocument.php +++ b/modules/sword/models/ErrorDocument.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2016 * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Sword_Model_ErrorDocument { @@ -44,7 +43,7 @@ public function __construct($request, $response) { $this->request = $request; $this->response = $response; - $this->logger = Zend_Registry::get('Zend_Log'); + $this->logger = \Zend_Registry::get('Zend_Log'); } /** @@ -132,11 +131,11 @@ private function setResponse($statusCode, $errorCond) private function getDocument($errorCond) { - $root = new SimpleXMLElement(''); + $root = new \SimpleXMLElement(''); $root->addAttribute('href', $errorCond); $root->addChild('title', 'ERROR'); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $generator = $config->sword->generator; $root->addChild('generator', $generator); diff --git a/modules/sword/models/ImportCollection.php b/modules/sword/models/ImportCollection.php index bd1e2a8c88..a7693e903b 100644 --- a/modules/sword/models/ImportCollection.php +++ b/modules/sword/models/ImportCollection.php @@ -29,8 +29,11 @@ * @author Sascha Szott * @copyright Copyright (c) 2016 * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ + +use Opus\Collection; +use Opus\CollectionRole; + class Sword_Model_ImportCollection { @@ -40,8 +43,8 @@ class Sword_Model_ImportCollection public function __construct() { - $logger = Zend_Registry::get('Zend_Log'); - $config = Zend_Registry::get('Zend_Config'); + $logger = \Zend_Registry::get('Zend_Log'); + $config = \Zend_Registry::get('Zend_Config'); $collectionNumber = $config->sword->collection->default->number; if (trim($collectionNumber) == '') { @@ -49,13 +52,13 @@ public function __construct() return; } - $collectionRole = Opus_CollectionRole::fetchByName('Import'); + $collectionRole = CollectionRole::fetchByName('Import'); if (is_null($collectionRole)) { $logger->warn('collection role "Import" does not exist -- documents that are imported via SWORD API will not be associated to OPUS collection'); return; } - $collectionList = Opus_Collection::fetchCollectionsByRoleNumber($collectionRole->getId(), $collectionNumber); + $collectionList = Collection::fetchCollectionsByRoleNumber($collectionRole->getId(), $collectionNumber); if (empty($collectionList)) { $logger->warn('could not find collection with number ' . $collectionNumber . ' and collection role ' . $collectionRole->getId() . ' -- documents that are imported via SWORD API will not be associated to OPUS collection'); return; diff --git a/modules/sword/models/ServiceDocument.php b/modules/sword/models/ServiceDocument.php index f01d451381..90796e7b08 100644 --- a/modules/sword/models/ServiceDocument.php +++ b/modules/sword/models/ServiceDocument.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2016 * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Sword_Model_ServiceDocument { @@ -50,7 +49,7 @@ class Sword_Model_ServiceDocument public function __construct($fullUrl) { - $this->config = Zend_Registry::get('Zend_Config'); + $this->config = \Zend_Registry::get('Zend_Config'); $this->fullUrl = $fullUrl; $this->initServiceDocument(); } diff --git a/public/index.php b/public/index.php index 1a7037b301..7a6aa4b0cf 100644 --- a/public/index.php +++ b/public/index.php @@ -30,7 +30,6 @@ * @author Thoralf Klein * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // Saving start time for profiling. @@ -57,14 +56,17 @@ require_once 'autoload.php'; require_once 'opus-php-compatibility.php'; +// TODO OPUSVIER-4420 remove after switching to Laminas/ZF3 +require_once APPLICATION_PATH . '/vendor/opus4-repo/framework/library/OpusDb/Mysqlutf8.php'; + // Zend_Application -$config = new Zend_Config_Ini( +$config = new \Zend_Config_Ini( APPLICATION_PATH . '/application/configs/application.ini', APPLICATION_ENV, ['allowModifications' => true] ); -$localConfig = new Zend_Config_Ini( +$localConfig = new \Zend_Config_Ini( APPLICATION_PATH . '/application/configs/config.ini', APPLICATION_ENV, ['allowModifications' => true] @@ -74,18 +76,18 @@ // configuration file that is modified via application user interface if (is_readable(APPLICATION_PATH . '/application/configs/config.xml')) { - $onlineConfig = new Zend_Config_Xml( + $onlineConfig = new \Zend_Config_Xml( APPLICATION_PATH . '/application/configs/config.xml' ); $config->merge($onlineConfig); } // Create application, bootstrap, and run -$application = new Zend_Application(APPLICATION_ENV, $config); +$application = new \Zend_Application(APPLICATION_ENV, $config); try { $application->bootstrap()->run(); -} catch (Exception $e) { +} catch (\Exception $e) { if (APPLICATION_ENV === 'production') { header("HTTP/1.0 500 Internal Server Error"); echo 'OPUS 4' . PHP_EOL; diff --git a/public/layouts/default/common.phtml b/public/layouts/default/common.phtml index db5d2e2571..09eeb15b9f 100755 --- a/public/layouts/default/common.phtml +++ b/public/layouts/default/common.phtml @@ -33,9 +33,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -$config = Zend_Registry::get('Zend_Config'); +$config = \Zend_Registry::get('Zend_Config'); -$pageLanguage = Zend_Registry::get('Zend_Translate')->getLocale(); +$pageLanguage = \Zend_Registry::get('Zend_Translate')->getLocale(); $this->headMeta() ->prependHttpEquiv('Content-Type', 'text/html; charset=UTF-8') @@ -72,7 +72,7 @@ uncomment the following line if you want to enable your own layout changes $this->headLink()->appendStylesheet($this->layoutPath() . '/css/custom.css'); */ -$this->container = Zend_Registry::get('Opus_Navigation'); +$this->container = \Zend_Registry::get('Opus_Navigation'); $jsFiles = ['searchutil.js', 'frontdoorutil.js', 'submit.js']; @@ -256,7 +256,7 @@ if (isset($config->javascript->latex->mathjax)) { getProfiler(); +$dbprofiler = \Zend_Registry::get('db_adapter')->getProfiler(); $profiler_show_queries = isset($config->db->params->showqueries) && filter_var($config->db->params->showqueries, FILTER_VALIDATE_BOOLEAN); $profiler_max_queries = (int) $config->db->params->maxqueries; if ($dbprofiler->getEnabled() === true) : ?> diff --git a/public/layouts/opus4/common.phtml b/public/layouts/opus4/common.phtml index 55c4d897d1..0c8939a5f0 100644 --- a/public/layouts/opus4/common.phtml +++ b/public/layouts/opus4/common.phtml @@ -33,9 +33,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -$config = Zend_Registry::get('Zend_Config'); +$config = \Zend_Registry::get('Zend_Config'); -$pageLanguage = Zend_Registry::get('Zend_Translate')->getLocale(); +$pageLanguage = \Zend_Registry::get('Zend_Translate')->getLocale(); /** * Prevent indexing and following of links by web crawlers. Dynamic search pages should not be indexed, since their @@ -83,7 +83,7 @@ $this->headLink() 'href' => $this->serverUrl() . $this->baseUrl() . '/solrsearch/opensearch' ]); -$this->container = Zend_Registry::get('Opus_Navigation'); +$this->container = \Zend_Registry::get('Opus_Navigation'); $jsFiles = ['searchutil.js', 'frontdoorutil.js', 'submit.js']; diff --git a/public/layouts/opus4/debug.phtml b/public/layouts/opus4/debug.phtml index 7a6fa9c45e..66c4a1dd43 100644 --- a/public/layouts/opus4/debug.phtml +++ b/public/layouts/opus4/debug.phtml @@ -1,5 +1,5 @@ getProfiler(); +$dbprofiler = \Zend_Registry::get('db_adapter')->getProfiler(); $profiler_show_queries = isset($config->db->params->showqueries) && filter_var($config->db->params->showqueries, FILTER_VALIDATE_BOOLEAN); $profiler_max_queries = (int) $config->db->params->maxqueries; if ($dbprofiler->getEnabled() === true) : diff --git a/scripts/change-password.php b/scripts/change-password.php index 498235236d..c88f30d857 100644 --- a/scripts/change-password.php +++ b/scripts/change-password.php @@ -30,12 +30,13 @@ * @author Thoralf Klein * @copyright Copyright (c) 2009-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // Bootstrapping require_once dirname(__FILE__) . '/common/bootstrap.php'; +use Opus\Account; + $programm = array_shift($argv); if (count($argv) < 2) { echo "usage: $programm [name of existing user] [new password]\n"; @@ -46,5 +47,5 @@ $password = array_shift($argv); // Set passwort of $user to $password. -$a = new Opus_Account(null, null, $username); +$a = new Account(null, null, $username); $a->setPassword($password)->store(); diff --git a/scripts/common/bootstrap.php b/scripts/common/bootstrap.php index 862e67a94a..bd87f0c607 100644 --- a/scripts/common/bootstrap.php +++ b/scripts/common/bootstrap.php @@ -32,7 +32,6 @@ * @author Felix Ostrowski * @copyright Copyright (c) 2009-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // Configure include path. @@ -61,8 +60,11 @@ require_once 'autoload.php'; require_once 'opus-php-compatibility.php'; +// TODO OPUSVIER-4420 remove after switching to Laminas/ZF3 +require_once APPLICATION_PATH . '/vendor/opus4-repo/framework/library/OpusDb/Mysqlutf8.php'; + // environment initializiation -$application = new Zend_Application( +$application = new \Zend_Application( APPLICATION_ENV, [ "config" => [ diff --git a/scripts/common/console.php b/scripts/common/console.php index 9491314097..d6c3c4e925 100644 --- a/scripts/common/console.php +++ b/scripts/common/console.php @@ -33,16 +33,15 @@ * @author Felix Ostrowski * @copyright Copyright (c) 2009-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // TODO integrate as command in opus4 tool // TODO add exit command -$config = Zend_Registry::get('Zend_Config'); +$config = \Zend_Registry::get('Zend_Config'); if (isset($config->security) && filter_var($config->security, FILTER_VALIDATE_BOOLEAN)) { // setup realm - $realm = Opus_Security_Realm::getInstance(); + $realm = \Opus\Security\Realm::getInstance(); } while (1) { diff --git a/scripts/common/snippets.php b/scripts/common/snippets.php index ff18ec6b97..b0470ede20 100644 --- a/scripts/common/snippets.php +++ b/scripts/common/snippets.php @@ -31,7 +31,6 @@ * @author Thoralf Klein * @copyright Copyright (c) 2009-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ if (false === is_null(ini_get('register_argc_argv')) diff --git a/scripts/common/update.php b/scripts/common/update.php index ab6ece17e3..36a958c16a 100644 --- a/scripts/common/update.php +++ b/scripts/common/update.php @@ -58,8 +58,11 @@ require_once 'autoload.php'; require_once 'opus-php-compatibility.php'; +// TODO OPUSVIER-4420 remove after switching to Laminas/ZF3 +require_once APPLICATION_PATH . '/vendor/opus4-repo/framework/library/OpusDb/Mysqlutf8.php'; + // environment initializiation -$application = new Zend_Application( +$application = new \Zend_Application( APPLICATION_ENV, [ "config" => [ diff --git a/scripts/cron/cron-check-consistency.php b/scripts/cron/cron-check-consistency.php index 9d542bd542..4818294984 100644 --- a/scripts/cron/cron-check-consistency.php +++ b/scripts/cron/cron-check-consistency.php @@ -28,20 +28,22 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ define('APPLICATION_ENV', 'production'); require_once dirname(__FILE__) . '/../common/bootstrap.php'; -$jobrunner = new Opus_Job_Runner; -$jobrunner->setLogger(Zend_Registry::get('Zend_Log')); +use Opus\Job\Runner; +use Opus\Search\Task\ConsistencyCheck; + +$jobrunner = new Runner; +$jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); // no waiting between jobs $jobrunner->setDelay(0); // set a limit of 100 index jobs per run $jobrunner->setLimit(100); -$worker = new Opus\Search\Task\ConsistencyCheck(); +$worker = new ConsistencyCheck(); $jobrunner->registerWorker($worker); $jobrunner->run(); diff --git a/scripts/cron/cron-db-clean-temporary.php b/scripts/cron/cron-db-clean-temporary.php index cf600d2b7c..627c88ae5a 100644 --- a/scripts/cron/cron-db-clean-temporary.php +++ b/scripts/cron/cron-db-clean-temporary.php @@ -1,5 +1,4 @@ * @copyright Copyright (c) 2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // Bootstrapping require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\Document; +use Opus\DocumentFinder; + $date = new DateTime(); $dateString = $date->sub(new DateInterval('P2D'))->format('Y-m-d'); -$f = new Opus_DocumentFinder(); +$f = new DocumentFinder(); $f->setServerState('temporary') ->setServerDateModifiedBefore($dateString); foreach ($f->ids() as $id) { - $d = new Opus_Document($id); + $d = Document::get($id); if ($d->getServerState() == 'temporary') { echo "deleting document: $id\n"; $d->deletePermanent(); diff --git a/scripts/cron/cron-embargo-update.php b/scripts/cron/cron-embargo-update.php index c6ab8894a6..ae9500c0be 100644 --- a/scripts/cron/cron-embargo-update.php +++ b/scripts/cron/cron-embargo-update.php @@ -34,6 +34,10 @@ require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\Date; +use Opus\Document; +use Opus\DocumentFinder; + /* * This cron job must be used if embargo dates are used in repository. * @@ -48,9 +52,9 @@ * in the next harvesting ServerDateModified needs to be updated. */ -$docfinder = new Opus_DocumentFinder(); +$docfinder = new DocumentFinder(); -$now = new Opus_Date(); +$now = new Date(); $now->setNow(); // Find documents with expired EmbargoDate and ServerDateModified < EmbargoDate @@ -59,4 +63,4 @@ $foundIds = $docfinder->ids(); // Update ServerDateModified for all found documents -Opus_Document::setServerDateModifiedByIds($now, $foundIds); +Document::setServerDateModifiedByIds($now, $foundIds); diff --git a/scripts/cron/cron-import-metadata.php b/scripts/cron/cron-import-metadata.php index cb3bfd7094..3274a0a9ce 100644 --- a/scripts/cron/cron-import-metadata.php +++ b/scripts/cron/cron-import-metadata.php @@ -28,22 +28,24 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ define('APPLICATION_ENV', 'production'); require_once dirname(__FILE__) . '/../common/bootstrap.php'; -$jobrunner = new Opus_Job_Runner; -$jobrunner->setLogger(Zend_Registry::get('Zend_Log')); +use Opus\Job\Runner; +use Opus\Job\Worker\MetadataImport; + +$jobrunner = new Runner; +$jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); // no waiting between jobs $jobrunner->setDelay(0); // set a limit of 100 index jobs per run $jobrunner->setLimit(100); -$importWorker = new Opus_Job_Worker_MetadataImport(null); -$importWorker->setLogger(Zend_Registry::get('Zend_Log')); +$importWorker = new MetadataImport(null); +$importWorker->setLogger(\Zend_Registry::get('Zend_Log')); $jobrunner->registerWorker($importWorker); diff --git a/scripts/cron/cron-php-runner.sh b/scripts/cron/cron-php-runner.sh index 7bccba8c6c..3101b6ff92 100755 --- a/scripts/cron/cron-php-runner.sh +++ b/scripts/cron/cron-php-runner.sh @@ -29,9 +29,6 @@ # @author Thoralf Klein # @copyright Copyright (c) 2011, OPUS 4 development team # @license http://www.gnu.org/licenses/gpl.html General Public License -# @version $Id$ - - set -e diff --git a/scripts/cron/cron-register-local-dois.php b/scripts/cron/cron-register-local-dois.php index 92bfda0a11..7102082793 100644 --- a/scripts/cron/cron-register-local-dois.php +++ b/scripts/cron/cron-register-local-dois.php @@ -33,6 +33,8 @@ require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\Doi\DoiManager; + /* * Dieses Script sucht nach Dokumenten im ServerState 'published', * die lokale DOIs besitzen, die noch nicht bei DataCite registiert wurden. @@ -45,7 +47,7 @@ // setze auf $printErrors auf true, um Fehlermeldungen auf der Konsole auszugeben $printErrors = false; -$doiManager = new Opus_Doi_DoiManager(); +$doiManager = new DoiManager(); $status = $doiManager->registerPending(); if ($status->isNoDocsToProcess()) { diff --git a/scripts/cron/cron-send-notification.php b/scripts/cron/cron-send-notification.php index 1f5a55e7a9..df760e9e99 100644 --- a/scripts/cron/cron-send-notification.php +++ b/scripts/cron/cron-send-notification.php @@ -28,7 +28,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // Define application environment (use 'production' by default) @@ -40,15 +39,18 @@ require_once dirname(__FILE__) . '/../common/bootstrap.php'; -$jobrunner = new Opus_Job_Runner; -$jobrunner->setLogger(Zend_Registry::get('Zend_Log')); +use Opus\Job\Runner; +use Opus\Job\Worker\MailNotification; + +$jobrunner = new Runner; +$jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); // no waiting between jobs $jobrunner->setDelay(0); // set a limit of 100 index jobs per run $jobrunner->setLimit(100); -$mailWorker = new Opus_Job_Worker_MailNotification(null, false); -$mailWorker->setLogger(Zend_Registry::get('Zend_Log')); +$mailWorker = new MailNotification(null, false); +$mailWorker->setLogger(\Zend_Registry::get('Zend_Log')); $jobrunner->registerWorker($mailWorker); diff --git a/scripts/cron/cron-send-review-request.php b/scripts/cron/cron-send-review-request.php index a651d984be..3af67b046c 100644 --- a/scripts/cron/cron-send-review-request.php +++ b/scripts/cron/cron-send-review-request.php @@ -28,10 +28,8 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ - /** * * This file is not part of the main OPUS 4 distribution! @@ -47,15 +45,18 @@ require_once dirname(__FILE__) . '/../common/bootstrap.php'; -$jobrunner = new Opus_Job_Runner; -$jobrunner->setLogger(Zend_Registry::get('Zend_Log')); +use Opus\Job\Runner; +use Opus\Job\Worker\MailNotification; + +$jobrunner = new Runner; +$jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); // no waiting between jobs $jobrunner->setDelay(0); // set a limit of 100 index jobs per run $jobrunner->setLimit(100); -$mailWorker = new Opus_Job_Worker_MailNotification(); -$mailWorker->setLogger(Zend_Registry::get('Zend_Log')); +$mailWorker = new MailNotification(); +$mailWorker->setLogger(\Zend_Registry::get('Zend_Log')); $jobrunner->registerWorker($mailWorker); diff --git a/scripts/cron/cron-solr-update.php b/scripts/cron/cron-solr-update.php index 448fbb6375..0ae224d9d6 100644 --- a/scripts/cron/cron-solr-update.php +++ b/scripts/cron/cron-solr-update.php @@ -30,7 +30,6 @@ * @author Thoralf Klein * @copyright Copyright (c) 2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ define('APPLICATION_ENV', 'development'); @@ -38,8 +37,11 @@ // Bootstrapping require_once dirname(__FILE__) . '/../common/bootstrap.php'; -$jobrunner = new Opus_Job_Runner(); -$jobrunner->setLogger(Zend_Registry::get('Zend_Log')); +use Opus\Job\Runner; +use Opus\Search\Task\IndexOpusDocument; + +$jobrunner = new Runner(); +$jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); // no waiting between jobs $jobrunner->setDelay(0); @@ -47,7 +49,7 @@ // set a limit of 100 index jobs per run $jobrunner->setLimit(100); -$indexWorker = new Opus\Search\Task\IndexOpusDocument(); +$indexWorker = new IndexOpusDocument(); $jobrunner->registerWorker($indexWorker); // run processing diff --git a/scripts/cron/cron-update-document-cache.php b/scripts/cron/cron-update-document-cache.php index 06204a7592..4bda85aaf0 100644 --- a/scripts/cron/cron-update-document-cache.php +++ b/scripts/cron/cron-update-document-cache.php @@ -30,7 +30,6 @@ * @author Edouard Simon * @copyright Copyright (c) 2011-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ define('APPLICATION_ENV', 'development'); @@ -38,26 +37,33 @@ // Bootstrapping require_once dirname(__FILE__) . '/../common/bootstrap.php'; -$opusDocCacheTable = new Opus_Db_DocumentXmlCache(); -$db = Zend_Registry::get('db_adapter'); +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Db\DocumentXmlCache; +use Opus\Model\Xml; +use Opus\Model\Xml\Cache; +use Opus\Model\Xml\Version1; + +$opusDocCacheTable = new DocumentXmlCache(); +$db = \Zend_Registry::get('db_adapter'); // $select = $db->select(); $select->from($opusDocCacheTable->info('name'), 'document_id'); -$docFinder = new Opus_DocumentFinder(); +$docFinder = new DocumentFinder(); $docFinder->setSubSelectNotExists($select); $docIds = $docFinder->ids(); echo "processing ".count($docIds)." documents\n"; foreach ($docIds as $docId) { - $model = new Opus_Document($docId); + $model = Document::get($docId); - $cache = new Opus_Model_Xml_Cache; + $cache = new Cache(); // xml version 1 - $omx = new Opus_Model_Xml(); - $omx->setStrategy(new Opus_Model_Xml_Version1) + $omx = new Xml(); + $omx->setStrategy(new Version1()) ->excludeEmptyFields() ->setModel($model) ->setXmlCache($cache); diff --git a/scripts/cron/cron-verify-local-dois.php b/scripts/cron/cron-verify-local-dois.php index 20c99ccf14..e296b7a0ec 100644 --- a/scripts/cron/cron-verify-local-dois.php +++ b/scripts/cron/cron-verify-local-dois.php @@ -33,6 +33,8 @@ require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\Doi\DoiManager; + /* * Dieses Script sucht nach Dokumenten, die lokale DOIs im Status 'registered' * besitzen und verifiziert diese DOIs. Die Verifikation ist erforderlich, weil @@ -54,11 +56,11 @@ $beforeDate = null; if (! is_null($delayInHours)) { - $dateTime = new DateTime(); + $dateTime = new \DateTime(); $beforeDate = date("Y-m-d H:i:s", strtotime("- $delayInHours hours")); } -$doiManager = new Opus_Doi_DoiManager(); +$doiManager = new DoiManager(); $status = $doiManager->verifyRegisteredBefore($beforeDate); if ($status->isNoDocsToProcess()) { diff --git a/scripts/cron/cron-workspace-files-check.php b/scripts/cron/cron-workspace-files-check.php index be6e814604..ced8be3851 100644 --- a/scripts/cron/cron-workspace-files-check.php +++ b/scripts/cron/cron-workspace-files-check.php @@ -30,15 +30,17 @@ * @author Thoralf Klein * @copyright Copyright (c) 2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // Bootstrapping require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\Document; +use Opus\Model\NotFoundException; + // Get files directory... $startTime = microtime(true); -$config = Zend_Registry::get('Zend_Config'); +$config = \Zend_Registry::get('Zend_Config'); $filesPath = realpath($config->workspacePath . DIRECTORY_SEPARATOR . "files"); if ($filesPath == false or empty($filesPath)) { @@ -70,8 +72,8 @@ $id = $matches[1]; try { - $d = new Opus_Document($id); - } catch (Opus_Model_NotFoundException $e) { + $d = Document::get($id); + } catch (NotFoundException $e) { echo "ERROR: No document $id found for workspace path '$file'!\n"; $errors++; } diff --git a/scripts/import/BibtexImporter.php b/scripts/import/BibtexImporter.php index f09b9bc3a6..3ab9e039d7 100644 --- a/scripts/import/BibtexImporter.php +++ b/scripts/import/BibtexImporter.php @@ -41,6 +41,13 @@ * TODO mode for only listing newly added documents in subsequent imports */ +use Opus\Collection; +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Enrichment; +use Opus\EnrichmentKey; +use Opus\Model\ModelException; +use Opus\Model\NotFoundException; use Opus\Bibtex\Import\Parser; use Opus\Bibtex\Import\Processor\Rule\RawData; @@ -68,9 +75,9 @@ foreach ($collectionIds as $colId) { try { - $col = new Opus_Collection($colId); + $col = new Collection($colId); $collections[] = $col; - } catch (Opus_Model_NotFoundException $omnfe) { + } catch (NotFoundException $omnfe) { echo "Collection $colId not found" . PHP_EOL; } } @@ -86,9 +93,9 @@ class ImportHelper public function createEnrichmentKey($name) { - $sourceEnrichmentKey = Opus_EnrichmentKey::fetchByName($name); + $sourceEnrichmentKey = EnrichmentKey::fetchByName($name); if (is_null($sourceEnrichmentKey)) { - $sourceEnrichmentKey = new Opus_EnrichmentKey(); + $sourceEnrichmentKey = new EnrichmentKey(); $sourceEnrichmentKey->setName($name); $sourceEnrichmentKey->store(); } @@ -126,7 +133,7 @@ public function createEnrichmentKey($name) $digits = strlen(count($opus)); foreach ($opus as $docdata) { - $doc = Opus_Document::fromArray($docdata); + $doc = Document::fromArray($docdata); $enrichments = $doc->getEnrichment(); @@ -142,7 +149,7 @@ public function createEnrichmentKey($name) // Check if BibTeX entry has already been imported $alreadyImported = false; - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); if (! is_null($hash)) { $finder->setEnrichmentKeyValue(RawData::SOURCE_DATA_HASH_KEY, $hash); @@ -158,29 +165,29 @@ public function createEnrichmentKey($name) } // Add import enrichments - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('opus.import.date'); $enrichment->setValue($importDate); $doc->addEnrichment($enrichment); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('opus.import.file'); $enrichment->setValue($filename); $doc->addEnrichment($enrichment); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('opus.import.format'); $enrichment->setValue($format); $doc->addEnrichment($enrichment); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('opus.import.id'); $enrichment->setValue($importId); $doc->addEnrichment($enrichment); try { - $doc = new Opus_Document($doc->store()); - } catch (Opus_Model_Exception $ome) { + $doc = Document::get($doc->store()); + } catch (ModelException $ome) { echo $ome->getMessage(); } diff --git a/scripts/import/CSVImporter.php b/scripts/import/CSVImporter.php index b2f333c19e..cb0ae0dda3 100755 --- a/scripts/import/CSVImporter.php +++ b/scripts/import/CSVImporter.php @@ -30,7 +30,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * diff --git a/scripts/import/MetadataImporter.php b/scripts/import/MetadataImporter.php index 1ddf5fb241..e6b086b264 100755 --- a/scripts/import/MetadataImporter.php +++ b/scripts/import/MetadataImporter.php @@ -31,12 +31,13 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ require_once dirname(__FILE__) . '/../common/bootstrap.php'; require_once 'Log.php'; +use Opus\Util\MetadataImport; + class MetadataImporter { @@ -49,7 +50,7 @@ public function run($options) $consoleConf = ['lineFormat' => '[%1$s] %4$s']; $logfileConf = ['append' => false, 'lineFormat' => '%4$s']; - $this->_console = Log::factory('console', '', '', $consoleConf, PEAR_LOG_INFO); + $this->_console = \Log::factory('console', '', '', $consoleConf, PEAR_LOG_INFO); if (count($options) < 2) { $this->_console->log('Missing parameter: no file to import.'); @@ -61,11 +62,11 @@ public function run($options) // logfile path is given $logfilePath = $options[2]; } - $this->_logfile = Log::factory('file', $logfilePath, '', $logfileConf, PEAR_LOG_INFO); + $this->_logfile = \Log::factory('file', $logfilePath, '', $logfileConf, PEAR_LOG_INFO); $xmlFile = $options[1]; - $importer = new Opus_Util_MetadataImport($xmlFile, true, $this->_console, $this->_logfile); + $importer = new MetadataImport($xmlFile, true, $this->_console, $this->_logfile); $importer->run(); } } diff --git a/scripts/opus-console.php b/scripts/opus-console.php index f3aa17a103..3c8cf0be1b 100644 --- a/scripts/opus-console.php +++ b/scripts/opus-console.php @@ -32,7 +32,6 @@ * @author Felix Ostrowski * @copyright Copyright (c) 2009-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // TODO integrate, if possible, as command into opus4 script diff --git a/scripts/opus-create-export-xml.php b/scripts/opus-create-export-xml.php index dd038c885a..107e14716e 100644 --- a/scripts/opus-create-export-xml.php +++ b/scripts/opus-create-export-xml.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Model\NotFoundException; /** * Script for exporting all documents. @@ -44,7 +47,7 @@ require_once dirname(__FILE__) . '/common/bootstrap.php'; -$config = Zend_Registry::get('Zend_Config'); +$config = \Zend_Registry::get('Zend_Config'); // process options $options = getopt('o:'); @@ -83,15 +86,15 @@ $opusDocuments->formatOutput = true; $export = $opusDocuments->createElement('export'); -$docFinder = new Opus_DocumentFinder(); +$docFinder = new DocumentFinder(); // get all documents foreach ($docFinder->ids() as $id) { $doc = null; try { - $doc = new Opus_Document($id); - } catch (Opus_Model_NotFoundException $e) { + $doc = Document::get($id); + } catch (NotFoundException $e) { echo "Document with id $id does not exist." . PHP_EOL; continue; } diff --git a/scripts/opus-create-xss-document.php b/scripts/opus-create-xss-document.php index 8624b34748..d900a1721c 100644 --- a/scripts/opus-create-xss-document.php +++ b/scripts/opus-create-xss-document.php @@ -34,6 +34,14 @@ // Bootstrapping require_once dirname(__FILE__) . '/common/bootstrap.php'; +use Opus\Collection; +use Opus\CollectionRole; +use Opus\DnbInstitute; +use Opus\Document; +use Opus\Licence; +use Opus\Person; + + $counter = 1; function randString($counter) { @@ -56,7 +64,7 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) // // Creating document, filling static fields. // -$doc = new Opus_Document(); +$doc = Document::new(); $doc->setType(randString($counter++)); $doc->setServerState('published'); $doc->setServerDatePublished('01.01.1900'); @@ -82,7 +90,7 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) // // Persons // -$submitter = new Opus_Person(); +$submitter = new Person(); $submitter->getField('Email')->setValidator(null); $submitter->setFirstName(randString($counter++)) ->setLastName(randString($counter++)) @@ -92,7 +100,7 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) ->setPlaceOfBirth(randString($counter++)); $doc->addPersonSubmitter($submitter); -$author = new Opus_Person(); +$author = new Person(); $author->getField('Email')->setValidator(null); $author->setFirstName(randString($counter++)) ->setLastName(randString($counter++)) @@ -102,28 +110,28 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) ->setPlaceOfBirth(randString($counter++)); $doc->addPersonAuthor($author); -$referee = new Opus_Person(); +$referee = new Person(); $referee->setFirstName('Gyro'.randString($counter++)); $referee->setLastName('Gearloose'.randString($counter++)); $referee->setAcademicTitle('Prof. Dr.'.randString($counter++)); $doc->addPersonReferee($referee); -$editor = new Opus_Person(); +$editor = new Person(); $editor->setFirstName('Bob'.randString($counter++)); $editor->setLastName('Foster'.randString($counter++)); $doc->addPersonEditor($editor); -$advisor = new Opus_Person(); +$advisor = new Person(); $advisor->setFirstName('Fred'.randString($counter++)); $advisor->setLastName('Clever'.randString($counter++)); $doc->addPersonAdvisor($advisor); -$translator = new Opus_Person(); +$translator = new Person(); $translator->setFirstName('Erika'.randString($counter++)); $translator->setLastName('Fuchs'.randString($counter++)); $doc->addPersonTranslator($translator); -$contributor = new Opus_Person(); +$contributor = new Person(); $contributor->setFirstName('Jeff'.randString($counter++)); $contributor->setLastName('Smart'.randString($counter++)); $contributor->store(); @@ -151,7 +159,7 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) // // Collections // -$institutesRole = new Opus_CollectionRole(); +$institutesRole = new CollectionRole(); $institutesRole->setName('institutes'.randString($counter++).rand()) ->setOaiName('institutes'.randString($counter++).rand()) ->setPosition(1) @@ -164,7 +172,7 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) ->store(); $instituteName = 'Institut für empirische Forschung ' . randString($counter++); -$instituteCollections = Opus_Collection::fetchCollectionsByRoleName($institutesRole->getId(), $instituteName); +$instituteCollections = Collection::fetchCollectionsByRoleName($institutesRole->getId(), $instituteName); if (count($instituteCollections) >= 1) { $instituteCollection = $instituteCollections[0]; } else { @@ -206,7 +214,7 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) // // DnbInstitutes // -$dnbInstitute = new Opus_DnbInstitute(); +$dnbInstitute = new DnbInstitute(); $dnbInstitute->setName(randString($counter++).rand()) ->setAddress(randString($counter++)) ->setCity(randString($counter++)) @@ -262,7 +270,7 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) // // Licenses // -$lic = new Opus_Licence(); +$lic = new Licence(); $lic->setActive(1); $lic->setLanguage('deu'.randString($counter++)); $lic->setLinkLicence(randString($counter++)); diff --git a/scripts/opus-dump-document-xml.php b/scripts/opus-dump-document-xml.php index f1f1273e65..ad70b2b2bb 100644 --- a/scripts/opus-dump-document-xml.php +++ b/scripts/opus-dump-document-xml.php @@ -30,12 +30,15 @@ * @author Thoralf Klein * @copyright Copyright (c) 2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // Bootstrapping require_once dirname(__FILE__) . '/common/bootstrap.php'; +use Opus\Document; +use Opus\Model\Xml; +use Opus\Model\Xml\Version1; + // Remove first argument array_shift($argv); @@ -45,13 +48,13 @@ foreach ($argv as $docId) { error_log(""); - $d = new Opus_Document($docId); + $d = Document::get($docId); - $xmlModel = new Opus_Model_Xml(); + $xmlModel = new Xml(); $xmlModel->setModel($d); $xmlModel->excludeEmptyFields(); - $xmlModel->setStrategy(new Opus_Model_Xml_Version1); - // $xmlModel->setXmlCache(new Opus_Model_Xml_Cache); + $xmlModel->setStrategy(new Version1()); + // $xmlModel->setXmlCache(new Cache()); $docXml = $xmlModel->getDomDocument(); $docXml->formatOutput = true; diff --git a/scripts/opus-import-document-xml.php b/scripts/opus-import-document-xml.php index 5c3bda11f0..9718457ede 100644 --- a/scripts/opus-import-document-xml.php +++ b/scripts/opus-import-document-xml.php @@ -30,12 +30,13 @@ * @author Thoralf Klein * @copyright Copyright (c) 2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // Bootstrapping require_once dirname(__FILE__) . '/common/bootstrap.php'; +use Opus\Document; + // Remove first argument array_shift($argv); @@ -46,7 +47,7 @@ error_log("loading filename $filename..."); $content = file_get_contents($filename); - $doc = Opus_Document::fromXml($content); + $doc = Document::fromXml($content); $docId = $doc->store(); error_log("loading filename $filename... done. Document $docId."); } diff --git a/scripts/opus-smtp-dumpserver.php b/scripts/opus-smtp-dumpserver.php index 5c701beedf..cd6cc9e05e 100644 --- a/scripts/opus-smtp-dumpserver.php +++ b/scripts/opus-smtp-dumpserver.php @@ -30,7 +30,6 @@ * @author Felix Ostrowski * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/scripts/snippets/OPUSHOSTING-481.php b/scripts/snippets/OPUSHOSTING-481.php index 6443a104b9..11082f3fc6 100644 --- a/scripts/snippets/OPUSHOSTING-481.php +++ b/scripts/snippets/OPUSHOSTING-481.php @@ -28,9 +28,9 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\DocumentFinder; /** * Dieses Script gibt die IDs aller veröffentlichten Dokumente aus, bei denen @@ -43,7 +43,7 @@ $firstName = "Jane"; $lastName = "Doe"; -$docfinder = new Opus_DocumentFinder(); +$docfinder = new DocumentFinder(); // wichtig: müssen diesen Filter setzen, da im Index nur Dokument im Zustand published sind $docfinder->setServerState('published'); $select = $docfinder->getSelect(); diff --git a/scripts/snippets/change-doi-landing-page-url.php b/scripts/snippets/change-doi-landing-page-url.php index 1347a11c27..aad2968515 100644 --- a/scripts/snippets/change-doi-landing-page-url.php +++ b/scripts/snippets/change-doi-landing-page-url.php @@ -42,16 +42,19 @@ require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\Doi\DoiManager; +use Opus\Doi\DoiException; + $doiValue = $argv[1]; $landingPageURL = $argv[2]; echo 'Change URL of landing page of DOI ' . $doiValue . ' to ' . $landingPageURL . "\n"; -$config = Zend_Registry::get('Zend_Config'); +$config = \Zend_Registry::get('Zend_Config'); try { - $doiManager = new Opus_Doi_DoiManager(); + $doiManager = new DoiManager(); $doiManager->updateLandingPageUrlOfDoi($doiValue, $landingPageURL); echo "Operation completed successfully\n"; -} catch (Opus_Doi_DoiException $e) { +} catch (DoiException $e) { echo 'Could not successfully change landing page URL of DOI ' . $doiValue . ' : ' . $e->getMessage() . "\n"; } diff --git a/scripts/snippets/change_document_type.php b/scripts/snippets/change_document_type.php index c7551f22e3..0ab81d48e6 100644 --- a/scripts/snippets/change_document_type.php +++ b/scripts/snippets/change_document_type.php @@ -1,7 +1,4 @@ - - setType($from)->ids(); _log(count($docIds) . " documents found"); foreach ($docIds as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $doc->setType($to); if (! $dryrun) { $doc->store(); diff --git a/scripts/snippets/create_10000_documents.php b/scripts/snippets/create_10000_documents.php index 62c2315f07..96221eaa47 100644 --- a/scripts/snippets/create_10000_documents.php +++ b/scripts/snippets/create_10000_documents.php @@ -28,7 +28,6 @@ * @author Thoralf Klein * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -37,8 +36,13 @@ * TODO move as command to opus4dev tool */ +use Opus\Collection; +use Opus\Date; +use Opus\Document; +use Opus\Person; + for ($i = 1; $i < 10000; $i++) { - $d = new Opus_Document(); + $d = Document::new(); $d->setServerState('published'); $d->setType('preprint'); $d->setLanguage('deu'); @@ -47,17 +51,17 @@ $title->setLanguage('deu'); $title->setValue('title-' . rand()); - $date = new Opus_Date(); + $date = new Date(); $date->setNow(); $date->setYear(1990 + ($i % 23)); $d->setPublishedDate($date); - $p = new Opus_Person(); + $p = new Person(); $p->setFirstName("foo-" . ($i % 7)); $p->setLastName("bar-" . ($i % 5)); $p = $d->addPersonAuthor($p); - $c = new Opus_Collection(15990 + ($i % 103)); + $c = new Collection(15990 + ($i % 103)); $d->addCollection($c); $s = $d->addSubject()->setType('ddc'); diff --git a/scripts/snippets/create_all_fields_document.php b/scripts/snippets/create_all_fields_document.php index 8c5b19376f..fa9710d088 100644 --- a/scripts/snippets/create_all_fields_document.php +++ b/scripts/snippets/create_all_fields_document.php @@ -36,7 +36,15 @@ // TODO move script (is used for testing purposes) - also is probably out of date (since data model changes) -$doc = new Opus_Document(); +use Opus\Collection; +use Opus\CollectionRole; +use Opus\DnbInstitute; +use Opus\Document; +use Opus\EnrichmentKey; +use Opus\Licence; +use Opus\Person; + +$doc = Document::new(); $doc->setType('all'); $doc->setServerState('published'); $doc->setServerDatePublished('1900-01-01'); @@ -44,12 +52,12 @@ // damn API. $doc->addPersonSubmiter() doesn't work for link models! // -> we should change this in 4.x -$submitter = new Opus_Person(); +$submitter = new Person(); $submitter->setFirstName('Donald')->setLastName('Duck')->setEmail('donald@example.org')->setDateOfBirth('1920-03-13') ->setPlaceOfBirth('Entenhausen'); $doc->addPersonSubmitter($submitter); -$author = new Opus_Person(); +$author = new Person(); $author->setFirstName('Daniel')->setLastName('Düsentrieb')->setAcademicTitle('Dr.-Ing.'); $doc->addPersonAuthor($author); @@ -87,9 +95,9 @@ $doc->setIssue('18'); $instituteName = 'Institut für empirische Forschung'; -$institutesRole = Opus_CollectionRole::fetchByName('institutes'); +$institutesRole = CollectionRole::fetchByName('institutes'); if (is_null($institutesRole) === true) { - $institutesRole = new Opus_CollectionRole(); + $institutesRole = new CollectionRole(); $institutesRole->setName('institutes') ->setOaiName('institutes') ->setPosition(1) @@ -101,7 +109,7 @@ ->setVisibleOai('Name') ->store(); } -$instituteCollections = Opus_Collection::fetchCollectionsByRoleName($institutesRole->getId(), $instituteName); +$instituteCollections = Collection::fetchCollectionsByRoleName($institutesRole->getId(), $instituteName); if (count($instituteCollections) >= 1) { $instituteCollection = $instituteCollections[0]; } else { @@ -156,9 +164,9 @@ $doc->setThesisDateAccepted('2003-02-01'); -$dnbInstitute = new Opus_DnbInstitute(); +$dnbInstitute = new DnbInstitute(); $dnbInstitute->setName('Forschungsinstitut für Code Coverage'); -foreach (Opus_DnbInstitute::getGrantors() as $grantor) { +foreach (DnbInstitute::getGrantors() as $grantor) { if ($dnbInstitute->getName() === $grantor->getName()) { $dnbInstitute = $grantor; break; @@ -170,32 +178,32 @@ $doc->setThesisGrantor($dnbInstitute); $doc->setThesisPublisher($dnbInstitute); -$referee = new Opus_Person(); +$referee = new Person(); $referee->setFirstName('Gyro'); $referee->setLastName('Gearloose'); $referee->setAcademicTitle('Prof. Dr.'); $referee->store(); $doc->addPersonReferee($referee); -$editor = new Opus_Person(); +$editor = new Person(); $editor->setFirstName('Bob'); $editor->setLastName('Foster'); $editor->store(); $doc->addPersonEditor($editor); -$advisor = new Opus_Person(); +$advisor = new Person(); $advisor->setFirstName('Fred'); $advisor->setLastName('Clever'); $advisor->store(); $doc->addPersonAdvisor($advisor); -$translator = new Opus_Person(); +$translator = new Person(); $translator->setFirstName('Erika'); $translator->setLastName('Fuchs'); $translator->store(); $doc->addPersonTranslator($translator); -$contributor = new Opus_Person(); +$contributor = new Person(); $contributor->setFirstName('Jeff'); $contributor->setLastName('Smart'); $contributor->store(); @@ -220,11 +228,11 @@ $noteTwo = $doc->addNote(); $noteTwo->setVisibility('private')->setMessage('und noch eine Bemerkung zum Bearbeitungsstand.'); -$licences = Opus_Licence::getAll(); +$licences = Licence::getAll(); if (count($licences) >= 1) { $lic = $licences[0]; } else { - $lic = new Opus_Licence(); + $lic = new Licence(); $lic->setActive(1); $lic->setLanguage('deu'); $lic->setLinkLicence('http://www.test.de'); @@ -234,7 +242,7 @@ $doc->setLicence($lic); // check for enrichment keys before creating enrichments -$enrichmentKeys = Opus_EnrichmentKey::getAll(); +$enrichmentKeys = EnrichmentKey::getAll(); $enrichmentKeyNames = []; foreach ($enrichmentKeys as $enrichmentKey) { $enrichmentKeyNames[] = $enrichmentKey->getName(); @@ -245,7 +253,7 @@ ); if (! empty($missingEnrichmentKeyNames)) { foreach ($missingEnrichmentKeyNames as $missingEnrichmentKeyName) { - $newEnrichmentKey = new Opus_EnrichmentKey(); + $newEnrichmentKey = new EnrichmentKey(); $newEnrichmentKey->setName($missingEnrichmentKeyName); $newEnrichmentKey->store(); } diff --git a/scripts/snippets/create_doctype-phtml_from_xml.php b/scripts/snippets/create_doctype-phtml_from_xml.php index a56a42efbb..df99e7f891 100644 --- a/scripts/snippets/create_doctype-phtml_from_xml.php +++ b/scripts/snippets/create_doctype-phtml_from_xml.php @@ -28,7 +28,6 @@ * @author Edouard Simon * @copyright Copyright (c) 2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -49,9 +48,9 @@ echo "No file supplied"; exit; } -$xml = new DOMDocument(); +$xml = new \DOMDocument(); $xml->load($filename); -$xslt = new DomDocument; +$xslt = new \DomDocument; $xslt->load(dirname(__FILE__)."/doctype.xslt"); $proc = new XSLTProcessor; $proc->importStyleSheet($xslt); diff --git a/scripts/snippets/create_title_from_enrichment.php b/scripts/snippets/create_title_from_enrichment.php index 2bb6079474..613c640157 100644 --- a/scripts/snippets/create_title_from_enrichment.php +++ b/scripts/snippets/create_title_from_enrichment.php @@ -30,7 +30,6 @@ * @author Michael Lang (lang@zib.de) * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id: update-thesispublisher.php 11775 2013-06-25 14:28:41Z tklein $ */ /** @@ -50,6 +49,9 @@ require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\Document; +use Opus\DocumentFinder; + $options = getopt('', ['dryrun', 'type:', 'doctype:', 'enrichment:']); $dryrun = isset($options['dryrun']); @@ -82,13 +84,13 @@ _log("TEST RUN: NO DATA WILL BE MODIFIED"); } -$docFinder = new Opus_DocumentFinder(); +$docFinder = new DocumentFinder(); $docIds = $docFinder->setEnrichmentKeyExists($enrichmentField)->ids(); _log(count($docIds) . " documents found"); foreach ($docIds as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); if ($doc->getType() == $doctype || $doctype == '') { $enrichments = $doc->getEnrichment(); foreach ($enrichments as $enrichment) { diff --git a/scripts/snippets/delete_all_docs.php b/scripts/snippets/delete_all_docs.php index cb74c3ea16..653afcda37 100644 --- a/scripts/snippets/delete_all_docs.php +++ b/scripts/snippets/delete_all_docs.php @@ -28,9 +28,10 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\DocumentFinder; /** * Removes all documents @@ -39,13 +40,13 @@ * */ -$finder = new Opus_DocumentFinder(); +$finder = new DocumentFinder(); foreach ($finder->ids() as $id) { - $doc = new Opus_Document($id); + $doc = Document::get($id); $doc->deletePermanent(); echo "document " . $id . " was deleted.\n"; } -$finder = new Opus_DocumentFinder(); +$finder = new DocumentFinder(); echo "done -- num of docs: " . $finder->count() . "\n"; exit(); diff --git a/scripts/snippets/delete_files.php b/scripts/snippets/delete_files.php index 58de45d706..1595e017c8 100644 --- a/scripts/snippets/delete_files.php +++ b/scripts/snippets/delete_files.php @@ -28,12 +28,13 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Model\NotFoundException; /** - * Removes associated Opus_File objects for all HHAR test documents (id = 1..90) + * Removes associated File objects for all HHAR test documents (id = 1..90) * since full text files do not exist in file system * * TODO move script (it is used for testing/development) @@ -45,8 +46,8 @@ for ($i = $startId; $i <= $endId; $i++) { $d = null; try { - $d = new Opus_Document($i); - } catch (Opus_Model_NotFoundException $e) { + $d = Document::get($i); + } catch (NotFoundException $e) { // document with id $i does not exist continue; } diff --git a/scripts/snippets/delete_non-demo_docs.php b/scripts/snippets/delete_non-demo_docs.php index 6fb65a1303..00557921cf 100644 --- a/scripts/snippets/delete_non-demo_docs.php +++ b/scripts/snippets/delete_non-demo_docs.php @@ -28,9 +28,10 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\DocumentFinder; /** * Erstellt die Demoinstanz, in der nur die Testdokumente mit den IDs 91 bis 110 @@ -39,15 +40,15 @@ * TODO move script (it is used for demo instance) */ -$finder = new Opus_DocumentFinder(); +$finder = new DocumentFinder(); foreach ($finder->ids() as $id) { if (intval($id) < 91 || intval($id) > 110) { - $doc = new Opus_Document($id); + $doc = Document::get($id); $doc->deletePermanent(); echo "document " . $id . " was deleted.\n"; } } -$finder = new Opus_DocumentFinder(); +$finder = new DocumentFinder(); echo "done -- num of remaining docs: " . $finder->count() . "\n"; exit(); diff --git a/scripts/snippets/export_document.php b/scripts/snippets/export_document.php index f2e88affce..7508c2c42c 100644 --- a/scripts/snippets/export_document.php +++ b/scripts/snippets/export_document.php @@ -28,9 +28,12 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Model\NotFoundException; +use Opus\Model\Xml; +use Opus\Model\Xml\Version1; /** * Returns the XML representation of the document with given id $id. @@ -45,15 +48,15 @@ } try { - $doc = new Opus_Document($id); -} catch (Opus_Model_NotFoundException $e) { + $doc = Document::get($id); +} catch (NotFoundException $e) { echo "document with id $id does not exist"; exit(); } -$xmlModel = new Opus_Model_Xml(); +$xmlModel = new Xml(); $xmlModel->setModel($doc); -$xmlModel->setStrategy(new Opus_Model_Xml_Version1()); +$xmlModel->setStrategy(new Version1()); $xmlModel->excludeEmptyFields(); echo $xmlModel->getDomDocument()->saveXML(); diff --git a/scripts/snippets/export_import_all_docs.php b/scripts/snippets/export_import_all_docs.php index f1d174cdec..284ec81c5a 100644 --- a/scripts/snippets/export_import_all_docs.php +++ b/scripts/snippets/export_import_all_docs.php @@ -28,38 +28,43 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Model\NotFoundException; +use Opus\Model\Xml; +use Opus\Model\Xml\Version1; + /** * Tries to export and import all documents. * * TODO move (this is a test script) */ -$docFinder = new Opus_DocumentFinder(); +$docFinder = new DocumentFinder(); foreach ($docFinder->ids() as $id) { $doc = null; try { - $doc = new Opus_Document($id); - } catch (Opus_Model_NotFoundException $e) { + $doc = Document::get($id); + } catch (NotFoundException $e) { // document with id $id does not exist continue; } echo "try to export document $id ... "; - $xmlModelOutput = new Opus_Model_Xml(); + $xmlModelOutput = new Xml(); $xmlModelOutput->setModel($doc); - $xmlModelOutput->setStrategy(new Opus_Model_Xml_Version1()); + $xmlModelOutput->setStrategy(new Version1()); $xmlModelOutput->excludeEmptyFields(); $domDocument = $xmlModelOutput->getDomDocument(); echo "export of document $id was successful.\n"; echo "try to import document based on the exported dom tree ... "; - $xmlModelImport = new Opus_Model_Xml(); - $xmlModelImport->setStrategy(new Opus_Model_Xml_Version1()); + $xmlModelImport = new Xml(); + $xmlModelImport->setStrategy(new Version1()); $xmlModelImport->setXml($domDocument->saveXML()); try { $doc = $xmlModelImport->getModel(); diff --git a/scripts/snippets/find_docs_with_multiple_titles_or_abstracts.php b/scripts/snippets/find_docs_with_multiple_titles_or_abstracts.php index cb90f8cbd2..369ededef5 100644 --- a/scripts/snippets/find_docs_with_multiple_titles_or_abstracts.php +++ b/scripts/snippets/find_docs_with_multiple_titles_or_abstracts.php @@ -28,9 +28,10 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\DocumentFinder; /** * @@ -45,9 +46,9 @@ $updateRequired = 0; -$docfinder = new Opus_DocumentFinder(); +$docfinder = new DocumentFinder(); foreach ($docfinder->ids() as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $numOfTitles = 0; foreach ($doc->getTitleMain() as $title) { diff --git a/scripts/snippets/find_docs_without_titles_in_doclanguage.php b/scripts/snippets/find_docs_without_titles_in_doclanguage.php index 8b85057c54..826a2433cb 100644 --- a/scripts/snippets/find_docs_without_titles_in_doclanguage.php +++ b/scripts/snippets/find_docs_without_titles_in_doclanguage.php @@ -28,7 +28,6 @@ * @author Doreen Thiede * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** * Dieses Skript gibt alle IDs der Dokumente zurück, die keinen Titel @@ -39,10 +38,12 @@ * TODO integrity check (where to put it?) - should be part of problem analysis package */ +use Opus\Document; + $updateRequired = 0; -$docfinder = new Opus_DocumentFinder(); +$docfinder = new \Opus\DocumentFinder(); foreach ($docfinder->ids() as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); foreach ($doc->getTitleMain() as $title) { $titleLanguage = $title->getLanguage(); diff --git a/scripts/snippets/find_missing_published_docs_in_searchindex.php b/scripts/snippets/find_missing_published_docs_in_searchindex.php index 1875b4624f..e5a01d19c3 100644 --- a/scripts/snippets/find_missing_published_docs_in_searchindex.php +++ b/scripts/snippets/find_missing_published_docs_in_searchindex.php @@ -28,9 +28,12 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\DocumentFinder; +use Opus\Search\Service; +use Opus\Search\QueryFactory; + /** * * Dieses Skript gibt alle IDs der Dokumente zurück, die im Server State @@ -42,12 +45,12 @@ */ $numOfErrors = 0; -$finder = new Opus_DocumentFinder(); +$finder = new DocumentFinder(); $finder->setServerState('published'); foreach ($finder->ids() as $docId) { // check if document with id $docId is already persisted in search index - $search = Opus\Search\Service::selectSearchingService(); - $query = Opus\Search\QueryFactory::selectDocumentById($search, $docId); + $search = Service::selectSearchingService(); + $query = QueryFactory::selectDocumentById($search, $docId); if ($search->customSearch($query)->getAllMatchesCount() != 1) { echo "document # $docId is not stored in search index\n"; diff --git a/scripts/snippets/find_modified_docs_in_searchindex.php b/scripts/snippets/find_modified_docs_in_searchindex.php index c230ad12ce..b62543d476 100644 --- a/scripts/snippets/find_modified_docs_in_searchindex.php +++ b/scripts/snippets/find_modified_docs_in_searchindex.php @@ -28,9 +28,11 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\DocumentFinder; + /** * * Dieses Skript findet alle Dokumente mit ServerState=published, deren ServerDateModified im Solr-Index kleiner ist @@ -43,7 +45,7 @@ */ $numOfModified = 0; $numOfErrors = 0; -$finder = new Opus_DocumentFinder(); +$finder = new DocumentFinder(); $finder->setServerState('published'); foreach ($finder->ids() as $docId) { // check if document with id $docId is already persisted in search index @@ -56,7 +58,7 @@ } else { $result = $search->getResults(); $solrModificationDate = $result[0]->getServerDateModified(); - $document = new Opus_Document($docId); + $document = Document::get($docId); $docModificationDate = $document->getServerDateModified()->getUnixTimestamp(); if ($solrModificationDate != $docModificationDate) { $numOfModified++; diff --git a/scripts/snippets/find_urns_for_docs_without_visible_files.php b/scripts/snippets/find_urns_for_docs_without_visible_files.php index d5696cbf4f..ef553ba244 100644 --- a/scripts/snippets/find_urns_for_docs_without_visible_files.php +++ b/scripts/snippets/find_urns_for_docs_without_visible_files.php @@ -28,9 +28,10 @@ * @author Thoralf Klein * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\DocumentFinder; /** * Dieses Script sucht Dokumente ohne sichtbare Dateien, fuer die bereits @@ -41,12 +42,12 @@ $updateRequired = 0; -$docfinder = new Opus_DocumentFinder(); +$docfinder = new DocumentFinder(); $docfinder->setIdentifierTypeExists('urn'); echo "checking documents...\n"; foreach ($docfinder->ids() as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $numVisibleFiles = 0; foreach ($doc->getFile() as $file) { diff --git a/scripts/snippets/get_nonextractable_docs.php b/scripts/snippets/get_nonextractable_docs.php index 1c15a151b9..f492815a0f 100644 --- a/scripts/snippets/get_nonextractable_docs.php +++ b/scripts/snippets/get_nonextractable_docs.php @@ -28,9 +28,11 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Model\NotFoundException; /** * Finds all non-extractable full texts. @@ -44,7 +46,7 @@ $solrServer = new Apache_Solr_Service($host, $port, $app); -$docFinder = new Opus_DocumentFinder(); +$docFinder = new DocumentFinder(); $overallNumOfFulltexts = 0; $numOfNonExtractableFulltexts = 0; @@ -52,8 +54,8 @@ foreach ($docFinder->ids() as $id) { $d = null; try { - $d = new Opus_Document($id); - } catch (Opus_Model_NotFoundException $e) { + $d = Document::get($id); + } catch (NotFoundException $e) { // document with id $id does not exist continue; } diff --git a/scripts/snippets/import_collections.php b/scripts/snippets/import_collections.php index 2116bebec8..8f1bba5043 100644 --- a/scripts/snippets/import_collections.php +++ b/scripts/snippets/import_collections.php @@ -28,9 +28,11 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Collection; +use Opus\Model\NotFoundException; + /** * script that imports collections from a text file * file format: each collection (name and number) on a separate line @@ -58,8 +60,8 @@ $rootCollection = null; try { - $rootCollection = new Opus_Collection($parentCollectionId); -} catch (Opus_Model_NotFoundException $e) { + $rootCollection = new Collection($parentCollectionId); +} catch (NotFoundException $e) { echo "Error: collection with id $parentCollectionId does not exist\n"; exit(); } @@ -82,7 +84,7 @@ continue; } - $collection = new Opus_Collection(); + $collection = new Collection(); $collection->setName(trim($parts[0])); $collection->setNumber(trim($parts[1])); $collection->setVisible($visible); diff --git a/scripts/snippets/import_dnb_ddc.php b/scripts/snippets/import_dnb_ddc.php index 1b2a044d6b..65a9497c45 100644 --- a/scripts/snippets/import_dnb_ddc.php +++ b/scripts/snippets/import_dnb_ddc.php @@ -28,9 +28,12 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Collection; +use Opus\CollectionRole; +use Opus\Db\TableGateway; + /** * script that imports collections from a text file * file format: each collection (name and number) on a separate line @@ -55,13 +58,13 @@ } // find next valid position for collection role -$table = Opus_Db_TableGateway::getInstance(Opus_CollectionRole::getTableGatewayClass()); +$table = TableGateway::getInstance(CollectionRole::getTableGatewayClass()); $select = $table->select()->from($table, ['MAX(position) AS max_position']); $row = $table->fetchRow($select); $position = $row->max_position + 1; // create root collection -$collectionRole = new Opus_CollectionRole(); +$collectionRole = new CollectionRole(); $collectionRole->setPosition($position); $collectionRole->setName('ddc_dnb'); $collectionRole->setOaiName('ddc_dnb'); @@ -73,7 +76,7 @@ $collectionRole->setVisibleOai(true); $collectionRoleId = $collectionRole->store(); -$rootCollection = new Opus_Collection(); +$rootCollection = new Collection(); $rootCollection->setPositionKey('Root'); $rootCollection->setVisible(true); $rootCollection->setRoleId($collectionRoleId); @@ -97,7 +100,7 @@ continue; } - $collection = new Opus_Collection(); + $collection = new Collection(); $collection->setNumber(trim($parts[0])); $collection->setOaiSubset(trim($parts[0])); $collection->setName(trim($parts[1])); diff --git a/scripts/snippets/import_document.php b/scripts/snippets/import_document.php index af2364d7bf..9ce0599658 100644 --- a/scripts/snippets/import_document.php +++ b/scripts/snippets/import_document.php @@ -28,9 +28,10 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Model\Xml; +use Opus\Model\Xml\Version1; /** * Imports the XML representation from stdin and creates a new OPUS 4 @@ -44,8 +45,8 @@ $xml .= $line; } -$xmlModel = new Opus_Model_Xml(); -$xmlModel->setStrategy(new Opus_Model_Xml_Version1()); +$xmlModel = new Xml(); +$xmlModel->setStrategy(new Version1()); $xmlModel->setXml($xml); $doc = $xmlModel->getModel(); diff --git a/scripts/snippets/publications-stats.php b/scripts/snippets/publications-stats.php index 54fdfc7e04..1d0bec8776 100644 --- a/scripts/snippets/publications-stats.php +++ b/scripts/snippets/publications-stats.php @@ -28,9 +28,9 @@ * @author Thoralf Klein * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\DocumentFinder; /** * Basic publication statistics (based on server_published_date) @@ -38,13 +38,13 @@ * TODO make command in opus4 tool */ -$df = new Opus_DocumentFinder(); +$df = new DocumentFinder(); $years = $df->setServerState('published')->groupedServerYearPublished(); sort($years); $cumSum = 0; foreach ($years as $year) { - $df = new Opus_DocumentFinder(); + $df = new DocumentFinder(); $count = $df->setServerState('published')->setServerDatePublishedRange($year, $year + 1)->count(); $cumSum += $count; diff --git a/scripts/snippets/reassign_doc_sort_order.php b/scripts/snippets/reassign_doc_sort_order.php index bfb858d769..66f20a277f 100644 --- a/scripts/snippets/reassign_doc_sort_order.php +++ b/scripts/snippets/reassign_doc_sort_order.php @@ -28,9 +28,11 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; +use Opus\Series; + /** * * Setzt die interne Sortierreihenfolge (doc_sort_order) für die einer @@ -45,7 +47,7 @@ * */ -foreach (Opus_Series::getAll() as $series) { +foreach (Series::getAll() as $series) { echo "\nreassign doc_sort_order for documents in series #" . $series->getId() . ': '; $docIds = $series->getDocumentIds(); if (empty($docIds)) { @@ -56,7 +58,7 @@ $seriesNumbers = []; foreach ($docIds as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); foreach ($doc->getSeries() as $docSeries) { if ($docSeries->getModel()->getId() === $series->getId()) { $seriesNumbers[$docId] = $docSeries->getNumber(); @@ -88,7 +90,7 @@ $seriesCounter = 0; foreach ($seriesNumbers as $docId => $seriesNumber) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $allSeries = $doc->getSeries(); $doc->setSeries([]); $doc->store(); diff --git a/scripts/snippets/release_all_unpublished_docs.php b/scripts/snippets/release_all_unpublished_docs.php index cb3a21c6ac..f1e39c80e3 100644 --- a/scripts/snippets/release_all_unpublished_docs.php +++ b/scripts/snippets/release_all_unpublished_docs.php @@ -28,9 +28,12 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Date; +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Model\NotFoundException; /** * Releases all documents in server state unpublished. @@ -38,20 +41,20 @@ * TODO useful? should it be part of opus4 or opus4dev */ -$docFinder = new Opus_DocumentFinder(); +$docFinder = new DocumentFinder(); $docFinder->setServerState('unpublished'); foreach ($docFinder->ids() as $id) { $d = null; try { - $d = new Opus_Document($id); - } catch (Opus_Model_NotFoundException $e) { + $d = Document::get($id); + } catch (NotFoundException $e) { // document with id $id does not exist continue; } if (! is_null($d)) { - $date = new Opus_Date(); + $date = new Date(); $date->setNow(); $d->setServerState('published'); $d->setServerDatePublished($date); diff --git a/scripts/snippets/split_firstname_academic_title.php b/scripts/snippets/split_firstname_academic_title.php index b2e1ed4856..427f7d4e05 100644 --- a/scripts/snippets/split_firstname_academic_title.php +++ b/scripts/snippets/split_firstname_academic_title.php @@ -28,9 +28,10 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Person; + /** * * Durchsucht die Vornamen aller in der Datenbank abgespeicherten Personen. @@ -45,7 +46,7 @@ * */ -foreach (Opus_Person::getAll() as $person) { +foreach (Person::getAll() as $person) { $firstname = $person->getFirstName(); $numOfOpeningParenthesis = substr_count($firstname, '('); $numOfClosingParenthesis = substr_count($firstname, ')'); diff --git a/scripts/snippets/update-dnbinstitute.php b/scripts/snippets/update-dnbinstitute.php index 7ae16244f2..3b48261dbc 100644 --- a/scripts/snippets/update-dnbinstitute.php +++ b/scripts/snippets/update-dnbinstitute.php @@ -29,7 +29,6 @@ * @author Edouard Simon (edouard.simon@zib.de) * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id: update-thesispublisher.php 11775 2013-06-25 14:28:41Z tklein $ */ /** * TODO find out what it does - make command? @@ -42,6 +41,11 @@ require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\DnbInstitute; +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Model\NotFoundException; + //if ($argc < 3) { // echo "Usage: {$argv[0]} (dryrun)\n"; // exit; @@ -63,8 +67,8 @@ $dryrun = isset($options['dryrun']); try { - $dnbInstitute = new Opus_DnbInstitute($thesisPublisherId); -} catch (Opus_Model_NotFoundException $omnfe) { + $dnbInstitute = new DnbInstitute($thesisPublisherId); +} catch (NotFoundException $omnfe) { _log("Opus_DnbInstitute with ID <$thesisPublisherId> does not exist.\nExiting..."); exit; } @@ -72,7 +76,7 @@ _log("TEST RUN: NO DATA WILL BE MODIFIED"); } -$docFinder = new Opus_DocumentFinder(); +$docFinder = new DocumentFinder(); $docIds = $docFinder ->setServerState('published'); if ($documentType != false) { @@ -84,7 +88,7 @@ foreach ($docIds as $docId) { try { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); if (count($doc->getFile()) == 0) { _log("Document <$docId> has no files, skipping.."); continue; diff --git a/scripts/snippets/validate-oai-xmetadissplus.php b/scripts/snippets/validate-oai-xmetadissplus.php index c92bdc5080..d837c27d91 100644 --- a/scripts/snippets/validate-oai-xmetadissplus.php +++ b/scripts/snippets/validate-oai-xmetadissplus.php @@ -30,7 +30,6 @@ * @author Edouard Simon * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ if (basename(__FILE__) !== basename($argv[0])) { echo "script must be executed directy (not via opus-console)\n"; diff --git a/scripts/update/002-Add-CC-4.0-licences.php b/scripts/update/002-Add-CC-4.0-licences.php index 8a40e28eb2..a69f5e757f 100755 --- a/scripts/update/002-Add-CC-4.0-licences.php +++ b/scripts/update/002-Add-CC-4.0-licences.php @@ -39,9 +39,12 @@ require_once dirname(__FILE__) . '/../common/update.php'; +use Opus\Database; +use Opus\Licence; + $helper = new Application_Update_Helper(); -$licence = Opus_Licence::fetchByName('CC BY 4.0'); +$licence = Licence::fetchByName('CC BY 4.0'); if (! is_null($licence)) { $helper->log('Creative Commons 4.0 seem to be present in database.'); @@ -50,7 +53,7 @@ if ($helper->askYesNo('Add CC 4.0 licences to database [Y|n]? ')) { $helper->log('Add CC 4.0 licences ...'); - $database = new Opus_Database(); + $database = new Database(); $script = APPLICATION_PATH . '/db/masterdata/021-add-version-4-CC-licences.sql'; diff --git a/scripts/update/004-Remove-leading-zeros-from-GND-identifier-for-persons.php b/scripts/update/004-Remove-leading-zeros-from-GND-identifier-for-persons.php index 84e4f11cee..8be1fe3293 100755 --- a/scripts/update/004-Remove-leading-zeros-from-GND-identifier-for-persons.php +++ b/scripts/update/004-Remove-leading-zeros-from-GND-identifier-for-persons.php @@ -39,11 +39,13 @@ require_once dirname(__FILE__) . '/../common/update.php'; +use Opus\Database; + $helper = new Application_Update_Helper(); $helper->log('Removing leading zeros from person GND identifiers ...'); -$database = new Opus_Database(); +$database = new Database(); $script = APPLICATION_PATH . '/db/update/remove-leading-zeros-from-author-GND-ids.sql'; diff --git a/scripts/update/008-Convert-database-to-utf8mb4.php b/scripts/update/008-Convert-database-to-utf8mb4.php index 3861663a56..bf74cdc965 100755 --- a/scripts/update/008-Convert-database-to-utf8mb4.php +++ b/scripts/update/008-Convert-database-to-utf8mb4.php @@ -41,5 +41,7 @@ * TODO direct dependency on framework internals - possibly a problem in the future */ -$update = new Opus_Update_Plugin_DatabaseCharset(); +use Opus\Update\Plugin\DatabaseCharset; + +$update = new DatabaseCharset(); $update->run(); diff --git a/scripts/update/update.php b/scripts/update/update.php index 668d31b961..34f1bdd11a 100644 --- a/scripts/update/update.php +++ b/scripts/update/update.php @@ -55,7 +55,10 @@ require_once 'autoload.php'; require_once 'opus-php-compatibility.php'; -$autoloader = Zend_Loader_Autoloader::getInstance(); +// TODO OPUSVIER-4420 remove after switching to Laminas/ZF3 +require_once APPLICATION_PATH . '/vendor/opus4-repo/framework/library/OpusDb/Mysqlutf8.php'; + +$autoloader = \Zend_Loader_Autoloader::getInstance(); $autoloader->suppressNotFoundWarnings(false); $autoloader->setFallbackAutoloader(true); diff --git a/scripts/update_migration/MigrateSeriesCollections.php b/scripts/update_migration/MigrateSeriesCollections.php index 2d7a2556e9..bafb4525a3 100755 --- a/scripts/update_migration/MigrateSeriesCollections.php +++ b/scripts/update_migration/MigrateSeriesCollections.php @@ -30,11 +30,16 @@ * @author Susanne Gottwald * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ **/ require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\Collection; +use Opus\CollectionRole; +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Series; + class FindMissingSeriesNumbers { @@ -44,7 +49,7 @@ class FindMissingSeriesNumbers public function __construct($logfile) { - $this->_seriesRole = Opus_CollectionRole::fetchByName('series'); + $this->_seriesRole = CollectionRole::fetchByName('series'); $this->initLogger($logfile); } @@ -56,15 +61,15 @@ public function __construct($logfile) private function initLogger($logfileName) { $logfile = @fopen($logfileName, 'a', false); - $writer = new Zend_Log_Writer_Stream($logfile); - $formatter = new Zend_Log_Formatter_Simple('%priorityName%: %message%' . PHP_EOL); + $writer = new \Zend_Log_Writer_Stream($logfile); + $formatter = new \Zend_Log_Formatter_Simple('%priorityName%: %message%' . PHP_EOL); $writer->setFormatter($formatter); - $this->_logger = new Zend_Log($writer); + $this->_logger = new \Zend_Log($writer); } /** * Für jede Collection der Collection Role series wird eine neue Schriftenreihe - * Opus_Series angelegt, wobei der Name, die Sichtbarkeit und die Sorierreihenfolge + * Series angelegt, wobei der Name, die Sichtbarkeit und die Sorierreihenfolge * übernommen wird. * * Die Wurzel-Collection der Collection Role series wird nicht betrachtet. @@ -75,12 +80,12 @@ private function initLogger($logfileName) private function migrateCollectionToSeries() { $numOfCollectionsMigrated = 0; - foreach (Opus_Collection::fetchCollectionsByRoleId($this->_seriesRole->getId()) as $collection) { + foreach (Collection::fetchCollectionsByRoleId($this->_seriesRole->getId()) as $collection) { // ignore root collection (does not have valid data and associated documents) if ($collection->isRoot()) { continue; } - $series = new Opus_Series(Opus_Series::createRowWithCustomId($collection->getId())); + $series = new Series(Series::createRowWithCustomId($collection->getId())); $series->setTitle($collection->getName()); $series->setVisible($collection->getVisible()); $series->setSortOrder($collection->getSortOrder()); @@ -99,7 +104,7 @@ private function migrateCollectionToSeries() * der Collection Role series (kurz: series-Collection) zugeordnet sind. * * Fall 1 (Dokumente ohne IdentifierSerial): - * Da die Bandnummer einer Schriftenreihe Opus_Series obligatorisch ist, können + * Da die Bandnummer einer Schriftenreihe Series obligatorisch ist, können * Dokumente ohne IdentifierSerial nicht migriert werden. Sie verbleiben * unangetastet. Die Zuweisung(en) zu series-Collection(s) wird (werden) nicht * verändert. @@ -131,11 +136,11 @@ private function migrateDocuments() { $numOfConflicts = 0; $numOfDocsMigrated = 0; - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setCollectionRoleId($this->_seriesRole->getId()); $serialIdsInUse = []; foreach ($finder->ids() as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $serialIds = $doc->getIdentifierSerial(); $numOfSerialIds = count($serialIds); @@ -178,7 +183,7 @@ private function migrateDocuments() $numOfConflicts++; } else { // no conflict - $series = new Opus_Series($collectionId); + $series = new Series($collectionId); $doc->addSeries($series)->setNumber($serialId); $doc->setIdentifierSerial([]); diff --git a/scripts/update_migration/MigrateSubjectsToCollections.php b/scripts/update_migration/MigrateSubjectsToCollections.php index bf392261c5..a41e7f37d7 100755 --- a/scripts/update_migration/MigrateSubjectsToCollections.php +++ b/scripts/update_migration/MigrateSubjectsToCollections.php @@ -30,12 +30,18 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ **/ // Bootstrapping. require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\Collection; +use Opus\CollectionRole; +use Opus\Document; +use Opus\DocumentFinder; +use Opus\EnrichmentKey; +use Opus\Model\NotFoundException; + // Parse arguments. global $argc, $argv; @@ -53,19 +59,19 @@ * TODO Not using LogService, because file is written to working directory (OPUSVIER-4289) */ $logfile = @fopen($logfileName, 'a', false); -$writer = new Zend_Log_Writer_Stream($logfile); -$formatter = new Zend_Log_Formatter_Simple('%timestamp% %priorityName%: %message%' . PHP_EOL); +$writer = new \Zend_Log_Writer_Stream($logfile); +$formatter = new \Zend_Log_Formatter_Simple('%timestamp% %priorityName%: %message%' . PHP_EOL); $writer->setFormatter($formatter); -$logger = new Zend_Log($writer); +$logger = new \Zend_Log($writer); // load collections (and check existence) -$mscRole = Opus_CollectionRole::fetchByName('msc'); +$mscRole = CollectionRole::fetchByName('msc'); if (! is_object($mscRole)) { $logger->warn("MSC collection does not exist. Cannot migrate SubjectMSC."); } -$ddcRole = Opus_CollectionRole::fetchByName('ddc'); +$ddcRole = CollectionRole::fetchByName('ddc'); if (! is_object($ddcRole)) { $logger->warn("DDC collection does not exist. Cannot migrate SubjectDDC."); } @@ -75,13 +81,13 @@ createEnrichmentKey('MigrateSubjectDDC'); // Iterate over all documents. -$docFinder = new Opus_DocumentFinder(); +$docFinder = new DocumentFinder(); $changedDocumentIds = []; foreach ($docFinder->ids() as $docId) { $doc = null; try { - $doc = new Opus_Document($docId); - } catch (Opus_Model_NotFoundException $e) { + $doc = Document::get($docId); + } catch (NotFoundException $e) { continue; } @@ -104,7 +110,7 @@ $changedDocumentIds[] = $docId; try { - $doc->unregisterPlugin('Opus_Document_Plugin_Index'); + $doc->unregisterPlugin('Opus\Document\Plugin\Index'); $doc->store(); $logger->info("changed document $docId"); } catch (Exception $e) { @@ -147,7 +153,7 @@ function migrateSubjectToCollection($doc, $subjectType, $roleId, $eKeyName) $removeSubjects[] = $subject; // check if (unique) collection for subject value exists - $collections = Opus_Collection::fetchCollectionsByRoleNumber($roleId, $value); + $collections = Collection::fetchCollectionsByRoleNumber($roleId, $value); if (! is_array($collections) or count($collections) < 1) { $logger->warn("$logPrefix No collection found for value '$value' -- migrating to enrichment $eKeyName."); // migrate subject to enrichments @@ -218,12 +224,12 @@ function migrateSubjectToCollection($doc, $subjectType, $roleId, $eKeyName) function createEnrichmentKey($name) { try { - $eKey = new Opus_EnrichmentKey(); + $eKey = new EnrichmentKey(); $eKey->setName($name)->store(); } catch (Exception $e) { } - return new Opus_EnrichmentKey($name); + return new EnrichmentKey($name); } echo "\nConsult the log file $argv[1] for full details\n"; diff --git a/scripts/xslt.php b/scripts/xslt.php index 23ac5c1529..417cc7b179 100755 --- a/scripts/xslt.php +++ b/scripts/xslt.php @@ -29,7 +29,6 @@ * @author Ralf Claussnitzer * @copyright Copyright (c) 2009, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ // TODO move this script (it is used for testing/development to test out XSLT scripts) @@ -42,13 +41,13 @@ exit; } -$xslt = new DOMDocument; +$xslt = new \DOMDocument; $xslt->load($args[1]); -$xml = new DOMDocument; +$xml = new \DOMDocument; $xml->load($args[2]); -$proc = new XSLTProcessor; +$proc = new \XSLTProcessor; $proc->registerPhpFunctions(); $proc->importStyleSheet($xslt); diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index c8f5cc2e22..2bdb5786b2 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ error_reporting(E_ALL | E_STRICT); @@ -59,8 +58,11 @@ require_once 'autoload.php'; +// TODO OPUSVIER-4420 remove after switching to Laminas/ZF3 +require_once APPLICATION_PATH . '/vendor/opus4-repo/framework/library/OpusDb/Mysqlutf8.php'; + // enable fallback autoloader for testing -$autoloader = Zend_Loader_Autoloader::getInstance(); +$autoloader = \Zend_Loader_Autoloader::getInstance(); $autoloader->suppressNotFoundWarnings(false); $autoloader->setFallbackAutoloader(true); diff --git a/tests/import-testdata.php b/tests/import-testdata.php index af9c61c7c5..5718785e50 100644 --- a/tests/import-testdata.php +++ b/tests/import-testdata.php @@ -54,8 +54,11 @@ require_once 'autoload.php'; +// TODO OPUSVIER-4420 remove after switching to Laminas/ZF3 +require_once APPLICATION_PATH . '/vendor/opus4-repo/framework/library/OpusDb/Mysqlutf8.php'; + // environment initializiation -$application = new Zend_Application( +$application = new \Zend_Application( APPLICATION_ENV, [ "config" => [ @@ -71,8 +74,8 @@ // Bootstrapping application $application->bootstrap('Backend'); -$config = Zend_Registry::get('Zend_Config'); -$config = $config->merge(new Zend_Config_Ini(dirname(__FILE__) . '/config.ini')); +$config = \Zend_Registry::get('Zend_Config'); +$config = $config->merge(new \Zend_Config_Ini(dirname(__FILE__) . '/config.ini')); -$database = new Opus_Database(); +$database = new \Opus\Database(); $database->import(APPLICATION_PATH . '/tests/sql'); diff --git a/tests/library/Application/Configuration/MaxUploadSizeTest.php b/tests/library/Application/Configuration/MaxUploadSizeTest.php index 4de91b0d95..0d09b6ffc4 100644 --- a/tests/library/Application/Configuration/MaxUploadSizeTest.php +++ b/tests/library/Application/Configuration/MaxUploadSizeTest.php @@ -46,7 +46,7 @@ class Application_Configuration_MaxUploadSizeTest extends TestCase */ public function testMaxUploadSize() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $configMaxFileSize = intval($config->publish->maxfilesize); $postMaxSize = $this->convertToKByte(ini_get('post_max_size')); diff --git a/tests/library/Application/ConfigurationTest.php b/tests/library/Application/ConfigurationTest.php index 126c5320ff..043b813193 100644 --- a/tests/library/Application/ConfigurationTest.php +++ b/tests/library/Application/ConfigurationTest.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + class Application_ConfigurationTest extends ControllerTestCase { @@ -101,7 +103,7 @@ public function testIsLanguageSupportedFalseEmpty() public function testGetOpusVersion() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $this->assertEquals($config->version, Application_Configuration::getOpusVersion()); } @@ -123,7 +125,7 @@ public function testIsLanguageSelectionEnabledTrue() public function testIsLanguageSelectionEnabledFalse() { - Zend_Registry::get('Zend_Config')->supportedLanguages = 'de'; + \Zend_Registry::get('Zend_Config')->supportedLanguages = 'de'; $this->assertEquals(['de'], $this->config->getSupportedLanguages()); $this->assertFalse($this->config->isLanguageSelectionEnabled()); } @@ -135,14 +137,14 @@ public function testGetDefaultLanguage() public function testGetDefaultLanguageIfOnlyOneIsSupported() { - Zend_Registry::get('Zend_Config')->supportedLanguages = 'de'; + \Zend_Registry::get('Zend_Config')->supportedLanguages = 'de'; $this->assertEquals('de', $this->config->getDefaultLanguage()); } public function testGetDefaultLanguageUnsupportedConfigured() { // because bootstrapping already happened locale needs to be manipulated directly - $locale = new Zend_Locale(); + $locale = new \Zend_Locale(); $locale->setDefault('fr'); $this->assertEquals('de', $this->config->getDefaultLanguage()); @@ -165,7 +167,7 @@ public function testGetWorkspacePath() */ public function testGetWorkspacePathSetWithSlash() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'workspacePath' => APPLICATION_PATH . '/tests/workspace/' ])); @@ -210,10 +212,10 @@ public function testGetName() $config = Application_Configuration::getInstance(); $this->assertEquals('OPUS 4', $config->getName()); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config(['name' => 'OPUS Test'])); + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config(['name' => 'OPUS Test'])); $this->assertEquals('OPUS Test', $config->getName()); - $zendConfig = Zend_Registry::get('Zend_Config'); + $zendConfig = \Zend_Registry::get('Zend_Config'); unset($zendConfig->name); $this->assertEquals('OPUS 4', $config->getName()); } @@ -266,13 +268,13 @@ public function testGetValueForNull() public function testDocumentPlugins() { - $document = new Opus_Document(); + $document = Document::new(); $this->assertEquals([ 'Opus\Search\Plugin\Index', - 'Opus_Document_Plugin_XmlCache', - 'Opus_Document_Plugin_IdentifierUrn', - 'Opus_Document_Plugin_IdentifierDoi' + 'Opus\Document\Plugin\XmlCache', + 'Opus\Document\Plugin\IdentifierUrn', + 'Opus\Document\Plugin\IdentifierDoi' ], $document->getDefaultPlugins()); } } diff --git a/tests/library/Application/Console/Document/DeleteCommandTest.php b/tests/library/Application/Console/Document/DeleteCommandTest.php index e2c5b173fd..0884a8da3a 100644 --- a/tests/library/Application/Console/Document/DeleteCommandTest.php +++ b/tests/library/Application/Console/Document/DeleteCommandTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Model\NotFoundException; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Application; @@ -69,7 +71,7 @@ public function testDeleteSingleDocument() $tester = new CommandTester($command); $docId = $this->documents[2]; - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $this->assertEquals('unpublished', $doc->getServerState()); @@ -80,19 +82,19 @@ public function testDeleteSingleDocument() 'interactive' => false ]); - $doc = new Opus_Document($this->documents[0]); + $doc = Document::get($this->documents[0]); $this->assertEquals('unpublished', $doc->getServerState()); - $doc = new Opus_Document($this->documents[1]); + $doc = Document::get($this->documents[1]); $this->assertEquals('unpublished', $doc->getServerState()); - $doc = new Opus_Document($this->documents[2]); + $doc = Document::get($this->documents[2]); $this->assertEquals('deleted', $doc->getServerState()); - $doc = new Opus_Document($this->documents[3]); + $doc = Document::get($this->documents[3]); $this->assertEquals('unpublished', $doc->getServerState()); - $doc = new Opus_Document($this->documents[4]); + $doc = Document::get($this->documents[4]); $this->assertEquals('unpublished', $doc->getServerState()); } @@ -121,19 +123,19 @@ public function testDeleteDocumentRange() 'interactive' => false ]); - $doc = new Opus_Document($this->documents[0]); + $doc = Document::get($this->documents[0]); $this->assertEquals('unpublished', $doc->getServerState()); - $doc = new Opus_Document($this->documents[1]); + $doc = Document::get($this->documents[1]); $this->assertEquals('deleted', $doc->getServerState()); - $doc = new Opus_Document($this->documents[2]); + $doc = Document::get($this->documents[2]); $this->assertEquals('deleted', $doc->getServerState()); - $doc = new Opus_Document($this->documents[3]); + $doc = Document::get($this->documents[3]); $this->assertEquals('deleted', $doc->getServerState()); - $doc = new Opus_Document($this->documents[4]); + $doc = Document::get($this->documents[4]); $this->assertEquals('unpublished', $doc->getServerState()); } @@ -147,7 +149,7 @@ public function testDeleteSingleDocumentPermanently() $tester = new CommandTester($command); $docId = $this->documents[2]; - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $this->assertEquals('unpublished', $doc->getServerState()); @@ -159,20 +161,20 @@ public function testDeleteSingleDocumentPermanently() 'interactive' => false ]); - $doc = new Opus_Document($this->documents[0]); + $doc = Document::get($this->documents[0]); $this->assertEquals('unpublished', $doc->getServerState()); - $doc = new Opus_Document($this->documents[1]); + $doc = Document::get($this->documents[1]); $this->assertEquals('unpublished', $doc->getServerState()); - $doc = new Opus_Document($this->documents[3]); + $doc = Document::get($this->documents[3]); $this->assertEquals('unpublished', $doc->getServerState()); - $doc = new Opus_Document($this->documents[4]); + $doc = Document::get($this->documents[4]); $this->assertEquals('unpublished', $doc->getServerState()); - $this->setExpectedException('Opus_Model_NotFoundException'); - new Opus_Document($this->documents[2]); + $this->setExpectedException('Opus\Model\NotFoundException'); + Document::get($this->documents[2]); } public function testDeleteAllDocumentsPermanently() @@ -198,28 +200,28 @@ public function testDeleteDocumentRangePermanently() 'interactive' => false ]); - $doc = new Opus_Document($this->documents[0]); + $doc = Document::get($this->documents[0]); $this->assertEquals('unpublished', $doc->getServerState()); - $doc = new Opus_Document($this->documents[4]); + $doc = Document::get($this->documents[4]); $this->assertEquals('unpublished', $doc->getServerState()); try { - new Opus_Document($this->documents[1]); + Document::get($this->documents[1]); $this->fail('Document should have been deleted permanently.'); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { } try { - new Opus_Document($this->documents[2]); + Document::get($this->documents[2]); $this->fail('Document should have been deleted permanently.'); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { } try { - new Opus_Document($this->documents[3]); + Document::get($this->documents[3]); $this->fail('Document should have been deleted permanently.'); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { } } diff --git a/tests/library/Application/Controller/Action/Helper/AbstractTest.php b/tests/library/Application/Controller/Action/Helper/AbstractTest.php index ad9d57da26..15d88bea34 100644 --- a/tests/library/Application/Controller/Action/Helper/AbstractTest.php +++ b/tests/library/Application/Controller/Action/Helper/AbstractTest.php @@ -50,6 +50,6 @@ public function testGetLogger() $logger = $helper->getLogger(); $this->assertInstanceOf('Zend_Log', $logger); - $this->assertEquals(Zend_Registry::get('Zend_Log'), $logger); + $this->assertEquals(\Zend_Registry::get('Zend_Log'), $logger); } } diff --git a/tests/library/Application/Controller/Action/Helper/AccessControlTest.php b/tests/library/Application/Controller/Action/Helper/AccessControlTest.php index e9160494cc..017d18365e 100644 --- a/tests/library/Application/Controller/Action/Helper/AccessControlTest.php +++ b/tests/library/Application/Controller/Action/Helper/AccessControlTest.php @@ -45,21 +45,21 @@ public function setUp() { parent::setUpWithEnv('production'); $this->assertSecurityConfigured(); - $acl = Zend_Registry::get('Opus_Acl'); + $acl = \Zend_Registry::get('Opus_Acl'); $acl->allow('guest', 'accounts'); $this->accessControl = new Application_Controller_Action_Helper_AccessControl(); } public function tearDown() { - $acl = Zend_Registry::get('Opus_Acl'); + $acl = \Zend_Registry::get('Opus_Acl'); $acl->deny('guest', 'accounts'); parent::tearDown(); } public function testAccessAllowed() { - $user = Zend_Auth::getInstance()->getIdentity(); + $user = \Zend_Auth::getInstance()->getIdentity(); $this->assertEquals('', $user, "expected no user to be set (should use default 'guest' as default)"); $allowedDocuments = $this->accessControl->accessAllowed('documents'); diff --git a/tests/library/Application/Controller/Action/Helper/BreadcrumbsTest.php b/tests/library/Application/Controller/Action/Helper/BreadcrumbsTest.php index 00e038be88..5caf07036c 100644 --- a/tests/library/Application/Controller/Action/Helper/BreadcrumbsTest.php +++ b/tests/library/Application/Controller/Action/Helper/BreadcrumbsTest.php @@ -1,5 +1,4 @@ helper = Zend_Controller_Action_HelperBroker::getStaticHelper('breadcrumbs'); - $this->navigation = Zend_Registry::get('Opus_View')->navigation(); + $this->helper = \Zend_Controller_Action_HelperBroker::getStaticHelper('breadcrumbs'); + $this->navigation = \Zend_Registry::get('Opus_View')->navigation(); $this->helper->setNavigation($this->navigation); - $this->helper->setView(Zend_Registry::get('Opus_View')); + $this->helper->setView(\Zend_Registry::get('Opus_View')); } private function getPage($label) @@ -77,7 +80,7 @@ public function testDirect() public function testSetDocumentBreadcrumb() { - $document = new Opus_Document(146); + $document = Document::get(146); // Seite zuerst holen, da das Label nach dem Aufruf von setDocumentBreadcrumb nicht mehr stimmt $page = $this->getPage('admin_document_index'); @@ -101,7 +104,7 @@ public function testSetParameters() public function testSetGetNavigation() { - $navigation = new Zend_Navigation(); + $navigation = new \Zend_Navigation(); $this->helper->setNavigation($navigation); $this->assertEquals($navigation, $this->helper->getNavigation()); @@ -139,7 +142,7 @@ public function testGetDocumentTitle() $document->setLanguage('deu'); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('01234567890123456789012345678901234567890123456789'); // 50 Zeichen lang @@ -156,7 +159,7 @@ public function testGetDocumentTitleWithMultiByteChars() $document = $this->createTestDocument(); $document->setLanguage('deu'); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('012345678901234567890123456789012345678ü123'); // 50 Zeichen lang diff --git a/tests/library/Application/Controller/Action/Helper/DatesTest.php b/tests/library/Application/Controller/Action/Helper/DatesTest.php index e6e4008df4..e70c2b8988 100644 --- a/tests/library/Application/Controller/Action/Helper/DatesTest.php +++ b/tests/library/Application/Controller/Action/Helper/DatesTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Date; + /** * Unit Test for class Admin_Model_Workflow. */ @@ -107,21 +109,21 @@ public function testGetOpusDateInvalidEnglish() public function testGetDateStringGerman() { $this->useGerman(); - $date = new Opus_Date('2005-03-25'); + $date = new Date('2005-03-25'); $this->assertEquals('25.03.2005', $this->__datesHelper->getDateString($date)); } public function testGetDateStringEnglish() { $this->useEnglish(); - $date = new Opus_Date('2005-03-25'); + $date = new Date('2005-03-25'); $this->assertEquals('2005/03/25', $this->__datesHelper->getDateString($date)); } public function testGetDateStringForInvalidDate() { $this->useGerman(); - $date = new Opus_Date('2005'); + $date = new Date('2005'); $this->assertFalse($date->isValid()); $this->assertEquals(null, $this->__datesHelper->getDateString($date)); } diff --git a/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php b/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php index f3d228ad47..f83fdd518c 100644 --- a/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php +++ b/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php @@ -52,7 +52,7 @@ class Application_Controller_Action_Helper_DocumentTypesTest extends ControllerT public function setUp() { parent::setUp(); - $this->docTypeHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); + $this->docTypeHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); } /* @@ -183,7 +183,7 @@ public function testGetDocumentThrowsSchemaInvalidException() */ public function testGetAllDocumentTypes() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); unset($config->documentTypes); $documentTypes = $this->docTypeHelper->getDocumentTypes(); @@ -223,7 +223,7 @@ public function testGetTemplateForInvalidDocumentType() */ public function testGetDocumentTypesWithPathNotSet() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); unset($config->publish->path->documenttypes); @@ -236,7 +236,7 @@ public function testGetDocumentTypesWithPathNotSet() public function testTranslationOfDocumentTypes() { $excludeFromTranslationCheck = ['demo_invalid', 'foobar', 'barbaz', 'bazbar']; - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $documentTypes = $this->docTypeHelper->getDocumentTypes(); @@ -282,7 +282,7 @@ public function testValidateAllXMLDocumentTypeDefinitions() */ public function testDocumentTypesAndTemplates() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $templates = $this->getFileNames($config->publish->path->documenttemplates, '.phtml'); $types = $this->getFileNames($config->publish->path->documenttypes, '.xml'); @@ -305,7 +305,7 @@ private function getFileNames($path, $extension) { $fileNames = []; - if ($path instanceof Zend_Config) { + if ($path instanceof \Zend_Config) { $path = $path->toArray(); } @@ -331,7 +331,7 @@ public function testGetDocTypesPathAsArray() public function testGetDocTypesPath() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'publish' => [ 'path' => [ 'documenttypes' => APPLICATION_PATH . '/application/configs/doctypes' @@ -361,7 +361,7 @@ public function testGetTemplates() public function testTemplateForEveryDocumentType() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); unset($config->documentTypes); $docTypes = $this->docTypeHelper->getAllDocumentTypes(); diff --git a/tests/library/Application/Controller/Action/Helper/DocumentsTest.php b/tests/library/Application/Controller/Action/Helper/DocumentsTest.php index fbb9ce34ba..4d33434acd 100644 --- a/tests/library/Application/Controller/Action/Helper/DocumentsTest.php +++ b/tests/library/Application/Controller/Action/Helper/DocumentsTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + class Application_Controller_Action_Helper_DocumentsTest extends ControllerTestCase { @@ -42,7 +44,7 @@ public function setUp() { parent::setUp(); - $this->documents = Zend_Controller_Action_HelperBroker::getStaticHelper('Documents'); + $this->documents = \Zend_Controller_Action_HelperBroker::getStaticHelper('Documents'); } public function testGetDocumentForIdForValidId() @@ -52,7 +54,7 @@ public function testGetDocumentForIdForValidId() $document = $this->documents->getDocumentForId($docId); $this->assertNotNull($document); - $this->assertInstanceOf('Opus_Document', $document); + $this->assertInstanceOf(Document::class, $document); } public function testGetDocumentForIdForEmptyValue() @@ -141,7 +143,7 @@ public function testGetSortedDocumentIdsForState($state) if (count($documents) > 0) { foreach ($documents as $docId) { - $document = new Opus_Document($docId); + $document = Document::get($docId); $this->assertEquals($state, $document->getServerState()); } } diff --git a/tests/library/Application/Controller/Action/Helper/FileTypesTest.php b/tests/library/Application/Controller/Action/Helper/FileTypesTest.php index 22dadc56c2..b749b2d8e1 100644 --- a/tests/library/Application/Controller/Action/Helper/FileTypesTest.php +++ b/tests/library/Application/Controller/Action/Helper/FileTypesTest.php @@ -62,7 +62,7 @@ public function testGetValidMimeTypes() public function testMimeTypeAddedToBaseConfigurationFromApplicationIni() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'filetypes' => ['xml' => ['mimeType' => [ 'text/xml', 'application/xml' ]]] @@ -98,7 +98,7 @@ public function testIsValidMimeType() public function testIsValidMimeTypeForExtensionWithMultipleTypes() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'filetypes' => ['xml' => ['mimeType' => [ 'text/xml', 'application/xml' ]]] @@ -110,7 +110,7 @@ public function testIsValidMimeTypeForExtensionWithMultipleTypes() public function testIsValidMimeTypeForExtension() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'filetypes' => ['xml' => ['mimeType' => [ 'text/xml', 'application/xml' ]]] @@ -135,7 +135,7 @@ public function testIsValidMimeTypeForNull() public function testExtensionCaseInsensitive() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'filetypes' => ['XML' => ['mimeType' => 'text/xml']] ])); diff --git a/tests/library/Application/Controller/Action/Helper/FilesTest.php b/tests/library/Application/Controller/Action/Helper/FilesTest.php index f338260005..92e22bf948 100644 --- a/tests/library/Application/Controller/Action/Helper/FilesTest.php +++ b/tests/library/Application/Controller/Action/Helper/FilesTest.php @@ -46,7 +46,7 @@ public function setUp() { parent::setUp(); - $this->helper = Zend_Controller_Action_HelperBroker::getStaticHelper('Files'); + $this->helper = \Zend_Controller_Action_HelperBroker::getStaticHelper('Files'); $this->assertNotNull($this->helper, 'Files Action Helper not available.'); diff --git a/tests/library/Application/Controller/Action/Helper/ResultScriptTest.php b/tests/library/Application/Controller/Action/Helper/ResultScriptTest.php index 3b650d3c59..80bbd725f8 100644 --- a/tests/library/Application/Controller/Action/Helper/ResultScriptTest.php +++ b/tests/library/Application/Controller/Action/Helper/ResultScriptTest.php @@ -52,7 +52,7 @@ public function testDefaultScript() public function testCustomScriptDoesNotExist() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'search' => ['result' => ['script' => 'result.phtml']] ])); @@ -63,7 +63,7 @@ public function testCustomScriptDoesNotExist() public function testCustomScriptExists() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'search' => ['result' => ['script' => 'result.phtml']] ])); diff --git a/tests/library/Application/Controller/Action/Helper/TranslationTest.php b/tests/library/Application/Controller/Action/Helper/TranslationTest.php index 8b3d8d2efb..5638278cdf 100644 --- a/tests/library/Application/Controller/Action/Helper/TranslationTest.php +++ b/tests/library/Application/Controller/Action/Helper/TranslationTest.php @@ -30,6 +30,13 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Identifier; +use Opus\Language; +use Opus\Note; +use Opus\Person; +use Opus\Model\Dependent\Link\DocumentPerson; +use Opus\Model\ModelException; + /** * Test for class Application_Controller_Action_Helper_Translation and translations in general. */ @@ -54,8 +61,8 @@ public function setUp() { parent::setUp(); - $this->translate = Zend_Registry::get('Zend_Translate'); - $this->helper = Zend_Controller_Action_HelperBroker::getStaticHelper('Translation'); + $this->translate = \Zend_Registry::get('Zend_Translate'); + $this->helper = \Zend_Controller_Action_HelperBroker::getStaticHelper('Translation'); } /** @@ -65,7 +72,7 @@ public function testGetKeyForValue() { $this->assertEquals( 'Opus_Document_ServerState_Value_Unpublished', - $this->helper->getKeyForValue('Opus_Document', 'ServerState', 'unpublished') + $this->helper->getKeyForValue('Opus\Document', 'ServerState', 'unpublished') ); } @@ -73,7 +80,7 @@ public function testGetKeyForValueOfDocumentType() { $this->assertEquals( 'testdoctype', - $this->helper->getKeyForValue('Opus_Document', 'Type', 'testdoctype') + $this->helper->getKeyForValue('Opus\Document', 'Type', 'testdoctype') ); } @@ -81,7 +88,7 @@ public function testGetKeyForValueOfDocumentLanguage() { $this->assertEquals( 'testdoclang', - $this->helper->getKeyForValue('Opus_Document', 'Language', 'testdoclang') + $this->helper->getKeyForValue('Opus\Document', 'Language', 'testdoclang') ); } @@ -89,7 +96,7 @@ public function testGetKeyForField() { $this->assertEquals( 'Language', - $this->helper->getKeyForField('Opus_Document', 'Language') + $this->helper->getKeyForField('Opus\Document', 'Language') ); } @@ -97,7 +104,7 @@ public function testGetKeyForTypeField() { $this->assertEquals( 'Opus_Document_Type', - $this->helper->getKeyForField('Opus_Document', 'Type') + $this->helper->getKeyForField('Opus\Document', 'Type') ); } @@ -107,7 +114,7 @@ public function testTranslationOfServerStateValues() $values = $doc->getField('ServerState')->getDefault(); foreach ($values as $value) { - $key = $this->helper->getKeyForValue('Opus_Document', 'ServerState', $value); + $key = $this->helper->getKeyForValue('Opus\Document', 'ServerState', $value); $this->assertNotEquals( $key, $this->translate->translate($key), @@ -118,11 +125,11 @@ public function testTranslationOfServerStateValues() public function testTranslationOfPersonRoleValues() { - $model = new Opus_Model_Dependent_Link_DocumentPerson(); + $model = new DocumentPerson(); $values = $model->getField('Role')->getDefault(); foreach ($values as $value) { - $key = $this->helper->getKeyForValue('Opus_Person', 'Role', $value); + $key = $this->helper->getKeyForValue('Opus\Person', 'Role', $value); $this->assertNotEquals( $key, $this->translate->translate($key), @@ -134,16 +141,16 @@ public function testTranslationOfPersonRoleValues() public function translationOfTypeValuesDataProvider() { return [ - ['Opus_Title'], - ['Opus_TitleAbstract'], - ['Opus_Identifier'], - ['Opus_Reference'], - ['Opus_Subject'] + ['Opus\Title'], + ['Opus\TitleAbstract'], + ['Opus\Identifier'], + ['Opus\Reference'], + ['Opus\Subject'] ]; } /** - * @throws Opus_Model_Exception + * @throws ModelException * @dataProvider translationOfTypeValuesDataProvider */ public function testTranslationOfTypeValues($className) @@ -163,11 +170,11 @@ public function testTranslationOfTypeValues($className) public function testTranslationOfNoteVisibilityValues() { - $model = new Opus_Note(); + $model = new Note(); $values = $model->getField('Visibility')->getDefault(); foreach ($values as $value) { - $key = $this->helper->getKeyForValue('Opus_Note', 'Visibility', $value); + $key = $this->helper->getKeyForValue('Opus\Note', 'Visibility', $value); $this->assertNotEquals( $key, $this->translate->translate($key), @@ -183,7 +190,7 @@ public function testTranslationOfOpusDocumentFields() $fieldNames = $model->describe(); foreach ($fieldNames as $name) { - $key = $this->helper->getKeyForField('Opus_Document', $name); + $key = $this->helper->getKeyForField('Opus\Document', $name); $this->assertTrue( $this->translate->isTranslated($key), "Translation key '$key' is missing." @@ -193,7 +200,7 @@ public function testTranslationOfOpusDocumentFields() public function testTranslationOfOpusIdentifierFields() { - $model = new Opus_Identifier(); + $model = new Identifier(); $fieldNames = $model->describe(); @@ -202,7 +209,7 @@ public function testTranslationOfOpusIdentifierFields() // do not provide translations for DOI specific fields continue; } - $key = $this->helper->getKeyForField('Opus_Identifier', $name); + $key = $this->helper->getKeyForField('Opus\Identifier', $name); $this->assertTrue( $this->translate->isTranslated($key), "Translation key '$key' is missing." @@ -212,14 +219,14 @@ public function testTranslationOfOpusIdentifierFields() public function testTranslationOfDocumentPersonFields() { - $model = new Opus_Model_Dependent_Link_DocumentPerson; - $target = new Opus_Person; + $model = new DocumentPerson(); + $target = new Person(); $model->setModel($target); $fieldNames = $model->describe(); foreach ($fieldNames as $name) { - $key = $this->helper->getKeyForField('Opus_Person', $name); + $key = $this->helper->getKeyForField('Opus\Person', $name); $this->assertTrue( $this->translate->isTranslated($key), "Translation key '$key' is missing." @@ -230,18 +237,18 @@ public function testTranslationOfDocumentPersonFields() public function translationOfFieldsDataProvider() { return [ - ['Opus_Reference'], - ['Opus_Title'], - ['Opus_TitleAbstract'], - ['Opus_Subject'], - ['Opus_Patent'], - ['Opus_Note'], - ['Opus_Enrichment'] + ['Opus\Reference'], + ['Opus\Title'], + ['Opus\TitleAbstract'], + ['Opus\Subject'], + ['Opus\Patent'], + ['Opus\Note'], + ['Opus\Enrichment'] ]; } /** - * @throws Opus_Model_Exception + * @throws ModelException * @dataProvider translationOfFieldsDataProvider */ public function testTranslationOfOpusEnrichmentFields($className) @@ -261,7 +268,7 @@ public function testTranslationOfOpusEnrichmentFields($className) public function testTranslationOfLanguages() { - $languages = Opus_Language::getAll(); + $languages = Language::getAll(); foreach ($languages as $language) { $key = $language->getPart2T(); diff --git a/tests/library/Application/Controller/Action/Helper/VersionTest.php b/tests/library/Application/Controller/Action/Helper/VersionTest.php index 50f8758676..e9caa76a91 100644 --- a/tests/library/Application/Controller/Action/Helper/VersionTest.php +++ b/tests/library/Application/Controller/Action/Helper/VersionTest.php @@ -36,14 +36,14 @@ class Application_Controller_Action_Helper_VersionTest extends TestCase public function testDirect() { - $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('version'); + $helper = \Zend_Controller_Action_HelperBroker::getStaticHelper('version'); $helper->setVersion('Opus-noVersion'); $this->assertEquals('Opus-noVersion', $helper->direct()); } public function testSetGetVersion() { - $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('version'); + $helper = \Zend_Controller_Action_HelperBroker::getStaticHelper('version'); $helper->setVersion('Opus-noVersion'); $this->assertEquals('Opus-noVersion', $helper->getVersion()); } diff --git a/tests/library/Application/Controller/Action/Helper/WorkflowTest.php b/tests/library/Application/Controller/Action/Helper/WorkflowTest.php index a453672e99..9a7784e374 100644 --- a/tests/library/Application/Controller/Action/Helper/WorkflowTest.php +++ b/tests/library/Application/Controller/Action/Helper/WorkflowTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Unit Test for class Application_Controller_Action_Helper_Workflow. */ @@ -129,7 +131,7 @@ public function testChangeStateToPublished() $this->__workflowHelper->changeState($doc, 'published'); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $this->assertEquals('published', $doc->getServerState()); $this->assertNotNull($doc->getServerDatePublished()); @@ -147,7 +149,7 @@ public function testChangeStateToDeleted() $this->__workflowHelper->changeState($doc, 'deleted'); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $this->assertEquals('deleted', $doc->getServerState()); } @@ -184,7 +186,7 @@ public function testChangeStateToUnpublished() $this->__workflowHelper->changeState($doc, 'unpublished'); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $this->assertEquals('unpublished', $doc->getServerState()); } @@ -217,7 +219,7 @@ public function testWorkflowTranslationsForStates() { $states = Application_Controller_Action_Helper_Workflow::getAllStates(); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); foreach ($states as $state) { $key = 'admin_workflow_' . $state; diff --git a/tests/library/Application/Controller/ActionCRUDTest.php b/tests/library/Application/Controller/ActionCRUDTest.php index 4e114aa650..08f8ddad5d 100644 --- a/tests/library/Application/Controller/ActionCRUDTest.php +++ b/tests/library/Application/Controller/ActionCRUDTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Licence; + /** * Class Application_Controller_ActionCRUDTest * @@ -52,7 +54,7 @@ public function setUp() $this->controller = $this->getController(); $this->controller->setFormClass('Admin_Form_Licence'); - $licences = Opus_Licence::getAll(); + $licences = Licence::getAll(); $this->licenceIds = []; @@ -63,7 +65,7 @@ public function setUp() public function tearDown() { - $licences = Opus_Licence::getAll(); + $licences = Licence::getAll(); if (count($this->licenceIds) < count($licences)) { foreach ($licences as $licence) { @@ -107,7 +109,7 @@ public function testSetGetFormClass() */ public function testSetFormClassBadClass() { - $this->controller->setFormClass('Opus_Document'); + $this->controller->setFormClass('Opus\Document'); } public function testIsClassSupportedTrue() @@ -122,7 +124,7 @@ public function testIsClassSupportedFalse() public function testGetAllModels() { - $licences = Opus_Licence::getAll(); + $licences = Licence::getAll(); $models = $this->controller->getAllModels(); @@ -134,7 +136,7 @@ public function testGetModel() $model = $this->controller->getModel(2); $this->assertNotNull($model); - $this->assertInstanceOf('Opus_Licence', $model); + $this->assertInstanceOf(Licence::class, $model); $this->assertEquals(2, $model->getId()); } @@ -160,7 +162,7 @@ public function testGetModelWithStringId() $model = $this->controller->getModel('City'); $this->assertNotNull($model); - $this->assertInstanceOf('Opus_EnrichmentKey', $model); + $this->assertInstanceOf('Opus\EnrichmentKey', $model); $this->assertEquals('City', $model->getName()); } @@ -176,7 +178,7 @@ public function testGetNewModel() $model = $this->controller->getNewModel(); $this->assertNotNull($model); - $this->assertInstanceOf('Opus_Licence', $model); + $this->assertInstanceOf(Licence::class, $model); $this->assertNull($model->getId()); } @@ -199,7 +201,7 @@ public function testGetNewModelForm() public function testGetEditModelForm() { - $model = new Opus_Licence(2); + $model = new Licence(2); $form = $this->controller->getEditModelForm($model); @@ -234,7 +236,7 @@ public function testLoadDefaultMessages() public function testGetConfirmationForm() { - $model = new Opus_Licence(2); + $model = new Licence(2); $form = $this->controller->getConfirmationForm($model); $this->assertNotNull($form); $this->assertInstanceOf('Application_Form_Confirmation', $form); @@ -281,7 +283,7 @@ public function testHandlePostSave() $licenceId = $params['id']; - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $licence->delete(); } @@ -419,7 +421,7 @@ public function testHandleConfirmationPostNoParamNull() public function testHandleConfirmationPostYes() { - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setNameLong(__METHOD__); $licence->setLanguage('deu'); @@ -443,7 +445,7 @@ public function testMessagesTranslated() { $messages = $this->controller->getMessages(); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); foreach ($messages as $message) { if (is_array($message)) { diff --git a/tests/library/Application/Controller/ModuleAccessTest.phtml b/tests/library/Application/Controller/ModuleAccessTest.phtml index b4970ae3f6..93f6fb2d2c 100644 --- a/tests/library/Application/Controller/ModuleAccessTest.phtml +++ b/tests/library/Application/Controller/ModuleAccessTest.phtml @@ -71,7 +71,7 @@ class Application_Controller_ModuleAccessTest extends ControllerTestCase { $controller = $this->getController(); - Zend_Registry::set('Zend_Log', null); + \Zend_Registry::set('Zend_Log', null); $controller->getLogger(); } diff --git a/tests/library/Application/Export/ExportPluginAbstractTest.php b/tests/library/Application/Export/ExportPluginAbstractTest.php index 2e6e682304..94a20a0acb 100644 --- a/tests/library/Application/Export/ExportPluginAbstractTest.php +++ b/tests/library/Application/Export/ExportPluginAbstractTest.php @@ -39,7 +39,7 @@ class Application_Export_ExportPluginAbstractTest extends ControllerTestCase public function testIsAccessRestrictedDefaultDisabled() { $stub = $this->getMockForAbstractClass('Application_Export_ExportPluginAbstract'); - $stub->setConfig(new Zend_Config([])); + $stub->setConfig(new \Zend_Config([])); $this->assertFalse($stub->isAccessRestricted()); } @@ -83,9 +83,9 @@ public function disabledOptions() private function setAdminOnly($optionValue) { - Zend_Registry::set( + \Zend_Registry::set( 'Zend_Config', - new Zend_Config(['adminOnly' => $optionValue]) + new \Zend_Config(['adminOnly' => $optionValue]) ); } } diff --git a/tests/library/Application/Export/ExportServiceTest.php b/tests/library/Application/Export/ExportServiceTest.php index 1600b4f82c..c4a994211a 100644 --- a/tests/library/Application/Export/ExportServiceTest.php +++ b/tests/library/Application/Export/ExportServiceTest.php @@ -101,7 +101,7 @@ public function testGetDefaults() public function testSetDefaults() { - $this->_service->setDefaults(new Zend_Config([ + $this->_service->setDefaults(new \Zend_Config([ 'class' => 'Export_Model_XsltExport' ])); @@ -112,7 +112,7 @@ public function testSetDefaults() public function testAddPlugin() { - $this->_service->addPlugin('marc', new Zend_Config([ + $this->_service->addPlugin('marc', new \Zend_Config([ 'class' => 'Export_Model_XsltExport', 'stylesheet' => 'marc.xslt' ])); diff --git a/tests/library/Application/Export/ExporterTest.php b/tests/library/Application/Export/ExporterTest.php index 64390a2234..8869be26f9 100644 --- a/tests/library/Application/Export/ExporterTest.php +++ b/tests/library/Application/Export/ExporterTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\UserRole; + class Application_Export_ExporterTest extends ControllerTestCase { @@ -42,7 +44,7 @@ public function setUp() { parent::setUp(); - $guest = Opus_UserRole::fetchByName('guest'); + $guest = UserRole::fetchByName('guest'); $modules = $guest->listAccessModules(); $this->_guestExportEnabled = in_array('export', $modules); @@ -51,7 +53,7 @@ public function setUp() public function tearDown() { // restore guest access to export module - $guest = Opus_UserRole::fetchByName('guest'); + $guest = UserRole::fetchByName('guest'); if ($this->_guestExportEnabled) { $guest->appendAccessModule('export'); @@ -145,7 +147,7 @@ public function testContextProperties() public function testGetAllowedFormats() { - $exporter = Zend_Registry::get('Opus_Exporter'); + $exporter = \Zend_Registry::get('Opus_Exporter'); $formats = $exporter->getAllowedFormats(); @@ -153,7 +155,7 @@ public function testGetAllowedFormats() $this->enableSecurity(); - $guest = Opus_UserRole::fetchByName('guest'); + $guest = UserRole::fetchByName('guest'); $guest->removeAccessModule('export'); $guest->store(); @@ -164,7 +166,7 @@ public function testGetAllowedFormats() public function testGetAllowedFormatsSorted() { - $exporter = Zend_Registry::get('Opus_Exporter'); + $exporter = \Zend_Registry::get('Opus_Exporter'); $formats = $exporter->getAllowedFormats(); diff --git a/tests/library/Application/Form/AbstractTest.php b/tests/library/Application/Form/AbstractTest.php index 674d58315b..b0c9277d9e 100644 --- a/tests/library/Application/Form/AbstractTest.php +++ b/tests/library/Application/Form/AbstractTest.php @@ -55,11 +55,11 @@ public function testInit() { $this->form->init(); - $paths = $this->form->getPluginLoader(Zend_Form::DECORATOR)->getPaths(); + $paths = $this->form->getPluginLoader(\Zend_Form::DECORATOR)->getPaths(); $this->assertArrayHasKey('Application_Form_Decorator_', $paths); $this->assertContains('Application/Form/Decorator/', $paths['Application_Form_Decorator_']); - $paths = $this->form->getPluginLoader(Zend_Form::ELEMENT)->getPaths(); + $paths = $this->form->getPluginLoader(\Zend_Form::ELEMENT)->getPaths(); $this->assertArrayHasKey('Application_Form_Element_', $paths); $this->assertContains('Application/Form/Element/', $paths['Application_Form_Element_']); } @@ -83,7 +83,7 @@ public function testGetElementValue() { $form = $this->form; - $elementText = new Zend_Form_Element_Text('text'); + $elementText = new \Zend_Form_Element_Text('text'); $form->addElement($elementText); $elementText->setValue('Test Test'); @@ -95,7 +95,7 @@ public function testGetElementValue() $elementText->setValue('0'); $this->assertEquals('0', $form->getElementValue('text')); - $elementCheckbox = new Zend_Form_Element_Checkbox('checkbox'); + $elementCheckbox = new \Zend_Form_Element_Checkbox('checkbox'); $form->addElement($elementCheckbox); $elementCheckbox->setChecked(true); @@ -251,12 +251,12 @@ public function testGetApplicationConfig() $this->assertNotNull($config); $this->assertInstanceOf('Zend_Config', $config); - $this->assertSame($config, Zend_Registry::get('Zend_Config')); + $this->assertSame($config, \Zend_Registry::get('Zend_Config')); } public function testSetApplicationConfig() { - $config = new Zend_Config(['test' => true]); + $config = new \Zend_Config(['test' => true]); $this->form->setApplicationConfig($config); @@ -268,6 +268,6 @@ public function testSetApplicationConfig() $returnedConfig = $this->form->getApplicationConfig(); - $this->assertSame(Zend_Registry::get('Zend_Config'), $returnedConfig); + $this->assertSame(\Zend_Registry::get('Zend_Config'), $returnedConfig); } } diff --git a/tests/library/Application/Form/AbstractViewableTest.php b/tests/library/Application/Form/AbstractViewableTest.php index e0352a1b2d..4af12d2dc5 100644 --- a/tests/library/Application/Form/AbstractViewableTest.php +++ b/tests/library/Application/Form/AbstractViewableTest.php @@ -56,24 +56,24 @@ public function testPrepareRenderingAsView() $form = $this->form; // Elemente hinzufügen, ein leeres, ein nicht leeres - $form->addElement(new Zend_Form_Element_Text('textempty')); - $element = new Zend_Form_Element_Textarea('textareaempty'); + $form->addElement(new \Zend_Form_Element_Text('textempty')); + $element = new \Zend_Form_Element_Textarea('textareaempty'); $element->setValue(' '); // leerer String $form->addElement($element); - $element = new Zend_Form_Element_Text('textfull'); + $element = new \Zend_Form_Element_Text('textfull'); $element->setValue('Mit Text'); $form->addElement($element); - $form->addElement(new Zend_Form_Element_Checkbox('checkboxfalse')); // wird entfernt - $element = new Zend_Form_Element_Checkbox('checkboxtrue'); // wird nicht entfernt + $form->addElement(new \Zend_Form_Element_Checkbox('checkboxfalse')); // wird entfernt + $element = new \Zend_Form_Element_Checkbox('checkboxtrue'); // wird nicht entfernt $element->setChecked(true); $form->addElement($element); - $form->addElement(new Zend_Form_Element_Submit('save')); // wird entfernt - $form->addElement(new Zend_Form_Element_Button('cancel')); // wird entfernt + $form->addElement(new \Zend_Form_Element_Submit('save')); // wird entfernt + $form->addElement(new \Zend_Form_Element_Button('cancel')); // wird entfernt - $element = new Zend_Form_Element_Select('select'); + $element = new \Zend_Form_Element_Select('select'); $element->addMultiOption('option1'); $element->setValue('option1'); $form->addElement($element); // wird nicht entfernt @@ -83,7 +83,7 @@ public function testPrepareRenderingAsView() $form->addSubForm($subform, 'subformempty'); $subform2 = $this->getForm(); // Nicht leeres Unterformular - $element = new Zend_Form_Element_Text('subformtextfull'); + $element = new \Zend_Form_Element_Text('subformtextfull'); $element->setValue('Im SubForm mit Text'); $subform2->addElement($element); @@ -132,11 +132,11 @@ public function testIsEmptyFalse() { $form = $this->getForm(); - $form->addElement(new Zend_Form_Element_Text('text')); + $form->addElement(new \Zend_Form_Element_Text('text')); $this->assertFalse($form->isEmpty()); // Element - $form->addSubForm(new Zend_Form_SubForm(), 'subform'); + $form->addSubForm(new \Zend_Form_SubForm(), 'subform'); $this->assertFalse($form->isEmpty()); // Element und Unterformular diff --git a/tests/library/Application/Form/ConfirmationTest.php b/tests/library/Application/Form/ConfirmationTest.php index 92c5dbddd6..667ade89b6 100644 --- a/tests/library/Application/Form/ConfirmationTest.php +++ b/tests/library/Application/Form/ConfirmationTest.php @@ -25,6 +25,9 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Date; +use Opus\Licence; + /** * Unit Tests für Bestaetigungsformular. * @@ -99,7 +102,7 @@ public function testConstructFormEmpty() public function testGetFormLegend() { $this->useEnglish(); - $form = new Application_Form_Confirmation('Opus_Language'); + $form = new Application_Form_Confirmation('Opus\Language'); $legend = $form->getFormLegend(); @@ -124,7 +127,7 @@ public function testGetModelClassName() public function testGetModelDisplayName() { $form = new Application_Form_Confirmation('Opus_Licence'); - $form->setModel(new Opus_Licence(4)); + $form->setModel(new Licence(4)); $this->assertContains('Creative Commons - CC BY-ND - Namensnennung', $form->getModelDisplayName()); } @@ -137,7 +140,7 @@ public function testGetModelDisplayNameNoModel() public function testSetGetModelDisplayName() { $form = new Application_Form_Confirmation('Opus_Licence'); - $form->setModel(new Opus_Licence(4)); + $form->setModel(new Licence(4)); $this->assertContains('Creative Commons - CC BY-ND - Namensnennung', $form->getModelDisplayName()); $form->setModelDisplayName('custom display name'); @@ -237,42 +240,33 @@ public function testSetQuestion() public function testSetModel() { - $this->form->setModel(new Opus_Licence(2)); + $this->form->setModel(new Licence(2)); $this->assertEquals(2, $this->form->getModelId()); } - /** - * @expectedException Application_Exception - * @expectedExceptionMessage must be Opus_Model_AbstractDb - */ public function testSetModelNull() { + $this->setExpectedException(Application_Exception::class, 'must be Opus\Model\AbstractDb'); $this->form->setModel(null); } - /** - * @expectedException Application_Exception - * @expectedExceptionMessage must be Opus_Model_AbstractDb - */ public function testSetModelNotObject() { + $this->setExpectedException(Application_Exception::class, 'must be Opus\Model\AbstractDb'); $this->form->setModel('notamodel'); } - /** - * @expectedException Application_Exception - * @expectedExceptionMessage not instance of - */ public function testSetModelBadModel() { - $this->form->setModel(new Opus_Date()); + $this->setExpectedException(Application_Exception::class, 'not instance of'); + $this->form->setModel(new Date()); } public function testRenderQuestion() { $this->useEnglish(); - $this->form->setModel(new Opus_Licence(4)); + $this->form->setModel(new Licence(4)); $this->form->setQuestion('Klasse: %1$s, Name: %2$s'); @@ -286,7 +280,7 @@ public function testRenderQuestionTranslated() { $this->useEnglish(); - $this->form->setModel(new Opus_Licence(1)); + $this->form->setModel(new Licence(1)); $this->form->setQuestion('SignatureValue'); // belieber Schlüssel, es geht nur um die Übersetzung @@ -295,7 +289,7 @@ public function testRenderQuestionTranslated() public function testRenderQuestionEscaped() { - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setNameLong('

Name mit Tags

'); diff --git a/tests/library/Application/Form/Decorator/ElementHtmlTagTest.php b/tests/library/Application/Form/Decorator/ElementHtmlTagTest.php index ce6c12ad07..75d064926b 100644 --- a/tests/library/Application/Form/Decorator/ElementHtmlTagTest.php +++ b/tests/library/Application/Form/Decorator/ElementHtmlTagTest.php @@ -51,7 +51,7 @@ public function testRender() { $decorator = new Application_Form_Decorator_ElementHtmlTag(); - $element = new Zend_Form_Element_Text('Value'); + $element = new \Zend_Form_Element_Text('Value'); $decorator->setElement($element); @@ -64,7 +64,7 @@ public function testRenderWithClass() $decorator->setOption('class', 'Value-data'); - $element = new Zend_Form_Element_Text('Value'); + $element = new \Zend_Form_Element_Text('Value'); $decorator->setElement($element); diff --git a/tests/library/Application/Form/Decorator/FieldsetWithButtonsTest.php b/tests/library/Application/Form/Decorator/FieldsetWithButtonsTest.php index c06f4bc409..77e2f4c584 100644 --- a/tests/library/Application/Form/Decorator/FieldsetWithButtonsTest.php +++ b/tests/library/Application/Form/Decorator/FieldsetWithButtonsTest.php @@ -44,8 +44,8 @@ public function setUp() { parent::setUp(); - $this->form = new Zend_Form_SubForm(); - $this->form->setView(new Zend_View()); + $this->form = new \Zend_Form_SubForm(); + $this->form->setView(new \Zend_View()); $this->form->setLegend('Test'); $this->decorator = new Application_Form_Decorator_FieldsetWithButtons(); diff --git a/tests/library/Application/Form/Decorator/FileHashTest.php b/tests/library/Application/Form/Decorator/FileHashTest.php index 6a87bc7f93..9e3f080936 100644 --- a/tests/library/Application/Form/Decorator/FileHashTest.php +++ b/tests/library/Application/Form/Decorator/FileHashTest.php @@ -32,6 +32,9 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\File; + class Application_Form_Decorator_FileHashTest extends ControllerTestCase { @@ -48,7 +51,7 @@ public function testRenderWithWrongElement() { $decorator = new Application_Form_Decorator_FileHash(); - $decorator->setElement(new Zend_Form_Element_Text('text')); + $decorator->setElement(new \Zend_Form_Element_Text('text')); $this->assertEquals('content', $decorator->render('content')); } @@ -57,7 +60,7 @@ public function testRender() { $element = new Application_Form_Element_FileHash('name'); - $file = new Opus_File(116); + $file = new File(116); $hashes = $file->getHashValue(); $hash = $hashes[0]; @@ -85,7 +88,7 @@ public function testRenderWithIst() $this->useEnglish(); $element = new Application_Form_Element_FileHash('name'); - $file = new Opus_File(116); + $file = new File(116); $hashes = $file->getHashValue(); $hash = $hashes[0]; @@ -114,7 +117,7 @@ public function testRenderWithMissingFile() $this->useEnglish(); $element = new Application_Form_Element_FileHash('name'); - $file = new Opus_File(123); + $file = new File(123); $hashes = $file->getHashValue(); $hash = $hashes[0]; @@ -132,19 +135,19 @@ public function testRenderWithMissingFile() . '
Expected:1ba50dc8abc619cea3ba39f77c75c0fe
' . '' . '
Actual:' - . Zend_Registry::get('Zend_Translate')->translate('frontdoor_checksum_not_verified') + . \Zend_Registry::get('Zend_Translate')->translate('frontdoor_checksum_not_verified') . '
', $output); } public function testRenderWithFileTooBig() { $this->useEnglish(); - $config = Zend_Registry::get('Zend_Config'); - $config->merge(new Zend_Config(['checksum' => ['maxVerificationSize' => '0']])); + $config = \Zend_Registry::get('Zend_Config'); + $config->merge(new \Zend_Config(['checksum' => ['maxVerificationSize' => '0']])); $element = new Application_Form_Element_FileHash('name'); - $file = new Opus_File(116); + $file = new File(116); $hashes = $file->getHashValue(); $hash = $hashes[0]; @@ -162,7 +165,7 @@ public function testRenderWithFileTooBig() . '
Expected:1ba50dc8abc619cea3ba39f77c75c0fe
' . '' . '
Actual:' - . Zend_Registry::get('Zend_Translate')->translate('frontdoor_file_too_big') + . \Zend_Registry::get('Zend_Translate')->translate('frontdoor_file_too_big') . '
', $output); } } diff --git a/tests/library/Application/Form/Decorator/FormHelpTest.php b/tests/library/Application/Form/Decorator/FormHelpTest.php index 367866c5b4..09fbfe87c3 100644 --- a/tests/library/Application/Form/Decorator/FormHelpTest.php +++ b/tests/library/Application/Form/Decorator/FormHelpTest.php @@ -42,7 +42,7 @@ public function setUp() { parent::setUp(); - $form = new Zend_Form(); + $form = new \Zend_Form(); $this->_decorator = new Application_Form_Decorator_FormHelp(); $this->_decorator->setElement($form); } diff --git a/tests/library/Application/Form/Decorator/HtmlTagWithIdTest.php b/tests/library/Application/Form/Decorator/HtmlTagWithIdTest.php index 7c4f298e07..f16964af97 100644 --- a/tests/library/Application/Form/Decorator/HtmlTagWithIdTest.php +++ b/tests/library/Application/Form/Decorator/HtmlTagWithIdTest.php @@ -45,7 +45,7 @@ public function testRender() { $decorator = new Application_Form_Decorator_HtmlTagWithId(); - $element = new Zend_Form_Element_Text('Value'); + $element = new \Zend_Form_Element_Text('Value'); $decorator->setElement($element); $this->assertEquals('
content
', $decorator->render('content')); @@ -56,7 +56,7 @@ public function testRenderWithClass() $decorator = new Application_Form_Decorator_HtmlTagWithId(); $decorator->setOption('class', 'wrapper'); - $element = new Zend_Form_Element_Text('Value'); + $element = new \Zend_Form_Element_Text('Value'); $decorator->setElement($element); $this->assertEquals('
content
', $decorator->render('content')); diff --git a/tests/library/Application/Form/Decorator/RemoveButtonTest.php b/tests/library/Application/Form/Decorator/RemoveButtonTest.php index 869466e8e0..5d10b86ab7 100644 --- a/tests/library/Application/Form/Decorator/RemoveButtonTest.php +++ b/tests/library/Application/Form/Decorator/RemoveButtonTest.php @@ -41,7 +41,7 @@ class Application_Form_Decorator_RemoveButtonTest extends ControllerTestCase public function testRender() { - $form = new Zend_Form(); + $form = new \Zend_Form(); $form->setName('Test'); $form->addElement('submit', 'Remove'); @@ -55,7 +55,7 @@ public function testRender() public function testRenderWithHidden() { - $form = new Zend_Form(); + $form = new \Zend_Form(); $form->setName('Test'); $form->addElement('submit', 'Remove'); $element = $form->createElement('hidden', 'Id'); diff --git a/tests/library/Application/Form/Decorator/TableHeaderTest.php b/tests/library/Application/Form/Decorator/TableHeaderTest.php index f601f5f401..1526f65718 100644 --- a/tests/library/Application/Form/Decorator/TableHeaderTest.php +++ b/tests/library/Application/Form/Decorator/TableHeaderTest.php @@ -53,7 +53,7 @@ public function testConstruct() ['placement' => 'prepend', 'columns' => $this->columns] ); - $this->assertEquals(Zend_Form_Decorator_Abstract::PREPEND, $decorator->getPlacement()); + $this->assertEquals(\Zend_Form_Decorator_Abstract::PREPEND, $decorator->getPlacement()); $this->assertEquals($this->columns, $decorator->getColumns()); } @@ -81,8 +81,8 @@ public function testRender() $decorator->setColumns($this->columns); - $form = new Zend_Form(); - $form->addSubForm(new Zend_Form_SubForm(), 'subform1'); + $form = new \Zend_Form(); + $form->addSubForm(new \Zend_Form_SubForm(), 'subform1'); $decorator->setElement($form); @@ -100,8 +100,8 @@ public function testRenderEscape() $decorator->setColumns([['label' => '

HTML

']]); - $form = new Zend_Form(); - $form->addSubForm(new Zend_Form_SubForm(), 'subform1'); + $form = new \Zend_Form(); + $form->addSubForm(new \Zend_Form_SubForm(), 'subform1'); $decorator->setElement($form); @@ -121,8 +121,8 @@ public function testRenderTranslate() $decorator->setColumns([['label' => 'Value']]); - $form = new Zend_Form(); - $form->addSubForm(new Zend_Form_SubForm(), 'subform1'); + $form = new \Zend_Form(); + $form->addSubForm(new \Zend_Form_SubForm(), 'subform1'); $decorator->setElement($form); diff --git a/tests/library/Application/Form/Decorator/UpdateFieldTest.php b/tests/library/Application/Form/Decorator/UpdateFieldTest.php index 14e320546a..441ece86e5 100644 --- a/tests/library/Application/Form/Decorator/UpdateFieldTest.php +++ b/tests/library/Application/Form/Decorator/UpdateFieldTest.php @@ -42,7 +42,7 @@ public function testRender() $decorator = new Application_Form_Decorator_UpdateField(); - $decorator->setElement(new Zend_Form_Element_Text('city')); + $decorator->setElement(new \Zend_Form_Element_Text('city')); $output = $decorator->render('CONTENT'); @@ -58,7 +58,7 @@ public function testRenderNameAndId() { $decorator = new Application_Form_Decorator_UpdateField(); - $decorator->setElement(new Zend_Form_Element_Text('Name')); + $decorator->setElement(new \Zend_Form_Element_Text('Name')); $output = $decorator->render('CONTENT'); @@ -72,7 +72,7 @@ public function testRenderActive() $decorator = new Application_Form_Decorator_UpdateField(); - $element = new Zend_Form_Element_Text('city'); + $element = new \Zend_Form_Element_Text('city'); $element->setAttrib('active', true); $decorator->setElement($element); @@ -94,7 +94,7 @@ public function testTranslationEnglish() $decorator = new Application_Form_Decorator_UpdateField(); - $decorator->setElement(new Zend_Form_Element_Text('city')); + $decorator->setElement(new \Zend_Form_Element_Text('city')); $output = $decorator->render('CONTENT'); @@ -107,9 +107,9 @@ public function testTranslationGerman() $decorator = new Application_Form_Decorator_UpdateField(); - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); - $element = new Zend_Form_Element_Text('city'); + $element = new \Zend_Form_Element_Text('city'); $element->setTranslator($translator); $decorator->setElement($element); diff --git a/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php b/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php index 6f42d17c33..f4af013633 100644 --- a/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php +++ b/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php @@ -69,7 +69,7 @@ public function testOptions() public function testOptionsTranslated() { - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); foreach ($this->keys as $key) { $this->assertTrue($translator->isTranslated($key), "Key '$key' not translated."); diff --git a/tests/library/Application/Form/Element/DocumentTypeTest.php b/tests/library/Application/Form/Element/DocumentTypeTest.php index 4014a3b00a..36f019d289 100644 --- a/tests/library/Application/Form/Element/DocumentTypeTest.php +++ b/tests/library/Application/Form/Element/DocumentTypeTest.php @@ -50,7 +50,7 @@ public function testOptions() { $element = $this->getElement(); - $types = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocumentTypes(); + $types = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocumentTypes(); $this->assertEquals(count($types), count($element->getMultiOptions())); diff --git a/tests/library/Application/Form/Element/EnrichmentKeyTest.php b/tests/library/Application/Form/Element/EnrichmentKeyTest.php index df07a0183d..ffe413c070 100644 --- a/tests/library/Application/Form/Element/EnrichmentKeyTest.php +++ b/tests/library/Application/Form/Element/EnrichmentKeyTest.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\EnrichmentKey; +use Opus\Model\ModelException; + class Application_Form_Element_EnrichmentKeyTest extends FormElementTestCase { @@ -58,7 +61,7 @@ public function setUp() parent::setUp(); // create a new enrichment key with an untranslated name - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName(self::$testEnrichmentKeyName); $enrichmentKey->store(); } @@ -68,7 +71,7 @@ public function tearDown() parent::tearDown(); // remove previously created enrichment key - $enrichmentKey = new Opus_EnrichmentKey(self::$testEnrichmentKeyName); + $enrichmentKey = new EnrichmentKey(self::$testEnrichmentKeyName); if (! is_null($enrichmentKey)) { $enrichmentKey->delete(); } @@ -81,7 +84,7 @@ public function testOptions() { // NOTE: This also refreshes the cache for enrichment keys. Static state can carry over between tests. - $allOptions = Opus_EnrichmentKey::getAll(); + $allOptions = EnrichmentKey::getAll(); $element = $this->getElement(); // creates form element for enrichment keys using cached keys @@ -100,7 +103,7 @@ public function testValidation() public function testMessageTranslated() { - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); $this->assertTrue($translator->isTranslated('validation_error_unknown_enrichmentkey')); } @@ -139,14 +142,14 @@ public function testKeysWithoutTranslationNotPrefixed() * Formularelement berücksichtigt wird, muss der Cache im Test explizit * zurückgesetzt werden. * - * @throws Opus_Model_Exception + * @throws ModelException */ public function testNewEnrichmentKeyIsAvailableAsOption() { $element = $this->getElement(); $options = $element->getMultiOptions(); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('thisnamedoesnotexist'); $enrichmentKey->store(); @@ -156,7 +159,7 @@ public function testNewEnrichmentKeyIsAvailableAsOption() $this->assertEquals(count($options), count($optionsAfterInsertOfNewEnrichmentKey)); // Cache zurücksetzen, so dass der neu angelegte Enrichment-Key berücksichtigt wird - Opus_EnrichmentKey::getAll(true); + EnrichmentKey::getAll(true); $element = $this->getElement(); $optionsAfterInsertOfNewEnrichmentKey = $element->getMultiOptions(); diff --git a/tests/library/Application/Form/Element/FileHashTest.php b/tests/library/Application/Form/Element/FileHashTest.php index e2e30f8101..e345696635 100644 --- a/tests/library/Application/Form/Element/FileHashTest.php +++ b/tests/library/Application/Form/Element/FileHashTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\File; + /** * Unit Test fuer Formularelement zur Anzeige eines File Hashes. * @@ -51,7 +53,7 @@ public function testGetLabel() $element = new Application_Form_Element_FileHash('filehash'); - $file = new Opus_File(116); + $file = new File(116); $hashes = $file->getHashValue(); $hash = $hashes[0]; diff --git a/tests/library/Application/Form/Element/FileLinkTest.php b/tests/library/Application/Form/Element/FileLinkTest.php index 45cafadb7e..548761203e 100644 --- a/tests/library/Application/Form/Element/FileLinkTest.php +++ b/tests/library/Application/Form/Element/FileLinkTest.php @@ -1,5 +1,4 @@ getElement(); @@ -72,13 +74,13 @@ public function testSetValueWithFileId() $file = $element->getValue(); - $this->assertInstanceOf('Opus_File', $file); + $this->assertInstanceOf('Opus\File', $file); $this->assertEquals(130, $file->getId()); } public function testSetValueWithMissingFile() { - $file = new Opus_File(123); + $file = new File(123); $element = $this->getElement(); diff --git a/tests/library/Application/Form/Element/FileTest.php b/tests/library/Application/Form/Element/FileTest.php index 7e9b0f8fa7..e58cfa41ad 100644 --- a/tests/library/Application/Form/Element/FileTest.php +++ b/tests/library/Application/Form/Element/FileTest.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Form_Element_FileTest extends FormElementTestCase { @@ -46,7 +45,7 @@ public function setUp() public function testDecoratorPath() { $element = new $this->_formElementClass('name'); - $paths = $element->getPluginLoader(Zend_Form::DECORATOR)->getPaths(); + $paths = $element->getPluginLoader(\Zend_Form::DECORATOR)->getPaths(); $this->assertArrayHasKey('Application_Form_Decorator_', $paths); $this->assertContains('Application/Form/Decorator/', $paths['Application_Form_Decorator_']); } diff --git a/tests/library/Application/Form/Element/GrantorTest.php b/tests/library/Application/Form/Element/GrantorTest.php index dde968f510..3f546be99c 100644 --- a/tests/library/Application/Form/Element/GrantorTest.php +++ b/tests/library/Application/Form/Element/GrantorTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\DnbInstitute; + class Application_Form_Element_GrantorTest extends FormElementTestCase { @@ -51,7 +53,7 @@ public function testOptions() { $element = $this->getElement(); - $grantors = Opus_DnbInstitute::getGrantors(); + $grantors = DnbInstitute::getGrantors(); $this->assertEquals(count($grantors), count($element->getMultiOptions())); @@ -77,8 +79,8 @@ public function testSetValueForNonGrantorInstitut() $optionCount = count($element->getMultiOptions()); - $grantors = Opus_DnbInstitute::getGrantors(); - $publishers = Opus_DnbInstitute::getPublishers(); + $grantors = DnbInstitute::getGrantors(); + $publishers = DnbInstitute::getPublishers(); $nonGrantors = array_diff($publishers, $grantors); @@ -107,7 +109,7 @@ public function testSetValueForUnknownId() $optionCount = count($element->getMultiOptions()); // getting unused id for test - $institutes = Opus_DnbInstitute::getAll(); + $institutes = DnbInstitute::getAll(); $instituteIds = array_map(function ($item) { return $item->getId(); @@ -129,7 +131,7 @@ public function testSetValueInstituteNotAddedTwice() { $element = $this->getElement(); - $grantors = Opus_DnbInstitute::getGrantors(); + $grantors = DnbInstitute::getGrantors(); $this->assertGreaterThan(0, count($grantors)); diff --git a/tests/library/Application/Form/Element/HitsPerPageTest.php b/tests/library/Application/Form/Element/HitsPerPageTest.php index cfc2b6ec96..9099810711 100644 --- a/tests/library/Application/Form/Element/HitsPerPageTest.php +++ b/tests/library/Application/Form/Element/HitsPerPageTest.php @@ -60,7 +60,7 @@ public function testInit() public function testInitWithCustomDefaultRows() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'searchengine' => ['solr' => ['numberOfDefaultSearchResults' => '15']] ])); diff --git a/tests/library/Application/Form/Element/IdentifierTest.php b/tests/library/Application/Form/Element/IdentifierTest.php index d58c26cef1..af79d97b57 100644 --- a/tests/library/Application/Form/Element/IdentifierTest.php +++ b/tests/library/Application/Form/Element/IdentifierTest.php @@ -31,6 +31,9 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Identifier; + class Application_Form_Element_IdentifierTest extends FormElementTestCase { @@ -52,7 +55,7 @@ public function testOptions() $translator = $element->getTranslator(); - $identifier = new Opus_Identifier(); + $identifier = new Identifier(); $types = $identifier->getField('Type')->getDefault(); diff --git a/tests/library/Application/Form/Element/LanguageScopeTest.php b/tests/library/Application/Form/Element/LanguageScopeTest.php index 07a5c18bde..f6b978ecc6 100644 --- a/tests/library/Application/Form/Element/LanguageScopeTest.php +++ b/tests/library/Application/Form/Element/LanguageScopeTest.php @@ -65,7 +65,7 @@ public function testOptions() public function testOptionsTranslated() { - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); foreach ($this->keys as $key) { $this->assertTrue( diff --git a/tests/library/Application/Form/Element/LanguageTest.php b/tests/library/Application/Form/Element/LanguageTest.php index 14c9e37364..6a139ae2f5 100644 --- a/tests/library/Application/Form/Element/LanguageTest.php +++ b/tests/library/Application/Form/Element/LanguageTest.php @@ -92,5 +92,6 @@ public function testValidation() public function testUnknownLanguage() { + $this->markTestIncomplete(); } } diff --git a/tests/library/Application/Form/Element/LanguageTypeTest.php b/tests/library/Application/Form/Element/LanguageTypeTest.php index c6da046a26..cdbf3e00b9 100644 --- a/tests/library/Application/Form/Element/LanguageTypeTest.php +++ b/tests/library/Application/Form/Element/LanguageTypeTest.php @@ -64,7 +64,7 @@ public function testOptions() public function testOptionsTranslated() { - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); foreach ($this->keys as $key) { $this->assertTrue($translator->isTranslated('Opus_Language_Type_Value_' . $key)); diff --git a/tests/library/Application/Form/Element/MultiCheckboxTest.php b/tests/library/Application/Form/Element/MultiCheckboxTest.php index c78374dcca..5d521b8d6f 100644 --- a/tests/library/Application/Form/Element/MultiCheckboxTest.php +++ b/tests/library/Application/Form/Element/MultiCheckboxTest.php @@ -46,7 +46,7 @@ public function setUp() public function testDecoratorPath() { $element = new $this->_formElementClass('name'); - $paths = $element->getPluginLoader(Zend_Form::DECORATOR)->getPaths(); + $paths = $element->getPluginLoader(\Zend_Form::DECORATOR)->getPaths(); $this->assertArrayHasKey('Application_Form_Decorator_', $paths); $this->assertContains('Application/Form/Decorator/', $paths['Application_Form_Decorator_']); } diff --git a/tests/library/Application/Form/Element/NumberTest.php b/tests/library/Application/Form/Element/NumberTest.php index 1ea80cac21..a6d3a96816 100644 --- a/tests/library/Application/Form/Element/NumberTest.php +++ b/tests/library/Application/Form/Element/NumberTest.php @@ -71,7 +71,7 @@ public function testCustomSize() public function testMessagesTranslated() { - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); $this->assertTrue($translator->isTranslated('validation_error_number_tooSmall')); $this->assertTrue($translator->isTranslated('validation_error_number_notBetween')); diff --git a/tests/library/Application/Form/Element/PersonRoleTest.php b/tests/library/Application/Form/Element/PersonRoleTest.php index 303c0f4085..1d3d01e669 100644 --- a/tests/library/Application/Form/Element/PersonRoleTest.php +++ b/tests/library/Application/Form/Element/PersonRoleTest.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/tests/library/Application/Form/Element/PositionTest.php b/tests/library/Application/Form/Element/PositionTest.php index c0c5281042..465180877d 100644 --- a/tests/library/Application/Form/Element/PositionTest.php +++ b/tests/library/Application/Form/Element/PositionTest.php @@ -52,7 +52,7 @@ public function testOptions() $options = $element->getMultiOptions(); - $collectionRoles = Opus_CollectionRole::fetchAll(); + $collectionRoles = \Opus\CollectionRole::fetchAll(); // One additional option for last position $this->assertEquals(count($collectionRoles) + 1, count($options)); diff --git a/tests/library/Application/Form/Element/PublisherTest.php b/tests/library/Application/Form/Element/PublisherTest.php index d0dc236717..6419692b2b 100644 --- a/tests/library/Application/Form/Element/PublisherTest.php +++ b/tests/library/Application/Form/Element/PublisherTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\DnbInstitute; + class Application_Form_Element_PublisherTest extends FormElementTestCase { @@ -51,7 +53,7 @@ public function testOptions() { $element = $this->getElement(); - $publishers = Opus_DnbInstitute::getPublishers(); + $publishers = DnbInstitute::getPublishers(); $this->assertEquals(count($publishers), count($element->getMultiOptions())); @@ -77,8 +79,8 @@ public function testSetValueForNonPublisherInstitut() $optionCount = count($element->getMultiOptions()); - $grantors = Opus_DnbInstitute::getGrantors(); - $publishers = Opus_DnbInstitute::getPublishers(); + $grantors = DnbInstitute::getGrantors(); + $publishers = DnbInstitute::getPublishers(); $nonPublishers = array_diff($grantors, $publishers); @@ -107,7 +109,7 @@ public function testSetValueForUnknownId() $optionCount = count($element->getMultiOptions()); // getting unused id for test - $institutes = Opus_DnbInstitute::getAll(); + $institutes = DnbInstitute::getAll(); $instituteIds = array_map(function ($item) { return $item->getId(); @@ -129,7 +131,7 @@ public function testSetValueInstituteNotAddedTwice() { $element = $this->getElement(); - $publishers = Opus_DnbInstitute::getPublishers(); + $publishers = DnbInstitute::getPublishers(); $this->assertGreaterThan(0, count($publishers)); diff --git a/tests/library/Application/Form/Element/RolesTest.php b/tests/library/Application/Form/Element/RolesTest.php index 389da60a6e..90031ea16b 100644 --- a/tests/library/Application/Form/Element/RolesTest.php +++ b/tests/library/Application/Form/Element/RolesTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\UserRole; + /** * Unit Tests von Formularelement fuer die Auswahl von Rollen. * @@ -54,7 +56,7 @@ public function testGetRolesMultiOptions() $options = $element->getRolesMultiOptions(); - $this->assertEquals(count(Opus_UserRole::getAll()), count($options)); + $this->assertEquals(count(UserRole::getAll()), count($options)); foreach ($options as $value => $label) { $this->assertEquals($value, $label); @@ -75,8 +77,8 @@ public function testSetValueWithRoles() $element = new Application_Form_Element_Roles('Roles'); $element->setValue([ - Opus_UserRole::fetchByName('docsadmin'), - Opus_UserRole::fetchByName('reviewer'), + UserRole::fetchByName('docsadmin'), + UserRole::fetchByName('reviewer'), ]); $this->assertEquals(['docsadmin', 'reviewer'], $element->getValue()); @@ -97,7 +99,7 @@ public function testGetRoles() $this->assertCount(count($expectedRoles), $roles); foreach ($roles as $role) { - $this->assertInstanceOf('Opus_UserRole', $role); + $this->assertInstanceOf('Opus\UserRole', $role); $this->assertContains($role->getName(), $expectedRoles); // removed already checked roles from expectation diff --git a/tests/library/Application/Form/Element/SeriesTest.php b/tests/library/Application/Form/Element/SeriesTest.php index 68dc63a650..f9a6829060 100644 --- a/tests/library/Application/Form/Element/SeriesTest.php +++ b/tests/library/Application/Form/Element/SeriesTest.php @@ -1,5 +1,4 @@ getElement(); - $allSeries = Opus_Series::getAll(); + $allSeries = Series::getAll(); $this->assertEquals(count($allSeries), count($element->getMultiOptions())); @@ -80,7 +82,7 @@ public function testValidation() public function testTranslation() { - $translator = Zend_Registry::get(Application_Translate::REGISTRY_KEY); + $translator = \Zend_Registry::get(Application_Translate::REGISTRY_KEY); $this->assertTrue($translator->isTranslated('validation_error_int')); } diff --git a/tests/library/Application/Form/Element/SortOrderTest.php b/tests/library/Application/Form/Element/SortOrderTest.php index 518b183162..a58332c6a2 100644 --- a/tests/library/Application/Form/Element/SortOrderTest.php +++ b/tests/library/Application/Form/Element/SortOrderTest.php @@ -70,7 +70,7 @@ public function testCustomSize() public function testMessagesTranslated() { - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); $this->assertTrue($translator->isTranslated('validation_error_int')); $this->assertTrue($translator->isTranslated('validation_error_negative_number')); diff --git a/tests/library/Application/Form/Element/SubmitTest.php b/tests/library/Application/Form/Element/SubmitTest.php index 239adc21fd..ab1edc9e2c 100644 --- a/tests/library/Application/Form/Element/SubmitTest.php +++ b/tests/library/Application/Form/Element/SubmitTest.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/tests/library/Application/Form/Element/ThemeTest.php b/tests/library/Application/Form/Element/ThemeTest.php index 393e9dc060..1f192ee199 100644 --- a/tests/library/Application/Form/Element/ThemeTest.php +++ b/tests/library/Application/Form/Element/ThemeTest.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Form_Element_ThemeTest extends FormElementTestCase diff --git a/tests/library/Application/Form/Element/TranslationModulesTest.php b/tests/library/Application/Form/Element/TranslationModulesTest.php index 9697b33e06..2e20cd4404 100644 --- a/tests/library/Application/Form/Element/TranslationModulesTest.php +++ b/tests/library/Application/Form/Element/TranslationModulesTest.php @@ -40,7 +40,7 @@ class Application_Form_Element_TranslationModulesTest extends ControllerTestCase public function testInit() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish']]] ])); @@ -53,7 +53,7 @@ public function testInit() public function testInitAllModules() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => null]]] ])); diff --git a/tests/library/Application/Form/Element/TranslationTest.php b/tests/library/Application/Form/Element/TranslationTest.php index c14836aadc..bd5870c182 100644 --- a/tests/library/Application/Form/Element/TranslationTest.php +++ b/tests/library/Application/Form/Element/TranslationTest.php @@ -75,7 +75,7 @@ public function testUpdateTranslations() $key = 'testkey'; - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $dao->remove($key); @@ -99,8 +99,8 @@ public function testUpdateTranslationsOnlyIfChanged() $element = new Application_Form_Element_Translation('DisplayName'); - $translate = Zend_Registry::get('Zend_Translate'); - $dao = new Opus_Translate_Dao(); + $translate = \Zend_Registry::get('Zend_Translate'); + $dao = new \Opus\Translate\Dao(); $dao->remove($key); @@ -167,7 +167,7 @@ public function testKeepModuleWhenUpdatingTranslation() { $element = new Application_Form_Element_Translation('Content'); - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $dao->removeAll(); $key = 'help_content_contact'; diff --git a/tests/library/Application/Form/Filter/Form_Filter_ReplaceNewlinesTest.php b/tests/library/Application/Form/Filter/Form_Filter_ReplaceNewlinesTest.php index b0c93048d8..787c8774a5 100644 --- a/tests/library/Application/Form/Filter/Form_Filter_ReplaceNewlinesTest.php +++ b/tests/library/Application/Form/Filter/Form_Filter_ReplaceNewlinesTest.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/tests/library/Application/Form/Model/AbstractTest.php b/tests/library/Application/Form/Model/AbstractTest.php index 866cdc751c..6cad3f2a36 100644 --- a/tests/library/Application/Form/Model/AbstractTest.php +++ b/tests/library/Application/Form/Model/AbstractTest.php @@ -89,25 +89,25 @@ public function testProcessPostCancel() public function testGetModel() { - $this->form->setModelClass('Opus_Licence'); + $this->form->setModelClass('Opus\Licence'); $this->form->getElement('Id')->setValue(1); $model = $this->form->getModel(); $this->assertNotNull($model); - $this->assertInstanceOf('Opus_Licence', $model); + $this->assertInstanceOf('Opus\Licence', $model); $this->assertEquals(1, $model->getId()); } public function testGetModelNewInstance() { - $this->form->setModelClass('Opus_Licence'); + $this->form->setModelClass('Opus\Licence'); $model = $this->form->getModel(); $this->assertNotNull($model); - $this->assertInstanceOf('Opus_Licence', $model); + $this->assertInstanceOf('Opus\Licence', $model); $this->assertNull($model->getId()); } @@ -126,7 +126,7 @@ public function testGetModelNoModelClass() */ public function testGetModelBadModelId() { - $this->form->setModelClass('Opus_Licence'); + $this->form->setModelClass('Opus\Licence'); $this->form->getElement('Id')->setValue('notAnId'); $this->form->getModel(); } @@ -137,7 +137,7 @@ public function testGetModelBadModelId() */ public function testGetModelUnknownModelId() { - $this->form->setModelClass('Opus_Licence'); + $this->form->setModelClass('Opus\Licence'); $this->form->getElement('Id')->setValue(1000); $this->form->getModel(); } @@ -148,9 +148,9 @@ public function testGetModelUnknownModelId() */ public function testSetGetModelClass() { - $this->form->setModelClass('Opus_Licence'); + $this->form->setModelClass('Opus\Licence'); - $this->assertEquals('Opus_Licence', $this->form->getModelClass()); + $this->assertEquals('Opus\Licence', $this->form->getModelClass()); $this->form->setModelClass(null); diff --git a/tests/library/Application/Form/Model/TableTest.php b/tests/library/Application/Form/Model/TableTest.php index 6599054bc2..860906c663 100644 --- a/tests/library/Application/Form/Model/TableTest.php +++ b/tests/library/Application/Form/Model/TableTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Licence; + class Application_Form_Model_TableTest extends ControllerTestCase { @@ -65,7 +67,7 @@ public function testSetGetModels() { $form = new Application_Form_Model_Table(); - $models = Opus_Licence::getAll(); + $models = Licence::getAll(); $form->setModels($models); @@ -80,7 +82,7 @@ public function testSetModelNotArray() { $form = new Application_Form_Model_Table(); - $models = Opus_Licence::getAll(); + $models = Licence::getAll(); $form->setModels('notanarray'); } @@ -89,7 +91,7 @@ public function testSetGetModelsNull() { $form = new Application_Form_Model_Table(); - $form->setModels(Opus_Licence::getAll()); + $form->setModels(Licence::getAll()); $this->assertNotNull($form->getModels()); @@ -178,7 +180,7 @@ public function testIsRenderShowActionLinkLog() $form->setLogger($logger); - $mock = $this->getMockBuilder(Zend_Controller_Action_Interface::class)->getMock(); + $mock = $this->getMockBuilder(\Zend_Controller_Action_Interface::class)->getMock(); $form->setController($mock); $this->assertTrue($form->isRenderShowActionLink(null)); @@ -192,7 +194,7 @@ public function testIsModifiableLog() $form->setLogger($logger); - $mock = $this->getMockBuilder(Zend_Controller_Action_Interface::class)->getMock(); + $mock = $this->getMockBuilder(\Zend_Controller_Action_Interface::class)->getMock(); $form->setController($mock); $this->assertTrue($form->isModifiable(null)); @@ -206,7 +208,7 @@ public function testIsDeletableLog() $form->setLogger($logger); - $mock = $this->getMockBuilder(Zend_Controller_Action_Interface::class)->getMock(); + $mock = $this->getMockBuilder(\Zend_Controller_Action_Interface::class)->getMock(); $form->setController($mock); $this->assertTrue($form->isDeletable(null)); @@ -220,7 +222,7 @@ public function testIsUsedLog() $form->setLogger($logger); - $mock = $this->getMockBuilder(Zend_Controller_Action_Interface::class)->getMock(); + $mock = $this->getMockBuilder(\Zend_Controller_Action_Interface::class)->getMock(); $form->setController($mock); $this->assertFalse($form->isUsed(null)); @@ -234,7 +236,7 @@ public function testIsProtectedLog() $form->setLogger($logger); - $mock = $this->getMockBuilder(Zend_Controller_Action_Interface::class)->getMock(); + $mock = $this->getMockBuilder(\Zend_Controller_Action_Interface::class)->getMock(); $form->setController($mock); $this->assertFalse($form->isProtected(null)); @@ -248,7 +250,7 @@ public function testGetRowCssClassLog() $form->setLogger($logger); - $mock = $this->getMockBuilder(Zend_Controller_Action_Interface::class)->getMock(); + $mock = $this->getMockBuilder(\Zend_Controller_Action_Interface::class)->getMock(); $form->setController($mock); $this->assertNull($form->getRowCssClass(null)); @@ -262,7 +264,7 @@ public function testGetRowTooltipLog() $form->setLogger($logger); - $mock = $this->getMockBuilder(Zend_Controller_Action_Interface::class)->getMock(); + $mock = $this->getMockBuilder(\Zend_Controller_Action_Interface::class)->getMock(); $form->setController($mock); $this->assertNull($form->getRowTooltip(null)); diff --git a/tests/library/Application/Form/Validate/CollectionRoleOaiNameUniqueTest.php b/tests/library/Application/Form/Validate/CollectionRoleOaiNameUniqueTest.php index 7c39749094..155c834d49 100644 --- a/tests/library/Application/Form/Validate/CollectionRoleOaiNameUniqueTest.php +++ b/tests/library/Application/Form/Validate/CollectionRoleOaiNameUniqueTest.php @@ -1,5 +1,4 @@ delete(); } @@ -75,7 +77,7 @@ public function testIsValidFalse() public function testGetModel() { - $collectionRole = new Opus_CollectionRole(); + $collectionRole = new CollectionRole(); $collectionRole->setName('NewTestColRoleName'); $collectionRole->setOaiName('NewTestColRoleOaiName'); $collectionRole->store(); diff --git a/tests/library/Application/Form/Validate/IdentifierTest.php b/tests/library/Application/Form/Validate/IdentifierTest.php index ca4db1e046..5086c28315 100644 --- a/tests/library/Application/Form/Validate/IdentifierTest.php +++ b/tests/library/Application/Form/Validate/IdentifierTest.php @@ -41,13 +41,13 @@ class Application_Form_Validate_IdentifierTest extends ControllerTestCase /** * Represents an validator-object for identifier-elements. - * @var Zend_Validate_Abstract + * @var \Zend_Validate_Abstract */ private $_validator; /** * Form element providing type of identifier. - * @var Zend_Form_Element + * @var \Zend_Form_Element */ private $_element; @@ -60,7 +60,7 @@ public function setUp() $this->makeConfigurationModifiable(); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'identifier' => ['validation' => [ 'isbn' => [ 'class' => 'Opus\Validate\Isbn' @@ -288,7 +288,7 @@ public function testMessagesKeyValid() */ public function testTranslationExists() { - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $config = Application_Configuration::getInstance()->getConfig(); $validators = $config->identifier->validation->toArray(); foreach ($validators as $key => $val) { diff --git a/tests/library/Application/Form/Validate/LoginAvailableTest.php b/tests/library/Application/Form/Validate/LoginAvailableTest.php index a9573cf045..d3b297f5c8 100644 --- a/tests/library/Application/Form/Validate/LoginAvailableTest.php +++ b/tests/library/Application/Form/Validate/LoginAvailableTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Account; + /** * */ @@ -47,7 +49,7 @@ public function setUp() parent::setUp(); $this->validator = new Application_Form_Validate_LoginAvailable(); - $user = new Opus_Account(); + $user = new Account(); $user->setLogin('user'); $user->setPassword('userpwd'); $user->store(); diff --git a/tests/library/Application/Form/Validate/MultiSubForm/RepeatedLanguagesTest.php b/tests/library/Application/Form/Validate/MultiSubForm/RepeatedLanguagesTest.php index 18f0b855cb..47eb3863fd 100644 --- a/tests/library/Application/Form/Validate/MultiSubForm/RepeatedLanguagesTest.php +++ b/tests/library/Application/Form/Validate/MultiSubForm/RepeatedLanguagesTest.php @@ -88,17 +88,17 @@ public function testGetSelectedLanguages() */ public function testPrepareValidation() { - $form = new Zend_Form(); + $form = new \Zend_Form(); $titleCount = 3; for ($index = 0; $index < $titleCount; $index++) { - $subform = new Zend_Form_SubForm(); + $subform = new \Zend_Form_SubForm(); $subform->addElement(new Application_Form_Element_Language('Language')); $form->addSubForm($subform, 'Title' . $index); } - $subform = new Zend_Form_Subform(); + $subform = new \Zend_Form_Subform(); $subform->addElement('submit', 'Add'); $form->addSubForm($subform, 'Actions'); diff --git a/tests/library/Application/Form/Validate/MultiSubForm/RepeatedValuesTest.php b/tests/library/Application/Form/Validate/MultiSubForm/RepeatedValuesTest.php index 33d0c66498..49a812f0f8 100644 --- a/tests/library/Application/Form/Validate/MultiSubForm/RepeatedValuesTest.php +++ b/tests/library/Application/Form/Validate/MultiSubForm/RepeatedValuesTest.php @@ -189,13 +189,13 @@ public function testPrepareValidation() { $validator = new Application_Form_Validate_MultiSubForm_RepeatedValues('Language', 'testmessage'); - $form = new Zend_Form(); + $form = new \Zend_Form(); - $subform = new Zend_Form_SubForm(); + $subform = new \Zend_Form_SubForm(); $subform->addElement('text', 'Language'); $form->addSubForm($subform, 'subform1'); - $subform = new Zend_Form_SubForm(); + $subform = new \Zend_Form_SubForm(); $subform->addElement('text', 'Language'); $form->addSubForm($subform, 'subform2'); @@ -227,13 +227,13 @@ public function testPrepareValidationWithOtherElements() { $validator = new Application_Form_Validate_MultiSubForm_RepeatedValues('Value', 'testmessage', 'Language'); - $form = new Zend_Form(); + $form = new \Zend_Form(); - $subform = new Zend_Form_SubForm(); + $subform = new \Zend_Form_SubForm(); $subform->addElement('text', 'Value'); $form->addSubForm($subform, 'subform1'); - $subform = new Zend_Form_SubForm(); + $subform = new \Zend_Form_SubForm(); $subform->addElement('text', 'Value'); $form->addSubForm($subform, 'subform2'); diff --git a/tests/library/Application/Form/Validate/OrcidTest.php b/tests/library/Application/Form/Validate/OrcidTest.php index 00d9916703..11e417d931 100644 --- a/tests/library/Application/Form/Validate/OrcidTest.php +++ b/tests/library/Application/Form/Validate/OrcidTest.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_Form_Validate_OrcidTest extends ControllerTestCase diff --git a/tests/library/Application/Form/Validate/RequiredIfTest.php b/tests/library/Application/Form/Validate/RequiredIfTest.php index 066a272ae3..cbaa23ba43 100644 --- a/tests/library/Application/Form/Validate/RequiredIfTest.php +++ b/tests/library/Application/Form/Validate/RequiredIfTest.php @@ -28,7 +28,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/tests/library/Application/Form/Validate/RequiredIfValueTest.php b/tests/library/Application/Form/Validate/RequiredIfValueTest.php index b714752556..2f9f27efcf 100644 --- a/tests/library/Application/Form/Validate/RequiredIfValueTest.php +++ b/tests/library/Application/Form/Validate/RequiredIfValueTest.php @@ -28,7 +28,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/tests/library/Application/Form/Validate/SeriesNumberAvailableTest.php b/tests/library/Application/Form/Validate/SeriesNumberAvailableTest.php index 89fe446c8a..45d5e7fc2f 100644 --- a/tests/library/Application/Form/Validate/SeriesNumberAvailableTest.php +++ b/tests/library/Application/Form/Validate/SeriesNumberAvailableTest.php @@ -77,7 +77,7 @@ public function testIsValidTrueForThisDocument() public function testMessagesTranslated() { - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); $this->assertTrue($translator->isTranslated('admin_series_error_number_exists')); } diff --git a/tests/library/Application/Form/Validate/ValuePresentInSubformsTest.php b/tests/library/Application/Form/Validate/ValuePresentInSubformsTest.php index 08456b8fc8..cf84e1b5de 100644 --- a/tests/library/Application/Form/Validate/ValuePresentInSubformsTest.php +++ b/tests/library/Application/Form/Validate/ValuePresentInSubformsTest.php @@ -28,7 +28,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** diff --git a/tests/library/Application/Import/ImporterTest.php b/tests/library/Application/Import/ImporterTest.php index f8b0ebeedf..c2460a0844 100644 --- a/tests/library/Application/Import/ImporterTest.php +++ b/tests/library/Application/Import/ImporterTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Log; + class Application_Import_ImporterTest extends ControllerTestCase { @@ -40,14 +43,14 @@ public function testImportEnrichmentWithoutValue() { $xml = file_get_contents(APPLICATION_PATH . '/tests/import/test_import_enrichment_without_value.xml'); - $importer = new Application_Import_Importer($xml, false, Opus_Log::get()); + $importer = new Application_Import_Importer($xml, false, Log::get()); $importer->run(); $document = $importer->getDocument(); $this->assertNotNull($document); - $this->assertInstanceOf('Opus_Document', $document); + $this->assertInstanceOf('Opus\Document', $document); $this->assertCount(1, $document->getEnrichment()); $this->assertEquals('Berlin', $document->getEnrichmentValue('City')); @@ -55,7 +58,7 @@ public function testImportEnrichmentWithoutValue() public function testFromArray() { - $doc = new Opus_Document(146); + $doc = Document::get(146); // var_dump($doc->toArray()); } diff --git a/tests/library/Application/Import/TarPackageReaderTest.php b/tests/library/Application/Import/TarPackageReaderTest.php index 01db536051..bc823eae61 100644 --- a/tests/library/Application/Import/TarPackageReaderTest.php +++ b/tests/library/Application/Import/TarPackageReaderTest.php @@ -44,7 +44,7 @@ public function setUp() public function testReadPackageWithXmlFile() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'filetypes' => ['xml' => ['mimeType' => [ 'text/xml', 'application/xml' ]]] diff --git a/tests/library/Application/Import/ZipPackageReaderTest.php b/tests/library/Application/Import/ZipPackageReaderTest.php index b0968397d5..55e15742df 100644 --- a/tests/library/Application/Import/ZipPackageReaderTest.php +++ b/tests/library/Application/Import/ZipPackageReaderTest.php @@ -44,7 +44,7 @@ public function setUp() public function testReadPackageWithXmlFile() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'filetypes' => ['xml' => ['mimeType' => [ 'text/xml', 'application/xml' ]]] diff --git a/tests/library/Application/Model/AbstractTest.php b/tests/library/Application/Model/AbstractTest.php index 2c536b61c9..784a53dfd3 100644 --- a/tests/library/Application/Model/AbstractTest.php +++ b/tests/library/Application/Model/AbstractTest.php @@ -73,12 +73,12 @@ public function testGetConfig() $config = $this->_model->getConfig(); $this->assertInstanceOf('Zend_Config', $config); - $this->assertEquals(Zend_Registry::get('Zend_Config'), $config); + $this->assertEquals(\Zend_Registry::get('Zend_Config'), $config); } public function testSetConfig() { - $config = new Zend_Config([]); + $config = new \Zend_Config([]); $this->_model->setConfig($config); diff --git a/tests/library/Application/Search/FacetManagerTest.php b/tests/library/Application/Search/FacetManagerTest.php index 9c7349ae20..9fae09b48f 100644 --- a/tests/library/Application/Search/FacetManagerTest.php +++ b/tests/library/Application/Search/FacetManagerTest.php @@ -98,7 +98,7 @@ public function testGetActiveFacets() public function testGetFacetEnrichment() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'searchengine' => ['solr' => ['facets' => 'enrichment_Audience']] ])); @@ -113,7 +113,7 @@ public function testGetFacetEnrichment() public function testGetFacetEnrichmentTranslated() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'searchengine' => ['solr' => ['facets' => 'enrichment_Audience']] ])); @@ -143,7 +143,7 @@ public function testGetFacetEnrichmentBoolean() public function testGetFacetConfigForFacetteWithDotInName() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'search' => ['facet' => ['enrichment_opus-source' => ['heading' => 'EnrichmentOpusSource']]] ])); @@ -165,7 +165,7 @@ public function testFacetLimit() public function testFacetSortCrit() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'search' => ['facet' => ['subject' => ['sort' => 'lexi']]] ])); diff --git a/tests/library/Application/Security/AclProviderTest.php b/tests/library/Application/Security/AclProviderTest.php index c69ef03fac..1922d83f89 100644 --- a/tests/library/Application/Security/AclProviderTest.php +++ b/tests/library/Application/Security/AclProviderTest.php @@ -1,5 +1,4 @@ setName('_test'); $testRole->appendAccessModule('documents'); $this->roleId = $testRole->store(); - $userAccount = new Opus_Account(); + $userAccount = new Account(); $userAccount->setLogin('role_tester') ->setPassword('role_tester'); $userAccount->setRole($testRole); $this->userId = $userAccount->store(); // fake authentication - Zend_Auth::getInstance()->getStorage()->write('role_tester'); + \Zend_Auth::getInstance()->getStorage()->write('role_tester'); } public function tearDown() { parent::tearDown(); - $testRole = new Opus_UserRole($this->roleId); + $testRole = new UserRole($this->roleId); $testRole->delete(); - $userAccount = new Opus_Account($this->userId); + $userAccount = new Account($this->userId); $userAccount->delete(); } @@ -73,7 +75,7 @@ public function testGetAcls() { $aclProvider = new Application_Security_AclProvider(); $acl = $aclProvider->getAcls(); - $this->assertTrue($acl instanceof Zend_Acl, 'Expected instance of Zend_Acl'); + $this->assertTrue($acl instanceof \Zend_Acl, 'Expected instance of Zend_Acl'); $this->assertTrue( $acl->isAllowed(Application_Security_AclProvider::ACTIVE_ROLE, 'documents'), "expected user has access to resource 'documents'" @@ -86,17 +88,17 @@ public function testGetAcls() public function testRoleNameLikeUserName() { - $userAccount = new Opus_Account(); + $userAccount = new Account(); $userAccount->setLogin('_test') ->setPassword('role_tester'); - $userAccount->setRole(new Opus_UserRole($this->roleId)); + $userAccount->setRole(new UserRole($this->roleId)); $userId = $userAccount->store(); - Zend_Auth::getInstance()->getStorage()->write('_test'); + \Zend_Auth::getInstance()->getStorage()->write('_test'); $aclProvider = new Application_Security_AclProvider(); $acl = $aclProvider->getAcls(); $userAccount->delete(); - $this->assertTrue($acl instanceof Zend_Acl, 'Excpected instance of Zend_Acl'); + $this->assertTrue($acl instanceof \Zend_Acl, 'Excpected instance of Zend_Acl'); $this->assertTrue( $acl->isAllowed(Application_Security_AclProvider::ACTIVE_ROLE, 'documents'), "expected user has access to resource 'documents'" diff --git a/tests/library/Application/Security/RoleConfigTest.php b/tests/library/Application/Security/RoleConfigTest.php index 76ae5fa6c7..6565945a1b 100644 --- a/tests/library/Application/Security/RoleConfigTest.php +++ b/tests/library/Application/Security/RoleConfigTest.php @@ -1,5 +1,4 @@ guestRole = new Opus_UserRole(2); + $this->guestRole = new UserRole(2); $this->guestRole->appendAccessModule('documents'); } @@ -57,7 +58,7 @@ public function tearDown() public function testApplyPermissions() { - $acl = new Zend_Acl(); + $acl = new \Zend_Acl(); $this->setExpectedException('Zend_Acl_Role_Registry_Exception'); $acl->isAllowed($this->guestRole, 'documents'); $roleConfig = new Application_Security_RoleConfig('guest'); diff --git a/tests/library/Application/Translate/TranslationManagerTest.php b/tests/library/Application/Translate/TranslationManagerTest.php index 0183bbd868..b57eff07f6 100644 --- a/tests/library/Application/Translate/TranslationManagerTest.php +++ b/tests/library/Application/Translate/TranslationManagerTest.php @@ -59,7 +59,7 @@ public function setUp() public function tearDown() { - $translationDb = new Opus_Translate_Dao(); + $translationDb = $this->getStorageInterface(); $translationDb->removeAll(); parent::tearDown(); @@ -67,7 +67,7 @@ public function tearDown() public function testGetFiles() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish']]] ])); @@ -173,7 +173,7 @@ public function testGetDuplicateKeys() { $manager = $this->object; - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => null]]] ])); @@ -201,7 +201,7 @@ public function testKeyMaxLength() { $translations = $this->object; - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => null]]] ])); @@ -247,7 +247,7 @@ public function testGetMergedTranslations() // TODO check translations from TMX, TMX+DB and just DB - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->setTranslation('yes', ['de' => 'Ja', 'en' => 'Yes']); $translations = $manager->getMergedTranslations('key'); @@ -282,7 +282,7 @@ public function testGetMergedTranslationDatabaseFiltered() $this->assertCount(1, $translations); $this->assertArrayHasKey('answer_no', $translations); - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->setTranslation('answer_yes', ['de' => 'JA', 'en' => 'YES']); @@ -330,7 +330,7 @@ public function testFilterEditedTranslations() $this->assertArrayHasKey('answer_no', $translations); $this->assertArrayHasKey('Field_Value_False', $translations); - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->setTranslation('answer_no', ['de' => 'Nicht', 'en' => 'No']); $translations = $manager->getMergedTranslations('key'); @@ -346,7 +346,7 @@ public function testReset() $testKey = 'answer_yes'; - $dao = new Opus_Translate_Dao(); + $dao = $this->getStorageInterface(); $dao->setTranslation($testKey, [ 'en' => 'YesTest', @@ -378,7 +378,7 @@ public function testDelete() { $manager = $this->object; - $dao = new Opus_Translate_Dao(); + $dao = $this->getStorageInterface(); $key = 'customTestKey'; @@ -657,7 +657,7 @@ public function testFilterByStateEdited() { $manager = $this->object; - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->setTranslation('testkey', [ 'en' => 'Testvalue', @@ -683,7 +683,7 @@ public function testFilterByStateAdded() { $manager = $this->object; - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->setTranslation('testkey', [ 'en' => 'Testvalue', @@ -704,7 +704,7 @@ public function testFilterByScope() { $manager = $this->object; - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->setTranslation('dummykey', [ 'en' => 'EN text', @@ -745,7 +745,7 @@ public function testGetModules() { $manager = $this->object; - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish']]] ])); @@ -759,7 +759,7 @@ public function testGetModules() public function testGetModulesNoRestrictions() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => null]]] ])); @@ -776,7 +776,7 @@ public function testGetModulesRestrictionForUnknownModules() { $manager = $this->object; - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish,unknown1']]] ])); @@ -792,7 +792,7 @@ public function testGetAllowedModules() { $manager = $this->object; - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,home,publish']]] ])); @@ -809,7 +809,7 @@ public function testGetAllowedModulesHandlingSpaces() { $manager = $this->object; - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default, home , publish ']]] ])); @@ -826,7 +826,7 @@ public function testGetAllowedModulesUnknownModule() { $manager = $this->object; - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,unknown1']]] ])); @@ -853,7 +853,7 @@ public function testUpdateTranslation() $oldKey = 'oldkey'; - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->setTranslation($oldKey, [ 'en' => 'English', @@ -932,7 +932,7 @@ public function testUpdateTranslationKeepValues() $oldKey = 'oldkey'; - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->setTranslation($oldKey, [ 'en' => 'English', @@ -1001,7 +1001,7 @@ public function testIsEditedTrue() { $manager = $this->object; - $dao = new Opus_Translate_Dao(); + $dao = $this->getStorageInterface(); $key = 'default_add'; @@ -1024,7 +1024,7 @@ public function testIsEditedFalseForAddedKey() { $manager = $this->object; - $dao = new Opus_Translate_Dao(); + $dao = $this->getStorageInterface(); $key = 'customtestkey'; @@ -1040,7 +1040,7 @@ public function testDeleteAll() { $manager = $this->object; - $dao = new Opus_Translate_Dao(); + $dao = $this->getStorageInterface(); $addedKey = 'customtestkey'; $editedKey = 'default_add'; @@ -1068,7 +1068,7 @@ public function testDeleteMatches() { $manager = $this->object; - $dao = new Opus_Translate_Dao(); + $dao = $this->getStorageInterface(); $addedKey = 'customtestkey'; $editedKey = 'default_add'; @@ -1097,7 +1097,7 @@ public function testDeleteMatchesByModule() { $manager = $this->object; - $dao = new Opus_Translate_Dao(); + $dao = $this->getStorageInterface(); $addedKey = 'customtestkey'; $editedKey = 'default_add'; @@ -1126,7 +1126,7 @@ public function testDeleteMatchesByState() { $manager = $this->object; - $dao = new Opus_Translate_Dao(); + $dao = $this->getStorageInterface(); $addedKey = 'customtestkey'; $editedKey = 'default_add'; @@ -1155,7 +1155,7 @@ public function testDeleteMatchesByScope() { $manager = $this->object; - $dao = new Opus_Translate_Dao(); + $dao = $this->getStorageInterface(); $addedKey = 'customtestkey'; $editedKey = 'default_add'; @@ -1183,7 +1183,7 @@ public function testDeleteMatchesByScope() public function testSetTranslation() { - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $manager = $this->object; @@ -1246,7 +1246,7 @@ public function testSetLanguageOrder() public function testSortLanguages() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'supportedLanguages' => 'de,en,fr' ])); @@ -1268,4 +1268,9 @@ public function testSortLanguages() $this->assertTrue(array_values($sorted)[0] === 'Deutsch'); } + + protected function getStorageInterface() + { + return new \Opus\Translate\Dao(); + } } diff --git a/tests/library/Application/TranslateTest.php b/tests/library/Application/TranslateTest.php index 12958c5b88..f77f4b6809 100644 --- a/tests/library/Application/TranslateTest.php +++ b/tests/library/Application/TranslateTest.php @@ -46,15 +46,15 @@ public function setUp() public function tearDown() { - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $dao->removeAll(); - Zend_Translate::clearCache(); + \Zend_Translate::clearCache(); parent::tearDown(); } public static function tearDownAfterClass() { - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $translate->loadTranslations(true); parent::tearDownAfterClass(); @@ -132,21 +132,21 @@ public function testLoadLanguageDirectoryNoFiles() */ public function testIsLogUntranslatedEnabledTrue() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->log->untranslated = self::CONFIG_VALUE_TRUE; $this->assertTrue($this->translate->isLogUntranslatedEnabled()); } public function testIsLogUntranslatedEnabledFalse() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->log->untranslated = self::CONFIG_VALUE_FALSE; $this->assertFalse($this->translate->isLogUntranslatedEnabled()); } public function testGetOptionsLogEnabled() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->log->untranslated = self::CONFIG_VALUE_TRUE; $options = $this->translate->getOptions(); @@ -160,7 +160,7 @@ public function testGetOptionsLogEnabled() public function testGetOptionsLogDisabled() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->log->untranslated = self::CONFIG_VALUE_FALSE; $options = $this->translate->getOptions(); @@ -172,7 +172,7 @@ public function testGetOptionsLogDisabled() public function testLoggingEnabled() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->log->untranslated = self::CONFIG_VALUE_TRUE; $logger = new MockLogger(); @@ -205,7 +205,7 @@ public function testLoggingEnabled() public function testLoggingDisabled() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->log->untranslated = self::CONFIG_VALUE_FALSE; $logger = new MockLogger(); @@ -271,10 +271,10 @@ public function testMixedTranslations() $key = 'admin_title_configuration'; // clear custom translations from database - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $translate->clearCache(); $translate->loadTranslations(); @@ -296,7 +296,7 @@ public function testMixedTranslations() ], 'admin'); // load module again with changes in database - Zend_Translate::clearCache(); + \Zend_Translate::clearCache(); $translate = new Application_Translate(); $translate->loadTranslations(); @@ -310,12 +310,12 @@ public function testMixedTranslations() public function testGetTranslations() { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); - Zend_Translate::clearCache(); + \Zend_Translate::clearCache(); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $translate->loadTranslations(true); $key = 'default_collection_role_ddc'; @@ -335,7 +335,7 @@ public function testGetTranslations() $database->setTranslation($key, $custom, 'default'); // new object necessary, because translation have already been loaded - Zend_Translate::clearCache(); + \Zend_Translate::clearCache(); $translate->loadDatabase(); $translations = $translate->getTranslations($key); @@ -345,20 +345,20 @@ public function testGetTranslations() public function testGetTranslationsUnknownKey() { - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $this->assertNull($translate->getTranslations('unknownkey9999')); } public function testSetTranslations() { - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $dao->remove('testkey'); $this->assertNull($dao->getTranslation('testkey')); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $data = [ 'en' => 'test key', @@ -377,7 +377,7 @@ public function testLoadingPerformance() $translate = new Application_Translate(); for ($i = 0; $i < 1000; $i++) { - Zend_Translate::clearCache(); + \Zend_Translate::clearCache(); $translate->loadTranslations(); } } @@ -386,24 +386,24 @@ public function testFallbackToDefaultLanguage() { $this->useGerman(); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $this->assertInstanceOf('Application_Translate', $translate); $key = 'test_fallback'; - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $dao->setTranslation($key, [ 'en' => 'English' ]); - Zend_Translate::clearCache(); + \Zend_Translate::clearCache(); $translate->loadTranslations(); // TODO this is currently necessary (not sure why) - Zend_Registry::get('Zend_Translate')->setLocale('de'); + \Zend_Registry::get('Zend_Translate')->setLocale('de'); $this->assertTrue($translate->isTranslated($key)); diff --git a/tests/library/Application/Update/AddCC30LicenceShortNamesTest.php b/tests/library/Application/Update/AddCC30LicenceShortNamesTest.php index c5a557761d..d20424a9d7 100644 --- a/tests/library/Application/Update/AddCC30LicenceShortNamesTest.php +++ b/tests/library/Application/Update/AddCC30LicenceShortNamesTest.php @@ -30,6 +30,11 @@ * @copyright Copyright (c) 2017-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Document; +use Opus\Licence; +use Opus\Model\Xml\Cache; + class Application_Update_AddCC30LicenceShotNamesTest extends ControllerTestCase { @@ -81,18 +86,18 @@ public function testGetShortName($expected, $longName) */ public function testUpdateLicenceWithoutVersion() { - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setNameLong('Creative Commons - Namensnennung'); $licence->setLanguage('deu'); $licence->setLinkLicence('http://opus4.kobv.org/test-licence'); $licenceId = $licence->store(); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $this->assertNull($licence->getName()); $this->_update->run(); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $licence->delete(); $this->assertEquals('CC BY 3.0', $licence->getName()); @@ -100,18 +105,18 @@ public function testUpdateLicenceWithoutVersion() public function testDoNotUpdate40Licence() { - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setNameLong('Creative Commons 4.0 - Namensnennung'); $licence->setLanguage('deu'); $licence->setLinkLicence('http://opus4.kobv.org/test-licence'); $licenceId = $licence->store(); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $this->assertNull($licence->getName()); $this->_update->run(); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $licence->delete(); $this->assertNull($licence->getName()); @@ -119,18 +124,18 @@ public function testDoNotUpdate40Licence() public function testUpdateForUnknownLicence() { - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setNameLong('Custom licence'); $licence->setLanguage('deu'); $licence->setLinkLicence('http://opus4.kobv.org/test-licence'); $licenceId = $licence->store(); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $this->assertNull($licence->getName()); $this->_update->run(); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $licence->delete(); $this->assertNull($licence->getName()); @@ -138,7 +143,7 @@ public function testUpdateForUnknownLicence() public function testUpdateForLicenceWithShortName() { - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setName('CC BY 5.0'); $licence->setNameLong('Creative Commons - Namensnennung'); $licence->setLanguage('deu'); @@ -147,7 +152,7 @@ public function testUpdateForLicenceWithShortName() $this->_update->run(); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $licence->delete(); $this->assertEquals('CC BY 5.0', $licence->getName()); @@ -168,7 +173,7 @@ public function testRemoveLicence() public function testDoNotUpdateServerDateModified() { - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setNameLong('Creative Commons - Namensnennung'); $licence->setLanguage('deu'); $licence->setLinkLicence('http://opus4.kobv.org/test-licence'); @@ -179,27 +184,27 @@ public function testDoNotUpdateServerDateModified() $doc->addLicence($licence); $docId = $doc->store(); - $cache = new Opus_Model_Xml_Cache(); + $cache = new Cache(); $this->assertNotNull($cache->getData($docId, '1.0')); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $dateModified = $doc->getServerDateModified(); sleep(2); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $this->assertNull($licence->getName()); $this->_update->run(); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $cacheResult = $cache->getData($docId, '1.0'); // clean up licence first - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $licence->delete(); $this->assertNull($cacheResult); diff --git a/tests/library/Application/Update/AddImportCollectionTest.php b/tests/library/Application/Update/AddImportCollectionTest.php index dc9202fa2b..5fa11c0177 100644 --- a/tests/library/Application/Update/AddImportCollectionTest.php +++ b/tests/library/Application/Update/AddImportCollectionTest.php @@ -29,7 +29,12 @@ * @author Jens Schwidder * @copyright Copyright (c) 2017-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * + */ + +use Opus\CollectionRole; +use Opus\EnrichmentKey; + +/** * TODO does deleting 'Import' for testing update make sense? */ class Application_Update_AddImportCollectionTest extends ControllerTestCase @@ -42,7 +47,7 @@ public function setUp() parent::setUp(); // delete import collections - $collectionRole = Opus_CollectionRole::fetchByName('Import'); + $collectionRole = CollectionRole::fetchByName('Import'); if (! is_null($collectionRole)) { $collectionRole->delete(); @@ -51,7 +56,7 @@ public function setUp() public function tearDown() { - $enrichmentKey = Opus_EnrichmentKey::fetchByName('opus.test.key'); + $enrichmentKey = EnrichmentKey::fetchByName('opus.test.key'); if (! is_null($enrichmentKey)) { $enrichmentKey->delete(); @@ -68,13 +73,13 @@ public function testAddEnrichmentKey() $keyName = 'opus.test.key'; - $enrichmentKey = Opus_EnrichmentKey::fetchByName($keyName); + $enrichmentKey = EnrichmentKey::fetchByName($keyName); $this->assertNull($enrichmentKey); $update->addEnrichmentKey($keyName); - $enrichmentKey = Opus_EnrichmentKey::fetchByName($keyName); + $enrichmentKey = EnrichmentKey::fetchByName($keyName); $this->assertNotNull($enrichmentKey); $this->assertEquals($keyName, $enrichmentKey->getName()); @@ -89,13 +94,13 @@ public function testAddCollection() $update->setLogger(new MockLogger()); $update->setQuietMode(true); - $collectionRole = Opus_CollectionRole::fetchByName('Import'); + $collectionRole = CollectionRole::fetchByName('Import'); $this->assertNull($collectionRole); $update->addCollection(); - $collectionRole = Opus_CollectionRole::fetchByName('Import'); + $collectionRole = CollectionRole::fetchByName('Import'); $this->assertNotNull($collectionRole); diff --git a/tests/library/Application/Update/ConvertCollectionRoleTranslationsTest.php b/tests/library/Application/Update/ConvertCollectionRoleTranslationsTest.php index 8f9be03596..3b6bc0c47c 100644 --- a/tests/library/Application/Update/ConvertCollectionRoleTranslationsTest.php +++ b/tests/library/Application/Update/ConvertCollectionRoleTranslationsTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; +use Opus\Model\NotFoundException; + class Application_Update_ConvertCollectionRoleTranslationsTest extends ControllerTestCase { @@ -42,13 +45,13 @@ public function tearDown() { if (! is_null($this->roleId)) { try { - $role = new Opus_CollectionRole($this->roleId); + $role = new CollectionRole($this->roleId); $role->delete(); - } catch (UnknownModelException $ex) { + } catch (NotFoundException $ex) { } } - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); parent::tearDown(); @@ -56,7 +59,7 @@ public function tearDown() public function testRun() { - $role = new Opus_CollectionRole(); + $role = new CollectionRole(); $invalidName = 'Collection Role mit ungültigem Namen.'; @@ -70,7 +73,7 @@ public function testRun() $update->setQuietMode(true); $update->run(); - $role = new Opus_CollectionRole($this->roleId); + $role = new CollectionRole($this->roleId); $name = $role->getName(); $oaiName = $role->getOaiName(); @@ -88,7 +91,7 @@ public function testRun() public function testRunWithExistingInvalidTranslationKey() { - $role = new Opus_CollectionRole(); + $role = new CollectionRole(); $invalidName = 'Tagungsbände'; @@ -109,7 +112,7 @@ public function testRunWithExistingInvalidTranslationKey() $update->setQuietMode(true); $update->run(); - $role = new Opus_CollectionRole($this->roleId); + $role = new CollectionRole($this->roleId); $name = $role->getName(); $oaiName = $role->getOaiName(); @@ -128,7 +131,7 @@ public function testRunWithExistingInvalidTranslationKey() public function testRunWithInvalidOaiName() { - $role = new Opus_CollectionRole(); + $role = new CollectionRole(); $invalidName = 'Tagungsbände'; @@ -142,7 +145,7 @@ public function testRunWithInvalidOaiName() $update->setQuietMode(true); $update->run(); - $role = new Opus_CollectionRole($this->roleId); + $role = new CollectionRole($this->roleId); $name = $role->getName(); $oaiName = $role->getOaiName(); diff --git a/tests/library/Application/Update/ImportCustomTranslationsTest.php b/tests/library/Application/Update/ImportCustomTranslationsTest.php index 4314fc40b5..2f840e11cd 100644 --- a/tests/library/Application/Update/ImportCustomTranslationsTest.php +++ b/tests/library/Application/Update/ImportCustomTranslationsTest.php @@ -50,7 +50,7 @@ public function setUp() $this->testPath = $path; - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); } @@ -78,7 +78,7 @@ public function testRunImportCustomTranslation() $tmxFile->save($filePath); - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); // Check translations not in database $this->assertNull($database->getTranslation('test_admin_title')); diff --git a/tests/library/Application/Update/ImportHelpFilesTest.php b/tests/library/Application/Update/ImportHelpFilesTest.php index 41fb45fd88..d29e743e1b 100644 --- a/tests/library/Application/Update/ImportHelpFilesTest.php +++ b/tests/library/Application/Update/ImportHelpFilesTest.php @@ -38,14 +38,14 @@ class Application_Update_ImportHelpFilesTest extends ControllerTestCase public function tearDown() { - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->removeAll(); parent::tearDown(); } public function testRun() { - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->removeAll(); $update = new Application_Update_ImportHelpFiles(); @@ -61,7 +61,7 @@ public function testRun() public function testRunWithModifiedTranslation() { - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->removeAll(); $folder = $this->createTestFolder(); @@ -99,7 +99,7 @@ public function testRunWithModifiedTranslation() public function testRunForCustomizedHelpFiles() { - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->removeAll(); $helpPath = $this->createTestFolder(); @@ -159,7 +159,7 @@ public function testMoveKeysToHelp() $update->setRemoveFilesEnabled(false); $update->setQuietMode(true); - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->removeAll(); $database->setTranslation('help_content_misc', [ @@ -199,7 +199,7 @@ public function testMoveKeysToHelpForEditedKey() $update->setRemoveFilesEnabled(false); $update->setQuietMode(true); - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->removeAll(); $database->setTranslation('help_content_metadata', [ @@ -246,7 +246,7 @@ public function testGetHelpFiles() $helpIni = $this->createTestFile('help.ini', $help, $folder); // setup translations - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->setTranslation('help_content_contact', [ 'en' => "$contactFile.en.txt", 'de' => "$contactFile.de.txt" @@ -299,7 +299,7 @@ public function testGetHelpFiles() */ public function testGetHelpFilesForDefaultSetup() { - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->removeAll(); $update = new Application_Update_ImportHelpFiles(); @@ -323,7 +323,7 @@ public function testGetHelpFilesForDefaultSetup() */ public function testImportChangedHelpFilesWithoutCustomizedKeys() { - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->removeAll(); $helpPath = $this->createTestFolder(); @@ -380,7 +380,7 @@ public function testImportChangedHelpFilesWithoutCustomizedKeys() */ public function testTmxContentMatchesHelpFiles() { - $database = new Opus_Translate_Dao(); + $database = $this->getStorageInterface(); $database->removeAll(); $update = new Application_Update_ImportHelpFiles(); @@ -405,4 +405,9 @@ public function testTmxContentMatchesHelpFiles() } } } + + protected function getStorageInterface() + { + return new \Opus\Translate\Dao(); + } } diff --git a/tests/library/Application/Update/ImportStaticPagesTest.php b/tests/library/Application/Update/ImportStaticPagesTest.php index efbfe91af6..885182e5af 100644 --- a/tests/library/Application/Update/ImportStaticPagesTest.php +++ b/tests/library/Application/Update/ImportStaticPagesTest.php @@ -40,13 +40,13 @@ public function setUp() { parent::setUp(); - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $dao->removeAll(); } public function tearDown() { - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $dao->removeAll(); parent::tearDown(); @@ -54,7 +54,7 @@ public function tearDown() public function testRun() { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $update = new Application_Update_ImportStaticPages(); $update->setRemoveFilesEnabled(false); @@ -75,7 +75,7 @@ public function testImportFilesAsKey() $update->importFilesAsKey('contact', 'testkey', 'home'); - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $translations = $database->getAll(); diff --git a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php index 1a566dd4a4..f17d1aee90 100644 --- a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php +++ b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php @@ -31,13 +31,19 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Date; +use Opus\Document; +use Opus\Identifier; +use Opus\Db\TableGateway; +use Opus\Model\ModelException; + class Application_Update_SetStatusOfExistingDoiTest extends ControllerTestCase { protected $additionalResources = 'database'; /** - * @throws Opus_Model_Exception + * @throws ModelException * * TODO test sets Status of all DOI identifier of published documents to 'registered' (side effect) * TODO this test has failed once (date got modified or compare didn't work) on Travis and worked in the next run @@ -48,7 +54,7 @@ public function testRunDoesNotModifyServerDateModified() $doc = $this->createTestDocument(); $doc->setServerState('published'); - $doi = new Opus_Identifier(); + $doi = new Identifier(); $doi->setType('doi'); $doi->setValue('testdoi'); @@ -61,14 +67,14 @@ public function testRunDoesNotModifyServerDateModified() $debug = "$modified (before)" . PHP_EOL; - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $modified2 = $doc->getServerDateModified(); $debug .= "$modified2 (before - from new object)" . PHP_EOL; - $time1 = Opus_Date::getNow(); + $time1 = Date::getNow(); sleep(2); - $time2 = Opus_Date::getNow(); + $time2 = Date::getNow(); $debug .= "$time1 - sleep(2) - $time2" . PHP_EOL; $debug .= $this->getServerDateModifiedFromDatabase($docId) . ' (before - from database)' . PHP_EOL; @@ -81,7 +87,7 @@ public function testRunDoesNotModifyServerDateModified() $debug .= $this->getServerDateModifiedFromDatabase($docId) . ' (after - from database)' . PHP_EOL; - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $debug .= "{$doc->getServerDateModified()} (after - from new object)" . PHP_EOL; @@ -91,7 +97,7 @@ public function testRunDoesNotModifyServerDateModified() protected function getServerDateModifiedFromDatabase($docId) { - $table = Opus_Db_TableGateway::getInstance('Opus_Db_Documents'); + $table = TableGateway::getInstance('Opus\Db\Documents'); $select = $table->select() ->from($table, ['server_date_modified']) ->where("id = $docId"); diff --git a/tests/library/Application/Util/DocumentAdapterTest.php b/tests/library/Application/Util/DocumentAdapterTest.php index 5acee95a3d..57f93cfca6 100644 --- a/tests/library/Application/Util/DocumentAdapterTest.php +++ b/tests/library/Application/Util/DocumentAdapterTest.php @@ -30,6 +30,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Person; +use Opus\Title; + /** * Unit test for class Review_Model_DocumentAdapter. * @@ -42,9 +46,9 @@ class Application_Util_DocumentAdapterTest extends ControllerTestCase public function testHasFilesTrue() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); - $doc = new Opus_Document(1); + $doc = Document::get(1); $docAdapter = new Application_Util_DocumentAdapter($view, $doc); @@ -53,7 +57,7 @@ public function testHasFilesTrue() public function testHasFilesFalse() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $doc = $this->createTestDocument(); @@ -64,9 +68,9 @@ public function testHasFilesFalse() public function testGetFileCount() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); - $doc = new Opus_Document(1); + $doc = Document::get(1); $docAdapter = new Application_Util_DocumentAdapter($view, $doc); @@ -75,7 +79,7 @@ public function testGetFileCount() public function testGetFileCountZero() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $doc = $this->createTestDocument(); @@ -86,7 +90,7 @@ public function testGetFileCountZero() public function testIsBelongsToBibliographyTrue() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $doc = $this->createTestDocument(); @@ -99,7 +103,7 @@ public function testIsBelongsToBibliographyTrue() public function testIsBelongsToBibliographyFalse() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $doc = $this->createTestDocument(); @@ -115,16 +119,16 @@ public function testIsBelongsToBibliographyFalse() */ public function testGetMainTitle() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $doc = $this->createTestDocument(); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('Deutscher Titel'); $doc->addTitleMain($title); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('eng'); $title->setValue('Englischer Titel'); $doc->addTitleMain($title); @@ -140,7 +144,7 @@ public function testGetMainTitleForDocWithNoTitles() { $this->useEnglish(); - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $doc = $this->createTestDocument(); $docId = $doc->store(); @@ -152,16 +156,16 @@ public function testGetMainTitleForDocWithNoTitles() public function testGetMainTitleForDocWithNoLanguage() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $doc = $this->createTestDocument(); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('Deutscher Titel'); $doc->addTitleMain($title); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('eng'); $title->setValue('Englischer Titel'); $doc->addTitleMain($title); @@ -174,16 +178,16 @@ public function testGetMainTitleForDocWithNoLanguage() public function testGetMainTitleForDocWithNoTitleInDocLanguage() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $doc = $this->createTestDocument(); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('Deutscher Titel'); $doc->addTitleMain($title); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('eng'); $title->setValue('Englischer Titel'); $doc->addTitleMain($title); @@ -198,16 +202,16 @@ public function testGetMainTitleForDocWithNoTitleInDocLanguage() public function testGetDocTitle() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $doc = $this->createTestDocument(); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('Deutscher Titel'); $doc->addTitleMain($title); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('eng'); $title->setValue('Englischer Titel'); $doc->addTitleMain($title); @@ -223,11 +227,11 @@ public function testGetAuthors() { $doc = $this->createTestDocument(); - $person = new Opus_Person(); + $person = new Person(); $person->setLastName("Doe"); $doc->addPersonAuthor($person); - $person = new Opus_Person(); + $person = new Person(); $person->setLastName("Smith"); $person->setFirstName("Jane"); $doc->addPersonAuthor($person); @@ -242,7 +246,7 @@ public function testGetAuthors() public function testGetAuthorsForDocumentWithoutAuthors() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $doc = $this->createTestDocument(); @@ -312,7 +316,7 @@ public function testGetYear() { $this->markTestIncomplete('not working yet'); - $doc = new Opus_Document(1); + $doc = Document::get(1); $adapter = new Application_Util_DocumentAdapter(null, $doc); diff --git a/tests/library/Application/Util/NotificationTest.php b/tests/library/Application/Util/NotificationTest.php index bd3afadd77..e274178dcd 100644 --- a/tests/library/Application/Util/NotificationTest.php +++ b/tests/library/Application/Util/NotificationTest.php @@ -32,6 +32,11 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Job; +use Opus\Person; +use Opus\Title; +use Opus\Job\Worker\MailNotification; + class Application_Util_NotificationTest extends ControllerTestCase { protected $configModifiable = true; @@ -48,9 +53,9 @@ public function setUp() { parent::setUp(); $this->notification = new Application_Util_Notification(); - $this->logger = Zend_Registry::get('Zend_Log'); + $this->logger = \Zend_Registry::get('Zend_Log'); // add required config keys - $this->config = Zend_Registry::get('Zend_Config'); + $this->config = \Zend_Registry::get('Zend_Config'); $this->config->notification->document->submitted->enabled = self::CONFIG_VALUE_TRUE; $this->config->notification->document->published->enabled = self::CONFIG_VALUE_TRUE; $this->config->notification->document->submitted->subject = 'Dokument #%1$s eingestellt: %2$s : %3$s'; @@ -70,7 +75,7 @@ public function testPrepareMailForSubmissionContext() $doc = $this->createTestDocument(); $doc->setLanguage("eng"); - $title = new Opus_Title(); + $title = new Title(); $title->setValue("Test Document"); $title->setLanguage("eng"); $doc->addTitleMain($title); @@ -198,24 +203,24 @@ public function testPrepareMailWithTwoOptionalArgs() $doc = $this->createTestDocument(); $doc->setLanguage("eng"); - $title = new Opus_Title(); + $title = new Title(); $title->setValue("Test Document"); $title->setLanguage("eng"); $doc->addTitleMain($title); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName("John"); $author->setLastName("Doe"); $author->setEmail("john@localhost.de"); $doc->addPersonAuthor($author); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName("Jane"); $author->setLastName("Doe"); $author->setEmail("jane@localhost.de"); $doc->addPersonAuthor($author); - $submitter = new Opus_Person(); + $submitter = new Person(); $submitter->setFirstName("John"); $submitter->setLastName("Submitter"); $submitter->setEmail("sub@localhost.de"); @@ -232,8 +237,8 @@ public function testPrepareMailWithTwoOptionalArgs() public function testCreateWorkerJobIfAsyncEnabled() { - // TODO use Opus_Job::deleteAll() - requires opus4admin permissions ! - $jobs = Opus_Job::getAll(); + // TODO use Job::deleteAll() - requires opus4admin permissions ! + $jobs = Job::getAll(); if (! empty($jobs)) { foreach ($jobs as $job) { @@ -241,13 +246,13 @@ public function testCreateWorkerJobIfAsyncEnabled() } } - $this->config->merge(new Zend_Config(['runjobs' => ['asynchronous' => self::CONFIG_VALUE_TRUE]])); - $this->assertEquals(0, Opus_Job::getCount(), 'test data changed.'); + $this->config->merge(new \Zend_Config(['runjobs' => ['asynchronous' => self::CONFIG_VALUE_TRUE]])); + $this->assertEquals(0, Job::getCount(), 'test data changed.'); $doc = $this->createTestDocument(); $doc->setLanguage("eng"); - $title = new Opus_Title(); + $title = new Title(); $title->setValue("Test Document"); $title->setLanguage("eng"); $doc->addTitleMain($title); @@ -255,11 +260,11 @@ public function testCreateWorkerJobIfAsyncEnabled() $doc->store(); $this->notification->prepareMail($doc, 'http://localhost/foo/1'); - $mailJobs = Opus_Job::getByLabels([Opus_Job_Worker_MailNotification::LABEL]); + $mailJobs = Job::getByLabels([MailNotification::LABEL]); $this->assertEquals(1, count($mailJobs), 'Expected 1 mail job'); - $jobs = Opus_Job::getAll(); + $jobs = Job::getAll(); if (! empty($jobs)) { foreach ($jobs as $job) { diff --git a/tests/library/Application/Util/PublicationNotificationTest.php b/tests/library/Application/Util/PublicationNotificationTest.php index 724329a9b7..a38be4216a 100644 --- a/tests/library/Application/Util/PublicationNotificationTest.php +++ b/tests/library/Application/Util/PublicationNotificationTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Person; +use Opus\Title; + class Application_Util_PublicationNotificationTest extends ControllerTestCase { @@ -48,9 +51,9 @@ public function setUp() { parent::setUp(); $this->notification = new Application_Util_PublicationNotification(); - $this->logger = Zend_Registry::get('Zend_Log'); + $this->logger = \Zend_Registry::get('Zend_Log'); // add required config keys - $this->config = Zend_Registry::get('Zend_Config'); + $this->config = \Zend_Registry::get('Zend_Config'); $this->config->notification->document->submitted->enabled = self::CONFIG_VALUE_TRUE; $this->config->notification->document->published->enabled = self::CONFIG_VALUE_TRUE; $this->config->notification->document->submitted->subject = 'Dokument #%1$s eingestellt: %2$s : %3$s'; @@ -152,7 +155,7 @@ public function testGetRecipientsForPublicationContextWithSubmitterAsRecipient() { $this->config->notification->document->published->email = "published@localhost"; $doc = $this->createTestDocument(); - $submitter = new Opus_Person(); + $submitter = new Person(); $submitter->setFirstName('John'); $submitter->setLastName('Submitter'); $submitter->setEmail('john.submitter@localhost.de'); @@ -185,7 +188,7 @@ public function testGetRecipientsForPublicationContextWithSubmitterWithoutMailAd { $this->config->notification->document->published->email = "published@localhost"; $doc = $this->createTestDocument(); - $submitter = new Opus_Person(); + $submitter = new Person(); $submitter->setFirstName('John'); $submitter->setLastName('Submitter'); $doc->addPersonSubmitter($submitter); @@ -207,12 +210,12 @@ public function testGetRecipientsForPublicationContextWithoutSubmitter() $doc = $this->createTestDocument(); $doc->setLanguage("eng"); - $title = new Opus_Title(); + $title = new Title(); $title->setValue("Test Document"); $title->setLanguage("eng"); $doc->addTitleMain($title); - $submitter = new Opus_Person(); + $submitter = new Person(); $submitter->setFirstName("John"); $submitter->setLastName("Submitter"); $submitter->setEmail("sub@localhost.de"); @@ -276,23 +279,23 @@ public function testPrepareMailForPublicationContext() $doc = $this->createTestDocument(); $doc->setLanguage("eng"); - $title = new Opus_Title(); + $title = new Title(); $title->setValue("Test Document"); $title->setLanguage("eng"); $doc->addTitleMain($title); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName("John"); $author->setLastName("Doe"); $doc->addPersonAuthor($author); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName("John With Address"); $author->setLastName("Doe"); $author->setEmail("doe@localhost.de"); $doc->addPersonAuthor($author); - $submitter = new Opus_Person(); + $submitter = new Person(); $submitter->setFirstName("John"); $submitter->setLastName("Submitter"); $submitter->setEmail("sub@localhost.de"); diff --git a/tests/library/Application/View/Helper/AccessAllowedTest.php b/tests/library/Application/View/Helper/AccessAllowedTest.php index 9e8618a46f..0fc729f99e 100644 --- a/tests/library/Application/View/Helper/AccessAllowedTest.php +++ b/tests/library/Application/View/Helper/AccessAllowedTest.php @@ -46,22 +46,22 @@ public function setUp() // bootstrapping authorization twice is not possible parent::setUpWithEnv('production'); $this->assertSecurityConfigured(); - $acl = Zend_Registry::get('Opus_Acl'); + $acl = \Zend_Registry::get('Opus_Acl'); $acl->allow('guest', 'accounts'); $this->__helper = new Application_View_Helper_AccessAllowed(); - $this->__helper->setView(Zend_Registry::get('Opus_View')); + $this->__helper->setView(\Zend_Registry::get('Opus_View')); } public function tearDown() { - $acl = Zend_Registry::get('Opus_Acl'); + $acl = \Zend_Registry::get('Opus_Acl'); $acl->deny('guest', 'accounts'); parent::tearDown(); } public function testAccessAllowed() { - $user = Zend_Auth::getInstance()->getIdentity(); + $user = \Zend_Auth::getInstance()->getIdentity(); $this->assertEquals('', $user, "expected no user to be set (should use default 'guest' as default)"); $allowedDocuments = $this->__helper->accessAllowed('documents'); $this->assertFalse($allowedDocuments, "expected access denied to resource 'documents'"); diff --git a/tests/library/Application/View/Helper/ActionCssClassTest.php b/tests/library/Application/View/Helper/ActionCssClassTest.php index 3ea78cd3ad..3902d619e4 100644 --- a/tests/library/Application/View/Helper/ActionCssClassTest.php +++ b/tests/library/Application/View/Helper/ActionCssClassTest.php @@ -39,7 +39,7 @@ class Application_View_Helper_ActionCssClassTest extends ControllerTestCase public function testActionCssClass() { $helper = new Application_View_Helper_ActionCssClass(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); $this->assertEquals('', $helper->actionCssClass()); diff --git a/tests/library/Application/View/Helper/AdminCssClassTest.php b/tests/library/Application/View/Helper/AdminCssClassTest.php index 21e5dfff0e..67017f49e4 100644 --- a/tests/library/Application/View/Helper/AdminCssClassTest.php +++ b/tests/library/Application/View/Helper/AdminCssClassTest.php @@ -59,7 +59,7 @@ public function modulesProvider() public function testAdminCssClass($module, $expected) { $helper = new Application_View_Helper_AdminCssClass(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); $helper->view->moduleName = $module; diff --git a/tests/library/Application/View/Helper/AdminMenuTest.php b/tests/library/Application/View/Helper/AdminMenuTest.php index 04fea50787..caf2b87b57 100644 --- a/tests/library/Application/View/Helper/AdminMenuTest.php +++ b/tests/library/Application/View/Helper/AdminMenuTest.php @@ -43,7 +43,7 @@ public function setUp() parent::setUpWithEnv('production'); $this->assertSecurityConfigured(); $this->_helper = new Application_View_Helper_AdminMenu(); - $this->_helper->setView(Zend_Registry::get('Opus_View')); + $this->_helper->setView(\Zend_Registry::get('Opus_View')); } private function getPageByLabel($label) @@ -58,7 +58,7 @@ public function testAdminMenu() public function testGetAcl() { - $this->assertSame(Zend_Registry::get('Opus_Acl'), $this->_helper->getAcl()); + $this->assertSame(\Zend_Registry::get('Opus_Acl'), $this->_helper->getAcl()); } public function testHasAllowedChildren() @@ -78,7 +78,7 @@ public function testHasAllowedChildren() $this->assertFalse($this->_helper->hasAllowedChildren($page)); // activate sub entry below 'admin_title_setup' - $acl = Zend_Registry::get('Opus_Acl'); + $acl = \Zend_Registry::get('Opus_Acl'); $acl->allow(Application_Security_AclProvider::ACTIVE_ROLE, 'options'); $page = $this->getPageByLabel('admin_title_config'); diff --git a/tests/library/Application/View/Helper/AssignCollectionAllowedTest.php b/tests/library/Application/View/Helper/AssignCollectionAllowedTest.php index 3a9594b8d2..9f92b722e9 100644 --- a/tests/library/Application/View/Helper/AssignCollectionAllowedTest.php +++ b/tests/library/Application/View/Helper/AssignCollectionAllowedTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; + class Application_View_Helper_AssignCollectionAllowedTest extends ControllerTestCase { @@ -46,7 +48,7 @@ public function setUp() $this->_helper = new Application_View_Helper_AssignCollectionAllowed(); - $role = new Opus_CollectionRole(); + $role = new CollectionRole(); $role->setName('TestCollectionRole'); $role->setOaiName('test'); $role->setDisplayBrowsing('Number'); diff --git a/tests/library/Application/View/Helper/BreadcrumbsTest.php b/tests/library/Application/View/Helper/BreadcrumbsTest.php index 94b311d76b..033ad02e0c 100644 --- a/tests/library/Application/View/Helper/BreadcrumbsTest.php +++ b/tests/library/Application/View/Helper/BreadcrumbsTest.php @@ -50,7 +50,7 @@ public function setUp() { parent::setUp(); - $this->view = Zend_Registry::get('Opus_View'); + $this->view = \Zend_Registry::get('Opus_View'); $this->breadcrumbs = $this->view->breadcrumbs(); diff --git a/tests/library/Application/View/Helper/CustomFileSortingEnabledTest.php b/tests/library/Application/View/Helper/CustomFileSortingEnabledTest.php index 2378b3ad25..e7ea82a5c8 100644 --- a/tests/library/Application/View/Helper/CustomFileSortingEnabledTest.php +++ b/tests/library/Application/View/Helper/CustomFileSortingEnabledTest.php @@ -41,7 +41,7 @@ public function testCustomFileSortingEnabled() $this->assertTrue($helper->customFileSortingEnabled()); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'frontdoor' => ['files' => ['customSorting' => self::CONFIG_VALUE_FALSE]] ])); diff --git a/tests/library/Application/View/Helper/DocumentTitleTest.php b/tests/library/Application/View/Helper/DocumentTitleTest.php index 8098b87ac7..ba9683cdf8 100644 --- a/tests/library/Application/View/Helper/DocumentTitleTest.php +++ b/tests/library/Application/View/Helper/DocumentTitleTest.php @@ -46,7 +46,7 @@ public function setup() parent::setUp(); $this->_helper = new Application_View_Helper_DocumentTitle(); - $this->_helper->setView(Zend_Registry::get('Opus_View')); + $this->_helper->setView(\Zend_Registry::get('Opus_View')); } public function testDocumentTitle() @@ -104,7 +104,7 @@ public function testDocumentNoLanguage() public function testDocumentTitleUserInterfaceLanguage() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['search' => ['result' => ['display' => [ 'preferUserInterfaceLanguage' => self::CONFIG_VALUE_TRUE ]]]] diff --git a/tests/library/Application/View/Helper/EmbargoHasPassedTest.php b/tests/library/Application/View/Helper/EmbargoHasPassedTest.php index e09c5a58a1..a64bdb9f0e 100644 --- a/tests/library/Application/View/Helper/EmbargoHasPassedTest.php +++ b/tests/library/Application/View/Helper/EmbargoHasPassedTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Date; + class Application_View_Helper_EmbargoHasPassedTest extends ControllerTestCase { @@ -45,7 +47,7 @@ public function testEmbargoHasPassedForDocumentObject() $this->assertTrue($helper->embargoHasPassed($document)); - $document->setEmbargoDate(new Opus_Date(new DateTime('tomorrow'))); + $document->setEmbargoDate(new Date(new DateTime('tomorrow'))); $this->assertFalse($helper->embargoHasPassed($document)); } @@ -59,7 +61,7 @@ public function testEmbargoHasPassed() $this->assertTrue($helper->embargoHasPassed($docId)); - $document->setEmbargoDate(new Opus_Date(new DateTime('tomorrow'))); + $document->setEmbargoDate(new Date(new DateTime('tomorrow'))); $document->store(); $this->assertFalse($helper->embargoHasPassed($docId)); diff --git a/tests/library/Application/View/Helper/EscapeValueTest.php b/tests/library/Application/View/Helper/EscapeValueTest.php index 125a41a0be..fbce93d3ae 100644 --- a/tests/library/Application/View/Helper/EscapeValueTest.php +++ b/tests/library/Application/View/Helper/EscapeValueTest.php @@ -43,7 +43,7 @@ public function setUp() parent::setUp(); $this->_helper = new Application_View_Helper_EscapeValue(); - $this->_helper->setView(Zend_Registry::get('Opus_View')); + $this->_helper->setView(\Zend_Registry::get('Opus_View')); } public function testEscapeValueNull() diff --git a/tests/library/Application/View/Helper/ExportLinksEnabledTest.php b/tests/library/Application/View/Helper/ExportLinksEnabledTest.php index b1c9f395b0..cb9755161b 100644 --- a/tests/library/Application/View/Helper/ExportLinksEnabledTest.php +++ b/tests/library/Application/View/Helper/ExportLinksEnabledTest.php @@ -52,7 +52,7 @@ public function testExportLinksEnabled() { $this->assertTrue($this->_helper->exportLinksEnabled()); - Zend_Registry::get('Opus_Exporter')->removeAll(); + \Zend_Registry::get('Opus_Exporter')->removeAll(); $this->assertFalse($this->_helper->exportLinksEnabled()); } diff --git a/tests/library/Application/View/Helper/ExportLinksTest.php b/tests/library/Application/View/Helper/ExportLinksTest.php index 56e81121b6..e7998d094c 100644 --- a/tests/library/Application/View/Helper/ExportLinksTest.php +++ b/tests/library/Application/View/Helper/ExportLinksTest.php @@ -73,7 +73,7 @@ public function testToStringForFrontdoor() public function testRenderLink() { - $page = new Zend_Navigation_Page_Mvc([ + $page = new \Zend_Navigation_Page_Mvc([ 'name' => 'bibtex', 'description' => 'Export BibTeX', 'module' => 'citationExport', diff --git a/tests/library/Application/View/Helper/FaqEditLinkTest.php b/tests/library/Application/View/Helper/FaqEditLinkTest.php index bd6ef8a29c..7dd16018b3 100644 --- a/tests/library/Application/View/Helper/FaqEditLinkTest.php +++ b/tests/library/Application/View/Helper/FaqEditLinkTest.php @@ -51,7 +51,7 @@ public function testRenderFaqEditLink() public function testRenderOnlyIfSetupAccess() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish,help']]] ])); @@ -76,7 +76,7 @@ public function testRenderOnlyIfSetupAccess() public function testRenderOnlyIfKeyEditable() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default']]] ])); @@ -86,7 +86,7 @@ public function testRenderOnlyIfKeyEditable() $this->assertEquals('', $html); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish,help']]] ])); @@ -104,7 +104,7 @@ public function testRenderOnlyIfKeyEditable() protected function getHelper() { $helper = new Application_View_Helper_FaqEditLink(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); return $helper; } } diff --git a/tests/library/Application/View/Helper/FileLinkTest.php b/tests/library/Application/View/Helper/FileLinkTest.php index 799007b69f..e689c810a3 100644 --- a/tests/library/Application/View/Helper/FileLinkTest.php +++ b/tests/library/Application/View/Helper/FileLinkTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\File; + /** * Unit Tests fuer View Helper zum Rendern von Datei-Links. * @@ -46,9 +48,9 @@ public function testFileLink() { $helper = new Application_View_Helper_FileLink(); - $helper->setView(new Zend_View()); + $helper->setView(new \Zend_View()); - $file = new Opus_File(126); + $file = new File(126); $this->assertEquals('
foo-pdf' . '', $helper->fileLink( @@ -62,9 +64,9 @@ public function testFileLinkSpecialCharacters() { $helper = new Application_View_Helper_FileLink(); - $helper->setView(new Zend_View()); + $helper->setView(new \Zend_View()); - $file = new Opus_File(130); + $file = new File(130); $this->assertEquals( 'Dateiname-mit-Sonderzeichen.pdf' @@ -77,9 +79,9 @@ public function testFileLinkSpacesAndQuotes() { $helper = new Application_View_Helper_FileLink(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); - $file = new Opus_File(131); + $file = new File(131); $this->assertEquals( '' @@ -92,9 +94,9 @@ public function testFileLinkNoLabel() { $helper = new Application_View_Helper_FileLink(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); - $file = new Opus_File(126); + $file = new File(126); $file->setLabel(null); $this->assertEquals( @@ -111,13 +113,13 @@ public function testBaseUrlUsedForFileLinks() { $helper = new Application_View_Helper_FileLink(); - $view = new Zend_View(); + $view = new \Zend_View(); $view->getHelper('BaseUrl')->setBaseUrl('/testbase'); $helper->setView($view); - $file = new Opus_File(126); + $file = new File(126); $this->assertEquals('foo-pdf' . '', $helper->fileLink( diff --git a/tests/library/Application/View/Helper/FileUrlTest.php b/tests/library/Application/View/Helper/FileUrlTest.php index 0b0dab7d08..4ae5d17686 100644 --- a/tests/library/Application/View/Helper/FileUrlTest.php +++ b/tests/library/Application/View/Helper/FileUrlTest.php @@ -39,7 +39,7 @@ class Application_View_Helper_FileUrlTest extends ControllerTestCase public function testFileUrl() { $helper = new Application_View_Helper_FileUrl(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); $fileUrl = $helper->fileUrl('123', 'foo.pdf'); $this->assertEquals('http:///files/123/foo.pdf', $fileUrl); @@ -48,7 +48,7 @@ public function testFileUrl() public function testFileUrlWithEscaping() { $helper = new Application_View_Helper_FileUrl(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); $fileUrl = $helper->fileUrl('123', 'foo:bar.pdf'); $this->assertEquals('http:///files/123/foo%3Abar.pdf', $fileUrl); diff --git a/tests/library/Application/View/Helper/FormDocumentsTest.php b/tests/library/Application/View/Helper/FormDocumentsTest.php index 53129e0cb7..8f20ddefd1 100644 --- a/tests/library/Application/View/Helper/FormDocumentsTest.php +++ b/tests/library/Application/View/Helper/FormDocumentsTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + class Application_View_Helper_FormDocumentsTest extends ControllerTestCase { @@ -55,7 +57,7 @@ public function testFormDocumentsWithoutDocuments() public function testFormDocuments() { $output = $this->_helper->formDocuments('Documents', null, null, [ - 1 => new Opus_Document(1) + 1 => Document::get(1) ]); $this->assertContains('
', $output); diff --git a/tests/library/Application/View/Helper/FormTranslationTest.php b/tests/library/Application/View/Helper/FormTranslationTest.php index 5dd88df6f5..1af1b2b4f5 100644 --- a/tests/library/Application/View/Helper/FormTranslationTest.php +++ b/tests/library/Application/View/Helper/FormTranslationTest.php @@ -38,7 +38,7 @@ class Application_View_Helper_Form_TranslationTest extends ControllerTestCase public function testRenderingMinimal() { $helper = new Application_View_Helper_FormTranslation(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); $output = $helper->formTranslation('DisplayName'); @@ -48,7 +48,7 @@ public function testRenderingMinimal() public function testRenderingOptions() { $helper = new Application_View_Helper_FormTranslation(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); $options = [ 'en' => 'English', diff --git a/tests/library/Application/View/Helper/FormatDateTest.php b/tests/library/Application/View/Helper/FormatDateTest.php index 596d2ab82d..b204c86d97 100644 --- a/tests/library/Application/View/Helper/FormatDateTest.php +++ b/tests/library/Application/View/Helper/FormatDateTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Date; + class Application_View_Helper_FormatDateTest extends ControllerTestCase { @@ -55,7 +57,7 @@ public function testFormatOpusDate() { $helper = new Application_View_Helper_FormatDate(); - $date = new Opus_Date(DateTime::createFromFormat('Y/m/d H:i', '2017/03/10 14:51')); + $date = new Date(DateTime::createFromFormat('Y/m/d H:i', '2017/03/10 14:51')); $this->useEnglish(); @@ -70,7 +72,7 @@ public function testFormatOpusDateWithTime() { $helper = new Application_View_Helper_FormatDate(); - $date = new Opus_Date(DateTime::createFromFormat('Y/m/d H:i', '2017/03/10 14:51')); + $date = new Date(DateTime::createFromFormat('Y/m/d H:i', '2017/03/10 14:51')); $this->useEnglish(); diff --git a/tests/library/Application/View/Helper/FormatValueTest.php b/tests/library/Application/View/Helper/FormatValueTest.php index 14d1fa4b37..7243fb259b 100644 --- a/tests/library/Application/View/Helper/FormatValueTest.php +++ b/tests/library/Application/View/Helper/FormatValueTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Date; +use Opus\Document; + /** * Unit tests for FormatValue view helper. */ @@ -44,7 +47,7 @@ public function setUp() { parent::setUp(); $this->__helper = new Application_View_Helper_FormatValue(); - $this->__helper->setView(Zend_Registry::get('Opus_View')); + $this->__helper->setView(\Zend_Registry::get('Opus_View')); } public function testViewHelperReturnsItself() @@ -76,7 +79,7 @@ public function testFormatValueForSelectField() $field->setValue('deu'); - $output = $this->__helper->format($field, 'Opus_Document'); + $output = $this->__helper->format($field, 'Opus\Document'); $this->assertTrue(in_array($output, ['German', 'Deutsch'])); } @@ -102,7 +105,7 @@ public function testFormatValueForYear() */ public function testFormatValueForDate() { - $doc = new Opus_Document(3); + $doc = Document::get(3); $field = $doc->getField('ThesisDateAccepted'); @@ -115,7 +118,7 @@ public function testFormatValueForInvalidDate() { $doc = $this->createTestDocument(); - $doc->setPublishedDate(new Opus_Date('2005')); + $doc->setPublishedDate(new Date('2005')); $field = $doc->getField('PublishedDate'); @@ -126,11 +129,11 @@ public function testFormatValueForInvalidDate() public function testFormatValueForPublicationState() { - $doc = new Opus_Document(3); + $doc = Document::get(3); $field = $doc->getField('PublicationState'); - $output = $this->__helper->format($field, 'Opus_Document'); + $output = $this->__helper->format($field, 'Opus\Document'); // PublicationState is not translated right now $this->assertEquals('draft', $output); diff --git a/tests/library/Application/View/Helper/FrontdoorUrlTest.php b/tests/library/Application/View/Helper/FrontdoorUrlTest.php index d6ea1126e1..6bbe57a6a3 100644 --- a/tests/library/Application/View/Helper/FrontdoorUrlTest.php +++ b/tests/library/Application/View/Helper/FrontdoorUrlTest.php @@ -39,7 +39,7 @@ class Application_View_Helper_FrontdoorUrlTest extends ControllerTestCase public function testFrontdoorUrl() { $helper = new Application_View_Helper_FrontdoorUrl(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); $frontDoorUrl = $helper->frontdoorUrl('123'); $this->assertEquals('http:///frontdoor/index/index/docId/123', $frontDoorUrl); diff --git a/tests/library/Application/View/Helper/FullUrlTest.php b/tests/library/Application/View/Helper/FullUrlTest.php index 879b9677ae..d98db4397c 100644 --- a/tests/library/Application/View/Helper/FullUrlTest.php +++ b/tests/library/Application/View/Helper/FullUrlTest.php @@ -29,7 +29,6 @@ * @author Michael Lang * @copyright Copyright (c) 2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_View_Helper_FullUrlTest extends ControllerTestCase @@ -43,8 +42,8 @@ class Application_View_Helper_FullUrlTest extends ControllerTestCase public function testFullUrl() { $helper = new Application_View_Helper_FullUrl(); - $view = new Zend_View(); - Zend_Controller_Front::getInstance()->setBaseUrl('opus4dev'); + $view = new \Zend_View(); + \Zend_Controller_Front::getInstance()->setBaseUrl('opus4dev'); $helper->setView($view); $this->assertEquals($helper->fullUrl(), 'http://opus4dev'); } diff --git a/tests/library/Application/View/Helper/FulltextLogoTest.php b/tests/library/Application/View/Helper/FulltextLogoTest.php index 7dfb0231f3..3db52ac029 100644 --- a/tests/library/Application/View/Helper/FulltextLogoTest.php +++ b/tests/library/Application/View/Helper/FulltextLogoTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; +use Opus\Document; + class Application_View_Helper_FulltextLogoTest extends ControllerTestCase { @@ -43,7 +46,7 @@ public function setUp() parent::setUp(); $this->_helper = new Application_View_Helper_FulltextLogo(); - $this->_helper->setView(Zend_Registry::get('Opus_View')); + $this->_helper->setView(\Zend_Registry::get('Opus_View')); $this->useEnglish(); } @@ -51,7 +54,7 @@ public function setUp() public function testFulltextLogo() { $doc = $this->createTestDocument(); - $doc = new Opus_Document($doc->store()); + $doc = Document::get($doc->store()); $this->assertEquals('', $this->_helper->fulltextLogo($doc)); } @@ -63,11 +66,11 @@ public function testFulltextLogoOpenAccess() { $doc = $this->createTestDocument(); - $openAccessRole = Opus_CollectionRole::fetchByName('open_access'); + $openAccessRole = CollectionRole::fetchByName('open_access'); $openAccess = $openAccessRole->getCollectionByOaiSubset('open_access'); $doc->addCollection($openAccess); - $doc = new Opus_Document($doc->store()); + $doc = Document::get($doc->store()); $this->assertEquals('', $this->_helper->fulltextLogo($doc)); } @@ -79,7 +82,7 @@ public function testFulltextLogoFulltext() $file = $this->createOpusTestFile('article.pdf'); $doc->addFile($file); - $doc = new Opus_Document($doc->store()); + $doc = Document::get($doc->store()); $this->assertEquals('', $this->_helper->fulltextLogo($doc)); } @@ -88,14 +91,14 @@ public function testFulltextLogoOpenAccessFulltext() { $doc = $this->createTestDocument(); - $openAccessRole = Opus_CollectionRole::fetchByName('open_access'); + $openAccessRole = CollectionRole::fetchByName('open_access'); $openAccess = $openAccessRole->getCollectionByOaiSubset('open_access'); $doc->addCollection($openAccess); $file = $this->createOpusTestFile('article.pdf'); $doc->addFile($file); - $doc = new Opus_Document($doc->store()); + $doc = Document::get($doc->store()); $this->assertEquals('', $this->_helper->fulltextLogo($doc)); } diff --git a/tests/library/Application/View/Helper/IsDisplayFieldTest.php b/tests/library/Application/View/Helper/IsDisplayFieldTest.php index a5adb407d9..693079f456 100644 --- a/tests/library/Application/View/Helper/IsDisplayFieldTest.php +++ b/tests/library/Application/View/Helper/IsDisplayFieldTest.php @@ -42,7 +42,7 @@ public function testIsDisplayField() $this->assertFalse($helper->isDisplayField('BelongsToBibliography')); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'frontdoor' => ['metadata' => ['BelongsToBibliography' => self::CONFIG_VALUE_TRUE]] ])); diff --git a/tests/library/Application/View/Helper/JavascriptMessagesTest.php b/tests/library/Application/View/Helper/JavascriptMessagesTest.php index 451f8d439c..c62aa01dc3 100644 --- a/tests/library/Application/View/Helper/JavascriptMessagesTest.php +++ b/tests/library/Application/View/Helper/JavascriptMessagesTest.php @@ -47,7 +47,7 @@ public function setUp() $this->helper = new Application_View_Helper_JavascriptMessages(); - $this->helper->setView(Zend_Registry::get('Opus_View')); + $this->helper->setView(\Zend_Registry::get('Opus_View')); } /** diff --git a/tests/library/Application/View/Helper/LanguageSelectorTest.php b/tests/library/Application/View/Helper/LanguageSelectorTest.php index f1111c90f8..15c741101b 100644 --- a/tests/library/Application/View/Helper/LanguageSelectorTest.php +++ b/tests/library/Application/View/Helper/LanguageSelectorTest.php @@ -50,7 +50,7 @@ public function setUp() $this->_helper = new Application_View_Helper_LanguageSelector(); - $this->_helper->setView(Zend_Registry::get('Opus_View')); + $this->_helper->setView(\Zend_Registry::get('Opus_View')); } public function testLanguageConfiguredAndInResourcesGerman() @@ -90,9 +90,9 @@ public function testLanguageConfiguredAndInResourcesEnglish() */ public function testLanguageConfiguredButNotInResources() { - Zend_Registry::set( + \Zend_Registry::set( 'Zend_Config', - Zend_Registry::get('Zend_Config')->merge(new Zend_Config(['supportedLanguages' => 'de,en,ru'])) + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config(['supportedLanguages' => 'de,en,ru'])) ); $result = $this->_helper->languageSelector(); @@ -113,9 +113,9 @@ public function testLanguageConfiguredButNotInResources() */ public function testOnlyOneLanguageConfigured() { - Zend_Registry::set( + \Zend_Registry::set( 'Zend_Config', - Zend_Registry::get('Zend_Config')->merge(new Zend_Config(['supportedLanguages' => 'en'])) + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config(['supportedLanguages' => 'en'])) ); $result = $this->_helper->languageSelector(); diff --git a/tests/library/Application/View/Helper/MessagesTest.php b/tests/library/Application/View/Helper/MessagesTest.php index 2d95e75be8..5febff32c0 100644 --- a/tests/library/Application/View/Helper/MessagesTest.php +++ b/tests/library/Application/View/Helper/MessagesTest.php @@ -43,7 +43,7 @@ public function testMessages() { $this->useEnglish(); - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $helper = new Application_View_Helper_Messages(); $helper->setView($view); @@ -67,7 +67,7 @@ public function testMessagesMultiple() { $this->useEnglish(); - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $helper = new Application_View_Helper_Messages(); $helper->setView($view); @@ -95,7 +95,7 @@ public function testMessagesTranslation() { $this->useEnglish(); - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $helper = new Application_View_Helper_Messages(); $helper->setView($view); @@ -119,7 +119,7 @@ public function testMessagesNone() { $helper = new Application_View_Helper_Messages(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); $this->assertEquals('', $helper->messages()); } @@ -128,7 +128,7 @@ public function testMessageWithoutMessageKey() { $helper = new Application_View_Helper_Messages(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); $this->assertEquals( <<assertTrue($helper->optionEnabled('orcid.linkAuthor.frontdoor')); $this->assertTrue($helper->optionEnabled('linkAuthor.frontdoor', 'orcid')); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'orcid' => ['linkAuthor' => ['frontdoor' => self::CONFIG_VALUE_FALSE]] ])); diff --git a/tests/library/Application/View/Helper/OptionUrlTest.php b/tests/library/Application/View/Helper/OptionUrlTest.php index 7caccc4777..3fceb6295d 100644 --- a/tests/library/Application/View/Helper/OptionUrlTest.php +++ b/tests/library/Application/View/Helper/OptionUrlTest.php @@ -45,21 +45,21 @@ public function testOptionUrl() $helper = new Application_View_Helper_OptionUrl(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'logoLink' => 'home' ])); $this->assertEquals('http://localhost/opus4/home', $helper->optionUrl('logoLink')); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'logoLink' => '/opus4/home' ])); $this->assertEquals('http://localhost/opus4/home', $helper->optionUrl('logoLink')); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'logoLink' => 'http://www.opus-repository.org' ])); diff --git a/tests/library/Application/View/Helper/OptionValueTest.php b/tests/library/Application/View/Helper/OptionValueTest.php index 81e62fcc97..1622f303b2 100644 --- a/tests/library/Application/View/Helper/OptionValueTest.php +++ b/tests/library/Application/View/Helper/OptionValueTest.php @@ -50,7 +50,7 @@ public function testOptionValueWithEscaping() $this->assertEquals('OPUS 4', $helper->optionValue('name')); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'name' => 'OPUS 4' ])); diff --git a/tests/library/Application/View/Helper/ResultAuthorsTest.php b/tests/library/Application/View/Helper/ResultAuthorsTest.php index f400d3d785..1987c120d2 100644 --- a/tests/library/Application/View/Helper/ResultAuthorsTest.php +++ b/tests/library/Application/View/Helper/ResultAuthorsTest.php @@ -43,7 +43,7 @@ public function setUp() parent::setUp(); $this->helper = new Application_View_Helper_ResultAuthors(); - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $this->helper->setView($view); } diff --git a/tests/library/Application/View/Helper/ResultTitleTest.php b/tests/library/Application/View/Helper/ResultTitleTest.php index b235452575..e3c2fc361d 100644 --- a/tests/library/Application/View/Helper/ResultTitleTest.php +++ b/tests/library/Application/View/Helper/ResultTitleTest.php @@ -43,7 +43,7 @@ public function setUp() parent::setUp(); $this->helper = new Application_View_Helper_ResultTitle(); - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $this->helper->setView($view); } diff --git a/tests/library/Application/View/Helper/ResultYearTest.php b/tests/library/Application/View/Helper/ResultYearTest.php index 4b34fc6d50..22ffa4598b 100644 --- a/tests/library/Application/View/Helper/ResultYearTest.php +++ b/tests/library/Application/View/Helper/ResultYearTest.php @@ -42,7 +42,7 @@ public function setUp() parent::setUp(); $this->helper = new Application_View_Helper_ResultYear(); - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $this->helper->setView($view); } diff --git a/tests/library/Application/View/Helper/SeriesNumberTest.php b/tests/library/Application/View/Helper/SeriesNumberTest.php index 345dd4b7ab..8d72f844dd 100644 --- a/tests/library/Application/View/Helper/SeriesNumberTest.php +++ b/tests/library/Application/View/Helper/SeriesNumberTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Series; + class Application_View_Helper_SeriesNumberTest extends ControllerTestCase { @@ -48,7 +50,7 @@ public function setUp() public function testSeriesNumberForLinkedDocument() { $document = $this->getDocument(146); - $series = new Opus_Series(1); + $series = new Series(1); $this->assertEquals('5/5', $this->_helper->seriesNumber($document, $series)); } @@ -56,7 +58,7 @@ public function testSeriesNumberForLinkedDocument() public function testSeriesNumberForNotLinkedDocument() { $document = $this->getDocument(146); - $series = new Opus_Series(2); + $series = new Series(2); $this->assertEquals('', $this->_helper->seriesNumber($document, $series)); } @@ -64,7 +66,7 @@ public function testSeriesNumberForNotLinkedDocument() public function testSeriesNumberEscaped() { $document = $this->createTestDocument(); - $series = new Opus_Series(5); + $series = new Series(5); $document->addSeries($series)->setNumber('XIII'); $document->store(); diff --git a/tests/library/Application/View/Helper/ShortenTextTest.php b/tests/library/Application/View/Helper/ShortenTextTest.php index d6cce2f5be..bb0f1bf44a 100644 --- a/tests/library/Application/View/Helper/ShortenTextTest.php +++ b/tests/library/Application/View/Helper/ShortenTextTest.php @@ -44,7 +44,7 @@ public function testShortenText() { $helper = new Application_View_Helper_ShortenText(); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'frontdoor' => ['numOfShortAbstractChars' => '10'] ])); @@ -70,7 +70,7 @@ public function testGetMaxLength() { $helper = new Application_View_Helper_ShortenText(); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'frontdoor' => ['numOfShortAbstractChars' => '10'] ])); @@ -78,7 +78,7 @@ public function testGetMaxLength() $helper->setMaxLength(null); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'frontdoor' => ['numOfShortAbstractChars' => 'bla'] ])); @@ -89,7 +89,7 @@ public function testSetMaxLength() { $helper = new Application_View_Helper_ShortenText(); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'frontdoor' => ['numOfShortAbstractChars' => '10'] ])); diff --git a/tests/library/Application/View/Helper/TransferUrlTest.php b/tests/library/Application/View/Helper/TransferUrlTest.php index c80c3ae54b..0b11fc5cd5 100644 --- a/tests/library/Application/View/Helper/TransferUrlTest.php +++ b/tests/library/Application/View/Helper/TransferUrlTest.php @@ -39,7 +39,7 @@ class Application_View_Helper_TransferUrlTest extends ControllerTestCase public function testTransferUrl() { $helper = new Application_View_Helper_TransferUrl(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); $transferUrl = $helper->transferUrl('123'); $this->assertEquals('http:///oai/container/index/docId/123', $transferUrl); diff --git a/tests/library/Application/View/Helper/TranslationEditLinkTest.php b/tests/library/Application/View/Helper/TranslationEditLinkTest.php index 1234e460d5..0176444843 100644 --- a/tests/library/Application/View/Helper/TranslationEditLinkTest.php +++ b/tests/library/Application/View/Helper/TranslationEditLinkTest.php @@ -51,7 +51,7 @@ public function testRenderTranslationEditLink() public function testRenderOnlyIfSetupAccess() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish,help']]] ])); @@ -76,7 +76,7 @@ public function testRenderOnlyIfSetupAccess() public function testRenderOnlyIfKeyEditable() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default']]] ])); @@ -86,7 +86,7 @@ public function testRenderOnlyIfKeyEditable() $this->assertEquals('', $html); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish,help']]] ])); @@ -104,7 +104,7 @@ public function testRenderOnlyIfKeyEditable() protected function getHelper() { $helper = new Application_View_Helper_TranslationEditLink(); - $helper->setView(Zend_Registry::get('Opus_View')); + $helper->setView(\Zend_Registry::get('Opus_View')); return $helper; } } diff --git a/tests/library/Application/View/Helper/ViewFormDefaultTest.php b/tests/library/Application/View/Helper/ViewFormDefaultTest.php index e81aca5817..b4f6aa685d 100644 --- a/tests/library/Application/View/Helper/ViewFormDefaultTest.php +++ b/tests/library/Application/View/Helper/ViewFormDefaultTest.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_View_Helper_ViewFormDefaultTest extends ControllerTestCase { @@ -37,7 +36,7 @@ class Application_View_Helper_ViewFormDefaultTest extends ControllerTestCase public function testViewFormDefault() { $helper = new Application_View_Helper_ViewFormDefault(); - $helper->setView(new Zend_View()); + $helper->setView(new \Zend_View()); $markup = $helper->viewFormDefault('testName', 'testValue', ['id' => '10']); @@ -47,7 +46,7 @@ public function testViewFormDefault() public function testViewFormDefaultOnlyName() { $helper = new Application_View_Helper_ViewFormDefault(); - $helper->setView(new Zend_View()); + $helper->setView(new \Zend_View()); $markup = $helper->viewFormDefault('testName'); @@ -57,7 +56,7 @@ public function testViewFormDefaultOnlyName() public function testViewFormDefaultEscaping() { $helper = new Application_View_Helper_ViewFormDefault(); - $helper->setView(new Zend_View()); + $helper->setView(new \Zend_View()); $markup = $helper->viewFormDefault('testName', '

HTML

', ['id' => '10']); diff --git a/tests/library/Application/View/Helper/ViewFormMultiCheckboxTest.php b/tests/library/Application/View/Helper/ViewFormMultiCheckboxTest.php index 810adb084c..21476f737d 100644 --- a/tests/library/Application/View/Helper/ViewFormMultiCheckboxTest.php +++ b/tests/library/Application/View/Helper/ViewFormMultiCheckboxTest.php @@ -36,7 +36,7 @@ class Application_View_Helper_ViewFormMultiCheckboxTest extends ControllerTestCa public function testViewFormMultiCheckbox() { $helper = new Application_View_Helper_ViewFormMultiCheckbox(); - $helper->setView(new Zend_View()); + $helper->setView(new \Zend_View()); $markup = $helper->viewFormMultiCheckbox( 'testName', @@ -51,7 +51,7 @@ public function testViewFormMultiCheckbox() public function testViewFormMultiCheckboxEscaping() { $helper = new Application_View_Helper_ViewFormMultiCheckbox(); - $helper->setView(new Zend_View()); + $helper->setView(new \Zend_View()); $markup = $helper->viewFormMultiCheckbox( 'testName', diff --git a/tests/library/Application/View/Helper/ViewFormSelectTest.php b/tests/library/Application/View/Helper/ViewFormSelectTest.php index 8456c498ab..a8b12f6b56 100644 --- a/tests/library/Application/View/Helper/ViewFormSelectTest.php +++ b/tests/library/Application/View/Helper/ViewFormSelectTest.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Application_View_Helper_ViewFormSelectTest extends ControllerTestCase { @@ -37,7 +36,7 @@ class Application_View_Helper_ViewFormSelectTest extends ControllerTestCase public function testViewFormSelect() { $helper = new Application_View_Helper_ViewFormSelect(); - $helper->setView(new Zend_View()); + $helper->setView(new \Zend_View()); $markup = $helper->viewFormSelect('testName', '1', null, ['Value1', 'Value2', 'Value3']); @@ -47,7 +46,7 @@ public function testViewFormSelect() public function testViewFormSelectEscaping() { $helper = new Application_View_Helper_ViewFormSelect(); - $helper->setView(new Zend_View()); + $helper->setView(new \Zend_View()); $markup = $helper->viewFormSelect('testName', '1', null, ['Value1', '

Value2

', 'Value3']); diff --git a/tests/library/Application/View/Helper/ViewFormTextareaTest.php b/tests/library/Application/View/Helper/ViewFormTextareaTest.php index 4e9b7ec7b5..4fab915dd9 100644 --- a/tests/library/Application/View/Helper/ViewFormTextareaTest.php +++ b/tests/library/Application/View/Helper/ViewFormTextareaTest.php @@ -37,7 +37,7 @@ class Application_View_Helper_ViewFormTextareaTest extends ControllerTestCase public function testViewFormTextarea() { $helper = new Application_View_Helper_ViewFormTextarea(); - $helper->setView(new Zend_View()); + $helper->setView(new \Zend_View()); $this->assertContains('class="field textarea"', $helper->viewFormTextarea('testName', 'testValue', [ 'id' => '10' diff --git a/tests/library/Application/ZendBasicsTest.php b/tests/library/Application/ZendBasicsTest.php index f884cf25f9..3d9d36a4de 100644 --- a/tests/library/Application/ZendBasicsTest.php +++ b/tests/library/Application/ZendBasicsTest.php @@ -65,7 +65,7 @@ public function testZendConfigBooleanOption($name, $value, $result) */ public function testZendConfigBooleanOptionLoadedFromIni($name, $value, $result) { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $options = $config->tests->config; $value = $options->$name; diff --git a/tests/library/Mock/Opus/Document.php b/tests/library/Mock/Opus/Document.php index ea87d24cd4..e4a0a90f17 100644 --- a/tests/library/Mock/Opus/Document.php +++ b/tests/library/Mock/Opus/Document.php @@ -29,13 +29,14 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2012, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Document; + /** - * Mock Opus_Document for unit testing. + * Mock Document for unit testing. */ -class Mock_Opus_Document extends Opus_Document +class Mock_Opus_Document extends Document { public function store() diff --git a/tests/modules/ControllerTestCaseTest.php b/tests/modules/ControllerTestCaseTest.php index 3eeee0f53d..a690f0fe6c 100644 --- a/tests/modules/ControllerTestCaseTest.php +++ b/tests/modules/ControllerTestCaseTest.php @@ -29,6 +29,11 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Document; +use Opus\Model\NotFoundException; +use Opus\Security\Realm; + class ControllerTestCaseTest extends ControllerTestCase { @@ -51,12 +56,12 @@ public function testLoginAdmin() { $this->enableSecurity(); $this->loginUser('admin', 'adminadmin'); - $realm = Opus_Security_Realm::getInstance(); + $realm = Realm::getInstance(); $this->assertContains( 'administrator', $realm->getRoles(), - Zend_Debug::dump($realm->getRoles(), null, false) + \Zend_Debug::dump($realm->getRoles(), null, false) ); } @@ -68,13 +73,13 @@ public function testLoginAdmin() public function testTearDownDidLogout() { $this->enableSecurity(); - $realm = Opus_Security_Realm::getInstance(); + $realm = Realm::getInstance(); $this->assertNotContains('administrator', $realm->getRoles()); } public function testSetHostname() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $this->assertEquals('http://', $view->serverUrl()); @@ -85,7 +90,7 @@ public function testSetHostname() public function testSetBaseUrlNotSet() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $this->assertEquals('', $view->baseUrl()); @@ -96,7 +101,7 @@ public function testSetBaseUrlNotSet() public function testSetBaseUrlSet() { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $this->setBaseUrl('opus4'); @@ -105,32 +110,32 @@ public function testSetBaseUrlSet() /** * Test removing document using identifier. - * - * @expectedException Opus_Model_NotFoundException */ public function testRemoveDocumentById() { - $doc = new Opus_Document(); + $doc = Document::new(); $docId = $doc->store(); $this->removeDocument($docId); - new Opus_Document($docId); + $this->setExpectedException(NotFoundException::class); + + Document::get($docId); } /** * Test removing document using object. - * - * @expectedException Opus_Model_NotFoundException */ public function testRemoveDocument() { - $doc = new Opus_Document(); + $doc = Document::new(); $docId = $doc->store(); $this->removeDocument($doc); - new Opus_Document($docId); + $this->setExpectedException(NotFoundException::class); + + Document::get($docId); } /** @@ -138,7 +143,7 @@ public function testRemoveDocument() */ public function testRemoveDocumentNotStored() { - $doc = new Opus_Document(); + $doc = Document::new(); $this->removeDocument($doc); } @@ -163,17 +168,17 @@ public function testGetTempFile() public function testDisableEnableTranslation() { - $defaultTranslator = Zend_Registry::get('Zend_Translate'); + $defaultTranslator = \Zend_Registry::get('Zend_Translate'); $this->assertTrue($defaultTranslator->isTranslated('LastName')); $this->disableTranslation(); - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); $this->assertFalse($translator->isTranslated('LastName')); $this->enableTranslation(); - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); $this->assertTrue($translator->isTranslated('LastName')); $this->assertSame($defaultTranslator, $translator); @@ -193,7 +198,7 @@ public function testGetWorkspacePath() */ public function testGetWorkspacePathNotDefined() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'workspacePath' => null ])); diff --git a/tests/modules/LanguageTest.php b/tests/modules/LanguageTest.php index 1e1ffcf050..1b81e40ae8 100644 --- a/tests/modules/LanguageTest.php +++ b/tests/modules/LanguageTest.php @@ -76,7 +76,7 @@ public function testSetLanguage() { $this->application->bootstrap('translation'); - $translator = Zend_Registry::get('Zend_Translate'); + $translator = \Zend_Registry::get('Zend_Translate'); $this->useGerman(); diff --git a/tests/modules/account/controllers/IndexControllerTest.php b/tests/modules/account/controllers/IndexControllerTest.php index 5b5a88ae6b..e2a54c7ae0 100644 --- a/tests/modules/account/controllers/IndexControllerTest.php +++ b/tests/modules/account/controllers/IndexControllerTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Account; + /** * Basic unit tests for account module. * @@ -48,7 +50,7 @@ public function setUp() parent::setUp(); $this->deleteUser('john'); - $this->user = new Opus_Account(); + $this->user = new Account(); $this->user->setLogin('john'); $this->user->setPassword('testpwd'); $this->user->store(); @@ -62,8 +64,8 @@ public function tearDown() private function deleteUser($username) { - $account = Opus_Account::fetchAccountByLogin($username); - if ($account instanceof Opus_Account) { + $account = Account::fetchAccountByLogin($username); + if ($account instanceof Account) { $account->delete(); } } @@ -73,7 +75,7 @@ private function deleteUser($username) */ public function testIndexSuccessAction() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->loginUser('admin', 'adminadmin'); @@ -89,7 +91,7 @@ public function testIndexSuccessAction() */ public function testIndexDeniedIfEditAccountDisabledAction() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->account->editOwnAccount = self::CONFIG_VALUE_FALSE; $this->loginUser('admin', 'adminadmin'); @@ -109,7 +111,7 @@ public function testIndexWithoutLoginAction() public function testChangePasswordFailsOnMissingInputAction() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->loginUser('john', 'testpwd'); @@ -125,7 +127,7 @@ public function testChangePasswordFailsOnMissingInputAction() $this->assertAction('save'); // Check if change failed... - $account = new Opus_Account(null, null, 'john'); + $account = new Account(null, null, 'john'); $this->assertTrue($account->isPasswordCorrect('testpwd')); $this->assertFalse($account->isPasswordCorrect('newpassword')); @@ -134,7 +136,7 @@ public function testChangePasswordFailsOnMissingInputAction() public function testChangePasswordFailsOnNoMatch() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->loginUser('john', 'testpwd'); @@ -151,7 +153,7 @@ public function testChangePasswordFailsOnNoMatch() $this->assertAction('save'); // Check if change failed... - $account = new Opus_Account(null, null, 'john'); + $account = new Account(null, null, 'john'); $this->assertTrue($account->isPasswordCorrect('testpwd')); $this->assertFalse($account->isPasswordCorrect('newpassword')); @@ -163,7 +165,7 @@ public function testChangePasswordFailsOnNoMatch() */ public function testChangePasswordSuccess() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->loginUser('john', 'testpwd'); @@ -181,7 +183,7 @@ public function testChangePasswordSuccess() $this->assertRedirect(); // Check if change succeeded... - $account = new Opus_Account(null, null, 'john'); + $account = new Account(null, null, 'john'); $this->assertTrue($account->isPasswordCorrect('newpassword')); $this->assertNotContains('
    ', $this->getResponse()->getBody()); @@ -192,7 +194,7 @@ public function testChangePasswordSuccess() */ public function testChangePasswordSuccessWithSpecialChars() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->loginUser('john', 'testpwd'); @@ -210,7 +212,7 @@ public function testChangePasswordSuccessWithSpecialChars() $this->assertRedirect(); // Check if change succeeded... - $account = new Opus_Account(null, null, 'john'); + $account = new Account(null, null, 'john'); $this->assertTrue($account->isPasswordCorrect('new@pwd$%')); $this->assertNotContains('
      ', $this->getResponse()->getBody()); @@ -221,7 +223,7 @@ public function testChangePasswordSuccessWithSpecialChars() */ public function testChangeLoginSuccess() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->deleteUser('john2'); @@ -240,11 +242,11 @@ public function testChangeLoginSuccess() $this->assertRedirect(); // Check if new user exists (with proper password) and old does not... - $account = Opus_Account::fetchAccountByLogin('john2'); + $account = Account::fetchAccountByLogin('john2'); $this->assertNotNull($account); $this->assertTrue($account->isPasswordCorrect('testpwd')); - $account = Opus_Account::fetchAccountByLogin('john'); + $account = Account::fetchAccountByLogin('john'); $this->assertNull($account); // Delete user 'john2' if we're done... diff --git a/tests/modules/account/forms/AccountTest.php b/tests/modules/account/forms/AccountTest.php index 5f9257c963..df371235e9 100644 --- a/tests/modules/account/forms/AccountTest.php +++ b/tests/modules/account/forms/AccountTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Account; + /** * Basic unit tests for account form for users. */ @@ -44,10 +46,10 @@ public function setUp() { parent::setUp(); - $account = Opus_Account::fetchAccountByLogin('user'); + $account = Account::fetchAccountByLogin('user'); if (is_null($account)) { - $account = new Opus_Account(); + $account = new Account(); $account->setLogin('user'); $account->setPassword('userpwd'); $account->store(); @@ -107,7 +109,7 @@ public function testChangedLoginNameValidationExistingLoginNameAccount() public function testChangedLoginNameValidationNewLoginName() { $form = new Account_Form_Account(); - $account = new Opus_Account(null, null, 'user'); + $account = new Account(null, null, 'user'); $form->populateFromModel($account); $this->assertNotNull($form); @@ -125,7 +127,7 @@ public function testChangedLoginNameValidationNewLoginName() public function testEditValidationSameAccount() { $form = new Account_Form_Account(); - $account = new Opus_Account(null, null, 'user'); + $account = new Account(null, null, 'user'); $form->populateFromModel($account); // check that form was populated @@ -145,7 +147,7 @@ public function testEditValidationSameAccount() public function testValidationMissmatchedPasswords() { $form = new Account_Form_Account(); - $account = new Opus_Account(null, null, 'user'); + $account = new Account(null, null, 'user'); $form->populateFromModel($account); $postData = [ @@ -166,7 +168,7 @@ public function testValidationMissmatchedPasswords() public function testValidationBadEmail() { $form = new Account_Form_Account(); - $account = new Opus_Account(null, null, 'user'); + $account = new Account(null, null, 'user'); $form->populateFromModel($account); $postData = [ diff --git a/tests/modules/admin/controllers/AccountControllerTest.php b/tests/modules/admin/controllers/AccountControllerTest.php index 6d07b1a1b4..c6175cd83a 100644 --- a/tests/modules/admin/controllers/AccountControllerTest.php +++ b/tests/modules/admin/controllers/AccountControllerTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Account; + /** * Basic unit tests for the Admin_AccountController class. * @@ -46,8 +48,8 @@ public static function tearDownAfterClass() $accounts = ['wally', 'wally2']; foreach ($accounts as $login) { - $account = Opus_Account::fetchAccountByLogin($login); - if ($account instanceof Opus_Account) { + $account = Account::fetchAccountByLogin($login); + if ($account instanceof Account) { $account->delete(); } } @@ -156,7 +158,7 @@ public function testCreateAction() $this->assertController('account'); $this->assertAction('new'); $this->assertRedirect(); - $this->assertNotNull(new Opus_Account(null, null, 'wally')); + $this->assertNotNull(new Account(null, null, 'wally')); } public function testCreateActionCancel() @@ -201,7 +203,7 @@ public function testCreateActionMissingInput() */ public function testUpdateAction() { - $account = new Opus_Account(null, null, 'wally'); + $account = new Account(null, null, 'wally'); $id = $account->getId(); $this->request ->setMethod('POST') @@ -222,7 +224,7 @@ public function testUpdateAction() $this->assertController('account'); $this->assertAction('edit'); $this->assertRedirect(); - $this->assertNotNull(new Opus_Account(null, null, 'wally2')); + $this->assertNotNull(new Account(null, null, 'wally2')); } public function testUpdateActionCancel() @@ -244,7 +246,7 @@ public function testUpdateActionCancel() */ public function testUpdateActionMissingInput() { - $account = new Opus_Account(null, null, 'wally2'); + $account = new Account(null, null, 'wally2'); $id = $account->getId(); $this->request ->setMethod('POST') @@ -269,7 +271,7 @@ public function testUpdateActionMissingInput() */ public function testUpdateActionChangePassword() { - $account = new Opus_Account(null, null, 'wally2'); + $account = new Account(null, null, 'wally2'); $id = $account->getId(); $this->request ->setMethod('POST') @@ -292,7 +294,7 @@ public function testUpdateActionChangePassword() $this->assertController('account'); $this->assertAction('edit'); $this->assertRedirect(); - $this->assertNotNull(new Opus_Account(null, null, 'wally2')); + $this->assertNotNull(new Account(null, null, 'wally2')); } /** @@ -302,7 +304,7 @@ public function testUpdateActionChangePassword() */ public function testDeleteAction() { - $account = new Opus_Account(null, null, 'wally2'); + $account = new Account(null, null, 'wally2'); $id = $account->getId(); $this->request ->setMethod('POST') @@ -316,13 +318,13 @@ public function testDeleteAction() $this->assertAction('delete'); $this->assertRedirect('/admin/account/index'); - $this->setExpectedException('Opus_Security_Exception'); - $this->assertNull(new Opus_Account(null, null, 'wally2')); + $this->setExpectedException('Opus\Security\SecurityException'); + $this->assertNull(new Account(null, null, 'wally2')); } public function testDeleteActionDeleteSelf() { - $user = new Opus_Account(); + $user = new Account(); $user->setLogin('john'); $user->setPassword('testpwd'); $user->store(); @@ -334,25 +336,25 @@ public function testDeleteActionDeleteSelf() $this->assertAction('delete'); $this->assertRedirect('/admin/account/index'); - $user = new Opus_Account(null, null, 'john'); + $user = new Account(null, null, 'john'); $this->assertNotNull($user); $user->delete(); } public function testDeleteActionDeleteAdmin() { - $user = new Opus_Account(null, null, 'admin'); + $user = new Account(null, null, 'admin'); $this->dispatch('/admin/account/delete/id/' . $user->getId()); $this->assertController('account'); $this->assertAction('delete'); $this->assertRedirect('/admin/account/index'); - $user = new Opus_Account(null, null, 'admin'); + $user = new Account(null, null, 'admin'); $this->assertNotNull($user); } public function testHideDeleteLinkForAdmin() { - $user = new Opus_Account(null, null, 'admin'); + $user = new Account(null, null, 'admin'); $this->dispatch('/admin/account'); $this->assertResponseCode(200); @@ -369,7 +371,7 @@ public function testHideDeleteLinkForCurrentUser() $this->assertResponseCode(200, $this->getResponse()->getBody()); $this->logoutUser(); - $user = new Opus_Account(null, null, 'security4'); + $user = new Account(null, null, 'security4'); $this->assertQueryCount( "a[@href='" . $this->getRequest()->getBaseUrl() diff --git a/tests/modules/admin/controllers/CollectionControllerTest.php b/tests/modules/admin/controllers/CollectionControllerTest.php index 34163b5eba..847dbeb0d1 100644 --- a/tests/modules/admin/controllers/CollectionControllerTest.php +++ b/tests/modules/admin/controllers/CollectionControllerTest.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Collection; +use Opus\CollectionRole; + /** * Basic unit tests for the collections controller in admin module. * @@ -52,7 +55,7 @@ public function setUp() { parent::setUp(); - $this->emptyCollectionRole = new Opus_CollectionRole(); + $this->emptyCollectionRole = new CollectionRole(); $this->emptyCollectionRole->setName("test1role"); $this->emptyCollectionRole->setOaiName("test1role"); $this->emptyCollectionRole->setDisplayBrowsing("Name"); @@ -60,7 +63,7 @@ public function setUp() $this->emptyCollectionRole->setPosition(100); $this->emptyCollectionRole->store(); - $this->nonEmptyCollectionRole = new Opus_CollectionRole(); + $this->nonEmptyCollectionRole = new CollectionRole(); $this->nonEmptyCollectionRole->setName("test2role"); $this->nonEmptyCollectionRole->setOaiName("test2role"); $this->nonEmptyCollectionRole->setDisplayBrowsing("Name"); @@ -71,13 +74,13 @@ public function setUp() $this->rootCollection = $this->nonEmptyCollectionRole->addRootCollection(); $this->rootCollection->store(); - $this->collection = new Opus_Collection(); + $this->collection = new Collection(); $this->collection->setName("first collection"); $this->collection->setNumber("123"); $this->rootCollection->addFirstChild($this->collection); $this->collection->store(); - $this->anotherCollection = new Opus_Collection(); + $this->anotherCollection = new Collection(); $this->anotherCollection->setName("last collection"); $this->anotherCollection->setNumber("987"); $this->rootCollection->addLastChild($this->anotherCollection); diff --git a/tests/modules/admin/controllers/CollectionrolesControllerTest.php b/tests/modules/admin/controllers/CollectionrolesControllerTest.php index b245ba2dce..503931f49a 100644 --- a/tests/modules/admin/controllers/CollectionrolesControllerTest.php +++ b/tests/modules/admin/controllers/CollectionrolesControllerTest.php @@ -30,7 +30,13 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * + */ + +use Opus\CollectionRole; +use Opus\Document; +use Opus\DocumentFinder; + +/** * @covers Admin_CollectionrolesController */ class Admin_CollectionrolesControllerTest extends ControllerTestCase @@ -46,7 +52,7 @@ public function setUp() { parent::setUp(); - $this->emptyCollectionRole = new Opus_CollectionRole(); + $this->emptyCollectionRole = new CollectionRole(); $this->emptyCollectionRole->setName("test1role"); $this->emptyCollectionRole->setOaiName("test1role"); $this->emptyCollectionRole->setDisplayBrowsing("Name"); @@ -54,7 +60,7 @@ public function setUp() $this->emptyCollectionRole->setPosition(100); $this->emptyCollectionRole->store(); - $this->nonEmptyCollectionRole = new Opus_CollectionRole(); + $this->nonEmptyCollectionRole = new CollectionRole(); $this->nonEmptyCollectionRole->setName("test2role"); $this->nonEmptyCollectionRole->setOaiName("test2role"); $this->nonEmptyCollectionRole->setDisplayBrowsing("Name"); @@ -68,7 +74,7 @@ public function setUp() public function tearDown() { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); if (! is_null($this->nonEmptyCollectionRole) && ! is_null($this->nonEmptyCollectionRole->getId())) { @@ -236,12 +242,12 @@ public function testDocumentServerDateModifiedNotUpdatedWhenCollectionSortOrderC { // check for expected test data - $collectionRole1 = new Opus_CollectionRole(1); + $collectionRole1 = new CollectionRole(1); $this->assertEquals(1, $collectionRole1->getPosition(), 'Test setup changed'); - $collectionRole2 = new Opus_CollectionRole(2); + $collectionRole2 = new CollectionRole(2); $this->assertEquals(2, $collectionRole2->getPosition(), 'Test setup changed'); - $docfinder = new Opus_DocumentFinder(); + $docfinder = new DocumentFinder(); $docfinder->setCollectionRoleId(2); $collectionRoleDocs = $docfinder->ids(); @@ -249,9 +255,9 @@ public function testDocumentServerDateModifiedNotUpdatedWhenCollectionSortOrderC // test if server_date_modified is altered - $docBefore = new Opus_Document(146); + $docBefore = Document::get(146); $this->dispatch('/admin/collectionroles/move/roleid/1/pos/2'); - $docAfter = new Opus_Document(146); + $docAfter = Document::get(146); // revert change in test data $this->resetRequest(); @@ -271,11 +277,11 @@ public function testCreateAction() { $this->useEnglish(); - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $dao->remove('default_collection_role_CreateTestColName'); - $roles = Opus_CollectionRole::fetchAll(); + $roles = CollectionRole::fetchAll(); $this->assertEquals(22, count($roles)); @@ -307,7 +313,7 @@ public function testCreateAction() $this->dispatch('/admin/collectionroles/create'); - $roles = Opus_CollectionRole::fetchAll(); + $roles = CollectionRole::fetchAll(); $this->assertEquals(count($roleIds) + 1, count($roles)); // neue Collection wurde erzeugt @@ -351,12 +357,12 @@ public function testCreateActionForEdit() { $this->useEnglish(); - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $dao->remove('default_collection_role_ModifiedName'); - $roles = Opus_CollectionRole::fetchAll(); + $roles = CollectionRole::fetchAll(); - $role = new Opus_CollectionRole(); + $role = new CollectionRole(); $role->setName('EditTestName'); $role->setOaiName('EditTestOaiName'); $role->setDisplayBrowsing('Name'); @@ -394,9 +400,9 @@ public function testCreateActionForEdit() $this->dispatch('/admin/collectionroles/create'); // TODO if assertion fails newly created role is not removed (cleanup) - $this->assertEquals(count($roles) + 1, count(Opus_CollectionRole::fetchAll())); // keine neue Collection + $this->assertEquals(count($roles) + 1, count(CollectionRole::fetchAll())); // keine neue Collection - $role = new Opus_CollectionRole($roleId); + $role = new CollectionRole($roleId); $role->delete(); @@ -431,12 +437,12 @@ public function testCreateActionForEditCancel() $this->useEnglish(); - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $dao->remove('default_collection_role_ModifiedName'); - $roles = Opus_CollectionRole::fetchAll(); + $roles = CollectionRole::fetchAll(); - $role = new Opus_CollectionRole(); + $role = new CollectionRole(); $role->setName('EditTestName'); $role->setOaiName('EditTestOaiName'); $role->setDisplayBrowsing('Name'); @@ -474,9 +480,9 @@ public function testCreateActionForEditCancel() $this->dispatch('/admin/collectionroles/create'); // TODO if assertion fails newly created role is not removed (cleanup) - $this->assertEquals(count($roles) + 1, count(Opus_CollectionRole::fetchAll())); // keine neue Collection + $this->assertEquals(count($roles) + 1, count(CollectionRole::fetchAll())); // keine neue Collection - $role = new Opus_CollectionRole($roleId); + $role = new CollectionRole($roleId); $role->delete(); @@ -505,7 +511,7 @@ public function testCollectionRoleNameChangeModifiesTranslationKey() $oldName = 'TestCollectionRole'; $newName = 'NewNameForCollectionRole'; - $role = new Opus_CollectionRole(); + $role = new CollectionRole(); $role->setName($oldName); $role->setOaiName('oaiTestRole'); $roleId = $role->store(); diff --git a/tests/modules/admin/controllers/DnbinstituteControllerTest.php b/tests/modules/admin/controllers/DnbinstituteControllerTest.php index c6b0791606..10a2457520 100644 --- a/tests/modules/admin/controllers/DnbinstituteControllerTest.php +++ b/tests/modules/admin/controllers/DnbinstituteControllerTest.php @@ -31,6 +31,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Account; +use Opus\DnbInstitute; +use Opus\UserRole; + /** * Class Admin_DnbinstituteControllerTest * @@ -55,9 +59,9 @@ public function setUp() public function tearDown() { if (isset($this->roleId) && isset($this->userId)) { - $testRole = new Opus_UserRole($this->roleId); + $testRole = new UserRole($this->roleId); $testRole->delete(); - $userAccount = new Opus_Account($this->userId); + $userAccount = new Account($this->userId); $userAccount->delete(); } @@ -70,12 +74,12 @@ public function tearDown() public function getModels() { - return Opus_DnbInstitute::getAll(); + return DnbInstitute::getAll(); } public function createNewModel() { - $model = new Opus_DnbInstitute(); + $model = new DnbInstitute(); $model->setName('TestName'); $model->setCity('TestCity'); @@ -91,7 +95,7 @@ public function createNewModel() public function getModel($identifier) { - return new Opus_DnbInstitute($identifier); + return new DnbInstitute($identifier); } private function verifyShow() @@ -183,7 +187,7 @@ public function testNewActionCancel() $this->assertEquals( $modelCount, - count(Opus_DnbInstitute::getAll()), + count(DnbInstitute::getAll()), 'Es sollte keine neue Sprache geben.' ); } @@ -269,7 +273,7 @@ public function testDeleteActionShowForm() { $this->useEnglish(); - $institute = new Opus_DnbInstitute(); + $institute = new DnbInstitute(); $institute->updateFromArray([ 'Name' => 'Delete Test Institute', @@ -293,13 +297,13 @@ public function testDeleteActionShowForm() */ public function testUserAccessToInstituteWithInstituteRights() { - $testRole = new Opus_UserRole(); + $testRole = new UserRole(); $testRole->setName('TestRole'); $testRole->appendAccessModule('admin'); $testRole->appendAccessModule('resource_institutions'); $this->roleId = $testRole->store(); - $userAccount = new Opus_Account(); + $userAccount = new Account(); $userAccount->setLogin('role_tester') ->setPassword('role_tester'); $userAccount->setRole($testRole); @@ -321,13 +325,13 @@ public function testUserAccessToInstituteWithInstituteRights() */ public function testUserAccessToInstituteWithoutInstituteRights() { - $testRole = new Opus_UserRole(); + $testRole = new UserRole(); $testRole->setName('TestRole'); $testRole->appendAccessModule('admin'); $testRole->appendAccessModule('resource_languages'); $this->roleId = $testRole->store(); - $userAccount = new Opus_Account(); + $userAccount = new Account(); $userAccount->setLogin('role_tester') ->setPassword('role_tester'); $userAccount->setRole($testRole); @@ -350,13 +354,13 @@ public function testUserAccessToInstituteWithoutInstituteRights() */ public function testUserAccessToInstituteWithInstituteRightsRegression3245() { - $testRole = new Opus_UserRole(); + $testRole = new UserRole(); $testRole->setName('TestRole'); $testRole->appendAccessModule('admin'); $testRole->appendAccessModule('resource_institutions'); $this->roleId = $testRole->store(); - $userAccount = new Opus_Account(); + $userAccount = new Account(); $userAccount->setLogin('role_tester') ->setPassword('role_tester'); $userAccount->setRole($testRole); diff --git a/tests/modules/admin/controllers/DocumentControllerTest.php b/tests/modules/admin/controllers/DocumentControllerTest.php index 5f5f1306c1..3356eb7dc1 100644 --- a/tests/modules/admin/controllers/DocumentControllerTest.php +++ b/tests/modules/admin/controllers/DocumentControllerTest.php @@ -32,6 +32,12 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; +use Opus\Date; +use Opus\Note; +use Opus\Person; +use Opus\Title; + /** * Unit tests for Admin_DocumentController. * @@ -87,10 +93,10 @@ public function testWarningDisplayingDateOfBirth() { $doc = $this->createTestDocument(); - $person = new Opus_Person(); + $person = new Person(); $person->setFirstName("Johnny"); $person->setLastName("Test"); - $dateOfBirth = new Opus_Date(new Zend_Date('1.1.2010', 'dd/MM/yyyy')); + $dateOfBirth = new Date(new \Zend_Date('1.1.2010', 'dd/MM/yyyy')); $person->setDateOfBirth($dateOfBirth); $doc->addPersonAuthor($person); @@ -149,7 +155,7 @@ public function testPreserveNewlinesForAbstract() $doc = $this->createTestDocument(); $doc->setLanguage("eng"); - $abstract = new Opus_Title(); + $abstract = new Title(); $abstract->setLanguage("eng"); $abstract->setValue("foo\nbar\n\nbaz"); $doc->addTitleAbstract($abstract); @@ -171,7 +177,7 @@ public function testPreserveNewlinesForNote() $doc->setLanguage("eng"); $doc->setServerState("published"); - $note = new Opus_Note(); + $note = new Note(); $note->setMessage("foo\nbar\n\nbaz"); $note->setVisibility("public"); $doc->addNote($note); @@ -189,7 +195,7 @@ public function testPreserveNewlinesForNote() public function testDisplayCollectionNumberAndNameOnOverviewPageForDDCCollection() { $this->markTestIncomplete("Muss fuer OPUS 4.4 angepasst werden."); // TODO OPUSVIER-2794 - $role = new Opus_CollectionRole(2); + $role = new CollectionRole(2); $displayBrowsing = $role->getDisplayBrowsing(); $role->setDisplayBrowsing('Name'); $role->store(); @@ -207,7 +213,7 @@ public function testDisplayCollectionNumberAndNameOnOverviewPageForDDCCollection public function testDisplayCollectionNumberAndNameOnAssignmentPageForDDCCollection() { $this->markTestIncomplete("Muss fuer OPUS 4.4 angepasst werden."); // TODO OPUSVIER-2794 - $role = new Opus_CollectionRole(2); + $role = new CollectionRole(2); $displayBrowsing = $role->getDisplayBrowsing(); $role->setDisplayBrowsing('Name'); $role->store(); @@ -943,9 +949,9 @@ public function testShowDocumentWithFilesWithLanguageNull() public function testUnableToTranslateForMetadataView() { $logger = new MockLogger(); - Zend_Registry::set('Zend_Log', $logger); + \Zend_Registry::set('Zend_Log', $logger); - $adapter = Zend_Registry::get('Zend_Translate')->getAdapter(); + $adapter = \Zend_Registry::get('Zend_Translate')->getAdapter(); $options = $adapter->getOptions(); $options['log'] = $logger; $adapter->setOptions($options); @@ -962,7 +968,7 @@ public function testUnableToTranslateForMetadataView() } } - $output = Zend_Debug::dump($failedTranslations, null, false); + $output = \Zend_Debug::dump($failedTranslations, null, false); // currently only two messages cannot be avoided $this->assertLessThanOrEqual(2, count($failedTranslations), $output); @@ -971,9 +977,9 @@ public function testUnableToTranslateForMetadataView() public function testUnableToTranslateForEditForm() { $logger = new MockLogger(); - Zend_Registry::set('Zend_Log', $logger); + \Zend_Registry::set('Zend_Log', $logger); - $adapter = Zend_Registry::get('Zend_Translate')->getAdapter(); + $adapter = \Zend_Registry::get('Zend_Translate')->getAdapter(); $options = $adapter->getOptions(); $options['log'] = $logger; $adapter->setOptions($options); @@ -990,7 +996,7 @@ public function testUnableToTranslateForEditForm() } } - $output = Zend_Debug::dump($failedTranslations, null, false); + $output = \Zend_Debug::dump($failedTranslations, null, false); // currently only two messages cannot be avoided $this->assertLessThanOrEqual(2, count($failedTranslations), $output); diff --git a/tests/modules/admin/controllers/DocumentsControllerTest.php b/tests/modules/admin/controllers/DocumentsControllerTest.php index d858a32750..ece21c584b 100644 --- a/tests/modules/admin/controllers/DocumentsControllerTest.php +++ b/tests/modules/admin/controllers/DocumentsControllerTest.php @@ -30,6 +30,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; +use Opus\DocumentFinder; +use Opus\Person; + /** * Basic unit test for the documents controller in the admin module. * @@ -68,7 +72,7 @@ public function testCollectionRoleNameGetsTranslatedForDDC() */ public function testCollectionRoleNameGetsTranslatedForUserCollection() { - $cr = new Opus_CollectionRole(); + $cr = new CollectionRole(); $cr->setName('foo'); $cr->setOaiName('foo'); $cr->store(); @@ -82,7 +86,7 @@ public function testCollectionRoleNameGetsTranslatedForUserCollection() public function testShowAllDocsForDDCCollection() { - $role = new Opus_CollectionRole(2); + $role = new CollectionRole(2); $displayBrowsing = $role->getDisplayBrowsing(); $role->setDisplayBrowsing('Name'); $role->store(); @@ -99,7 +103,7 @@ public function testShowAllDocsForDDCCollection() public function testShowAllDocsForBklCollection() { - $role = new Opus_CollectionRole(7); + $role = new CollectionRole(7); $displayBrowsing = $role->getDisplayBrowsing(); $role->setDisplayBrowsing('Name'); $role->store(); @@ -144,7 +148,7 @@ public function testSelectHitsPerPage() public function testShowAllHits() { - $docFinder = new Opus_DocumentFinder(); + $docFinder = new DocumentFinder(); $docFinder->setServerState('unpublished'); $unpublishedDocs = $docFinder->count(); @@ -155,7 +159,7 @@ public function testShowAllHits() public function testHitsPerPageBadParameter() { - $docFinder = new Opus_DocumentFinder(); + $docFinder = new DocumentFinder(); $this->dispatch('/admin/documents/index/state/unpublished/hitsperpage/dummy'); $this->assertQueryCount('span.title', 10); // default @@ -163,7 +167,7 @@ public function testHitsPerPageBadParameter() public function testConfigureDefaultHitsPerPage() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->admin->documents->maxDocsDefault = '7'; $this->dispatch('/admin/documents'); @@ -172,7 +176,7 @@ public function testConfigureDefaultHitsPerPage() public function testConfigureHitsPerPageOptions() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->admin->documents->maxDocsOptions = "20,60,all"; $this->dispatch('/admin/documents'); @@ -205,7 +209,7 @@ public function testLinkForStateAuditedPresent() public function testShowAuthorFilter() { - $person = new Opus_Person(); + $person = new Person(); $person->setLastName('Test'); $person->setFirstName('Justa'); $person->setIdentifierOrcid('0000-0000-0000-0001'); diff --git a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php index cc2b6e32a0..89099c3ccc 100644 --- a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php +++ b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php @@ -33,6 +33,12 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Enrichment; +use Opus\EnrichmentKey; +use Opus\Enrichment\AbstractType; +use Opus\Model\NotFoundException; + /** * Basic unit tests for Admin_EnrichmentkeyController class. * @@ -44,7 +50,7 @@ class Admin_EnrichmentkeyControllerTest extends CrudControllerTestCase protected $additionalResources = 'all'; /** - * @var all enrichment keys + * @var EnrichmentKey[] All enrichment keys */ private $allEnrichmentKeys = []; @@ -52,26 +58,26 @@ public function setUp() { $this->setController('enrichmentkey'); parent::setUp(); - foreach (Opus_EnrichmentKey::getAll() as $value) { + foreach (EnrichmentKey::getAll() as $value) { array_push($this->allEnrichmentKeys, $value->getDisplayName()); } } public function getModels() { - return Opus_EnrichmentKey::getAll(); + return EnrichmentKey::getAll(); } public function createNewModel() { - $model = new Opus_EnrichmentKey(); + $model = new EnrichmentKey(); $model->setName('TestEnrichmentKey'); return $model->store(); } public function getModel($identifier) { - return new Opus_EnrichmentKey($identifier); + return new EnrichmentKey($identifier); } /** @@ -121,7 +127,7 @@ public function testNewActionSave() $this->assertRedirectRegex('/^\/admin\/enrichmentkey/'); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $enrichmentKey = new Opus_EnrichmentKey('MyTestEnrichment'); + $enrichmentKey = new EnrichmentKey('MyTestEnrichment'); $this->assertNotNull($enrichmentKey); $this->assertEquals('MyTestEnrichment', $enrichmentKey->getName()); $this->assertNull($enrichmentKey->getOptions()); @@ -147,7 +153,7 @@ public function testNewActionSaveEnrichmentKeyWithTypeOptionsAndStrictValidation $this->assertRedirectRegex('/^\/admin\/enrichmentkey/'); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $enrichmentKey = new Opus_EnrichmentKey('MyTestEnrichment'); + $enrichmentKey = new EnrichmentKey('MyTestEnrichment'); $this->assertNotNull($enrichmentKey); $this->assertEquals('MyTestEnrichment', $enrichmentKey->getName()); $this->assertEquals('RegexType', $enrichmentKey->getType()); @@ -174,7 +180,7 @@ public function testNewActionSaveEnrichmentKeyWithTypeOptionsAndNoValidation() $this->assertRedirectRegex('/^\/admin\/enrichmentkey/'); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $enrichmentKey = new Opus_EnrichmentKey('MyTestEnrichment'); + $enrichmentKey = new EnrichmentKey('MyTestEnrichment'); $this->assertNotNull($enrichmentKey); $this->assertEquals('MyTestEnrichment', $enrichmentKey->getName()); $this->assertEquals('RegexType', $enrichmentKey->getType()); @@ -198,7 +204,7 @@ public function testNewActionSaveMissingEnrichmentType() $this->assertRedirectRegex('/^\/admin\/enrichmentkey/'); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $enrichmentKey = new Opus_EnrichmentKey('MyTestEnrichment'); + $enrichmentKey = new EnrichmentKey('MyTestEnrichment'); $this->assertNotNull($enrichmentKey); $this->assertEquals('MyTestEnrichment', $enrichmentKey->getName()); $this->assertNull($enrichmentKey->getOptions()); @@ -222,7 +228,7 @@ public function testNewActionSaveEmptyEnrichmentType() $this->assertRedirectRegex('/^\/admin\/enrichmentkey/'); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $enrichmentKey = new Opus_EnrichmentKey('MyTestEnrichment'); + $enrichmentKey = new EnrichmentKey('MyTestEnrichment'); $this->assertNotNull($enrichmentKey); $this->assertEquals('MyTestEnrichment', $enrichmentKey->getName()); $this->assertNull($enrichmentKey->getOptions()); @@ -247,7 +253,7 @@ public function testNewActionSaveUnknownEnrichmentType() $this->assertResponseCode(200); $this->assertXpath('//div[@id = "admin_enrichmentkey_type-element"]/ul[@class="errors"]'); - $this->assertNull(Opus_EnrichmentKey::fetchByName('MyTestEnrichment')); + $this->assertNull(EnrichmentKey::fetchByName('MyTestEnrichment')); } public function testNewActionTranslationsEmpty() @@ -279,7 +285,7 @@ public function testNewActionCancel() $this->assertRedirectTo('/admin/enrichmentkey', 'Should be a redirect to index action.'); - $this->assertEquals($modelCount, count(Opus_EnrichmentKey::getAll()), 'There should be no new enrichment.'); + $this->assertEquals($modelCount, count(EnrichmentKey::getAll()), 'There should be no new enrichment.'); } public function testNewActionSaveForExistingEnrichment() @@ -321,7 +327,7 @@ public function testEditActionShowFormForUnprotectedEnrichmentKey($enrichmentKey public function testEditActionShowFormForProtectedEnrichmentKey() { $protectedEnrichmentKeyName = 'ClassRvk'; - $this->assertNotNull(new Opus_EnrichmentKey($protectedEnrichmentKeyName)); + $this->assertNotNull(new EnrichmentKey($protectedEnrichmentKeyName)); $this->dispatch($this->getControllerPath() . '/edit/id/' . $protectedEnrichmentKeyName); @@ -329,19 +335,15 @@ public function testEditActionShowFormForProtectedEnrichmentKey() $this->assertRedirectTo($this->getControllerPath()); $this->verifyFlashMessage('controller_crud_model_not_modifiable', self::MESSAGE_LEVEL_FAILURE); - $enrichmentKey = new Opus_EnrichmentKey($protectedEnrichmentKeyName); + $enrichmentKey = new EnrichmentKey($protectedEnrichmentKeyName); $this->assertEquals($protectedEnrichmentKeyName, $enrichmentKey->getName()); } - /** - * @expectedException Opus_Model_NotFoundException - * @expectedExceptionMessage No Opus_Db_EnrichmentKeys with id MyTestEnrichment in database. - */ public function testEditActionSave() { $this->createsModels = true; - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('MyTestEnrichment'); $enrichmentKey->setType('TextType'); $enrichmentKey->store(); @@ -359,25 +361,26 @@ public function testEditActionSave() $this->assertRedirectTo($this->getControllerPath()); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $enrichmentKey = new Opus_EnrichmentKey('MyTestEnrichmentModified'); + $enrichmentKey = new EnrichmentKey('MyTestEnrichmentModified'); $this->assertNotNull($enrichmentKey); $this->assertEquals('MyTestEnrichmentModified', $enrichmentKey->getName()); $this->assertEquals('RegexType', $enrichmentKey->getType()); $this->assertEquals(json_encode(["regex" => "^.*$", "validation" => "strict"]), $enrichmentKey->getOptions()); - new Opus_EnrichmentKey('MyTestEnrichment'); + $this->setExpectedException( + NotFoundException::class, + 'No Opus\Db\EnrichmentKeys with id MyTestEnrichment in database.' + ); + + new EnrichmentKey('MyTestEnrichment'); $this->fail('Previous statement should have thrown exception.'); } - /** - * @expectedException Opus_Model_NotFoundException - * @expectedExceptionMessage No Opus_Db_EnrichmentKeys with id ClassRvkModified in database. - */ public function testEditActionSaveForProtectedEnrichment() { $protectedEnrichmentKeyName = 'ClassRvk'; - $this->assertNotNull(new Opus_EnrichmentKey($protectedEnrichmentKeyName)); + $this->assertNotNull(new EnrichmentKey($protectedEnrichmentKeyName)); $this->getRequest()->setMethod('POST')->setPost([ 'Id' => $protectedEnrichmentKeyName, @@ -394,10 +397,15 @@ public function testEditActionSaveForProtectedEnrichment() $this->assertRedirectTo($this->getControllerPath()); $this->verifyFlashMessage('controller_crud_model_not_modifiable', self::MESSAGE_LEVEL_FAILURE); - $enrichmentKey = new Opus_EnrichmentKey($protectedEnrichmentKeyName); + $enrichmentKey = new EnrichmentKey($protectedEnrichmentKeyName); $this->assertEquals($protectedEnrichmentKeyName, $enrichmentKey->getName()); - new Opus_EnrichmentKey("${protectedEnrichmentKeyName}Modified"); + $this->setExpectedException( + NotFoundException::class, + 'No Opus\Db\EnrichmentKeys with id ClassRvkModified in database.' + ); + + new EnrichmentKey("${protectedEnrichmentKeyName}Modified"); $this->fail('Previous statement should have thrown exception.'); } @@ -405,7 +413,7 @@ public function testEditActionSaveWithoutEnrichmentType() { $this->createsModels = true; - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('MyTestEnrichment'); $enrichmentKey->setType('TextType'); $enrichmentKey->store(); @@ -426,7 +434,7 @@ public function testEditActionSaveWithEmptyEnrichmentType() { $this->createsModels = true; - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('MyTestEnrichment'); $enrichmentKey->setType('TextType'); $enrichmentKey->store(); @@ -448,7 +456,7 @@ public function testEditActionSaveWithExistingEnrichmentType() { $this->createsModels = true; - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('MyTestEnrichment'); $enrichmentKey->setType('TextType'); $enrichmentKey->store(); @@ -463,7 +471,7 @@ public function testEditActionSaveWithExistingEnrichmentType() $this->dispatch($this->getControllerPath() . '/edit'); $this->assertResponseCode(302); - $enrichmentKey = Opus_EnrichmentKey::fetchByName('MyTestEnrichment'); + $enrichmentKey = EnrichmentKey::fetchByName('MyTestEnrichment'); $this->assertEquals('BooleanType', $enrichmentKey->getEnrichmentType()->getName()); } @@ -471,7 +479,7 @@ public function testEditActionSaveWithUnknownEnrichmentType() { $this->createsModels = true; - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('MyTestEnrichment'); $enrichmentKey->store(); @@ -485,19 +493,15 @@ public function testEditActionSaveWithUnknownEnrichmentType() $this->dispatch($this->getControllerPath() . '/edit'); $this->assertResponseCode(200); - $this->assertNull(Opus_EnrichmentKey::fetchByName('MyTestEnrichmentModified')); - $this->assertNotNull(Opus_EnrichmentKey::fetchByName('MyTestEnrichment')); + $this->assertNull(EnrichmentKey::fetchByName('MyTestEnrichmentModified')); + $this->assertNotNull(EnrichmentKey::fetchByName('MyTestEnrichment')); } - /** - * @expectedException Opus_Model_NotFoundException - * @expectedExceptionMessage No Opus_Db_EnrichmentKeys with id MyTestEnrichmentModified in database. - */ public function testEditActionCancel() { $this->createsModels = true; - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('MyTestEnrichment'); $enrichmentKey->setType('TextType'); $enrichmentKey->store(); @@ -514,26 +518,27 @@ public function testEditActionCancel() $this->dispatch($this->getControllerPath() . '/edit'); $this->assertRedirectTo($this->getControllerPath()); - $enrichmentKey = new Opus_EnrichmentKey('MyTestEnrichment'); + $enrichmentKey = new EnrichmentKey('MyTestEnrichment'); $this->assertNotNull($enrichmentKey); $this->assertEquals('MyTestEnrichment', $enrichmentKey->getName()); $this->assertEquals('TextType', $enrichmentKey->getType()); $this->assertNull($enrichmentKey->getOptions()); - new Opus_EnrichmentKey('MyTestEnrichmentModified'); + $this->setExpectedException( + NotFoundException::class, + 'No Opus\Db\EnrichmentKeys with id MyTestEnrichmentModified in database.' + ); + + new EnrichmentKey('MyTestEnrichmentModified'); $this->fail('Previous statement should have thrown exception.'); } - /** - * @expectedException Opus_Model_NotFoundException - * @expectedExceptionMessage No Opus_Db_EnrichmentKeys with id ClassRvkModified in database. - */ public function testEditActionCancelForProtectedEnrichment() { $protectedEnrichmentKeyName = 'ClassRvk'; - $this->assertNotNull(new Opus_EnrichmentKey($protectedEnrichmentKeyName)); + $this->assertNotNull(new EnrichmentKey($protectedEnrichmentKeyName)); $this->getRequest()->setMethod('POST')->setPost([ 'Id' => $protectedEnrichmentKeyName, @@ -546,10 +551,15 @@ public function testEditActionCancelForProtectedEnrichment() $this->assertRedirect(); $this->assertRedirectTo($this->getControllerPath()); - $enrichmentKey = new Opus_EnrichmentKey($protectedEnrichmentKeyName); + $enrichmentKey = new EnrichmentKey($protectedEnrichmentKeyName); $this->assertEquals($protectedEnrichmentKeyName, $enrichmentKey->getName()); - new Opus_EnrichmentKey("${protectedEnrichmentKeyName}Modified"); + $this->setExpectedException( + NotFoundException::class, + 'No Opus\Db\EnrichmentKeys with id ClassRvkModified in database.' + ); + + new EnrichmentKey("${protectedEnrichmentKeyName}Modified"); $this->fail('Previous statement should have thrown exception.'); } @@ -567,7 +577,7 @@ public function testDeleteActionShowFormForUnprotectedEnrichmentKey($enrichmentK $this->assertQuery('input#ConfirmYes'); $this->assertQuery('input#ConfirmNo'); - $enrichmentKey = new Opus_EnrichmentKey($enrichmentKeyName); + $enrichmentKey = new EnrichmentKey($enrichmentKeyName); $this->assertNotNull($enrichmentKey); $this->assertEquals($enrichmentKeyName, $enrichmentKey->getName()); @@ -576,7 +586,7 @@ public function testDeleteActionShowFormForUnprotectedEnrichmentKey($enrichmentK public function testDeleteActionShowFormForProtectedEnrichmentKey() { $protectedEnrichmentKeyName = 'ClassRvk'; - $this->assertNotNull(new Opus_EnrichmentKey($protectedEnrichmentKeyName)); + $this->assertNotNull(new EnrichmentKey($protectedEnrichmentKeyName)); $this->dispatch($this->getControllerPath() . '/delete/id/' . $protectedEnrichmentKeyName); @@ -584,14 +594,14 @@ public function testDeleteActionShowFormForProtectedEnrichmentKey() $this->assertRedirectTo($this->getControllerPath()); $this->verifyFlashMessage('controller_crud_model_cannot_delete', self::MESSAGE_LEVEL_FAILURE); - $enrichmentKey = new Opus_EnrichmentKey($protectedEnrichmentKeyName); + $enrichmentKey = new EnrichmentKey($protectedEnrichmentKeyName); $this->assertEquals($protectedEnrichmentKeyName, $enrichmentKey->getName()); } public function testRemoveFromDocsShowFormForProtectedEnrichment() { $protectedEnrichmentKeyName = 'ClassRvk'; - $this->assertNotNull(new Opus_EnrichmentKey($protectedEnrichmentKeyName)); + $this->assertNotNull(new EnrichmentKey($protectedEnrichmentKeyName)); $this->dispatch($this->getControllerPath() . '/removeFromDocs/id/' . $protectedEnrichmentKeyName); @@ -599,14 +609,14 @@ public function testRemoveFromDocsShowFormForProtectedEnrichment() $this->assertRedirectTo($this->getControllerPath()); $this->verifyFlashMessage('controller_crud_model_cannot_delete', self::MESSAGE_LEVEL_FAILURE); - $enrichmentKey = new Opus_EnrichmentKey($protectedEnrichmentKeyName); + $enrichmentKey = new EnrichmentKey($protectedEnrichmentKeyName); $this->assertEquals($protectedEnrichmentKeyName, $enrichmentKey->getName()); } public function testRemoveFromDocsShowFormForUnprotectedEnrichment() { $enrichmentKeyName = 'Audience'; // wird von einem Dokument verwendet - $enrichmentKey = new Opus_EnrichmentKey($enrichmentKeyName); + $enrichmentKey = new EnrichmentKey($enrichmentKeyName); $this->assertEquals($enrichmentKeyName, $enrichmentKey->getName()); $this->useEnglish(); @@ -618,14 +628,14 @@ public function testRemoveFromDocsShowFormForUnprotectedEnrichment() $this->assertQuery('input#ConfirmYes'); $this->assertQuery('input#ConfirmNo'); - $enrichmentKey = new Opus_EnrichmentKey($enrichmentKeyName); + $enrichmentKey = new EnrichmentKey($enrichmentKeyName); $this->assertEquals($enrichmentKeyName, $enrichmentKey->getName()); } public function testRemoveFromDocsForProtectedEnrichmentKey() { $protectedEnrichmentKeyName = 'ClassRvk'; - $this->assertNotNull(new Opus_EnrichmentKey($protectedEnrichmentKeyName)); + $this->assertNotNull(new EnrichmentKey($protectedEnrichmentKeyName)); $post = [ 'Id' => $protectedEnrichmentKeyName, @@ -639,7 +649,7 @@ public function testRemoveFromDocsForProtectedEnrichmentKey() $this->assertRedirectTo($this->getControllerPath()); $this->verifyFlashMessage('controller_crud_model_cannot_delete', self::MESSAGE_LEVEL_FAILURE); - $enrichmentKey = new Opus_EnrichmentKey($protectedEnrichmentKeyName); + $enrichmentKey = new EnrichmentKey($protectedEnrichmentKeyName); $this->assertEquals($protectedEnrichmentKeyName, $enrichmentKey->getName()); } @@ -648,23 +658,23 @@ public function testRemoveFromDocsForUnprotectedEnrichmentKey() $enrichmentKeyName = 'testRemoveFromDocsForUnprotectedEnrichmentKey'; $this->createsModels = true; // damit am Ende des Test ein Cleanup durchgeführt wird (neu angelegter EK wird gelöscht) - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName($enrichmentKeyName); $enrichmentKey->setType('TextType'); $enrichmentKey->store(); - $this->assertContains($enrichmentKeyName, Opus_EnrichmentKey::getAll(true)); + $this->assertContains($enrichmentKeyName, EnrichmentKey::getAll(true)); // assign test document to enrichment key $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName($enrichmentKeyName); $enrichment->setValue('foo'); $doc->addEnrichment($enrichment); $docId = $doc->store(); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $this->assertCount(1, $doc->getEnrichment()); $this->useEnglish(); @@ -682,10 +692,10 @@ public function testRemoveFromDocsForUnprotectedEnrichmentKey() $this->verifyFlashMessage('controller_crud_delete_success', self::MESSAGE_LEVEL_NOTICE); // EnrichmentKey muss noch vorhanden sein, aber das entsprechende Enrichment im Testdokument wurde gelöscht - $enrichmentKey = new Opus_EnrichmentKey($enrichmentKeyName); + $enrichmentKey = new EnrichmentKey($enrichmentKeyName); $this->assertEquals($enrichmentKeyName, $enrichmentKey->getName()); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $this->assertCount(0, $doc->getEnrichment()); } @@ -712,7 +722,7 @@ public function testEnrichmentTypeHandlingRoundTrip() $this->assertRedirectRegex('/^\/admin\/enrichmentkey/'); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $enrichmentKey = new Opus_EnrichmentKey($enrichmentKeyName); + $enrichmentKey = new EnrichmentKey($enrichmentKeyName); $this->assertNotNull($enrichmentKey); $this->assertEquals($enrichmentKeyName, $enrichmentKey->getName()); $this->assertEquals($post['Type'], $enrichmentKey->getType()); @@ -772,7 +782,7 @@ public function testEnrichmentTypeWithInvalidOptions() $this->assertRedirectRegex('/^\/admin\/enrichmentkey/'); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $enrichmentKey = new Opus_EnrichmentKey($enrichmentKeyName); + $enrichmentKey = new EnrichmentKey($enrichmentKeyName); $this->assertNotNull($enrichmentKey); $this->assertEquals($enrichmentKeyName, $enrichmentKey->getName()); $this->assertNull($enrichmentKey->getOptions()); @@ -803,7 +813,7 @@ public function testAllEnrichmentTypesAreAvailableInEditForm() $this->getRequest()->setMethod('GET'); $this->dispatch($this->getControllerPath() . '/new'); - $allEnrichmentTypes = Opus_Enrichment_AbstractType::getAllEnrichmentTypes(false); + $allEnrichmentTypes = AbstractType::getAllEnrichmentTypes(false); $this->assertXpathCount('//select/option', 1 + count($allEnrichmentTypes)); // +1, weil Standardauswahl leer ist $this->assertXpathContentRegex('//select/option[1]', "//"); @@ -842,7 +852,7 @@ public function testProtectedCssClassIsSet() */ public function testUsedCssClassIsSet() { - $usedKeys = Opus_EnrichmentKey::getAllReferenced(); + $usedKeys = EnrichmentKey::getAllReferenced(); $this->dispatch($this->getControllerPath()); $response = $this->getResponse(); $this->checkForBadStringsInHtml($response->getBody()); @@ -883,7 +893,7 @@ public function testProtectedCssClassIsNotSet() */ public function testUsedCssClassIsNotSet() { - $unusedKeys = array_diff($this->allEnrichmentKeys, Opus_EnrichmentKey::getAllReferenced()); + $unusedKeys = array_diff($this->allEnrichmentKeys, EnrichmentKey::getAllReferenced()); $this->dispatch($this->getControllerPath()); $response = $this->getResponse(); $this->checkForBadStringsInHtml($response->getBody()); @@ -908,7 +918,7 @@ public function testInitializedNewFormWithUnregisteredKeyName() { $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('unregistered'); $enrichment->setValue('value'); @@ -923,13 +933,13 @@ public function testInitializedNewFormWithUnregisteredKeyName() public function testInitializedNewFormWithRegisteredUnusedKeyName() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('unused'); $id = $enrichmentKey->store(); $this->dispatch($this->getControllerPath() . '/new/id/unused'); - $enrichmentKey = new Opus_EnrichmentKey($id); + $enrichmentKey = new EnrichmentKey($id); $enrichmentKey->delete(); // Formularfeld "Name" darf nicht gefüllt sein @@ -938,13 +948,13 @@ public function testInitializedNewFormWithRegisteredUnusedKeyName() public function testInitializedNewFormWithRegisteredUsedKeyName() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('used'); $id = $enrichmentKey->store(); $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('used'); $enrichment->setValue('value'); @@ -953,7 +963,7 @@ public function testInitializedNewFormWithRegisteredUsedKeyName() $this->dispatch($this->getControllerPath() . '/new/id/used'); - $enrichmentKey = new Opus_EnrichmentKey($id); + $enrichmentKey = new EnrichmentKey($id); $enrichmentKey->delete(); // Formularfeld "Name" darf nicht gefüllt sein @@ -990,7 +1000,7 @@ public function testRemoveFromDocsActionWithUnregisteredId() { $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('testRemoveFromDocsActionWithUnregisteredId'); $enrichment->setValue('value'); @@ -1004,13 +1014,13 @@ public function testRemoveFromDocsActionWithUnregisteredId() public function testRemoveFromDocsActionWithRegisteredUnusedId() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('unused'); $id = $enrichmentKey->store(); $this->dispatch($this->getControllerPath() . '/removeFromDocs/id/unused'); - $enrichmentKey = new Opus_EnrichmentKey($id); + $enrichmentKey = new EnrichmentKey($id); $enrichmentKey->delete(); $this->assertRedirectTo('/admin/enrichmentkey'); @@ -1018,13 +1028,13 @@ public function testRemoveFromDocsActionWithRegisteredUnusedId() public function testRemoveFromDocsActionWithRegisteredUsedId() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('used'); $id = $enrichmentKey->store(); $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('used'); $enrichment->setValue('value'); @@ -1033,7 +1043,7 @@ public function testRemoveFromDocsActionWithRegisteredUsedId() $this->dispatch($this->getControllerPath() . '/removeFromDocs/id/used'); - $enrichmentKey = new Opus_EnrichmentKey($id); + $enrichmentKey = new EnrichmentKey($id); $enrichmentKey->delete(); $this->assertResponseCode(200); @@ -1044,7 +1054,7 @@ public function testRemoveFromDocsActionPostWithUnregisteredKey() { $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('unregistered'); $enrichment->setValue('value'); @@ -1062,19 +1072,19 @@ public function testRemoveFromDocsActionPostWithUnregisteredKey() $this->assertRedirectTo('/admin/enrichmentkey'); // das Testdokument sollte kein Enrichment mehr haben - $doc = new Opus_Document($id); + $doc = Document::get($id); $this->assertNull($doc->getEnrichment('unregistered')); } public function testRemoveFromDocsActionPostWithRegisteredKey() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('used'); $id = $enrichmentKey->store(); $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('used'); $enrichment->setValue('value'); @@ -1092,9 +1102,9 @@ public function testRemoveFromDocsActionPostWithRegisteredKey() $this->assertRedirectTo('/admin/enrichmentkey'); // das Testdokument sollte kein Enrichment mehr haben; der EnrichmentKey muss weiterhin existieren - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $this->assertNull($doc->getEnrichment('used')); - $enrichmentKey = new Opus_EnrichmentKey($id); + $enrichmentKey = new EnrichmentKey($id); $this->assertNotNull($enrichmentKey); // cleanup @@ -1105,7 +1115,7 @@ public function testIndexPageShowUnregisteredKeys() { $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('unregistered'); $enrichment->setValue('value'); @@ -1123,13 +1133,13 @@ public function testIndexPageShowUnregisteredKeys() public function testIndexPageShowRegisteredUnusedKeys() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('unused'); $id = $enrichmentKey->store(); $this->dispatch($this->getControllerPath() . '/'); - $enrichmentKey = new Opus_EnrichmentKey($id); + $enrichmentKey = new EnrichmentKey($id); $enrichmentKey->delete(); $this->assertResponseCode(200); @@ -1141,13 +1151,13 @@ public function testIndexPageShowRegisteredUnusedKeys() public function testIndexPageShowRegisteredUsedKeys() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('used'); $id = $enrichmentKey->store(); $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('used'); $enrichment->setValue('value'); @@ -1156,7 +1166,7 @@ public function testIndexPageShowRegisteredUsedKeys() $this->dispatch($this->getControllerPath() . '/'); - $enrichmentKey = new Opus_EnrichmentKey($id); + $enrichmentKey = new EnrichmentKey($id); $enrichmentKey->delete(); $this->assertResponseCode(200); @@ -1170,7 +1180,7 @@ public function testNewActionWithRenamingUnregisteredKey() { // prepare test document with unregistered enrichment key $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('unregistered'); $enrichment->setValue('value'); $doc->addEnrichment($enrichment); @@ -1189,13 +1199,13 @@ public function testNewActionWithRenamingUnregisteredKey() $this->assertRedirect(); $this->assertRedirectRegex('/^\/admin\/enrichmentkey/'); - $enrichmentKey = Opus_EnrichmentKey::fetchByName('unregistered'); + $enrichmentKey = EnrichmentKey::fetchByName('unregistered'); $this->assertNull($enrichmentKey); - $enrichmentKey = Opus_EnrichmentKey::fetchByName('unregisterednew'); + $enrichmentKey = EnrichmentKey::fetchByName('unregisterednew'); $this->assertNotNull($enrichmentKey); - $doc = new Opus_Document($id); + $doc = Document::get($id); $enrichments = $doc->getEnrichment(); $this->assertCount(1, $enrichments); $this->assertEquals('unregisterednew', $enrichments[0]->getKeyName()); @@ -1208,7 +1218,7 @@ public function testNewActionWithoutRenamingUnregisteredKey() { // prepare test document with unregistered enrichment key $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName('unregistered'); $enrichment->setValue('value'); $doc->addEnrichment($enrichment); @@ -1227,10 +1237,10 @@ public function testNewActionWithoutRenamingUnregisteredKey() $this->assertRedirect(); $this->assertRedirectRegex('/^\/admin\/enrichmentkey/'); - $enrichmentKey = Opus_EnrichmentKey::fetchByName('unregistered'); + $enrichmentKey = EnrichmentKey::fetchByName('unregistered'); $this->assertNotNull($enrichmentKey); - $doc = new Opus_Document($id); + $doc = Document::get($id); $enrichments = $doc->getEnrichment(); $this->assertCount(1, $enrichments); $this->assertEquals('unregistered', $enrichments[0]->getKeyName()); diff --git a/tests/modules/admin/controllers/FilemanagerControllerTest.php b/tests/modules/admin/controllers/FilemanagerControllerTest.php index abba2f0a7f..45e02571d4 100644 --- a/tests/modules/admin/controllers/FilemanagerControllerTest.php +++ b/tests/modules/admin/controllers/FilemanagerControllerTest.php @@ -33,6 +33,10 @@ * TODO einiges durch Selenium abgedeckt; Unit Tests vielleicht möglich */ +use Opus\Date; +use Opus\Document; +use Opus\UserRole; + /** * @covers Admin_FilemanagerController */ @@ -269,11 +273,11 @@ public function testRemoveGuestAccess() $file->setPathName('testdatei.txt'); $documentId = $document->store(); - $document = new Opus_Document($documentId); + $document = Document::get($documentId); $fileId = $document->getFile(0)->getId(); - $roleGuest = Opus_UserRole::fetchByName('guest'); + $roleGuest = UserRole::fetchByName('guest'); $files = $roleGuest->listAccessFiles(); $this->assertContains($fileId, $files); @@ -297,7 +301,7 @@ public function testRemoveGuestAccess() $this->assertResponseCode(302); $this->assertRedirectTo('/admin/document/index/id/' . $documentId); - $roleGuest = Opus_UserRole::fetchByName('guest'); + $roleGuest = UserRole::fetchByName('guest'); $files = $roleGuest->listAccessFiles(); $this->assertNotContains($fileId, $files); } @@ -331,7 +335,7 @@ public function testFileUploadDate() $docId = $doc->store(); - $dateNow = new Opus_Date(); + $dateNow = new Date(); $dateNow->setNow(); $this->dispatch('admin/filemanager/index/id/' . $docId); @@ -345,7 +349,7 @@ public function testFileUploadDate() public function testFileUploadDateAfterModification() { $this->useGerman(); - $doc = new Opus_Document(305); + $doc = Document::get(305); foreach ($doc->getFile() as $file) { $file->setComment(rand()); diff --git a/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php b/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php index fac57993fb..94da727fd6 100644 --- a/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php +++ b/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Job; +use Opus\Job\Runner; + /** * Class Admin_IndexmaintenanceControllerTest * @@ -46,7 +49,7 @@ class Admin_IndexmaintenanceControllerTest extends ControllerTestCase public function tearDown() { // Cleanup of Log File - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $filename = $config->workspacePath . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'opus_consistency-check.log'; if (file_exists($filename)) { unlink($filename); @@ -58,7 +61,7 @@ public function tearDown() } // Cleanup of Jobs Table - $jobs = Opus_Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL]); + $jobs = Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL]); foreach ($jobs as $job) { try { $job->delete(); @@ -170,7 +173,7 @@ private function disableAsyncMode() private function setAsyncMode($value) { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'runjobs' => ['asynchronous' => $value] ])); } @@ -187,7 +190,7 @@ private function disableAsyncIndexmaintenanceMode() private function setAsyncIndexmaintenanceMode($value) { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'runjobs' => ['indexmaintenance' => ['asynchronous' => $value]] ])); } @@ -241,7 +244,7 @@ public function testCheckconsistencyActionWithEnabledFeature() { $this->enableAsyncIndexmaintenanceMode(); - $numOfJobs = Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL); + $numOfJobs = Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL); $this->assertEquals(0, $numOfJobs); $this->getRequest()->setMethod('POST'); @@ -250,19 +253,19 @@ public function testCheckconsistencyActionWithEnabledFeature() $this->assertResponseCode(302); $this->assertResponseLocationHeader($this->getResponse(), '/admin/indexmaintenance'); - $this->assertEquals(1, Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); + $this->assertEquals(1, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); - $jobs = Opus_Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL]); + $jobs = Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL]); $jobs[0]->delete(); - $this->assertEquals(0, Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); + $this->assertEquals(0, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); } public function testCheckconsistencyActionResult() { $this->enableAsyncIndexmaintenanceMode(); - $this->assertEquals(0, Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL), 'missing cleanup of jobs table'); + $this->assertEquals(0, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL), 'missing cleanup of jobs table'); $this->getRequest()->setMethod('POST'); $this->dispatch('/admin/indexmaintenance/checkconsistency'); @@ -270,7 +273,7 @@ public function testCheckconsistencyActionResult() $this->assertResponseCode(302); $this->assertResponseLocationHeader($this->getResponse(), '/admin/indexmaintenance'); - $this->assertEquals(1, Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL), 'consistency check job was not stored in database'); + $this->assertEquals(1, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL), 'consistency check job was not stored in database'); /* * check if job was scheduled for execution @@ -291,13 +294,13 @@ public function testCheckconsistencyActionResult() /* * run job immediately and check for result */ - $jobrunner = new Opus_Job_Runner(); - $jobrunner->setLogger(Zend_Registry::get('Zend_Log')); + $jobrunner = new Runner(); + $jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); $worker = new Opus\Search\Task\ConsistencyCheck(); $jobrunner->registerWorker($worker); $jobrunner->run(); - $jobs = Opus_Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL]); + $jobs = Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL]); if (count($jobs) > 0) { $job = $jobs[0]; $message = 'at least one unexpected job found (Label: \'%s\', State: \'%s\', Data: \'%s\', Errors: \'%s\, SHA1 Hash: \'%s\')'; @@ -309,7 +312,7 @@ public function testCheckconsistencyActionResult() $this->fail(sprintf($message, $label, $state, $data, $errors, $hash)); } - $this->assertEquals(0, Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL), 'consistency check job was not removed from database after execution'); + $this->assertEquals(0, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL), 'consistency check job was not removed from database after execution'); $this->resetResponse(); $this->resetRequest(); diff --git a/tests/modules/admin/controllers/InfoControllerTest.php b/tests/modules/admin/controllers/InfoControllerTest.php index dcd9ca908d..d8f3104847 100644 --- a/tests/modules/admin/controllers/InfoControllerTest.php +++ b/tests/modules/admin/controllers/InfoControllerTest.php @@ -43,7 +43,7 @@ class Admin_InfoControllerTest extends ControllerTestCase public function testIndexDisplayVersion() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $this->dispatch('admin/info'); $this->assertResponseCode(200); $this->assertQuery('dt#admin_info_version'); @@ -59,10 +59,10 @@ public function testVersionWithOldVersion() $this->useEnglish(); // set version that would otherwise be retrieved from server - $versionHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('version'); + $versionHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('version'); $versionHelper->setVersion('4.6'); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $oldVersion = $config->version; $config->version = '4.5-TEST'; $this->dispatch('admin/info/update'); @@ -80,8 +80,8 @@ public function testVersionWithOldVersion() public function testVersionWithCurrentVersion() { $this->useEnglish(); - $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('version'); - $helper->setVersion(Zend_Registry::get('Zend_Config')->version); + $helper = \Zend_Controller_Action_HelperBroker::getStaticHelper('version'); + $helper->setVersion(\Zend_Registry::get('Zend_Config')->version); $this->dispatch('admin/info/update'); $this->assertQueryContentContains('//div', 'Your OPUS version is up to date.'); diff --git a/tests/modules/admin/controllers/IprangeControllerTest.php b/tests/modules/admin/controllers/IprangeControllerTest.php index 4966d53655..5e4e68fb30 100644 --- a/tests/modules/admin/controllers/IprangeControllerTest.php +++ b/tests/modules/admin/controllers/IprangeControllerTest.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Iprange; +use Opus\UserRole; + /** * Basic unit tests for IP range controller in admin module. * @@ -51,20 +54,20 @@ public function setUp() public function getModels() { - return Opus_Iprange::getAll(); + return Iprange::getAll(); } public function createNewModel() { $this->createsModels = true; - $ipRange = new Opus_Iprange(); + $ipRange = new Iprange(); $ipRange->setName('localhost'); $ipRange->setStartingip('127.0.0.1'); $ipRange->setEndingip('127.0.0.2'); $ipRange->setRole([ - Opus_UserRole::fetchByName('reviewer'), - Opus_UserRole::fetchByName('docsadmin') + UserRole::fetchByName('reviewer'), + UserRole::fetchByName('docsadmin') ]); return $ipRange->store(); @@ -72,7 +75,7 @@ public function createNewModel() public function getModel($identifier) { - return new Opus_Iprange($identifier); + return new Iprange($identifier); } public function testShowAction() @@ -150,7 +153,7 @@ public function testNewActionCancel() $this->assertRedirectTo('/admin/iprange', 'Should redirect to index action.'); - $this->assertEquals($modelCount, count(Opus_Iprange::getAll()), 'There should be no new ip range.'); + $this->assertEquals($modelCount, count(Iprange::getAll()), 'There should be no new ip range.'); } public function testEditActionShowForm() @@ -188,7 +191,7 @@ public function testEditActionSave() $this->assertRedirectTo("/admin/iprange/show/id/$iprangeId"); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $iprange = new Opus_IpRange($iprangeId); + $iprange = new Iprange($iprangeId); $this->assertEquals('ModifiedName', $iprange->getName()); $this->assertEquals('127.0.0.99', $iprange->getStartingip()); @@ -216,7 +219,7 @@ public function testEditActionCancel() $this->dispatch("/admin/iprange/edit"); $this->assertRedirectTo('/admin/iprange'); - $iprange = new Opus_Iprange($iprangeId); + $iprange = new Iprange($iprangeId); $this->assertEquals('localhost', $iprange->getName()); } diff --git a/tests/modules/admin/controllers/JobControllerTest.php b/tests/modules/admin/controllers/JobControllerTest.php index e324573cd1..6c7f398fd7 100644 --- a/tests/modules/admin/controllers/JobControllerTest.php +++ b/tests/modules/admin/controllers/JobControllerTest.php @@ -29,7 +29,11 @@ * @author Edouard Simon * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * + */ + +use Opus\Job; + +/** * @covers Admin_JobController */ class Admin_JobControllerTest extends ControllerTestCase @@ -46,20 +50,20 @@ public function setUp() $this->makeConfigurationModifiable(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $this->__configBackup = $config; - $config->merge(new Zend_Config(['runjobs' => ['asynchronous' => self::CONFIG_VALUE_TRUE]])); + $config->merge(new \Zend_Config(['runjobs' => ['asynchronous' => self::CONFIG_VALUE_TRUE]])); - $this->assertEquals(0, Opus_Job::getCount(Opus_Job::STATE_FAILED), 'test data changed.'); + $this->assertEquals(0, Job::getCount(Job::STATE_FAILED), 'test data changed.'); for ($i = 0; $i < 10; $i++) { - $job = new Opus_Job(); + $job = new Job(); $job->setLabel('testjob' . ($i < 5 ? 1 : 2)); $job->setData([ 'documentId' => $i, 'task' => 'get-me-a-coffee' ]); - $job->setState(Opus_Job::STATE_FAILED); + $job->setState(Job::STATE_FAILED); $this->jobIds[] = $job->store(); } } @@ -67,12 +71,12 @@ public function setUp() public function tearDown() { - $testJobs = Opus_Job::getAll($this->jobIds); + $testJobs = Job::getAll($this->jobIds); foreach ($testJobs as $job) { $job->delete(); } - Zend_Registry::set('Zend_Config', $this->__configBackup); + \Zend_Registry::set('Zend_Config', $this->__configBackup); parent::tearDown(); } @@ -95,7 +99,7 @@ public function testMonitorFailedWorkerJobs() public function testJobDetailsAction() { - $failedJobsUrl = '/admin/job/detail/label/testjob1/state/' . Opus_Job::STATE_FAILED; + $failedJobsUrl = '/admin/job/detail/label/testjob1/state/' . Job::STATE_FAILED; $this->dispatch($failedJobsUrl); $this->assertResponseCode(200); $this->assertQueryContentContains('table.worker-jobs td div', 'task: get-me-a-coffee'); diff --git a/tests/modules/admin/controllers/LanguageControllerTest.php b/tests/modules/admin/controllers/LanguageControllerTest.php index 7226218523..40e8248395 100644 --- a/tests/modules/admin/controllers/LanguageControllerTest.php +++ b/tests/modules/admin/controllers/LanguageControllerTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Language; + /** * Basic unit tests for Admin_LanguageController class. * @@ -49,14 +51,14 @@ public function setUp() public function getModels() { - return Opus_Language::getAll(); + return Language::getAll(); } public function testShowAction() { $this->createsModels = true; - $language = new Opus_Language(); + $language = new Language(); $language->setActive(true); $language->setRefName('German'); @@ -71,7 +73,7 @@ public function testShowAction() $this->dispatch('/admin/language/show/id/' . $modelId); - $model = new Opus_Language($modelId); + $model = new Language($modelId); $model->delete(); $this->assertResponseCode(200); @@ -166,7 +168,7 @@ public function testNewActionCancel() $this->assertEquals( $modelCount, - count(Opus_Language::getAll()), + count(Language::getAll()), 'Es sollte keine neue Sprache geben.' ); } @@ -192,7 +194,7 @@ public function testEditActionSave() { $this->createsModels = true; - $model = new Opus_Language(); + $model = new Language(); $model->setRefName('Test'); $model->setPart2T('tst'); @@ -216,7 +218,7 @@ public function testEditActionSave() $this->assertRedirectTo('/admin/language/show/id/' . $modelId); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $model = new Opus_Language($modelId); + $model = new Language($modelId); $this->assertEquals(1, $model->getActive()); $this->assertEquals('RefNameModified', $model->getRefName()); @@ -232,7 +234,7 @@ public function testEditActionCancel() { $this->createsModels = true; - $model = new Opus_Language(); + $model = new Language(); $model->setRefName('Test'); $model->setPart2T('tst'); @@ -249,7 +251,7 @@ public function testEditActionCancel() $this->dispatch('/admin/language/edit'); $this->assertRedirectTo('/admin/language'); - $model = new Opus_Language($modelId); + $model = new Language($modelId); $this->assertEquals('Test', $model->getRefName()); } @@ -268,7 +270,7 @@ public function testDeleteActionShowForm() public function createNewModel() { - $model = new Opus_Language(); + $model = new Language(); $model->setRefName('TestLang'); $model->setPart2T('lan'); @@ -278,6 +280,6 @@ public function createNewModel() public function getModel($identifier) { - return new Opus_Language($identifier); + return new Language($identifier); } } diff --git a/tests/modules/admin/controllers/LicenceControllerTest.php b/tests/modules/admin/controllers/LicenceControllerTest.php index 695ef047f0..7fd01874f6 100644 --- a/tests/modules/admin/controllers/LicenceControllerTest.php +++ b/tests/modules/admin/controllers/LicenceControllerTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Licence; + /** * Unit Tests für Klasse Admin_LicenceController. * @@ -51,7 +53,7 @@ public function setUp() public function getModels() { - return Opus_Licence::getAll(); + return Licence::getAll(); } /** @@ -61,7 +63,7 @@ public function testShowAction() { $this->createsModels = true; - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setActive(true); $licence->setNameLong('TestNameLong'); @@ -80,7 +82,7 @@ public function testShowAction() $this->dispatch('/admin/licence/show/id/' . $licenceId); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $licence->delete(); $this->assertResponseCode(200); @@ -189,7 +191,7 @@ public function testNewActionCancel() $this->assertEquals( $modelCount, - count(Opus_Licence::getAll()), + count(Licence::getAll()), 'Es sollte keine neue Lizenz geben.' ); } @@ -214,7 +216,7 @@ public function testEditActionSave() { $this->createsModels = true; - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setNameLong('NameLong'); $licence->setLanguage('deu'); @@ -242,7 +244,7 @@ public function testEditActionSave() $this->assertRedirectTo('/admin/licence/show/id/' . $licenceId); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $this->assertEquals(1, $licence->getActive()); $this->assertEquals('NameLongModified', $licence->getNameLong()); @@ -261,7 +263,7 @@ public function testEditActionCancel() { $this->createsModels = true; - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setNameLong('NameLong'); $licence->setLanguage('deu'); @@ -280,7 +282,7 @@ public function testEditActionCancel() $this->dispatch('/admin/licence/edit'); $this->assertRedirectTo('/admin/licence'); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $this->assertEquals('NameLong', $licence->getNameLong()); } @@ -310,7 +312,7 @@ public function testDeleteActionUsedLicence() public function createNewModel() { - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setNameLong('Test Licence (LicenceControllerTest::testDeleteAction)'); $licence->setLinkLicence('testlink'); @@ -321,6 +323,6 @@ public function createNewModel() public function getModel($identifier) { - return new Opus_Licence($identifier); + return new Licence($identifier); } } diff --git a/tests/modules/admin/controllers/PersonControllerTest.php b/tests/modules/admin/controllers/PersonControllerTest.php index 3d285b0f2e..4d7a69a479 100644 --- a/tests/modules/admin/controllers/PersonControllerTest.php +++ b/tests/modules/admin/controllers/PersonControllerTest.php @@ -1,5 +1,4 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * + */ + +use Opus\Person; + +/** * @covers Admin_PersonController */ class Admin_PersonControllerTest extends ControllerTestCase @@ -110,7 +113,7 @@ public function testAssignActionAddPerson() preg_match('/person\/(\d+)\//', $location, $matches); $personId = $matches[1]; - $person = new Opus_Person($personId); + $person = new Person($personId); $lastName = $person->getLastName(); @@ -193,7 +196,7 @@ public function testEditlinkedActionSave() { $document = $this->createTestDocument(); - $person = new Opus_Person(); + $person = new Person(); $person->setLastName('Testy-EditlinkedAction'); $person = $document->addPersonTranslator($person); @@ -218,7 +221,7 @@ public function testEditlinkedActionSave() $this->assertRedirectTo('/admin/document/edit/id/' . $documentId . '/continue/updateperson/person/' . $personId); - $person = new Opus_Person($personId); + $person = new Person($personId); $this->assertEquals('Testy', $person->getLastName()); $this->assertEquals('Simone', $person->getFirstName()); @@ -378,7 +381,7 @@ public function testIndexPaginationFirstPage() } /** - * TODO test is affected by other tests creating Opus_Person objects, because deleting test documents does not + * TODO test is affected by other tests creating Person objects, because deleting test documents does not * delete linked persons */ public function testIndexPaginationLastPage() @@ -392,7 +395,7 @@ public function testIndexPaginationLastPage() $this->assertQuery('div.pagination-next'); $this->assertQuery('div.pagination-last'); - $personsCount = Opus_Person::getAllPersonsCount(); + $personsCount = Person::getAllPersonsCount(); $pages = ceil($personsCount / 50); diff --git a/tests/modules/admin/controllers/ReportControllerTest.php b/tests/modules/admin/controllers/ReportControllerTest.php index ee66be9d97..252ec40863 100644 --- a/tests/modules/admin/controllers/ReportControllerTest.php +++ b/tests/modules/admin/controllers/ReportControllerTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Identifier; + /** * Unit tests for Admin_ReportController * @@ -50,11 +53,11 @@ public function setUp() parent::setUp(); // backup config - $this->config = Zend_Registry::get('Zend_Config'); + $this->config = \Zend_Registry::get('Zend_Config'); // modify DOI config - $config = Zend_Registry::get('Zend_Config'); - $config->merge(new Zend_Config([ + $config = \Zend_Registry::get('Zend_Config'); + $config->merge(new \Zend_Config([ 'doi' => [ 'prefix' => '10.5072', 'localPrefix' => 'opustest', @@ -69,18 +72,18 @@ public function setUp() ] ] ])); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); } public function tearDown() { // restore config - Zend_Registry::set('Zend_Config', $this->config); + \Zend_Registry::set('Zend_Config', $this->config); if (! is_null($this->docIds)) { // removed previously created test documents from database foreach ($this->docIds as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $doc->deletePermanent(); } } @@ -257,12 +260,12 @@ private function createTestDocs() private function createTestDocWithDoi($serverState, $doiStatus, $local = true) { - $doc = new Opus_Document(); + $doc = Document::new(); $doc->setServerState($serverState); $docId = $doc->store(); $this->docIds[] = $docId; - $doi = new Opus_Identifier(); + $doi = new Identifier(); $doi->setType('doi'); if ($local) { $doi->setValue('10.5072/opustest-' . $docId); diff --git a/tests/modules/admin/controllers/RoleControllerTest.php b/tests/modules/admin/controllers/RoleControllerTest.php index a43c5734d7..ac905f5736 100644 --- a/tests/modules/admin/controllers/RoleControllerTest.php +++ b/tests/modules/admin/controllers/RoleControllerTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\UserRole; + /** * Basic unit tests for Admin_RoleController class. * @@ -123,7 +125,7 @@ public function testCreateAction() $this->assertController('role'); $this->assertAction('new'); $this->assertRedirect('/admin/role/index'); - $this->assertNotNull(Opus_UserRole::fetchByName('testrole')); + $this->assertNotNull(UserRole::fetchByName('testrole')); } public function testCreateActionCancel() @@ -166,7 +168,7 @@ public function testCreateActionMissingInput() */ public function testUpdateAction() { - $role = Opus_UserRole::fetchByName('testrole'); + $role = UserRole::fetchByName('testrole'); $this->request ->setMethod('POST') @@ -183,7 +185,7 @@ public function testUpdateAction() $this->assertController('role'); $this->assertAction('edit'); $this->assertRedirect(); - $role = Opus_UserRole::fetchByName('testrole2'); + $role = UserRole::fetchByName('testrole2'); $this->assertNotNull($role); $this->assertNotNull($role->getId()); $this->assertEquals('testrole2', $role->getDisplayName()); @@ -194,7 +196,7 @@ public function testUpdateAction() */ public function testUpdateActionInvalidInput() { - $role = Opus_UserRole::fetchByName('testrole2'); + $role = UserRole::fetchByName('testrole2'); $this->request ->setMethod('POST') @@ -218,7 +220,7 @@ public function testUpdateActionInvalidInput() */ public function testDeleteAction() { - $role = Opus_UserRole::fetchByName('testrole2'); + $role = UserRole::fetchByName('testrole2'); $this->assertNotNull($role); $this->getRequest()->setMethod('POST') ->setPost([ diff --git a/tests/modules/admin/controllers/SeriesControllerTest.php b/tests/modules/admin/controllers/SeriesControllerTest.php index 1641448852..5ae75e1ea0 100644 --- a/tests/modules/admin/controllers/SeriesControllerTest.php +++ b/tests/modules/admin/controllers/SeriesControllerTest.php @@ -33,6 +33,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Series; + /** * Class Admin_SeriesControllerTest. * @@ -51,12 +53,12 @@ public function setUp() public function getModels() { - return Opus_Series::getAllSortedBySortKey(); + return Series::getAllSortedBySortKey(); } public function createNewModel() { - $series = new Opus_Series(); + $series = new Series(); $series->setTitle('Testseries'); $series->setInfobox('Infotext'); @@ -68,7 +70,7 @@ public function createNewModel() public function getModel($identifier) { - return new Opus_Series($identifier); + return new Series($identifier); } public function testShowAction() @@ -93,7 +95,7 @@ public function testShowNewAction() { $this->dispatch('/admin/series/new'); - $sortOrder = Opus_Series::getMaxSortKey() + 1; + $sortOrder = Series::getMaxSortKey() + 1; $this->assertXPath('//input[@type = "checkbox" and @checked = "checked"]'); $this->assertXPath('//input[@name = "SortOrder" and @value = "' . $sortOrder . '"]'); @@ -155,7 +157,7 @@ public function testNewActionCancel() $this->assertEquals( $modelCount, - count(Opus_Series::getAllSortedBySortKey()), + count(Series::getAllSortedBySortKey()), 'Es sollte keine neue Series geben.' ); } @@ -192,7 +194,7 @@ public function testEditActionSave() $this->assertRedirectTo('/admin/series/show/id/' . $seriesId); $this->verifyFlashMessage('controller_crud_save_success', self::MESSAGE_LEVEL_NOTICE); - $series = new Opus_Series($seriesId); + $series = new Series($seriesId); $this->assertEquals('ModifiedTitle', $series->getTitle()); $this->assertEquals('ModifiedInfo', $series->getInfobox()); @@ -218,7 +220,7 @@ public function testEditActionCancel() $this->dispatch('/admin/series/edit'); $this->assertRedirectTo('/admin/series'); - $series = new Opus_Series($seriesId); + $series = new Series($seriesId); $this->assertEquals('Testseries', $series->getTitle()); } @@ -239,7 +241,7 @@ public function testHideDocumentsLinkForSeriesWithoutDocuments() { $this->dispatch('/admin/series'); - $allSeries = Opus_Series::getAll(); + $allSeries = Series::getAll(); foreach ($allSeries as $series) { $seriesId = $series->getId(); @@ -255,7 +257,7 @@ public function testSeriesVisibilityIsDisplayedCorrectly() { $this->dispatch('/admin/series'); - $allSeries = Opus_Series::getAll(); + $allSeries = Series::getAll(); foreach ($allSeries as $series) { $seriesId = $series->getId(); @@ -271,7 +273,7 @@ public function testSeriesIdIsShownInTable() { $this->dispatch('/admin/series'); - $allSeries = Opus_Series::getAll(); + $allSeries = Series::getAll(); foreach ($allSeries as $series) { $seriesId = $series->getId(); diff --git a/tests/modules/admin/controllers/WorkflowControllerTest.php b/tests/modules/admin/controllers/WorkflowControllerTest.php index bd8e04f954..efc9d54337 100644 --- a/tests/modules/admin/controllers/WorkflowControllerTest.php +++ b/tests/modules/admin/controllers/WorkflowControllerTest.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Person; + /** * Class Admin_WorkflowControllerTest. * @@ -44,7 +47,7 @@ class Admin_WorkflowControllerTest extends ControllerTestCase private function enablePublishNotification() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->notification->document->published->enabled = self::CONFIG_VALUE_TRUE; $config->notification->document->published->email = "published@localhost"; } @@ -53,7 +56,7 @@ private function createDocWithSubmitterAndAuthor($submitterMail, $authorMail) { $doc = $this->createTestDocument(); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName("John"); $author->setLastName("Doe"); if ($author != '') { @@ -61,7 +64,7 @@ private function createDocWithSubmitterAndAuthor($submitterMail, $authorMail) } $doc->addPersonAuthor($author); - $submitter = new Opus_Person(); + $submitter = new Person(); $submitter->setFirstName("John"); $submitter->setLastName("Submitter"); if ($submitterMail != '') { @@ -101,7 +104,7 @@ public function testDeleteActionConfirmNo() $this->assertAction('changestate'); $this->assertRedirect('/admin/document/index'); - $doc = new Opus_Document(24); + $doc = Document::get(24); $this->assertNotEquals('deleted', $doc->getServerState()); } @@ -121,7 +124,7 @@ public function testDeleteActionConfirmYes() $this->assertAction('changestate'); $this->assertRedirect('/admin/document/index'); - $doc = new Opus_Document(102); + $doc = Document::get(102); $this->assertEquals('deleted', $doc->getServerState()); $doc->setServerState('unpublished'); $doc->store(); @@ -164,7 +167,7 @@ public function testPermanentDeleteActionConfirmNo() $this->assertAction('changestate'); $this->assertRedirect('/admin/document/index'); - $doc = new Opus_Document($documentId); + $doc = Document::get($documentId); $this->assertEquals('deleted', $doc->getServerState()); } @@ -184,7 +187,7 @@ public function testPublishActionConfirmYes() $this->assertAction('changestate'); $this->assertRedirect('/admin/document/index'); - $doc = new Opus_Document(100); + $doc = Document::get(100); $this->assertEquals('published', $doc->getServerState()); $doc->setServerState('unpublished'); $doc->store(); @@ -383,18 +386,18 @@ public function testAuthorNotificationForMultipleAuthors() 'author@localhost.de' ); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName("AFN"); $author->setLastName("ALN"); $author->setEmail("A@localhost.de"); $doc->addPersonAuthor($author); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName("BFN"); $author->setLastName("BLN"); $doc->addPersonAuthor($author); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName("CFN"); $author->setLastName("CLN"); $author->setEmail("C@localhost.de"); @@ -433,14 +436,14 @@ public function testShowDocInfoOnConfirmationPage() public function testConfirmationDisabled() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'confirmation' => ['document' => ['statechange' => ['enabled' => self::CONFIG_VALUE_FALSE]]] ])); $this->dispatch('/admin/workflow/changestate/docId/102/targetState/deleted'); $this->assertRedirectTo('/admin/document/index/id/102'); // Änderung wird sofort durchgefuehrt - $doc = new Opus_Document(102); + $doc = Document::get(102); $this->assertEquals('deleted', $doc->getServerState()); $doc->setServerState('unpublished'); $doc->store(); diff --git a/tests/modules/admin/forms/AbstractDocumentSubFormTest.php b/tests/modules/admin/forms/AbstractDocumentSubFormTest.php index d2a3e49b5a..cf782a44a4 100644 --- a/tests/modules/admin/forms/AbstractDocumentSubFormTest.php +++ b/tests/modules/admin/forms/AbstractDocumentSubFormTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Licence; + /** * Unit Tests fuer abstrakte Parent-Klasse fuer Metadaten Unterformulare. * @@ -70,7 +72,7 @@ public function testInit() */ public function testPopulateFromModel() { - $this->form->populateFromModel(new Opus_Licence()); + $this->form->populateFromModel(new Licence()); } /** diff --git a/tests/modules/admin/forms/AccountTest.php b/tests/modules/admin/forms/AccountTest.php index 126ea1b3dc..4650ce97c0 100644 --- a/tests/modules/admin/forms/AccountTest.php +++ b/tests/modules/admin/forms/AccountTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Account; + class Admin_Form_AccountTest extends ControllerTestCase { @@ -41,7 +43,7 @@ public function setUp() { parent::setUp(); - $user = new Opus_Account(); + $user = new Account(); $user->setLogin('user'); $user->setPassword('userpwd'); $user->store(); @@ -66,7 +68,7 @@ public function testCreateForm() public function testCreateFormForUser() { - $user = new Opus_Account(null, null, 'user'); + $user = new Account(null, null, 'user'); $form = new Admin_Form_Account($user->getId()); $this->assertNotNUll($form); $this->assertEquals('user', $form->getElement('username')->getValue()); @@ -79,7 +81,7 @@ public function testCreateFormForUser() public function testCreateFormForCurrentUser() { $this->loginUser('admin', 'adminadmin'); - $user = new Opus_Account(null, null, 'admin'); + $user = new Account(null, null, 'admin'); $form = new Admin_Form_Account($user->getId()); $this->assertNotNull($form); $element = $form->getSubForm(Admin_Form_Account::SUBFORM_ROLES)->getElement('administrator'); @@ -91,7 +93,7 @@ public function testCreateFormForCurrentUser() */ public function testDoNotLowerCaseUsername() { - $user = new Opus_Account(null, null, 'user'); + $user = new Account(null, null, 'user'); $form = new Admin_Form_Account($user->getId()); @@ -106,7 +108,7 @@ public function testDoNotLowerCaseUsername() public function testChangedLoginNameValidationExistingLoginNameAccount() { - $user = new Opus_Account(null, null, 'user'); + $user = new Account(null, null, 'user'); $form = new Admin_Form_Account($user->getId()); @@ -124,7 +126,7 @@ public function testChangedLoginNameValidationExistingLoginNameAccount() public function testChangedLoginNameValidationNewLoginName() { - $user = new Opus_Account(null, null, 'user'); + $user = new Account(null, null, 'user'); $form = new Admin_Form_Account($user->getId()); @@ -142,7 +144,7 @@ public function testChangedLoginNameValidationNewLoginName() public function testEditValidationSameAccount() { - $user = new Opus_Account(null, null, 'user'); + $user = new Account(null, null, 'user'); $form = new Admin_Form_Account($user->getId()); diff --git a/tests/modules/admin/forms/ActionBoxTest.php b/tests/modules/admin/forms/ActionBoxTest.php index add480b5ca..e971909065 100644 --- a/tests/modules/admin/forms/ActionBoxTest.php +++ b/tests/modules/admin/forms/ActionBoxTest.php @@ -36,17 +36,17 @@ class Admin_Form_ActionBoxTest extends ControllerTestCase public function testGetJumpLinks() { - $testForm = new Zend_Form(); + $testForm = new \Zend_Form(); - $subform = new Zend_Form_SubForm(); + $subform = new \Zend_Form_SubForm(); $subform->setLegend('Subform 1'); $testForm->addSubForm($subform, 'form1'); - $subform = new Zend_Form_SubForm(); + $subform = new \Zend_Form_SubForm(); $subform->setLegend('Subform 2'); $testForm->addSubForm($subform, 'form2'); - $subform = new Zend_Form_SubForm(); + $subform = new \Zend_Form_SubForm(); $subform->setLegend(null); $testForm->addSubForm($subform, 'form3'); diff --git a/tests/modules/admin/forms/CollectionRoleTest.php b/tests/modules/admin/forms/CollectionRoleTest.php index 7817a9e65a..5a08894046 100644 --- a/tests/modules/admin/forms/CollectionRoleTest.php +++ b/tests/modules/admin/forms/CollectionRoleTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; + class Admin_Form_CollectionRoleTest extends ControllerTestCase { @@ -40,7 +42,7 @@ public function testConstructForm() { $form = new Admin_Form_CollectionRole(); - $this->assertEquals(15, count($form->getElements())); + $this->assertCount(15, $form->getElements()); $this->assertNotNull($form->getElement('Name')); $this->assertNotNull($form->getElement('DisplayName')); @@ -65,7 +67,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_CollectionRole(); - $model = new Opus_CollectionRole(); + $model = new CollectionRole(); $model->setName('TestName'); $model->setOaiName('TestOaiName'); @@ -103,7 +105,7 @@ public function testPopulateFromModelWithId() { $form = new Admin_Form_CollectionRole(); - $model = new Opus_CollectionRole(2); + $model = new CollectionRole(2); $form->populateFromModel($model); @@ -135,7 +137,7 @@ public function testUpdateModel() $form->getElement('AssignLeavesOnly')->setValue(1); $form->getElement('HideEmptyCollections')->setValue(1); - $model = new Opus_CollectionRole(); + $model = new CollectionRole(); $form->updateModel($model); diff --git a/tests/modules/admin/forms/CollectionTest.php b/tests/modules/admin/forms/CollectionTest.php index 8abc2feb67..3800076891 100644 --- a/tests/modules/admin/forms/CollectionTest.php +++ b/tests/modules/admin/forms/CollectionTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Collection; + class Admin_Form_CollectionTest extends ControllerTestCase { @@ -40,7 +42,7 @@ public function testConstructForm() { $form = new Admin_Form_Collection(); - $this->assertEquals('7', count($form->getElements())); + $this->assertCount(7, $form->getElements()); $this->assertNotNull($form->getElement('Name')); $this->assertNotNull($form->getElement('Number')); $this->assertNotNull($form->getElement('Visible')); @@ -56,7 +58,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Collection(); - $model = new Opus_Collection(); + $model = new Collection(); $model->setName('TestName'); $model->setNumber('50'); @@ -77,7 +79,7 @@ public function testHandlingOfNullValue() { $form = new Admin_Form_Collection(); - $model = new Opus_Collection(); + $model = new Collection(); $model->setName('TestName'); $model->setNumber(null); @@ -94,7 +96,7 @@ public function testPopulateFromModelWithId() { $form = new Admin_Form_Collection(); - $model = new Opus_Collection(3); + $model = new Collection(3); $form->populateFromModel($model); @@ -113,7 +115,7 @@ public function testUpdateModel() $form->getElement('OaiSubset')->setValue('TestSubset'); // $form->getElement('Theme')->setValue('plain'); - $model = new Opus_Collection(); + $model = new Collection(); $form->updateModel($model); diff --git a/tests/modules/admin/forms/ConfigurationTest.php b/tests/modules/admin/forms/ConfigurationTest.php index c177effef4..12fe339ce8 100644 --- a/tests/modules/admin/forms/ConfigurationTest.php +++ b/tests/modules/admin/forms/ConfigurationTest.php @@ -49,7 +49,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Configuration(); - $form->populateFromModel(new Zend_Config([ + $form->populateFromModel(new \Zend_Config([ 'searchengine' => ['solr' => ['parameterDefaults' => ['rows' => '20']]] ])); // searchengine.solr.parameterDefaults.rows @@ -65,7 +65,7 @@ public function testUpdateModel() $form->getElement('maxSearchResults')->setValue(15); - $config = new Zend_Config([], true); + $config = new \Zend_Config([], true); $form->updateModel($config); diff --git a/tests/modules/admin/forms/DnbInstituteTest.php b/tests/modules/admin/forms/DnbInstituteTest.php index 734060dd79..95a52d2e87 100644 --- a/tests/modules/admin/forms/DnbInstituteTest.php +++ b/tests/modules/admin/forms/DnbInstituteTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\DnbInstitute; + class Admin_Form_DnbInstituteTest extends ControllerTestCase { @@ -40,7 +42,7 @@ public function testConstructForm() { $form = new Admin_Form_DnbInstitute(); - $this->assertEquals(11, count($form->getElements())); + $this->assertCount(11, $form->getElements()); $this->assertNotNull($form->getElement('Name')); $this->assertNotNull($form->getElement('Department')); @@ -60,7 +62,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_DnbInstitute(); - $model = new Opus_DnbInstitute(); + $model = new DnbInstitute(); $model->setName('TestName'); $model->setDepartment('TestDepartment'); $model->setAddress('TestAddress'); @@ -88,7 +90,7 @@ public function testPopulateFromModelWithId() { $form = new Admin_Form_DnbInstitute(); - $model = new Opus_DnbInstitute(2); + $model = new DnbInstitute(2); $form->populateFromModel($model); @@ -108,7 +110,7 @@ public function testUpdateModel() $form->getElement('IsGrantor')->setChecked(true); $form->getElement('IsPublisher')->setChecked(false); - $model = new Opus_DnbInstitute(); + $model = new DnbInstitute(); $form->updateModel($model); diff --git a/tests/modules/admin/forms/Document/AbstractTest.php b/tests/modules/admin/forms/Document/AbstractTest.php index e8d0c7b80a..b951da360d 100644 --- a/tests/modules/admin/forms/Document/AbstractTest.php +++ b/tests/modules/admin/forms/Document/AbstractTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\TitleAbstract; + /** * Unit Tests fuer Unterformular fuer Zusammenfassungen. */ @@ -52,7 +55,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Abstract(); - $doc = new Opus_Document(146); + $doc = Document::get(146); $abstracts = $doc->getTitleAbstract(); @@ -74,7 +77,7 @@ public function testUpdateModel() $form->getElement('Language')->setValue('eng'); $form->getElement('Value')->setValue('Test Zusammenfassung!'); - $abstract = new Opus_TitleAbstract(); + $abstract = new TitleAbstract(); $form->updateModel($abstract); @@ -86,7 +89,7 @@ public function testGetModel() { $form = new Admin_Form_Document_Abstract(); - $doc = new Opus_Document(146); + $doc = Document::get(146); $abstracts = $doc->getTitleAbstract(); diff --git a/tests/modules/admin/forms/Document/BibliographicTest.php b/tests/modules/admin/forms/Document/BibliographicTest.php index 37d0741ba2..87ae43f4c2 100644 --- a/tests/modules/admin/forms/Document/BibliographicTest.php +++ b/tests/modules/admin/forms/Document/BibliographicTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Unit Tests fuer Unterformular fuer bibliographische Information im Metadaten-Formular. */ @@ -78,7 +80,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Bibliographic(); - $doc = new Opus_Document(146); + $doc = Document::get(146); $form->populateFromModel($doc); diff --git a/tests/modules/admin/forms/Document/CollectionTest.php b/tests/modules/admin/forms/Document/CollectionTest.php index 74a121e1db..f6c2a54779 100644 --- a/tests/modules/admin/forms/Document/CollectionTest.php +++ b/tests/modules/admin/forms/Document/CollectionTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Collection; + /** * Tests fuer Admin_Form_Document_Collection Unterformular Klasse. */ @@ -43,7 +45,7 @@ public function createForm() { $form = new Admin_Form_Document_Collection(); - $this->assertEquals(3, count($form->getElements())); + $this->assertCount(3, $form->getElements()); $this->assertNotNull($form->getElement('Id')); $this->assertNotNull($form->getElement('Edit')); @@ -54,7 +56,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Collection(); - $collection = new Opus_Collection(499); + $collection = new Collection(499); $form->populateFromModel($collection); @@ -68,7 +70,7 @@ public function testPopulateFromModelWithRootCollectionWithoutName() $form = new Admin_Form_Document_Collection(); - $collection = new Opus_Collection(2); // Root-Collection DDC-Klassifikation + $collection = new Collection(2); // Root-Collection DDC-Klassifikation $form->populateFromModel($collection); @@ -122,7 +124,7 @@ public function testPopulateFromPost() $form->populateFromPost($post); - $collection = new Opus_Collection(499); + $collection = new Collection(499); $this->assertEquals($collection->getDisplayName(), $form->getLegend()); $this->assertEquals($collection->getId(), $form->getElement('Id')->getValue()); diff --git a/tests/modules/admin/forms/Document/CollectionsTest.php b/tests/modules/admin/forms/Document/CollectionsTest.php index 3c8bc8f91a..59ead8de88 100644 --- a/tests/modules/admin/forms/Document/CollectionsTest.php +++ b/tests/modules/admin/forms/Document/CollectionsTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + class Admin_Form_Document_CollectionsTest extends ControllerTestCase { @@ -55,7 +57,7 @@ public function testAddGetSubformWithDashInName() { $form = new Admin_Form_Document_Collections(); - $subform = new Zend_Form_SubForm(); + $subform = new \Zend_Form_SubForm(); $form->addSubForm($subform, 'ddc-2'); @@ -94,7 +96,7 @@ public function testPopulateFromPost() */ public function testFormNameRendering() { - $form = new Zend_Form(); + $form = new \Zend_Form(); $form->setName('ddc-2'); $html = $form->render(); @@ -104,7 +106,7 @@ public function testFormNameRendering() public function testGetGroupedCollections() { - $document = new Opus_Document(146); + $document = Document::get(146); $form = new Admin_Form_Document_Collections(); @@ -116,6 +118,6 @@ public function testGetGroupedCollections() $ddc = $grouped['ddc']; $this->assertCount(4, $ddc); - $this->assertInstanceOf('Opus_Collection', $ddc[0]); + $this->assertInstanceOf('Opus\Collection', $ddc[0]); } } diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index 8ba8fdb2ad..e54b449eac 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -31,6 +31,12 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Enrichment; +use Opus\EnrichmentKey; +use Opus\Enrichment\RegexType; +use Opus\Enrichment\SelectType; + /** * Unit Test für Unterformular für ein Enrichment im Metadaten-Formular. */ @@ -55,7 +61,7 @@ public function testPopulateFromModelWithoutType() { $enrichmentKey = $this->createTestEnrichmentKey('keywithouttype'); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue('foo'); $enrichment->setKeyName('keywithouttype'); @@ -69,7 +75,7 @@ public function testPopulateFromModelWithUnknownType() { $enrichmentKey = $this->createTestEnrichmentKey('keywithunknowntype', 'FooBarType'); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue('foo'); $enrichment->setKeyName('keywithunknowntype'); @@ -83,7 +89,7 @@ public function testPopulateFromModelBooleanTypeChecked() { $enrichmentKey = $this->createTestEnrichmentKey('boolean', 'BooleanType'); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue(1); $enrichment->setKeyName('boolean'); @@ -97,7 +103,7 @@ public function testPopulateFromModelBooleanTypeUnchecked() { $enrichmentKey = $this->createTestEnrichmentKey('boolean', 'BooleanType'); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue(0); $enrichment->setKeyName('boolean'); @@ -118,7 +124,7 @@ public function testPopulateFromModelSelectType() ); foreach ($options as $option) { - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue($option); $enrichment->setKeyName('select'); @@ -138,7 +144,7 @@ public function testPopulateFromModelSelectTypeWithInvalidValue() ['values' => $options, 'validation' => 'strict'] ); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue('foobar'); // dieser Wert ist gemäß Konfiguration nicht gültig $enrichment->setKeyName('select'); @@ -151,7 +157,7 @@ public function testPopulateFromModelTextType() { $enrichmentKey = $this->createTestEnrichmentKey('text', 'TextType'); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue('foo'); $enrichment->setKeyName('text'); @@ -164,7 +170,7 @@ public function testPopulateFromModelTextareaType() { $enrichmentKey = $this->createTestEnrichmentKey('textarea', 'TextareaType'); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue("foo\nbar\baz"); $enrichment->setKeyName('textarea'); @@ -177,7 +183,7 @@ public function testPopulateFromModelRegexType() { $enrichmentKey = $this->createTestEnrichmentKey('regexkey', 'RegexType', ["regex" => "^foo$"]); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue("foo"); $enrichment->setKeyName('regexkey'); @@ -197,7 +203,7 @@ public function testPopulateFromModelRegexTypeWithInvalidValue() ] ); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue("bar"); // dieser Wert ist gemäß der Typkonfiguration nicht gültig $enrichment->setKeyName('regexkey'); @@ -241,7 +247,7 @@ private function assertFormElementValues($enrichment, $valueFormElementName) public function testUpdateModel() { - $keyNames = Opus_EnrichmentKey::getAll(); + $keyNames = EnrichmentKey::getAll(); $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); @@ -250,7 +256,7 @@ public function testUpdateModel() $form->getElement('KeyName')->setValue($keyName); $form->getElement('Value')->setValue('Test Enrichment Value'); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $form->updateModel($enrichment); $this->assertEquals($keyName, $enrichment->getKeyName()); @@ -271,7 +277,7 @@ public function testUpdateModelWithSelectType() $form->getElement('KeyName')->setValue('select'); $form->getElement('Value')->setValue(1); // Index des ausgewählten Werts - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue('foo'); // das Enrichment-Formular wird nur für Enrichments mit gesetztem Wert aufgerufen $form->updateModel($enrichment); @@ -299,7 +305,7 @@ public function testUpdateModelWithSelectTypeWithInvalidValueAndNoValidationAndI $form->getElement('KeyName')->setValue('select'); $form->getElement('Value')->setValue(0); // Index des ausgewählten Werts: der Ursprungswert des Enrichments (foobar) - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue('foobar'); // das Enrichment-Formular wird nur für Enrichments mit gesetztem Wert aufgerufen $form->updateModel($enrichment); @@ -327,7 +333,7 @@ public function testUpdateModelWithSelectTypeWithInvalidValueAndNoValidationAndV $form->getElement('KeyName')->setValue('select'); $form->getElement('Value')->setValue(1); // Index des ausgewählten Werts: foo - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setValue('foobar'); // das Enrichment-Formular wird nur für Enrichments mit gesetztem Wert aufgerufen $form->updateModel($enrichment); @@ -339,11 +345,11 @@ public function testUpdateModelWithSelectTypeWithInvalidValueAndNoValidationAndV public function testGetModel() { - $document = new Opus_Document(146); + $document = Document::get(146); $enrichments = $document->getEnrichment(); $enrichment = $enrichments[0]; - $keyNames = Opus_EnrichmentKey::getAll(); + $keyNames = EnrichmentKey::getAll(); $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); @@ -361,7 +367,7 @@ public function testGetModel() public function testGetNewModel() { - $keyNames = Opus_EnrichmentKey::getAll(); + $keyNames = EnrichmentKey::getAll(); $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); @@ -379,7 +385,7 @@ public function testGetNewModel() public function testGetModelUnknownId() { - $keyNames = Opus_EnrichmentKey::getAll(); + $keyNames = EnrichmentKey::getAll(); $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); @@ -406,7 +412,7 @@ public function testGetModelUnknownId() public function testGetModelBadId() { - $keyNames = Opus_EnrichmentKey::getAll(); + $keyNames = EnrichmentKey::getAll(); $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); @@ -425,7 +431,7 @@ public function testGetModelBadId() public function testValidationWithoutType() { - $keyNames = Opus_EnrichmentKey::getAll(); + $keyNames = EnrichmentKey::getAll(); $keyName = $keyNames[1]->getName(); // Geht davon aus, dass mindestens 2 Enrichment Keys existieren $form = new Admin_Form_Document_Enrichment(); @@ -453,7 +459,7 @@ public function testValidationWithSelectType() { $options = ['foo', 'bar', 'baz']; $selectOptions = ['values' => $options]; - $type = new Opus_Enrichment_SelectType(); + $type = new SelectType(); $type->setOptions($selectOptions); $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); @@ -482,7 +488,7 @@ public function testValidationWithSelectTypeMissingValue() { $options = ['foo', 'bar', 'baz']; $selectOptions = ['values' => $options]; - $type = new Opus_Enrichment_SelectType(); + $type = new SelectType(); $type->setOptions($selectOptions); $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); @@ -513,7 +519,7 @@ public function testValidationWithSelectTypeInvalidValue() { $options = ['foo', 'bar', 'baz']; $selectOptions = ['values' => $options]; - $type = new Opus_Enrichment_SelectType(); + $type = new SelectType(); $type->setOptions($selectOptions); $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); @@ -545,7 +551,7 @@ public function testValidationWithSelectTypeAndStrictValidationAndInvalidValue() { $options = ['foo', 'bar', 'baz']; $selectOptions = ['values' => $options, 'validation' => 'strict']; - $type = new Opus_Enrichment_SelectType(); + $type = new SelectType(); $type->setOptions($selectOptions); $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); @@ -577,7 +583,7 @@ public function testValidationWithSelectTypeAndStrictValidationAndValidValue() { $options = ['foo', 'bar', 'baz']; $selectOptions = ['values' => $options, 'validation' => 'strict']; - $type = new Opus_Enrichment_SelectType(); + $type = new SelectType(); $type->setOptions($selectOptions); $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); @@ -599,7 +605,7 @@ public function testValidationWithSelectTypeAndStrictValidationAndValidValue() $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(0, $form->getErrors('Value')); - $enrichment = new Opus_Enrichment($enrichmentId); + $enrichment = new Enrichment($enrichmentId); $form->updateModel($enrichment); $this->assertEquals('baz', $enrichment->getValue()); @@ -610,7 +616,7 @@ public function testValidationWithSelectTypeAndNoValidationAndInvalidValue() { $options = ['foo', 'bar', 'baz']; $selectOptions = ['values' => $options, 'validation' => 'none']; - $type = new Opus_Enrichment_SelectType(); + $type = new SelectType(); $type->setOptions($selectOptions); $enrichmentKey = $this->createEnrichmentKeyAndForm('select', $type); @@ -632,7 +638,7 @@ public function testValidationWithSelectTypeAndNoValidationAndInvalidValue() $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(0, $form->getErrors('Value')); - $enrichment = new Opus_Enrichment($enrichmentId); + $enrichment = new Enrichment($enrichmentId); $form->updateModel($enrichment); $this->assertEquals('foobar', $enrichment->getValue()); @@ -641,7 +647,7 @@ public function testValidationWithSelectTypeAndNoValidationAndInvalidValue() public function testValidationWithRegexType() { - $type = new Opus_Enrichment_RegexType(); + $type = new RegexType(); $type->setOptions(['regex' => '^abc$']); $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); @@ -671,7 +677,7 @@ public function testValidationWithRegexType() public function testValidationWithRegexTypeWithMissingValue() { - $type = new Opus_Enrichment_RegexType(); + $type = new RegexType(); $type->setOptions(['regex' => '^.*$']); $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); @@ -701,7 +707,7 @@ public function testValidationWithRegexTypeWithMissingValue() public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() { - $type = new Opus_Enrichment_RegexType(); + $type = new RegexType(); $type->setOptions(['regex' => '^abc$']); // mit dem Namen soll sichergestellt werden, dass dieser Enrichment-Key @@ -733,7 +739,7 @@ public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() public function testValidationWithRegexTypeAndStrictValidationWithInvalidOriginalValue() { - $type = new Opus_Enrichment_RegexType(); + $type = new RegexType(); $type->setOptions(['regex' => '^abc$', 'validation' => 'strict']); $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); @@ -763,7 +769,7 @@ public function testValidationWithRegexTypeAndStrictValidationWithInvalidOrigina public function testValidationWithRegexTypeAndStrictValidationWithInvalidChangedValue() { - $type = new Opus_Enrichment_RegexType(); + $type = new RegexType(); $type->setOptions(['regex' => '^abc$', 'validation' => 'strict']); $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); @@ -793,7 +799,7 @@ public function testValidationWithRegexTypeAndStrictValidationWithInvalidChanged public function testValidationWithRegexTypeAndStrictValidationWithValidValue() { - $type = new Opus_Enrichment_RegexType(); + $type = new RegexType(); $type->setOptions(['regex' => '^abc$', 'validation' => 'strict']); $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); @@ -821,7 +827,7 @@ public function testValidationWithRegexTypeAndStrictValidationWithValidValue() public function testValidationWithRegexTypeAndNoValidationWithInvalidOriginalValue() { - $type = new Opus_Enrichment_RegexType(); + $type = new RegexType(); $type->setOptions(['regex' => '^abc$', 'validation' => 'none']); $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); @@ -849,7 +855,7 @@ public function testValidationWithRegexTypeAndNoValidationWithInvalidOriginalVal public function testValidationWithRegexTypeAndNoValidationWithInvalidChangedValue() { - $type = new Opus_Enrichment_RegexType(); + $type = new RegexType(); $type->setOptions(['regex' => '^abc$', 'validation' => 'none']); $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); @@ -879,7 +885,7 @@ public function testValidationWithRegexTypeAndNoValidationWithInvalidChangedValu public function testValidationWithRegexTypeAndNoValidationWithValidValue() { - $type = new Opus_Enrichment_RegexType(); + $type = new RegexType(); $type->setOptions(['regex' => '^abc$', 'validation' => 'none']); $enrichmentKey = $this->createEnrichmentKeyAndForm('regex', $type); @@ -907,7 +913,7 @@ public function testValidationWithRegexTypeAndNoValidationWithValidValue() private function createTestEnrichmentKey($name, $type = null, $options = null) { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName($name); if (! is_null($type)) { @@ -931,7 +937,7 @@ private function createEnrichmentKeyAndForm($name, $type) // Methodenaufruf hier erforderlich, damit der interne Cache, in dem // alle EnrichmentKeys gehalten werden, neu aufgesetzt wird - Opus_EnrichmentKey::getAll(); + EnrichmentKey::getAll(); return $enrichmentKey; } @@ -954,13 +960,13 @@ public function testPrepareRenderingAsView() private function createTestDocWithEnrichmentOfGivenKey($keyName, $enrichmentValue = 'testvalue') { $doc = $this->createTestDocument(); - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName($keyName); $enrichment->setValue($enrichmentValue); $doc->addEnrichment($enrichment); $docId = $doc->store(); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $enrichment = $doc->getEnrichment()[0]; return $enrichment->getId(); } diff --git a/tests/modules/admin/forms/Document/FileTest.php b/tests/modules/admin/forms/Document/FileTest.php index fdb24795e3..92ca88fc1d 100644 --- a/tests/modules/admin/forms/Document/FileTest.php +++ b/tests/modules/admin/forms/Document/FileTest.php @@ -31,6 +31,9 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\File; + class Admin_Form_Document_FileTest extends ControllerTestCase { @@ -50,7 +53,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_File(); - $file = new Opus_File(); + $file = new File(); $this->assertNull($form->getModel()); diff --git a/tests/modules/admin/forms/Document/FilesTest.php b/tests/modules/admin/forms/Document/FilesTest.php index b1b3bf2a47..dc4d580ee9 100644 --- a/tests/modules/admin/forms/Document/FilesTest.php +++ b/tests/modules/admin/forms/Document/FilesTest.php @@ -1,5 +1,4 @@ assertEquals(1, count($form->getSubForms())); @@ -83,7 +85,7 @@ public function testColumnLabelTranslations() $header = $property->getValue($form); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); foreach ($header as $column) { if (isset($column['label']) && ! is_null($column['label'])) { diff --git a/tests/modules/admin/forms/Document/GeneralTest.php b/tests/modules/admin/forms/Document/GeneralTest.php index 149ff9cbaa..196a08314d 100644 --- a/tests/modules/admin/forms/Document/GeneralTest.php +++ b/tests/modules/admin/forms/Document/GeneralTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Unit Tests fuer Admin_Form_Document_General. */ @@ -54,13 +56,13 @@ public function testCreateForm() } /** - * TODO use temporary Opus_Document instead of doc from test data + * TODO use temporary Document instead of doc from test data */ public function testPopulateFromModel() { $this->useEnglish(); - $document = new Opus_Document(146); + $document = Document::get(146); $form = new Admin_Form_Document_General(); diff --git a/tests/modules/admin/forms/Document/IdentifierTest.php b/tests/modules/admin/forms/Document/IdentifierTest.php index 7f2fbe91fc..7947539626 100644 --- a/tests/modules/admin/forms/Document/IdentifierTest.php +++ b/tests/modules/admin/forms/Document/IdentifierTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Identifier; + /** * Unit Test fuer Identifier Formular Klasse. */ @@ -52,7 +55,7 @@ public function testCreateForm() } /** - * Testet das Setzen der Elemente entsprechend Opus_Identifier. + * Testet das Setzen der Elemente entsprechend Identifier. * * Dokument 146 wird verwendet, da es vollständig besetzt ist und normalerweise in den Unit Tests nicht modifiziert * wird. @@ -61,7 +64,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Identifier(); - $document = new Opus_Document(146); + $document = Document::get(146); $identifiers = $document->getIdentifier(); $identifier = $identifiers[0]; @@ -79,7 +82,7 @@ public function testUpdateModel() $form->getElement('Type')->setValue('url'); $form->getElement('Value')->setValue('test-urn-1'); - $identifier = new Opus_Identifier(); + $identifier = new Identifier(); $form->updateModel($identifier); @@ -112,7 +115,7 @@ public function testGetModelExistingIdentifier() { $form = new Admin_Form_Document_Identifier(); - $document = new Opus_Document(146); + $document = Document::get(146); $identifiers = $document->getIdentifier(); $identifierId = $identifiers[0]->getId(); diff --git a/tests/modules/admin/forms/Document/InstituteTest.php b/tests/modules/admin/forms/Document/InstituteTest.php index b3aff3edb4..dae9d25de4 100644 --- a/tests/modules/admin/forms/Document/InstituteTest.php +++ b/tests/modules/admin/forms/Document/InstituteTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Model\Dependent\Link\DocumentDnbInstitute; + /** * Unit Tests fuer Unterformular fuer Verknuepfung mit einem Institut im Metadaten-Formular. */ @@ -61,7 +64,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Institute(Admin_Form_Document_Institute::ROLE_PUBLISHER); - $doc = new Opus_Document(146); + $doc = Document::get(146); $publishers = $doc->getThesisPublisher(); $publisher = $publishers[0]; @@ -77,7 +80,7 @@ public function testUpdateModel() $form->getElement('Institute')->setValue(3); - $model = new Opus_Model_Dependent_Link_DocumentDnbInstitute(); + $model = new DocumentDnbInstitute(); $form->updateModel($model); @@ -88,7 +91,7 @@ public function testGetModel() { $form = new Admin_Form_Document_Institute(Admin_Form_Document_Institute::ROLE_PUBLISHER); - $doc = new Opus_Document(146); + $doc = Document::get(146); $publishers = $doc->getThesisPublisher(); $publisher = $publishers[0]; $publisherId = $publisher->getModel()->getId(); diff --git a/tests/modules/admin/forms/Document/LicencesTest.php b/tests/modules/admin/forms/Document/LicencesTest.php index aec480d078..e9c06a7e67 100644 --- a/tests/modules/admin/forms/Document/LicencesTest.php +++ b/tests/modules/admin/forms/Document/LicencesTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Licence; + /** * Description of Document_LicencesTest */ @@ -42,7 +45,7 @@ public function testCreateForm() { $form = new Admin_Form_Document_Licences(); - $licences = Opus_Licence::getAll(); + $licences = Licence::getAll(); foreach ($licences as $licence) { $element = $form->getElement('licence' . $licence->getId()); @@ -61,11 +64,11 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Licences(); - $document = new Opus_Document(146); + $document = Document::get(146); $form->populateFromModel($document); - $licences = Opus_Licence::getAll(); + $licences = Licence::getAll(); foreach ($licences as $licence) { $element = $form->getElement('licence' . $licence->getId()); @@ -124,8 +127,8 @@ public function testHasLicenceFalse() { $form = new Admin_Form_Document_Licences(); - $document = new Opus_Document(146); - $licence = new Opus_Licence(2); + $document = Document::get(146); + $licence = new Licence(2); $this->assertFalse($form->hasLicence($document, $licence)); } @@ -134,7 +137,7 @@ public function testHasLicenceTrue() { $form = new Admin_Form_Document_Licences(); - $document = new Opus_Document(146); + $document = Document::get(146); $this->assertTrue($form->hasLicence($document, 4)); } diff --git a/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php b/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php index 9de45dd833..811be82257 100644 --- a/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php +++ b/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php @@ -31,6 +31,11 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Enrichment; +use Opus\EnrichmentKey; +use Opus\Model\ModelException; + /** * Unit Tests für Admin_Form_Document_MultiEnrichmentSubForm Formular das * mehrere Unterformulare vom Typ Admin_Form_Document_Enrichment verwalten kann. @@ -49,7 +54,7 @@ public function testGetFieldValues() $form = new Admin_Form_Document_MultiEnrichmentSubForm('Admin_Form_Document_Enrichment', 'Enrichment'); // create a test document with four enrichments - $doc = new Opus_Document(); + $doc = Document::new(); $enrichments = []; $enrichments[] = $this->createEnrichment('Audience', 'val1'); @@ -86,7 +91,7 @@ public function testPopulateFromModel() ); // create a test document with two enrichments - $doc = new Opus_Document(); + $doc = Document::new(); $enrichments = []; $enrichments[] = $this->createEnrichment('Audience', 'val1'); @@ -277,15 +282,15 @@ public function testProcessPostRemove() * Hilfsfunktion zum Erzeugen eines neuen Enrichments für den übergebenen * Enrichment-Key. * - * @param $keyName Name des Enrichment-Keys - * @param $value Wert des Enrichments + * @param string $keyName Name des Enrichment-Keys + * @param string $value Wert des Enrichments * - * @return Opus_Enrichment neu erzeugtes Enrichment-Objekt - * @throws Opus_Model_Exception + * @return Enrichment neu erzeugtes Enrichment-Objekt + * @throws ModelException */ private function createEnrichment($keyName, $value) { - $enrichment = new Opus_Enrichment(); + $enrichment = new Enrichment(); $enrichment->setKeyName($keyName); $enrichment->setValue($value); return $enrichment; @@ -298,12 +303,12 @@ private function createEnrichment($keyName, $value) * @param null $type optionaler Typ des Enrichment-Keys * @param null $options optionale Konfigurationsoptionen des Typs * - * @return Opus_EnrichmentKey neu erzeugter Enrichment-Key - * @throws Opus_Model_Exception + * @return EnrichmentKey neu erzeugter Enrichment-Key + * @throws ModelException */ private function createEnrichmentKey($type = null, $options = null) { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName(self::$firstEnrichmentKeyName); if (! is_null($type)) { @@ -316,7 +321,7 @@ private function createEnrichmentKey($type = null, $options = null) $enrichmentKey->store(); - $enrichmentKey = Opus_EnrichmentKey::fetchByName(self::$firstEnrichmentKeyName); + $enrichmentKey = EnrichmentKey::fetchByName(self::$firstEnrichmentKeyName); $this->assertNotNull($enrichmentKey); return $enrichmentKey; @@ -350,7 +355,7 @@ private function createTestPostDataAndConstructForm($keyName, $value, $clickedBu ], ]; - Opus_EnrichmentKey::getAll(); + EnrichmentKey::getAll(); // trifft nur zu, wenn der Add-Button gedrückt oder ein Enrichment-Key im Select-Feld ausgewählt wurde if (! is_null($clickedButton)) { diff --git a/tests/modules/admin/forms/Document/MultiSubFormTest.php b/tests/modules/admin/forms/Document/MultiSubFormTest.php index 4115438b8c..18433be7b6 100644 --- a/tests/modules/admin/forms/Document/MultiSubFormTest.php +++ b/tests/modules/admin/forms/Document/MultiSubFormTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Title; + /** * Unit Tests für MulitSubForm Formular das mehrere Unterformular des gleichen Typs verwalten kann. */ @@ -86,7 +89,7 @@ public function testPopulateFromModel() new Application_Form_Validate_MultiSubForm_RepeatedLanguages() ); - $document = new Opus_Document(146); + $document = Document::get(146); $form->populateFromModel($document); @@ -126,12 +129,12 @@ public function testGetFieldValues() new Application_Form_Validate_MultiSubForm_RepeatedLanguages() ); - $document = new Opus_Document(146); + $document = Document::get(146); $values = $form->getFieldValues($document); $this->assertEquals(2, count($values)); - $this->assertTrue($values[0] instanceof Opus_Title); + $this->assertTrue($values[0] instanceof Title); $this->assertEquals('sub', $values[0]->getType()); } @@ -206,7 +209,7 @@ public function testProcessPostRemove() new Application_Form_Validate_MultiSubForm_RepeatedLanguages() ); - $document = new Opus_Document(146); + $document = Document::get(146); $form->populateFromModel($document); @@ -268,7 +271,7 @@ public function testGetSubFormModels() new Application_Form_Validate_MultiSubForm_RepeatedLanguages() ); - $document = new Opus_Document(146); + $document = Document::get(146); $form->populateFromModel($document); $form->appendSubForm(); @@ -330,7 +333,7 @@ public function testDetermineSubFormForAnchor() new Application_Form_Validate_MultiSubForm_RepeatedLanguages() ); - $document = new Opus_Document(146); + $document = Document::get(146); $this->assertEquals($form, $form->determineSubFormForAnchor(0)); @@ -456,8 +459,8 @@ public function testPrepareSubFormDecoratorsForTableRendering() 'columns' => $columns ]); - $subform = new Zend_Form_SubForm(); - $subform->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', Zend_Form::DECORATOR); + $subform = new \Zend_Form_SubForm(); + $subform->addPrefixPath('Application_Form_Decorator', 'Application/Form/Decorator', \Zend_Form::DECORATOR); $subform->setDecorators([]); $subform->addElement('text', 'test', ['decorators' => [ @@ -491,7 +494,7 @@ public function testAddRemoveButtonForTableRendering() $method = new ReflectionMethod('Admin_Form_Document_MultiSubForm', 'addRemoveButton'); $method->setAccessible(true); - $subform = new Zend_Form_SubForm(); + $subform = new \Zend_Form_SubForm(); $subform->addElement('hidden', 'Id'); $method->invoke($form, $subform); @@ -525,17 +528,17 @@ public function testOddEven() $document = $this->createTestDocument(); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('Titel1'); $title->setLanguage('deu'); $document->addTitleParent($title); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('Titel2'); $title->setLanguage('eng'); $document->addTitleParent($title); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('Titel3'); $title->setLanguage('rus'); $document->addTitleParent($title); @@ -563,17 +566,17 @@ public function testOddEvenAfterRemove() $document = $this->createTestDocument(); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('Titel1'); $title->setLanguage('deu'); $document->addTitleParent($title); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('Titel2'); $title->setLanguage('eng'); $document->addTitleParent($title); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('Titel3'); $title->setLanguage('rus'); $document->addTitleParent($title); @@ -656,7 +659,7 @@ public function testSubformsAppearInOrderOfObjects() { $form = new Admin_Form_Document_MultiSubForm('Admin_Form_Document_Identifier', 'Identifier'); - $doc = new Opus_Document(146); + $doc = Document::get(146); $identifiers = $doc->getIdentifier(); diff --git a/tests/modules/admin/forms/Document/NoteTest.php b/tests/modules/admin/forms/Document/NoteTest.php index 1931218a7c..d3d0843630 100644 --- a/tests/modules/admin/forms/Document/NoteTest.php +++ b/tests/modules/admin/forms/Document/NoteTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Note; + /** * Description of Document_NoteTest */ @@ -53,7 +56,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Note(); - $note = new Opus_Note(); + $note = new Note(); $note->setMessage('Message1'); $note->setVisibility('public'); @@ -76,7 +79,7 @@ public function testUpdateModel() $form->getElement('Message')->setValue('Test Message'); $form->getElement('Visibility')->setChecked(true); - $note = new Opus_Note(); + $note = new Note(); $form->updateModel($note); @@ -94,7 +97,7 @@ public function testGetModel() { $form = new Admin_Form_Document_Note(); - $doc = new Opus_Document(146); + $doc = Document::get(146); $notes = $doc->getNote(); @@ -143,7 +146,7 @@ public function testPrepareRenderingAsView() { $form = new Admin_Form_Document_Note(); - $note = new Opus_Note(); + $note = new Note(); $note->setMessage('Message1'); $note->setVisibility('public'); diff --git a/tests/modules/admin/forms/Document/PatentTest.php b/tests/modules/admin/forms/Document/PatentTest.php index 2e6784ef3e..de6beef809 100644 --- a/tests/modules/admin/forms/Document/PatentTest.php +++ b/tests/modules/admin/forms/Document/PatentTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Patent; + /** * Unit Tests fuer Admin_Form_Document_Patent. */ @@ -59,7 +62,7 @@ public function testPopulateFromModel() $form = new Admin_Form_Document_Patent(); - $document = new Opus_Document(146); + $document = Document::get(146); $patents = $document->getPatent(); $patent = $patents[0]; $patentId = $patent->getId(); @@ -88,7 +91,7 @@ public function testUpdateModel() $form->getElement('Application')->setValue('Patent Title'); $form->getElement('DateGranted')->setValue('2008/03/20'); - $patent = new Opus_Patent(); + $patent = new Patent(); $form->updateModel($patent); @@ -129,7 +132,7 @@ public function testGetModel() { $this->useEnglish(); - $document = new Opus_Document(146); + $document = Document::get(146); $patents = $document->getPatent(); $patentId = $patents[0]->getId(); @@ -243,7 +246,7 @@ public function testRegressionOpusvier2824() $form->getElement('Countries')->setValue('Germany'); $form->getElement('Application')->setValue('description'); - $patent = new Opus_Patent(); + $patent = new Patent(); $form->updateModel($patent); @@ -254,7 +257,7 @@ public function testRegressionOpusvier2824() $documentId = $document->getId(); - $document = new Opus_Document($documentId); + $document = Document::get($documentId); $patents = $document->getPatent(); $patent = $patents[0]; diff --git a/tests/modules/admin/forms/Document/PersonMovesTest.php b/tests/modules/admin/forms/Document/PersonMovesTest.php index 65cd1cf63e..f8fcaa90c3 100644 --- a/tests/modules/admin/forms/Document/PersonMovesTest.php +++ b/tests/modules/admin/forms/Document/PersonMovesTest.php @@ -37,7 +37,7 @@ public function testConstructForm() { $form = new Admin_Form_Document_PersonMoves(); - $this->assertEquals(4, count($form->getElements())); + $this->assertCount(4, $form->getElements()); $this->assertNotNull($form->getElement('First')); $this->assertNotNull($form->getElement('Up')); @@ -49,7 +49,7 @@ public function testConstructFormPositionFirst() { $form = new Admin_Form_Document_PersonMoves(Admin_Form_Document_PersonMoves::POSITION_FIRST); - $this->assertEquals(2, count($form->getElements())); + $this->assertCount(2, $form->getElements()); $this->assertNotNull($form->getElement('Down')); $this->assertNotNull($form->getElement('Last')); @@ -59,7 +59,7 @@ public function testConstructFormPositionLast() { $form = new Admin_Form_Document_PersonMoves(Admin_Form_Document_PersonMoves::POSITION_LAST); - $this->assertEquals(2, count($form->getElements())); + $this->assertCount(2, $form->getElements()); $this->assertNotNull($form->getElement('First')); $this->assertNotNull($form->getElement('Up')); @@ -86,23 +86,23 @@ public function testChangePosition() { $form = new Admin_Form_Document_PersonMoves(); - $this->assertEquals(4, count($form->getElements())); + $this->assertCount(4, $form->getElements()); $form->changePosition(Admin_Form_Document_PersonMoves::POSITION_FIRST); - $this->assertEquals(2, count($form->getElements())); + $this->assertCount(2, $form->getElements()); $this->assertNotNull($form->getElement('Down')); $this->assertNotNull($form->getElement('Last')); $form->changePosition(Admin_Form_Document_PersonMoves::POSITION_LAST); - $this->assertEquals(2, count($form->getElements())); + $this->assertCount(2, $form->getElements()); $this->assertNotNull($form->getElement('First')); $this->assertNotNull($form->getElement('Up')); $form->changePosition(Admin_Form_Document_PersonMoves::POSITION_DEFAULT); - $this->assertEquals(4, count($form->getElements())); + $this->assertCount(4, $form->getElements()); } public function testProcessPostEmpty() diff --git a/tests/modules/admin/forms/Document/PersonRoleTest.php b/tests/modules/admin/forms/Document/PersonRoleTest.php index d1625bee0c..389f40aa23 100644 --- a/tests/modules/admin/forms/Document/PersonRoleTest.php +++ b/tests/modules/admin/forms/Document/PersonRoleTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License **/ +use Opus\Document; + /** * Unit Tests fuer Unterformular fuer Personen in einer Rolle im Metadaten-Formular. */ @@ -42,8 +44,8 @@ public function testCreateForm() { $form = new Admin_Form_Document_PersonRole('author'); - $this->assertEquals(1, count($form->getElements())); - $this->assertEquals(0, count($form->getSubForms())); + $this->assertCount(1, $form->getElements()); + $this->assertCount(0, $form->getSubForms()); $this->assertEquals('author', $form->getRoleName()); $this->assertNotNull($form->getElement('Add')); } @@ -52,13 +54,13 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_PersonRole('author'); - $document = new Opus_Document(21); // hat zwei Authoren + $document = Document::get(21); // hat zwei Authoren - $this->assertEquals(0, count($form->getSubForms())); + $this->assertCount(0, $form->getSubForms()); $form->populateFromModel($document); - $this->assertEquals(2, count($form->getSubForms())); + $this->assertCount(2, $form->getSubForms()); } public function testProcessPostAdd() @@ -92,15 +94,15 @@ public function testProcessPostRemove() ] ]; - $document = new Opus_Document(21); // hat zwei Authoren + $document = Document::get(21); // hat zwei Authoren $form->populateFromModel($document); - $this->assertEquals(2, count($form->getSubForms()), 'Ungenügend Unterformulare.'); + $this->assertCount(2, $form->getSubForms(), 'Ungenügend Unterformulare.'); $form->processPost($post, null); - $this->assertEquals(1, count($form->getSubForms()), 'Unterformular wurde nicht entfernt.'); + $this->assertCount(1, $form->getSubForms(), 'Unterformular wurde nicht entfernt.'); // TODO prüfe Namen von Unterformularen } @@ -115,11 +117,11 @@ public function testProcessPostEdit() ] ]; - $document = new Opus_Document(21); // hat zwei Authoren + $document = Document::get(21); // hat zwei Authoren $form->populateFromModel($document); - $this->assertEquals(2, count($form->getSubForms())); + $this->assertCount(2, $form->getSubForms()); $result = $form->processPost($post, null); @@ -517,11 +519,11 @@ public function testGetSubFormModels() { $form = $this->getFormForSorting(); - $doc = new Opus_Document(250); + $doc = Document::get(250); $authors = $form->getSubFormModels($doc); - $this->assertEquals(3, count($authors)); + $this->assertCount(3, $authors); $this->assertEquals(310, $authors[0]->getModel()->getId()); $this->assertEquals(311, $authors[1]->getModel()->getId()); @@ -532,13 +534,13 @@ public function testUpdateModel() { $form = $this->getFormForSorting(); - $doc = new Opus_Document(250); + $doc = Document::get(250); $form->updateModel($doc); $authors = $doc->getPersonAuthor(); - $this->assertEquals(3, count($authors)); + $this->assertCount(3, $authors); $this->assertEquals(310, $authors[0]->getModel()->getId()); $this->assertEquals(311, $authors[1]->getModel()->getId()); @@ -553,7 +555,7 @@ public function testAddPersonLastPosition() $form->addPerson(['person' => '311']); $form->addPerson(['person' => '312']); - $this->assertEquals(3, count($form->getSubForms())); + $this->assertCount(3, $form->getSubForms()); $this->verifyExpectedOrder($form, [310, 311, 312]); } @@ -628,7 +630,7 @@ public function testAttemptToAddPersonTwiceInSameRole() $form->addPerson(['person' => '310']); $form->addPerson(['person' => '310']); - $this->assertEquals(1, count($form->getSubForms())); + $this->assertCount(1, $form->getSubForms()); $this->assertEquals(310, $form->getSubForm('PersonAuthor0')->getElementValue('PersonId')); } @@ -643,11 +645,11 @@ public function testAddPersonWithoutId() $form->addPerson([]); - $this->assertEquals(0, count($form->getSubForms())); + $this->assertCount(0, $form->getSubForms()); $messages = $logger->getMessages(); - $this->assertEquals(1, count($messages)); + $this->assertCount(1, $messages); $this->assertContains('Attempt to add person without ID.', $messages[0]); } @@ -688,7 +690,7 @@ protected function getFormForSorting() { $form = new Admin_Form_Document_PersonRole('author'); - $document = new Opus_Document(250); + $document = Document::get(250); $authors = $document->getPersonAuthor(); $authorId0 = $authors[0]->getModel()->getId(); // 310 diff --git a/tests/modules/admin/forms/Document/PersonTest.php b/tests/modules/admin/forms/Document/PersonTest.php index 36b46bc5ca..7aaaa4789a 100644 --- a/tests/modules/admin/forms/Document/PersonTest.php +++ b/tests/modules/admin/forms/Document/PersonTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License **/ +use Opus\Document; + /** * Unit Tests fuer Unterformular fuer eine mit einem Dokument verknuepfte Person. */ @@ -97,7 +99,7 @@ public function testGetLinkModel() { $form = new Admin_Form_Document_Person(); - $document = new Opus_Document(146); + $document = Document::get(146); $authors = $document->getPersonAuthor(); diff --git a/tests/modules/admin/forms/Document/PersonsTest.php b/tests/modules/admin/forms/Document/PersonsTest.php index dafd397a63..a38b5414f6 100644 --- a/tests/modules/admin/forms/Document/PersonsTest.php +++ b/tests/modules/admin/forms/Document/PersonsTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License **/ +use Opus\Document; + /** * Unit Tests fuer Unterformular fuer Personen im Metadaten-Formular. */ @@ -51,7 +53,7 @@ public function testCreateForm() { $form = new Admin_Form_Document_Persons(); - $this->assertEquals(8, count($form->getSubForms())); + $this->assertCount(8, $form->getSubForms()); foreach ($this->roles as $role) { $this->assertNotNull($form->getSubForm($role), "Unterformular '$role' fehlt."); @@ -66,17 +68,17 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Persons(); - $document = new Opus_Document(146); // 1 Person in jeder Rolle + $document = Document::get(146); // 1 Person in jeder Rolle $form->populateFromModel($document); foreach ($this->roles as $role) { $subform = $form->getSubForm($role); $this->assertNotNull($subform, "Unterformular '$role' fehlt."); - $this->assertEquals( + $this->assertCount( 1, - count($subform->getSubForms()), - "Unterformular '$role' sollte ein Unterformlar haben." + $subform->getSubForms(), + "Unterformular '$role' sollte ein Unterformular haben." ); } } @@ -254,7 +256,7 @@ public function testProcessPostChangeRole() { $form = new Admin_Form_Document_Persons(); - $document = new Opus_Document(250); + $document = Document::get(250); $form->populateFromModel($document); @@ -292,7 +294,7 @@ public function testProcessPostSort() { $form = new Admin_Form_Document_Persons(); - $document = new Opus_Document(146); + $document = Document::get(146); $form->populateFromModel($document); @@ -328,7 +330,7 @@ public function testProcessPostEmptyWithPersons() { $form = new Admin_Form_Document_Persons(); - $document = new Opus_Document(146); + $document = Document::get(146); $form->populateFromModel($document); @@ -339,7 +341,7 @@ public function testProcessPostResultNull() { $form = new Admin_Form_Document_Persons(); - $document = new Opus_Document(146); + $document = Document::get(146); $form->populateFromModel($document); diff --git a/tests/modules/admin/forms/Document/SeriesTest.php b/tests/modules/admin/forms/Document/SeriesTest.php index 6738a808e6..6eb046384f 100644 --- a/tests/modules/admin/forms/Document/SeriesTest.php +++ b/tests/modules/admin/forms/Document/SeriesTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Model\Dependent\Link\DocumentSeries; + /** * Unit Tests fuer Unterformular fuer Verknuepfung mit Schriftenreihe in Metadaten-Formular. */ @@ -42,7 +45,7 @@ public function testCreateForm() { $form = new Admin_Form_Document_Series(); - $this->assertEquals(4, count($form->getElements())); + $this->assertCount(4, $form->getElements()); $this->assertNotNull($form->getElement('Id')); $this->assertNotNull($form->getElement('SeriesId')); $this->assertNotNull($form->getElement('Number')); @@ -53,7 +56,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Series(); - $doc = new Opus_Document(146); + $doc = Document::get(146); $series = $doc->getSeries(); $model = $series[0]; @@ -74,7 +77,7 @@ public function testUpdateModel() $form->getElement('Number')->setValue('III'); $form->getElement('SortOrder')->setValue(2); - $model = new Opus_Model_Dependent_Link_DocumentSeries(); + $model = new DocumentSeries(); $form->updateModel($model); @@ -87,7 +90,7 @@ public function testGetModel() { $form = new Admin_Form_Document_Series(); - $doc = new Opus_Document(146); + $doc = Document::get(146); $series = $doc->getSeries(); $form->getElement('Id')->setValue($doc->getId()); diff --git a/tests/modules/admin/forms/Document/SubjectTest.php b/tests/modules/admin/forms/Document/SubjectTest.php index 8cb2caa5eb..033cdb198c 100644 --- a/tests/modules/admin/forms/Document/SubjectTest.php +++ b/tests/modules/admin/forms/Document/SubjectTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Subject; + /** * Unit Tests fuer Unterformular fuer ein Subject im Metadaten-Formular. */ @@ -42,7 +45,7 @@ public function testCreateForm() { $form = new Admin_Form_Document_Subject('psyndex'); - $this->assertEquals(4, count($form->getElements())); + $this->assertCount(4, $form->getElements()); $this->assertNotNull($form->getElement('Id')); $this->assertNotNull($form->getElement('Value')); @@ -57,7 +60,7 @@ public function testCreateFormWithLanguage() { $form = new Admin_Form_Document_Subject('swd', 'deu'); - $this->assertEquals(4, count($form->getElements())); + $this->assertCount(4, $form->getElements()); $this->assertNotNull($form->getElement('Id')); $this->assertNotNull($form->getElement('Value')); @@ -76,7 +79,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Subject('swd', 'deu'); - $document = new Opus_Document(146); + $document = Document::get(146); $subjects = $document->getSubject(); $subjectSwd = $subjects[0]; @@ -98,7 +101,7 @@ public function testUpdateModel() $form->getElement('Value')->setValue('Test Schlagwort'); $form->getElement('ExternalKey')->setValue('Test Schluessel'); - $subject = new Opus_Subject(); + $subject = new Subject(); $form->updateModel($subject); @@ -112,7 +115,7 @@ public function testGetModel() { $form = new Admin_Form_Document_Subject('uncontrolled'); - $document = new Opus_Document(146); + $document = Document::get(146); $subjects = $document->getSubject(); $subject = $subjects[1]; @@ -170,7 +173,7 @@ public function testGetModelUnknownId() $messages = $logger->getMessages(); - $this->assertEquals(1, count($messages)); + $this->assertCount(1, $messages); $this->assertContains('Unknown subject ID = \'7777\'.', $messages[0]); } diff --git a/tests/modules/admin/forms/Document/SubjectTypeTest.php b/tests/modules/admin/forms/Document/SubjectTypeTest.php index f3787e94c0..b75250c701 100644 --- a/tests/modules/admin/forms/Document/SubjectTypeTest.php +++ b/tests/modules/admin/forms/Document/SubjectTypeTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Unit Tests für Unterformular, daß Subjects eines bestimmten Typs anzeigt. */ @@ -77,7 +79,7 @@ public function testGetFieldValues() { $form = new Admin_Form_Document_SubjectType('swd'); - $document = new Opus_Document(146); + $document = Document::get(146); $values = $form->getFieldValues($document); @@ -92,7 +94,7 @@ public function testUpdateModel() { $form = new Admin_Form_Document_SubjectType('swd'); // Formular ohne Schlagwörter - $document = new Opus_Document(200); + $document = Document::get(200); $this->assertEquals(2, count($document->getSubject())); diff --git a/tests/modules/admin/forms/Document/SubjectsTest.php b/tests/modules/admin/forms/Document/SubjectsTest.php index 3bbfb163af..77d2f3c2cc 100644 --- a/tests/modules/admin/forms/Document/SubjectsTest.php +++ b/tests/modules/admin/forms/Document/SubjectsTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + class Admin_Form_Document_SubjectsTest extends ControllerTestCase { @@ -39,12 +41,12 @@ public function testConstructForm() { $form = new Admin_Form_Document_Subjects(); - $this->assertEquals(3, count($form->getSubForms())); + $this->assertCount(3, $form->getSubForms()); $this->assertNotNull($form->getSubForm('Swd')); $this->assertNotNull($form->getSubForm('Psyndex')); $this->assertNotNull($form->getSubForm('Uncontrolled')); - $this->assertEquals(1, count($form->getDecorators())); + $this->assertCount(1, $form->getDecorators()); $this->assertNotNull($form->getDecorator('FormElements')); } @@ -54,13 +56,13 @@ public function testUpdateModel() $document = $this->createTestDocument(); - $form->populateFromModel(new Opus_Document(146)); // zwei Schlagwörter + $form->populateFromModel(Document::get(146)); // zwei Schlagwörter $form->updateModel($document); $subjects = $document->getSubject(); - $this->assertEquals(2, count($subjects)); + $this->assertCount(2, $subjects); // Reihenfolge sollte gleich bleiben, solange IDs in Testdaten nicht geändert werden $this->assertEquals('swd', $subjects[0]->getType()); diff --git a/tests/modules/admin/forms/Document/TitleTest.php b/tests/modules/admin/forms/Document/TitleTest.php index 21d742f3d1..12163d0ae0 100644 --- a/tests/modules/admin/forms/Document/TitleTest.php +++ b/tests/modules/admin/forms/Document/TitleTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Title; + /** * Unit Test fuer Unterformular fuer einen Titel. */ @@ -52,7 +55,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document_Title(); - $doc = new Opus_Document(146); + $doc = Document::get(146); $titles = $doc->getTitleMain(); @@ -74,7 +77,7 @@ public function testUpdateModel() $form->getElement('Language')->setValue('rus'); $form->getElement('Value')->setValue('Test Title'); - $title = new Opus_Title(); + $title = new Title(); $form->updateModel($title); @@ -87,7 +90,7 @@ public function testGetModel() { $form = new Admin_Form_Document_Title(); - $doc = new Opus_Document(146); + $doc = Document::get(146); $titles = $doc->getTitleMain(); diff --git a/tests/modules/admin/forms/Document/TitlesMainTest.php b/tests/modules/admin/forms/Document/TitlesMainTest.php index 462b6d5f71..76025cb3c9 100644 --- a/tests/modules/admin/forms/Document/TitlesMainTest.php +++ b/tests/modules/admin/forms/Document/TitlesMainTest.php @@ -28,9 +28,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Title; + /** * Unit Tests fuer das Unterformular fuer die Haupttitel eines Dokuments. */ @@ -95,11 +96,11 @@ protected function getTestDocument() $document->setLanguage('deu'); - $title1 = new Opus_Title(); + $title1 = new Title(); $title1->setLanguage('deu'); $title1->setValue('Deutscher Titel'); - $title2 = new Opus_Title(); + $title2 = new Title(); $title2->setLanguage('eng'); $title2->setValue('English Title'); diff --git a/tests/modules/admin/forms/DocumentTest.php b/tests/modules/admin/forms/DocumentTest.php index 790b212731..e4bc6cf5d0 100644 --- a/tests/modules/admin/forms/DocumentTest.php +++ b/tests/modules/admin/forms/DocumentTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Title; + /** * Unit Tests für Metadaten-Formular Klasse. */ @@ -72,7 +75,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Document(); - $document = new Opus_Document(146); + $document = Document::get(146); $form->populateFromModel($document); @@ -86,7 +89,7 @@ public function testPopulateFromModel() public function testGetInstanceFromPost() { - $document = new Opus_Document(146); + $document = Document::get(146); $post = []; @@ -150,7 +153,7 @@ public function testIsValidTrue() $form = new Admin_Form_Document(); $document = $this->createTestDocument(); - $document->addTitleMain(new Opus_Title()); + $document->addTitleMain(new Title()); $form->populateFromModel($document); @@ -186,7 +189,7 @@ public function testIsValidFalse() $form = new Admin_Form_Document(); $document = $this->createTestDocument(); - $document->addTitleMain(new Opus_Title()); + $document->addTitleMain(new Title()); $form->populateFromModel($document); @@ -226,7 +229,7 @@ public function testIsValidFalseDependency() $form = new Admin_Form_Document(); $document = $this->createTestDocument(); - $document->addTitleMain(new Opus_Title()); + $document->addTitleMain(new Title()); $form->populateFromModel($document); @@ -266,8 +269,8 @@ public function testIsValidFalseDependency2() $form = new Admin_Form_Document(); $document = $this->createTestDocument(); - $document->addTitleMain(new Opus_Title()); - $document->addTitleMain(new Opus_Title()); + $document->addTitleMain(new Title()); + $document->addTitleMain(new Title()); $form->populateFromModel($document); @@ -320,7 +323,7 @@ public function testPrepareRenderingAsViewFullDocument() { $form = new Admin_Form_Document(); - $document = new Opus_Document(146); + $document = Document::get(146); $form->populateFromModel($document); $form->prepareRenderingAsView(); @@ -348,7 +351,7 @@ public function testPrepareRenderingAsViewDocumentWithoutFiles() { $form = new Admin_Form_Document(); - $document = new Opus_Document(200); + $document = Document::get(200); $form->populateFromModel($document); $form->prepareRenderingAsView(); @@ -383,7 +386,7 @@ protected function verifySubForms($form, $names) protected function getHash($form) { - $session = new Zend_Session_Namespace('testing'); + $session = new \Zend_Session_Namespace('testing'); $hashElement = $form->getSubForm('Actions')->getElement('OpusHash'); $hashElement->setSession($session); diff --git a/tests/modules/admin/forms/EnrichmentKeyTest.php b/tests/modules/admin/forms/EnrichmentKeyTest.php index af40d5bbcc..bd32c7b6ab 100644 --- a/tests/modules/admin/forms/EnrichmentKeyTest.php +++ b/tests/modules/admin/forms/EnrichmentKeyTest.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\EnrichmentKey; +use Opus\Model\ModelException; + /** * Unit Tests for Admin_Form_Enrichmentkey. * @@ -61,7 +64,7 @@ public function testConstructForm() public function testPopulateFromModel() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('Test'); $form = new Admin_Form_EnrichmentKey(); @@ -75,7 +78,7 @@ public function testPopulateFromModel() public function testPopulateFromExistingModel() { - $enrichment = new Opus_EnrichmentKey('City'); + $enrichment = new EnrichmentKey('City'); $this->assertNotNull($enrichment); $form = new Admin_Form_EnrichmentKey(); @@ -89,7 +92,7 @@ public function testPopulateFromExistingModel() public function testPopulateFromModelWithEnrichmentType() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('TestKey'); $enrichmentKey->setType('TextType'); @@ -104,7 +107,7 @@ public function testPopulateFromModelWithEnrichmentType() public function testPopulateFromModelWithUnknownEnrichmentType() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('TestKey'); $enrichmentKey->setType('FooType'); @@ -119,7 +122,7 @@ public function testPopulateFromModelWithUnknownEnrichmentType() public function testPopulateFromModelWithEnrichmentTypeAndOptionsAndStrictValidation() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('TestKey'); $enrichmentKey->setType('RegexType'); $enrichmentKey->setOptions(json_encode(['regex' => '^a$', 'validation' => 'strict'])); @@ -135,7 +138,7 @@ public function testPopulateFromModelWithEnrichmentTypeAndOptionsAndStrictValida public function testPopulateFromModelWithEnrichmentTypeAndOptionsAndNoValidation() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('TestKey'); $enrichmentKey->setType('RegexType'); $enrichmentKey->setOptions(json_encode(['regex' => '^a$', 'validation' => 'none'])); @@ -151,7 +154,7 @@ public function testPopulateFromModelWithEnrichmentTypeAndOptionsAndNoValidation public function testPopulateFromModelWithUnknownEnrichmentTypeAndOptions() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('TestKey'); $enrichmentKey->setType('FooType'); $enrichmentKey->setOptions(json_encode(['regex' => '^a$', 'validation' => 'strict'])); @@ -170,7 +173,7 @@ public function testUpdateModel() $form = new Admin_Form_EnrichmentKey(); $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_NAME)->setValue('TestEnrichmentKey'); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $form->updateModel($enrichmentKey); $this->assertEquals('TestEnrichmentKey', $enrichmentKey->getName()); @@ -184,7 +187,7 @@ public function testUpdateModelWithType() $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_NAME)->setValue('TestEnrichmentKey'); $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_TYPE)->setValue('TextType'); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $form->updateModel($enrichmentKey); $this->assertEquals('TestEnrichmentKey', $enrichmentKey->getName()); @@ -198,7 +201,7 @@ public function testUpdateModelWithUnknownType() $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_NAME)->setValue('TestEnrichmentKey'); $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_TYPE)->setValue('UnknownType'); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $form->updateModel($enrichmentKey); $this->assertEquals('TestEnrichmentKey', $enrichmentKey->getName()); @@ -214,7 +217,7 @@ public function testUpdateModelWithTypeAndOptionsAndStrictValidation() $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_OPTIONS)->setValue('^a$'); $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_VALIDATION)->setValue('1'); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $form->updateModel($enrichmentKey); $this->assertEquals('TestEnrichmentKey', $enrichmentKey->getName()); @@ -230,7 +233,7 @@ public function testUpdateModelWithTypeAndOptionsAndNoValidation() $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_OPTIONS)->setValue('^a$'); $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_VALIDATION)->setValue('0'); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $form->updateModel($enrichmentKey); $this->assertEquals('TestEnrichmentKey', $enrichmentKey->getName()); @@ -246,7 +249,7 @@ public function testUpdateModelWithUnknownTypeAndOptions() $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_OPTIONS)->setValue('^a$'); $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_VALIDATION)->setValue('1'); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $form->updateModel($enrichmentKey); $this->assertEquals('TestEnrichmentKey', $enrichmentKey->getName()); @@ -263,7 +266,7 @@ public function testValidationSuccess() $this->assertTrue($form->isValid($this->createArray('Test', 'RegexType', '^a$'))); $this->assertTrue($form->isValid( $this->createArray( - str_pad('Long', Opus_EnrichmentKey::getFieldMaxLength('Name'), 'g'), + str_pad('Long', EnrichmentKey::getFieldMaxLength('Name'), 'g'), "TextType" ) )); @@ -280,7 +283,7 @@ public function testValidationFailure() $this->assertFalse($form->isValid($this->createArray(' ', 'TextType'))); $this->assertFalse($form->isValid( $this->createArray( - str_pad('toolong', Opus_EnrichmentKey::getFieldMaxLength('Name') + 1, 'g'), + str_pad('toolong', EnrichmentKey::getFieldMaxLength('Name') + 1, 'g'), "TextType" ) )); @@ -300,12 +303,12 @@ public function testValidationFailure() public function testSetNameElementValue() { $form = new Admin_Form_EnrichmentKey(); - $form->populateFromModel(new Opus_EnrichmentKey()); + $form->populateFromModel(new EnrichmentKey()); $form->setNameElementValue('foo'); $this->assertEquals('foo', $form->getElement(Admin_Form_EnrichmentKey::ELEMENT_NAME)->getValue()); - $form->populateFromModel(new Opus_EnrichmentKey()); + $form->populateFromModel(new EnrichmentKey()); $this->assertNull($form->getElement(Admin_Form_EnrichmentKey::ELEMENT_NAME)->getValue()); } @@ -313,12 +316,11 @@ public function testSetNameElementValue() * Hat ein existierender Enrichment Key bereits einen zugeordneten Enrichment Type, * so kann dieser nicht mehr gelöscht, sondern nur auf einen anderen Typ geändert werden. * - * @throws Zend_Form_Exception - * @throws \Opus\Model\Exception + * @throws \Zend_Form_Exception */ public function testTypeIsRequiredForExistingTypedKey() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('TestKey'); $enrichmentKey->setType('BooleanType'); @@ -336,12 +338,11 @@ public function testTypeIsRequiredForExistingTypedKey() * Hat ein existierender Enrichment Key keinen zugeordneten Enrichment Type, * so muss dieser beim erneuten Speichern des Enrichment Keys auch nicht gesetzt werden. * - * @throws Zend_Form_Exception - * @throws \Opus\Model\Exception + * @throws \Zend_Form_Exception */ public function testTypeIsRequiredForExistingUntypedKey() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('TestKey'); $form = new Admin_Form_EnrichmentKey(); @@ -368,7 +369,7 @@ private function createArray($name, $type = null, $options = null) public function testPopulateDisplayName() { - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('Country'); $form = new Admin_Form_EnrichmentKey(); @@ -386,13 +387,13 @@ public function testUpdateTranslations() { $key = 'MyTestKey'; - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName($key); $enrichmentKey->store(); $this->addModelToCleanup($enrichmentKey); - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->setTranslation("Enrichment$key", [ 'en' => 'Old', 'de' => 'Alt' @@ -420,14 +421,14 @@ public function testChangeTranslationsKeysWithNameChange() { $oldKey = 'EnrichmentTestKey'; - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); $database->setTranslation($oldKey, [ 'en' => 'English', 'de' => 'Deutsch' ], 'default'); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('TestKey'); $enrichmentKey->store(); $this->addModelToCleanup($enrichmentKey); @@ -458,14 +459,14 @@ public function testEmptyTranslationRemovesKey() { $key = 'EnrichmentTestKey'; - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); $database->setTranslation($key, [ 'en' => 'English', 'de' => 'Deutsch' ], 'default'); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName('TestKey'); $enrichmentKey->store(); $this->addModelToCleanup($enrichmentKey); @@ -491,7 +492,7 @@ public function testDoNotPopulateTranslationForNewKey() { $form = new Admin_Form_EnrichmentKey(); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $form->populateFromModel($enrichmentKey); diff --git a/tests/modules/admin/forms/File/HashesTest.php b/tests/modules/admin/forms/File/HashesTest.php index 50165ad574..db5989ee52 100644 --- a/tests/modules/admin/forms/File/HashesTest.php +++ b/tests/modules/admin/forms/File/HashesTest.php @@ -1,5 +1,4 @@ populateFromModel($file); - $this->assertEquals(2, count($form->getElements())); + $this->assertCount(2, $form->getElements()); $this->assertNotNull($form->getElement('Hash0')); $this->assertNotNull($form->getElement('Hash1')); } @@ -53,10 +55,10 @@ public function testPopulateFromModelNoHashes() { $form = new Admin_Form_File_Hashes(); - $file = new Opus_File(121); // keine Hashes + $file = new File(121); // keine Hashes $form->populateFromModel($file); - $this->assertEquals(0, count($form->getElements())); + $this->assertCount(0, $form->getElements()); } } diff --git a/tests/modules/admin/forms/File/UploadTest.php b/tests/modules/admin/forms/File/UploadTest.php index ae4c0e8109..d70c17acf7 100644 --- a/tests/modules/admin/forms/File/UploadTest.php +++ b/tests/modules/admin/forms/File/UploadTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Document; + /** * @category Application Unit Test * @package Admin_Form_File @@ -52,13 +54,13 @@ public function testCreateForm() $elements = ['Id', 'File', 'Label', 'Comment', 'Language', 'Save', 'Cancel', 'OpusHash', 'SortOrder']; - $this->assertEquals(count($elements), count($form->getElements())); + $this->assertSameSize($elements, $form->getElements()); foreach ($elements as $element) { $this->assertNotNull($form->getElement($element), "Element '$element' is missing.'"); } - $this->assertEquals(1, count($form->getSubForms())); + $this->assertCount(1, $form->getSubForms()); $this->assertNotNull($form->getSubForm('Info')); $this->assertEquals('admin_filemanager_upload', $form->getLegend()); @@ -66,7 +68,7 @@ public function testCreateForm() public function testPopulateFromModel() { - $document = new Opus_Document(146); + $document = Document::get(146); $form = new Admin_Form_File_Upload(); @@ -118,7 +120,7 @@ public function testUpdateModel() $files = $document->getFile(); - $this->assertEquals(1, count($files)); + $this->assertCount(1, $files); $file = $files[0]; @@ -137,7 +139,7 @@ public function testGetFileInfo() $fileInfo = $form->getFileInfo(); $this->assertInternalType('array', $fileInfo); - $this->assertEquals(0, count($fileInfo)); + $this->assertCount(0, $fileInfo); } public function testSetGetFileInfo() diff --git a/tests/modules/admin/forms/FileManagerTest.php b/tests/modules/admin/forms/FileManagerTest.php index 68f44a0099..b6238a049c 100644 --- a/tests/modules/admin/forms/FileManagerTest.php +++ b/tests/modules/admin/forms/FileManagerTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Document; + /** * Unit Test fuer FileManager Formular. * @@ -65,7 +67,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_FileManager(); - $document = new Opus_Document(92); + $document = Document::get(92); $filesForm = $form->getSubForm(Admin_Form_FileManager::SUBFORM_FILES); @@ -91,7 +93,7 @@ public function testUpdateModel() { $form = new Admin_Form_FileManager(); - $document = new Opus_Document(92); + $document = Document::get(92); $form->populateFromModel($document); @@ -162,7 +164,7 @@ public function testConstructFromPostEmptyAndNoDocument() public function testConstructFromPost() { - $document = new Opus_Document(146); + $document = Document::get(146); $post = [ 'Files' => [ @@ -206,7 +208,7 @@ public function testSetGetMessage() public function testGetInstanceFromPost() { - $document = new Opus_Document(146); + $document = Document::get(146); $post = [ 'Files' => [ diff --git a/tests/modules/admin/forms/FileTest.php b/tests/modules/admin/forms/FileTest.php index a46e10ace7..246fb66202 100644 --- a/tests/modules/admin/forms/FileTest.php +++ b/tests/modules/admin/forms/FileTest.php @@ -1,5 +1,4 @@ useEnglish(); $form = new Admin_Form_File(); - $file = new Opus_File(126); // hängt an Testdokument 146 + $file = new File(126); // hängt an Testdokument 146 $form->populateFromModel($file); @@ -87,7 +89,7 @@ public function testPopulateFromModelFileDoesNotExist() { $form = new Admin_Form_File(); - $file = new Opus_File(123); // von Dokument 122 + $file = new File(123); // von Dokument 122 $form->populateFromModel($file); @@ -178,7 +180,7 @@ public function testGetModel() $form->getElement('Id')->setValue(126); // Datei 'test.pdf' von Dokument 146 - $file = new Opus_File(126); + $file = new File(126); $form->populateFromModel($file); @@ -186,7 +188,7 @@ public function testGetModel() $model = $form->getModel(); - $this->assertInstanceOf('Opus_File', $model); + $this->assertInstanceOf('Opus\File', $model); $this->assertEquals(126, $model->getId()); $this->assertEquals('Testkommentar', $model->getComment()); diff --git a/tests/modules/admin/forms/FilesTest.php b/tests/modules/admin/forms/FilesTest.php index 623c834d50..bdd72ceee9 100644 --- a/tests/modules/admin/forms/FilesTest.php +++ b/tests/modules/admin/forms/FilesTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Document; + /** * Unit Tests fuer Unterformular, das Dateien in FileManager auflistet. * @@ -128,7 +130,7 @@ public function testContinueEdit() { $form = new Admin_Form_Files(); - $document = new Opus_Document(91); + $document = Document::get(91); $form->populateFromModel($document); @@ -141,7 +143,7 @@ public function testContinueEditRemoveSubForm() { $form = new Admin_Form_Files(); - $document = new Opus_Document(91); + $document = Document::get(91); $form->populateFromModel($document); @@ -161,7 +163,7 @@ public function testContinueEditRemoveSubFormAndUpdate() { $form = new Admin_Form_Files(); - $document = new Opus_Document(91); + $document = Document::get(91); $form->populateFromModel($document); @@ -194,7 +196,7 @@ public function testGetSubFormForId() { $form = new Admin_Form_Files(); - $document = new Opus_Document(91); + $document = Document::get(91); $form->populateFromModel($document); @@ -212,7 +214,7 @@ public function testFilesAppearInOrder() { $form = new Admin_Form_Files(); - $document = new Opus_Document(155); + $document = Document::get(155); $form->populateFromModel($document); @@ -236,7 +238,7 @@ public function testGetFieldValues() { $form = new Admin_Form_Files(); - $document = new Opus_Document(155); + $document = Document::get(155); $files = $document->getFile(); diff --git a/tests/modules/admin/forms/InfoBoxTest.php b/tests/modules/admin/forms/InfoBoxTest.php index 6be8dee74c..583a89a410 100644 --- a/tests/modules/admin/forms/InfoBoxTest.php +++ b/tests/modules/admin/forms/InfoBoxTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Person; + class Admin_Form_InfoBoxTest extends ControllerTestCase { @@ -48,7 +51,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_InfoBox(); - $document = new Opus_Document(146); + $document = Document::get(146); $form->populateFromModel($document); @@ -84,7 +87,7 @@ public function testConstructFromPost() { $form = new Admin_Form_InfoBox(); - $document = new Opus_Document(146); + $document = Document::get(146); $form->constructFromPost([], $document); @@ -107,12 +110,12 @@ public function testConstructFromPostWithBadObject() $logger->clear(); - $form->constructFromPost([], new Opus_Person()); + $form->constructFromPost([], new Person()); $messages = $logger->getMessages(); $this->assertEquals(1, count($messages)); - $this->assertContains('Called with instance of \'Opus_Person\'', $messages[0]); + $this->assertContains('Called with instance of \'Opus\Person\'', $messages[0]); } public function testIsEmpty() diff --git a/tests/modules/admin/forms/IpRangeTest.php b/tests/modules/admin/forms/IpRangeTest.php index c9d418c26f..a043fb7d1f 100644 --- a/tests/modules/admin/forms/IpRangeTest.php +++ b/tests/modules/admin/forms/IpRangeTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Iprange; +use Opus\UserRole; + /** * Basic unit tests for IP range form. */ @@ -44,7 +47,7 @@ public function setUp() { parent::setUp(); - $model = new Opus_Iprange(); + $model = new Iprange(); $model->setName('localhost'); $model->setStartingip('127.0.0.1'); $model->setEndingip('127.0.0.2'); @@ -54,7 +57,7 @@ public function setUp() public function tearDown() { if (! is_null($this->_modelId)) { - $range = new Opus_Iprange($this->_modelId); + $range = new Iprange($this->_modelId); $range->delete(); } @@ -81,13 +84,13 @@ public function testPopulateFromModel() { $form = new Admin_Form_IpRange(); - $range = new Opus_Iprange(); + $range = new Iprange(); $range->setName('localhost'); $range->setStartingip('127.0.0.1'); $range->setEndingip('127.0.0.100'); $range->setRole([ - Opus_UserRole::fetchByName('docsadmin'), - Opus_UserRole::fetchByName('jobaccess') + UserRole::fetchByName('docsadmin'), + UserRole::fetchByName('jobaccess') ]); $form->populateFromModel($range); @@ -108,7 +111,7 @@ public function testPopulateFromModelWithIp() { $form = new Admin_Form_IpRange(); - $model = new Opus_Iprange($this->_modelId); + $model = new Iprange($this->_modelId); $form->populateFromModel($model); @@ -124,7 +127,7 @@ public function testUpdateModel() $form->getElement('Startingip')->setValue('127.0.0.1'); $form->getElement('Endingip')->setValue('127.0.0.3'); - $model = new Opus_Iprange(); + $model = new Iprange(); $form->updateModel($model); diff --git a/tests/modules/admin/forms/LanguageTest.php b/tests/modules/admin/forms/LanguageTest.php index 57b0e9bfda..20ccc64298 100644 --- a/tests/modules/admin/forms/LanguageTest.php +++ b/tests/modules/admin/forms/LanguageTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Language; + class Admin_Form_LanguageTest extends ControllerTestCase { @@ -60,7 +62,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Language(); - $language = new Opus_Language(); + $language = new Language(); $language->setActive(true); $language->setPart2B('ger'); $language->setPart2T('deu'); @@ -87,7 +89,7 @@ public function testPopulateFromModelWithId() { $form = new Admin_Form_Language(); - $language = new Opus_Language(2); + $language = new Language(2); $form->populateFromModel($language); @@ -108,7 +110,7 @@ public function testUpdateModel() $form->getElement('Scope')->setValue('I'); $form->getElement('Type')->setValue('L'); - $language = new Opus_Language(); + $language = new Language(); $form->updateModel($language); diff --git a/tests/modules/admin/forms/LicenceTest.php b/tests/modules/admin/forms/LicenceTest.php index 847b94cf74..d41275eb5c 100644 --- a/tests/modules/admin/forms/LicenceTest.php +++ b/tests/modules/admin/forms/LicenceTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Licence; + /** * Unit Tests fuer Formular fuer eine Lizenz. * @@ -67,7 +69,7 @@ public function testPopulateFromModel() { $form = new Admin_Form_Licence(); - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setActive(true); $licence->setCommentInternal('Test Internal Comment'); $licence->setDescMarkup('

      Test Markup

      '); @@ -101,7 +103,7 @@ public function testPopulateFromModelWithId() { $form = new Admin_Form_Licence(); - $licence = new Opus_Licence(2); + $licence = new Licence(2); $form->populateFromModel($licence); @@ -126,7 +128,7 @@ public function testUpdateModel() $form->getElement('SortOrder')->setValue(5); $form->getElement('PodAllowed')->setChecked(true); - $licence = new Opus_Licence(); + $licence = new Licence(); $form->updateModel($licence); diff --git a/tests/modules/admin/forms/NotificationTest.php b/tests/modules/admin/forms/NotificationTest.php index a144a016fa..08f656e48b 100644 --- a/tests/modules/admin/forms/NotificationTest.php +++ b/tests/modules/admin/forms/NotificationTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + class Admin_Form_NotificationTest extends ControllerTestCase { @@ -39,7 +41,7 @@ public function testGetRows() { $form = new Admin_Form_Notification(); - $form->addPublishNotificationSelection(new Opus_Document(146)); + $form->addPublishNotificationSelection(Document::get(146)); $rows = $form->getRows(); diff --git a/tests/modules/admin/forms/Person/DocumentsTest.php b/tests/modules/admin/forms/Person/DocumentsTest.php index e2eeb6f84c..f7fa05b9f3 100644 --- a/tests/modules/admin/forms/Person/DocumentsTest.php +++ b/tests/modules/admin/forms/Person/DocumentsTest.php @@ -81,7 +81,7 @@ public function testSetDocuments() $this->assertArrayHasKey(5, $options); foreach ($options as $docId => $doc) { - $this->assertInstanceOf('Opus_Document', $doc); + $this->assertInstanceOf('Opus\Document', $doc); $this->assertEquals($docId, $doc->getId()); } } diff --git a/tests/modules/admin/forms/PersonLinkTest.php b/tests/modules/admin/forms/PersonLinkTest.php index c814e384a3..f6a4c7f424 100644 --- a/tests/modules/admin/forms/PersonLinkTest.php +++ b/tests/modules/admin/forms/PersonLinkTest.php @@ -30,8 +30,12 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Person; +use Opus\Model\Dependent\Link\DocumentPerson; + /** - * Unit Tests für Formular das Opus_Model_Dependent_Link_DocumentPerson Objekte anzeigt. + * Unit Tests für Formular das DocumentPerson Objekte anzeigt. */ class Admin_Form_PersonLinkTest extends ControllerTestCase { @@ -56,9 +60,9 @@ public function testPopulateFromModel() { $form = new Admin_Form_PersonLink(); - $model = new Opus_Model_Dependent_Link_DocumentPerson(); + $model = new DocumentPerson(); - $person = new Opus_Person(310); // von Testdokument 250 (Personensortierung) + $person = new Person(310); // von Testdokument 250 (Personensortierung) $model->setModel($person); $model->setSortOrder(5); @@ -94,7 +98,7 @@ public function testGetModel() $this->assertNull($form->getModel()); - $document = new Opus_Document(250); + $document = Document::get(250); $authors = $document->getPersonAuthor(); $this->assertEquals(3, count($authors)); @@ -158,7 +162,7 @@ public function testUpdateModel() $form->getElement('SortOrder')->setValue(6); $form->getElement('AllowContact')->setChecked(true); - $model = new Opus_Model_Dependent_Link_DocumentPerson(); + $model = new DocumentPerson(); $form->updateModel($model); diff --git a/tests/modules/admin/forms/PersonTest.php b/tests/modules/admin/forms/PersonTest.php index 60557f01d4..c6a708b1aa 100644 --- a/tests/modules/admin/forms/PersonTest.php +++ b/tests/modules/admin/forms/PersonTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Person; + /** * Unit Test fuer Formularklasse zum Editieren einer Person. */ @@ -61,7 +64,7 @@ public function testPopulateFromModel() $form = new Admin_Form_Person(); - $person = new Opus_Person(); + $person = new Person(); $person->setFirstName('John'); $person->setLastName('Doe'); @@ -113,7 +116,7 @@ public function testUpdateModel() $form->getElement('IdentifierMisc')->setValue('5678'); - $person = new Opus_Person(); + $person = new Person(); $form->updateModel($person); @@ -145,7 +148,7 @@ public function testUpdateModelBadModel() $messages = $logger->getMessages(); $this->assertEquals(1, count($messages)); - $this->assertContains('not instance of Opus_Person', $messages[0]); + $this->assertContains('not instance of Opus\Person', $messages[0]); } public function testGetModel() @@ -154,7 +157,7 @@ public function testGetModel() $form = new Admin_Form_Person(); - $document = new Opus_Document(146); + $document = Document::get(146); $persons = $document->getPerson(); $person = $persons[0]->getModel(); diff --git a/tests/modules/admin/forms/PersonsTest.php b/tests/modules/admin/forms/PersonsTest.php index a37eebbd00..550eb4cdd5 100644 --- a/tests/modules/admin/forms/PersonsTest.php +++ b/tests/modules/admin/forms/PersonsTest.php @@ -528,7 +528,7 @@ public function testKeepPostValues() $form->getElement('PlaceOfBirth')->setValue('Köln'); - $output = $form->render(Zend_Registry::get('Opus_View')); + $output = $form->render(\Zend_Registry::get('Opus_View')); $this->assertContains('', $output); $this->assertContains('', $output); diff --git a/tests/modules/admin/forms/RoleTest.php b/tests/modules/admin/forms/RoleTest.php index e2f5542f34..3dac7e01ba 100644 --- a/tests/modules/admin/forms/RoleTest.php +++ b/tests/modules/admin/forms/RoleTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\UserRole; + class Admin_Form_RoleTest extends ControllerTestCase { @@ -43,14 +45,14 @@ public function testCreateForm() public function testContructWithRole() { - $role = Opus_UserRole::fetchByName('guest'); + $role = UserRole::fetchByName('guest'); $form = new Admin_Form_Role($role->getId()); $this->assertEquals('guest', $form->getElementValue(Admin_Form_Role::ELEMENT_NAME)); } public function testPopulateFromModel() { - $role = Opus_UserRole::fetchByName('administrator'); + $role = UserRole::fetchByName('administrator'); $form = new Admin_Form_Role(); $form->populateFromModel($role); @@ -68,6 +70,8 @@ public function validRoleNameDataProvider() } /** + * @param string $validName Role name + * * @dataProvider validRoleNameDataProvider */ public function testValidRoleName($validName) @@ -91,6 +95,7 @@ public function invalidRoleNameDataProvider() } /** + * @param string $invalidName Role name * @dataProvider invalidRoleNameDataProvider */ public function testInvalidRoleName($invalidName) diff --git a/tests/modules/admin/forms/SeriesTest.php b/tests/modules/admin/forms/SeriesTest.php index fe4a65c63d..a9367d13e3 100644 --- a/tests/modules/admin/forms/SeriesTest.php +++ b/tests/modules/admin/forms/SeriesTest.php @@ -1,5 +1,4 @@ setTitle('TestTitle'); $series->setInfobox('TestInfo'); $series->setVisible(1); @@ -74,7 +76,7 @@ public function testPopulateFromModelWithId() { $form = new Admin_Form_Series(); - $series = new Opus_Series(2); + $series = new Series(2); $form->populateFromModel($series); @@ -90,7 +92,7 @@ public function testUpdateModel() $form->getElement('Visible')->setValue(1); $form->getElement('SortOrder')->setValue(22); - $series = new Opus_Series(); + $series = new Series(); $form->updateModel($series); diff --git a/tests/modules/admin/forms/UserRolesTest.php b/tests/modules/admin/forms/UserRolesTest.php index c35d27edd5..753abab194 100644 --- a/tests/modules/admin/forms/UserRolesTest.php +++ b/tests/modules/admin/forms/UserRolesTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Account; +use Opus\UserRole; + class Admin_Form_UserRolesTest extends ControllerTestCase { @@ -40,16 +43,16 @@ public function testConstruct() { $form = new Admin_Form_UserRoles(); - $roles = Opus_UserRole::getAll(); + $roles = UserRole::getAll(); $elements = $form->getElements(); - $this->assertEquals(count($roles), count($elements)); + $this->assertSameSize($roles, $elements); } public function testPopulateFromModel() { - $account = Opus_Account::fetchAccountByLogin('sworduser'); + $account = Account::fetchAccountByLogin('sworduser'); $form = new Admin_Form_UserRoles(); @@ -97,7 +100,7 @@ public function testUpdateModel() $form->getElement('administrator')->setValue(1); $form->getElement('sworduser')->setValue(1); - $account = new Opus_Account(); + $account = new Account(); $form->updateModel($account); diff --git a/tests/modules/admin/forms/WorkflowNotificationTest.php b/tests/modules/admin/forms/WorkflowNotificationTest.php index a33c8e88dd..bcd2d24657 100644 --- a/tests/modules/admin/forms/WorkflowNotificationTest.php +++ b/tests/modules/admin/forms/WorkflowNotificationTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Person; + class Admin_Form_WorkflowNotificationTest extends ControllerTestCase { @@ -42,46 +45,46 @@ protected function setUpTestDocument() { $doc = $this->createTestDocument(); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName('John'); $author->setLastName('Tester'); $author->setEmail('john@example.org'); $doc->addPersonAuthor($author); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName('Jane'); $author->setLastName('Doe'); $author->setEmail('jane@example.org'); $doc->addPersonAuthor($author); // This email is used twice for different authors (John & Anton) - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName('Anton'); $author->setLastName('Other'); $author->setEmail('john@example.org'); $doc->addPersonAuthor($author); // Jim doesn't have an email address and won't be a recipient - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName('Jim'); $author->setLastName('Busy'); $doc->addPersonAuthor($author); // Jane is author and submitter - $submitter = new Opus_Person(); + $submitter = new Person(); $submitter->setFirstName('Jane'); $submitter->setLastName('Doe'); $submitter->setEmail('jane@example.org'); $doc->addPersonSubmitter($submitter); // Bob is just submitter - $submitter = new Opus_Person(); + $submitter = new Person(); $submitter->setFirstName('Bob'); $submitter->setLastName('Writer'); $submitter->setEmail('bob@example.org'); $doc->addPersonSubmitter($submitter); - $this->doc = new Opus_Document($doc->store()); + $this->doc = Document::get($doc->store()); } public function testGetRecipients() @@ -143,7 +146,7 @@ public function testGetSelectedRecipients() * Add a checkbox for each PersonSubmitter and PersonAuthor (used to select * recipients for publish notification email) * - * @param Opus_Document $document + * @param Document $document protected function addPublishNotificationSelection($document) { $translator = $this->getTranslator(); diff --git a/tests/modules/admin/models/CollectionRoleTest.php b/tests/modules/admin/models/CollectionRoleTest.php index abc293096a..d4c400394e 100644 --- a/tests/modules/admin/models/CollectionRoleTest.php +++ b/tests/modules/admin/models/CollectionRoleTest.php @@ -29,6 +29,9 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\CollectionRole; + class Admin_Model_CollectionRoleTest extends ControllerTestCase { @@ -42,7 +45,7 @@ public function setUp() { parent::setUp(); - $collectionRole = new Opus_CollectionRole(); + $collectionRole = new CollectionRole(); $collectionRole->setName('TestCollectionRole-Name'); $collectionRole->setOaiName('TestCollectionRole-OaiName'); $collectionRole->setVisible(1); @@ -58,11 +61,11 @@ public function setUp() public function tearDown() { - $collectionRole = new Opus_CollectionRole($this->collectionRoleId); + $collectionRole = new CollectionRole($this->collectionRoleId); $collectionRole->delete(); if (! is_null($this->moveTestColId)) { - $collectionRole = new Opus_CollectionRole($this->moveTestColId); + $collectionRole = new CollectionRole($this->moveTestColId); $collectionRole->delete(); } @@ -135,7 +138,7 @@ public function testSetVisibilityTrue() $model->setVisibility(true); - $collectionRole = new Opus_CollectionRole($this->collectionRoleId); + $collectionRole = new CollectionRole($this->collectionRoleId); $this->assertEquals(1, $collectionRole->getVisible()); } @@ -150,14 +153,14 @@ public function testSetVisibilityFalse() $model->setVisibility(false); - $collectionRole = new Opus_CollectionRole($this->collectionRoleId); + $collectionRole = new CollectionRole($this->collectionRoleId); $this->assertEquals(0, $collectionRole->getVisible()); } public function testMove() { - $colRole = new Opus_CollectionRole(); + $colRole = new CollectionRole(); $colRole->setName('MoveTestColRole-Name'); $colRole->setOaiName('MoveTestColRole-OaiName'); $colRole->setDisplayFrontdoor('Number'); @@ -165,7 +168,7 @@ public function testMove() $colRole->setPosition(100); $this->moveTestColId = $colRole->store(); - $colRoles = Opus_CollectionRole::fetchAll(); + $colRoles = CollectionRole::fetchAll(); $colRolesCount = count($colRoles); @@ -176,7 +179,7 @@ public function testMove() $model->move(100); - $colRoles = Opus_CollectionRole::fetchAll(); + $colRoles = CollectionRole::fetchAll(); $colRolesCount = count($colRoles); diff --git a/tests/modules/admin/models/CollectionsTest.php b/tests/modules/admin/models/CollectionsTest.php index 084626eda5..931542d85b 100644 --- a/tests/modules/admin/models/CollectionsTest.php +++ b/tests/modules/admin/models/CollectionsTest.php @@ -30,6 +30,9 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\CollectionRole; + class Admin_Model_CollectionsTest extends ControllerTestCase { @@ -45,7 +48,7 @@ public function setUp() { parent::setUp(); - $collectionRole = new Opus_CollectionRole(); + $collectionRole = new CollectionRole(); $collectionRole->setName('TestCollectionRole-Name'); $collectionRole->setOaiName('TestCollectionRole-OaiName'); $collectionRole->setVisible(1); @@ -60,7 +63,7 @@ public function setUp() $this->collectionRoleId = $collectionRole->store(); $this->model = new Admin_Model_Collections(); - $this->model->setView(Zend_Registry::get('Opus_View')); + $this->model->setView(\Zend_Registry::get('Opus_View')); $document = $this->createTestDocument(); $document->addCollection($root); @@ -69,7 +72,7 @@ public function setUp() public function tearDown() { - $collectionRole = new Opus_CollectionRole($this->collectionRoleId); + $collectionRole = new CollectionRole($this->collectionRoleId); $collectionRole->delete(); parent::tearDown(); @@ -97,9 +100,9 @@ public function testGetCollectionRoleInfo() } $this->assertArrayHasKey('isRoot', $collection); $this->assertArrayHasKey('role', $collection); - $this->assertInstanceOf('Opus_CollectionRole', $collection['role']); + $this->assertInstanceOf('Opus\CollectionRole', $collection['role']); $this->assertArrayHasKey('collection', $collection); - $this->assertInstanceOf('Opus_Collection', $collection['collection']); + $this->assertInstanceOf('Opus\Collection', $collection['collection']); $this->assertArrayHasKey('assigned', $collection); $this->assertFalse($collection['assigned']); } @@ -110,7 +113,7 @@ public function testGetCollectionRoleInfo() */ public function testRoleInvisible() { - $collectionRole = Opus_CollectionRole::fetchByName('TestCollectionRole-Name'); + $collectionRole = CollectionRole::fetchByName('TestCollectionRole-Name'); $collectionRole->setVisible(0); $collectionRole->store(); @@ -131,9 +134,9 @@ public function testRoleInvisible() } $this->assertArrayHasKey('isRoot', $collection); $this->assertArrayHasKey('role', $collection); - $this->assertInstanceOf('Opus_CollectionRole', $collection['role']); + $this->assertInstanceOf('Opus\CollectionRole', $collection['role']); $this->assertArrayHasKey('collection', $collection); - $this->assertInstanceOf('Opus_Collection', $collection['collection']); + $this->assertInstanceOf('Opus\Collection', $collection['collection']); $this->assertArrayHasKey('assigned', $collection); $this->assertFalse($collection['assigned']); } @@ -158,9 +161,9 @@ public function testCollectionRoleWithoutRootNotIncluded() } $this->assertArrayHasKey('isRoot', $collection); $this->assertArrayHasKey('role', $collection); - $this->assertInstanceOf('Opus_CollectionRole', $collection['role']); + $this->assertInstanceOf('Opus\CollectionRole', $collection['role']); $this->assertArrayHasKey('collection', $collection); - $this->assertInstanceOf('Opus_Collection', $collection['collection']); + $this->assertInstanceOf('Opus\Collection', $collection['collection']); $this->assertArrayHasKey('assigned', $collection); $this->assertFalse($collection['assigned']); } diff --git a/tests/modules/admin/models/DocumentEditSessionTest.php b/tests/modules/admin/models/DocumentEditSessionTest.php index 93fdae9439..460923e7b7 100644 --- a/tests/modules/admin/models/DocumentEditSessionTest.php +++ b/tests/modules/admin/models/DocumentEditSessionTest.php @@ -39,13 +39,10 @@ public function testCreateModel() $this->assertEquals(146, $model->getDocumentId()); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage mit document ID '-1' aufgerufen - */ public function testCreateModelWithBadId() { - $model = new Admin_Model_DocumentEditSession(-1); + $this->setExpectedException(\InvalidArgumentException::class, 'mit document ID \'-1\' aufgerufen'); + new Admin_Model_DocumentEditSession(-1); } public function testAddPerson() @@ -81,7 +78,7 @@ public function testRetrievePersons() $model->addPerson($props); - $this->assertEquals(1, count($model->retrievePersons())); + $this->assertCount(1, $model->retrievePersons()); // retrievePersons removes variable from session $this->assertEmpty($model->retrievePersons()); diff --git a/tests/modules/admin/models/DoiReportTest.php b/tests/modules/admin/models/DoiReportTest.php index e74009f4fa..812759214d 100644 --- a/tests/modules/admin/models/DoiReportTest.php +++ b/tests/modules/admin/models/DoiReportTest.php @@ -30,7 +30,13 @@ * @author Jens Schwidder * @copyright Copyright (c) 2018-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * + */ + +use Opus\Document; +use Opus\DocumentFinder; +use Opus\Identifier; + +/** * TODO test-performance */ class Admin_Model_DoiReportTest extends ControllerTestCase @@ -46,14 +52,14 @@ public function setUp() { parent::setUp(); - $config = Zend_Registry::get('Zend_Config'); - $config->merge(new Zend_Config([ + $config = \Zend_Registry::get('Zend_Config'); + $config->merge(new \Zend_Config([ 'doi' => [ 'prefix' => '10.5072', 'localPrefix' => 'opustest' ] ])); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->docIds = []; @@ -107,14 +113,14 @@ public function testGetNumDoisForBulkRegistration() public function testGetNumDoisForBulkVerification() { - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setServerState('published'); $finder->setIdentifierTypeExists('doi'); $expected = 0; foreach ($finder->ids() as $docId) { - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $identifier = $doc->getIdentifierDoi(0); if ($identifier->getStatus() === 'registered') { $expected++; @@ -133,7 +139,7 @@ private function createTestDocWithDoi($serverState, $doiStatus, $local = true) $docId = $doc->store(); $this->docIds[] = $docId; - $doi = new Opus_Identifier(); + $doi = new Identifier(); $doi->setType('doi'); if ($local) { $doi->setValue('10.5072/opustest-' . $docId); diff --git a/tests/modules/admin/models/DoiStatusTest.php b/tests/modules/admin/models/DoiStatusTest.php index 2aed7ee37f..db2cbf9851 100644 --- a/tests/modules/admin/models/DoiStatusTest.php +++ b/tests/modules/admin/models/DoiStatusTest.php @@ -1,5 +1,4 @@ docId)) { // removed previously created test document from database - $doc = new Opus_Document($this->docId); + $doc = Document::get($this->docId); $doc->deletePermanent(); } parent::tearDown(); @@ -51,7 +54,7 @@ public function tearDown() public function testWithPublishedDoc() { $this->createTestDocWithDoi('published'); - $doc = new Opus_Document($this->docId); + $doc = Document::get($this->docId); $identifiers = $doc->getIdentifier(); $doi = $identifiers[0]; @@ -66,7 +69,7 @@ public function testWithPublishedDoc() public function testWithUnpublishedDoc() { $this->createTestDocWithDoi('unpublished'); - $doc = new Opus_Document($this->docId); + $doc = Document::get($this->docId); $identifiers = $doc->getIdentifier(); $doi = $identifiers[0]; @@ -80,11 +83,11 @@ public function testWithUnpublishedDoc() private function createTestDocWithDoi($serverState) { - $doc = new Opus_Document(); + $doc = Document::new(); $doc->setServerState($serverState); $this->docId = $doc->store(); - $doi = new Opus_Identifier(); + $doi = new Identifier(); $doi->setType('doi'); $doi->setValue('10.5027/opustest-' . $this->docId); $doi->setStatus('registered'); diff --git a/tests/modules/admin/models/EnrichmentKeysTest.php b/tests/modules/admin/models/EnrichmentKeysTest.php index d1484b2e24..39a4e3f0f9 100644 --- a/tests/modules/admin/models/EnrichmentKeysTest.php +++ b/tests/modules/admin/models/EnrichmentKeysTest.php @@ -42,7 +42,7 @@ class Admin_Model_EnrichmentKeysTest extends ControllerTestCase public function tearDown() { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); parent::tearDown(); @@ -52,7 +52,7 @@ public function testGetProtectedEnrichmentKeys() { $model = new Admin_Model_EnrichmentKeys(); - $config = new Zend_Config(['enrichmentkey' => ['protected' => [ + $config = new \Zend_Config(['enrichmentkey' => ['protected' => [ 'modules' => 'pkey1,pkey2', 'migration' => 'pkey3,pkey4' ]]]); @@ -67,7 +67,7 @@ public function testGetProtectedEnrichmentKeys() $this->assertContains('pkey3', $protectedKeys); $this->assertContains('pkey4', $protectedKeys); - $config = new Zend_Config(['enrichmentkey' => ['protected' => [ + $config = new \Zend_Config(['enrichmentkey' => ['protected' => [ 'migration' => 'pkey3,pkey4' ]]]); @@ -80,7 +80,7 @@ public function testGetProtectedEnrichmentKeys() $this->assertContains('pkey3', $protectedKeys); $this->assertContains('pkey4', $protectedKeys); - $config = new Zend_Config(['enrichmentkey' => ['protected' => [ + $config = new \Zend_Config(['enrichmentkey' => ['protected' => [ 'modules' => 'pkey1,pkey2', ]]]); @@ -98,7 +98,7 @@ public function testGetProtectedEnrichmentKeysNotConfigured() { $model = new Admin_Model_EnrichmentKeys(); - $config = new Zend_Config([]); + $config = new \Zend_Config([]); $model->setConfig($config); @@ -110,7 +110,7 @@ public function testGetProtectedEnrichmentKeysNotConfigured() public function testCreateTranslations() { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); $model = new Admin_Model_EnrichmentKeys(); @@ -133,7 +133,7 @@ public function testCreateTranslations() public function testCreateTranslationsDoNotOverwriteExistingValues() { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); $hintKey = 'hint_EnrichmentMyTestEnrichment'; @@ -174,7 +174,7 @@ public function testCreateTranslationsDoNotOverwriteExistingValues() public function testChangeNamesOfTranslationKeys() { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); $model = new Admin_Model_EnrichmentKeys(); @@ -203,7 +203,7 @@ public function testRemoveTranslations() { $model = new Admin_Model_EnrichmentKeys(); - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); $name = 'TestEnrichment'; diff --git a/tests/modules/admin/models/FileImportTest.php b/tests/modules/admin/models/FileImportTest.php index 6fe5a6c905..3ab1843768 100644 --- a/tests/modules/admin/models/FileImportTest.php +++ b/tests/modules/admin/models/FileImportTest.php @@ -1,5 +1,4 @@ model->addFilesToDocument($this->documentId, ['test.txt']); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $files = $document->getFile(); @@ -193,7 +195,7 @@ public function testDeleteFile() $this->model->addFilesToDocument($this->documentId, ['test1.txt', 'test2.txt']); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $files = $document->getFile(); @@ -208,7 +210,7 @@ public function testDeleteFile() // eigentlicher Test $this->model->deleteFile($this->documentId, $files[0]->getId()); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $files = $document->getFile(); diff --git a/tests/modules/admin/models/HashTest.php b/tests/modules/admin/models/HashTest.php index 686664c665..2e1ee05e87 100644 --- a/tests/modules/admin/models/HashTest.php +++ b/tests/modules/admin/models/HashTest.php @@ -30,13 +30,15 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + class Admin_Model_HashTest extends ControllerTestCase { public function testCreate() { $this->markTestIncomplete('No hash in test data.'); - $doc = new Opus_Document(91); + $doc = Document::get(91); $files = $doc->getFiles(); $file = $files[0]; } diff --git a/tests/modules/admin/models/IndexMaintenanceTest.php b/tests/modules/admin/models/IndexMaintenanceTest.php index 5f9aabd483..1fec061aad 100644 --- a/tests/modules/admin/models/IndexMaintenanceTest.php +++ b/tests/modules/admin/models/IndexMaintenanceTest.php @@ -32,6 +32,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\DocumentFinder; +use Opus\Job; +use Opus\Job\Runner; + class Admin_Model_IndexMaintenanceTest extends ControllerTestCase { @@ -42,11 +46,11 @@ class Admin_Model_IndexMaintenanceTest extends ControllerTestCase public function tearDown() { if (! is_null($this->config)) { - Zend_Registry::set('Zend_Config', $this->config); + \Zend_Registry::set('Zend_Config', $this->config); } // Cleanup of Log File - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $filename = $config->workspacePath . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'opus_consistency-check.log'; if (file_exists($filename)) { unlink($filename); @@ -58,7 +62,7 @@ public function tearDown() } // Cleanup of Jobs Table - $jobs = Opus_Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL]); + $jobs = Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL]); foreach ($jobs as $job) { try { $job->delete(); @@ -100,14 +104,14 @@ public function testConstructorWithFeatureEnabledBoth() private function enableAsyncMode() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'runjobs' => ['asynchronous' => self::CONFIG_VALUE_TRUE] ])); } private function enableAsyncIndexmaintenanceMode() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'runjobs' => ['indexmaintenance' => ['asynchronous' => self::CONFIG_VALUE_TRUE]] ])); } @@ -144,7 +148,7 @@ public function testNotAllowConsistencyCheck() $model->createJob(); $this->assertFalse($model->allowConsistencyCheck()); - $this->assertEquals(1, Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); + $this->assertEquals(1, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); } public function testNotAllowConsistencyCheckAlt() @@ -155,7 +159,7 @@ public function testNotAllowConsistencyCheckAlt() $model->createJob(); $this->assertFalse($model->allowConsistencyCheck()); - $this->assertEquals(1, Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); + $this->assertEquals(1, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); } public function testProcessingStateInvalidContext() @@ -167,15 +171,15 @@ public function testProcessingStateInvalidContext() private function runJobImmediately() { - $this->assertEquals(1, Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); + $this->assertEquals(1, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); - $jobrunner = new Opus_Job_Runner; - $jobrunner->setLogger(Zend_Registry::get('Zend_Log')); + $jobrunner = new Runner; + $jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); $worker = new Opus\Search\Task\ConsistencyCheck(); $jobrunner->registerWorker($worker); $jobrunner->run(); - $this->assertEquals(0, Opus_Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); + $this->assertEquals(0, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); } public function testProcessingStateInitial() @@ -241,7 +245,7 @@ public function testReadLogfileWithNonEmptyFile() { $this->enableAsyncMode(); - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setServerState('published'); $numOfPublishedDocs = $finder->count(); @@ -263,7 +267,7 @@ public function testReadLogfileWithNonEmptyFile() private function touchLogfile($lock = false) { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if ($lock) { $filename = $config->workspacePath . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'opus_consistency-check.log.lock'; } else { diff --git a/tests/modules/admin/models/UrnGeneratorTest.php b/tests/modules/admin/models/UrnGeneratorTest.php index 1101d788d8..dfacff86a4 100644 --- a/tests/modules/admin/models/UrnGeneratorTest.php +++ b/tests/modules/admin/models/UrnGeneratorTest.php @@ -47,24 +47,24 @@ public function tearDown() { if (! is_null($this->config)) { // undo modifications in configuration - Zend_Registry::set('Zend_Config', $this->config); + \Zend_Registry::set('Zend_Config', $this->config); } } private function modifyUrnConfig($nss, $nid) { // backup current config state - $this->config = Zend_Registry::get('Zend_Config'); + $this->config = \Zend_Registry::get('Zend_Config'); // modify current config state - $config = Zend_Registry::get('Zend_Config'); - $config->merge(new Zend_Config([ + $config = \Zend_Registry::get('Zend_Config'); + $config->merge(new \Zend_Config([ 'urn' => [ 'nss' => $nss, 'nid' => $nid ] ])); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); } public function testWithMissingConfig() diff --git a/tests/modules/citationExport/controller/IndexControllerTest.php b/tests/modules/citationExport/controller/IndexControllerTest.php index 334546847d..196b79fba8 100644 --- a/tests/modules/citationExport/controller/IndexControllerTest.php +++ b/tests/modules/citationExport/controller/IndexControllerTest.php @@ -32,6 +32,10 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Identifier; +use Opus\Series; + /** * Class CitationExport_IndexControllerTest. * @@ -65,7 +69,7 @@ public function testMultipleIdentifiersInRis() $this->assertContains('SN - 1-5432-876-9', $response->getBody()); $this->assertContains('SN - 1234-5678', $response->getBody()); $this->assertContains('SN - 4321-8765', $response->getBody()); - $urnResolverUrl = Zend_Registry::get('Zend_Config')->urn->resolverUrl; + $urnResolverUrl = \Zend_Registry::get('Zend_Config')->urn->resolverUrl; $this->assertContains('UR - ' . $urnResolverUrl . 'urn:nbn:de:foo:123-bar-456', $response->getBody()); $this->assertContains('UR - ' . $urnResolverUrl . 'urn:nbn:de:foo:123-bar-789', $response->getBody()); $this->assertContains('UR - http://www.myexampledomain.de/foo', $response->getBody()); @@ -134,7 +138,7 @@ public function testIndexActionWithInvalidOutputParam() public function testIndexActionWithUnpublishedDocument() { - $doc = new Opus_Document($this->documentId); + $doc = Document::get($this->documentId); $doc->setServerState('unpublished'); $doc->store(); $this->dispatch('/citationExport/index/index/output/foo/docId/' . $this->documentId); @@ -190,7 +194,6 @@ public function testIndexActionRisDoctypeDoctoralthesis() $this->setDocumentType('doctoralthesis'); $this->dispatch('/citationExport/index/index/output/ris/docId/' . $this->documentId); $this->checkRisAssertions('THES'); - ; } public function testIndexActionRisDoctypeMasterthesis() @@ -316,7 +319,7 @@ public function testIndexActionRisMisc() public function testIndexActionRisSubjectUncontrolled() { - $doc = new Opus_Document($this->documentId); + $doc = Document::get($this->documentId); $doc->addSubject()->setType('uncontrolled')->setValue('Freies Schlagwort'); $doc->store(); $this->dispatch('/citationExport/index/index/output/ris/docId/' . $this->documentId); @@ -327,7 +330,7 @@ public function testIndexActionRisSubjectUncontrolled() public function testIndexActionRisSubjectSwd() { - $doc = new Opus_Document($this->documentId); + $doc = Document::get($this->documentId); $doc->addSubject()->setType('swd')->setValue('SWD-Schlagwort'); $doc->store(); $this->dispatch('/citationExport/index/index/output/ris/docId/' . $this->documentId); @@ -338,8 +341,8 @@ public function testIndexActionRisSubjectSwd() public function testIndexActionRisSeriesVisible() { - $s = new Opus_Series(4); - $doc = new Opus_Document($this->documentId); + $s = new Series(4); + $doc = Document::get($this->documentId); $doc->addSeries($s)->setNumber('SeriesNumber'); $doc->store(); $this->dispatch('/citationExport/index/index/output/ris/docId/' . $this->documentId); @@ -350,8 +353,8 @@ public function testIndexActionRisSeriesVisible() public function testIndexActionRisSeriesInvisible() { - $s = new Opus_Series(3); - $doc = new Opus_Document($this->documentId); + $s = new Series(3); + $doc = Document::get($this->documentId); $doc->addSeries($s)->setNumber('SeriesNumber'); $doc->store(); $this->dispatch('/citationExport/index/index/output/ris/docId/' . $this->documentId); @@ -362,7 +365,7 @@ public function testIndexActionRisSeriesInvisible() public function testIndexActionRisPublicNote() { - $doc = new Opus_Document(146); + $doc = Document::get(146); $this->dispatch('/citationExport/index/index/output/ris/docId/' . $doc->getId()); $this->assertResponseCode(200); $response = $this->getResponse(); @@ -371,7 +374,7 @@ public function testIndexActionRisPublicNote() public function testIndexActionRisPrivateNote() { - $doc = new Opus_Document(146); + $doc = Document::get(146); $this->dispatch('/citationExport/index/index/output/ris/docId/' . $doc->getId()); $this->assertResponseCode(200); $response = $this->getResponse(); @@ -449,8 +452,8 @@ public function testIndexActionBibtexMisc() public function testIndexActionBibtexSeriesVisible() { $this->setDocumentType('preprint'); - $s = new Opus_Series(4); - $doc = new Opus_Document($this->documentId); + $s = new Series(4); + $doc = Document::get($this->documentId); $doc->addSeries($s)->setNumber('SeriesNumber'); $doc->store(); $this->dispatch('/citationExport/index/index/output/bibtex/docId/' . $this->documentId); @@ -463,8 +466,8 @@ public function testIndexActionBibtexSeriesVisible() public function testIndexActionBibtexSeriesInvisible() { $this->setDocumentType('preprint'); - $s = new Opus_Series(3); - $doc = new Opus_Document($this->documentId); + $s = new Series(3); + $doc = Document::get($this->documentId); $doc->addSeries($s)->setNumber('SeriesNumber'); $doc->store(); $this->dispatch('/citationExport/index/index/output/bibtex/docId/' . $this->documentId); @@ -480,8 +483,8 @@ public function testIndexActionBibtexEnrichmentVisibleAsNote() $bibtexConfArray = [ 'citationExport' => ['bibtex' => ['enrichment' => 'SourceTitle']] ]; - $bibtexConf = new Zend_Config($bibtexConfArray); - Zend_Registry::getInstance()->get('Zend_Config')->merge($bibtexConf); + $bibtexConf = new \Zend_Config($bibtexConfArray); + \Zend_Registry::getInstance()->get('Zend_Config')->merge($bibtexConf); $this->dispatch('/citationExport/index/index/output/bibtex/docId/146'); $this->assertResponseCode(200); $response = $this->getResponse(); @@ -519,7 +522,7 @@ public function testDownloadActionWithInvalidOutputParam() public function testDownloadActionWithUnpublishedDocument() { - $doc = new Opus_Document($this->documentId); + $doc = Document::get($this->documentId); $doc->setServerState('unpublished'); $doc->store(); $this->dispatch('/citationExport/index/download/output/foo/docId/' . $this->documentId); @@ -714,7 +717,7 @@ public function testBibtexNoType() private function setDocumentType($documenttype) { - $doc = new Opus_Document($this->documentId); + $doc = Document::get($this->documentId); $doc->setType($documenttype); $doc->store(); } @@ -750,7 +753,7 @@ public function testDoiRendering() $doc = $this->createTestDocument(); $doc->setType('article'); - $doi = new Opus_Identifier(); + $doi = new Identifier(); $doi->setValue('123_345_678'); $doc->addIdentifierDoi($doi); diff --git a/tests/modules/citationExport/model/HelperTest.php b/tests/modules/citationExport/model/HelperTest.php index 602df8c642..751ee17c0c 100644 --- a/tests/modules/citationExport/model/HelperTest.php +++ b/tests/modules/citationExport/model/HelperTest.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\DnbInstitute; +use Opus\Document; + class CitationExport_Model_HelperTest extends ControllerTestCase { @@ -78,10 +81,10 @@ public function testGetAvailableStylesheets() public function testBibtexAttributeSchoolForMasterThesis() { - $document = new Opus_Document($this->_documentId); + $document = Document::get($this->_documentId); $document->setType('masterthesis'); - $institute = new Opus_DnbInstitute(4); + $institute = new DnbInstitute(4); $document->addThesisPublisher($institute); $document->store(); @@ -98,11 +101,11 @@ public function testBibtexAttributeSchoolForMasterThesis() public function testBibtexAttributeSchoolWithDepartment() { - $document = new Opus_Document($this->_documentId); + $document = Document::get($this->_documentId); $document->setType('masterthesis'); - $institute = new Opus_DnbInstitute(); + $institute = new DnbInstitute(); $institute->setName('Test Uni'); $institute->setDepartment('Test Dep'); $institute->setIsPublisher(true); @@ -127,10 +130,10 @@ public function testBibtexAttributeSchoolWithDepartment() public function testBibtexAttributeSchoolForDoctoralThesis() { - $document = new Opus_Document($this->_documentId); + $document = Document::get($this->_documentId); $document->setType('doctoralthesis'); - $institute = new Opus_DnbInstitute(4); + $institute = new DnbInstitute(4); $document->addThesisPublisher($institute); $document->store(); @@ -156,7 +159,7 @@ public function testGetExtension() public function testGetTemplateForDocument() { - $document = new Opus_Document($this->_documentId); + $document = Document::get($this->_documentId); $document->setType('masterthesis'); $document->store(); @@ -176,7 +179,7 @@ public function testGetTemplateForDocument() */ public function testGetTemplateForDocumentInvalidFormat() { - $document = new Opus_Document($this->_documentId); + $document = Document::get($this->_documentId); $document->setType('masterthesis'); $document->store(); @@ -223,7 +226,7 @@ public function testGetDocumentUnpublished() $this->enableSecurity(); $this->loginUser('security7', 'security7pwd'); - $document = new Opus_Document($this->_documentId); + $document = Document::get($this->_documentId); $document->setServerState('unpublished'); $document->store(); @@ -236,7 +239,7 @@ public function testGetDocumentUnpublished() public function testGetPlainOutputRis() { - $document = new Opus_Document(146); + $document = Document::get(146); $output = $this->_helper->getPlainOutput($document, 'ris.xslt'); diff --git a/tests/modules/default/controllers/AuthControllerTest.php b/tests/modules/default/controllers/AuthControllerTest.php index eb70c14e2c..8583d88b6c 100644 --- a/tests/modules/default/controllers/AuthControllerTest.php +++ b/tests/modules/default/controllers/AuthControllerTest.php @@ -106,7 +106,7 @@ public function testLogoutActionAsAdmin() $this->dispatch('/auth/logout/rmodule/home/rcontroller/index/raction/index'); $this->assertResponseLocationHeader($this->response, '/home'); $this->assertResponseCode('302'); - $this->assertNull(Zend_Auth::getInstance()->getIdentity()); + $this->assertNull(\Zend_Auth::getInstance()->getIdentity()); } public function testLogoutActionAsAnonymous() @@ -114,7 +114,7 @@ public function testLogoutActionAsAnonymous() $this->dispatch('/auth/logout/rmodule/home/rcontroller/index/raction/index'); $this->assertResponseLocationHeader($this->response, '/home'); $this->assertResponseCode('302'); - $this->assertNull(Zend_Auth::getInstance()->getIdentity()); + $this->assertNull(\Zend_Auth::getInstance()->getIdentity()); } public function testLogoutActionFromAdministrationModule() @@ -124,7 +124,7 @@ public function testLogoutActionFromAdministrationModule() $this->assertNotContains('Argument 4 passed to Zend_Controller_Action_Helper_Redirector::direct() must be an array, null given', $this->response->outputBody()); $this->assertResponseLocationHeader($this->response, '/home'); $this->assertResponseCode('302'); - $this->assertNull(Zend_Auth::getInstance()->getIdentity()); + $this->assertNull(\Zend_Auth::getInstance()->getIdentity()); } public function testLogoutActionFromAnyModule() @@ -133,6 +133,6 @@ public function testLogoutActionFromAnyModule() $this->dispatch('/auth/logout/rmodule/any/rcontroller/index/raction/index'); $this->assertResponseLocationHeader($this->response, '/home'); $this->assertResponseCode('302'); - $this->assertNull(Zend_Auth::getInstance()->getIdentity()); + $this->assertNull(\Zend_Auth::getInstance()->getIdentity()); } } diff --git a/tests/modules/export/BibtexExportTest.php b/tests/modules/export/BibtexExportTest.php index 6698b4f493..d6a848db39 100644 --- a/tests/modules/export/BibtexExportTest.php +++ b/tests/modules/export/BibtexExportTest.php @@ -42,7 +42,7 @@ public function setUp() { parent::setUp(); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'searchengine' => ['solr' => ['numberOfDefaultSearchResults' => '10']] ])); } @@ -77,7 +77,7 @@ public function setUp() public function testExportSingleDocument() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'export' => ['download' => self::CONFIG_VALUE_FALSE] ])); @@ -96,7 +96,7 @@ public function testExportSingleDocument() */ public function testExportLatestDocuments() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'export' => ['download' => self::CONFIG_VALUE_FALSE], 'searchengine' => ['solr' => ['numberOfDefaultSearchResults' => '10']] ])); @@ -112,7 +112,7 @@ public function testExportLatestDocuments() public function testExportLatestDocumentsWithCustomRows() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'export' => ['download' => self::CONFIG_VALUE_FALSE] ])); diff --git a/tests/modules/export/BootstrapTest.php b/tests/modules/export/BootstrapTest.php index e39b3ed120..99d884756b 100644 --- a/tests/modules/export/BootstrapTest.php +++ b/tests/modules/export/BootstrapTest.php @@ -45,7 +45,7 @@ public function testInitExport() $this->dispatch('/frontdoor/index/index/docId/1'); // TODO configuration change has no influence at this point - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'export' => [ 'stylesheet' => [ 'frontdoor' => null diff --git a/tests/modules/export/DataCiteExportTest.php b/tests/modules/export/DataCiteExportTest.php index e9f3e7ef42..99f766d253 100644 --- a/tests/modules/export/DataCiteExportTest.php +++ b/tests/modules/export/DataCiteExportTest.php @@ -31,6 +31,13 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Date; +use Opus\Document; +use Opus\Identifier; +use Opus\Model\ModelException; +use Opus\Person; +use Opus\Title; + class Export_DataCiteExportTest extends ControllerTestCase { @@ -41,7 +48,7 @@ class Export_DataCiteExportTest extends ControllerTestCase public function testExportOfValidDataCiteXML() { // DOI Präfix setzen - $oldConfig = Zend_Registry::get('Zend_Config'); + $oldConfig = \Zend_Registry::get('Zend_Config'); $this->adaptDoiConfiguration(); // freigegebenes Testdokument mit allen Pflichtfeldern anlegen @@ -52,7 +59,7 @@ public function testExportOfValidDataCiteXML() $this->dispatch('/export/index/datacite/docId/' . $docId); // Änderungen an Konfiguration zurücksetzen - Zend_Registry::set('Zend_Config', $oldConfig); + \Zend_Registry::set('Zend_Config', $oldConfig); $this->assertResponseCode(200); $this->assertHeaderContains('Content-Type', 'text/xml; charset=UTF-8'); @@ -90,7 +97,7 @@ public function testExportOfDataCiteXmlStatusPage() public function testExportOfDataCiteXmlStatusPageForUnpublishedDoc() { - $oldConfig = Zend_Registry::get('Zend_Config'); + $oldConfig = \Zend_Registry::get('Zend_Config'); $this->adaptDoiConfiguration(); // nicht freigegebenes Testdokument mit allen Pflichtfeldern erzeugen @@ -102,7 +109,7 @@ public function testExportOfDataCiteXmlStatusPageForUnpublishedDoc() $this->dispatch('/export/index/datacite/docId/' . $docId); // Änderungen an Konfiguration zurücksetzen - Zend_Registry::set('Zend_Config', $oldConfig); + \Zend_Registry::set('Zend_Config', $oldConfig); $this->assertResponseCode(200); @@ -114,7 +121,7 @@ public function testExportOfDataCiteXmlStatusPageForUnpublishedDoc() public function testExportOfDataCiteXmlStatusPageForUnpublishedDocWithMissingField() { - $oldConfig = Zend_Registry::get('Zend_Config'); + $oldConfig = \Zend_Registry::get('Zend_Config'); $this->adaptDoiConfiguration(); // nicht freigegebenes Testdokument mit Pflichtfeldern erzeugen @@ -130,7 +137,7 @@ public function testExportOfDataCiteXmlStatusPageForUnpublishedDocWithMissingFie $this->dispatch('/export/index/datacite/docId/' . $docId); // Änderungen an Konfiguration zurücksetzen - Zend_Registry::set('Zend_Config', $oldConfig); + \Zend_Registry::set('Zend_Config', $oldConfig); $this->assertResponseCode(200); @@ -142,20 +149,20 @@ public function testExportOfDataCiteXmlStatusPageForUnpublishedDocWithMissingFie public function testExportOfDataCiteXmlForUnpublishedDocWithServerDatePublished() { - $oldConfig = Zend_Registry::get('Zend_Config'); + $oldConfig = \Zend_Registry::get('Zend_Config'); $this->adaptDoiConfiguration(); // nicht freigegebenes Testdokument mit Pflichtfeldern erzeugen und ServerDatePublished $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); - $doc->setServerDatePublished(new Opus_Date('2019-12-24')); + $doc->setServerDatePublished(new Date('2019-12-24')); $docId = $this->addRequiredFields($doc); $this->useGerman(); $this->dispatch('/export/index/datacite/docId/' . $docId); // Änderungen an Konfiguration zurücksetzen - Zend_Registry::set('Zend_Config', $oldConfig); + \Zend_Registry::set('Zend_Config', $oldConfig); $this->assertResponseCode(200); $this->assertHeaderContains('Content-Type', 'text/xml; charset=UTF-8'); @@ -164,7 +171,7 @@ public function testExportOfDataCiteXmlForUnpublishedDocWithServerDatePublished( public function testExportOfDataCiteXmlStatusPageForPublishedDocWithoutServerDatePublished() { - $oldConfig = Zend_Registry::get('Zend_Config'); + $oldConfig = \Zend_Registry::get('Zend_Config'); $this->adaptDoiConfiguration(); // freigegebenes Testdokument mit Pflichtfeldern erzeugen @@ -172,7 +179,7 @@ public function testExportOfDataCiteXmlStatusPageForPublishedDocWithoutServerDat $doc->setServerState('published'); $docId = $this->addRequiredFields($doc); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $doc->setServerDatePublished(''); // dies setzt das Publication Year auf 0001 (ohne Monat und Tag) $doc->store(); @@ -180,7 +187,7 @@ public function testExportOfDataCiteXmlStatusPageForPublishedDocWithoutServerDat $this->dispatch('/export/index/datacite/docId/' . $docId); // Änderungen an Konfiguration zurücksetzen - Zend_Registry::set('Zend_Config', $oldConfig); + \Zend_Registry::set('Zend_Config', $oldConfig); $this->assertResponseCode(200); @@ -195,17 +202,17 @@ public function testExportOfDataCiteXmlStatusPageForPublishedDocWithoutServerDat * Nicht freigeschaltete Dokumente können nur dann exportiert werden, * wenn der Benutzer das Recht 'resource_documents' besitzt. * - * @throws Opus_Model_Exception + * @throws ModelException * @throws Zend_Exception */ public function testExportOfDataCiteXmlWithUnpublishedDocNotAllowed() { $removeAccess = $this->addModuleAccess('export', 'guest'); $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] @@ -226,7 +233,7 @@ public function testExportOfDataCiteXmlWithUnpublishedDocNotAllowed() // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); if ($removeAccess) { $this->removeModuleAccess('export', 'guest'); } @@ -238,10 +245,10 @@ public function testExportOfDataCiteXmlWithUnpublishedDocNotAllowed() public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForAdmin() { $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] @@ -262,7 +269,7 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForAdmin() // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->assertResponseCode(200); $this->assertContains("DataCite XML of document ${docId} is not valid", $this->getResponse()->getBody()); @@ -272,10 +279,10 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForNonAdminUserW { $removeAccess = $this->addModuleAccess('export', 'docsadmin'); $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] @@ -296,7 +303,7 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForNonAdminUserW // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); if ($removeAccess) { $this->removeModuleAccess('export', 'docsadmin'); } @@ -309,10 +316,10 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForNonAdminUserW { $removeAccess = $this->addModuleAccess('export', 'collectionsadmin'); $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] @@ -333,7 +340,7 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForNonAdminUserW // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); if ($removeAccess) { $this->removeModuleAccess('export', 'collectionsadmin'); } @@ -343,7 +350,7 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForNonAdminUserW } /** - * @param Opus_Document $doc + * @param Document $doc * @return int ID des gespeicherten Dokuments */ private function addRequiredFields($doc) @@ -353,19 +360,19 @@ private function addRequiredFields($doc) $doc->setLanguage('deu'); $docId = $doc->store(); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); - $doi = new Opus_Identifier(); + $doi = new Identifier(); $doi->setType('doi'); $doi->setValue('10.2345/opustest-' . $docId); $doc->setIdentifier([$doi]); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName('John'); $author->setLastName('Doe'); $doc->setPersonAuthor([$author]); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('Meaningless title'); $title->setLanguage('deu'); $doc->setTitleMain([$title]); @@ -376,8 +383,8 @@ private function addRequiredFields($doc) private function adaptDoiConfiguration() { - Zend_Registry::set('Zend_Config', Zend_Registry::get('Zend_Config')->merge( - new Zend_Config([ + \Zend_Registry::set('Zend_Config', \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config([ 'doi' => [ 'autoCreate' => false, 'prefix' => '10.2345', diff --git a/tests/modules/export/Marc21ExportTest.php b/tests/modules/export/Marc21ExportTest.php index 4d06cfe9dc..63ba46627a 100644 --- a/tests/modules/export/Marc21ExportTest.php +++ b/tests/modules/export/Marc21ExportTest.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Model\ModelException; + class Export_Marc21ExportTest extends ControllerTestCase { @@ -41,17 +43,17 @@ class Export_Marc21ExportTest extends ControllerTestCase * Nicht freigeschaltete Dokumente können nur dann im Format MARC21-XML exportiert werden, * wenn der Benutzer das Recht 'resource_documents' besitzt. * - * @throws Opus_Model_Exception + * @throws ModelException * @throws Zend_Exception */ public function testMarc21XmlExportWithUnpublishedDocNotAllowed() { $removeAccess = $this->addModuleAccess('export', 'guest'); $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] @@ -72,7 +74,7 @@ public function testMarc21XmlExportWithUnpublishedDocNotAllowed() // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); if ($removeAccess) { $this->removeModuleAccess('export', 'guest'); } @@ -84,10 +86,10 @@ public function testMarc21XmlExportWithUnpublishedDocNotAllowed() public function testMarc21XmlExportWithUnpublishedDocAllowedForAdmin() { $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] @@ -108,7 +110,7 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForAdmin() // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->assertResponseCode(200); $this->assertXpathContentContains('//marc:leader', '00000naa a22000005 4500'); @@ -126,10 +128,10 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForNonAdminUserWithP { $removeAccess = $this->addModuleAccess('export', 'docsadmin'); $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] @@ -150,7 +152,7 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForNonAdminUserWithP // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); if ($removeAccess) { $this->removeModuleAccess('export', 'docsadmin'); } @@ -171,10 +173,10 @@ public function testMarc21XmlExportWithPublishedDocNotAllowedForGuest() { $removeAccess = $this->addModuleAccess('export', 'guest'); $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_TRUE]] @@ -193,7 +195,7 @@ public function testMarc21XmlExportWithPublishedDocNotAllowedForGuest() // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); if ($removeAccess) { $this->removeModuleAccess('export', 'guest'); } @@ -206,10 +208,10 @@ public function testMarc21XmlExportWithPublishedDocAllowedForAdmin() { $removeAccess = $this->addModuleAccess('export', 'docsadmin'); $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_TRUE]] @@ -230,7 +232,7 @@ public function testMarc21XmlExportWithPublishedDocAllowedForAdmin() // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); if ($removeAccess) { $this->removeModuleAccess('export', 'docsadmin'); } @@ -253,10 +255,10 @@ public function testMarc21XmlExportWithPublishedDocAllowedForGuest() { $removeAccess = $this->addModuleAccess('export', 'guest'); $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] @@ -275,7 +277,7 @@ public function testMarc21XmlExportWithPublishedDocAllowedForGuest() // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); if ($removeAccess) { $this->removeModuleAccess('export', 'guest'); } @@ -298,10 +300,10 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForNonAdminUserWitho { $removeAccess = $this->addModuleAccess('export', 'collectionsadmin'); $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] @@ -322,7 +324,7 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForNonAdminUserWitho // revert configuration changes $this->restoreSecuritySetting(); - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); if ($removeAccess) { $this->removeModuleAccess('export', 'collectionsadmin'); } diff --git a/tests/modules/export/RisExportTest.php b/tests/modules/export/RisExportTest.php index cb813dba22..4f4979fd18 100644 --- a/tests/modules/export/RisExportTest.php +++ b/tests/modules/export/RisExportTest.php @@ -48,7 +48,7 @@ public function testDoiUrlRendered() $docId = $document->store(); - $doiResolverUrl = Zend_Registry::get('Zend_Config')->doi->resolverUrl; + $doiResolverUrl = \Zend_Registry::get('Zend_Config')->doi->resolverUrl; $this->dispatch("/export/index/ris/searchtype/id/docId/$docId"); diff --git a/tests/modules/export/controllers/IndexControllerTest.php b/tests/modules/export/controllers/IndexControllerTest.php index 709dcb2bc6..238bcb3291 100644 --- a/tests/modules/export/controllers/IndexControllerTest.php +++ b/tests/modules/export/controllers/IndexControllerTest.php @@ -33,8 +33,11 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\File; +use Opus\Title; +use Opus\Model\ModelException; use Opus\Search\Service; -use \Opus\Search\Util\Indexer; /** * Class Export_IndexControllerTest. @@ -188,9 +191,9 @@ public function testRequestToRawXmlIsDenied() $this->_removeExportFromGuest = $this->addAccessOnModuleExportForGuest(); // enable security - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->security = self::CONFIG_VALUE_TRUE; - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/index/export/xml'); @@ -211,13 +214,13 @@ public function testUnavailableSolrServerReturns503() $this->_removeExportFromGuest = $this->addAccessOnModuleExportForGuest(); // manipulate solr configuration - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $host = $config->searchengine->index->host; $port = $config->searchengine->index->port; $this->disableSolr(); $config->security = self::CONFIG_VALUE_TRUE; - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/index/searchtype/all/export/xml/stylesheet/example'); $body = $this->getResponse()->getBody(); @@ -237,7 +240,7 @@ public function testSolrIndexIsNotUpToDate() $doc1 = $this->createTestDocument(); $doc1->setServerState('published'); $doc1->setLanguage('eng'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('test document for OPUSVIER-1726'); $title->setLanguage('eng'); $doc1->setTitleMain($title); @@ -248,7 +251,7 @@ public function testSolrIndexIsNotUpToDate() $doc2 = $this->createTestDocument(); $doc2->setServerState('published'); $doc2->setLanguage('eng'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('another test document for OPUSVIER-1726'); $title->setLanguage('eng'); $doc2->setTitleMain($title); @@ -300,7 +303,7 @@ private function helperForOPUSVIER2488($url, $numOfTestDocs, $rows, $start = 0) $doc = $this->createTestDocument(); $doc->setServerState('published'); $doc->setLanguage('eng'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('OPUSVIER-2488'); $title->setLanguage('eng'); $doc->setTitleMain($title); @@ -603,16 +606,16 @@ public function testPublistActionWithoutStylesheetParameterInUrl() public function testPublistActionWithoutStylesheetParameterInUrlAndInvalidConfigParameter() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (isset($config->plugins->export->publist->stylesheet)) { $config->plugins->export->publist->stylesheet = 'invalid'; } else { - $config = new Zend_Config(['plugins' => ['export' => [ + $config = new \Zend_Config(['plugins' => ['export' => [ 'publist' => ['stylesheet' => 'invalid']], true]]); // Include the above made configuration changes in the application configuration. - $config->merge(Zend_Registry::get('Zend_Config')); + $config->merge(\Zend_Registry::get('Zend_Config')); } - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/publist/role/publists/number/coll_visible'); @@ -623,25 +626,25 @@ public function testPublistActionWithoutStylesheetParameterInUrlAndInvalidConfig public function testPublistActionWithValidStylesheetInConfig() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (isset($config->plugins->export->publist->stylesheet)) { $config->plugins->export->publist->stylesheet = 'raw'; } else { - $config = new Zend_Config(['plugins' => ['export' => [ + $config = new \Zend_Config(['plugins' => ['export' => [ 'publist' => ['stylesheet' => 'raw']], true]]); // Include the above made configuration changes in the application configuration. - $config->merge(Zend_Registry::get('Zend_Config')); + $config->merge(\Zend_Registry::get('Zend_Config')); } if (isset($config->plugins->export->publist->stylesheetDirectory)) { $config->plugins->export->publist->stylesheetDirectory = 'stylesheets'; } else { - $config = new Zend_Config(['plugins' => ['export' => [ + $config = new \Zend_Config(['plugins' => ['export' => [ 'publist' => ['stylesheetDirectory' => 'stylesheets']], true]]); // Include the above made configuration changes in the application configuration. - $config->merge(Zend_Registry::get('Zend_Config')); + $config->merge(\Zend_Registry::get('Zend_Config')); } - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/publist/role/publists/number/coll_visible'); @@ -677,7 +680,7 @@ public function testPublistActionUrnResolverUrlCorrect() { $this->dispatch('/export/index/publist/role/ccs/number/H.3'); - $urnResolverUrl = Zend_Registry::get('Zend_Config')->urn->resolverUrl; + $urnResolverUrl = \Zend_Registry::get('Zend_Config')->urn->resolverUrl; $this->assertXpathContentContains('//a[starts-with(@href, "' . $urnResolverUrl . '")]', 'URN'); } @@ -686,7 +689,7 @@ public function testPublistActionDoiResolverUrlCorrect() { $this->dispatch('/export/index/publist/role/ddc/number/51'); // contains test document 146 - $doiResolverUrl = Zend_Registry::get('Zend_Config')->doi->resolverUrl; + $doiResolverUrl = \Zend_Registry::get('Zend_Config')->doi->resolverUrl; $this->assertXpathContentContains('//a[starts-with(@href, "' . $doiResolverUrl . '")]', 'DOI'); } @@ -704,17 +707,17 @@ protected function setPublistConfig($options) public function testPublistActionGroupedByCompletedYear() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); // FIXME OPUSVIER-4130 config does not make sense - completely ignores value of setting if (isset($config->plugins->export->publist->groupby->completedyear)) { $config->plugins->export->publist->groupby->completedyear = self::CONFIG_VALUE_TRUE; } else { - $configNew = new Zend_Config(['plugins' => ['export' => [ + $configNew = new \Zend_Config(['plugins' => ['export' => [ 'publist' => ['groupby' => ['completedyear' => self::CONFIG_VALUE_TRUE]]]]], false); // Include the above made configuration changes in the application configuration. $config->merge($configNew); } - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/publist/role/publists/number/coll_visible'); @@ -795,8 +798,8 @@ public function testPrefixesForIdClassAndAnchorInDefaultLayout() */ public function testPublistActionDisplaysUrlencodedFiles() { - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config(['plugins' => ['export' => [ + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config(['plugins' => ['export' => [ 'publist' => [ 'file' => [ 'allow' => [ @@ -807,7 +810,7 @@ public function testPublistActionDisplaysUrlencodedFiles() // This is necessary due to static variable in Export_Model_PublicationList // which is not reset between tests. - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $this->assertTrue( isset($config->plugins->export->publist->file->allow->mimetype), 'Failed setting configuration option' @@ -818,9 +821,9 @@ public function testPublistActionDisplaysUrlencodedFiles() 'Failed setting configuration option' ); - $doc = new Opus_Document(92); + $doc = Document::get(92); $file = $doc->getFile(1); - $this->assertTrue($file instanceof Opus_File, 'Test setup has changed.'); + $this->assertTrue($file instanceof File, 'Test setup has changed.'); $this->assertEquals('datei mit unüblichem Namen.xhtml', $file->getPathName(), 'Test setup has changed.'); $collection = $doc->getCollection(0); @@ -903,7 +906,7 @@ public function testXmlExportDoesNotContainUnpublishedDocument() */ public function testExportedFilePath() { - Zend_Controller_Front::getInstance()->setBaseUrl('opus4dev'); + \Zend_Controller_Front::getInstance()->setBaseUrl('opus4dev'); $this->dispatch('/export/index/index/docId/146/export/xml/stylesheet/example/searchtype/id'); $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; $server = $this->getRequest()->getBasePath(); @@ -914,7 +917,7 @@ public function testExportedFilePath() * Zugriff auf MARC21 Export standardmäßig nur für Administratoren freigegeben, * auch wenn das Zugriffsrecht auf das Module export vorhanden ist. * - * @throws Opus_Model_Exception + * @throws ModelException */ public function testNonAdminAccessOnRestrictedMarc21ExportForbidden() { @@ -934,7 +937,7 @@ public function testNonAdminAccessOnRestrictedMarc21ExportForbidden() * Zugriff auf DataCite Export standardmäßig nur für Administratoren freigegeben, * auch wenn das Zugriffsrecht auf das Module export vorhanden ist. * - * @throws Opus_Model_Exception + * @throws ModelException */ public function testNonAdminAccessOnRestrictedDataCiteExportForbidden() { @@ -954,7 +957,7 @@ public function testNonAdminAccessOnRestrictedDataCiteExportForbidden() * Zugriff auf RIS Export ist nicht eingeschränkt, wenn Zugriffsrecht auf das * Module export besteht. * - * @throws Opus_Model_Exception + * @throws ModelException */ public function testNonAdminAccessOnUnrestrictedExportAllowed() { @@ -976,8 +979,8 @@ public function testNonAdminAccessOnUnrestrictedExportAllowed() */ public function testNonAdminAccessOnUnrestrictedMarc21ExportAllowed() { - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config( ['plugins' => ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]]]] ) ); @@ -999,7 +1002,7 @@ public function testNonAdminAccessOnUnrestrictedMarc21ExportAllowed() * Gibt true zurück, wenn der Zugriff auf das Module export hinzugefügt wurde. * * @return bool - * @throws Opus_Model_Exception + * @throws ModelException */ private function addAccessOnModuleExportForGuest() { diff --git a/tests/modules/export/models/DataciteExportTest.php b/tests/modules/export/models/DataciteExportTest.php index 305b6a7006..785abe382d 100644 --- a/tests/modules/export/models/DataciteExportTest.php +++ b/tests/modules/export/models/DataciteExportTest.php @@ -30,6 +30,12 @@ * @copyright Copyright (c) 2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Document; +use Opus\Identifier; +use Opus\Person; +use Opus\Title; + class Export_Model_DataciteExportTest extends ControllerTestCase { @@ -60,10 +66,10 @@ public function testExecuteWithUnknownDocId() public function testExecuteWithValidDoc() { // DOI Präfix setzen - $oldConfig = Zend_Registry::get('Zend_Config'); + $oldConfig = \Zend_Registry::get('Zend_Config'); - Zend_Registry::set('Zend_Config', Zend_Registry::get('Zend_Config')->merge( - new Zend_Config([ + \Zend_Registry::set('Zend_Config', \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config([ 'doi' => [ 'prefix' => '10.2345', 'localPrefix' => 'opustest' @@ -72,24 +78,24 @@ public function testExecuteWithValidDoc() )); // Testdokument mit allen Pflichtfeldern anlegen - $doc = new Opus_Document(); + $doc = Document::new(); $doc->setType('all'); $doc->setServerState('published'); $doc->setPublisherName('Foo Publishing Corp.'); $doc->setLanguage('deu'); $docId = $doc->store(); - $doi = new Opus_Identifier(); + $doi = new Identifier(); $doi->setType('doi'); $doi->setValue('10.2345/opustest-' . $docId); $doc->setIdentifier([$doi]); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName('John'); $author->setLastName('Doe'); $doc->setPersonAuthor([$author]); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('Meaningless title'); $title->setLanguage('deu'); $doc->setTitleMain([$title]); @@ -107,7 +113,7 @@ public function testExecuteWithValidDoc() // Testdokument wieder löschen $doc->deletePermanent(); // Änderungen an Konfiguration zurücksetzen - Zend_Registry::set('Zend_Config', $oldConfig); + \Zend_Registry::set('Zend_Config', $oldConfig); $this->assertTrue($result); $this->assertHeaderContains('Content-Type', 'text/xml; charset=UTF-8'); @@ -116,7 +122,7 @@ public function testExecuteWithValidDoc() public function testExecuteWithInvalidDoc() { // Testdokument mit fehlenden Pflichtfeldern anlegen - $doc = new Opus_Document(); + $doc = Document::new(); $doc->setServerState('published'); $docId = $doc->store(); @@ -125,7 +131,7 @@ public function testExecuteWithInvalidDoc() $request->setParam('docId', $docId); $plugin->setRequest($request); $plugin->setResponse($this->getResponse()); - $view = new Zend_View(); + $view = new \Zend_View(); $plugin->setView($view); $result = $plugin->execute(); @@ -141,7 +147,7 @@ public function testExecuteWithInvalidDoc() public function testExecuteWithInvalidDocAndInvalidValidateParamValue() { // Testdokument mit fehlenden Pflichtfeldern anlegen - $doc = new Opus_Document(); + $doc = Document::new(); $doc->setServerState('published'); $docId = $doc->store(); @@ -152,7 +158,7 @@ public function testExecuteWithInvalidDocAndInvalidValidateParamValue() $plugin->setRequest($request); $plugin->setResponse($this->getResponse()); - $view = new Zend_View(); + $view = new \Zend_View(); $plugin->setView($view); $result = $plugin->execute(); @@ -167,7 +173,7 @@ public function testExecuteWithInvalidDocAndInvalidValidateParamValue() public function testExecuteWithInvalidDocSkipValidation() { - $doc = new Opus_Document(); + $doc = Document::new(); $doc->setServerState('published'); $docId = $doc->store(); diff --git a/tests/modules/export/models/PublistExportTest.php b/tests/modules/export/models/PublistExportTest.php index 6621f3c5b3..972d06aee4 100644 --- a/tests/modules/export/models/PublistExportTest.php +++ b/tests/modules/export/models/PublistExportTest.php @@ -47,10 +47,10 @@ public function testConstruction() public function testGetMimeTypes() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->merge( - new Zend_Config(['plugins' => ['export' => [ + new \Zend_Config(['plugins' => ['export' => [ 'publist' => [ 'file' => [ 'allow' => [ diff --git a/tests/modules/export/models/XmlExportTest.php b/tests/modules/export/models/XmlExportTest.php index 3598960639..83aeea2643 100644 --- a/tests/modules/export/models/XmlExportTest.php +++ b/tests/modules/export/models/XmlExportTest.php @@ -32,6 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Title; +use Opus\Db\DocumentXmlCache; + /** * Class Export_Model_XmlExportTest * @@ -55,7 +58,7 @@ public function setUp() $plugin->setRequest($this->getRequest()); $plugin->setResponse($this->getResponse()); $plugin->init(); - $plugin->setConfig(new Zend_Config([ + $plugin->setConfig(new \Zend_Config([ 'class' => 'Export_Model_XmlExport', 'maxDocumentsGuest' => '100', 'maxDocumentsUser' => '500', @@ -68,7 +71,7 @@ public function testXmlPreparation() { $doc = $this->createTestDocument(); $doc->setServerState('published'); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('Deutscher Titel'); $doc->setTitleMain($title); @@ -91,7 +94,7 @@ public function testXmlPreparationForFrontdoor() { $doc = $this->createTestDocument(); $doc->setServerState('published'); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('Deutscher Titel'); $doc->setTitleMain($title); @@ -158,7 +161,7 @@ public function testXmlSortOrder() $thirdDocId = $thirdDoc->store(); // Dokument aus dem Cache löschen - $documentCacheTable = new Opus_Db_DocumentXmlCache(); + $documentCacheTable = new DocumentXmlCache(); $documentCacheTable->delete('document_id = ' . $secondDocId); $documentCacheTable->delete('document_id = ' . $firstDocId); @@ -273,7 +276,7 @@ public function testIsDownloadEnabled() $plugin->setDownloadEnabled(null); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'export' => ['download' => self::CONFIG_VALUE_FALSE] ])); @@ -304,7 +307,7 @@ public function testGetContentTypeFromConfiguration() $this->assertEquals('text/xml', $plugin->getContentType()); - $config = new Zend_Config(['contentType' => 'text/plain']); + $config = new \Zend_Config(['contentType' => 'text/plain']); $plugin->setContentType(null); // clear cached content type @@ -319,7 +322,7 @@ public function testGetContentTypeFallback() $plugin->setContentType(null); - $plugin->setConfig(new Zend_Config([])); + $plugin->setConfig(new \Zend_Config([])); $this->assertEquals('text/xml', $plugin->getContentType()); } @@ -341,7 +344,7 @@ public function testGetAttachmentFilename() $plugin->setAttachmentFilename(null); // clear cached name - $plugin->setConfig(new Zend_Config(['attachmentFilename' => 'article.pdf'])); + $plugin->setConfig(new \Zend_Config(['attachmentFilename' => 'article.pdf'])); $this->assertEquals('article.pdf', $plugin->getAttachmentFilename()); } diff --git a/tests/modules/frontdoor/controllers/IndexControllerTest.php b/tests/modules/frontdoor/controllers/IndexControllerTest.php index d3a3b390c4..76b9b4e442 100644 --- a/tests/modules/frontdoor/controllers/IndexControllerTest.php +++ b/tests/modules/frontdoor/controllers/IndexControllerTest.php @@ -33,6 +33,13 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Collection; +use Opus\CollectionRole; +use Opus\Date; +use Opus\Document; +use Opus\Note; +use Opus\Title; + /** * Class Frontdoor_IndexControllerTest. * @@ -46,7 +53,7 @@ class Frontdoor_IndexControllerTest extends ControllerTestCase /** * Document to count on :) * - * @var Opus_Document + * @var Document */ protected $_document = null; protected $_document_col = null; @@ -62,18 +69,18 @@ public function setUp() parent::setUpWithEnv('production'); $this->assertSecurityConfigured(); - $path = Zend_Registry::get('temp_dir') . '~localstat.xml'; + $path = \Zend_Registry::get('temp_dir') . '~localstat.xml'; @unlink($path); $this->_document = $this->createTestDocument(); $this->_document->setType("doctoral_thesis"); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('Titel'); $this->_document->addTitleMain($title); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('eng'); $title->setValue('Title'); $this->_document->addTitleMain($title); @@ -87,13 +94,13 @@ public function setUp() // create collection test document $this->_document_col = $this->createTestDocument(); - $this->_document_col->addCollection(new Opus_Collection(40)); // invisible collection - $this->_document_col->addCollection(new Opus_Collection(16214)); // visible collection with invisible collection role - $this->_document_col->addCollection(new Opus_Collection(1031)); // visible collection with visible collection role + $this->_document_col->addCollection(new Collection(40)); // invisible collection + $this->_document_col->addCollection(new Collection(16214)); // visible collection with invisible collection role + $this->_document_col->addCollection(new Collection(1031)); // visible collection with visible collection role // collection role ID = 10 (sichbar) - $this->_document_col->addCollection(new Opus_Collection(16136)); // versteckte Collection (Role = 10) - $this->_document_col->addCollection(new Opus_Collection(15991)); // sichbare Collection (Role = 10); + $this->_document_col->addCollection(new Collection(16136)); // versteckte Collection (Role = 10) + $this->_document_col->addCollection(new Collection(15991)); // sichbare Collection (Role = 10); $this->_document_col->setServerState('published'); $this->_document_col->store(); } @@ -216,7 +223,7 @@ public function testFrontdoorTitleRespectsDocumentLanguageDeu() { $docId = $this->_document->getId(); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $doc->setLanguage('deu'); $doc->setServerState('published'); $doc->store(); @@ -234,7 +241,7 @@ public function testFrontdoorTitleRespectsDocumentLanguageEng() { $docId = $this->_document->getId(); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $doc->setLanguage('eng'); $doc->setServerState('published'); $doc->store(); @@ -256,7 +263,7 @@ public function testFrontdoorTitleRespectsDocumentLanguageWithoutCorrespondingTi { $docId = $this->_document->getId(); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $doc->setLanguage('fra'); $doc->setServerState('published'); $doc->store(); @@ -277,7 +284,7 @@ public function testFrontdoorTitleRespectsDocumentLanguageMultipleCandidates() { $docId = $this->_document->getId(); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $doc->setLanguage('deu'); $doc->setServerState('published'); $doc->addTitleMain()->setValue('Titel2')->setLanguage('deu'); @@ -295,7 +302,7 @@ public function testFrontdoorTitleRespectsDocumentLanguageMultipleCandidates() */ public function testIdentifierUrlIsHandledProperlyInFrontdoorForNonProtocolURL() { - $d = new Opus_Document('91'); + $d = Document::get('91'); $identifiers = $d->getIdentifierUrl(); $identifier = $identifiers[0]; $this->assertEquals('www.myexampledomain.de/myexamplepath', $identifier->getValue()); @@ -308,7 +315,7 @@ public function testIdentifierUrlIsHandledProperlyInFrontdoorForNonProtocolURL() */ public function testIdentifierUrlIsHandledProperlyInFrontdoorForProtocolURL() { - $d = new Opus_Document('92'); + $d = Document::get('92'); $identifiers = $d->getIdentifierUrl(); $identifier = $identifiers[0]; $this->assertEquals('http://www.myexampledomain.de/myexamplepath', $identifier->getValue()); @@ -321,7 +328,7 @@ public function testIdentifierUrlIsHandledProperlyInFrontdoorForProtocolURL() */ public function testUrlEscapedFileNameDoc1() { - $d = new Opus_Document(1); + $d = Document::get(1); $filePathnames = []; foreach ($d->getFile() as $file) { $filePathnames[] = $file->getPathName(); @@ -345,7 +352,7 @@ public function testUrlEscapedFileNameDoc1() */ public function testUrlEscapedFileNameDoc147() { - $d = new Opus_Document(147); + $d = Document::get(147); $filePathnames = []; foreach ($d->getFile() as $file) { $filePathnames[] = $file->getPathName(); @@ -380,7 +387,7 @@ public function testSubjectSortOrder() public function testSubjectSortOrderAlphabetical() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'frontdoor' => ['subjects' => ['alphabeticalSorting' => self::CONFIG_VALUE_TRUE]] ])); @@ -398,7 +405,7 @@ public function testSubjectSortOrderAlphabetical() */ public function testSeries149InVisible() { - $d = new Opus_Document(149); + $d = Document::get(149); $seriesIds = []; $seriesNumbers = []; foreach ($d->getSeries() as $series) { @@ -429,7 +436,7 @@ public function testSeries149InVisible() */ public function testUrlEncodedAuthorNamesDoc150() { - $d = new Opus_Document(150); + $d = Document::get(150); $firstNames = []; $lastNames = []; @@ -459,8 +466,8 @@ public function testShowLinkForPrintOnDemandIfLicenceAppropriate() 'url' => 'http://localhost/', 'button' => '' ]]; - $podConfig = new Zend_Config($podConfArray); - Zend_Registry::getInstance()->get('Zend_Config')->merge($podConfig); + $podConfig = new \Zend_Config($podConfArray); + \Zend_Registry::getInstance()->get('Zend_Config')->merge($podConfig); $this->dispatch('/frontdoor/index/index/docId/1'); $this->assertQuery('div#print-on-demand'); @@ -475,8 +482,8 @@ public function testHideLinkForPrintOnDemandIfLicenceNotAppropriate() 'url' => 'http://localhost/', 'button' => '' ]]; - $podConfig = new Zend_Config($podConfArray); - Zend_Registry::getInstance()->get('Zend_Config')->merge($podConfig); + $podConfig = new \Zend_Config($podConfArray); + \Zend_Registry::getInstance()->get('Zend_Config')->merge($podConfig); $this->dispatch('/frontdoor/index/index/docId/91'); $this->assertNotQuery('div#print-on-demand'); @@ -503,7 +510,7 @@ public function testDisplayAllUserDefinedCollectionRoles() public function testDisplayAllDocumentFields() { $this->dispatch('/frontdoor/index/index/docId/146'); - $translate = Zend_Registry::getInstance()->get('Zend_Translate'); + $translate = \Zend_Registry::getInstance()->get('Zend_Translate'); $path = 'table.result-data.frontdoordata th.name'; @@ -578,7 +585,7 @@ public function testAbstractPreserveSpace() $doc->setLanguage("eng"); $doc->setServerState("published"); - $abstract = new Opus_Title(); + $abstract = new Title(); $abstract->setLanguage("eng"); $abstract->setValue("foo\nbar\n\nbaz"); $doc->addTitleAbstract($abstract); @@ -600,7 +607,7 @@ public function testNotePerserveSpace() $doc->setLanguage("eng"); $doc->setServerState("published"); - $note = new Opus_Note(); + $note = new Note(); $note->setMessage("foo\nbar\n\nbaz"); $note->setVisibility("public"); $doc->addNote($note); @@ -620,7 +627,7 @@ public function testNotePerserveSpace() */ public function testOPUSVIER2651NameNumber() { - $role = new Opus_CollectionRole(7); + $role = new CollectionRole(7); $displayFrontdoor = $role->getDisplayFrontdoor(); $role->setDisplayFrontdoor('Name,Number'); $role->store(); @@ -643,7 +650,7 @@ public function testOPUSVIER2651NameNumber() */ public function testOPUSVIER2651NumberName() { - $role = new Opus_CollectionRole(7); + $role = new CollectionRole(7); $displayFrontdoor = $role->getDisplayFrontdoor(); $role->setDisplayFrontdoor('Number,Name'); $role->store(); @@ -666,7 +673,7 @@ public function testOPUSVIER2651NumberName() */ public function testOPUSVIER2651Name() { - $role = new Opus_CollectionRole(7); + $role = new CollectionRole(7); $displayFrontdoor = $role->getDisplayFrontdoor(); $role->setDisplayFrontdoor('Name'); $role->store(); @@ -690,7 +697,7 @@ public function testOPUSVIER2651Name() */ public function testOPUSVIER2651Number() { - $role = new Opus_CollectionRole(7); + $role = new CollectionRole(7); $displayFrontdoor = $role->getDisplayFrontdoor(); $role->setDisplayFrontdoor('Number'); $role->store(); @@ -790,7 +797,7 @@ public function testValidateXHTML() public function testValidateXHTMLWithShortendAbstracts() { // Aktiviere Kürzung von Abstrakten - $config = Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + $config = \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['frontdoor' => ['numOfShortAbstractChars' => '200']] )); @@ -932,7 +939,7 @@ public function testDateFormatEnglish() */ public function testFilesInCustomSortOrder() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->frontdoor->files->customSorting = '1'; $this->dispatch('/frontdoor/index/index/docId/155'); @@ -951,7 +958,7 @@ public function testFilesInCustomSortOrder() */ public function testFilesInAlphabeticSortOrder() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->frontdoor->files->customSorting = self::CONFIG_VALUE_FALSE; $this->dispatch('/frontdoor/index/index/docId/155'); @@ -975,12 +982,12 @@ public function testTitleSortOrderGermanFirst() $functions = ['addTitleMain', 'addTitleParent', 'addTitleSub', 'addTitleAdditional', 'addTitleAbstract']; foreach ($functions as $function) { $doc = $this->createTestDocument(); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('deutscher Titel'); $doc->$function($title); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('eng'); $title->setValue('englischer Titel'); $doc->$function($title); @@ -1020,12 +1027,12 @@ public function testTitleSortOrderEnglishFirst() $functions = ['addTitleMain', 'addTitleParent', 'addTitleSub', 'addTitleAdditional', 'addTitleAbstract']; foreach ($functions as $function) { $doc = $this->createTestDocument(); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('deu'); $title->setValue('deutscher Titel'); $doc->$function($title); - $title = new Opus_Title(); + $title = new Title(); $title->setLanguage('eng'); $title->setValue('englischer Titel'); $doc->$function($title); @@ -1194,7 +1201,7 @@ public function testEmbargoDatePassed() $doc->setServerState('published'); $doc->addFile($file); - $date = new Opus_Date(); + $date = new Date(); $date->setYear('2000')->setMonth('00')->setDay('01'); $doc->setEmbargoDate($date); @@ -1217,7 +1224,7 @@ public function testEmbargoDateHasNotPassed() $doc->setServerState('published'); $doc->addFile($file); - $date = new Opus_Date(); + $date = new Date(); $date->setYear('2100')->setMonth('00')->setDay('01'); $doc->setEmbargoDate($date); @@ -1314,8 +1321,8 @@ public function testXmlExportButtonPresentForAdmin() { $this->enableSecurity(); $this->loginUser('admin', 'adminadmin'); - $config = Zend_Registry::get('Zend_Config'); - $config->merge(new Zend_Config(['export' => ['stylesheet' => ['frontdoor' => 'example']]])); + $config = \Zend_Registry::get('Zend_Config'); + $config->merge(new \Zend_Config(['export' => ['stylesheet' => ['frontdoor' => 'example']]])); $this->dispatch('/frontdoor/index/index/docId/305'); $this->assertQuery( '//a[@href="/export/index/index/docId/305/export/xml/searchtype/id/stylesheet/example"]' @@ -1328,8 +1335,8 @@ public function testXmlExportButtonPresentForAdmin() public function testXmlExportNotButtonPresentForGuest() { $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); - $config->merge(new Zend_Config(['export' => ['stylesheet' => ['frontdoor' => 'example']]])); + $config = \Zend_Registry::get('Zend_Config'); + $config->merge(new \Zend_Config(['export' => ['stylesheet' => ['frontdoor' => 'example']]])); $this->dispatch('/frontdoor/index/index/docId/305'); $this->assertNotQuery('//a[@href="/frontdoor/index/index/docId/305/export/xml/stylesheet/example"]'); } @@ -1362,7 +1369,7 @@ public function testGoogleScholarLinkEnglish() public function testGoogleScholarOpenInNewWindowEnabled() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'googleScholar' => ['openInNewWindow' => self::CONFIG_VALUE_TRUE] ])); $this->dispatch('/frontdoor/index/index/docId/146'); @@ -1373,7 +1380,7 @@ public function testGoogleScholarOpenInNewWindowEnabled() public function testGoogleScholarOpenInNewWindowDisabled() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'googleScholar' => ['openInNewWindow' => self::CONFIG_VALUE_FALSE] ])); $this->dispatch('/frontdoor/index/index/docId/146'); @@ -1395,7 +1402,7 @@ public function testShowDocumentWithFileWithoutLanguage() public function testTwitterOpenInNewWindowEnabled() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'twitter' => ['openInNewWindow' => self::CONFIG_VALUE_TRUE] ])); $this->dispatch('/frontdoor/index/index/docId/146'); @@ -1406,7 +1413,7 @@ public function testTwitterOpenInNewWindowEnabled() public function testTwitterOpenInNewWindowDisabled() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'twitter' => ['openInNewWindow' => self::CONFIG_VALUE_FALSE] ])); $this->dispatch('/frontdoor/index/index/docId/146'); @@ -1419,10 +1426,10 @@ public function testUnableToTranslate() { $filter = new LogFilter(); - $logger = Zend_Registry::get('Zend_Log'); + $logger = \Zend_Registry::get('Zend_Log'); $logger->addFilter($filter); - $this->assertEquals(7, Zend_Registry::get('LOG_LEVEL'), 'Log level should be 7 for test.'); + $this->assertEquals(7, \Zend_Registry::get('LOG_LEVEL'), 'Log level should be 7 for test.'); $this->dispatch('/frontdoor/index/index/docId/146'); @@ -1434,7 +1441,7 @@ public function testUnableToTranslate() } } - $output = Zend_Debug::dump($failedTranslations, null, false); + $output = \Zend_Debug::dump($failedTranslations, null, false); // until all messages can be prevented less than 20 is good enough $this->assertLessThanOrEqual(1, count($failedTranslations), $output); @@ -1446,7 +1453,7 @@ public function testMetaTagsForUrns() $this->assertResponseCode(200); - $urnResolverUrl = Zend_Registry::get('Zend_Config')->urn->resolverUrl; + $urnResolverUrl = \Zend_Registry::get('Zend_Config')->urn->resolverUrl; $this->assertXpath('//meta[@name="DC.identifier" and @content="urn:nbn:op:123"]'); $this->assertXpath('//meta[@name="DC.identifier" and @content="' . $urnResolverUrl . 'urn:nbn:op:123"]'); @@ -1455,7 +1462,7 @@ public function testMetaTagsForUrns() public function testBelongsToBibliographyTurnedOn() { $this->useEnglish(); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'frontdoor' => ['metadata' => ['BelongsToBibliography' => self::CONFIG_VALUE_TRUE]] ])); @@ -1467,7 +1474,7 @@ public function testBelongsToBibliographyTurnedOn() public function testBelongsToBibliographyTurnedOff() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'frontdoor' => ['metadata' => ['BelongsToBibliography' => self::CONFIG_VALUE_FALSE]] ])); diff --git a/tests/modules/frontdoor/controllers/MailControllerTest.php b/tests/modules/frontdoor/controllers/MailControllerTest.php index afe52d65c6..9ef0dd7f00 100644 --- a/tests/modules/frontdoor/controllers/MailControllerTest.php +++ b/tests/modules/frontdoor/controllers/MailControllerTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Person; +use Opus\Title; + /** * Class Frontdoor_MailControllerTest. * @@ -53,7 +56,7 @@ public function setUp() $document->setServerState('published'); $document->setType('baz'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('foobartitle'); $title->setLanguage('deu'); $document->setTitleMain($title); @@ -65,12 +68,12 @@ public function setUp() $document->setServerState('published'); $document->setType('baz'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('foobartitle'); $title->setLanguage('deu'); $document->setTitleMain($title); - $author = new Opus_Person(); + $author = new Person(); $author->setFirstName('John'); $author->setLastName('Doe'); $author->setEmail('doe@example.org'); diff --git a/tests/modules/frontdoor/forms/AtLeastOneValidatorTest.php b/tests/modules/frontdoor/forms/AtLeastOneValidatorTest.php index 85d7313aac..04dee57290 100644 --- a/tests/modules/frontdoor/forms/AtLeastOneValidatorTest.php +++ b/tests/modules/frontdoor/forms/AtLeastOneValidatorTest.php @@ -37,8 +37,8 @@ public function testValidationSuccess() { $validator = new Frontdoor_Form_AtLeastOneValidator(); - $checkbox1 = new Zend_Form_Element_Checkbox('checkbox1'); - $checkbox2 = new Zend_Form_Element_Checkbox('checkbox2'); + $checkbox1 = new \Zend_Form_Element_Checkbox('checkbox1'); + $checkbox2 = new \Zend_Form_Element_Checkbox('checkbox2'); $validator->addField($checkbox1); $validator->addField($checkbox2); @@ -52,8 +52,8 @@ public function testValidationFailure() { $validator = new Frontdoor_Form_AtLeastOneValidator(); - $checkbox1 = new Zend_Form_Element_Checkbox('checkbox1'); - $checkbox2 = new Zend_Form_Element_Checkbox('checkbox2'); + $checkbox1 = new \Zend_Form_Element_Checkbox('checkbox1'); + $checkbox2 = new \Zend_Form_Element_Checkbox('checkbox2'); $validator->addField($checkbox1); $validator->addField($checkbox2); diff --git a/tests/modules/frontdoor/models/AuthorsTest.php b/tests/modules/frontdoor/models/AuthorsTest.php index d536669619..dddf3a564d 100644 --- a/tests/modules/frontdoor/models/AuthorsTest.php +++ b/tests/modules/frontdoor/models/AuthorsTest.php @@ -30,6 +30,11 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Document; +use Opus\Person; +use Opus\Title; + class Frontdoor_Model_AuthorsTest extends ControllerTestCase { @@ -50,12 +55,12 @@ public function setUp() $document->setType('testtype'); $document->setLanguage('deu'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('testtitle'); $title->setLanguage('deu'); $document->setTitleMain($title); - $author1 = new Opus_Person(); + $author1 = new Person(); $author1->setFirstName('John'); $author1->setLastName('Doe'); $author1->setEmail('doe@example.org'); @@ -64,7 +69,7 @@ public function setUp() $link_person1 = $document->addPersonAuthor($author1); $link_person1->setAllowEmailContact('1'); - $author2 = new Opus_Person(); + $author2 = new Person(); $author2->setFirstName('Jane'); $author2->setLastName('Doe'); $this->author2Id = $author2->store(); @@ -72,7 +77,7 @@ public function setUp() $link_person2 = $document->addPersonAuthor($author2); $link_person2->setAllowEmailContact('0'); - $author3 = new Opus_Person(); + $author3 = new Person(); $author3->setFirstName('Jimmy'); $author3->setLastName('Doe'); $this->author3Id = $author3->store(); @@ -80,7 +85,7 @@ public function setUp() $link_person3 = $document->addPersonAuthor($author3); $link_person3->setAllowEmailContact('1'); - $author4 = new Opus_Person(); + $author4 = new Person(); $author4->setFirstName('Foo'); $author4->setLastName('Bar'); $author4->setEmail('foo@bar.de'); @@ -197,7 +202,7 @@ public function testUnknownDocumentID() public function testPublishedDocument() { - $doc = new Opus_Document($this->documentId); + $doc = Document::get($this->documentId); $model = new Frontdoor_Model_Authors($doc); $this->assertNotNull($model); } @@ -205,7 +210,7 @@ public function testPublishedDocument() public function testUnpublishedDocument() { $this->markTestIncomplete('TODO: ensure that this method is called with guest privileges'); - $doc = new Opus_Document($this->unpublishedDocumentId); + $doc = Document::get($this->unpublishedDocumentId); $this->setExpectedException('Frontdoor_Model_Exception', 'access to requested document is forbidden'); new Frontdoor_Model_Authors($doc); } diff --git a/tests/modules/frontdoor/models/FileTest.php b/tests/modules/frontdoor/models/FileTest.php index cd5bcaa76b..d8abad5cf8 100644 --- a/tests/modules/frontdoor/models/FileTest.php +++ b/tests/modules/frontdoor/models/FileTest.php @@ -31,6 +31,10 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Date; +use Opus\File; + class Frontdoor_Model_FileTest extends ControllerTestCase { @@ -94,7 +98,7 @@ public function testGetFileObjectNoDocumentDeletedExceptionIfAccessAllowed() $realm = new MockRealm(true, true); $opusFile = $file->getFileObject($realm); - $this->assertTrue($opusFile instanceof Opus_File); + $this->assertTrue($opusFile instanceof File); $this->assertEquals(self::FILENAME_DELETED_DOC, $opusFile->getPathName()); } @@ -104,7 +108,7 @@ public function testGetFileObjectAccessAllowedForUserWithAccessToDocumentsResour $file->setAclHelper(new MockAccessControl(true)); $realm = new MockRealm(false, false); // sollte egal sein $opusFile = $file->getFileObject($realm); - $this->assertTrue($opusFile instanceof Opus_File); + $this->assertTrue($opusFile instanceof File); } /** @@ -272,7 +276,7 @@ public function testFileAccessDeniedIfNotVisibleInFrontdoorForGuest() $realm = new MockRealm(true, true); - $opusFile = new Opus_File(128); + $opusFile = new File(128); $this->assertEquals(0, $opusFile->getVisibleInFrontdoor(), "Testdaten geändert."); $this->assertEquals("frontdoor_invisible.txt", $opusFile->getPathName(), "Testdaten geändert."); @@ -327,7 +331,7 @@ public function testAccessDeniedForEmbargoedDocument() $doc->setServerState('published'); $doc->addFile($file); - $date = new Opus_Date(); + $date = new Date(); $date->setYear('2100')->setMonth('00')->setDay('01'); $doc->setEmbargoDate($date); @@ -350,7 +354,7 @@ public function testAccessForEmbargoedDocumentForDocumentsAdmin() $doc->setServerState('published'); $doc->addFile($file); - $date = new Opus_Date(); + $date = new Date(); $date->setYear('2100')->setMonth('00')->setDay('01'); $doc->setEmbargoDate($date); @@ -375,7 +379,7 @@ public function testAccessForEmbargoedDocumentForAdmin() $doc->setServerState('published'); $doc->addFile($file); - $date = new Opus_Date(); + $date = new Date(); $date->setYear('2100')->setMonth('00')->setDay('01'); $doc->setEmbargoDate($date); @@ -395,7 +399,7 @@ public function testGetFileObjectForUnpublishedFileForDocumentsAdmin() $doc->setServerState('unpublished'); $doc->addFile($file); - $date = new Opus_Date(); + $date = new Date(); $date->setYear('2100')->setMonth('00')->setDay('01'); $doc->setEmbargoDate($date); diff --git a/tests/modules/frontdoor/models/HtmlMetaTagsTest.php b/tests/modules/frontdoor/models/HtmlMetaTagsTest.php index 6fa7d1d110..3e57423d68 100644 --- a/tests/modules/frontdoor/models/HtmlMetaTagsTest.php +++ b/tests/modules/frontdoor/models/HtmlMetaTagsTest.php @@ -31,6 +31,17 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Date; +use Opus\DnbInstitute; +use Opus\Document; +use Opus\Identifier; +use Opus\Licence; +use Opus\Model\ModelException; +use Opus\Person; +use Opus\Subject; +use Opus\Title; +use Opus\TitleAbstract; + class Frontdoor_Model_HtmlMetaTagsTest extends ControllerTestCase { @@ -42,7 +53,7 @@ class Frontdoor_Model_HtmlMetaTagsTest extends ControllerTestCase private $htmlMetaTags; /** - * @var Opus_Date + * @var Date */ private $currDate; @@ -50,11 +61,11 @@ public function setUp() { parent::setUp(); $this->htmlMetaTags = new Frontdoor_Model_HtmlMetaTags( - Zend_Registry::get('Zend_Config'), + \Zend_Registry::get('Zend_Config'), 'http://localhost/opus' ); - $this->currDate = new Opus_Date(new Zend_Date()); + $this->currDate = new Date(new \Zend_Date()); } public function testCreateTagsForMinimalDocument() @@ -85,7 +96,7 @@ public function testCreateTagsForJournalPaper() public function testCreateTagsForCustomTypeJournalPaper() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['metatags' => ['mapping' => ['journal_paper' => ['customdoctype']]]] )); @@ -94,7 +105,7 @@ public function testCreateTagsForCustomTypeJournalPaper() } /** - * @param Opus_Document $doc + * @param Document $doc */ private function handleJournalPaper($doc) { @@ -116,7 +127,7 @@ public function testCreateTagsForConferencePaper() public function testCreateTagsForCustomTypeConferencePaper() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['metatags' => ['mapping' => ['conference_paper' => ['customdoctype']]]] )); @@ -125,7 +136,7 @@ public function testCreateTagsForCustomTypeConferencePaper() } /** - * @param Opus_Document $doc + * @param Document $doc */ private function handleConferencePaper($doc) { @@ -147,7 +158,7 @@ public function testCreateTagsForThesis() public function testCreateTagsForCustomTypeThesis() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['metatags' => ['mapping' => ['thesis' => ['customdoctype']]]] )); @@ -156,7 +167,7 @@ public function testCreateTagsForCustomTypeThesis() } /** - * @param Opus_Document $doc + * @param Document $doc */ private function handleThesis($doc) { @@ -176,7 +187,7 @@ public function testCreateTagsForWorkingPaper() public function testCreateTagsForCustomTypeWorkingPaper() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['metatags' => ['mapping' => ['working_paper' => ['customdoctype']]]] )); @@ -185,7 +196,7 @@ public function testCreateTagsForCustomTypeWorkingPaper() } /** - * @param Opus_Document $doc + * @param Document $doc */ private function handleWorkingPaper($doc) { @@ -209,7 +220,7 @@ public function testCreateTagsForWorkingPaperWithContributingCorporation() public function testCreateTagsForCustomTypeWorkingPaperWithContributingCorporation() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['metatags' => ['mapping' => ['working_paper' => ['customdoctype']]]] )); @@ -221,7 +232,7 @@ public function testCreateTagsForCustomTypeWorkingPaperWithContributingCorporati } /** - * @param Opus_Document $doc + * @param Document $doc */ private function handleWorkingPaperWithContributingCorporation($doc) { @@ -243,7 +254,7 @@ public function testCreateTagsForWorkingPaperWithPublisher() public function testCreateTagsForCustomTypeWorkingPaperWithPublisher() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['metatags' => ['mapping' => ['working_paper' => ['customdoctype']]]] )); @@ -256,7 +267,7 @@ public function testCreateTagsForCustomTypeWorkingPaperWithPublisher() } /** - * @param Opus_Document $doc + * @param Document $doc */ private function handleWorkingPaperWithPublisher($doc) { @@ -274,7 +285,7 @@ public function testCreateTagsForBook() public function testCreateTagsForCustomTypeBook() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['metatags' => ['mapping' => ['book' => ['customdoctype']]]] )); @@ -283,7 +294,7 @@ public function testCreateTagsForCustomTypeBook() } /** - * @param Opus_Document $doc + * @param Document $doc */ private function handleBook($doc) { @@ -302,7 +313,7 @@ public function testCreateTagsForBookPart() public function testCreateTagsForCustomTypeBookPart() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['metatags' => ['mapping' => ['book_part' => ['customdoctype']]]] )); @@ -311,7 +322,7 @@ public function testCreateTagsForCustomTypeBookPart() } /** - * @param Opus_Document $doc + * @param Document $doc */ private function handleBookPart($doc) { @@ -521,7 +532,7 @@ private function assertAbstract($tags) } /** - * @param tags $tags + * @param array $tags Tags */ private function assertLicenceLink($tags) { @@ -548,7 +559,7 @@ private function assertFile($tags, $docId) } /** - * @param Opus_Document $doc + * @param Document $doc * @param array $tags */ private function assertThesisPublisher($doc, $tags) @@ -578,7 +589,7 @@ private function assertInstitution($tags, $value) } /** - * @return Opus_Document + * @return Document */ private function createJournalPaper() { @@ -617,8 +628,8 @@ private function createOther() /** * @param string $docType - * @return Opus_Document - * @throws Opus_Model_Exception + * @return Document + * @throws ModelException */ private function createTestDoc($docType) { @@ -637,7 +648,7 @@ private function createTestDoc($docType) // hier bereits store aufrufen, weil wir die DocId für URN und DOI brauchen $docId = $doc->store(); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $this->addAuthors($doc, 3); $this->addTitles($doc); $this->addAbstracts($doc); @@ -648,18 +659,18 @@ private function createTestDoc($docType) $this->addLicence($doc); $doc->store(); - return new Opus_Document($docId); + return Document::get($docId); } /** - * @param Opus_Document $doc + * @param Document $doc * @param int $num */ private function addAuthors($doc, $num) { $authors = []; for ($i = 0; $i < $num; $i++) { - $author = new Opus_Person(); + $author = new Person(); $author->setLastName('lastName-' . $i); if ($i % 2 == 0) { // nur jeder zweite Autor bekommt einen Vornamen @@ -671,18 +682,18 @@ private function addAuthors($doc, $num) } /** - * @param Opus_Document $doc + * @param Document $doc */ private function addTitles($doc) { $titles = []; - $title = new Opus_Title(); + $title = new Title(); $title->setType('main'); $title->setLanguage('deu'); $title->setValue('titlemain-deu'); $titles[] = $title; - $title = new Opus_Title(); + $title = new Title(); $title->setType('main'); $title->setLanguage('eng'); $title->setValue('titlemain-eng'); @@ -692,7 +703,7 @@ private function addTitles($doc) $titles = []; - $title = new Opus_Title(); + $title = new Title(); $title->setType('sub'); $title->setLanguage('eng'); $title->setValue('titlesub-eng'); @@ -702,7 +713,7 @@ private function addTitles($doc) $titles = []; - $title = new Opus_Title(); + $title = new Title(); $title->setType('parent'); $title->setLanguage('deu'); $title->setValue('titleparent-eng'); @@ -712,19 +723,19 @@ private function addTitles($doc) } /** - * @param Opus_Document $doc + * @param Document $doc */ private function addAbstracts($doc) { $abstracts = []; - $abstr = new Opus_TitleAbstract(); + $abstr = new TitleAbstract(); $abstr->setType('abstract'); $abstr->setLanguage('deu'); $abstr->setValue('abstract1-deu'); $abstracts[] = $abstr; - $abstr = new Opus_TitleAbstract(); + $abstr = new TitleAbstract(); $abstr->setType('abstract'); $abstr->setLanguage('deu'); $abstr->setValue('abstract2-deu'); @@ -734,28 +745,28 @@ private function addAbstracts($doc) } /** - * @param Opus_Document $doc + * @param Document $doc */ private function addIdentifiers($doc) { $identifers = []; - $identifer = new Opus_Identifier(); + $identifer = new Identifier(); $identifer->setType('doi'); $identifer->setValue('doi' . $doc->getId()); $identifers[] = $identifer; - $identifer = new Opus_Identifier(); + $identifer = new Identifier(); $identifer->setType('urn'); $identifer->setValue('urn' . $doc->getId()); $identifers[] = $identifer; - $identifer = new Opus_Identifier(); + $identifer = new Identifier(); $identifer->setType('issn'); $identifer->setValue('issn'); $identifers[] = $identifer; - $identifer = new Opus_Identifier(); + $identifer = new Identifier(); $identifer->setType('isbn'); $identifer->setValue('isbn'); $identifers[] = $identifer; @@ -764,19 +775,19 @@ private function addIdentifiers($doc) } /** - * @param Opus_Document $doc + * @param Document $doc */ private function addSubjects($doc) { $subjects = []; - $subject = new Opus_Subject(); + $subject = new Subject(); $subject->setType('type1'); $subject->setValue('value1'); $subject->setLanguage('deu'); $subjects[] = $subject; - $subject = new Opus_Subject(); + $subject = new Subject(); $subject->setType('type2'); $subject->setValue('value2'); $subject->setLanguage('deu'); @@ -786,20 +797,20 @@ private function addSubjects($doc) } /** - * @param Opus_Document $doc + * @param Document $doc */ private function addLicence($doc) { - $licence = new Opus_Licence(3); + $licence = new Licence(3); $doc->setLicence($licence); } /** - * @param Opus_Document $doc + * @param Document $doc */ private function addFile($doc) { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $path = $config->workspacePath . DIRECTORY_SEPARATOR . uniqid(); mkdir($path, 0777, true); @@ -824,11 +835,11 @@ private function createFile($path, $fileName, $header) } /** - * @param Opus_Document $doc + * @param Document $doc */ private function addThesisPublisher($doc) { - $institute = new Opus_DnbInstitute(3); + $institute = new DnbInstitute(3); $doc->setThesisPublisher($institute); } @@ -836,7 +847,7 @@ public function testGetMetatagsType() { $metaTags = $this->htmlMetaTags; - $document = new Opus_Document(146); + $document = Document::get(146); $book = $this->createBook(); $metaTags->getMetatagsType($document); @@ -861,7 +872,7 @@ public function testGetMappingConfig() public function testGetMappingConfigCustomDocumentType() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'metatags' => ['mapping' => ['book' => ['mybooktype']]] ])); @@ -875,7 +886,7 @@ public function testGetMappingConfigCustomDocumentType() public function testGetMappingConfigDefaultOverride() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'metatags' => ['mapping' => ['book' => ['article']]] ])); diff --git a/tests/modules/home/controllers/IndexControllerTest.php b/tests/modules/home/controllers/IndexControllerTest.php index ce8ba4286e..e65b83fc13 100644 --- a/tests/modules/home/controllers/IndexControllerTest.php +++ b/tests/modules/home/controllers/IndexControllerTest.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\DocumentFinder; + /** * Basic unit test for inded controller of home module. * @@ -82,7 +84,7 @@ public function testHelpActionGerman() public function testHelpActionSeparate() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->help->separate = self::CONFIG_VALUE_TRUE; $this->dispatch('/home/index/help'); $this->assertResponseCode(200); @@ -172,7 +174,7 @@ public function testStartPageContainsTotalNumOfDocs() $element = $document->getElementById('solrsearch-totalnumofdocs'); $numOfDocs = $element->firstChild->textContent; - $docFinder = new Opus_DocumentFinder(); + $docFinder = new DocumentFinder(); $docFinder->setServerState('published'); $numOfDbDocs = $docFinder->count(); @@ -251,7 +253,7 @@ public function testShowLanguageSelector() public function testHideLanguageSelector() { - Zend_Registry::get('Zend_Config')->supportedLanguages = 'de'; + \Zend_Registry::get('Zend_Config')->supportedLanguages = 'de'; $this->dispatch("/home"); $this->assertNotQuery('//ul#lang-switch'); } diff --git a/tests/modules/home/models/HelpFilesTest.php b/tests/modules/home/models/HelpFilesTest.php index 50fce62cf8..921a30691d 100644 --- a/tests/modules/home/models/HelpFilesTest.php +++ b/tests/modules/home/models/HelpFilesTest.php @@ -62,7 +62,7 @@ public function testGetFiles() public function testGetFileContent() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'help' => [ 'useFiles' => true ] @@ -90,7 +90,7 @@ public function testGetFileContentNull() public function testGetFileContentForAllFiles() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'help' => [ 'useFiles' => true ] diff --git a/tests/modules/oai/controllers/ContainerControllerTest.php b/tests/modules/oai/controllers/ContainerControllerTest.php index 9352149558..21f5696173 100644 --- a/tests/modules/oai/controllers/ContainerControllerTest.php +++ b/tests/modules/oai/controllers/ContainerControllerTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\File; +use Opus\UserRole; + /** * Class Oai_ContainerControllerTest. * @@ -73,7 +76,7 @@ public function testRequestUnknownDocId() public function testRequestUnpublishedDoc() { - $r = Opus_UserRole::fetchByName('guest'); + $r = UserRole::fetchByName('guest'); $modules = $r->listAccessModules(); $addOaiModuleAccess = ! in_array('oai', $modules); @@ -83,9 +86,9 @@ public function testRequestUnpublishedDoc() } // enable security - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->security = self::CONFIG_VALUE_TRUE; - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); @@ -115,7 +118,7 @@ public function testRequestPublishedDocWithoutAssociatedFiles() public function testRequestPublishedDocWithInaccessibleFile() { // create test file test.pdf in file system - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $path = $config->workspacePath . DIRECTORY_SEPARATOR . uniqid(); mkdir($path, 0777, true); $filepath = $path . DIRECTORY_SEPARATOR . 'test.pdf'; @@ -124,7 +127,7 @@ public function testRequestPublishedDocWithInaccessibleFile() $doc = $this->createTestDocument(); $doc->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(false); $file->setPathName('test.pdf'); $file->setTempFile($filepath); @@ -135,7 +138,7 @@ public function testRequestPublishedDocWithInaccessibleFile() // cleanup $file->delete(); - Opus_Util_File::deleteDirectory($path); + \Opus\Util\File::deleteDirectory($path); $this->assertResponseCode(500); $this->assertContains( @@ -152,7 +155,7 @@ public function testRequestPublishedDocWithAccessibleFile() ); // create test file test.pdf in file system - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $path = $config->workspacePath . DIRECTORY_SEPARATOR . uniqid(); mkdir($path, 0777, true); $filepath = $path . DIRECTORY_SEPARATOR . 'test.pdf'; @@ -161,7 +164,7 @@ public function testRequestPublishedDocWithAccessibleFile() $doc = $this->createTestDocument(); $doc->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('test.pdf'); $file->setTempFile($filepath); @@ -172,7 +175,7 @@ public function testRequestPublishedDocWithAccessibleFile() // cleanup $file->delete(); - Opus_Util_File::deleteDirectory($path); + \Opus\Util\File::deleteDirectory($path); $this->assertResponseCode(200); } diff --git a/tests/modules/oai/controllers/IndexControllerTest.php b/tests/modules/oai/controllers/IndexControllerTest.php index aa7e50d122..79e7ec5079 100644 --- a/tests/modules/oai/controllers/IndexControllerTest.php +++ b/tests/modules/oai/controllers/IndexControllerTest.php @@ -31,7 +31,23 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * + */ + +use Opus\Collection; +use Opus\CollectionRole; +use Opus\DnbInstitute; +use Opus\Document; +use Opus\Enrichment; +use Opus\File; +use Opus\Identifier; +use Opus\Licence; +use Opus\Person; +use Opus\Series; +use Opus\TitleAbstract; +use Opus\UserRole; + + +/** * TODO split specific protocol tests into separate classes * TODO unit tests transformations directly without "dispatch" * TODO create plugins for formats/protocols/standards @@ -133,7 +149,7 @@ public function testNoVerb() */ public function testIdentify() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'oai' => ['repository' => ['name' => 'test-repo-name']] ])); @@ -192,7 +208,7 @@ public function testIdentifyDescriptionEprintsConfigured() 'comment' => ['url' => 'test-comment-url', 'text' => 'test-comment-text'] ]; - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'oai' => ['description' => ['eprints' => $values]] ])); @@ -218,7 +234,7 @@ public function testIdentifyDescriptionEprintsConfigured() public function testIdentifyDescriptionOaiIdentifier() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'oai' => ['repository' => ['identifier' => 'test-repo-identifier'], 'sample' => ['identifier' => 'test-sample-identifier']] ])); @@ -623,7 +639,7 @@ public function testGetRecordXMetaDissPlusDoc91CheckThesisYearAccepted() */ public function testGetRecordXMetaDissPlusDoc146SubjectDDC() { - $doc = new Opus_Document(146); + $doc = Document::get(146); $ddcs = []; foreach ($doc->getCollection() as $c) { if ($c->getRoleName() == 'ddc') { @@ -723,7 +739,7 @@ public function testGetRecordXMetaDissPlusDoc1DdbIdentifier() */ public function testGetRecordXMetaDissPlusDoc132EmptyThesisGrantor() { - $doc = new Opus_Document(132); + $doc = Document::get(132); $this->assertEquals( 'doctoralthesis', $doc->getType(), @@ -758,7 +774,7 @@ public function testGetRecordXMetaDissPlusDoc132EmptyThesisGrantor() */ public function testGetRecordXMetaDissPlusDoc132EmptyThesisPublisher() { - $doc = new Opus_Document(132); + $doc = Document::get(132); $this->assertEquals( 'doctoralthesis', $doc->getType(), @@ -793,7 +809,7 @@ public function testGetRecordXMetaDissPlusDoc132EmptyThesisPublisher() */ public function testGetRecordXMetaDissPlusDoc93() { - $doc = new Opus_Document(93); + $doc = Document::get(93); $this->assertEquals( 'doctoralthesis', $doc->getType(), @@ -834,7 +850,7 @@ public function testGetRecordXMetaDissPlusDoc93() */ public function testGetRecordXMetaDissPlusDoc146ThesisAndDdb() { - $doc = new Opus_Document(146); + $doc = Document::get(146); $this->assertEquals( 'masterthesis', $doc->getType(), @@ -913,7 +929,7 @@ public function testThesisLevelForXMetaDissPlus() */ public function testGetRecordOaiDcDoc91DocType() { - $doc = new Opus_Document(91); + $doc = Document::get(91); $this->assertEquals("report", $doc->getType(), "testdata changed"); $this->dispatch('/oai?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai::91'); @@ -957,7 +973,7 @@ public function testGetRecordOaiDcDoc146() $this->assertEquals('Baz University', $elements->item(1)->nodeValue, 'dc:contributor field changed'); // Regression test for OPUSVIER-2393 (show dc:identifier) - $urnResolverUrl = Zend_Registry::get('Zend_Config')->urn->resolverUrl; + $urnResolverUrl = \Zend_Registry::get('Zend_Config')->urn->resolverUrl; $elements = $xpath->query('//oai_dc:dc/dc:identifier[text()="' . $urnResolverUrl . 'urn:nbn:op:123"]'); $this->assertEquals(1, $elements->length, 'dc:identifier URN count changed'); @@ -1009,7 +1025,7 @@ public function testGetRecordOaiDcDoc91() */ public function testGetRecordOaiDcDoc10SubjectDdcAndDate() { - $doc = new Opus_Document(10); + $doc = Document::get(10); $ddcs = []; foreach ($doc->getCollection() as $c) { if ($c->getRoleName() == 'ddc') { @@ -1058,7 +1074,7 @@ public function testGetRecordOaiDcDoc10SubjectDdcAndDate() */ public function testGetRecordOaiDcDoc114DcDate() { - $doc = new Opus_Document(114); + $doc = Document::get(114); $completedDate = $doc->getCompletedDate(); $this->assertEquals("2011-04-19", "$completedDate", "testdata changed"); @@ -1206,8 +1222,8 @@ public function testListRecords() */ public function testListRecordsXMetaDissPlusDocumentsWithFilesOnly() { - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config([ 'oai' => [ 'max' => [ 'listrecords' => '100', @@ -1232,8 +1248,8 @@ public function testListRecordsXMetaDissPlusDocumentsWithFilesOnly() */ public function testListRecordsXMetaDissPlusDocumentsWithoutUrn() { - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config([ 'oai' => [ 'max' => [ 'listrecords' => '100', @@ -1330,7 +1346,7 @@ public function testTransferUrlIsPresent() { $doc = $this->createTestDocument(); $doc->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('foobar.pdf'); $doc->addFile($file); @@ -1366,7 +1382,7 @@ public function testGetRecordEpicurUrlEncoding() { $expectedFileNames = ["'many' - spaces and quotes.pdf", 'special-chars-%-"-#-&.pdf']; - $doc = new Opus_Document(147); + $doc = Document::get(147); $fileNames = array_map(function ($f) { return $f->getPathName(); }, $doc->getFile()); @@ -1408,12 +1424,12 @@ public function testDifferentFilesVisibilityOfOneDoc() $d = $this->createTestDocument(); $d->setServerState('published'); - $f1 = new Opus_File(); + $f1 = new File(); $f1->setPathName('foo.pdf'); $f1->setVisibleInOai(false); $d->addFile($f1); - $f2 = new Opus_File(); + $f2 = new File(); $f2->setPathName('bar.pdf'); $f2->setVisibleInOai(false); $d->addFile($f2); @@ -1475,7 +1491,7 @@ public function testRequestForMetadataPrefixCopyxmlAndVerbListIdentifiersIsDenie public function enableSecurity() { - $r = Opus_UserRole::fetchByName('guest'); + $r = UserRole::fetchByName('guest'); $modules = $r->listAccessModules(); $this->_addOaiModuleAccess = ! in_array('oai', $modules); @@ -1485,7 +1501,7 @@ public function enableSecurity() } // enable security - Zend_Registry::get('Zend_Config')->merge(new Zend_Config(['security' => self::CONFIG_VALUE_TRUE])); + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config(['security' => self::CONFIG_VALUE_TRUE])); } /** @@ -1497,7 +1513,7 @@ public function testDdbFileNumberForSingleDocumentAndSingleFile() { $doc = $this->createTestDocument(); $doc->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('foobar.pdf'); $doc->addFile($file); @@ -1522,11 +1538,11 @@ public function testDdbFileNumberForSingleDocumentAndMultipleFiles() { $doc = $this->createTestDocument(); $doc->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('foo.pdf'); $doc->addFile($file); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('bar.pdf'); $doc->addFile($file); @@ -1549,15 +1565,15 @@ public function testDdbFileNumberForSingleDocumentAndMultipleFiles() */ public function testDdbFileNumberForMultipleDocumentsForXMetaDissPlus() { - $collection = new Opus_Collection(112); + $collection = new Collection(112); $doc1 = $this->createTestDocument(); $doc1->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('foo.pdf'); $doc1->addFile($file); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('bar.pdf'); $doc1->addFile($file); @@ -1566,7 +1582,7 @@ public function testDdbFileNumberForMultipleDocumentsForXMetaDissPlus() $doc2 = $this->createTestDocument(); $doc2->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('baz.pdf'); $doc2->addFile($file); @@ -1588,15 +1604,15 @@ public function testDdbFileNumberForMultipleDocumentsForXMetaDissPlus() */ public function testTransferUrlIsIOnlyGivenForDocsWithFulltext() { - $collection = new Opus_Collection(112); + $collection = new Collection(112); $doc1 = $this->createTestDocument(); $doc1->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('foo.pdf'); $doc1->addFile($file); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('bar.pdf'); $doc1->addFile($file); @@ -1605,7 +1621,7 @@ public function testTransferUrlIsIOnlyGivenForDocsWithFulltext() $doc2 = $this->createTestDocument(); $doc2->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setVisibleInOai(true); $file->setPathName('baz.pdf'); $doc2->addFile($file); @@ -1648,14 +1664,14 @@ public function testTransferUrlIsIOnlyGivenForDocsWithFulltext() */ public function testForDDCSubjectTypeForXMetaDissPlus() { - $collection = new Opus_Collection(112); + $collection = new Collection(112); $doc = $this->createTestDocument(); $doc->setServerState('published'); $doc->addCollection($collection); // fixing test for OPUSVIER-3142 - $visibleFile = new Opus_File(); + $visibleFile = new File(); $visibleFile->setPathName('visible_file.txt'); $visibleFile->setVisibleInOai(true); $doc->addFile($visibleFile); @@ -1676,7 +1692,7 @@ public function testForDDCSubjectTypeForXMetaDissPlus() */ public function testForInvalidSetSpecsInListRecords() { - $collectionRole = Opus_CollectionRole::fetchByOaiName('pacs'); + $collectionRole = CollectionRole::fetchByOaiName('pacs'); $this->assertNotNull($collectionRole); $this->assertContains(79, $collectionRole->getDocumentIdsInSet('pacs:07.75.+h')); @@ -1699,7 +1715,7 @@ public function testForInvalidSetSpecsInListRecords() */ public function testForInvalidSetSpecsInListIdentifiers() { - $collectionRole = Opus_CollectionRole::fetchByOaiName('pacs'); + $collectionRole = CollectionRole::fetchByOaiName('pacs'); $this->assertNotNull($collectionRole); $this->assertContains(79, $collectionRole->getDocumentIdsInSet('pacs:07.75.+h')); @@ -1722,7 +1738,7 @@ public function testForInvalidSetSpecsInListIdentifiers() */ public function testForInvalidSetSpecsInGetRecord79() { - $collectionRole = Opus_CollectionRole::fetchByOaiName('pacs'); + $collectionRole = CollectionRole::fetchByOaiName('pacs'); $this->assertNotNull($collectionRole); $this->assertContains(79, $collectionRole->getDocumentIdsInSet('pacs:07.75.+h')); @@ -1774,21 +1790,21 @@ public function testXMetaDissPlusOmitPersonSurnameIfEmpty() $document = $this->createTestDocument(); $document->setServerState('published'); - $author = new Opus_Person(); + $author = new Person(); $author->setLastName('Foo'); $author->setDateOfBirth('1900-01-01'); $author->setPlaceOfBirth('Berlin'); // $authorId = $author->store(); $document->addPersonAuthor($author); - $advisor = new Opus_Person(); + $advisor = new Person(); $advisor->setLastName('Bar'); $advisor->setDateOfBirth('1900-01-01'); $advisor->setPlaceOfBirth('Berlin'); // $advisorId = $advisor->store(); $document->addPersonAdvisor($advisor); - $referee = new Opus_Person(); + $referee = new Person(); $referee->setLastName('Baz'); $referee->setDateOfBirth('1900-01-01'); $referee->setPlaceOfBirth('Berlin'); @@ -1904,8 +1920,8 @@ public function testListRecordsWithResumptionToken() { $max_records = '2'; - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config(['oai' => ['max' => ['listrecords' => $max_records]]]) + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config(['oai' => ['max' => ['listrecords' => $max_records]]]) ); // first request: fetch documents list and expect resumption code @@ -1950,8 +1966,8 @@ public function testListRecordsWithEmptyResumptionTokenForLastBlock() { $max_records = '100'; - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config(['oai' => ['max' => ['listrecords' => $max_records]]]) + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config(['oai' => ['max' => ['listrecords' => $max_records]]]) ); // first request: fetch documents list and expect resumption code @@ -2100,7 +2116,7 @@ public function testHabilitationIsDcTypeDoctoralthesis() */ public function testXMetaDissPlusDcsourceContainsTitleParent() { - $doc = new Opus_Document(146); + $doc = Document::get(146); $parentTitle = $doc->getTitleParent(); $this->assertFalse(empty($parentTitle), 'Test Data modified: Expected TitleParent'); @@ -2167,7 +2183,7 @@ public function testXMetaDissPlusDcsourceContainsTitleParentPageNumber() */ public function testXMetaDissPlusDctermsispartofContainsSeriesTitleAndNumber() { - $doc = new Opus_Document(146); + $doc = Document::get(146); $series = $doc->getSeries(); $this->dispatch('/oai?verb=GetRecord&metadataPrefix=XMetaDissPlus&identifier=oai::146'); @@ -2275,17 +2291,17 @@ public function testListRecordsForOpenAireRelation() $doc = $this->createTestDocument(); $doc->setServerState('published'); - $relation = new Opus_Enrichment(); + $relation = new Enrichment(); $relation->setKeyName('Relation'); $relation->setValue('test-1234'); $doc->addEnrichment($relation); - $relation = new Opus_Enrichment(); + $relation = new Enrichment(); $relation->setKeyName('Relation'); $relation->setValue('info:eu-repo/grantAgreement/EC/FP7/1234withPrefix'); $doc->addEnrichment($relation); - $role = Opus_CollectionRole::fetchByName('openaire'); + $role = CollectionRole::fetchByName('openaire'); $openaire = $role->getCollectionByOaiSubset('openaire'); $doc->addCollection($openaire); @@ -2361,7 +2377,7 @@ public function testXMetaDissPlusForPeriodicalParts() $doc = $this->createTestDocument(); $doc->setServerState('published'); $doc->setType('periodicalpart'); - $series = new Opus_Series(7); + $series = new Series(7); $doc->addSeries($series)->setNumber('1337'); $docId = $doc->store(); @@ -2591,7 +2607,7 @@ public function testGetRecordXMetaDissPlusDcmiType() public function testGetRecordMarc21OfDocId91() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'marc21' => [ 'isil' => 'DE-9999', 'publisherName' => 'publisherNameFromConfig', @@ -2650,65 +2666,65 @@ public function testGetRecordMarc21OfTestDocOfUnknownType() $doc->setPageNumber('10'); $doc->setCreatingCorporation('Foo Creating Corp.'); - $identifierUrn = new Opus_Identifier(); + $identifierUrn = new Identifier(); $identifierUrn->setType('urn'); $identifierUrn->setValue('urn:nbn:de:foo:opus-4711'); - $identifierIssn = new Opus_Identifier(); + $identifierIssn = new Identifier(); $identifierIssn->setType('issn'); $identifierIssn->setValue('0953-4563'); $doc->setIdentifier([$identifierUrn, $identifierIssn]); - $ddc33x = new Opus_Collection(45); // sichtbar - $ddc334 = new Opus_Collection(402); // unsichtbar - $ddc34x = new Opus_Collection(46); // sichtbar + $ddc33x = new Collection(45); // sichtbar + $ddc334 = new Collection(402); // unsichtbar + $ddc34x = new Collection(46); // sichtbar $doc->setCollection([$ddc33x, $ddc334, $ddc34x]); - $titleMainDeu = new Opus_TitleAbstract(); + $titleMainDeu = new TitleAbstract(); $titleMainDeu->setLanguage('deu'); $titleMainDeu->setType('main'); $titleMainDeu->setValue('TitleMainInDocumentLanguage'); - $titleMainEng = new Opus_TitleAbstract(); + $titleMainEng = new TitleAbstract(); $titleMainEng->setLanguage('eng'); $titleMainEng->setType('main'); $titleMainEng->setValue('TitleMainInOtherLanguage'); $doc->setTitleMain([$titleMainDeu, $titleMainEng]); - $titleSubDeu = new Opus_TitleAbstract(); + $titleSubDeu = new TitleAbstract(); $titleSubDeu->setLanguage('deu'); $titleSubDeu->setType('sub'); $titleSubDeu->setValue('TitleSubInDocumentLanguage'); - $titleSubEng = new Opus_TitleAbstract(); + $titleSubEng = new TitleAbstract(); $titleSubEng->setLanguage('eng'); $titleSubEng->setType('sub'); $titleSubEng->setValue('TitleSubInOtherLanguage'); $doc->setTitleSub([$titleSubDeu, $titleSubEng]); - $titleParent = new Opus_TitleAbstract(); + $titleParent = new TitleAbstract(); $titleParent->setLanguage('deu'); $titleParent->setType('parent'); $titleParent->setValue('TitleParentInDocumentLanguage'); $doc->setTitleParent([$titleParent]); - $abstractDeu = new Opus_TitleAbstract(); + $abstractDeu = new TitleAbstract(); $abstractDeu->setLanguage('deu'); $abstractDeu->setType('abstract'); $abstractDeu->setValue('TitleAbstractInDocumentLanguage'); - $abstractEng = new Opus_TitleAbstract(); + $abstractEng = new TitleAbstract(); $abstractEng->setLanguage('eng'); $abstractEng->setType('abstract'); $abstractEng->setValue('TitleAbstractInOtherLanguage'); $doc->setTitleAbstract([$abstractEng, $abstractDeu]); - $doc->setThesisPublisher([new Opus_DnbInstitute(2), new Opus_DnbInstitute(4)]); + $doc->setThesisPublisher([new DnbInstitute(2), new DnbInstitute(4)]); - $editor = new Opus_Person(); + $editor = new Person(); $editor->setFirstName('John'); $editor->setLastName('Doe'); $doc->addPersonEditor($editor); - $doc->addSeries(new Opus_Series(1))->setNumber(1); - $doc->addSeries(new Opus_Series(2))->setNumber(2); - $doc->addSeries(new Opus_Series(3))->setNumber(3); + $doc->addSeries(new Series(1))->setNumber(1); + $doc->addSeries(new Series(2))->setNumber(2); + $doc->addSeries(new Series(3))->setNumber(3); $docId = $doc->store(); @@ -2819,15 +2835,15 @@ public function testGenerationOfField856WithInvisibleInOaiFile() $doc->setServerState('published'); $doc->setPublisherPlace('publisherPlace'); - $f1 = new Opus_File(); + $f1 = new File(); $f1->setPathName('invisible-in-oai.pdf'); $f1->setVisibleInOai(false); $doc->addFile($f1); - $licencePresent = new Opus_Licence(1); + $licencePresent = new Licence(1); $doc->addLicence($licencePresent); - $licenceMissing = new Opus_Licence(2); + $licenceMissing = new Licence(2); $doc->addLicence($licenceMissing); $docId = $doc->store(); @@ -2853,20 +2869,20 @@ public function testGenerationOfField856With2VisibleInOaiFiles() $doc->setServerState('published'); $doc->setPublisherPlace('publisherPlace'); - $f1 = new Opus_File(); + $f1 = new File(); $f1->setPathName('visible-in-oai.pdf'); $f1->setVisibleInOai(true); $doc->addFile($f1); - $f2 = new Opus_File(); + $f2 = new File(); $f2->setPathName('visible-in-oai.txt'); $f2->setVisibleInOai(true); $doc->addFile($f2); - $licencePresent = new Opus_Licence(1); + $licencePresent = new Licence(1); $doc->addLicence($licencePresent); - $licenceMissing = new Opus_Licence(2); + $licenceMissing = new Licence(2); $doc->addLicence($licenceMissing); $docId = $doc->store(); @@ -3564,13 +3580,13 @@ public function testGenerationOfField773WithVolumeAndIsbn() /** * Helper function for adding title parent to given document. * - * @param $doc Opus_Document + * @param $doc Document * @param $language string * @param $value string */ private function addTitleParent($doc, $language, $value) { - $titleParent = new Opus_TitleAbstract(); + $titleParent = new TitleAbstract(); $titleParent->setType('parent'); $titleParent->setLanguage($language); $titleParent->setValue($value); @@ -3581,13 +3597,13 @@ private function addTitleParent($doc, $language, $value) /** * Helper function for adding identifier of given type to given document. * - * @param $doc Opus_Document + * @param $doc Document * @param $value string * @param $type string */ private function addIdentifier($doc, $value, $type) { - $identifier = new Opus_Identifier(); + $identifier = new Identifier(); $identifier->setType($type); $identifier->setValue($value); diff --git a/tests/modules/oai/models/ContainerTest.php b/tests/modules/oai/models/ContainerTest.php index 4c09d5fe03..0cf11e5825 100644 --- a/tests/modules/oai/models/ContainerTest.php +++ b/tests/modules/oai/models/ContainerTest.php @@ -1,4 +1,11 @@ workspacePath)) { throw new Exception("config key 'workspacePath' not defined in config file"); } @@ -55,11 +62,11 @@ public function setUp() public function tearDown() { if (! is_null($this->roleId)) { - $testRole = new Opus_UserRole($this->roleId); + $testRole = new UserRole($this->roleId); $testRole->delete(); } if (! is_null($this->userId)) { - $userAccount = new Opus_Account($this->userId); + $userAccount = new Account($this->userId); $userAccount->delete(); } parent::tearDown(); @@ -100,7 +107,7 @@ public function testConstructorWithUnknownDocId() public function testConstructorWithUnpublishedDocument() { - $r = Opus_UserRole::fetchByName('guest'); + $r = UserRole::fetchByName('guest'); $modules = $r->listAccessModules(); $addOaiModuleAccess = ! in_array('oai', $modules); @@ -110,9 +117,9 @@ public function testConstructorWithUnpublishedDocument() } // enable security - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->security = self::CONFIG_VALUE_TRUE; - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); @@ -153,7 +160,7 @@ public function testGetName() { $doc = $this->createTestDocument(); $doc->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setPathName('foo.pdf'); $file->setVisibleInOai(false); $doc->addFile($file); @@ -190,7 +197,7 @@ public function testDocumentWithNonExistentFile() { $doc = $this->createTestDocument(); $doc->setServerState('published'); - $file = new Opus_File(); + $file = new File(); $file->setPathName('test.pdf'); $file->setVisibleInOai(true); $doc->addFile($file); @@ -333,7 +340,7 @@ public function testAdminAccessToFileRegression3281() $docId = $doc->store(); $this->tryAccessForDocument($docId, true); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $doc->setServerState('unpublished'); $docId = $doc->store(); $this->tryAccessForDocument($docId, true); @@ -352,13 +359,13 @@ public function testAccessUserToFileRegression3281() $doc->setServerState('unpublished'); $unpublishedDocId = $doc->store(); - $testRole = new Opus_UserRole(); + $testRole = new UserRole(); $testRole->setName('test_access'); $testRole->appendAccessDocument($unpublishedDocId); $testRole->appendAccessDocument($publishedDocId); $this->roleId = $testRole->store(); - $userAccount = new Opus_Account(); + $userAccount = new Account(); $userAccount->setLogin('test_account')->setPassword('role_tester_user2'); $userAccount->setRole($testRole); $this->userId = $userAccount->store(); @@ -379,7 +386,7 @@ public function testGuestAccessToFileRegression3281() $docId = $doc->store(); $this->tryAccessForDocument($docId, true); - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $doc->setServerState('unpublished'); $docId = $doc->store(); $this->tryAccessForDocument($docId, false); @@ -414,7 +421,7 @@ public function testGetAccessibleFilesForEmbargoedDocument() $doc->setServerState('published'); // set embargo date to tomorrow - $date = new Opus_Date(); + $date = new Date(); $date->setDateTime(new DateTime('tomorrow')); $doc->setEmbargoDate($date); diff --git a/tests/modules/oai/models/DocumentListTest.php b/tests/modules/oai/models/DocumentListTest.php index 70b98c7291..cae073de0d 100644 --- a/tests/modules/oai/models/DocumentListTest.php +++ b/tests/modules/oai/models/DocumentListTest.php @@ -1,5 +1,4 @@ createTestDocument(); $docWithUrn->setServerState('published'); - $identifier = new Opus_Identifier(); + $identifier = new Identifier(); $identifier->setValue('urn_value1'); $identifier->setType('urn'); $docWithUrn->addIdentifier($identifier); @@ -77,7 +80,7 @@ public function testIntervalOAIPMHQueries() $doc->addFile($file); $this->docId = $doc->store(); - $doc = new Opus_Document($this->docId); + $doc = Document::get($this->docId); $serverDateModified = $doc->getServerDateModified(); $today = new DateTime(); @@ -135,7 +138,7 @@ public function testIntervalOAIPMHQueryWithoutTestDoc() $doc->setServerState('published'); $this->docId = $doc->store(); - $doc = new Opus_Document($this->docId); + $doc = Document::get($this->docId); $serverDateModified = $doc->getServerDateModified(); $today = new DateTime(); diff --git a/tests/modules/oai/models/XmlFactoryTest.php b/tests/modules/oai/models/XmlFactoryTest.php index 425a254244..5cc3f93dd0 100644 --- a/tests/modules/oai/models/XmlFactoryTest.php +++ b/tests/modules/oai/models/XmlFactoryTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + class Oai_Model_XmlFactoryTest extends ControllerTestCase { @@ -56,7 +58,7 @@ public function testGetAccessRights() $file->setVisibleInOai(1); $file->setVisibleInFrontdoor(1); $doc->addFile($file); - $doc = new Opus_Document($doc->store()); // store and get fresh object + $doc = Document::get($doc->store()); // store and get fresh object // document with file accessible in OAI and frontdoor $this->assertEquals('info:eu-repo/semantics/openAccess', $this->_xmlFactory->getAccessRights($doc)); @@ -78,7 +80,7 @@ public function testGetAccessRights() $file2->setVisibleInOai(1); $file2->setVisibleInFrontdoor(1); $doc->addFile($file2); - $doc = new Opus_Document($doc->store()); + $doc = Document::get($doc->store()); $this->assertCount(2, $doc->getFile()); diff --git a/tests/modules/publish/View/Helper/JavascriptMessagesTest.php b/tests/modules/publish/View/Helper/JavascriptMessagesTest.php index 46b9583715..b0dfa32797 100644 --- a/tests/modules/publish/View/Helper/JavascriptMessagesTest.php +++ b/tests/modules/publish/View/Helper/JavascriptMessagesTest.php @@ -46,7 +46,7 @@ public function setUp() $this->helper = new Publish_View_Helper_JavascriptMessages(); - $this->helper->setView(Zend_Registry::get('Opus_View')); + $this->helper->setView(\Zend_Registry::get('Opus_View')); } /** diff --git a/tests/modules/publish/controllers/DepositControllerTest.php b/tests/modules/publish/controllers/DepositControllerTest.php index 00aa12b66e..6b3a6b99ba 100644 --- a/tests/modules/publish/controllers/DepositControllerTest.php +++ b/tests/modules/publish/controllers/DepositControllerTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Class Publish_DepositControllerTest. * @@ -58,7 +60,7 @@ public function testdepositActionWithoutPost() */ public function testDepositActionWithValidPostAndBackButton() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $elemente = [ 1 => ['name' => 'PersonSubmitterFirstName_1', 'value' => 'Hans'], 2 => ['name' => 'PersonSubmitterLastName_1', 'value' => 'Hansmann'], @@ -90,7 +92,7 @@ public function testDepositActionWithValidPostAndBackButton() */ public function testDepositActionWithValidPostAndSendButton() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $elemente = [ 1 => ['name' => 'PersonSubmitterFirstName_1', 'value' => 'Hans', 'datatype' => 'Person', 'subfield' => '0'], 2 => ['name' => 'PersonSubmitterLastName_1', 'value' => 'Hansmann', 'datatype' => 'Person', 'subfield' => '1'], @@ -157,14 +159,14 @@ public function testDepositActionWithValidPostAndSendButton() $this->assertController('deposit'); $this->assertAction('deposit'); - $doc = new Opus_Document($session->documentId); + $doc = Document::get($session->documentId); $this->assertEquals('unpublished', $doc->getServerState()); $this->assertEquals('publish', $doc->getEnrichmentValue('opus.source')); } public function testConfirmAction() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->depositConfirmDocumentId = '712'; $this->dispatch('/publish/deposit/confirm'); $this->assertController('deposit'); @@ -188,7 +190,7 @@ public function testGetConfirmActionResultsInRedirect() */ public function testDepositActionWithAbortInPost() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $elemente = [ 1 => ['name' => 'PersonSubmitterFirstName_1', 'value' => 'Hans'], 2 => ['name' => 'PersonSubmitterLastName_1', 'value' => 'Hansmann'], @@ -227,7 +229,7 @@ public function testStoreExistingDocument() $doc->setServerState('published'); $doc->setType('preprint'); - $log = Zend_Registry::get('Zend_Log'); + $log = \Zend_Registry::get('Zend_Log'); $deposit = new Publish_Model_Deposit($log); $deposit->storeDocument($doc->store()); } diff --git a/tests/modules/publish/controllers/FormControllerTest.php b/tests/modules/publish/controllers/FormControllerTest.php index 3694015ab4..c5b4d24e2f 100644 --- a/tests/modules/publish/controllers/FormControllerTest.php +++ b/tests/modules/publish/controllers/FormControllerTest.php @@ -33,6 +33,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Class Publish_FormControllerTest. * @@ -117,7 +119,7 @@ public function testCheckActionWithValidPostAndAddButton() { $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'preprint'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -177,7 +179,7 @@ public function testCheckActionWithValidPostAndSendButton() { $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'preprint'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -209,7 +211,7 @@ public function testCheckActionWithValidPostAndSendButtonAndAllRequiredFields() { $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'preprint'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -263,12 +265,12 @@ public function testCheckActionWithValidPostAndSendButtonAndAllRequiredFields() */ public function testOPUSVIER1886WithBibliography() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->bibliographie = self::CONFIG_VALUE_TRUE; $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'demo'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -292,14 +294,14 @@ public function testOPUSVIER1886WithBibliography() public function testOPUSVIER1886WithBibliographyUnselected() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->bibliographie = self::CONFIG_VALUE_TRUE; $doc = $this->createTemporaryDoc(); $doc->setBelongsToBibliography(0); $doc->store(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'demo'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -323,14 +325,14 @@ public function testOPUSVIER1886WithBibliographyUnselected() public function testOPUSVIER1886WithBibliographySelected() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->bibliographie = self::CONFIG_VALUE_TRUE; $doc = $this->createTemporaryDoc(); $doc->setBelongsToBibliography(1); $doc->store(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'demo'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -357,12 +359,12 @@ public function testOPUSVIER1886WithBibliographySelected() */ public function testOPUSVIER1886WithoutBibliography() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->bibliographie = self::CONFIG_VALUE_FALSE; $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'demo'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -390,7 +392,7 @@ public function testOPUSVIER1886WithoutBibliography() public function testFormManipulationForBibliography() { $this->markTestIncomplete('testing multipart formdata not yet solved'); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->bibliographie = self::CONFIG_VALUE_FALSE; $this->request @@ -405,9 +407,9 @@ public function testFormManipulationForBibliography() 'send' => 'Weiter zum nächsten Schritt', ]); $this->dispatch('/publish/form/upload'); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); - $doc = new Opus_Document($session->documentId); + $doc = Document::get($session->documentId); $belongsToBibliography = $doc->getBelongsToBibliography(); $doc->deletePermanent(); @@ -417,7 +419,7 @@ public function testFormManipulationForBibliography() } /** - * @return Opus_Document + * @return Document */ private function createTemporaryDoc() { @@ -450,29 +452,33 @@ public function testShowFileNoticeOnSecondFormPageIfFileUploadIsEnabled() { $this->fileNoticeOnSecondFormPage(self::CONFIG_VALUE_TRUE); - $this->assertContains('

      Alle Felder (Testdokumenttyp)

      ', $this->getResponse()->getBody()); - $this->assertContains('Sie haben folgende Datei(en) hochgeladen:', $this->getResponse()->getBody()); - $this->assertContains('Es wurden keine Dateien hochgeladen.', $this->getResponse()->getBody()); + $output = $this->getResponse()->getBody(); + + $this->assertContains('

      Alle Felder (Testdokumenttyp)

      ', $output); + $this->assertContains('Sie haben folgende Datei(en) hochgeladen:', $output); + $this->assertContains('Es wurden keine Dateien hochgeladen.', $output); } public function testShowFileNoticeOnThirdFormPageIfFileUploadIsEnabled() { $this->fileNoticeOnThirdFormPage(self::CONFIG_VALUE_TRUE); + $output = $this->getResponse()->getBody(); + $this->assertResponseCode(200); - $this->assertContains('Bitte überprüfen Sie Ihre Eingaben', $this->getResponse()->getBody()); - $this->assertContains('Sie haben folgende Datei(en) hochgeladen:', $this->getResponse()->getBody()); - $this->assertContains('Es wurden keine Dateien hochgeladen.', $this->getResponse()->getBody()); + $this->assertContains('Bitte überprüfen Sie Ihre Eingaben', $output); + $this->assertContains('Sie haben folgende Datei(en) hochgeladen:', $output); + $this->assertContains('Es wurden keine Dateien hochgeladen.', $output); } private function fileNoticeOnThirdFormPage($value) { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->enable_upload = $value; $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'demo'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -491,12 +497,12 @@ private function fileNoticeOnThirdFormPage($value) private function fileNoticeOnSecondFormPage($value) { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->enable_upload = $value; $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -525,7 +531,7 @@ private function addTemporaryTestDocument($session, $documentType) */ public function testCheckActionWithAddButton() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $this->addTemporaryTestDocument($session, 'preprint'); $data = [ 'PersonSubmitterFirstName_1' => '', @@ -576,7 +582,7 @@ public function testCheckActionWithAddButton() */ public function testCheckActionWithDeleteButton() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $this->addTemporaryTestDocument($session, 'preprint'); $session->additionalFields['TitleMain'] = '2'; @@ -631,7 +637,7 @@ public function testCheckActionWithDeleteButton() */ public function testCheckActionWithBrowseDownButton() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $this->addTemporaryTestDocument($session, 'preprint'); $session->additionalFields['Institute'] = '1'; $session->additionalFields['collId0Institute_1'] = '1'; @@ -687,7 +693,7 @@ public function testCheckActionWithBrowseDownButton() */ public function testCheckActionWithBrowseUpButton() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $this->addTemporaryTestDocument($session, 'preprint'); $session->additionalFields['Institute'] = '1'; $session->additionalFields['collId0Institute_1'] = '1'; @@ -744,7 +750,7 @@ public function testCheckActionWithBrowseUpButton() */ public function testCheckActionWithMissingButton() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $this->addTemporaryTestDocument($session, 'preprint'); $session->additionalFields['PersonSubmitter'] = '1'; $session->additionalFields['TitleMain'] = '1'; @@ -812,7 +818,7 @@ public function testManipulatePostMissingTitleMainLanguage() { $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'preprint'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -845,7 +851,7 @@ public function testManipulatePostMissingTitleAbstractLanguage() { $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'preprint'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -879,7 +885,7 @@ public function testManipulatePostMissingTitleParentLanguage() { $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -909,7 +915,7 @@ public function testManipulatePostMissingTitleSubLanguage() { $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -939,7 +945,7 @@ public function testManipulatePostMissingTitleAdditionalLanguage() { $doc = $this->createTemporaryDoc(); - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; $session->documentId = $doc->getId(); $session->fulltext = '0'; @@ -967,7 +973,7 @@ public function testManipulatePostMissingTitleAdditionalLanguage() public function testBarfooTemplateIsRenderedForDoctypeFoobar() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'foobar'; $doc = $this->createTemporaryDoc(); $session->documentId = $doc->getId(); @@ -986,7 +992,7 @@ public function testBarfooTemplateIsRenderedForDoctypeFoobar() public function testApplicationErrorForDoctypeBarbaz() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'barbaz'; $doc = $this->createTemporaryDoc(); $session->documentId = $doc->getId(); @@ -1004,7 +1010,7 @@ public function testApplicationErrorForDoctypeBarbaz() public function testApplicationErrorForDoctypeBazbar() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'bazbar'; $doc = $this->createTemporaryDoc(); $session->documentId = $doc->getId(); diff --git a/tests/modules/publish/controllers/IndexControllerTest.php b/tests/modules/publish/controllers/IndexControllerTest.php index 0b93441551..920475d93f 100644 --- a/tests/modules/publish/controllers/IndexControllerTest.php +++ b/tests/modules/publish/controllers/IndexControllerTest.php @@ -58,7 +58,7 @@ public function testIndexAction() public function testShowFileUpload() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->enable_upload = self::CONFIG_VALUE_TRUE; $this->dispatch('/publish'); @@ -78,7 +78,7 @@ public function testShowFileUpload() public function testDoNotShowFileUpload() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->enable_upload = self::CONFIG_VALUE_FALSE; $this->dispatch('/publish'); @@ -99,7 +99,7 @@ public function testDoNotShowFileUpload() public function testShowBibliographyCheckbox() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->bibliographie = self::CONFIG_VALUE_TRUE; $this->dispatch('/publish'); @@ -117,7 +117,7 @@ public function testShowBibliographyCheckbox() public function testDoNotShowBibliographyCheckbox() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->bibliographie = self::CONFIG_VALUE_FALSE; $this->dispatch('/publish'); @@ -139,7 +139,7 @@ public function testDoNotShowBibliographyCheckbox() public function testDocumentTypeSelectBoxIsSortedAlphabetically() { // manipulate list of available document types in application configuration - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $include = $config->documentTypes->include; $exclude = $config->documentTypes->exclude; $config->documentTypes->include = 'all, article, workingpaper, demodemo'; diff --git a/tests/modules/publish/forms/PublishingFirstTest.php b/tests/modules/publish/forms/PublishingFirstTest.php index f337468eae..60476af560 100644 --- a/tests/modules/publish/forms/PublishingFirstTest.php +++ b/tests/modules/publish/forms/PublishingFirstTest.php @@ -44,12 +44,12 @@ public function testConstructorWithEmptyView() public function testIsValidMethodWithMissingDocumentType() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->require_upload = self::CONFIG_VALUE_FALSE; $config->form->first->show_rights_checkbox = self::CONFIG_VALUE_FALSE; $config->form->first->bibliographie = self::CONFIG_VALUE_FALSE; - $form = new Publish_Form_PublishingFirst(new Zend_View()); + $form = new Publish_Form_PublishingFirst(new \Zend_View()); $data = [ 'documentType' => '' ]; @@ -60,12 +60,12 @@ public function testIsValidMethodWithMissingDocumentType() public function testIsValidMethodWithMissingRightsCheckbox() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->form->first->require_upload = self::CONFIG_VALUE_FALSE; $config->form->first->show_rights_checkbox = self::CONFIG_VALUE_TRUE; $config->form->first->bibliographie = self::CONFIG_VALUE_FALSE; - $form = new Publish_Form_PublishingFirst(new Zend_View()); + $form = new Publish_Form_PublishingFirst(new \Zend_View()); $data = [ 'documentType' => 'preprint', 'rights' => '0' diff --git a/tests/modules/publish/forms/PublishingSecondTest.php b/tests/modules/publish/forms/PublishingSecondTest.php index a954c3f3b3..84fac9df99 100644 --- a/tests/modules/publish/forms/PublishingSecondTest.php +++ b/tests/modules/publish/forms/PublishingSecondTest.php @@ -40,8 +40,8 @@ class Publish_Form_PublishingSecondTest extends ControllerTestCase public function setUp() { - $writer = new Zend_Log_Writer_Null; - $this->_logger = new Zend_Log($writer); + $writer = new \Zend_Log_Writer_Null; + $this->_logger = new \Zend_Log($writer); parent::setUp(); } @@ -59,7 +59,7 @@ public function testConstructorWithoutDocTypeInSession() */ public function testConstructorWithDocTypeInSession() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'preprint'; $form = new Publish_Form_PublishingSecond($this->_logger); $this->assertNotNull($form->getElement('back')); @@ -71,9 +71,9 @@ public function testConstructorWithDocTypeInSession() */ public function testIsValidWithInvalidData() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ @@ -90,9 +90,9 @@ public function testIsValidWithInvalidData() */ public function testIsValidWithValidData() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'demo'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ @@ -109,9 +109,9 @@ public function testIsValidWithValidData() */ public function testPrepareCheckMethodWithDemoType() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'demo'; $form = new Publish_Form_PublishingSecond($this->_logger); @@ -128,7 +128,7 @@ public function testPrepareCheckMethodWithDemoType() public function testExternalElementLegalNotices() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; $session->additionalFields = []; diff --git a/tests/modules/publish/models/DepositTest.php b/tests/modules/publish/models/DepositTest.php index 7e64f01a83..2252720f8d 100644 --- a/tests/modules/publish/models/DepositTest.php +++ b/tests/modules/publish/models/DepositTest.php @@ -1,5 +1,4 @@ setServerState('published'); $documentId = $document->store(); - $log = Zend_Registry::get('Zend_Log'); + $log = \Zend_Registry::get('Zend_Log'); $deposit = new Publish_Model_Deposit($log); $deposit->storeDocument($documentId); } @@ -74,7 +76,7 @@ public function testValidDocumentData() $document->setServerState('temporary'); $docId = $document->store(); - $this->enrichmentKey = new Opus_EnrichmentKey(); + $this->enrichmentKey = new EnrichmentKey(); $this->enrichmentKey->setName('Foo2Title'); $this->enrichmentKey->store(); @@ -137,7 +139,7 @@ public function testValidDocumentData() 'Foo2Title' => ['value' => 'title as enrichment', 'datatype' => 'Enrichment', 'subfield' => '0'], ]; - $log = Zend_Registry::get('Zend_Log'); + $log = \Zend_Registry::get('Zend_Log'); $dep = new Publish_Model_Deposit($log); $dep->storeDocument($docId, null, $data); @@ -226,7 +228,7 @@ public function testCastStringToDate() $date = $deposit->castStringToOpusDate('2017/03/12'); - $this->assertInstanceOf('Opus_Date', $date); + $this->assertInstanceOf('Opus\Date', $date); $this->assertEquals('2017', $date->getYear()); @@ -245,7 +247,7 @@ public function testCastStringToDateGerman() $date = $deposit->castStringToOpusDate('12.03.2017'); - $this->assertInstanceOf('Opus_Date', $date); + $this->assertInstanceOf('Opus\Date', $date); $this->assertEquals('2017', $date->getYear()); diff --git a/tests/modules/publish/models/DocumenttypeParserTest.php b/tests/modules/publish/models/DocumenttypeParserTest.php index 87e7e8fe04..d8a9327cd1 100644 --- a/tests/modules/publish/models/DocumenttypeParserTest.php +++ b/tests/modules/publish/models/DocumenttypeParserTest.php @@ -1,5 +1,4 @@ _logger = new Zend_Log($writer); + $writer = new \Zend_Log_Writer_Null; + $this->_logger = new \Zend_Log($writer); parent::setUp(); } @@ -50,14 +50,14 @@ public function setUp() */ public function testConstructorWithWrongDom() { - $dom = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('irgendwas'); + $dom = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('irgendwas'); $model = new Publish_Model_DocumenttypeParser($dom, null); $this->assertNull($model->dom); } public function testConstructorWithCorrectDom() { - $dom = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('preprint'); + $dom = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('preprint'); $model = new Publish_Model_DocumenttypeParser($dom, null); $this->assertInstanceOf('DOMDocument', $model->dom); } @@ -67,9 +67,9 @@ public function testConstructorWithCorrectDom() */ public function testConstructorWithCorrectDomAndWrongForm() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'irgendwas'; - $dom = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('preprint'); + $dom = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('preprint'); $form = new Publish_Form_PublishingSecond($this->_logger); $model = new Publish_Model_DocumenttypeParser($dom, $form); $this->assertInstanceOf('DOMDocument', $model->dom); @@ -77,9 +77,9 @@ public function testConstructorWithCorrectDomAndWrongForm() public function testConstructorWithCorrectDomAndCorrectForm() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'preprint'; - $dom = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('preprint'); + $dom = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('preprint'); $form = new Publish_Form_PublishingSecond($this->_logger); $model = new Publish_Model_DocumenttypeParser($dom, $form); $this->assertInstanceOf('DOMDocument', $model->dom); @@ -92,11 +92,11 @@ public function testConstructorWithCorrectDomAndCorrectForm() public function testInccorectFieldName() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; /* @var $dom DomDocument */ - $dom = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('all'); + $dom = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('all'); $this->assertInstanceOf('DOMDocument', $dom); foreach ($dom->getElementsByTagname('documenttype') as $rootNode) { @@ -124,11 +124,11 @@ public function testInccorectFieldName() public function testIncorrectEnrichmentKey() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; /* @var $dom DomDocument */ - $dom = Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('all'); + $dom = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes')->getDocument('all'); $this->assertInstanceOf('DOMDocument', $dom); foreach ($dom->getElementsByTagname('documenttype') as $rootNode) { diff --git a/tests/modules/publish/models/ExtendedValidationTest.php b/tests/modules/publish/models/ExtendedValidationTest.php index 5e4cd4b656..8a8ced1784 100644 --- a/tests/modules/publish/models/ExtendedValidationTest.php +++ b/tests/modules/publish/models/ExtendedValidationTest.php @@ -40,14 +40,14 @@ class Publish_Model_ExtendedValidationTest extends ControllerTestCase public function setUp() { - $writer = new Zend_Log_Writer_Null; - $this->_logger = new Zend_Log($writer); + $writer = new \Zend_Log_Writer_Null; + $this->_logger = new \Zend_Log($writer); parent::setUp(); } public function testPersonsFirstNamesWithInvalidData() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ @@ -71,7 +71,7 @@ public function testPersonsFirstNamesWithInvalidData() public function testPersonsEmailWithInvalidData() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ @@ -95,9 +95,9 @@ public function testPersonsEmailWithInvalidData() public function testPersonsEmailNotificationWithValidData() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ @@ -121,9 +121,9 @@ public function testPersonsEmailNotificationWithValidData() public function testPersonsEmailNotificationWithInvalidData() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ @@ -150,9 +150,9 @@ public function testPersonsEmailNotificationWithInvalidData() */ public function testMainTitleWithWrongDocLanguage() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ @@ -179,9 +179,9 @@ public function testMainTitleWithWrongDocLanguage() */ public function testEmptyMainTitleLanguage() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ @@ -211,9 +211,9 @@ public function testSeveralMainTitleLanguages() { $this->markTestSkipped('Method getExtendedForm removed from Form class: moved to FormController class as manipulateSession'); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; $session->additionalFields = []; $session->additionalFields['TitleMain'] = '4'; @@ -250,9 +250,9 @@ public function testSeveralMainTitleLanguages() */ public function testSeveralTitleTypeLanguages() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ @@ -285,9 +285,9 @@ public function testSeveralTitleTypeLanguages() */ public function testSeriesNumberValidationWithUnknownSeries() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ @@ -311,9 +311,9 @@ public function testSeriesNumberValidationWithUnknownSeries() */ public function testSeriesNumberValidationWithMissingSeriesField() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->documentTypes->include = 'all'; - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; $form = new Publish_Form_PublishingSecond($this->_logger); $data = [ diff --git a/tests/modules/publish/models/FormElementTest.php b/tests/modules/publish/models/FormElementTest.php index 6be0d8f6bb..bd091a5d67 100644 --- a/tests/modules/publish/models/FormElementTest.php +++ b/tests/modules/publish/models/FormElementTest.php @@ -40,14 +40,14 @@ class Publish_Model_FormElementTest extends ControllerTestCase public function setUp() { - $writer = new Zend_Log_Writer_Null; - $this->_logger = new Zend_Log($writer); + $writer = new \Zend_Log_Writer_Null; + $this->_logger = new \Zend_Log($writer); parent::setUp(); } public function testUnrequiredFirstNames() { - $session = new Zend_Session_Namespace('Publish'); + $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; $form = new Publish_Form_PublishingSecond($this->_logger); diff --git a/tests/modules/publish/models/LoggedUserTest.php b/tests/modules/publish/models/LoggedUserTest.php index d4cc9e4482..57de31bded 100644 --- a/tests/modules/publish/models/LoggedUserTest.php +++ b/tests/modules/publish/models/LoggedUserTest.php @@ -29,6 +29,9 @@ * @copyright Copyright (c) 2008-2019, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Account; + class Publish_Model_LoggedUserTest extends ControllerTestCase { @@ -73,7 +76,7 @@ public function testCreatePersonValidUser() $this->setZendAuthIdentity($accountName); - $account = new Opus_Account(); + $account = new Account(); $account->setLogin($accountName) ->setPassword($accountPassword) ->store(); @@ -92,9 +95,9 @@ public function testCreatePersonValidUser() */ private function setZendAuthIdentity($identity) { - $namespace = Zend_Auth_Storage_Session::NAMESPACE_DEFAULT; - $member = Zend_Auth_Storage_Session::MEMBER_DEFAULT; - $session = new Zend_Session_Namespace($namespace); + $namespace = \Zend_Auth_Storage_Session::NAMESPACE_DEFAULT; + $member = \Zend_Auth_Storage_Session::MEMBER_DEFAULT; + $session = new \Zend_Session_Namespace($namespace); $session->{$member} = $identity; } } diff --git a/tests/modules/publish/models/ValidationTest.php b/tests/modules/publish/models/ValidationTest.php index 48bafb50e7..f5c388a245 100644 --- a/tests/modules/publish/models/ValidationTest.php +++ b/tests/modules/publish/models/ValidationTest.php @@ -31,6 +31,11 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Collection; +use Opus\CollectionRole; +use Opus\Licence; +use Opus\Series; + class Publish_Model_ValidationTest extends ControllerTestCase { @@ -41,7 +46,7 @@ class Publish_Model_ValidationTest extends ControllerTestCase public function setUp() { parent::setUp(); - $this->session = new Zend_Session_Namespace(); + $this->session = new \Zend_Session_Namespace(); } public function testValidationWithInvalidDatatype() @@ -212,7 +217,7 @@ public function testSelectOptionsForLicence() */ public function testSortOrderOfSelectOptionForLicence() { - $licences = Opus_Licence::getAll(); + $licences = Licence::getAll(); $activeLicences = []; @@ -267,7 +272,7 @@ public function testInvisibleCollectionRoleDDC() { $val = new Publish_Model_Validation('Collection', $this->session, 'ddc'); - $collectionRole = Opus_CollectionRole::fetchByName($val->collectionRole); + $collectionRole = CollectionRole::fetchByName($val->collectionRole); $visibleFlag = $collectionRole->getVisible(); $collectionRole->setVisible(0); $collectionRole->store(); @@ -283,7 +288,7 @@ public function testVisibleCollectionRoleDDC() { $val = new Publish_Model_Validation('Collection', $this->session, 'ddc'); - $collectionRole = Opus_CollectionRole::fetchByName($val->collectionRole); + $collectionRole = CollectionRole::fetchByName($val->collectionRole); $visibleFlag = $collectionRole->getVisible(); $collectionRole->setVisible(1); $collectionRole->store(); @@ -332,7 +337,7 @@ public function testSortOrderOfSeries() $val = new Publish_Model_Validation('Series', $this->session); $values = $val->selectOptions(); - $series = Opus_Series::getAllSortedBySortKey(); + $series = Series::getAllSortedBySortKey(); $visibleSeries = []; @@ -356,7 +361,7 @@ public function testSortOrderOfSeries() */ public function testCollectionFieldVisiblePublish() { - $collectionRole = new Opus_CollectionRole(); + $collectionRole = new CollectionRole(); $collectionRole->setName("test"); $collectionRole->setOaiName("test"); $collectionRole->setDisplayBrowsing("Name"); @@ -368,7 +373,7 @@ public function testCollectionFieldVisiblePublish() $rootCollection = $collectionRole->addRootCollection(); $rootCollection->store(); - $invisibleCollection = new Opus_Collection(); + $invisibleCollection = new Collection(); $invisibleCollection->setName("invisible collection"); $invisibleCollection->setNumber("123"); $invisibleCollection->setVisible(true); @@ -376,7 +381,7 @@ public function testCollectionFieldVisiblePublish() $rootCollection->addFirstChild($invisibleCollection); $invisibleCollection->store(); - $visibleCollection = new Opus_Collection(); + $visibleCollection = new Collection(); $visibleCollection->setName("visible collection"); $visibleCollection->setNumber("987"); $visibleCollection->setVisiblePublish(true); @@ -384,7 +389,7 @@ public function testCollectionFieldVisiblePublish() $rootCollection->addLastChild($visibleCollection); $visibleId = $visibleCollection->store(); - $mixedVisibilityCollection = new Opus_Collection(); + $mixedVisibilityCollection = new Collection(); $mixedVisibilityCollection->setName("mixed visibility"); $mixedVisibilityCollection->setNumber("456"); $mixedVisibilityCollection->setVisiblePublish(true); @@ -408,7 +413,7 @@ public function testCollectionFieldVisiblePublish() */ public function testRootCollectionFieldVisiblePublish() { - $collectionRole = new Opus_CollectionRole(); + $collectionRole = new CollectionRole(); $collectionRole->setName("test"); $collectionRole->setOaiName("test"); $collectionRole->setDisplayBrowsing("Name"); @@ -423,7 +428,7 @@ public function testRootCollectionFieldVisiblePublish() $rootCollection->setVisiblePublish(false); $rootCollection->store(); - $visibleCollection = new Opus_Collection(); + $visibleCollection = new Collection(); $visibleCollection->setName("visible collection"); $visibleCollection->setNumber("123"); $visibleCollection->setVisible(true); @@ -431,7 +436,7 @@ public function testRootCollectionFieldVisiblePublish() $rootCollection->addFirstChild($visibleCollection); $visibleCollection->store(); - $invisibleCollection = new Opus_Collection(); + $invisibleCollection = new Collection(); $invisibleCollection->setName("collection to invisible root collection"); $invisibleCollection->setNumber("123"); $invisibleCollection->setVisible(true); @@ -439,7 +444,7 @@ public function testRootCollectionFieldVisiblePublish() $rootCollection->addFirstChild($invisibleCollection); $invisibleCollection->store(); - $childCollection = new Opus_Collection(); + $childCollection = new Collection(); $childCollection->setName("collection child"); $childCollection->setNumber("123"); $childCollection->setVisible(true); diff --git a/tests/modules/review/controllers/IndexControllerTest.php b/tests/modules/review/controllers/IndexControllerTest.php index 493dbd925e..8dcec8b54c 100644 --- a/tests/modules/review/controllers/IndexControllerTest.php +++ b/tests/modules/review/controllers/IndexControllerTest.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; + /** * Basic unit tests for class Review_IndexController. * @@ -52,7 +54,7 @@ public function setUp() $document->setEnrichment([]); $this->documentId = $document->store(); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals(0, count($document->getPersonReferee())); $this->assertEquals(0, count($document->getEnrichment())); } @@ -107,7 +109,7 @@ public function testIndexActionClearButtonWithOneDocumentGoesToClear() $this->assertContains('sureyes', $response->getBody()); $this->assertContains('sureno', $response->getBody()); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals('unpublished', $document->getServerState()); } @@ -129,7 +131,7 @@ public function testClearActionWithOneDocumentUnconfirmed() $this->assertContains('sureyes', $response->getBody()); $this->assertContains('sureno', $response->getBody()); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals('unpublished', $document->getServerState()); } @@ -152,7 +154,7 @@ public function testClearActionWithOneDocumentCanceled() $this->assertNotContains('sureyes', $response->getBody()); $this->assertNotContains('sureno', $response->getBody()); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals('unpublished', $document->getServerState()); } @@ -175,7 +177,7 @@ public function testClearActionWithOneDocumentConfirmed() $this->assertNotContains('sureyes', $response->getBody()); $this->assertNotContains('sureno', $response->getBody()); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals('published', $document->getServerState()); } @@ -197,7 +199,7 @@ public function testRejectActionWithOneDocumentUnconfirmed() $this->assertContains('sureyes', $response->getBody()); $this->assertContains('sureno', $response->getBody()); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals('unpublished', $document->getServerState()); } @@ -220,7 +222,7 @@ public function testRejectActionWithOneDocumentCanceled() $this->assertNotContains('sureyes', $response->getBody()); $this->assertNotContains('sureno', $response->getBody()); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals('unpublished', $document->getServerState()); } @@ -243,7 +245,7 @@ public function testRejectActionWithOneDocumentConfirmed() $this->assertNotContains('sureyes', $response->getBody()); $this->assertNotContains('sureno', $response->getBody()); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals('deleted', $document->getServerState()); } } diff --git a/tests/modules/review/models/ClearDocumentsHelperTest.php b/tests/modules/review/models/ClearDocumentsHelperTest.php index e838559906..050cfa93cf 100644 --- a/tests/modules/review/models/ClearDocumentsHelperTest.php +++ b/tests/modules/review/models/ClearDocumentsHelperTest.php @@ -30,6 +30,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Document; +use Opus\Person; + class Review_Model_ClearDocumentsHelperTest extends ControllerTestCase { @@ -48,11 +51,11 @@ public function setUp() $document->setEnrichment([]); $this->documentId = $document->store(); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals(0, count($document->getPersonReferee())); $this->assertEquals(0, count($document->getEnrichment())); - $person = new Opus_Person(); + $person = new Person(); $person->setFirstName('John'); $person->setLastName('Doe'); $this->person = $person; @@ -63,7 +66,7 @@ public function testClearDocument() $helper = new Review_Model_ClearDocumentsHelper(); $helper->clear([$this->documentId], 23, $this->person); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals('published', $document->getServerState()); $this->assertEquals(1, count($document->getPersonReferee())); @@ -82,7 +85,7 @@ public function testClearDocumentWithFile() $filepath = $path . DIRECTORY_SEPARATOR . "foobar.pdf"; touch($filepath); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $document->addFile() ->setTempFile($filepath) ->setPathName('foobar.pdf') @@ -92,7 +95,7 @@ public function testClearDocumentWithFile() $helper = new Review_Model_ClearDocumentsHelper(); $helper->clear([$this->documentId], 23, $this->person); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals('published', $document->getServerState()); $this->assertEquals(1, count($document->getPersonReferee())); @@ -106,7 +109,7 @@ public function testRejectDocument() $helper = new Review_Model_ClearDocumentsHelper(); $helper->reject([$this->documentId], 23, $this->person); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertNotEquals('published', $document->getServerState()); $this->assertEquals(1, count($document->getPersonReferee())); @@ -119,7 +122,7 @@ public function testClearInvalidDocument() { $helper = new Review_Model_ClearDocumentsHelper(); - $this->setExpectedException('Opus_Model_NotFoundException'); + $this->setExpectedException('Opus\Model\NotFoundException'); $helper->clear([$this->documentId + 100000], 23); } @@ -127,7 +130,7 @@ public function testRejectInvalidDocument() { $helper = new Review_Model_ClearDocumentsHelper(); - $this->setExpectedException('Opus_Model_NotFoundException'); + $this->setExpectedException('Opus\Model\NotFoundException'); $helper->reject([$this->documentId + 100000], 23); } @@ -136,7 +139,7 @@ public function testClearDocumentWoPerson() $helper = new Review_Model_ClearDocumentsHelper(); $helper->clear([$this->documentId], 23); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertEquals('published', $document->getServerState()); $this->assertEquals(0, count($document->getPersonReferee())); @@ -150,7 +153,7 @@ public function testRejectDocumentWoPerson() $helper = new Review_Model_ClearDocumentsHelper(); $helper->reject([$this->documentId], 23); - $document = new Opus_Document($this->documentId); + $document = Document::get($this->documentId); $this->assertNotEquals('published', $document->getServerState()); $this->assertEquals(0, count($document->getPersonReferee())); diff --git a/tests/modules/rss/controllers/IndexControllerTest.php b/tests/modules/rss/controllers/IndexControllerTest.php index 578eba2096..227aee3d33 100644 --- a/tests/modules/rss/controllers/IndexControllerTest.php +++ b/tests/modules/rss/controllers/IndexControllerTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Title; + /** * Class Rss_IndexControllerTest * @@ -62,11 +64,11 @@ public function testUnavailableSolrServerReturns503() $this->requireSolrConfig(); // manipulate solr configuration - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $host = $config->searchengine->index->host; $port = $config->searchengine->index->port; $config->searchengine->index->app = 'solr/corethatdoesnotexist'; - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/rss/index/index/searchtype/all'); $body = $this->getResponse()->getBody(); @@ -91,7 +93,7 @@ public function testSolrIndexIsNotUpToDate() $doc1 = $this->createTestDocument(); $doc1->setServerState('published'); $doc1->setLanguage('eng'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('test document for OPUSVIER-1726'); $title->setLanguage('eng'); $doc1->setTitleMain($title); @@ -100,8 +102,8 @@ public function testSolrIndexIsNotUpToDate() $doc1->store(); $docId1 = $doc1->getId(); - $date = new Zend_Date($doc1->getServerDatePublished()); - $dateValue1 = $date->get(Zend_Date::RFC_2822); + $date = new \Zend_Date($doc1->getServerDatePublished()); + $dateValue1 = $date->get(\Zend_Date::RFC_2822); $indexer = Opus\Search\Service::selectIndexingService(null, 'solr'); @@ -115,15 +117,15 @@ public function testSolrIndexIsNotUpToDate() $doc2 = $this->createTestDocument(); $doc2->setServerState('published'); $doc2->setLanguage('eng'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('another test document for OPUSVIER-1726'); $title->setLanguage('eng'); $doc2->setTitleMain($title); $doc2->store(); $docId2 = $doc2->getId(); - $date = new Zend_Date($doc2->getServerDatePublished()); - $dateValue2 = $date->get(Zend_Date::RFC_2822); + $date = new \Zend_Date($doc2->getServerDatePublished()); + $dateValue2 = $date->get(\Zend_Date::RFC_2822); $this->dispatch('/rss/index/index/searchtype/all'); @@ -183,7 +185,7 @@ public function testOutputWithEmptySearchResult() */ public function testRssLink() { - Zend_Controller_Front::getInstance()->setBaseUrl('opus4dev'); + \Zend_Controller_Front::getInstance()->setBaseUrl('opus4dev'); $this->dispatch('/rss/index/index'); $this->assertXpathContentContains('//link', 'http://opus4dev/frontdoor/index/index/docId/147'); $this->assertXpathContentContains('//link', 'http://opus4dev/frontdoor/index/index/docId/150'); diff --git a/tests/modules/rss/models/FeedTest.php b/tests/modules/rss/models/FeedTest.php index f35308cd0d..9e5f8be17c 100644 --- a/tests/modules/rss/models/FeedTest.php +++ b/tests/modules/rss/models/FeedTest.php @@ -44,22 +44,22 @@ public function setUp() { parent::setUp(); - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $this->_model = new Rss_Model_Feed($view); } public function testGetTitle() { - $view = Zend_Registry::get('Opus_View'); - Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); + $view = \Zend_Registry::get('Opus_View'); + \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); $model = new Rss_Model_Feed($view); $this->assertEquals('http:///opus4test', $model->getTitle()); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); - $config->merge(new Zend_Config([ + $config->merge(new \Zend_Config([ 'rss' => ['default' => ['feedTitle' => 'OPUS 4 Test']] ])); $this->assertEquals('OPUS 4 Test', $model->getTitle()); @@ -67,7 +67,7 @@ public function testGetTitle() public function testGetTitleWithName() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'rss' => ['default' => ['feedTitle' => '%1$s']] ])); $this->assertEquals('OPUS 4', $this->_model->getTitle()); @@ -75,11 +75,11 @@ public function testGetTitleWithName() public function testGetTitleWithFullUrl() { - $view = Zend_Registry::get('Opus_View'); - Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); + $view = \Zend_Registry::get('Opus_View'); + \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); $model = new Rss_Model_Feed($view); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'rss' => ['default' => ['feedTitle' => '%4$s']] ])); $this->assertEquals('http:///opus4test', $this->_model->getTitle()); @@ -87,11 +87,11 @@ public function testGetTitleWithFullUrl() public function testGetTitleWithBaseUrl() { - $view = Zend_Registry::get('Opus_View'); - Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); + $view = \Zend_Registry::get('Opus_View'); + \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); $model = new Rss_Model_Feed($view); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'rss' => ['default' => ['feedTitle' => '%3$s']] ])); $this->assertEquals('opus4test', $model->getTitle()); @@ -99,12 +99,12 @@ public function testGetTitleWithBaseUrl() public function testGetTitleWithHost() { - $view = Zend_Registry::get('Opus_View'); - Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); + $view = \Zend_Registry::get('Opus_View'); + \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); $view->getHelper('ServerUrl')->setHost('testhost'); $model = new Rss_Model_Feed($view); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'rss' => ['default' => ['feedTitle' => '%2$s']] ])); $this->assertEquals('testhost', $model->getTitle()); @@ -114,7 +114,7 @@ public function testGetDescription() { $this->assertEquals('OPUS documents', $this->_model->getDescription()); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'rss' => ['default' => ['feedDescription' => 'Test description.']] ])); diff --git a/tests/modules/setup/controllers/LanguageControllerTest.php b/tests/modules/setup/controllers/LanguageControllerTest.php index 991c8b85d8..b122b216fa 100644 --- a/tests/modules/setup/controllers/LanguageControllerTest.php +++ b/tests/modules/setup/controllers/LanguageControllerTest.php @@ -44,7 +44,7 @@ class Setup_LanguageControllerTest extends ControllerTestCase public function tearDown() { - $database = new Opus_Translate_Dao(); + $database = $this->getTranslationManager(); $database->removeAll(); parent::tearDown(); } @@ -55,8 +55,8 @@ public function tearDown() public function testMissingConfigMessageIsDisplayedRed() { $this->markTestSkipped('Needs to be updated for no modules allowed.'); - $config = Zend_Registry::get('Zend_Config'); - $config->merge(new Zend_Config(['setup' => ['translation' => ['modules' => ['allowed' => null]]]])); + $config = \Zend_Registry::get('Zend_Config'); + $config->merge(new \Zend_Config(['setup' => ['translation' => ['modules' => ['allowed' => null]]]])); $this->getRequest()->setPost(['Anzeigen' => 'Anzeigen', 'search' => 'test', 'sort' => 'unit']); $this->dispatch('/setup/language/show'); @@ -94,7 +94,7 @@ public function testStoringUpdatedTranslationForKeyWithDashes() $this->dispatch("/setup/language/edit/key/$key"); - $database = new Opus_Translate_Dao(); + $database = $this->getTranslationManager(); $storedTranslations = $database->getTranslation($key); @@ -202,7 +202,7 @@ public function testIndexActionStateAdded() public function testIndexActionScopeKey() { - $dao = new Opus_Translate_Dao(); + $dao = $this->getTranslationManager(); $key1 = 'testentry'; $key2 = 'customkey2'; @@ -226,7 +226,7 @@ public function testIndexActionScopeKey() public function testIndexActionScopeTranslation() { - $dao = new Opus_Translate_Dao(); + $dao = $this->getTranslationManager(); $key1 = 'testentry'; $key2 = 'customkey2'; @@ -372,7 +372,7 @@ public function testAddTranslationCancel() public function testResetTranslationShowForm() { - $database = new Opus_Translate_Dao(); + $database = $this->getTranslationManager(); $database->setTranslation('default_add', [ 'en' => 'AddEdited', @@ -394,7 +394,7 @@ public function testResetTranslationShowForm() public function testResetTranslationConfirmNo() { - $database = new Opus_Translate_Dao(); + $database = $this->getTranslationManager(); $database->setTranslation('default_add', [ 'en' => 'AddTest', @@ -423,7 +423,7 @@ public function testResetTranslationConfirmNo() public function testResetTranslationConfirmYes() { - $database = new Opus_Translate_Dao(); + $database = $this->getTranslationManager(); $database->setTranslation('default_add', [ 'en' => 'AddTest', @@ -473,7 +473,7 @@ public function testDeleteTranslationShowForm() public function testDeleteTranslationConfirmYes() { - $dao = new Opus_Translate_Dao(); + $dao = $this->getTranslationManager(); $key = 'customtestkey'; @@ -499,7 +499,7 @@ public function testDeleteTranslationConfirmYes() public function testDeleteTranslationConfirmNo() { - $dao = new Opus_Translate_Dao(); + $dao = $this->getTranslationManager(); $key = 'customtestkey'; @@ -540,7 +540,7 @@ public function testDeleteAllShowForm() public function testDeleteAllConfirmYes() { - $database = new Opus_Translate_Dao(); + $database = $this->getTranslationManager(); $database->setTranslation('default_add', [ 'en' => 'CreateTest', @@ -572,7 +572,7 @@ public function testDeleteAllConfirmYes() public function testDeleteAllConfirmYesMatchingEntriesOnly() { - $database = new Opus_Translate_Dao(); + $database = $this->getTranslationManager(); $database->setTranslation('default_add', [ 'en' => 'CreateTest', @@ -603,7 +603,7 @@ public function testDeleteAllConfirmYesMatchingEntriesOnly() public function testDeleteAllConfirmNo() { - $dao = new Opus_Translate_Dao(); + $dao = $this->getTranslationManager(); $key = 'customtestkey'; @@ -691,7 +691,7 @@ public function testEditInvalidExistingKey() public function testChangeNameOfAddedKey() { - $database = new Opus_Translate_Dao(); + $database = $this->getTranslationManager(); $oldKey = 'customkey'; $newKey = 'renamedkey'; @@ -727,7 +727,7 @@ public function testChangeNameOfAddedKey() public function testChangeModuleOfAddedKey() { - $dao = new Opus_Translate_Dao(); + $dao = $this->getTranslationManager(); $key = 'customtestkey'; @@ -790,7 +790,7 @@ public function testExportShowPage() public function testExportFiltered() { - $dao = new Opus_Translate_Dao(); + $dao = $this->getTranslationManager(); $dao->setTranslation('customtestkey', [ 'en' => 'English', @@ -822,7 +822,7 @@ public function testExportFilteredWithUnmodified() public function testExportAll() { - $dao = new Opus_Translate_Dao(); + $dao = $this->getTranslationManager(); $dao->setTranslation('testkey1', [ 'en' => 'Test key 1', @@ -849,7 +849,7 @@ public function testExportAll() public function testExportAllWithUnmodified() { - $dao = new Opus_Translate_Dao(); + $dao = $this->getTranslationManager(); $dao->setTranslation('testkey1', [ 'en' => 'Test key 1', @@ -885,11 +885,11 @@ public function testImportFile() } /** - * @return Opus_Database_Dao + * @return \Opus\Translate\Dao * TODO really use translation manager (be independent of database) */ protected function getTranslationManager() { - return new Opus_Translate_Dao(); + return new \Opus\Translate\Dao(); } } diff --git a/tests/modules/setup/forms/ImprintPageTest.php b/tests/modules/setup/forms/ImprintPageTest.php index 8a8c19135c..954019ac3b 100644 --- a/tests/modules/setup/forms/ImprintPageTest.php +++ b/tests/modules/setup/forms/ImprintPageTest.php @@ -40,7 +40,7 @@ class Setup_Form_ImprintPageTest extends ControllerTestCase public function testInit() { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); $form = new Setup_Form_ImprintPage(); diff --git a/tests/modules/setup/forms/TranslationTest.php b/tests/modules/setup/forms/TranslationTest.php index 95dd1f0728..7883721fb8 100644 --- a/tests/modules/setup/forms/TranslationTest.php +++ b/tests/modules/setup/forms/TranslationTest.php @@ -40,7 +40,7 @@ class Setup_Form_TranslationTest extends ControllerTestCase public function tearDown() { - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->removeAll(); parent::tearDown(); // TODO: Change the autogenerated stub @@ -198,13 +198,13 @@ public function testIsValidDuplicateKey() $key = 'testkey835'; - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->setTranslation($key, [ 'en' => 'English', 'de' => 'Deutsch' ], 'admin'); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $translate->loadDatabase(true); $this->assertFalse($form->isValid([ @@ -242,7 +242,7 @@ public function testPopulateFromKeyAddedKey() $key = 'testkey123'; - $database = new Opus_Translate_Dao(); + $database = new \Opus\Translate\Dao(); $database->setTranslation($key, [ 'en' => 'English', 'de' => 'Deutsch' @@ -337,7 +337,7 @@ public function testUpdateModuleOfAddedKey() { $form = $this->getForm(); - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $key = 'newkey1'; @@ -365,7 +365,7 @@ public function testUpdateNameOfAddedKey() { $form = $this->getForm(); - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $oldKey = 'oldkey1'; $newKey = 'newkey2'; @@ -411,7 +411,7 @@ public function testUpdateNameOfAddedKey() public function testUpdateManuallyToOriginal() { $manager = new Application_Translate_TranslationManager(); - $dao = new Opus_Translate_Dao(); + $dao = new \Opus\Translate\Dao(); $key = 'default_add'; diff --git a/tests/modules/setup/forms/TranslationValuesTest.php b/tests/modules/setup/forms/TranslationValuesTest.php index cee4b77b82..2b52670a6d 100644 --- a/tests/modules/setup/forms/TranslationValuesTest.php +++ b/tests/modules/setup/forms/TranslationValuesTest.php @@ -47,7 +47,7 @@ public function testInit() $elements = $form->getElements(); - $this->assertEquals(count($languages), count($elements)); + $this->assertSameSize($languages, $elements); } public function testPopulate() diff --git a/tests/modules/setup/forms/Validate/TranslationKeyFormatTest.php b/tests/modules/setup/forms/Validate/TranslationKeyFormatTest.php index 7f48294ff6..660d28784c 100644 --- a/tests/modules/setup/forms/Validate/TranslationKeyFormatTest.php +++ b/tests/modules/setup/forms/Validate/TranslationKeyFormatTest.php @@ -64,7 +64,7 @@ public function testIsValid($value, $result) public function testMessagesTranslated() { $validator = new Setup_Form_Validate_TranslationKeyFormat(); - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $messageTemplates = $validator->getMessageTemplates(); $key = $messageTemplates[$validator::NOT_MATCH]; $this->assertTrue($translate->isTranslated($key)); diff --git a/tests/modules/solrsearch/controllers/BrowseControllerTest.php b/tests/modules/solrsearch/controllers/BrowseControllerTest.php index 72153ac7c2..6b3e6d33c3 100644 --- a/tests/modules/solrsearch/controllers/BrowseControllerTest.php +++ b/tests/modules/solrsearch/controllers/BrowseControllerTest.php @@ -33,6 +33,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Series; + /** * Class Solrsearch_BrowseControllerTest. * @@ -95,7 +97,7 @@ public function testSeriesActionWithOneVisibleSeriesWithoutAnyPublishedDocument( $d->setServerState('unpublished'); $d->store(); - $s = new Opus_Series(7); + $s = new Series(7); $s->setVisible('1'); $s->store(); @@ -118,7 +120,7 @@ public function testSeriesActionWithOneVisibleSeriesWithOnePublishedDocument() $d->setServerState('published'); $d->store(); - $s = new Opus_Series(7); + $s = new Series(7); $s->setVisible('1'); $s->store(); @@ -130,7 +132,7 @@ public function testSeriesActionWithOneVisibleSeriesWithOnePublishedDocument() $this->restoreSeriesVisibility($visibilities); $this->assertContains('/solrsearch/index/search/searchtype/series/id/7', $this->getResponse()->getBody()); - foreach (Opus_Series::getAll() as $series) { + foreach (Series::getAll() as $series) { if ($series->getId() != 7) { $this->assertNotContains('/solrsearch/index/search/searchtype/series/id/' . $series->getId(), $this->getResponse()->getBody()); } @@ -141,7 +143,7 @@ public function testSeriesActionWithOneVisibleSeriesWithOnePublishedDocument() private function setAllSeriesToUnvisible() { $visibilities = []; - foreach (Opus_Series::getAll() as $seriesItem) { + foreach (Series::getAll() as $seriesItem) { $visibilities[$seriesItem->getId()] = $seriesItem->getVisible(); $seriesItem->setVisible(0); $seriesItem->store(); @@ -151,7 +153,7 @@ private function setAllSeriesToUnvisible() private function restoreSeriesVisibility($visibilities) { - foreach (Opus_Series::getAll() as $seriesItem) { + foreach (Series::getAll() as $seriesItem) { $seriesItem->setVisible($visibilities[$seriesItem->getId()]); $seriesItem->store(); } @@ -175,7 +177,7 @@ public function testSeriesActionRespectsSeriesSortOrderAfterManipulation() $sortOrders = $this->getSortOrders(); // reverse ordering of series - foreach (Opus_Series::getAll() as $seriesItem) { + foreach (Series::getAll() as $seriesItem) { $seriesItem->setSortOrder(10 - intval($sortOrders[$seriesItem->getId()])); $seriesItem->store(); } @@ -197,11 +199,11 @@ public function testSeriesActionRespectsSeriesSortOrderIfItCoincidesBetweenTwoSe { $sortOrders = $this->getSortOrders(); - $s = new Opus_Series(2); + $s = new Series(2); $s->setSortOrder(6); $s->store(); - $s = new Opus_Series(6); + $s = new Series(6); $s->setSortOrder(0); $s->store(); @@ -221,7 +223,7 @@ public function testSeriesActionRespectsSeriesSortOrderIfItCoincidesBetweenTwoSe private function getSortOrders() { $sortOrders = []; - foreach (Opus_Series::getAll() as $seriesItem) { + foreach (Series::getAll() as $seriesItem) { $sortOrders[$seriesItem->getId()] = $seriesItem->getSortOrder(); } return $sortOrders; @@ -229,7 +231,7 @@ private function getSortOrders() private function setSortOrders($sortOrders) { - foreach (Opus_Series::getAll() as $seriesItem) { + foreach (Series::getAll() as $seriesItem) { $seriesItem->setSortOrder($sortOrders[$seriesItem->getId()]); $seriesItem->store(); } diff --git a/tests/modules/solrsearch/controllers/IndexControllerTest.php b/tests/modules/solrsearch/controllers/IndexControllerTest.php index 04bdb3b3ca..d4faedc2ee 100644 --- a/tests/modules/solrsearch/controllers/IndexControllerTest.php +++ b/tests/modules/solrsearch/controllers/IndexControllerTest.php @@ -34,6 +34,15 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; +use Opus\Date; +use Opus\DocumentFinder; +use Opus\Identifier; +use Opus\Person; +use Opus\Security\Realm; +use Opus\Subject; +use Opus\Title; + /** * Class Solrsearch_IndexControllerTest. * @@ -326,7 +335,7 @@ public function testPaginationBarContainsOverallNumberOfHitsInDoctypeBrowsing() */ public function testLastPageUrlEqualsNextPageUrlDocTypeArticle() { - $docFinder = new Opus_DocumentFinder(); + $docFinder = new DocumentFinder(); $docFinder->setType('article')->setServerState('published'); // check if test requirements are met @@ -652,12 +661,12 @@ public function testUnavailableSolrServerReturns503() $this->requireSolrConfig(); // manipulate solr configuration - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $host = $config->searchengine->solr->default->service->default->endpoint->localhost->host; $port = $config->searchengine->solr->default->service->default->endpoint->localhost->port; $config->searchengine->solr->default->service->default->endpoint->localhost->path = '/solr/corethatdoesnotexist'; - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/solrsearch/browse/doctypes'); @@ -678,12 +687,12 @@ public function testCatchAllSearchConsidersIdentifiers() $doc = $this->createTestDocument(); $doc->setServerState('published'); $doc->setLanguage('eng'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('test document for OPUSVIER-2475'); $title->setLanguage('eng'); $doc->setTitleMain($title); - $id = new Opus_Identifier(); + $id = new Identifier(); $field = $id->getField('Type'); $identifierTypes = array_keys($field->getDefault()); @@ -733,12 +742,12 @@ public function testCatchAllSearchConsidersAllPersons($lastName, $role, $contain $doc = $this->createTestDocument(); $doc->setServerState('published'); $doc->setLanguage('eng'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('test document for OPUSVIER-2484'); $title->setLanguage('eng'); $doc->setTitleMain($title); - $person = new Opus_Person(); + $person = new Person(); $person->setLastName($lastName); $personLink = $doc->addPerson($person); $personLink->setRole($role); @@ -759,7 +768,7 @@ public function testCatchAllSearchConsidersAllPersons($lastName, $role, $contain public function testFacetLimitWithDefaultSetting() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $numOfSubjects = 20; $this->addSampleDocWithMultipleSubjects($numOfSubjects); @@ -784,7 +793,7 @@ public function testFacetLimitWithDefaultSetting() public function testFacetLimitWithGlobalSetting() { // manipulate application configuration - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->search->facet->default->limit = '5'; $numOfSubjects = 10; @@ -803,22 +812,22 @@ public function testFacetLimitWithGlobalSetting() public function testFacetLimitWithLocalSettingForSubjectFacet() { // manipulate application configuration - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $limit = null; $oldConfig = null; if (isset($config->searchengine->solr->facetlimit->subject)) { $limit = $config->searchengine->solr->facetlimit->subject; } else { - $config = new Zend_Config([ + $config = new \Zend_Config([ 'searchengine' => [ 'solr' => [ 'facetlimit' => [ 'subject' => '5']]]], true); - $oldConfig = Zend_Registry::get('Zend_Config'); + $oldConfig = \Zend_Registry::get('Zend_Config'); // Include the above made configuration changes in the application configuration. - $config->merge(Zend_Registry::get('Zend_Config')); + $config->merge(\Zend_Registry::get('Zend_Config')); } - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $numOfSubjects = 10; $this->addSampleDocWithMultipleSubjects($numOfSubjects); @@ -826,13 +835,13 @@ public function testFacetLimitWithLocalSettingForSubjectFacet() $this->dispatch('/solrsearch/index/search/searchtype/simple/query/facetlimittestwithsubjects-opusvier2610'); // undo configuration manipulation - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (! is_null($oldConfig)) { $config = $oldConfig; } else { $config->searchengine->solr->facetlimit->subject = $limit; } - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); for ($index = 0; $index < 5; $index++) { $this->assertContains('/solrsearch/index/search/searchtype/simple/query/facetlimittestwithsubjects-opusvier2610/start/0/rows/10/subjectfq/subject0' . $index, $this->getResponse()->getBody()); @@ -858,13 +867,13 @@ private function addSampleDocWithMultipleSubjects($numOfSubjects = 0) $doc = $this->createTestDocument(); $doc->setServerState('published'); $doc->setLanguage('eng'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('facetlimittestwithsubjects-opusvier2610'); $title->setLanguage('eng'); $doc->addTitleMain($title); for ($index = 0; $index < $numOfSubjects; $index++) { - $subject = new Opus_Subject(); + $subject = new Subject(); if ($index < 10) { $subject->setValue('subject' . '0' . $index); } else { @@ -882,27 +891,27 @@ private function addSampleDocWithMultipleSubjects($numOfSubjects = 0) public function testFacetSortLexicographicallyForInstituteFacet() { // manipulate application configuration - $oldConfig = Zend_Registry::get('Zend_Config'); + $oldConfig = \Zend_Registry::get('Zend_Config'); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (isset($config->searchengine->solr->sortcrit->institute)) { $config->searchengine->solr->sortcrit->institute = 'lexi'; } else { - $config = new Zend_Config([ + $config = new \Zend_Config([ 'searchengine' => [ 'solr' => [ 'sortcrit' => [ 'institute' => 'lexi']]]], true); - $oldConfig = Zend_Registry::get('Zend_Config'); + $oldConfig = \Zend_Registry::get('Zend_Config'); // Include the above made configuration changes in the application configuration. - $config->merge(Zend_Registry::get('Zend_Config')); + $config->merge(\Zend_Registry::get('Zend_Config')); } - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/solrsearch/index/search/searchtype/all'); // undo configuration manipulation - Zend_Registry::set('Zend_Config', $oldConfig); + \Zend_Registry::set('Zend_Config', $oldConfig); $searchStrings = [ 'Abwasserwirtschaft und Gewässerschutz B-2', @@ -936,7 +945,7 @@ public function testFacetSortLexicographicallyForInstituteFacet() public function testFacetSortForYearInverted() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'search' => ['facet' => ['year' => [ 'sort' => 'lexi', 'indexField' => 'published_year_inverted' @@ -1027,7 +1036,7 @@ public function testSortOrderOfDocumentsInBrowsing() { $olderDoc = $this->createTestDocument(); $olderDoc->setServerState('published'); - $date = new Opus_Date(); + $date = new Date(); $date->setNow(); $date->setDay($date->getDay() - 1); $olderDoc->setServerDatePublished($date); @@ -1063,13 +1072,13 @@ public function testSortOrderOfDocumentsInBrowsingWithSortfield() $olderDoc = $this->createTestDocument(); $olderDoc->setServerState('published'); $olderDoc->setLanguage('eng'); - $date = new Opus_Date(); + $date = new Date(); $date->setNow(); $date->setDay($date->getDay() - 1); $olderDoc->setServerDatePublished($date); $olderDoc->setType('article'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('zzzOlderDoc'); // 'zzz' to show the document at the first page $title->setLanguage('eng'); $olderDoc->addTitleMain($title); @@ -1079,7 +1088,7 @@ public function testSortOrderOfDocumentsInBrowsingWithSortfield() $newerDoc->setServerState('published'); $newerDoc->setLanguage('eng'); $newerDoc->setType('article'); - $title = new Opus_Title(); + $title = new Title(); $title->setValue('zzzNewerDoc'); $title->setLanguage('eng'); $newerDoc->addTitleMain($title); @@ -1142,7 +1151,7 @@ public function testAuthorFacetClosed() public function testFacetExtenderWithVariousConfigFacetLimits() { $this->useEnglish(); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'search' => ['facet' => [ 'author_facet' => ['limit' => '3'], 'year' => ['limit' => '15'] @@ -1248,7 +1257,7 @@ public function testXmlExportButtonPresentForAdminInLatestSearch() $this->enableSecurity(); $this->loginUser('admin', 'adminadmin'); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'export' => ['stylesheet' => ['search' => 'example']], 'searchengine' => ['solr' => ['numberOfDefaultSearchResults' => '10']] ])); @@ -1263,17 +1272,17 @@ public function testXmlExportButtonPresentForAdminInLatestSearch() public function testXmlExportButtonNotPresentForGuest() { $this->enableSecurity(); - $config = Zend_Registry::get('Zend_Config'); - $config->merge(new Zend_Config(['export' => ['stylesheet' => ['search' => 'example']]])); + $config = \Zend_Registry::get('Zend_Config'); + $config->merge(new \Zend_Config(['export' => ['stylesheet' => ['search' => 'example']]])); $this->dispatch('/solrsearch/index/search/searchtype/all'); - $this->assertFalse(Opus_Security_Realm::getInstance()->checkModule('export')); + $this->assertFalse(Realm::getInstance()->checkModule('export')); $this->assertNotQuery('//a[@href="/solrsearch/index/search/searchtype/all/export/xml/stylesheet/example"]'); } public function testDisableEmptyCollectionsTrue() { - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config(['browsing' => ['disableEmptyCollections' => self::CONFIG_VALUE_TRUE]]) + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config(['browsing' => ['disableEmptyCollections' => self::CONFIG_VALUE_TRUE]]) ); $this->dispatch('/solrsearch/index/search/searchtype/collection/id/2'); @@ -1287,8 +1296,8 @@ public function testDisableEmptyCollectionsTrue() public function testDisableEmptyCollectionsFalse() { - Zend_Registry::get('Zend_Config')->merge( - new Zend_Config(['browsing' => ['disableEmptyCollections' => self::CONFIG_VALUE_FALSE]]) + \Zend_Registry::get('Zend_Config')->merge( + new \Zend_Config(['browsing' => ['disableEmptyCollections' => self::CONFIG_VALUE_FALSE]]) ); $this->dispatch('/solrsearch/index/search/searchtype/collection/id/2'); @@ -1306,7 +1315,7 @@ public function testDisableEmptyCollectionsFalse() public function testEnableHideEmptyCollectionsForCollectionRoleMSC() { - $collRole = Opus_CollectionRole::fetchByName('msc'); + $collRole = CollectionRole::fetchByName('msc'); $hideEmptyCollections = $collRole->getHideEmptyCollections(); $collRole->setHideEmptyCollections(1); $collRole->store(); @@ -1322,7 +1331,7 @@ public function testEnableHideEmptyCollectionsForCollectionRoleMSC() public function testDisableHideEmptyCollectionsForCollectionRoleMSC() { - $collRole = Opus_CollectionRole::fetchByName('msc'); + $collRole = CollectionRole::fetchByName('msc'); $hideEmptyCollections = $collRole->getHideEmptyCollections(); $collRole->setHideEmptyCollections(0); $collRole->store(); diff --git a/tests/modules/solrsearch/models/CollectionListTest.php b/tests/modules/solrsearch/models/CollectionListTest.php index f52d70e858..d662e5c4e2 100644 --- a/tests/modules/solrsearch/models/CollectionListTest.php +++ b/tests/modules/solrsearch/models/CollectionListTest.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; +use Opus\Model\ModelException; + class Solrsearch_Model_CollectionListTest extends ControllerTestCase { @@ -225,12 +228,12 @@ public function testCollectionRoleTitle() /** * Teste das Ausblenden von leeren Sammlungen am Beispiel der MSC. * - * @throws Opus_Model_Exception + * @throws ModelException * @throws Solrsearch_Model_Exception */ public function testGetChildrenWithoutEmptyCollections() { - $collRole = Opus_CollectionRole::fetchByName('msc'); + $collRole = CollectionRole::fetchByName('msc'); $hideEmptyCollections = $collRole->getHideEmptyCollections(); $collRole->setHideEmptyCollections(1); $collRole->store(); @@ -251,7 +254,7 @@ public function testGetChildrenWithoutEmptyCollections() private function getCollectionRole($collectionRoleId) { - $collectionRole = new Opus_CollectionRole($collectionRoleId); + $collectionRole = new CollectionRole($collectionRoleId); $this->assertNotNull($collectionRole); $this->assertEquals('1', $collectionRole->getVisible()); $this->assertEquals('1', $collectionRole->getVisibleBrowsingStart()); diff --git a/tests/modules/solrsearch/models/CollectionRolesTest.php b/tests/modules/solrsearch/models/CollectionRolesTest.php index 63ae989e0a..4e4c9d12a4 100644 --- a/tests/modules/solrsearch/models/CollectionRolesTest.php +++ b/tests/modules/solrsearch/models/CollectionRolesTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\CollectionRole; + class Solrsearch_Model_CollectionRolesTest extends ControllerTestCase { @@ -50,7 +52,7 @@ public function testHasVisibleChildrenForEmptyCollectionRole() $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); $method = $class->getMethod('hasVisibleChildren'); $method->setAccessible(true); - $hasChildren = $method->invokeArgs($collectionRoles, [new Opus_CollectionRole(17)]); + $hasChildren = $method->invokeArgs($collectionRoles, [new CollectionRole(17)]); $this->assertFalse($hasChildren); } @@ -62,7 +64,7 @@ public function testHasVisibleChildrenForNonEmptyCollectionRole() $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); $method = $class->getMethod('hasVisibleChildren'); $method->setAccessible(true); - $hasChildren = $method->invokeArgs($collectionRoles, [new Opus_CollectionRole(7)]); + $hasChildren = $method->invokeArgs($collectionRoles, [new CollectionRole(7)]); $this->assertTrue($hasChildren); } @@ -74,7 +76,7 @@ public function testHasPublishedDocsForEmptyCollectionRole() $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); $method = $class->getMethod('hasPublishedDocs'); $method->setAccessible(true); - $hasChildren = $method->invokeArgs($collectionRoles, [new Opus_CollectionRole(17)]); + $hasChildren = $method->invokeArgs($collectionRoles, [new CollectionRole(17)]); $this->assertFalse($hasChildren); } @@ -86,7 +88,7 @@ public function testHasPublishedDocsForNonEmptyCollectionRoleWithoutPublishedDoc $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); $method = $class->getMethod('hasPublishedDocs'); $method->setAccessible(true); - $hasChildren = $method->invokeArgs($collectionRoles, [new Opus_CollectionRole(7)]); + $hasChildren = $method->invokeArgs($collectionRoles, [new CollectionRole(7)]); $this->assertFalse($hasChildren); } @@ -98,7 +100,7 @@ public function testHasPublishedDocsForNonEmptyCollectionRoleWithPublishedDocs() $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); $method = $class->getMethod('hasPublishedDocs'); $method->setAccessible(true); - $hasChildren = $method->invokeArgs($collectionRoles, [new Opus_CollectionRole(5)]); + $hasChildren = $method->invokeArgs($collectionRoles, [new CollectionRole(5)]); $this->assertTrue($hasChildren); } diff --git a/tests/modules/solrsearch/models/ExceptionTest.php b/tests/modules/solrsearch/models/ExceptionTest.php index 59895d3de5..2fb19a6573 100644 --- a/tests/modules/solrsearch/models/ExceptionTest.php +++ b/tests/modules/solrsearch/models/ExceptionTest.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Solrsearch_Model_ExceptionTest extends ControllerTestCase diff --git a/tests/modules/solrsearch/models/FacetMenuTest.php b/tests/modules/solrsearch/models/FacetMenuTest.php index e8b39c4ae7..43ff79ea04 100644 --- a/tests/modules/solrsearch/models/FacetMenuTest.php +++ b/tests/modules/solrsearch/models/FacetMenuTest.php @@ -44,8 +44,8 @@ class Solrsearch_Model_FacetMenuTest extends ControllerTestCase */ public function testGetFacetLimitsFromConfig() { - $config = Zend_Registry::get('Zend_Config'); - $config->merge(new Zend_Config(['searchengine' => + $config = \Zend_Registry::get('Zend_Config'); + $config->merge(new \Zend_Config(['searchengine' => ['solr' => ['facetlimit' => [ @@ -72,18 +72,18 @@ public function testGetFacetLimitsFromConfig() */ public function testGetFacetLimitsFromConfigWithYearInverted() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (isset($config->searchengine->solr->facets)) { $config->searchengine->solr->facets = 'year,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute'; } else { - $testConfig = new Zend_Config([ + $testConfig = new \Zend_Config([ 'searchengine' => [ 'solr' => [ 'facets' => 'year,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute']]], true); // Include the above made configuration changes in the application configuration. $testConfig->merge($config); } - $config->merge(new Zend_Config(['searchengine' => + $config->merge(new \Zend_Config(['searchengine' => ['solr' => ['facetlimit' => [ @@ -130,11 +130,11 @@ public function testBuildFacetArray() public function testBuildFacetArrayWithYearInverted() { $model = new Solrsearch_Model_FacetMenu(); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (isset($config->searchengine->solr->facets)) { $config->searchengine->solr->facets = 'year_inverted,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute'; } else { - $testConfig = new Zend_Config([ + $testConfig = new \Zend_Config([ 'searchengine' => [ 'solr' => [ 'facets' => 'year_inverted,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute']]], true); diff --git a/tests/modules/solrsearch/models/PaginationUtilTest.php b/tests/modules/solrsearch/models/PaginationUtilTest.php index d9fb56bcea..e7af6a9aba 100644 --- a/tests/modules/solrsearch/models/PaginationUtilTest.php +++ b/tests/modules/solrsearch/models/PaginationUtilTest.php @@ -29,7 +29,6 @@ * @author Julian Heise * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class Solrsearch_Model_PaginationUtilTest extends ControllerTestCase diff --git a/tests/modules/solrsearch/models/SearchTest.php b/tests/modules/solrsearch/models/SearchTest.php index 5a9dc7cac2..97c2329aa6 100644 --- a/tests/modules/solrsearch/models/SearchTest.php +++ b/tests/modules/solrsearch/models/SearchTest.php @@ -124,7 +124,7 @@ public function testCreateSimpleSearchUrlParamsWithCustomRows() { $request = $this->getRequest(); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'searchengine' => ['solr' => ['numberOfDefaultSearchResults' => '25']] ])); diff --git a/tests/modules/solrsearch/models/SeriesTest.php b/tests/modules/solrsearch/models/SeriesTest.php index 9062b5c996..f56c0f3254 100644 --- a/tests/modules/solrsearch/models/SeriesTest.php +++ b/tests/modules/solrsearch/models/SeriesTest.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Series; + class Solrsearch_Model_SeriesTest extends ControllerTestCase { @@ -65,7 +67,7 @@ public function testConstructWithNonEmptyVisibleSeries() { $series = new Solrsearch_Model_Series(1); $this->assertNotNull($series); - $seriesFramework = new Opus_Series(1); + $seriesFramework = new Series(1); $this->assertEquals($seriesFramework->getId(), $series->getId()); $this->assertEquals($seriesFramework->getTitle(), $series->getTitle()); $this->assertEquals($seriesFramework->getInfobox(), $series->getInfobox()); diff --git a/tests/modules/solrsearch/models/SeriesUtilTest.php b/tests/modules/solrsearch/models/SeriesUtilTest.php index 50d9b01ea4..5a1aabd57f 100644 --- a/tests/modules/solrsearch/models/SeriesUtilTest.php +++ b/tests/modules/solrsearch/models/SeriesUtilTest.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Series; + class Solrsearch_Model_SeriesUtilTest extends ControllerTestCase { @@ -44,7 +46,7 @@ public function setUp() { parent::setUp(); - foreach (Opus_Series::getAll() as $seriesItem) { + foreach (Series::getAll() as $seriesItem) { $this->visibilities[$seriesItem->getId()] = $seriesItem->getVisible(); } @@ -95,7 +97,7 @@ public function testGetVisibleSeriesSortedBySortKey() public function testGetVisibleSeriesSortedAlphabetically() { - Zend_Registry::get('Zend_Config')->merge(new Zend_Config([ + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ 'browsing' => [ 'series' => [ 'sortByTitle' => self::CONFIG_VALUE_TRUE @@ -116,7 +118,7 @@ public function testGetVisibleSeriesSortedAlphabetically() private function setAllSeriesToUnvisible() { - foreach (Opus_Series::getAll() as $seriesItem) { + foreach (Series::getAll() as $seriesItem) { $seriesItem->setVisible(0); $seriesItem->store(); } @@ -124,7 +126,7 @@ private function setAllSeriesToUnvisible() private function restoreVisiblitySettings() { - foreach (Opus_Series::getAll() as $seriesItem) { + foreach (Series::getAll() as $seriesItem) { $seriesItem->setVisible($this->visibilities[$seriesItem->getId()]); $seriesItem->store(); } diff --git a/tests/modules/solrsearch/models/search/BasicTest.php b/tests/modules/solrsearch/models/search/BasicTest.php index eb8ada45bf..21039aff23 100644 --- a/tests/modules/solrsearch/models/search/BasicTest.php +++ b/tests/modules/solrsearch/models/search/BasicTest.php @@ -58,7 +58,7 @@ public function testCreateQueryBuilderInputFromRequest() */ public function testGetRowsFromConfig() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $oldParamRows = $config->searchengine->solr->numberOfDefaultSearchResults; $config->searchengine->solr->numberOfDefaultSearchResults = '1337'; diff --git a/tests/modules/sword/controllers/DepositControllerErrorCasesTest.php b/tests/modules/sword/controllers/DepositControllerErrorCasesTest.php index 461020cf94..4ce202359e 100644 --- a/tests/modules/sword/controllers/DepositControllerErrorCasesTest.php +++ b/tests/modules/sword/controllers/DepositControllerErrorCasesTest.php @@ -1,5 +1,4 @@ getRequest()->setRawBody('some content'); // remove enrichment key opus.import.user - $enrichmentKey = new Opus_EnrichmentKey(Application_Import_AdditionalEnrichments::OPUS_IMPORT_USER); + $enrichmentKey = new EnrichmentKey(Application_Import_AdditionalEnrichments::OPUS_IMPORT_USER); $enrichmentKey->delete(); $this->dispatch('/sword/deposit'); - $enrichmentKey = new Opus_EnrichmentKey(); + $enrichmentKey = new EnrichmentKey(); $enrichmentKey->setName(Application_Import_AdditionalEnrichments::OPUS_IMPORT_USER); $enrichmentKey->store(); @@ -199,7 +203,7 @@ public function testTarArchiveProvokeUrnCollision() private function addDocWithUrn() { - $doc = new Opus_Document(); + $doc = Document::new(); $doc->addIdentifier()->setType('urn')->setValue('colliding-urn'); $doc->store(); return $doc; diff --git a/tests/modules/sword/controllers/DepositControllerMultipleDocsTest.php b/tests/modules/sword/controllers/DepositControllerMultipleDocsTest.php index 780a83bb8f..bf62e87325 100644 --- a/tests/modules/sword/controllers/DepositControllerMultipleDocsTest.php +++ b/tests/modules/sword/controllers/DepositControllerMultipleDocsTest.php @@ -1,5 +1,4 @@ * @copyright Copyright (c) 2016-2019 * @license http://www.gnu.org/licenses/gpl.html General Public License - * + */ + +use Opus\Document; + +/** * @covers Sword_DepositController */ class Sword_DepositControllerTest extends ControllerTestCase @@ -181,7 +184,7 @@ private function checkMinimalDoc($doc, $language = 'deu', $docType = 'book', $ti } /** - * @param Opus_Document $doc + * @param Document $doc * @throws Exception */ private function checkAllFieldsImport($doc) @@ -400,15 +403,15 @@ private function checkTitleFields($titles, $titleType) /** * - * @param type $fileName - * @param type $contentType - * @param type $abstractExist - * @param type $deleteDoc - * @param type $deleteCollection - * @param type $numOfEnrichments - * @param type $numOfCollections - * @param type $serverState - * @return Opus_Document + * @param string $fileName + * @param string $contentType + * @param bool $abstractExist + * @param bool $deleteDoc + * @param bool $deleteCollection + * @param int $numOfEnrichments + * @param int $numOfCollections + * @param string $serverState + * @return Document */ private function depositSuccessful( $fileName, diff --git a/tests/modules/sword/controllers/ServicedocumentControllerTest.php b/tests/modules/sword/controllers/ServicedocumentControllerTest.php index 7097081037..a4571622bd 100644 --- a/tests/modules/sword/controllers/ServicedocumentControllerTest.php +++ b/tests/modules/sword/controllers/ServicedocumentControllerTest.php @@ -1,5 +1,4 @@ assertEquals(2, $root->length); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $this->testHelper->assertNodeProperties(0, $root, 'atom:title', $config->name); $collectionNode = $root->item(1); diff --git a/tests/rebuild-database.php b/tests/rebuild-database.php index 7330cfef22..b4d6cd3e4a 100644 --- a/tests/rebuild-database.php +++ b/tests/rebuild-database.php @@ -54,8 +54,11 @@ require_once 'autoload.php'; +// TODO OPUSVIER-4420 remove after switching to Laminas/ZF3 +require_once APPLICATION_PATH . '/vendor/opus4-repo/framework/library/OpusDb/Mysqlutf8.php'; + // environment initializiation -$application = new Zend_Application( +$application = new \Zend_Application( APPLICATION_ENV, [ "config" => [ @@ -68,7 +71,7 @@ ] ); -Zend_Registry::set('opus.disableDatabaseVersionCheck', true); +\Zend_Registry::set('opus.disableDatabaseVersionCheck', true); // Bootstrapping application $application->bootstrap('Backend'); @@ -77,7 +80,7 @@ * Prepare database. */ -$database = new Opus_Database(); +$database = new \Opus\Database(); $dbName = $database->getName(); diff --git a/tests/rebuilding_database.sh b/tests/rebuilding_database.sh index 7abb493336..f0e6273c68 100755 --- a/tests/rebuilding_database.sh +++ b/tests/rebuilding_database.sh @@ -136,7 +136,7 @@ mkdir -p $workspace_dir/tmp mkdir -p $workspace_dir/tmp/resumption mkdir -p $series_logos_dir -rm -rf $workspace_test_dir/* +rm -rf "${workspace_test_dir:?}"/* mkdir -p $workspace_test_dir/cache mkdir -p $workspace_test_dir/export mkdir -p $workspace_test_dir/incoming diff --git a/tests/scripts/cron/ConsistencyCheckTest.php b/tests/scripts/cron/ConsistencyCheckTest.php index 07ca6db663..19de892f39 100644 --- a/tests/scripts/cron/ConsistencyCheckTest.php +++ b/tests/scripts/cron/ConsistencyCheckTest.php @@ -33,6 +33,9 @@ require_once('CronTestCase.php'); +use Opus\DocumentFinder; +use Opus\Job; + class ConsistencyCheckTest extends CronTestCase { @@ -40,7 +43,7 @@ class ConsistencyCheckTest extends CronTestCase private function getPublishedDocumentCount() { - $finder = new Opus_DocumentFinder(); + $finder = new DocumentFinder(); $finder->setServerState('published'); return count($finder->ids()); } @@ -53,10 +56,10 @@ public function testJobSuccess() $this->createJob(Opus\Search\Task\ConsistencyCheck::LABEL); $this->executeScript('cron-check-consistency.php'); - $allJobs = Opus_Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL], null, Opus_Job::STATE_UNDEFINED); + $allJobs = Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL], null, Job::STATE_UNDEFINED); $this->assertTrue(empty($allJobs), 'Expected no more jobs in queue: found ' . count($allJobs) . ' jobs'); - $failedJobs = Opus_Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL], null, Opus_Job::STATE_FAILED); + $failedJobs = Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL], null, Job::STATE_FAILED); $this->assertTrue(empty($failedJobs), 'Expected no failed jobs in queue: found ' . count($failedJobs) . ' jobs'); $logPath = parent::$scriptPath . '/../../workspace/log/'; @@ -95,10 +98,10 @@ public function testJobSuccessWithInconsistency() $this->createJob(Opus\Search\Task\ConsistencyCheck::LABEL); $this->executeScript('cron-check-consistency.php'); - $allJobs = Opus_Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL], null, Opus_Job::STATE_UNDEFINED); + $allJobs = Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL], null, Job::STATE_UNDEFINED); $this->assertTrue(empty($allJobs), 'Expected no more jobs in queue: found ' . count($allJobs) . ' jobs'); - $failedJobs = Opus_Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL], null, Opus_Job::STATE_FAILED); + $failedJobs = Job::getByLabels([Opus\Search\Task\ConsistencyCheck::LABEL], null, Job::STATE_FAILED); $this->assertTrue(empty($failedJobs), 'Expected no failed jobs in queue: found ' . count($failedJobs) . ' jobs'); $logPath = parent::$scriptPath . '/../../workspace/log/'; diff --git a/tests/scripts/cron/CronTestCase.php b/tests/scripts/cron/CronTestCase.php index ddf3647218..cf9c505d88 100644 --- a/tests/scripts/cron/CronTestCase.php +++ b/tests/scripts/cron/CronTestCase.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Job; +use Opus\Model\NotFoundException; + /** * */ @@ -53,9 +56,9 @@ public function tearDown() if (! empty($this->jobIds)) { foreach ($this->jobIds as $jobId) { try { - $job = new Opus_Job($jobId); + $job = new Job($jobId); $job->delete(); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { } } } @@ -76,7 +79,7 @@ protected function executeScript($fileName) protected function createJob($label, $data = []) { - $job = new Opus_Job(); + $job = new Job(); $job->setLabel($label); $job->setData($data); $this->jobIds[] = $job->store(); diff --git a/tests/scripts/cron/DbCleanTemporaryTest.php b/tests/scripts/cron/DbCleanTemporaryTest.php index 5281c6cb15..d6f269c508 100644 --- a/tests/scripts/cron/DbCleanTemporaryTest.php +++ b/tests/scripts/cron/DbCleanTemporaryTest.php @@ -1,5 +1,4 @@ changeDocumentDateModified(3); $this->executeScript('cron-db-clean-temporary.php'); try { - $doc = new Opus_Document($this->doc->getId()); + $doc = Document::get($this->doc->getId()); $doc->deletePermanent(); - $this->fail("expected Opus_Model_NotFoundException"); - } catch (Opus_Model_NotFoundException $e) { + $this->fail("expected Opus\Model\NotFoundException"); + } catch (NotFoundException $e) { } } @@ -70,9 +73,9 @@ public function testKeepDocumentNewerThan3Days() $this->changeDocumentDateModified(2); $this->executeScript('cron-db-clean-temporary.php'); try { - $doc = new Opus_Document($this->doc->getId()); + $doc = Document::get($this->doc->getId()); $doc->deletePermanent(); - } catch (Opus_Model_NotFoundException $e) { + } catch (NotFoundException $e) { $this->fail("expected existing document."); } } @@ -81,6 +84,6 @@ private function changeDocumentDateModified($numDaysBeforeNow) { $date = new DateTime(); $date->sub(new DateInterval("P{$numDaysBeforeNow}D")); - $this->doc->changeServerDateModified(new Opus_Date($date)); + $this->doc->changeServerDateModified(new Date($date)); } } diff --git a/tests/scripts/cron/EmbargoUpdateTest.php b/tests/scripts/cron/EmbargoUpdateTest.php index 5a55e4089c..00d46eae4f 100644 --- a/tests/scripts/cron/EmbargoUpdateTest.php +++ b/tests/scripts/cron/EmbargoUpdateTest.php @@ -34,6 +34,9 @@ require_once('CronTestCase.php'); +use Opus\Date; +use Opus\Document; + /** * */ @@ -44,38 +47,38 @@ class EmbargoUpdateTest extends CronTestCase public function testEmbargoUpdate() { - $twoDaysAgo = new Opus_Date(); + $twoDaysAgo = new Date(); $twoDaysAgo->setDateTime(new DateTime(date('Y-m-d H:i:s', strtotime('-2 day')))); $yesterday = date('Y-m-d', strtotime('-1 day')); $today = date('Y-m-d', time()); - $doc = new Opus_Document(); + $doc = Document::new(); $doc->setEmbargoDate($yesterday); $expiredId = $doc->store(); - $doc = new Opus_Document(); + $doc = Document::new(); $noEmbargoId = $doc->store(); - $doc = new Opus_Document(); + $doc = Document::new(); $doc->setEmbargoDate($today); $notExpiredId = $doc->store(); - Opus_Document::setServerDateModifiedByIds($twoDaysAgo, [$expiredId, $noEmbargoId, $notExpiredId]); + Document::setServerDateModifiedByIds($twoDaysAgo, [$expiredId, $noEmbargoId, $notExpiredId]); $this->executeScript('cron-embargo-update.php'); // document embargo until yesterday -> therefore ServerDateModified got updated - $doc = new Opus_Document($expiredId); + $doc = Document::get($expiredId); $this->assertTrue($this->sameDay(new DateTime($today), $doc->getServerDateModified()->getDateTime())); // document embargo until today -> therefore ServerDateModified not yet updated - $doc = new Opus_Document($notExpiredId); + $doc = Document::get($notExpiredId); $this->assertTrue($this->sameDay($twoDaysAgo->getDateTime(), $doc->getServerDateModified()->getDateTime())); // no document embargo -> therefore ServerDateModified unchanged - $doc = new Opus_Document($noEmbargoId); + $doc = Document::get($noEmbargoId); $this->assertTrue($this->sameDay($twoDaysAgo->getDateTime(), $doc->getServerDateModified()->getDateTime())); } diff --git a/tests/scripts/cron/MetadataImportTest.php b/tests/scripts/cron/MetadataImportTest.php index 782d4f6add..826a9d3a98 100644 --- a/tests/scripts/cron/MetadataImportTest.php +++ b/tests/scripts/cron/MetadataImportTest.php @@ -34,6 +34,9 @@ require_once('CronTestCase.php'); +use Opus\Document; +use Opus\Job; +use Opus\Job\Worker\MetadataImport; class MetadataImportTest extends CronTestCase { @@ -55,9 +58,9 @@ public function setUp() public function tearDown() { if ($this->documentImported) { - $ids = Opus_Document::getAllIds(); + $ids = Document::getAllIds(); $last_id = array_pop($ids); - $doc = new Opus_Document($last_id); + $doc = Document::get($last_id); $doc->deletePermanent(); } parent::tearDown(); @@ -66,14 +69,16 @@ public function tearDown() public function testJobFailedWithoutXml() { $xml = null; - $this->createJob(Opus_Job_Worker_MetadataImport::LABEL, ['xml' => $xml]); + $this->createJob(MetadataImport::LABEL, ['xml' => $xml]); $this->executeScript('cron-import-metadata.php'); - $allJobs = Opus_Job::getByLabels([Opus_Job_Worker_MetadataImport::LABEL], null, Opus_Job::STATE_UNDEFINED); + $allJobs = Job::getByLabels([MetadataImport::LABEL], null, Job::STATE_UNDEFINED); $this->assertTrue(empty($allJobs), 'Expected no more jobs in queue'); - $failedJobs = Opus_Job::getByLabels([Opus_Job_Worker_MetadataImport::LABEL], null, Opus_Job::STATE_FAILED); + $failedJobs = Job::getByLabels([MetadataImport::LABEL], null, Job::STATE_FAILED); $this->assertEquals(1, count($failedJobs), 'Expected one failed job in queue'); - $this->assertJobException(array_pop($failedJobs), 'Opus_Job_Worker_InvalidJobException'); + + // TODO Opus\\\\Job... is necessary to match Opus\\Job... in the actual error message - Fix! + $this->assertJobException(array_pop($failedJobs), 'Opus\\\\Job\\\\Worker\\\\InvalidJobException'); } public function testJobFailedWithSkippedDocumentsException() @@ -82,14 +87,14 @@ public function testJobFailedWithSkippedDocumentsException() $xml = new DOMDocument(); $this->assertTrue($xml->load($this->xmlDir . $filename), 'Could not load xml as DomDocument'); - $this->createJob(Opus_Job_Worker_MetadataImport::LABEL, ['xml' => $xml->saveXML()]); + $this->createJob(MetadataImport::LABEL, ['xml' => $xml->saveXML()]); $this->executeScript('cron-import-metadata.php'); - $allJobs = Opus_Job::getByLabels([Opus_Job_Worker_MetadataImport::LABEL], null, Opus_Job::STATE_UNDEFINED); + $allJobs = Job::getByLabels([MetadataImport::LABEL], null, Job::STATE_UNDEFINED); $this->assertTrue(empty($allJobs), 'Expected no more jobs in queue'); - $failedJobs = Opus_Job::getByLabels([Opus_Job_Worker_MetadataImport::LABEL], null, Opus_Job::STATE_FAILED); + $failedJobs = Job::getByLabels([MetadataImport::LABEL], null, Job::STATE_FAILED); $this->assertEquals(1, count($failedJobs), 'Expected one failed job in queue'); - $this->assertJobException(array_pop($failedJobs), 'Opus_Util_MetadataImportSkippedDocumentsException'); + $this->assertJobException(array_pop($failedJobs), 'Opus\\\\Util\\\\MetadataImportSkippedDocumentsException'); } public function testJobFailedWithInvalidXmlException() @@ -98,14 +103,14 @@ public function testJobFailedWithInvalidXmlException() $xml = new DOMDocument(); $this->assertTrue($xml->load($this->xmlDir . $filename), 'Could not load xml as DomDocument'); - $this->createJob(Opus_Job_Worker_MetadataImport::LABEL, ['xml' => $xml->saveXML()]); + $this->createJob(MetadataImport::LABEL, ['xml' => $xml->saveXML()]); $this->executeScript('cron-import-metadata.php'); - $allJobs = Opus_Job::getByLabels([Opus_Job_Worker_MetadataImport::LABEL], null, Opus_Job::STATE_UNDEFINED); + $allJobs = Job::getByLabels([MetadataImport::LABEL], null, Job::STATE_UNDEFINED); $this->assertTrue(empty($allJobs), 'Expected no more jobs in queue'); - $failedJobs = Opus_Job::getByLabels([Opus_Job_Worker_MetadataImport::LABEL], null, Opus_Job::STATE_FAILED); + $failedJobs = Job::getByLabels([MetadataImport::LABEL], null, Job::STATE_FAILED); $this->assertEquals(1, count($failedJobs), 'Expected one failed job in queue'); - $this->assertJobException(array_pop($failedJobs), 'Opus_Util_MetadataImportInvalidXmlException'); + $this->assertJobException(array_pop($failedJobs), 'Opus\\\\Util\\\\MetadataImportInvalidXmlException'); } @@ -115,12 +120,12 @@ public function testJobSuccess() $xml = new DOMDocument(); $this->assertTrue($xml->load($this->xmlDir . $filename), 'Could not load xml as DomDocument'); - $this->createJob(Opus_Job_Worker_MetadataImport::LABEL, ['xml' => $xml->saveXML()]); + $this->createJob(MetadataImport::LABEL, ['xml' => $xml->saveXML()]); $this->executeScript('cron-import-metadata.php'); - $allJobs = Opus_Job::getByLabels([Opus_Job_Worker_MetadataImport::LABEL], null, Opus_Job::STATE_UNDEFINED); + $allJobs = Job::getByLabels([MetadataImport::LABEL], null, Job::STATE_UNDEFINED); $this->assertTrue(empty($allJobs), 'Expected no more jobs in queue'); - $failedJobs = Opus_Job::getByLabels([Opus_Job_Worker_MetadataImport::LABEL], null, Opus_Job::STATE_FAILED); + $failedJobs = Job::getByLabels([MetadataImport::LABEL], null, Job::STATE_FAILED); $this->assertTrue(empty($failedJobs), 'Expected no failed jobs in queue'); $this->documentImported = true; diff --git a/tests/scripts/cron/OpusDocumentMock.php b/tests/scripts/cron/OpusDocumentMock.php index 3183e816ab..aa4aa74870 100644 --- a/tests/scripts/cron/OpusDocumentMock.php +++ b/tests/scripts/cron/OpusDocumentMock.php @@ -1,5 +1,4 @@ createJob(Opus_Job_Worker_MailNotification::LABEL, [ + $this->createJob(MailNotification::LABEL, [ 'subject' => 'SendNotification Test', 'message' => 'This is a test message generated in ' . __FILE__, 'users' => [['address' => 'user@example.org', 'name' => 'Test User']] ]); $this->executeScript('cron-send-notification.php'); - $allJobs = Opus_Job::getByLabels([Opus_Job_Worker_MailNotification::LABEL], null, Opus_Job::STATE_UNDEFINED); + $allJobs = Job::getByLabels([MailNotification::LABEL], null, Job::STATE_UNDEFINED); $this->assertTrue(empty($allJobs), 'Expected no more jobs in queue'); - $failedJobs = Opus_Job::getByLabels([Opus_Job_Worker_MailNotification::LABEL], null, Opus_Job::STATE_FAILED); + $failedJobs = Job::getByLabels([MailNotification::LABEL], null, Job::STATE_FAILED); $this->assertTrue(empty($failedJobs), 'Expected no failed jobs in queue'); } public function testFailSendNotification() { - $this->createJob(Opus_Job_Worker_MailNotification::LABEL, [ + $this->createJob(MailNotification::LABEL, [ 'subject' => 'SendNotification Test', 'message' => 'This is a test message generated in ' . __FILE__, 'users' => '' ]); $this->executeScript('cron-send-notification.php'); - $failedJobs = Opus_Job::getByLabels([Opus_Job_Worker_MailNotification::LABEL], null, Opus_Job::STATE_FAILED); + $failedJobs = Job::getByLabels([MailNotification::LABEL], null, Job::STATE_FAILED); $this->assertEquals(1, count($failedJobs), 'Expected one failed job in queue'); } } diff --git a/tests/scripts/cron/SolrUpdateTest.php b/tests/scripts/cron/SolrUpdateTest.php index 32d7ac2040..aca260213d 100644 --- a/tests/scripts/cron/SolrUpdateTest.php +++ b/tests/scripts/cron/SolrUpdateTest.php @@ -34,6 +34,8 @@ */ require_once('CronTestCase.php'); +use Opus\Job; + /** * */ @@ -49,7 +51,7 @@ public function setUp() parent::setUp(); $this->document = $this->createTestDocument(); $this->document->store(); - Opus_Job::deleteAll(); + Job::deleteAll(); } public function testSolrUpdateIndex() @@ -58,9 +60,9 @@ public function testSolrUpdateIndex() 'documentId' => $this->document->getId(), 'task' => 'index']); $this->executeScript('cron-solr-update.php'); - $allJobs = Opus_Job::getByLabels([Opus\Search\Task\IndexOpusDocument::LABEL], null, Opus_Job::STATE_UNDEFINED); + $allJobs = Job::getByLabels([Opus\Search\Task\IndexOpusDocument::LABEL], null, Job::STATE_UNDEFINED); $this->assertTrue(empty($allJobs), 'Expected no more jobs in queue'); - $failedJobs = Opus_Job::getByLabels([Opus\Search\Task\IndexOpusDocument::LABEL], null, Opus_Job::STATE_FAILED); + $failedJobs = Job::getByLabels([Opus\Search\Task\IndexOpusDocument::LABEL], null, Job::STATE_FAILED); $this->assertTrue(empty($failedJobs), 'Expected no failed jobs in queue'); } @@ -70,9 +72,9 @@ public function testSolrRemoveIndex() 'documentId' => $this->document->getId(), 'task' => 'remove']); $this->executeScript('cron-solr-update.php'); - $allJobs = Opus_Job::getByLabels([Opus\Search\Task\IndexOpusDocument::LABEL], null, Opus_Job::STATE_UNDEFINED); + $allJobs = Job::getByLabels([Opus\Search\Task\IndexOpusDocument::LABEL], null, Job::STATE_UNDEFINED); $this->assertTrue(empty($allJobs), 'Expected no more jobs in queue'); - $failedJobs = Opus_Job::getByLabels([Opus\Search\Task\IndexOpusDocument::LABEL], null, Opus_Job::STATE_FAILED); + $failedJobs = Job::getByLabels([Opus\Search\Task\IndexOpusDocument::LABEL], null, Job::STATE_FAILED); $this->assertTrue(empty($failedJobs), 'Expected no failed jobs in queue'); } @@ -82,7 +84,7 @@ public function testJobFailsIfInvalidTask() 'documentId' => $this->document->getId(), 'task' => 'do-the-unexpected']); $this->executeScript('cron-solr-update.php'); - $allJobs = Opus_Job::getByLabels([Opus\Search\Task\IndexOpusDocument::LABEL], null, Opus_Job::STATE_FAILED); + $allJobs = Job::getByLabels([Opus\Search\Task\IndexOpusDocument::LABEL], null, Job::STATE_FAILED); $this->assertEquals(1, count($allJobs), 'Expected one failed job in queue (found ' . count($allJobs) . ')'); } } diff --git a/tests/scripts/cron/UpdateDocumentCacheTest.php b/tests/scripts/cron/UpdateDocumentCacheTest.php index de236e92e6..66c8f10630 100644 --- a/tests/scripts/cron/UpdateDocumentCacheTest.php +++ b/tests/scripts/cron/UpdateDocumentCacheTest.php @@ -33,6 +33,9 @@ require_once('CronTestCase.php'); +use Opus\Licence; +use Opus\Db\DocumentXmlCache; + /** * */ @@ -46,7 +49,7 @@ public function testUpdateOnLicenceChange() $document = $this->createTestDocument(); $document->store(); - $documentCacheTable = new Opus_Db_DocumentXmlCache(); + $documentCacheTable = new DocumentXmlCache(); $docXmlCache = $documentCacheTable->find($document->getId(), '1')->current()->xml_data; $domDoc = new DomDocument(); @@ -54,7 +57,7 @@ public function testUpdateOnLicenceChange() $licences = $domDoc->getElementsByTagName('Licence'); $this->assertTrue($licences->length == 0, 'Expected no Licence element in dom.'); - $licence = new Opus_Licence(); + $licence = new Licence(); $licence->setNameLong('TestLicence'); $licence->setLinkLicence('http://example.org/licence'); $licenceId = $licence->store(); @@ -62,7 +65,7 @@ public function testUpdateOnLicenceChange() $document->setLicence($licence); $docId = $document->store(); - $licence = new Opus_Licence($licenceId); + $licence = new Licence($licenceId); $licence->setNameLong('TestLicenceAltered'); $licence->store(); diff --git a/tests/security/LicencesAdminTests.php b/tests/security/LicencesAdminTest.php similarity index 100% rename from tests/security/LicencesAdminTests.php rename to tests/security/LicencesAdminTest.php diff --git a/tests/security/RefereeTest.php b/tests/security/RefereeTest.php index 2beee718c5..c0f40b9dcc 100644 --- a/tests/security/RefereeTest.php +++ b/tests/security/RefereeTest.php @@ -1,5 +1,4 @@ setLogin('referee'); $account->setPassword('refereereferee'); $account->setRole([$userRole]); diff --git a/tests/security/SeriesAdminTest.php b/tests/security/SeriesAdminTest.php index d9809e5a67..88e292026d 100644 --- a/tests/security/SeriesAdminTest.php +++ b/tests/security/SeriesAdminTest.php @@ -1,5 +1,4 @@ enableSecurity(); - $userRole = new Opus_UserRole(); + $userRole = new UserRole(); $userRole->setName($this->roleName); $userRole->appendAccessModule('admin'); $userRole->appendAccessModule('resource_series'); $userRole->store(); - $user = new Opus_Account(); + $user = new Account(); $user->setLogin($this->userName); $user->setPassword('seriesadminpwd'); $user->addRole($userRole); @@ -67,10 +69,10 @@ public function tearDown() $this->logoutUser(); $this->restoreSecuritySetting(); - $user = Opus_Account::fetchAccountByLogin($this->userName); + $user = Account::fetchAccountByLogin($this->userName); $user->delete(); - $userRole = Opus_UserRole::fetchByName($this->roleName); + $userRole = UserRole::fetchByName($this->roleName); $userRole->delete(); parent::tearDown(); diff --git a/tests/support/AssumptionChecker.php b/tests/support/AssumptionChecker.php index 1442f64e79..ac2cf25460 100644 --- a/tests/support/AssumptionChecker.php +++ b/tests/support/AssumptionChecker.php @@ -59,7 +59,7 @@ public function checkYearFacetAssumption() $this->testCase->resetRequest(); $this->testCase->resetResponse(); - Zend_Registry::get('Zend_Config')->merge(new Zend_Config( + \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( ['searchengine' => ['solr' => [ 'facetlimit' => ['year' => '10', 'year_inverted' => '10'], 'facets' => 'year,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute' @@ -90,7 +90,7 @@ public function checkYearFacetAssumption() for ($i = 0; $i < 10; $i++) { $lastPos = strpos($response, '>' . $searchStrings[$i] . '', $lastPos); if ($lastPos === false) { - Zend_Debug::dump("'" . $searchStrings[$i] . '\' not found in year facet list (iteration ' . $i . ')'); + \Zend_Debug::dump("'" . $searchStrings[$i] . '\' not found in year facet list (iteration ' . $i . ')'); } $this->testCase->assertFalse($lastPos === false, "'" . $searchStrings[$i] . '\' not found in year facet list (iteration ' . $i . ')'); if ($lastPos === false) { diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index d06fc82138..34218af87a 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -32,6 +32,15 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Db\TableGateway; +use Opus\Document; +use Opus\File; +use Opus\UserRole; +use Opus\Model\ModelException; +use Opus\Model\NotFoundException; +use Opus\Security\AuthAdapter; +use Opus\Security\Realm; + /** * Base class for controller tests. * @@ -111,7 +120,7 @@ public function tearDown() public function getApplication() { - return new Zend_Application( + return new \Zend_Application( $this->applicationEnv, ["config" => [ APPLICATION_PATH . '/application/configs/application.ini', @@ -132,7 +141,7 @@ public function cleanupBefore() $this->closeDatabaseConnection(); // Resetting singletons or other kinds of persistent objects. - Opus_Db_TableGateway::clearInstances(); + TableGateway::clearInstances(); // Clean-up possible artifacts in $_SERVER of previous test. unset($_SERVER['REMOTE_ADDR']); @@ -142,7 +151,7 @@ public function cleanupBefore() public function cleanupDatabase() { - if (! is_null(Zend_Db_Table::getDefaultAdapter())) { + if (! is_null(\Zend_Db_Table::getDefaultAdapter())) { $this->deleteTestDocuments(); // data integrity checks TODO should be made unnecessary @@ -166,7 +175,7 @@ public function additionalChecks() */ protected function checkDoc146() { - $doc = new Opus_Document(146); + $doc = Document::get(146); $modified = $doc->getServerDateModified(); $this->assertEquals(2012, $modified->getYear()); @@ -174,7 +183,7 @@ protected function checkDoc146() protected function checkDoc1() { - $doc = new Opus_Document(1); + $doc = Document::get(1); $modified = $doc->getServerDateModified(); $this->assertEquals(2010, $modified->getYear()); @@ -182,7 +191,7 @@ protected function checkDoc1() protected function closeDatabaseConnection() { - $adapter = Zend_Db_Table::getDefaultAdapter(); + $adapter = \Zend_Db_Table::getDefaultAdapter(); if ($adapter) { $adapter->closeConnection(); } @@ -227,41 +236,41 @@ protected function checkForBadStringsInHtml($body) */ public function loginUser($login, $password) { - $adapter = new Opus_Security_AuthAdapter(); + $adapter = new AuthAdapter(); $adapter->setCredentials($login, $password); - $auth = Zend_Auth::getInstance(); + $auth = \Zend_Auth::getInstance(); $auth->authenticate($adapter); $this->assertTrue($auth->hasIdentity()); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); if (isset($config->security) && filter_var($config->security, FILTER_VALIDATE_BOOLEAN)) { Application_Security_AclProvider::init(); // make sure ACLs are not cached in action helper TODO find better solution try { - $accessControl = Zend_Controller_Action_HelperBroker::getExistingHelper('accessControl'); + $accessControl = \Zend_Controller_Action_HelperBroker::getExistingHelper('accessControl'); $accessControl->setAcl(null); - } catch (Zend_Controller_Action_Exception $excep) { + } catch (\Zend_Controller_Action_Exception $excep) { } } } public function logoutUser() { - $instance = Zend_Auth::getInstance(); + $instance = \Zend_Auth::getInstance(); if (! is_null($instance)) { $instance->clearIdentity(); } - $realm = Opus_Security_Realm::getInstance(); + $realm = Realm::getInstance(); $realm->setUser(null); $realm->setIp(null); // make sure ACLs are not cached in action helper TODO find better solution try { - $accessControl = Zend_Controller_Action_HelperBroker::getExistingHelper('accessControl'); + $accessControl = \Zend_Controller_Action_HelperBroker::getExistingHelper('accessControl'); $accessControl->setAcl(null); - } catch (Zend_Controller_Action_Exception $excep) { + } catch (\Zend_Controller_Action_Exception $excep) { } } @@ -281,14 +290,14 @@ protected function requireSolrConfig() /** * Modifies Solr configuration to un unknown core to simulate connection failure. - * @throws Zend_Exception + * @throws \Zend_Exception */ protected function disableSolr() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); // TODO old config path still needed? // $config->searchengine->index->app = 'solr/corethatdoesnotexist'; - $config->merge(new Zend_Config([ + $config->merge(new \Zend_Config([ 'searchengine' => [ 'solr' => [ 'default' => [ @@ -307,7 +316,7 @@ protected function disableSolr() /** * - * @param Zend_Controller_Response_Abstract $response + * @param \Zend_Controller_Response_Abstract $response * @param string $location */ protected function assertResponseLocationHeader($response, $location) @@ -324,17 +333,17 @@ protected function assertResponseLocationHeader($response, $location) public function enableSecurity() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $this->securityEnabled = $config->security; $config->security = self::CONFIG_VALUE_TRUE; - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); } public function restoreSecuritySetting() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->security = $this->securityEnabled; - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); } /** @@ -342,9 +351,9 @@ public function restoreSecuritySetting() */ public function useGerman() { - $session = new Zend_Session_Namespace(); + $session = new \Zend_Session_Namespace(); $session->language = 'de'; - Zend_Registry::get('Zend_Translate')->setLocale('de'); + \Zend_Registry::get('Zend_Translate')->setLocale('de'); Application_Form_Element_Language::initLanguageList(); } @@ -353,9 +362,9 @@ public function useGerman() */ public function useEnglish() { - $session = new Zend_Session_Namespace(); + $session = new \Zend_Session_Namespace(); $session->language = 'en'; - Zend_Registry::get('Zend_Translate')->setLocale('en'); + \Zend_Registry::get('Zend_Translate')->setLocale('en'); Application_Form_Element_Language::initLanguageList(); } @@ -439,14 +448,14 @@ function ($public, $system, $context) use ($mapping) { // Array mit Fehlern ausgeben if (count($errors) !== 0) { - $output = Zend_Debug::dump($errors, 'XHTML Fehler', false); + $output = \Zend_Debug::dump($errors, 'XHTML Fehler', false); } else { $output = ''; } - $this->assertEquals( + $this->assertCount( 0, - count($errors), + $errors, 'XHTML Schemaverletzungen gefunden (' . count($errors) . ')' . PHP_EOL . $output ); @@ -489,7 +498,7 @@ public function verifyCommandAvailable($command) */ public function isFailTestOnMissingCommand() { - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); return (isset($config->tests->failTestOnMissingCommand) && filter_var($config->tests->failTestOnMissingCommand, FILTER_VALIDATE_BOOLEAN)); } @@ -499,15 +508,15 @@ public function isFailTestOnMissingCommand() * * Fuer gruene Nachrichten Level muss self::MESSAGE_LEVEL_NOTICE verwendet werden. * - * @param $message Übersetzungsschlüssel bzw. Nachricht + * @param string $message Übersetzungsschlüssel bzw. Nachricht * @param string $level 'notice' oder 'failure' */ public function verifyFlashMessage($message, $level = self::MESSAGE_LEVEL_FAILURE) { - $flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger'); + $flashMessenger = \Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger'); $flashMessages = $flashMessenger->getCurrentMessages(); - $this->assertEquals(1, count($flashMessages), 'Expected one flash message in queue.'); + $this->assertCount(1, $flashMessages, 'Expected one flash message in queue.'); $flashMessage = $flashMessages[0]; $this->assertEquals($message, $flashMessage['message']); @@ -519,15 +528,15 @@ public function verifyFlashMessage($message, $level = self::MESSAGE_LEVEL_FAILUR * * Fuer gruene Nachrichten Level muss self::MESSAGE_LEVEL_NOTICE verwendet werden. * - * @param $message Übersetzungsschlüssel bzw. Nachricht + * @param string $message Übersetzungsschlüssel bzw. Nachricht * @param string $level 'notice' oder 'failure' */ public function verifyNotFlashMessageContains($message, $level = self::MESSAGE_LEVEL_FAILURE) { - $flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger'); + $flashMessenger = \Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger'); $flashMessages = $flashMessenger->getCurrentMessages(); - $this->assertEquals(1, count($flashMessages), 'Expected one flash message in queue.'); + $this->assertCount(1, $flashMessages, 'Expected one flash message in queue.'); $flashMessage = $flashMessages[0]; $this->assertNotContains($message, $flashMessage['message']); @@ -565,7 +574,7 @@ public function verifyBreadcrumbDefined($location = null) } } - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $path = explode('/', $location); @@ -585,7 +594,7 @@ public function verifyBreadcrumbDefined($location = null) if (! $breadcrumbDefined) { $breadcrumbDefined = true; - $translate = Zend_Registry::get('Zend_Translate'); + $translate = \Zend_Registry::get('Zend_Translate'); $label = $page->getLabel(); @@ -607,14 +616,14 @@ public function verifyBreadcrumbDefined($location = null) */ public function dumpBody() { - Zend_Debug::dump($this->getResponse()->getBody()); + \Zend_Debug::dump($this->getResponse()->getBody()); } /** * Removes a test document from the database. * - * @param $value Opus_Document|int - * @throws Opus_Model_Exception + * @param $value Document|int + * @throws ModelException */ public function removeDocument($value) { @@ -623,10 +632,10 @@ public function removeDocument($value) } $doc = $value; - if (! ($value instanceof Opus_Document)) { + if (! ($value instanceof Document)) { try { - $doc = new Opus_Document($value); - } catch (Opus_Model_NotFoundException $e) { + $doc = Document::get($value); + } catch (NotFoundException $e) { // could not find document -> no cleanup operation required: exit silently return; } @@ -639,9 +648,9 @@ public function removeDocument($value) } try { - new Opus_Document($docId); + Document::get($docId); $doc->deletePermanent(); - } catch (Opus_Model_NotFoundException $omnfe) { + } catch (NotFoundException $omnfe) { // Model nicht gefunden -> alles gut (hoffentlich) $this->getLogger()->debug("Test document {$docId} was deleted successfully by test."); return; @@ -652,9 +661,9 @@ public function removeDocument($value) // make sure test documents have been deleted try { - new Opus_Document($docId); + Document::get($docId); $this->getLogger()->debug("Test document {$docId} was not deleted."); - } catch (Opus_Model_NotFoundException $omnfe) { + } catch (NotFoundException $omnfe) { // ignore - document was deleted successfully $this->getLogger()->debug("Test document {$docId} was deleted successfully."); } @@ -675,18 +684,18 @@ protected function deleteTestDocuments() protected function getDocument($docId) { - return new Opus_Document($docId); + return Document::get($docId); } /** * Erzeugt ein Testdokument, das nach der Testausführung automatisch aufgeräumt wird. * - * @return Opus_Document - * @throws Opus_Model_Exception + * @return Document + * @throws ModelException */ protected function createTestDocument() { - $doc = new Opus_Document(); + $doc = Document::new(); $this->addTestDocument($doc); return $doc; } @@ -723,8 +732,8 @@ protected function deleteTempFiles() /** * @param string $filename * @param string $filepath - * @return Opus_File - * @throws Opus_Model_Exception + * @return File + * @throws ModelException * @throws Zend_Exception */ protected function createOpusTestFile($filename, $filepath = null) @@ -742,11 +751,11 @@ protected function createOpusTestFile($filename, $filepath = null) } $this->assertTrue(is_readable($filepath)); - $file = new Opus_File(); + $file = new File(); $file->setPathName(basename($filepath)); $file->setTempFile($filepath); if (array_key_exists($filename, $this->testFiles)) { - throw Exception('filenames should be unique'); + throw new \Exception('filenames should be unique'); } $this->testFiles[$filename] = $filepath; return $file; @@ -810,7 +819,7 @@ protected function setWorkspacePath($path) protected function getConfig() { - return Zend_Registry::get('Zend_Config'); + return \Zend_Registry::get('Zend_Config'); } protected function createTestFolder() @@ -890,13 +899,13 @@ protected function deleteFolder($path, $deleteOutsideWorkspace = false) public function assertSecurityConfigured() { - $this->assertEquals('1', Zend_Registry::get('Zend_Config')->security); + $this->assertEquals('1', \Zend_Registry::get('Zend_Config')->security); $this->assertTrue( - Zend_Registry::isRegistered('Opus_Acl'), + \Zend_Registry::isRegistered('Opus_Acl'), 'Expected registry key Opus_Acl to be set' ); - $acl = Zend_Registry::get('Opus_Acl'); - $this->assertTrue($acl instanceof Zend_Acl, 'Expected instance of Zend_Acl'); + $acl = \Zend_Registry::get('Opus_Acl'); + $this->assertTrue($acl instanceof \Zend_Acl, 'Expected instance of Zend_Acl'); } public function resetSearch() @@ -912,7 +921,7 @@ public function resetSearch() */ public function setHostname($host) { - $view = Zend_Registry::get('Opus_View'); + $view = \Zend_Registry::get('Opus_View'); $view->getHelper('ServerUrl')->setHost($host); } @@ -927,7 +936,7 @@ public function setHostname($host) */ public function setBaseUrl($baseUrl) { - Zend_Controller_Front::getInstance()->setBaseUrl($baseUrl); + \Zend_Controller_Front::getInstance()->setBaseUrl($baseUrl); } /** @@ -941,10 +950,10 @@ public function setBaseUrl($baseUrl) public function disableTranslation() { if (is_null($this->translatorBackup)) { - $this->translatorBackup = Zend_Registry::get('Zend_Translate'); + $this->translatorBackup = \Zend_Registry::get('Zend_Translate'); } - Zend_Registry::set('Zend_Translate', new Application_Translate([ + \Zend_Registry::set('Zend_Translate', new Application_Translate([ 'adapter' => 'array', 'content' => [], 'locale' => 'auto' @@ -959,7 +968,7 @@ public function disableTranslation() public function enableTranslation() { if (! is_null($this->translatorBackup)) { - Zend_Registry::set('Zend_Translate', $this->translatorBackup); + \Zend_Registry::set('Zend_Translate', $this->translatorBackup); } } @@ -967,14 +976,14 @@ public function enableTranslation() * Allow the given user (identified by his or her name) to access the given module. * Returns true if access permission was added; otherwise false. * - * @param $moduleName module name - * @param $userName user name + * @param string $moduleName module name + * @param string $userName user name * @return bool - * @throws \Opus\Model\Exception + * @throws ModelException */ protected function addModuleAccess($moduleName, $userName) { - $r = Opus_UserRole::fetchByName($userName); + $r = UserRole::fetchByName($userName); $modules = $r->listAccessModules(); if (! in_array($moduleName, $modules)) { $r->appendAccessModule($moduleName); @@ -988,14 +997,14 @@ protected function addModuleAccess($moduleName, $userName) * Disallow the given user (identified by his or her name) to access the given module. * Returns true if access permission was removed; otherwise false. * - * @param $moduleName module name - * @param $userName user name + * @param string $moduleName module name + * @param string $userName user name * @return bool - * @throws \Opus\Model\Exception + * @throws ModelException */ protected function removeModuleAccess($moduleName, $userName) { - $r = Opus_UserRole::fetchByName($userName); + $r = UserRole::fetchByName($userName); $modules = $r->listAccessModules(); if (in_array($moduleName, $modules)) { $r->removeAccessModule($moduleName); diff --git a/tests/support/CrudControllerTestCase.php b/tests/support/CrudControllerTestCase.php index 75bdfd203b..5fe77fe881 100644 --- a/tests/support/CrudControllerTestCase.php +++ b/tests/support/CrudControllerTestCase.php @@ -29,9 +29,10 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Model\NotFoundException; + abstract class CrudControllerTestCase extends ControllerTestCase { @@ -106,7 +107,6 @@ public function testIndexAction() $this->assertAction('index'); $models = $this->getModels(); - ; $this->assertQuery('a.add', 'Kein Add Button gefunden.'); if (count($models) > 0) { @@ -224,7 +224,7 @@ public function testDeleteActionYes() try { $this->getModel($modelId); - } catch (Opus_Model_NotFoundException $omnfe) { + } catch (NotFoundException $omnfe) { // alles gut, Modell wurde geloescht } diff --git a/tests/support/DepositTestHelper.php b/tests/support/DepositTestHelper.php index addcb68754..d8c5399f7c 100644 --- a/tests/support/DepositTestHelper.php +++ b/tests/support/DepositTestHelper.php @@ -31,6 +31,11 @@ * @copyright Copyright (c) 2016-2017 * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Collection; +use Opus\CollectionRole; +use Opus\Document; + class DepositTestHelper extends PHPUnit_Framework_Assert { @@ -103,7 +108,7 @@ public function uploadFile($request, $fileName, $checksum = null) public function addImportCollection() { if (is_null($this->collectionId)) { - $collectionRole = Opus_CollectionRole::fetchByName('Import'); + $collectionRole = CollectionRole::fetchByName('Import'); $this->assertFalse( is_null($collectionRole), 'Collection Role "Import" is part of standard distribution since OPUS 4.5' @@ -111,7 +116,7 @@ public function addImportCollection() $rootCollection = $collectionRole->getRootCollection(); // create temporary collection - $collection = new Opus_Collection(); + $collection = new Collection(); $timestamp = time(); $this->collectionNumber = 'sword-test-number-' . $timestamp; $collection->setNumber($this->collectionNumber); @@ -120,24 +125,24 @@ public function addImportCollection() $rootCollection->addLastChild($collection); $this->collectionId = $collection->store(); - $this->configBackup = Zend_Registry::get('Zend_Config'); - $config = Zend_Registry::get('Zend_Config'); + $this->configBackup = \Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $config->sword->collection->default->number = $this->collectionNumber; $config->sword->collection->default->abstract = 'sword.collection.default.abstract'; $config->sword->collection->default->collectionPolicy = 'sword.collection.default.collectionPolicy'; $config->sword->collection->default->treatment = 'sword.collection.default.treatment'; $config->sword->collection->default->acceptPackaging = 'sword.collection.default.acceptPackaging'; - Zend_Registry::set('Zend_Config', $config); + \Zend_Registry::set('Zend_Config', $config); } } public function removeImportCollection() { if (! is_null($this->collectionId)) { - $collection = new Opus_Collection($this->collectionId); + $collection = new Collection($this->collectionId); $collection->delete(); $this->collectionId = null; - Zend_Registry::set('Zend_Config', $this->configBackup); + \Zend_Registry::set('Zend_Config', $this->configBackup); } } @@ -239,7 +244,7 @@ public function checkAtomEntryDocument( $idNode = $entryChildren->item(0); $this->assertEquals('id', $idNode->nodeName); $docId = $idNode->nodeValue; - $doc = new Opus_Document($docId); + $doc = Document::get($docId); $this->assertNodeProperties(1, $entryChildren, 'updated', $doc->getServerDateCreated()); $this->assertNodeProperties(2, $entryChildren, 'title', $doc->getTitleMain(0)->getValue()); @@ -272,7 +277,7 @@ public function checkAtomEntryDocument( $this->frontdoorUrl = 'http:///frontdoor/index/index/docId/' . $docId; $this->assertEquals($this->frontdoorUrl, $attribute->nodeValue); - $config = Zend_Registry::get('Zend_Config'); + $config = \Zend_Registry::get('Zend_Config'); $generatorValue = $config->sword->generator; $this->assertNodeProperties(5 + $offset, $entryChildren, 'generator', $generatorValue); diff --git a/tests/support/DummyValidator.php b/tests/support/DummyValidator.php index cd14797d61..66ab37a700 100644 --- a/tests/support/DummyValidator.php +++ b/tests/support/DummyValidator.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2020 * @license http://www.gnu.org/licenses/gpl.html General Public License */ -class DummyValidator extends Zend_Validate_Abstract +class DummyValidator extends \Zend_Validate_Abstract { public function isValid($value) diff --git a/tests/support/FormElementTestCase.php b/tests/support/FormElementTestCase.php index 7e39b930f2..e4245a77d3 100644 --- a/tests/support/FormElementTestCase.php +++ b/tests/support/FormElementTestCase.php @@ -113,7 +113,7 @@ public function testConstruct() { $element = $this->getElement(); - $paths = $element->getPluginLoader(Zend_Form::DECORATOR)->getPaths(); + $paths = $element->getPluginLoader(\Zend_Form::DECORATOR)->getPaths(); $this->assertArrayHasKey('Application_Form_Decorator_', $paths); $this->assertContains('Application/Form/Decorator/', $paths['Application_Form_Decorator_']); } diff --git a/tests/support/LogFilter.php b/tests/support/LogFilter.php index b76175982b..de3e1da05f 100644 --- a/tests/support/LogFilter.php +++ b/tests/support/LogFilter.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id: MockLogger.php 13692 2014-10-10 11:08:14Z schwidder $ */ /** @@ -37,7 +36,7 @@ * * TODO expand functionality */ -class LogFilter implements Zend_Log_Filter_Interface +class LogFilter implements \Zend_Log_Filter_Interface { private $messages = []; diff --git a/tests/support/MockAccessControl.php b/tests/support/MockAccessControl.php index 321b11f636..178b653a57 100644 --- a/tests/support/MockAccessControl.php +++ b/tests/support/MockAccessControl.php @@ -29,13 +29,12 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class MockAccessControl implements Application_Security_AccessControl { - private $defaultAnswer = false; + private $defaultAnswer; public function __construct($answer = false) { diff --git a/tests/support/MockLogger.php b/tests/support/MockLogger.php index e91999de07..d99acd8303 100644 --- a/tests/support/MockLogger.php +++ b/tests/support/MockLogger.php @@ -29,7 +29,6 @@ * @author Jens Schwidder * @copyright Copyright (c) 2013-2014, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ /** @@ -37,12 +36,12 @@ * * TODO Unterscheidung von Nachrichten in Log-Leveln? */ -class MockLogger extends Zend_Log +class MockLogger extends \Zend_Log { private $messages = []; - private $logger = null; + private $logger; public function __construct($logger = null) { diff --git a/tests/support/MockRealm.php b/tests/support/MockRealm.php index 9ba4cffe18..34a0cf154d 100644 --- a/tests/support/MockRealm.php +++ b/tests/support/MockRealm.php @@ -29,11 +29,11 @@ * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ +use Opus\Security\IRealm; -class MockRealm implements Opus_Security_IRealm +class MockRealm implements IRealm { private $fileAllowed; @@ -68,9 +68,11 @@ public function getRoles() public function setUser($username) { } + public function setIp($ipaddress) { } + public function check($privilege, $documentServerState = null, $fileId = null) { } diff --git a/tests/support/SendMailMock.php b/tests/support/SendMailMock.php index f91673bce2..c77d168495 100644 --- a/tests/support/SendMailMock.php +++ b/tests/support/SendMailMock.php @@ -29,7 +29,6 @@ * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ class SendMailMock @@ -49,7 +48,7 @@ class SendMailMock * @param string $bodyText * @param array $address Recipients (array [#] => array ('name' => '...', 'address' => '...')) */ - public function sendMail($from, $fromName, $subject, $bodyText, $address) + public function sendMail(string $from, string $fromName, string $subject, string $bodyText, array $address) { $this->from = $from; $this->fromName = $fromName; diff --git a/tests/support/SimpleBootstrap.php b/tests/support/SimpleBootstrap.php index b21f562482..75fc31d15b 100644 --- a/tests/support/SimpleBootstrap.php +++ b/tests/support/SimpleBootstrap.php @@ -35,7 +35,7 @@ use Opus\Log\LogService; -class SimpleBootstrap extends Zend_Application_Bootstrap_Bootstrap +class SimpleBootstrap extends \Zend_Application_Bootstrap_Bootstrap { /** @@ -55,8 +55,8 @@ class SimpleBootstrap extends Zend_Application_Bootstrap_Bootstrap */ protected function _initConfiguration() { - $config = new Zend_Config($this->getOptions(), true); - Zend_Registry::set('Zend_Config', $config); + $config = new \Zend_Config($this->getOptions(), true); + \Zend_Registry::set('Zend_Config', $config); return $config; } @@ -78,8 +78,8 @@ protected function _initLogging() $logger = $logService->createLog(LogService::DEFAULT_LOG, null, null, $logFilename); $logLevel = $logService->getDefaultPriority(); - Zend_Registry::set('Zend_Log', $logger); - Zend_Registry::set('LOG_LEVEL', $logLevel); + \Zend_Registry::set('Zend_Log', $logger); + \Zend_Registry::set('LOG_LEVEL', $logLevel); $logger->debug('Logging initialized'); diff --git a/tests/support/TestCase.php b/tests/support/TestCase.php index ad379065e8..c6f5fb28d0 100644 --- a/tests/support/TestCase.php +++ b/tests/support/TestCase.php @@ -30,13 +30,15 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; + /** * Base class for application tests. * * TODO any effect vvv ? * @preserveGlobalState disabled */ -class TestCase extends Zend_Test_PHPUnit_ControllerTestCase +class TestCase extends \Zend_Test_PHPUnit_ControllerTestCase { protected $application; @@ -84,14 +86,14 @@ public function tearDown() public function cleanupBefore() { // FIXME Does it help with the mystery bug? - Zend_Registry::_unsetInstance(); + \Zend_Registry::_unsetInstance(); $this->resetAutoloader(); } public function getApplication() { - return new Zend_Application( + return new \Zend_Application( $this->applicationEnv, ["config" => [ APPLICATION_PATH . '/tests/simple.ini' @@ -125,8 +127,8 @@ public function appBootstrap() */ public function resetAutoloader() { - Zend_Loader_Autoloader::resetInstance(); - $autoloader = Zend_Loader_Autoloader::getInstance(); + \Zend_Loader_Autoloader::resetInstance(); + $autoloader = \Zend_Loader_Autoloader::getInstance(); $autoloader->suppressNotFoundWarnings(false); $autoloader->setFallbackAutoloader(true); } @@ -136,22 +138,22 @@ public function resetAutoloader() */ protected function closeLogfile() { - if (! Zend_Registry::isRegistered('Zend_Log')) { + if (! \Zend_Registry::isRegistered('Zend_Log')) { return; } - $log = Zend_Registry::get('Zend_Log'); + $log = \Zend_Registry::get('Zend_Log'); if (isset($log)) { $log->__destruct(); - Zend_Registry::set('Zend_Log', null); + \Zend_Registry::set('Zend_Log', null); } - Opus_Log::drop(); + Log::drop(); } public function makeConfigurationModifiable() { - $config = new Zend_Config([], true); - Zend_Registry::set('Zend_Config', $config->merge(Zend_Registry::get('Zend_Config'))); + $config = new \Zend_Config([], true); + \Zend_Registry::set('Zend_Config', $config->merge(\Zend_Registry::get('Zend_Config'))); } } From 803f8158b6f86cbc27d84885d79f0d4813fb3df6 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 20 Oct 2020 22:41:31 +0200 Subject: [PATCH 070/270] OPUSVIER-4415 Fixed coding style --- library/Application/Controller/Action/Helper/AccessControl.php | 3 +-- modules/admin/controllers/ReportController.php | 1 - modules/admin/forms/Document/Enrichment.php | 1 - modules/admin/forms/File.php | 1 - scripts/opus-create-xss-document.php | 1 - tests/modules/oai/controllers/IndexControllerTest.php | 1 - 6 files changed, 1 insertion(+), 7 deletions(-) diff --git a/library/Application/Controller/Action/Helper/AccessControl.php b/library/Application/Controller/Action/Helper/AccessControl.php index 8ec96bdbcf..258f40bb61 100644 --- a/library/Application/Controller/Action/Helper/AccessControl.php +++ b/library/Application/Controller/Action/Helper/AccessControl.php @@ -38,8 +38,7 @@ * * TODO weiter ausbauen und mit Opus\Security\IRealm konsolidieren (Framework vs. Application Security) */ -class Application_Controller_Action_Helper_AccessControl extends \Zend_Controller_Action_Helper_Abstract - implements Application_Security_AccessControl +class Application_Controller_Action_Helper_AccessControl extends \Zend_Controller_Action_Helper_Abstract implements Application_Security_AccessControl { private $_acl; diff --git a/modules/admin/controllers/ReportController.php b/modules/admin/controllers/ReportController.php index fe1fdc9c04..95ee9d7ceb 100644 --- a/modules/admin/controllers/ReportController.php +++ b/modules/admin/controllers/ReportController.php @@ -36,7 +36,6 @@ use Opus\Doi\DoiManagerStatus; use Opus\Doi\RegistrationException; - /** * Controller for generating reports. */ diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index 3cd34c5ee5..668cd4aadf 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -40,7 +40,6 @@ use Opus\Model\ModelException; use Opus\Model\NotFoundException; - /** * Unterformular für einzelne Enrichments im Metadaten-Formular. * diff --git a/modules/admin/forms/File.php b/modules/admin/forms/File.php index 7ab63b8696..b759bbf16a 100644 --- a/modules/admin/forms/File.php +++ b/modules/admin/forms/File.php @@ -30,7 +30,6 @@ use Opus\Model\AbstractDb; use Opus\Model\NotFoundException; - /** * Formular fuer Anzeige/Editieren einer Datei. * diff --git a/scripts/opus-create-xss-document.php b/scripts/opus-create-xss-document.php index d900a1721c..9ad4c28c73 100644 --- a/scripts/opus-create-xss-document.php +++ b/scripts/opus-create-xss-document.php @@ -41,7 +41,6 @@ use Opus\Licence; use Opus\Person; - $counter = 1; function randString($counter) { diff --git a/tests/modules/oai/controllers/IndexControllerTest.php b/tests/modules/oai/controllers/IndexControllerTest.php index 79e7ec5079..30160d433e 100644 --- a/tests/modules/oai/controllers/IndexControllerTest.php +++ b/tests/modules/oai/controllers/IndexControllerTest.php @@ -46,7 +46,6 @@ use Opus\TitleAbstract; use Opus\UserRole; - /** * TODO split specific protocol tests into separate classes * TODO unit tests transformations directly without "dispatch" From ee2a7f6b1117511bc4cfc9be74b18b11f0ed1a92 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 21 Oct 2020 13:02:28 +0200 Subject: [PATCH 071/270] OPUSVIER-4450 LicencesAdminTest fixed --- tests/security/LicencesAdminTest.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/security/LicencesAdminTest.php b/tests/security/LicencesAdminTest.php index 4d91f79d9b..00e7e090d2 100644 --- a/tests/security/LicencesAdminTest.php +++ b/tests/security/LicencesAdminTest.php @@ -1,5 +1,4 @@ assertNotQuery('//a[@href="/admin/series"]'); $this->assertNotQuery('//a[@href="/admin/language"]'); $this->assertNotQuery('//a[@href="/admin/dnbinstitute"]'); - $this->assertQuery('//a[@href="/admin/index/setup"]'); + $this->assertNotQuery('//a[@href="/admin/index/setup"]'); $this->assertNotQuery('//a[@href="/review"]'); } @@ -86,7 +85,7 @@ public function testAccessLicenceController() public function testNoAccessDocumentsController() { $this->dispatch('/admin/documents'); - $this->assertRedirectTo('/auth'); + $this->assertRedirectTo('/auth/index/rmodule/admin/rcontroller/documents/raction/index'); } /** @@ -102,18 +101,20 @@ public function testEditLinkInFrontdoorNotPresent() public function testNoAccessFilebrowserController() { $this->dispatch('/admin/filebrowser/index/docId/92'); - $this->assertRedirectTo('/auth'); + $this->assertRedirectTo('/auth/index/rmodule/admin/rcontroller/filebrowser/raction/index/docId/92'); } public function testNoAccessWorkflowController() { $this->dispatch('/admin/workflow/changestate/docId/300/targetState/deleted'); - $this->assertRedirectTo('/auth'); + $this->assertRedirectTo( + '/auth/index/rmodule/admin/rcontroller/workflow/raction/changestate/docId/300/targetState/deleted' + ); } public function testNoAccessAccessController() { $this->dispatch('/admin/access/listmodule/roleid/2'); - $this->assertRedirectTo('/auth'); + $this->assertRedirectTo('/auth/index/rmodule/admin/rcontroller/access/raction/listmodule/roleid/2'); } } From d68ee4973815bc22caf87e851d4483de7c9bc04e Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 21 Oct 2020 14:49:33 +0200 Subject: [PATCH 072/270] OPUSVIER-4415 Depend on dev-master libraries --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 457aec8624..e47b351350 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,8 @@ "jpgraph/jpgraph": "dev-master", "solarium/solarium": "3.8.*", "opus4-repo/opus4-common": "dev-master", - "opus4-repo/framework": "dev-OPUSVIER-4395", - "opus4-repo/search": "dev-OPUSVIER-4395", + "opus4-repo/framework": "dev-master", + "opus4-repo/search": "dev-master", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", From c95df6aaf76becec81ea694a0edd36210d777658 Mon Sep 17 00:00:00 2001 From: stconradr Date: Thu, 12 Nov 2020 10:38:05 +0100 Subject: [PATCH 073/270] =?UTF-8?q?OPUSVIER-4298=20Embargofristen=20aus=20?= =?UTF-8?q?SWORD=20Schnittstelle=20=C3=BCbernehmen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/Application/Import/Importer.php | 1 + library/Application/Import/opus-import.xsd | 2 ++ 2 files changed, 3 insertions(+) diff --git a/library/Application/Import/Importer.php b/library/Application/Import/Importer.php index 15c09ad9c5..a22697c5bb 100644 --- a/library/Application/Import/Importer.php +++ b/library/Application/Import/Importer.php @@ -347,6 +347,7 @@ private function resetDocument($doc) 'CompletedYear', 'ThesisDateAccepted', 'ThesisYearAccepted', + 'EmbargoDate', 'ContributingCorporation', 'CreatingCorporation', 'Edition', diff --git a/library/Application/Import/opus-import.xsd b/library/Application/Import/opus-import.xsd index ca8751432e..2c25a9a8ee 100644 --- a/library/Application/Import/opus-import.xsd +++ b/library/Application/Import/opus-import.xsd @@ -263,11 +263,13 @@ + + From c2007644e548aec6ace6e79a1a62be0e26b48284 Mon Sep 17 00:00:00 2001 From: stconradr Date: Fri, 13 Nov 2020 10:05:45 +0100 Subject: [PATCH 074/270] Update Importer.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Einrückung angepasst --- library/Application/Import/Importer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Application/Import/Importer.php b/library/Application/Import/Importer.php index a22697c5bb..6f0ad48969 100644 --- a/library/Application/Import/Importer.php +++ b/library/Application/Import/Importer.php @@ -347,7 +347,7 @@ private function resetDocument($doc) 'CompletedYear', 'ThesisDateAccepted', 'ThesisYearAccepted', - 'EmbargoDate', + 'EmbargoDate', 'ContributingCorporation', 'CreatingCorporation', 'Edition', From 18fe62466b5bb5a7847673d6be6eb90631314633 Mon Sep 17 00:00:00 2001 From: stconradr Date: Fri, 13 Nov 2020 10:07:25 +0100 Subject: [PATCH 075/270] Update opus-import.xsd --- library/Application/Import/opus-import.xsd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/Application/Import/opus-import.xsd b/library/Application/Import/opus-import.xsd index 2c25a9a8ee..be2898959d 100644 --- a/library/Application/Import/opus-import.xsd +++ b/library/Application/Import/opus-import.xsd @@ -263,13 +263,13 @@ - + - + @@ -412,4 +412,4 @@ - \ No newline at end of file + From 3ef3d46f2ede281af9fb8947f4c0a2890d10675c Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 15 Nov 2020 01:09:32 +0100 Subject: [PATCH 076/270] fixed typos in comments --- library/Application/Form/Element/EnrichmentKey.php | 2 +- modules/admin/forms/Document/Enrichment.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Application/Form/Element/EnrichmentKey.php b/library/Application/Form/Element/EnrichmentKey.php index b52a958c57..16f0e73484 100644 --- a/library/Application/Form/Element/EnrichmentKey.php +++ b/library/Application/Form/Element/EnrichmentKey.php @@ -97,7 +97,7 @@ public function hasKeyName($keyName) } /** - * Fügt den übergebenen EnrichmentKey-Namen zur Auswahl hinzu, sofern es nicht bereits existiert. + * Fügt den übergebenen EnrichmentKey-Namen zur Auswahl hinzu, sofern er nicht bereits existiert. * * @param $keyName */ diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index d31385197a..cd3c9e6f12 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -619,7 +619,7 @@ public function getErrors($name = null, $suppressArrayNotation = false) * Verstößt der in einem Feld gespeicherte Enrichment-Wert gegen die aktuelle Typkonfiguration * des Enrichment Keys, so wird im Validierungsmodus "non strict" nur ein Hinweis, aber keine * Fehlermeldung angezeigt. Der unveränderte (aber bezüglich der aktuellen Typkonfiguration invalide) - * Wert lässt sicher weiterhin speichern. + * Wert lässt sich weiterhin speichern. * * Wichtig: diese Methode muss sowohl beim ersten Formularaufruf (GET-Request) als auch beim * Speichern des Formulars (POST-Request) aufgerufen werden, wenn es Validierungsfehler gibt. From 84acafdc3b5a1ae2d3fa6d12fe876b391785c834 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 15 Nov 2020 11:42:42 +0100 Subject: [PATCH 077/270] removed obsolete method parameter --- library/Application/Form/Model/Table.php | 2 +- tests/library/Application/Form/Model/TableTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Application/Form/Model/Table.php b/library/Application/Form/Model/Table.php index 7603f26092..f467498c22 100644 --- a/library/Application/Form/Model/Table.php +++ b/library/Application/Form/Model/Table.php @@ -179,7 +179,7 @@ public function setController($controller) * Determines if a link for the show action should be rendered. * @return bool true - link should be rendered */ - public function isRenderShowActionLink($model = null) + public function isRenderShowActionLink() { if (! is_null($this->_controller)) { if (! method_exists($this->_controller, 'getShowActionEnabled')) { diff --git a/tests/library/Application/Form/Model/TableTest.php b/tests/library/Application/Form/Model/TableTest.php index 6599054bc2..a68bf49fb0 100644 --- a/tests/library/Application/Form/Model/TableTest.php +++ b/tests/library/Application/Form/Model/TableTest.php @@ -180,7 +180,7 @@ public function testIsRenderShowActionLinkLog() $mock = $this->getMockBuilder(Zend_Controller_Action_Interface::class)->getMock(); $form->setController($mock); - $this->assertTrue($form->isRenderShowActionLink(null)); + $this->assertTrue($form->isRenderShowActionLink()); $this->assertEquals('The used controller does not have the method getShowActionEnabled.', $logger->getMessages()[0]); } From 8762d4541fbe57f2f04b2496177faffc76f6cb58 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 15 Nov 2020 13:02:58 +0100 Subject: [PATCH 078/270] apply namespace changes to class --- tests/modules/admin/forms/Document/EnrichmentTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index 299d95a380..d17b982788 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -632,7 +632,7 @@ public function testValidationNoneWithSelectTypeAndValidValue() $result = $form->isValid($post); - $enrichment = new Opus_Enrichment($enrichmentId); + $enrichment = new Enrichment($enrichmentId); $form->updateModel($enrichment); $enrichmentValue = $enrichment->getValue(); @@ -669,7 +669,7 @@ public function testValidationNoneWithSelectTypeAndAcceptedValue() $result = $form->isValid($post); - $enrichment = new Opus_Enrichment($enrichmentId); + $enrichment = new Enrichment($enrichmentId); $form->updateModel($enrichment); $enrichmentValue = $enrichment->getValue(); @@ -776,7 +776,7 @@ public function testValidationStrictWithSelectTypeAndLastValidValue() $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(0, $form->getErrors('Value')); - $enrichment = new Opus_Enrichment($enrichmentId); + $enrichment = new Enrichment($enrichmentId); $form->updateModel($enrichment); $this->assertEquals($options[count($options) - 1], $enrichment->getValue()); From 09afd61db059456f887a3cb3e4dc4c0468b8352a Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 15 Nov 2020 13:09:40 +0100 Subject: [PATCH 079/270] apply namespace changes to class --- modules/admin/forms/Document/Enrichment.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index 676589920c..69ad9a602a 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -38,7 +38,6 @@ use Opus\Enrichment\SelectType; use Opus\Enrichment\TextType; use Opus\Model\ModelException; -use Opus\Model\NotFoundException; /** * Unterformular für einzelne Enrichments im Metadaten-Formular. @@ -119,7 +118,7 @@ public function populateFromModel($enrichment) * Texteingabefeld verwendet. * * @param string $enrichmentValue Wert des anzuzeigenden Enrichments (in der Datenbank) - * @param Opus_EnrichmentKey|null $enrichmentKey EnrichmentKey des Enrichments, für das ein Eingabeformularelement + * @param EnrichmentKey|null $enrichmentKey EnrichmentKey des Enrichments, für das ein Eingabeformularelement * erzeugt werden soll * @param string|null $formValue aktueller Formularwert für das Enrichment (nur bei der Verarbeitung eines * POST-Requests gesetzt) @@ -291,7 +290,7 @@ public function getModel() try { $enrichment = new Enrichment($enrichmentId); - } catch (NotFoundException $omnfe) { + } catch (ModelException $omnfe) { $this->getLogger()->err( __METHOD__ . " Unknown enrichment ID = '$enrichmentId' (" . $omnfe->getMessage() . ').' ); @@ -467,8 +466,8 @@ private function handleSelectFieldStrict($enrichmentData, $enrichmentType, $pare $enrichmentId = $enrichmentData[self::ELEMENT_ID]; $enrichment = null; try { - $enrichment = new Opus_Enrichment($enrichmentId); - } catch (Opus\Model\Exception $e) { + $enrichment = new Enrichment($enrichmentId); + } catch (ModelException $e) { // ignore exception silently and do not change validation result } @@ -631,7 +630,7 @@ public function getErrors($name = null, $suppressArrayNotation = false) * Wichtig: diese Methode muss sowohl beim ersten Formularaufruf (GET-Request) als auch beim * Speichern des Formulars (POST-Request) aufgerufen werden, wenn es Validierungsfehler gibt. * - * @param Opus_EnrichmentKey $enrichmentKey Name des Enrichment-Keys + * @param EnrichmentKey $enrichmentKey Name des Enrichment-Keys * * @throws Zend_Form_Exception */ From 468301d5dbced6551bb0bb4412117ba0d50692c0 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sun, 15 Nov 2020 13:45:52 +0100 Subject: [PATCH 080/270] added missing import of class TextType --- tests/modules/admin/forms/Document/EnrichmentTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index d17b982788..6f2ccf3f4a 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -36,6 +36,7 @@ use Opus\EnrichmentKey; use Opus\Enrichment\RegexType; use Opus\Enrichment\SelectType; +use Opus\Enrichment\TextType; /** * Unit Test für Unterformular für ein Enrichment im Metadaten-Formular. From 01a222913fc1166528e5236dfe0c178cae59a56f Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Mon, 23 Nov 2020 17:43:13 +0100 Subject: [PATCH 081/270] added test cases for OPUSVIER-4298 --- .../Application/Import/ImporterTest.php | 36 +++++++++++++++++++ .../Application/Import/XmlValidationTest.php | 36 +++++++++++++++++++ tests/resources/import/embargo-date.xml | 17 +++++++++ .../import/incomplete-embargo-date.xml | 18 ++++++++++ .../import/incomplete-embargo-year.xml | 18 ++++++++++ 5 files changed, 125 insertions(+) create mode 100644 tests/resources/import/embargo-date.xml create mode 100644 tests/resources/import/incomplete-embargo-date.xml create mode 100644 tests/resources/import/incomplete-embargo-year.xml diff --git a/tests/library/Application/Import/ImporterTest.php b/tests/library/Application/Import/ImporterTest.php index c2460a0844..6312a66f1d 100644 --- a/tests/library/Application/Import/ImporterTest.php +++ b/tests/library/Application/Import/ImporterTest.php @@ -56,6 +56,42 @@ public function testImportEnrichmentWithoutValue() $this->assertEquals('Berlin', $document->getEnrichmentValue('City')); } + /** + * Bei der Angabe eines EmbargoDate im Import-XML muss eine Tages- und Monatsangabe sowie + * eine Jahresangabe enthalten sein. Eine alleinige Jahresangabe ist nicht zulässig. + */ + public function testImportInvalidEmbargoDate() + { + $xml = file_get_contents(APPLICATION_PATH . '/tests/resources/import/incomplete-embargo-date.xml'); + + $importer = new Application_Import_Importer($xml, false, Log::get()); + + $this->setExpectedException(Application_Import_MetadataImportSkippedDocumentsException::class); + $importer->run(); + + $document = $importer->getDocument(); + $this->assertNull($document); + } + + public function testValidEmbargoDate() + { + $xml = file_get_contents(APPLICATION_PATH . '/tests/resources/import/embargo-date.xml'); + + $importer = new Application_Import_Importer($xml, false, Log::get()); + + $importer->run(); + + $document = $importer->getDocument(); + + $this->assertNotNull($document); + $this->assertInstanceOf('Opus\Document', $document); + + $embargoDate = $document->getEmbargoDate(); + $this->assertEquals(12, $embargoDate->getDay()); + $this->assertEquals(11, $embargoDate->getMonth()); + $this->assertEquals(2042, $embargoDate->getYear()); + } + public function testFromArray() { $doc = Document::get(146); diff --git a/tests/library/Application/Import/XmlValidationTest.php b/tests/library/Application/Import/XmlValidationTest.php index 95a2a192d2..d802249a94 100644 --- a/tests/library/Application/Import/XmlValidationTest.php +++ b/tests/library/Application/Import/XmlValidationTest.php @@ -83,6 +83,42 @@ public function testEnrichmentWithoutValueValid() $this->assertCount(0, $errors); } + /** + * In XML Schema 1.0 lässt sich die Forderung, dass bei der Angabe eines Embargo-Date + * sowohl das Attribute monthDay und year angegeben werden muss, nicht definieren. + * + * Daher wird ein Dokument, in dem für das Embargo-Date nur die Jahresangabe enthalten + * ist, als valide betrachtet. + */ + public function testIncompleteEmbargoDateMissingMonthDay() + { + $validator = new Application_Import_XmlValidation(); + + $xml = file_get_contents(APPLICATION_PATH . '/tests/resources/import/incomplete-embargo-date.xml'); + + $this->assertTrue($validator->validate($xml)); + } + + public function testIncompleteEmbargoDateMissingYear() + { + $validator = new Application_Import_XmlValidation(); + + $xml = file_get_contents(APPLICATION_PATH . '/tests/resources/import/incomplete-embargo-year.xml'); + + $this->assertFalse($validator->validate($xml)); + + $this->assertCount(1, $validator->getErrors()); + } + + public function testCompleteEmbargoDate() + { + $validator = new Application_Import_XmlValidation(); + + $xml = file_get_contents(APPLICATION_PATH . '/tests/resources/import/embargo-date.xml'); + + $this->assertTrue($validator->validate($xml)); + } + private function _checkValid($xml, $name) { $validator = new Application_Import_XmlValidation(); diff --git a/tests/resources/import/embargo-date.xml b/tests/resources/import/embargo-date.xml new file mode 100644 index 0000000000..7bec776af2 --- /dev/null +++ b/tests/resources/import/embargo-date.xml @@ -0,0 +1,17 @@ + + + + + + + + valid embargoed document + + + + + + + \ No newline at end of file diff --git a/tests/resources/import/incomplete-embargo-date.xml b/tests/resources/import/incomplete-embargo-date.xml new file mode 100644 index 0000000000..5ed9c17d7b --- /dev/null +++ b/tests/resources/import/incomplete-embargo-date.xml @@ -0,0 +1,18 @@ + + + + + + + + invalid embargoed document + + + + + + + + \ No newline at end of file diff --git a/tests/resources/import/incomplete-embargo-year.xml b/tests/resources/import/incomplete-embargo-year.xml new file mode 100644 index 0000000000..1ccb4a6003 --- /dev/null +++ b/tests/resources/import/incomplete-embargo-year.xml @@ -0,0 +1,18 @@ + + + + + + + + invalid embargoed document + + + + + + + + \ No newline at end of file From bb2511c73d13c7a97327271d402d2f182a3ee028 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 30 Nov 2020 17:43:10 +0100 Subject: [PATCH 082/270] OPUSVIER-4484 Fixed escaping for command. --- bin/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install.sh b/bin/install.sh index 364a607a63..61483eaf17 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -299,7 +299,7 @@ then echo -e "Solr server is running under http://localhost:$SOLR_SERVER_PORT/solr\n" # start indexing of testdata - "$BASEDIR/bin/opus4 index:index" + "$BASEDIR/bin/opus4" index:index fi cd "$BASEDIR" From 537fb865a5491df7461ce563f19e977fc0e40011 Mon Sep 17 00:00:00 2001 From: Jens Schwidder Date: Thu, 3 Dec 2020 17:12:28 +0100 Subject: [PATCH 083/270] OPUSVIER-4100 EOL at EOF --- modules/admin/language/enrichments.tmx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/admin/language/enrichments.tmx b/modules/admin/language/enrichments.tmx index 59f86e20ab..d766e6f943 100644 --- a/modules/admin/language/enrichments.tmx +++ b/modules/admin/language/enrichments.tmx @@ -23,4 +23,4 @@ - \ No newline at end of file + From 945075d6babe945b9401a00a562b63c1b020cb20 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 4 Dec 2020 13:55:31 +0100 Subject: [PATCH 084/270] OPUSVIER-4298 EOL at EOF, Tests cleanup --- tests/library/Application/Import/ImporterTest.php | 8 +++----- tests/resources/import/embargo-date.xml | 2 +- tests/resources/import/incomplete-embargo-date.xml | 2 +- tests/resources/import/incomplete-embargo-year.xml | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/library/Application/Import/ImporterTest.php b/tests/library/Application/Import/ImporterTest.php index 6312a66f1d..5b25795d22 100644 --- a/tests/library/Application/Import/ImporterTest.php +++ b/tests/library/Application/Import/ImporterTest.php @@ -50,7 +50,7 @@ public function testImportEnrichmentWithoutValue() $document = $importer->getDocument(); $this->assertNotNull($document); - $this->assertInstanceOf('Opus\Document', $document); + $this->assertInstanceOf(Document::class, $document); $this->assertCount(1, $document->getEnrichment()); $this->assertEquals('Berlin', $document->getEnrichmentValue('City')); @@ -68,9 +68,6 @@ public function testImportInvalidEmbargoDate() $this->setExpectedException(Application_Import_MetadataImportSkippedDocumentsException::class); $importer->run(); - - $document = $importer->getDocument(); - $this->assertNull($document); } public function testValidEmbargoDate() @@ -84,7 +81,7 @@ public function testValidEmbargoDate() $document = $importer->getDocument(); $this->assertNotNull($document); - $this->assertInstanceOf('Opus\Document', $document); + $this->assertInstanceOf(Document::class, $document); $embargoDate = $document->getEmbargoDate(); $this->assertEquals(12, $embargoDate->getDay()); @@ -94,6 +91,7 @@ public function testValidEmbargoDate() public function testFromArray() { + $this->markTestIncomplete('Test for debugging - TODO expand'); $doc = Document::get(146); // var_dump($doc->toArray()); diff --git a/tests/resources/import/embargo-date.xml b/tests/resources/import/embargo-date.xml index 7bec776af2..299d0c691b 100644 --- a/tests/resources/import/embargo-date.xml +++ b/tests/resources/import/embargo-date.xml @@ -14,4 +14,4 @@ - \ No newline at end of file + diff --git a/tests/resources/import/incomplete-embargo-date.xml b/tests/resources/import/incomplete-embargo-date.xml index 5ed9c17d7b..105a9e749a 100644 --- a/tests/resources/import/incomplete-embargo-date.xml +++ b/tests/resources/import/incomplete-embargo-date.xml @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/tests/resources/import/incomplete-embargo-year.xml b/tests/resources/import/incomplete-embargo-year.xml index 1ccb4a6003..184c576229 100644 --- a/tests/resources/import/incomplete-embargo-year.xml +++ b/tests/resources/import/incomplete-embargo-year.xml @@ -15,4 +15,4 @@ - \ No newline at end of file + From f517ccf85683420caf00a0a81a29507e2d76771e Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sat, 5 Dec 2020 22:09:32 +0100 Subject: [PATCH 085/270] removed obsolete lines --- tests/library/Application/Import/ImporterTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/library/Application/Import/ImporterTest.php b/tests/library/Application/Import/ImporterTest.php index 6312a66f1d..e1a2fceb8e 100644 --- a/tests/library/Application/Import/ImporterTest.php +++ b/tests/library/Application/Import/ImporterTest.php @@ -68,9 +68,6 @@ public function testImportInvalidEmbargoDate() $this->setExpectedException(Application_Import_MetadataImportSkippedDocumentsException::class); $importer->run(); - - $document = $importer->getDocument(); - $this->assertNull($document); } public function testValidEmbargoDate() From 0d3d9db2d7412664e7fba5034d3afee559068193 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Mon, 7 Dec 2020 16:42:38 +0100 Subject: [PATCH 086/270] #373: bugfix --- public/layouts/default/common.phtml | 32 ++++++++++++++-------- public/layouts/opus4/debug.phtml | 41 ++++++++++++++++++----------- 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/public/layouts/default/common.phtml b/public/layouts/default/common.phtml index 09eeb15b9f..a399e3be77 100755 --- a/public/layouts/default/common.phtml +++ b/public/layouts/default/common.phtml @@ -273,16 +273,26 @@ if ($dbprofiler->getEnabled() === true) : ?> Peak memory consumption:
      getQueryProfiles()) : ?> Queries:
      -
        - -
      • -
        getQuery()) ?>
        -
      • - - -
      • ...
      • - -
      +
      + + + +
      :
      +
      + $profiler_max_queries) { + echo '...'; + break; + } + ?> +
      getQuery()) ?>
      +
      + +
@@ -297,7 +307,7 @@ if (isset($config->debugSession) and ((bool)$config->debugSession === true) and

Session

-
+
 
 
diff --git a/public/layouts/opus4/debug.phtml b/public/layouts/opus4/debug.phtml index 66c4a1dd43..572ef3255e 100644 --- a/public/layouts/opus4/debug.phtml +++ b/public/layouts/opus4/debug.phtml @@ -2,8 +2,7 @@ $dbprofiler = \Zend_Registry::get('db_adapter')->getProfiler(); $profiler_show_queries = isset($config->db->params->showqueries) && filter_var($config->db->params->showqueries, FILTER_VALIDATE_BOOLEAN); $profiler_max_queries = (int) $config->db->params->maxqueries; -if ($dbprofiler->getEnabled() === true) : - ?> +if ($dbprofiler->getEnabled() === true) : ?>

Profiling information @@ -11,20 +10,32 @@ if ($dbprofiler->getEnabled() === true) : (execution time )

- Total number of queries: getTotalNumQueries() ?>
- Total query time (s): getTotalElapsedSecs() ?>
- Current memory consumption:
- Peak memory consumption:
+ Total number of queries: getTotalNumQueries() ?>
+ Total query time (s): getTotalElapsedSecs() ?>
+ Current memory consumption:
+ Peak memory consumption:
getQueryProfiles()) : ?> - Queries:
-
    - -
  • getQuery()) ?>
  • - - -
  • ...
  • - -
+ Queries:
+
+ + + +
:
+
+ $profiler_max_queries) { + echo '...'; + break; + } + ?> +
getQuery()) ?>
+
+ +
From 7d3b386e5d39d13b44cbd042ad691e5efc95275d Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Mon, 7 Dec 2020 16:55:08 +0100 Subject: [PATCH 087/270] #373: fixed coding style violations --- public/layouts/default/common.phtml | 6 ++---- public/layouts/opus4/debug.phtml | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/public/layouts/default/common.phtml b/public/layouts/default/common.phtml index a399e3be77..cf37a20679 100755 --- a/public/layouts/default/common.phtml +++ b/public/layouts/default/common.phtml @@ -279,15 +279,13 @@ if ($dbprofiler->getEnabled() === true) : ?>
:
$profiler_max_queries) { echo '...'; - break; - } + break; } ?>
getQuery()) ?>
diff --git a/public/layouts/opus4/debug.phtml b/public/layouts/opus4/debug.phtml index 572ef3255e..1f61d8026b 100644 --- a/public/layouts/opus4/debug.phtml +++ b/public/layouts/opus4/debug.phtml @@ -22,15 +22,13 @@ if ($dbprofiler->getEnabled() === true) : ?>
:
$profiler_max_queries) { echo '...'; - break; - } + break; } ?>
getQuery()) ?>
From 31a13531257a08e18faa9dd0aa96ce2cc2a68db3 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Mon, 7 Dec 2020 17:03:19 +0100 Subject: [PATCH 088/270] #373: second try of fixing coding style violations --- public/layouts/default/common.phtml | 8 ++++---- public/layouts/opus4/debug.phtml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/public/layouts/default/common.phtml b/public/layouts/default/common.phtml index cf37a20679..ba698ea763 100755 --- a/public/layouts/default/common.phtml +++ b/public/layouts/default/common.phtml @@ -279,14 +279,14 @@ if ($dbprofiler->getEnabled() === true) : ?> + continue; + } ?>
:
$profiler_max_queries) { echo '...'; - break; } - ?> + break; + } ?>
getQuery()) ?>
diff --git a/public/layouts/opus4/debug.phtml b/public/layouts/opus4/debug.phtml index 1f61d8026b..5321ce70b4 100644 --- a/public/layouts/opus4/debug.phtml +++ b/public/layouts/opus4/debug.phtml @@ -22,14 +22,14 @@ if ($dbprofiler->getEnabled() === true) : ?> + continue; + } ?>
:
$profiler_max_queries) { echo '...'; - break; } - ?> + break; + } ?>
getQuery()) ?>
From fce6bde7ecd0cba411f805873b701f7e139c5466 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 7 Dec 2020 18:00:43 +0100 Subject: [PATCH 089/270] Issue #373 Coding style. --- public/layouts/default/common.phtml | 8 ++++---- public/layouts/opus4/debug.phtml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/public/layouts/default/common.phtml b/public/layouts/default/common.phtml index ba698ea763..e9eef093e4 100755 --- a/public/layouts/default/common.phtml +++ b/public/layouts/default/common.phtml @@ -275,18 +275,18 @@ if ($dbprofiler->getEnabled() === true) : ?> Queries:
- -
:
- $profiler_max_queries) { + $profiler_max_queries) : echo '...'; break; - } ?> + endif ?>
getQuery()) ?>
diff --git a/public/layouts/opus4/debug.phtml b/public/layouts/opus4/debug.phtml index 5321ce70b4..4013fa3af8 100644 --- a/public/layouts/opus4/debug.phtml +++ b/public/layouts/opus4/debug.phtml @@ -18,18 +18,18 @@ if ($dbprofiler->getEnabled() === true) : ?> Queries:
- -
:
- $profiler_max_queries) { + $profiler_max_queries) : echo '...'; break; - } ?> + endif ?>
getQuery()) ?>
From 20d373916f23c7352e3ae053696bf13f7b0cf908 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 7 Dec 2020 21:13:28 +0100 Subject: [PATCH 090/270] Issue #373 Valides XHTML. --- public/layouts/opus4/debug.phtml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/layouts/opus4/debug.phtml b/public/layouts/opus4/debug.phtml index 4013fa3af8..54e881adf1 100644 --- a/public/layouts/opus4/debug.phtml +++ b/public/layouts/opus4/debug.phtml @@ -25,12 +25,11 @@ if ($dbprofiler->getEnabled() === true) : ?> continue; } ?>
:
-
- $profiler_max_queries) : +
$profiler_max_queries) : echo '...'; break; - endif ?> -
getQuery()) ?>
+ endif ?>getQuery()) ?>
From 63a017551b36e46fd543ffd96c87feeb3f62f43f Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 7 Dec 2020 21:18:41 +0100 Subject: [PATCH 091/270] Issue #373 Moved coding style check to end of build --- .github/workflows/php.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 30fc822c66..05ca9640fc 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -31,9 +31,6 @@ jobs: - name: Mail-Server run: php scripts/opus-smtp-dumpserver.php 2>&1 >> tests/workspace/log/opus-smtp-dumpserver.log & - - name: Coding-Style - run: php composer.phar cs-check - - name: Test-library run: php composer.phar test -- --testsuite library @@ -48,3 +45,6 @@ jobs: - name: Test-scripts run: php composer.phar test -- --testsuite scripts + + - name: Coding-Style + run: php composer.phar cs-check From 0d87a7a5a6269b1247176d3e2e43196a9d0d1d3a Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Wed, 9 Dec 2020 19:54:13 +0100 Subject: [PATCH 092/270] enabled session.cookie_httponly --- apacheconf/apache22.conf.template | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apacheconf/apache22.conf.template b/apacheconf/apache22.conf.template index a4100da227..a29a4c761b 100644 --- a/apacheconf/apache22.conf.template +++ b/apacheconf/apache22.conf.template @@ -50,7 +50,8 @@ Alias /OPUS_URL_BASE "/BASEDIR/public" php_flag short_open_tag on # Setting cookie options - php_value session.cookie_path /OPUS_URL_BASE + php_value session.cookie_path /OPUS_URL_BASE + php_value session.cookie_httponly on # On Debian/Ubuntu, prevent PHP from deleting the cookies #Enable for UBUNTU/DEBIAN:# php_value session.gc_probability 0 From 06a03aca0522a72f53ca920022f14b23a9a2c873 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Wed, 9 Dec 2020 19:54:46 +0100 Subject: [PATCH 093/270] enabled session.cookie_httponly --- apacheconf/apache24.conf.template | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apacheconf/apache24.conf.template b/apacheconf/apache24.conf.template index cbd39e44a2..2800a9d157 100644 --- a/apacheconf/apache24.conf.template +++ b/apacheconf/apache24.conf.template @@ -48,7 +48,8 @@ Alias /OPUS_URL_BASE "/BASEDIR/public" php_flag short_open_tag on # Setting cookie options - php_value session.cookie_path /OPUS_URL_BASE + php_value session.cookie_path /OPUS_URL_BASE + php_value session.cookie_httponly on # On Debian/Ubuntu, prevent PHP from deleting the cookies #Enable for UBUNTU/DEBIAN:# php_value session.gc_probability 0 From 120d190622590db610ecb992747a6bad974a8e77 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 11 Dec 2020 15:23:13 +0100 Subject: [PATCH 094/270] OPUSVIER-4494 Add import folder to workspace --- bin/install-testdata.sh | 1 + bin/prepare-workspace.sh | 1 + build.xml | 2 + db/masterdata/022-set-opus-version.sql | 2 +- .../Update/AddImportToWorkspace.php | 64 +++++++++++++++++++ .../014-Create-import-folder-in-workspace.php | 42 ++++++++++++ tests/rebuilding_database.sh | 2 + 7 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 library/Application/Update/AddImportToWorkspace.php create mode 100755 scripts/update/014-Create-import-folder-in-workspace.php diff --git a/bin/install-testdata.sh b/bin/install-testdata.sh index 27c3e9d67c..f7cdbacac6 100755 --- a/bin/install-testdata.sh +++ b/bin/install-testdata.sh @@ -34,6 +34,7 @@ BASEDIR="`dirname "$SCRIPT_PATH"`" # mkdir -p "$BASEDIR/tests/workspace/files" +mkdir -p "$BASEDIR/tests/workspace/import" mkdir -p "$BASEDIR/tests/workspace/incoming" mkdir -p "$BASEDIR/tests/workspace/log" mkdir -p "$BASEDIR/tests/workspace/cache" diff --git a/bin/prepare-workspace.sh b/bin/prepare-workspace.sh index 7c1e323256..6093262598 100755 --- a/bin/prepare-workspace.sh +++ b/bin/prepare-workspace.sh @@ -31,6 +31,7 @@ SCRIPT_PATH="`dirname "$SCRIPT_NAME_FULL"`" BASEDIR="`dirname "$SCRIPT_PATH"`" mkdir -p "$BASEDIR/workspace/files" +mkdir -p "$BASEDIR/workspace/import" mkdir -p "$BASEDIR/workspace/incoming" mkdir -p "$BASEDIR/workspace/log" mkdir -p "$BASEDIR/workspace/cache" diff --git a/build.xml b/build.xml index 2c799ab5f9..b8c90a9bc7 100644 --- a/build.xml +++ b/build.xml @@ -73,6 +73,7 @@ + @@ -83,6 +84,7 @@ + diff --git a/db/masterdata/022-set-opus-version.sql b/db/masterdata/022-set-opus-version.sql index fd51b649f9..df43a69da4 100644 --- a/db/masterdata/022-set-opus-version.sql +++ b/db/masterdata/022-set-opus-version.sql @@ -11,7 +11,7 @@ START TRANSACTION; -- Set internal OPUS version (for controlling updates) TRUNCATE TABLE `opus_version`; -INSERT INTO `opus_version` (`version`) VALUES (13); +INSERT INTO `opus_version` (`version`) VALUES (14); COMMIT; diff --git a/library/Application/Update/AddImportToWorkspace.php b/library/Application/Update/AddImportToWorkspace.php new file mode 100644 index 0000000000..85553f6666 --- /dev/null +++ b/library/Application/Update/AddImportToWorkspace.php @@ -0,0 +1,64 @@ + + * @copyright Copyright (c) 2020, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +use Opus\Util\ConsoleColors; + +/** + * Add import folder to workspace. + */ +class Application_Update_AddImportToWorkspace extends Application_Update_PluginAbstract +{ + + public function run() + { + $this->log('Checking import folder in workspace'); + + $workspacePath = Application_Configuration::getInstance()->getWorkspacePath(); + + $importPath = rtrim($workspacePath, '/') . '/import'; + + if (file_exists($importPath)) { + $this->log("Folder '$importPath' already exists."); + } else { + mkdir($importPath); + $this->log("Folder '$importPath' created."); + + $colors = new ConsoleColors(); + + $this->log($colors->yellow( + 'You might have to update the file permission (group) of the folder, so it can be accessed by Apache2.', + $colors::RED + )); + } + } +} diff --git a/scripts/update/014-Create-import-folder-in-workspace.php b/scripts/update/014-Create-import-folder-in-workspace.php new file mode 100755 index 0000000000..16a7314b08 --- /dev/null +++ b/scripts/update/014-Create-import-folder-in-workspace.php @@ -0,0 +1,42 @@ +#!/usr/bin/env php + + + * @copyright Copyright (c) 2020, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +require_once dirname(__FILE__) . '/../common/update.php'; + +/** + */ + +$update = new Application_Update_AddImportToWorkspace(); +$update->run(); diff --git a/tests/rebuilding_database.sh b/tests/rebuilding_database.sh index f0e6273c68..dd71b5e00a 100755 --- a/tests/rebuilding_database.sh +++ b/tests/rebuilding_database.sh @@ -131,6 +131,7 @@ mkdir -p $workspace_files_dir mkdir -p $workspace_log_dir mkdir -p $workspace_dir/cache mkdir -p $workspace_dir/export +mkdir -p $workspace_dir/import mkdir -p $workspace_dir/incoming mkdir -p $workspace_dir/tmp mkdir -p $workspace_dir/tmp/resumption @@ -139,6 +140,7 @@ mkdir -p $series_logos_dir rm -rf "${workspace_test_dir:?}"/* mkdir -p $workspace_test_dir/cache mkdir -p $workspace_test_dir/export +mkdir -p $workspace_test_dir/import mkdir -p $workspace_test_dir/incoming mkdir -p $workspace_test_dir/tmp mkdir -p $workspace_test_dir/tmp/resumption From 432ce4ab6f235109fe2aac3cca32f8811c7f8f79 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 11 Dec 2020 17:28:42 +0100 Subject: [PATCH 095/270] OPUSVIER-4496 Show workspace folders in admin --- .../Application/Configuration/Workspace.php | 65 +++++++++++++++++++ modules/admin/controllers/InfoController.php | 7 +- modules/admin/language/info.tmx | 20 +++++- modules/admin/views/scripts/info/index.phtml | 54 +++++++++++---- modules/default/language/default.tmx | 18 +++++ public/layouts/opus4/css/admin.css | 32 +++++++++ 6 files changed, 180 insertions(+), 16 deletions(-) create mode 100644 library/Application/Configuration/Workspace.php diff --git a/library/Application/Configuration/Workspace.php b/library/Application/Configuration/Workspace.php new file mode 100644 index 0000000000..d8dd56dab5 --- /dev/null +++ b/library/Application/Configuration/Workspace.php @@ -0,0 +1,65 @@ + + * @copyright Copyright (c) 2020 + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +/** + * Checking of information about workspace. + */ +class Application_Configuration_Workspace +{ + + public function getFolders() + { + $workspacePath = Application_Configuration::getInstance()->getWorkspacePath(); + + $folders = []; + + foreach (new DirectoryIterator($workspacePath) as $fileInfo) { + if ($fileInfo->isDot() or $fileInfo->isFile()) { + continue; // ignore '.' and '..' and files + } + + $name = $fileInfo->getBasename(); + + if (substr($name, 0, 1) === '.') { + continue; // ignore folders starting with a dot + } + + $status = $fileInfo->isReadable() ? 'r' : ''; + $status .= $fileInfo->isWritable() ? 'w' : ''; + + $folders[$name] = $status; + } + + return $folders; + } +} diff --git a/modules/admin/controllers/InfoController.php b/modules/admin/controllers/InfoController.php index 32929d78c0..551fa98428 100644 --- a/modules/admin/controllers/InfoController.php +++ b/modules/admin/controllers/InfoController.php @@ -32,7 +32,7 @@ * @package Module_Admin * @author Jens Schwidder * @author Michael Lang - * @copyright Copyright (c) 2008-2014, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ class Admin_InfoController extends Application_Controller_Action @@ -52,6 +52,11 @@ public function indexAction() } $this->view->postMaxSize = ini_get('post_max_size'); $this->view->uploadMaxFilesize = ini_get('upload_max_filesize'); + + $workspace = new Application_Configuration_Workspace(); + $folders = $workspace->getFolders(); + ksort($folders); + $this->view->workspaceFolders = $folders; } /** diff --git a/modules/admin/language/info.tmx b/modules/admin/language/info.tmx index 936fcaf4ec..8e1c0caa15 100644 --- a/modules/admin/language/info.tmx +++ b/modules/admin/language/info.tmx @@ -123,7 +123,25 @@ Installierte OPUS Version - + + + + Other Parameters + + + Weitere Parameter + + + + + + Workspace + + + Arbeitsverzeichnisse + + + File 'VERSION.txt' not found. diff --git a/modules/admin/views/scripts/info/index.phtml b/modules/admin/views/scripts/info/index.phtml index 4060f03e50..14b1ffa7a1 100644 --- a/modules/admin/views/scripts/info/index.phtml +++ b/modules/admin/views/scripts/info/index.phtml @@ -24,29 +24,37 @@ * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * @category TODO + * @category Application * @author Jens Schwidder * @author Michael Lang - * @copyright Copyright (c) 2008-2014, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ + + +$opusVersion = Application_Configuration::getOpusVersion(); ?> +
+ translate('admin_info_version') ?> + +
+ -
- $infoValue) : ?> -
translate($infoKey)) ?>
-
- -
+
+ translate('admin_info_other') ?> +
+ $infoValue) : ?> +
translate($infoKey)) ?>
+
+ +
+
-
-
- translate('admin_info_versioncheck')) ?>
-
-
translate('admin_info_section_upload') ?> @@ -78,3 +86,21 @@
+ +
+ translate('admin_info_workspace') ?> + + + + + + + workspaceFolders as $folder => $state) : ?> + + + + + +
translate('folder') ?>translate('state') ?>
+ +
diff --git a/modules/default/language/default.tmx b/modules/default/language/default.tmx index d83c87d35f..f06177ace2 100644 --- a/modules/default/language/default.tmx +++ b/modules/default/language/default.tmx @@ -755,5 +755,23 @@
+ + + Folder + + + Verzeichnis + + + + + + Status + + + State + + + diff --git a/public/layouts/opus4/css/admin.css b/public/layouts/opus4/css/admin.css index 2b59c4a1e2..519ea707fa 100644 --- a/public/layouts/opus4/css/admin.css +++ b/public/layouts/opus4/css/admin.css @@ -2543,3 +2543,35 @@ a.create-document-link { .code { font-family: monospace; } + +.admin_info fieldset { + margin-bottom: 2.5em; +} + +.admin_info fieldset legend { + text-transform: none; + font-size: 1.5em; + border-bottom: 2px solid #26517d; + margin-bottom: 1em; +} + +.admin_info fieldset .opus-version-info { + font-size: 1.3em; + margin-left: 2em; +} + +.admin_info fieldset table { + font-size: 1.3em; + margin-left: 2em; + margin-right: 2em; + margin-top: 0; + padding-left: 0; + margin-bottom: 0; + width: auto; +} + +.admin_info table.workspace-folders tr.state-r, +.admin_info table.workspace-folders tr.state- { + background: #ffb1ae; +} + From 6dc672e999bbd22e8ad0ef243a65c7984801c0ea Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Tue, 15 Dec 2020 00:45:27 +0100 Subject: [PATCH 096/270] OPUSVIER-4140: split EKs into managed and unmanaged ones --- modules/admin/forms/EnrichmentTable.php | 27 ++++ .../scripts/enrichmentkey/enrichment.phtml | 111 +++++++++++++ .../scripts/enrichmentkey/modeltable.phtml | 87 ++--------- public/layouts/opus4/css/admin.css | 4 +- .../EnrichmentkeyControllerTest.php | 147 +++++++++++++++++- 5 files changed, 291 insertions(+), 85 deletions(-) create mode 100644 modules/admin/views/scripts/enrichmentkey/enrichment.phtml diff --git a/modules/admin/forms/EnrichmentTable.php b/modules/admin/forms/EnrichmentTable.php index 4bb8a81221..52693364f0 100644 --- a/modules/admin/forms/EnrichmentTable.php +++ b/modules/admin/forms/EnrichmentTable.php @@ -41,6 +41,10 @@ class Admin_Form_EnrichmentTable extends Application_Form_Model_Table { private $enrichmentKeys; + private $managedKeys = array(); + + private $unmanagedKeys = array(); + public function init() { $this->enrichmentKeys = new Admin_Model_EnrichmentKeys(); @@ -120,4 +124,27 @@ public function getRowTooltip($model) return ""; } + + public function setModels($models) + { + parent::setModels($models); + foreach ($models as $enrichmentKey) { + if (is_null($enrichmentKey->getEnrichmentType())) { + $this->unmanagedKeys[] = $enrichmentKey; + } + else { + $this->managedKeys[] = $enrichmentKey; + } + } + } + + public function getManaged() + { + return $this->managedKeys; + } + + public function getUnmanaged() + { + return $this->unmanagedKeys; + } } diff --git a/modules/admin/views/scripts/enrichmentkey/enrichment.phtml b/modules/admin/views/scripts/enrichmentkey/enrichment.phtml new file mode 100644 index 0000000000..05aa53135a --- /dev/null +++ b/modules/admin/views/scripts/enrichmentkey/enrichment.phtml @@ -0,0 +1,111 @@ + + * @copyright Copyright (c) 2008-2020, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ +?> + + + + + + managed) : ?> + + + + + + + enrichments as $enrichment) : ?> + + + managed) : ?> + + + + + + + + + +
NameTyp
+ getId())) : ?> + getDisplayName()) ?> + + + getDisplayName()) ?> + + element->isProtected($enrichment)) : ?> + + + + + getType()) ?> + getOptionsPrintable(); + if (! is_null($optionsPrintable)) : ?> + + + + getId())) : ?> + translate('admin_button_create'); ?> + element->isModifiable($enrichment)) : ?> + translate('admin_button_edit'); ?> + + + getId())) : ?> + translate('admin_button_remove_from_documents'); ?> + element->isModifiable($enrichment) && $this->element->isUsed($enrichment)) : ?> + translate('admin_button_remove_from_documents'); ?> + + + element->isModifiable($enrichment)) : ?> + translate('admin_button_translations'); ?> + + + getId()) && $this->element->isModifiable($enrichment)) : ?> + translate('admin_button_remove'); ?> + +
diff --git a/modules/admin/views/scripts/enrichmentkey/modeltable.phtml b/modules/admin/views/scripts/enrichmentkey/modeltable.phtml index ebcf869981..c88268cda6 100644 --- a/modules/admin/views/scripts/enrichmentkey/modeltable.phtml +++ b/modules/admin/views/scripts/enrichmentkey/modeltable.phtml @@ -27,7 +27,7 @@ * @category Application * @package Application_View_Scripts_EnrichmentKey * @author Sascha Szott - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2020, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ ?> @@ -36,79 +36,14 @@ translate($this->element->getColumnLabel(0)) ?> - - - - - - - - - element->getModels() as $model) : ?> - - - - - - - - - - -
NameTyp
- getId())) : ?> - getDisplayName()) ?> - - - getDisplayName()) ?> - - element->isProtected($model)) : ?> - - - - - getType()) ?> - getOptionsPrintable(); - if (! is_null($optionsPrintable)) : ?> - - - - getId())) : ?> - translate('admin_button_create'); ?> - element->isModifiable($model)) : ?> - translate('admin_button_edit'); ?> - - - getId())) : ?> - translate('admin_button_remove_from_documents'); ?> - element->isModifiable($model) && $this->element->isUsed($model)) : ?> - translate('admin_button_remove_from_documents'); ?> - - - element->isModifiable($model)) : ?> - translate('admin_button_translations'); ?> - - - getId()) && $this->element->isModifiable($model)) : ?> - translate('admin_button_remove'); ?> - -
+ +partial('enrichmentkey/enrichment.phtml', [ + 'managed' => true, + 'enrichments' => $this->element->getManaged(), + 'element' => $this->element]); ?> +partial('enrichmentkey/enrichment.phtml', [ + 'managed' => false, + 'enrichments' => $this->element->getUnmanaged(), + 'element' => $this->element]); ?> diff --git a/public/layouts/opus4/css/admin.css b/public/layouts/opus4/css/admin.css index 2b59c4a1e2..89df0fe737 100644 --- a/public/layouts/opus4/css/admin.css +++ b/public/layouts/opus4/css/admin.css @@ -2536,7 +2536,9 @@ a.create-document-link { float: right; } -#enrichmentkeyTable span.strong { +#enrichmentkeyTable span.strong, +#enrichmentkeyTableManaged span.strong, +#enrichmentkeyTableUnmanaged span.strong { font-weight: bold; } diff --git a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php index 89099c3ccc..e274b34cd6 100644 --- a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php +++ b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php @@ -839,8 +839,8 @@ public function testProtectedCssClassIsSet() foreach ($protectedKeys as &$value) { if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an protected css-class in enrichmentkeyTable - $this->assertXpathContentContains('//table[@id="enrichmentkeyTable"] - //tr[contains(@class,\'protected\')]', $value); + $this->assertXpathContentContains( + '//table[@id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'protected\')]', $value); } } } @@ -859,8 +859,9 @@ public function testUsedCssClassIsSet() foreach ($usedKeys as &$value) { if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an used css-class in enrichmentkeyTable - $this->assertXpathContentContains('//table[@id="enrichmentkeyTable"] - //tr[contains(@class,\'used\')]', $value); + $this->assertXpathContentContains( + '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'used\')]', + $value); } } } @@ -880,8 +881,9 @@ public function testProtectedCssClassIsNotSet() foreach ($unprotectedKeys as &$value) { if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an protected css-class in enrichmentkeyTable - $this->assertNotXpathContentContains('//table[@id="enrichmentkeyTable"] - //tr[contains(@class,\'protected\')]', $value); + $this->assertNotXpathContentContains( + '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'protected\')]', + $value); } } } @@ -900,8 +902,9 @@ public function testUsedCssClassIsNotSet() foreach ($unusedKeys as &$value) { if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an unused css-class in enrichmentkeyTable - $this->assertXpathContentContains('//table[@id="enrichmentkeyTable"] - //tr[contains(@class,\'unused\')]', $value); + $this->assertXpathContentContains( + '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'unused\')]', + $value); } } } @@ -1256,4 +1259,132 @@ public function enrichmentKeyNamesProvider() ['Audience'] // referenced enrichment key ]; } + + /** + * Tests the function getUnmanaged() + * + * @covers ::getUnmanaged + */ + public function testGetUnmanaged() + { + $this->dispatch($this->getControllerPath() . '/'); + + $this->assertResponseCode(200); + + $domDoc = new DOMDocument(); + $domDoc->loadHTML($this->getResponse()->getBody()); + $xpath = new DOMXPath($domDoc); + $nodeList = $xpath->query('//table[@id="enrichmentkeyTableUnmanaged"]/tbody/tr'); + $tableRowCount = $nodeList->length; + + $enrichmentKeyLast = new EnrichmentKey(); + $enrichmentKeyLast->setName('unmanagedEKlast'); + $enrichmentKeyLast->store(); + + $enrichmentKeyFirst = new EnrichmentKey(); + $enrichmentKeyFirst->setName('unmanagedEKfirst'); + $enrichmentKeyFirst->store(); + + $this->getResponse()->clearBody(); + + $this->dispatch($this->getControllerPath() . '/'); + + $this->assertResponseCode(200); + + // cleanup + $enrichmentKeyFirst->delete(); + $enrichmentKeyLast->delete(); + + $domDoc = new DOMDocument(); + $domDoc->loadHTML($this->getResponse()->getBody()); + $xpath = new DOMXPath($domDoc); + + // zwei neue Zeilen sollten in Tabelle für unmanaged EKs erscheinen + $nodeList = $xpath->query('//table[@id="enrichmentkeyTableUnmanaged"]/tbody/tr'); + $this->assertEquals(2 + $tableRowCount, $nodeList->length); + + // unmanagedEKfirst sollte direkt vor unmanagedEKlast erscheinen (in der Tabelle für unmanaged EKs) + $foundFirst = false; + $foundLast = false; + foreach ($nodeList as $node) { + $textContent = trim($node->textContent); + if (strpos($textContent, 'unmanagedEKfirst') === 0) { + $foundFirst = true; + continue; + } + else if ($foundFirst) { + if (strpos($textContent, 'unmanagedEKlast') === 0) { + $foundLast = true; + } + break; + } + } + $this->assertTrue($foundFirst); + $this->assertTrue($foundLast); + } + + /** + * Tests the function getManaged() + * + * @covers ::getManaged + */ + public function testGetManaged() + { + $this->dispatch($this->getControllerPath() . '/'); + + $this->assertResponseCode(200); + + $domDoc = new DOMDocument(); + $domDoc->loadHTML($this->getResponse()->getBody()); + $xpath = new DOMXPath($domDoc); + $nodeList = $xpath->query('//table[@id="enrichmentkeyTableManaged"]/tbody/tr'); + $tableRowCount = $nodeList->length; + + $enrichmentKeyLast = new EnrichmentKey(); + $enrichmentKeyLast->setName('managedEKlast'); + $enrichmentKeyLast->setType('TextType'); + $enrichmentKeyLast->store(); + + $enrichmentKeyFirst = new EnrichmentKey(); + $enrichmentKeyFirst->setName('managedEKfirst'); + $enrichmentKeyFirst->setType('TextType'); + $enrichmentKeyFirst->store(); + + $this->getResponse()->clearBody(); + + $this->dispatch($this->getControllerPath() . '/'); + + $this->assertResponseCode(200); + + // cleanup + $enrichmentKeyFirst->delete(); + $enrichmentKeyLast->delete(); + + $domDoc = new DOMDocument(); + $domDoc->loadHTML($this->getResponse()->getBody()); + $xpath = new DOMXPath($domDoc); + + // zwei neue Zeilen sollten in Tabelle für managed EKs erscheinen + $nodeList = $xpath->query('//table[@id="enrichmentkeyTableManaged"]/tbody/tr'); + $this->assertEquals(2 + $tableRowCount, $nodeList->length); + + // managedEKfirst sollte direkt vor managedEKlast erscheinen (in der Tabelle für managed EKs) + $foundFirst = false; + $foundLast = false; + foreach ($nodeList as $node) { + $textContent = trim($node->textContent); + if (strpos($textContent, 'managedEKfirst') === 0) { + $foundFirst = true; + continue; + } + else if ($foundFirst) { + if (strpos($textContent, 'managedEKlast') === 0) { + $foundLast = true; + } + break; + } + } + $this->assertTrue($foundFirst); + $this->assertTrue($foundLast); + } } From c8b40797e36163fc024c6ea5fe878394c6a07111 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Tue, 15 Dec 2020 00:53:50 +0100 Subject: [PATCH 097/270] OPUSVIER-4140: do not show empty tables --- .../views/scripts/enrichmentkey/enrichment.phtml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/admin/views/scripts/enrichmentkey/enrichment.phtml b/modules/admin/views/scripts/enrichmentkey/enrichment.phtml index 05aa53135a..aabb0c527d 100644 --- a/modules/admin/views/scripts/enrichmentkey/enrichment.phtml +++ b/modules/admin/views/scripts/enrichmentkey/enrichment.phtml @@ -32,18 +32,19 @@ */ ?> +enrichments) && ! empty($this->enrichments)) : ?> managed) : ?> - + - enrichments as $enrichment) : ?> + enrichments as $enrichment) : ?> - +
Name TypTyp
@@ -51,8 +52,8 @@ getDisplayName()) ?> - getDisplayName()) ?> - + getDisplayName()) ?> + element->isProtected($enrichment)) : ?>
+ From eb03f998f8b560aeb8f310b6e0091b9f4a2af107 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Tue, 15 Dec 2020 02:21:30 +0100 Subject: [PATCH 098/270] OPUSVIER-4202: allow displaying EK specific error messages --- modules/admin/forms/Document/Enrichment.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index 69ad9a602a..5e1f831855 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -504,14 +504,24 @@ private function handleSelectFieldStrict($enrichmentData, $enrichmentType, $pare */ public function isValid($data) { + $enrichmentData = $data[$this->getName()]; + $enrichmentKey = EnrichmentKey::fetchByName($enrichmentData[self::ELEMENT_KEY_NAME]); + + $keyName = null; + if (! is_null($enrichmentKey)) { + $keyName = $enrichmentKey->getName(); + } + // ggf. Anzeige einer EK-spezifischen Fehlermeldung + $errorMessage = $this->handleEnrichmentKeySpecificTranslations('errorMessage', $keyName); + $valueElement = $this->getElement(self::ELEMENT_VALUE); + $valueElement->clearErrorMessages()->addError($errorMessage); + $validationResult = parent::isValid($data); // ggf. kann das negative Validierungsergebnis noch auf "positiv" (true / valid) geändert werden, // wenn die Validation Policy des Enrichment Types des verwendeten Enrichment Keys auf "none" // gesetzt wurde und sich der Enrichment-Wert im POST-Request nicht vom ursprünglich im // Dokument gespeicherten Enrichment-Wert unterscheidet - $enrichmentData = $data[$this->getName()]; - $enrichmentKey = EnrichmentKey::fetchByName($enrichmentData[self::ELEMENT_KEY_NAME]); if (! is_null($enrichmentKey)) { $enrichmentType = $enrichmentKey->getEnrichmentType(); if (! is_null($enrichmentType)) { From 0e510dfe9f4beb6e81e0a01f67a94517c6251e15 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Tue, 15 Dec 2020 02:27:35 +0100 Subject: [PATCH 099/270] OPUSVIER-4140: fixed coding style violations --- modules/admin/forms/EnrichmentTable.php | 7 +++---- .../controllers/EnrichmentkeyControllerTest.php | 17 ++++++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/modules/admin/forms/EnrichmentTable.php b/modules/admin/forms/EnrichmentTable.php index 52693364f0..59dc13e381 100644 --- a/modules/admin/forms/EnrichmentTable.php +++ b/modules/admin/forms/EnrichmentTable.php @@ -41,9 +41,9 @@ class Admin_Form_EnrichmentTable extends Application_Form_Model_Table { private $enrichmentKeys; - private $managedKeys = array(); + private $managedKeys = []; - private $unmanagedKeys = array(); + private $unmanagedKeys = []; public function init() { @@ -131,8 +131,7 @@ public function setModels($models) foreach ($models as $enrichmentKey) { if (is_null($enrichmentKey->getEnrichmentType())) { $this->unmanagedKeys[] = $enrichmentKey; - } - else { + } else { $this->managedKeys[] = $enrichmentKey; } } diff --git a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php index e274b34cd6..aeb246b0ba 100644 --- a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php +++ b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php @@ -840,7 +840,8 @@ public function testProtectedCssClassIsSet() if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an protected css-class in enrichmentkeyTable $this->assertXpathContentContains( - '//table[@id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'protected\')]', $value); + '//table[@id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'protected\')]', + $value); } } } @@ -860,8 +861,8 @@ public function testUsedCssClassIsSet() if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an used css-class in enrichmentkeyTable $this->assertXpathContentContains( - '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'used\')]', - $value); + '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'used\')]', + $value); } } } @@ -882,8 +883,8 @@ public function testProtectedCssClassIsNotSet() if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an protected css-class in enrichmentkeyTable $this->assertNotXpathContentContains( - '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'protected\')]', - $value); + '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'protected\')]', + $value); } } } @@ -1311,8 +1312,7 @@ public function testGetUnmanaged() if (strpos($textContent, 'unmanagedEKfirst') === 0) { $foundFirst = true; continue; - } - else if ($foundFirst) { + } else if ($foundFirst) { if (strpos($textContent, 'unmanagedEKlast') === 0) { $foundLast = true; } @@ -1376,8 +1376,7 @@ public function testGetManaged() if (strpos($textContent, 'managedEKfirst') === 0) { $foundFirst = true; continue; - } - else if ($foundFirst) { + } else if ($foundFirst) { if (strpos($textContent, 'managedEKlast') === 0) { $foundLast = true; } From f331f842467c4aa207e3ac1bb571015984954f95 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Tue, 15 Dec 2020 09:56:47 +0100 Subject: [PATCH 100/270] OPUSVIER-4140: fixed coding style violations --- .../EnrichmentkeyControllerTest.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php index aeb246b0ba..a17fcb2bdf 100644 --- a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php +++ b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php @@ -840,8 +840,9 @@ public function testProtectedCssClassIsSet() if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an protected css-class in enrichmentkeyTable $this->assertXpathContentContains( - '//table[@id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'protected\')]', - $value); + '//table[@id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'protected\')]', + $value + ); } } } @@ -861,8 +862,9 @@ public function testUsedCssClassIsSet() if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an used css-class in enrichmentkeyTable $this->assertXpathContentContains( - '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'used\')]', - $value); + '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'used\')]', + $value + ); } } } @@ -883,8 +885,9 @@ public function testProtectedCssClassIsNotSet() if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an protected css-class in enrichmentkeyTable $this->assertNotXpathContentContains( - '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'protected\')]', - $value); + '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'protected\')]', + $value + ); } } } @@ -904,8 +907,9 @@ public function testUsedCssClassIsNotSet() if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an unused css-class in enrichmentkeyTable $this->assertXpathContentContains( - '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'unused\')]', - $value); + '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'unused\')]', + $value + ); } } } From 81bd563bb49e9bd6af47df4177500ff3744744cd Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Tue, 15 Dec 2020 10:39:45 +0100 Subject: [PATCH 101/270] fixed indentation --- .../modules/admin/controllers/EnrichmentkeyControllerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php index a17fcb2bdf..26e55b934f 100644 --- a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php +++ b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php @@ -907,8 +907,8 @@ public function testUsedCssClassIsNotSet() if (strpos($response->getBody(), $value) !== false) { // Xpath looks, if value has an unused css-class in enrichmentkeyTable $this->assertXpathContentContains( - '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'unused\')]', - $value + '//table[@id="enrichmentkeyTableManaged" or @id="enrichmentkeyTableUnmanaged"]//tr[contains(@class,\'unused\')]', + $value ); } } From 51d2997024479f4eb4ed0d3a555f4b82864bc33b Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Wed, 16 Dec 2020 01:50:46 +0100 Subject: [PATCH 102/270] removed obsolete translation keys --- modules/admin/language/validation.tmx | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/modules/admin/language/validation.tmx b/modules/admin/language/validation.tmx index ec74552a89..9e08b33092 100644 --- a/modules/admin/language/validation.tmx +++ b/modules/admin/language/validation.tmx @@ -162,24 +162,6 @@ - - - This selection is not valid. - - - Dieser Auswahlwert steht nicht zur Verfügung. - - - - - - This value is not valid. - - - Dieser Wert ist nicht gültig. - - - Role names must only contains letters and numbers and start with a letter. From 5f0d89eec4d11303f336d7dc644acc6a4988446d Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Wed, 16 Dec 2020 01:52:03 +0100 Subject: [PATCH 103/270] fixed broken tests; added tests with EK specific translation keys --- .../admin/forms/Document/EnrichmentTest.php | 133 ++++++++++++++---- 1 file changed, 102 insertions(+), 31 deletions(-) diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index 6f2ccf3f4a..bb54139a88 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -452,7 +452,7 @@ public function testValidationWithoutType() $this->assertContains('notInArray', $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); - $this->assertContains('isEmpty', $form->getErrors('Value')); + $this->assertContains('admin_enrichment_errorMessage', $form->getElement('Value')->getErrorMessages()); } private function createTestSelectType($options, $strictValidation = false) @@ -575,7 +575,7 @@ public function testValidationNoneWithSelectTypeAndMissingValue() $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); - $this->assertContains('isEmpty', $form->getErrors('Value')); + $this->assertContains('admin_enrichment_errorMessage', $form->getElement('Value')->getErrorMessages()); } public function testValidationNoneWithSelectTypeAndInvalidValue() @@ -608,7 +608,7 @@ public function testValidationNoneWithSelectTypeAndInvalidValue() $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); - $this->assertContains('notInArray', $form->getErrors('Value')); + $this->assertContains('admin_enrichment_errorMessage', $form->getElement('Value')->getErrorMessages()); } public function testValidationNoneWithSelectTypeAndValidValue() @@ -837,12 +837,12 @@ public function testValidationWithRegexType() $this->assertFalse($form->isValid($post)); - $this->assertCount(0, $form->getErrors('KeyName')); + // cleanup + $enrichmentKey->delete(); + $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); - $this->assertContains('regexNotMatch', $form->getErrors('Value')); - - $enrichmentKey->delete(); + $this->assertContains('admin_enrichment_errorMessage', $form->getElement('Value')->getErrorMessages()); } public function testValidationWithRegexTypeWithMissingValue() @@ -866,12 +866,12 @@ public function testValidationWithRegexTypeWithMissingValue() $this->assertFalse($form->isValid($post)); - $this->assertCount(0, $form->getErrors('KeyName')); + // cleanup + $enrichmentKey->delete(); + $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); - $this->assertContains('isEmpty', $form->getErrors('Value')); - - $enrichmentKey->delete(); + $this->assertContains('admin_enrichment_errorMessage', $form->getElement('Value')->getErrorMessages()); } public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() @@ -897,12 +897,12 @@ public function testValidationWithRegexTypeUsedByFirstEnrichmentKey() $this->assertFalse($form->isValid($post)); - $this->assertCount(0, $form->getErrors('KeyName')); + // cleanup + $enrichmentKey->delete(); + $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); - $this->assertContains('regexNotMatch', $form->getErrors('Value')); - - $enrichmentKey->delete(); + $this->assertContains('admin_enrichment_errorMessage', $form->getElement('Value')->getErrorMessages()); } public function testValidationStrictWithRegexTypeAndInvalidOriginalValue() @@ -926,12 +926,12 @@ public function testValidationStrictWithRegexTypeAndInvalidOriginalValue() $this->assertFalse($form->isValid($post)); - $this->assertCount(0, $form->getErrors('KeyName')); + // cleanup + $enrichmentKey->delete(); + $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); - $this->assertContains('regexNotMatch', $form->getErrors('Value')); - - $enrichmentKey->delete(); + $this->assertContains('admin_enrichment_errorMessage', $form->getElement('Value')->getErrorMessages()); } public function testValidationStrictWithRegexTypeAndInvalidChangedValue() @@ -955,12 +955,12 @@ public function testValidationStrictWithRegexTypeAndInvalidChangedValue() $this->assertFalse($form->isValid($post)); - $this->assertCount(0, $form->getErrors('KeyName')); + // cleanup + $enrichmentKey->delete(); + $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); - $this->assertContains('regexNotMatch', $form->getErrors('Value')); - - $enrichmentKey->delete(); + $this->assertContains('admin_enrichment_errorMessage', $form->getElement('Value')->getErrorMessages()); } public function testValidationStrictWithRegexTypeAndValidValue() @@ -984,10 +984,11 @@ public function testValidationStrictWithRegexTypeAndValidValue() $this->assertTrue($form->isValid($post)); + //cleanup + $enrichmentKey->delete(); + $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(0, $form->getErrors('Value')); - - $enrichmentKey->delete(); } public function testValidationNoneWithRegexTypeAndInvalidOriginalValue() @@ -1011,10 +1012,11 @@ public function testValidationNoneWithRegexTypeAndInvalidOriginalValue() $this->assertTrue($form->isValid($post)); + // cleanup + $enrichmentKey->delete(); + $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(0, $form->getErrors('Value')); - - $enrichmentKey->delete(); } public function testValidationNoneWithRegexTypeAndInvalidChangedValue() @@ -1038,12 +1040,12 @@ public function testValidationNoneWithRegexTypeAndInvalidChangedValue() $this->assertFalse($form->isValid($post)); - $this->assertCount(0, $form->getErrors('KeyName')); + // cleanup + $enrichmentKey->delete(); + $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(1, $form->getErrors('Value')); - $this->assertContains('regexNotMatch', $form->getErrors('Value')); - - $enrichmentKey->delete(); + $this->assertContains('admin_enrichment_errorMessage', $form->getElement('Value')->getErrorMessages()); } public function testValidationNoneWithRegexTypeAndValidValue() @@ -1067,10 +1069,79 @@ public function testValidationNoneWithRegexTypeAndValidValue() $this->assertTrue($form->isValid($post)); + // cleanup + $enrichmentKey->delete(); + $this->assertCount(0, $form->getErrors('KeyName')); $this->assertCount(0, $form->getErrors('Value')); + } + + public function testEnrichmentKeySpecificTranslationWithRegexType() + { + $translate = \Zend_Registry::get('Zend_Translate'); + $translate->setTranslations('admin_enrichment_ektest_errorMessage', ['de' => 'de', 'en' => 'en']); + $translate->loadTranslations(true); + + $type = $this->createTestRegexType('^abc$'); + $enrichmentKey = $this->createEnrichmentKey('ektest', $type); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('ektest', 'invalidvalue'); + + $form = new Admin_Form_Document_Enrichment(); + $form->setName('Enrichment0'); + $form->initValueFormElement('ektest', $enrichmentId); + + $post = [ + 'Enrichment0' => [ + 'Id' => $enrichmentId, + 'KeyName' => 'ektest', + 'Value' => 'anotherinvalidvalue' // invalid value + ] + ]; + + $this->assertFalse($form->isValid($post)); + + // cleanup + $enrichmentKey->delete(); + + $this->assertCount(1, $form->getErrors('Value')); + $this->assertContains('admin_enrichment_ektest_errorMessage', $form->getElement('Value')->getErrorMessages()); + } + + public function testEnrichmentKeySpecificTranslationWithSelectType() + { + $translate = \Zend_Registry::get('Zend_Translate'); + $translate->setTranslations('admin_enrichment_ektest_errorMessage', ['de' => 'de', 'en' => 'en']); + $translate->loadTranslations(true); + + $options = ['foo', 'bar', 'baz']; + $type = $this->createTestSelectType($options); + + $enrichmentKey = $this->createEnrichmentKey('ektest', $type); + $enrichmentId = $this->createTestDocWithEnrichmentOfGivenKey('ektest'); + + $form = new Admin_Form_Document_Enrichment(); + $form->setName('Enrichment0'); + $form->initValueFormElement('ektest'); + + $post = [ + 'Enrichment0' => [ + 'Id' => $enrichmentId, + 'KeyName' => 'ektest', + 'Value' => count($options) + 1 // diese Option nicht zulässig + ] + ]; + $result = $form->isValid($post); + + // cleanup $enrichmentKey->delete(); + + $this->assertFalse($result); + + $this->assertCount(0, $form->getErrors('KeyName')); + + $this->assertCount(1, $form->getErrors('Value')); + $this->assertContains('admin_enrichment_ektest_errorMessage', $form->getElement('Value')->getErrorMessages()); } private function createTestEnrichmentKey($name, $type = null, $options = null) From 50b00bb92161b45a006e129cefad66b7a29353e2 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Wed, 16 Dec 2020 01:53:37 +0100 Subject: [PATCH 104/270] fixed implementation of OPUSVIER-4202: do not show error message twice --- modules/admin/forms/Document/Enrichment.php | 37 ++++++++++++--------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index 5e1f831855..3d9f7b589e 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -158,6 +158,13 @@ private function createValueFormElement($enrichmentValue, $enrichmentKey = null, // wird $value durch den nachfolgenden Methodenaufruf nicht gesetzt $element = $enrichmentType->getFormElement($value); + $enrichmentKeyName = null; + if (! is_null($enrichmentKey)) { + $enrichmentKeyName = $enrichmentKey->getName(); + } + $translationKey = $this->handleEnrichmentKeySpecificTranslations('errorMessage', $enrichmentKeyName, false); + $element->addErrorMessage($translationKey); + // neues Formularelement soll vor dem Entfernen-Button erscheinen $element->setOrder(2); @@ -472,7 +479,7 @@ private function handleSelectFieldStrict($enrichmentData, $enrichmentType, $pare } if (! is_null($enrichment) && array_search($enrichment->getValue(), $enrichmentType->getValues()) === false) { - $this->getElement(self::ELEMENT_VALUE)->addError($this->handleEnrichmentKeySpecificTranslations('errorMessage', $enrichment->getKeyName())); + $this->getElement(self::ELEMENT_VALUE)->markAsError(); return false; // Auswahlwert ist nach Typkonfiguration nicht zulässig } } else { @@ -504,20 +511,11 @@ private function handleSelectFieldStrict($enrichmentData, $enrichmentType, $pare */ public function isValid($data) { + $validationResult = parent::isValid($data); + $enrichmentData = $data[$this->getName()]; $enrichmentKey = EnrichmentKey::fetchByName($enrichmentData[self::ELEMENT_KEY_NAME]); - $keyName = null; - if (! is_null($enrichmentKey)) { - $keyName = $enrichmentKey->getName(); - } - // ggf. Anzeige einer EK-spezifischen Fehlermeldung - $errorMessage = $this->handleEnrichmentKeySpecificTranslations('errorMessage', $keyName); - $valueElement = $this->getElement(self::ELEMENT_VALUE); - $valueElement->clearErrorMessages()->addError($errorMessage); - - $validationResult = parent::isValid($data); - // ggf. kann das negative Validierungsergebnis noch auf "positiv" (true / valid) geändert werden, // wenn die Validation Policy des Enrichment Types des verwendeten Enrichment Keys auf "none" // gesetzt wurde und sich der Enrichment-Wert im POST-Request nicht vom ursprünglich im @@ -653,23 +651,30 @@ private function handleValidationErrorNonStrict($enrichmentKey = null) if (! is_null($enrichmentKey)) { $enrichmentKeyName = $enrichmentKey->getName(); } - $hint = $this->handleEnrichmentKeySpecificTranslations('validationMessage', $enrichmentKeyName); + $hint = $this->handleEnrichmentKeySpecificTranslations('validationMessage', $enrichmentKeyName, true); $element->setHint($hint); $element->removeDecorator('Errors'); } - private function handleEnrichmentKeySpecificTranslations($keySuffix, $enrichmentKeyName = null) + private function handleEnrichmentKeySpecificTranslations($keySuffix, $enrichmentKeyName = null, $doTranslation = false) { $translator = $this->getTranslator(); $translationPrefix = 'admin_enrichment_'; if (! is_null($enrichmentKeyName)) { $translationKey = $translationPrefix . $enrichmentKeyName . '_' . $keySuffix; if ($translator->isTranslated($translationKey)) { - return $translator->translate($translationKey); + if ($doTranslation) { + return $translator->translate($translationKey); + } + return $translationKey; } } - return $translator->translate($translationPrefix . $keySuffix); + $translationKey = $translationPrefix . $keySuffix; + if ($doTranslation) { + return $translator->translate($translationKey); + } + return $translationKey; } } From 2e21da7b7fd74ba2eefb55002ccffb91d7bef7b1 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 18 Dec 2020 14:57:06 +0100 Subject: [PATCH 105/270] OPUSVIER-4496 Remove OPUS version from general info. --- library/Application/Configuration.php | 1 - 1 file changed, 1 deletion(-) diff --git a/library/Application/Configuration.php b/library/Application/Configuration.php index 56db82f838..a146784e13 100644 --- a/library/Application/Configuration.php +++ b/library/Application/Configuration.php @@ -273,7 +273,6 @@ public static function getOpusVersion() public static function getOpusInfo() { $info = []; - $info['admin_info_version'] = self::getOpusVersion(); return $info; } From a793bff85a5bff2d61653d90a98301dfbe5adbea Mon Sep 17 00:00:00 2001 From: Kaustabh Barman Date: Thu, 31 Dec 2020 18:06:40 +0100 Subject: [PATCH 106/270] OPUSVIER-4251 tabs removed --- .DS_Store | Bin 0 -> 8196 bytes .../sql/990_create_documents_testdata__hhhar.sql | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ad58a724afdd43bb1b04d43e526d3a2dc6f905d0 GIT binary patch literal 8196 zcmeHMO>Y}T7=Fh|leJBnO`0^R0Lj7vRWwA20`&>uI*E!)AR&(0L`iXX*K23VddKXp zlcpiacYXkH=E4D~{{V>_C$1bh@CUeX=&3w2yH0oQ?G>SPN1AzOXWnOKo@YMRvnC=| z={A;$=7~r_6jse6NeH4|#G#N0OK!k2;E4{&B!f6P)Ex3o3sMDA1yTi41yTi41^y2T z;GHdk@{;#{P@ATy0;vM8qypl6C?E=34s9>6^5{S!uK=*4D3$?v+yf-05ZZERdx4cu zv>DtUSO{g|6@vwE)E9(1Y&o>Ozy@$)0i0OaGYfAhO!f|3LAnzw2R2Pp1yTiu6%cp# z9BI@+G@|$Ss?81E<~r)dmb!zu_*@3$i1HHCA)74VH1c6_?;k)t9YBqc4!;2}_GYq| ze&Th)5&WiiY|HbPmi}Owk<6%)w#2?mC{0C`F81i zp>S3zEiDw@U%7pLo>k`FUjDH9sD1k6?CbMyz8BKq@Cgqonhc&V(jSluHL#51kRAJ_ z&+boE?eoj#@~=%?om8i$uT9NN&CXt*o1eWg{rVeq^_s33M=e*3bd}rOt=L_&u1d|-fBR!>G>38~z{-Nh=f?a2Cv0H3`eZWer%&P1j+hCuwZMGlaGyORg zt2Gi>0}tVx9@kvQ=1vPG!aIxA-o<*isX>eMnA&8=_XqnHUeR5ZqgDDCqx_8S(mKYv z2ux!D^K1Y!A-}k_v4c5z`2OYs^(At{yHV`npCfxX326go&{4ckC>2L$z(|k#$Xy(5 zJx6OnTXIZIse?Iy5&WZ=Jhi~XruS$CES3;`=;jZggaUEYJ@nzwkvLnxJh3lvg0Xia z?8oKVr9&?b@ig9tU>x(#(FRp9JL{MmktWRyRz?gnj@jc-s*9dX^5Q*+xsQ2g!Tb=> z0E6V!0^Tvi7`(e!WAY4+w=UWK6k(gCZH)R3=H%1l(M!frgenmm5>-Q52lGwZK`wb+ z3ieU_ICvOP*1{U>*kKgdbFP`XoHhurg JWpY`Qe*sUlj3592 literal 0 HcmV?d00001 diff --git a/tests/sql/990_create_documents_testdata__hhhar.sql b/tests/sql/990_create_documents_testdata__hhhar.sql index 7fb9d0d952..47463810de 100644 --- a/tests/sql/990_create_documents_testdata__hhhar.sql +++ b/tests/sql/990_create_documents_testdata__hhhar.sql @@ -663,7 +663,7 @@ INSERT INTO `document_subjects` (`id`, `document_id`, `language`, `type`, `value (103, 41, 'deu', 'swd', 'Fluid-Struktur-Wechselwirkung', NULL), (104, 41, 'deu', 'swd', 'Nichtlineare Dynamik', NULL), (105, 41, 'deu', 'swd', 'Verzweigung ', NULL), -(106, 41, 'deu', 'swd', '\n Dynamische Verzweigung', NULL), +(106, 41, 'deu', 'swd', '\n Dynamische Verzweigung', NULL), (107, 41, 'deu', 'swd', 'Ordnungsreduktion', NULL), (108, 41, 'deu', 'uncontrolled', 'Kalman-Filter', NULL), (109, 41, 'deu', 'uncontrolled', 'Schiff', NULL), @@ -965,7 +965,7 @@ INSERT INTO `document_title_abstracts` (`id`, `document_id`, `type`, `value`, `l (100, 40, 'abstract', 'In den letzten Jahren hat sich die endovaskuläre Versorgung von abdominalen Aorten-Aneurysmen mittels Stentgrafts neben der konventionellen, offenen Operation als Alternativverfahren zur Vermeidung einer Gefäßruptur etabliert. Das erkrankte Gefäß wird durch eine Schlauchprothese überbrückt und somit vom systemischen Druck abgeschirmt. Trotz der Weiterentwicklung von endovaskulären Aortenprothesen in den letzten 15 Jahren weist die minimal-invasive Versorgung noch eine Re-Interventionsrate von 20% innerhalb von 4 Jahren auf. Mangelnde Abdichtung und Migration der Prothesen zählen zu den häufigsten Versagensursachen.\nIn dieser Arbeit wurden Faktoren für das Versagen von Stentgrafts identifiziert, Grundlagen zur Testung dieser Prothesen gelegt sowie Designkriterien zur Weiterentwicklung dieser Prothesen abgeleitet. Auf Grundlage von klinischen Daten, Experimenten und Berechnungen wurde eine Bestimmung und Beurteilung von Migrations- und Abdichtungsparameter qualitativ\nund quantitativ ermöglicht.\nIn 80% der untersuchten Patienten waren ein Fixierungsverlust infolge einer Gefäßdilatation oder das Abknicken der Prothese verantwortlich für die Migration der Prothesen. Es wurde gezeigt, dass die Permeabilität von Thrombus zu einem erhöhten Druck im Aneurysmasack und somit zu einem Versagen der Behandlung bei wasserdurchlässigen Prothesen und kurzen Fixierungszonen führt. Endoleckagen II verursachen eine Wiederbelastung der Gefäßwand bis zu Werten des systemischen Drucks und führen häufig zum Anwachsen des Aneurysmas.\nAufgrund der hohen Inzidenz dieser Leckage wurde ein neues Prothesendesign in Form einer dünnen, überdimensionierten Membran entwickelt, welche einen Verschluss der Kollateralen ermöglicht. Erste Ergebnisse zeigten, dass durch das Auskleiden des Aneurysmas eine verbesserte Abdichtung des Aneurysmas im Vergleich zu einer Standardprothese und eine adäquate Fixierung im Gefäß erzielt werden.', 'deu'), (101, 40, 'abstract', 'In recent years minimally-invasive endovascular surgery of abdominal aortic aneurysms by means of stentgrafts has emerged alongside conventional open surgery as an alternative procedure for the prevention of vessel rupture. The degenerated vessel is bridged by a tubular prosthesis and is thereby decoupled from the systemic pressure. Despite the continuous evolution of endovascular stentgrafts over the last 15 years minimally-invasive treatment still suffers\na re-intervention rate of 20% within 4 years. Inadequate sealing and migration of the prostheses rank among the most frequent failure causes.\nIn this study, factors of stentgraft failure were identified, basic principles for component testing were established and design criteria for the development of prostheses were derived.\nBased on clinical data, parametric and patient-specific in vitro experiments and on mathematical models, fixation and flow forces were related to occurrence of migration in individual patients. Based on in vitro permeability measurements of thrombus and clotted grafts an analytical model was used to investigate the role of the thrombus as a sealing medium against pressure build-up in the aneurysm sac. Additionally, the influence of retrograde flow through the collateral vessels into the bridged aneurysm (endoleak II) on the pressure acting in the aneurysm was analyzed.\nIn 80% of the patient data examined, a loss of fixation due to vessel dilation in the fixation region, or kinking of the prosthesis, were responsible for migration of the prostheses. The permeability of the thrombus was found to be sufficiently high to lead to pressurisation of the aneurysm sac and thus to a failure of the treatment for a permeable prosthesis and short attachment zones. Endoleak II was found topotentially lead to re-pressurization of the vessel\nwall up to the systemic pressure and was frequently found to be the cause for dilatation of the aneurysm clinically.\nDue to the high incidence of this leakage type a new design was proposed, to completely seal the collateral vessels by means of a thin, oversized membrane. It was demonstrated that sealing of the aneurysm was improved in comparison to a standard prosthesis and appropriate fixation stability could be achieved with the new implant design.', 'eng'), (102, 41, 'main', 'Ein Beitrag zur numerischen und experimentellen Untersuchung extremer Schiffsbewegungen', 'deu'), -(103, 41, 'abstract', 'Die Dynamik von Schiffen kann bei kleinen Anregungen durch lineare Modelle exakt beschrieben und analysiert \n werden. Wachsen die Anregungen, können die Bewegungen Amplituden annehmen, bei denen die Nichtlinearitäten des Systems nicht mehr \n vernachlässigt werden können. In diesen Fällen können das Bewegungsverhalten und das Vorhandensein kritischer Bewegungszustände nur \n noch im Zeitbereich untersucht werden, was auf Simulationen hinausläuft. Das Ergebnis einer Simulation eines nichtlinearen dynamischen \n Systems ist jedoch stark von den Parametern des Systems sowie von den Anfangsbedingungen abhängig, so dass zu jeder Kombination aus \n Anfangsbedingungen und Systemparametern eine Simulation erstellt werden müsste, um die Reaktion eines Schiffes auf alle relevanten \n Seegangsbedingungen bewerten zu können.\n\nSeit zwei Jahrzehnten stehen effiziente mathematische Analyseverfahren zur Behandlung stark nichtlinearer Probleme zur Verfügung. In dieser Arbeit wird \nmit Hilfe der lokalen Verzweigungsanalyse die Existenz kritischer Bewegungsformen gezeigt. Die hydrodynamischen Kräfte und Momente werden dabei mit dem \nProgrammpaket Simbel berechnet. Trotz einer Modifikation der in Simbel implementierten Hydrodynamikberechnung stellte sich heraus, dass die Analyse eines \nvollständig modellierten Schiffes bis heute noch nicht zufriedenstellend gelingt, da die Rechenzeiten immer noch sehr lang sind. Das gleiche gilt für die \nMöglichkeit, in Versuchen preisgünstig gezielt kritische Stellen, die zu einer abrupten Änderung des Systemverhaltens durch eine minimale \nParameteränderung führen, im Experiment zu zeigen. Dabei soll es in diesen Versuchen im Entwicklungsstadium der Methoden nicht um die Untersuchung eines \nspeziellen Schiffsrumpfes unter möglichst realen Seegangsbedingungen gehen, sondern um den experimentellen Nachweis der numerisch ermittelten Phänomene. \n\nIn der vorgestellten Arbeit wird zu beiden Problemen ein Lösungsansatz entwickelt und die Tauglichkeit demonstriert. Für die Versuche ist ein Versuchsschwimmkörper mit einfacher Geometrie entwickelt worden, mit dem im Labor des Institutes umfangreiche Parameterstudien kostengünstig durchgeführt\nwerden können. Das dafür entwickelte berührungslose Positions- und Lagemesssystem liefert Messwerte mit einer Genauigkeit von bis zu einem halben Millimeter in den translatorischen und von einem Hundertstel Grad bei den rotatorischen Freiheitsgraden bei einer Frequenz von 228Hz. Diese Präzision bei einer so hohen Dynamik wird durch den Einsatz eines integrierten Messsystems aus Stereokamera und einer Inertialmesseinheit (IMU) der tactical grade–Klasse, die durch ein erweitertes kontinuierlich–diskretes Kalman–Filter in Echtzeit miteinander kombiniert werden, erreicht. Sowohl die IMU als auch die Stereokamera wurden aus Standardkomponenten aufgebaut, so dass sämtliche Sensorrohdaten und die Zwischenwerte jeder Verarbeitungsstufe vorliegen. Dieser Vorteil im Vergleich zum Einsatz einer kommerziellen IMU oder Stereokamera ermöglicht die Umsetzung unterschiedlicher Integrationstiefen bei der Kombination beider Systeme. In der rechenintensivsten Variante werden Parameter beider Subsysteme als Zustandsgröße des Gesamtsystems geführt, so dass sich einzelne Kameraparameter und IMU–Sensorfehler während des Betriebs schätzen und kompensieren lassen. Im Wellenkanal des Institutes für Mechanik und Meerestechnik ist kein Platz für umfangreiche Manöver oder Tests mit dem fahrenden Schwimmkörper vorhanden. Daher werden die Versuche hier auf einen\nstehenden oder langsam fahrenden Schwimmkörper beschränkt, was jedoch nur eine geringe Einschränkung für die Methodenvalidierung bedeutet. Durch ein dynamisches Positioniersystem wird der Schwimmkörper bei Wellenanregungen auf seiner Sollposition gehalten, ohne dass dabei die Roll- oder die Stampfbewegungen nennenswert angeregt werden. Die Positioniergenauigkeit liegt bei schwachen Anregungen bei schlimmstenfalls ±2mm, bei hohen Wellen und starken Bewegungen liegt die Genauigkeit bei ca. ±10mm quer zu den Wellen und ca. ±30mm in Wellenrichtung.\n\nMit dieser Versuchsanordnung ist es zukünftig möglich, unter beliebigen Winkeln zu den einfallenden Wellen gut wiederholbare Messungen durchzuführen, bei denen man sich in Abstimmung mit den Berechnungen den kritischen Systemzuständen nähern kann. Da die Messungen, die Regelung und die Wellenklappensteuerung miteinander vernetzt sind, kann diese Parametersuche weitestgehend automatisiert ablaufen und gegebenenfalls durch Optimierer beschleunigt werden. \n\nDie numerischen Untersuchungen werden durch ein hier in dieser Arbeit entwickeltes Modellreduktionsverfahren beschleunigt, mit dem die Ordnung des mathematischen Systems deutlich reduziert werden kann. Dies verkürzt zum einen die Rechenzeit, führt aber vor allen Dingen zu einem schnelleren Einschwingen des Systems auf eine periodische Bewegung.', 'deu'), +(103, 41, 'abstract', 'Die Dynamik von Schiffen kann bei kleinen Anregungen durch lineare Modelle exakt beschrieben und analysiert \n werden. Wachsen die Anregungen, können die Bewegungen Amplituden annehmen, bei denen die Nichtlinearitäten des Systems nicht mehr \n vernachlässigt werden können. In diesen Fällen können das Bewegungsverhalten und das Vorhandensein kritischer Bewegungszustände nur \n noch im Zeitbereich untersucht werden, was auf Simulationen hinausläuft. Das Ergebnis einer Simulation eines nichtlinearen dynamischen \n Systems ist jedoch stark von den Parametern des Systems sowie von den Anfangsbedingungen abhängig, so dass zu jeder Kombination aus \n Anfangsbedingungen und Systemparametern eine Simulation erstellt werden müsste, um die Reaktion eines Schiffes auf alle relevanten \n Seegangsbedingungen bewerten zu können.\n\nSeit zwei Jahrzehnten stehen effiziente mathematische Analyseverfahren zur Behandlung stark nichtlinearer Probleme zur Verfügung. In dieser Arbeit wird \nmit Hilfe der lokalen Verzweigungsanalyse die Existenz kritischer Bewegungsformen gezeigt. Die hydrodynamischen Kräfte und Momente werden dabei mit dem \nProgrammpaket Simbel berechnet. Trotz einer Modifikation der in Simbel implementierten Hydrodynamikberechnung stellte sich heraus, dass die Analyse eines \nvollständig modellierten Schiffes bis heute noch nicht zufriedenstellend gelingt, da die Rechenzeiten immer noch sehr lang sind. Das gleiche gilt für die \nMöglichkeit, in Versuchen preisgünstig gezielt kritische Stellen, die zu einer abrupten Änderung des Systemverhaltens durch eine minimale \nParameteränderung führen, im Experiment zu zeigen. Dabei soll es in diesen Versuchen im Entwicklungsstadium der Methoden nicht um die Untersuchung eines \nspeziellen Schiffsrumpfes unter möglichst realen Seegangsbedingungen gehen, sondern um den experimentellen Nachweis der numerisch ermittelten Phänomene. \n\nIn der vorgestellten Arbeit wird zu beiden Problemen ein Lösungsansatz entwickelt und die Tauglichkeit demonstriert. Für die Versuche ist ein Versuchsschwimmkörper mit einfacher Geometrie entwickelt worden, mit dem im Labor des Institutes umfangreiche Parameterstudien kostengünstig durchgeführt\nwerden können. Das dafür entwickelte berührungslose Positions- und Lagemesssystem liefert Messwerte mit einer Genauigkeit von bis zu einem halben Millimeter in den translatorischen und von einem Hundertstel Grad bei den rotatorischen Freiheitsgraden bei einer Frequenz von 228Hz. Diese Präzision bei einer so hohen Dynamik wird durch den Einsatz eines integrierten Messsystems aus Stereokamera und einer Inertialmesseinheit (IMU) der tactical grade–Klasse, die durch ein erweitertes kontinuierlich–diskretes Kalman–Filter in Echtzeit miteinander kombiniert werden, erreicht. Sowohl die IMU als auch die Stereokamera wurden aus Standardkomponenten aufgebaut, so dass sämtliche Sensorrohdaten und die Zwischenwerte jeder Verarbeitungsstufe vorliegen. Dieser Vorteil im Vergleich zum Einsatz einer kommerziellen IMU oder Stereokamera ermöglicht die Umsetzung unterschiedlicher Integrationstiefen bei der Kombination beider Systeme. In der rechenintensivsten Variante werden Parameter beider Subsysteme als Zustandsgröße des Gesamtsystems geführt, so dass sich einzelne Kameraparameter und IMU–Sensorfehler während des Betriebs schätzen und kompensieren lassen. Im Wellenkanal des Institutes für Mechanik und Meerestechnik ist kein Platz für umfangreiche Manöver oder Tests mit dem fahrenden Schwimmkörper vorhanden. Daher werden die Versuche hier auf einen\nstehenden oder langsam fahrenden Schwimmkörper beschränkt, was jedoch nur eine geringe Einschränkung für die Methodenvalidierung bedeutet. Durch ein dynamisches Positioniersystem wird der Schwimmkörper bei Wellenanregungen auf seiner Sollposition gehalten, ohne dass dabei die Roll- oder die Stampfbewegungen nennenswert angeregt werden. Die Positioniergenauigkeit liegt bei schwachen Anregungen bei schlimmstenfalls ±2mm, bei hohen Wellen und starken Bewegungen liegt die Genauigkeit bei ca. ±10mm quer zu den Wellen und ca. ±30mm in Wellenrichtung.\n\nMit dieser Versuchsanordnung ist es zukünftig möglich, unter beliebigen Winkeln zu den einfallenden Wellen gut wiederholbare Messungen durchzuführen, bei denen man sich in Abstimmung mit den Berechnungen den kritischen Systemzuständen nähern kann. Da die Messungen, die Regelung und die Wellenklappensteuerung miteinander vernetzt sind, kann diese Parametersuche weitestgehend automatisiert ablaufen und gegebenenfalls durch Optimierer beschleunigt werden. \n\nDie numerischen Untersuchungen werden durch ein hier in dieser Arbeit entwickeltes Modellreduktionsverfahren beschleunigt, mit dem die Ordnung des mathematischen Systems deutlich reduziert werden kann. Dies verkürzt zum einen die Rechenzeit, führt aber vor allen Dingen zu einem schnelleren Einschwingen des Systems auf eine periodische Bewegung.', 'deu'), (104, 42, 'main', 'Charakterisierung von MOS-Transistoren vor und nach Gateoxiddurchbruch', 'deu'), (105, 42, 'main', 'Characterization of MOS transistors before and after gate oxide breakdown', 'eng'), (106, 42, 'abstract', 'Die fortschreitende Skalierung und zunehmende Packungsdichte integrierter Schaltkreise führt zu immer höheren Belastungen der elektronischen Bauelemente. Bei MOS-Transistoren erhöht sich dadurch die Wahrscheinlichkeit eines Gateoxiddurchbruchs. In der vorliegenden Arbeit werden Untersuchungen zum Verhalten von MOS-Transistoren vor und nach einem Gateoxiddurchbruch präsentiert. Dabei werden unterschiedliche Durchbruchsarten klassifiziert und Modelle für die DC-Kennlinien sowie für das Rauschen (Random Telegraph Signals) nach Durchbruch entwickelt. Mit Hilfe der Modelle wird abschließend die Funktion ausgewählter analoger und digitaler Schaltungen analysiert. Es zeigt sich, daß je nach Anwendung und Durchbruchstyp auch nach Durchbruch eines Transistors die Funktion der Schaltkreise erhalten bleiben kann. Mit diesem Ansatz kann bereits während der Design-Phase die Zuverlässigkeit der Schaltung untersucht werden.', 'deu'), From e36aa118a032f56d137b5d27a2cc8a9079a462f4 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 5 Jan 2021 17:13:38 +0100 Subject: [PATCH 107/270] OPUSVIER-4140 Styling of enrichments page. --- modules/admin/language/enrichmentkey.tmx | 18 +++++++++++++++++ .../scripts/enrichmentkey/modeltable.phtml | 20 ++++++++++++++----- public/layouts/opus4/css/admin.css | 4 ++-- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/modules/admin/language/enrichmentkey.tmx b/modules/admin/language/enrichmentkey.tmx index 0dc50f2163..b0e4414c9e 100644 --- a/modules/admin/language/enrichmentkey.tmx +++ b/modules/admin/language/enrichmentkey.tmx @@ -292,6 +292,24 @@ + + + Managed Keys + + + Registrierte Enrichments + + + + + + Unmanaged Keys + + + Enrichments ohne Typ + + + diff --git a/modules/admin/views/scripts/enrichmentkey/modeltable.phtml b/modules/admin/views/scripts/enrichmentkey/modeltable.phtml index c88268cda6..afee1360b1 100644 --- a/modules/admin/views/scripts/enrichmentkey/modeltable.phtml +++ b/modules/admin/views/scripts/enrichmentkey/modeltable.phtml @@ -32,18 +32,28 @@ */ ?> -

- translate($this->element->getColumnLabel(0)) ?> -

-
+

translate('admin_title_enrichmentkey') ?> + translate('admin_button_add') ?> -

+ + +element->getManaged()) > 0) : ?> +
+ translate('admin_enrichmentkey_managed') ?> partial('enrichmentkey/enrichment.phtml', [ 'managed' => true, 'enrichments' => $this->element->getManaged(), 'element' => $this->element]); ?> +
+ + +element->getUnmanaged()) > 0) : ?> +
+ translate('admin_enrichmentkey_unmanaged') ?> partial('enrichmentkey/enrichment.phtml', [ 'managed' => false, 'enrichments' => $this->element->getUnmanaged(), 'element' => $this->element]); ?> +
+ \ No newline at end of file diff --git a/public/layouts/opus4/css/admin.css b/public/layouts/opus4/css/admin.css index 89df0fe737..43df016995 100644 --- a/public/layouts/opus4/css/admin.css +++ b/public/layouts/opus4/css/admin.css @@ -570,7 +570,7 @@ ul.form-action { /* @group form content */ .adminContainer .collection_new a.add, -.adminContainer .enrichmentkey_new a.add, +.adminContainer span.enrichmentkey_new a.add, .adminContainer table a.add, .adminContainer td.edit a, .adminContainer td.move-up a, @@ -1637,7 +1637,7 @@ ul.links input:hover { } .adminContainer .collection_new a.add, -.adminContainer .enrichmentkey_new a.add, +.adminContainer span.enrichmentkey_new a.add, .adminContainer table a.add { background-position: -17px -16px; border-radius: 5px; From d39b585e3ab7fc9c38070fad6faa4f40b9867846 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 6 Jan 2021 10:00:46 +0100 Subject: [PATCH 108/270] OPUSVIER-4202 Some comments for later. --- modules/admin/forms/Document/Enrichment.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/admin/forms/Document/Enrichment.php b/modules/admin/forms/Document/Enrichment.php index 3d9f7b589e..90b5ea979d 100644 --- a/modules/admin/forms/Document/Enrichment.php +++ b/modules/admin/forms/Document/Enrichment.php @@ -657,6 +657,16 @@ private function handleValidationErrorNonStrict($enrichmentKey = null) $element->removeDecorator('Errors'); } + /** + * @param $keySuffix + * @param null $enrichmentKeyName + * @param false $doTranslation + * @return string + * + * TODO tests for this function + * TODO function does not have to be private + * TODO function could have a better name - it doesn't just "handle" it returns something "get" + */ private function handleEnrichmentKeySpecificTranslations($keySuffix, $enrichmentKeyName = null, $doTranslation = false) { $translator = $this->getTranslator(); From cf817e1276561bfdba98281ca3cc165f2ce2fe4c Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 6 Jan 2021 14:09:55 +0100 Subject: [PATCH 109/270] OPUSVIER-4251 Removed tabs. Fixed dependencies. --- composer.json | 6 +++--- tests/sql/990_create_documents_testdata__hhhar.sql | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 315cde6bfc..e47b351350 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,9 @@ "zendframework/zendframework1": "1.12.*", "jpgraph/jpgraph": "dev-master", "solarium/solarium": "3.8.*", - "opus4-repo/opus4-common": "4.7", - "opus4-repo/framework": "4.7.0.x", - "opus4-repo/search": "4.7.0.x", + "opus4-repo/opus4-common": "dev-master", + "opus4-repo/framework": "dev-master", + "opus4-repo/search": "dev-master", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", diff --git a/tests/sql/990_create_documents_testdata__hhhar.sql b/tests/sql/990_create_documents_testdata__hhhar.sql index 47463810de..a08aa7ca0f 100644 --- a/tests/sql/990_create_documents_testdata__hhhar.sql +++ b/tests/sql/990_create_documents_testdata__hhhar.sql @@ -663,7 +663,7 @@ INSERT INTO `document_subjects` (`id`, `document_id`, `language`, `type`, `value (103, 41, 'deu', 'swd', 'Fluid-Struktur-Wechselwirkung', NULL), (104, 41, 'deu', 'swd', 'Nichtlineare Dynamik', NULL), (105, 41, 'deu', 'swd', 'Verzweigung ', NULL), -(106, 41, 'deu', 'swd', '\n Dynamische Verzweigung', NULL), +(106, 41, 'deu', 'swd', 'Dynamische Verzweigung', NULL), (107, 41, 'deu', 'swd', 'Ordnungsreduktion', NULL), (108, 41, 'deu', 'uncontrolled', 'Kalman-Filter', NULL), (109, 41, 'deu', 'uncontrolled', 'Schiff', NULL), @@ -965,7 +965,7 @@ INSERT INTO `document_title_abstracts` (`id`, `document_id`, `type`, `value`, `l (100, 40, 'abstract', 'In den letzten Jahren hat sich die endovaskuläre Versorgung von abdominalen Aorten-Aneurysmen mittels Stentgrafts neben der konventionellen, offenen Operation als Alternativverfahren zur Vermeidung einer Gefäßruptur etabliert. Das erkrankte Gefäß wird durch eine Schlauchprothese überbrückt und somit vom systemischen Druck abgeschirmt. Trotz der Weiterentwicklung von endovaskulären Aortenprothesen in den letzten 15 Jahren weist die minimal-invasive Versorgung noch eine Re-Interventionsrate von 20% innerhalb von 4 Jahren auf. Mangelnde Abdichtung und Migration der Prothesen zählen zu den häufigsten Versagensursachen.\nIn dieser Arbeit wurden Faktoren für das Versagen von Stentgrafts identifiziert, Grundlagen zur Testung dieser Prothesen gelegt sowie Designkriterien zur Weiterentwicklung dieser Prothesen abgeleitet. Auf Grundlage von klinischen Daten, Experimenten und Berechnungen wurde eine Bestimmung und Beurteilung von Migrations- und Abdichtungsparameter qualitativ\nund quantitativ ermöglicht.\nIn 80% der untersuchten Patienten waren ein Fixierungsverlust infolge einer Gefäßdilatation oder das Abknicken der Prothese verantwortlich für die Migration der Prothesen. Es wurde gezeigt, dass die Permeabilität von Thrombus zu einem erhöhten Druck im Aneurysmasack und somit zu einem Versagen der Behandlung bei wasserdurchlässigen Prothesen und kurzen Fixierungszonen führt. Endoleckagen II verursachen eine Wiederbelastung der Gefäßwand bis zu Werten des systemischen Drucks und führen häufig zum Anwachsen des Aneurysmas.\nAufgrund der hohen Inzidenz dieser Leckage wurde ein neues Prothesendesign in Form einer dünnen, überdimensionierten Membran entwickelt, welche einen Verschluss der Kollateralen ermöglicht. Erste Ergebnisse zeigten, dass durch das Auskleiden des Aneurysmas eine verbesserte Abdichtung des Aneurysmas im Vergleich zu einer Standardprothese und eine adäquate Fixierung im Gefäß erzielt werden.', 'deu'), (101, 40, 'abstract', 'In recent years minimally-invasive endovascular surgery of abdominal aortic aneurysms by means of stentgrafts has emerged alongside conventional open surgery as an alternative procedure for the prevention of vessel rupture. The degenerated vessel is bridged by a tubular prosthesis and is thereby decoupled from the systemic pressure. Despite the continuous evolution of endovascular stentgrafts over the last 15 years minimally-invasive treatment still suffers\na re-intervention rate of 20% within 4 years. Inadequate sealing and migration of the prostheses rank among the most frequent failure causes.\nIn this study, factors of stentgraft failure were identified, basic principles for component testing were established and design criteria for the development of prostheses were derived.\nBased on clinical data, parametric and patient-specific in vitro experiments and on mathematical models, fixation and flow forces were related to occurrence of migration in individual patients. Based on in vitro permeability measurements of thrombus and clotted grafts an analytical model was used to investigate the role of the thrombus as a sealing medium against pressure build-up in the aneurysm sac. Additionally, the influence of retrograde flow through the collateral vessels into the bridged aneurysm (endoleak II) on the pressure acting in the aneurysm was analyzed.\nIn 80% of the patient data examined, a loss of fixation due to vessel dilation in the fixation region, or kinking of the prosthesis, were responsible for migration of the prostheses. The permeability of the thrombus was found to be sufficiently high to lead to pressurisation of the aneurysm sac and thus to a failure of the treatment for a permeable prosthesis and short attachment zones. Endoleak II was found topotentially lead to re-pressurization of the vessel\nwall up to the systemic pressure and was frequently found to be the cause for dilatation of the aneurysm clinically.\nDue to the high incidence of this leakage type a new design was proposed, to completely seal the collateral vessels by means of a thin, oversized membrane. It was demonstrated that sealing of the aneurysm was improved in comparison to a standard prosthesis and appropriate fixation stability could be achieved with the new implant design.', 'eng'), (102, 41, 'main', 'Ein Beitrag zur numerischen und experimentellen Untersuchung extremer Schiffsbewegungen', 'deu'), -(103, 41, 'abstract', 'Die Dynamik von Schiffen kann bei kleinen Anregungen durch lineare Modelle exakt beschrieben und analysiert \n werden. Wachsen die Anregungen, können die Bewegungen Amplituden annehmen, bei denen die Nichtlinearitäten des Systems nicht mehr \n vernachlässigt werden können. In diesen Fällen können das Bewegungsverhalten und das Vorhandensein kritischer Bewegungszustände nur \n noch im Zeitbereich untersucht werden, was auf Simulationen hinausläuft. Das Ergebnis einer Simulation eines nichtlinearen dynamischen \n Systems ist jedoch stark von den Parametern des Systems sowie von den Anfangsbedingungen abhängig, so dass zu jeder Kombination aus \n Anfangsbedingungen und Systemparametern eine Simulation erstellt werden müsste, um die Reaktion eines Schiffes auf alle relevanten \n Seegangsbedingungen bewerten zu können.\n\nSeit zwei Jahrzehnten stehen effiziente mathematische Analyseverfahren zur Behandlung stark nichtlinearer Probleme zur Verfügung. In dieser Arbeit wird \nmit Hilfe der lokalen Verzweigungsanalyse die Existenz kritischer Bewegungsformen gezeigt. Die hydrodynamischen Kräfte und Momente werden dabei mit dem \nProgrammpaket Simbel berechnet. Trotz einer Modifikation der in Simbel implementierten Hydrodynamikberechnung stellte sich heraus, dass die Analyse eines \nvollständig modellierten Schiffes bis heute noch nicht zufriedenstellend gelingt, da die Rechenzeiten immer noch sehr lang sind. Das gleiche gilt für die \nMöglichkeit, in Versuchen preisgünstig gezielt kritische Stellen, die zu einer abrupten Änderung des Systemverhaltens durch eine minimale \nParameteränderung führen, im Experiment zu zeigen. Dabei soll es in diesen Versuchen im Entwicklungsstadium der Methoden nicht um die Untersuchung eines \nspeziellen Schiffsrumpfes unter möglichst realen Seegangsbedingungen gehen, sondern um den experimentellen Nachweis der numerisch ermittelten Phänomene. \n\nIn der vorgestellten Arbeit wird zu beiden Problemen ein Lösungsansatz entwickelt und die Tauglichkeit demonstriert. Für die Versuche ist ein Versuchsschwimmkörper mit einfacher Geometrie entwickelt worden, mit dem im Labor des Institutes umfangreiche Parameterstudien kostengünstig durchgeführt\nwerden können. Das dafür entwickelte berührungslose Positions- und Lagemesssystem liefert Messwerte mit einer Genauigkeit von bis zu einem halben Millimeter in den translatorischen und von einem Hundertstel Grad bei den rotatorischen Freiheitsgraden bei einer Frequenz von 228Hz. Diese Präzision bei einer so hohen Dynamik wird durch den Einsatz eines integrierten Messsystems aus Stereokamera und einer Inertialmesseinheit (IMU) der tactical grade–Klasse, die durch ein erweitertes kontinuierlich–diskretes Kalman–Filter in Echtzeit miteinander kombiniert werden, erreicht. Sowohl die IMU als auch die Stereokamera wurden aus Standardkomponenten aufgebaut, so dass sämtliche Sensorrohdaten und die Zwischenwerte jeder Verarbeitungsstufe vorliegen. Dieser Vorteil im Vergleich zum Einsatz einer kommerziellen IMU oder Stereokamera ermöglicht die Umsetzung unterschiedlicher Integrationstiefen bei der Kombination beider Systeme. In der rechenintensivsten Variante werden Parameter beider Subsysteme als Zustandsgröße des Gesamtsystems geführt, so dass sich einzelne Kameraparameter und IMU–Sensorfehler während des Betriebs schätzen und kompensieren lassen. Im Wellenkanal des Institutes für Mechanik und Meerestechnik ist kein Platz für umfangreiche Manöver oder Tests mit dem fahrenden Schwimmkörper vorhanden. Daher werden die Versuche hier auf einen\nstehenden oder langsam fahrenden Schwimmkörper beschränkt, was jedoch nur eine geringe Einschränkung für die Methodenvalidierung bedeutet. Durch ein dynamisches Positioniersystem wird der Schwimmkörper bei Wellenanregungen auf seiner Sollposition gehalten, ohne dass dabei die Roll- oder die Stampfbewegungen nennenswert angeregt werden. Die Positioniergenauigkeit liegt bei schwachen Anregungen bei schlimmstenfalls ±2mm, bei hohen Wellen und starken Bewegungen liegt die Genauigkeit bei ca. ±10mm quer zu den Wellen und ca. ±30mm in Wellenrichtung.\n\nMit dieser Versuchsanordnung ist es zukünftig möglich, unter beliebigen Winkeln zu den einfallenden Wellen gut wiederholbare Messungen durchzuführen, bei denen man sich in Abstimmung mit den Berechnungen den kritischen Systemzuständen nähern kann. Da die Messungen, die Regelung und die Wellenklappensteuerung miteinander vernetzt sind, kann diese Parametersuche weitestgehend automatisiert ablaufen und gegebenenfalls durch Optimierer beschleunigt werden. \n\nDie numerischen Untersuchungen werden durch ein hier in dieser Arbeit entwickeltes Modellreduktionsverfahren beschleunigt, mit dem die Ordnung des mathematischen Systems deutlich reduziert werden kann. Dies verkürzt zum einen die Rechenzeit, führt aber vor allen Dingen zu einem schnelleren Einschwingen des Systems auf eine periodische Bewegung.', 'deu'), +(103, 41, 'abstract', 'Die Dynamik von Schiffen kann bei kleinen Anregungen durch lineare Modelle exakt beschrieben und analysiert \n werden. Wachsen die Anregungen, können die Bewegungen Amplituden annehmen, bei denen die Nichtlinearitäten des Systems nicht mehr \n vernachlässigt werden können. In diesen Fällen können das Bewegungsverhalten und das Vorhandensein kritischer Bewegungszustände nur \n noch im Zeitbereich untersucht werden, was auf Simulationen hinausläuft. Das Ergebnis einer Simulation eines nichtlinearen dynamischen \n Systems ist jedoch stark von den Parametern des Systems sowie von den Anfangsbedingungen abhängig, so dass zu jeder Kombination aus \n Anfangsbedingungen und Systemparametern eine Simulation erstellt werden müsste, um die Reaktion eines Schiffes auf alle relevanten \n Seegangsbedingungen bewerten zu können.\n\nSeit zwei Jahrzehnten stehen effiziente mathematische Analyseverfahren zur Behandlung stark nichtlinearer Probleme zur Verfügung. In dieser Arbeit wird \nmit Hilfe der lokalen Verzweigungsanalyse die Existenz kritischer Bewegungsformen gezeigt. Die hydrodynamischen Kräfte und Momente werden dabei mit dem \nProgrammpaket Simbel berechnet. Trotz einer Modifikation der in Simbel implementierten Hydrodynamikberechnung stellte sich heraus, dass die Analyse eines \nvollständig modellierten Schiffes bis heute noch nicht zufriedenstellend gelingt, da die Rechenzeiten immer noch sehr lang sind. Das gleiche gilt für die \nMöglichkeit, in Versuchen preisgünstig gezielt kritische Stellen, die zu einer abrupten Änderung des Systemverhaltens durch eine minimale \nParameteränderung führen, im Experiment zu zeigen. Dabei soll es in diesen Versuchen im Entwicklungsstadium der Methoden nicht um die Untersuchung eines \nspeziellen Schiffsrumpfes unter möglichst realen Seegangsbedingungen gehen, sondern um den experimentellen Nachweis der numerisch ermittelten Phänomene. \n\nIn der vorgestellten Arbeit wird zu beiden Problemen ein Lösungsansatz entwickelt und die Tauglichkeit demonstriert. Für die Versuche ist ein Versuchsschwimmkörper mit einfacher Geometrie entwickelt worden, mit dem im Labor des Institutes umfangreiche Parameterstudien kostengünstig durchgeführt\nwerden können. Das dafür entwickelte berührungslose Positions- und Lagemesssystem liefert Messwerte mit einer Genauigkeit von bis zu einem halben Millimeter in den translatorischen und von einem Hundertstel Grad bei den rotatorischen Freiheitsgraden bei einer Frequenz von 228Hz. Diese Präzision bei einer so hohen Dynamik wird durch den Einsatz eines integrierten Messsystems aus Stereokamera und einer Inertialmesseinheit (IMU) der tactical grade–Klasse, die durch ein erweitertes kontinuierlich–diskretes Kalman–Filter in Echtzeit miteinander kombiniert werden, erreicht. Sowohl die IMU als auch die Stereokamera wurden aus Standardkomponenten aufgebaut, so dass sämtliche Sensorrohdaten und die Zwischenwerte jeder Verarbeitungsstufe vorliegen. Dieser Vorteil im Vergleich zum Einsatz einer kommerziellen IMU oder Stereokamera ermöglicht die Umsetzung unterschiedlicher Integrationstiefen bei der Kombination beider Systeme. In der rechenintensivsten Variante werden Parameter beider Subsysteme als Zustandsgröße des Gesamtsystems geführt, so dass sich einzelne Kameraparameter und IMU–Sensorfehler während des Betriebs schätzen und kompensieren lassen. Im Wellenkanal des Institutes für Mechanik und Meerestechnik ist kein Platz für umfangreiche Manöver oder Tests mit dem fahrenden Schwimmkörper vorhanden. Daher werden die Versuche hier auf einen\nstehenden oder langsam fahrenden Schwimmkörper beschränkt, was jedoch nur eine geringe Einschränkung für die Methodenvalidierung bedeutet. Durch ein dynamisches Positioniersystem wird der Schwimmkörper bei Wellenanregungen auf seiner Sollposition gehalten, ohne dass dabei die Roll- oder die Stampfbewegungen nennenswert angeregt werden. Die Positioniergenauigkeit liegt bei schwachen Anregungen bei schlimmstenfalls ±2mm, bei hohen Wellen und starken Bewegungen liegt die Genauigkeit bei ca. ±10mm quer zu den Wellen und ca. ±30mm in Wellenrichtung.\n\nMit dieser Versuchsanordnung ist es zukünftig möglich, unter beliebigen Winkeln zu den einfallenden Wellen gut wiederholbare Messungen durchzuführen, bei denen man sich in Abstimmung mit den Berechnungen den kritischen Systemzuständen nähern kann. Da die Messungen, die Regelung und die Wellenklappensteuerung miteinander vernetzt sind, kann diese Parametersuche weitestgehend automatisiert ablaufen und gegebenenfalls durch Optimierer beschleunigt werden. \n\nDie numerischen Untersuchungen werden durch ein hier in dieser Arbeit entwickeltes Modellreduktionsverfahren beschleunigt, mit dem die Ordnung des mathematischen Systems deutlich reduziert werden kann. Dies verkürzt zum einen die Rechenzeit, führt aber vor allen Dingen zu einem schnelleren Einschwingen des Systems auf eine periodische Bewegung.', 'deu'), (104, 42, 'main', 'Charakterisierung von MOS-Transistoren vor und nach Gateoxiddurchbruch', 'deu'), (105, 42, 'main', 'Characterization of MOS transistors before and after gate oxide breakdown', 'eng'), (106, 42, 'abstract', 'Die fortschreitende Skalierung und zunehmende Packungsdichte integrierter Schaltkreise führt zu immer höheren Belastungen der elektronischen Bauelemente. Bei MOS-Transistoren erhöht sich dadurch die Wahrscheinlichkeit eines Gateoxiddurchbruchs. In der vorliegenden Arbeit werden Untersuchungen zum Verhalten von MOS-Transistoren vor und nach einem Gateoxiddurchbruch präsentiert. Dabei werden unterschiedliche Durchbruchsarten klassifiziert und Modelle für die DC-Kennlinien sowie für das Rauschen (Random Telegraph Signals) nach Durchbruch entwickelt. Mit Hilfe der Modelle wird abschließend die Funktion ausgewählter analoger und digitaler Schaltungen analysiert. Es zeigt sich, daß je nach Anwendung und Durchbruchstyp auch nach Durchbruch eines Transistors die Funktion der Schaltkreise erhalten bleiben kann. Mit diesem Ansatz kann bereits während der Design-Phase die Zuverlässigkeit der Schaltung untersucht werden.', 'deu'), From 0f73a4c494001b5849871b77a8ff9486211c5a47 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 6 Jan 2021 14:14:55 +0100 Subject: [PATCH 110/270] OPUSVIER-4251 Readded notes for 4.7.1 --- RELEASE_NOTES.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 2ff711bf0b..9c8da2a0cb 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,37 @@ # OPUS 4 Release Notes +--- + +## Release 4.7.1 + +# Neues Kommandozeilen-Skript `bin/opus4` + +Es gibt das neue Skript `bin/opus4`, dass in Zukunft die Rolle des zentralen OPUS 4 +Werkzeugs auf der Kommandozeile übernehmen wird. Mit den Kommando `list` lassen sich +die bisher integrierten Kommandos anzeigen. Mit `help` lassen sich Informationen zu +einzelnen Kommandos abrufen. + + $ bin/opus4 list + $ bin/opus4 help index:index + +# Wartung des Solr-Index + +Das Skript `script/SolrIndexBuilder.php` wurde durch `bin/opus4` ersetzt. Dadurch +soll der Aufruf vereinfacht werden. Das neue Skript soll außerdem in Zukunft auch +andere Funktionen übernehmen, die nichts mit dem Index zu tun haben. + +Im OPUS 4 Handbuch gibt es eine neue Seite, die die Funktionen des Skripts für +den Index beschreibt. + + + +Es gibt jetzt die Möglichkeit einzelne Dokumente einfacher zu indexieren oder auch +aus dem Index zu entfernen. Es kann über eine Option bestimmt werden wie viele +Dokument gleichzeitig zum Solr-Server geschickt werden sollen. Das kann helfen, +wenn es Probleme bei der Indexierung gibt. + +--- + ## Release 4.7.0.4 2020-12-02 Diese Version behebt einen Bug im Framework bei der Abfrage, wenn in einem Dokument @@ -14,6 +46,8 @@ Die Versionen 4.7.0.1-4.7.0.3 wurden als kleine Patch-Releases veröffentlicht, die Versionsnummer von OPUS 4 zu verändern. In Zukunft werden wir auch für diese Patch-Releases die Versionsnummer aktualisieren. +--- + ## Release 4.7 2020-07-31 Die Änderungen in OPUS __4.7__, die hier aufgeführt sind, ergänzen was schon für From 9a1d4f1cf99a018bfd1417234c371da1835be8a8 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 7 Jan 2021 09:26:50 +0100 Subject: [PATCH 111/270] OPUSVIER-4358 Avoid problem of rounded dates in database. --- .../Application/Update/SetStatusOfExistingDoiTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php index f17d1aee90..9e30977822 100644 --- a/tests/library/Application/Update/SetStatusOfExistingDoiTest.php +++ b/tests/library/Application/Update/SetStatusOfExistingDoiTest.php @@ -46,8 +46,7 @@ class Application_Update_SetStatusOfExistingDoiTest extends ControllerTestCase * @throws ModelException * * TODO test sets Status of all DOI identifier of published documents to 'registered' (side effect) - * TODO this test has failed once (date got modified or compare didn't work) on Travis and worked in the next run - * without changes - Why? + * TODO Remove debug code no longer needed. */ public function testRunDoesNotModifyServerDateModified() { @@ -63,6 +62,8 @@ public function testRunDoesNotModifyServerDateModified() sleep(2); + $doc = Document::get($docId); // use date stored in database - sometimes rounding happens when storing dates + $modified = $doc->getServerDateModified(); $debug = "$modified (before)" . PHP_EOL; From 88e947a119c9ad16249eb2047edb9826aed984a7 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 8 Jan 2021 11:27:53 +0100 Subject: [PATCH 112/270] OPUSVIER-4454 Keep SWORD packages if error occurs. --- .../Import/AdditionalEnrichments.php | 34 ++++++ library/Application/Import/Importer.php | 11 ++ library/Application/Import/PackageReader.php | 8 ++ .../sword/controllers/DepositController.php | 36 +++++-- modules/sword/models/PackageHandler.php | 10 +- .../controllers/DepositControllerTest.php | 101 ++++++++++++++++++ tests/support/ControllerTestCase.php | 13 +++ 7 files changed, 206 insertions(+), 7 deletions(-) diff --git a/library/Application/Import/AdditionalEnrichments.php b/library/Application/Import/AdditionalEnrichments.php index caf011c0d2..5381a2074e 100644 --- a/library/Application/Import/AdditionalEnrichments.php +++ b/library/Application/Import/AdditionalEnrichments.php @@ -47,18 +47,44 @@ use Opus\EnrichmentKey; +/** + * Additional enrichments for imported documents. + * + * TODO each enrichment should have a separate class, so the list can be extended + * TODO rename, there aren't any Enrichments here, just "info" (properties) + * TODO map info properties to enrichments or Properties later + */ class Application_Import_AdditionalEnrichments { + + /** + * Authenticated user account that performed the import. + */ const OPUS_IMPORT_USER = 'opus.import.user'; + /** + * Date of import. + */ const OPUS_IMPORT_DATE = 'opus.import.date'; + /** + * Name of import file. + */ const OPUS_IMPORT_FILE = 'opus.import.file'; + /** + * Checksum of import file. + */ const OPUS_IMPORT_CHECKSUM = 'opus.import.checksum'; + /** + * Source of added document like SWORD or the publish form. + */ const OPUS_SOURCE = 'opus.source'; + /** + * @var + */ private $enrichmentMap; /** @@ -121,4 +147,12 @@ public function getChecksum() } return $this->enrichmentMap[self::OPUS_IMPORT_CHECKSUM]; } + + public function getFileName() + { + if (! array_key_exists(self::OPUS_IMPORT_FILE, $this->enrichmentMap)) { + return null; + } + return $this->enrichmentMap[self::OPUS_IMPORT_FILE]; + } } diff --git a/library/Application/Import/Importer.php b/library/Application/Import/Importer.php index 6f0ad48969..7e736c2e2f 100644 --- a/library/Application/Import/Importer.php +++ b/library/Application/Import/Importer.php @@ -45,6 +45,14 @@ use Opus\Model\NotFoundException; use Opus\Security\SecurityException; +/** + * Class Application_Import_Importer + * + * TODO behavior of this importer changes depending swordContext - It means special handling code in various places. + * With every new context, every new use case this code will get more complicated. It would be better if the + * different context would be implemented in separate classes that extend a base class providing common + * functionality. + */ class Application_Import_Importer { @@ -59,6 +67,9 @@ class Application_Import_Importer private $swordContext = false; private $importDir = null; + /** + * @var null + */ private $statusDoc = null; /** diff --git a/library/Application/Import/PackageReader.php b/library/Application/Import/PackageReader.php index 2c9413deec..e1e240ce95 100644 --- a/library/Application/Import/PackageReader.php +++ b/library/Application/Import/PackageReader.php @@ -42,6 +42,7 @@ abstract class Application_Import_PackageReader { + const METADATA_FILENAME = 'opus.xml'; const EXTRACTION_DIR_NAME = 'extracted'; @@ -81,6 +82,7 @@ private function processOpusXML($xml, $dirName) $importer->setImportCollection($importCollection->getCollection()); $importer->run(); + return $importer->getStatusDoc(); } @@ -94,6 +96,12 @@ abstract protected function extractPackage($dirName); * @param string $dirName * @return Application_Import_ImportStatusDocument * @throws Zend_Exception + * + * TODO improve readability of code - readPackage extracts the package into a folder and then calls processPackage + * from the outside it is the function that "processes the package" + * the way these functions are chained makes it hard to add additional steps to the process - either the + * calling function should call read... first and then process... or probalby better process.. should call + * read... as one of its processing steps */ public function readPackage($dirName) { diff --git a/modules/sword/controllers/DepositController.php b/modules/sword/controllers/DepositController.php index f33dc2735b..ebd4f2babb 100644 --- a/modules/sword/controllers/DepositController.php +++ b/modules/sword/controllers/DepositController.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License * * TODO use OPUS 4 base class? + * TODO too much code in this controller + * TODO change AdditionalEnrichments into something like ImportInfo and make it easy to access properties like "user" */ class Sword_DepositController extends \Zend_Rest_Controller { @@ -42,6 +44,9 @@ public function init() $this->getHelper('ViewRenderer')->setNoRender(); } + /** + * TODO This function does too much. + */ public function postAction() { $request = $this->getRequest(); @@ -101,31 +106,40 @@ public function postAction() } } + // TODO data is stored again within handlePackage - that should be avoied + $filename = $additionalEnrichments->getFileName(); + $config = Application_Configuration::getInstance(); + $filePath = $config->getWorkspacePath() . 'import/' . $filename; + file_put_contents($filePath, $payload); + + $errorDoc = null; + try { $statusDoc = $packageHandler->handlePackage($payload); if (is_null($statusDoc)) { // im Archiv befindet sich keine Datei opus.xml oder die Datei ist leer $errorDoc = new Sword_Model_ErrorDocument($request, $response); $errorDoc->setMissingXml(); - return; - } - - if ($statusDoc->noDocImported()) { + } else if ($statusDoc->noDocImported()) { // im Archiv befindet sich zwar ein nicht leeres opus.xml; es // konnte aber kein Dokument erfolgreich importiert werden $errorDoc = new Sword_Model_ErrorDocument($request, $response); $errorDoc->setInternalFrameworkError(); - return; } } catch (Application_Import_MetadataImportInvalidXmlException $ex) { $errorDoc = new Sword_Model_ErrorDocument($request, $response); $errorDoc->setInvalidXml(); - return; } catch (Exception $ex) { $errorDoc = new Sword_Model_ErrorDocument($request, $response); + } + + if ($errorDoc !== null) { return; } + // cleanup file after successful import + unlink($filePath); + $this->returnAtomEntryDocument($statusDoc, $request, $response, $userName); } @@ -217,4 +231,14 @@ public function deleteAction() { $this->return500($this->getResponse()); } + + /** + * Generates a name for storing the package as a file. + */ + protected function generatePackageFileName($importInfo) + { + $filename = ''; + + return $filename; + } } diff --git a/modules/sword/models/PackageHandler.php b/modules/sword/models/PackageHandler.php index 6f0cd6b733..e5bcb77137 100644 --- a/modules/sword/models/PackageHandler.php +++ b/modules/sword/models/PackageHandler.php @@ -27,8 +27,11 @@ * @category Application * @package Module_Sword * @author Sascha Szott - * @copyright Copyright (c) 2016-2019 + * @copyright Copyright (c) 2016-2020 * @license http://www.gnu.org/licenses/gpl.html General Public License + * + * TODO separate differentiation of ZIP and TAR into separate classes - it should be possible to ADD another class to + * support a new type of package - it should not be necessary to MODIFY existing classes for that */ class Sword_Model_PackageHandler { @@ -87,8 +90,11 @@ public function handlePackage($payload) try { $tmpDirName = $this->createTmpDir($payload); $this->savePackage($payload, $tmpDirName); + + $statusDoc = $packageReader->readPackage($tmpDirName); } finally { + // TODO copy file before cleanup if error occured if (! is_null($tmpDirName)) { $this->cleanupTmpDir($tmpDirName); } @@ -147,6 +153,8 @@ private function getPackageReader() * * @param string $payload * @param string $tmpDir + * + * TODO save package into import folder (no longer temporary file) */ private function savePackage($payload, $tmpDir) { diff --git a/tests/modules/sword/controllers/DepositControllerTest.php b/tests/modules/sword/controllers/DepositControllerTest.php index a0300fd06e..82fad0cb3a 100644 --- a/tests/modules/sword/controllers/DepositControllerTest.php +++ b/tests/modules/sword/controllers/DepositControllerTest.php @@ -167,6 +167,48 @@ public function testTarSingleDocWithMultipleFilesImplicit() $this->testHelper->removeImportCollection(); } + public function testFileIsRemovedFromImportFolderAfterSuccess() + { + $doc = $this->depositSuccessful( + 'minimal-record.zip', + DepositTestHelper::CONTENT_TYPE_ZIP, + true, + false + ); + + $config = Application_Configuration::getInstance(); + $importDir = $config->getWorkspacePath() . 'import/'; + $enrichments = $doc->getEnrichmentValues(); + $filename = $enrichments['opus.import.file']; + $filePath = $importDir . $filename; + + $this->addFileToCleanup($filePath); + + $this->assertFileNotExists($filePath); + } + + public function testFileIsKeptInImportFolderAfterError() + { + $doc = $this->depositWithError( + 'invalid-xml.zip', + DepositTestHelper::CONTENT_TYPE_ZIP, + true, + false + ); + + $this->assertNull($doc); + + $config = Application_Configuration::getInstance(); + $importDir = $config->getWorkspacePath() . 'import/'; + $filename = 'invalid-xml.zip'; + $filePath = $importDir . $filename; + + $this->addFileToCleanup($filePath); + + $this->assertFileExists($filePath); + } + + private function checkOnlyOneDocIsImported($doc) { $this->assertEquals('eng', $doc->getLanguage()); @@ -444,6 +486,38 @@ private function depositSuccessful( return $doc; } + /** + * TODO addapt function to run deposit requests producing various errors + */ + private function depositWithError( + $fileName, + $contentType, + $abstractExist = true, + $deleteDoc = true, + $deleteCollection = true, + $numOfEnrichments = 5, + $numOfCollections = 1, + $serverState = 'unpublished' + ) { + + $this->testHelper->assertEmptyTmpDir(); + $this->testHelper->disableExceptionConversion(); + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setHeader('Content-Type', $contentType); + $this->testHelper->setValidAuthorizationHeader($this->getRequest(), DepositTestHelper::USER_AGENT); + $checksum = $this->testHelper->uploadFile($this->getRequest(), $fileName); + $this->getRequest()->setHeader('Content-Disposition', $fileName); + $this->testHelper->addImportCollection(); + + $this->dispatch('/sword/deposit'); + $this->testHelper->assertEmptyTmpDir(); + + $doc = $this->checkErrorDocument($checksum, $fileName, $abstractExist, $numOfEnrichments, $numOfCollections, $serverState, $deleteDoc); + if ($deleteCollection) { + $this->testHelper->removeImportCollection(); + } + } + private function checkAtomEntryDocument($checksum, $fileName, $abstractExist, $numOfEnrichments, $numOfCollections, $serverState, $deleteDoc) { $this->assertEquals(201, $this->getResponse()->getHttpResponseCode()); @@ -466,6 +540,33 @@ private function checkAtomEntryDocument($checksum, $fileName, $abstractExist, $n $doc->deletePermanent(); } + /** + * TODO adapt function for checking error document OPUSVIER-4500 + */ + private function checkErrorDocument($checksum, $fileName, $abstractExist, $numOfEnrichments, $numOfCollections, $serverState, $deleteDoc) + { + $this->assertNotEquals(201, $this->getResponse()->getHttpResponseCode()); + + /** + $doc = new DOMDocument(); + $doc->loadXML($this->getResponse()->getBody()); + + $roots = $doc->childNodes; + $this->assertEquals(1, $roots->length); + $root = $roots->item(0); + + $doc = $this->testHelper->checkAtomEntryDocument($root, $fileName, $checksum, $abstractExist, $numOfEnrichments, $numOfCollections); + $this->assertEquals($serverState, $doc->getServerState()); + $this->checkHttpResponseHeaders($this->testHelper->getFrontdoorUrl()); + + if (! $deleteDoc) { + return $doc; + } + + $doc->deletePermanent(); + */ + } + private function checkHttpResponseHeaders($frontdoorUrl) { $headers = $this->getResponse()->getHeaders(); diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index 34218af87a..be6e86004c 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -735,6 +735,8 @@ protected function deleteTempFiles() * @return File * @throws ModelException * @throws Zend_Exception + * + * TODO allow same filename in different locations */ protected function createOpusTestFile($filename, $filepath = null) { @@ -761,6 +763,17 @@ protected function createOpusTestFile($filename, $filepath = null) return $file; } + public function addFileToCleanup($filePath) + { + if ($this->testFiles === null) { + $this->testFiles = []; + } + + $fileName = basename($filePath); + + $this->testFiles[$fileName] = $filePath; + } + protected function deleteTestFiles() { if (! is_null($this->testFiles)) { From 9eb195994ab588098a93fd060e412b247ce8b7e4 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 8 Jan 2021 11:43:23 +0100 Subject: [PATCH 113/270] OPUSVIER-4454 Add checksum to package file name --- modules/sword/controllers/DepositController.php | 10 ++++++---- .../sword/controllers/DepositControllerTest.php | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/sword/controllers/DepositController.php b/modules/sword/controllers/DepositController.php index ebd4f2babb..06d3f63ef3 100644 --- a/modules/sword/controllers/DepositController.php +++ b/modules/sword/controllers/DepositController.php @@ -107,7 +107,7 @@ public function postAction() } // TODO data is stored again within handlePackage - that should be avoied - $filename = $additionalEnrichments->getFileName(); + $filename = $this->generatePackageFileName($additionalEnrichments); $config = Application_Configuration::getInstance(); $filePath = $config->getWorkspacePath() . 'import/' . $filename; file_put_contents($filePath, $payload); @@ -233,12 +233,14 @@ public function deleteAction() } /** - * Generates a name for storing the package as a file. + * Generates a name for storing the package as a file.\ + * @param Application_Import_AdditionalEnrichments $importInfo */ protected function generatePackageFileName($importInfo) { - $filename = ''; + $filename = $importInfo->getFileName(); + $checksum = $importInfo->getChecksum(); - return $filename; + return "$checksum-$filename"; } } diff --git a/tests/modules/sword/controllers/DepositControllerTest.php b/tests/modules/sword/controllers/DepositControllerTest.php index 82fad0cb3a..8e602a7f91 100644 --- a/tests/modules/sword/controllers/DepositControllerTest.php +++ b/tests/modules/sword/controllers/DepositControllerTest.php @@ -200,7 +200,11 @@ public function testFileIsKeptInImportFolderAfterError() $config = Application_Configuration::getInstance(); $importDir = $config->getWorkspacePath() . 'import/'; - $filename = 'invalid-xml.zip'; + + $payload = file_get_contents(APPLICATION_PATH . '/tests/resources/sword-packages/invalid-xml.zip'); + $checksum = md5($payload); + + $filename = "$checksum-invalid-xml.zip"; $filePath = $importDir . $filename; $this->addFileToCleanup($filePath); From 09cacca9e2c0c1e9223f053366ad6db037675028 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 8 Jan 2021 13:38:11 +0100 Subject: [PATCH 114/270] OPUSVIER-4496 Fixed test after HTML change --- tests/modules/admin/controllers/InfoControllerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/modules/admin/controllers/InfoControllerTest.php b/tests/modules/admin/controllers/InfoControllerTest.php index d8f3104847..bd0f1291e3 100644 --- a/tests/modules/admin/controllers/InfoControllerTest.php +++ b/tests/modules/admin/controllers/InfoControllerTest.php @@ -46,8 +46,8 @@ public function testIndexDisplayVersion() $config = \Zend_Registry::get('Zend_Config'); $this->dispatch('admin/info'); $this->assertResponseCode(200); - $this->assertQuery('dt#admin_info_version'); - $this->assertQueryContentContains("//dt[@id='admin_info_version']/following-sibling::dd", $config->version); + $this->assertQuery('//div[@class="opus-version-info"]'); + $this->assertQueryContentContains("//div[@class='opus-version-info']", $config->version); $this->validateXHTML(); } From 5fd8ce3a0aa5535bf81796af545753b557b60f28 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 18 Jan 2021 21:20:14 +0100 Subject: [PATCH 115/270] OPUSVIER-4395 Changed document deletion --- composer.json | 6 ++--- .../Console/Document/DeleteCommand.php | 5 ++-- .../Controller/Action/Helper/Workflow.php | 5 +--- .../publish/controllers/DepositController.php | 2 +- .../publish/controllers/FormController.php | 2 +- .../review/models/ClearDocumentsHelper.php | 3 ++- scripts/cron/cron-db-clean-temporary.php | 14 +++++----- scripts/snippets/delete_all_docs.php | 2 +- scripts/snippets/delete_non-demo_docs.php | 2 +- .../controllers/ReportControllerTest.php | 2 +- .../Document/MultiEnrichmentSubFormTest.php | 4 +-- tests/modules/admin/models/DoiStatusTest.php | 2 +- .../controllers/IndexControllerTest.php | 4 +-- .../export/models/DataciteExportTest.php | 8 +++--- .../controllers/FormControllerTest.php | 2 +- .../rss/controllers/IndexControllerTest.php | 4 +-- .../DepositControllerErrorCasesTest.php | 4 +-- .../DepositControllerMultipleDocsTest.php | 2 +- .../controllers/DepositControllerTest.php | 26 +++++++++---------- tests/scripts/cron/DbCleanTemporaryTest.php | 4 +-- tests/scripts/cron/MetadataImportTest.php | 2 +- tests/support/ControllerTestCase.php | 2 +- 22 files changed, 53 insertions(+), 54 deletions(-) diff --git a/composer.json b/composer.json index e47b351350..bd41da1cc2 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,9 @@ "zendframework/zendframework1": "1.12.*", "jpgraph/jpgraph": "dev-master", "solarium/solarium": "3.8.*", - "opus4-repo/opus4-common": "dev-master", - "opus4-repo/framework": "dev-master", - "opus4-repo/search": "dev-master", + "opus4-repo/opus4-common": "dev-OPUSVIER-4395", + "opus4-repo/framework": "dev-OPUSVIER-4395", + "opus4-repo/search": "dev-OPUSVIER-4395", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", diff --git a/library/Application/Console/Document/DeleteCommand.php b/library/Application/Console/Document/DeleteCommand.php index 865284391e..83306ffe5e 100644 --- a/library/Application/Console/Document/DeleteCommand.php +++ b/library/Application/Console/Document/DeleteCommand.php @@ -151,9 +151,10 @@ protected function deleteDocument($docId, $permanent = false) { $doc = Document::get($docId); if ($permanent) { - $doc->deletePermanent(); - } else { $doc->delete(); + } else { + $doc->setServerState(Document::STATE_DELETED); + $doc->store(); } } } diff --git a/library/Application/Controller/Action/Helper/Workflow.php b/library/Application/Controller/Action/Helper/Workflow.php index 6f3e0d9d01..62a7603bde 100644 --- a/library/Application/Controller/Action/Helper/Workflow.php +++ b/library/Application/Controller/Action/Helper/Workflow.php @@ -157,11 +157,8 @@ public static function getTargetStates($currentState) public function changeState($document, $targetState) { switch ($targetState) { - case 'deleted': - $document->delete(); - break; case 'removed': - $document->deletePermanent(); + $document->delete(); break; default: $document->setServerState($targetState); diff --git a/modules/publish/controllers/DepositController.php b/modules/publish/controllers/DepositController.php index 960b5256a8..0336e75d1b 100644 --- a/modules/publish/controllers/DepositController.php +++ b/modules/publish/controllers/DepositController.php @@ -75,7 +75,7 @@ public function depositAction() if (isset($this->session->documentId)) { try { $document = Document::get($this->session->documentId); - $document->deletePermanent(); + $document->delete(); } catch (ModelException $e) { $this->getLogger()->err( "deletion of document # " . $this->session->documentId . " was not successful", diff --git a/modules/publish/controllers/FormController.php b/modules/publish/controllers/FormController.php index 5c9b39d2ae..acbeab6473 100644 --- a/modules/publish/controllers/FormController.php +++ b/modules/publish/controllers/FormController.php @@ -222,7 +222,7 @@ public function checkAction() if (isset($this->session->documentId)) { try { $document = Document::get($this->session->documentId); - $document->deletePermanent(); + $document->delete(); } catch (ModelException $e) { $this->getLogger()->err( "deletion of document # " . $this->session->documentId . " was not successful", diff --git a/modules/review/models/ClearDocumentsHelper.php b/modules/review/models/ClearDocumentsHelper.php index 0d729a2c08..d3c1e79d0d 100644 --- a/modules/review/models/ClearDocumentsHelper.php +++ b/modules/review/models/ClearDocumentsHelper.php @@ -112,7 +112,8 @@ public function reject(array $docIds = null, $userId = null, $person = null) $enrichment->setKeyName('review.rejected_by') ->setValue($userId); - $document->delete(); + $document->setServerState(Document::STATE_DELETED); + $document->store(); } return; diff --git a/scripts/cron/cron-db-clean-temporary.php b/scripts/cron/cron-db-clean-temporary.php index 627c88ae5a..d825cb46bf 100644 --- a/scripts/cron/cron-db-clean-temporary.php +++ b/scripts/cron/cron-db-clean-temporary.php @@ -39,16 +39,16 @@ $date = new DateTime(); $dateString = $date->sub(new DateInterval('P2D'))->format('Y-m-d'); -$f = new DocumentFinder(); -$f->setServerState('temporary') +$finder = new DocumentFinder(); +$finder->setServerState('temporary') ->setServerDateModifiedBefore($dateString); -foreach ($f->ids() as $id) { - $d = Document::get($id); - if ($d->getServerState() == 'temporary') { +foreach ($finder->ids() as $id) { + $doc = Document::get($id); + if ($doc->getServerState() == 'temporary') { echo "deleting document: $id\n"; - $d->deletePermanent(); + $doc->delete(); } else { - echo "NOT deleting document: $id because it has server state ".$d->getServerState(); + echo "NOT deleting document: $id because it has server state ".$doc->getServerState(); } } diff --git a/scripts/snippets/delete_all_docs.php b/scripts/snippets/delete_all_docs.php index 653afcda37..b652d4f466 100644 --- a/scripts/snippets/delete_all_docs.php +++ b/scripts/snippets/delete_all_docs.php @@ -43,7 +43,7 @@ $finder = new DocumentFinder(); foreach ($finder->ids() as $id) { $doc = Document::get($id); - $doc->deletePermanent(); + $doc->delete(); echo "document " . $id . " was deleted.\n"; } diff --git a/scripts/snippets/delete_non-demo_docs.php b/scripts/snippets/delete_non-demo_docs.php index 00557921cf..2c757fd353 100644 --- a/scripts/snippets/delete_non-demo_docs.php +++ b/scripts/snippets/delete_non-demo_docs.php @@ -44,7 +44,7 @@ foreach ($finder->ids() as $id) { if (intval($id) < 91 || intval($id) > 110) { $doc = Document::get($id); - $doc->deletePermanent(); + $doc->delete(); echo "document " . $id . " was deleted.\n"; } } diff --git a/tests/modules/admin/controllers/ReportControllerTest.php b/tests/modules/admin/controllers/ReportControllerTest.php index 252ec40863..faabc9634e 100644 --- a/tests/modules/admin/controllers/ReportControllerTest.php +++ b/tests/modules/admin/controllers/ReportControllerTest.php @@ -84,7 +84,7 @@ public function tearDown() // removed previously created test documents from database foreach ($this->docIds as $docId) { $doc = Document::get($docId); - $doc->deletePermanent(); + $doc->delete(); } } diff --git a/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php b/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php index 811be82257..b929b3b0e3 100644 --- a/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php +++ b/tests/modules/admin/forms/Document/MultiEnrichmentSubFormTest.php @@ -68,7 +68,7 @@ public function testGetFieldValues() $result = $form->getFieldValues($doc); // cleanup: remove latest test document - $doc->deletePermanent(); + $doc->delete(); // die beiden Enrichments mit dem Schlüssel opus.doi/urn.autoCreate // werden gesondert behandelt und erscheinen daher nicht im Unterformular @@ -110,7 +110,7 @@ public function testPopulateFromModel() $this->assertCount(count($enrichments), $form->getSubForms()); // cleanup: remove latest test document - $doc->deletePermanent(); + $doc->delete(); } public function testConstructFromPost() diff --git a/tests/modules/admin/models/DoiStatusTest.php b/tests/modules/admin/models/DoiStatusTest.php index db2cbf9851..8b66809077 100644 --- a/tests/modules/admin/models/DoiStatusTest.php +++ b/tests/modules/admin/models/DoiStatusTest.php @@ -46,7 +46,7 @@ public function tearDown() if (! is_null($this->docId)) { // removed previously created test document from database $doc = Document::get($this->docId); - $doc->deletePermanent(); + $doc->delete(); } parent::tearDown(); } diff --git a/tests/modules/export/controllers/IndexControllerTest.php b/tests/modules/export/controllers/IndexControllerTest.php index 238bcb3291..bc908667ec 100644 --- a/tests/modules/export/controllers/IndexControllerTest.php +++ b/tests/modules/export/controllers/IndexControllerTest.php @@ -264,7 +264,7 @@ public function testSolrIndexIsNotUpToDate() $solrXml = $indexer->toSolrDocument($doc2); // delete document from database - $doc2->deletePermanent(); + $doc2->delete(); // add document to search index // TODO fix $methodSendSolrXmlToServer = $class->getMethod('sendSolrXmlToServer'); @@ -278,7 +278,7 @@ public function testSolrIndexIsNotUpToDate() $indexer->removeDocumentFromEntryIndexById($docId2); $indexer->commit(); - $doc1->deletePermanent(); + $doc1->delete(); $body = $this->getResponse()->getBody(); diff --git a/tests/modules/export/models/DataciteExportTest.php b/tests/modules/export/models/DataciteExportTest.php index 785abe382d..904cc1c049 100644 --- a/tests/modules/export/models/DataciteExportTest.php +++ b/tests/modules/export/models/DataciteExportTest.php @@ -111,7 +111,7 @@ public function testExecuteWithValidDoc() $result = $plugin->execute(); // Testdokument wieder löschen - $doc->deletePermanent(); + $doc->delete(); // Änderungen an Konfiguration zurücksetzen \Zend_Registry::set('Zend_Config', $oldConfig); @@ -137,7 +137,7 @@ public function testExecuteWithInvalidDoc() $result = $plugin->execute(); // Testdokument wieder löschen - $doc->deletePermanent(); + $doc->delete(); $this->assertFalse($result); $this->assertTrue(is_array($view->requiredFieldsStatus)); @@ -164,7 +164,7 @@ public function testExecuteWithInvalidDocAndInvalidValidateParamValue() $result = $plugin->execute(); // Testdokument wieder löschen - $doc->deletePermanent(); + $doc->delete(); $this->assertFalse($result); $this->assertTrue(is_array($view->requiredFieldsStatus)); @@ -187,7 +187,7 @@ public function testExecuteWithInvalidDocSkipValidation() $result = $plugin->execute(); // Testdokument wieder löschen - $doc->deletePermanent(); + $doc->delete(); // XML wird in jedem Fall generiert, auch wenn das DataCite-XML nicht valide ist $this->assertTrue($result); diff --git a/tests/modules/publish/controllers/FormControllerTest.php b/tests/modules/publish/controllers/FormControllerTest.php index c5b4d24e2f..bfd5192a67 100644 --- a/tests/modules/publish/controllers/FormControllerTest.php +++ b/tests/modules/publish/controllers/FormControllerTest.php @@ -411,7 +411,7 @@ public function testFormManipulationForBibliography() $doc = Document::get($session->documentId); $belongsToBibliography = $doc->getBelongsToBibliography(); - $doc->deletePermanent(); + $doc->delete(); $this->assertResponseCode(200); $this->assertNotContains("Es sind Fehler aufgetreten.", $this->response->getBody()); diff --git a/tests/modules/rss/controllers/IndexControllerTest.php b/tests/modules/rss/controllers/IndexControllerTest.php index 227aee3d33..63107f3cc9 100644 --- a/tests/modules/rss/controllers/IndexControllerTest.php +++ b/tests/modules/rss/controllers/IndexControllerTest.php @@ -110,7 +110,7 @@ public function testSolrIndexIsNotUpToDate() $indexer->addDocumentsToIndex($doc1); // delete document from database - $doc1->deletePermanent(); + $doc1->delete(); sleep(2); // make sure $doc2 do not get the same value for server_date_published @@ -132,7 +132,7 @@ public function testSolrIndexIsNotUpToDate() // make search index up to date $indexer->removeDocumentsFromIndexById($docId1); - $doc2->deletePermanent(); + $doc2->delete(); $body = $this->getResponse()->getBody(); $this->assertNotContains("No Opus_Db_Documents with id $docId1 in database.", $body); diff --git a/tests/modules/sword/controllers/DepositControllerErrorCasesTest.php b/tests/modules/sword/controllers/DepositControllerErrorCasesTest.php index 4ce202359e..ba415da35d 100644 --- a/tests/modules/sword/controllers/DepositControllerErrorCasesTest.php +++ b/tests/modules/sword/controllers/DepositControllerErrorCasesTest.php @@ -191,14 +191,14 @@ public function testZipArchiveProvokeUrnCollision() { $doc = $this->addDocWithUrn(); $this->depositError('one-doc-with-urn.zip', DepositTestHelper::CONTENT_TYPE_ZIP, 400, 'http://www.opus-repository.org/sword/error/InternalFrameworkError'); - $doc->deletePermanent(); + $doc->delete(); } public function testTarArchiveProvokeUrnCollision() { $doc = $this->addDocWithUrn(); $this->depositError('one-doc-with-urn.tar', DepositTestHelper::CONTENT_TYPE_TAR, 400, 'http://www.opus-repository.org/sword/error/InternalFrameworkError'); - $doc->deletePermanent(); + $doc->delete(); } private function addDocWithUrn() diff --git a/tests/modules/sword/controllers/DepositControllerMultipleDocsTest.php b/tests/modules/sword/controllers/DepositControllerMultipleDocsTest.php index bf62e87325..36e487da21 100644 --- a/tests/modules/sword/controllers/DepositControllerMultipleDocsTest.php +++ b/tests/modules/sword/controllers/DepositControllerMultipleDocsTest.php @@ -106,7 +106,7 @@ private function checkMultipleAtomEntryDocument($checksum, $fileName) foreach ($children as $child) { $doc = $this->testHelper->checkAtomEntryDocument($child, $fileName, $checksum); $this->checkMetadata($docCount, $doc); - $doc->deletePermanent(); + $doc->delete(); $docCount++; } } diff --git a/tests/modules/sword/controllers/DepositControllerTest.php b/tests/modules/sword/controllers/DepositControllerTest.php index a0300fd06e..66ac4e535d 100644 --- a/tests/modules/sword/controllers/DepositControllerTest.php +++ b/tests/modules/sword/controllers/DepositControllerTest.php @@ -65,7 +65,7 @@ public function testZipArchiveAllFieldDocumentDeposit() { $doc = $this->depositSuccessful('allfields-document.zip', DepositTestHelper::CONTENT_TYPE_ZIP, true, false, false, 7, 3, 'published'); $this->checkAllFieldsImport($doc); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -73,7 +73,7 @@ public function testTarArchiveAllFieldDocumentDeposit() { $doc = $this->depositSuccessful('allfields-document.tar', DepositTestHelper::CONTENT_TYPE_TAR, true, false, false, 7, 3, 'published'); $this->checkAllFieldsImport($doc); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -81,7 +81,7 @@ public function testZipArchiveDanglingIds() { $doc = $this->depositSuccessful('dangling-ids.zip', DepositTestHelper::CONTENT_TYPE_ZIP, false, false); $this->checkMinimalDoc($doc); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -89,7 +89,7 @@ public function testTarArchiveDanglingIds() { $doc = $this->depositSuccessful('dangling-ids.tar', DepositTestHelper::CONTENT_TYPE_TAR, false, false); $this->checkMinimalDoc($doc); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -97,7 +97,7 @@ public function testZipArchiveWithUrnCollision() { $doc = $this->depositSuccessful('urn-collision.zip', DepositTestHelper::CONTENT_TYPE_ZIP, false, false); $this->checkOnlyOneDocIsImported($doc); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -105,7 +105,7 @@ public function testTarArchiveWithUrnCollision() { $doc = $this->depositSuccessful('urn-collision.tar', DepositTestHelper::CONTENT_TYPE_TAR, false, false); $this->checkOnlyOneDocIsImported($doc); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -113,7 +113,7 @@ public function testZipArchiveWithEmptyElementsDocumentDeposit() { $doc = $this->depositSuccessful('empty-elements.zip', DepositTestHelper::CONTENT_TYPE_ZIP, false, false); $this->checkMinimalDoc($doc, 'eng', 'book', 'titlemain'); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -121,7 +121,7 @@ public function testTarArchiveWithEmptyElementsDocumentDeposit() { $doc = $this->depositSuccessful('empty-elements.tar', DepositTestHelper::CONTENT_TYPE_TAR, false, false); $this->checkMinimalDoc($doc, 'eng', 'book', 'titlemain'); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -129,7 +129,7 @@ public function testZipArchiveWithEmptyElementsDocumentDepositAlternative() { $doc = $this->depositSuccessful('empty-elements-alternative.zip', DepositTestHelper::CONTENT_TYPE_ZIP, false, false); $this->checkMinimalDoc($doc, 'eng', 'book', 'titlemain'); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -137,7 +137,7 @@ public function testTarArchiveWithEmptyElementsDocumentDepositAlternative() { $doc = $this->depositSuccessful('empty-elements-alternative.tar', DepositTestHelper::CONTENT_TYPE_TAR, false, false); $this->checkMinimalDoc($doc, 'eng', 'book', 'titlemain'); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -150,7 +150,7 @@ public function testZipSingleDocWithMultipleFilesImplicit() $this->checkFile($files[0], 'doc1.pdf', $language, null, 1, 1); $this->checkFile($files[1], 'doc1.txt', $language, null, 1, 1); $this->checkFile($files[2], 'foo.txt', $language, null, 1, 1); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -163,7 +163,7 @@ public function testTarSingleDocWithMultipleFilesImplicit() $this->checkFile($files[0], 'doc1.pdf', $language, null, 1, 1); $this->checkFile($files[1], 'doc1.txt', $language, null, 1, 1); $this->checkFile($files[2], 'foo.txt', $language, null, 1, 1); - $doc->deletePermanent(); + $doc->delete(); $this->testHelper->removeImportCollection(); } @@ -463,7 +463,7 @@ private function checkAtomEntryDocument($checksum, $fileName, $abstractExist, $n return $doc; } - $doc->deletePermanent(); + $doc->delete(); } private function checkHttpResponseHeaders($frontdoorUrl) diff --git a/tests/scripts/cron/DbCleanTemporaryTest.php b/tests/scripts/cron/DbCleanTemporaryTest.php index d6f269c508..a94497369b 100644 --- a/tests/scripts/cron/DbCleanTemporaryTest.php +++ b/tests/scripts/cron/DbCleanTemporaryTest.php @@ -62,7 +62,7 @@ public function testCleanUpDocumentOlderThan2Days() $this->executeScript('cron-db-clean-temporary.php'); try { $doc = Document::get($this->doc->getId()); - $doc->deletePermanent(); + $doc->delete(); $this->fail("expected Opus\Model\NotFoundException"); } catch (NotFoundException $e) { } @@ -74,7 +74,7 @@ public function testKeepDocumentNewerThan3Days() $this->executeScript('cron-db-clean-temporary.php'); try { $doc = Document::get($this->doc->getId()); - $doc->deletePermanent(); + $doc->delete(); } catch (NotFoundException $e) { $this->fail("expected existing document."); } diff --git a/tests/scripts/cron/MetadataImportTest.php b/tests/scripts/cron/MetadataImportTest.php index 826a9d3a98..24be140301 100644 --- a/tests/scripts/cron/MetadataImportTest.php +++ b/tests/scripts/cron/MetadataImportTest.php @@ -61,7 +61,7 @@ public function tearDown() $ids = Document::getAllIds(); $last_id = array_pop($ids); $doc = Document::get($last_id); - $doc->deletePermanent(); + $doc->delete(); } parent::tearDown(); } diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index 34218af87a..32fc417f17 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -649,7 +649,7 @@ public function removeDocument($value) try { Document::get($docId); - $doc->deletePermanent(); + $doc->delete(); } catch (NotFoundException $omnfe) { // Model nicht gefunden -> alles gut (hoffentlich) $this->getLogger()->debug("Test document {$docId} was deleted successfully by test."); From 150a0b05017e78967b538f0706bf89b6e6d6c238 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 18 Jan 2021 21:58:45 +0100 Subject: [PATCH 116/270] OPUSVIER-4395 Reset DoiManager after test --- tests/support/ControllerTestCase.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index 32fc417f17..8de64faa38 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -34,6 +34,7 @@ use Opus\Db\TableGateway; use Opus\Document; +use Opus\Doi\DoiManager; use Opus\File; use Opus\UserRole; use Opus\Model\ModelException; @@ -113,6 +114,7 @@ public function tearDown() $this->logger = null; + DoiManager::setInstance(null); Application_Configuration::clearInstance(); // reset Application_Configuration parent::tearDown(); From 182b908cc800ac8aa05be8e2557b1944de6709be Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 20 Jan 2021 17:21:33 +0100 Subject: [PATCH 117/270] OPUSVIER-4395 Updated dependencies --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index bd41da1cc2..e47b351350 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,9 @@ "zendframework/zendframework1": "1.12.*", "jpgraph/jpgraph": "dev-master", "solarium/solarium": "3.8.*", - "opus4-repo/opus4-common": "dev-OPUSVIER-4395", - "opus4-repo/framework": "dev-OPUSVIER-4395", - "opus4-repo/search": "dev-OPUSVIER-4395", + "opus4-repo/opus4-common": "dev-master", + "opus4-repo/framework": "dev-master", + "opus4-repo/search": "dev-master", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", From d98d9c4afd259723a49293eae62ed356730a1bd6 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 20 Jan 2021 17:33:17 +0100 Subject: [PATCH 118/270] OPUSVIER-4395 Updated release notes --- RELEASE_NOTES.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9c8da2a0cb..8cc5ffe085 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -30,6 +30,27 @@ aus dem Index zu entfernen. Es kann über eine Option bestimmt werden wie viele Dokument gleichzeitig zum Solr-Server geschickt werden sollen. Das kann helfen, wenn es Probleme bei der Indexierung gibt. +# OPUS Framework Package + +## API + +Die `deletePermanent` Funktion von `Opus\Document`, um Dokumente vollständig zu +löschen, wurde entfernt. Die `delete` Funktion löscht Dokumente jetzt vollständig, +anstatt sie nur in den Server-Status **deleted** zu versetzen. Um Dokumente als +gelöscht zu markieren ohne sie komplett zu entfernen, muss nun `serServerState` +verwendet werden. + + $doc->setServerState(Document::STATE_DELETED); + $doc->store(); + +Dies muss unter Umständen bei eigenen Skripten berücksichtigt werden. + +## PHP Namespaces + +Der Code des OPUS Frameworks wurde in Vorbereitung auf die Migration zu Laminas +auf PHP Namespaces umgestellt und die Verwendung der Klassen in der Application +entsprechend angepasst. + --- ## Release 4.7.0.4 2020-12-02 From 4650f2ced196634f46014e95cefad5e20442f997 Mon Sep 17 00:00:00 2001 From: alw-bsz <49676210+alw-bsz@users.noreply.github.com> Date: Fri, 22 Jan 2021 17:03:10 +0100 Subject: [PATCH 119/270] typo corrected --- modules/setup/language/setup.tmx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/setup/language/setup.tmx b/modules/setup/language/setup.tmx index 660ad5a2c2..5b19cd58ca 100644 --- a/modules/setup/language/setup.tmx +++ b/modules/setup/language/setup.tmx @@ -323,10 +323,10 @@ help_title_searchtipps

Die Übersetzungen für diese Schlüssel können auch in der allgmeinen Übersetzungsverwaltung direkt angezeigt und -editiert werden. Sei gehören zum Modul "help".

+editiert werden. Sie gehören zum Modul "help".

Die Einträge für contact und imprint verwenden die gleichen Übersetzungsschlüssel wie die -entsprechenden Seiten. Wenn die Inhalte editiert werden ändern sie sich auf der FAQ-Seite und auch den einzelnen Seiten +entsprechenden Seiten. Wenn die Inhalte editiert werden, ändern sie sich auf der FAQ-Seite und auch den einzelnen Seiten für Impressum und Kontakt.

]]> From 3886401fbf5b1493d3e1adc9c915612014d9269d Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 1 Mar 2021 20:07:14 +0100 Subject: [PATCH 120/270] OPUSVIER-4518 Remove Zend_Registry usage --- composer.json | 6 +- library/Application/Configuration.php | 61 ++------- .../Configuration/MaxUploadSize.php | 10 +- .../Action/Helper/DocumentTypes.php | 52 ++++---- .../Controller/Action/Helper/Files.php | 7 +- .../Controller/Action/Helper/ReturnParams.php | 9 +- .../Controller/Action/Helper/Version.php | 6 +- .../Controller/Action/Helper/Workflow.php | 5 +- library/Application/Form/Abstract.php | 6 +- .../Form/Validate/DuplicateValue.php | 14 ++- .../Form/Validate/LanguageUsedOnceOnly.php | 6 +- .../Form/Validate/SeriesNumberAvailable.php | 7 +- .../Form/Validate/ValuePresentInSubforms.php | 6 +- library/Application/Import/PackageReader.php | 3 +- library/Application/Model/Abstract.php | 6 +- library/Application/Security/AclProvider.php | 2 +- library/Application/Security/RoleConfig.php | 5 +- library/Application/Translate.php | 6 +- library/Application/Translate/Help.php | 4 +- .../View/Helper/CustomFileSortingEnabled.php | 5 +- .../Application/View/Helper/JQueryEnabled.php | 4 +- .../Application/View/Helper/LayoutPath.php | 4 +- library/Application/View/Helper/LoginBar.php | 3 +- modules/admin/forms/ActionBox.php | 4 +- modules/admin/forms/Document/Person.php | 5 +- modules/admin/forms/WorkflowNotification.php | 5 +- modules/admin/models/IndexMaintenance.php | 6 +- modules/admin/models/Statistics.php | 2 +- modules/admin/models/UrnGenerator.php | 8 +- modules/citationExport/Bootstrap.php | 6 +- modules/export/Bootstrap.php | 8 +- modules/export/models/PublistExport.php | 5 +- .../frontdoor/controllers/MailController.php | 4 +- modules/frontdoor/models/HtmlMetaTags.php | 36 ++++-- modules/home/models/HelpFiles.php | 4 +- modules/oai/models/Request.php | 5 +- modules/oai/models/Server.php | 7 +- .../publish/controllers/FormController.php | 5 +- modules/publish/forms/PublishingAbstract.php | 8 +- .../models/DocumentWorkflowSubmitterId.php | 8 +- modules/publish/models/DocumenttypeParser.php | 5 +- modules/publish/models/FormElement.php | 3 +- modules/publish/models/LoggedUser.php | 4 +- modules/publish/models/Validation.php | 5 +- .../views/helpers/BibliographieOverview.php | 3 +- .../publish/views/helpers/FileOverview.php | 5 +- .../review/models/ClearDocumentsHelper.php | 5 +- .../scripts/index/browsecollection.phtml | 4 +- .../sword/controllers/DepositController.php | 7 +- .../controllers/ServicedocumentController.php | 7 +- modules/sword/models/AtomEntryDocument.php | 7 +- modules/sword/models/ErrorDocument.php | 9 +- modules/sword/models/ImportCollection.php | 6 +- modules/sword/models/ServiceDocument.php | 5 +- public/layouts/default/common.phtml | 4 +- public/layouts/opus4/common.phtml | 4 +- public/layouts/opus4/debug.phtml | 2 +- scripts/common/console.php | 7 +- scripts/cron/cron-check-consistency.php | 3 +- scripts/cron/cron-import-metadata.php | 5 +- scripts/cron/cron-send-notification.php | 5 +- scripts/cron/cron-send-review-request.php | 5 +- scripts/cron/cron-solr-update.php | 3 +- scripts/cron/cron-update-document-cache.php | 3 +- scripts/cron/cron-workspace-files-check.php | 6 +- scripts/opus-create-export-xml.php | 5 +- .../snippets/change-doi-landing-page-url.php | 4 +- tests/import-testdata.php | 2 +- .../Configuration/MaxUploadSizeTest.php | 2 +- .../library/Application/ConfigurationTest.php | 23 ++-- .../Controller/Action/Helper/AbstractTest.php | 9 +- .../Action/Helper/DocumentTypesTest.php | 12 +- .../Action/Helper/FileTypesTest.php | 16 +-- .../Action/Helper/ResultScriptTest.php | 8 +- .../Export/ExportPluginAbstractTest.php | 5 +- .../Application/Export/ExportServiceTest.php | 6 +- .../library/Application/Form/AbstractTest.php | 10 +- .../Form/Decorator/FileHashTest.php | 2 +- .../Form/Element/HitsPerPageTest.php | 4 +- .../Form/Element/TranslationModulesTest.php | 8 +- .../Form/Validate/IdentifierTest.php | 6 +- .../Import/TarPackageReaderTest.php | 4 +- .../Import/ZipPackageReaderTest.php | 4 +- .../Application/Model/AbstractTest.php | 10 +- .../Application/Search/FacetManagerTest.php | 16 +-- .../Translate/TranslationManagerTest.php | 40 +++--- tests/library/Application/TranslateTest.php | 17 +-- .../Application/Util/NotificationTest.php | 7 +- .../Util/PublicationNotificationTest.php | 8 +- .../Helper/CustomFileSortingEnabledTest.php | 4 +- .../View/Helper/DocumentTitleTest.php | 4 +- .../View/Helper/FaqEditLinkTest.php | 12 +- .../View/Helper/IsDisplayFieldTest.php | 4 +- .../View/Helper/LanguageSelectorTest.php | 10 +- .../View/Helper/OptionEnabledTest.php | 4 +- .../Application/View/Helper/OptionUrlTest.php | 12 +- .../View/Helper/OptionValueTest.php | 4 +- .../View/Helper/ShortenTextTest.php | 16 +-- .../View/Helper/TranslationEditLinkTest.php | 12 +- tests/library/Application/ZendBasicsTest.php | 2 +- tests/modules/ControllerTestCaseTest.php | 6 +- .../controllers/IndexControllerTest.php | 17 +-- .../controllers/DocumentControllerTest.php | 7 +- .../controllers/DocumentsControllerTest.php | 4 +- .../IndexmaintenanceControllerTest.php | 13 +- .../admin/controllers/InfoControllerTest.php | 6 +- .../admin/controllers/JobControllerTest.php | 9 +- .../controllers/ReportControllerTest.php | 14 +-- .../controllers/WorkflowControllerTest.php | 6 +- tests/modules/admin/models/DoiReportTest.php | 6 +- .../admin/models/IndexMaintenanceTest.php | 20 +-- .../modules/admin/models/UrnGeneratorTest.php | 26 +--- .../controller/IndexControllerTest.php | 9 +- tests/modules/export/BibtexExportTest.php | 16 +-- tests/modules/export/BootstrapTest.php | 4 +- tests/modules/export/DataCiteExportTest.php | 111 ++++++----------- tests/modules/export/Marc21ExportTest.php | 117 +++++++----------- tests/modules/export/RisExportTest.php | 2 +- .../controllers/IndexControllerTest.php | 70 +++++------ .../export/models/DataciteExportTest.php | 19 +-- .../export/models/PublistExportTest.php | 16 +-- tests/modules/export/models/XmlExportTest.php | 4 +- .../controllers/IndexControllerTest.php | 78 ++++++------ .../frontdoor/models/HtmlMetaTagsTest.php | 24 ++-- .../home/controllers/IndexControllerTest.php | 4 +- tests/modules/home/models/HelpFilesTest.php | 8 +- .../controllers/ContainerControllerTest.php | 7 +- .../oai/controllers/IndexControllerTest.php | 62 +++++----- tests/modules/oai/models/ContainerTest.php | 5 +- .../controllers/DepositControllerTest.php | 5 +- .../controllers/FormControllerTest.php | 14 +-- .../controllers/IndexControllerTest.php | 10 +- .../publish/forms/PublishingFirstTest.php | 4 +- .../publish/forms/PublishingSecondTest.php | 6 +- tests/modules/publish/models/DepositTest.php | 7 +- .../publish/models/ExtendedValidationTest.php | 16 +-- .../rss/controllers/IndexControllerTest.php | 3 +- tests/modules/rss/models/FeedTest.php | 31 ++--- .../controllers/LanguageControllerTest.php | 4 +- .../controllers/IndexControllerTest.php | 94 +++++--------- .../solrsearch/models/FacetMenuTest.php | 47 +++---- .../modules/solrsearch/models/SearchTest.php | 4 +- .../solrsearch/models/SeriesUtilTest.php | 4 +- .../solrsearch/models/search/BasicTest.php | 6 +- .../ServicedocumentControllerTest.php | 2 +- tests/rebuild-database.php | 4 +- tests/simple.ini | 2 + tests/support/AssumptionChecker.php | 10 +- tests/support/ControllerTestCase.php | 68 +++++++--- tests/support/DepositTestHelper.php | 12 +- tests/support/SimpleBootstrap.php | 10 +- tests/support/TestCase.php | 19 +-- 152 files changed, 918 insertions(+), 951 deletions(-) diff --git a/composer.json b/composer.json index e47b351350..a80264e01c 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,9 @@ "zendframework/zendframework1": "1.12.*", "jpgraph/jpgraph": "dev-master", "solarium/solarium": "3.8.*", - "opus4-repo/opus4-common": "dev-master", - "opus4-repo/framework": "dev-master", - "opus4-repo/search": "dev-master", + "opus4-repo/opus4-common": "dev-OPUSVIER-4518", + "opus4-repo/framework": "dev-OPUSVIER-4518", + "opus4-repo/search": "dev-OPUSVIER-4518", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", diff --git a/library/Application/Configuration.php b/library/Application/Configuration.php index a146784e13..42a9218832 100644 --- a/library/Application/Configuration.php +++ b/library/Application/Configuration.php @@ -32,10 +32,13 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; +use Opus\Log; + /** * Klasse für das Laden von Übersetzungsressourcen. */ -class Application_Configuration +class Application_Configuration extends Config { use \Opus\LoggingTrait; @@ -93,7 +96,7 @@ public static function getInstance() */ public function getConfig() { - return \Zend_Registry::get('Zend_Config'); + return Config::get(); } /** @@ -201,52 +204,6 @@ public function isLanguageSelectionEnabled() return $this->_languageSelectionEnabled; } - /** - * Returns the path to the application workspace. - * - * @throws Application_Exception - */ - public function getWorkspacePath() - { - $config = $this->getConfig(); - - if (! isset($config->workspacePath)) { - $this->getLogger()->err('missing config key workspacePath'); - throw new Application_Exception('missing configuration key workspacePath'); - } - - $workspacePath = $config->workspacePath; - - if (substr($workspacePath, -1) === DIRECTORY_SEPARATOR) { - return $workspacePath; - } else { - return $config->workspacePath . DIRECTORY_SEPARATOR; - } - } - - /** - * Returns path to temporary files folder. - * @return string Path for temporary files. - * @throws Application_Exception - */ - public function getTempPath() - { - if (is_null($this->_tempPath)) { - $this->_tempPath = trim($this->getWorkspacePath() . 'tmp' . DIRECTORY_SEPARATOR); - } - - return $this->_tempPath; - } - - /** - * Set path to folder for temporary files. - * @param $tempPath - */ - public function setTempPath($tempPath) - { - $this->_tempPath = $tempPath; - } - /** * Returns path to files folder for document files. * @return string Folder for storing document files @@ -262,7 +219,7 @@ public function getFilesPath() */ public static function getOpusVersion() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $localVersion = $config->version; return (is_null($localVersion)) ? 'unknown' : $localVersion; } @@ -312,7 +269,7 @@ public static function getValueFromConfig(\Zend_Config $config, $option) /** * Returns value for key in current configuration. - * @param $key Name of option + * @param $key string Name of option */ public function getValue($key) { @@ -332,7 +289,7 @@ public function getValue($key) public static function setValueInConfig(\Zend_Config $config, $option, $value) { if ($config->readOnly()) { - \Zend_Registry::get('Zend_Log')->err('Zend_Config object is readonly.'); + Log::get()->err('Zend_Config object is readonly.'); return; } @@ -377,7 +334,7 @@ public function getTranslate() public static function isUpdateInProgress() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); return isset($config->updateInProgress) && filter_var($config->updateInProgress, FILTER_VALIDATE_BOOLEAN); } diff --git a/library/Application/Configuration/MaxUploadSize.php b/library/Application/Configuration/MaxUploadSize.php index 43e1ab490d..f8df5c7024 100644 --- a/library/Application/Configuration/MaxUploadSize.php +++ b/library/Application/Configuration/MaxUploadSize.php @@ -27,9 +27,13 @@ * @category Application * @package Application_Configuration * @author Sascha Szott - * @copyright Copyright (c) 2016-2019 + * @copyright Copyright (c) 2016-2021 * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Config; +use Opus\Log; + class Application_Configuration_MaxUploadSize { @@ -47,9 +51,9 @@ public function getMaxUploadSizeInKB() public function getMaxUploadSizeInByte() { - $logger = \Zend_Registry::get('Zend_Log'); + $logger = Log::get(); - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $maxFileSizeInt = intval($config->publish->maxfilesize); $logger->debug('publish.maxfilesize (Byte) = ' . $maxFileSizeInt); diff --git a/library/Application/Controller/Action/Helper/DocumentTypes.php b/library/Application/Controller/Action/Helper/DocumentTypes.php index b5b8633b73..6b366ea5c1 100644 --- a/library/Application/Controller/Action/Helper/DocumentTypes.php +++ b/library/Application/Controller/Action/Helper/DocumentTypes.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; + /** * Helper class for getting document types and template names. * @@ -39,13 +41,6 @@ class Application_Controller_Action_Helper_DocumentTypes extends \Zend_Controller_Action_Helper_Abstract { - /** - * Configuration. - * - * @var Zend_Config - */ - private $_config; - /** * Names and paths for document type definition files. * @var array @@ -70,14 +65,6 @@ class Application_Controller_Action_Helper_DocumentTypes extends \Zend_Controlle */ private $_errors; - /** - * Constructs instances. - */ - public function __construct() - { - $this->_config = \Zend_Registry::get('Zend_Config'); - } - /** * Returns filtered list of document types. * @return array @@ -184,8 +171,10 @@ public function getTemplateName($documentType) $template = null; - if (isset($this->_config->documentTypes->templates->$documentType)) { - $template = $this->_config->documentTypes->templates->$documentType; + $config = $this->getConfig(); + + if (isset($config->documentTypes->templates->$documentType)) { + $template = $config->documentTypes->templates->$documentType; } if (! empty($template)) { @@ -200,12 +189,14 @@ public function getTemplateName($documentType) */ public function getTemplates() { + $config = $this->getConfig(); + if (! isset($this->_templates)) { - if (! isset($this->_config->publish->path->documenttemplates)) { + if (! isset($config->publish->path->documenttemplates)) { throw new Application_Exception('invalid configuration: publish.path.documenttemplates is not defined'); } - $path = $this->_config->publish->path->documenttemplates; + $path = $config->publish->path->documenttemplates; if ($path instanceof \Zend_Config) { $path = $path->toArray(); @@ -257,8 +248,10 @@ public function getDocTypesPath() { $path = null; - if (isset($this->_config->publish->path->documenttypes)) { - $path = $this->_config->publish->path->documenttypes; + $config = $this->getConfig(); + + if (isset($config->publish->path->documenttypes)) { + $path = $config->publish->path->documenttypes; } if (empty($path)) { @@ -345,10 +338,12 @@ public function direct() */ protected function _getIncludeList() { - if (! isset($this->_config->documentTypes->include)) { + $config = $this->getConfig(); + + if (! isset($config->documentTypes->include)) { return []; } - return $this->_getList($this->_config->documentTypes->include); + return $this->_getList($config->documentTypes->include); } /** @@ -357,10 +352,12 @@ protected function _getIncludeList() */ protected function _getExcludeList() { - if (! isset($this->_config->documentTypes->exclude)) { + $config = $this->getConfig(); + + if (! isset($config->documentTypes->exclude)) { return []; } - return $this->_getList($this->_config->documentTypes->exclude); + return $this->_getList($config->documentTypes->exclude); } private function _getList($str) @@ -454,4 +451,9 @@ public function getPathForDocumentType($name) return null; } + + public function getConfig() + { + return Config::get(); + } } diff --git a/library/Application/Controller/Action/Helper/Files.php b/library/Application/Controller/Action/Helper/Files.php index 632bc371b8..01c8a2be1b 100644 --- a/library/Application/Controller/Action/Helper/Files.php +++ b/library/Application/Controller/Action/Helper/Files.php @@ -31,6 +31,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; +use Opus\Log; + /** * Helper for basic file and folder operations. * @@ -73,7 +76,7 @@ public function listFiles($folder, $ignoreAllowedTypes = false) private function getAllowedFileTypes() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); if (! isset($config->publish->filetypes->allowed)) { return null; @@ -86,7 +89,7 @@ private function getAllowedFileTypes() private function checkFile($file, $ignoreAllowedTypes) { - $log = \Zend_Registry::get('Zend_Log'); + $log = Log::get(); $logMessage = 'check for file: ' . $file->getPathname(); if (! $ignoreAllowedTypes) { diff --git a/library/Application/Controller/Action/Helper/ReturnParams.php b/library/Application/Controller/Action/Helper/ReturnParams.php index bf34b260ea..f4338c9bd2 100644 --- a/library/Application/Controller/Action/Helper/ReturnParams.php +++ b/library/Application/Controller/Action/Helper/ReturnParams.php @@ -24,12 +24,15 @@ * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * @category TODO + * @category Application + * * @author Jens Schwidder - * @copyright Copyright (c) 2008-2010, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; + /** * Helper class for getting an array with current request parameters. * @@ -48,7 +51,7 @@ class Application_Controller_Action_Helper_ReturnParams extends \Zend_Controller public function getReturnParameters() { // TODO put into constructor - $log = \Zend_Registry::get('Zend_Log'); + $log = Log::get(); $params = []; foreach (\Zend_Controller_Front::getInstance()->getRequest()->getUserParams() as $key => $value) { diff --git a/library/Application/Controller/Action/Helper/Version.php b/library/Application/Controller/Action/Helper/Version.php index 697f441e25..404ead48f5 100644 --- a/library/Application/Controller/Action/Helper/Version.php +++ b/library/Application/Controller/Action/Helper/Version.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Config; + /** * Helper für das Auslesen der aktuellen Opusversion vom Opus-Server. * @@ -32,7 +34,7 @@ * @package Application_Controller_Helper * @author Michael Lang * @author Jens Schwidder - * @copyright Copyright (c) 2014, OPUS 4 development team + * @copyright Copyright (c) 2014-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ class Application_Controller_Action_Helper_Version extends Application_Controller_Action_Helper_Abstract @@ -70,7 +72,7 @@ public function setVersion($version) */ public function getLatestReleaseFromServer() { - $latestUrl = \Zend_Registry::get('Zend_Config')->update->latestVersionCheckUrl; + $latestUrl = Config::get()->update->latestVersionCheckUrl; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); diff --git a/library/Application/Controller/Action/Helper/Workflow.php b/library/Application/Controller/Action/Helper/Workflow.php index 62a7603bde..861faf3926 100644 --- a/library/Application/Controller/Action/Helper/Workflow.php +++ b/library/Application/Controller/Action/Helper/Workflow.php @@ -27,11 +27,12 @@ * @category Application * @package Controller * @author Jens Schwidder - * @copyright Copyright (c) 2008-2018, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\Document; +use Opus\Log; /** * Controller helper for providing workflow support. @@ -91,7 +92,7 @@ public function isTransitionAllowed($document, $targetState) */ public function getAllowedTargetStatesForDocument($document) { - $logger = \Zend_Registry::get('Zend_Log'); + $logger = Log::get(); $currentState = $document->getServerState(); diff --git a/library/Application/Form/Abstract.php b/library/Application/Form/Abstract.php index b3f08051df..39ed9007dc 100644 --- a/library/Application/Form/Abstract.php +++ b/library/Application/Form/Abstract.php @@ -25,13 +25,15 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Config; + /** * Abstrakte Basisklasse für OPUS Formulare. * * @category Application * @package Application_Form * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ abstract class Application_Form_Abstract extends \Zend_Form_SubForm @@ -190,7 +192,7 @@ public function setLabelPrefix($prefix) public function getApplicationConfig() { if (is_null($this->_config)) { - $this->_config = \Zend_Registry::get('Zend_Config'); + $this->_config = Config::get(); } return $this->_config; diff --git a/library/Application/Form/Validate/DuplicateValue.php b/library/Application/Form/Validate/DuplicateValue.php index 56ba105b9c..f9e5868dd3 100644 --- a/library/Application/Form/Validate/DuplicateValue.php +++ b/library/Application/Form/Validate/DuplicateValue.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; + /** * Checks if in an edit form a value is selected more than once for a field. * @@ -82,8 +84,8 @@ class Application_Form_Validate_DuplicateValue extends \Zend_Validate_Abstract /** * Konstruiert Validator. * - * @param $values Werte der benachbarten Unterformulare - * @param $position Position des Unterformulars + * @param $values array Werte der benachbarten Unterformulare + * @param $position int Position des Unterformulars * @param null $message Fehlermeldung */ public function __construct($values, $position, $message = null) @@ -101,8 +103,8 @@ public function __construct($values, $position, $message = null) * The function assumes that the context contains multiple arrays (subforms) * that contain the same element. * - * @param string $value Does not matter for this validator - * @param hash $context Values of all the subforms + * @param $value string Does not matter for this validator + * @param $context array Values of all the subforms */ public function isValid($value, $context = null) { @@ -112,7 +114,7 @@ public function isValid($value, $context = null) $valueCount = count($this->_values); if (! ($this->_position < $valueCount)) { - \Zend_Registry::get('Zend_Log')->err( + Log::get()->err( __CLASS__ . ' mit Position > count(values) konstruiert.' ); @@ -126,7 +128,7 @@ public function isValid($value, $context = null) } } } else { - \Zend_Registry::get('Zend_Log')->err(__CLASS__ . ' mit Values = NULL konstruiert.'); + Log::get()->err(__CLASS__ . ' mit Values = NULL konstruiert.'); } return true; diff --git a/library/Application/Form/Validate/LanguageUsedOnceOnly.php b/library/Application/Form/Validate/LanguageUsedOnceOnly.php index 08477d0c1e..8c7b51d73e 100644 --- a/library/Application/Form/Validate/LanguageUsedOnceOnly.php +++ b/library/Application/Form/Validate/LanguageUsedOnceOnly.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; + /** * Prüft, ob die Sprache bereits benutzt wurde. * @@ -98,7 +100,7 @@ public function isValid($value, $context = null) $langCount = count($this->_languages); if (! ($this->_position < $langCount)) { - \Zend_Registry::get('Zend_Log')->err(__CLASS__ . ' mit Position > count(Languages) konstruiert.'); + Log::get()->err(__CLASS__ . ' mit Position > count(Languages) konstruiert.'); } if (! is_null($this->_languages)) { @@ -109,7 +111,7 @@ public function isValid($value, $context = null) } } } else { - \Zend_Registry::get('Zend_Log')->err(__CLASS__ . ' mit Languages = NULL konstruiert.'); + Log::get()->err(__CLASS__ . ' mit Languages = NULL konstruiert.'); } return true; diff --git a/library/Application/Form/Validate/SeriesNumberAvailable.php b/library/Application/Form/Validate/SeriesNumberAvailable.php index 6236e984a0..91c4261417 100644 --- a/library/Application/Form/Validate/SeriesNumberAvailable.php +++ b/library/Application/Form/Validate/SeriesNumberAvailable.php @@ -26,10 +26,11 @@ * * @category Application * @author Jens Schwidder - * @copyright Copyright (c) 2008-2012, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; use Opus\Series; use Opus\Model\NotFoundException; @@ -75,14 +76,14 @@ public function isValid($value, $context = null) } if (strlen(trim($seriesId)) == 0 && is_numeric($seriesId)) { - \Zend_Registry::get('Zend_Log')->err(__METHOD__ . ' Context without \'SeriesId\'.'); + Log::get()->err(__METHOD__ . ' Context without \'SeriesId\'.'); return true; // should be captured somewhere else } try { $series = new Series($seriesId); } catch (NotFoundException $omnfe) { - \Zend_Registry::get('Zend_Log')->err(__METHOD__ . $omnfe->getMessage()); + Log::get()->err(__METHOD__ . $omnfe->getMessage()); return true; } diff --git a/library/Application/Form/Validate/ValuePresentInSubforms.php b/library/Application/Form/Validate/ValuePresentInSubforms.php index 52af725cfa..cda2fe96c8 100644 --- a/library/Application/Form/Validate/ValuePresentInSubforms.php +++ b/library/Application/Form/Validate/ValuePresentInSubforms.php @@ -27,10 +27,12 @@ * @category Application * @package Form_Validate * @author Jens Schwidder - * @copyright Copyright (c) 2013-2020, OPUS 4 development team + * @copyright Copyright (c) 2013-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; + /** * Prüft ob ein Wertfür ein Feld in Unterformularen mindestens einmal vorkommt. * @@ -87,7 +89,7 @@ public function isValid($value, $context = null) } } } else { - \Zend_Registry::get('Zend_Log')->err(__CLASS__ . '::' . __METHOD__ . ' mit $context = null aufgerufen.'); + Log::get()->err(__CLASS__ . '::' . __METHOD__ . ' mit $context = null aufgerufen.'); } $this->_error(self::NOT_VALID); diff --git a/library/Application/Import/PackageReader.php b/library/Application/Import/PackageReader.php index e1e240ce95..ea45e9c082 100644 --- a/library/Application/Import/PackageReader.php +++ b/library/Application/Import/PackageReader.php @@ -37,6 +37,7 @@ * Currently ZIP and TAR files are supported by extending classes. */ +use Opus\Log; use Opus\Model\ModelException; use Opus\Security\SecurityException; @@ -127,7 +128,7 @@ public function readPackage($dirName) public function getLogger() { - return \Zend_Registry::get('Zend_Log'); + return Log::get(); } /** diff --git a/library/Application/Model/Abstract.php b/library/Application/Model/Abstract.php index d689f3aef6..a99a1f9129 100644 --- a/library/Application/Model/Abstract.php +++ b/library/Application/Model/Abstract.php @@ -25,13 +25,15 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Config; + /** * Abstract base class for model classes. * * @category Application * @package Application_Model * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ abstract class Application_Model_Abstract @@ -62,7 +64,7 @@ public function setConfig(\Zend_Config $config = null) public function getConfig() { if (is_null($this->_config)) { - $this->_config = \Zend_Registry::get('Zend_Config'); + $this->_config = Config::get(); } return $this->_config; } diff --git a/library/Application/Security/AclProvider.php b/library/Application/Security/AclProvider.php index 09e7670c0c..377b332d97 100644 --- a/library/Application/Security/AclProvider.php +++ b/library/Application/Security/AclProvider.php @@ -139,7 +139,7 @@ public function getAcls() $this->loadRoles($acl, $parents); // create role for user on-the-fly with assigned roles as parents - if (\Zend_Registry::get('LOG_LEVEL') >= \Zend_LOG::DEBUG) { + if ($logger->getLevel() >= \Zend_LOG::DEBUG) { $logger->debug( "ACL: Create role '" . $user . "' with parents " . "(" . implode(", ", $parents) . ")" ); diff --git a/library/Application/Security/RoleConfig.php b/library/Application/Security/RoleConfig.php index 3cae274a1e..d9bfdba0d6 100644 --- a/library/Application/Security/RoleConfig.php +++ b/library/Application/Security/RoleConfig.php @@ -27,10 +27,11 @@ * @category Application * @package Controller * @author Jens Schwidder - * @copyright Copyright (c) 2008-2012, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; use Opus\UserRole; /** @@ -66,7 +67,7 @@ public function getRolePermissions($acl, $roleName) $role = UserRole::fetchByName($roleName); if (is_null($role)) { - \Zend_Registry::get('Zend_Log')->err("Attempt to load unknown role '$roleName'."); + Log::get()->err("Attempt to load unknown role '$roleName'."); return; } diff --git a/library/Application/Translate.php b/library/Application/Translate.php index d93897f0a0..7631106383 100644 --- a/library/Application/Translate.php +++ b/library/Application/Translate.php @@ -27,10 +27,12 @@ * @category Application * @package Application * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; + /** * Erweiterung von Zend_Translate, um Übersetzungsressourcen für Module zu laden. * @@ -216,7 +218,7 @@ public function getOptions() */ public function isLogUntranslatedEnabled() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); return (isset($config->log->untranslated)) ? filter_var($config->log->untranslated, FILTER_VALIDATE_BOOLEAN) : false; } diff --git a/library/Application/Translate/Help.php b/library/Application/Translate/Help.php index 64ead65124..f7e53826df 100644 --- a/library/Application/Translate/Help.php +++ b/library/Application/Translate/Help.php @@ -33,6 +33,8 @@ * TODO define and use interface */ +use Opus\Config; + abstract class Application_Translate_Help { @@ -52,7 +54,7 @@ public static function getInstance() public function getConfig() { if (is_null($this->config)) { - $this->config = \Zend_Registry::get('Zend_Config'); + $this->config = Config::get(); } return $this->config; } diff --git a/library/Application/View/Helper/CustomFileSortingEnabled.php b/library/Application/View/Helper/CustomFileSortingEnabled.php index 048da27c50..529eb84a65 100644 --- a/library/Application/View/Helper/CustomFileSortingEnabled.php +++ b/library/Application/View/Helper/CustomFileSortingEnabled.php @@ -27,10 +27,11 @@ * @category Application * @package Application_View_Helper * @author Jens Schwidder - * @copyright Copyright (c) 2017, OPUS 4 development team + * @copyright Copyright (c) 2017-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; class Application_View_Helper_CustomFileSortingEnabled extends \Zend_View_Helper_Abstract { @@ -41,7 +42,7 @@ class Application_View_Helper_CustomFileSortingEnabled extends \Zend_View_Helper */ public function customFileSortingEnabled() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); return isset($config->frontdoor->files->customSorting) && filter_var($config->frontdoor->files->customSorting, FILTER_VALIDATE_BOOLEAN); } diff --git a/library/Application/View/Helper/JQueryEnabled.php b/library/Application/View/Helper/JQueryEnabled.php index d34c0bec70..85dfb945b9 100644 --- a/library/Application/View/Helper/JQueryEnabled.php +++ b/library/Application/View/Helper/JQueryEnabled.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; + /** * Checks if JQuery Library is available. */ @@ -40,7 +42,7 @@ class Application_View_Helper_JQueryEnabled extends \Zend_View_Helper_Abstract public function jQueryEnabled() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); if (! isset($config->javascript->jquery->path)) { return false; } diff --git a/library/Application/View/Helper/LayoutPath.php b/library/Application/View/Helper/LayoutPath.php index 5202821dee..8ace179806 100644 --- a/library/Application/View/Helper/LayoutPath.php +++ b/library/Application/View/Helper/LayoutPath.php @@ -31,12 +31,14 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; + class Application_View_Helper_LayoutPath extends \Zend_View_Helper_Abstract { public function layoutPath() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $theme = 'opus4'; if (isset($config->theme)) { $theme = $config->theme; diff --git a/library/Application/View/Helper/LoginBar.php b/library/Application/View/Helper/LoginBar.php index 936cff613f..4469a3614d 100644 --- a/library/Application/View/Helper/LoginBar.php +++ b/library/Application/View/Helper/LoginBar.php @@ -33,6 +33,7 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; use Opus\Security\Realm; /** @@ -131,7 +132,7 @@ public function __toString() if ($realm->checkModule('account') == true) { // Prüfe, ob Nutzer ihren Account editieren dürfen - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); if (isset($config) and isset($config->account->editOwnAccount)) { $addAccountLink = filter_var($config->account->editOwnAccount, FILTER_VALIDATE_BOOLEAN); } diff --git a/modules/admin/forms/ActionBox.php b/modules/admin/forms/ActionBox.php index a5121d223a..f8779b4343 100644 --- a/modules/admin/forms/ActionBox.php +++ b/modules/admin/forms/ActionBox.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; + /** * Unterformular für Actionbox für Metadaten-Formular. * @@ -122,7 +124,7 @@ public function getJumpLinks() } } else { // Sollte niemals passieren - \Zend_Registry::get('Zend_Log')->err('ActionBox without parent form'); + Log::get()->err('ActionBox without parent form'); } return $links; diff --git a/modules/admin/forms/Document/Person.php b/modules/admin/forms/Document/Person.php index 25deafc39c..680fd45fbf 100644 --- a/modules/admin/forms/Document/Person.php +++ b/modules/admin/forms/Document/Person.php @@ -116,8 +116,9 @@ public function getLinkModel($documentId, $role) $this->updateModel($personLink); $personLink->setRole($role); - if (\Zend_Registry::get('LOG_LEVEL') >= \Zend_Log::DEBUG) { - $log = $this->getLogger(); + $log = $this->getLogger(); + + if ($log->getLevel() >= \Zend_Log::DEBUG) { $log->debug(\Zend_Debug::dump($personLink->getId(), 'DocumentPerson-ID', false)); $log->debug(\Zend_Debug::dump($personLink->getRole(), 'DocumentPerson-Role', false)); $log->debug(\Zend_Debug::dump($personLink->getSortOrder(), 'DocumentPerson-SortOrder', false)); diff --git a/modules/admin/forms/WorkflowNotification.php b/modules/admin/forms/WorkflowNotification.php index 5ba52ccab4..bfca2884c5 100644 --- a/modules/admin/forms/WorkflowNotification.php +++ b/modules/admin/forms/WorkflowNotification.php @@ -27,12 +27,13 @@ * @category Application * @package Module_Admin * @author Jens Schwidder - * @copyright Copyright (c) 2018, OPUS 4 development team + * @copyright Copyright (c) 2018-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License * * TODO use getRecipients */ +use Opus\Config; use Opus\Document; class Admin_Form_WorkflowNotification extends Admin_Form_YesNoForm @@ -67,7 +68,7 @@ public function getTargetState() public function isNotificationEnabled() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); return (isset($config->notification->document->published->enabled) && filter_var($config->notification->document->published->enabled, FILTER_VALIDATE_BOOLEAN)); } diff --git a/modules/admin/models/IndexMaintenance.php b/modules/admin/models/IndexMaintenance.php index e89dc9c039..b1f2819b41 100644 --- a/modules/admin/models/IndexMaintenance.php +++ b/modules/admin/models/IndexMaintenance.php @@ -32,7 +32,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; use Opus\Job; +use Opus\Log; use Opus\Search\Task\ConsistencyCheck; class Admin_Model_IndexMaintenance @@ -48,8 +50,8 @@ class Admin_Model_IndexMaintenance public function __construct($logger = null) { - $this->_config = \Zend_Registry::get('Zend_Config'); - $this->_logger = (is_null($logger)) ? \Zend_Registry::get('Zend_Log') : $logger; + $this->_config = Config::get(); + $this->_logger = (is_null($logger)) ? Log::get() : $logger; $this->setFeatureDisabled(); if ($this->_featureDisabled) { diff --git a/modules/admin/models/Statistics.php b/modules/admin/models/Statistics.php index 7cd9bcbed3..5dc63200fa 100644 --- a/modules/admin/models/Statistics.php +++ b/modules/admin/models/Statistics.php @@ -131,7 +131,7 @@ public function getInstituteStatistics($selectedYear) LEFT JOIN collections c ON ldc.collection_id=c.id WHERE c.role_id=? AND YEAR(server_date_published)=? AND server_state='published' group by name"; - $db = \Zend_Registry::get('db_adapter'); + $db = \Zend_Db_Table::getDefaultAdapter(); $res = $db->query($query, [$role->getId(), $selectedYear])->fetchAll(); foreach ($res as $result) { diff --git a/modules/admin/models/UrnGenerator.php b/modules/admin/models/UrnGenerator.php index 1037e727a4..df8710d91f 100644 --- a/modules/admin/models/UrnGenerator.php +++ b/modules/admin/models/UrnGenerator.php @@ -27,11 +27,13 @@ * @category Application * @package Module_Admin * @author Sascha Szott - * @copyright Copyright (c) 2018, OPUS 4 development team + * @copyright Copyright (c) 2018-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; use Opus\Identifier\Urn; +use Opus\Log; class Admin_Model_UrnGenerator { @@ -49,7 +51,7 @@ class Admin_Model_UrnGenerator */ public function __construct() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); if (! isset($config->urn->nid) || $config->urn->nid == '') { throw new Application_Exception('missing configuration setting for urn.nid - is required for URN generation'); @@ -74,7 +76,7 @@ public function generateUrnForDocument($docId) $identifierUrn = new Urn($this->nid, $this->nss); $urn = $identifierUrn->getUrn($docId); - $log = \Zend_Registry::get('Zend_Log'); + $log = Log::get(); $log->debug('URN generation result for document ' . $docId . ' is ' . $urn); return $urn; diff --git a/modules/citationExport/Bootstrap.php b/modules/citationExport/Bootstrap.php index 53a72fa3b6..f57dbcbe83 100644 --- a/modules/citationExport/Bootstrap.php +++ b/modules/citationExport/Bootstrap.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; + class CitationExport_Bootstrap extends \Zend_Application_Module_Bootstrap { @@ -47,7 +49,7 @@ protected function _initExport() if (! \Zend_Registry::isRegistered('Opus_Exporter')) { if (! $updateInProgress) { - \Zend_Registry::get('Zend_Log')->warn(__METHOD__ . ' exporter not found'); + Log::get()->warn(__METHOD__ . ' exporter not found'); } return; } @@ -56,7 +58,7 @@ protected function _initExport() if (is_null($exporter)) { if ($updateInProgress) { - \Zend_Registry::get('Zend_Log')->warn(__METHOD__ . ' exporter not found'); + Log::get()->warn(__METHOD__ . ' exporter not found'); } return; } diff --git a/modules/export/Bootstrap.php b/modules/export/Bootstrap.php index 3eb48c2bf0..2a3a67062a 100644 --- a/modules/export/Bootstrap.php +++ b/modules/export/Bootstrap.php @@ -32,6 +32,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; +use Opus\Log; use Opus\Security\Realm; class Export_Bootstrap extends \Zend_Application_Module_Bootstrap @@ -43,7 +45,7 @@ protected function _initExport() if (! \Zend_Registry::isRegistered('Opus_Exporter')) { if (! $updateInProgress) { - \Zend_Registry::get('Zend_Log')->warn(__METHOD__ . ' exporter not found'); + Log::get()->warn(__METHOD__ . ' exporter not found'); } return; } @@ -52,12 +54,12 @@ protected function _initExport() if (is_null($exporter)) { if (! $updateInProgress) { - \Zend_Registry::get('Zend_Log')->warn(__METHOD__ . ' exporter not found'); + Log::get()->warn(__METHOD__ . ' exporter not found'); } return; } - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); // only add XML export if user has access and stylesheet is configured if (isset($config->export->stylesheet->frontdoor)) { diff --git a/modules/export/models/PublistExport.php b/modules/export/models/PublistExport.php index ba9f904fef..bc88e9220b 100644 --- a/modules/export/models/PublistExport.php +++ b/modules/export/models/PublistExport.php @@ -27,12 +27,13 @@ * @category Application * @package Module_Export * @author Jens Schwidder - * @copyright Copyright (c) 2008-2014, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\Collection; use Opus\CollectionRole; +use Opus\Config; /** * Export plugin for exporting collections based on role name and collection number. @@ -124,7 +125,7 @@ public function execute() $this->_proc->setParameter('', 'groupBy', $groupBy); $this->_proc->setParameter('', 'pluginName', $this->getName()); - $urnResolverUrl = \Zend_Registry::get('Zend_Config')->urn->resolverUrl; + $urnResolverUrl = Config::get()->urn->resolverUrl; $this->_proc->setParameter('', 'urnResolverUrl', $urnResolverUrl); $this->loadStyleSheet($this->buildStylesheetPath($stylesheet, $view->getScriptPath('') . $stylesheetDirectory)); diff --git a/modules/frontdoor/controllers/MailController.php b/modules/frontdoor/controllers/MailController.php index 98c20e47f3..8ac41dd616 100644 --- a/modules/frontdoor/controllers/MailController.php +++ b/modules/frontdoor/controllers/MailController.php @@ -29,7 +29,7 @@ * @author Simone Finkbeiner-Franke * @author Jens Schwidder * @author Sascha Szott - * @copyright Copyright (c) 2009, OPUS 4 development team + * @copyright Copyright (c) 2009-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ @@ -112,7 +112,7 @@ public function sendmailAction() $from = ''; $from = $form->getValue('sender_mail'); if ($from == '') { - $config = Zend_Registry::get('Zend_Config'); + $config = Config::get(); if (true === isset($config->mail->opus->address)) { $from = $config->mail->opus->address; } diff --git a/modules/frontdoor/models/HtmlMetaTags.php b/modules/frontdoor/models/HtmlMetaTags.php index 1038322542..dc47fc6f67 100644 --- a/modules/frontdoor/models/HtmlMetaTags.php +++ b/modules/frontdoor/models/HtmlMetaTags.php @@ -38,6 +38,10 @@ * TODO new types have to be added as functions -> make extendable? how is it used when rendering? * Basically each type could be a separate class. Refactor for later so new types or metatags won't necessarily * require changing core classes (this class here). + * TODO how to handle configuration - during production requests it is not a problem, but for tests the configuration + * is sometimes manipulated and setting the configuration in the constructor means that those updates only work + * if the same configuration object is manipulated, which isn't always possible - one solution would be to make + * sure, that the configuration for tests is always modifiable */ class Frontdoor_Model_HtmlMetaTags { @@ -283,12 +287,13 @@ private function handleLicences($document, &$metas) */ private function handleIdentifierUrn($document, &$metas) { + $config = $this->getConfig(); foreach ($document->getIdentifierUrn() as $identifier) { $identifierValue = trim($identifier->getValue()); if ($identifierValue !== '') { $metas[] = ['DC.identifier', $identifierValue]; - if (isset($this->config, $this->config->urn->resolverUrl)) { - $metas[] = ['DC.identifier', $this->config->urn->resolverUrl . $identifierValue]; + if (isset($config, $config->urn->resolverUrl)) { + $metas[] = ['DC.identifier', $config->urn->resolverUrl . $identifierValue]; } } } @@ -357,9 +362,10 @@ private function handleFrontdoorUrl($document, &$metas) private function handleFulltextUrls($document, &$metas) { if (Application_Xslt::embargoHasPassed($document)) { + $config = $this->getConfig(); $baseUrlFiles = $this->fullUrl; - if (isset($this->config, $this->config->deliver->url->prefix)) { - $baseUrlFiles .= $this->config->deliver->url->prefix; + if (isset($config, $config->deliver->url->prefix)) { + $baseUrlFiles .= $config->deliver->url->prefix; } else { $baseUrlFiles .= '/files'; } @@ -568,17 +574,19 @@ public function getMetatagsType($document) public function getMappingConfig() { - if (is_null($this->mapping) && isset($this->config)) { + $config = $this->getConfig(); + + if (is_null($this->mapping) && isset($config)) { $mapping = []; // load default mappings - if (isset($this->config->metatags->defaultMapping)) { - $mapping = array_merge($mapping, $this->loadMapping($this->config->metatags->defaultMapping)); + if (isset($config->metatags->defaultMapping)) { + $mapping = array_merge($mapping, $this->loadMapping($config->metatags->defaultMapping)); } // load custom mapping - if (isset($this->config->metatags->mapping)) { - $mapping = array_merge($mapping, $this->loadMapping($this->config->metatags->mapping)); + if (isset($config->metatags->mapping)) { + $mapping = array_merge($mapping, $this->loadMapping($config->metatags->mapping)); } $this->mapping = $mapping; @@ -598,4 +606,14 @@ private function loadMapping($config) } return $mapping; } + + public function getConfig() + { + return $this->config; + } + + public function setConfig($config) + { + $this->config = $config; + } } diff --git a/modules/home/models/HelpFiles.php b/modules/home/models/HelpFiles.php index 82b1fd0542..5afd112ab9 100644 --- a/modules/home/models/HelpFiles.php +++ b/modules/home/models/HelpFiles.php @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; + /** * Model for encapsuling access to help files. * @@ -146,7 +148,7 @@ private function getHelpConfig() $config = new \Zend_Config_Ini($filePath); } catch (\Zend_Config_Exception $zce) { // TODO einfachere Lösung? - $logger = \Zend_Registry::get('Zend_Log'); + $logger = Log::get(); if (! is_null($logger)) { $logger->err("could not load help configuration", $zce); } diff --git a/modules/oai/models/Request.php b/modules/oai/models/Request.php index fce281724b..42ee80524a 100644 --- a/modules/oai/models/Request.php +++ b/modules/oai/models/Request.php @@ -28,11 +28,12 @@ * @category Application * @package Module_Oai * @author Henning Gerhardt (henning.gerhardt@slub-dresden.de) - * @copyright Copyright (c) 2009, OPUS 4 development team + * @copyright Copyright (c) 2009-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\Date; +use Opus\Log; use Opus\Security\Realm; /** @@ -393,7 +394,7 @@ public function setResumptionPath($path) */ public function validate(array $oaiRequest) { - $logger = \Zend_Registry::get('Zend_Log'); + $logger = Log::get(); $errorInformation = [ 'message' => 'General oai request validation error.', diff --git a/modules/oai/models/Server.php b/modules/oai/models/Server.php index 9c8b14318b..40940ea2f8 100644 --- a/modules/oai/models/Server.php +++ b/modules/oai/models/Server.php @@ -27,12 +27,13 @@ * @category Application * @package Oai_Modul * @author Jens Schwidder - * @copyright Copyright (c) 2017, OPUS 4 development team + * @copyright Copyright (c) 2017-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\Document; use Opus\DocumentFinder; +use Opus\Log; use Opus\Model\NotFoundException; use Opus\Model\Xml; use Opus\Model\Xml\Cache; @@ -204,7 +205,7 @@ protected function handleRequestIntern(array $oaiRequest, $requestUri) } foreach ($oaiRequest as $parameter => $value) { - \Zend_Registry::get('Zend_Log')->debug("'oai_' . $parameter, $value"); + Log::get()->debug("'oai_' . $parameter, $value"); $this->_proc->setParameter('', 'oai_' . $parameter, $value); } @@ -723,7 +724,7 @@ private function getDocumentXmlDomNode($document) { if (! in_array($document->getServerState(), $this->_deliveringDocumentStates)) { $message = 'Trying to get a document in server state "' . $document->getServerState() . '"'; - \Zend_Registry::get('Zend_Log')->err($message); + Log::get()->err($message); throw new \Exception($message); } diff --git a/modules/publish/controllers/FormController.php b/modules/publish/controllers/FormController.php index acbeab6473..c44d2acdef 100644 --- a/modules/publish/controllers/FormController.php +++ b/modules/publish/controllers/FormController.php @@ -27,10 +27,11 @@ * @category Application * @package Module_Publish * @author Susanne Gottwald - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; use Opus\Document; use Opus\Model\ModelException; @@ -103,7 +104,7 @@ public function uploadAction() $this->view->subtitle = $this->view->translate('publish_controller_index_anotherFile'); } - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); if (isset($config->publish->filetypes->allowed)) { $this->view->extensions = $config->publish->filetypes->allowed; diff --git a/modules/publish/forms/PublishingAbstract.php b/modules/publish/forms/PublishingAbstract.php index 43b6478b12..56edf24bd5 100644 --- a/modules/publish/forms/PublishingAbstract.php +++ b/modules/publish/forms/PublishingAbstract.php @@ -1,5 +1,4 @@ - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Config; + abstract class Publish_Form_PublishingAbstract extends \Zend_Form { @@ -45,7 +47,7 @@ abstract class Publish_Form_PublishingAbstract extends \Zend_Form public function __construct() { $this->_session = new \Zend_Session_Namespace('Publish'); - $this->_config = \Zend_Registry::get('Zend_Config'); + $this->_config = Config::get(); $this->_documentTypesHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('DocumentTypes'); $this->view = $this->getView(); parent::__construct(); diff --git a/modules/publish/models/DocumentWorkflowSubmitterId.php b/modules/publish/models/DocumentWorkflowSubmitterId.php index 15a5b6dc34..a4d4410003 100644 --- a/modules/publish/models/DocumentWorkflowSubmitterId.php +++ b/modules/publish/models/DocumentWorkflowSubmitterId.php @@ -1,5 +1,4 @@ - * @copyright Copyright (c) 2011-2012, OPUS 4 development team + * @copyright Copyright (c) 2011-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Log; + class Publish_Model_DocumentWorkflowMatheon extends Publish_Model_DocumentWorkflow { @@ -45,7 +47,7 @@ protected function initializeDocument() $userId = trim($loggedUserModel->getUserId()); if (empty($userId)) { - $logger = \Zend_Registry::get('Zend_Log'); + $logger = Log::get(); $logger->debug("No user logged in. Skipping enrichment."); return; } diff --git a/modules/publish/models/DocumenttypeParser.php b/modules/publish/models/DocumenttypeParser.php index 13d0d83b0d..840c0eecd2 100644 --- a/modules/publish/models/DocumenttypeParser.php +++ b/modules/publish/models/DocumenttypeParser.php @@ -28,11 +28,12 @@ * @package Module_Publish * @author Susanne Gottwald * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\EnrichmentKey; +use Opus\Log; class Publish_Model_DocumenttypeParser extends Application_Model_Abstract { @@ -69,7 +70,7 @@ class Publish_Model_DocumenttypeParser extends Application_Model_Abstract */ public function __construct($dom, $form, $additionalFields = [], $postValues = []) { - $this->_log = \Zend_Registry::get('Zend_Log'); + $this->_log = Log::get(); $this->_session = new \Zend_Session_Namespace('Publish'); $this->form = $form; $this->dom = $dom; diff --git a/modules/publish/models/FormElement.php b/modules/publish/models/FormElement.php index 6660bec4cc..d7e04c67bc 100644 --- a/modules/publish/models/FormElement.php +++ b/modules/publish/models/FormElement.php @@ -32,6 +32,7 @@ */ use Opus\CollectionRole; +use Opus\Log; class Publish_Model_FormElement { @@ -77,7 +78,7 @@ public function __construct( ) { $this->session = new \Zend_Session_Namespace('Publish'); $this->sessionOpus = new \Zend_Session_Namespace(); - $this->log = \Zend_Registry::get('Zend_Log'); + $this->log = Log::get(); $this->form = $form; $this->_elementName = $name; diff --git a/modules/publish/models/LoggedUser.php b/modules/publish/models/LoggedUser.php index 093a770321..b07753e53d 100644 --- a/modules/publish/models/LoggedUser.php +++ b/modules/publish/models/LoggedUser.php @@ -1,5 +1,4 @@ _log = \Zend_Registry::get('Zend_Log'); + $this->_log = Log::get(); $login = \Zend_Auth::getInstance()->getIdentity(); if (is_null($login) or trim($login) == '') { diff --git a/modules/publish/models/Validation.php b/modules/publish/models/Validation.php index ae07f24de5..f5cc0fdd7b 100644 --- a/modules/publish/models/Validation.php +++ b/modules/publish/models/Validation.php @@ -28,12 +28,13 @@ * @package Module_Publish * @author Susanne Gottwald * @author Michael Lang - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\Collection; use Opus\CollectionRole; +use Opus\Config; use Opus\DnbInstitute; use Opus\Licence; use Opus\Series; @@ -438,7 +439,7 @@ private function getSeries() } } - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); if (isset($config->browsing->series->sortByTitle) && filter_var($config->browsing->series->sortByTitle, FILTER_VALIDATE_BOOLEAN)) { diff --git a/modules/publish/views/helpers/BibliographieOverview.php b/modules/publish/views/helpers/BibliographieOverview.php index 7e64ae8389..90c8492a67 100644 --- a/modules/publish/views/helpers/BibliographieOverview.php +++ b/modules/publish/views/helpers/BibliographieOverview.php @@ -31,6 +31,7 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; use Opus\Document; class Publish_View_Helper_BibliographieOverview extends \Zend_View_Helper_Abstract @@ -48,7 +49,7 @@ class Publish_View_Helper_BibliographieOverview extends \Zend_View_Helper_Abstra */ public function bibliographieOverview() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); if (! isset($config->form->first->bibliographie) || (! filter_var($config->form->first->bibliographie, FILTER_VALIDATE_BOOLEAN))) { return; diff --git a/modules/publish/views/helpers/FileOverview.php b/modules/publish/views/helpers/FileOverview.php index 95a6cd4c46..b4d20469cc 100644 --- a/modules/publish/views/helpers/FileOverview.php +++ b/modules/publish/views/helpers/FileOverview.php @@ -27,10 +27,11 @@ * @category Application * @package Module_Publish * @author Susanne Gottwald - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; use Opus\Document; class Publish_View_Helper_FileOverview extends \Zend_View_Helper_Abstract @@ -49,7 +50,7 @@ class Publish_View_Helper_FileOverview extends \Zend_View_Helper_Abstract */ public function fileOverview() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); if (! isset($config->form->first->enable_upload) || (! filter_var($config->form->first->enable_upload, FILTER_VALIDATE_BOOLEAN))) { return; diff --git a/modules/review/models/ClearDocumentsHelper.php b/modules/review/models/ClearDocumentsHelper.php index d3c1e79d0d..0053b7539f 100644 --- a/modules/review/models/ClearDocumentsHelper.php +++ b/modules/review/models/ClearDocumentsHelper.php @@ -34,6 +34,7 @@ use Opus\Date; use Opus\Document; +use Opus\Log; use Opus\Person; use Opus\UserRole; @@ -54,7 +55,7 @@ class Review_Model_ClearDocumentsHelper */ public function clear(array $docIds = null, $userId = null, $person = null) { - $logger = \Zend_Registry::get('Zend_Log'); + $logger = Log::get(); foreach ($docIds as $docId) { $logger->debug('Change state to "published" for document: ' . $docId); @@ -98,7 +99,7 @@ public function clear(array $docIds = null, $userId = null, $person = null) */ public function reject(array $docIds = null, $userId = null, $person = null) { - $logger = \Zend_Registry::get('Zend_Log'); + $logger = Log::get(); foreach ($docIds as $docId) { $logger->debug('Deleting document with id: ' . $docId); diff --git a/modules/solrsearch/views/scripts/index/browsecollection.phtml b/modules/solrsearch/views/scripts/index/browsecollection.phtml index 207035e33a..c5cc367473 100644 --- a/modules/solrsearch/views/scripts/index/browsecollection.phtml +++ b/modules/solrsearch/views/scripts/index/browsecollection.phtml @@ -30,6 +30,8 @@ * @copyright Copyright (c) 2008-2010, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Config; ?> parents)) : ?> @@ -69,7 +71,7 @@

title) ?>

disableEmptyCollections = isset($config->browsing->disableEmptyCollections) && filter_var($config->browsing->disableEmptyCollections, FILTER_VALIDATE_BOOLEAN); $collRoleName = htmlspecialchars($this->collectionRole->getName(), ENT_QUOTES); diff --git a/modules/sword/controllers/DepositController.php b/modules/sword/controllers/DepositController.php index 06d3f63ef3..dd921a5ee6 100644 --- a/modules/sword/controllers/DepositController.php +++ b/modules/sword/controllers/DepositController.php @@ -28,13 +28,16 @@ * @package Module_Sword * @author Sascha Szott * @author Jens Schwidder - * @copyright Copyright (c) 2016-2017 + * @copyright Copyright (c) 2016-2021 * @license http://www.gnu.org/licenses/gpl.html General Public License * * TODO use OPUS 4 base class? * TODO too much code in this controller * TODO change AdditionalEnrichments into something like ImportInfo and make it easy to access properties like "user" */ + +use Opus\Log; + class Sword_DepositController extends \Zend_Rest_Controller { @@ -168,7 +171,7 @@ private function maxUploadSizeExceeded($payload) $maxUploadSize = (new Application_Configuration_MaxUploadSize())->getMaxUploadSizeInByte(); if ($size > $maxUploadSize) { - $log = \Zend_Registry::get('Zend_Log'); + $log = Log::get(); $log->warn('current package size ' . $size . ' exceeds the maximum upload size ' . $maxUploadSize); return true; } diff --git a/modules/sword/controllers/ServicedocumentController.php b/modules/sword/controllers/ServicedocumentController.php index 8c878bbccc..9b0708bbe7 100644 --- a/modules/sword/controllers/ServicedocumentController.php +++ b/modules/sword/controllers/ServicedocumentController.php @@ -27,9 +27,12 @@ * @category Application * @package Module_Sword * @author Sascha Szott - * @copyright Copyright (c) 2016 + * @copyright Copyright (c) 2016-2021 * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Config; + class Sword_ServicedocumentController extends \Zend_Rest_Controller { @@ -74,7 +77,7 @@ private function setServiceDocument($response) $serviceDocument = new Sword_Model_ServiceDocument($fullUrl); $domDocument = $serviceDocument->getDocument(); - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $prettyPrinting = isset($config->prettyXml) && filter_var($config->prettyXml, FILTER_VALIDATE_BOOLEAN); if ($prettyPrinting) { $domDocument->preserveWhiteSpace = false; diff --git a/modules/sword/models/AtomEntryDocument.php b/modules/sword/models/AtomEntryDocument.php index ee7d6b8162..254c6fa314 100644 --- a/modules/sword/models/AtomEntryDocument.php +++ b/modules/sword/models/AtomEntryDocument.php @@ -30,6 +30,9 @@ * @copyright Copyright (c) 2016 * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Config; + class Sword_Model_AtomEntryDocument { @@ -55,7 +58,7 @@ public function setResponse($request, $response, $fullUrl, $userName) $this->fullUrl = $fullUrl; if (! empty($this->entries)) { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $prettyPrinting = isset($config->prettyXml) && filter_var($config->prettyXml, FILTER_VALIDATE_BOOLEAN); if ($prettyPrinting) { $dom = new DOMDocument; @@ -121,7 +124,7 @@ private function handleMultipleEntries($userName, $request) private function addSwordElements($rootElement, $request) { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $generator = $config->sword->generator; $rootElement->addChild('generator', $generator); diff --git a/modules/sword/models/ErrorDocument.php b/modules/sword/models/ErrorDocument.php index 51ee27765c..85934349eb 100644 --- a/modules/sword/models/ErrorDocument.php +++ b/modules/sword/models/ErrorDocument.php @@ -27,9 +27,14 @@ * @category Application * @package Module_Sword * @author Sascha Szott + * @author Jens Schwidder * @copyright Copyright (c) 2016 * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Config; +use Opus\Log; + class Sword_Model_ErrorDocument { @@ -43,7 +48,7 @@ public function __construct($request, $response) { $this->request = $request; $this->response = $response; - $this->logger = \Zend_Registry::get('Zend_Log'); + $this->logger = Log::get(); } /** @@ -135,7 +140,7 @@ private function getDocument($errorCond) $root->addAttribute('href', $errorCond); $root->addChild('title', 'ERROR'); - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $generator = $config->sword->generator; $root->addChild('generator', $generator); diff --git a/modules/sword/models/ImportCollection.php b/modules/sword/models/ImportCollection.php index a7693e903b..b2124927ea 100644 --- a/modules/sword/models/ImportCollection.php +++ b/modules/sword/models/ImportCollection.php @@ -33,6 +33,8 @@ use Opus\Collection; use Opus\CollectionRole; +use Opus\Config; +use Opus\Log; class Sword_Model_ImportCollection { @@ -43,8 +45,8 @@ class Sword_Model_ImportCollection public function __construct() { - $logger = \Zend_Registry::get('Zend_Log'); - $config = \Zend_Registry::get('Zend_Config'); + $logger = Log::get(); + $config = Config::get(); $collectionNumber = $config->sword->collection->default->number; if (trim($collectionNumber) == '') { diff --git a/modules/sword/models/ServiceDocument.php b/modules/sword/models/ServiceDocument.php index 90796e7b08..44c904f8a7 100644 --- a/modules/sword/models/ServiceDocument.php +++ b/modules/sword/models/ServiceDocument.php @@ -30,6 +30,9 @@ * @copyright Copyright (c) 2016 * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Config; + class Sword_Model_ServiceDocument { @@ -49,7 +52,7 @@ class Sword_Model_ServiceDocument public function __construct($fullUrl) { - $this->config = \Zend_Registry::get('Zend_Config'); + $this->config = Config::get(); $this->fullUrl = $fullUrl; $this->initServiceDocument(); } diff --git a/public/layouts/default/common.phtml b/public/layouts/default/common.phtml index e9eef093e4..45fdc9815f 100755 --- a/public/layouts/default/common.phtml +++ b/public/layouts/default/common.phtml @@ -33,7 +33,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -$config = \Zend_Registry::get('Zend_Config'); +use Opus\Config; + +$config = Config::get(); $pageLanguage = \Zend_Registry::get('Zend_Translate')->getLocale(); diff --git a/public/layouts/opus4/common.phtml b/public/layouts/opus4/common.phtml index 0c8939a5f0..7b68e607f5 100644 --- a/public/layouts/opus4/common.phtml +++ b/public/layouts/opus4/common.phtml @@ -33,7 +33,9 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ -$config = \Zend_Registry::get('Zend_Config'); +use Opus\Config; + +$config = Config::get(); $pageLanguage = \Zend_Registry::get('Zend_Translate')->getLocale(); diff --git a/public/layouts/opus4/debug.phtml b/public/layouts/opus4/debug.phtml index 54e881adf1..7eb6622d63 100644 --- a/public/layouts/opus4/debug.phtml +++ b/public/layouts/opus4/debug.phtml @@ -1,5 +1,5 @@ getProfiler(); +$dbprofiler = \Zend_Db_Table::getDefaultAdapter()->getProfiler(); $profiler_show_queries = isset($config->db->params->showqueries) && filter_var($config->db->params->showqueries, FILTER_VALIDATE_BOOLEAN); $profiler_max_queries = (int) $config->db->params->maxqueries; if ($dbprofiler->getEnabled() === true) : ?> diff --git a/scripts/common/console.php b/scripts/common/console.php index d6c3c4e925..9773785686 100644 --- a/scripts/common/console.php +++ b/scripts/common/console.php @@ -1,5 +1,4 @@ * @author Thoralf Klein * @author Felix Ostrowski - * @copyright Copyright (c) 2009-2010, OPUS 4 development team + * @copyright Copyright (c) 2009-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ // TODO integrate as command in opus4 tool // TODO add exit command -$config = \Zend_Registry::get('Zend_Config'); +use Opus\Config; + +$config = Config::get(); if (isset($config->security) && filter_var($config->security, FILTER_VALIDATE_BOOLEAN)) { // setup realm $realm = \Opus\Security\Realm::getInstance(); diff --git a/scripts/cron/cron-check-consistency.php b/scripts/cron/cron-check-consistency.php index 4818294984..b54918022d 100644 --- a/scripts/cron/cron-check-consistency.php +++ b/scripts/cron/cron-check-consistency.php @@ -35,10 +35,11 @@ require_once dirname(__FILE__) . '/../common/bootstrap.php'; use Opus\Job\Runner; +use Opus\Log; use Opus\Search\Task\ConsistencyCheck; $jobrunner = new Runner; -$jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); +$jobrunner->setLogger(Log::get()); // no waiting between jobs $jobrunner->setDelay(0); // set a limit of 100 index jobs per run diff --git a/scripts/cron/cron-import-metadata.php b/scripts/cron/cron-import-metadata.php index 3274a0a9ce..a8a7a64cb9 100644 --- a/scripts/cron/cron-import-metadata.php +++ b/scripts/cron/cron-import-metadata.php @@ -36,16 +36,17 @@ use Opus\Job\Runner; use Opus\Job\Worker\MetadataImport; +use Opus\Log; $jobrunner = new Runner; -$jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); +$jobrunner->setLogger(Log::get()); // no waiting between jobs $jobrunner->setDelay(0); // set a limit of 100 index jobs per run $jobrunner->setLimit(100); $importWorker = new MetadataImport(null); -$importWorker->setLogger(\Zend_Registry::get('Zend_Log')); +$importWorker->setLogger(Log::get()); $jobrunner->registerWorker($importWorker); diff --git a/scripts/cron/cron-send-notification.php b/scripts/cron/cron-send-notification.php index df760e9e99..3f5b92c52a 100644 --- a/scripts/cron/cron-send-notification.php +++ b/scripts/cron/cron-send-notification.php @@ -41,16 +41,17 @@ use Opus\Job\Runner; use Opus\Job\Worker\MailNotification; +use Opus\Log; $jobrunner = new Runner; -$jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); +$jobrunner->setLogger(Log::get()); // no waiting between jobs $jobrunner->setDelay(0); // set a limit of 100 index jobs per run $jobrunner->setLimit(100); $mailWorker = new MailNotification(null, false); -$mailWorker->setLogger(\Zend_Registry::get('Zend_Log')); +$mailWorker->setLogger(Log::get()); $jobrunner->registerWorker($mailWorker); diff --git a/scripts/cron/cron-send-review-request.php b/scripts/cron/cron-send-review-request.php index 3af67b046c..1452583412 100644 --- a/scripts/cron/cron-send-review-request.php +++ b/scripts/cron/cron-send-review-request.php @@ -47,16 +47,17 @@ use Opus\Job\Runner; use Opus\Job\Worker\MailNotification; +use Opus\Log; $jobrunner = new Runner; -$jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); +$jobrunner->setLogger(Log::get()); // no waiting between jobs $jobrunner->setDelay(0); // set a limit of 100 index jobs per run $jobrunner->setLimit(100); $mailWorker = new MailNotification(); -$mailWorker->setLogger(\Zend_Registry::get('Zend_Log')); +$mailWorker->setLogger(Log::get()); $jobrunner->registerWorker($mailWorker); diff --git a/scripts/cron/cron-solr-update.php b/scripts/cron/cron-solr-update.php index 0ae224d9d6..304355d465 100644 --- a/scripts/cron/cron-solr-update.php +++ b/scripts/cron/cron-solr-update.php @@ -39,9 +39,10 @@ use Opus\Job\Runner; use Opus\Search\Task\IndexOpusDocument; +use Opus\Log; $jobrunner = new Runner(); -$jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); +$jobrunner->setLogger(Log::get()); // no waiting between jobs $jobrunner->setDelay(0); diff --git a/scripts/cron/cron-update-document-cache.php b/scripts/cron/cron-update-document-cache.php index 4bda85aaf0..102b26c005 100644 --- a/scripts/cron/cron-update-document-cache.php +++ b/scripts/cron/cron-update-document-cache.php @@ -1,5 +1,4 @@ select(); $select->from($opusDocCacheTable->info('name'), 'document_id'); diff --git a/scripts/cron/cron-workspace-files-check.php b/scripts/cron/cron-workspace-files-check.php index ced8be3851..ae9e86c885 100644 --- a/scripts/cron/cron-workspace-files-check.php +++ b/scripts/cron/cron-workspace-files-check.php @@ -1,5 +1,4 @@ - * @copyright Copyright (c) 2011, OPUS 4 development team + * @copyright Copyright (c) 2011-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ // Bootstrapping require_once dirname(__FILE__) . '/../common/bootstrap.php'; +use Opus\Config; use Opus\Document; use Opus\Model\NotFoundException; // Get files directory... $startTime = microtime(true); -$config = \Zend_Registry::get('Zend_Config'); +$config = Config::get(); $filesPath = realpath($config->workspacePath . DIRECTORY_SEPARATOR . "files"); if ($filesPath == false or empty($filesPath)) { diff --git a/scripts/opus-create-export-xml.php b/scripts/opus-create-export-xml.php index 107e14716e..349c91ca31 100644 --- a/scripts/opus-create-export-xml.php +++ b/scripts/opus-create-export-xml.php @@ -27,10 +27,11 @@ * @category Application * @author Gunar Maiwald * @author Jens Schwidder - * @copyright Copyright (c) 2011-2016, OPUS 4 development team + * @copyright Copyright (c) 2011-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; use Opus\Document; use Opus\DocumentFinder; use Opus\Model\NotFoundException; @@ -47,7 +48,7 @@ require_once dirname(__FILE__) . '/common/bootstrap.php'; -$config = \Zend_Registry::get('Zend_Config'); +$config = Config::get(); // process options $options = getopt('o:'); diff --git a/scripts/snippets/change-doi-landing-page-url.php b/scripts/snippets/change-doi-landing-page-url.php index aad2968515..67e7c68d80 100644 --- a/scripts/snippets/change-doi-landing-page-url.php +++ b/scripts/snippets/change-doi-landing-page-url.php @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; + if (basename(__FILE__) !== basename($argv[0])) { echo "script must be executed directy (not via opus-console)\n"; exit; @@ -50,7 +52,7 @@ echo 'Change URL of landing page of DOI ' . $doiValue . ' to ' . $landingPageURL . "\n"; -$config = \Zend_Registry::get('Zend_Config'); +$config = Config::get(); try { $doiManager = new DoiManager(); $doiManager->updateLandingPageUrlOfDoi($doiValue, $landingPageURL); diff --git a/tests/import-testdata.php b/tests/import-testdata.php index 5718785e50..7817e4fb64 100644 --- a/tests/import-testdata.php +++ b/tests/import-testdata.php @@ -74,7 +74,7 @@ // Bootstrapping application $application->bootstrap('Backend'); -$config = \Zend_Registry::get('Zend_Config'); +$config = \Opus\Config::get(); $config = $config->merge(new \Zend_Config_Ini(dirname(__FILE__) . '/config.ini')); $database = new \Opus\Database(); diff --git a/tests/library/Application/Configuration/MaxUploadSizeTest.php b/tests/library/Application/Configuration/MaxUploadSizeTest.php index 0d09b6ffc4..b027e00315 100644 --- a/tests/library/Application/Configuration/MaxUploadSizeTest.php +++ b/tests/library/Application/Configuration/MaxUploadSizeTest.php @@ -46,7 +46,7 @@ class Application_Configuration_MaxUploadSizeTest extends TestCase */ public function testMaxUploadSize() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $configMaxFileSize = intval($config->publish->maxfilesize); $postMaxSize = $this->convertToKByte(ini_get('post_max_size')); diff --git a/tests/library/Application/ConfigurationTest.php b/tests/library/Application/ConfigurationTest.php index 043b813193..e5fd9ac175 100644 --- a/tests/library/Application/ConfigurationTest.php +++ b/tests/library/Application/ConfigurationTest.php @@ -28,10 +28,11 @@ * @package Application * @author Jens Schwidder * @author Michael Lang config->getConfig(); $this->assertNotNull($zendConfig); - $this->assertInstanceOf('Zend_Config', $zendConfig); + $this->assertInstanceOf(\Zend_Config::class, $zendConfig); } public function testGetLogger() @@ -63,7 +64,7 @@ public function testGetLogger() $logger = $this->config->getLogger(); $this->assertNotNull($logger); - $this->assertInstanceOf('Zend_Log', $logger); + $this->assertInstanceOf(\Zend_Log::class, $logger); } public function testSetLogger() @@ -103,7 +104,7 @@ public function testIsLanguageSupportedFalseEmpty() public function testGetOpusVersion() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $this->assertEquals($config->version, Application_Configuration::getOpusVersion()); } @@ -125,7 +126,7 @@ public function testIsLanguageSelectionEnabledTrue() public function testIsLanguageSelectionEnabledFalse() { - \Zend_Registry::get('Zend_Config')->supportedLanguages = 'de'; + Config::get()->supportedLanguages = 'de'; $this->assertEquals(['de'], $this->config->getSupportedLanguages()); $this->assertFalse($this->config->isLanguageSelectionEnabled()); } @@ -137,7 +138,7 @@ public function testGetDefaultLanguage() public function testGetDefaultLanguageIfOnlyOneIsSupported() { - \Zend_Registry::get('Zend_Config')->supportedLanguages = 'de'; + $this->getConfig()->supportedLanguages = 'de'; $this->assertEquals('de', $this->config->getDefaultLanguage()); } @@ -167,9 +168,9 @@ public function testGetWorkspacePath() */ public function testGetWorkspacePathSetWithSlash() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'workspacePath' => APPLICATION_PATH . '/tests/workspace/' - ])); + ]); $workspacePath = $this->config->getWorkspacePath(); @@ -212,10 +213,10 @@ public function testGetName() $config = Application_Configuration::getInstance(); $this->assertEquals('OPUS 4', $config->getName()); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config(['name' => 'OPUS Test'])); + $this->adjustConfiguration(['name' => 'OPUS Test']); $this->assertEquals('OPUS Test', $config->getName()); - $zendConfig = \Zend_Registry::get('Zend_Config'); + $zendConfig = $this->getConfig(); unset($zendConfig->name); $this->assertEquals('OPUS 4', $config->getName()); } @@ -255,7 +256,7 @@ public function testGetValueForArray() $subconfig = $config->getValue('orcid'); - $this->assertInstanceOf('Zend_Config', $subconfig); + $this->assertInstanceOf(\Zend_Config::class, $subconfig); } public function testGetValueForNull() diff --git a/tests/library/Application/Controller/Action/Helper/AbstractTest.php b/tests/library/Application/Controller/Action/Helper/AbstractTest.php index 15d88bea34..ac1fb1b9cb 100644 --- a/tests/library/Application/Controller/Action/Helper/AbstractTest.php +++ b/tests/library/Application/Controller/Action/Helper/AbstractTest.php @@ -27,9 +27,12 @@ * @category Application Unit Test * @package Application_Controller_Action_Helper * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Log; + class Application_Controller_Action_HelperAbstractTest extends TestCase { @@ -49,7 +52,7 @@ public function testGetLogger() $logger = $helper->getLogger(); - $this->assertInstanceOf('Zend_Log', $logger); - $this->assertEquals(\Zend_Registry::get('Zend_Log'), $logger); + $this->assertInstanceOf(\Zend_Log::class, $logger); + $this->assertEquals( Log::get(), $logger); } } diff --git a/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php b/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php index f83fdd518c..792e26a7e1 100644 --- a/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php +++ b/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php @@ -183,7 +183,7 @@ public function testGetDocumentThrowsSchemaInvalidException() */ public function testGetAllDocumentTypes() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); unset($config->documentTypes); $documentTypes = $this->docTypeHelper->getDocumentTypes(); @@ -223,7 +223,7 @@ public function testGetTemplateForInvalidDocumentType() */ public function testGetDocumentTypesWithPathNotSet() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); unset($config->publish->path->documenttypes); @@ -282,7 +282,7 @@ public function testValidateAllXMLDocumentTypeDefinitions() */ public function testDocumentTypesAndTemplates() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $templates = $this->getFileNames($config->publish->path->documenttemplates, '.phtml'); $types = $this->getFileNames($config->publish->path->documenttypes, '.xml'); @@ -331,13 +331,13 @@ public function testGetDocTypesPathAsArray() public function testGetDocTypesPath() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'publish' => [ 'path' => [ 'documenttypes' => APPLICATION_PATH . '/application/configs/doctypes' ] ] - ])); + ]); $paths = $this->docTypeHelper->getDocTypesPath(); @@ -361,7 +361,7 @@ public function testGetTemplates() public function testTemplateForEveryDocumentType() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); unset($config->documentTypes); $docTypes = $this->docTypeHelper->getAllDocumentTypes(); diff --git a/tests/library/Application/Controller/Action/Helper/FileTypesTest.php b/tests/library/Application/Controller/Action/Helper/FileTypesTest.php index b749b2d8e1..aa8ee90d88 100644 --- a/tests/library/Application/Controller/Action/Helper/FileTypesTest.php +++ b/tests/library/Application/Controller/Action/Helper/FileTypesTest.php @@ -62,11 +62,11 @@ public function testGetValidMimeTypes() public function testMimeTypeAddedToBaseConfigurationFromApplicationIni() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'filetypes' => ['xml' => ['mimeType' => [ 'text/xml', 'application/xml' ]]] - ])); + ]); $types = $this->_helper->getValidMimeTypes(); @@ -98,11 +98,11 @@ public function testIsValidMimeType() public function testIsValidMimeTypeForExtensionWithMultipleTypes() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'filetypes' => ['xml' => ['mimeType' => [ 'text/xml', 'application/xml' ]]] - ])); + ]); $this->assertTrue($this->_helper->isValidMimeType('application/xml')); $this->assertTrue($this->_helper->isValidMimeType('text/xml')); @@ -110,11 +110,11 @@ public function testIsValidMimeTypeForExtensionWithMultipleTypes() public function testIsValidMimeTypeForExtension() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'filetypes' => ['xml' => ['mimeType' => [ 'text/xml', 'application/xml' ]]] - ])); + ]); $this->assertTrue($this->_helper->isValidMimeType('application/xml', 'xml')); $this->assertTrue($this->_helper->isValidMimeType('text/xml', 'xml')); @@ -135,9 +135,9 @@ public function testIsValidMimeTypeForNull() public function testExtensionCaseInsensitive() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'filetypes' => ['XML' => ['mimeType' => 'text/xml']] - ])); + ]); $this->assertTrue($this->_helper->isValidMimeType('text/xml', 'xml')); $this->assertTrue($this->_helper->isValidMimeType('text/xml', 'XML')); diff --git a/tests/library/Application/Controller/Action/Helper/ResultScriptTest.php b/tests/library/Application/Controller/Action/Helper/ResultScriptTest.php index 80bbd725f8..f952689747 100644 --- a/tests/library/Application/Controller/Action/Helper/ResultScriptTest.php +++ b/tests/library/Application/Controller/Action/Helper/ResultScriptTest.php @@ -52,9 +52,9 @@ public function testDefaultScript() public function testCustomScriptDoesNotExist() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'search' => ['result' => ['script' => 'result.phtml']] - ])); + ]); $script = $this->helper->direct(); @@ -63,9 +63,9 @@ public function testCustomScriptDoesNotExist() public function testCustomScriptExists() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'search' => ['result' => ['script' => 'result.phtml']] - ])); + ]); touch(APPLICATION_PATH . '/application/configs/templates/result.phtml'); diff --git a/tests/library/Application/Export/ExportPluginAbstractTest.php b/tests/library/Application/Export/ExportPluginAbstractTest.php index 94a20a0acb..62ee508fd2 100644 --- a/tests/library/Application/Export/ExportPluginAbstractTest.php +++ b/tests/library/Application/Export/ExportPluginAbstractTest.php @@ -83,9 +83,6 @@ public function disabledOptions() private function setAdminOnly($optionValue) { - \Zend_Registry::set( - 'Zend_Config', - new \Zend_Config(['adminOnly' => $optionValue]) - ); + $this->adjustConfiguration(['adminOnly' => $optionValue]); } } diff --git a/tests/library/Application/Export/ExportServiceTest.php b/tests/library/Application/Export/ExportServiceTest.php index c4a994211a..6a3f08b2c5 100644 --- a/tests/library/Application/Export/ExportServiceTest.php +++ b/tests/library/Application/Export/ExportServiceTest.php @@ -60,7 +60,7 @@ public function testLoadPlugins() $this->assertArrayHasKey('publist', $plugins); $this->assertArrayHasKey('datacite', $plugins); - $this->assertInstanceOf('Zend_Config', $plugins['index']); + $this->assertInstanceOf(\Zend_Config::class, $plugins['index']); $bibtexConfig = $plugins['bibtex']; @@ -84,7 +84,7 @@ public function testGetPlugin() $pluginConfig = $plugin->getConfig(); $this->assertNotNull($pluginConfig); - $this->assertInstanceOf('Zend_Config', $pluginConfig); + $this->assertInstanceOf(\Zend_Config::class, $pluginConfig); $this->assertEquals(100, $pluginConfig->maxDocumentsGuest); } @@ -94,7 +94,7 @@ public function testGetDefaults() $defaults = $this->_service->getDefaults(); $this->assertNotNull($defaults); - $this->assertInstanceOf('Zend_Config', $defaults); + $this->assertInstanceOf(\Zend_Config::class, $defaults); $this->assertEquals('Export_Model_XmlExport', $defaults->class); } diff --git a/tests/library/Application/Form/AbstractTest.php b/tests/library/Application/Form/AbstractTest.php index b0c9277d9e..336d9c9541 100644 --- a/tests/library/Application/Form/AbstractTest.php +++ b/tests/library/Application/Form/AbstractTest.php @@ -31,7 +31,7 @@ * @category Application Unit Test * @package Application_Form * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ class Application_Form_AbstractTest extends ControllerTestCase @@ -76,7 +76,7 @@ public function testSetLogger() public function testGetLogger() { $this->assertNotNull($this->form->getLogger()); - $this->assertInstanceOf('Zend_Log', $this->form->getLogger()); + $this->assertInstanceOf(\Zend_Log::class, $this->form->getLogger()); } public function testGetElementValue() @@ -250,8 +250,8 @@ public function testGetApplicationConfig() $config = $this->form->getApplicationConfig(); $this->assertNotNull($config); - $this->assertInstanceOf('Zend_Config', $config); - $this->assertSame($config, \Zend_Registry::get('Zend_Config')); + $this->assertInstanceOf(\Zend_Config::class, $config); + $this->assertSame($config, $this->getConfig()); } public function testSetApplicationConfig() @@ -268,6 +268,6 @@ public function testSetApplicationConfig() $returnedConfig = $this->form->getApplicationConfig(); - $this->assertSame(\Zend_Registry::get('Zend_Config'), $returnedConfig); + $this->assertSame( $this->getConfig(), $returnedConfig); } } diff --git a/tests/library/Application/Form/Decorator/FileHashTest.php b/tests/library/Application/Form/Decorator/FileHashTest.php index 9e3f080936..3fda2cde5b 100644 --- a/tests/library/Application/Form/Decorator/FileHashTest.php +++ b/tests/library/Application/Form/Decorator/FileHashTest.php @@ -142,7 +142,7 @@ public function testRenderWithMissingFile() public function testRenderWithFileTooBig() { $this->useEnglish(); - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->merge(new \Zend_Config(['checksum' => ['maxVerificationSize' => '0']])); $element = new Application_Form_Element_FileHash('name'); diff --git a/tests/library/Application/Form/Element/HitsPerPageTest.php b/tests/library/Application/Form/Element/HitsPerPageTest.php index 9099810711..519862c920 100644 --- a/tests/library/Application/Form/Element/HitsPerPageTest.php +++ b/tests/library/Application/Form/Element/HitsPerPageTest.php @@ -60,9 +60,9 @@ public function testInit() public function testInitWithCustomDefaultRows() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'searchengine' => ['solr' => ['numberOfDefaultSearchResults' => '15']] - ])); + ]); $element = new Application_Form_Element_HitsPerPage('rows'); diff --git a/tests/library/Application/Form/Element/TranslationModulesTest.php b/tests/library/Application/Form/Element/TranslationModulesTest.php index 2e20cd4404..4c7a98ac7a 100644 --- a/tests/library/Application/Form/Element/TranslationModulesTest.php +++ b/tests/library/Application/Form/Element/TranslationModulesTest.php @@ -40,9 +40,9 @@ class Application_Form_Element_TranslationModulesTest extends ControllerTestCase public function testInit() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish']]] - ])); + ]); $element = new Application_Form_Element_TranslationModules('modules'); @@ -53,9 +53,9 @@ public function testInit() public function testInitAllModules() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => null]]] - ])); + ]); $element = new Application_Form_Element_TranslationModules('modules'); diff --git a/tests/library/Application/Form/Validate/IdentifierTest.php b/tests/library/Application/Form/Validate/IdentifierTest.php index 5086c28315..7395f95328 100644 --- a/tests/library/Application/Form/Validate/IdentifierTest.php +++ b/tests/library/Application/Form/Validate/IdentifierTest.php @@ -58,9 +58,7 @@ public function setUp() { parent::setUp(); - $this->makeConfigurationModifiable(); - - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'identifier' => ['validation' => [ 'isbn' => [ 'class' => 'Opus\Validate\Isbn' @@ -69,7 +67,7 @@ public function setUp() 'class' => 'Opus\Validate\Issn' ] ]] - ])); + ]); $this->_element = new Application_Form_Element_Identifier('Element'); $this->_element->setValue('ISBN'); diff --git a/tests/library/Application/Import/TarPackageReaderTest.php b/tests/library/Application/Import/TarPackageReaderTest.php index bc823eae61..5941cc9137 100644 --- a/tests/library/Application/Import/TarPackageReaderTest.php +++ b/tests/library/Application/Import/TarPackageReaderTest.php @@ -44,11 +44,11 @@ public function setUp() public function testReadPackageWithXmlFile() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'filetypes' => ['xml' => ['mimeType' => [ 'text/xml', 'application/xml' ]]] - ])); + ]); $reader = new Application_Import_TarPackageReader(); diff --git a/tests/library/Application/Import/ZipPackageReaderTest.php b/tests/library/Application/Import/ZipPackageReaderTest.php index 55e15742df..3937766b95 100644 --- a/tests/library/Application/Import/ZipPackageReaderTest.php +++ b/tests/library/Application/Import/ZipPackageReaderTest.php @@ -44,11 +44,11 @@ public function setUp() public function testReadPackageWithXmlFile() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'filetypes' => ['xml' => ['mimeType' => [ 'text/xml', 'application/xml' ]]] - ])); + ]); $reader = new Application_Import_ZipPackageReader(); diff --git a/tests/library/Application/Model/AbstractTest.php b/tests/library/Application/Model/AbstractTest.php index 784a53dfd3..ce99ef1267 100644 --- a/tests/library/Application/Model/AbstractTest.php +++ b/tests/library/Application/Model/AbstractTest.php @@ -25,6 +25,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +use Opus\Config; + /** * Unit Tests fuer abstrakte Basisklasse fuer Modelle. * @@ -55,7 +57,7 @@ public function testGetLogger() $logger = $this->_model->getLogger(); $this->assertNotNull($logger); - $this->assertInstanceOf('Zend_Log', $logger); + $this->assertInstanceOf(\Zend_Log::class, $logger); } public function testSetLogger() @@ -72,8 +74,8 @@ public function testGetConfig() { $config = $this->_model->getConfig(); - $this->assertInstanceOf('Zend_Config', $config); - $this->assertEquals(\Zend_Registry::get('Zend_Config'), $config); + $this->assertInstanceOf(\Zend_Config::class, $config); + $this->assertEquals(Config::get(), $config); } public function testSetConfig() @@ -84,7 +86,7 @@ public function testSetConfig() $returnedConfig = $this->_model->getConfig(); - $this->assertInstanceOf('Zend_Config', $returnedConfig); + $this->assertInstanceOf(\Zend_Config::class, $returnedConfig); $this->assertEquals($config, $returnedConfig); } } diff --git a/tests/library/Application/Search/FacetManagerTest.php b/tests/library/Application/Search/FacetManagerTest.php index 9fae09b48f..8b38713bda 100644 --- a/tests/library/Application/Search/FacetManagerTest.php +++ b/tests/library/Application/Search/FacetManagerTest.php @@ -98,9 +98,9 @@ public function testGetActiveFacets() public function testGetFacetEnrichment() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'searchengine' => ['solr' => ['facets' => 'enrichment_Audience']] - ])); + ]); $manager = new Application_Search_FacetManager(); @@ -113,9 +113,9 @@ public function testGetFacetEnrichment() public function testGetFacetEnrichmentTranslated() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'searchengine' => ['solr' => ['facets' => 'enrichment_Audience']] - ])); + ]); $manager = new Application_Search_FacetManager(); @@ -143,9 +143,9 @@ public function testGetFacetEnrichmentBoolean() public function testGetFacetConfigForFacetteWithDotInName() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'search' => ['facet' => ['enrichment_opus-source' => ['heading' => 'EnrichmentOpusSource']]] - ])); + ]); $manager = new Application_Search_FacetManager(); @@ -165,9 +165,9 @@ public function testFacetLimit() public function testFacetSortCrit() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'search' => ['facet' => ['subject' => ['sort' => 'lexi']]] - ])); + ]); $manager = new Application_Search_FacetManager(); diff --git a/tests/library/Application/Translate/TranslationManagerTest.php b/tests/library/Application/Translate/TranslationManagerTest.php index b57eff07f6..abb86e3c3e 100644 --- a/tests/library/Application/Translate/TranslationManagerTest.php +++ b/tests/library/Application/Translate/TranslationManagerTest.php @@ -67,9 +67,9 @@ public function tearDown() public function testGetFiles() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish']]] - ])); + ]); $files = $this->object->getFiles(); @@ -173,9 +173,9 @@ public function testGetDuplicateKeys() { $manager = $this->object; - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => null]]] - ])); + ]); $duplicateKeys = $manager->getDuplicateKeys(); @@ -201,9 +201,9 @@ public function testKeyMaxLength() { $translations = $this->object; - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => null]]] - ])); + ]); $translations->setModules(null); @@ -745,9 +745,9 @@ public function testGetModules() { $manager = $this->object; - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish']]] - ])); + ]); $modules = $manager->getModules(); @@ -759,9 +759,9 @@ public function testGetModules() public function testGetModulesNoRestrictions() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => null]]] - ])); + ]); $manager = $this->object; @@ -776,9 +776,9 @@ public function testGetModulesRestrictionForUnknownModules() { $manager = $this->object; - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish,unknown1']]] - ])); + ]); $modules = $manager->getModules(); @@ -792,9 +792,9 @@ public function testGetAllowedModules() { $manager = $this->object; - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,home,publish']]] - ])); + ]); $modules = $manager->getAllowedModules(); @@ -809,9 +809,9 @@ public function testGetAllowedModulesHandlingSpaces() { $manager = $this->object; - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default, home , publish ']]] - ])); + ]); $modules = $manager->getAllowedModules(); @@ -826,9 +826,9 @@ public function testGetAllowedModulesUnknownModule() { $manager = $this->object; - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,unknown1']]] - ])); + ]); $logger = new MockLogger(); @@ -1246,9 +1246,9 @@ public function testSetLanguageOrder() public function testSortLanguages() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'supportedLanguages' => 'de,en,fr' - ])); + ]); $manager = $this->object; diff --git a/tests/library/Application/TranslateTest.php b/tests/library/Application/TranslateTest.php index f77f4b6809..1855eb4028 100644 --- a/tests/library/Application/TranslateTest.php +++ b/tests/library/Application/TranslateTest.php @@ -87,7 +87,7 @@ public function testGetLogger() $logger = $this->translate->getLogger(); $this->assertNotNull($logger); - $this->assertInstanceOf('Zend_Log', $logger); + $this->assertInstanceOf(\Zend_Log::class, $logger); } public function testSetLogger() @@ -132,21 +132,21 @@ public function testLoadLanguageDirectoryNoFiles() */ public function testIsLogUntranslatedEnabledTrue() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->log->untranslated = self::CONFIG_VALUE_TRUE; $this->assertTrue($this->translate->isLogUntranslatedEnabled()); } public function testIsLogUntranslatedEnabledFalse() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->log->untranslated = self::CONFIG_VALUE_FALSE; $this->assertFalse($this->translate->isLogUntranslatedEnabled()); } public function testGetOptionsLogEnabled() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->log->untranslated = self::CONFIG_VALUE_TRUE; $options = $this->translate->getOptions(); @@ -154,13 +154,13 @@ public function testGetOptionsLogEnabled() $this->assertInternalType('array', $options); $this->assertEquals(10, count($options)); $this->assertArrayHasKey('log', $options); - $this->assertInstanceOf('Zend_Log', $options['log']); + $this->assertInstanceOf(\Zend_Log::class, $options['log']); $this->assertTrue($options['logUntranslated']); } public function testGetOptionsLogDisabled() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->log->untranslated = self::CONFIG_VALUE_FALSE; $options = $this->translate->getOptions(); @@ -172,7 +172,7 @@ public function testGetOptionsLogDisabled() public function testLoggingEnabled() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->log->untranslated = self::CONFIG_VALUE_TRUE; $logger = new MockLogger(); @@ -205,7 +205,7 @@ public function testLoggingEnabled() public function testLoggingDisabled() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->log->untranslated = self::CONFIG_VALUE_FALSE; $logger = new MockLogger(); @@ -275,6 +275,7 @@ public function testMixedTranslations() $database->removeAll(); $translate = \Zend_Registry::get('Zend_Translate'); + $translate->clearCache(); $translate->loadTranslations(); diff --git a/tests/library/Application/Util/NotificationTest.php b/tests/library/Application/Util/NotificationTest.php index e274178dcd..2c546c8b71 100644 --- a/tests/library/Application/Util/NotificationTest.php +++ b/tests/library/Application/Util/NotificationTest.php @@ -28,11 +28,12 @@ * @package Tests * @author Sascha Szott * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\Job; +use Opus\Log; use Opus\Person; use Opus\Title; use Opus\Job\Worker\MailNotification; @@ -53,9 +54,9 @@ public function setUp() { parent::setUp(); $this->notification = new Application_Util_Notification(); - $this->logger = \Zend_Registry::get('Zend_Log'); + $this->logger = Log::get(); // add required config keys - $this->config = \Zend_Registry::get('Zend_Config'); + $this->config = $this->getConfig(); $this->config->notification->document->submitted->enabled = self::CONFIG_VALUE_TRUE; $this->config->notification->document->published->enabled = self::CONFIG_VALUE_TRUE; $this->config->notification->document->submitted->subject = 'Dokument #%1$s eingestellt: %2$s : %3$s'; diff --git a/tests/library/Application/Util/PublicationNotificationTest.php b/tests/library/Application/Util/PublicationNotificationTest.php index a38be4216a..e40f458a80 100644 --- a/tests/library/Application/Util/PublicationNotificationTest.php +++ b/tests/library/Application/Util/PublicationNotificationTest.php @@ -27,10 +27,12 @@ * @category Application * @package Tests * @author Jens Schwidder - * @copyright Copyright (c) 2018-2019, OPUS 4 development team + * @copyright Copyright (c) 2018-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; +use Opus\Log; use Opus\Person; use Opus\Title; @@ -51,9 +53,9 @@ public function setUp() { parent::setUp(); $this->notification = new Application_Util_PublicationNotification(); - $this->logger = \Zend_Registry::get('Zend_Log'); + $this->logger = Log::get(); // add required config keys - $this->config = \Zend_Registry::get('Zend_Config'); + $this->config = Config::get(); $this->config->notification->document->submitted->enabled = self::CONFIG_VALUE_TRUE; $this->config->notification->document->published->enabled = self::CONFIG_VALUE_TRUE; $this->config->notification->document->submitted->subject = 'Dokument #%1$s eingestellt: %2$s : %3$s'; diff --git a/tests/library/Application/View/Helper/CustomFileSortingEnabledTest.php b/tests/library/Application/View/Helper/CustomFileSortingEnabledTest.php index e7ea82a5c8..6352438292 100644 --- a/tests/library/Application/View/Helper/CustomFileSortingEnabledTest.php +++ b/tests/library/Application/View/Helper/CustomFileSortingEnabledTest.php @@ -41,9 +41,9 @@ public function testCustomFileSortingEnabled() $this->assertTrue($helper->customFileSortingEnabled()); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'frontdoor' => ['files' => ['customSorting' => self::CONFIG_VALUE_FALSE]] - ])); + ]); $this->assertFalse($helper->customFileSortingEnabled()); } diff --git a/tests/library/Application/View/Helper/DocumentTitleTest.php b/tests/library/Application/View/Helper/DocumentTitleTest.php index ba9683cdf8..5baf2692cf 100644 --- a/tests/library/Application/View/Helper/DocumentTitleTest.php +++ b/tests/library/Application/View/Helper/DocumentTitleTest.php @@ -104,11 +104,11 @@ public function testDocumentNoLanguage() public function testDocumentTitleUserInterfaceLanguage() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( + $this->adjustConfiguration( ['search' => ['result' => ['display' => [ 'preferUserInterfaceLanguage' => self::CONFIG_VALUE_TRUE ]]]] - )); + ); $this->assertTrue($this->_helper->isPreferUserInterfaceLanguage()); diff --git a/tests/library/Application/View/Helper/FaqEditLinkTest.php b/tests/library/Application/View/Helper/FaqEditLinkTest.php index 7dd16018b3..bb7517b9e5 100644 --- a/tests/library/Application/View/Helper/FaqEditLinkTest.php +++ b/tests/library/Application/View/Helper/FaqEditLinkTest.php @@ -51,9 +51,9 @@ public function testRenderFaqEditLink() public function testRenderOnlyIfSetupAccess() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish,help']]] - ])); + ]); $helper = $this->getHelper(); @@ -76,9 +76,9 @@ public function testRenderOnlyIfSetupAccess() public function testRenderOnlyIfKeyEditable() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default']]] - ])); + ]); $helper = $this->getHelper(); @@ -86,9 +86,9 @@ public function testRenderOnlyIfKeyEditable() $this->assertEquals('', $html); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish,help']]] - ])); + ]); // TODO enable editing of help module diff --git a/tests/library/Application/View/Helper/IsDisplayFieldTest.php b/tests/library/Application/View/Helper/IsDisplayFieldTest.php index 693079f456..247c77a023 100644 --- a/tests/library/Application/View/Helper/IsDisplayFieldTest.php +++ b/tests/library/Application/View/Helper/IsDisplayFieldTest.php @@ -42,9 +42,9 @@ public function testIsDisplayField() $this->assertFalse($helper->isDisplayField('BelongsToBibliography')); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'frontdoor' => ['metadata' => ['BelongsToBibliography' => self::CONFIG_VALUE_TRUE]] - ])); + ]); $this->assertTrue($helper->isDisplayField('BelongsToBibliography')); } diff --git a/tests/library/Application/View/Helper/LanguageSelectorTest.php b/tests/library/Application/View/Helper/LanguageSelectorTest.php index 15c741101b..49064cce0b 100644 --- a/tests/library/Application/View/Helper/LanguageSelectorTest.php +++ b/tests/library/Application/View/Helper/LanguageSelectorTest.php @@ -90,10 +90,7 @@ public function testLanguageConfiguredAndInResourcesEnglish() */ public function testLanguageConfiguredButNotInResources() { - \Zend_Registry::set( - 'Zend_Config', - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config(['supportedLanguages' => 'de,en,ru'])) - ); + $this->adjustConfiguration(['supportedLanguages' => 'de,en,ru']); $result = $this->_helper->languageSelector(); @@ -113,10 +110,7 @@ public function testLanguageConfiguredButNotInResources() */ public function testOnlyOneLanguageConfigured() { - \Zend_Registry::set( - 'Zend_Config', - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config(['supportedLanguages' => 'en'])) - ); + $this->adjustConfiguration(['supportedLanguages' => 'en']); $result = $this->_helper->languageSelector(); diff --git a/tests/library/Application/View/Helper/OptionEnabledTest.php b/tests/library/Application/View/Helper/OptionEnabledTest.php index a8023dd569..4e60904699 100644 --- a/tests/library/Application/View/Helper/OptionEnabledTest.php +++ b/tests/library/Application/View/Helper/OptionEnabledTest.php @@ -43,9 +43,9 @@ public function testOptionEnabled() $this->assertTrue($helper->optionEnabled('orcid.linkAuthor.frontdoor')); $this->assertTrue($helper->optionEnabled('linkAuthor.frontdoor', 'orcid')); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'orcid' => ['linkAuthor' => ['frontdoor' => self::CONFIG_VALUE_FALSE]] - ])); + ]); $this->assertFalse($helper->optionEnabled('orcid.linkAuthor.frontdoor')); $this->assertFalse($helper->optionEnabled('linkAuthor.frontdoor', 'orcid')); diff --git a/tests/library/Application/View/Helper/OptionUrlTest.php b/tests/library/Application/View/Helper/OptionUrlTest.php index 3fceb6295d..d2d90be672 100644 --- a/tests/library/Application/View/Helper/OptionUrlTest.php +++ b/tests/library/Application/View/Helper/OptionUrlTest.php @@ -47,21 +47,21 @@ public function testOptionUrl() $helper->setView(\Zend_Registry::get('Opus_View')); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'logoLink' => 'home' - ])); + ]); $this->assertEquals('http://localhost/opus4/home', $helper->optionUrl('logoLink')); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'logoLink' => '/opus4/home' - ])); + ]); $this->assertEquals('http://localhost/opus4/home', $helper->optionUrl('logoLink')); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'logoLink' => 'http://www.opus-repository.org' - ])); + ]); $this->assertEquals('http://www.opus-repository.org', $helper->optionUrl('logoLink')); } diff --git a/tests/library/Application/View/Helper/OptionValueTest.php b/tests/library/Application/View/Helper/OptionValueTest.php index 1622f303b2..8318073330 100644 --- a/tests/library/Application/View/Helper/OptionValueTest.php +++ b/tests/library/Application/View/Helper/OptionValueTest.php @@ -50,9 +50,9 @@ public function testOptionValueWithEscaping() $this->assertEquals('OPUS 4', $helper->optionValue('name')); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'name' => 'OPUS 4' - ])); + ]); $this->assertEquals('OPUS 4', $helper->optionValue('name')); $this->assertEquals('<b>OPUS 4</b>', $helper->optionValue('name', null, true)); diff --git a/tests/library/Application/View/Helper/ShortenTextTest.php b/tests/library/Application/View/Helper/ShortenTextTest.php index bb0f1bf44a..ac8b87f3a2 100644 --- a/tests/library/Application/View/Helper/ShortenTextTest.php +++ b/tests/library/Application/View/Helper/ShortenTextTest.php @@ -44,9 +44,9 @@ public function testShortenText() { $helper = new Application_View_Helper_ShortenText(); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'frontdoor' => ['numOfShortAbstractChars' => '10'] - ])); + ]); $this->assertEquals('short text', $helper->shortenText('short text')); $this->assertEquals('shortened', $helper->shortenText('shortened text')); @@ -70,17 +70,17 @@ public function testGetMaxLength() { $helper = new Application_View_Helper_ShortenText(); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'frontdoor' => ['numOfShortAbstractChars' => '10'] - ])); + ]); $this->assertEquals(10, $helper->getMaxLength()); $helper->setMaxLength(null); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'frontdoor' => ['numOfShortAbstractChars' => 'bla'] - ])); + ]); $this->assertEquals(0, $helper->getMaxLength()); } @@ -89,9 +89,9 @@ public function testSetMaxLength() { $helper = new Application_View_Helper_ShortenText(); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'frontdoor' => ['numOfShortAbstractChars' => '10'] - ])); + ]); $this->assertEquals(10, $helper->getMaxLength()); diff --git a/tests/library/Application/View/Helper/TranslationEditLinkTest.php b/tests/library/Application/View/Helper/TranslationEditLinkTest.php index 0176444843..b952bde5c6 100644 --- a/tests/library/Application/View/Helper/TranslationEditLinkTest.php +++ b/tests/library/Application/View/Helper/TranslationEditLinkTest.php @@ -51,9 +51,9 @@ public function testRenderTranslationEditLink() public function testRenderOnlyIfSetupAccess() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish,help']]] - ])); + ]); $helper = $this->getHelper(); @@ -76,9 +76,9 @@ public function testRenderOnlyIfSetupAccess() public function testRenderOnlyIfKeyEditable() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default']]] - ])); + ]); $helper = $this->getHelper(); @@ -86,9 +86,9 @@ public function testRenderOnlyIfKeyEditable() $this->assertEquals('', $html); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'setup' => ['translation' => ['modules' => ['allowed' => 'default,publish,help']]] - ])); + ]); // TODO enable editing of help module diff --git a/tests/library/Application/ZendBasicsTest.php b/tests/library/Application/ZendBasicsTest.php index 3d9d36a4de..b46edd719c 100644 --- a/tests/library/Application/ZendBasicsTest.php +++ b/tests/library/Application/ZendBasicsTest.php @@ -65,7 +65,7 @@ public function testZendConfigBooleanOption($name, $value, $result) */ public function testZendConfigBooleanOptionLoadedFromIni($name, $value, $result) { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $options = $config->tests->config; $value = $options->$name; diff --git a/tests/modules/ControllerTestCaseTest.php b/tests/modules/ControllerTestCaseTest.php index a690f0fe6c..9e18a34e34 100644 --- a/tests/modules/ControllerTestCaseTest.php +++ b/tests/modules/ControllerTestCaseTest.php @@ -26,7 +26,7 @@ * * @category Application Unit Test * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ @@ -198,9 +198,9 @@ public function testGetWorkspacePath() */ public function testGetWorkspacePathNotDefined() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'workspacePath' => null - ])); + ]); $this->getWorkspacePath(); } diff --git a/tests/modules/account/controllers/IndexControllerTest.php b/tests/modules/account/controllers/IndexControllerTest.php index e2a54c7ae0..7366175b65 100644 --- a/tests/modules/account/controllers/IndexControllerTest.php +++ b/tests/modules/account/controllers/IndexControllerTest.php @@ -27,11 +27,12 @@ * @category Tests * @package Account * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\Account; +use Opus\Config; /** * Basic unit tests for account module. @@ -75,7 +76,7 @@ private function deleteUser($username) */ public function testIndexSuccessAction() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->loginUser('admin', 'adminadmin'); @@ -91,7 +92,7 @@ public function testIndexSuccessAction() */ public function testIndexDeniedIfEditAccountDisabledAction() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $config->account->editOwnAccount = self::CONFIG_VALUE_FALSE; $this->loginUser('admin', 'adminadmin'); @@ -111,7 +112,7 @@ public function testIndexWithoutLoginAction() public function testChangePasswordFailsOnMissingInputAction() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->loginUser('john', 'testpwd'); @@ -136,7 +137,7 @@ public function testChangePasswordFailsOnMissingInputAction() public function testChangePasswordFailsOnNoMatch() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->loginUser('john', 'testpwd'); @@ -165,7 +166,7 @@ public function testChangePasswordFailsOnNoMatch() */ public function testChangePasswordSuccess() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->loginUser('john', 'testpwd'); @@ -194,7 +195,7 @@ public function testChangePasswordSuccess() */ public function testChangePasswordSuccessWithSpecialChars() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->loginUser('john', 'testpwd'); @@ -223,7 +224,7 @@ public function testChangePasswordSuccessWithSpecialChars() */ public function testChangeLoginSuccess() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->account->editOwnAccount = self::CONFIG_VALUE_TRUE; $this->deleteUser('john2'); diff --git a/tests/modules/admin/controllers/DocumentControllerTest.php b/tests/modules/admin/controllers/DocumentControllerTest.php index 3356eb7dc1..b7ddd5d60f 100644 --- a/tests/modules/admin/controllers/DocumentControllerTest.php +++ b/tests/modules/admin/controllers/DocumentControllerTest.php @@ -28,12 +28,13 @@ * @author Jens Schwidder * @author Michael Lang * @author Maximilian Salomon - * @copyright Copyright (c) 2008-2020, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\CollectionRole; use Opus\Date; +use Opus\Log; use Opus\Note; use Opus\Person; use Opus\Title; @@ -949,7 +950,7 @@ public function testShowDocumentWithFilesWithLanguageNull() public function testUnableToTranslateForMetadataView() { $logger = new MockLogger(); - \Zend_Registry::set('Zend_Log', $logger); + Log::set($logger); $adapter = \Zend_Registry::get('Zend_Translate')->getAdapter(); $options = $adapter->getOptions(); @@ -977,7 +978,7 @@ public function testUnableToTranslateForMetadataView() public function testUnableToTranslateForEditForm() { $logger = new MockLogger(); - \Zend_Registry::set('Zend_Log', $logger); + Log::set($logger); $adapter = \Zend_Registry::get('Zend_Translate')->getAdapter(); $options = $adapter->getOptions(); diff --git a/tests/modules/admin/controllers/DocumentsControllerTest.php b/tests/modules/admin/controllers/DocumentsControllerTest.php index ece21c584b..671bfef985 100644 --- a/tests/modules/admin/controllers/DocumentsControllerTest.php +++ b/tests/modules/admin/controllers/DocumentsControllerTest.php @@ -167,7 +167,7 @@ public function testHitsPerPageBadParameter() public function testConfigureDefaultHitsPerPage() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->admin->documents->maxDocsDefault = '7'; $this->dispatch('/admin/documents'); @@ -176,7 +176,7 @@ public function testConfigureDefaultHitsPerPage() public function testConfigureHitsPerPageOptions() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->admin->documents->maxDocsOptions = "20,60,all"; $this->dispatch('/admin/documents'); diff --git a/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php b/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php index 94da727fd6..f917ad34e6 100644 --- a/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php +++ b/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php @@ -33,6 +33,7 @@ use Opus\Job; use Opus\Job\Runner; +use Opus\Log; /** * Class Admin_IndexmaintenanceControllerTest @@ -49,7 +50,7 @@ class Admin_IndexmaintenanceControllerTest extends ControllerTestCase public function tearDown() { // Cleanup of Log File - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $filename = $config->workspacePath . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'opus_consistency-check.log'; if (file_exists($filename)) { unlink($filename); @@ -173,9 +174,9 @@ private function disableAsyncMode() private function setAsyncMode($value) { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'runjobs' => ['asynchronous' => $value] - ])); + ]); } private function enableAsyncIndexmaintenanceMode() @@ -190,9 +191,9 @@ private function disableAsyncIndexmaintenanceMode() private function setAsyncIndexmaintenanceMode($value) { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'runjobs' => ['indexmaintenance' => ['asynchronous' => $value]] - ])); + ]); } public function testCheckconsistencyActionWithDisabledFeature() @@ -295,7 +296,7 @@ public function testCheckconsistencyActionResult() * run job immediately and check for result */ $jobrunner = new Runner(); - $jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); + $jobrunner->setLogger( Log::get()); $worker = new Opus\Search\Task\ConsistencyCheck(); $jobrunner->registerWorker($worker); $jobrunner->run(); diff --git a/tests/modules/admin/controllers/InfoControllerTest.php b/tests/modules/admin/controllers/InfoControllerTest.php index bd0f1291e3..5de7dbb1bb 100644 --- a/tests/modules/admin/controllers/InfoControllerTest.php +++ b/tests/modules/admin/controllers/InfoControllerTest.php @@ -43,7 +43,7 @@ class Admin_InfoControllerTest extends ControllerTestCase public function testIndexDisplayVersion() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $this->dispatch('admin/info'); $this->assertResponseCode(200); $this->assertQuery('//div[@class="opus-version-info"]'); @@ -62,7 +62,7 @@ public function testVersionWithOldVersion() $versionHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('version'); $versionHelper->setVersion('4.6'); - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $oldVersion = $config->version; $config->version = '4.5-TEST'; $this->dispatch('admin/info/update'); @@ -81,7 +81,7 @@ public function testVersionWithCurrentVersion() { $this->useEnglish(); $helper = \Zend_Controller_Action_HelperBroker::getStaticHelper('version'); - $helper->setVersion(\Zend_Registry::get('Zend_Config')->version); + $helper->setVersion($this->getConfig()->version); $this->dispatch('admin/info/update'); $this->assertQueryContentContains('//div', 'Your OPUS version is up to date.'); diff --git a/tests/modules/admin/controllers/JobControllerTest.php b/tests/modules/admin/controllers/JobControllerTest.php index 6c7f398fd7..4b637e590a 100644 --- a/tests/modules/admin/controllers/JobControllerTest.php +++ b/tests/modules/admin/controllers/JobControllerTest.php @@ -27,7 +27,7 @@ * @category Tests * @package Admin * @author Edouard Simon - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ @@ -41,7 +41,6 @@ class Admin_JobControllerTest extends ControllerTestCase protected $additionalResources = 'all'; - private $__configBackup; private $jobIds = []; public function setUp() @@ -50,9 +49,7 @@ public function setUp() $this->makeConfigurationModifiable(); - $config = \Zend_Registry::get('Zend_Config'); - $this->__configBackup = $config; - $config->merge(new \Zend_Config(['runjobs' => ['asynchronous' => self::CONFIG_VALUE_TRUE]])); + $this->adjustConfiguration(['runjobs' => ['asynchronous' => self::CONFIG_VALUE_TRUE]]); $this->assertEquals(0, Job::getCount(Job::STATE_FAILED), 'test data changed.'); @@ -70,13 +67,11 @@ public function setUp() public function tearDown() { - $testJobs = Job::getAll($this->jobIds); foreach ($testJobs as $job) { $job->delete(); } - \Zend_Registry::set('Zend_Config', $this->__configBackup); parent::tearDown(); } diff --git a/tests/modules/admin/controllers/ReportControllerTest.php b/tests/modules/admin/controllers/ReportControllerTest.php index faabc9634e..f2e10c790f 100644 --- a/tests/modules/admin/controllers/ReportControllerTest.php +++ b/tests/modules/admin/controllers/ReportControllerTest.php @@ -44,20 +44,14 @@ class Admin_ReportControllerTest extends ControllerTestCase protected $additionalResources = 'all'; - private $config; - private $docIds; public function setUp() { parent::setUp(); - // backup config - $this->config = \Zend_Registry::get('Zend_Config'); - // modify DOI config - $config = \Zend_Registry::get('Zend_Config'); - $config->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'doi' => [ 'prefix' => '10.5072', 'localPrefix' => 'opustest', @@ -71,15 +65,11 @@ public function setUp() ] ] ] - ])); - \Zend_Registry::set('Zend_Config', $config); + ]); } public function tearDown() { - // restore config - \Zend_Registry::set('Zend_Config', $this->config); - if (! is_null($this->docIds)) { // removed previously created test documents from database foreach ($this->docIds as $docId) { diff --git a/tests/modules/admin/controllers/WorkflowControllerTest.php b/tests/modules/admin/controllers/WorkflowControllerTest.php index efc9d54337..3e082e73db 100644 --- a/tests/modules/admin/controllers/WorkflowControllerTest.php +++ b/tests/modules/admin/controllers/WorkflowControllerTest.php @@ -47,7 +47,7 @@ class Admin_WorkflowControllerTest extends ControllerTestCase private function enablePublishNotification() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->notification->document->published->enabled = self::CONFIG_VALUE_TRUE; $config->notification->document->published->email = "published@localhost"; } @@ -436,9 +436,9 @@ public function testShowDocInfoOnConfirmationPage() public function testConfirmationDisabled() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'confirmation' => ['document' => ['statechange' => ['enabled' => self::CONFIG_VALUE_FALSE]]] - ])); + ]); $this->dispatch('/admin/workflow/changestate/docId/102/targetState/deleted'); $this->assertRedirectTo('/admin/document/index/id/102'); // Änderung wird sofort durchgefuehrt diff --git a/tests/modules/admin/models/DoiReportTest.php b/tests/modules/admin/models/DoiReportTest.php index 812759214d..c91cd8f4e5 100644 --- a/tests/modules/admin/models/DoiReportTest.php +++ b/tests/modules/admin/models/DoiReportTest.php @@ -52,14 +52,12 @@ public function setUp() { parent::setUp(); - $config = \Zend_Registry::get('Zend_Config'); - $config->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'doi' => [ 'prefix' => '10.5072', 'localPrefix' => 'opustest' ] - ])); - \Zend_Registry::set('Zend_Config', $config); + ]); $this->docIds = []; diff --git a/tests/modules/admin/models/IndexMaintenanceTest.php b/tests/modules/admin/models/IndexMaintenanceTest.php index 1fec061aad..3504228e6f 100644 --- a/tests/modules/admin/models/IndexMaintenanceTest.php +++ b/tests/modules/admin/models/IndexMaintenanceTest.php @@ -28,13 +28,15 @@ * @package Tests * @author Sascha Szott * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; use Opus\DocumentFinder; use Opus\Job; use Opus\Job\Runner; +use Opus\Log; class Admin_Model_IndexMaintenanceTest extends ControllerTestCase { @@ -46,11 +48,11 @@ class Admin_Model_IndexMaintenanceTest extends ControllerTestCase public function tearDown() { if (! is_null($this->config)) { - \Zend_Registry::set('Zend_Config', $this->config); + Config::set($this->config); // TODO why is this here? } // Cleanup of Log File - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $filename = $config->workspacePath . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'opus_consistency-check.log'; if (file_exists($filename)) { unlink($filename); @@ -104,16 +106,16 @@ public function testConstructorWithFeatureEnabledBoth() private function enableAsyncMode() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'runjobs' => ['asynchronous' => self::CONFIG_VALUE_TRUE] - ])); + ]); } private function enableAsyncIndexmaintenanceMode() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'runjobs' => ['indexmaintenance' => ['asynchronous' => self::CONFIG_VALUE_TRUE]] - ])); + ]); } public function testAllowConsistencyCheck() @@ -174,7 +176,7 @@ private function runJobImmediately() $this->assertEquals(1, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); $jobrunner = new Runner; - $jobrunner->setLogger(\Zend_Registry::get('Zend_Log')); + $jobrunner->setLogger( Log::get()); $worker = new Opus\Search\Task\ConsistencyCheck(); $jobrunner->registerWorker($worker); $jobrunner->run(); @@ -267,7 +269,7 @@ public function testReadLogfileWithNonEmptyFile() private function touchLogfile($lock = false) { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); if ($lock) { $filename = $config->workspacePath . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'opus_consistency-check.log.lock'; } else { diff --git a/tests/modules/admin/models/UrnGeneratorTest.php b/tests/modules/admin/models/UrnGeneratorTest.php index dfacff86a4..98587a42fc 100644 --- a/tests/modules/admin/models/UrnGeneratorTest.php +++ b/tests/modules/admin/models/UrnGeneratorTest.php @@ -34,37 +34,15 @@ class Admin_Model_UrnGeneratorTest extends ControllerTestCase { - private $config; - - public function setUp() - { - parent::setUp(); - - $this->makeConfigurationModifiable(); - } - - public function tearDown() - { - if (! is_null($this->config)) { - // undo modifications in configuration - \Zend_Registry::set('Zend_Config', $this->config); - } - } - private function modifyUrnConfig($nss, $nid) { - // backup current config state - $this->config = \Zend_Registry::get('Zend_Config'); - // modify current config state - $config = \Zend_Registry::get('Zend_Config'); - $config->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'urn' => [ 'nss' => $nss, 'nid' => $nid ] - ])); - \Zend_Registry::set('Zend_Config', $config); + ]); } public function testWithMissingConfig() diff --git a/tests/modules/citationExport/controller/IndexControllerTest.php b/tests/modules/citationExport/controller/IndexControllerTest.php index 196b79fba8..13187d3272 100644 --- a/tests/modules/citationExport/controller/IndexControllerTest.php +++ b/tests/modules/citationExport/controller/IndexControllerTest.php @@ -69,7 +69,7 @@ public function testMultipleIdentifiersInRis() $this->assertContains('SN - 1-5432-876-9', $response->getBody()); $this->assertContains('SN - 1234-5678', $response->getBody()); $this->assertContains('SN - 4321-8765', $response->getBody()); - $urnResolverUrl = \Zend_Registry::get('Zend_Config')->urn->resolverUrl; + $urnResolverUrl = $this->getConfig()->urn->resolverUrl; $this->assertContains('UR - ' . $urnResolverUrl . 'urn:nbn:de:foo:123-bar-456', $response->getBody()); $this->assertContains('UR - ' . $urnResolverUrl . 'urn:nbn:de:foo:123-bar-789', $response->getBody()); $this->assertContains('UR - http://www.myexampledomain.de/foo', $response->getBody()); @@ -480,11 +480,10 @@ public function testIndexActionBibtexSeriesInvisible() /** Regression Test for OPUSVIER-3251 */ public function testIndexActionBibtexEnrichmentVisibleAsNote() { - $bibtexConfArray = [ + $this->adjustConfiguration([ 'citationExport' => ['bibtex' => ['enrichment' => 'SourceTitle']] - ]; - $bibtexConf = new \Zend_Config($bibtexConfArray); - \Zend_Registry::getInstance()->get('Zend_Config')->merge($bibtexConf); + ]); + $this->dispatch('/citationExport/index/index/output/bibtex/docId/146'); $this->assertResponseCode(200); $response = $this->getResponse(); diff --git a/tests/modules/export/BibtexExportTest.php b/tests/modules/export/BibtexExportTest.php index d6a848db39..29c92cc030 100644 --- a/tests/modules/export/BibtexExportTest.php +++ b/tests/modules/export/BibtexExportTest.php @@ -42,9 +42,9 @@ public function setUp() { parent::setUp(); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'searchengine' => ['solr' => ['numberOfDefaultSearchResults' => '10']] - ])); + ]); } /** @@ -77,9 +77,9 @@ public function setUp() public function testExportSingleDocument() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'export' => ['download' => self::CONFIG_VALUE_FALSE] - ])); + ]); $this->dispatch('/export/index/bibtex/searchtype/id/docId/146'); @@ -96,10 +96,10 @@ public function testExportSingleDocument() */ public function testExportLatestDocuments() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'export' => ['download' => self::CONFIG_VALUE_FALSE], 'searchengine' => ['solr' => ['numberOfDefaultSearchResults' => '10']] - ])); + ]); $this->dispatch('/export/index/bibtex/searchtype/latest'); @@ -112,9 +112,9 @@ public function testExportLatestDocuments() public function testExportLatestDocumentsWithCustomRows() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'export' => ['download' => self::CONFIG_VALUE_FALSE] - ])); + ]); $this->dispatch('/export/index/bibtex/searchtype/latest/rows/12'); diff --git a/tests/modules/export/BootstrapTest.php b/tests/modules/export/BootstrapTest.php index 99d884756b..447f35685f 100644 --- a/tests/modules/export/BootstrapTest.php +++ b/tests/modules/export/BootstrapTest.php @@ -45,13 +45,13 @@ public function testInitExport() $this->dispatch('/frontdoor/index/index/docId/1'); // TODO configuration change has no influence at this point - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'export' => [ 'stylesheet' => [ 'frontdoor' => null ] ] - ])); + ]); $this->assertResponseCode(200); $this->assertQuery('a.export.bibtex'); diff --git a/tests/modules/export/DataCiteExportTest.php b/tests/modules/export/DataCiteExportTest.php index 99f766d253..8604b75e91 100644 --- a/tests/modules/export/DataCiteExportTest.php +++ b/tests/modules/export/DataCiteExportTest.php @@ -48,7 +48,6 @@ class Export_DataCiteExportTest extends ControllerTestCase public function testExportOfValidDataCiteXML() { // DOI Präfix setzen - $oldConfig = \Zend_Registry::get('Zend_Config'); $this->adaptDoiConfiguration(); // freigegebenes Testdokument mit allen Pflichtfeldern anlegen @@ -58,9 +57,6 @@ public function testExportOfValidDataCiteXML() $this->dispatch('/export/index/datacite/docId/' . $docId); - // Änderungen an Konfiguration zurücksetzen - \Zend_Registry::set('Zend_Config', $oldConfig); - $this->assertResponseCode(200); $this->assertHeaderContains('Content-Type', 'text/xml; charset=UTF-8'); $this->assertNotEmpty($this->getResponse()->getBody()); @@ -97,7 +93,6 @@ public function testExportOfDataCiteXmlStatusPage() public function testExportOfDataCiteXmlStatusPageForUnpublishedDoc() { - $oldConfig = \Zend_Registry::get('Zend_Config'); $this->adaptDoiConfiguration(); // nicht freigegebenes Testdokument mit allen Pflichtfeldern erzeugen @@ -108,9 +103,6 @@ public function testExportOfDataCiteXmlStatusPageForUnpublishedDoc() $this->useGerman(); $this->dispatch('/export/index/datacite/docId/' . $docId); - // Änderungen an Konfiguration zurücksetzen - \Zend_Registry::set('Zend_Config', $oldConfig); - $this->assertResponseCode(200); $this->assertContains("DataCite XML des nicht freigeschalteten Dokuments $docId ist gültig", $this->getResponse()->getBody()); @@ -121,7 +113,6 @@ public function testExportOfDataCiteXmlStatusPageForUnpublishedDoc() public function testExportOfDataCiteXmlStatusPageForUnpublishedDocWithMissingField() { - $oldConfig = \Zend_Registry::get('Zend_Config'); $this->adaptDoiConfiguration(); // nicht freigegebenes Testdokument mit Pflichtfeldern erzeugen @@ -136,9 +127,6 @@ public function testExportOfDataCiteXmlStatusPageForUnpublishedDocWithMissingFie $this->useGerman(); $this->dispatch('/export/index/datacite/docId/' . $docId); - // Änderungen an Konfiguration zurücksetzen - \Zend_Registry::set('Zend_Config', $oldConfig); - $this->assertResponseCode(200); $this->assertContains("DataCite XML von Dokument $docId ist nicht gültig", $this->getResponse()->getBody()); @@ -149,7 +137,6 @@ public function testExportOfDataCiteXmlStatusPageForUnpublishedDocWithMissingFie public function testExportOfDataCiteXmlForUnpublishedDocWithServerDatePublished() { - $oldConfig = \Zend_Registry::get('Zend_Config'); $this->adaptDoiConfiguration(); // nicht freigegebenes Testdokument mit Pflichtfeldern erzeugen und ServerDatePublished @@ -161,9 +148,6 @@ public function testExportOfDataCiteXmlForUnpublishedDocWithServerDatePublished( $this->useGerman(); $this->dispatch('/export/index/datacite/docId/' . $docId); - // Änderungen an Konfiguration zurücksetzen - \Zend_Registry::set('Zend_Config', $oldConfig); - $this->assertResponseCode(200); $this->assertHeaderContains('Content-Type', 'text/xml; charset=UTF-8'); $this->assertNotEmpty($this->getResponse()->getBody()); @@ -171,7 +155,6 @@ public function testExportOfDataCiteXmlForUnpublishedDocWithServerDatePublished( public function testExportOfDataCiteXmlStatusPageForPublishedDocWithoutServerDatePublished() { - $oldConfig = \Zend_Registry::get('Zend_Config'); $this->adaptDoiConfiguration(); // freigegebenes Testdokument mit Pflichtfeldern erzeugen @@ -186,9 +169,6 @@ public function testExportOfDataCiteXmlStatusPageForPublishedDocWithoutServerDat $this->useGerman(); $this->dispatch('/export/index/datacite/docId/' . $docId); - // Änderungen an Konfiguration zurücksetzen - \Zend_Registry::set('Zend_Config', $oldConfig); - $this->assertResponseCode(200); $this->assertContains("DataCite XML von Dokument $docId ist nicht gültig", $this->getResponse()->getBody()); @@ -209,17 +189,14 @@ public function testExportOfDataCiteXmlWithUnpublishedDocNotAllowed() { $removeAccess = $this->addModuleAccess('export', 'guest'); $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] - ] + + $this->adjustConfiguration([ + 'plugins' => [ + 'export' => [ + 'datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE] ] - ) - ); + ] + ]); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); @@ -233,7 +210,7 @@ public function testExportOfDataCiteXmlWithUnpublishedDocNotAllowed() // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); + if ($removeAccess) { $this->removeModuleAccess('export', 'guest'); } @@ -245,17 +222,14 @@ public function testExportOfDataCiteXmlWithUnpublishedDocNotAllowed() public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForAdmin() { $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] - ] + + $this->adjustConfiguration([ + 'plugins' => [ + 'export' => [ + 'datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE] ] - ) - ); + ] + ]); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); @@ -269,7 +243,6 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForAdmin() // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); $this->assertResponseCode(200); $this->assertContains("DataCite XML of document ${docId} is not valid", $this->getResponse()->getBody()); @@ -279,17 +252,14 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForNonAdminUserW { $removeAccess = $this->addModuleAccess('export', 'docsadmin'); $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] - ] + + $this->adjustConfiguration([ + 'plugins' => [ + 'export' => [ + 'datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE] ] - ) - ); + ] + ]); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); @@ -303,7 +273,7 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForNonAdminUserW // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); + if ($removeAccess) { $this->removeModuleAccess('export', 'docsadmin'); } @@ -316,17 +286,14 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForNonAdminUserW { $removeAccess = $this->addModuleAccess('export', 'collectionsadmin'); $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] - ] + + $this->adjustConfiguration([ + 'plugins' => [ + 'export' => [ + 'datacite' => ['adminOnly' => self::CONFIG_VALUE_FALSE] ] - ) - ); + ] + ]); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); @@ -340,7 +307,7 @@ public function testExportOfDataCiteXmlWithUnpublishedDocAllowedForNonAdminUserW // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); + if ($removeAccess) { $this->removeModuleAccess('export', 'collectionsadmin'); } @@ -383,14 +350,12 @@ private function addRequiredFields($doc) private function adaptDoiConfiguration() { - \Zend_Registry::set('Zend_Config', \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config([ - 'doi' => [ - 'autoCreate' => false, - 'prefix' => '10.2345', - 'localPrefix' => 'opustest' - ] - ]) - )); + $this->adjustConfiguration([ + 'doi' => [ + 'autoCreate' => false, + 'prefix' => '10.2345', + 'localPrefix' => 'opustest' + ] + ]); } } diff --git a/tests/modules/export/Marc21ExportTest.php b/tests/modules/export/Marc21ExportTest.php index 63ba46627a..49a390fa99 100644 --- a/tests/modules/export/Marc21ExportTest.php +++ b/tests/modules/export/Marc21ExportTest.php @@ -50,16 +50,12 @@ public function testMarc21XmlExportWithUnpublishedDocNotAllowed() { $removeAccess = $this->addModuleAccess('export', 'guest'); $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] - ] + $this->adjustConfiguration([ + 'plugins' => + ['export' => + ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] ] - ) + ] ); $doc = $this->createTestDocument(); @@ -74,7 +70,7 @@ public function testMarc21XmlExportWithUnpublishedDocNotAllowed() // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); + if ($removeAccess) { $this->removeModuleAccess('export', 'guest'); } @@ -86,16 +82,12 @@ public function testMarc21XmlExportWithUnpublishedDocNotAllowed() public function testMarc21XmlExportWithUnpublishedDocAllowedForAdmin() { $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] - ] + $this->adjustConfiguration([ + 'plugins' => + ['export' => + ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] ] - ) + ] ); $doc = $this->createTestDocument(); @@ -110,7 +102,6 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForAdmin() // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); $this->assertResponseCode(200); $this->assertXpathContentContains('//marc:leader', '00000naa a22000005 4500'); @@ -128,16 +119,12 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForNonAdminUserWithP { $removeAccess = $this->addModuleAccess('export', 'docsadmin'); $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] - ] + $this->adjustConfiguration([ + 'plugins' => + ['export' => + ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] ] - ) + ] ); $doc = $this->createTestDocument(); @@ -152,7 +139,7 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForNonAdminUserWithP // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); + if ($removeAccess) { $this->removeModuleAccess('export', 'docsadmin'); } @@ -173,17 +160,14 @@ public function testMarc21XmlExportWithPublishedDocNotAllowedForGuest() { $removeAccess = $this->addModuleAccess('export', 'guest'); $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['marc21' => ['adminOnly' => self::CONFIG_VALUE_TRUE]] - ] + + $this->adjustConfiguration([ + 'plugins' => [ + 'export' => [ + 'marc21' => ['adminOnly' => self::CONFIG_VALUE_TRUE] ] - ) - ); + ] + ]); $doc = $this->createTestDocument(); $doc->setServerState('published'); @@ -195,7 +179,7 @@ public function testMarc21XmlExportWithPublishedDocNotAllowedForGuest() // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); + if ($removeAccess) { $this->removeModuleAccess('export', 'guest'); } @@ -208,16 +192,13 @@ public function testMarc21XmlExportWithPublishedDocAllowedForAdmin() { $removeAccess = $this->addModuleAccess('export', 'docsadmin'); $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['marc21' => ['adminOnly' => self::CONFIG_VALUE_TRUE]] - ] + + $this->adjustConfiguration([ + 'plugins' => + ['export' => + ['marc21' => ['adminOnly' => self::CONFIG_VALUE_TRUE]] ] - ) + ] ); $doc = $this->createTestDocument(); @@ -232,7 +213,7 @@ public function testMarc21XmlExportWithPublishedDocAllowedForAdmin() // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); + if ($removeAccess) { $this->removeModuleAccess('export', 'docsadmin'); } @@ -255,16 +236,13 @@ public function testMarc21XmlExportWithPublishedDocAllowedForGuest() { $removeAccess = $this->addModuleAccess('export', 'guest'); $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] - ] + + $this->adjustConfiguration([ + 'plugins' => + ['export' => + ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] ] - ) + ] ); $doc = $this->createTestDocument(); @@ -277,7 +255,7 @@ public function testMarc21XmlExportWithPublishedDocAllowedForGuest() // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); + if ($removeAccess) { $this->removeModuleAccess('export', 'guest'); } @@ -300,16 +278,13 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForNonAdminUserWitho { $removeAccess = $this->addModuleAccess('export', 'collectionsadmin'); $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => - ['export' => - ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] - ] + + $this->adjustConfiguration([ + 'plugins' => + ['export' => + ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] ] - ) + ] ); $doc = $this->createTestDocument(); @@ -324,7 +299,7 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForNonAdminUserWitho // revert configuration changes $this->restoreSecuritySetting(); - \Zend_Registry::set('Zend_Config', $config); + if ($removeAccess) { $this->removeModuleAccess('export', 'collectionsadmin'); } diff --git a/tests/modules/export/RisExportTest.php b/tests/modules/export/RisExportTest.php index 4f4979fd18..7c7783e24b 100644 --- a/tests/modules/export/RisExportTest.php +++ b/tests/modules/export/RisExportTest.php @@ -48,7 +48,7 @@ public function testDoiUrlRendered() $docId = $document->store(); - $doiResolverUrl = \Zend_Registry::get('Zend_Config')->doi->resolverUrl; + $doiResolverUrl = $this->getConfig()->doi->resolverUrl; $this->dispatch("/export/index/ris/searchtype/id/docId/$docId"); diff --git a/tests/modules/export/controllers/IndexControllerTest.php b/tests/modules/export/controllers/IndexControllerTest.php index bc908667ec..4780faeef4 100644 --- a/tests/modules/export/controllers/IndexControllerTest.php +++ b/tests/modules/export/controllers/IndexControllerTest.php @@ -191,9 +191,8 @@ public function testRequestToRawXmlIsDenied() $this->_removeExportFromGuest = $this->addAccessOnModuleExportForGuest(); // enable security - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->security = self::CONFIG_VALUE_TRUE; - \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/index/export/xml'); @@ -214,13 +213,12 @@ public function testUnavailableSolrServerReturns503() $this->_removeExportFromGuest = $this->addAccessOnModuleExportForGuest(); // manipulate solr configuration - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $host = $config->searchengine->index->host; $port = $config->searchengine->index->port; $this->disableSolr(); $config->security = self::CONFIG_VALUE_TRUE; - \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/index/searchtype/all/export/xml/stylesheet/example'); $body = $this->getResponse()->getBody(); @@ -606,16 +604,14 @@ public function testPublistActionWithoutStylesheetParameterInUrl() public function testPublistActionWithoutStylesheetParameterInUrlAndInvalidConfigParameter() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); if (isset($config->plugins->export->publist->stylesheet)) { $config->plugins->export->publist->stylesheet = 'invalid'; } else { - $config = new \Zend_Config(['plugins' => ['export' => [ - 'publist' => ['stylesheet' => 'invalid']], true]]); - // Include the above made configuration changes in the application configuration. - $config->merge(\Zend_Registry::get('Zend_Config')); + $this->adjustConfiguration([ + 'plugins' => ['export' => ['publist' => ['stylesheet' => 'invalid']]] + ]); } - \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/publist/role/publists/number/coll_visible'); @@ -626,25 +622,23 @@ public function testPublistActionWithoutStylesheetParameterInUrlAndInvalidConfig public function testPublistActionWithValidStylesheetInConfig() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); + if (isset($config->plugins->export->publist->stylesheet)) { $config->plugins->export->publist->stylesheet = 'raw'; } else { - $config = new \Zend_Config(['plugins' => ['export' => [ - 'publist' => ['stylesheet' => 'raw']], true]]); - // Include the above made configuration changes in the application configuration. - $config->merge(\Zend_Registry::get('Zend_Config')); + $this->adjustConfiguration([ + 'plugins' => ['export' => ['publist' => ['stylesheet' => 'raw']], true] + ]); } if (isset($config->plugins->export->publist->stylesheetDirectory)) { $config->plugins->export->publist->stylesheetDirectory = 'stylesheets'; } else { - $config = new \Zend_Config(['plugins' => ['export' => [ - 'publist' => ['stylesheetDirectory' => 'stylesheets']], true]]); - // Include the above made configuration changes in the application configuration. - $config->merge(\Zend_Registry::get('Zend_Config')); + $this->adjustConfiguration([ + 'plugins' => ['export' => ['publist' => ['stylesheetDirectory' => 'stylesheets']], true] + ]); } - \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/publist/role/publists/number/coll_visible'); @@ -680,7 +674,7 @@ public function testPublistActionUrnResolverUrlCorrect() { $this->dispatch('/export/index/publist/role/ccs/number/H.3'); - $urnResolverUrl = \Zend_Registry::get('Zend_Config')->urn->resolverUrl; + $urnResolverUrl = $this->getConfig()->urn->resolverUrl; $this->assertXpathContentContains('//a[starts-with(@href, "' . $urnResolverUrl . '")]', 'URN'); } @@ -689,7 +683,7 @@ public function testPublistActionDoiResolverUrlCorrect() { $this->dispatch('/export/index/publist/role/ddc/number/51'); // contains test document 146 - $doiResolverUrl = \Zend_Registry::get('Zend_Config')->doi->resolverUrl; + $doiResolverUrl = $this->getConfig()->doi->resolverUrl; $this->assertXpathContentContains('//a[starts-with(@href, "' . $doiResolverUrl . '")]', 'DOI'); } @@ -707,17 +701,15 @@ protected function setPublistConfig($options) public function testPublistActionGroupedByCompletedYear() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); // FIXME OPUSVIER-4130 config does not make sense - completely ignores value of setting if (isset($config->plugins->export->publist->groupby->completedyear)) { $config->plugins->export->publist->groupby->completedyear = self::CONFIG_VALUE_TRUE; } else { - $configNew = new \Zend_Config(['plugins' => ['export' => [ - 'publist' => ['groupby' => ['completedyear' => self::CONFIG_VALUE_TRUE]]]]], false); - // Include the above made configuration changes in the application configuration. - $config->merge($configNew); + $this->adjustConfiguration([ + 'plugins' => ['export' => ['publist' => ['groupby' => ['completedyear' => self::CONFIG_VALUE_TRUE]]]] + ]); } - \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/publist/role/publists/number/coll_visible'); @@ -798,19 +790,17 @@ public function testPrefixesForIdClassAndAnchorInDefaultLayout() */ public function testPublistActionDisplaysUrlencodedFiles() { - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config(['plugins' => ['export' => [ - 'publist' => [ - 'file' => [ - 'allow' => [ - 'mimetype' => ['application/xhtml+xml' => 'HTML']]]]]]]) - ); + $this->adjustConfiguration([ + 'plugins' => ['export' => ['publist' => ['file' => ['allow' => [ + 'mimetype' => ['application/xhtml+xml' => 'HTML'] + ]]]]] + ]); // explicitly re-initialize mime type config to apply changes in Zend_Config // This is necessary due to static variable in Export_Model_PublicationList // which is not reset between tests. - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $this->assertTrue( isset($config->plugins->export->publist->file->allow->mimetype), 'Failed setting configuration option' @@ -979,11 +969,9 @@ public function testNonAdminAccessOnUnrestrictedExportAllowed() */ public function testNonAdminAccessOnUnrestrictedMarc21ExportAllowed() { - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config( - ['plugins' => ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]]]] - ) - ); + $this->adjustConfiguration([ + 'plugins' => ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]]] + ]); $exportAccessProvided = $this->addAccessOnModuleExportForGuest(); $this->enableSecurity(); diff --git a/tests/modules/export/models/DataciteExportTest.php b/tests/modules/export/models/DataciteExportTest.php index 904cc1c049..06ac66132a 100644 --- a/tests/modules/export/models/DataciteExportTest.php +++ b/tests/modules/export/models/DataciteExportTest.php @@ -65,17 +65,12 @@ public function testExecuteWithUnknownDocId() public function testExecuteWithValidDoc() { - // DOI Präfix setzen - $oldConfig = \Zend_Registry::get('Zend_Config'); - - \Zend_Registry::set('Zend_Config', \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config([ - 'doi' => [ - 'prefix' => '10.2345', - 'localPrefix' => 'opustest' - ] - ]) - )); + $this->adjustConfiguration([ + 'doi' => [ + 'prefix' => '10.2345', + 'localPrefix' => 'opustest' + ] + ]); // Testdokument mit allen Pflichtfeldern anlegen $doc = Document::new(); @@ -112,8 +107,6 @@ public function testExecuteWithValidDoc() // Testdokument wieder löschen $doc->delete(); - // Änderungen an Konfiguration zurücksetzen - \Zend_Registry::set('Zend_Config', $oldConfig); $this->assertTrue($result); $this->assertHeaderContains('Content-Type', 'text/xml; charset=UTF-8'); diff --git a/tests/modules/export/models/PublistExportTest.php b/tests/modules/export/models/PublistExportTest.php index 972d06aee4..c699311359 100644 --- a/tests/modules/export/models/PublistExportTest.php +++ b/tests/modules/export/models/PublistExportTest.php @@ -27,10 +27,12 @@ * @category Application * @package Module_Export * @author Michael Lang - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; + class Export_Model_PublistExportTest extends ControllerTestCase { @@ -47,15 +49,15 @@ public function testConstruction() public function testGetMimeTypes() { - $config = \Zend_Registry::get('Zend_Config'); - - $config->merge( - new \Zend_Config(['plugins' => ['export' => [ + $this->adjustConfiguration([ + 'plugins' => ['export' => [ 'publist' => [ 'file' => [ 'allow' => [ - 'mimetype' => ['application/xhtml+xml' => 'HTML']]]]]]]) - ); + 'mimetype' => ['application/xhtml+xml' => 'HTML']]]]]] + ]); + + $config = Config::get(); $plugin = new Export_Model_PublistExport('publist'); $plugin->setConfig($config->plugins->export->publist); diff --git a/tests/modules/export/models/XmlExportTest.php b/tests/modules/export/models/XmlExportTest.php index 83aeea2643..afe298a478 100644 --- a/tests/modules/export/models/XmlExportTest.php +++ b/tests/modules/export/models/XmlExportTest.php @@ -276,9 +276,9 @@ public function testIsDownloadEnabled() $plugin->setDownloadEnabled(null); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'export' => ['download' => self::CONFIG_VALUE_FALSE] - ])); + ]); $this->assertFalse($plugin->isDownloadEnabled()); } diff --git a/tests/modules/frontdoor/controllers/IndexControllerTest.php b/tests/modules/frontdoor/controllers/IndexControllerTest.php index 76b9b4e442..52112e0185 100644 --- a/tests/modules/frontdoor/controllers/IndexControllerTest.php +++ b/tests/modules/frontdoor/controllers/IndexControllerTest.php @@ -29,14 +29,16 @@ * @author Julian Heise * @author Michael Lang * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\Collection; use Opus\CollectionRole; +use Opus\Config; use Opus\Date; use Opus\Document; +use Opus\Log; use Opus\Note; use Opus\Title; @@ -69,7 +71,7 @@ public function setUp() parent::setUpWithEnv('production'); $this->assertSecurityConfigured(); - $path = \Zend_Registry::get('temp_dir') . '~localstat.xml'; + $path = Config::getInstance()->getTempPath() . '~localstat.xml'; @unlink($path); $this->_document = $this->createTestDocument(); @@ -387,9 +389,9 @@ public function testSubjectSortOrder() public function testSubjectSortOrderAlphabetical() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'frontdoor' => ['subjects' => ['alphabeticalSorting' => self::CONFIG_VALUE_TRUE]] - ])); + ]); // frontdoor.subjects.alphabeticalSorting @@ -462,12 +464,12 @@ public function testUrlEncodedAuthorNamesDoc150() */ public function testShowLinkForPrintOnDemandIfLicenceAppropriate() { - $podConfArray = ['printOnDemand' => [ - 'url' => 'http://localhost/', - 'button' => '' - ]]; - $podConfig = new \Zend_Config($podConfArray); - \Zend_Registry::getInstance()->get('Zend_Config')->merge($podConfig); + $this->adjustConfiguration([ + 'printOnDemand' => [ + 'url' => 'http://localhost/', + 'button' => '' + ] + ]); $this->dispatch('/frontdoor/index/index/docId/1'); $this->assertQuery('div#print-on-demand'); @@ -478,12 +480,12 @@ public function testShowLinkForPrintOnDemandIfLicenceAppropriate() */ public function testHideLinkForPrintOnDemandIfLicenceNotAppropriate() { - $podConfArray = ['printOnDemand' => [ - 'url' => 'http://localhost/', - 'button' => '' - ]]; - $podConfig = new \Zend_Config($podConfArray); - \Zend_Registry::getInstance()->get('Zend_Config')->merge($podConfig); + $this->adjustConfiguration([ + 'printOnDemand' => [ + 'url' => 'http://localhost/', + 'button' => '' + ] + ]); $this->dispatch('/frontdoor/index/index/docId/91'); $this->assertNotQuery('div#print-on-demand'); @@ -797,9 +799,9 @@ public function testValidateXHTML() public function testValidateXHTMLWithShortendAbstracts() { // Aktiviere Kürzung von Abstrakten - $config = \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( + $this->adjustConfiguration( ['frontdoor' => ['numOfShortAbstractChars' => '200']] - )); + ); $this->dispatch('/frontdoor/index/index/docId/92'); $this->assertResponseCode(200); @@ -939,7 +941,7 @@ public function testDateFormatEnglish() */ public function testFilesInCustomSortOrder() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->frontdoor->files->customSorting = '1'; $this->dispatch('/frontdoor/index/index/docId/155'); @@ -958,7 +960,7 @@ public function testFilesInCustomSortOrder() */ public function testFilesInAlphabeticSortOrder() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->frontdoor->files->customSorting = self::CONFIG_VALUE_FALSE; $this->dispatch('/frontdoor/index/index/docId/155'); @@ -1321,8 +1323,7 @@ public function testXmlExportButtonPresentForAdmin() { $this->enableSecurity(); $this->loginUser('admin', 'adminadmin'); - $config = \Zend_Registry::get('Zend_Config'); - $config->merge(new \Zend_Config(['export' => ['stylesheet' => ['frontdoor' => 'example']]])); + $this->adjustConfiguration(['export' => ['stylesheet' => ['frontdoor' => 'example']]]); $this->dispatch('/frontdoor/index/index/docId/305'); $this->assertQuery( '//a[@href="/export/index/index/docId/305/export/xml/searchtype/id/stylesheet/example"]' @@ -1335,8 +1336,7 @@ public function testXmlExportButtonPresentForAdmin() public function testXmlExportNotButtonPresentForGuest() { $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - $config->merge(new \Zend_Config(['export' => ['stylesheet' => ['frontdoor' => 'example']]])); + $this->adjustConfiguration(['export' => ['stylesheet' => ['frontdoor' => 'example']]]); $this->dispatch('/frontdoor/index/index/docId/305'); $this->assertNotQuery('//a[@href="/frontdoor/index/index/docId/305/export/xml/stylesheet/example"]'); } @@ -1369,9 +1369,9 @@ public function testGoogleScholarLinkEnglish() public function testGoogleScholarOpenInNewWindowEnabled() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'googleScholar' => ['openInNewWindow' => self::CONFIG_VALUE_TRUE] - ])); + ]); $this->dispatch('/frontdoor/index/index/docId/146'); $this->assertResponseCode(200); $this->assertXpathCount('//a[contains(@href, "scholar.google.de") and @target = "_blank"]', 1); @@ -1380,9 +1380,9 @@ public function testGoogleScholarOpenInNewWindowEnabled() public function testGoogleScholarOpenInNewWindowDisabled() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'googleScholar' => ['openInNewWindow' => self::CONFIG_VALUE_FALSE] - ])); + ]); $this->dispatch('/frontdoor/index/index/docId/146'); $this->assertResponseCode(200); $this->assertXpathCount('//a[contains(@href, "scholar.google.de") and @target = "_blank"]', 0); @@ -1402,9 +1402,9 @@ public function testShowDocumentWithFileWithoutLanguage() public function testTwitterOpenInNewWindowEnabled() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'twitter' => ['openInNewWindow' => self::CONFIG_VALUE_TRUE] - ])); + ]); $this->dispatch('/frontdoor/index/index/docId/146'); $this->assertResponseCode(200); $this->assertXpathCount('//a[contains(@href, "twitter.com") and @target = "_blank"]', 1); @@ -1413,9 +1413,9 @@ public function testTwitterOpenInNewWindowEnabled() public function testTwitterOpenInNewWindowDisabled() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'twitter' => ['openInNewWindow' => self::CONFIG_VALUE_FALSE] - ])); + ]); $this->dispatch('/frontdoor/index/index/docId/146'); $this->assertResponseCode(200); $this->assertXpathCount('//a[contains(@href, "twitter.com") and @target = "_blank"]', 0); @@ -1426,10 +1426,10 @@ public function testUnableToTranslate() { $filter = new LogFilter(); - $logger = \Zend_Registry::get('Zend_Log'); + $logger = Log::get(); $logger->addFilter($filter); - $this->assertEquals(7, \Zend_Registry::get('LOG_LEVEL'), 'Log level should be 7 for test.'); + $this->assertEquals(7, $logger->getLevel(), 'Log level should be 7 for test.'); $this->dispatch('/frontdoor/index/index/docId/146'); @@ -1453,7 +1453,7 @@ public function testMetaTagsForUrns() $this->assertResponseCode(200); - $urnResolverUrl = \Zend_Registry::get('Zend_Config')->urn->resolverUrl; + $urnResolverUrl = $this->getConfig()->urn->resolverUrl; $this->assertXpath('//meta[@name="DC.identifier" and @content="urn:nbn:op:123"]'); $this->assertXpath('//meta[@name="DC.identifier" and @content="' . $urnResolverUrl . 'urn:nbn:op:123"]'); @@ -1462,9 +1462,9 @@ public function testMetaTagsForUrns() public function testBelongsToBibliographyTurnedOn() { $this->useEnglish(); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'frontdoor' => ['metadata' => ['BelongsToBibliography' => self::CONFIG_VALUE_TRUE]] - ])); + ]); $this->dispatch('/frontdoor/index/index/docId/146'); @@ -1474,9 +1474,9 @@ public function testBelongsToBibliographyTurnedOn() public function testBelongsToBibliographyTurnedOff() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'frontdoor' => ['metadata' => ['BelongsToBibliography' => self::CONFIG_VALUE_FALSE]] - ])); + ]); $this->dispatch('/frontdoor/index/index/docId/146'); diff --git a/tests/modules/frontdoor/models/HtmlMetaTagsTest.php b/tests/modules/frontdoor/models/HtmlMetaTagsTest.php index 3e57423d68..a6de78e0e8 100644 --- a/tests/modules/frontdoor/models/HtmlMetaTagsTest.php +++ b/tests/modules/frontdoor/models/HtmlMetaTagsTest.php @@ -61,7 +61,7 @@ public function setUp() { parent::setUp(); $this->htmlMetaTags = new Frontdoor_Model_HtmlMetaTags( - \Zend_Registry::get('Zend_Config'), + $this->getConfig(), 'http://localhost/opus' ); @@ -96,7 +96,7 @@ public function testCreateTagsForJournalPaper() public function testCreateTagsForCustomTypeJournalPaper() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( + $this->htmlMetaTags->setConfig($this->adjustConfiguration( ['metatags' => ['mapping' => ['journal_paper' => ['customdoctype']]]] )); @@ -127,7 +127,7 @@ public function testCreateTagsForConferencePaper() public function testCreateTagsForCustomTypeConferencePaper() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( + $this->htmlMetaTags->setConfig($this->adjustConfiguration( ['metatags' => ['mapping' => ['conference_paper' => ['customdoctype']]]] )); @@ -158,7 +158,7 @@ public function testCreateTagsForThesis() public function testCreateTagsForCustomTypeThesis() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( + $this->htmlMetaTags->setConfig($this->adjustConfiguration( ['metatags' => ['mapping' => ['thesis' => ['customdoctype']]]] )); @@ -187,7 +187,7 @@ public function testCreateTagsForWorkingPaper() public function testCreateTagsForCustomTypeWorkingPaper() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( + $this->htmlMetaTags->setConfig($this->adjustConfiguration( ['metatags' => ['mapping' => ['working_paper' => ['customdoctype']]]] )); @@ -220,7 +220,7 @@ public function testCreateTagsForWorkingPaperWithContributingCorporation() public function testCreateTagsForCustomTypeWorkingPaperWithContributingCorporation() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( + $this->htmlMetaTags->setConfig($this->adjustConfiguration( ['metatags' => ['mapping' => ['working_paper' => ['customdoctype']]]] )); @@ -254,7 +254,7 @@ public function testCreateTagsForWorkingPaperWithPublisher() public function testCreateTagsForCustomTypeWorkingPaperWithPublisher() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( + $this->htmlMetaTags->setConfig($this->adjustConfiguration( ['metatags' => ['mapping' => ['working_paper' => ['customdoctype']]]] )); @@ -285,7 +285,7 @@ public function testCreateTagsForBook() public function testCreateTagsForCustomTypeBook() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( + $this->htmlMetaTags->setConfig($this->adjustConfiguration( ['metatags' => ['mapping' => ['book' => ['customdoctype']]]] )); @@ -313,7 +313,7 @@ public function testCreateTagsForBookPart() public function testCreateTagsForCustomTypeBookPart() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( + $this->htmlMetaTags->setConfig($this->adjustConfiguration( ['metatags' => ['mapping' => ['book_part' => ['customdoctype']]]] )); @@ -810,7 +810,7 @@ private function addLicence($doc) */ private function addFile($doc) { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $path = $config->workspacePath . DIRECTORY_SEPARATOR . uniqid(); mkdir($path, 0777, true); @@ -872,7 +872,7 @@ public function testGetMappingConfig() public function testGetMappingConfigCustomDocumentType() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->htmlMetaTags->setConfig($this->adjustConfiguration([ 'metatags' => ['mapping' => ['book' => ['mybooktype']]] ])); @@ -886,7 +886,7 @@ public function testGetMappingConfigCustomDocumentType() public function testGetMappingConfigDefaultOverride() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->htmlMetaTags->setConfig($this->adjustConfiguration([ 'metatags' => ['mapping' => ['book' => ['article']]] ])); diff --git a/tests/modules/home/controllers/IndexControllerTest.php b/tests/modules/home/controllers/IndexControllerTest.php index e65b83fc13..67a3e722f0 100644 --- a/tests/modules/home/controllers/IndexControllerTest.php +++ b/tests/modules/home/controllers/IndexControllerTest.php @@ -84,7 +84,7 @@ public function testHelpActionGerman() public function testHelpActionSeparate() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->help->separate = self::CONFIG_VALUE_TRUE; $this->dispatch('/home/index/help'); $this->assertResponseCode(200); @@ -253,7 +253,7 @@ public function testShowLanguageSelector() public function testHideLanguageSelector() { - \Zend_Registry::get('Zend_Config')->supportedLanguages = 'de'; + $this->getConfig()->supportedLanguages = 'de'; $this->dispatch("/home"); $this->assertNotQuery('//ul#lang-switch'); } diff --git a/tests/modules/home/models/HelpFilesTest.php b/tests/modules/home/models/HelpFilesTest.php index 921a30691d..272c6e0ca1 100644 --- a/tests/modules/home/models/HelpFilesTest.php +++ b/tests/modules/home/models/HelpFilesTest.php @@ -62,11 +62,11 @@ public function testGetFiles() public function testGetFileContent() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'help' => [ 'useFiles' => true ] - ])); + ]); $content = $this->help->getContent('contact.de.txt'); @@ -90,11 +90,11 @@ public function testGetFileContentNull() public function testGetFileContentForAllFiles() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'help' => [ 'useFiles' => true ] - ])); + ]); $helpFiles = $this->help->getFiles(); diff --git a/tests/modules/oai/controllers/ContainerControllerTest.php b/tests/modules/oai/controllers/ContainerControllerTest.php index 21f5696173..408fcf4905 100644 --- a/tests/modules/oai/controllers/ContainerControllerTest.php +++ b/tests/modules/oai/controllers/ContainerControllerTest.php @@ -86,9 +86,8 @@ public function testRequestUnpublishedDoc() } // enable security - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->security = self::CONFIG_VALUE_TRUE; - \Zend_Registry::set('Zend_Config', $config); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); @@ -118,7 +117,7 @@ public function testRequestPublishedDocWithoutAssociatedFiles() public function testRequestPublishedDocWithInaccessibleFile() { // create test file test.pdf in file system - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $path = $config->workspacePath . DIRECTORY_SEPARATOR . uniqid(); mkdir($path, 0777, true); $filepath = $path . DIRECTORY_SEPARATOR . 'test.pdf'; @@ -155,7 +154,7 @@ public function testRequestPublishedDocWithAccessibleFile() ); // create test file test.pdf in file system - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $path = $config->workspacePath . DIRECTORY_SEPARATOR . uniqid(); mkdir($path, 0777, true); $filepath = $path . DIRECTORY_SEPARATOR . 'test.pdf'; diff --git a/tests/modules/oai/controllers/IndexControllerTest.php b/tests/modules/oai/controllers/IndexControllerTest.php index 30160d433e..73233ff8fb 100644 --- a/tests/modules/oai/controllers/IndexControllerTest.php +++ b/tests/modules/oai/controllers/IndexControllerTest.php @@ -148,9 +148,9 @@ public function testNoVerb() */ public function testIdentify() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'oai' => ['repository' => ['name' => 'test-repo-name']] - ])); + ]); $this->dispatch('/oai?verb=Identify'); $this->assertResponseCode(200); @@ -207,9 +207,9 @@ public function testIdentifyDescriptionEprintsConfigured() 'comment' => ['url' => 'test-comment-url', 'text' => 'test-comment-text'] ]; - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'oai' => ['description' => ['eprints' => $values]] - ])); + ]); $this->dispatch('/oai?verb=Identify'); $this->assertResponseCode(200); @@ -233,10 +233,10 @@ public function testIdentifyDescriptionEprintsConfigured() public function testIdentifyDescriptionOaiIdentifier() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'oai' => ['repository' => ['identifier' => 'test-repo-identifier'], 'sample' => ['identifier' => 'test-sample-identifier']] - ])); + ]); $this->dispatch('/oai?verb=Identify'); $this->assertResponseCode(200); @@ -972,7 +972,7 @@ public function testGetRecordOaiDcDoc146() $this->assertEquals('Baz University', $elements->item(1)->nodeValue, 'dc:contributor field changed'); // Regression test for OPUSVIER-2393 (show dc:identifier) - $urnResolverUrl = \Zend_Registry::get('Zend_Config')->urn->resolverUrl; + $urnResolverUrl = $this->getConfig()->urn->resolverUrl; $elements = $xpath->query('//oai_dc:dc/dc:identifier[text()="' . $urnResolverUrl . 'urn:nbn:op:123"]'); $this->assertEquals(1, $elements->length, 'dc:identifier URN count changed'); @@ -1221,16 +1221,15 @@ public function testListRecords() */ public function testListRecordsXMetaDissPlusDocumentsWithFilesOnly() { - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config([ - 'oai' => [ - 'max' => [ - 'listrecords' => '100', - 'listidentifiers' => '200', - ] + $this->adjustConfiguration([ + 'oai' => [ + 'max' => [ + 'listrecords' => '100', + 'listidentifiers' => '200', ] - ]) - ); + ] + ]); + $this->dispatch('/oai?verb=ListRecords&metadataPrefix=xMetaDissPlus'); $responseBody = $this->getResponse()->getBody(); @@ -1247,16 +1246,15 @@ public function testListRecordsXMetaDissPlusDocumentsWithFilesOnly() */ public function testListRecordsXMetaDissPlusDocumentsWithoutUrn() { - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config([ - 'oai' => [ - 'max' => [ - 'listrecords' => '100', - 'listidentifiers' => '200', - ] + $this->adjustConfiguration([ + 'oai' => [ + 'max' => [ + 'listrecords' => '100', + 'listidentifiers' => '200', ] - ]) - ); + ] + ]); + $this->dispatch('/oai?verb=ListRecords&metadataPrefix=xMetaDissPlus'); $xpath = $this->prepareXpathFromResultString($this->getResponse()->getBody()); @@ -1500,7 +1498,7 @@ public function enableSecurity() } // enable security - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config(['security' => self::CONFIG_VALUE_TRUE])); + $this->adjustConfiguration(['security' => self::CONFIG_VALUE_TRUE]); } /** @@ -1919,9 +1917,7 @@ public function testListRecordsWithResumptionToken() { $max_records = '2'; - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config(['oai' => ['max' => ['listrecords' => $max_records]]]) - ); + $this->adjustConfiguration(['oai' => ['max' => ['listrecords' => $max_records]]]); // first request: fetch documents list and expect resumption code $this->dispatch("/oai?verb=ListRecords&metadataPrefix=oai_dc"); @@ -1965,9 +1961,7 @@ public function testListRecordsWithEmptyResumptionTokenForLastBlock() { $max_records = '100'; - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config(['oai' => ['max' => ['listrecords' => $max_records]]]) - ); + $this->adjustConfiguration(['oai' => ['max' => ['listrecords' => $max_records]]]); // first request: fetch documents list and expect resumption code $this->dispatch("/oai?verb=ListRecords&metadataPrefix=oai_dc"); @@ -2606,13 +2600,13 @@ public function testGetRecordXMetaDissPlusDcmiType() public function testGetRecordMarc21OfDocId91() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'marc21' => [ 'isil' => 'DE-9999', 'publisherName' => 'publisherNameFromConfig', 'publisherCity' => 'publisherCityFromConfig', ] - ])); + ]); $this->dispatch('/oai?verb=GetRecord&metadataPrefix=marc21&identifier=oai::91'); diff --git a/tests/modules/oai/models/ContainerTest.php b/tests/modules/oai/models/ContainerTest.php index 0cf11e5825..56f54c6fa6 100644 --- a/tests/modules/oai/models/ContainerTest.php +++ b/tests/modules/oai/models/ContainerTest.php @@ -52,7 +52,7 @@ class Oai_Model_ContainerTest extends ControllerTestCase public function setUp() { parent::setUp(); - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); if (! isset($config->workspacePath)) { throw new Exception("config key 'workspacePath' not defined in config file"); } @@ -117,9 +117,8 @@ public function testConstructorWithUnpublishedDocument() } // enable security - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->security = self::CONFIG_VALUE_TRUE; - \Zend_Registry::set('Zend_Config', $config); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); diff --git a/tests/modules/publish/controllers/DepositControllerTest.php b/tests/modules/publish/controllers/DepositControllerTest.php index 6b3a6b99ba..74fae2ad7d 100644 --- a/tests/modules/publish/controllers/DepositControllerTest.php +++ b/tests/modules/publish/controllers/DepositControllerTest.php @@ -27,11 +27,12 @@ * @category Tests * @package Publish * @author Susanne Gottwald - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\Document; +use Opus\Log; /** * Class Publish_DepositControllerTest. @@ -229,7 +230,7 @@ public function testStoreExistingDocument() $doc->setServerState('published'); $doc->setType('preprint'); - $log = \Zend_Registry::get('Zend_Log'); + $log = Log::get(); $deposit = new Publish_Model_Deposit($log); $deposit->storeDocument($doc->store()); } diff --git a/tests/modules/publish/controllers/FormControllerTest.php b/tests/modules/publish/controllers/FormControllerTest.php index bfd5192a67..8400127ff1 100644 --- a/tests/modules/publish/controllers/FormControllerTest.php +++ b/tests/modules/publish/controllers/FormControllerTest.php @@ -265,7 +265,7 @@ public function testCheckActionWithValidPostAndSendButtonAndAllRequiredFields() */ public function testOPUSVIER1886WithBibliography() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->bibliographie = self::CONFIG_VALUE_TRUE; $doc = $this->createTemporaryDoc(); @@ -294,7 +294,7 @@ public function testOPUSVIER1886WithBibliography() public function testOPUSVIER1886WithBibliographyUnselected() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->bibliographie = self::CONFIG_VALUE_TRUE; $doc = $this->createTemporaryDoc(); @@ -325,7 +325,7 @@ public function testOPUSVIER1886WithBibliographyUnselected() public function testOPUSVIER1886WithBibliographySelected() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->bibliographie = self::CONFIG_VALUE_TRUE; $doc = $this->createTemporaryDoc(); @@ -359,7 +359,7 @@ public function testOPUSVIER1886WithBibliographySelected() */ public function testOPUSVIER1886WithoutBibliography() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->bibliographie = self::CONFIG_VALUE_FALSE; $doc = $this->createTemporaryDoc(); @@ -392,7 +392,7 @@ public function testOPUSVIER1886WithoutBibliography() public function testFormManipulationForBibliography() { $this->markTestIncomplete('testing multipart formdata not yet solved'); - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->bibliographie = self::CONFIG_VALUE_FALSE; $this->request @@ -473,7 +473,7 @@ public function testShowFileNoticeOnThirdFormPageIfFileUploadIsEnabled() private function fileNoticeOnThirdFormPage($value) { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->enable_upload = $value; $doc = $this->createTemporaryDoc(); @@ -497,7 +497,7 @@ private function fileNoticeOnThirdFormPage($value) private function fileNoticeOnSecondFormPage($value) { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->enable_upload = $value; $doc = $this->createTemporaryDoc(); diff --git a/tests/modules/publish/controllers/IndexControllerTest.php b/tests/modules/publish/controllers/IndexControllerTest.php index 920475d93f..9c1062a633 100644 --- a/tests/modules/publish/controllers/IndexControllerTest.php +++ b/tests/modules/publish/controllers/IndexControllerTest.php @@ -58,7 +58,7 @@ public function testIndexAction() public function testShowFileUpload() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->enable_upload = self::CONFIG_VALUE_TRUE; $this->dispatch('/publish'); @@ -78,7 +78,7 @@ public function testShowFileUpload() public function testDoNotShowFileUpload() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->enable_upload = self::CONFIG_VALUE_FALSE; $this->dispatch('/publish'); @@ -99,7 +99,7 @@ public function testDoNotShowFileUpload() public function testShowBibliographyCheckbox() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->bibliographie = self::CONFIG_VALUE_TRUE; $this->dispatch('/publish'); @@ -117,7 +117,7 @@ public function testShowBibliographyCheckbox() public function testDoNotShowBibliographyCheckbox() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->bibliographie = self::CONFIG_VALUE_FALSE; $this->dispatch('/publish'); @@ -139,7 +139,7 @@ public function testDoNotShowBibliographyCheckbox() public function testDocumentTypeSelectBoxIsSortedAlphabetically() { // manipulate list of available document types in application configuration - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $include = $config->documentTypes->include; $exclude = $config->documentTypes->exclude; $config->documentTypes->include = 'all, article, workingpaper, demodemo'; diff --git a/tests/modules/publish/forms/PublishingFirstTest.php b/tests/modules/publish/forms/PublishingFirstTest.php index 60476af560..48026dc5da 100644 --- a/tests/modules/publish/forms/PublishingFirstTest.php +++ b/tests/modules/publish/forms/PublishingFirstTest.php @@ -44,7 +44,7 @@ public function testConstructorWithEmptyView() public function testIsValidMethodWithMissingDocumentType() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->require_upload = self::CONFIG_VALUE_FALSE; $config->form->first->show_rights_checkbox = self::CONFIG_VALUE_FALSE; $config->form->first->bibliographie = self::CONFIG_VALUE_FALSE; @@ -60,7 +60,7 @@ public function testIsValidMethodWithMissingDocumentType() public function testIsValidMethodWithMissingRightsCheckbox() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->form->first->require_upload = self::CONFIG_VALUE_FALSE; $config->form->first->show_rights_checkbox = self::CONFIG_VALUE_TRUE; $config->form->first->bibliographie = self::CONFIG_VALUE_FALSE; diff --git a/tests/modules/publish/forms/PublishingSecondTest.php b/tests/modules/publish/forms/PublishingSecondTest.php index 84fac9df99..1d0a2cd16f 100644 --- a/tests/modules/publish/forms/PublishingSecondTest.php +++ b/tests/modules/publish/forms/PublishingSecondTest.php @@ -71,7 +71,7 @@ public function testConstructorWithDocTypeInSession() */ public function testIsValidWithInvalidData() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; @@ -90,7 +90,7 @@ public function testIsValidWithInvalidData() */ public function testIsValidWithValidData() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'demo'; @@ -109,7 +109,7 @@ public function testIsValidWithValidData() */ public function testPrepareCheckMethodWithDemoType() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'demo'; diff --git a/tests/modules/publish/models/DepositTest.php b/tests/modules/publish/models/DepositTest.php index 2252720f8d..4f6c00e9e2 100644 --- a/tests/modules/publish/models/DepositTest.php +++ b/tests/modules/publish/models/DepositTest.php @@ -27,11 +27,12 @@ * @category Application * @package Module_Publish Unit Test * @author Susanne Gottwald - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\EnrichmentKey; +use Opus\Log; class Publish_Model_DepositTest extends ControllerTestCase { @@ -63,7 +64,7 @@ public function testInvalidDocumentState() $document->setServerState('published'); $documentId = $document->store(); - $log = \Zend_Registry::get('Zend_Log'); + $log = Log::get(); $deposit = new Publish_Model_Deposit($log); $deposit->storeDocument($documentId); } @@ -139,7 +140,7 @@ public function testValidDocumentData() 'Foo2Title' => ['value' => 'title as enrichment', 'datatype' => 'Enrichment', 'subfield' => '0'], ]; - $log = \Zend_Registry::get('Zend_Log'); + $log = Log::get(); $dep = new Publish_Model_Deposit($log); $dep->storeDocument($docId, null, $data); diff --git a/tests/modules/publish/models/ExtendedValidationTest.php b/tests/modules/publish/models/ExtendedValidationTest.php index 8a8ced1784..3e80998039 100644 --- a/tests/modules/publish/models/ExtendedValidationTest.php +++ b/tests/modules/publish/models/ExtendedValidationTest.php @@ -95,7 +95,7 @@ public function testPersonsEmailWithInvalidData() public function testPersonsEmailNotificationWithValidData() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; @@ -121,7 +121,7 @@ public function testPersonsEmailNotificationWithValidData() public function testPersonsEmailNotificationWithInvalidData() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; @@ -150,7 +150,7 @@ public function testPersonsEmailNotificationWithInvalidData() */ public function testMainTitleWithWrongDocLanguage() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; @@ -179,7 +179,7 @@ public function testMainTitleWithWrongDocLanguage() */ public function testEmptyMainTitleLanguage() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; @@ -211,7 +211,7 @@ public function testSeveralMainTitleLanguages() { $this->markTestSkipped('Method getExtendedForm removed from Form class: moved to FormController class as manipulateSession'); - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; @@ -250,7 +250,7 @@ public function testSeveralMainTitleLanguages() */ public function testSeveralTitleTypeLanguages() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all,preprint,article,demo,workingpaper'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'workingpaper'; @@ -285,7 +285,7 @@ public function testSeveralTitleTypeLanguages() */ public function testSeriesNumberValidationWithUnknownSeries() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; @@ -311,7 +311,7 @@ public function testSeriesNumberValidationWithUnknownSeries() */ public function testSeriesNumberValidationWithMissingSeriesField() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->documentTypes->include = 'all'; $session = new \Zend_Session_Namespace('Publish'); $session->documentType = 'all'; diff --git a/tests/modules/rss/controllers/IndexControllerTest.php b/tests/modules/rss/controllers/IndexControllerTest.php index 63107f3cc9..080d909ba2 100644 --- a/tests/modules/rss/controllers/IndexControllerTest.php +++ b/tests/modules/rss/controllers/IndexControllerTest.php @@ -64,11 +64,10 @@ public function testUnavailableSolrServerReturns503() $this->requireSolrConfig(); // manipulate solr configuration - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $host = $config->searchengine->index->host; $port = $config->searchengine->index->port; $config->searchengine->index->app = 'solr/corethatdoesnotexist'; - \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/rss/index/index/searchtype/all'); $body = $this->getResponse()->getBody(); diff --git a/tests/modules/rss/models/FeedTest.php b/tests/modules/rss/models/FeedTest.php index 9e5f8be17c..d3b2bf2e4e 100644 --- a/tests/modules/rss/models/FeedTest.php +++ b/tests/modules/rss/models/FeedTest.php @@ -57,19 +57,20 @@ public function testGetTitle() $this->assertEquals('http:///opus4test', $model->getTitle()); - $config = \Zend_Registry::get('Zend_Config'); - - $config->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'rss' => ['default' => ['feedTitle' => 'OPUS 4 Test']] - ])); + ]); + + $model->setConfig(null); // reset local reference to configuration + $this->assertEquals('OPUS 4 Test', $model->getTitle()); } public function testGetTitleWithName() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'rss' => ['default' => ['feedTitle' => '%1$s']] - ])); + ]); $this->assertEquals('OPUS 4', $this->_model->getTitle()); } @@ -79,9 +80,9 @@ public function testGetTitleWithFullUrl() \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); $model = new Rss_Model_Feed($view); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'rss' => ['default' => ['feedTitle' => '%4$s']] - ])); + ]); $this->assertEquals('http:///opus4test', $this->_model->getTitle()); } @@ -91,9 +92,9 @@ public function testGetTitleWithBaseUrl() \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); $model = new Rss_Model_Feed($view); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'rss' => ['default' => ['feedTitle' => '%3$s']] - ])); + ]); $this->assertEquals('opus4test', $model->getTitle()); } @@ -104,9 +105,9 @@ public function testGetTitleWithHost() $view->getHelper('ServerUrl')->setHost('testhost'); $model = new Rss_Model_Feed($view); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'rss' => ['default' => ['feedTitle' => '%2$s']] - ])); + ]); $this->assertEquals('testhost', $model->getTitle()); } @@ -114,9 +115,11 @@ public function testGetDescription() { $this->assertEquals('OPUS documents', $this->_model->getDescription()); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'rss' => ['default' => ['feedDescription' => 'Test description.']] - ])); + ]); + + $this->_model->setConfig(null); // reset local reference to configuration $this->assertEquals('Test description.', $this->_model->getDescription()); } diff --git a/tests/modules/setup/controllers/LanguageControllerTest.php b/tests/modules/setup/controllers/LanguageControllerTest.php index b122b216fa..dec2de21e3 100644 --- a/tests/modules/setup/controllers/LanguageControllerTest.php +++ b/tests/modules/setup/controllers/LanguageControllerTest.php @@ -55,8 +55,8 @@ public function tearDown() public function testMissingConfigMessageIsDisplayedRed() { $this->markTestSkipped('Needs to be updated for no modules allowed.'); - $config = \Zend_Registry::get('Zend_Config'); - $config->merge(new \Zend_Config(['setup' => ['translation' => ['modules' => ['allowed' => null]]]])); + + $this->adjustConfiguration(['setup' => ['translation' => ['modules' => ['allowed' => null]]]]); $this->getRequest()->setPost(['Anzeigen' => 'Anzeigen', 'search' => 'test', 'sort' => 'unit']); $this->dispatch('/setup/language/show'); diff --git a/tests/modules/solrsearch/controllers/IndexControllerTest.php b/tests/modules/solrsearch/controllers/IndexControllerTest.php index d4faedc2ee..6c30e092c0 100644 --- a/tests/modules/solrsearch/controllers/IndexControllerTest.php +++ b/tests/modules/solrsearch/controllers/IndexControllerTest.php @@ -661,12 +661,11 @@ public function testUnavailableSolrServerReturns503() $this->requireSolrConfig(); // manipulate solr configuration - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $host = $config->searchengine->solr->default->service->default->endpoint->localhost->host; $port = $config->searchengine->solr->default->service->default->endpoint->localhost->port; $config->searchengine->solr->default->service->default->endpoint->localhost->path = '/solr/corethatdoesnotexist'; - \Zend_Registry::set('Zend_Config', $config); $this->dispatch('/solrsearch/browse/doctypes'); @@ -768,7 +767,7 @@ public function testCatchAllSearchConsidersAllPersons($lastName, $role, $contain public function testFacetLimitWithDefaultSetting() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $numOfSubjects = 20; $this->addSampleDocWithMultipleSubjects($numOfSubjects); @@ -793,7 +792,7 @@ public function testFacetLimitWithDefaultSetting() public function testFacetLimitWithGlobalSetting() { // manipulate application configuration - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->search->facet->default->limit = '5'; $numOfSubjects = 10; @@ -811,38 +810,21 @@ public function testFacetLimitWithGlobalSetting() public function testFacetLimitWithLocalSettingForSubjectFacet() { - // manipulate application configuration - $config = \Zend_Registry::get('Zend_Config'); - $limit = null; - $oldConfig = null; - if (isset($config->searchengine->solr->facetlimit->subject)) { - $limit = $config->searchengine->solr->facetlimit->subject; - } else { - $config = new \Zend_Config([ - 'searchengine' => [ - 'solr' => [ - 'facetlimit' => [ - 'subject' => '5']]]], true); - $oldConfig = \Zend_Registry::get('Zend_Config'); - // Include the above made configuration changes in the application configuration. - $config->merge(\Zend_Registry::get('Zend_Config')); - } - \Zend_Registry::set('Zend_Config', $config); + $this->adjustConfiguration([ + 'searchengine' => [ + 'solr' => [ + 'facetlimit' => [ + 'subject' => '5' + ] + ] + ] + ]); $numOfSubjects = 10; $this->addSampleDocWithMultipleSubjects($numOfSubjects); $this->dispatch('/solrsearch/index/search/searchtype/simple/query/facetlimittestwithsubjects-opusvier2610'); - // undo configuration manipulation - $config = \Zend_Registry::get('Zend_Config'); - if (! is_null($oldConfig)) { - $config = $oldConfig; - } else { - $config->searchengine->solr->facetlimit->subject = $limit; - } - \Zend_Registry::set('Zend_Config', $config); - for ($index = 0; $index < 5; $index++) { $this->assertContains('/solrsearch/index/search/searchtype/simple/query/facetlimittestwithsubjects-opusvier2610/start/0/rows/10/subjectfq/subject0' . $index, $this->getResponse()->getBody()); } @@ -890,28 +872,19 @@ private function addSampleDocWithMultipleSubjects($numOfSubjects = 0) public function testFacetSortLexicographicallyForInstituteFacet() { - // manipulate application configuration - $oldConfig = \Zend_Registry::get('Zend_Config'); - - $config = \Zend_Registry::get('Zend_Config'); - if (isset($config->searchengine->solr->sortcrit->institute)) { - $config->searchengine->solr->sortcrit->institute = 'lexi'; - } else { - $config = new \Zend_Config([ - 'searchengine' => [ - 'solr' => [ - 'sortcrit' => [ - 'institute' => 'lexi']]]], true); - $oldConfig = \Zend_Registry::get('Zend_Config'); - // Include the above made configuration changes in the application configuration. - $config->merge(\Zend_Registry::get('Zend_Config')); - } - \Zend_Registry::set('Zend_Config', $config); + $this->adjustConfiguration([ + 'searchengine' => [ + 'solr' => [ + 'sortcrit' => [ + 'institute' => 'lexi' + ] + ] + ] + ]); $this->dispatch('/solrsearch/index/search/searchtype/all'); - // undo configuration manipulation - \Zend_Registry::set('Zend_Config', $oldConfig); + $this->resetConfiguration(); $searchStrings = [ 'Abwasserwirtschaft und Gewässerschutz B-2', @@ -945,13 +918,13 @@ public function testFacetSortLexicographicallyForInstituteFacet() public function testFacetSortForYearInverted() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'search' => ['facet' => ['year' => [ 'sort' => 'lexi', 'indexField' => 'published_year_inverted' ]]], 'searchengine' => ['solr' => ['facets' => 'year,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute']] - ])); + ]); $this->dispatch('/solrsearch/index/search/searchtype/all'); @@ -1151,12 +1124,12 @@ public function testAuthorFacetClosed() public function testFacetExtenderWithVariousConfigFacetLimits() { $this->useEnglish(); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'search' => ['facet' => [ 'author_facet' => ['limit' => '3'], 'year' => ['limit' => '15'] ]] - ])); + ]); $this->dispatch('/solrsearch/index/search/searchtype/all/'); $this->assertQueryContentContains("//div[@id='author_facet_facet']/div/a", ' + more'); $this->assertQueryContentContains("//div[@id='year_facet']/div/a", ' + more'); @@ -1257,10 +1230,10 @@ public function testXmlExportButtonPresentForAdminInLatestSearch() $this->enableSecurity(); $this->loginUser('admin', 'adminadmin'); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'export' => ['stylesheet' => ['search' => 'example']], 'searchengine' => ['solr' => ['numberOfDefaultSearchResults' => '10']] - ])); + ]); $this->dispatch('/solrsearch/index/search/searchtype/latest'); $this->assertQuery('//a[@href="/solrsearch/index/search/searchtype/latest/rows/10/export/xml/stylesheet/example"]'); @@ -1272,8 +1245,7 @@ public function testXmlExportButtonPresentForAdminInLatestSearch() public function testXmlExportButtonNotPresentForGuest() { $this->enableSecurity(); - $config = \Zend_Registry::get('Zend_Config'); - $config->merge(new \Zend_Config(['export' => ['stylesheet' => ['search' => 'example']]])); + $this->adjustConfiguration(['export' => ['stylesheet' => ['search' => 'example']]]); $this->dispatch('/solrsearch/index/search/searchtype/all'); $this->assertFalse(Realm::getInstance()->checkModule('export')); $this->assertNotQuery('//a[@href="/solrsearch/index/search/searchtype/all/export/xml/stylesheet/example"]'); @@ -1281,9 +1253,7 @@ public function testXmlExportButtonNotPresentForGuest() public function testDisableEmptyCollectionsTrue() { - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config(['browsing' => ['disableEmptyCollections' => self::CONFIG_VALUE_TRUE]]) - ); + $this->adjustConfiguration(['browsing' => ['disableEmptyCollections' => self::CONFIG_VALUE_TRUE]]); $this->dispatch('/solrsearch/index/search/searchtype/collection/id/2'); @@ -1296,9 +1266,7 @@ public function testDisableEmptyCollectionsTrue() public function testDisableEmptyCollectionsFalse() { - \Zend_Registry::get('Zend_Config')->merge( - new \Zend_Config(['browsing' => ['disableEmptyCollections' => self::CONFIG_VALUE_FALSE]]) - ); + $this->adjustConfiguration(['browsing' => ['disableEmptyCollections' => self::CONFIG_VALUE_FALSE]]); $this->dispatch('/solrsearch/index/search/searchtype/collection/id/2'); diff --git a/tests/modules/solrsearch/models/FacetMenuTest.php b/tests/modules/solrsearch/models/FacetMenuTest.php index 43ff79ea04..a33ad0a931 100644 --- a/tests/modules/solrsearch/models/FacetMenuTest.php +++ b/tests/modules/solrsearch/models/FacetMenuTest.php @@ -44,17 +44,17 @@ class Solrsearch_Model_FacetMenuTest extends ControllerTestCase */ public function testGetFacetLimitsFromConfig() { - $config = \Zend_Registry::get('Zend_Config'); - $config->merge(new \Zend_Config(['searchengine' => - ['solr' => - ['facetlimit' => - [ + + $this->adjustConfiguration([ + 'searchengine' => [ + 'solr' => [ + 'facetlimit' => [ 'author_facet' => '3', 'year' => '15' ] ] ] - ])); + ]); $facetLimits = Opus\Search\Config::getFacetLimits(); @@ -72,27 +72,28 @@ public function testGetFacetLimitsFromConfig() */ public function testGetFacetLimitsFromConfigWithYearInverted() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); if (isset($config->searchengine->solr->facets)) { $config->searchengine->solr->facets = 'year,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute'; } else { - $testConfig = new \Zend_Config([ + $this->adjustConfiguration([ 'searchengine' => [ 'solr' => [ - 'facets' => 'year,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute']]], true); - // Include the above made configuration changes in the application configuration. - $testConfig->merge($config); + 'facets' => 'year,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute' + ] + ] + ]); } - $config->merge(new \Zend_Config(['searchengine' => - ['solr' => - ['facetlimit' => - [ + $this->adjustConfiguration([ + 'searchengine' => [ + 'solr' => [ + 'facetlimit' => [ 'author_facet' => '3', 'year' => '15' ] ] ] - ])); + ]); $facetLimits = Opus\Search\Config::getFacetLimits(); @@ -130,17 +131,21 @@ public function testBuildFacetArray() public function testBuildFacetArrayWithYearInverted() { $model = new Solrsearch_Model_FacetMenu(); - $config = \Zend_Registry::get('Zend_Config'); + + $config = $this->getConfig(); + if (isset($config->searchengine->solr->facets)) { $config->searchengine->solr->facets = 'year_inverted,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute'; } else { - $testConfig = new \Zend_Config([ + $this->adjustConfiguration([ 'searchengine' => [ 'solr' => [ - 'facets' => 'year_inverted,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute']]], true); - // Include the above made configuration changes in the application configuration. - $testConfig->merge($config); + 'facets' => 'year_inverted,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute' + ] + ] + ]); } + $paramSet = ['facetNumber_year' => 'all']; $facetArray = $model->buildFacetArray($paramSet); $this->assertEquals(10000, $facetArray['year']); diff --git a/tests/modules/solrsearch/models/SearchTest.php b/tests/modules/solrsearch/models/SearchTest.php index 97c2329aa6..21b9223b4f 100644 --- a/tests/modules/solrsearch/models/SearchTest.php +++ b/tests/modules/solrsearch/models/SearchTest.php @@ -124,9 +124,9 @@ public function testCreateSimpleSearchUrlParamsWithCustomRows() { $request = $this->getRequest(); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'searchengine' => ['solr' => ['numberOfDefaultSearchResults' => '25']] - ])); + ]); $model = new Solrsearch_Model_Search(); diff --git a/tests/modules/solrsearch/models/SeriesUtilTest.php b/tests/modules/solrsearch/models/SeriesUtilTest.php index 5a1aabd57f..f00ea66ede 100644 --- a/tests/modules/solrsearch/models/SeriesUtilTest.php +++ b/tests/modules/solrsearch/models/SeriesUtilTest.php @@ -97,13 +97,13 @@ public function testGetVisibleSeriesSortedBySortKey() public function testGetVisibleSeriesSortedAlphabetically() { - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'browsing' => [ 'series' => [ 'sortByTitle' => self::CONFIG_VALUE_TRUE ] ] - ])); + ]); $series = $this->model->getVisibleSeries(); diff --git a/tests/modules/solrsearch/models/search/BasicTest.php b/tests/modules/solrsearch/models/search/BasicTest.php index 21039aff23..5fa6599bae 100644 --- a/tests/modules/solrsearch/models/search/BasicTest.php +++ b/tests/modules/solrsearch/models/search/BasicTest.php @@ -58,8 +58,7 @@ public function testCreateQueryBuilderInputFromRequest() */ public function testGetRowsFromConfig() { - $config = \Zend_Registry::get('Zend_Config'); - $oldParamRows = $config->searchengine->solr->numberOfDefaultSearchResults; + $config = $this->getConfig(); $config->searchengine->solr->numberOfDefaultSearchResults = '1337'; $request = $this->getRequest(); @@ -68,9 +67,6 @@ public function testGetRowsFromConfig() $queryBuilder = new Solrsearch_Model_Search_Basic(); $result = $queryBuilder->createQueryBuilderInputFromRequest($request); - //clean-up - $config->searchengine->solr->numberOfDefaultSearchResults = $oldParamRows; - $this->assertEquals($result['rows'], 1337); } diff --git a/tests/modules/sword/controllers/ServicedocumentControllerTest.php b/tests/modules/sword/controllers/ServicedocumentControllerTest.php index a4571622bd..619c5f5bd2 100644 --- a/tests/modules/sword/controllers/ServicedocumentControllerTest.php +++ b/tests/modules/sword/controllers/ServicedocumentControllerTest.php @@ -178,7 +178,7 @@ private function checkWorkspaceSubtree($root) { $this->assertEquals(2, $root->length); - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $this->testHelper->assertNodeProperties(0, $root, 'atom:title', $config->name); $collectionNode = $root->item(1); diff --git a/tests/rebuild-database.php b/tests/rebuild-database.php index b4d6cd3e4a..a7e9b8f141 100644 --- a/tests/rebuild-database.php +++ b/tests/rebuild-database.php @@ -71,7 +71,9 @@ ] ); -\Zend_Registry::set('opus.disableDatabaseVersionCheck', true); +$options = $application->getOptions(); +$options['opus']['disableDatabaseVersionCheck'] = true; +$application->setOptions($options); // Bootstrapping application $application->bootstrap('Backend'); diff --git a/tests/simple.ini b/tests/simple.ini index 2c91bbe0fa..b76c468338 100644 --- a/tests/simple.ini +++ b/tests/simple.ini @@ -57,3 +57,5 @@ resources.frontController.returnResponse=0 workspacePath = APPLICATION_PATH "/workspace" [testing : production] + +opus.disableDatabaseVersionCheck = 1 diff --git a/tests/support/AssumptionChecker.php b/tests/support/AssumptionChecker.php index ac2cf25460..077fd4ac71 100644 --- a/tests/support/AssumptionChecker.php +++ b/tests/support/AssumptionChecker.php @@ -59,12 +59,12 @@ public function checkYearFacetAssumption() $this->testCase->resetRequest(); $this->testCase->resetResponse(); - \Zend_Registry::get('Zend_Config')->merge(new \Zend_Config( - ['searchengine' => ['solr' => [ + $this->adjustConfiguration([ + 'searchengine' => ['solr' => [ 'facetlimit' => ['year' => '10', 'year_inverted' => '10'], 'facets' => 'year,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute' - ]]] - )); + ]] + ]); $this->testCase->dispatch('/solrsearch/index/search/searchtype/all'); @@ -94,8 +94,8 @@ public function checkYearFacetAssumption() } $this->testCase->assertFalse($lastPos === false, "'" . $searchStrings[$i] . '\' not found in year facet list (iteration ' . $i . ')'); if ($lastPos === false) { - break; $loopComplete = false; + break; } } $this->testCase->assertTrue($loopComplete); diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index 6e05df144b..6bbb04a709 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -28,10 +28,11 @@ * @author Jens Schwidder * @author Thoralf Klein * @author Michael Lang - * @copyright Copyright (c) 2008-2020, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; use Opus\Db\TableGateway; use Opus\Document; use Opus\Doi\DoiManager; @@ -77,6 +78,8 @@ class ControllerTestCase extends TestCase private $cleanupModels; + private $baseConfig = null; + /** * Method to initialize Zend_Application for each test. */ @@ -120,6 +123,44 @@ public function tearDown() parent::tearDown(); } + /** + * Overwrites selected properties of current configuration. + * + * @note A test doesn't need to backup and recover replaced configuration as + * this is done in setup and tear-down phases. + * + * @param array $overlay properties to overwrite existing values in configuration + * @param callable $callback callback to invoke with adjusted configuration before enabling e.g. to delete some options + * @return \Zend_Config reference on updated configuration + */ + protected function adjustConfiguration($overlay, $callback = null) + { + $previous = Config::get(); + + if ($this->baseConfig === null) { + $this->baseConfig = $previous; + } + + $updated = new \Zend_Config($previous->toArray(), true); + + $updated->merge(new \Zend_Config($overlay)); + + if (is_callable($callback)) { + $updated = call_user_func($callback, $updated); + } + + Config::set($updated); + + return $updated; + } + + protected function resetConfiguration() + { + if ($this->baseConfig !== null) { + Config::set($this->baseConfig); + } + } + public function getApplication() { return new \Zend_Application( @@ -245,7 +286,7 @@ public function loginUser($login, $password) $auth->authenticate($adapter); $this->assertTrue($auth->hasIdentity()); - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); if (isset($config->security) && filter_var($config->security, FILTER_VALIDATE_BOOLEAN)) { Application_Security_AclProvider::init(); @@ -296,10 +337,9 @@ protected function requireSolrConfig() */ protected function disableSolr() { - $config = \Zend_Registry::get('Zend_Config'); // TODO old config path still needed? // $config->searchengine->index->app = 'solr/corethatdoesnotexist'; - $config->merge(new \Zend_Config([ + $this->adjustConfiguration([ 'searchengine' => [ 'solr' => [ 'default' => [ @@ -313,7 +353,7 @@ protected function disableSolr() ] ] ] - ])); + ]); } /** @@ -335,17 +375,18 @@ protected function assertResponseLocationHeader($response, $location) public function enableSecurity() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $this->securityEnabled = $config->security; $config->security = self::CONFIG_VALUE_TRUE; - \Zend_Registry::set('Zend_Config', $config); } + /** + * TODO is this needed for tearDown? + */ public function restoreSecuritySetting() { - $config = \Zend_Registry::get('Zend_Config'); + $config = $this->getConfig(); $config->security = $this->securityEnabled; - \Zend_Registry::set('Zend_Config', $config); } /** @@ -500,7 +541,7 @@ public function verifyCommandAvailable($command) */ public function isFailTestOnMissingCommand() { - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); return (isset($config->tests->failTestOnMissingCommand) && filter_var($config->tests->failTestOnMissingCommand, FILTER_VALIDATE_BOOLEAN)); } @@ -832,11 +873,6 @@ protected function setWorkspacePath($path) $this->workspacePath = $path; } - protected function getConfig() - { - return \Zend_Registry::get('Zend_Config'); - } - protected function createTestFolder() { $workspacePath = $this->getWorkspacePath(); @@ -914,7 +950,7 @@ protected function deleteFolder($path, $deleteOutsideWorkspace = false) public function assertSecurityConfigured() { - $this->assertEquals('1', \Zend_Registry::get('Zend_Config')->security); + $this->assertEquals('1', Config::get()->security); $this->assertTrue( \Zend_Registry::isRegistered('Opus_Acl'), 'Expected registry key Opus_Acl to be set' diff --git a/tests/support/DepositTestHelper.php b/tests/support/DepositTestHelper.php index d8c5399f7c..77b4679cf8 100644 --- a/tests/support/DepositTestHelper.php +++ b/tests/support/DepositTestHelper.php @@ -28,12 +28,13 @@ * @package Tests * @author Sascha Szott * @author Jens Schwidder - * @copyright Copyright (c) 2016-2017 + * @copyright Copyright (c) 2016-2021 * @license http://www.gnu.org/licenses/gpl.html General Public License */ use Opus\Collection; use Opus\CollectionRole; +use Opus\Config; use Opus\Document; class DepositTestHelper extends PHPUnit_Framework_Assert @@ -51,8 +52,6 @@ class DepositTestHelper extends PHPUnit_Framework_Assert private $collectionNumber; - private $configBackup; - private $frontdoorUrl; public function getCollectionId() @@ -125,14 +124,12 @@ public function addImportCollection() $rootCollection->addLastChild($collection); $this->collectionId = $collection->store(); - $this->configBackup = \Zend_Registry::get('Zend_Config'); - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $config->sword->collection->default->number = $this->collectionNumber; $config->sword->collection->default->abstract = 'sword.collection.default.abstract'; $config->sword->collection->default->collectionPolicy = 'sword.collection.default.collectionPolicy'; $config->sword->collection->default->treatment = 'sword.collection.default.treatment'; $config->sword->collection->default->acceptPackaging = 'sword.collection.default.acceptPackaging'; - \Zend_Registry::set('Zend_Config', $config); } } @@ -142,7 +139,6 @@ public function removeImportCollection() $collection = new Collection($this->collectionId); $collection->delete(); $this->collectionId = null; - \Zend_Registry::set('Zend_Config', $this->configBackup); } } @@ -277,7 +273,7 @@ public function checkAtomEntryDocument( $this->frontdoorUrl = 'http:///frontdoor/index/index/docId/' . $docId; $this->assertEquals($this->frontdoorUrl, $attribute->nodeValue); - $config = \Zend_Registry::get('Zend_Config'); + $config = Config::get(); $generatorValue = $config->sword->generator; $this->assertNodeProperties(5 + $offset, $entryChildren, 'generator', $generatorValue); diff --git a/tests/support/SimpleBootstrap.php b/tests/support/SimpleBootstrap.php index 75fc31d15b..fa64388ef0 100644 --- a/tests/support/SimpleBootstrap.php +++ b/tests/support/SimpleBootstrap.php @@ -27,12 +27,14 @@ * @category Tests * @package Support * @author Jens Schwidder - * @copyright Copyright (c) 2019, OPUS 4 development team + * @copyright Copyright (c) 2019-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License * * TODO take care of duplicated code (from regular bootstrap) - maybe SimpleBootstrap is not needed anymore? */ +use Opus\Config; +use Opus\Log; use Opus\Log\LogService; class SimpleBootstrap extends \Zend_Application_Bootstrap_Bootstrap @@ -56,7 +58,7 @@ class SimpleBootstrap extends \Zend_Application_Bootstrap_Bootstrap protected function _initConfiguration() { $config = new \Zend_Config($this->getOptions(), true); - \Zend_Registry::set('Zend_Config', $config); + Config::set($config); return $config; } @@ -76,10 +78,8 @@ protected function _initLogging() $logService = LogService::getInstance(); $logger = $logService->createLog(LogService::DEFAULT_LOG, null, null, $logFilename); - $logLevel = $logService->getDefaultPriority(); - \Zend_Registry::set('Zend_Log', $logger); - \Zend_Registry::set('LOG_LEVEL', $logLevel); + Log::set($logger); $logger->debug('Logging initialized'); diff --git a/tests/support/TestCase.php b/tests/support/TestCase.php index c6f5fb28d0..a13ed753cf 100644 --- a/tests/support/TestCase.php +++ b/tests/support/TestCase.php @@ -26,10 +26,11 @@ * * @category Application Unit Test * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Config; use Opus\Log; /** @@ -138,22 +139,26 @@ public function resetAutoloader() */ protected function closeLogfile() { - if (! \Zend_Registry::isRegistered('Zend_Log')) { - return; - } + $log = Log::get(); - $log = \Zend_Registry::get('Zend_Log'); if (isset($log)) { $log->__destruct(); - \Zend_Registry::set('Zend_Log', null); } Log::drop(); } + /** + * TODO adjustConfiguration also makes it configurable - so maybe not needed anymore + */ public function makeConfigurationModifiable() { $config = new \Zend_Config([], true); - \Zend_Registry::set('Zend_Config', $config->merge(\Zend_Registry::get('Zend_Config'))); + Config::set($config->merge(Config::get())); + } + + protected function getConfig() + { + return Config::get(); } } From 9816cd13750582c5174305e9c3cf6fc7e49b6dd0 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 1 Mar 2021 20:52:16 +0100 Subject: [PATCH 121/270] OPUSVIER-4518 Fixed coding style --- .../Configuration/MaxUploadSize.php | 2 +- .../Controller/Action/Helper/Files.php | 2 +- .../Controller/Action/Helper/ReturnParams.php | 2 +- .../Controller/Action/Helper/Workflow.php | 2 +- .../Form/Validate/DuplicateValue.php | 6 +++--- modules/admin/models/IndexMaintenance.php | 2 +- modules/admin/models/UrnGenerator.php | 2 +- modules/home/models/HelpFiles.php | 2 +- modules/oai/models/Request.php | 2 +- .../models/DocumentWorkflowSubmitterId.php | 2 +- modules/publish/models/DocumenttypeParser.php | 2 +- modules/publish/models/FormElement.php | 2 +- modules/publish/models/LoggedUser.php | 2 +- modules/review/models/ClearDocumentsHelper.php | 4 ++-- .../sword/controllers/DepositController.php | 4 ++-- modules/sword/models/ErrorDocument.php | 2 +- modules/sword/models/ImportCollection.php | 2 +- .../Controller/Action/Helper/AbstractTest.php | 2 +- .../library/Application/Form/AbstractTest.php | 2 +- .../Form/Decorator/FileHashTest.php | 2 +- .../Application/Util/NotificationTest.php | 4 ++-- .../Util/PublicationNotificationTest.php | 2 +- .../EnrichmentkeyControllerTest.php | 4 ++-- .../IndexmaintenanceControllerTest.php | 2 +- .../admin/controllers/InfoControllerTest.php | 2 +- .../admin/models/IndexMaintenanceTest.php | 2 +- tests/modules/export/Marc21ExportTest.php | 18 ++++++------------ .../controllers/DepositControllerTest.php | 2 +- tests/modules/publish/models/DepositTest.php | 4 ++-- tests/support/TestCase.php | 2 +- 30 files changed, 42 insertions(+), 48 deletions(-) diff --git a/library/Application/Configuration/MaxUploadSize.php b/library/Application/Configuration/MaxUploadSize.php index f8df5c7024..3b9f45582e 100644 --- a/library/Application/Configuration/MaxUploadSize.php +++ b/library/Application/Configuration/MaxUploadSize.php @@ -51,7 +51,7 @@ public function getMaxUploadSizeInKB() public function getMaxUploadSizeInByte() { - $logger = Log::get(); + $logger = Log::get(); $config = Config::get(); $maxFileSizeInt = intval($config->publish->maxfilesize); diff --git a/library/Application/Controller/Action/Helper/Files.php b/library/Application/Controller/Action/Helper/Files.php index 01c8a2be1b..9384fd71d6 100644 --- a/library/Application/Controller/Action/Helper/Files.php +++ b/library/Application/Controller/Action/Helper/Files.php @@ -89,7 +89,7 @@ private function getAllowedFileTypes() private function checkFile($file, $ignoreAllowedTypes) { - $log = Log::get(); + $log = Log::get(); $logMessage = 'check for file: ' . $file->getPathname(); if (! $ignoreAllowedTypes) { diff --git a/library/Application/Controller/Action/Helper/ReturnParams.php b/library/Application/Controller/Action/Helper/ReturnParams.php index f4338c9bd2..d31b0fc6fa 100644 --- a/library/Application/Controller/Action/Helper/ReturnParams.php +++ b/library/Application/Controller/Action/Helper/ReturnParams.php @@ -51,7 +51,7 @@ class Application_Controller_Action_Helper_ReturnParams extends \Zend_Controller public function getReturnParameters() { // TODO put into constructor - $log = Log::get(); + $log = Log::get(); $params = []; foreach (\Zend_Controller_Front::getInstance()->getRequest()->getUserParams() as $key => $value) { diff --git a/library/Application/Controller/Action/Helper/Workflow.php b/library/Application/Controller/Action/Helper/Workflow.php index 861faf3926..17b2eb06ae 100644 --- a/library/Application/Controller/Action/Helper/Workflow.php +++ b/library/Application/Controller/Action/Helper/Workflow.php @@ -92,7 +92,7 @@ public function isTransitionAllowed($document, $targetState) */ public function getAllowedTargetStatesForDocument($document) { - $logger = Log::get(); + $logger = Log::get(); $currentState = $document->getServerState(); diff --git a/library/Application/Form/Validate/DuplicateValue.php b/library/Application/Form/Validate/DuplicateValue.php index f9e5868dd3..445580fd9f 100644 --- a/library/Application/Form/Validate/DuplicateValue.php +++ b/library/Application/Form/Validate/DuplicateValue.php @@ -115,9 +115,9 @@ public function isValid($value, $context = null) if (! ($this->_position < $valueCount)) { Log::get()->err( - __CLASS__ . - ' mit Position > count(values) konstruiert.' - ); + __CLASS__ . + ' mit Position > count(values) konstruiert.' + ); } if (! is_null($this->_values)) { diff --git a/modules/admin/models/IndexMaintenance.php b/modules/admin/models/IndexMaintenance.php index b1f2819b41..21805a6c13 100644 --- a/modules/admin/models/IndexMaintenance.php +++ b/modules/admin/models/IndexMaintenance.php @@ -51,7 +51,7 @@ class Admin_Model_IndexMaintenance public function __construct($logger = null) { $this->_config = Config::get(); - $this->_logger = (is_null($logger)) ? Log::get() : $logger; + $this->_logger = (is_null($logger)) ? Log::get() : $logger; $this->setFeatureDisabled(); if ($this->_featureDisabled) { diff --git a/modules/admin/models/UrnGenerator.php b/modules/admin/models/UrnGenerator.php index df8710d91f..d8d542c283 100644 --- a/modules/admin/models/UrnGenerator.php +++ b/modules/admin/models/UrnGenerator.php @@ -76,7 +76,7 @@ public function generateUrnForDocument($docId) $identifierUrn = new Urn($this->nid, $this->nss); $urn = $identifierUrn->getUrn($docId); - $log = Log::get(); + $log = Log::get(); $log->debug('URN generation result for document ' . $docId . ' is ' . $urn); return $urn; diff --git a/modules/home/models/HelpFiles.php b/modules/home/models/HelpFiles.php index 5afd112ab9..038395009c 100644 --- a/modules/home/models/HelpFiles.php +++ b/modules/home/models/HelpFiles.php @@ -148,7 +148,7 @@ private function getHelpConfig() $config = new \Zend_Config_Ini($filePath); } catch (\Zend_Config_Exception $zce) { // TODO einfachere Lösung? - $logger = Log::get(); + $logger = Log::get(); if (! is_null($logger)) { $logger->err("could not load help configuration", $zce); } diff --git a/modules/oai/models/Request.php b/modules/oai/models/Request.php index 42ee80524a..ed7b135d1c 100644 --- a/modules/oai/models/Request.php +++ b/modules/oai/models/Request.php @@ -394,7 +394,7 @@ public function setResumptionPath($path) */ public function validate(array $oaiRequest) { - $logger = Log::get(); + $logger = Log::get(); $errorInformation = [ 'message' => 'General oai request validation error.', diff --git a/modules/publish/models/DocumentWorkflowSubmitterId.php b/modules/publish/models/DocumentWorkflowSubmitterId.php index a4d4410003..d5551ea1a9 100644 --- a/modules/publish/models/DocumentWorkflowSubmitterId.php +++ b/modules/publish/models/DocumentWorkflowSubmitterId.php @@ -47,7 +47,7 @@ protected function initializeDocument() $userId = trim($loggedUserModel->getUserId()); if (empty($userId)) { - $logger = Log::get(); + $logger = Log::get(); $logger->debug("No user logged in. Skipping enrichment."); return; } diff --git a/modules/publish/models/DocumenttypeParser.php b/modules/publish/models/DocumenttypeParser.php index 840c0eecd2..937ad604d9 100644 --- a/modules/publish/models/DocumenttypeParser.php +++ b/modules/publish/models/DocumenttypeParser.php @@ -70,7 +70,7 @@ class Publish_Model_DocumenttypeParser extends Application_Model_Abstract */ public function __construct($dom, $form, $additionalFields = [], $postValues = []) { - $this->_log = Log::get(); + $this->_log = Log::get(); $this->_session = new \Zend_Session_Namespace('Publish'); $this->form = $form; $this->dom = $dom; diff --git a/modules/publish/models/FormElement.php b/modules/publish/models/FormElement.php index d7e04c67bc..8d88c6e817 100644 --- a/modules/publish/models/FormElement.php +++ b/modules/publish/models/FormElement.php @@ -78,7 +78,7 @@ public function __construct( ) { $this->session = new \Zend_Session_Namespace('Publish'); $this->sessionOpus = new \Zend_Session_Namespace(); - $this->log = Log::get(); + $this->log = Log::get(); $this->form = $form; $this->_elementName = $name; diff --git a/modules/publish/models/LoggedUser.php b/modules/publish/models/LoggedUser.php index b07753e53d..4d9b6cb717 100644 --- a/modules/publish/models/LoggedUser.php +++ b/modules/publish/models/LoggedUser.php @@ -44,7 +44,7 @@ class Publish_Model_LoggedUser public function __construct() { - $this->_log = Log::get(); + $this->_log = Log::get(); $login = \Zend_Auth::getInstance()->getIdentity(); if (is_null($login) or trim($login) == '') { diff --git a/modules/review/models/ClearDocumentsHelper.php b/modules/review/models/ClearDocumentsHelper.php index 0053b7539f..cec8ac29ac 100644 --- a/modules/review/models/ClearDocumentsHelper.php +++ b/modules/review/models/ClearDocumentsHelper.php @@ -55,7 +55,7 @@ class Review_Model_ClearDocumentsHelper */ public function clear(array $docIds = null, $userId = null, $person = null) { - $logger = Log::get(); + $logger = Log::get(); foreach ($docIds as $docId) { $logger->debug('Change state to "published" for document: ' . $docId); @@ -99,7 +99,7 @@ public function clear(array $docIds = null, $userId = null, $person = null) */ public function reject(array $docIds = null, $userId = null, $person = null) { - $logger = Log::get(); + $logger = Log::get(); foreach ($docIds as $docId) { $logger->debug('Deleting document with id: ' . $docId); diff --git a/modules/sword/controllers/DepositController.php b/modules/sword/controllers/DepositController.php index dd921a5ee6..1f771e7899 100644 --- a/modules/sword/controllers/DepositController.php +++ b/modules/sword/controllers/DepositController.php @@ -123,7 +123,7 @@ public function postAction() // im Archiv befindet sich keine Datei opus.xml oder die Datei ist leer $errorDoc = new Sword_Model_ErrorDocument($request, $response); $errorDoc->setMissingXml(); - } else if ($statusDoc->noDocImported()) { + } elseif ($statusDoc->noDocImported()) { // im Archiv befindet sich zwar ein nicht leeres opus.xml; es // konnte aber kein Dokument erfolgreich importiert werden $errorDoc = new Sword_Model_ErrorDocument($request, $response); @@ -171,7 +171,7 @@ private function maxUploadSizeExceeded($payload) $maxUploadSize = (new Application_Configuration_MaxUploadSize())->getMaxUploadSizeInByte(); if ($size > $maxUploadSize) { - $log = Log::get(); + $log = Log::get(); $log->warn('current package size ' . $size . ' exceeds the maximum upload size ' . $maxUploadSize); return true; } diff --git a/modules/sword/models/ErrorDocument.php b/modules/sword/models/ErrorDocument.php index 85934349eb..359850ba9b 100644 --- a/modules/sword/models/ErrorDocument.php +++ b/modules/sword/models/ErrorDocument.php @@ -48,7 +48,7 @@ public function __construct($request, $response) { $this->request = $request; $this->response = $response; - $this->logger = Log::get(); + $this->logger = Log::get(); } /** diff --git a/modules/sword/models/ImportCollection.php b/modules/sword/models/ImportCollection.php index b2124927ea..85e124ed43 100644 --- a/modules/sword/models/ImportCollection.php +++ b/modules/sword/models/ImportCollection.php @@ -45,7 +45,7 @@ class Sword_Model_ImportCollection public function __construct() { - $logger = Log::get(); + $logger = Log::get(); $config = Config::get(); $collectionNumber = $config->sword->collection->default->number; diff --git a/tests/library/Application/Controller/Action/Helper/AbstractTest.php b/tests/library/Application/Controller/Action/Helper/AbstractTest.php index ac1fb1b9cb..2607bb3ff4 100644 --- a/tests/library/Application/Controller/Action/Helper/AbstractTest.php +++ b/tests/library/Application/Controller/Action/Helper/AbstractTest.php @@ -53,6 +53,6 @@ public function testGetLogger() $logger = $helper->getLogger(); $this->assertInstanceOf(\Zend_Log::class, $logger); - $this->assertEquals( Log::get(), $logger); + $this->assertEquals(Log::get(), $logger); } } diff --git a/tests/library/Application/Form/AbstractTest.php b/tests/library/Application/Form/AbstractTest.php index 336d9c9541..4c15c68e2a 100644 --- a/tests/library/Application/Form/AbstractTest.php +++ b/tests/library/Application/Form/AbstractTest.php @@ -268,6 +268,6 @@ public function testSetApplicationConfig() $returnedConfig = $this->form->getApplicationConfig(); - $this->assertSame( $this->getConfig(), $returnedConfig); + $this->assertSame($this->getConfig(), $returnedConfig); } } diff --git a/tests/library/Application/Form/Decorator/FileHashTest.php b/tests/library/Application/Form/Decorator/FileHashTest.php index 3fda2cde5b..0b4b5c54cf 100644 --- a/tests/library/Application/Form/Decorator/FileHashTest.php +++ b/tests/library/Application/Form/Decorator/FileHashTest.php @@ -142,7 +142,7 @@ public function testRenderWithMissingFile() public function testRenderWithFileTooBig() { $this->useEnglish(); - $config = $this->getConfig(); + $config = $this->getConfig(); $config->merge(new \Zend_Config(['checksum' => ['maxVerificationSize' => '0']])); $element = new Application_Form_Element_FileHash('name'); diff --git a/tests/library/Application/Util/NotificationTest.php b/tests/library/Application/Util/NotificationTest.php index 2c546c8b71..cf9ff7d787 100644 --- a/tests/library/Application/Util/NotificationTest.php +++ b/tests/library/Application/Util/NotificationTest.php @@ -54,9 +54,9 @@ public function setUp() { parent::setUp(); $this->notification = new Application_Util_Notification(); - $this->logger = Log::get(); + $this->logger = Log::get(); // add required config keys - $this->config = $this->getConfig(); + $this->config = $this->getConfig(); $this->config->notification->document->submitted->enabled = self::CONFIG_VALUE_TRUE; $this->config->notification->document->published->enabled = self::CONFIG_VALUE_TRUE; $this->config->notification->document->submitted->subject = 'Dokument #%1$s eingestellt: %2$s : %3$s'; diff --git a/tests/library/Application/Util/PublicationNotificationTest.php b/tests/library/Application/Util/PublicationNotificationTest.php index e40f458a80..020716a022 100644 --- a/tests/library/Application/Util/PublicationNotificationTest.php +++ b/tests/library/Application/Util/PublicationNotificationTest.php @@ -53,7 +53,7 @@ public function setUp() { parent::setUp(); $this->notification = new Application_Util_PublicationNotification(); - $this->logger = Log::get(); + $this->logger = Log::get(); // add required config keys $this->config = Config::get(); $this->config->notification->document->submitted->enabled = self::CONFIG_VALUE_TRUE; diff --git a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php index 26e55b934f..c0f3ca0320 100644 --- a/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php +++ b/tests/modules/admin/controllers/EnrichmentkeyControllerTest.php @@ -1316,7 +1316,7 @@ public function testGetUnmanaged() if (strpos($textContent, 'unmanagedEKfirst') === 0) { $foundFirst = true; continue; - } else if ($foundFirst) { + } elseif ($foundFirst) { if (strpos($textContent, 'unmanagedEKlast') === 0) { $foundLast = true; } @@ -1380,7 +1380,7 @@ public function testGetManaged() if (strpos($textContent, 'managedEKfirst') === 0) { $foundFirst = true; continue; - } else if ($foundFirst) { + } elseif ($foundFirst) { if (strpos($textContent, 'managedEKlast') === 0) { $foundLast = true; } diff --git a/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php b/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php index f917ad34e6..d1d2ad9beb 100644 --- a/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php +++ b/tests/modules/admin/controllers/IndexmaintenanceControllerTest.php @@ -296,7 +296,7 @@ public function testCheckconsistencyActionResult() * run job immediately and check for result */ $jobrunner = new Runner(); - $jobrunner->setLogger( Log::get()); + $jobrunner->setLogger(Log::get()); $worker = new Opus\Search\Task\ConsistencyCheck(); $jobrunner->registerWorker($worker); $jobrunner->run(); diff --git a/tests/modules/admin/controllers/InfoControllerTest.php b/tests/modules/admin/controllers/InfoControllerTest.php index 5de7dbb1bb..957339f5da 100644 --- a/tests/modules/admin/controllers/InfoControllerTest.php +++ b/tests/modules/admin/controllers/InfoControllerTest.php @@ -62,7 +62,7 @@ public function testVersionWithOldVersion() $versionHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('version'); $versionHelper->setVersion('4.6'); - $config = $this->getConfig(); + $config = $this->getConfig(); $oldVersion = $config->version; $config->version = '4.5-TEST'; $this->dispatch('admin/info/update'); diff --git a/tests/modules/admin/models/IndexMaintenanceTest.php b/tests/modules/admin/models/IndexMaintenanceTest.php index 3504228e6f..98351429ed 100644 --- a/tests/modules/admin/models/IndexMaintenanceTest.php +++ b/tests/modules/admin/models/IndexMaintenanceTest.php @@ -176,7 +176,7 @@ private function runJobImmediately() $this->assertEquals(1, Job::getCountForLabel(Opus\Search\Task\ConsistencyCheck::LABEL)); $jobrunner = new Runner; - $jobrunner->setLogger( Log::get()); + $jobrunner->setLogger(Log::get()); $worker = new Opus\Search\Task\ConsistencyCheck(); $jobrunner->registerWorker($worker); $jobrunner->run(); diff --git a/tests/modules/export/Marc21ExportTest.php b/tests/modules/export/Marc21ExportTest.php index 49a390fa99..5d1c9ecf6d 100644 --- a/tests/modules/export/Marc21ExportTest.php +++ b/tests/modules/export/Marc21ExportTest.php @@ -55,8 +55,7 @@ public function testMarc21XmlExportWithUnpublishedDocNotAllowed() ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] ] - ] - ); + ]); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); @@ -87,8 +86,7 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForAdmin() ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] ] - ] - ); + ]); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); @@ -124,8 +122,7 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForNonAdminUserWithP ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] ] - ] - ); + ]); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); @@ -198,8 +195,7 @@ public function testMarc21XmlExportWithPublishedDocAllowedForAdmin() ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_TRUE]] ] - ] - ); + ]); $doc = $this->createTestDocument(); $doc->setServerState('published'); @@ -242,8 +238,7 @@ public function testMarc21XmlExportWithPublishedDocAllowedForGuest() ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] ] - ] - ); + ]); $doc = $this->createTestDocument(); $doc->setServerState('published'); @@ -284,8 +279,7 @@ public function testMarc21XmlExportWithUnpublishedDocAllowedForNonAdminUserWitho ['export' => ['marc21' => ['adminOnly' => self::CONFIG_VALUE_FALSE]] ] - ] - ); + ]); $doc = $this->createTestDocument(); $doc->setServerState('unpublished'); diff --git a/tests/modules/publish/controllers/DepositControllerTest.php b/tests/modules/publish/controllers/DepositControllerTest.php index 74fae2ad7d..9bd4ea0c0e 100644 --- a/tests/modules/publish/controllers/DepositControllerTest.php +++ b/tests/modules/publish/controllers/DepositControllerTest.php @@ -230,7 +230,7 @@ public function testStoreExistingDocument() $doc->setServerState('published'); $doc->setType('preprint'); - $log = Log::get(); + $log = Log::get(); $deposit = new Publish_Model_Deposit($log); $deposit->storeDocument($doc->store()); } diff --git a/tests/modules/publish/models/DepositTest.php b/tests/modules/publish/models/DepositTest.php index 4f6c00e9e2..d5c81f44bb 100644 --- a/tests/modules/publish/models/DepositTest.php +++ b/tests/modules/publish/models/DepositTest.php @@ -64,7 +64,7 @@ public function testInvalidDocumentState() $document->setServerState('published'); $documentId = $document->store(); - $log = Log::get(); + $log = Log::get(); $deposit = new Publish_Model_Deposit($log); $deposit->storeDocument($documentId); } @@ -140,7 +140,7 @@ public function testValidDocumentData() 'Foo2Title' => ['value' => 'title as enrichment', 'datatype' => 'Enrichment', 'subfield' => '0'], ]; - $log = Log::get(); + $log = Log::get(); $dep = new Publish_Model_Deposit($log); $dep->storeDocument($docId, null, $data); diff --git a/tests/support/TestCase.php b/tests/support/TestCase.php index a13ed753cf..3204ad6bf0 100644 --- a/tests/support/TestCase.php +++ b/tests/support/TestCase.php @@ -139,7 +139,7 @@ public function resetAutoloader() */ protected function closeLogfile() { - $log = Log::get(); + $log = Log::get(); if (isset($log)) { $log->__destruct(); From 6543a09f77cf37c9dd2f494abaadb2d625c4a551 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 2 Mar 2021 17:08:48 +0100 Subject: [PATCH 122/270] OPUSVIER-4518 Remove using 'Zend_Log' in registry --- modules/admin/views/scripts/actionbox.phtml | 4 +++- modules/admin/views/scripts/docinfo.phtml | 4 +++- modules/admin/views/scripts/docstatus.phtml | 4 +++- modules/admin/views/scripts/infobox.phtml | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/admin/views/scripts/actionbox.phtml b/modules/admin/views/scripts/actionbox.phtml index 60ee0594a5..64331dc18e 100644 --- a/modules/admin/views/scripts/actionbox.phtml +++ b/modules/admin/views/scripts/actionbox.phtml @@ -40,6 +40,8 @@ * If Javascript is enabled the box will remain at the top of the window even when scrolling * further down the page to make the functions always easily available to an administrator. */ + +use Opus\Log; ?> -err('Use of partial \'actionbox.phtml\' without document.'); ?> +err('Use of partial \'actionbox.phtml\' without document.'); ?> diff --git a/modules/admin/views/scripts/docinfo.phtml b/modules/admin/views/scripts/docinfo.phtml index 7b6b90a816..3509fd8144 100644 --- a/modules/admin/views/scripts/docinfo.phtml +++ b/modules/admin/views/scripts/docinfo.phtml @@ -29,6 +29,8 @@ * @copyright Copyright (c) 2008-2018, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ + +use Opus\Log; ?> document)) : ?> @@ -40,6 +42,6 @@ -err('Use of partial \'docinfo.phtml\' without document = null.'); ?> +err('Use of partial \'docinfo.phtml\' without document = null.'); ?> diff --git a/modules/admin/views/scripts/docstatus.phtml b/modules/admin/views/scripts/docstatus.phtml index 76a33f60c0..ded41a9fbf 100644 --- a/modules/admin/views/scripts/docstatus.phtml +++ b/modules/admin/views/scripts/docstatus.phtml @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License * @version $Id$ */ + +use Opus\Log; ?> document)) : ?> @@ -44,6 +46,6 @@ -err('Use of partial \'docstatus.phtml\' without document = null.'); ?> +err('Use of partial \'docstatus.phtml\' without document = null.'); ?> diff --git a/modules/admin/views/scripts/infobox.phtml b/modules/admin/views/scripts/infobox.phtml index a29c3a3520..168c72841c 100644 --- a/modules/admin/views/scripts/infobox.phtml +++ b/modules/admin/views/scripts/infobox.phtml @@ -30,6 +30,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License * @version $Id$ */ + +use Opus\Log; ?> element->getDocument()) ?> @@ -43,6 +45,6 @@ -err('Use of partial \'docinfo.phtml\' without document = null.'); ?> +err('Use of partial \'docinfo.phtml\' without document = null.'); ?> From 532e427ec38d57be4d2b4c905d8faa922e57ab99 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 2 Mar 2021 17:10:15 +0100 Subject: [PATCH 123/270] OPUSVIER-4518 Remove Zend_Registry usage for translation --- library/Application/Configuration.php | 2 +- library/Application/Form/Element/DocumentType.php | 4 ++-- library/Application/Form/Element/Position.php | 2 +- .../Form/Element/SupportedLanguages.php | 2 +- .../Form/Element/TranslationModules.php | 2 +- library/Application/Form/Translations.php | 4 ++-- library/Application/Search/Facet.php | 2 +- .../Application/Translate/TranslationManager.php | 2 +- .../Application/View/Helper/DocumentAbstract.php | 2 +- library/Application/View/Helper/DocumentTitle.php | 2 +- .../Application/View/Helper/FormTranslation.php | 2 +- .../Application/View/Helper/LanguageSelector.php | 4 ++-- library/Application/View/Helper/Locale.php | 2 +- .../views/scripts/collectionroles/index.phtml | 2 +- modules/home/controllers/IndexController.php | 2 +- modules/home/models/HelpFiles.php | 4 ++-- modules/publish/controllers/IndexController.php | 2 +- modules/setup/controllers/LanguageController.php | 2 +- modules/setup/forms/FaqItem.php | 2 +- modules/setup/forms/Translation.php | 2 +- modules/setup/forms/TranslationValues.php | 2 +- public/layouts/default/common.phtml | 2 +- public/layouts/opus4/common.phtml | 2 +- .../Controller/Action/Helper/DocumentTypesTest.php | 2 +- .../Controller/Action/Helper/TranslationTest.php | 2 +- .../Controller/Action/Helper/WorkflowTest.php | 2 +- .../Application/Controller/ActionCRUDTest.php | 2 +- .../Application/Form/Decorator/FileHashTest.php | 4 ++-- .../Application/Form/Decorator/UpdateFieldTest.php | 2 +- .../Form/Element/CollectionDisplayFormatTest.php | 2 +- .../Application/Form/Element/EnrichmentKeyTest.php | 2 +- .../Application/Form/Element/LanguageScopeTest.php | 2 +- .../Application/Form/Element/LanguageTypeTest.php | 2 +- .../Application/Form/Element/NumberTest.php | 2 +- .../Application/Form/Element/SortOrderTest.php | 2 +- .../Application/Form/Element/TranslationTest.php | 2 +- .../Application/Form/Validate/IdentifierTest.php | 2 +- .../Form/Validate/SeriesNumberAvailableTest.php | 2 +- tests/library/Application/TranslateTest.php | 14 +++++++------- tests/modules/ControllerTestCaseTest.php | 6 +++--- tests/modules/LanguageTest.php | 2 +- .../admin/controllers/DocumentControllerTest.php | 4 ++-- .../admin/forms/Document/EnrichmentTest.php | 4 ++-- tests/modules/admin/forms/Document/FilesTest.php | 2 +- tests/modules/setup/forms/TranslationTest.php | 2 +- .../forms/Validate/TranslationKeyFormatTest.php | 2 +- tests/support/ControllerTestCase.php | 8 ++++---- 47 files changed, 65 insertions(+), 65 deletions(-) diff --git a/library/Application/Configuration.php b/library/Application/Configuration.php index 42a9218832..a82a443c93 100644 --- a/library/Application/Configuration.php +++ b/library/Application/Configuration.php @@ -329,7 +329,7 @@ public static function clearInstance() */ public function getTranslate() { - return \Zend_Registry::get('Zend_Translate'); + return Application_Translate::getInstance(); } public static function isUpdateInProgress() diff --git a/library/Application/Form/Element/DocumentType.php b/library/Application/Form/Element/DocumentType.php index e29191c2ae..a315156b29 100644 --- a/library/Application/Form/Element/DocumentType.php +++ b/library/Application/Form/Element/DocumentType.php @@ -51,7 +51,7 @@ public function init() $this->setDisableTranslator(true); - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); foreach ($options as $index => $type) { if (! is_null($translator) && $translator->isTranslated($index)) { @@ -69,7 +69,7 @@ public function setValue($value) { $option = $this->getMultiOption($value); - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); if (! is_null($translator) && $translator->isTranslated($value)) { $label = $translator->translate($value); diff --git a/library/Application/Form/Element/Position.php b/library/Application/Form/Element/Position.php index 0b96defc4f..4b9f1befd4 100644 --- a/library/Application/Form/Element/Position.php +++ b/library/Application/Form/Element/Position.php @@ -44,7 +44,7 @@ public function init() $allCollectionRoles = CollectionRole::fetchAll(); - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); foreach ($allCollectionRoles as $collectionRole) { $position = $collectionRole->getPosition(); diff --git a/library/Application/Form/Element/SupportedLanguages.php b/library/Application/Form/Element/SupportedLanguages.php index e0b2305962..7a51dba14e 100644 --- a/library/Application/Form/Element/SupportedLanguages.php +++ b/library/Application/Form/Element/SupportedLanguages.php @@ -96,7 +96,7 @@ public function loadDefaultDecorators() */ public function getLanguageOptions() { - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $currentLocale = new \Zend_Locale($translator->getLocale()); diff --git a/library/Application/Form/Element/TranslationModules.php b/library/Application/Form/Element/TranslationModules.php index ae3729d87d..6fd2420447 100644 --- a/library/Application/Form/Element/TranslationModules.php +++ b/library/Application/Form/Element/TranslationModules.php @@ -48,7 +48,7 @@ public function init() $modules = $manager->getModules(); - $translator = \Zend_Registry::get('Zend_Translate'); // TODO bad design (external, hidden dependency) + $translator = Application_Translate::getInstance(); // TODO bad design (external, hidden dependency) array_unshift($modules, $translator->translate('default_all')); diff --git a/library/Application/Form/Translations.php b/library/Application/Form/Translations.php index 085a0dbb77..28de872c1d 100644 --- a/library/Application/Form/Translations.php +++ b/library/Application/Form/Translations.php @@ -143,7 +143,7 @@ public function populateFromTranslations() { $elements = $this->getTranslationElements(); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); foreach ($elements as $name => $element) { // TODO handle no translation @@ -162,7 +162,7 @@ public function updateTranslations() $element->updateTranslations($key); } - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $translate->clearCache(); \Zend_Translate::clearCache(); } diff --git a/library/Application/Search/Facet.php b/library/Application/Search/Facet.php index c305087398..79cabd7429 100644 --- a/library/Application/Search/Facet.php +++ b/library/Application/Search/Facet.php @@ -205,7 +205,7 @@ public function setTranslated($translated) public function getTranslator() { - return \Zend_Registry::get('Zend_Translate'); + return Application_Translate::getInstance(); } public function setTranslationPrefix($prefix) diff --git a/library/Application/Translate/TranslationManager.php b/library/Application/Translate/TranslationManager.php index 2873dd087a..dd40d30d51 100644 --- a/library/Application/Translate/TranslationManager.php +++ b/library/Application/Translate/TranslationManager.php @@ -621,7 +621,7 @@ public function deleteAll() public function clearCache() { if (\Zend_Registry::isRegistered('Zend_Translate')) { - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $translate->clearCache(); } } diff --git a/library/Application/View/Helper/DocumentAbstract.php b/library/Application/View/Helper/DocumentAbstract.php index 02cee7b94b..1ecf8e2d19 100644 --- a/library/Application/View/Helper/DocumentAbstract.php +++ b/library/Application/View/Helper/DocumentAbstract.php @@ -48,7 +48,7 @@ class Application_View_Helper_DocumentAbstract extends Application_View_Helper_D public function documentAbstract($document = null) { if ($this->isPreferUserInterfaceLanguage()) { - $language = Language::getPart2tForPart1(\Zend_Registry::get('Zend_Translate')->getLocale()); + $language = Language::getPart2tForPart1(Application_Translate::getInstance()->getLocale()); $abstract = $document->getMainAbstract($language); } else { diff --git a/library/Application/View/Helper/DocumentTitle.php b/library/Application/View/Helper/DocumentTitle.php index 3ad4817f66..54953238e0 100644 --- a/library/Application/View/Helper/DocumentTitle.php +++ b/library/Application/View/Helper/DocumentTitle.php @@ -55,7 +55,7 @@ class Application_View_Helper_DocumentTitle extends Application_View_Helper_Docu public function documentTitle($document = null) { if ($this->isPreferUserInterfaceLanguage()) { - $language = Language::getPart2tForPart1(\Zend_Registry::get('Zend_Translate')->getLocale()); + $language = Language::getPart2tForPart1(Application_Translate::getInstance()->getLocale()); $title = $document->getMainTitle($language); } else { diff --git a/library/Application/View/Helper/FormTranslation.php b/library/Application/View/Helper/FormTranslation.php index d64f8af057..af42fb3b95 100644 --- a/library/Application/View/Helper/FormTranslation.php +++ b/library/Application/View/Helper/FormTranslation.php @@ -81,7 +81,7 @@ public function formTranslation($name, $value = null, $attribs = null, $options $filter = new \Zend_Filter_PregReplace($pattern, ''); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $name = $this->view->escape($name); diff --git a/library/Application/View/Helper/LanguageSelector.php b/library/Application/View/Helper/LanguageSelector.php index 38151b4feb..bb2f0ee602 100644 --- a/library/Application/View/Helper/LanguageSelector.php +++ b/library/Application/View/Helper/LanguageSelector.php @@ -52,12 +52,12 @@ public function languageSelector() } $returnParams = \Zend_Controller_Action_HelperBroker::getStaticHelper('ReturnParams'); - $currentLocale = new \Zend_Locale(\Zend_Registry::get('Zend_Translate')->getLocale()); + $currentLocale = new \Zend_Locale(Application_Translate::getInstance()->getLocale()); $configHelper = new Application_Configuration(); // only show languages that are present in resources and activated in configuration - $translations = \Zend_Registry::get('Zend_Translate')->getList(); + $translations = Application_Translate::getInstance()->getList(); $supportedLang = $configHelper->getActivatedLanguages(); $translations = array_intersect($translations, $supportedLang); diff --git a/library/Application/View/Helper/Locale.php b/library/Application/View/Helper/Locale.php index 4e6878d500..7d3698d599 100644 --- a/library/Application/View/Helper/Locale.php +++ b/library/Application/View/Helper/Locale.php @@ -42,6 +42,6 @@ class Application_View_Helper_Locale extends Application_View_Helper_Abstract */ public function locale() { - return \Zend_Registry::get('Zend_Translate')->getLocale(); + return Application_Translate::getInstance()->getLocale(); } } diff --git a/modules/admin/views/scripts/collectionroles/index.phtml b/modules/admin/views/scripts/collectionroles/index.phtml index a0dddf0073..a904b050eb 100644 --- a/modules/admin/views/scripts/collectionroles/index.phtml +++ b/modules/admin/views/scripts/collectionroles/index.phtml @@ -52,7 +52,7 @@ collectionRoles as $i => $collectionRole) : $translatelabel = 'default_collection_role_' . $collectionRole->getName(); diff --git a/modules/home/controllers/IndexController.php b/modules/home/controllers/IndexController.php index c65072d800..2220dd6ff3 100644 --- a/modules/home/controllers/IndexController.php +++ b/modules/home/controllers/IndexController.php @@ -128,7 +128,7 @@ public function languageAction() $appConfig = new Application_Configuration(); if ($appConfig->isLanguageSelectionEnabled() && ! is_null($language) - && \Zend_Registry::get('Zend_Translate')->isAvailable($language)) { + && Application_Translate::getInstance()->isAvailable($language)) { $sessiondata = new \Zend_Session_Namespace(); $sessiondata->language = $language; } diff --git a/modules/home/models/HelpFiles.php b/modules/home/models/HelpFiles.php index 038395009c..c3f8e84e48 100644 --- a/modules/home/models/HelpFiles.php +++ b/modules/home/models/HelpFiles.php @@ -73,7 +73,7 @@ public function getHelpPath() */ public function getContent($key) { - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $translationKey = "help_content_$key"; $translation = $translate->translate($translationKey); @@ -179,7 +179,7 @@ public function setHelpPath($path) public function isContentAvailable($key) { - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $translationKey = "help_content_$key"; diff --git a/modules/publish/controllers/IndexController.php b/modules/publish/controllers/IndexController.php index 1f5af1dcb3..9785ec4685 100644 --- a/modules/publish/controllers/IndexController.php +++ b/modules/publish/controllers/IndexController.php @@ -83,7 +83,7 @@ public function indexAction() } // Quick bug fix for OPUSVIER-3564 - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); if ($translate->isTranslated('tooltip_documentType')) { $this->view->documentType['hint'] = 'tooltip_documentType'; } diff --git a/modules/setup/controllers/LanguageController.php b/modules/setup/controllers/LanguageController.php index dbec35710c..d68aa30c88 100644 --- a/modules/setup/controllers/LanguageController.php +++ b/modules/setup/controllers/LanguageController.php @@ -241,7 +241,7 @@ public function editAction() if ($form->isValid($post)) { $form->updateTranslation(); $form = null; - \Zend_Registry::get('Zend_Translate')->clearCache(); // TODO encapsulate + Application_Translate::getInstance()->clearCache(); // TODO encapsulate } else { // TODO go back to form } diff --git a/modules/setup/forms/FaqItem.php b/modules/setup/forms/FaqItem.php index a5d7455b9d..107daa6810 100644 --- a/modules/setup/forms/FaqItem.php +++ b/modules/setup/forms/FaqItem.php @@ -63,7 +63,7 @@ public function setName($name) $this->getElement(self::ELEMENT_ID)->setValue($name); $this->getElement(self::ELEMENT_NAME)->setValue($name); - $manager = \Zend_Registry::get('Zend_Translate'); + $manager = Application_Translate::getInstance(); $translations = $manager->getTranslations("help_title_$name"); $this->getElement(self::ELEMENT_QUESTION)->setValue($translations); diff --git a/modules/setup/forms/Translation.php b/modules/setup/forms/Translation.php index 26a2405135..b8fa6cdba1 100644 --- a/modules/setup/forms/Translation.php +++ b/modules/setup/forms/Translation.php @@ -251,6 +251,6 @@ public function disableKeyEditing() */ protected function getTranslationManager() { - return \Zend_Registry::get('Zend_Translate'); + return Application_Translate::getInstance(); } } diff --git a/modules/setup/forms/TranslationValues.php b/modules/setup/forms/TranslationValues.php index 8c7db0970a..6d6a352917 100644 --- a/modules/setup/forms/TranslationValues.php +++ b/modules/setup/forms/TranslationValues.php @@ -49,7 +49,7 @@ public function init() [['Wrapper' => 'HtmlTag'], ['class' => 'row']] ]); - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $languages = $this->getLanguages(); diff --git a/public/layouts/default/common.phtml b/public/layouts/default/common.phtml index 45fdc9815f..64726b5d8c 100755 --- a/public/layouts/default/common.phtml +++ b/public/layouts/default/common.phtml @@ -37,7 +37,7 @@ use Opus\Config; $config = Config::get(); -$pageLanguage = \Zend_Registry::get('Zend_Translate')->getLocale(); +$pageLanguage = Application_Translate::getInstance()->getLocale(); $this->headMeta() ->prependHttpEquiv('Content-Type', 'text/html; charset=UTF-8') diff --git a/public/layouts/opus4/common.phtml b/public/layouts/opus4/common.phtml index 7b68e607f5..5e511472fe 100644 --- a/public/layouts/opus4/common.phtml +++ b/public/layouts/opus4/common.phtml @@ -37,7 +37,7 @@ use Opus\Config; $config = Config::get(); -$pageLanguage = \Zend_Registry::get('Zend_Translate')->getLocale(); +$pageLanguage = Application_Translate::getInstance()->getLocale(); /** * Prevent indexing and following of links by web crawlers. Dynamic search pages should not be indexed, since their diff --git a/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php b/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php index 792e26a7e1..24006f311d 100644 --- a/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php +++ b/tests/library/Application/Controller/Action/Helper/DocumentTypesTest.php @@ -236,7 +236,7 @@ public function testGetDocumentTypesWithPathNotSet() public function testTranslationOfDocumentTypes() { $excludeFromTranslationCheck = ['demo_invalid', 'foobar', 'barbaz', 'bazbar']; - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $documentTypes = $this->docTypeHelper->getDocumentTypes(); diff --git a/tests/library/Application/Controller/Action/Helper/TranslationTest.php b/tests/library/Application/Controller/Action/Helper/TranslationTest.php index 5638278cdf..dc4061c9e8 100644 --- a/tests/library/Application/Controller/Action/Helper/TranslationTest.php +++ b/tests/library/Application/Controller/Action/Helper/TranslationTest.php @@ -61,7 +61,7 @@ public function setUp() { parent::setUp(); - $this->translate = \Zend_Registry::get('Zend_Translate'); + $this->translate = Application_Translate::getInstance(); $this->helper = \Zend_Controller_Action_HelperBroker::getStaticHelper('Translation'); } diff --git a/tests/library/Application/Controller/Action/Helper/WorkflowTest.php b/tests/library/Application/Controller/Action/Helper/WorkflowTest.php index 9a7784e374..42beab64aa 100644 --- a/tests/library/Application/Controller/Action/Helper/WorkflowTest.php +++ b/tests/library/Application/Controller/Action/Helper/WorkflowTest.php @@ -219,7 +219,7 @@ public function testWorkflowTranslationsForStates() { $states = Application_Controller_Action_Helper_Workflow::getAllStates(); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); foreach ($states as $state) { $key = 'admin_workflow_' . $state; diff --git a/tests/library/Application/Controller/ActionCRUDTest.php b/tests/library/Application/Controller/ActionCRUDTest.php index 08f8ddad5d..bd9fb8785b 100644 --- a/tests/library/Application/Controller/ActionCRUDTest.php +++ b/tests/library/Application/Controller/ActionCRUDTest.php @@ -445,7 +445,7 @@ public function testMessagesTranslated() { $messages = $this->controller->getMessages(); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); foreach ($messages as $message) { if (is_array($message)) { diff --git a/tests/library/Application/Form/Decorator/FileHashTest.php b/tests/library/Application/Form/Decorator/FileHashTest.php index 0b4b5c54cf..6f862d8ffc 100644 --- a/tests/library/Application/Form/Decorator/FileHashTest.php +++ b/tests/library/Application/Form/Decorator/FileHashTest.php @@ -135,7 +135,7 @@ public function testRenderWithMissingFile() . '
Expected:1ba50dc8abc619cea3ba39f77c75c0fe
' . '' . '
Actual:' - . \Zend_Registry::get('Zend_Translate')->translate('frontdoor_checksum_not_verified') + . Application_Translate::getInstance()->translate('frontdoor_checksum_not_verified') . '
', $output); } @@ -165,7 +165,7 @@ public function testRenderWithFileTooBig() . '
Expected:1ba50dc8abc619cea3ba39f77c75c0fe
' . '' . '
Actual:' - . \Zend_Registry::get('Zend_Translate')->translate('frontdoor_file_too_big') + . Application_Translate::getInstance()->translate('frontdoor_file_too_big') . '
', $output); } } diff --git a/tests/library/Application/Form/Decorator/UpdateFieldTest.php b/tests/library/Application/Form/Decorator/UpdateFieldTest.php index 441ece86e5..6e3f6a1734 100644 --- a/tests/library/Application/Form/Decorator/UpdateFieldTest.php +++ b/tests/library/Application/Form/Decorator/UpdateFieldTest.php @@ -107,7 +107,7 @@ public function testTranslationGerman() $decorator = new Application_Form_Decorator_UpdateField(); - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $element = new \Zend_Form_Element_Text('city'); $element->setTranslator($translator); diff --git a/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php b/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php index 0a8f7f7711..b9669b74a1 100644 --- a/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php +++ b/tests/library/Application/Form/Element/CollectionDisplayFormatTest.php @@ -69,7 +69,7 @@ public function testOptions() public function testOptionsTranslated() { - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); foreach ($this->keys as $key) { $this->assertTrue($translator->isTranslated($key), "Key '$key' not translated."); diff --git a/tests/library/Application/Form/Element/EnrichmentKeyTest.php b/tests/library/Application/Form/Element/EnrichmentKeyTest.php index e870d8ffad..e0958c3798 100644 --- a/tests/library/Application/Form/Element/EnrichmentKeyTest.php +++ b/tests/library/Application/Form/Element/EnrichmentKeyTest.php @@ -104,7 +104,7 @@ public function testValidation() public function testMessageTranslated() { - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $this->assertTrue($translator->isTranslated('validation_error_unknown_enrichmentkey')); } diff --git a/tests/library/Application/Form/Element/LanguageScopeTest.php b/tests/library/Application/Form/Element/LanguageScopeTest.php index 23b7ce469a..8157114ab4 100644 --- a/tests/library/Application/Form/Element/LanguageScopeTest.php +++ b/tests/library/Application/Form/Element/LanguageScopeTest.php @@ -65,7 +65,7 @@ public function testOptions() public function testOptionsTranslated() { - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); foreach ($this->keys as $key) { $this->assertTrue( diff --git a/tests/library/Application/Form/Element/LanguageTypeTest.php b/tests/library/Application/Form/Element/LanguageTypeTest.php index b5f998de7a..d1fc587749 100644 --- a/tests/library/Application/Form/Element/LanguageTypeTest.php +++ b/tests/library/Application/Form/Element/LanguageTypeTest.php @@ -64,7 +64,7 @@ public function testOptions() public function testOptionsTranslated() { - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); foreach ($this->keys as $key) { $this->assertTrue($translator->isTranslated('Opus_Language_Type_Value_' . $key)); diff --git a/tests/library/Application/Form/Element/NumberTest.php b/tests/library/Application/Form/Element/NumberTest.php index a6d3a96816..11667b7be5 100644 --- a/tests/library/Application/Form/Element/NumberTest.php +++ b/tests/library/Application/Form/Element/NumberTest.php @@ -71,7 +71,7 @@ public function testCustomSize() public function testMessagesTranslated() { - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $this->assertTrue($translator->isTranslated('validation_error_number_tooSmall')); $this->assertTrue($translator->isTranslated('validation_error_number_notBetween')); diff --git a/tests/library/Application/Form/Element/SortOrderTest.php b/tests/library/Application/Form/Element/SortOrderTest.php index a58332c6a2..fffc61b3f0 100644 --- a/tests/library/Application/Form/Element/SortOrderTest.php +++ b/tests/library/Application/Form/Element/SortOrderTest.php @@ -70,7 +70,7 @@ public function testCustomSize() public function testMessagesTranslated() { - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $this->assertTrue($translator->isTranslated('validation_error_int')); $this->assertTrue($translator->isTranslated('validation_error_negative_number')); diff --git a/tests/library/Application/Form/Element/TranslationTest.php b/tests/library/Application/Form/Element/TranslationTest.php index bd5870c182..0fba9ad77c 100644 --- a/tests/library/Application/Form/Element/TranslationTest.php +++ b/tests/library/Application/Form/Element/TranslationTest.php @@ -99,7 +99,7 @@ public function testUpdateTranslationsOnlyIfChanged() $element = new Application_Form_Element_Translation('DisplayName'); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $dao = new \Opus\Translate\Dao(); $dao->remove($key); diff --git a/tests/library/Application/Form/Validate/IdentifierTest.php b/tests/library/Application/Form/Validate/IdentifierTest.php index 7395f95328..95346c34d3 100644 --- a/tests/library/Application/Form/Validate/IdentifierTest.php +++ b/tests/library/Application/Form/Validate/IdentifierTest.php @@ -286,7 +286,7 @@ public function testMessagesKeyValid() */ public function testTranslationExists() { - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $config = Application_Configuration::getInstance()->getConfig(); $validators = $config->identifier->validation->toArray(); foreach ($validators as $key => $val) { diff --git a/tests/library/Application/Form/Validate/SeriesNumberAvailableTest.php b/tests/library/Application/Form/Validate/SeriesNumberAvailableTest.php index 45d5e7fc2f..90e16259ef 100644 --- a/tests/library/Application/Form/Validate/SeriesNumberAvailableTest.php +++ b/tests/library/Application/Form/Validate/SeriesNumberAvailableTest.php @@ -77,7 +77,7 @@ public function testIsValidTrueForThisDocument() public function testMessagesTranslated() { - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $this->assertTrue($translator->isTranslated('admin_series_error_number_exists')); } diff --git a/tests/library/Application/TranslateTest.php b/tests/library/Application/TranslateTest.php index 1855eb4028..a25df12ab9 100644 --- a/tests/library/Application/TranslateTest.php +++ b/tests/library/Application/TranslateTest.php @@ -54,7 +54,7 @@ public function tearDown() public static function tearDownAfterClass() { - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $translate->loadTranslations(true); parent::tearDownAfterClass(); @@ -274,7 +274,7 @@ public function testMixedTranslations() $database = new \Opus\Translate\Dao(); $database->removeAll(); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $translate->clearCache(); $translate->loadTranslations(); @@ -316,7 +316,7 @@ public function testGetTranslations() \Zend_Translate::clearCache(); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $translate->loadTranslations(true); $key = 'default_collection_role_ddc'; @@ -346,7 +346,7 @@ public function testGetTranslations() public function testGetTranslationsUnknownKey() { - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $this->assertNull($translate->getTranslations('unknownkey9999')); } @@ -359,7 +359,7 @@ public function testSetTranslations() $this->assertNull($dao->getTranslation('testkey')); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $data = [ 'en' => 'test key', @@ -387,7 +387,7 @@ public function testFallbackToDefaultLanguage() { $this->useGerman(); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $this->assertInstanceOf('Application_Translate', $translate); @@ -404,7 +404,7 @@ public function testFallbackToDefaultLanguage() $translate->loadTranslations(); // TODO this is currently necessary (not sure why) - \Zend_Registry::get('Zend_Translate')->setLocale('de'); + Application_Translate::getInstance()->setLocale('de'); $this->assertTrue($translate->isTranslated($key)); diff --git a/tests/modules/ControllerTestCaseTest.php b/tests/modules/ControllerTestCaseTest.php index 9e18a34e34..9ca025f046 100644 --- a/tests/modules/ControllerTestCaseTest.php +++ b/tests/modules/ControllerTestCaseTest.php @@ -168,17 +168,17 @@ public function testGetTempFile() public function testDisableEnableTranslation() { - $defaultTranslator = \Zend_Registry::get('Zend_Translate'); + $defaultTranslator = Applicaton_Translate::getInstance(); $this->assertTrue($defaultTranslator->isTranslated('LastName')); $this->disableTranslation(); - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $this->assertFalse($translator->isTranslated('LastName')); $this->enableTranslation(); - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $this->assertTrue($translator->isTranslated('LastName')); $this->assertSame($defaultTranslator, $translator); diff --git a/tests/modules/LanguageTest.php b/tests/modules/LanguageTest.php index 1b81e40ae8..25e583b4fc 100644 --- a/tests/modules/LanguageTest.php +++ b/tests/modules/LanguageTest.php @@ -76,7 +76,7 @@ public function testSetLanguage() { $this->application->bootstrap('translation'); - $translator = \Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $this->useGerman(); diff --git a/tests/modules/admin/controllers/DocumentControllerTest.php b/tests/modules/admin/controllers/DocumentControllerTest.php index b7ddd5d60f..fef38b8e95 100644 --- a/tests/modules/admin/controllers/DocumentControllerTest.php +++ b/tests/modules/admin/controllers/DocumentControllerTest.php @@ -952,7 +952,7 @@ public function testUnableToTranslateForMetadataView() $logger = new MockLogger(); Log::set($logger); - $adapter = \Zend_Registry::get('Zend_Translate')->getAdapter(); + $adapter = Application_Translate::getInstance()->getAdapter(); $options = $adapter->getOptions(); $options['log'] = $logger; $adapter->setOptions($options); @@ -980,7 +980,7 @@ public function testUnableToTranslateForEditForm() $logger = new MockLogger(); Log::set($logger); - $adapter = \Zend_Registry::get('Zend_Translate')->getAdapter(); + $adapter = Application_Translate::getInstance()->getAdapter(); $options = $adapter->getOptions(); $options['log'] = $logger; $adapter->setOptions($options); diff --git a/tests/modules/admin/forms/Document/EnrichmentTest.php b/tests/modules/admin/forms/Document/EnrichmentTest.php index bb54139a88..d9624749ca 100644 --- a/tests/modules/admin/forms/Document/EnrichmentTest.php +++ b/tests/modules/admin/forms/Document/EnrichmentTest.php @@ -1078,7 +1078,7 @@ public function testValidationNoneWithRegexTypeAndValidValue() public function testEnrichmentKeySpecificTranslationWithRegexType() { - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $translate->setTranslations('admin_enrichment_ektest_errorMessage', ['de' => 'de', 'en' => 'en']); $translate->loadTranslations(true); @@ -1109,7 +1109,7 @@ public function testEnrichmentKeySpecificTranslationWithRegexType() public function testEnrichmentKeySpecificTranslationWithSelectType() { - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $translate->setTranslations('admin_enrichment_ektest_errorMessage', ['de' => 'de', 'en' => 'en']); $translate->loadTranslations(true); diff --git a/tests/modules/admin/forms/Document/FilesTest.php b/tests/modules/admin/forms/Document/FilesTest.php index dc4d580ee9..0f9efdb858 100644 --- a/tests/modules/admin/forms/Document/FilesTest.php +++ b/tests/modules/admin/forms/Document/FilesTest.php @@ -85,7 +85,7 @@ public function testColumnLabelTranslations() $header = $property->getValue($form); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); foreach ($header as $column) { if (isset($column['label']) && ! is_null($column['label'])) { diff --git a/tests/modules/setup/forms/TranslationTest.php b/tests/modules/setup/forms/TranslationTest.php index 7883721fb8..13bd4976d1 100644 --- a/tests/modules/setup/forms/TranslationTest.php +++ b/tests/modules/setup/forms/TranslationTest.php @@ -204,7 +204,7 @@ public function testIsValidDuplicateKey() 'de' => 'Deutsch' ], 'admin'); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $translate->loadDatabase(true); $this->assertFalse($form->isValid([ diff --git a/tests/modules/setup/forms/Validate/TranslationKeyFormatTest.php b/tests/modules/setup/forms/Validate/TranslationKeyFormatTest.php index 660d28784c..5835b17dbb 100644 --- a/tests/modules/setup/forms/Validate/TranslationKeyFormatTest.php +++ b/tests/modules/setup/forms/Validate/TranslationKeyFormatTest.php @@ -64,7 +64,7 @@ public function testIsValid($value, $result) public function testMessagesTranslated() { $validator = new Setup_Form_Validate_TranslationKeyFormat(); - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $messageTemplates = $validator->getMessageTemplates(); $key = $messageTemplates[$validator::NOT_MATCH]; $this->assertTrue($translate->isTranslated($key)); diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index 6bbb04a709..0f3a4b23b0 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -396,7 +396,7 @@ public function useGerman() { $session = new \Zend_Session_Namespace(); $session->language = 'de'; - \Zend_Registry::get('Zend_Translate')->setLocale('de'); + Applicaton_Translate::getInstance()->setLocale('de'); Application_Form_Element_Language::initLanguageList(); } @@ -407,7 +407,7 @@ public function useEnglish() { $session = new \Zend_Session_Namespace(); $session->language = 'en'; - \Zend_Registry::get('Zend_Translate')->setLocale('en'); + Applicaton_Translate::getInstance()->setLocale('en'); Application_Form_Element_Language::initLanguageList(); } @@ -637,7 +637,7 @@ public function verifyBreadcrumbDefined($location = null) if (! $breadcrumbDefined) { $breadcrumbDefined = true; - $translate = \Zend_Registry::get('Zend_Translate'); + $translate = Applicaton_Translate::getInstance(); $label = $page->getLabel(); @@ -1001,7 +1001,7 @@ public function setBaseUrl($baseUrl) public function disableTranslation() { if (is_null($this->translatorBackup)) { - $this->translatorBackup = \Zend_Registry::get('Zend_Translate'); + $this->translatorBackup = Applicaton_Translate::getInstance(); } \Zend_Registry::set('Zend_Translate', new Application_Translate([ From 7f60a16b84fba4e853e5405c63322d50942e7a1c Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 2 Mar 2021 20:07:37 +0100 Subject: [PATCH 124/270] OPUSVIER-4518 Remove 'Opus_View' from registry --- .../Controller/Action/Helper/SendFile.php | 2 +- .../Form/Element/EnrichmentKey.php | 4 ++-- library/Application/View/Helper/LinkList.php | 2 +- .../View/Helper/ViewFormTextarea.php | 2 +- .../Action/Helper/BreadcrumbsTest.php | 4 ++-- .../Application/Util/DocumentAdapterTest.php | 24 +++++++++---------- .../View/Helper/AccessAllowedTest.php | 2 +- .../View/Helper/ActionCssClassTest.php | 2 +- .../View/Helper/AdminCssClassTest.php | 2 +- .../Application/View/Helper/AdminMenuTest.php | 2 +- .../View/Helper/BreadcrumbsTest.php | 2 +- .../View/Helper/DocumentTitleTest.php | 2 +- .../View/Helper/EscapeValueTest.php | 2 +- .../View/Helper/FaqEditLinkTest.php | 2 +- .../Application/View/Helper/FileLinkTest.php | 4 ++-- .../Application/View/Helper/FileUrlTest.php | 4 ++-- .../View/Helper/FormTranslationTest.php | 4 ++-- .../View/Helper/FormatValueTest.php | 2 +- .../View/Helper/FrontdoorUrlTest.php | 2 +- .../View/Helper/FulltextLogoTest.php | 2 +- .../View/Helper/JavascriptMessagesTest.php | 2 +- .../View/Helper/LanguageSelectorTest.php | 2 +- .../Application/View/Helper/MessagesTest.php | 10 ++++---- .../Application/View/Helper/OptionUrlTest.php | 2 +- .../View/Helper/ResultAuthorsTest.php | 2 +- .../View/Helper/ResultTitleTest.php | 2 +- .../View/Helper/ResultYearTest.php | 2 +- .../View/Helper/TransferUrlTest.php | 2 +- .../View/Helper/TranslationEditLinkTest.php | 2 +- tests/modules/ControllerTestCaseTest.php | 8 +++---- tests/modules/admin/forms/PersonsTest.php | 2 +- .../modules/admin/models/CollectionsTest.php | 2 +- .../View/Helper/JavascriptMessagesTest.php | 2 +- tests/modules/rss/models/FeedTest.php | 10 ++++---- tests/support/ControllerTestCase.php | 17 ++++++++----- 35 files changed, 72 insertions(+), 67 deletions(-) diff --git a/library/Application/Controller/Action/Helper/SendFile.php b/library/Application/Controller/Action/Helper/SendFile.php index 41649fb44e..8c1b394e8a 100644 --- a/library/Application/Controller/Action/Helper/SendFile.php +++ b/library/Application/Controller/Action/Helper/SendFile.php @@ -25,7 +25,7 @@ * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * @category Applicaton + * @category Application * @author Thoralf Klein * @copyright Copyright (c) 2011-2016, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License diff --git a/library/Application/Form/Element/EnrichmentKey.php b/library/Application/Form/Element/EnrichmentKey.php index 622efa7626..0e0dfa2b13 100644 --- a/library/Application/Form/Element/EnrichmentKey.php +++ b/library/Application/Form/Element/EnrichmentKey.php @@ -67,7 +67,7 @@ private function addKeyNameAsOption($keyName) { $translationKey = 'Enrichment' . $keyName; - $translator = Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); if (! is_null($translator) && ($translator->isTranslated($translationKey))) { $this->addMultiOption($keyName, $translator->translate($translationKey)); } else { @@ -77,7 +77,7 @@ private function addKeyNameAsOption($keyName) private function resetValidator() { - $translator = Zend_Registry::get('Zend_Translate'); + $translator = Application_Translate::getInstance(); $message = 'validation_error_unknown_enrichmentkey'; if (! is_null($translator) && $translator->isTranslated($message)) { $message = $translator->translate($message); diff --git a/library/Application/View/Helper/LinkList.php b/library/Application/View/Helper/LinkList.php index b4b77d1bfe..39cc7134e6 100644 --- a/library/Application/View/Helper/LinkList.php +++ b/library/Application/View/Helper/LinkList.php @@ -24,7 +24,7 @@ * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * @category Applicaton + * @category Application * @package Appliation_View_Helper * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team diff --git a/library/Application/View/Helper/ViewFormTextarea.php b/library/Application/View/Helper/ViewFormTextarea.php index 8233571402..a050d3ec6d 100644 --- a/library/Application/View/Helper/ViewFormTextarea.php +++ b/library/Application/View/Helper/ViewFormTextarea.php @@ -24,7 +24,7 @@ * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * @category Applicaton + * @category Application * @package Application_View_Helper * @author Jens Schwidder * @copyright Copyright (c) 2008-2013, OPUS 4 development team diff --git a/tests/library/Application/Controller/Action/Helper/BreadcrumbsTest.php b/tests/library/Application/Controller/Action/Helper/BreadcrumbsTest.php index 5caf07036c..43277d82ac 100644 --- a/tests/library/Application/Controller/Action/Helper/BreadcrumbsTest.php +++ b/tests/library/Application/Controller/Action/Helper/BreadcrumbsTest.php @@ -49,9 +49,9 @@ public function setUp() parent::setUp(); $this->helper = \Zend_Controller_Action_HelperBroker::getStaticHelper('breadcrumbs'); - $this->navigation = \Zend_Registry::get('Opus_View')->navigation(); + $this->navigation = $this->getView()->navigation(); $this->helper->setNavigation($this->navigation); - $this->helper->setView(\Zend_Registry::get('Opus_View')); + $this->helper->setView($this->getView()); } private function getPage($label) diff --git a/tests/library/Application/Util/DocumentAdapterTest.php b/tests/library/Application/Util/DocumentAdapterTest.php index 57f93cfca6..5c41fe7400 100644 --- a/tests/library/Application/Util/DocumentAdapterTest.php +++ b/tests/library/Application/Util/DocumentAdapterTest.php @@ -46,7 +46,7 @@ class Application_Util_DocumentAdapterTest extends ControllerTestCase public function testHasFilesTrue() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = Document::get(1); @@ -57,7 +57,7 @@ public function testHasFilesTrue() public function testHasFilesFalse() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = $this->createTestDocument(); @@ -68,7 +68,7 @@ public function testHasFilesFalse() public function testGetFileCount() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = Document::get(1); @@ -79,7 +79,7 @@ public function testGetFileCount() public function testGetFileCountZero() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = $this->createTestDocument(); @@ -90,7 +90,7 @@ public function testGetFileCountZero() public function testIsBelongsToBibliographyTrue() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = $this->createTestDocument(); @@ -103,7 +103,7 @@ public function testIsBelongsToBibliographyTrue() public function testIsBelongsToBibliographyFalse() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = $this->createTestDocument(); @@ -119,7 +119,7 @@ public function testIsBelongsToBibliographyFalse() */ public function testGetMainTitle() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = $this->createTestDocument(); @@ -144,7 +144,7 @@ public function testGetMainTitleForDocWithNoTitles() { $this->useEnglish(); - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = $this->createTestDocument(); $docId = $doc->store(); @@ -156,7 +156,7 @@ public function testGetMainTitleForDocWithNoTitles() public function testGetMainTitleForDocWithNoLanguage() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = $this->createTestDocument(); @@ -178,7 +178,7 @@ public function testGetMainTitleForDocWithNoLanguage() public function testGetMainTitleForDocWithNoTitleInDocLanguage() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = $this->createTestDocument(); @@ -202,7 +202,7 @@ public function testGetMainTitleForDocWithNoTitleInDocLanguage() public function testGetDocTitle() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = $this->createTestDocument(); @@ -246,7 +246,7 @@ public function testGetAuthors() public function testGetAuthorsForDocumentWithoutAuthors() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $doc = $this->createTestDocument(); diff --git a/tests/library/Application/View/Helper/AccessAllowedTest.php b/tests/library/Application/View/Helper/AccessAllowedTest.php index 0fc729f99e..4f4e51c656 100644 --- a/tests/library/Application/View/Helper/AccessAllowedTest.php +++ b/tests/library/Application/View/Helper/AccessAllowedTest.php @@ -49,7 +49,7 @@ public function setUp() $acl = \Zend_Registry::get('Opus_Acl'); $acl->allow('guest', 'accounts'); $this->__helper = new Application_View_Helper_AccessAllowed(); - $this->__helper->setView(\Zend_Registry::get('Opus_View')); + $this->__helper->setView($this->getView()); } public function tearDown() diff --git a/tests/library/Application/View/Helper/ActionCssClassTest.php b/tests/library/Application/View/Helper/ActionCssClassTest.php index 3902d619e4..4d8278353e 100644 --- a/tests/library/Application/View/Helper/ActionCssClassTest.php +++ b/tests/library/Application/View/Helper/ActionCssClassTest.php @@ -39,7 +39,7 @@ class Application_View_Helper_ActionCssClassTest extends ControllerTestCase public function testActionCssClass() { $helper = new Application_View_Helper_ActionCssClass(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $this->assertEquals('', $helper->actionCssClass()); diff --git a/tests/library/Application/View/Helper/AdminCssClassTest.php b/tests/library/Application/View/Helper/AdminCssClassTest.php index 67017f49e4..79fe61a587 100644 --- a/tests/library/Application/View/Helper/AdminCssClassTest.php +++ b/tests/library/Application/View/Helper/AdminCssClassTest.php @@ -59,7 +59,7 @@ public function modulesProvider() public function testAdminCssClass($module, $expected) { $helper = new Application_View_Helper_AdminCssClass(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $helper->view->moduleName = $module; diff --git a/tests/library/Application/View/Helper/AdminMenuTest.php b/tests/library/Application/View/Helper/AdminMenuTest.php index caf2b87b57..65e3b3bca3 100644 --- a/tests/library/Application/View/Helper/AdminMenuTest.php +++ b/tests/library/Application/View/Helper/AdminMenuTest.php @@ -43,7 +43,7 @@ public function setUp() parent::setUpWithEnv('production'); $this->assertSecurityConfigured(); $this->_helper = new Application_View_Helper_AdminMenu(); - $this->_helper->setView(\Zend_Registry::get('Opus_View')); + $this->_helper->setView($this->getView()); } private function getPageByLabel($label) diff --git a/tests/library/Application/View/Helper/BreadcrumbsTest.php b/tests/library/Application/View/Helper/BreadcrumbsTest.php index 033ad02e0c..eae4814e85 100644 --- a/tests/library/Application/View/Helper/BreadcrumbsTest.php +++ b/tests/library/Application/View/Helper/BreadcrumbsTest.php @@ -50,7 +50,7 @@ public function setUp() { parent::setUp(); - $this->view = \Zend_Registry::get('Opus_View'); + $this->view = $this->getView(); $this->breadcrumbs = $this->view->breadcrumbs(); diff --git a/tests/library/Application/View/Helper/DocumentTitleTest.php b/tests/library/Application/View/Helper/DocumentTitleTest.php index 5baf2692cf..9d17ae0950 100644 --- a/tests/library/Application/View/Helper/DocumentTitleTest.php +++ b/tests/library/Application/View/Helper/DocumentTitleTest.php @@ -46,7 +46,7 @@ public function setup() parent::setUp(); $this->_helper = new Application_View_Helper_DocumentTitle(); - $this->_helper->setView(\Zend_Registry::get('Opus_View')); + $this->_helper->setView($this->getView()); } public function testDocumentTitle() diff --git a/tests/library/Application/View/Helper/EscapeValueTest.php b/tests/library/Application/View/Helper/EscapeValueTest.php index fbce93d3ae..ed4bb66474 100644 --- a/tests/library/Application/View/Helper/EscapeValueTest.php +++ b/tests/library/Application/View/Helper/EscapeValueTest.php @@ -43,7 +43,7 @@ public function setUp() parent::setUp(); $this->_helper = new Application_View_Helper_EscapeValue(); - $this->_helper->setView(\Zend_Registry::get('Opus_View')); + $this->_helper->setView($this->getView()); } public function testEscapeValueNull() diff --git a/tests/library/Application/View/Helper/FaqEditLinkTest.php b/tests/library/Application/View/Helper/FaqEditLinkTest.php index bb7517b9e5..1a526347f5 100644 --- a/tests/library/Application/View/Helper/FaqEditLinkTest.php +++ b/tests/library/Application/View/Helper/FaqEditLinkTest.php @@ -104,7 +104,7 @@ public function testRenderOnlyIfKeyEditable() protected function getHelper() { $helper = new Application_View_Helper_FaqEditLink(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); return $helper; } } diff --git a/tests/library/Application/View/Helper/FileLinkTest.php b/tests/library/Application/View/Helper/FileLinkTest.php index e689c810a3..c430265ffb 100644 --- a/tests/library/Application/View/Helper/FileLinkTest.php +++ b/tests/library/Application/View/Helper/FileLinkTest.php @@ -79,7 +79,7 @@ public function testFileLinkSpacesAndQuotes() { $helper = new Application_View_Helper_FileLink(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $file = new File(131); @@ -94,7 +94,7 @@ public function testFileLinkNoLabel() { $helper = new Application_View_Helper_FileLink(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $file = new File(126); $file->setLabel(null); diff --git a/tests/library/Application/View/Helper/FileUrlTest.php b/tests/library/Application/View/Helper/FileUrlTest.php index 4ae5d17686..9560cc252a 100644 --- a/tests/library/Application/View/Helper/FileUrlTest.php +++ b/tests/library/Application/View/Helper/FileUrlTest.php @@ -39,7 +39,7 @@ class Application_View_Helper_FileUrlTest extends ControllerTestCase public function testFileUrl() { $helper = new Application_View_Helper_FileUrl(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $fileUrl = $helper->fileUrl('123', 'foo.pdf'); $this->assertEquals('http:///files/123/foo.pdf', $fileUrl); @@ -48,7 +48,7 @@ public function testFileUrl() public function testFileUrlWithEscaping() { $helper = new Application_View_Helper_FileUrl(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $fileUrl = $helper->fileUrl('123', 'foo:bar.pdf'); $this->assertEquals('http:///files/123/foo%3Abar.pdf', $fileUrl); diff --git a/tests/library/Application/View/Helper/FormTranslationTest.php b/tests/library/Application/View/Helper/FormTranslationTest.php index 1af1b2b4f5..245ef88a8c 100644 --- a/tests/library/Application/View/Helper/FormTranslationTest.php +++ b/tests/library/Application/View/Helper/FormTranslationTest.php @@ -38,7 +38,7 @@ class Application_View_Helper_Form_TranslationTest extends ControllerTestCase public function testRenderingMinimal() { $helper = new Application_View_Helper_FormTranslation(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $output = $helper->formTranslation('DisplayName'); @@ -48,7 +48,7 @@ public function testRenderingMinimal() public function testRenderingOptions() { $helper = new Application_View_Helper_FormTranslation(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $options = [ 'en' => 'English', diff --git a/tests/library/Application/View/Helper/FormatValueTest.php b/tests/library/Application/View/Helper/FormatValueTest.php index 7243fb259b..3ed236ba0d 100644 --- a/tests/library/Application/View/Helper/FormatValueTest.php +++ b/tests/library/Application/View/Helper/FormatValueTest.php @@ -47,7 +47,7 @@ public function setUp() { parent::setUp(); $this->__helper = new Application_View_Helper_FormatValue(); - $this->__helper->setView(\Zend_Registry::get('Opus_View')); + $this->__helper->setView($this->getView()); } public function testViewHelperReturnsItself() diff --git a/tests/library/Application/View/Helper/FrontdoorUrlTest.php b/tests/library/Application/View/Helper/FrontdoorUrlTest.php index 6bbe57a6a3..c25415733e 100644 --- a/tests/library/Application/View/Helper/FrontdoorUrlTest.php +++ b/tests/library/Application/View/Helper/FrontdoorUrlTest.php @@ -39,7 +39,7 @@ class Application_View_Helper_FrontdoorUrlTest extends ControllerTestCase public function testFrontdoorUrl() { $helper = new Application_View_Helper_FrontdoorUrl(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $frontDoorUrl = $helper->frontdoorUrl('123'); $this->assertEquals('http:///frontdoor/index/index/docId/123', $frontDoorUrl); diff --git a/tests/library/Application/View/Helper/FulltextLogoTest.php b/tests/library/Application/View/Helper/FulltextLogoTest.php index 3db52ac029..f4beb056b3 100644 --- a/tests/library/Application/View/Helper/FulltextLogoTest.php +++ b/tests/library/Application/View/Helper/FulltextLogoTest.php @@ -46,7 +46,7 @@ public function setUp() parent::setUp(); $this->_helper = new Application_View_Helper_FulltextLogo(); - $this->_helper->setView(\Zend_Registry::get('Opus_View')); + $this->_helper->setView($this->getView()); $this->useEnglish(); } diff --git a/tests/library/Application/View/Helper/JavascriptMessagesTest.php b/tests/library/Application/View/Helper/JavascriptMessagesTest.php index c62aa01dc3..8b854b297d 100644 --- a/tests/library/Application/View/Helper/JavascriptMessagesTest.php +++ b/tests/library/Application/View/Helper/JavascriptMessagesTest.php @@ -47,7 +47,7 @@ public function setUp() $this->helper = new Application_View_Helper_JavascriptMessages(); - $this->helper->setView(\Zend_Registry::get('Opus_View')); + $this->helper->setView($this->getView()); } /** diff --git a/tests/library/Application/View/Helper/LanguageSelectorTest.php b/tests/library/Application/View/Helper/LanguageSelectorTest.php index 49064cce0b..8ca23c536f 100644 --- a/tests/library/Application/View/Helper/LanguageSelectorTest.php +++ b/tests/library/Application/View/Helper/LanguageSelectorTest.php @@ -50,7 +50,7 @@ public function setUp() $this->_helper = new Application_View_Helper_LanguageSelector(); - $this->_helper->setView(\Zend_Registry::get('Opus_View')); + $this->_helper->setView($this->getView()); } public function testLanguageConfiguredAndInResourcesGerman() diff --git a/tests/library/Application/View/Helper/MessagesTest.php b/tests/library/Application/View/Helper/MessagesTest.php index 5febff32c0..2e0eb7eb56 100644 --- a/tests/library/Application/View/Helper/MessagesTest.php +++ b/tests/library/Application/View/Helper/MessagesTest.php @@ -43,7 +43,7 @@ public function testMessages() { $this->useEnglish(); - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $helper = new Application_View_Helper_Messages(); $helper->setView($view); @@ -67,7 +67,7 @@ public function testMessagesMultiple() { $this->useEnglish(); - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $helper = new Application_View_Helper_Messages(); $helper->setView($view); @@ -95,7 +95,7 @@ public function testMessagesTranslation() { $this->useEnglish(); - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $helper = new Application_View_Helper_Messages(); $helper->setView($view); @@ -119,7 +119,7 @@ public function testMessagesNone() { $helper = new Application_View_Helper_Messages(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $this->assertEquals('', $helper->messages()); } @@ -128,7 +128,7 @@ public function testMessageWithoutMessageKey() { $helper = new Application_View_Helper_Messages(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $this->assertEquals( <<setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $this->adjustConfiguration([ 'logoLink' => 'home' diff --git a/tests/library/Application/View/Helper/ResultAuthorsTest.php b/tests/library/Application/View/Helper/ResultAuthorsTest.php index 1987c120d2..15f0595644 100644 --- a/tests/library/Application/View/Helper/ResultAuthorsTest.php +++ b/tests/library/Application/View/Helper/ResultAuthorsTest.php @@ -43,7 +43,7 @@ public function setUp() parent::setUp(); $this->helper = new Application_View_Helper_ResultAuthors(); - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $this->helper->setView($view); } diff --git a/tests/library/Application/View/Helper/ResultTitleTest.php b/tests/library/Application/View/Helper/ResultTitleTest.php index e3c2fc361d..dffed5785a 100644 --- a/tests/library/Application/View/Helper/ResultTitleTest.php +++ b/tests/library/Application/View/Helper/ResultTitleTest.php @@ -43,7 +43,7 @@ public function setUp() parent::setUp(); $this->helper = new Application_View_Helper_ResultTitle(); - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $this->helper->setView($view); } diff --git a/tests/library/Application/View/Helper/ResultYearTest.php b/tests/library/Application/View/Helper/ResultYearTest.php index 22ffa4598b..2d427e51b6 100644 --- a/tests/library/Application/View/Helper/ResultYearTest.php +++ b/tests/library/Application/View/Helper/ResultYearTest.php @@ -42,7 +42,7 @@ public function setUp() parent::setUp(); $this->helper = new Application_View_Helper_ResultYear(); - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $this->helper->setView($view); } diff --git a/tests/library/Application/View/Helper/TransferUrlTest.php b/tests/library/Application/View/Helper/TransferUrlTest.php index 0b11fc5cd5..9af1c22f2d 100644 --- a/tests/library/Application/View/Helper/TransferUrlTest.php +++ b/tests/library/Application/View/Helper/TransferUrlTest.php @@ -39,7 +39,7 @@ class Application_View_Helper_TransferUrlTest extends ControllerTestCase public function testTransferUrl() { $helper = new Application_View_Helper_TransferUrl(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); $transferUrl = $helper->transferUrl('123'); $this->assertEquals('http:///oai/container/index/docId/123', $transferUrl); diff --git a/tests/library/Application/View/Helper/TranslationEditLinkTest.php b/tests/library/Application/View/Helper/TranslationEditLinkTest.php index b952bde5c6..dd85a8ee91 100644 --- a/tests/library/Application/View/Helper/TranslationEditLinkTest.php +++ b/tests/library/Application/View/Helper/TranslationEditLinkTest.php @@ -104,7 +104,7 @@ public function testRenderOnlyIfKeyEditable() protected function getHelper() { $helper = new Application_View_Helper_TranslationEditLink(); - $helper->setView(\Zend_Registry::get('Opus_View')); + $helper->setView($this->getView()); return $helper; } } diff --git a/tests/modules/ControllerTestCaseTest.php b/tests/modules/ControllerTestCaseTest.php index 9ca025f046..ed65f30e18 100644 --- a/tests/modules/ControllerTestCaseTest.php +++ b/tests/modules/ControllerTestCaseTest.php @@ -79,7 +79,7 @@ public function testTearDownDidLogout() public function testSetHostname() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $this->assertEquals('http://', $view->serverUrl()); @@ -90,7 +90,7 @@ public function testSetHostname() public function testSetBaseUrlNotSet() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $this->assertEquals('', $view->baseUrl()); @@ -101,7 +101,7 @@ public function testSetBaseUrlNotSet() public function testSetBaseUrlSet() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $this->setBaseUrl('opus4'); @@ -168,7 +168,7 @@ public function testGetTempFile() public function testDisableEnableTranslation() { - $defaultTranslator = Applicaton_Translate::getInstance(); + $defaultTranslator = Application_Translate::getInstance(); $this->assertTrue($defaultTranslator->isTranslated('LastName')); $this->disableTranslation(); diff --git a/tests/modules/admin/forms/PersonsTest.php b/tests/modules/admin/forms/PersonsTest.php index 550eb4cdd5..9bbe255225 100644 --- a/tests/modules/admin/forms/PersonsTest.php +++ b/tests/modules/admin/forms/PersonsTest.php @@ -528,7 +528,7 @@ public function testKeepPostValues() $form->getElement('PlaceOfBirth')->setValue('Köln'); - $output = $form->render(\Zend_Registry::get('Opus_View')); + $output = $form->render($this->getView()); $this->assertContains('', $output); $this->assertContains('', $output); diff --git a/tests/modules/admin/models/CollectionsTest.php b/tests/modules/admin/models/CollectionsTest.php index 931542d85b..35723d87b4 100644 --- a/tests/modules/admin/models/CollectionsTest.php +++ b/tests/modules/admin/models/CollectionsTest.php @@ -63,7 +63,7 @@ public function setUp() $this->collectionRoleId = $collectionRole->store(); $this->model = new Admin_Model_Collections(); - $this->model->setView(\Zend_Registry::get('Opus_View')); + $this->model->setView($this->getView()); $document = $this->createTestDocument(); $document->addCollection($root); diff --git a/tests/modules/publish/View/Helper/JavascriptMessagesTest.php b/tests/modules/publish/View/Helper/JavascriptMessagesTest.php index b0dfa32797..d098125349 100644 --- a/tests/modules/publish/View/Helper/JavascriptMessagesTest.php +++ b/tests/modules/publish/View/Helper/JavascriptMessagesTest.php @@ -46,7 +46,7 @@ public function setUp() $this->helper = new Publish_View_Helper_JavascriptMessages(); - $this->helper->setView(\Zend_Registry::get('Opus_View')); + $this->helper->setView($this->getView()); } /** diff --git a/tests/modules/rss/models/FeedTest.php b/tests/modules/rss/models/FeedTest.php index d3b2bf2e4e..f9c8dde181 100644 --- a/tests/modules/rss/models/FeedTest.php +++ b/tests/modules/rss/models/FeedTest.php @@ -44,14 +44,14 @@ public function setUp() { parent::setUp(); - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $this->_model = new Rss_Model_Feed($view); } public function testGetTitle() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); $model = new Rss_Model_Feed($view); @@ -76,7 +76,7 @@ public function testGetTitleWithName() public function testGetTitleWithFullUrl() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); $model = new Rss_Model_Feed($view); @@ -88,7 +88,7 @@ public function testGetTitleWithFullUrl() public function testGetTitleWithBaseUrl() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); $model = new Rss_Model_Feed($view); @@ -100,7 +100,7 @@ public function testGetTitleWithBaseUrl() public function testGetTitleWithHost() { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4test'); $view->getHelper('ServerUrl')->setHost('testhost'); $model = new Rss_Model_Feed($view); diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index 0f3a4b23b0..70ac59fe1d 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -396,7 +396,7 @@ public function useGerman() { $session = new \Zend_Session_Namespace(); $session->language = 'de'; - Applicaton_Translate::getInstance()->setLocale('de'); + Application_Translate::getInstance()->setLocale('de'); Application_Form_Element_Language::initLanguageList(); } @@ -407,7 +407,7 @@ public function useEnglish() { $session = new \Zend_Session_Namespace(); $session->language = 'en'; - Applicaton_Translate::getInstance()->setLocale('en'); + Application_Translate::getInstance()->setLocale('en'); Application_Form_Element_Language::initLanguageList(); } @@ -617,7 +617,7 @@ public function verifyBreadcrumbDefined($location = null) } } - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $path = explode('/', $location); @@ -637,7 +637,7 @@ public function verifyBreadcrumbDefined($location = null) if (! $breadcrumbDefined) { $breadcrumbDefined = true; - $translate = Applicaton_Translate::getInstance(); + $translate = Application_Translate::getInstance(); $label = $page->getLabel(); @@ -972,7 +972,7 @@ public function resetSearch() */ public function setHostname($host) { - $view = \Zend_Registry::get('Opus_View'); + $view = $this->getView(); $view->getHelper('ServerUrl')->setHost($host); } @@ -1001,7 +1001,7 @@ public function setBaseUrl($baseUrl) public function disableTranslation() { if (is_null($this->translatorBackup)) { - $this->translatorBackup = Applicaton_Translate::getInstance(); + $this->translatorBackup = Application_Translate::getInstance(); } \Zend_Registry::set('Zend_Translate', new Application_Translate([ @@ -1088,4 +1088,9 @@ protected function cleanupModels() } } } + + protected function getView() + { + return $this->application->getBootstrap()->getResource('view'); + } } From e0342829a92b1efe6c70f921afa97499b9bc6d44 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 3 Mar 2021 08:33:55 +0100 Subject: [PATCH 125/270] OPUSVIER-4518 Fix enable/disable translation for tests --- library/Application/Translate.php | 5 +++++ tests/support/ControllerTestCase.php | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/library/Application/Translate.php b/library/Application/Translate.php index 7631106383..54432c9d29 100644 --- a/library/Application/Translate.php +++ b/library/Application/Translate.php @@ -98,6 +98,11 @@ public static function getInstance() return self::$instance; } + public static function setInstance($instance) + { + self::$instance = $instance; + \Zend_Registry::set(self::REGISTRY_KEY, $instance); + } /** * Loads all modules. */ diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index 70ac59fe1d..b142f43c78 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -1004,11 +1004,13 @@ public function disableTranslation() $this->translatorBackup = Application_Translate::getInstance(); } - \Zend_Registry::set('Zend_Translate', new Application_Translate([ + $translate = new Application_Translate([ 'adapter' => 'array', 'content' => [], 'locale' => 'auto' - ])); + ]); + + Application_Translate::setInstance($translate); } /** @@ -1019,7 +1021,7 @@ public function disableTranslation() public function enableTranslation() { if (! is_null($this->translatorBackup)) { - \Zend_Registry::set('Zend_Translate', $this->translatorBackup); + Application_Translate::setInstance($this->translatorBackup); } } From df2ac1ebf9addc1dc3020a4b71a77da6cf2dc6f1 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 3 Mar 2021 09:44:37 +0100 Subject: [PATCH 126/270] OPUSVIER-4518 Cleanup translations after test --- library/Application/Bootstrap.php | 2 +- tests/support/ControllerTestCase.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/library/Application/Bootstrap.php b/library/Application/Bootstrap.php index 0d29187f26..0949d4314e 100644 --- a/library/Application/Bootstrap.php +++ b/library/Application/Bootstrap.php @@ -237,7 +237,7 @@ protected function _initTranslation() 'route' => ['en' => 'de'] // TODO make configurable in administration AND/OR generate automatically (all lang -> default) ]); - \Zend_Registry::set(Application_Translate::REGISTRY_KEY, $translate); + Application_Translate::setInstance($translate); $configHelper = new Application_Configuration(); diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index b142f43c78..ed5f53ed26 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -119,6 +119,7 @@ public function tearDown() DoiManager::setInstance(null); Application_Configuration::clearInstance(); // reset Application_Configuration + Application_Translate::setInstance(null); parent::tearDown(); } From 75ca2a54a11716c52733c6548df4bd00cc583563 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 3 Mar 2021 14:57:40 +0100 Subject: [PATCH 127/270] OPUSVIER-4522 Change disableDatabaseVersionCheck --- db/createdb.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/createdb.php b/db/createdb.php index db01409d6c..b1b950d3d4 100644 --- a/db/createdb.php +++ b/db/createdb.php @@ -71,7 +71,9 @@ ] ); -\Zend_Registry::set('opus.disableDatabaseVersionCheck', true); +$options = $application->getOptions(); +$options['opus']['disableDatabaseVersionCheck'] = true; +$application->setOptions($options); // Bootstrapping application $application->bootstrap('Backend'); From c3bf50005325365b157d7d55e0d47307de668b08 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 3 Mar 2021 14:59:39 +0100 Subject: [PATCH 128/270] OPUSVIER-4518 Remove ACL from Zend_Registry --- .../Controller/Action/Helper/AccessControl.php | 2 +- .../Controller/Action/Helper/Workflow.php | 2 +- library/Application/Security/AclProvider.php | 14 +++++++++++++- .../Controller/Action/Helper/AccessControlTest.php | 4 ++-- .../Application/View/Helper/AccessAllowedTest.php | 4 ++-- .../Application/View/Helper/AdminMenuTest.php | 4 ++-- tests/support/ControllerTestCase.php | 8 ++++---- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/library/Application/Controller/Action/Helper/AccessControl.php b/library/Application/Controller/Action/Helper/AccessControl.php index 258f40bb61..c51ba3773d 100644 --- a/library/Application/Controller/Action/Helper/AccessControl.php +++ b/library/Application/Controller/Action/Helper/AccessControl.php @@ -81,7 +81,7 @@ public function accessAllowed($resource) protected function getAcl() { if (is_null($this->_acl)) { - $this->_acl = \Zend_Registry::isRegistered('Opus_Acl') ? \Zend_Registry::get('Opus_Acl') : null; + $this->_acl = Application_Security_AclProvider::getAcl(); } return $this->_acl; } diff --git a/library/Application/Controller/Action/Helper/Workflow.php b/library/Application/Controller/Action/Helper/Workflow.php index 17b2eb06ae..986ba75d59 100644 --- a/library/Application/Controller/Action/Helper/Workflow.php +++ b/library/Application/Controller/Action/Helper/Workflow.php @@ -222,7 +222,7 @@ public static function getWorkflowConfig() public function getAcl() { if (is_null($this->_acl)) { - $this->_acl = \Zend_Registry::isRegistered('Opus_Acl') ? \Zend_Registry::get('Opus_Acl') : null; + $this->_acl = Application_Security_AclProvider::getAcl(); } return $this->_acl; } diff --git a/library/Application/Security/AclProvider.php b/library/Application/Security/AclProvider.php index 377b332d97..2b5b0c9b01 100644 --- a/library/Application/Security/AclProvider.php +++ b/library/Application/Security/AclProvider.php @@ -89,6 +89,8 @@ class Application_Security_AclProvider ] ]; + private static $acl; + public static function init() { $aclProvider = new Application_Security_AclProvider(); @@ -97,7 +99,7 @@ public static function init() $aclProvider->getLogger()->debug('ACL: bootrapping'); - \Zend_Registry::set('Opus_Acl', $acl); + self::$acl = $acl; \Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl); \Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole( @@ -105,6 +107,16 @@ public static function init() ); } + public static function getAcl() + { + return self::$acl; + } + + public static function clear() + { + self::$acl = null; + } + /** Zend_Debug::dump * Liefert ein Zend_Acl Objekt für den aktuellen Nutzer zurück. */ diff --git a/tests/library/Application/Controller/Action/Helper/AccessControlTest.php b/tests/library/Application/Controller/Action/Helper/AccessControlTest.php index 017d18365e..51c662828a 100644 --- a/tests/library/Application/Controller/Action/Helper/AccessControlTest.php +++ b/tests/library/Application/Controller/Action/Helper/AccessControlTest.php @@ -45,14 +45,14 @@ public function setUp() { parent::setUpWithEnv('production'); $this->assertSecurityConfigured(); - $acl = \Zend_Registry::get('Opus_Acl'); + $acl = Application_Security_AclProvider::getAcl(); $acl->allow('guest', 'accounts'); $this->accessControl = new Application_Controller_Action_Helper_AccessControl(); } public function tearDown() { - $acl = \Zend_Registry::get('Opus_Acl'); + $acl = Application_Security_AclProvider::getAcl(); $acl->deny('guest', 'accounts'); parent::tearDown(); } diff --git a/tests/library/Application/View/Helper/AccessAllowedTest.php b/tests/library/Application/View/Helper/AccessAllowedTest.php index 4f4e51c656..b7b4febbd8 100644 --- a/tests/library/Application/View/Helper/AccessAllowedTest.php +++ b/tests/library/Application/View/Helper/AccessAllowedTest.php @@ -46,7 +46,7 @@ public function setUp() // bootstrapping authorization twice is not possible parent::setUpWithEnv('production'); $this->assertSecurityConfigured(); - $acl = \Zend_Registry::get('Opus_Acl'); + $acl = Application_Security_AclProvider::getAcl(); $acl->allow('guest', 'accounts'); $this->__helper = new Application_View_Helper_AccessAllowed(); $this->__helper->setView($this->getView()); @@ -54,7 +54,7 @@ public function setUp() public function tearDown() { - $acl = \Zend_Registry::get('Opus_Acl'); + $acl = Application_Security_AclProvider::getAcl(); $acl->deny('guest', 'accounts'); parent::tearDown(); } diff --git a/tests/library/Application/View/Helper/AdminMenuTest.php b/tests/library/Application/View/Helper/AdminMenuTest.php index 65e3b3bca3..dfa3223794 100644 --- a/tests/library/Application/View/Helper/AdminMenuTest.php +++ b/tests/library/Application/View/Helper/AdminMenuTest.php @@ -58,7 +58,7 @@ public function testAdminMenu() public function testGetAcl() { - $this->assertSame(\Zend_Registry::get('Opus_Acl'), $this->_helper->getAcl()); + $this->assertSame(Application_Security_AclProvider::getAcl(), $this->_helper->getAcl()); } public function testHasAllowedChildren() @@ -78,7 +78,7 @@ public function testHasAllowedChildren() $this->assertFalse($this->_helper->hasAllowedChildren($page)); // activate sub entry below 'admin_title_setup' - $acl = \Zend_Registry::get('Opus_Acl'); + $acl = Application_Security_AclProvider::getAcl(); $acl->allow(Application_Security_AclProvider::ACTIVE_ROLE, 'options'); $page = $this->getPageByLabel('admin_title_config'); diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index ed5f53ed26..c74d925faf 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -952,11 +952,11 @@ protected function deleteFolder($path, $deleteOutsideWorkspace = false) public function assertSecurityConfigured() { $this->assertEquals('1', Config::get()->security); - $this->assertTrue( - \Zend_Registry::isRegistered('Opus_Acl'), - 'Expected registry key Opus_Acl to be set' + $this->assertNotNull( + Application_Security_AclProvider::getAcl(), + 'Expected Zend_Acl to be set' ); - $acl = \Zend_Registry::get('Opus_Acl'); + $acl = Application_Security_AclProvider::getAcl(); $this->assertTrue($acl instanceof \Zend_Acl, 'Expected instance of Zend_Acl'); } From 011590dbc5d83e86341616b95f04d87329f7566c Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 3 Mar 2021 15:00:38 +0100 Subject: [PATCH 129/270] OPUSVIER-4518 Remove Zend_Registry for translations --- library/Application/Controller/Plugin/LoadTranslation.php | 4 ++-- library/Application/Form/Element/Language.php | 2 +- library/Application/Form/Validate/LanguageUsedOnceOnly.php | 2 +- .../Application/Form/Validate/MultiSubForm/RepeatedValues.php | 2 +- library/Application/Translate/TranslationManager.php | 4 ++-- library/Application/View/Helper/TranslateIdentifier.php | 2 +- library/Application/View/Helper/TranslateLanguage.php | 2 +- tests/library/Application/Form/Element/SeriesTest.php | 2 +- tests/modules/frontdoor/controllers/IndexControllerTest.php | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/library/Application/Controller/Plugin/LoadTranslation.php b/library/Application/Controller/Plugin/LoadTranslation.php index 21dfb563ab..52ab053a55 100644 --- a/library/Application/Controller/Plugin/LoadTranslation.php +++ b/library/Application/Controller/Plugin/LoadTranslation.php @@ -51,8 +51,8 @@ public function preDispatch(\Zend_Controller_Request_Abstract $request) $currentModule = $request->getModuleName(); // Add translation - if ($currentModule !== 'default' && \Zend_Registry::isRegistered(Application_Translate::REGISTRY_KEY)) { - \Zend_Registry::get(Application_Translate::REGISTRY_KEY)->loadModule($currentModule); + if ($currentModule !== 'default' && Application_Translate::getInstance() !== null) { + Application_Translate::getInstance()->loadModule($currentModule); } } } diff --git a/library/Application/Form/Element/Language.php b/library/Application/Form/Element/Language.php index edaac5ce48..ace34f620d 100644 --- a/library/Application/Form/Element/Language.php +++ b/library/Application/Form/Element/Language.php @@ -70,7 +70,7 @@ public static function getLanguageList() */ public static function initLanguageList() { - $translate = \Zend_Registry::get(Application_Translate::REGISTRY_KEY); + $translate = Application_Translate::getInstance(); $languages = []; foreach (Language::getAllActiveTable() as $languageRow) { $langId = $languageRow['part2_t']; diff --git a/library/Application/Form/Validate/LanguageUsedOnceOnly.php b/library/Application/Form/Validate/LanguageUsedOnceOnly.php index 8c7b51d73e..0c40365dc7 100644 --- a/library/Application/Form/Validate/LanguageUsedOnceOnly.php +++ b/library/Application/Form/Validate/LanguageUsedOnceOnly.php @@ -82,7 +82,7 @@ public function __construct($languages, $position) { $this->_languages = $languages; $this->_position = $position; - $this->setTranslator(\Zend_Registry::get(Application_Translate::REGISTRY_KEY)); + $this->setTranslator(Application_Translate::getInstance()); } /** diff --git a/library/Application/Form/Validate/MultiSubForm/RepeatedValues.php b/library/Application/Form/Validate/MultiSubForm/RepeatedValues.php index 353ff545de..e106b108b7 100644 --- a/library/Application/Form/Validate/MultiSubForm/RepeatedValues.php +++ b/library/Application/Form/Validate/MultiSubForm/RepeatedValues.php @@ -58,7 +58,7 @@ public function __construct($elementName, $message, $otherElements = null) $this->_elementName = $elementName; $this->_otherElements = $otherElements; - $translator = \Zend_Registry::get(Application_Translate::REGISTRY_KEY); + $translator = Application_Translate::getInstance(); if ($translator->isTranslated($message)) { $this->_message = $translator->translate($message); diff --git a/library/Application/Translate/TranslationManager.php b/library/Application/Translate/TranslationManager.php index dd40d30d51..4ca107e85a 100644 --- a/library/Application/Translate/TranslationManager.php +++ b/library/Application/Translate/TranslationManager.php @@ -620,8 +620,8 @@ public function deleteAll() public function clearCache() { - if (\Zend_Registry::isRegistered('Zend_Translate')) { - $translate = Application_Translate::getInstance(); + $translate = Application_Translate::getInstance(); + if ($translate !== null) { $translate->clearCache(); } } diff --git a/library/Application/View/Helper/TranslateIdentifier.php b/library/Application/View/Helper/TranslateIdentifier.php index 772e71f742..4bbe8f3c8b 100644 --- a/library/Application/View/Helper/TranslateIdentifier.php +++ b/library/Application/View/Helper/TranslateIdentifier.php @@ -47,7 +47,7 @@ public function translateIdentifier($type = null) return $this; } - $translator = \Zend_Registry::get(Application_Translate::REGISTRY_KEY); + $translator = Application_Translate::getInstance(); // TODO map from Type to field name $fieldname = Identifier::getFieldnameForType($type); return $translator->translate($fieldname); diff --git a/library/Application/View/Helper/TranslateLanguage.php b/library/Application/View/Helper/TranslateLanguage.php index 670bd1a0a9..2102fc3504 100644 --- a/library/Application/View/Helper/TranslateLanguage.php +++ b/library/Application/View/Helper/TranslateLanguage.php @@ -52,7 +52,7 @@ class Application_View_Helper_TranslateLanguage extends \Zend_View_Helper_Transl */ public function translateLanguage($langId) { - $translator = \Zend_Registry::get(Application_Translate::REGISTRY_KEY); + $translator = Application_Translate::getInstance(); return $translator->translateLanguage($langId); } } diff --git a/tests/library/Application/Form/Element/SeriesTest.php b/tests/library/Application/Form/Element/SeriesTest.php index c1f1ada138..294806a6d8 100644 --- a/tests/library/Application/Form/Element/SeriesTest.php +++ b/tests/library/Application/Form/Element/SeriesTest.php @@ -82,7 +82,7 @@ public function testValidation() public function testTranslation() { - $translator = \Zend_Registry::get(Application_Translate::REGISTRY_KEY); + $translator = Application_Translate::getInstance(); $this->assertTrue($translator->isTranslated('validation_error_int')); } diff --git a/tests/modules/frontdoor/controllers/IndexControllerTest.php b/tests/modules/frontdoor/controllers/IndexControllerTest.php index 52112e0185..b5fbfae722 100644 --- a/tests/modules/frontdoor/controllers/IndexControllerTest.php +++ b/tests/modules/frontdoor/controllers/IndexControllerTest.php @@ -512,7 +512,7 @@ public function testDisplayAllUserDefinedCollectionRoles() public function testDisplayAllDocumentFields() { $this->dispatch('/frontdoor/index/index/docId/146'); - $translate = \Zend_Registry::getInstance()->get('Zend_Translate'); + $translate = Application_Translate::getInstance(); $path = 'table.result-data.frontdoordata th.name'; From 9632ea7806ae878b81134645ff48fe6eb30353d3 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 3 Mar 2021 16:36:40 +0100 Subject: [PATCH 130/270] OPUSVIER-4518 Reset ACL after test --- .../Controller/Action/Helper/Workflow.php | 30 +++++++++---------- tests/support/ControllerTestCase.php | 1 + 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/library/Application/Controller/Action/Helper/Workflow.php b/library/Application/Controller/Action/Helper/Workflow.php index 986ba75d59..5a34b95598 100644 --- a/library/Application/Controller/Action/Helper/Workflow.php +++ b/library/Application/Controller/Action/Helper/Workflow.php @@ -103,23 +103,21 @@ public function getAllowedTargetStatesForDocument($document) if (! is_null($acl)) { $logger->debug("ACL: got instance"); - if (! is_null($acl)) { - $allowedTargetStates = []; - - foreach ($targetStates as $targetState) { - $resource = 'workflow_' . $currentState . '_' . $targetState; - if (! $acl->has(new \Zend_Acl_Resource($resource)) || $acl->isAllowed( - Application_Security_AclProvider::ACTIVE_ROLE, - $resource - )) { - $allowedTargetStates[] = $targetState; - } else { - $logger->debug("ACL: $resource not allowed"); - } + $allowedTargetStates = []; + + foreach ($targetStates as $targetState) { + $resource = 'workflow_' . $currentState . '_' . $targetState; + if (! $acl->has(new \Zend_Acl_Resource($resource)) || $acl->isAllowed( + Application_Security_AclProvider::ACTIVE_ROLE, + $resource + )) { + $allowedTargetStates[] = $targetState; + } else { + $logger->debug("ACL: $resource not allowed"); } - - return $allowedTargetStates; } + + return $allowedTargetStates; } return $targetStates; @@ -221,7 +219,7 @@ public static function getWorkflowConfig() */ public function getAcl() { - if (is_null($this->_acl)) { + if ($this->_acl === null) { $this->_acl = Application_Security_AclProvider::getAcl(); } return $this->_acl; diff --git a/tests/support/ControllerTestCase.php b/tests/support/ControllerTestCase.php index c74d925faf..a1e49d95dd 100644 --- a/tests/support/ControllerTestCase.php +++ b/tests/support/ControllerTestCase.php @@ -120,6 +120,7 @@ public function tearDown() DoiManager::setInstance(null); Application_Configuration::clearInstance(); // reset Application_Configuration Application_Translate::setInstance(null); + Application_Security_AclProvider::clear(); parent::tearDown(); } From 7e2fd0dac6b7fd803b7a64f8c62efcebfa641556 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 3 Mar 2021 18:12:11 +0100 Subject: [PATCH 131/270] OPUSVIER-4518 Remove Zend_Registry for DB --- public/layouts/default/common.phtml | 2 +- tests/library/Application/Controller/ModuleAccessTest.phtml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/layouts/default/common.phtml b/public/layouts/default/common.phtml index 64726b5d8c..6781c81855 100755 --- a/public/layouts/default/common.phtml +++ b/public/layouts/default/common.phtml @@ -258,7 +258,7 @@ if (isset($config->javascript->latex->mathjax)) { getProfiler(); +$dbprofiler = Zend_Db_Table::getDefaultAdapter()->getProfiler(); $profiler_show_queries = isset($config->db->params->showqueries) && filter_var($config->db->params->showqueries, FILTER_VALIDATE_BOOLEAN); $profiler_max_queries = (int) $config->db->params->maxqueries; if ($dbprofiler->getEnabled() === true) : ?> diff --git a/tests/library/Application/Controller/ModuleAccessTest.phtml b/tests/library/Application/Controller/ModuleAccessTest.phtml index 93f6fb2d2c..d192e4ee1d 100644 --- a/tests/library/Application/Controller/ModuleAccessTest.phtml +++ b/tests/library/Application/Controller/ModuleAccessTest.phtml @@ -31,6 +31,8 @@ * @license http://www.gnu.org/licenses/gpl.html General Public License */ +use Opus\Log; + class Application_Controller_ModuleAccessTest extends ControllerTestCase { @@ -69,9 +71,10 @@ class Application_Controller_ModuleAccessTest extends ControllerTestCase */ public function testNoLogger() { + $this->markTestSkipped('Does this test make sense?'); $controller = $this->getController(); - \Zend_Registry::set('Zend_Log', null); + Log::drop(); $controller->getLogger(); } From 4ce7d12567f57ddd6abd6b0ffbf89acd83541ce5 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 4 Mar 2021 15:32:35 +0100 Subject: [PATCH 132/270] OPUSVIER-4518 Update dependencies for merge --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a80264e01c..e47b351350 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,9 @@ "zendframework/zendframework1": "1.12.*", "jpgraph/jpgraph": "dev-master", "solarium/solarium": "3.8.*", - "opus4-repo/opus4-common": "dev-OPUSVIER-4518", - "opus4-repo/framework": "dev-OPUSVIER-4518", - "opus4-repo/search": "dev-OPUSVIER-4518", + "opus4-repo/opus4-common": "dev-master", + "opus4-repo/framework": "dev-master", + "opus4-repo/search": "dev-master", "opus4-repo/opus4-bibtex": "0.1-beta", "components/jquery": "3.4.*", "components/jqueryui": "1.12.*", From 2c45c130aa8679d10b2f7d577a08964a4e84c623 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 26 Mar 2021 15:08:39 +0100 Subject: [PATCH 133/270] OPUSVIER-4521 Remove 'Available_Languages' from registry --- library/Application/Form/Element/Language.php | 1 - 1 file changed, 1 deletion(-) diff --git a/library/Application/Form/Element/Language.php b/library/Application/Form/Element/Language.php index ace34f620d..327d020db4 100644 --- a/library/Application/Form/Element/Language.php +++ b/library/Application/Form/Element/Language.php @@ -77,6 +77,5 @@ public static function initLanguageList() $languages[$langId] = $translate->translateLanguage($langId); } self::$_languageList = $languages; - \Zend_Registry::set('Available_Languages', $languages); } } From 87bb139ba5bae35ccb24ec0524a5fbb3da498a6e Mon Sep 17 00:00:00 2001 From: j3nsch Date: Wed, 21 Apr 2021 18:50:19 +0200 Subject: [PATCH 134/270] OPUSVIER-4419 OAI metadataPrefix case insensitive --- modules/oai/controllers/IndexController.php | 14 ++-- modules/oai/models/DocumentList.php | 9 ++- modules/oai/models/Request.php | 7 +- modules/oai/models/Server.php | 75 ++++++++++++------- modules/oai/views/scripts/index/oai-pmh.xslt | 16 ++-- .../oai/controllers/IndexControllerTest.php | 41 ++++++++++ 6 files changed, 112 insertions(+), 50 deletions(-) diff --git a/modules/oai/controllers/IndexController.php b/modules/oai/controllers/IndexController.php index b554de93f6..2c8d15f80e 100644 --- a/modules/oai/controllers/IndexController.php +++ b/modules/oai/controllers/IndexController.php @@ -77,23 +77,25 @@ public function moduleAccessDeniedAction() */ public function indexAction() { + $request = $this->getRequest(); + // to handle POST and GET Request, take any given parameter - $oaiRequest = $this->getRequest()->getParams(); + $parameters = $request->getParams(); // remove parameters which are "safe" to remove $safeRemoveParameters = ['module', 'controller', 'action', 'role']; - foreach ($safeRemoveParameters as $parameter) { - unset($oaiRequest[$parameter]); + foreach ($safeRemoveParameters as $name) { + unset($parameters[$name]); } - $server = new Oai_Model_Server(); + $server = new Oai_Model_Server(); // TODO needs factory $server->setScriptPath($this->view->getScriptPath('index')); $server->setBaseUrl($this->view->fullUrl()); - $server->setBaseUri($this->getRequest()->getBaseUrl()); + $server->setBaseUri($request->getBaseUrl()); $server->setResponse($this->getResponse()); // TODO temporary hack - $this->getResponse()->setBody($server->handleRequest($oaiRequest, $this->getRequest()->getRequestUri())); + $this->getResponse()->setBody($server->handleRequest($parameters, $request->getRequestUri())); $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=UTF-8', true); } } diff --git a/modules/oai/models/DocumentList.php b/modules/oai/models/DocumentList.php index cfbe73e757..d24f5c5321 100644 --- a/modules/oai/models/DocumentList.php +++ b/modules/oai/models/DocumentList.php @@ -74,13 +74,14 @@ public function query(array $oaiRequest) // add server state restrictions $finder->setServerStateInList($this->deliveringDocumentStates); - $metadataPrefix = $oaiRequest['metadataPrefix']; - if (strcasecmp('xMetaDissPlus', $metadataPrefix) === 0 - || 'xMetaDiss' === $metadataPrefix) { + $metadataPrefix = strtolower($oaiRequest['metadataPrefix']); + + if (strcmp('xmetadissplus', $metadataPrefix) === 0 + || 'xmetadiss' === $metadataPrefix) { $finder->setFilesVisibleInOai(); $finder->setNotEmbargoedOn($today); } - if ('xMetaDiss' === $metadataPrefix) { + if ('xmetadiss' === $metadataPrefix) { $finder->setTypeInList($this->xMetaDissRestriction); $finder->setNotEmbargoedOn($today); } diff --git a/modules/oai/models/Request.php b/modules/oai/models/Request.php index ed7b135d1c..c7658c8c53 100644 --- a/modules/oai/models/Request.php +++ b/modules/oai/models/Request.php @@ -183,6 +183,9 @@ private function _validateFrom(&$date) * * @param mixed $oaiMetadataPrefix * @return boolean + * + * TODO handling case insensitivity of metadataPrefix is spread through the code (here and other places) + * TODO function handles access control in addition to checking if format is supported (mixed responsibilities) */ private function _validateMetadataPrefix($oaiMetadataPrefix) { @@ -193,7 +196,7 @@ private function _validateMetadataPrefix($oaiMetadataPrefix) // we support both spellings, xMetaDissPlus and XMetaDissPlus TODO really? $availableMetadataPrefixes = ['xMetaDissPlus']; foreach ($possibleFiles as $prefixFile) { - $availableMetadataPrefixes[] = basename($prefixFile, '.xslt'); + $availableMetadataPrefixes[] = strtolower(basename($prefixFile, '.xslt')); } // only adminstrators can request copy_xml format @@ -201,7 +204,7 @@ private function _validateMetadataPrefix($oaiMetadataPrefix) $availableMetadataPrefixes = array_diff($availableMetadataPrefixes, ['copy_xml']); } - $result = in_array($oaiMetadataPrefix, $availableMetadataPrefixes); + $result = in_array(strtolower($oaiMetadataPrefix), $availableMetadataPrefixes); if (false === $result) { // MetadataPrefix not available. diff --git a/modules/oai/models/Server.php b/modules/oai/models/Server.php index 40940ea2f8..1d49579bdb 100644 --- a/modules/oai/models/Server.php +++ b/modules/oai/models/Server.php @@ -110,12 +110,12 @@ public function init() $this->_xmlFactory = new Oai_Model_XmlFactory(); } - public function handleRequest(array $oaiRequest, $requestUri) + public function handleRequest($parameters, $requestUri) { // TODO move error handling into Oai_Model_Server try { // handle request - return $this->handleRequestIntern($oaiRequest, $requestUri); + return $this->handleRequestIntern($parameters, $requestUri); } catch (Oai_Model_Exception $e) { $errorCode = Oai_Model_Error::mapCode($e->getCode()); $this->getLogger()->err($errorCode); @@ -146,42 +146,18 @@ public function handleRequest(array $oaiRequest, $requestUri) /** * Handles an OAI request. * - * @param array $oaiRequest Contains full request information + * @param Oai_Model_OaiRequest $oaiRequest Contains full request information * @throws Oai_Model_Exception Thrown if the request could not be handled. * @return void */ - protected function handleRequestIntern(array $oaiRequest, $requestUri) + protected function handleRequestIntern($oaiRequest, $requestUri) { $this->init(); // Setup stylesheet $this->loadStyleSheet($this->getScriptPath() . '/oai-pmh.xslt'); - $this->_proc->registerPHPFunctions('Opus\Language::getLanguageCode'); - Application_Xslt::registerViewHelper( - $this->_proc, - [ - 'optionValue', - 'fileUrl', - 'frontdoorUrl', - 'transferUrl', - 'dcmiType', - 'dcType', - 'openAireType' - ] - ); - $this->_proc->setParameter('', 'urnResolverUrl', $this->getConfig()->urn->resolverUrl); - $this->_proc->setParameter('', 'doiResolverUrl', $this->getConfig()->doi->resolverUrl); - - // Set response time - $this->_proc->setParameter( - '', - 'dateTime', - str_replace('+00:00', 'Z', \Zend_Date::now()->setTimeZone('UTC')->getIso()) - ); - - // set OAI base url - $this->_proc->setParameter('', 'oai_base_url', $this->getOaiBaseUrl()); + $this->setupProcessor(); $metadataPrefixPath = $this->getScriptPath() . DIRECTORY_SEPARATOR . 'prefixes'; $resumptionPath = $this->_configuration->getResumptionTokenPath(); @@ -204,6 +180,11 @@ protected function handleRequestIntern(array $oaiRequest, $requestUri) throw new Oai_Model_Exception($request->getErrorMessage(), $request->getErrorCode()); } + // TODO refactor - temporary hack to have all lower case version of metadataPrefix to use in XSLT + if (isset($oaiRequest['metadataPrefix'])) { + $oaiRequest['metadataPrefixMode'] = strtolower($oaiRequest['metadataPrefix']); + } + foreach ($oaiRequest as $parameter => $value) { Log::get()->debug("'oai_' . $parameter, $value"); $this->_proc->setParameter('', 'oai_' . $parameter, $value); @@ -242,6 +223,41 @@ protected function handleRequestIntern(array $oaiRequest, $requestUri) return $this->_proc->transformToXML($this->_xml); } + /** + * @throws Zend_Date_Exception + * @throws Zend_Exception + * + * TODO factory (function) for processor + */ + protected function setupProcessor() + { + $this->_proc->registerPHPFunctions('Opus\Language::getLanguageCode'); + Application_Xslt::registerViewHelper( + $this->_proc, + [ + 'optionValue', + 'fileUrl', + 'frontdoorUrl', + 'transferUrl', + 'dcmiType', + 'dcType', + 'openAireType' + ] + ); + $this->_proc->setParameter('', 'urnResolverUrl', $this->getConfig()->urn->resolverUrl); + $this->_proc->setParameter('', 'doiResolverUrl', $this->getConfig()->doi->resolverUrl); + + // Set response time + $this->_proc->setParameter( + '', + 'dateTime', + str_replace('+00:00', 'Z', \Zend_Date::now()->setTimeZone('UTC')->getIso()) + ); + + // set OAI base url + $this->_proc->setParameter('', 'oai_base_url', $this->getOaiBaseUrl()); + } + /** * Implements response for OAI-PMH verb 'GetRecord'. * @@ -461,6 +477,7 @@ private function _handlingOfLists(array &$oaiRequest, $maxRecords) $metadataPrefix = $token->getMetadataPrefix(); $this->_proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix); + $this->_proc->setParameter('', 'oai_metadataPrefixMode', strtolower($metadataPrefix)); $resumed = true; } else { // no resumptionToken is given diff --git a/modules/oai/views/scripts/index/oai-pmh.xslt b/modules/oai/views/scripts/index/oai-pmh.xslt index 1d4e5c6fa6..b2816468f7 100644 --- a/modules/oai/views/scripts/index/oai-pmh.xslt +++ b/modules/oai/views/scripts/index/oai-pmh.xslt @@ -72,6 +72,7 @@ + @@ -401,25 +402,22 @@ - + - - - - + - + - + - + - + diff --git a/tests/modules/oai/controllers/IndexControllerTest.php b/tests/modules/oai/controllers/IndexControllerTest.php index 73233ff8fb..181ba8bba8 100644 --- a/tests/modules/oai/controllers/IndexControllerTest.php +++ b/tests/modules/oai/controllers/IndexControllerTest.php @@ -3602,4 +3602,45 @@ private function addIdentifier($doc, $value, $type) $doc->addIdentifier($identifier); } + + public function metadataPrefixProvider() + { + return [ + ['MARC21'], + ['marc21'], + ['mArC21'] + ]; + } + + /** + * @param $metadataPrefix + * @dataProvider metadataPrefixProvider + */ + public function testMetadataPrefixCaseInsensitive($metadataPrefix) + { + $this->dispatch("/oai?verb=ListRecords&metadataPrefix=$metadataPrefix"); + $this->assertResponseCode(200); + + $body = $this->getResponse()->getBody(); + + $this->checkForCustomBadStringsInHtml($body, ["Exception", "Stacktrace", "badVerb"]); + + $this->assertContains( + '', + $body, + "Response must contain ''" + ); + $this->assertContains( + '', + $body, + "Response must contain ''" + ); + + // TODO check that metadata is generated + $this->assertNotContains( + '', + $body, + 'Response must not contains empty \'\' elements.' + ); + } } From 88f0182bd042a64d21be208b2db78dd9ae9a67eb Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 22 Apr 2021 16:20:19 +0200 Subject: [PATCH 135/270] OPUSVIER-4527 Additional unit tests --- .../Update/ImportStaticPagesTest.php | 3 +- tests/modules/setup/forms/HomePageTest.php | 103 ++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 tests/modules/setup/forms/HomePageTest.php diff --git a/tests/library/Application/Update/ImportStaticPagesTest.php b/tests/library/Application/Update/ImportStaticPagesTest.php index 885182e5af..a746f0ff21 100644 --- a/tests/library/Application/Update/ImportStaticPagesTest.php +++ b/tests/library/Application/Update/ImportStaticPagesTest.php @@ -77,10 +77,11 @@ public function testImportFilesAsKey() $database = new \Opus\Translate\Dao(); - $translations = $database->getAll(); + $translations = $database->getTranslationsWithModules(); $this->assertCount(1, $translations); $this->assertArrayHasKey('testkey', $translations); + $this->assertEquals('home', $translations['testkey']['module']); } public function testGetFiles() diff --git a/tests/modules/setup/forms/HomePageTest.php b/tests/modules/setup/forms/HomePageTest.php new file mode 100644 index 0000000000..c7070996ec --- /dev/null +++ b/tests/modules/setup/forms/HomePageTest.php @@ -0,0 +1,103 @@ + + * @copyright Copyright (c) 2021, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +class Setup_Form_HomePageTest extends ControllerTestCase +{ + + protected $additionalResources = 'Translation'; + + private $database; + + public function setUp() + { + parent::setUp(); + + $this->database = new \Opus\Translate\Dao(); + $this->database->removeAll(); + } + + public function tearDown() + { + $this->database->removeAll(); + + parent::tearDown(); + } + + public function testInit() + { + $form = new Setup_Form_HomePage(); + + $element = $form->getElement('home_index_index_pagetitle'); + $this->assertNotNull($element); + $this->assertEquals([ + 'en' => 'Home', + 'de' => 'Einstieg' + ], $element->getValue()); + } + + public function testUpdatingTranslations() + { + $key = 'home_index_index_pagetitle'; + + $this->database->setTranslation($key, [ + 'en' => 'TestHome', + 'de' => 'TestEinstieg' + ], null); + + $translations = $this->database->getTranslationsWithModules(); + + $this->assertArrayHasKey($key, $translations); + $this->assertEmpty($translations[$key]['module']); + + $form = new Setup_Form_HomePage(); + + $element = $form->getElement($key); + + $change = [ + 'en' => 'Homepage', + 'de' => 'Startseite' + ]; + + $element->setValue($change); + + $form->updateTranslations(); + + $database = $this->database; + + $translations = $database->getTranslationsWithModules(); + + $this->assertCount(1, $translations); + $this->assertArrayHasKey($key, $translations); + $this->assertEquals('home', $translations[$key]['module']); + } +} \ No newline at end of file From ac9b9350897dc12fda18ce924d9c3dc9cd062def Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 22 Apr 2021 16:35:13 +0200 Subject: [PATCH 136/270] OPUSVIER-4527 Clear translations in tearDown --- tests/modules/setup/forms/HomePageTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/modules/setup/forms/HomePageTest.php b/tests/modules/setup/forms/HomePageTest.php index c7070996ec..cc75ef3715 100644 --- a/tests/modules/setup/forms/HomePageTest.php +++ b/tests/modules/setup/forms/HomePageTest.php @@ -49,6 +49,9 @@ public function setUp() public function tearDown() { $this->database->removeAll(); + $translate = Application_Translate::getInstance(); + $translate->clearCache(); + \Zend_Translate::clearCache(); parent::tearDown(); } @@ -76,6 +79,7 @@ public function testUpdatingTranslations() $translations = $this->database->getTranslationsWithModules(); + $this->assertCount(1, $translations); $this->assertArrayHasKey($key, $translations); $this->assertEmpty($translations[$key]['module']); From a61571d11db344edfbc1d3f905b3c1e843e0aec8 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 22 Apr 2021 17:25:03 +0200 Subject: [PATCH 137/270] OPUSVIER-4527 More testing --- .../Form/Element/TranslationTest.php | 34 +++++++++++++++++++ tests/modules/setup/forms/HomePageTest.php | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/library/Application/Form/Element/TranslationTest.php b/tests/library/Application/Form/Element/TranslationTest.php index 0fba9ad77c..8978f53b49 100644 --- a/tests/library/Application/Form/Element/TranslationTest.php +++ b/tests/library/Application/Form/Element/TranslationTest.php @@ -208,4 +208,38 @@ public function testValuesAreNotTranslated() $this->assertNotContains('id="DisplayName-de" value="Institut"', $output); $this->assertContains('id="DisplayName-de" value="Institute"', $output); } + + public function testUpdateTranslationForDuplicateKey() + { + $database = new \Opus\Translate\Dao(); + $database->removeAll(); + + $key = 'duplicateTestKey'; + + $database->setTranslation($key, [ + 'en' => 'AdminEn', + 'de' => 'AdminDe' + ], 'admin'); + + $database->setTranslation($key, [ + 'en' => 'HomeEn', + 'de' => 'HomeDe' + ], 'home'); + + $element = new Application_Form_Element_Translation('DuplicateTest'); + + $data = [ + 'en' => 'NewEn', + 'de' => 'NewDe' + ]; + + $element->setValue($data); + + $element->updateTranslations($key); + + $translations = $database->getTranslationsWithModules(); + + // var_dump($translations); + $this-markTestIncomplete('no assertions'); + } } diff --git a/tests/modules/setup/forms/HomePageTest.php b/tests/modules/setup/forms/HomePageTest.php index cc75ef3715..960d27165f 100644 --- a/tests/modules/setup/forms/HomePageTest.php +++ b/tests/modules/setup/forms/HomePageTest.php @@ -104,4 +104,4 @@ public function testUpdatingTranslations() $this->assertArrayHasKey($key, $translations); $this->assertEquals('home', $translations[$key]['module']); } -} \ No newline at end of file +} From 12463347d3dcbd313fa0992b2670c0745b79c7f5 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 22 Apr 2021 20:09:41 +0200 Subject: [PATCH 138/270] OPUSVIER-4527 Fixed typo. --- tests/library/Application/Form/Element/TranslationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/library/Application/Form/Element/TranslationTest.php b/tests/library/Application/Form/Element/TranslationTest.php index 8978f53b49..a6294a6636 100644 --- a/tests/library/Application/Form/Element/TranslationTest.php +++ b/tests/library/Application/Form/Element/TranslationTest.php @@ -240,6 +240,6 @@ public function testUpdateTranslationForDuplicateKey() $translations = $database->getTranslationsWithModules(); // var_dump($translations); - $this-markTestIncomplete('no assertions'); + $this->markTestIncomplete('no assertions'); } } From 3a7c165c7163df82d7ec34dade506369d05b0e21 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Thu, 22 Apr 2021 22:47:54 +0200 Subject: [PATCH 139/270] OPUSVIER-4038 Configurable base URL --- application/configs/application.ini | 3 ++- application/configs/config.ini.template | 4 ++++ library/Application/Bootstrap.php | 25 ++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/application/configs/application.ini b/application/configs/application.ini index 4561bbee9f..6c8a69eb35 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -79,8 +79,9 @@ security = 1 workspacePath = APPLICATION_PATH "/workspace" version = 4.7.0.4 update.latestVersionCheckUrl = "https://api.github.com/repos/opus4/application/releases/latest" + ; base URL of your OPUS instance (used for generating absolute URLs, e.g. in email messages) -url = 'https://web.example.org/opus' +url = ; OAI SETTINGS oai.repository.name = diff --git a/application/configs/config.ini.template b/application/configs/config.ini.template index c52858a6d8..ccee327226 100644 --- a/application/configs/config.ini.template +++ b/application/configs/config.ini.template @@ -39,6 +39,10 @@ ; Name of OPUS 4 Repository name = 'OPUS 4' +; Base URL of OPUS 4 (used for generating absolute URLs) +; This needs to be configured if OPUS 4 is running behind a proxy. +url = + ; Link for main logo logoLink = home diff --git a/library/Application/Bootstrap.php b/library/Application/Bootstrap.php index 0949d4314e..efc52b45a3 100644 --- a/library/Application/Bootstrap.php +++ b/library/Application/Bootstrap.php @@ -39,7 +39,7 @@ * @author Simone Finkbeiner (simone.finkbeiner@ub.uni-stuttgart.de) * @author Jens Schwidder * @author Michael Lang - * @copyright Copyright (c) 2008-2020, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License * * TODO unit test bootstrap @@ -164,6 +164,29 @@ protected function _initView() return $view; } + /** + * Set base URL if it has been configured. + * + * This is useful when running OPUS 4 behind a proxy, so absolute URLs will be resolved correctly. + * + * @throws Zend_Application_Bootstrap_Exception + */ + protected function _initBaseUrl() + { + $this->bootstrap('View'); + + $view = $this->getResource('View'); + $config = $this->getResource('Configuration'); + + if (isset($config->url)) { + $baseUrl = $config->url; + } + + if (! empty($baseUrl)) { + $view->getHelper('BaseUrl')->setBaseUrl($baseUrl); + } + } + /** * Setup \Zend_Cache for caching application data and register under '\Zend_Cache_Page'. * From 55a83c41af983e0ccda14c6e0d7805fe7e827ac6 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 23 Apr 2021 15:35:50 +0200 Subject: [PATCH 140/270] OPUSVIER-4038 Use serverUrl and baseUrl --- library/Application/Bootstrap.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/library/Application/Bootstrap.php b/library/Application/Bootstrap.php index efc52b45a3..7f1da915f0 100644 --- a/library/Application/Bootstrap.php +++ b/library/Application/Bootstrap.php @@ -183,7 +183,21 @@ protected function _initBaseUrl() } if (! empty($baseUrl)) { - $view->getHelper('BaseUrl')->setBaseUrl($baseUrl); + $urlParts = parse_url($baseUrl); + + // setting server url + $helper = $view->getHelper('ServerUrl'); + if (isset($urlParts['scheme'])) { + $helper->setScheme($urlParts['scheme']); + } + if (isset($urlParts['host'])) { + $helper->setHost($urlParts['host']); + } + + // setting base url + if (isset($urlParts['path'])) { + $view->getHelper('BaseUrl')->setBaseUrl($urlParts['path']); + } } } From f999020074b070a701661c3e466273b5ca8ec3ef Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 26 Apr 2021 11:20:53 +0200 Subject: [PATCH 141/270] OPUSVIER-4508 Render links using Zend helpers --- modules/admin/controllers/OailinkController.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/admin/controllers/OailinkController.php b/modules/admin/controllers/OailinkController.php index ff52703380..b3a13cad54 100644 --- a/modules/admin/controllers/OailinkController.php +++ b/modules/admin/controllers/OailinkController.php @@ -27,7 +27,8 @@ * @category Application * @package Module_Admin * @author Henning Gerhardt (henning.gerhardt@slub-dresden.de) - * @copyright Copyright (c) 2008-2018, OPUS 4 development team + * @author Jens Schwidder + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ @@ -47,19 +48,16 @@ class Admin_OailinkController extends Application_Controller_Action */ public function indexAction() { - $this->view->title = $this->view->translate('admin_title_oailink'); + $view = $this->view; - $request = $this->getRequest(); + $view->title = $this->view->translate('admin_title_oailink'); // set baseLink for OAI requests - $baseUrl = $request->getBaseUrl(); - $baseHost = $request->getHttpHost(); - $baseScheme = $request->getScheme(); - $this->view->baseLink = $baseScheme . '://' . $baseHost . $baseUrl . '/oai'; + $view->baseLink = $view->serverUrl($view->baseUrl('/oai')); // set repIdentifier for OAI request examples $config = $this->getConfig(); $repIdentifier = $config->oai->repository->identifier; - $this->view->repIdentifier = $repIdentifier; + $view->repIdentifier = $repIdentifier; } } From 04fa6382d9606cff94f4184b8b8a509eebc64244 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 26 Apr 2021 12:39:02 +0200 Subject: [PATCH 142/270] OPUSVIER-4507 Use Zend helper for baseUrl --- modules/export/models/XmlExport.php | 10 ++++++---- modules/export/views/scripts/publist/default.xslt | 1 - .../views/scripts/stylesheets-custom/example.xslt | 6 ++---- modules/export/views/scripts/stylesheets/export.xslt | 6 ++---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/modules/export/models/XmlExport.php b/modules/export/models/XmlExport.php index bda2484547..2889bff451 100644 --- a/modules/export/models/XmlExport.php +++ b/modules/export/models/XmlExport.php @@ -204,10 +204,12 @@ protected function loadStyleSheet($stylesheet) $this->_xslt = new DomDocument; $this->_xslt->load($stylesheet); $this->_proc->importStyleSheet($this->_xslt); - if (isset($_SERVER['HTTP_HOST'])) { - $this->_proc->setParameter('', 'host', $_SERVER['HTTP_HOST']); - } - $this->_proc->setParameter('', 'server', $this->getRequest()->getBaseUrl()); + + $view = $this->getView(); + + $this->_proc->setParameter('', 'host', $view->serverUrl()); // TODO remove - use opusUrl + $this->_proc->setParameter('', 'server', $view->baseUrl()); // TODO remove - use opusUrl + $this->_proc->setParameter('', 'opusUrl', $view->fullUrl()); } /** diff --git a/modules/export/views/scripts/publist/default.xslt b/modules/export/views/scripts/publist/default.xslt index e27a420139..5cbec2fb41 100644 --- a/modules/export/views/scripts/publist/default.xslt +++ b/modules/export/views/scripts/publist/default.xslt @@ -32,7 +32,6 @@ * @author Edouard Simon * @copyright Copyright (c) 2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License - * @version $Id$ */ --> diff --git a/modules/export/views/scripts/stylesheets-custom/example.xslt b/modules/export/views/scripts/stylesheets-custom/example.xslt index 1ed6bcb990..74d06dc87f 100644 --- a/modules/export/views/scripts/stylesheets-custom/example.xslt +++ b/modules/export/views/scripts/stylesheets-custom/example.xslt @@ -40,8 +40,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - + @@ -215,8 +214,7 @@ https:// - - + /files/ / diff --git a/modules/export/views/scripts/stylesheets/export.xslt b/modules/export/views/scripts/stylesheets/export.xslt index 97a4d20689..8b22f62d8b 100644 --- a/modules/export/views/scripts/stylesheets/export.xslt +++ b/modules/export/views/scripts/stylesheets/export.xslt @@ -44,8 +44,7 @@ TODO export as ZIP/TAR xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - + @@ -276,8 +275,7 @@ TODO export as ZIP/TAR https:// - - + /files/ / From 094de33bfa1336315aa1ea70d3416aaec57ab7fb Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 26 Apr 2021 14:11:49 +0200 Subject: [PATCH 143/270] OPUSVIER-4507 Fixed test and example export XSLT --- library/Application/Bootstrap.php | 2 ++ .../scripts/stylesheets-custom/example.xslt | 1 - .../export/controllers/IndexControllerTest.php | 16 ++++++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/library/Application/Bootstrap.php b/library/Application/Bootstrap.php index 7f1da915f0..886fa607bf 100644 --- a/library/Application/Bootstrap.php +++ b/library/Application/Bootstrap.php @@ -170,6 +170,8 @@ protected function _initView() * This is useful when running OPUS 4 behind a proxy, so absolute URLs will be resolved correctly. * * @throws Zend_Application_Bootstrap_Exception + * + * TODO \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4'); TODO is this useful */ protected function _initBaseUrl() { diff --git a/modules/export/views/scripts/stylesheets-custom/example.xslt b/modules/export/views/scripts/stylesheets-custom/example.xslt index 74d06dc87f..5fbfc00e4f 100644 --- a/modules/export/views/scripts/stylesheets-custom/example.xslt +++ b/modules/export/views/scripts/stylesheets-custom/example.xslt @@ -213,7 +213,6 @@ - https:// /files/ diff --git a/tests/modules/export/controllers/IndexControllerTest.php b/tests/modules/export/controllers/IndexControllerTest.php index 4780faeef4..69767a06e7 100644 --- a/tests/modules/export/controllers/IndexControllerTest.php +++ b/tests/modules/export/controllers/IndexControllerTest.php @@ -29,7 +29,7 @@ * @author Sascha Szott * @author Michael Lang * @author Jens Schwidder - * @copyright Copyright (c) 2008-2019, OPUS 4 development team + * @copyright Copyright (c) 2008-2021, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License */ @@ -892,15 +892,19 @@ public function testXmlExportDoesNotContainUnpublishedDocument() /** * Regressionstest für OPUSVIER-3391. - * // TODO insert host + * // TODO refactor - bootstrapping happens before so the helpers need to be adjusted - better way? */ public function testExportedFilePath() { - \Zend_Controller_Front::getInstance()->setBaseUrl('opus4dev'); + $opusUrl = 'https://localhost/opus4'; + + $view = $this->getView(); + $view->getHelper('ServerUrl')->setHost('localhost'); + $view->getHelper('ServerUrl')->setScheme('https'); + \Zend_Controller_Front::getInstance()->setBaseUrl('/opus4'); + $this->dispatch('/export/index/index/docId/146/export/xml/stylesheet/example/searchtype/id'); - $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; - $server = $this->getRequest()->getBasePath(); - $this->assertXpathContentContains('//file', 'https://' . $host . $server . '/files/146/test.pdf'); + $this->assertXpathContentContains('//file', $opusUrl . '/files/146/test.pdf'); } /** From 6c82bbfad4ddbf86b4751d20b6c5dc7d1fdc863f Mon Sep 17 00:00:00 2001 From: j3nsch Date: Mon, 26 Apr 2021 15:22:20 +0200 Subject: [PATCH 144/270] OPUSVIER-4038 Updated release notes; Removed old variables --- RELEASE_NOTES.md | 17 +++++++++++++++++ modules/export/models/XmlExport.php | 2 -- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 8cc5ffe085..1c6d5d61fc 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,6 +4,16 @@ ## Release 4.7.1 +# Konfiguration + +Der Parameter `url` kann verwendet werden, um die absolute URL für eine OPUS 4 +Instanz manuell zu setzen. Diese URL wird dann verwendet, um absolute Links, +z.B. in Exporten oder E-Mails, zu generieren. + + url = 'https://opus4mig.kobv.de/opus4-demo' + +URLs mit Port werden momentan nicht unterstützt. + # Neues Kommandozeilen-Skript `bin/opus4` Es gibt das neue Skript `bin/opus4`, dass in Zukunft die Rolle des zentralen OPUS 4 @@ -30,6 +40,13 @@ aus dem Index zu entfernen. Es kann über eine Option bestimmt werden wie viele Dokument gleichzeitig zum Solr-Server geschickt werden sollen. Das kann helfen, wenn es Probleme bei der Indexierung gibt. +# Export + +Die beiden Variablen `host` und `server` in den Export-XSLT Skripten wurden durch +die Variable `opusUrl` ersetzt. Eigene Skripte, die diese Variablen einsetzen, +müssen angepasst werden. Die neue Variable `opusUrl` enthält die absolute URL für +die OPUS 4 Instanz. + # OPUS Framework Package ## API diff --git a/modules/export/models/XmlExport.php b/modules/export/models/XmlExport.php index 2889bff451..26cde8c0a2 100644 --- a/modules/export/models/XmlExport.php +++ b/modules/export/models/XmlExport.php @@ -207,8 +207,6 @@ protected function loadStyleSheet($stylesheet) $view = $this->getView(); - $this->_proc->setParameter('', 'host', $view->serverUrl()); // TODO remove - use opusUrl - $this->_proc->setParameter('', 'server', $view->baseUrl()); // TODO remove - use opusUrl $this->_proc->setParameter('', 'opusUrl', $view->fullUrl()); } From 44db51c4902915f310c904fb18ef147e050f1b57 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 7 May 2021 17:09:27 +0200 Subject: [PATCH 145/270] OPUSVIER-4542 Add PhpMetrics to application --- composer.json | 6 ++++-- phpmetrics.json | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 phpmetrics.json diff --git a/composer.json b/composer.json index e47b351350..881bd778ff 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,8 @@ "mayflower/php-codebrowser": "~1.1", "squizlabs/php_codesniffer": "2.*", "opus4-repo/codesniffer": "dev-master", - "zendframework/zend-coding-standard": "~1.0.0" + "zendframework/zend-coding-standard": "~1.0.0", + "phpmetrics/phpmetrics": "2.7.4" }, "minimum-stability": "dev", "prefer-stable": true, @@ -75,6 +76,7 @@ "phpmd": "phpmd library xml cleancode,unusedcode,design,naming --reportfile build/phpmd.xml --ignore-violations-on-exit", "phploc": "phploc --log-csv build/phploc.csv src", "phpcpd": "phpcpd . --min-lines 3 --min-tokens 30 --log-pmd build/pmd-cpd.xml --progress || true", - "index": "bin/opus4 index:index" + "index": "bin/opus4 index:index", + "metrics": "phpmetrics --config=phpmetrics.json" } } diff --git a/phpmetrics.json b/phpmetrics.json new file mode 100644 index 0000000000..867e867903 --- /dev/null +++ b/phpmetrics.json @@ -0,0 +1,13 @@ +{ + "includes": [ + "library", + "modules", + "scripts" + ], + "exclude": [ + ], + "report": { + "html": "build/metrics/", + "violations": "build/violations.xml" + } +} From 2093c927a9dc8cc2b1840fbfd38e58996c84a1f9 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 7 May 2021 17:19:13 +0200 Subject: [PATCH 146/270] OPUSVIER-4547 Centralize instantiation of Searcher object --- .../Application/Search/SearcherFactory.php | 53 +++++++++++++++++++ .../frontdoor/controllers/IndexController.php | 2 +- modules/rss/controllers/IndexController.php | 2 +- .../controllers/BrowseController.php | 4 +- modules/solrsearch/models/Search/Abstract.php | 2 +- .../home/controllers/IndexControllerTest.php | 2 +- .../controllers/IndexControllerTest.php | 7 +++ 7 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 library/Application/Search/SearcherFactory.php diff --git a/library/Application/Search/SearcherFactory.php b/library/Application/Search/SearcherFactory.php new file mode 100644 index 0000000000..331d40331d --- /dev/null +++ b/library/Application/Search/SearcherFactory.php @@ -0,0 +1,53 @@ + + * @copyright Copyright (c) 2021, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +use Opus\Search\Util\Searcher; + +/** + * Factory for searcher objects. + * + * TODO factory should be injected into objects that need it + */ +class SearcherFactory +{ + + /** + * @return Searcher Configured Searcher object + */ + public static function getSearcher() + { + $searcher = new Searcher(); + $searcher->setAcl(Application_Security_AclProvider::getAcl()); + return $searcher; + } +} diff --git a/modules/frontdoor/controllers/IndexController.php b/modules/frontdoor/controllers/IndexController.php index 0654007a41..25cb0a0ea5 100644 --- a/modules/frontdoor/controllers/IndexController.php +++ b/modules/frontdoor/controllers/IndexController.php @@ -307,7 +307,7 @@ protected function handleSearchResultNavigation() // TODO fix usage of search code - should be identical to search/export/rss - except just 1 row - $searcher = new Opus\Search\Util\Searcher(); + $searcher = SearcherFactory::getSearcher(); $resultList = $searcher->search($query); diff --git a/modules/rss/controllers/IndexController.php b/modules/rss/controllers/IndexController.php index 3c4f1978d7..3781a0eba5 100644 --- a/modules/rss/controllers/IndexController.php +++ b/modules/rss/controllers/IndexController.php @@ -88,7 +88,7 @@ public function indexAction() $resultList = []; try { - $searcher = new Opus\Search\Util\Searcher(); + $searcher = SearcherFactory::getSearcher(); $resultList = $searcher->search($search->createSearchQuery($params)); } catch (Opus\Search\Exception $exception) { $this->handleSolrError($exception); diff --git a/modules/solrsearch/controllers/BrowseController.php b/modules/solrsearch/controllers/BrowseController.php index 8909a77c67..313c53b90f 100644 --- a/modules/solrsearch/controllers/BrowseController.php +++ b/modules/solrsearch/controllers/BrowseController.php @@ -70,7 +70,7 @@ public function doctypesAction() $query->setFacetField($facetname); try { - $searcher = new Opus\Search\Util\Searcher(); + $searcher = SearcherFactory::getSearcher(); $facets = $searcher->search($query)->getFacets(); } catch (Opus\Search\Exception $e) { $this->getLogger()->err(__METHOD__ . ' : ' . $e); @@ -103,7 +103,7 @@ public function yearsAction() $query->setFacetField($indexField); try { - $searcher = new Opus\Search\Util\Searcher(); + $searcher = SearcherFactory::getSearcher(); $facets = $searcher->search($query)->getFacets(); } catch (Opus\Search\Exception $ose) { $this->getLogger()->err(__METHOD__ . ' : ' . $ose); diff --git a/modules/solrsearch/models/Search/Abstract.php b/modules/solrsearch/models/Search/Abstract.php index caf96f01d6..2d110036ff 100644 --- a/modules/solrsearch/models/Search/Abstract.php +++ b/modules/solrsearch/models/Search/Abstract.php @@ -444,7 +444,7 @@ public function performSearch($query, $openFacets = null) $resultList = null; try { - $searcher = new Opus\Search\Util\Searcher(); + $searcher = SearcherFactory::getSearcher(); if (! is_null($openFacets)) { $searcher->setFacetArray($openFacets); diff --git a/tests/modules/home/controllers/IndexControllerTest.php b/tests/modules/home/controllers/IndexControllerTest.php index 67a3e722f0..d080432c65 100644 --- a/tests/modules/home/controllers/IndexControllerTest.php +++ b/tests/modules/home/controllers/IndexControllerTest.php @@ -140,7 +140,7 @@ public function testNoticeAction() private function getDocsInSearchIndex($checkConsistency = true) { - $searcher = new Opus\Search\Util\Searcher(); + $searcher = SearcherFactory::getSearcher(); $query = new Opus\Search\Util\Query(); $query->setCatchAll("*:*"); $query->setRows(Opus\Search\Util\Query::MAX_ROWS); diff --git a/tests/modules/solrsearch/controllers/IndexControllerTest.php b/tests/modules/solrsearch/controllers/IndexControllerTest.php index 6c30e092c0..07e5d3e435 100644 --- a/tests/modules/solrsearch/controllers/IndexControllerTest.php +++ b/tests/modules/solrsearch/controllers/IndexControllerTest.php @@ -1413,4 +1413,11 @@ public function testAuthorSearchLinks() '//div[@class = "results_author"]/a[contains(@href, "solrsearch/index/search/searchtype/authorsearch/author/%22Doe%2C+John%22")]' ); } + + public function testServerStateFacetForAdmins() + { + $this->dispatch('/solrsearch/index/search/searchtype/latest'); + + $this->markTestIncomplete(); + } } From 88ff9403d9411b15d34aa302632fa8567d3614d3 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 7 May 2021 17:19:26 +0200 Subject: [PATCH 147/270] OPUSVIER-4547 Coding style --- library/Application/Search/QueryBuilderException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Application/Search/QueryBuilderException.php b/library/Application/Search/QueryBuilderException.php index 4bf10666bc..87992fdc96 100644 --- a/library/Application/Search/QueryBuilderException.php +++ b/library/Application/Search/QueryBuilderException.php @@ -25,7 +25,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @category Application - * @package Util + * @package Search * @author Sascha Szott * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License From d912aa4decaf99425e13763079a6fcf5f14f0859 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 7 May 2021 17:46:56 +0200 Subject: [PATCH 148/270] OPUSVIER-4547 Fixed classname --- library/Application/Search/SearcherFactory.php | 2 +- modules/frontdoor/controllers/IndexController.php | 2 +- modules/rss/controllers/IndexController.php | 2 +- modules/solrsearch/controllers/BrowseController.php | 4 ++-- modules/solrsearch/models/Search/Abstract.php | 2 +- tests/modules/home/controllers/IndexControllerTest.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library/Application/Search/SearcherFactory.php b/library/Application/Search/SearcherFactory.php index 331d40331d..315ab0ab99 100644 --- a/library/Application/Search/SearcherFactory.php +++ b/library/Application/Search/SearcherFactory.php @@ -38,7 +38,7 @@ * * TODO factory should be injected into objects that need it */ -class SearcherFactory +class Application_Search_SearcherFactory { /** diff --git a/modules/frontdoor/controllers/IndexController.php b/modules/frontdoor/controllers/IndexController.php index 25cb0a0ea5..eb548d12fd 100644 --- a/modules/frontdoor/controllers/IndexController.php +++ b/modules/frontdoor/controllers/IndexController.php @@ -307,7 +307,7 @@ protected function handleSearchResultNavigation() // TODO fix usage of search code - should be identical to search/export/rss - except just 1 row - $searcher = SearcherFactory::getSearcher(); + $searcher = Application_Search_SearcherFactory::getSearcher(); $resultList = $searcher->search($query); diff --git a/modules/rss/controllers/IndexController.php b/modules/rss/controllers/IndexController.php index 3781a0eba5..b2efd412b7 100644 --- a/modules/rss/controllers/IndexController.php +++ b/modules/rss/controllers/IndexController.php @@ -88,7 +88,7 @@ public function indexAction() $resultList = []; try { - $searcher = SearcherFactory::getSearcher(); + $searcher = Application_Search_SearcherFactory::getSearcher(); $resultList = $searcher->search($search->createSearchQuery($params)); } catch (Opus\Search\Exception $exception) { $this->handleSolrError($exception); diff --git a/modules/solrsearch/controllers/BrowseController.php b/modules/solrsearch/controllers/BrowseController.php index 313c53b90f..c3f4892911 100644 --- a/modules/solrsearch/controllers/BrowseController.php +++ b/modules/solrsearch/controllers/BrowseController.php @@ -70,7 +70,7 @@ public function doctypesAction() $query->setFacetField($facetname); try { - $searcher = SearcherFactory::getSearcher(); + $searcher = Application_Search_SearcherFactory::getSearcher(); $facets = $searcher->search($query)->getFacets(); } catch (Opus\Search\Exception $e) { $this->getLogger()->err(__METHOD__ . ' : ' . $e); @@ -103,7 +103,7 @@ public function yearsAction() $query->setFacetField($indexField); try { - $searcher = SearcherFactory::getSearcher(); + $searcher = Application_Search_SearcherFactory::getSearcher(); $facets = $searcher->search($query)->getFacets(); } catch (Opus\Search\Exception $ose) { $this->getLogger()->err(__METHOD__ . ' : ' . $ose); diff --git a/modules/solrsearch/models/Search/Abstract.php b/modules/solrsearch/models/Search/Abstract.php index 2d110036ff..de1f389ce5 100644 --- a/modules/solrsearch/models/Search/Abstract.php +++ b/modules/solrsearch/models/Search/Abstract.php @@ -444,7 +444,7 @@ public function performSearch($query, $openFacets = null) $resultList = null; try { - $searcher = SearcherFactory::getSearcher(); + $searcher = Application_Search_SearcherFactory::getSearcher(); if (! is_null($openFacets)) { $searcher->setFacetArray($openFacets); diff --git a/tests/modules/home/controllers/IndexControllerTest.php b/tests/modules/home/controllers/IndexControllerTest.php index d080432c65..6b97c5bc0c 100644 --- a/tests/modules/home/controllers/IndexControllerTest.php +++ b/tests/modules/home/controllers/IndexControllerTest.php @@ -140,7 +140,7 @@ public function testNoticeAction() private function getDocsInSearchIndex($checkConsistency = true) { - $searcher = SearcherFactory::getSearcher(); + $searcher = Application_Search_SearcherFactory::getSearcher(); $query = new Opus\Search\Util\Query(); $query->setCatchAll("*:*"); $query->setRows(Opus\Search\Util\Query::MAX_ROWS); From 093dae2bf01579b0bd9e1cde935d9a222e1e691b Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 7 May 2021 23:02:41 +0200 Subject: [PATCH 149/270] OPUSVIER-4547 Added unit test --- .../solrsearch/controllers/IndexControllerTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/modules/solrsearch/controllers/IndexControllerTest.php b/tests/modules/solrsearch/controllers/IndexControllerTest.php index 07e5d3e435..0e443d9063 100644 --- a/tests/modules/solrsearch/controllers/IndexControllerTest.php +++ b/tests/modules/solrsearch/controllers/IndexControllerTest.php @@ -1416,8 +1416,14 @@ public function testAuthorSearchLinks() public function testServerStateFacetForAdmins() { - $this->dispatch('/solrsearch/index/search/searchtype/latest'); + $this->enableSecurity(); + $this->loginUser('admin', 'adminadmin'); - $this->markTestIncomplete(); + $this->dispatch('/solrsearch/index/search/searchtype/all'); + + $this->assertXpath('//div[@id = "server_state_facet"]'); + $this->assertXpath('//div[@id = "server_state_facet"]//a[contains(@href, "server_statefq/published")]'); + $this->assertXpath('//div[@id = "server_state_facet"]//a[contains(@href, "server_statefq/unpublished")]'); + $this->assertXpath('//div[@id = "server_state_facet"]//a[contains(@href, "server_statefq/deleted")]'); } } From ec40217b5930289860626b0530c0a505914006a9 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 11 May 2021 10:31:35 +0200 Subject: [PATCH 150/270] OPUSVIER-4551 Fixed DOI config; added test --- application/configs/application.ini | 2 +- tests/library/DoiConfigTest.php | 51 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/library/DoiConfigTest.php diff --git a/application/configs/application.ini b/application/configs/application.ini index 6c8a69eb35..2199c4a7ee 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -378,7 +378,7 @@ doi.localPrefix = '' doi.suffixFormat = '' ; Klasse, die für die Generierung von DOIs zuständig ist. Die Defaultklasse unterstützt ausschließlich ; das SuffixFormat "${localPrefix}-${docId}" (daher wird der Wert von doi.suffixFormat wird nicht betrachtet). -doi.generatorClass = 'Opus_Doi_Generator_DefaultGenerator' +doi.generatorClass = 'Opus\Doi\Generator\DefaultGenerator' ; Nutzername für DataCite Metadata Store (MDS) doi.registration.datacite.username = '' ; Passwort für DataCite Metadata Store (MDS) diff --git a/tests/library/DoiConfigTest.php b/tests/library/DoiConfigTest.php new file mode 100644 index 0000000000..9367d93bc6 --- /dev/null +++ b/tests/library/DoiConfigTest.php @@ -0,0 +1,51 @@ + + * @copyright Copyright (c) 2021, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +use Opus\Doi\Generator\DoiGeneratorFactory; + +/** + * TODO move to opus4-doi + */ +class DoiConfigTest extends ControllerTestCase +{ + + /** + * Makes sure configuration in application.ini specifies an existing class. + */ + public function testDoiConfig() + { + $generator = DoiGeneratorFactory::create(); + + $this->assertNotNull($generator); + } +} From d536341bebea7734d7cd84374fcabf6a4b5aa0d3 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Tue, 18 May 2021 10:53:36 +0200 Subject: [PATCH 151/270] OPUSVIER-4550 Fixed creating DB users --- bin/install-database.sh | 6 ++++-- bin/install_mysql_docker.sh | 2 +- build.xml | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/install-database.sh b/bin/install-database.sh index 964dc34eb3..299ee31859 100755 --- a/bin/install-database.sh +++ b/bin/install-database.sh @@ -176,8 +176,10 @@ mysqlRoot() { mysqlRoot < have to be in one line export MYSQL_PWD=root \ - && mysql --default-character-set=utf8 -h 'localhost' -P '3306' -u 'root' -v -e "CREATE DATABASE IF NOT EXISTS opusdb DEFAULT CHARACTER SET = UTF8 DEFAULT COLLATE = UTF8_GENERAL_CI; GRANT ALL PRIVILEGES ON opusdb.* TO 'opus4'@'localhost' IDENTIFIED BY 'root'; GRANT SELECT,INSERT,UPDATE,DELETE ON opusdb.* TO 'opus4admin'@'localhost' IDENTIFIED BY 'root'; FLUSH PRIVILEGES;" + && mysql --default-character-set=utf8 -h 'localhost' -P '3306' -u 'root' -v -e "CREATE DATABASE IF NOT EXISTS opusdb DEFAULT CHARACTER SET = UTF8 DEFAULT COLLATE = UTF8_GENERAL_CI; CREATE USER 'opus4admin'@'localhost' IDENTIFIED BY 'root'; GRANT ALL PRIVILEGES ON opusdb.* TO 'opus4admin'@'localhost'; CREATE USER 'opus4'@'localhost' IDENTIFIED BY 'root'; GRANT SELECT,INSERT,UPDATE,DELETE ON opusdb.* TO 'opus4'@'localhost'; FLUSH PRIVILEGES;" diff --git a/build.xml b/build.xml index b8c90a9bc7..f9ea077f51 100644 --- a/build.xml +++ b/build.xml @@ -12,9 +12,9 @@ - + - + From 83963a16edc2365376f20e893bd9f732cdb051d6 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Thu, 27 May 2021 00:45:45 +0200 Subject: [PATCH 152/270] OPUSVIER-4459 --- .../admin/controllers/ImportController.php | 117 +++++++++++++++++ modules/admin/forms/Import.php | 120 ++++++++++++++++++ .../admin/views/scripts/documents/index.phtml | 6 +- .../admin/views/scripts/import/bibtex.phtml | 60 +++++++++ modules/default/language/admin.tmx | 20 ++- public/layouts/opus4/css/admin.css | 8 +- 6 files changed, 327 insertions(+), 4 deletions(-) create mode 100644 modules/admin/controllers/ImportController.php create mode 100644 modules/admin/forms/Import.php create mode 100644 modules/admin/views/scripts/import/bibtex.phtml diff --git a/modules/admin/controllers/ImportController.php b/modules/admin/controllers/ImportController.php new file mode 100644 index 0000000000..89e273b05b --- /dev/null +++ b/modules/admin/controllers/ImportController.php @@ -0,0 +1,117 @@ + + * @copyright Copyright (c) 2021, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +use Opus\Bibtex\Import\Console\Helper\BibtexImportHelper; +use Opus\Bibtex\Import\Console\Helper\BibtexImportResult; + +class Admin_ImportController extends Application_Controller_Action +{ + + public function bibtexAction() + { + $this->view->title = 'admin_import_bibtex'; + $request = $this->getRequest(); + $form = new Admin_Form_Import(); + if ($request->isPost()) { + $postData = $this->getRequest()->getPost(); + + if (! $form->isValid($postData)) { + // ['module' => 'admin', 'controller' => 'import', 'action' => 'bibtex'], + $this->_helper->Redirector->redirectTo( + 'bibtex', + ['failure' => 'missing file'], + 'import', + 'admin' + ); + return; + } + + $upload = new \Zend_File_Transfer_Adapter_Http(); + $files = $upload->getFileInfo(); + + if (count($files) > 0) { + $bibtexFile = $files['File']; + if (isset($bibtexFile['tmp_name'])) { + $bibtexImportResult = new BibtexImportResult(); + + $bibtexImportHelper = $this->createBibtexImportHelper($bibtexFile['tmp_name'], $postData); + $bibtexImportHelper->doImport($bibtexImportResult); + + $this->view->importResult = $bibtexImportResult->getMessages(); + $this->view->numDocsImported = $bibtexImportResult->getNumDocsImported(); + $this->view->numDocsProcessed = $bibtexImportResult->getNumDocsProcessed(); + } + } else { + // POST-Request ist zwar gültig; allerdings konnte keine Datei ausgelesen werden + $this->_helper->Redirector->redirectTo( + 'bibtex', + ['failure' => 'missing file'], + 'import', + 'admin' + ); + return; + } + } else { + // show upload form + $this->view->form = $form; + } + } + + private function createBibtexImportHelper($fileName, $postData) + { + $bibtexImportHelper = new BibtexImportHelper($fileName); + if (array_key_exists(Admin_Form_Import::ELEMENT_INI_FILENAME, $postData)) { + $bibtexImportHelper->setIniFileName($postData[Admin_Form_Import::ELEMENT_INI_FILENAME]); + } + + if (array_key_exists(Admin_Form_Import::ELEMENT_MAPPING_NAME, $postData)) { + $bibtexImportHelper->setMappingConfiguration($postData[Admin_Form_Import::ELEMENT_MAPPING_NAME]); + } + + if (array_key_exists(Admin_Form_Import::ELEMENT_COLLECTION_IDS, $postData)) { + $bibtexImportHelper->setCollectionIds($postData[Admin_Form_Import::ELEMENT_COLLECTION_IDS]); + } + + if (array_key_exists(Admin_Form_Import::ELEMENT_VERBOSE, $postData) && $postData[Admin_Form_Import::ELEMENT_VERBOSE] === '1') { + $bibtexImportHelper->enableVerbose(); + } + + if (array_key_exists(Admin_Form_Import::ELEMENT_DRY_MODE, $postData) && $postData[Admin_Form_Import::ELEMENT_DRY_MODE] === '1') { + $bibtexImportHelper->enableDryMode(); + } + + return $bibtexImportHelper; + } +} diff --git a/modules/admin/forms/Import.php b/modules/admin/forms/Import.php new file mode 100644 index 0000000000..75ffdd1f23 --- /dev/null +++ b/modules/admin/forms/Import.php @@ -0,0 +1,120 @@ + + * @copyright Copyright (c) 2021, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ + +/** + * Form for uploading metadata file, e.g. BibTeX file. + */ +class Admin_Form_Import extends Application_Form_Abstract +{ + + const ELEMENT_FILE = 'File'; + + const ELEMENT_VERBOSE = 'Verbose'; + + const ELEMENT_COLLECTION_IDS = 'CollectionIds'; + + const ELEMENT_DRY_MODE = 'DryMode'; + + const ELEMENT_IMPORT = 'Import'; + + const ELEMENT_MAPPING_NAME = 'MappingName'; + + const ELEMENT_INI_FILENAME = 'IniFilename'; + + public function init() + { + parent::init(); + + $this->addElement( + 'file', + self::ELEMENT_FILE, + [ + 'label' => 'admin_import_file', + 'required' => true + ] + ); + + $this->addElement( + 'text', + self::ELEMENT_INI_FILENAME, + [ + 'label' => 'admin_import_ini_filename', + 'size' => 50 + ] + ); + + $this->addElement( + 'text', + self::ELEMENT_MAPPING_NAME, + [ + 'label' => 'admin_import_mapping_name', + 'size' => 50 + ] + ); + + $this->addElement( + 'text', + self::ELEMENT_COLLECTION_IDS, + [ + 'label' => 'admin_import_collection_ids', + 'size' => 50 + ] + ); + + $this->addElement( + 'checkbox', + self::ELEMENT_VERBOSE, + [ + 'label' => 'admin_import_verbose' + ] + ); + + $this->addElement( + 'checkbox', + self::ELEMENT_DRY_MODE, + [ + 'label' => 'admin_import_dry_mode' + ] + ); + + $this->addElement( + 'submit', + self::ELEMENT_IMPORT + ); + + $this->setDecorators([ + 'FormElements', + 'Form' + ]); + } +} diff --git a/modules/admin/views/scripts/documents/index.phtml b/modules/admin/views/scripts/documents/index.phtml index 7416a212c4..d236252526 100644 --- a/modules/admin/views/scripts/documents/index.phtml +++ b/modules/admin/views/scripts/documents/index.phtml @@ -86,9 +86,11 @@ -
+
diff --git a/modules/admin/views/scripts/import/bibtex.phtml b/modules/admin/views/scripts/import/bibtex.phtml new file mode 100644 index 0000000000..c78b1c3558 --- /dev/null +++ b/modules/admin/views/scripts/import/bibtex.phtml @@ -0,0 +1,60 @@ + + * @copyright Copyright (c) 2021, OPUS 4 development team + * @license http://www.gnu.org/licenses/gpl.html General Public License + */ +?> +

BibTeX Import

+ +

+ +form ?> + +importResult)) : ?> +

+ translate('admin_import_bibtex_label_output')?> +

+

+

+importResult as $line):
+    echo "$line\n";
+endforeach; ?>
+
+

+

+

+ translate('admin_import_bibtex_label_num_docs_processed')?>: numDocsProcessed ?> +
+
+ translate('admin_import_bibtex_label_num_docs_imported')?>: numDocsImported ?> +
+

+ diff --git a/modules/default/language/admin.tmx b/modules/default/language/admin.tmx index 30477dbd85..0f0eea0bee 100644 --- a/modules/default/language/admin.tmx +++ b/modules/default/language/admin.tmx @@ -200,7 +200,25 @@ Create new document and open it for editing. - Neues document erzeugen und zum Editieren öffnen. + Neues Dokument erzeugen und zum Editieren öffnen. + + + + + + Import BibTeX + + + BibTeX-Import + + + + + + Import documents from BibTeX file. + + + Importiert Dokumente aus einer BibTeX-Datei. diff --git a/public/layouts/opus4/css/admin.css b/public/layouts/opus4/css/admin.css index 2b59c4a1e2..d19062662e 100644 --- a/public/layouts/opus4/css/admin.css +++ b/public/layouts/opus4/css/admin.css @@ -2532,8 +2532,14 @@ a.link-button:hover { color: white; } -a.create-document-link { +div.create-document-link { float: right; + display: block; +} + +div.preformatted { + font-family: monospace; + white-space: pre; } #enrichmentkeyTable span.strong { From 887026dbe2d4d4ca26d6ffca5fe10e3528ff43a4 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Thu, 27 May 2021 10:51:39 +0200 Subject: [PATCH 153/270] OPUSVIER-4459: add BibTeX import command to App.php --- library/Application/Console/App.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/Application/Console/App.php b/library/Application/Console/App.php index d22e975ff6..2f022b2cf3 100644 --- a/library/Application/Console/App.php +++ b/library/Application/Console/App.php @@ -35,6 +35,7 @@ use Opus\Search\Console\RemoveCommand; use Opus\Search\Console\ExtractCommand; use Opus\Search\Console\ExtractFileCommand; +use Opus\Bibtex\Import\Console\BibtexImportCommand; use Symfony\Component\Console\Application; /** @@ -54,6 +55,7 @@ public function __construct() // $this->add(new Application_Console_Index_RepairCommand()); // $this->add(new Application_Console_Index_CheckCommand()); $this->add(new Application_Console_Document_DeleteCommand()); + $this->add(new BibtexImportCommand()); $this->setDefaultCommand('list'); } From ba371e7ed933e456eddcbe89d7eb7315339c984b Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Thu, 27 May 2021 10:54:00 +0200 Subject: [PATCH 154/270] OPUSVIER-4459: add link to bibtex action of import controller --- modules/admin/controllers/DocumentsController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/admin/controllers/DocumentsController.php b/modules/admin/controllers/DocumentsController.php index 6ff346f1d9..9fa98a2e3d 100644 --- a/modules/admin/controllers/DocumentsController.php +++ b/modules/admin/controllers/DocumentsController.php @@ -215,6 +215,12 @@ public function indexAction() 'default', true ); + + $this->view->bibtexImportLink = $this->view->url( + ['module' => 'admin', 'controller' => 'import', 'action' => 'bibtex'], + 'default', + true + ); } /** From 114fa2869c89d355182ef88b1f8e4987238d0cb1 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Sat, 29 May 2021 13:02:28 +0200 Subject: [PATCH 155/270] OPUSVIER-4459: changed name of CSS class of document action links --- modules/admin/views/scripts/documents/index.phtml | 2 +- public/layouts/opus4/css/admin.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/admin/views/scripts/documents/index.phtml b/modules/admin/views/scripts/documents/index.phtml index d236252526..a1d51946bb 100644 --- a/modules/admin/views/scripts/documents/index.phtml +++ b/modules/admin/views/scripts/documents/index.phtml @@ -86,7 +86,7 @@ -