to avoid a little warning
[old-projects.git] / depview / file.php
index 84d6e14..02e6a76 100644 (file)
@@ -1,37 +1,76 @@
 <?php
 require("config.inc.php");
 require("header.inc.php");
+
+/* validate parameters */
+if (!isset($_REQUEST['id'])) {
+  echo "no file specified";
+  include("footer.inc.php");
+  exit;
+}
+$id = $_REQUEST['id'];
 $res = mysql_query("select path from file where id=$id");
 if (!list($page)=mysql_fetch_row($res)) {
-  echo "page not found";
+  echo "file $id not found";
   include("footer.inc.php");
   exit;
 }
+$d = isset($_REQUEST['d']) ? $_REQUEST['d'] : 0;
 ?>
 
 <h1>Dependencies for <?php echo $page; ?></h1>
+<p>
+  Current context is highlighted in yellow.<br />
+  <a href="list.php">back to file list</a>
+</p>
 
+<h2>files that <?php echo $page; ?> depends on</h2>
 <table>
 <tr>
+  <th>relation</th>
   <th>context</th>
   <th>file</th>
 </tr>
-
 <?php
-$res = mysql_query("select dep.id,dep.dir,dep.dep,file.path from dep left join file on dep.dep=file.id where page=$id order by dep.dir");
-while (list($id,$dir,$dep,$path)=mysql_fetch_row($res)) {
+$res = mysql_query("select dep.dir,dep.type,dep.dep,file.path from dep left join file on dep.dep=file.id where page=$id order by dep.dir");
+while (list($dir,$type,$cid,$cpath)=mysql_fetch_row($res)) {
 $res2 = mysql_query("select path from dir where id=$dir");
 list($dirname)=mysql_fetch_row($res2);
 ?>
+<tr <?php if ($d==$dir) echo 'class="current"'; ?>>
+  <td><?php echo $type; ?></td>
+  <td><?php echo $dirname; ?></td>
+  <td><a href="file.php?id=<?php echo $cid; ?>&d=<?php echo $dir; ?>"><?php echo $cpath; ?></a></td>
+</tr>
+<?php
+}
+?>
+</table>
+
+<h2>files that depend on <?php echo $page; ?></h2>
+<table>
 <tr>
+  <th>relation</th>
+  <th>context</th>
+  <th>file</th>
+</tr>
+<?php
+$res = mysql_query("select dep.dir,dep.type,dep.page,file.path from dep left join file on dep.page=file.id where dep=$id order by dep.dir");
+while (list($dir,$type,$pid,$ppath)=mysql_fetch_row($res)) {
+$res2 = mysql_query("select path from dir where id=$dir");
+list($dirname)=mysql_fetch_row($res2);
+?>
+<tr <?php if ($d==$dir) echo 'class="current"'; ?>>
+  <td><?php echo $type; ?></td>
   <td><?php echo $dirname; ?></td>
-  <td><a href="file.php?id=<?php echo $dep; ?>"><?php echo $path; ?></a></td>
+  <td><a href="file.php?id=<?php echo $pid; ?>&d=<?php echo $dir; ?>"><?php echo $ppath; ?></a></td>
 </tr>
 <?php
 }
 ?>
 </table>
 
+
 <?php
 require("footer.inc.php");
 ?>