blob: d7e6c513992e18a9210ae32ab26b33946fa35c09 (
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
|
<?php
/**
* Take a (article's) filename and return its
* teaser. It has the articles folder hardcoded
*/
function get_title($name){
$content = file_get_contents("articles/$name.html");
$doc = new DOMDocument();
$doc->loadHTML($content);
$finder = new DOMXPath($doc);
$query_set = $finder->query("//h1[@class='chapter' or @class='unnumbered']");
if (1 != $query_set->length)
return "No title for this item";
// assuming all the articles are well-formed..
return $query_set->item(0)->nodeValue;
}
/**
* Take a (article's) filename and return its
* DOM. It has the articles folder hardcoded
*/
function get_article($name){
$raw_content = file_get_contents("articles/$name.html");
return $raw_content;
}
/**
* Fetch the page $page and return its
* DOM.
*/
function get_page($page){
$content = file_get_contents($page);
$doc = new DOMDocument();
$doc->loadHTML($content);
return $doc;
}
?>
|