PageRenderTime 33ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/include/Savant/Savant2/tests/3_fetch.php

https://github.com/radicaldesigns/amp
PHP | 71 lines | 42 code | 18 blank | 11 comment | 0 complexity | 3f287628b7aa45873819704c7eb8d9e7 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, BSD-3-Clause, LGPL-2.0, CC-BY-SA-3.0, AGPL-1.0
  1. <?php
  2. /**
  3. *
  4. * Tests fetch() issues
  5. *
  6. * @version $Id: 3_fetch.php,v 1.1 2004/10/04 01:52:24 pmjones Exp $
  7. *
  8. */
  9. error_reporting(E_ALL);
  10. require_once 'Savant2.php';
  11. $conf = array(
  12. 'template_path' => 'templates',
  13. 'resource_path' => 'resources'
  14. );
  15. $savant = new Savant2($conf);
  16. $array = array(
  17. 'key0' => 'val0',
  18. 'key1' => 'val1',
  19. 'key2' => 'val2',
  20. );
  21. $var1 = 'variable1';
  22. $var2 = 'variable2';
  23. $var3 = 'variable3';
  24. $ref1 = 'reference1';
  25. $ref2 = 'reference2';
  26. $ref3 = 'reference3';
  27. // assign vars
  28. $savant->assign($var1, $var1);
  29. $savant->assign($var2, $var2);
  30. $savant->assign($var3, $var3);
  31. // assigns $array to a variable $set
  32. $savant->assign('set', $array);
  33. // assigns the keys and values of array
  34. $savant->assign($array);
  35. // assign references
  36. $savant->assignRef($ref1, $ref1);
  37. $savant->assignRef($ref2, $ref2);
  38. $savant->assignRef($ref3, $ref3);
  39. echo "<h1>Fetch non-existent template</h1>";
  40. $result = $savant->fetch('no_such_template.tpl.php');
  41. echo "result: <pre>";
  42. print_r($result);
  43. echo "</pre>";
  44. echo "<h1>Storage</h1>";
  45. echo "properties: <pre>";
  46. print_r(get_object_vars($savant));
  47. echo "</pre>";
  48. echo "<h1>Fetch existing template</h1>";
  49. $result = $savant->fetch('test.tpl.php');
  50. echo "fetched this code: <pre>";
  51. print_r(htmlentities($result));
  52. echo "</pre>";
  53. ?>