Odyssey
Forms.prg
1 <?php
2 // All instances of $Cn were changed to $chome mws 1/8/2003
3 
4 $public_html = "$home_path/public_html/";
5 
6 // get http scheme and url for opening editable web pages correctly
7 $http_scheme = $SYSENV['require_encryption'] ? 'https' : 'http';
8 $http_url = "{$http_scheme}://{$_SERVER['HTTP_HOST']}";
9 
10 $dp = popen("ls -1ra ${public_html}.*.html", "r");
11 // Now dp points to all the filenames that are in the directory
12 $fileArray = array();
13 while (!feof($dp)) {
14  $filename = fgets($dp, 4096);
15  if ($filename == "") {
16  break; // last record
17  }
18  $filename = str_replace("\n", "", $filename);
19  $fp = fopen ("$filename","r");
20  if ($fp) {
21  while (!feof ($fp)) {
22  $buffer = fgets($fp, 4096);
23  if (preg_match ("/<title>(.*)<\/title>/i",$buffer,$matches)){
24  $title=$matches[1];
25  break;
26  }
27  }
28  fclose ($fp);
29  }
30  // Strip the filepath off the file and the . off the file to get the filename
31  $filename = str_replace($public_html . ".", "", $filename);
32 
33  if (trim($filename != "")) {
34  if ($title == "") {
35  $title=$filename;
36  }
37 
38  $fileArray[] = array(
39  "name" => $title,
40  "link" => "javascript:openwin('$filename')"
41  );
42  }
43 }
44 pclose($dp);
45 ?>
46 <script type="text/javascript">
47  var cu = "<?php echo $chome; ?>";
48  var host = "<?php echo $http_url; ?>";
49 
50  var gridData = <?php echo HCU_JsonEncode($fileArray); ?>;
51  var gridFiles = null;
52 
53  $(document).ready(function(e) {
54  gridFiles = $("#gridFiles").kendoGrid({
55  dataSource: {
56  data: gridData
57  },
58  noRecords: {
59  template: "No editable web pages were found."
60  },
61  columns: [{
62  field: "name",
63  title: "Available Web Pages"
64  }],
65  rowTemplate: kendo.template($("#gridRowTamplate").html())
66  }).data("kendoGrid");
67  });
68 
69  function openwin(file) {
70  // get date
71  var date = new Date();
72  var link = host + "/fi/" + cu + "/." + file + "?t=" + date.getTime();
73 
74  var wnd = window.open(link, "FORM", "scrollbars=yes, resizable=yes");
75  }
76 </script>
77 
78 <script type="text/x-kendo-tmpl" id="gridRowTamplate">
79  <tr data-uid="#: uid #">
80  <td>
81  <span class="fa fa-file"></span>&emsp;
82  <a href="#: data.link #">#: data.name #</a>
83  </td>
84  </tr>
85 </script>
86 
87 <style type="text/css"></style>
88 
89 <div class="container-fluid">
90  <h2>Editable Web Pages</h2>
91  <div id="gridFiles"></div>
92 </div>