-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayout_editor.php
More file actions
81 lines (75 loc) · 2.58 KB
/
Copy pathlayout_editor.php
File metadata and controls
81 lines (75 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
require __DIR__ . '/auth.php';
$defaultFonts = [
'Inter, "Segoe UI", sans-serif',
'Roboto, "Helvetica Neue", Arial, sans-serif',
'Montserrat, "Segoe UI", sans-serif',
'Open Sans, "Helvetica Neue", sans-serif',
];
$fontConfigFile = __DIR__ . '/config/layout-editor.php';
$configuredFonts = [];
if (is_file($fontConfigFile)) {
$config = require $fontConfigFile;
if (is_array($config)) {
if (isset($config['fonts']) && is_array($config['fonts'])) {
$configuredFonts = $config['fonts'];
} elseif (function_exists('array_is_list') && array_is_list($config)) {
$configuredFonts = $config;
} elseif (array_key_exists(0, $config)) {
$configuredFonts = $config;
}
}
}
$fonts = array_values(array_filter(array_map('strval', $configuredFonts))); // remove invalid
if (!$fonts) {
$fonts = $defaultFonts;
}
$editorConfig = [
'pages' => [
['id' => 'page-1', 'title' => t('layout_editor.pages.default', ['index' => 1])],
],
'activePageId' => 'page-1',
'zoom' => 1,
'canvas' => [
'width' => 1024,
'height' => 768,
'gridSize' => 40,
],
'labels' => [
'page' => t('layout_editor.pages.label_pattern'),
'status' => t('layout_editor.pages.status_template'),
'cursor' => t('layout_editor.canvas.cursor'),
],
'messages' => [
'previewLoading' => t('layout_editor.properties.placeholder_preview_loading'),
'previewError' => t('layout_editor.properties.placeholder_preview_error'),
'placeholderHint' => t('layout_editor.properties.placeholder_expression_hint'),
],
'export' => [
'endpoint' => 'layout_export.php',
'strings' => [
'queued' => t('layout_editor.export.queued'),
'processing' => t('layout_editor.export.processing'),
'completed' => t('layout_editor.export.completed'),
'error' => t('layout_editor.export.error'),
'progress' => t('layout_editor.export.progress'),
'none' => t('layout_editor.export.none_available'),
],
],
'api' => [
'base' => 'layout_editor_api.php',
],
'fonts' => $fonts,
];
$user = auth_require('layout_editor');
render_page('layout-editor.tpl', [
'titleKey' => 'layout_editor.title',
'page' => 'layout_editor',
'editorConfig' => $editorConfig,
'fontOptions' => $fonts,
'extraStyles' => ['public/assets/css/layout-editor.css'],
'extraScripts' => [
'public/assets/js/vendor/qrcode.min.js',
'public/assets/js/layout-editor.js',
],
]);