3 * Project: Smarty: the PHP compiling template engine
4 * File: smarty_internal_utility.php
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * For questions, help, comments, discussion, etc., please join the
18 * Smarty mailing list. Send a blank e-mail to
19 * smarty-discussion-subscribe@googlegroups.com
21 * @link http://www.smarty.net/
22 * @copyright 2008 New Digital Group, Inc.
23 * @author Monte Ohrt <monte at ohrt dot com>
26 * @subpackage PluginsInternal
27 * @version 3-SVN$Rev: 3286 $
34 * @subpackage Security
36 class Smarty_Internal_Utility
39 * private constructor to prevent calls creation of new instances
41 final private function __construct()
43 // intentionally left blank
47 * Compile all template files
49 * @param string $extension template file name extension
50 * @param bool $force_compile force all to recompile
51 * @param int $time_limit set maximum execution time
52 * @param int $max_errors set maximum allowed errors
53 * @param Smarty $smarty Smarty instance
55 * @return integer number of template files compiled
57 public static function compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
59 // switch off time limit
60 if (function_exists('set_time_limit')) {
61 @set_time_limit($time_limit);
63 $smarty->force_compile = $force_compile;
66 // loop over array of template directories
67 foreach ($smarty->getTemplateDir() as $_dir) {
68 $_compileDirs = new RecursiveDirectoryIterator($_dir);
69 $_compile = new RecursiveIteratorIterator($_compileDirs);
70 foreach ($_compile as $_fileinfo) {
71 $_file = $_fileinfo->getFilename();
72 if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
75 if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
78 if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) {
79 $_template_file = $_file;
81 $_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
83 echo '<br>', $_dir, '---', $_template_file;
85 $_start_time = microtime(true);
87 $_tpl = $smarty->createTemplate($_template_file, null, null, null, false);
88 if ($_tpl->mustCompile()) {
89 $_tpl->compileTemplateSource();
91 echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
94 echo ' is up to date';
98 catch (Exception $e) {
99 echo 'Error: ', $e->getMessage(), "<br><br>";
103 $smarty->template_objects = array();
104 $_tpl->smarty->template_objects = array();
106 if ($max_errors !== null && $_error_count == $max_errors) {
107 echo '<br><br>too many errors';
117 * Compile all config files
119 * @param string $extension config file name extension
120 * @param bool $force_compile force all to recompile
121 * @param int $time_limit set maximum execution time
122 * @param int $max_errors set maximum allowed errors
123 * @param Smarty $smarty Smarty instance
125 * @return integer number of config files compiled
127 public static function compileAllConfig($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
129 // switch off time limit
130 if (function_exists('set_time_limit')) {
131 @set_time_limit($time_limit);
133 $smarty->force_compile = $force_compile;
136 // loop over array of template directories
137 foreach ($smarty->getConfigDir() as $_dir) {
138 $_compileDirs = new RecursiveDirectoryIterator($_dir);
139 $_compile = new RecursiveIteratorIterator($_compileDirs);
140 foreach ($_compile as $_fileinfo) {
141 $_file = $_fileinfo->getFilename();
142 if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
145 if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
148 if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) {
149 $_config_file = $_file;
151 $_config_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
153 echo '<br>', $_dir, '---', $_config_file;
155 $_start_time = microtime(true);
157 $_config = new Smarty_Internal_Config($_config_file, $smarty);
158 if ($_config->mustCompile()) {
159 $_config->compileConfigSource();
161 echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
164 echo ' is up to date';
168 catch (Exception $e) {
169 echo 'Error: ', $e->getMessage(), "<br><br>";
172 if ($max_errors !== null && $_error_count == $max_errors) {
173 echo '<br><br>too many errors';
183 * Delete compiled template file
185 * @param string $resource_name template name
186 * @param string $compile_id compile id
187 * @param integer $exp_time expiration time
188 * @param Smarty $smarty Smarty instance
190 * @return integer number of template files deleted
192 public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty)
194 $_compile_dir = realpath($smarty->getCompileDir()) . '/';
195 $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
196 $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
197 if (isset($resource_name)) {
198 $_save_stat = $smarty->caching;
199 $smarty->caching = false;
200 $tpl = new $smarty->template_class($resource_name, $smarty);
201 $smarty->caching = $_save_stat;
203 // remove from template cache
204 $tpl->source; // have the template registered before unset()
205 if ($smarty->allow_ambiguous_resources) {
206 $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
208 $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
210 if (isset($_templateId[150])) {
211 $_templateId = sha1($_templateId);
213 unset($smarty->template_objects[$_templateId]);
215 if ($tpl->source->exists) {
216 $_resource_part_1 = basename(str_replace('^', '/', $tpl->compiled->filepath));
217 $_resource_part_1_length = strlen($_resource_part_1);
222 $_resource_part_2 = str_replace('.php', '.cache.php', $_resource_part_1);
223 $_resource_part_2_length = strlen($_resource_part_2);
225 $_dir = $_compile_dir;
226 if ($smarty->use_sub_dirs && isset($_compile_id)) {
227 $_dir .= $_compile_id . $_dir_sep;
229 if (isset($_compile_id)) {
230 $_compile_id_part = str_replace('\\', '/', $_compile_dir . $_compile_id . $_dir_sep);
231 $_compile_id_part_length = strlen($_compile_id_part);
235 $_compileDirs = new RecursiveDirectoryIterator($_dir);
236 // NOTE: UnexpectedValueException thrown for PHP >= 5.3
238 catch (Exception $e) {
241 $_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
242 foreach ($_compile as $_file) {
243 if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
247 $_filepath = str_replace('\\', '/', (string) $_file);
249 if ($_file->isDir()) {
250 if (!$_compile->isDot()) {
251 // delete folder if empty
252 @rmdir($_file->getPathname());
256 if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && $a = !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length)))
257 && (!isset($resource_name)
258 || (isset($_filepath[$_resource_part_1_length])
259 && substr_compare($_filepath, $_resource_part_1, - $_resource_part_1_length, $_resource_part_1_length) == 0)
260 || (isset($_filepath[$_resource_part_2_length])
261 && substr_compare($_filepath, $_resource_part_2, - $_resource_part_2_length, $_resource_part_2_length) == 0))
263 if (isset($exp_time)) {
264 if (time() - @filemtime($_filepath) >= $exp_time) {
272 if ($unlink && @unlink($_filepath)) {
277 // clear compiled cache
278 Smarty_Resource::$sources = array();
279 Smarty_Resource::$compileds = array();
285 * Return array of tag/attributes of all tags used by an template
287 * @param Smarty_Internal_Template $template
290 * @throws SmartyException
291 * @return array of tag/attributes
293 public static function getTags(Smarty_Internal_Template $template)
295 $template->smarty->get_used_tags = true;
296 $template->compileTemplateSource();
298 return $template->used_tags;
302 * diagnose Smarty setup
303 * If $errors is secified, the diagnostic report will be appended to the array, rather than being output.
305 * @param Smarty $smarty Smarty instance to test
306 * @param array $errors array to push results into rather than outputting them
308 * @return bool status, true if everything is fine, false else
310 public static function testInstall(Smarty $smarty, &$errors = null)
314 if ($errors === null) {
316 echo "Smarty Installation test...\n";
317 echo "Testing template directory...\n";
320 $_stream_resolve_include_path = function_exists('stream_resolve_include_path');
322 // test if all registered template_dir are accessible
323 foreach ($smarty->getTemplateDir() as $template_dir) {
324 $_template_dir = $template_dir;
325 $template_dir = realpath($template_dir);
326 // resolve include_path or fail existence
327 if (!$template_dir) {
328 if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) {
329 // try PHP include_path
330 if ($_stream_resolve_include_path) {
331 $template_dir = stream_resolve_include_path($_template_dir);
333 $template_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_template_dir);
336 if ($template_dir !== false) {
337 if ($errors === null) {
338 echo "$template_dir is OK.\n";
344 $message = "FAILED: $_template_dir does not exist (and couldn't be found in include_path either)";
345 if ($errors === null) {
346 echo $message . ".\n";
348 $errors['template_dir'] = $message;
355 $message = "FAILED: $_template_dir does not exist";
356 if ($errors === null) {
357 echo $message . ".\n";
359 $errors['template_dir'] = $message;
366 if (!is_dir($template_dir)) {
368 $message = "FAILED: $template_dir is not a directory";
369 if ($errors === null) {
370 echo $message . ".\n";
372 $errors['template_dir'] = $message;
374 } elseif (!is_readable($template_dir)) {
376 $message = "FAILED: $template_dir is not readable";
377 if ($errors === null) {
378 echo $message . ".\n";
380 $errors['template_dir'] = $message;
383 if ($errors === null) {
384 echo "$template_dir is OK.\n";
389 if ($errors === null) {
390 echo "Testing compile directory...\n";
393 // test if registered compile_dir is accessible
394 $__compile_dir = $smarty->getCompileDir();
395 $_compile_dir = realpath($__compile_dir);
396 if (!$_compile_dir) {
398 $message = "FAILED: {$__compile_dir} does not exist";
399 if ($errors === null) {
400 echo $message . ".\n";
402 $errors['compile_dir'] = $message;
404 } elseif (!is_dir($_compile_dir)) {
406 $message = "FAILED: {$_compile_dir} is not a directory";
407 if ($errors === null) {
408 echo $message . ".\n";
410 $errors['compile_dir'] = $message;
412 } elseif (!is_readable($_compile_dir)) {
414 $message = "FAILED: {$_compile_dir} is not readable";
415 if ($errors === null) {
416 echo $message . ".\n";
418 $errors['compile_dir'] = $message;
420 } elseif (!is_writable($_compile_dir)) {
422 $message = "FAILED: {$_compile_dir} is not writable";
423 if ($errors === null) {
424 echo $message . ".\n";
426 $errors['compile_dir'] = $message;
429 if ($errors === null) {
430 echo "{$_compile_dir} is OK.\n";
434 if ($errors === null) {
435 echo "Testing plugins directory...\n";
438 // test if all registered plugins_dir are accessible
439 // and if core plugins directory is still registered
440 $_core_plugins_dir = realpath(dirname(__FILE__) . '/../plugins');
441 $_core_plugins_available = false;
442 foreach ($smarty->getPluginsDir() as $plugin_dir) {
443 $_plugin_dir = $plugin_dir;
444 $plugin_dir = realpath($plugin_dir);
445 // resolve include_path or fail existence
447 if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
448 // try PHP include_path
449 if ($_stream_resolve_include_path) {
450 $plugin_dir = stream_resolve_include_path($_plugin_dir);
452 $plugin_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_plugin_dir);
455 if ($plugin_dir !== false) {
456 if ($errors === null) {
457 echo "$plugin_dir is OK.\n";
463 $message = "FAILED: $_plugin_dir does not exist (and couldn't be found in include_path either)";
464 if ($errors === null) {
465 echo $message . ".\n";
467 $errors['plugins_dir'] = $message;
474 $message = "FAILED: $_plugin_dir does not exist";
475 if ($errors === null) {
476 echo $message . ".\n";
478 $errors['plugins_dir'] = $message;
485 if (!is_dir($plugin_dir)) {
487 $message = "FAILED: $plugin_dir is not a directory";
488 if ($errors === null) {
489 echo $message . ".\n";
491 $errors['plugins_dir'] = $message;
493 } elseif (!is_readable($plugin_dir)) {
495 $message = "FAILED: $plugin_dir is not readable";
496 if ($errors === null) {
497 echo $message . ".\n";
499 $errors['plugins_dir'] = $message;
501 } elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) {
502 $_core_plugins_available = true;
503 if ($errors === null) {
504 echo "$plugin_dir is OK.\n";
507 if ($errors === null) {
508 echo "$plugin_dir is OK.\n";
512 if (!$_core_plugins_available) {
514 $message = "WARNING: Smarty's own libs/plugins is not available";
515 if ($errors === null) {
516 echo $message . ".\n";
517 } elseif (!isset($errors['plugins_dir'])) {
518 $errors['plugins_dir'] = $message;
522 if ($errors === null) {
523 echo "Testing cache directory...\n";
526 // test if all registered cache_dir is accessible
527 $__cache_dir = $smarty->getCacheDir();
528 $_cache_dir = realpath($__cache_dir);
531 $message = "FAILED: {$__cache_dir} does not exist";
532 if ($errors === null) {
533 echo $message . ".\n";
535 $errors['cache_dir'] = $message;
537 } elseif (!is_dir($_cache_dir)) {
539 $message = "FAILED: {$_cache_dir} is not a directory";
540 if ($errors === null) {
541 echo $message . ".\n";
543 $errors['cache_dir'] = $message;
545 } elseif (!is_readable($_cache_dir)) {
547 $message = "FAILED: {$_cache_dir} is not readable";
548 if ($errors === null) {
549 echo $message . ".\n";
551 $errors['cache_dir'] = $message;
553 } elseif (!is_writable($_cache_dir)) {
555 $message = "FAILED: {$_cache_dir} is not writable";
556 if ($errors === null) {
557 echo $message . ".\n";
559 $errors['cache_dir'] = $message;
562 if ($errors === null) {
563 echo "{$_cache_dir} is OK.\n";
567 if ($errors === null) {
568 echo "Testing configs directory...\n";
571 // test if all registered config_dir are accessible
572 foreach ($smarty->getConfigDir() as $config_dir) {
573 $_config_dir = $config_dir;
574 $config_dir = realpath($config_dir);
575 // resolve include_path or fail existence
577 if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) {
578 // try PHP include_path
579 if ($_stream_resolve_include_path) {
580 $config_dir = stream_resolve_include_path($_config_dir);
582 $config_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_config_dir);
585 if ($config_dir !== false) {
586 if ($errors === null) {
587 echo "$config_dir is OK.\n";
593 $message = "FAILED: $_config_dir does not exist (and couldn't be found in include_path either)";
594 if ($errors === null) {
595 echo $message . ".\n";
597 $errors['config_dir'] = $message;
604 $message = "FAILED: $_config_dir does not exist";
605 if ($errors === null) {
606 echo $message . ".\n";
608 $errors['config_dir'] = $message;
615 if (!is_dir($config_dir)) {
617 $message = "FAILED: $config_dir is not a directory";
618 if ($errors === null) {
619 echo $message . ".\n";
621 $errors['config_dir'] = $message;
623 } elseif (!is_readable($config_dir)) {
625 $message = "FAILED: $config_dir is not readable";
626 if ($errors === null) {
627 echo $message . ".\n";
629 $errors['config_dir'] = $message;
632 if ($errors === null) {
633 echo "$config_dir is OK.\n";
638 if ($errors === null) {
639 echo "Testing sysplugin files...\n";
641 // test if sysplugins are available
642 $source = SMARTY_SYSPLUGINS_DIR;
643 if (is_dir($source)) {
645 "smarty_cacheresource.php" => true,
646 "smarty_cacheresource_custom.php" => true,
647 "smarty_cacheresource_keyvaluestore.php" => true,
648 "smarty_config_source.php" => true,
649 "smarty_internal_cacheresource_file.php" => true,
650 "smarty_internal_compile_append.php" => true,
651 "smarty_internal_compile_assign.php" => true,
652 "smarty_internal_compile_block.php" => true,
653 "smarty_internal_compile_break.php" => true,
654 "smarty_internal_compile_call.php" => true,
655 "smarty_internal_compile_capture.php" => true,
656 "smarty_internal_compile_config_load.php" => true,
657 "smarty_internal_compile_continue.php" => true,
658 "smarty_internal_compile_debug.php" => true,
659 "smarty_internal_compile_eval.php" => true,
660 "smarty_internal_compile_extends.php" => true,
661 "smarty_internal_compile_for.php" => true,
662 "smarty_internal_compile_foreach.php" => true,
663 "smarty_internal_compile_function.php" => true,
664 "smarty_internal_compile_if.php" => true,
665 "smarty_internal_compile_include.php" => true,
666 "smarty_internal_compile_include_php.php" => true,
667 "smarty_internal_compile_insert.php" => true,
668 "smarty_internal_compile_ldelim.php" => true,
669 "smarty_internal_compile_nocache.php" => true,
670 "smarty_internal_compile_private_block_plugin.php" => true,
671 "smarty_internal_compile_private_function_plugin.php" => true,
672 "smarty_internal_compile_private_modifier.php" => true,
673 "smarty_internal_compile_private_object_block_function.php" => true,
674 "smarty_internal_compile_private_object_function.php" => true,
675 "smarty_internal_compile_private_print_expression.php" => true,
676 "smarty_internal_compile_private_registered_block.php" => true,
677 "smarty_internal_compile_private_registered_function.php" => true,
678 "smarty_internal_compile_private_special_variable.php" => true,
679 "smarty_internal_compile_rdelim.php" => true,
680 "smarty_internal_compile_section.php" => true,
681 "smarty_internal_compile_setfilter.php" => true,
682 "smarty_internal_compile_while.php" => true,
683 "smarty_internal_compilebase.php" => true,
684 "smarty_internal_config.php" => true,
685 "smarty_internal_config_file_compiler.php" => true,
686 "smarty_internal_configfilelexer.php" => true,
687 "smarty_internal_configfileparser.php" => true,
688 "smarty_internal_data.php" => true,
689 "smarty_internal_debug.php" => true,
690 "smarty_internal_filter_handler.php" => true,
691 "smarty_internal_function_call_handler.php" => true,
692 "smarty_internal_get_include_path.php" => true,
693 "smarty_internal_nocache_insert.php" => true,
694 "smarty_internal_parsetree.php" => true,
695 "smarty_internal_resource_eval.php" => true,
696 "smarty_internal_resource_extends.php" => true,
697 "smarty_internal_resource_file.php" => true,
698 "smarty_internal_resource_registered.php" => true,
699 "smarty_internal_resource_stream.php" => true,
700 "smarty_internal_resource_string.php" => true,
701 "smarty_internal_smartytemplatecompiler.php" => true,
702 "smarty_internal_template.php" => true,
703 "smarty_internal_templatebase.php" => true,
704 "smarty_internal_templatecompilerbase.php" => true,
705 "smarty_internal_templatelexer.php" => true,
706 "smarty_internal_templateparser.php" => true,
707 "smarty_internal_utility.php" => true,
708 "smarty_internal_write_file.php" => true,
709 "smarty_resource.php" => true,
710 "smarty_resource_custom.php" => true,
711 "smarty_resource_recompiled.php" => true,
712 "smarty_resource_uncompiled.php" => true,
713 "smarty_security.php" => true,
715 $iterator = new DirectoryIterator($source);
716 foreach ($iterator as $file) {
717 if (!$file->isDot()) {
718 $filename = $file->getFilename();
719 if (isset($expected[$filename])) {
720 unset($expected[$filename]);
726 $message = "FAILED: files missing from libs/sysplugins: " . join(', ', array_keys($expected));
727 if ($errors === null) {
728 echo $message . ".\n";
730 $errors['sysplugins'] = $message;
732 } elseif ($errors === null) {
737 $message = "FAILED: " . SMARTY_SYSPLUGINS_DIR . ' is not a directory';
738 if ($errors === null) {
739 echo $message . ".\n";
741 $errors['sysplugins_dir_constant'] = $message;
745 if ($errors === null) {
746 echo "Testing plugin files...\n";
748 // test if core plugins are available
749 $source = SMARTY_PLUGINS_DIR;
750 if (is_dir($source)) {
752 "block.textformat.php" => true,
753 "function.counter.php" => true,
754 "function.cycle.php" => true,
755 "function.fetch.php" => true,
756 "function.html_checkboxes.php" => true,
757 "function.html_image.php" => true,
758 "function.html_options.php" => true,
759 "function.html_radios.php" => true,
760 "function.html_select_date.php" => true,
761 "function.html_select_time.php" => true,
762 "function.html_table.php" => true,
763 "function.mailto.php" => true,
764 "function.math.php" => true,
765 "modifier.capitalize.php" => true,
766 "modifier.date_format.php" => true,
767 "modifier.debug_print_var.php" => true,
768 "modifier.escape.php" => true,
769 "modifier.regex_replace.php" => true,
770 "modifier.replace.php" => true,
771 "modifier.spacify.php" => true,
772 "modifier.truncate.php" => true,
773 "modifiercompiler.cat.php" => true,
774 "modifiercompiler.count_characters.php" => true,
775 "modifiercompiler.count_paragraphs.php" => true,
776 "modifiercompiler.count_sentences.php" => true,
777 "modifiercompiler.count_words.php" => true,
778 "modifiercompiler.default.php" => true,
779 "modifiercompiler.escape.php" => true,
780 "modifiercompiler.from_charset.php" => true,
781 "modifiercompiler.indent.php" => true,
782 "modifiercompiler.lower.php" => true,
783 "modifiercompiler.noprint.php" => true,
784 "modifiercompiler.string_format.php" => true,
785 "modifiercompiler.strip.php" => true,
786 "modifiercompiler.strip_tags.php" => true,
787 "modifiercompiler.to_charset.php" => true,
788 "modifiercompiler.unescape.php" => true,
789 "modifiercompiler.upper.php" => true,
790 "modifiercompiler.wordwrap.php" => true,
791 "outputfilter.trimwhitespace.php" => true,
792 "shared.escape_special_chars.php" => true,
793 "shared.literal_compiler_param.php" => true,
794 "shared.make_timestamp.php" => true,
795 "shared.mb_str_replace.php" => true,
796 "shared.mb_unicode.php" => true,
797 "shared.mb_wordwrap.php" => true,
798 "variablefilter.htmlspecialchars.php" => true,
800 $iterator = new DirectoryIterator($source);
801 foreach ($iterator as $file) {
802 if (!$file->isDot()) {
803 $filename = $file->getFilename();
804 if (isset($expected[$filename])) {
805 unset($expected[$filename]);
811 $message = "FAILED: files missing from libs/plugins: " . join(', ', array_keys($expected));
812 if ($errors === null) {
813 echo $message . ".\n";
815 $errors['plugins'] = $message;
817 } elseif ($errors === null) {
822 $message = "FAILED: " . SMARTY_PLUGINS_DIR . ' is not a directory';
823 if ($errors === null) {
824 echo $message . ".\n";
826 $errors['plugins_dir_constant'] = $message;
830 if ($errors === null) {
831 echo "Tests complete.\n";