X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/eef50167aaa4e525f1eb5a462c441ce8a203c43d..f0c8ab294f56f5eccaa57e58fc2b086f3fa71736:/nieuws.inc.php diff --git a/nieuws.inc.php b/nieuws.inc.php index 438c282..e5e1ffa 100644 --- a/nieuws.inc.php +++ b/nieuws.inc.php @@ -9,7 +9,7 @@ function showdate($parts) { global $monthname; return implode(' ', array_filter([ - intval($parts[3]), $parts[2] > 0 ? $monthname[intval($parts[2])] : '', $parts[1], + intval(@$parts[3]), $parts[2] > 0 ? $monthname[intval($parts[2])] : '', $parts[1], count($parts) > 6 ? "$parts[4]:$parts[5]" : '', ])); } @@ -19,7 +19,7 @@ class ArchiveArticle function __construct($path) { $this->page = $path; - $this->link = preg_replace('/\.html$/', '', $path); + $this->link = preg_replace('{(?:/index)?\.html$}', '', $path); } function __get($col) @@ -29,6 +29,7 @@ class ArchiveArticle function file() { + if (!file_exists($this->page)) return; return fopen($this->page, 'r'); } @@ -39,7 +40,12 @@ class ArchiveArticle function safetitle() { - return strip_tags($this->title); + return trim(strip_tags($this->title)); + } + + function name() + { + return $this->safetitle ?: $this->link; } function last() @@ -54,7 +60,7 @@ class ArchiveArticle function dateparts() { - preg_match('', $this->page, $ymd); + preg_match('< / (\d{4}) [/-] (\d{2}) (?:- (\d{2}) )? - >x', $this->page, $ymd); return $ymd; } @@ -96,7 +102,7 @@ class ArchiveArticle function thumb($size = '300x') { if (!$this->image or $this->image[0] !== '/') return; - return "thumb/$size{$this->image}"; + return preg_replace('{^(?:/thumb/[^/]*)?}', "thumb/$size", $this->image); } } @@ -108,7 +114,9 @@ function shownews($input, $limit = 1000) $article = new ArchiveArticle($filename); print '
  • '; if ($article->thumb) { - printf('', $article->thumb); + $img = preg_replace('{(?<= \b src="/) [^"]* }x', $article->thumb, $article->img); + $img = preg_replace('{(?= />$)}', ' class="left"', $img); + print $img; } print '
    '; printf(