X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/8f4f651e106516ebc1b67e820da748de8311f8d8..HEAD:/article.inc.php diff --git a/article.inc.php b/article.inc.php index f56b2be..093852f 100644 --- a/article.inc.php +++ b/article.inc.php @@ -4,6 +4,7 @@ class ArchiveArticle 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) { @@ -47,7 +48,7 @@ class ArchiveArticle $this->path = ''; $this->restricted = FALSE; while (TRUE) { - if (file_exists("$path/.private")) { + if (file_exists("$path/.private") and !$this->restricted) { $this->restricted = $path; } @@ -65,16 +66,16 @@ class ArchiveArticle 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() @@ -165,8 +166,9 @@ class ArchiveArticle return ltrim($this->image, '/'); } return preg_replace( - ['{^(?:/thumb/[^/]*)?}', '/\.groot(?=\.\w+$)/'], ["thumb/$size", ''], - $this->image + ['{^(?:/thumb/[^/]*)?}', '/\.groot(?=\.\w+$)/', '/(?:\.jpg)?$/'], + [ "thumb/$size", '', '.jpg' ], + $this->image, 1 ); } @@ -185,7 +187,7 @@ class ArchiveArticle else { foreach (explode(' ', $params) as $param) { if ($set = strpos($param, '=')) { - $Page->place[ substr($param, 0, $set) ] = substr($param, $set + 1); + $Page->place[ substr($param, 0, $set) ] = urldecode(substr($param, $set + 1)); } elseif (!empty($param)) { $Page->place[] = $param; @@ -221,7 +223,7 @@ class ArchiveArticle # 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.'"[^>]*>';