summaryrefslogtreecommitdiff
path: root/plugins/data.addjstabs.php
blob: 9e375546a6c67c27d940c54b4225d2a91ecc27e1 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php

namespace Bitweaver\Liberty;

use Bitweaver\KernelTools;

/**
 * @version  $Revision$
 * @package  liberty
 * @subpackage plugins_data
 *
 * +----------------------------------------------------------------------+
 * | Copyright (c) 2015, bitweaver.org
 * +----------------------------------------------------------------------+
 * | All Rights Reserved. See below for details and a complete list of authors.
 * | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
 * |
 * | For comments, please use phpdocu.sourceforge.net documentation standards!!!
 * | -> see http://phpdocu.sourceforge.net/
 * +----------------------------------------------------------------------+
 * | Author: StarRider <starrrider@users.sourceforge.net>
 * | port to jstabs <lester@lsces.co.uk>
 * +----------------------------------------------------------------------+
 */

/**
 * definitions
 */
define( 'PLUGIN_GUID_DATAADDJSTABS', 'dataaddjstabs' );
global $gLibertySystem;
global $gContent;
$pluginParams = [
	'tag' => 'ADDJSTABS',
	'auto_activate' => false,
	'requires_pair' => false,
	'load_function' => 'data_addjstabs',
	'title' => 'AddJSTabs',
	'help_page' => 'DataPluginAddJSTabs',
	'description' => KernelTools::tra("Will join the contents from several sources in a Tabbed Interface."),
	'help_function' => 'data_addjstabs_help',
	'syntax' => "{ADDTABS tab1= tab2= tab3= . . . tab99= }",
	'plugin_type' => DATA_PLUGIN,
];
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAADDJSTABS, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAADDJSTABS );

/**
 * Help Function
 */
function data_addjstabs_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>tab1 - tab99</td>'
				.'<td>' . KernelTools::tra( "numeric") . '<br />' . KernelTools::tra("(optional)") . '</td>'
				.'<td>' . KernelTools::tra( "Will create a Tab interface on a page using jstab format. The name on each tab is the name given to the imported page.The value sent with the TabX parameter is a Numeric Content Id. This allows blog posts, images, wiki pages . . . (and more) to be added.")
				. KernelTools::tra("<br /><strong>Note 1:</strong> A listing of Content Id's can be found ")
				. '<a href="'.LIBERTY_PKG_URL.'list_content.php" title="Launch BitWeaver Content Browser in New Window" onkeypress="javascript:BitBase.popUpWin(this.href,\'standard\',800,800);" onclick="javascript:BitBase.popUpWin(this.href,\'standard\',800,800);return false;">' . KernelTools::tra( "Here" ) . '</a>'
				. KernelTools::tra("<br /><strong>Note 2:</strong> The order used when the tabs are specified does not matter. The Tabname does - Tab1 is always first and Tab99 will always be last.</td>")
			.'</tr>'
		.'</table>'
		. KernelTools::tra("Example: ") . '{ADDTABS tab1=15 tab2=12 tab3=11}';
	return $help;
}

function data_addjstabs($data, $params) {
	global $gBitSmarty;
//	$gBitSmarty->registerSmartyPlugin( 'block','jstab' );
//	$gBitSmarty->registerSmartyPlugin( 'block','jstabs' );

	extract ($params, EXTR_SKIP);
	$id = 1000000 * microtime();
	$html = '';
	$good = false;

	for ($i = 1; $i <= 99; $i++) {
		if( isset( ${'tab'.$i} ) ) {
			if (is_numeric( ${'tab'.$i} ) ) {
				if( $obj = LibertyBase::getLibertyObject( ${'tab'.$i} ) ) {
					$params['title'] = $obj->getTitle();
					$html .= \Bitweaver\Liberty\smarty_block_jstab( $params, $obj->mInfo['parsed_data'], $gBitSmarty, '' );
					$good=True;
				}
			}
			else {
				$good=false;
			}
		}
	}
	if( !$good ) {
		$html = KernelTools::tra("The plugin AddTabs requires valid parameters. Numeric content id numbers can use the parameter names 'tab1' thru 'tab99'");
	}
	if( !empty( $html )) {
		return \Bitweaver\Liberty\smarty_block_jstabs( [], $html, $gBitSmarty, '' );
	}
		return $html;

}