Skip to content

Commit d598874

Browse files
authored
Merge pull request #997 from OPUS4/css996
Neues, moderneres CSS für OPUS 4
2 parents 63a1493 + f2df75c commit d598874

File tree

106 files changed

+22742
-3089
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+22742
-3089
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ tests/workspace/**/*
3434
cache.properties
3535

3636
downloads
37-
components
3837

3938
# ignore files generated by processing templates
4039
opus4-solr-jetty.conf

application/configs/application.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ workspacePath = APPLICATION_PATH "/workspace"
7373
version = 4.8
7474
update.latestVersionCheckUrl = "https://api.github.com/repos/opus4/application/releases/latest"
7575

76+
; THEMES
77+
; only the 'opus4' layout uses the new CSS view helpers
78+
themes.legacyCss = false
79+
themes.selectedTheme = default
80+
81+
; Avaiable themes (containing CSS variables for color scheme)
82+
themes.theme.default = Default
83+
themes.theme.negative = Negative
84+
themes.theme.custom = Custom
85+
7686
; Determines the implementation of the OPUS 4 data model
7787
modelFactory = 'Opus\ModelFactory'
7888
model.fieldDescriptorClass = "Opus\Db\Model\DbFieldDescriptor"

application/configs/navigationModules.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,17 @@
859859
</pages>
860860
<resource>translations</resource>
861861
</translation>
862-
-->
862+
863+
<appearance>
864+
<type>mvc</type>
865+
<label>setup_title_appearance</label>
866+
<description>setup_title_appearance_description</description>
867+
<group>group-cafelatte</group>
868+
<module>setup</module>
869+
<controller>appearance</controller>
870+
<action>index</action>
871+
<resource>setup</resource>
872+
</appearance>
863873
</pages>
864874
</setup>
865875

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"opus4-repo/framework": "dev-master as 4.8.1",
2727
"opus4-repo/search": "4.7.3.x-dev || 4.8.1.x-dev",
2828
"opus4-repo/opus4-bibtex": "^4.8",
29-
"opus4-repo/opus4-import": "^4.8",
29+
"opus4-repo/opus4-import": "dev-main as 4.8.1",
3030
"opus4-repo/opus4-pdf": "^4.8",
3131
"opus4-repo/opus4-job": ">4.8",
3232
"opus4-repo/opus4-security": "^4.8",

library/Application/Configuration.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,17 +247,26 @@ public static function getOpusInfo()
247247
/**
248248
* Saves configuration as XML file.
249249
*
250-
* @param Zend_Config $config
250+
* @param Zend_Config $update
251251
* @throws Zend_Config_Exception
252252
*/
253-
public static function save($config)
253+
public static function save($update)
254254
{
255+
$config = self::load();
256+
257+
$config->merge($update);
258+
255259
$writer = new Zend_Config_Writer_Xml();
256260
$writer->write(APPLICATION_PATH . '/application/configs/config.xml', $config);
257261
}
258262

263+
/**
264+
* @return Zend_Config_Xml
265+
* @throws Zend_Config_Exception
266+
*/
259267
public static function load()
260268
{
269+
return new Zend_Config_Xml(APPLICATION_PATH . '/application/configs/config.xml', null, true);
261270
}
262271

263272
/**
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
/**
4+
* This file is part of OPUS. The software OPUS has been originally developed
5+
* at the University of Stuttgart with funding from the German Research Net,
6+
* the Federal Department of Higher Education and Research and the Ministry
7+
* of Science, Research and the Arts of the State of Baden-Wuerttemberg.
8+
*
9+
* OPUS 4 is a complete rewrite of the original OPUS software and was developed
10+
* by the Stuttgart University Library, the Library Service Center
11+
* Baden-Wuerttemberg, the Cooperative Library Network Berlin-Brandenburg,
12+
* the Saarland University and State Library, the Saxon State Library -
13+
* Dresden State and University Library, the Bielefeld University Library and
14+
* the University Library of Hamburg University of Technology with funding from
15+
* the German Research Foundation and the European Regional Development Fund.
16+
*
17+
* LICENCE
18+
* OPUS is free software; you can redistribute it and/or modify it under the
19+
* terms of the GNU General Public License as published by the Free Software
20+
* Foundation; either version 2 of the Licence, or any later version.
21+
* OPUS is distributed in the hope that it will be useful, but WITHOUT ANY
22+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
24+
* details. You should have received a copy of the GNU General Public License
25+
* along with OPUS; if not, write to the Free Software Foundation, Inc., 51
26+
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
*
28+
* @copyright Copyright (c) 2023, OPUS 4 development team
29+
* @license http://www.gnu.org/licenses/gpl.html General Public License
30+
*/
31+
32+
use Opus\Common\Config;
33+
34+
/**
35+
* Form element for selecting theme (color scheme) for OPUS 4.
36+
*/
37+
class Application_Form_Element_ThemeSelect extends Application_Form_Element_Select
38+
{
39+
public function init()
40+
{
41+
parent::init();
42+
43+
$themes = $this->getThemes();
44+
45+
if ($themes !== null) {
46+
foreach ($themes as $name => $label) {
47+
$this->addMultiOption($name, $label);
48+
}
49+
}
50+
}
51+
52+
/**
53+
* @param string $value
54+
* @return $this
55+
*/
56+
public function setValue($value)
57+
{
58+
if (! array_key_exists($value, $this->getMultiOptions())) {
59+
return parent::setValue('default');
60+
} else {
61+
return parent::setValue($value);
62+
}
63+
}
64+
65+
/**
66+
* @return string[]
67+
*/
68+
protected function getThemes()
69+
{
70+
$config = Config::get();
71+
72+
$themes = null;
73+
74+
if (isset($config->themes->theme)) {
75+
$themes = $config->themes->theme->toArray();
76+
}
77+
78+
return $themes;
79+
}
80+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/**
4+
* This file is part of OPUS. The software OPUS has been originally developed
5+
* at the University of Stuttgart with funding from the German Research Net,
6+
* the Federal Department of Higher Education and Research and the Ministry
7+
* of Science, Research and the Arts of the State of Baden-Wuerttemberg.
8+
*
9+
* OPUS 4 is a complete rewrite of the original OPUS software and was developed
10+
* by the Stuttgart University Library, the Library Service Center
11+
* Baden-Wuerttemberg, the Cooperative Library Network Berlin-Brandenburg,
12+
* the Saarland University and State Library, the Saxon State Library -
13+
* Dresden State and University Library, the Bielefeld University Library and
14+
* the University Library of Hamburg University of Technology with funding from
15+
* the German Research Foundation and the European Regional Development Fund.
16+
*
17+
* LICENCE
18+
* OPUS is free software; you can redistribute it and/or modify it under the
19+
* terms of the GNU General Public License as published by the Free Software
20+
* Foundation; either version 2 of the Licence, or any later version.
21+
* OPUS is distributed in the hope that it will be useful, but WITHOUT ANY
22+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
24+
* details. You should have received a copy of the GNU General Public License
25+
* along with OPUS; if not, write to the Free Software Foundation, Inc., 51
26+
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
*
28+
* @copyright Copyright (c) 2023, OPUS 4 development team
29+
* @license http://www.gnu.org/licenses/gpl.html General Public License
30+
*/
31+
32+
use Opus\Common\Config;
33+
34+
class Application_View_Helper_ModuleCss extends Zend_View_Helper_Abstract
35+
{
36+
public function moduleCss()
37+
{
38+
$view = $this->view;
39+
40+
$theme = $this->getTheme();
41+
42+
$moduleCssFile = "module-{$view->moduleName}.css";
43+
44+
$moduleCssFilePath = APPLICATION_PATH . "/public/layouts/{$theme}/css/$moduleCssFile";
45+
46+
if (file_exists($moduleCssFilePath)) {
47+
$view->headLink()
48+
->prependStylesheet($view->layoutPath() . "/css/$moduleCssFile", 'screen,print');
49+
}
50+
}
51+
52+
/**
53+
* @return string
54+
*/
55+
public function getTheme()
56+
{
57+
$config = Config::get();
58+
$theme = 'opus4';
59+
if (isset($config->theme)) {
60+
$theme = $config->theme;
61+
}
62+
return $theme;
63+
}
64+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
/**
4+
* This file is part of OPUS. The software OPUS has been originally developed
5+
* at the University of Stuttgart with funding from the German Research Net,
6+
* the Federal Department of Higher Education and Research and the Ministry
7+
* of Science, Research and the Arts of the State of Baden-Wuerttemberg.
8+
*
9+
* OPUS 4 is a complete rewrite of the original OPUS software and was developed
10+
* by the Stuttgart University Library, the Library Service Center
11+
* Baden-Wuerttemberg, the North Rhine-Westphalian Library Service Center,
12+
* the Cooperative Library Network Berlin-Brandenburg, the Saarland University
13+
* and State Library, the Saxon State Library - Dresden State and University
14+
* Library, the Bielefeld University Library and the University Library of
15+
* Hamburg University of Technology with funding from the German Research
16+
* Foundation and the European Regional Development Fund.
17+
*
18+
* LICENCE
19+
* OPUS is free software; you can redistribute it and/or modify it under the
20+
* terms of the GNU General Public License as published by the Free Software
21+
* Foundation; either version 2 of the Licence, or any later version.
22+
* OPUS is distributed in the hope that it will be useful, but WITHOUT ANY
23+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
24+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
25+
* details. You should have received a copy of the GNU General Public License
26+
* along with OPUS; if not, write to the Free Software Foundation, Inc., 51
27+
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28+
*
29+
* @copyright Copyright (c) 2023, OPUS 4 development team
30+
* @license http://www.gnu.org/licenses/gpl.html General Public License
31+
*/
32+
33+
use Opus\Common\Config;
34+
35+
/**
36+
* Returns path to file containing the CSS variables for the selected theme.
37+
*/
38+
class Application_View_Helper_SelectedThemeCss extends Zend_View_Helper_Abstract
39+
{
40+
/**
41+
* Returns path to CSS for selected theme.
42+
*
43+
* @return string
44+
*/
45+
public function selectedThemeCss()
46+
{
47+
$config = Config::get();
48+
49+
$selectedTheme = 'default';
50+
51+
if (isset($config->themes)) {
52+
$themes = $config->themes;
53+
54+
if (isset($themes->selectedTheme)) {
55+
$selectedTheme = $themes->selectedTheme;
56+
57+
if (isset($themes->theme)) {
58+
$configuredThemes = $themes->theme->toArray();
59+
if (! array_key_exists($selectedTheme, $configuredThemes)) {
60+
$selectedTheme = 'default';
61+
}
62+
}
63+
}
64+
}
65+
66+
return "theme-vars--$selectedTheme.css";
67+
}
68+
}

modules/default/language/setup.tmx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@
2222
</tuv>
2323
</tu>
2424

25+
<tu tuid="setup_title_appearance">
26+
<tuv xml:lang="en">
27+
<seg>Appearance</seg>
28+
</tuv>
29+
<tuv xml:lang="de">
30+
<seg>Darstellung</seg>
31+
</tuv>
32+
</tu>
33+
34+
<tu tuid="setup_title_appearance_description">
35+
<tuv xml:lang="en">
36+
<seg>Selection of UI theme</seg>
37+
</tuv>
38+
<tuv xml:lang="de">
39+
<seg>Auswahl des UI-Farbschemas</seg>
40+
</tuv>
41+
</tu>
42+
2543
<tu tuid="setup_infopages_choose">
2644
<tuv xml:lang="en">
2745
<seg>Choose Translation Resource</seg>

modules/publish/views/helpers/Element.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ protected function renderElement($field, $options = null, $name = null)
6565
$fieldset = "<fieldset class='left-labels'>";
6666
$fieldset .= $this->getLegendFor($field['header']);
6767
$fieldset .= $this->getFieldsetHint($field['id']);
68-
$fieldset .= "<div class='form-item'>";
68+
if ($field['req'] === 'required') {
69+
$fieldset .= "<div class='form-item required'>";
70+
} else {
71+
$fieldset .= "<div class='form-item'>";
72+
}
6973
$fieldset .= $this->getLabelFor($field['id'], $field['label'], $field['req']);
7074

7175
switch ($field['type']) {

modules/publish/views/helpers/Fieldset.php

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,23 @@ public function renderHtmlText($field, $options)
4747
{
4848
$fieldset = "";
4949
if (! isset($field['isLeaf'])) {
50-
$fieldset .= "\n\t\t\t\t<input type='text' class='form-textfield' name='" . $field['id'] . "' id='"
50+
// TODO hack for changing the width of some fields
51+
$maxWidthClass = '';
52+
53+
if (
54+
$field['datatype'] === 'Title'
55+
|| in_array($field['id'], [
56+
'IdentifierUrl',
57+
'PublisherName',
58+
'EnrichmentConferenceTitle',
59+
'EnrichmentConferencePlace',
60+
'Enrichmentopus_crossrefLicence', // TODO still used?
61+
])
62+
) {
63+
$maxWidthClass = ' textfield-max-width';
64+
}
65+
66+
$fieldset .= "\n\t\t\t\t<input type='text' class='form-textfield$maxWidthClass' name='" . $field['id'] . "' id='"
5167
. $field['id'] . "' ";
5268
if ($options !== null) {
5369
$fieldset .= $options . " ";
@@ -105,7 +121,7 @@ public function renderHtmlTextarea($field, $options)
105121
public function renderHtmlSelect($field, $options)
106122
{
107123
// TODO move style to CSS
108-
$fieldset = "\n\t\t\t\t" . '<select style="width:300px" name="' . $field['id']
124+
$fieldset = "\n\t\t\t\t" . '<select name="' . $field['id']
109125
. '" class="form-selectfield" id="' . $field['id'] . '"';
110126
$fieldset .= ' title="' . htmlspecialchars($this->view->translate($field['hint']), ENT_QUOTES) . '"';
111127
if ($field['disabled'] === true) {
@@ -119,16 +135,15 @@ public function renderHtmlSelect($field, $options)
119135
}
120136

121137
foreach ($field['options'] as $key => $option) {
122-
$fieldset .= '<option value="' . htmlspecialchars($key, ENT_QUOTES) . '" label="'
123-
. htmlspecialchars($option, ENT_QUOTES) . '"';
138+
$key = strval($key);
139+
$optionValue = htmlspecialchars($key, ENT_QUOTES);
140+
$optionLabel = htmlspecialchars($option, ENT_QUOTES);
124141

125142
// $key can be int or string, $field['value'] is always a string
126-
if ($option === $field['value'] || strval($key) === $field['value']) {
127-
$fieldset .= ' selected="selected"';
128-
}
143+
$selected = $option === $field['value'] || $key === $field['value'] ? ' selected="selected"' : '';
129144

130-
$fieldset .= '>';
131-
$fieldset .= htmlspecialchars($option, ENT_QUOTES) . '</option>' . "\n\t\t\t\t\t";
145+
$fieldset .= "<option value=\"$optionValue\" title=\"$optionLabel\"$selected>$optionLabel</option>";
146+
$fieldset .= "\n\t\t\t\t\t";
132147
}
133148
$fieldset .= '</select>' . "\n";
134149

0 commit comments

Comments
 (0)