Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

smarty_internal_testinstall.php 33KB

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