1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8function wikiplugin_remarksbox_info()
9{
10	return [
11		'name' => tra('Remarks Box'),
12		'documentation' => 'PluginRemarksBox',
13		'description' => tra('Display a comment, tip, note or warning box'),
14		'prefs' => [ 'wikiplugin_remarksbox' ],
15		'body' => tra('remarks text'),
16		'iconname' => 'comment',
17		'introduced' => 2,
18		'tags' => [ 'basic' ],
19		'format' => 'html',
20		'params' => [
21			'type' => [
22				'required' => false,
23				'name' => tra('Type'),
24				'description' => tra('Select type of remarksbox, which determines what icon and style will be displayed'),
25				'since' => '2.0',
26				'default' => 'tip',
27				'filter' => 'word',
28				'options' => [
29					['text' => '', 'value' => ''],
30					['text' => tra('Comment'), 'value' => 'comment'],
31					['text' => tra('Confirm'), 'value' => 'confirm'],
32					['text' => tra('Errors'), 'value' => 'errors'],
33					['text' => tra('Information'), 'value' => 'information'],
34					['text' => tra('Note'), 'value' => 'note'],
35					['text' => tra('Tip'), 'value' => 'tip'],
36					['text' => tra('Warning'), 'value' => 'warning']
37				]
38			],
39			'title' => [
40				'required' => false,
41				'name' => tra('Title'),
42				'description' => tra('Label displayed above the remark.'),
43				'since' => '2.0',
44				'filter' => 'text',
45				'default' => '',
46			],
47			'highlight' => [
48				'required' => false,
49				'name' => tra('Highlight'),
50				'description' => tra('Use the highlight class for formatting (not used by default).') ,
51				'since' => '2.0',
52				'filter' => 'alpha',
53				'default' => '',
54				'options' => [
55					['text' => '', 'value' => ''],
56					['text' => tra('Yes'), 'value' => 'y'],
57					['text' => tra('No'), 'value' => 'n']
58				]
59			],
60			'icon' => [
61				'required' => false,
62				'name' => tra('Custom Icon'),
63				'description' => tra('Enter a custom icon name (from tiki available icon at https://doc.tiki.org/PluginIcon)'),
64				'since' => '2.0',
65				'filter' => 'text',
66				//'default' => '',  (use empty string for no icon)
67			],
68			'close' => [
69				'required' => false,
70				'name' => tra('Close'),
71				'description' => tra('Show a close button (not shown by default).'),
72				'since' => '4.0',
73				'filter' => 'alpha',
74				'default' => 'y',
75				'options' => [
76					['text' => '', 'value' => ''],
77					['text' => tra('Yes'), 'value' => 'y'],
78					['text' => tra('No'), 'value' => 'n']
79				]
80			],
81			'width' => [
82				'required' => false,
83				'name' => tra('Width'),
84				'description' => tr('Width (e.g. %0100%%1 or %0250px%1 - default "")', '<code>', '</code>'),
85				'since' => '4.1',
86				'filter' => 'text',
87				'default' => ''
88			],
89			'store_cookie' => [
90				'name' => tr('Remember Dismiss'),
91				'description' => tr('Set whether to remember if the alert is dismissed (not remembered by default).
92					Requires %0id%1 and %0version%1 parameters to be set.', '<code>', '</code>'),
93				'since' => '14.0',
94				'required' => false,
95				'filter' => 'text',
96				'options' => [
97					['text' => '', 'value' => ''],
98					['text' => tra('Yes'), 'value' => 'y'],
99					['text' => tra('No'), 'value' => 'n']
100				]
101			],
102			'id' => [
103				'name' => tr('ID'),
104				'description' => tr('Sets an HTML id for the account.'),
105				'since' => '14.0',
106				'required' => false,
107				'filter' => 'text'
108			],
109			'version' => [
110				'name' => tr('Version'),
111				'description' => tr('Sets a version for the alert. If new version, the alert should show up again even
112					if it was previously dismissed using the %0store_cookie%1 parameter', '<code>', '</code>'),
113				'since' => '14.0',
114				'required' => false,
115				'filter' => 'text',
116				'default' => '',
117			],
118			'title_tag' => [
119				'name' => tr('Title Tag'),
120				'description' => tr(''),
121				'since' => '21.1',
122				'required' => false,
123				'filter' => 'text',
124				'options' => [
125					['text' => '', 'value' => ''],
126					['text' => tr('Div class h4') . ' ' . tr('(default)'), 'value' => 'div'],
127					['text' => tr('H4 (legacy)'), 'value' => 'h4'],
128				],
129				'default' => 'div',
130			],
131			'title_class' => [
132				'name' => tr('Title Class'),
133				'description' => tr(''),
134				'since' => '21.1',
135				'required' => false,
136				'filter' => 'text',
137				'default' => 'alert-heading h4',
138			],
139		]
140	];
141}
142
143function wikiplugin_remarksbox($data, $params)
144{
145	$plugininfo = wikiplugin_remarksbox_info();
146	$default = [];
147	foreach ($plugininfo['params'] as $key => $param) {
148		if (isset($param['default'])) {
149			$default[$key] = $param['default'];
150		}
151	}
152	$params = array_merge($default, $params);
153
154	$smarty = TikiLib::lib('smarty');
155	require_once('lib/smarty_tiki/block.remarksbox.php');
156
157	$repeat = false;
158	$ret = smarty_block_remarksbox($params, '~/np~' . tra($data) . ' ~np~', $smarty, $repeat);
159	return $ret;
160}
161