-function shownews($input, $limit = 1000)
-{
- if (!is_array($input)) $input = glob("$input/*.html");
- print '<ul class="left">'."\n\n";
- foreach (array_reverse($input) as $filename) {
- $url = preg_replace('/\.html$/', '', $filename);
- print '<li>';
- if ($image = shownewsimage($url)) {
- printf('<img src="%s" class="left" />', "/thumb/300x/".$image);
+ function title()
+ {
+ return preg_replace('{<h2>(.*)</h2>\s*}', '\1', fgets($this->file));
+ }
+
+ function safetitle()
+ {
+ return trim(strip_tags($this->title));
+ }
+
+ function name()
+ {
+ return $this->safetitle ?: $this->link;
+ }
+
+ function last()
+ {
+ return filemtime($this->page);
+ }
+
+ function lastiso()
+ {
+ return date(DATE_ATOM, $this->last);
+ }
+
+ function dateparts()
+ {
+ preg_match('< / (\d{4}) [/-] (\d{2}) (?:- (\d{2}) )? - >x', $this->page, $ymd);
+ array_shift($ymd);
+ return $ymd;
+ }
+
+ function dateiso()
+ {
+ return implode('-', $this->dateparts()) . 'T12:00:00+02:00';
+ }
+
+ function date()
+ {
+ return showdate($this->dateparts);
+ }
+
+ function body()
+ {
+ $this->title;
+ $rest = fread($this->file, filesize($this->page));
+ if ( preg_match('{
+ \n (?: < (?: p | figure [^>]* ) >\s* )+ (<img\ [^>]*>) | \n <hr\ />
+ }x', $rest, $img, PREG_OFFSET_CAPTURE) ) {
+ if (isset($img[1])) {
+ $this->img = $img[1][0];
+ }
+ return substr($rest, 0, $img[0][1]);