5 |
// show all news entries by default |
// show all news entries by default |
6 |
$max_items = -1; |
$max_items = -1; |
7 |
|
|
8 |
|
$current_tag = array(); |
9 |
|
$current_tag_body_is_empty = true; |
10 |
|
$current_link_ref = ""; |
11 |
|
|
12 |
function startElement($parser, $name, $attribs) { |
function startElement($parser, $name, $attribs) { |
13 |
global $max_items; |
global $max_items; |
14 |
|
global $current_tag; |
15 |
|
global $current_tag_body_is_empty; |
16 |
|
global $current_link_ref; |
17 |
|
|
18 |
if ($max_items == 0) return; |
if ($max_items == 0) return; |
19 |
|
|
20 |
|
array_push($current_tag, $name); |
21 |
|
|
22 |
|
$current_tag_body_is_empty = true; |
23 |
|
|
24 |
if ($name == "entry") { |
if ($name == "entry") { |
25 |
if (count($attribs) && isset($attribs["date"])) { |
if (count($attribs) && isset($attribs["date"])) { |
26 |
$d = $attribs["date"]; |
$d = $attribs["date"]; |
28 |
echo "<span class=\"news_date\">$d</span> "; |
echo "<span class=\"news_date\">$d</span> "; |
29 |
} else echo "<b>???</b> "; |
} else echo "<b>???</b> "; |
30 |
} else if ($name == "link") { |
} else if ($name == "link") { |
31 |
$addr = (isset($attribs["ref"])) ? $attribs["ref"] : ""; |
$current_link_ref = (isset($attribs["ref"])) ? $attribs["ref"] : ""; |
32 |
echo "<a href=\"$addr\">"; |
echo "<a href=\"$current_link_ref\">"; |
33 |
} else if ($name == "list") { |
} else if ($name == "list") { |
34 |
echo "<ul class=\"news\">"; |
echo "<ul class=\"news\">"; |
35 |
} else if ($name == "li") { |
} else if ($name == "li") { |
39 |
|
|
40 |
function endElement($parser, $name) { |
function endElement($parser, $name) { |
41 |
global $max_items; |
global $max_items; |
42 |
|
global $current_tag; |
43 |
|
global $current_tag_body_is_empty; |
44 |
|
global $current_link_ref; |
45 |
|
|
46 |
if ($max_items == 0) return; |
if ($max_items == 0) return; |
47 |
|
|
48 |
|
array_pop($current_tag); |
49 |
|
|
50 |
if ($name == "entry") { echo "</div>\n"; |
if ($name == "entry") { echo "</div>\n"; |
51 |
if ($max_items > 0) $max_items--; |
if ($max_items > 0) $max_items--; |
52 |
} |
} |
53 |
else if ($name == "link") echo "</a>"; |
else if ($name == "link") { |
54 |
|
if ($current_tag_body_is_empty) echo $current_link_ref; |
55 |
|
echo "</a>"; |
56 |
|
$current_link_ref = ""; // reset |
57 |
|
} |
58 |
else if ($name == "list") echo "</ul>"; |
else if ($name == "list") echo "</ul>"; |
59 |
else if ($name == "li") echo "</li>"; |
else if ($name == "li") echo "</li>"; |
60 |
} |
} |
61 |
|
|
62 |
function characterData($parser, $data) { |
function characterData($parser, $data) { |
63 |
global $max_items; |
global $max_items; |
64 |
|
global $current_tag; |
65 |
|
global $current_tag_body_is_empty; |
66 |
|
|
67 |
|
$current_tag_body_is_empty = false; |
68 |
|
|
69 |
if ($max_items == 0) return; |
if ($max_items == 0) return; |
70 |
|
|
71 |
echo $data; |
echo $data; |