Table of Contents

multinamespace Plugin

Compatible with DokuWiki

No compatibility info given!

plugin Allow to put a file in multiple namespace

Last updated on
2005-12-14
Provides
Syntax
Requires
include

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to crosspost

Tagged with include, sync

What's that?

This plugin allow you to save a file in multiple namespace…

For example, you got an article for PHP and JavaScript language.

With this plugin you can save your file into php:thearticlename and javascript:thearticlename.

:!: IMPORTANT NOTE: The file is not duplicated! This plugin works with Include Plugin or Blog Plugin (must be present in your wiki).

Use it...

The syntax is simple:

{=other:namespace=}

Between {= and =}, just write the other namespace where you want to save the file (separated with pipe: |)

Install

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

> this link is down, no way to install via plugin manager :( — Dirk Haage 2006-02-14 20:36

↑It's true, I can't install it through plugin manager either, because the zip file only contains the syntax.php, not a proper plugin folder. — Roberto Ciang 2007-02-13 23:24

Create a folder “multinamespace” in “lib/plugins” and put below code in “syntax.php” :

syntax.php
<?php
 
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class syntax_plugin_multinamespace extends DokuWiki_Syntax_Plugin {
 
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'iDo',
            'email'  => 'iDo@woow-fr.com',
            'date'   => '14/12/2005',
            'name'   => 'multinamespace Plugin',
			'desc'   => 'Now it`s possible to put a page in multiple namespace',
            'url'    => 'http://www.dokuwiki.org/plugin:multinamespace',
        );
    }
 
    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'substition';
    }
 
    /**
     * Where to sort in?
     */
    function getSort(){
        return 50;
    }
 
    /**
     * Connect pattern to lexer
     */
    function connectTo($mode) {
      $this->Lexer->addSpecialPattern("{=.*=}",$mode,'plugin_multinamespace');
    }
 
    /**
     * Handle the match
     */
    function handle($match, $state, $pos, &$handler){
        global $ID;
 
		$match = substr($match,2,-2); // Strip markup
        $match = explode('|',$match); // Split title from URL
 
		$filelist=array();
		$e=explode(':',$ID);
		$e=$e[count($e)-1];
		foreach ($match as $v) {
			if (strpos($ID,':')===false)
				$v.=':'.$ID;
			else
				$v.=':'.$e;
			$exists=file_exists(wikiFN($v));
			// check for existence and permission
			if (($exists) || (auth_quickaclcheck($v) < 1)) continue;
			if (in_array($v, $filelist)) continue;
			array_push($filelist,$v);
		}
        return $filelist;
    }  
 
    /**
     * Create output
     */
    function render($mode, &$renderer, $data) {
        if($mode == 'xhtml'){
			$this->_IncludeInNameSpace($data);
            $renderer->doc = '';
            return true;
        }
        return false;
    }
 
	function _IncludeInNameSpace($data) {
		global $ID;
		foreach ($data as $v) {
			if ($ID!=$v)				
				saveWikiText($v, '{{page>'.$ID.'}}', 'link from '.$ID);
		}
	}
}
 
//Setup VIM: ex: et ts=4 enc=utf-8 :
?>

Comments

sounds nice :) is it updating both/all pages, when any of the articles is edited? — Freddy 2005-12-14 22:19

In fact, there is only one page with the article, all other page contains only "{{page>yournamespace:yourpage}}" so when you edit the original page all other are modified too.


works really good! A nice feature would be that in the moment you hit the edit button you will get the page with the content and not the copy which includes it, just for convenience. I don´t know whether this would be easy to accomplish. — loco 2006-02-15 15:50

I like the concept, but there's something missing in the parsing code - this plugin doesn't parse out the namespaces already attached to the page name, meaning that if the page with namespaces is [[here:it:is]], and multinamespace it into {=where:i:want=} the net result is a link to [[where:i:want:here:it:is]] ^^;; It'd be much preferable for each namespace to start from the root - for the plugin to extract JUST the page name, that is. Thanks for a great plugin, though! Aside from that, it works great. — Naki 2006-03-29 01:25

Hey, Naki, try using {=:where:i:want=}. By default, having a preceding colon in the address will make DokuWiki parse from the root. — PKoch 2006-04-10 23:18 GMT

Unfortunately, I had tried that before - the results were the same. The page name still ends up having the full namespace:pagename structure, rather than pulling just the pagename. I should clarify how the test structure here is - the page to start with is in a namespace already, not a top-level page. You can see the result at the test site I've been trying DW on: http://test.dragonsnotes.com/dokuwiki You can view http://test.dragonsnotes.com/dokuwiki/doku.php/games:bonuses:ace_combat_five for the page with the test implementation of the leading colon, and just take a look at the anime listing on the left for the results. The duplicated page SHOULD be listed under scifi directly, but instead it places the page in bonuses:page - and incorrectly, I might add, as the page is not properly duplicated but instead has a pointer to itself. — Naki 2006-04-11 15:59 CST

Naki, i have updated the code and the Zip :) Now, it seems ok :)
iDo 2006-04-13 17:10 GMT+1
Unfortunately, it still seems to not be working. I installed the updated version manually, and tested with 1 as the original page. 2 and 3 are the result - It looks as though the | delimiter is broken, and it's still generating wrong {{page>inserted_page}} links as well. Could this be because I have internal DokuWiki redirection enabled? Just a thought. — Naki 2006-04-16 23:22 CST
Ok, i have updated again, i hope it's ok :)
iDo 2006-04-18 16:35
I think we've just about got it here! ^^ This time it created the correct pages in the correct places! 1 Was the original test page,2, 3, and 4 the test pages. It created the correct namespace structures for each of them. But, 2 and 3 are linked to 4, and 4 is linked to 2, rather than 1. All that's left is to make sure that the inserted page is always the original page and it'll be good to go! Thank you again for all the help. ^^ — Naki 2006-04-16 23:02 CST
Hi :) I can't reproduce this bug… may be it's a cache problem… try to delete all files and folder in /data/cache/ and delete your page (bubblegum_crisis_music_videos.txt) from all location except original. And then reload original page. — iDo 2006-04-19 10:01
Ah! That got it working. Thanks again for all the help, it's really appreciated. — Naki 2006-04-18 21:55 CST

Could just be me, but I had to place “{=example:example=}” at the very top of the file or find the rest of the page blanked out. Before I figured that out, I was under the impression that this plugin was broken. — Brent Shultz 2006-12-01 05:42