public $raw, $title, $body; # file contents
public $meta = []; # head metadata properties
public $place = []; # template variables replaced in render()
+ public $api = FALSE; # requested programming interface
function __construct($path)
{
- $this->page = preg_replace('{^\.(?:/|$)}', '', $path);
- $this->link = preg_replace('{(?:(?:/|^)index)?\.html$}', '', $this->page);
- $this->raw($this->page);
+ $this->file = preg_replace('{^\.(?:/|$)}', '', $path);
+ $this->link = preg_replace('{(?:(?:/|^)index)?\.html$}', '', $this->file);
+ $this->raw($this->file);
}
function raw($page)
return;
}
- function index()
+ function index($api = TRUE)
{
$this->handler;
if (empty($this->handler)) {
return;
}
- $User = NULL;
+ $this->api = $api;
$Page = $this;
- $res = include "./{$this->handler}/index.php";
- return $res;
+ global $User;
+ return require "./{$this->handler}/index.php";
}
function restricted()
function last()
{
- return filemtime($this->page);
+ return filemtime($this->file);
}
function lastiso()
{
function dateparts()
{
- preg_match('< / (\d{4}) [/-] (\d{2}) (?:- (\d{2}) )? - >x', $this->page, $ymd);
+ preg_match('< / (\d{4}) [/-] (\d{2}) (?:- (\d{2}) )? - >x', $this->file, $ymd);
array_shift($ymd);
return $ymd;
}
return ltrim($this->image, '/');
}
return preg_replace(
- ['{^(?:/thumb/[^/]*)?}', '/\.groot(?=\.\w+$)/'], ["thumb/$size", ''],
- $this->image
+ ['{^(?:/thumb/[^/]*)?}', '/\.groot(?=\.\w+$)/', '/(?:\.jpg)?$/'],
+ [ "thumb/$size", '', '.jpg' ],
+ $this->image, 1
);
}
# keep either login or logout parts depending on user level
global $User;
$userexists = $User && property_exists($User, 'login') && $User->login;
- if (! ($userexists and $User->admin("edit {$this->link}")) ) {
+ if (! ($userexists and !empty($this->editable)) ) {
# remove matching elements until first corresponding closing tag
$hideclass = $userexists ? 'logout' : 'login';
$tagmatch = '<([a-z]+) class="'.$hideclass.'"[^>]*>';