Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

When ?ns given, try to be clever by using namespace for unknown pages

darcs-hash:20090126155418-6e07b-02becf49566705930197f214683fbea3a558836d.gz
  • Loading branch information...
commit 6c9a275772077be72e081d9a36df97a3a190f24f 1 parent 2da0f9d
@splitbrain splitbrain authored
Showing with 35 additions and 4 deletions.
  1. +35 −4 syntax.php
View
39 syntax.php
@@ -52,7 +52,9 @@ function connectTo($mode) {
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
- $id = cleanID(substr($match,7,-2));
+ $id = substr($match,7,-2);
+ list($id,$opt) = explode('?',$id,2);
+ $id = cleanID($id);
// fetch the instructions of the control page
$instructions = p_cached_instructions(wikiFN($id),false,$id);
@@ -89,7 +91,7 @@ function handle($match, $state, $pos, &$handler){
}
}
- return array(wikiFN($id),$list);
+ return array(wikiFN($id),$list,$opt);
}
/**
@@ -101,6 +103,7 @@ function render($format, &$R, $data) {
global $INFO;
global $ID;
$fn = $data[0];
+ $opt = $data[2];
$data = $data[1];
if($format == 'metadata'){
@@ -110,8 +113,36 @@ function render($format, &$R, $data) {
$R->info['cache'] = false; // no cache please
- $parent = (array) $data[$INFO['id']]['parents']; // get the "path" of the page we're on currently
- array_push($parent,$INFO['id']);
+ $parent = array();
+ if(isset($data[$INFO['id']])){
+ $parent = (array) $data[$INFO['id']]['parents']; // get the "path" of the page we're on currently
+ array_push($parent,$INFO['id']);
+ }elseif($opt == 'ns'){
+ $ns = $INFO['id'];
+
+ // traverse up for matching namespaces
+ do {
+ $ns = getNS($ns);
+ $try = "$ns:";
+ resolve_pageid('',$try,$foo);
+ if(isset($data[$try])){
+ // got a start page
+ $parent = (array) $data[$try]['parents'];
+ array_push($parent,$try);
+ break;
+ }else{
+ // search for the first page matching the namespace
+ foreach($data as $key => $junk){
+ if(getNS($key) == $ns){
+ $parent = (array) $data[$key]['parents'];
+ array_push($parent,$key);
+ break;
+ }
+ }
+ }
+
+ }while($ns);
+ }
// we need the top ID for the renderer
$oldid = $ID;
Please sign in to comment.
Something went wrong with that request. Please try again.