page: localise page variables within template includes
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 28 Jun 2018 22:03:05 +0000 (00:03 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 7 Jul 2018 21:17:29 +0000 (23:17 +0200)
Clean up parameter interface:

- $Page provides containing page instead of parent script;
- $Args reserved for placeholder arguments;
- $Place inherited and joined with placeholder options.

The latter replaces GET overrides without bleeding into subsequent includes.

login/admin.html
login/commits.html
login/commits.php
login/visits.php
nieuws.php
page.php

index c07a25e3b72f61f658bf17393d94d36df29c9632..91920630267e6942fcce5d8e2f52351cf9f2be2a 100644 (file)
@@ -8,4 +8,4 @@ Wijzigingen zijn direct zichtbaar, en worden periodiek bijgehouden:
 
 <h3>Laatste aanpassingen</h3>
 
-[[login/commits pagesize=10]]
+[[login/commits n=10]]
index 4750f325d1383f666b71a9050a4e2c9e70bd127c..b7a0413fdb1d8d4a8bdb1f9a8a28efa2cfc5da46 100644 (file)
@@ -1,4 +1,4 @@
 <h2>Aanpassingen</h2>
 
-[[login/commits pagesize=50]]
+[[login/commits n=50]]
 
index c411f4704e2e8348110bbcd35d94d83a636a9b57..7b88964604e61340bfcb4a560ff3ddf69b5742bb 100644 (file)
@@ -4,7 +4,7 @@ if (!function_exists('popen')) {
        return;
 }
 
-$pagesize = intval(@$_GET['pagesize']) ?: 20;
+$pagesize = intval(@$Place['n'] ?: @$_GET['n']) ?: 20;
 $gitcmd = "git log -n $pagesize --pretty='%at\t%an\t%s'";
 
 if ( $offset = intval(@$_GET['start']) ) {
index 8e5d1f661e1b5a8515e182690c96a8312bbcfb92..93bdd94f2d71614e2296265e560337dc83fb63ea 100644 (file)
@@ -9,7 +9,7 @@ foreach (glob('profile/*') as $userdir) {
        ];
 }
 
-if (@$_GET['order'] == 'seen') {
+if (@$Place['order'] == 'seen') {
        array_multisort(array_column($logins, 'seen'), SORT_DESC, SORT_NUMERIC, $logins);
 }
 
index cafc94c6795a25ec866ee06c04fa689000c64e42..6bf66160fa594a6c56d24da89b3eaf93a176adc0 100644 (file)
@@ -1,4 +1,4 @@
 <?php
 include_once 'nieuws.inc.php';
-$articles = ($Page ?: 'nieuws') . '/????';
-shownews($articles, @$_GET['n'] ?: 5);
+$articles = (ltrim($Args, '/') ?: 'nieuws') . '/????';
+shownews($articles, @$Place['n'] ?: 5);
index 50e098acaf1c0606e1483bca1886124f04339c31..b160e45290295d56bfb30a0fd1b1116eba4465e0 100644 (file)
--- a/page.php
+++ b/page.php
@@ -31,11 +31,12 @@ function getoutput($blocks = [])
                        }
                        elseif (file_exists("$name.php")) {
                                ob_start();
-                               $Page = $GLOBALS['Page'];
-                               $Args = $GLOBALS['Args'];
+                               $Page = $GLOBALS['Page'] . $GLOBALS['Args'];
+                               $Args = '';
+                               $Place = $GLOBALS['Place'];
                                foreach (explode(' ', $params) as $param) {
                                        if ($set = strpos($param, '=')) {
-                                               $_GET[ substr($param, 0, $set) ] = substr($param, $set + 1);
+                                               $Place[ substr($param, 0, $set) ] = substr($param, $set + 1);
                                        }
                                        elseif (!empty($param)) {
                                                $Args .= '/'.$param;