ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Html.php
Go to the documentation of this file.
1<?php
3
4class Html extends Exporter
5{
9 protected static function toStringDo($languages)
10 {
11 return self::buildTable($languages, false);
12 }
13 protected static function h($str)
14 {
15 return htmlspecialchars($str, ENT_COMPAT, 'UTF-8');
16 }
17 protected static function buildTable($languages, $forDocs)
18 {
19 $prefix = $forDocs ? ' ' : '';
20 $lines = array();
21 $lines[] = $prefix.'<table'.($forDocs ? ' class="table table-bordered table-condensed table-striped"' : '').'>';
22 $lines[] = $prefix.' <thead>';
23 $lines[] = $prefix.' <tr>';
24 $lines[] = $prefix.' <th>Language code</th>';
25 $lines[] = $prefix.' <th>Language name</th>';
26 $lines[] = $prefix.' <th># plurals</th>';
27 $lines[] = $prefix.' <th>Formula</th>';
28 $lines[] = $prefix.' <th>Plurals</th>';
29 $lines[] = $prefix.' </tr>';
30 $lines[] = $prefix.' </thead>';
31 $lines[] = $prefix.' <tbody>';
32 foreach ($languages as $lc) {
33 $lines[] = $prefix.' <tr>';
34 $lines[] = $prefix.' <td>'.$lc->id.'</td>';
35 $name = self::h($lc->name);
36 if (isset($lc->supersededBy)) {
37 $name .= '<br /><small><span>Superseded by</span> '.$lc->supersededBy.'</small>';
38 }
39 $lines[] = $prefix.' <td>'.$name.'</td>';
40 $lines[] = $prefix.' <td>'.count($lc->categories).'</td>';
41 $lines[] = $prefix.' <td>'.self::h($lc->formula).'</td>';
42 $cases = array();
43 foreach ($lc->categories as $c) {
44 $cases[] = '<li><span>'.$c->id.'</span><code>'.self::h($c->examples).'</code></li>';
45 }
46 $lines[] = $prefix.' <td><ol'.($forDocs ? ' class="cases"' : '').' start="0">'.implode('', $cases).'</ol></td>';
47 $lines[] = $prefix.' </tr>';
48 }
49 $lines[] = $prefix.' </tbody>';
50 $lines[] = $prefix.'</table>';
51
52 return implode("\n", $lines);
53 }
57 public static function getDescription()
58 {
59 return 'Build a HTML table';
60 }
61}
An exception for terminatinating execution or to throw for unit testing.
Base class for all the exporters.
Definition: Exporter.php:11
static buildTable($languages, $forDocs)
Definition: Html.php:17
static toStringDo($languages)
Definition: Html.php:9
$languages
Definition: cssgen2.php:34
$lc
Definition: date.php:267