summaryrefslogtreecommitdiff
path: root/plugins/data.alias.php
blob: 9c3eb75e7d0a42db086efb7e2d1d5dae5dc40335 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php

namespace Bitweaver\Liberty;

use Bitweaver\Wiki\BitPage;
use Bitweaver\KernelTools;

/**
 * assigned_modules
 *
 * @author     xing
 * @version    $Revision$
 * @package    liberty
 * @subpackage plugins_data
 * @copyright  Copyright (c) 2004, bitweaver.org
 */

/**
 * Setup Code
 */
define( 'PLUGIN_GUID_DATAalias', 'dataalias' );
global $gLibertySystem;
$pluginParams = [
	'tag' => 'alias',
	'auto_activate' => false,
	'requires_pair' => false,
	'load_function' => '\data_alias',
	'title' => 'Alias',
	'help_page' => 'DataPluginAlias',
	'description' => KernelTools::tra( "This plugin allows you to easily create an alias for a page." ),
	'help_function' => '\data_alias_help',
	'syntax' => "{alias page='title'}",
	'plugin_type' => DATA_PLUGIN,
];
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAalias, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAalias );

function data_alias_help() {
	$help =
		'<table class="data help">'
			.'<tr>'
				.'<th>' . KernelTools::tra( "Key" ) . '</th>'
				.'<th>' . KernelTools::tra( "Type" ) . '</th>'
				.'<th>' . KernelTools::tra( "Comments" ) . '</th>'
			.'</tr>'
			.'<tr class="odd">'
				.'<td>' . KernelTools::tra( "page" ) . '</td>'
				.'<td>' . KernelTools::tra( "string") . '<br />' . KernelTools::tra( "(required)" ) . '</td>'
				.'<td>' . KernelTools::tra( "The name of any other wiki page." ) .'</td>'
			.'</tr>'
		.'</table>'
		. KernelTools::tra( "Example: " ) . "{alias page='Welcome'}";
	return $help;
}

function data_alias( $pData, $pParams, $pCommonObject ) {
	$page = '';
	require_once WIKI_PKG_CLASS_PATH.'BitPage.php';

	foreach( $pParams as $key => $value ) {
		if( !empty( $value ) ) {
			switch( $key ) {
				case 'page':
					$page = $value;
					break;
			default:
				break;
			}
		}
	}
	return KernelTools::tra("This page is an alias for:").'&nbsp;'.BitPage::getPageLink($page, BitPage::pageExists($page));
}