1: <?php
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: class Smarty_Internal_Utility
37: {
38: 39: 40:
41: final private function __construct()
42: {
43:
44: }
45:
46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56:
57: public static function compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
58: {
59:
60: if (function_exists('set_time_limit')) {
61: @set_time_limit($time_limit);
62: }
63: $smarty->force_compile = $force_compile;
64: $_count = 0;
65: $_error_count = 0;
66:
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) {
73: continue;
74: }
75: if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
76: continue;
77: }
78: if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) {
79: $_template_file = $_file;
80: } else {
81: $_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
82: }
83: echo '<br>', $_dir, '---', $_template_file;
84: flush();
85: $_start_time = microtime(true);
86: try {
87: $_tpl = $smarty->createTemplate($_template_file, null, null, null, false);
88: if ($_tpl->mustCompile()) {
89: $_tpl->compileTemplateSource();
90: $_count ++;
91: echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
92: flush();
93: } else {
94: echo ' is up to date';
95: flush();
96: }
97: }
98: catch (Exception $e) {
99: echo 'Error: ', $e->getMessage(), "<br><br>";
100: $_error_count ++;
101: }
102:
103: $smarty->template_objects = array();
104: $_tpl->smarty->template_objects = array();
105: $_tpl = null;
106: if ($max_errors !== null && $_error_count == $max_errors) {
107: echo '<br><br>too many errors';
108: exit();
109: }
110: }
111: }
112:
113: return $_count;
114: }
115:
116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126:
127: public static function compileAllConfig($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
128: {
129:
130: if (function_exists('set_time_limit')) {
131: @set_time_limit($time_limit);
132: }
133: $smarty->force_compile = $force_compile;
134: $_count = 0;
135: $_error_count = 0;
136:
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) {
143: continue;
144: }
145: if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
146: continue;
147: }
148: if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) {
149: $_config_file = $_file;
150: } else {
151: $_config_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
152: }
153: echo '<br>', $_dir, '---', $_config_file;
154: flush();
155: $_start_time = microtime(true);
156: try {
157: $_config = new Smarty_Internal_Config($_config_file, $smarty);
158: if ($_config->mustCompile()) {
159: $_config->compileConfigSource();
160: $_count ++;
161: echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
162: flush();
163: } else {
164: echo ' is up to date';
165: flush();
166: }
167: }
168: catch (Exception $e) {
169: echo 'Error: ', $e->getMessage(), "<br><br>";
170: $_error_count ++;
171: }
172: if ($max_errors !== null && $_error_count == $max_errors) {
173: echo '<br><br>too many errors';
174: exit();
175: }
176: }
177: }
178:
179: return $_count;
180: }
181:
182: 183: 184: 185: 186: 187: 188: 189: 190: 191:
192: public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty)
193: {
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;
202:
203:
204: $tpl->source;
205: if ($smarty->allow_ambiguous_resources) {
206: $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
207: } else {
208: $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
209: }
210: if (isset($_templateId[150])) {
211: $_templateId = sha1($_templateId);
212: }
213: unset($smarty->template_objects[$_templateId]);
214:
215: if ($tpl->source->exists) {
216: $_resource_part_1 = basename(str_replace('^', '/', $tpl->compiled->filepath));
217: $_resource_part_1_length = strlen($_resource_part_1);
218: } else {
219: return 0;
220: }
221:
222: $_resource_part_2 = str_replace('.php', '.cache.php', $_resource_part_1);
223: $_resource_part_2_length = strlen($_resource_part_2);
224: }
225: $_dir = $_compile_dir;
226: if ($smarty->use_sub_dirs && isset($_compile_id)) {
227: $_dir .= $_compile_id . $_dir_sep;
228: }
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);
232: }
233: $_count = 0;
234: try {
235: $_compileDirs = new RecursiveDirectoryIterator($_dir);
236:
237: }
238: catch (Exception $e) {
239: return 0;
240: }
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) {
244: continue;
245: }
246:
247: $_filepath = str_replace('\\', '/', (string) $_file);
248:
249: if ($_file->isDir()) {
250: if (!$_compile->isDot()) {
251:
252: @rmdir($_file->getPathname());
253: }
254: } else {
255: $unlink = false;
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))
262: ) {
263: if (isset($exp_time)) {
264: if (time() - @filemtime($_filepath) >= $exp_time) {
265: $unlink = true;
266: }
267: } else {
268: $unlink = true;
269: }
270: }
271:
272: if ($unlink && @unlink($_filepath)) {
273: $_count ++;
274: }
275: }
276: }
277:
278: Smarty_Resource::$sources = array();
279: Smarty_Resource::$compileds = array();
280:
281: return $_count;
282: }
283:
284: 285: 286: 287: 288: 289: 290: 291: 292:
293: public static function getTags(Smarty_Internal_Template $template)
294: {
295: $template->smarty->get_used_tags = true;
296: $template->compileTemplateSource();
297:
298: return $template->used_tags;
299: }
300:
301: 302: 303: 304: 305: 306: 307: 308: 309:
310: public static function testInstall(Smarty $smarty, &$errors = null)
311: {
312: $status = true;
313:
314: if ($errors === null) {
315: echo "<PRE>\n";
316: echo "Smarty Installation test...\n";
317: echo "Testing template directory...\n";
318: }
319:
320: $_stream_resolve_include_path = function_exists('stream_resolve_include_path');
321:
322:
323: foreach ($smarty->getTemplateDir() as $template_dir) {
324: $_template_dir = $template_dir;
325: $template_dir = realpath($template_dir);
326:
327: if (!$template_dir) {
328: if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) {
329:
330: if ($_stream_resolve_include_path) {
331: $template_dir = stream_resolve_include_path($_template_dir);
332: } else {
333: $template_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_template_dir);
334: }
335:
336: if ($template_dir !== false) {
337: if ($errors === null) {
338: echo "$template_dir is OK.\n";
339: }
340:
341: continue;
342: } else {
343: $status = false;
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";
347: } else {
348: $errors['template_dir'] = $message;
349: }
350:
351: continue;
352: }
353: } else {
354: $status = false;
355: $message = "FAILED: $_template_dir does not exist";
356: if ($errors === null) {
357: echo $message . ".\n";
358: } else {
359: $errors['template_dir'] = $message;
360: }
361:
362: continue;
363: }
364: }
365:
366: if (!is_dir($template_dir)) {
367: $status = false;
368: $message = "FAILED: $template_dir is not a directory";
369: if ($errors === null) {
370: echo $message . ".\n";
371: } else {
372: $errors['template_dir'] = $message;
373: }
374: } elseif (!is_readable($template_dir)) {
375: $status = false;
376: $message = "FAILED: $template_dir is not readable";
377: if ($errors === null) {
378: echo $message . ".\n";
379: } else {
380: $errors['template_dir'] = $message;
381: }
382: } else {
383: if ($errors === null) {
384: echo "$template_dir is OK.\n";
385: }
386: }
387: }
388:
389: if ($errors === null) {
390: echo "Testing compile directory...\n";
391: }
392:
393:
394: $__compile_dir = $smarty->getCompileDir();
395: $_compile_dir = realpath($__compile_dir);
396: if (!$_compile_dir) {
397: $status = false;
398: $message = "FAILED: {$__compile_dir} does not exist";
399: if ($errors === null) {
400: echo $message . ".\n";
401: } else {
402: $errors['compile_dir'] = $message;
403: }
404: } elseif (!is_dir($_compile_dir)) {
405: $status = false;
406: $message = "FAILED: {$_compile_dir} is not a directory";
407: if ($errors === null) {
408: echo $message . ".\n";
409: } else {
410: $errors['compile_dir'] = $message;
411: }
412: } elseif (!is_readable($_compile_dir)) {
413: $status = false;
414: $message = "FAILED: {$_compile_dir} is not readable";
415: if ($errors === null) {
416: echo $message . ".\n";
417: } else {
418: $errors['compile_dir'] = $message;
419: }
420: } elseif (!is_writable($_compile_dir)) {
421: $status = false;
422: $message = "FAILED: {$_compile_dir} is not writable";
423: if ($errors === null) {
424: echo $message . ".\n";
425: } else {
426: $errors['compile_dir'] = $message;
427: }
428: } else {
429: if ($errors === null) {
430: echo "{$_compile_dir} is OK.\n";
431: }
432: }
433:
434: if ($errors === null) {
435: echo "Testing plugins directory...\n";
436: }
437:
438:
439:
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:
446: if (!$plugin_dir) {
447: if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
448:
449: if ($_stream_resolve_include_path) {
450: $plugin_dir = stream_resolve_include_path($_plugin_dir);
451: } else {
452: $plugin_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_plugin_dir);
453: }
454:
455: if ($plugin_dir !== false) {
456: if ($errors === null) {
457: echo "$plugin_dir is OK.\n";
458: }
459:
460: continue;
461: } else {
462: $status = false;
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";
466: } else {
467: $errors['plugins_dir'] = $message;
468: }
469:
470: continue;
471: }
472: } else {
473: $status = false;
474: $message = "FAILED: $_plugin_dir does not exist";
475: if ($errors === null) {
476: echo $message . ".\n";
477: } else {
478: $errors['plugins_dir'] = $message;
479: }
480:
481: continue;
482: }
483: }
484:
485: if (!is_dir($plugin_dir)) {
486: $status = false;
487: $message = "FAILED: $plugin_dir is not a directory";
488: if ($errors === null) {
489: echo $message . ".\n";
490: } else {
491: $errors['plugins_dir'] = $message;
492: }
493: } elseif (!is_readable($plugin_dir)) {
494: $status = false;
495: $message = "FAILED: $plugin_dir is not readable";
496: if ($errors === null) {
497: echo $message . ".\n";
498: } else {
499: $errors['plugins_dir'] = $message;
500: }
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";
505: }
506: } else {
507: if ($errors === null) {
508: echo "$plugin_dir is OK.\n";
509: }
510: }
511: }
512: if (!$_core_plugins_available) {
513: $status = false;
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;
519: }
520: }
521:
522: if ($errors === null) {
523: echo "Testing cache directory...\n";
524: }
525:
526:
527: $__cache_dir = $smarty->getCacheDir();
528: $_cache_dir = realpath($__cache_dir);
529: if (!$_cache_dir) {
530: $status = false;
531: $message = "FAILED: {$__cache_dir} does not exist";
532: if ($errors === null) {
533: echo $message . ".\n";
534: } else {
535: $errors['cache_dir'] = $message;
536: }
537: } elseif (!is_dir($_cache_dir)) {
538: $status = false;
539: $message = "FAILED: {$_cache_dir} is not a directory";
540: if ($errors === null) {
541: echo $message . ".\n";
542: } else {
543: $errors['cache_dir'] = $message;
544: }
545: } elseif (!is_readable($_cache_dir)) {
546: $status = false;
547: $message = "FAILED: {$_cache_dir} is not readable";
548: if ($errors === null) {
549: echo $message . ".\n";
550: } else {
551: $errors['cache_dir'] = $message;
552: }
553: } elseif (!is_writable($_cache_dir)) {
554: $status = false;
555: $message = "FAILED: {$_cache_dir} is not writable";
556: if ($errors === null) {
557: echo $message . ".\n";
558: } else {
559: $errors['cache_dir'] = $message;
560: }
561: } else {
562: if ($errors === null) {
563: echo "{$_cache_dir} is OK.\n";
564: }
565: }
566:
567: if ($errors === null) {
568: echo "Testing configs directory...\n";
569: }
570:
571:
572: foreach ($smarty->getConfigDir() as $config_dir) {
573: $_config_dir = $config_dir;
574: $config_dir = realpath($config_dir);
575:
576: if (!$config_dir) {
577: if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) {
578:
579: if ($_stream_resolve_include_path) {
580: $config_dir = stream_resolve_include_path($_config_dir);
581: } else {
582: $config_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_config_dir);
583: }
584:
585: if ($config_dir !== false) {
586: if ($errors === null) {
587: echo "$config_dir is OK.\n";
588: }
589:
590: continue;
591: } else {
592: $status = false;
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";
596: } else {
597: $errors['config_dir'] = $message;
598: }
599:
600: continue;
601: }
602: } else {
603: $status = false;
604: $message = "FAILED: $_config_dir does not exist";
605: if ($errors === null) {
606: echo $message . ".\n";
607: } else {
608: $errors['config_dir'] = $message;
609: }
610:
611: continue;
612: }
613: }
614:
615: if (!is_dir($config_dir)) {
616: $status = false;
617: $message = "FAILED: $config_dir is not a directory";
618: if ($errors === null) {
619: echo $message . ".\n";
620: } else {
621: $errors['config_dir'] = $message;
622: }
623: } elseif (!is_readable($config_dir)) {
624: $status = false;
625: $message = "FAILED: $config_dir is not readable";
626: if ($errors === null) {
627: echo $message . ".\n";
628: } else {
629: $errors['config_dir'] = $message;
630: }
631: } else {
632: if ($errors === null) {
633: echo "$config_dir is OK.\n";
634: }
635: }
636: }
637:
638: if ($errors === null) {
639: echo "Testing sysplugin files...\n";
640: }
641:
642: $source = SMARTY_SYSPLUGINS_DIR;
643: if (is_dir($source)) {
644: $expected = array(
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,
714: );
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]);
721: }
722: }
723: }
724: if ($expected) {
725: $status = false;
726: $message = "FAILED: files missing from libs/sysplugins: " . join(', ', array_keys($expected));
727: if ($errors === null) {
728: echo $message . ".\n";
729: } else {
730: $errors['sysplugins'] = $message;
731: }
732: } elseif ($errors === null) {
733: echo "... OK\n";
734: }
735: } else {
736: $status = false;
737: $message = "FAILED: " . SMARTY_SYSPLUGINS_DIR . ' is not a directory';
738: if ($errors === null) {
739: echo $message . ".\n";
740: } else {
741: $errors['sysplugins_dir_constant'] = $message;
742: }
743: }
744:
745: if ($errors === null) {
746: echo "Testing plugin files...\n";
747: }
748:
749: $source = SMARTY_PLUGINS_DIR;
750: if (is_dir($source)) {
751: $expected = array(
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,
799: );
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]);
806: }
807: }
808: }
809: if ($expected) {
810: $status = false;
811: $message = "FAILED: files missing from libs/plugins: " . join(', ', array_keys($expected));
812: if ($errors === null) {
813: echo $message . ".\n";
814: } else {
815: $errors['plugins'] = $message;
816: }
817: } elseif ($errors === null) {
818: echo "... OK\n";
819: }
820: } else {
821: $status = false;
822: $message = "FAILED: " . SMARTY_PLUGINS_DIR . ' is not a directory';
823: if ($errors === null) {
824: echo $message . ".\n";
825: } else {
826: $errors['plugins_dir_constant'] = $message;
827: }
828: }
829:
830: if ($errors === null) {
831: echo "Tests complete.\n";
832: echo "</PRE>\n";
833: }
834:
835: return $status;
836: }
837: }
838: