Projekt

Allgemein

Profil

GX-Task #47081

Von Moritz Bunjes vor fast 8 Jahren aktualisiert

Bisher befindet sich die Initialisierung von window.JSEngineConfiguration in einem script-Tag innerhalb des head-Tags jeder HTML-Seite des Honeygrids. Diese bläht das HTML unnötig auf, so dass wir uns dazu entschieden haben diese zum restlichen JavaScript in die gm_javascript.js.php zu verschieben. Damit ändert sich auch der Weg eigene Sprach-Sections im JavaScript verfügbar zu machen. Es gibt eine neue PHP-Klasse JSEngineConfiguration. Um eigene Sections hinzuzuführen ist nun ein Overload der Methode _getSections des Konstruktors von JSEngineConfiguration notwendig. Ein Beispiel: 

 ~~~ 
 protected public function _getSections() __construct(NonEmptyStringType $appVersion, 
                             NonEmptyStringType $baseUrl, 
                             NonEmptyStringType $templatePath, 
                             LanguageCode $languageCode, 
                             LanguageTextManager $languageTextManager, 
                             EditableKeyValueCollection $sections, 
                             BoolType $debugMode) 
 { 
     $additionalSection = array('js_section_name' 
	 parent::__construct($appVersion, $baseUrl, $templatePath, $languageCode, $languageTextManager, d$sections, 
                         $debugMode); 

     $this->_addSections(array('js_section_name' => 'section_name'); 
     $this->sections = array_merge($this->sections, $additionalSection); 

     return parent::_getSections(); 'section_name')); 
 } 
 ~~~ 
 Damit ist die Section section_name im JavaScript unter dem Namen js_section_name bekannt gemacht und kann im JavaScript genutzt werden: 
 jse.core.lang.translate('phrase_name', 'js_section_name') // phrase value will be returned; 

Zurück