load.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <html>
  2. <head>
  3. <title>Tocas UI 2.3.3 min.document</title>
  4. <link rel="stylesheet" href="dist/tocas.css">
  5. <style>
  6. body{
  7. background-color:white;
  8. padding:5px;
  9. }
  10. </style>
  11. </head>
  12. <body>
  13. <br>
  14. <a href="index.php" style="padding-left:10px;">< Back to List</a>
  15. <?php
  16. /* $it = new RecursiveDirectoryIterator(realpath("."));
  17. $allowed=array("json");
  18. foreach(new RecursiveIteratorIterator($it) as $file) {
  19. if(in_array(substr($file, strrpos($file, '.') + 1),$allowed)) {
  20. $filename = basename($file);
  21. $content = json_decode(file_get_contents($file));
  22. //print_r($content);
  23. }
  24. } */
  25. function objectToArray($d) {
  26. if (is_object($d)) {
  27. // Gets the properties of the given object
  28. // with get_object_vars function
  29. $d = get_object_vars($d);
  30. }
  31. if (is_array($d)) {
  32. /*
  33. * Return array converted to object
  34. * Using __FUNCTION__ (Magic constant)
  35. * for recursive call
  36. */
  37. return array_map(__FUNCTION__, $d);
  38. }
  39. else {
  40. // Return array
  41. return $d;
  42. }
  43. }
  44. if (isset($_GET['docname']) == false || $_GET['docname'] == ""){
  45. die("ERROR. Undefined document name");
  46. }
  47. $content = json_decode(file_get_contents($_GET['docname']));
  48. $content = objectToArray($content);
  49. ?>
  50. <div class="ts segment">
  51. <div class="ts header">
  52. <?php if (isset($content['Title'])){echo $content['Title'];}?>
  53. <div class="sub header"><?php echo $content['Description'];?><br><?php
  54. if (isset($content['Outline'])){
  55. echo $content['Outline'];
  56. }?></div>
  57. </div>
  58. </div>
  59. <div class="ts segment">
  60. <?php
  61. function replaceHighLight($result){
  62. return str_replace("]]","</mark>",str_replace("[[","<mark>",$result));
  63. }
  64. function stripHighLight($result){
  65. return str_replace("}}","",str_replace("{{","",str_replace("]]","",str_replace("[[","",$result))));
  66. }
  67. function replaceDummyImage($result){
  68. $returnval = [];
  69. if (strpos($result,"!-") != 0){
  70. $data = explode("\n",$result);
  71. foreach ($data as $line){
  72. if (strpos($line,"!-") != 0){
  73. $firstpos = strpos($line,"!-");
  74. $lastpos = strripos($line,"-!");
  75. $key = substr($line,$firstpos,$lastpos - $firstpos + 2);
  76. $finishedLine = str_replace($key,"img/dummy.png",$line);
  77. array_push($returnval,$finishedLine);
  78. }else{
  79. array_push($returnval,$line);
  80. }
  81. }
  82. return implode("\n",$returnval);
  83. }else{
  84. return $result;
  85. }
  86. }
  87. foreach ($content['Definitions'] as $defines){
  88. foreach ($defines['Sections'] as $define){
  89. $title = "";
  90. if(isset($define['Title'])){$title = $define['Title'];}
  91. echo '<div class="ts header">' . $title . '
  92. <div class="inline sub header">' . $define['Description'] . '</div>
  93. </div>';
  94. echo '<div class="ts segment">' . replaceDummyImage(stripHighLight($define['HTML'])) . '</div>';
  95. //echo replaceDummyImage(stripHighLight($define['HTML']));
  96. echo '<div class="ts segment">
  97. <div class="fluid field" style="width:100%;">
  98. <textarea rows="5" style="width:100%;">'.replaceDummyImage(stripHighLight($define['HTML'])).'</textarea>
  99. </div></div>';
  100. }
  101. //print_r($defines['Sections']);
  102. echo '<div class="ts section divider"></div>';
  103. }
  104. ?>
  105. Tocas UI 2.3.3 Documentation written by <a href="https://github.com/YamiOdymel">Yami Odymel</a>, adapter to ArOZ Online System under ArOZ Online Project feat. IMUS Laboratory.
  106. <br>
  107. <a href="index.php" style="padding-left:10px;">< Back to List</a>
  108. <br><br><br>
  109. </div>
  110. </body>
  111. </html>