summaryrefslogtreecommitdiff
path: root/buildmaster/todos.php
blob: 3528def31c4e7bb1677ccad0f1d3cbb801904ba4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
require_once "../init.php";

include BASE . "/lib/helper.php";
include BASE . "/lib/mysql.php";

$result = mysql_run_query(
  "SELECT DISTINCT " .
  "`todos`.`id`," .
  "`todos`.`file`," .
  "`todos`.`line`," .
  "`todos`.`description` " .
  "FROM `todos`;"
);

if (array_key_exists("graph", $_GET)) {

  if ($result -> num_rows > 0) {

    while ($row = $result->fetch_assoc())
      $knot_rows[$row["id"]] =
        $row["file"]. " (line ".$row["line"].") #".$row["id"].":\\n".
        str_replace("\"","\\\"",$row["description"]);

    $knots="";
    foreach ($knot_rows as $knot)
      $knots=$knots . "\"" . $knot . "\";\n";

  }

  $result = mysql_run_query(
    "SELECT DISTINCT " .
    "`todo_links`.`dependent`," .
    "`todo_links`.`depending_on` " .
    "FROM `todo_links`;"
  );

  if ($result -> num_rows > 0) {
    $count = 0;
    while ($row = $result->fetch_assoc()) {
      $link_rows[$count]["dependent"] =
        $knot_rows[$row["dependent"]];
      $link_rows[$count]["depending_on"] =
        $knot_rows[$row["depending_on"]];
      $count++;
    }

    $edges="";
    foreach ($link_rows as $link)
      $edges=$edges . "\"" . $link["depending_on"] . "\" -> \"" . $link["dependent"] . "\";\n";
  }

  header ("Content-type: image/png");
  passthru(
    "echo \"" . base64_encode(
      "digraph dependencies {\n" .
      "rankdir=LR;\n" .
      "fontname=dejavu;\n" .
      $knots .
      $edges .
      "}\n"
    ) . "\" | " .
    "base64 -d | " .
    "timeout 30 dot -Tpng -o/dev/stdout /dev/stdin"
  );

} else { // array_key_exists("graph", $_GET)

  if ($result -> num_rows > 0) {

    print "<html>\n";
    print "<head>\n";
    print "<title>Todos in the build scripts</title>\n";
    print "</head>\n";
    print "<body>\n";
    show_warning_on_offline_slave();

    while ($row = $result->fetch_assoc()) {
      print "<a href=\"#TODO" . $row["id"] . "\" name=\"TODO" . $row["id"] ."\">TODO #" . $row["id"] . "</a>";
      print " - ";
      print "<a href=\"";
      print git_url("builder","tree","master",$row["file"],$row["line"]);
      print "\">" . $row["file"] . "(line " . $row["line"] . ")</a>";
      print ":<br>\n";
      print str_replace("\\n","<br>\n",$row["description"]);
      print "<br>\n";
      print "<br>\n";
    }

    print "</body>\n";
    print "</html>\n";

  }

}

?>