summaryrefslogtreecommitdiff
path: root/plugins/data.alias.php
blob: 4502babb66c3edc00b4a9334ec60ec2a8b06460a (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
<?php
/**
 * 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 = array (
	'tag' => 'alias',
	'auto_activate' => FALSE,
	'requires_pair' => FALSE,
	'load_function' => 'data_alias',
	'title' => 'Alias',
	'help_page' => 'DataPluginAlias',
	'description' => 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>' . tra( "Key" ) . '</th>'
				.'<th>' . tra( "Type" ) . '</th>'
				.'<th>' . tra( "Comments" ) . '</th>'
			.'</tr>'
			.'<tr class="odd">'
				.'<td>' . tra( "page" ) . '</td>'
				.'<td>' . tra( "string") . '<br />' . tra( "(required)" ) . '</td>'
				.'<td>' . tra( "The name of any other wiki page." ) .'</td>'
			.'</tr>'
		.'</table>'
		. 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 tra("This page is an alias for:").'&nbsp;'.BitPage::getPageLink($page, LibertyContent::pageExists($page));
}
?>