Browse Source

Use language dictionary from typo3 backend in frontend code

pull/75/head
Jacob Mendt 6 years ago
parent
commit
0940f3467c
  1. 3
      dlf/plugins/pageview/class.tx_dlf_pageview.php
  2. 9
      dlf/plugins/pageview/tx_dlf_pageview.js
  3. 42
      dlf/plugins/pageview/tx_dlf_pageview_fulltext_control.js
  4. 18
      dlf/plugins/pageview/tx_dlf_utils.js
  5. 6
      dlf/plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php
  6. 8
      dlf/plugins/toolbox/tools/fulltext/locallang.xml

3
dlf/plugins/pageview/class.tx_dlf_pageview.php

@ -148,8 +148,7 @@ class tx_dlf_pageview extends tx_dlf_plugin {
controls: ["' . implode('", "', $this->controls) . '"],
div: "' . $this->conf['elementId'] . '",
fulltexts: ["' . implode('", "', $this->fulltexts) . '"],
images: ["' . implode('", "', $this->images) . '"],
lang: "'.$this->lang.'"
images: ["' . implode('", "', $this->images) . '"]
})
}
}

9
dlf/plugins/pageview/tx_dlf_pageview.js

@ -91,13 +91,6 @@ var dlfViewer = function(settings){
this.offset = 0;
/**
* Language token
* @type {string}
* @private
*/
this.lang = dlfUtils.exists(settings.lang) ? settings.lang : 'de';
/**
* @type {Array.<number>}
* @private
*/
@ -131,7 +124,7 @@ dlfViewer.prototype.addCustomControls = function() {
// Adds fulltext behavior only if there are fulltext availabe and no double page
// behavior is active
if (this.fulltexts[0] !== undefined && this.fulltexts[0] !== '' && this.images.length == 1)
fulltextControl = new dlfViewerFullTextControl(this.map, this.images[0], this.fulltexts[0], this.lang);
fulltextControl = new dlfViewerFullTextControl(this.map, this.images[0], this.fulltexts[0]);
// add image manipulation tool if container is added
if ($('.tx-dlf-tools-imagetools').length > 0 && dlfUtils.isWebGLEnabled()){

42
dlf/plugins/pageview/tx_dlf_pageview_fulltext_control.js

@ -42,9 +42,8 @@ jQuery.fn.scrollTo = function(elem, speed) {
* @param {ol.Map} map
* @param {Object} image
* @param {string} fulltextUrl
* @param {string} lang
*/
var dlfViewerFullTextControl = function(map, image, fulltextUrl, lang){
var dlfViewerFullTextControl = function(map, image, fulltextUrl){
/**
* @private
@ -63,12 +62,14 @@ var dlfViewerFullTextControl = function(map, image, fulltextUrl, lang){
* @private
*/
this.url = fulltextUrl;
/**
* @type {Object}
* @private
* @type {string}
*/
this.lang = lang == 'de' || lang == 'en' ? lang : 'de';
this.dic = $('#tx-dlf-tools-fulltext').length > 0 && $('#tx-dlf-tools-fulltext').attr('data-dic') ?
dlfUtils.parseDataDic($('#tx-dlf-tools-fulltext')) :
{'fulltext-on':'Activate Fulltext','fulltext-off':'Dectivate Fulltext'};
/**
* @type {Array.<Array.<ol.Feature>}
@ -273,12 +274,18 @@ var dlfViewerFullTextControl = function(map, image, fulltextUrl, lang){
anchorEl.on('click', toogleFulltext);
anchorEl.on('touchstart', toogleFulltext);
};
// set initial title of fulltext element
$("#tx-dlf-tools-fulltext")
.text(this.dic['fulltext-on'])
.attr('title', this.dic['fulltext-on']);
// if fulltext is activated via cookie than run activation methode
if (dlfUtils.getCookie("tx-dlf-pageview-fulltext-select") == 'enabled') {
// activate the fulltext behavior
this.activate(anchorEl);
}
};
};
/**
@ -355,11 +362,10 @@ dlfViewerFullTextControl.prototype.enableFulltextSelect = function(textBlockFeat
this.map.addLayer(this.highlightLayerTextLine);
// show fulltext container
var title = dlfViewerFullTextControl.dic[this.lang][1],
className = 'fulltext-visible';
var className = 'fulltext-visible';
$("#tx-dlf-tools-fulltext").addClass(className)
.text(title)
.attr('title', title);
.text(this.dic['fulltext-off'])
.attr('title', this.dic['fulltext-off']);
$('#tx-dlf-fulltextselection').addClass(className);
$('#tx-dlf-fulltextselection').show();
@ -390,11 +396,10 @@ dlfViewerFullTextControl.prototype.disableFulltextSelect = function() {
this.highlightLayer.getSource().clear();
this.highlightLayerTextLine.getSource().clear()
var title = dlfViewerFullTextControl.dic[this.lang][0],
className = 'fulltext-visible';
var className = 'fulltext-visible';
$("#tx-dlf-tools-fulltext").removeClass(className)
.text(title)
.attr('title', title);
.text(this.dic['fulltext-on'])
.attr('title', this.dic['fulltext-on']);
$('#tx-dlf-fulltextselection').removeClass(className);
$('#tx-dlf-fulltextselection').hide();
@ -545,13 +550,4 @@ dlfViewerFullTextControl.style.textlineStyle = function() {
})
});
};
/**
*
* @type {{en: string[], de: string[]}}
*/
dlfViewerFullTextControl.dic = {
'en': ['Activate Fulltext', 'Deactivate Fulltext'],
'de': ['Volltexte an', 'Volltexte aus']
};

18
dlf/plugins/pageview/tx_dlf_utils.js

@ -159,6 +159,24 @@ dlfUtils.isWebGLEnabled = function(){
};
/**
* @param {Element} element
* @return {Object}
*/
dlfUtils.parseDataDic = function(element) {
var dataDicString = $(element).attr('data-dic'),
dataDicRecords = dataDicString.split(';'),
dataDic = {};
for (var i = 0, ii = dataDicRecords.length; i < ii; i++){
var key = dataDicRecords[i].split(':')[0],
value = dataDicRecords[i].split(':')[1];
dataDic[key] = value;
}
return dataDic;
};
/**
* Set a cookie value
*
* @param {string} name The key of the value

6
dlf/plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php

@ -93,9 +93,11 @@ class tx_dlf_toolsFulltext extends tx_dlf_plugin {
$fullTextFile = $this->doc->physicalPagesInfo[$this->doc->physicalPages[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']];
if (!empty($fullTextFile)) {
$markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="'.$this->pi_getLL('fulltext-select', '', TRUE).'">'.$this->pi_getLL('fulltext-select', '', TRUE).'</a>';
$markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext-on:'
.$this->pi_getLL('fulltext-on', '', TRUE).';fulltext-off:'
.$this->pi_getLL('fulltext-off', '', TRUE).'"></a>';
} else {
$markerArray['###FULLTEXT_SELECT###'] = $this->pi_getLL('fulltext-select', '', TRUE);
$markerArray['###FULLTEXT_SELECT###'] = $this->pi_getLL('fulltext-not-available', '', TRUE);
}
$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);

8
dlf/plugins/toolbox/tools/fulltext/locallang.xml

@ -28,10 +28,14 @@
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="fulltext-select">Activate Fulltext</label>
<label index="fulltext-on">Activate Fulltext</label>
<label index="fulltext-off">Dectivate Fulltext</label>
<label index="fulltext-not-available">No Fulltext available</label>
</languageKey>
<languageKey index="de" type="array">
<label index="fulltext-select">Volltexte an</label>
<label index="fulltext-on">Volltext an</label>
<label index="fulltext-off">Volltext aus</label>
<label index="fulltext-not-available">Keine Volltexte vorhanden</label>
</languageKey>
</data>
</T3locallang>

Loading…
Cancel
Save