4 'januari', 'februari', 'maart', 'april', 'mei', 'juni',
5 'juli', 'augustus', 'september', 'oktober', 'november', 'december',
8 function showdate($parts)
11 return implode(' ', array_filter([
12 intval(@$parts[3]), $parts[2] > 0 ? $monthname[intval($parts[2])] : '', $parts[1],
13 count($parts) > 6 ? "$parts[4]:$parts[5]" : '',
19 function __construct($path)
22 $this->link = preg_replace('{(?:/index)?\.html$}', '', $path);
27 return $this->$col = $this->$col(); # run method and cache
32 if (!file_exists($this->page)) return;
33 return fopen($this->page, 'r');
38 return preg_replace('{<h2>(.*)</h2>\s*}', '\1', fgets($this->file));
43 return trim(strip_tags($this->title));
48 return $this->safetitle ?: $this->link;
53 return filemtime($this->page);
58 return date(DATE_ATOM, $this->last);
63 preg_match('< / (\d{4}) [/-] (\d{2}) (?:- (\d{2}) )? - >x', $this->page, $ymd);
69 return implode('-', $this->dateparts());
74 return showdate($this->dateparts);
80 $rest = fread($this->file, filesize($this->page));
81 if ( preg_match('{\n<p>(<img [^>]*>)</p>}', $rest, $img, PREG_OFFSET_CAPTURE) ) {
82 $this->img = $img[1][0];
83 return substr($rest, 0, $img[0][1]);
97 if ( preg_match('/\bsrc="([^"]*)"/', $this->img, $src) ) {
102 function thumb($size = '300x')
104 if (!$this->image or $this->image[0] !== '/') return;
105 return preg_replace('{^(?:/thumb/[^/]*)?}', "thumb/$size", $this->image);
109 function shownews($input, $limit = 1000)
111 if (!is_array($input)) $input = glob("$input/*.html");
112 foreach (array_reverse($input) as $filename) {
113 $article = new ArchiveArticle($filename);
114 print '<article class="left">';
115 if ($article->thumb) {
116 $img = preg_replace('{(?<= \b src="/) [^"]* }x', $article->thumb, $article->img);
117 $img = preg_replace('{(?= />$)}', ' class="left"', $img);
122 '<h3><a href="/%s">%s <small class="date">%s</small></a></h3>',
123 $article->link, $article->title, $article->date
125 print $article->body;
127 print "</article>\n\n";
129 if (--$limit <= 0) break;
133 function printtoc($input, $class = FALSE)
135 if (!is_array($input)) $input = glob("$input/*.html");
137 if ($class) printf(' class="%s"', $class);
139 foreach (array_reverse($input) as $page) {
140 $article = new ArchiveArticle($page);
141 $html = $article->safetitle;
142 $dateparts = $article->dateparts;
144 $dateparts[1] = NULL; # omit year
146 $html .= sprintf(' <small class="date">%s</small>', showdate($dateparts));
147 if ($class == 'gallery' and $article->img) {
148 $html = "<div>$html</div>";
149 $html = sprintf('<img src="%s" />', $article->thumb(200)) . $html;
151 $html = sprintf('<a href="/%s">%s</a>', $article->link, $html);
152 print "<li><article>$html</article></li>\n";