Skip to content

Commit

Permalink
Aktualisierung VuFind Kern
Browse files Browse the repository at this point in the history
  • Loading branch information
hajoseng committed Aug 7, 2018
1 parent 97732c4 commit 4fcc22b
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 54 deletions.
18 changes: 11 additions & 7 deletions import-marc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,32 @@ set EXTRA_SOLRMARC_SETTINGS=%EXTRA_SOLRMARC_SETTINGS% -Dsolr.core.name=%SOLRCOR
rem ##################################################
rem # Set VUFIND_HOME
rem ##################################################
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound
if not (!%VUFIND_HOME%!)==(!!) goto vufindhomefound
rem VUFIND_HOME not set -- try to call env.bat to
rem fix the problem before we give up completely
if exist env.bat goto useenvbat
rem If env.bat doesn't exist, the user hasn't run the installer yet.
echo ERROR: env.bat does not exist -- could not set up environment.
echo WARNING: env.bat does not exist -- trying default environment settings.
echo Please run "php install.php" to correct this problem.
goto end
rem Extract path from current batch file and trim trailing slash:
set VUFIND_HOME=%~dp0%
set VUFIND_HOME=%VUFIND_HOME:~0,-1%
goto vufindhomefound
:useenvbat
call env > nul
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound
if not (!%VUFIND_HOME%!)==(!!) goto vufindhomefound
echo You need to set the VUFIND_HOME environmental variable before running this script.
goto end
:vufindhomefound

rem #####################################################
rem # Build java command
rem #####################################################
if not "!%JAVA_HOME%!"=="!!" goto javahomefound
if not (!%JAVA_HOME%!)==(!!) goto javahomefound
set JAVA=java
goto javaset
:javahomefound
set JAVA="%JAVA_HOME%\bin\java"
set JAVA=%JAVA_HOME%\bin\java
:javaset

rem ##################################################
Expand All @@ -93,6 +96,7 @@ if not exist %VUFIND_LOCAL_DIR%\import\import.properties goto nolocalproperties
set PROPERTIES_FILE=%VUFIND_LOCAL_DIR%\import\import.properties
goto propertiesfound
:nolocalproperties
echo WARNING: VUFIND_LOCAL_DIR environment variable is not set. Is this intentional?
set PROPERTIES_FILE=%VUFIND_HOME%\import\import.properties
:propertiesfound

Expand All @@ -112,4 +116,4 @@ echo %RUN_CMD%
:end

rem We're all done -- close down the local environment.
endlocal
endlocal
10 changes: 7 additions & 3 deletions import-marc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ then
INDEX_OPTIONS='-Xms512m -Xmx512m -DentityExpansionLimit=0'
fi


##################################################
# Set SOLRCORE
##################################################
Expand All @@ -61,15 +60,20 @@ then
EXTRA_SOLRMARC_SETTINGS="$EXTRA_SOLRMARC_SETTINGS -Dsolr.core.name=$SOLRCORE"
fi


##################################################
# Set VUFIND_HOME
##################################################
if [ -z "$VUFIND_HOME" ]
then
VUFIND_HOME="/usr/local/vufind"
# set VUFIND_HOME to the absolute path of the directory containing this script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
export VUFIND_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
fi

if [ -z "$VUFIND_LOCAL_DIR" ]
then
echo "WARNING: VUFIND_LOCAL_DIR environment variable is not set. Is this intentional?"
fi

#####################################################
# Build java command
Expand Down
23 changes: 17 additions & 6 deletions import/index_java/src/org/vufind/index/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ public static ConfigManager instance()
* Given the base name of a configuration file, locate the full path.
* @param filename base name of a configuration file
*/
private File findConfigFile(String filename)
private File findConfigFile(String filename) throws IllegalStateException
{
// Find VuFind's home directory in the environment; if it's not available,
// try using a relative path on the assumption that we are currently in
// VuFind's import subdirectory:
String vufindHome = System.getenv("VUFIND_HOME");
if (vufindHome == null) {
vufindHome = "..";
// this shouldn't happen since import-marc.sh and .bat always set VUFIND_HOME
throw new IllegalStateException("VUFIND_HOME must be set");
}

// Check for VuFind 2.0's local directory environment variable:
Expand Down Expand Up @@ -133,11 +134,21 @@ public Ini loadConfigFile(String filename)
// Retrieve the file if it is not already cached.
if (!configCache.containsKey(filename)) {
Ini ini = new Ini();
File configFile = null;
try {
ini.load(new FileReader(findConfigFile(filename)));
configCache.putIfAbsent(filename, ini);
configFile = findConfigFile(filename);
} catch (IllegalStateException e) {
dieWithError("Illegal State: " + e.getMessage());
} catch (Throwable e) {
dieWithError("Unable to access " + filename);
dieWithError("Unable to locate " + filename);
}
try {
if (configFile != null) {
ini.load(new FileReader(configFile));
configCache.putIfAbsent(filename, ini);
}
} catch (Throwable e) {
dieWithError("Unable to access " + configFile.getAbsolutePath());
}
}
return configCache.get(filename);
Expand Down Expand Up @@ -231,4 +242,4 @@ private void dieWithError(String msg)
logger.error(msg);
throw new SolrMarcIndexerException(SolrMarcIndexerException.EXIT, msg);
}
}
}
19 changes: 11 additions & 8 deletions index-alphabetic-browse.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,35 @@ goto end
rem ##################################################
rem # Set SOLR_HOME
rem ##################################################
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound
if not (!%VUFIND_HOME%!)==(!!) goto vufindhomefound
rem VUFIND_HOME not set -- try to call env.bat to
rem fix the problem before we give up completely
if exist env.bat goto useenvbat
rem If env.bat doesn't exist, the user hasn't run the installer yet.
echo ERROR: env.bat does not exist -- could not set up environment.
echo Please run install.php to correct this problem.
goto end
echo WARNING: env.bat does not exist -- trying default environment settings.
echo Please run "php install.php" to correct this problem.
rem Extract path from current batch file and trim trailing slash:
set VUFIND_HOME=%~dp0%
set VUFIND_HOME=%VUFIND_HOME:~0,-1%
goto vufindhomefound
:useenvbat
call env > nul
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound
if not (!%VUFIND_HOME%!)==(!!) goto vufindhomefound
echo You need to set the VUFIND_HOME environmental variable before running this script.
goto end
:vufindhomefound
if not "!%SOLR_HOME%!"=="!!" goto solrhomefound
if not (!%SOLR_HOME%!)==(!!) goto solrhomefound
set SOLR_HOME=%VUFIND_HOME%\solr\vufind
:solrhomefound

rem #####################################################
rem # Build java command
rem #####################################################
if not "!%JAVA_HOME%!"=="!!" goto javahomefound
if not (!%JAVA_HOME%!)==(!!) goto javahomefound
set JAVA=java
goto javaset
:javahomefound
set JAVA="%JAVA_HOME%\bin\java"
set JAVA=%JAVA_HOME%\bin\java
:javaset

cd %VUFIND_HOME%\import
Expand Down
7 changes: 6 additions & 1 deletion module/VuFind/src/VuFind/Controller/MyResearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ protected function processEditSubmit($user, $driver, $listID)
$tagParser = $this->serviceLocator->get('VuFind\Tags');
$favorites = $this->serviceLocator
->get('VuFind\Favorites\FavoritesService');
$didSomething = false;
foreach ($lists as $list) {
$tags = $this->params()->fromPost('tags' . $list);
$favorites->save(
Expand All @@ -629,13 +630,17 @@ protected function processEditSubmit($user, $driver, $listID)
],
$user, $driver
);
$didSomething = true;
}
// add to a new list?
$addToList = $this->params()->fromPost('addToList');
if ($addToList > -1) {
$didSomething = true;
$favorites->save(['list' => $addToList], $user, $driver);
}
$this->flashMessenger()->addMessage('edit_list_success', 'success');
if ($didSomething) {
$this->flashMessenger()->addMessage('edit_list_success', 'success');
}

$newUrl = null === $listID
? $this->url()->fromRoute('myresearch-favorites')
Expand Down
4 changes: 4 additions & 0 deletions module/VuFind/src/VuFind/Cover/Layer/AbstractTextLayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ protected function textHeight($text, $font, $size)
protected function drawText($im, $settings, $text, $y, $font, $fontSize, $mcolor,
$scolor = false, $align = null
) {
// In case the text contains non-normalized UTF-8, fix that for proper
// display:
$text = \Normalizer::normalize($text);

// If the wrap width is smaller than the image width, we want to account
// for this when right or left aligning to maintain padding on the image.
$wrapGap = ($settings->width - $settings->wrapWidth) / 2;
Expand Down
20 changes: 12 additions & 8 deletions module/VuFind/src/VuFind/OAI/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,12 @@ protected function attachRecordHeader($xml, $id, $date, $sets = [],
* @param object $record A record driver object
* @param string $format Metadata format to obtain (false for none)
* @param bool $headerOnly Only attach the header?
* @param string $set Currently active set
*
* @return bool
*/
protected function attachNonDeleted($container, $record, $format,
$headerOnly = false
$headerOnly = false, $set = ''
) {
// Get the XML (and display an error if it is unsupported):
if ($format === false) {
Expand All @@ -324,10 +325,13 @@ protected function attachNonDeleted($container, $record, $format,
// Check for sets:
$fields = $record->getRawData();
if (null !== $this->setField && !empty($fields[$this->setField])) {
$sets = $fields[$this->setField];
$sets = (array)$fields[$this->setField];
} else {
$sets = [];
}
if (!empty($set)) {
$sets = array_unique(array_merge($sets, [$set]));
}

// Get modification date:
$date = $record->getLastIndexed();
Expand Down Expand Up @@ -598,14 +602,14 @@ protected function listRecords($verb = 'ListRecords')
$solrLimit = ($params['cursor'] + $this->pageSize) - $currentCursor;

// Get non-deleted records from the Solr index:
$set = $params['set'] ?? '';
$result = $this->listRecordsGetNonDeleted(
$from, $until, $solrOffset, $solrLimit,
$params['set'] ?? ''
$from, $until, $solrOffset, $solrLimit, $set
);
$nonDeletedCount = $result->getResultTotal();
$format = $params['metadataPrefix'];
foreach ($result->getResults() as $doc) {
if (!$this->attachNonDeleted($xml, $doc, $format, $headersOnly)) {
if (!$this->attachNonDeleted($xml, $doc, $format, $headersOnly, $set)) {
$this->unexpectedError('Cannot load document');
}
$currentCursor++;
Expand Down Expand Up @@ -732,9 +736,9 @@ protected function listRecordsGetNonDeleted($from, $until, $offset, $limit,
// Apply filters as needed.
if (!empty($set)) {
if (isset($this->setQueries[$set])) {
// use hidden filter here to allow for complex queries;
// plain old addFilter expects simple field:value queries.
$params->addHiddenFilter($this->setQueries[$set]);
// Put parentheses around the query so that it does not get
// parsed as a simple field:value filter.
$params->addFilter('(' . $this->setQueries[$set] . ')');
} elseif (null !== $this->setField) {
$params->addFilter(
$this->setField . ':"' . addcslashes($set, '"') . '"'
Expand Down
8 changes: 3 additions & 5 deletions module/VuFind/src/VuFind/RecordDriver/DefaultRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -1123,9 +1123,8 @@ public function getSeries()
*/
public function getShortTitle()
{
$shortTitle = isset($this->fields['title_short']) ?
return isset($this->fields['title_short']) ?
$this->fields['title_short'] : '';
return is_array($shortTitle) ? $shortTitle[0] : $shortTitle;
}

/**
Expand Down Expand Up @@ -1249,9 +1248,8 @@ public function getThumbnail($size = 'small')
*/
public function getTitle()
{
$title = isset($this->fields['title']) ?
return isset($this->fields['title']) ?
$this->fields['title'] : '';
return is_array($title) ? $title[0] : $title;
}

/**
Expand Down Expand Up @@ -1455,7 +1453,7 @@ public function getXML($format, $baseUrl = null, $recordLink = null)
$xml->addChild('title', htmlspecialchars($this->getTitle()), $dc);
$authors = $this->getDeduplicatedAuthors();
foreach ($authors as $list) {
foreach ((array)$list as $author) {
foreach (array_keys($list) as $author) {
$xml->addChild('creator', htmlspecialchars($author), $dc);
}
}
Expand Down
16 changes: 8 additions & 8 deletions module/VuFind/src/VuFind/View/Helper/Root/OpenUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ class OpenUrl extends \Zend\View\Helper\AbstractHelper
/**
* Constructor
*
* @param \VuFind\View\Helper\Root\Context $context Context helper
* @param array $openUrlRules VuFind OpenURL rules
* @param PluginManager $pluginManager Resolver plugin manager
* @param \Zend\Config\Config $config VuFind OpenURL config
* @param Context $context Context helper
* @param array $openUrlRules VuFind OpenURL rules
* @param PluginManager $pluginManager Resolver plugin manager
* @param \Zend\Config\Config $config VuFind OpenURL config
*/
public function __construct(\VuFind\View\Helper\Root\Context $context,
$openUrlRules, PluginManager $pluginManager, $config = null
public function __construct(Context $context, $openUrlRules,
PluginManager $pluginManager, $config = null
) {
$this->context = $context;
$this->openUrlRules = $openUrlRules;
Expand All @@ -100,9 +100,9 @@ public function __construct(\VuFind\View\Helper\Root\Context $context,
}

/**
* Render appropriate UI controls for an OpenURL link.
* Set up context for helper
*
* @param \VuFind\RecordDriver $driver The current recorddriver
* @param \VuFind\RecordDriver $driver The current record driver
* @param string $area OpenURL context ('results', 'record'
* or 'holdings'
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ public function testUnknownTypeOpenURL()
$this->assertEquals('url_ver=Z39.88-2004&ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&rfr_id=info%3Asid%2Fvufind.svn.sourceforge.net%3Agenerator&rft.title=La+congiura+dei+Principi+Napoletani+1701+%3A+%28prima+e+seconda+stesura%29+%2F&rft.date=1992&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&rft.creator=Vico%2C+Giambattista%2C+1668-1744.&rft.pub=Centro+di+Studi+Vichiani%2C&rft.format=Thingie&rft.language=Italian', $driver->getOpenUrl());
}

/**
* Test Dublin Core conversion.
*
* @return void
*/
public function testDublinCore()
{
$expected = <<<XML
<?xml version="1.0"?>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"><dc:title>La congiura dei Principi Napoletani 1701 : (prima e seconda stesura) /</dc:title><dc:creator>Vico, Giambattista, 1668-1744.</dc:creator><dc:creator>Pandolfi, Claudia.</dc:creator><dc:language>Italian</dc:language><dc:language>Latin</dc:language><dc:publisher>Centro di Studi Vichiani,</dc:publisher><dc:date>1992</dc:date><dc:subject>Naples (Kingdom) History Spanish rule, 1442-1707 Sources</dc:subject></oai_dc:dc>
XML;
$xml = $this->getDriver()->getXML('oai_dc');
$this->assertEquals($expected, $xml);
}

/**
* Get a record driver with fake data.
*
Expand Down
13 changes: 8 additions & 5 deletions solr.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ rem Unrecognized action -- display help text
if "!%1!"=="!!" goto usage

rem Set VUFIND_HOME (if not already set)
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound
rem VUFIND_HOME not set -- try to call env.bat to
if not (!%VUFIND_HOME%!)==(!!) goto vufindhomefound
rem VUFIND_HOME not set -- try to call env.bat to
rem fix the problem before we give up completely
if exist env.bat goto useenvbat
rem If env.bat doesn't exist, the user hasn't run the installer yet.
echo ERROR: env.bat does not exist -- could not set up environment.
echo WARNING: env.bat does not exist -- trying default environment settings.
echo Please run "php install.php" to correct this problem.
goto end
rem Extract path from current batch file and trim trailing slash:
set VUFIND_HOME=%~dp0%
set VUFIND_HOME=%VUFIND_HOME:~0,-1%
goto vufindhomefound
:useenvbat
call env > nul
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound
if not (!%VUFIND_HOME%!)==(!!) goto vufindhomefound
echo You need to set the VUFIND_HOME environmental variable before running this script.
goto end
:vufindhomefound
Expand Down
Loading

0 comments on commit 4fcc22b

Please sign in to comment.