12
12
use FileConverter \Engine \EngineBase ;
13
13
use FileConverter \Engine \Helper \Archive ;
14
14
use GuzzleHttp \json_decode ;
15
+ use QuipXml \OneLiner \OneLiner ;
15
16
16
17
class NativeSlideshow extends EngineBase {
17
18
/**
@@ -48,12 +49,7 @@ public function convertFile($source, $destination) {
48
49
49
50
// Apply the slideshow mode.
50
51
foreach ($ slideshow ['items ' ] as $ i => &$ slide ) {
51
- if (!isset ($ slide ['notes ' ])) {
52
- if ($ slideshow ['mode ' ] === 'schedule ' ) {
53
- unset($ slideshow ['items ' ][$ i ]);
54
- }
55
- }
56
- else {
52
+ if (isset ($ slide ['notes ' ])) {
57
53
// Extract settings from the slide notes.
58
54
$ keys = array (
59
55
'@(?<k>SLIDESHOW\.[^:]+):(?<v>[^\n]+)(?:\n|$)@s ' ,
@@ -73,6 +69,10 @@ public function convertFile($source, $destination) {
73
69
}
74
70
unset($ slide ['notes ' ]);
75
71
}
72
+ if ($ slideshow ['mode ' ] === 'schedule '
73
+ && (!isset ($ slide ['begin ' ]) || empty ($ slide ['begin ' ]))) {
74
+ unset($ slideshow ['items ' ][$ i ]);
75
+ }
76
76
}
77
77
unset($ slide );
78
78
$ slideshow ['items ' ] = array_values ($ slideshow ['items ' ]);
@@ -110,15 +110,40 @@ public function convertFile($source, $destination) {
110
110
$ this ->isTempWritable ($ to );
111
111
copy (__DIR__ . '/Resources/Slideshow/slideshow.css ' , $ to );
112
112
113
+ // Build the strtr replacements.
114
+ $ tr = array (
115
+ '{{ slideshow.title|escape }} ' => htmlspecialchars ($ slideshow ['title ' ]),
116
+ '{{ slideshow|json_encode() }} ' => json_encode ($ slideshow ),
117
+ '{{ debug }} ' => '' ,
118
+ );
119
+
120
+ // Build a debug page.
121
+ $ debug = '' ;
122
+ foreach ($ slideshow ['items ' ] as $ slide ) {
123
+ $ row = '' ;
124
+ $ img = OneLiner::wrap ('img ' , '' , TRUE , array (
125
+ 'src ' => "img/slide {$ slide [number]}.jpg " ,
126
+ 'style ' => 'width:95%;border:1px solid #000 ' ,
127
+ ));
128
+ $ row .= OneLiner::wrap ('<div class="col-sm-3"> ' , $ img );
129
+ $ details = '' ;
130
+ $ details .= OneLiner::wrap ('strong ' , 'BEGIN: ' . $ slide ['begin ' ]);
131
+ $ details .= '<br /> ' . json_encode ($ slide );
132
+ $ row .= OneLiner::wrap ('<div class="col-sm-9"> ' , $ details );
133
+ $ debug .= OneLiner::wrap ('<div class="row"> ' , $ row );
134
+ }
135
+ $ tr ['{{ debug }} ' ] = $ debug ;
136
+ $ to = "$ tmp/debug.htm " ;
137
+ $ content = file_get_contents (__DIR__ . '/Resources/Slideshow/debug.htm ' );
138
+ $ content = strtr ($ content , $ tr );
139
+ file_put_contents ($ to , $ content );
140
+
113
141
// The index file involves template variables.
114
142
// Provide a raw
115
143
$ to = "$ tmp/index.htm " ;
116
144
$ this ->isTempWritable ($ to );
117
145
$ content = file_get_contents (__DIR__ . '/Resources/Slideshow/index.htm ' );
118
- $ content = strtr ($ content , array (
119
- '{{ slideshow.title|escape }} ' => htmlspecialchars ($ slideshow ['title ' ]),
120
- '{{ slideshow|json_encode() }} ' => json_encode ($ slideshow ),
121
- ));
146
+ $ content = strtr ($ content , $ tr );
122
147
file_put_contents ($ to , $ content );
123
148
124
149
// Save the slideshow.
0 commit comments