-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclassIndex.php
More file actions
59 lines (53 loc) · 1.46 KB
/
Copy pathclassIndex.php
File metadata and controls
59 lines (53 loc) · 1.46 KB
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
<?php
class ClassIndex {
protected $root = '';
protected $list = array(
array( // dia1
'title'=> "Título del primer apartado",
'links'=> array(
'fichero.md'=> "Texto del primer enlace",
'fichero.php'=> "Texto del segundo enlace",
)
),
);
/*
<li>
<p><a href="dia01">Día 1</a> — Cliente/Servidor. XAMPP. Introducción al PHP.</p>
<ul><?php printLinks(1) ?></ul>
</li>
*/
public function printList() {
foreach($this->list as $index=>$item) {
$day = $index+1;
$folder = 'dia'.self::two($day);
$title = $item['title'];
echo "<li>";
echo "<p class=\"plus\">";
echo "<a href=\"$folder.7z\" title=\"Descargar 7-zip\">Día $day</a>";
echo " <span><span>$title</span></span>";
//echo " [<a href=\"$folder.7z\"><sub>7</sub>z</a>]";
echo "</p>";
$this->printLinks($day, $item['links']);
echo "</li>";
}
}
private function printLinks($day, $links) {
$folder = 'dia'.self::two($day);
echo "<ul>";
foreach ($links as $link=>$text) {
if (self::endsWith($link, '.md'))
$href = "../markdown.php?md={$this->root}/$folder/$link";
else $href="$folder/$link";
echo "<li><a href=\"$href\" target=\"dia\">$link</a> — $text</li>";
}
echo "</ul>";
}
private static function two($number) {
return ($number<10?'0':'').$number;
}
private static function endsWith($haystack, $needle) {
$length = strlen($needle);
if ($length == 0) return true;
else return (substr($haystack, -$length) === $needle);
}
}