Skip to content

Commit

Permalink
Fix Leader, 00x display issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Dec 19, 2024
1 parent 26b5ea1 commit d52a722
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
10 changes: 7 additions & 3 deletions classes/BaseTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ public function getSolrField($tag, $subfield = '', $onlyStored = false) {
}

$existingSolrFields = $this->solr()->getSolrFields($onlyStored);
$fieldPrefix = $this->indexingParameters->fieldPrefix;
if (!isset($solrField) || !in_array($solrField, $existingSolrFields)) {
$solrField = $tag;
if ($subfield != '')
Expand All @@ -258,7 +259,7 @@ public function getSolrField($tag, $subfield = '', $onlyStored = false) {
foreach ($existingSolrFields as $existingSolrField) {
if (!preg_match('/_ss$/', $existingSolrField))
continue;
if (preg_match('/^' . $solrField . '_/', $existingSolrField)) {
if (preg_match('/^' . $fieldPrefix . $solrField . '_/', $existingSolrField)) {
$parts = explode('_', $existingSolrField);
if (count($parts) == 4) {
$found = TRUE;
Expand Down Expand Up @@ -515,14 +516,17 @@ protected function readAnalysisParameters() {
} else {
$this->log->error('there is no parameterFile');
}

$this->readIndexingParameters('marctosolr.params.json');
error_log('indexingParameters: ' . json_encode($this->indexingParameters));
}

protected function readIndexingParameters($paramFile) {
$path = $this->getFilePath($paramFile);
if (file_exists($path)) {
$this->indexingParameters = json_decode(file_get_contents($path));
if ($this->analysisParameters) {
$this->analysisParameters->analysisTimestamp = date("Y-m-d H:i:s", filemtime($path));
if ($this->indexingParameters) {
$this->indexingParameters->analysisTimestamp = date("Y-m-d H:i:s", filemtime($path));
}
}
}
Expand Down
24 changes: 17 additions & 7 deletions classes/Issues.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class Issues extends BaseTab {

public function prepareData(Smarty &$smarty) {
parent::prepareData($smarty);

// $this->analysisParameters = json_decode(file_get_contents($path))
$smarty->assign("delta", $this->delta);
if ($this->delta) {
$this->count = $this->readCount($this->getDeltaFilePath('count.csv'));
Expand Down Expand Up @@ -164,15 +166,23 @@ private function readIssues() {
* @return string The
*/
private function createIssueQuery($record) {
// TODO: use getSolrField($tag, $subfield)
if ($record->type == 'undefined field') {
$issueQuery = sprintf('%s_count_i:*', $record->path);
} elseif ($record->type == 'repetition of non-repeatable field') {
$issueQuery = sprintf('%s_count_i:[%s]', $record->path, urlencode('2 TO *'));
} elseif ($record->type == 'undefined subfield') {
if ($record->type == 'undefined field' && $this->indexingParameters->indexFieldCounts) {
$issueQuery = sprintf('%s%s_count_i:*', $this->indexingParameters->fieldPrefix, $record->path);
}
elseif ($record->type == 'repetition of non-repeatable field' && $this->indexingParameters->indexFieldCounts) {
$issueQuery = sprintf('%s%s_count_i:[%s]', $this->indexingParameters->fieldPrefix, $record->path, urlencode('2 TO *'));
}
elseif ($record->type == 'undefined subfield') {
// error_log(sprintf('getSolrField: %s%s -> %s', $record->path, $record->message, $this->getSolrField($record->path, $record->message)));
$issueQuery = sprintf('%s:*', $this->getSolrField($record->path, $record->message));
} else {
}
elseif ($record->type == 'repetition of non-repeatable subfield' && $this->indexingParameters->indexSubfieldCounts) {
$issueQuery = sprintf('%s%s_count_is:[%s]',
$this->indexingParameters->fieldPrefix,
str_replace('$', '', $record->path),
urlencode('2 TO *'));
}
else {
$issueQuery = sprintf('errorId:%s', $record->id);
}
return $issueQuery;
Expand Down
8 changes: 4 additions & 4 deletions classes/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getLeaderByPositionString($position) {
public function getLeaderByPosition($start, $end = NULL) {
$leader = $this->getFirstField('Leader_ss');
if ($leader != null) {
$length = ($end == null) ? 1 : $end - $start;
$length = ($end == null) ? 1 : ($end + 1) - $start;
$part = substr($leader, $start, $length);
return $part;
}
Expand All @@ -135,7 +135,7 @@ public function getLeaderByPosition($start, $end = NULL) {
public function get008ByPosition($start, $end = NULL) {
$field = $this->getField('008');
if ($field != null) {
$length = ($end == null) ? 1 : $end - $start;
$length = ($end == null) ? 1 : ($end + 1) - $start;
$part = substr($field, $start, $length);
return $part;
}
Expand All @@ -145,7 +145,7 @@ public function get008ByPosition($start, $end = NULL) {
public function get007ByPosition($start, $end = NULL) {
$field = $this->getField('007');
if ($field != null) {
$length = ($end == null) ? 1 : $end - $start;
$length = ($end == null) ? 1 : ($end + 1) - $start;
$part = substr($field, $start, $length);
return $part;
}
Expand All @@ -155,7 +155,7 @@ public function get007ByPosition($start, $end = NULL) {
public function get006ByPosition($start, $end = NULL) {
$field = $this->getField('006');
if ($field != null) {
$length = ($end == null) ? 1 : $end - $start;
$length = ($end == null) ? 1 : ($end + 1) - $start;
$part = substr($field, $start, $length);
return $part;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/marc/leader.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<tr>
<td>{$id}</td>
<td>{$data->label}</td>
{assign var="code" value=$record->getLeaderByPosition($data->start, $data->end)}
{assign var="code" value=$record->getLeaderByPosition($data->start, $data->end)}
<td>
{if preg_match('/ /', $code)}
"{str_replace(' ', '&nbsp;', $code)}"
Expand Down

0 comments on commit d52a722

Please sign in to comment.