Skip to content
Snippets Groups Projects
Commit 5ea581f2 authored by Demian Katz's avatar Demian Katz
Browse files

Added mechanism to separate export format labels from unique IDs.

- Also cleaned up inconsistent use of the translator; all labels are now translated.
- Resolves VUFIND-1065.
parent 9dcf8129
No related merge requests found
......@@ -12,6 +12,8 @@
; non-XML formats.
; headers[] - a repeatable field containing HTTP headers that should be output to
; specify the appropriate export format.
; label - the label to display to the user when referring to this format; if omitted,
; the section name will be used by default.
; redirectUrl - a URL to forward the user to when they export this format (used for
; sending data to an external service like RefWorks). The URL must include one
; or more of these special tokens:
......
......@@ -90,7 +90,7 @@ class Export
if (isset($this->mainConfig->Export->$option)
&& $this->mainConfig->Export->$option == true
) {
$this->bulkOptions[] = $option;
$this->bulkOptions[] = $option;
}
}
}
......@@ -325,4 +325,17 @@ class Export
return isset($this->exportConfig->$format->headers)
? $this->exportConfig->$format->headers : array();
}
/**
* Get the display label for the specified export format.
*
* @param string $format Format identifier
*
* @return string
*/
public function getLabelForFormat($format)
{
return isset($this->exportConfig->$format->label)
? $this->exportConfig->$format->label : $format;
}
}
......@@ -22,7 +22,7 @@
<a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Export')?>" class="export exportMenu"><?=$this->transEsc('Export Record')?></a>
<ul class="menu offscreen" id="exportMenu">
<? foreach ($exportFormats as $exportFormat): ?>
<li><a <? if ($this->export()->needsRedirect($exportFormat)): ?>target="<?=$this->escapeHtmlAttr($exportFormat)?>Main" <? endif; ?>href="<?=$this->recordLink()->getActionUrl($this->driver, 'Export')?>?style=<?=$this->escapeHtmlAttr($exportFormat)?>"><?=$this->transEsc('Export to')?> <?=$this->escapeHtml($exportFormat)?></a></li>
<li><a <? if ($this->export()->needsRedirect($exportFormat)): ?>target="<?=$this->escapeHtmlAttr($exportFormat)?>Main" <? endif; ?>href="<?=$this->recordLink()->getActionUrl($this->driver, 'Export')?>?style=<?=$this->escapeHtmlAttr($exportFormat)?>"><?=$this->transEsc('Export to')?> <?=$this->transEsc($this->export()->getLabelForFormat($exportFormat))?></a></li>
<? endforeach; ?>
</ul>
</li>
......
<p>
<a class="save" onclick="hideLightbox();" href="<?=$this->escapeHtmlAttr($this->url)?>"<?=$this->export()->needsRedirect($this->format) ? ' target="_blank"' : ''?>><?=
$this->export()->needsRedirect($this->format)
? $this->transEsc('export_redirect', array('%%service%%' => $this->translate($this->format)))
? $this->transEsc('export_redirect', array('%%service%%' => $this->translate($this->export()->getLabelForFormat($this->format))))
: $this->transEsc('export_download')
?></a>
</p>
\ No newline at end of file
......@@ -20,7 +20,7 @@
<label for="format"><?=$this->transEsc('Format')?>:</label>
<select name="format" id="format">
<? foreach ($this->exportOptions as $exportOption): ?>
<option value="<?=$this->escapeHtmlAttr($exportOption)?>"><?=$this->transEsc($exportOption)?></option>
<option value="<?=$this->escapeHtmlAttr($exportOption)?>"><?=$this->transEsc($this->export()->getLabelForFormat($exportOption))?></option>
<? endforeach; ?>
</select>
<br/>
......
......@@ -11,7 +11,7 @@
<?=$this->transEsc('export_choose_format')?>
<ul>
<? foreach ($exportFormats as $exportFormat): ?>
<li><a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Export')?>?style=<?=$this->escapeHtml($exportFormat)?>"><?=$this->transEsc('Export to')?> <?=$this->escapeHtml($exportFormat)?></a></li>
<li><a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Export')?>?style=<?=$this->escapeHtml($exportFormat)?>"><?=$this->transEsc('Export to')?> <?=$this->transEsc($this->export()->getLabelForFormat($exportFormat))?></a></li>
<? endforeach; ?>
</ul>
<? else: ?>
......
......@@ -23,7 +23,7 @@
<a class="export-toggle dropdown-toggle" data-toggle="dropdown" href="<?=$this->recordLink()->getActionUrl($this->driver, 'Export')?>"><i class="fa fa-list-alt"></i> <?=$this->transEsc('Export Record') ?></a>
<ul class="dropdown-menu" role="menu">
<? foreach ($exportFormats as $exportFormat): ?>
<li><a <? if ($this->export()->needsRedirect($exportFormat)): ?>target="<?=$this->escapeHtmlAttr($exportFormat)?>Main" <? endif; ?>href="<?=$this->recordLink()->getActionUrl($this->driver, 'Export')?>?style=<?=$this->escapeHtmlAttr($exportFormat)?>"><?=$this->transEsc('Export to')?> <?=$this->transEsc($exportFormat)?></a></li>
<li><a <? if ($this->export()->needsRedirect($exportFormat)): ?>target="<?=$this->escapeHtmlAttr($exportFormat)?>Main" <? endif; ?>href="<?=$this->recordLink()->getActionUrl($this->driver, 'Export')?>?style=<?=$this->escapeHtmlAttr($exportFormat)?>"><?=$this->transEsc('Export to')?> <?=$this->transEsc($this->export()->getLabelForFormat($exportFormat))?></a></li>
<? endforeach; ?>
</ul>
</li>
......
......@@ -3,7 +3,7 @@
<?=$this->transEsc('export_success'); ?>&nbsp;&mdash;&nbsp;
<a class="btn btn-primary" href="<?=$this->escapeHtmlAttr($this->url)?>"<?=$this->export()->needsRedirect($this->format) ? ' target="_blank"' : ''?>><?=
$this->export()->needsRedirect($this->format)
? $this->transEsc('export_redirect', array('%%service%%' => $this->translate($this->format)))
? $this->transEsc('export_redirect', array('%%service%%' => $this->translate($this->export()->getLabelForFormat($this->format))))
: $this->transEsc('export_download')
?></a>
</div>
......
......@@ -40,7 +40,7 @@
<div class="col-sm-9">
<select name="format" id="format" class="form-control">
<? foreach ($this->exportOptions as $exportOption): ?>
<option value="<?=$this->escapeHtmlAttr($exportOption)?>"><?=$this->transEsc($exportOption)?></option>
<option value="<?=$this->escapeHtmlAttr($exportOption)?>"><?=$this->transEsc($this->export()->getLabelForFormat($exportOption))?></option>
<? endforeach; ?>
</select>
</div>
......
......@@ -12,7 +12,7 @@
<?=$this->transEsc('export_choose_format')?>
<ul>
<? foreach ($exportFormats as $exportFormat): ?>
<li><a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Export')?>?style=<?=$this->escapeHtml($exportFormat)?>"><?=$this->transEsc('Export to')?> <?=$this->escapeHtml($exportFormat)?></a></li>
<li><a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Export')?>?style=<?=$this->escapeHtml($exportFormat)?>"><?=$this->transEsc('Export to')?> <?=$this->transEsc($this->export()->getLabelForFormat($exportFormat))?></a></li>
<? endforeach; ?>
</ul>
<? else: ?>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment