function __construct($path)
{
$this->page = $path;
- $this->link = preg_replace('/\.html$/', '', $path);
+ $this->link = preg_replace('{(?:/index)?\.html$}', '', $path);
}
function __get($col)
function file()
{
+ if (!file_exists($this->page)) return;
return fopen($this->page, 'r');
}
function safetitle()
{
- return strip_tags($this->title);
+ return trim(strip_tags($this->title));
+ }
+
+ function name()
+ {
+ return $this->safetitle ?: $this->link;
}
function last()
function dateparts()
{
- preg_match('</(\d{4})/(\d{2})-(\d{2})->', $this->page, $ymd);
+ preg_match('</(\d{4})[/-](\d{2})-(\d{2})->', $this->page, $ymd);
return $ymd;
}
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);
}
}