Welcome to mirror list, hosted at ThFree Co, Russian Federation.

html_templates.php « web « cruise-control - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 83f6cc879fe09be4407ef8c9f6d55912f4f741b3 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php

function show_header($title)
{
  echo "
<html>
  <head>
    <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;charset=utf-8\">
    <title>$title</title>
  </head><body>";
} 

function show_heading($text, $size = 1)
{
  echo "
    <h$size>$text</h$size>";
}

function show_footer()
{
  echo "
  </body>
<html>";
}

function end_table()
{
  echo "
    </table>";
}

function array_to_table_row($odd = true, $data)
{
  $bgcolor = $odd ? " bgcolor=\"#ccccdd\"" : "";
  echo "
    <tr$bgcolor>";
  foreach ($data as &$item) {
    echo "
      <td style=\"padding-left:8px; padding-right:8px\">$item</td>";
  }
  echo "
    </tr>";
}

function start_table()
{
  echo '
    <table rules="cols" frame="vsides">';
}

function start_form($action, $method = "get")
{
  echo "
    <form action=\"$action\" method=\"$method\">";
}

function end_form()
{
  echo "
    </form>";
}

function show_select_box($items, $name, $selected = "", $onchange_hdl = "")
{
  $onchange = $onchange_hdl ? " onchange=\"$onchange_hdl\"" : "";
  echo "
    <select name=\"$name\"$onchange>";
  foreach ($items as &$item) {
    $item_selected = $selected == $item ? " selected=\"yes\"" : "";
    echo "
      <option value=\"$item\"$item_selected>$item</option>";
  }
  echo "
    </select>";
}

function get_href($label, $url, $new_window = false)
{
  $target = $new_window ? " target=\"_blank\"" : "";
  return "<a href=\"$url\"$target>$label</a>";
}

function warn($msg)
{
  echo "<p><font color=\"red\"><b>$msg</b></font>";
}

function get_current_url()
{
  return $_SERVER["REQUEST_URI"];
}

function set_var($url, $var, $value)
{
  $url = cut_var($url, $var);
  if ($url[strlen($url) - 1] == "?") {
    $url .= "$var=$value";
  } elseif (strpos($url, "?") !== false) {
    $url .= "&$var=$value";
  } else {
    $url .= "?$var=$value";
  }
  return $url;
}

function cut_var($url, $var)
{
  // XXX there is probably a cleaner solution for this
  return preg_replace('/&?' . $var . '=[^&]+/', '', $url);
}

?>