|
1 | 1 | <?php |
2 | 2 |
|
3 | | -// See also the share_user_info plugin |
| 3 | +/* For licensing terms, see /license.txt */ |
4 | 4 |
|
5 | | -echo '<div class="well">'; |
6 | | -if (!empty($plugin_info['settings']['hello_world_show_type'])) { |
7 | | - echo '<h2>'.$plugin_info['settings']['hello_world_show_type'].'</h2>'; |
8 | | -} else { |
9 | | - echo '<h2>Hello world</h2>'; |
| 5 | +/** |
| 6 | + * Render a minimal translated greeting in the assigned plugin region. |
| 7 | + */ |
| 8 | + |
| 9 | +if (!class_exists('Plugin', false)) { |
| 10 | + $globalInc = __DIR__.'/../../main/inc/global.inc.php'; |
| 11 | + |
| 12 | + if (is_file($globalInc)) { |
| 13 | + require_once $globalInc; |
| 14 | + } |
| 15 | +} |
| 16 | + |
| 17 | +if (!class_exists('HelloWorldPlugin', false)) { |
| 18 | + require_once __DIR__.'/src/HelloWorldPlugin.php'; |
| 19 | +} |
| 20 | + |
| 21 | +$plugin = HelloWorldPlugin::create(); |
| 22 | + |
| 23 | +$region = ''; |
| 24 | +if (isset($plugin_info) && is_array($plugin_info)) { |
| 25 | + $region = (string) ($plugin_info['current_region'] ?? ''); |
10 | 26 | } |
11 | 27 |
|
12 | | -//Using get_lang inside a plugin |
13 | | -echo get_lang('Hello plugin'); |
| 28 | +if ('' === $region && isset($_GET['region'])) { |
| 29 | + $region = (string) $_GET['region']; |
| 30 | +} |
| 31 | + |
| 32 | +$region = preg_replace('/[^a-zA-Z0-9_\-]/', '', $region) ?: 'unknown'; |
| 33 | + |
| 34 | +$greeting = htmlspecialchars($plugin->getConfiguredGreeting(), ENT_QUOTES, 'UTF-8'); |
| 35 | +$title = htmlspecialchars($plugin->get_lang('region_title'), ENT_QUOTES, 'UTF-8'); |
| 36 | +$description = htmlspecialchars($plugin->get_lang('region_description'), ENT_QUOTES, 'UTF-8'); |
| 37 | +$regionLabel = htmlspecialchars($region, ENT_QUOTES, 'UTF-8'); |
14 | 38 |
|
15 | | -echo '</div>'; |
| 39 | +echo <<<HTML |
| 40 | +<div class="hello-world-plugin my-4 rounded-2xl border border-support-3 bg-white p-5 shadow-sm" data-hello-world-region="{$regionLabel}"> |
| 41 | + <div class="flex flex-col gap-4 sm:flex-row sm:items-start"> |
| 42 | + <div class="flex h-12 w-12 shrink-0 items-center justify-center rounded-2xl bg-support-2 text-primary"> |
| 43 | + <span class="mdi mdi-hand-wave-outline text-2xl" aria-hidden="true"></span> |
| 44 | + </div> |
| 45 | + <div class="min-w-0 flex-1"> |
| 46 | + <div class="mb-1 flex flex-wrap items-center gap-2"> |
| 47 | + <h3 class="mb-0 text-lg font-semibold text-gray-90">{$title}</h3> |
| 48 | + <span class="rounded-full bg-support-1 px-2 py-0.5 text-xs font-medium text-primary">{$regionLabel}</span> |
| 49 | + </div> |
| 50 | + <p class="mb-3 text-body-2 text-gray-50">{$description}</p> |
| 51 | + <div class="rounded-xl bg-gray-15 px-4 py-3 text-xl font-semibold text-primary"> |
| 52 | + {$greeting} |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | +</div> |
| 57 | +HTML; |
0 commit comments