Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
/**
3
 * Smarty Internal TestInstall
4
 * Test Smarty installation
5
 *
6
 * @package    Smarty
7
 * @subpackage Utilities
8
 * @author     Uwe Tews
9
 */
10
 
11
/**
12
 * TestInstall class
13
 *
14
 * @package    Smarty
15
 * @subpackage Utilities
16
 */
17
class Smarty_Internal_TestInstall
18
{
19
    /**
20
     * diagnose Smarty setup
21
     * If $errors is secified, the diagnostic report will be appended to the array, rather than being output.
22
     *
23
     * @param \Smarty $smarty
24
     * @param array   $errors array to push results into rather than outputting them
25
     *
26
     * @return bool status, true if everything is fine, false else
27
     */
28
    public static function testInstall(Smarty $smarty, &$errors = null)
29
    {
30
        $status = true;
31
        if ($errors === null) {
32
            echo "<PRE>\n";
33
            echo "Smarty Installation test...\n";
34
            echo "Testing template directory...\n";
35
        }
36
        $_stream_resolve_include_path = function_exists('stream_resolve_include_path');
37
        // test if all registered template_dir are accessible
38
        foreach ($smarty->getTemplateDir() as $template_dir) {
39
            $_template_dir = $template_dir;
40
            $template_dir = realpath($template_dir);
41
            // resolve include_path or fail existence
42
            if (!$template_dir) {
43
                if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) {
44
                    // try PHP include_path
45
                    if ($_stream_resolve_include_path) {
46
                        $template_dir = stream_resolve_include_path($_template_dir);
47
                    } else {
48
                        $template_dir = $smarty->ext->_getIncludePath->getIncludePath($_template_dir, null, $smarty);
49
                    }
50
                    if ($template_dir !== false) {
51
                        if ($errors === null) {
52
                            echo "$template_dir is OK.\n";
53
                        }
54
                        continue;
55
                    } else {
56
                        $status = false;
57
                        $message =
58
                            "FAILED: $_template_dir does not exist (and couldn't be found in include_path either)";
59
                        if ($errors === null) {
60
                            echo $message . ".\n";
61
                        } else {
62
                            $errors[ 'template_dir' ] = $message;
63
                        }
64
                        continue;
65
                    }
66
                } else {
67
                    $status = false;
68
                    $message = "FAILED: $_template_dir does not exist";
69
                    if ($errors === null) {
70
                        echo $message . ".\n";
71
                    } else {
72
                        $errors[ 'template_dir' ] = $message;
73
                    }
74
                    continue;
75
                }
76
            }
77
            if (!is_dir($template_dir)) {
78
                $status = false;
79
                $message = "FAILED: $template_dir is not a directory";
80
                if ($errors === null) {
81
                    echo $message . ".\n";
82
                } else {
83
                    $errors[ 'template_dir' ] = $message;
84
                }
85
            } elseif (!is_readable($template_dir)) {
86
                $status = false;
87
                $message = "FAILED: $template_dir is not readable";
88
                if ($errors === null) {
89
                    echo $message . ".\n";
90
                } else {
91
                    $errors[ 'template_dir' ] = $message;
92
                }
93
            } else {
94
                if ($errors === null) {
95
                    echo "$template_dir is OK.\n";
96
                }
97
            }
98
        }
99
        if ($errors === null) {
100
            echo "Testing compile directory...\n";
101
        }
102
        // test if registered compile_dir is accessible
103
        $__compile_dir = $smarty->getCompileDir();
104
        $_compile_dir = realpath($__compile_dir);
105
        if (!$_compile_dir) {
106
            $status = false;
107
            $message = "FAILED: {$__compile_dir} does not exist";
108
            if ($errors === null) {
109
                echo $message . ".\n";
110
            } else {
111
                $errors[ 'compile_dir' ] = $message;
112
            }
113
        } elseif (!is_dir($_compile_dir)) {
114
            $status = false;
115
            $message = "FAILED: {$_compile_dir} is not a directory";
116
            if ($errors === null) {
117
                echo $message . ".\n";
118
            } else {
119
                $errors[ 'compile_dir' ] = $message;
120
            }
121
        } elseif (!is_readable($_compile_dir)) {
122
            $status = false;
123
            $message = "FAILED: {$_compile_dir} is not readable";
124
            if ($errors === null) {
125
                echo $message . ".\n";
126
            } else {
127
                $errors[ 'compile_dir' ] = $message;
128
            }
129
        } elseif (!is_writable($_compile_dir)) {
130
            $status = false;
131
            $message = "FAILED: {$_compile_dir} is not writable";
132
            if ($errors === null) {
133
                echo $message . ".\n";
134
            } else {
135
                $errors[ 'compile_dir' ] = $message;
136
            }
137
        } else {
138
            if ($errors === null) {
139
                echo "{$_compile_dir} is OK.\n";
140
            }
141
        }
142
        if ($errors === null) {
143
            echo "Testing plugins directory...\n";
144
        }
145
        // test if all registered plugins_dir are accessible
146
        // and if core plugins directory is still registered
147
        $_core_plugins_dir = realpath(dirname(__FILE__) . '/../plugins');
148
        $_core_plugins_available = false;
149
        foreach ($smarty->getPluginsDir() as $plugin_dir) {
150
            $_plugin_dir = $plugin_dir;
151
            $plugin_dir = realpath($plugin_dir);
152
            // resolve include_path or fail existence
153
            if (!$plugin_dir) {
154
                if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
155
                    // try PHP include_path
156
                    if ($_stream_resolve_include_path) {
157
                        $plugin_dir = stream_resolve_include_path($_plugin_dir);
158
                    } else {
159
                        $plugin_dir = $smarty->ext->_getIncludePath->getIncludePath($_plugin_dir, null, $smarty);
160
                    }
161
                    if ($plugin_dir !== false) {
162
                        if ($errors === null) {
163
                            echo "$plugin_dir is OK.\n";
164
                        }
165
                        continue;
166
                    } else {
167
                        $status = false;
168
                        $message = "FAILED: $_plugin_dir does not exist (and couldn't be found in include_path either)";
169
                        if ($errors === null) {
170
                            echo $message . ".\n";
171
                        } else {
172
                            $errors[ 'plugins_dir' ] = $message;
173
                        }
174
                        continue;
175
                    }
176
                } else {
177
                    $status = false;
178
                    $message = "FAILED: $_plugin_dir does not exist";
179
                    if ($errors === null) {
180
                        echo $message . ".\n";
181
                    } else {
182
                        $errors[ 'plugins_dir' ] = $message;
183
                    }
184
                    continue;
185
                }
186
            }
187
            if (!is_dir($plugin_dir)) {
188
                $status = false;
189
                $message = "FAILED: $plugin_dir is not a directory";
190
                if ($errors === null) {
191
                    echo $message . ".\n";
192
                } else {
193
                    $errors[ 'plugins_dir' ] = $message;
194
                }
195
            } elseif (!is_readable($plugin_dir)) {
196
                $status = false;
197
                $message = "FAILED: $plugin_dir is not readable";
198
                if ($errors === null) {
199
                    echo $message . ".\n";
200
                } else {
201
                    $errors[ 'plugins_dir' ] = $message;
202
                }
203
            } elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) {
204
                $_core_plugins_available = true;
205
                if ($errors === null) {
206
                    echo "$plugin_dir is OK.\n";
207
                }
208
            } else {
209
                if ($errors === null) {
210
                    echo "$plugin_dir is OK.\n";
211
                }
212
            }
213
        }
214
        if (!$_core_plugins_available) {
215
            $status = false;
216
            $message = "WARNING: Smarty's own libs/plugins is not available";
217
            if ($errors === null) {
218
                echo $message . ".\n";
219
            } elseif (!isset($errors[ 'plugins_dir' ])) {
220
                $errors[ 'plugins_dir' ] = $message;
221
            }
222
        }
223
        if ($errors === null) {
224
            echo "Testing cache directory...\n";
225
        }
226
        // test if all registered cache_dir is accessible
227
        $__cache_dir = $smarty->getCacheDir();
228
        $_cache_dir = realpath($__cache_dir);
229
        if (!$_cache_dir) {
230
            $status = false;
231
            $message = "FAILED: {$__cache_dir} does not exist";
232
            if ($errors === null) {
233
                echo $message . ".\n";
234
            } else {
235
                $errors[ 'cache_dir' ] = $message;
236
            }
237
        } elseif (!is_dir($_cache_dir)) {
238
            $status = false;
239
            $message = "FAILED: {$_cache_dir} is not a directory";
240
            if ($errors === null) {
241
                echo $message . ".\n";
242
            } else {
243
                $errors[ 'cache_dir' ] = $message;
244
            }
245
        } elseif (!is_readable($_cache_dir)) {
246
            $status = false;
247
            $message = "FAILED: {$_cache_dir} is not readable";
248
            if ($errors === null) {
249
                echo $message . ".\n";
250
            } else {
251
                $errors[ 'cache_dir' ] = $message;
252
            }
253
        } elseif (!is_writable($_cache_dir)) {
254
            $status = false;
255
            $message = "FAILED: {$_cache_dir} is not writable";
256
            if ($errors === null) {
257
                echo $message . ".\n";
258
            } else {
259
                $errors[ 'cache_dir' ] = $message;
260
            }
261
        } else {
262
            if ($errors === null) {
263
                echo "{$_cache_dir} is OK.\n";
264
            }
265
        }
266
        if ($errors === null) {
267
            echo "Testing configs directory...\n";
268
        }
269
        // test if all registered config_dir are accessible
270
        foreach ($smarty->getConfigDir() as $config_dir) {
271
            $_config_dir = $config_dir;
272
            // resolve include_path or fail existence
273
            if (!$config_dir) {
274
                if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) {
275
                    // try PHP include_path
276
                    if ($_stream_resolve_include_path) {
277
                        $config_dir = stream_resolve_include_path($_config_dir);
278
                    } else {
279
                        $config_dir = $smarty->ext->_getIncludePath->getIncludePath($_config_dir, null, $smarty);
280
                    }
281
                    if ($config_dir !== false) {
282
                        if ($errors === null) {
283
                            echo "$config_dir is OK.\n";
284
                        }
285
                        continue;
286
                    } else {
287
                        $status = false;
288
                        $message = "FAILED: $_config_dir does not exist (and couldn't be found in include_path either)";
289
                        if ($errors === null) {
290
                            echo $message . ".\n";
291
                        } else {
292
                            $errors[ 'config_dir' ] = $message;
293
                        }
294
                        continue;
295
                    }
296
                } else {
297
                    $status = false;
298
                    $message = "FAILED: $_config_dir does not exist";
299
                    if ($errors === null) {
300
                        echo $message . ".\n";
301
                    } else {
302
                        $errors[ 'config_dir' ] = $message;
303
                    }
304
                    continue;
305
                }
306
            }
307
            if (!is_dir($config_dir)) {
308
                $status = false;
309
                $message = "FAILED: $config_dir is not a directory";
310
                if ($errors === null) {
311
                    echo $message . ".\n";
312
                } else {
313
                    $errors[ 'config_dir' ] = $message;
314
                }
315
            } elseif (!is_readable($config_dir)) {
316
                $status = false;
317
                $message = "FAILED: $config_dir is not readable";
318
                if ($errors === null) {
319
                    echo $message . ".\n";
320
                } else {
321
                    $errors[ 'config_dir' ] = $message;
322
                }
323
            } else {
324
                if ($errors === null) {
325
                    echo "$config_dir is OK.\n";
326
                }
327
            }
328
        }
329
        if ($errors === null) {
330
            echo "Testing sysplugin files...\n";
331
        }
332
        // test if sysplugins are available
333
        $source = SMARTY_SYSPLUGINS_DIR;
334
        if (is_dir($source)) {
335
            $expectedSysplugins = array(
336
                'smartycompilerexception.php'                               => true,
337
                'smartyexception.php'                                       => true,
338
                'smarty_cacheresource.php'                                  => true,
339
                'smarty_cacheresource_custom.php'                           => true,
340
                'smarty_cacheresource_keyvaluestore.php'                    => true,
341
                'smarty_data.php'                                           => true,
342
                'smarty_internal_block.php'                                 => true,
343
                'smarty_internal_cacheresource_file.php'                    => true,
344
                'smarty_internal_compilebase.php'                           => true,
345
                'smarty_internal_compile_append.php'                        => true,
346
                'smarty_internal_compile_assign.php'                        => true,
347
                'smarty_internal_compile_block.php'                         => true,
348
                'smarty_internal_compile_block_child.php'                   => true,
349
                'smarty_internal_compile_block_parent.php'                  => true,
350
                'smarty_internal_compile_child.php'                         => true,
351
                'smarty_internal_compile_parent.php'                        => true,
352
                'smarty_internal_compile_break.php'                         => true,
353
                'smarty_internal_compile_call.php'                          => true,
354
                'smarty_internal_compile_capture.php'                       => true,
355
                'smarty_internal_compile_config_load.php'                   => true,
356
                'smarty_internal_compile_continue.php'                      => true,
357
                'smarty_internal_compile_debug.php'                         => true,
358
                'smarty_internal_compile_eval.php'                          => true,
359
                'smarty_internal_compile_extends.php'                       => true,
360
                'smarty_internal_compile_for.php'                           => true,
361
                'smarty_internal_compile_foreach.php'                       => true,
362
                'smarty_internal_compile_function.php'                      => true,
363
                'smarty_internal_compile_if.php'                            => true,
364
                'smarty_internal_compile_include.php'                       => true,
365
                'smarty_internal_compile_include_php.php'                   => true,
366
                'smarty_internal_compile_insert.php'                        => true,
367
                'smarty_internal_compile_ldelim.php'                        => true,
368
                'smarty_internal_compile_make_nocache.php'                  => true,
369
                'smarty_internal_compile_nocache.php'                       => true,
370
                'smarty_internal_compile_private_block_plugin.php'          => true,
371
                'smarty_internal_compile_private_foreachsection.php'        => true,
372
                'smarty_internal_compile_private_function_plugin.php'       => true,
373
                'smarty_internal_compile_private_modifier.php'              => true,
374
                'smarty_internal_compile_private_object_block_function.php' => true,
375
                'smarty_internal_compile_private_object_function.php'       => true,
376
                'smarty_internal_compile_private_php.php'                   => true,
377
                'smarty_internal_compile_private_print_expression.php'      => true,
378
                'smarty_internal_compile_private_registered_block.php'      => true,
379
                'smarty_internal_compile_private_registered_function.php'   => true,
380
                'smarty_internal_compile_private_special_variable.php'      => true,
381
                'smarty_internal_compile_rdelim.php'                        => true,
382
                'smarty_internal_compile_section.php'                       => true,
383
                'smarty_internal_compile_setfilter.php'                     => true,
384
                'smarty_internal_compile_shared_inheritance.php'            => true,
385
                'smarty_internal_compile_while.php'                         => true,
386
                'smarty_internal_configfilelexer.php'                       => true,
387
                'smarty_internal_configfileparser.php'                      => true,
388
                'smarty_internal_config_file_compiler.php'                  => true,
389
                'smarty_internal_data.php'                                  => true,
390
                'smarty_internal_debug.php'                                 => true,
391
                'smarty_internal_errorhandler.php'                          => true,
392
                'smarty_internal_extension_handler.php'                     => true,
393
                'smarty_internal_method_addautoloadfilters.php'             => true,
394
                'smarty_internal_method_adddefaultmodifiers.php'            => true,
395
                'smarty_internal_method_append.php'                         => true,
396
                'smarty_internal_method_appendbyref.php'                    => true,
397
                'smarty_internal_method_assignbyref.php'                    => true,
398
                'smarty_internal_method_assignglobal.php'                   => true,
399
                'smarty_internal_method_clearallassign.php'                 => true,
400
                'smarty_internal_method_clearallcache.php'                  => true,
401
                'smarty_internal_method_clearassign.php'                    => true,
402
                'smarty_internal_method_clearcache.php'                     => true,
403
                'smarty_internal_method_clearcompiledtemplate.php'          => true,
404
                'smarty_internal_method_clearconfig.php'                    => true,
405
                'smarty_internal_method_compileallconfig.php'               => true,
406
                'smarty_internal_method_compilealltemplates.php'            => true,
407
                'smarty_internal_method_configload.php'                     => true,
408
                'smarty_internal_method_createdata.php'                     => true,
409
                'smarty_internal_method_getautoloadfilters.php'             => true,
410
                'smarty_internal_method_getconfigvariable.php'              => true,
411
                'smarty_internal_method_getconfigvars.php'                  => true,
412
                'smarty_internal_method_getdebugtemplate.php'               => true,
413
                'smarty_internal_method_getdefaultmodifiers.php'            => true,
414
                'smarty_internal_method_getglobal.php'                      => true,
415
                'smarty_internal_method_getregisteredobject.php'            => true,
416
                'smarty_internal_method_getstreamvariable.php'              => true,
417
                'smarty_internal_method_gettags.php'                        => true,
418
                'smarty_internal_method_gettemplatevars.php'                => true,
419
                'smarty_internal_method_literals.php'                       => true,
420
                'smarty_internal_method_loadfilter.php'                     => true,
421
                'smarty_internal_method_loadplugin.php'                     => true,
422
                'smarty_internal_method_mustcompile.php'                    => true,
423
                'smarty_internal_method_registercacheresource.php'          => true,
424
                'smarty_internal_method_registerclass.php'                  => true,
425
                'smarty_internal_method_registerdefaultconfighandler.php'   => true,
426
                'smarty_internal_method_registerdefaultpluginhandler.php'   => true,
427
                'smarty_internal_method_registerdefaulttemplatehandler.php' => true,
428
                'smarty_internal_method_registerfilter.php'                 => true,
429
                'smarty_internal_method_registerobject.php'                 => true,
430
                'smarty_internal_method_registerplugin.php'                 => true,
431
                'smarty_internal_method_registerresource.php'               => true,
432
                'smarty_internal_method_setautoloadfilters.php'             => true,
433
                'smarty_internal_method_setdebugtemplate.php'               => true,
434
                'smarty_internal_method_setdefaultmodifiers.php'            => true,
435
                'smarty_internal_method_unloadfilter.php'                   => true,
436
                'smarty_internal_method_unregistercacheresource.php'        => true,
437
                'smarty_internal_method_unregisterfilter.php'               => true,
438
                'smarty_internal_method_unregisterobject.php'               => true,
439
                'smarty_internal_method_unregisterplugin.php'               => true,
440
                'smarty_internal_method_unregisterresource.php'             => true,
441
                'smarty_internal_nocache_insert.php'                        => true,
442
                'smarty_internal_parsetree.php'                             => true,
443
                'smarty_internal_parsetree_code.php'                        => true,
444
                'smarty_internal_parsetree_dq.php'                          => true,
445
                'smarty_internal_parsetree_dqcontent.php'                   => true,
446
                'smarty_internal_parsetree_tag.php'                         => true,
447
                'smarty_internal_parsetree_template.php'                    => true,
448
                'smarty_internal_parsetree_text.php'                        => true,
449
                'smarty_internal_resource_eval.php'                         => true,
450
                'smarty_internal_resource_extends.php'                      => true,
451
                'smarty_internal_resource_file.php'                         => true,
452
                'smarty_internal_resource_php.php'                          => true,
453
                'smarty_internal_resource_registered.php'                   => true,
454
                'smarty_internal_resource_stream.php'                       => true,
455
                'smarty_internal_resource_string.php'                       => true,
456
                'smarty_internal_runtime_cachemodify.php'                   => true,
457
                'smarty_internal_runtime_cacheresourcefile.php'             => true,
458
                'smarty_internal_runtime_capture.php'                       => true,
459
                'smarty_internal_runtime_codeframe.php'                     => true,
460
                'smarty_internal_runtime_filterhandler.php'                 => true,
461
                'smarty_internal_runtime_foreach.php'                       => true,
462
                'smarty_internal_runtime_getincludepath.php'                => true,
463
                'smarty_internal_runtime_inheritance.php'                   => true,
464
                'smarty_internal_runtime_make_nocache.php'                  => true,
465
                'smarty_internal_runtime_tplfunction.php'                   => true,
466
                'smarty_internal_runtime_updatecache.php'                   => true,
467
                'smarty_internal_runtime_updatescope.php'                   => true,
468
                'smarty_internal_runtime_writefile.php'                     => true,
469
                'smarty_internal_smartytemplatecompiler.php'                => true,
470
                'smarty_internal_template.php'                              => true,
471
                'smarty_internal_templatebase.php'                          => true,
472
                'smarty_internal_templatecompilerbase.php'                  => true,
473
                'smarty_internal_templatelexer.php'                         => true,
474
                'smarty_internal_templateparser.php'                        => true,
475
                'smarty_internal_testinstall.php'                           => true,
476
                'smarty_internal_undefined.php'                             => true,
477
                'smarty_resource.php'                                       => true,
478
                'smarty_resource_custom.php'                                => true,
479
                'smarty_resource_recompiled.php'                            => true,
480
                'smarty_resource_uncompiled.php'                            => true,
481
                'smarty_security.php'                                       => true,
482
                'smarty_template_cached.php'                                => true,
483
                'smarty_template_compiled.php'                              => true,
484
                'smarty_template_config.php'                                => true,
485
                'smarty_template_resource_base.php'                         => true,
486
                'smarty_template_source.php'                                => true,
487
                'smarty_undefined_variable.php'                             => true,
488
                'smarty_variable.php'                                       => true,
489
            );
490
            $iterator = new DirectoryIterator($source);
491
            foreach ($iterator as $file) {
492
                if (!$file->isDot()) {
493
                    $filename = $file->getFilename();
494
                    if (isset($expectedSysplugins[ $filename ])) {
495
                        unset($expectedSysplugins[ $filename ]);
496
                    }
497
                }
498
            }
499
            if ($expectedSysplugins) {
500
                $status = false;
501
                $message = "FAILED: files missing from libs/sysplugins: " . join(', ', array_keys($expectedSysplugins));
502
                if ($errors === null) {
503
                    echo $message . ".\n";
504
                } else {
505
                    $errors[ 'sysplugins' ] = $message;
506
                }
507
            } elseif ($errors === null) {
508
                echo "... OK\n";
509
            }
510
        } else {
511
            $status = false;
512
            $message = "FAILED: " . SMARTY_SYSPLUGINS_DIR . ' is not a directory';
513
            if ($errors === null) {
514
                echo $message . ".\n";
515
            } else {
516
                $errors[ 'sysplugins_dir_constant' ] = $message;
517
            }
518
        }
519
        if ($errors === null) {
520
            echo "Testing plugin files...\n";
521
        }
522
        // test if core plugins are available
523
        $source = SMARTY_PLUGINS_DIR;
524
        if (is_dir($source)) {
525
            $expectedPlugins = array(
526
                'block.textformat.php'                  => true,
527
                'function.counter.php'                  => true,
528
                'function.cycle.php'                    => true,
529
                'function.fetch.php'                    => true,
530
                'function.html_checkboxes.php'          => true,
531
                'function.html_image.php'               => true,
532
                'function.html_options.php'             => true,
533
                'function.html_radios.php'              => true,
534
                'function.html_select_date.php'         => true,
535
                'function.html_select_time.php'         => true,
536
                'function.html_table.php'               => true,
537
                'function.mailto.php'                   => true,
538
                'function.math.php'                     => true,
539
                'modifier.capitalize.php'               => true,
540
                'modifier.date_format.php'              => true,
541
                'modifier.debug_print_var.php'          => true,
542
                'modifier.escape.php'                   => true,
543
                'modifier.mb_wordwrap.php'              => true,
544
                'modifier.regex_replace.php'            => true,
545
                'modifier.replace.php'                  => true,
546
                'modifier.spacify.php'                  => true,
547
                'modifier.truncate.php'                 => true,
548
                'modifiercompiler.cat.php'              => true,
549
                'modifiercompiler.count_characters.php' => true,
550
                'modifiercompiler.count_paragraphs.php' => true,
551
                'modifiercompiler.count_sentences.php'  => true,
552
                'modifiercompiler.count_words.php'      => true,
553
                'modifiercompiler.default.php'          => true,
554
                'modifiercompiler.escape.php'           => true,
555
                'modifiercompiler.from_charset.php'     => true,
556
                'modifiercompiler.indent.php'           => true,
557
                'modifiercompiler.lower.php'            => true,
558
                'modifiercompiler.noprint.php'          => true,
559
                'modifiercompiler.string_format.php'    => true,
560
                'modifiercompiler.strip.php'            => true,
561
                'modifiercompiler.strip_tags.php'       => true,
562
                'modifiercompiler.to_charset.php'       => true,
563
                'modifiercompiler.unescape.php'         => true,
564
                'modifiercompiler.upper.php'            => true,
565
                'modifiercompiler.wordwrap.php'         => true,
566
                'outputfilter.trimwhitespace.php'       => true,
567
                'shared.escape_special_chars.php'       => true,
568
                'shared.literal_compiler_param.php'     => true,
569
                'shared.make_timestamp.php'             => true,
570
                'shared.mb_str_replace.php'             => true,
571
                'shared.mb_unicode.php'                 => true,
572
                'variablefilter.htmlspecialchars.php'   => true,
573
            );
574
            $iterator = new DirectoryIterator($source);
575
            foreach ($iterator as $file) {
576
                if (!$file->isDot()) {
577
                    $filename = $file->getFilename();
578
                    if (isset($expectedPlugins[ $filename ])) {
579
                        unset($expectedPlugins[ $filename ]);
580
                    }
581
                }
582
            }
583
            if ($expectedPlugins) {
584
                $status = false;
585
                $message = "FAILED: files missing from libs/plugins: " . join(', ', array_keys($expectedPlugins));
586
                if ($errors === null) {
587
                    echo $message . ".\n";
588
                } else {
589
                    $errors[ 'plugins' ] = $message;
590
                }
591
            } elseif ($errors === null) {
592
                echo "... OK\n";
593
            }
594
        } else {
595
            $status = false;
596
            $message = "FAILED: " . SMARTY_PLUGINS_DIR . ' is not a directory';
597
            if ($errors === null) {
598
                echo $message . ".\n";
599
            } else {
600
                $errors[ 'plugins_dir_constant' ] = $message;
601
            }
602
        }
603
        if ($errors === null) {
604
            echo "Tests complete.\n";
605
            echo "</PRE>\n";
606
        }
607
        return $status;
608
    }
609
}