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));
82 \n (?: < (?: p | figure [^>]* ) >\s* )+ (<img\ [^>]*>) | \n <hr\ />
83 }x', $rest, $img, PREG_OFFSET_CAPTURE) ) {
85 $this->img = $img[1][0];
87 return substr($rest, 0, $img[0][1]);
94 if (preg_match('{<p>(.*?)</p>}s', $this->body, $bodyp)) {
108 if ( preg_match('/\bsrc="([^"]*)"/', $this->img, $src) ) {
113 function thumb($size = '300x')
115 if (!$this->image or $this->image[0] !== '/') return;
117 ['{^(?:/thumb/[^/]*)?}', '/\.groot(?=\.\w+$)/'], ["thumb/$size", ''],
123 function shownews($input, $limit = 1000)
125 if (!is_array($input)) $input = glob("$input/*.html");
126 foreach (array_reverse($input) as $filename) {
127 $article = new ArchiveArticle($filename);
128 print '<article class="left">';
129 if ($article->thumb) {
130 $imgattr = ' class="left"';
131 if (preg_match('{ (\s alt="[^"]+") }x', $article->img, $img)) {
132 $imgattr .= $img[0]; # preserve alt value
134 printf('<img src="/%s"%s />', $article->thumb, $imgattr);
138 '<h3><a href="/%s">%s <small class="date">%s</small></a></h3>',
139 $article->link, $article->title, $article->date
141 print $article->body;
143 print "</article>\n\n";
145 if (--$limit <= 0) break;
149 function printtoc($input, $class = FALSE)
151 if (!is_array($input)) $input = glob("$input/*.html");
153 if ($class) printf(' class="%s"', $class);
155 foreach (array_reverse($input) as $page) {
156 $article = new ArchiveArticle($page);
157 $html = $article->safetitle;
158 $dateparts = $article->dateparts;
160 $dateparts[1] = NULL; # omit year
162 $html .= sprintf(' <small class="date">%s</small>', showdate($dateparts));
163 if ($class == 'gallery' and $article->img) {
164 $html = "<div>$html</div>";
165 $html = sprintf('<img src="%s" />', $article->thumb(200)) . $html;
167 $html = sprintf('<a href="/%s">%s</a>', $article->link, $html);
168 print "<li><article>$html</article></li>\n";