選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

smarty_internal_testinstall.php 35KB

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