@@ -55,7 +55,7 @@ class KeyboardDetails
55
55
56
56
/**
57
57
* render_keyboard_details - display keyboard download boxes and details
58
- * @param $id - keyboard ID
58
+ * @param $id - keyboard package ID
59
59
* @param string $tier - ['stable', 'alpha', or 'beta']
60
60
* @param bool $landingPage - when true, details won't display keyboard search box or title
61
61
* @param string $bcp47 - BCP 47 tag to pass as a hint to download links for apps to make connection
@@ -125,41 +125,48 @@ protected static function download_box($platform) {
125
125
protected static function WriteWebBoxes ($ useDescription ) {
126
126
global $ embed_target ;
127
127
global $ KeymanHosts ;
128
- if (isset (self ::$ keyboard ->platformSupport ->desktopWeb ) && self ::$ keyboard ->platformSupport ->desktopWeb != 'none ' && empty (self ::$ deprecatedBy )) {
129
- if (empty (self ::$ bcp47 )) {
130
- if (isset (self ::$ keyboard ->languages )) {
131
- if (is_array (self ::$ keyboard ->languages )) {
132
- if (count (self ::$ keyboard ->languages ) > 0 ) {
133
- $ lang = self ::$ keyboard ->languages [0 ];
134
- }
135
- } else {
136
- $ langs = array_keys (get_object_vars (self ::$ keyboard ->languages ));
137
- if (count ($ langs ) > 0 ) {
138
- $ lang = $ langs [0 ];
139
- }
128
+
129
+ // only show if the jsFilename property is present in the .keyboard_info
130
+ if (empty (self ::$ keyboard ->jsFilename )) {
131
+ return FALSE ;
132
+ }
133
+
134
+ if (!isset (self ::$ keyboard ->platformSupport ->desktopWeb ) || self ::$ keyboard ->platformSupport ->desktopWeb == 'none ' || !empty (self ::$ deprecatedBy )) {
135
+ return FALSE ;
136
+ }
137
+
138
+ if (empty (self ::$ bcp47 )) {
139
+ if (isset (self ::$ keyboard ->languages )) {
140
+ if (is_array (self ::$ keyboard ->languages )) {
141
+ if (count (self ::$ keyboard ->languages ) > 0 ) {
142
+ $ lang = self ::$ keyboard ->languages [0 ];
143
+ }
144
+ } else {
145
+ $ langs = array_keys (get_object_vars (self ::$ keyboard ->languages ));
146
+ if (count ($ langs ) > 0 ) {
147
+ $ lang = $ langs [0 ];
140
148
}
141
149
}
142
- } else {
143
- $ lang = self ::$ bcp47 ;
144
- }
145
- if (!isset ($ lang )) $ lang = 'en ' ;
146
- $ url = "{$ KeymanHosts ->keymanweb_com }/# $ lang,Keyboard_ " . self ::$ keyboard ->id ;
147
- if ($ useDescription ) {
148
- $ description = htmlentities (self ::$ keyboard ->name );
149
- $ description = "<div class= \"download-description \">Use $ description in your web browser. No need to install anything.</div> " ;
150
- $ linktext = 'Use keyboard online ' ;
151
- } else {
152
- $ description = '' ;
153
- $ linktext = 'Full online editor ' ;
154
150
}
155
- return <<<END
156
- <div class="download download-web">
157
- <a class="download-link" $ embed_target href=' $ url'> $ linktext</a>
158
- $ description
159
- </div>
160
- END ;
151
+ } else {
152
+ $ lang = self ::$ bcp47 ;
153
+ }
154
+ if (!isset ($ lang )) $ lang = 'en ' ;
155
+ $ url = "{$ KeymanHosts ->keymanweb_com }/# $ lang,Keyboard_ " . self ::GetWebKeyboardId ();
156
+ if ($ useDescription ) {
157
+ $ description = htmlentities (self ::$ keyboard ->name );
158
+ $ description = "<div class= \"download-description \">Use $ description in your web browser. No need to install anything.</div> " ;
159
+ $ linktext = 'Use keyboard online ' ;
160
+ } else {
161
+ $ description = '' ;
162
+ $ linktext = 'Full online editor ' ;
161
163
}
162
- return FALSE ;
164
+ return <<<END
165
+ <div class="download download-web">
166
+ <a class="download-link" $ embed_target href=' $ url'> $ linktext</a>
167
+ $ description
168
+ </div>
169
+ END ;
163
170
}
164
171
165
172
protected static function LoadData () {
@@ -170,7 +177,7 @@ protected static function LoadData() {
170
177
if ($ s === FALSE ) {
171
178
// Will fail later in the script
172
179
self ::$ error .= error_get_last ()['message ' ] . "\n" ;
173
- self ::$ title = 'Failed to load keyboard ' . self ::$ id ;
180
+ self ::$ title = 'Failed to load keyboard package ' . self ::$ id ;
174
181
header ('HTTP/1.0 404 Keyboard not found ' );
175
182
} else {
176
183
$ s = json_decode ($ s );
@@ -184,7 +191,7 @@ protected static function LoadData() {
184
191
self ::$ license = self ::map_license (isset (self ::$ keyboard ->license ) ? self ::$ keyboard ->license : 'Unknown ' );
185
192
} else {
186
193
self ::$ error .= "Error returned from {$ KeymanHosts ->api_keyman_com }: $ s \n" ;
187
- self ::$ title = 'Failed to load keyboard ' . self ::$ id ;
194
+ self ::$ title = 'Failed to load keyboard package ' . self ::$ id ;
188
195
header ('HTTP/1.0 500 Internal Server Error ' );
189
196
}
190
197
}
@@ -300,7 +307,7 @@ protected static function WriteTitle() {
300
307
// If parameters are missing ...
301
308
?>
302
309
<h1 class='red underline'><?= self ::$ id ?> </h1>
303
- <p>Keyboard <?= self ::$ id ?> not found.</p>
310
+ <p>Keyboard package <?= self ::$ id ?> not found.</p>
304
311
<?php
305
312
// DEBUG: Only display errors on local sites
306
313
global $ KeymanHosts ;
@@ -340,7 +347,6 @@ protected static function WriteTitle() {
340
347
341
348
if (!empty (self ::$ deprecatedBy )) {
342
349
$ dep = self ::$ deprecatedBy ;
343
- $ id = self ::$ id ;
344
350
echo "
345
351
<div>
346
352
<a href='/keyboards/ $ dep$ session_query_q' class='deprecated'><span>Important note:</span>
@@ -393,6 +399,13 @@ protected static function WriteDownloadBoxes() {
393
399
}
394
400
}
395
401
402
+ private static function GetWebKeyboardId () {
403
+ if (empty (self ::$ keyboard ->jsFilename )) {
404
+ return "" ;
405
+ }
406
+ return preg_replace ("/\.js$/ " , "" , self ::$ keyboard ->jsFilename );
407
+ }
408
+
396
409
protected static function GetWebDeviceFromPageDevice () {
397
410
global $ pageDevice ;
398
411
switch ($ pageDevice ) {
@@ -418,12 +431,18 @@ protected static function WriteKeymanWebBox() {
418
431
return ;
419
432
}
420
433
434
+ // only show if the jsFilename property is present in the .keyboard_info
435
+ if (empty (self ::$ keyboard ->jsFilename )) {
436
+ return ;
437
+ }
438
+
421
439
// only inject on desktop platforms
422
440
$ webDevice = self ::GetWebDeviceFromPageDevice ();
423
441
if (!$ webDevice ) {
424
442
return ;
425
443
}
426
444
445
+ $ keymanWebId = self ::GetWebKeyboardId ();
427
446
$ webtext = self ::WriteWebBoxes (false );
428
447
$ cdnUrlBase = KeymanWebHost::getKeymanWebUrlBase ();
429
448
?>
@@ -452,7 +471,7 @@ function() {
452
471
document.getElementById('osk-host').appendChild(newOSK.element);
453
472
}
454
473
);
455
- keyman.addKeyboards('<?= self :: $ id ?> ');
474
+ keyman.addKeyboards('<?= $ keymanWebId ?> ');
456
475
})();
457
476
</script>
458
477
<?php
0 commit comments