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
8//this script may only be included - so its better to die if called directly.
9if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
10	header("location: index.php");
11	exit;
12}
13
14/**
15 * Returns a string with the href and data attributes to make a bootstrap modal appear on a link
16 * Note: Expects to be inside a "double quoted" href attribute in an html anchor
17 *
18 * @param array $params [size => 'modal-sm|modal-lg|modal-xl' (default: 'modal-md')]
19 * @param Smarty_Internal_Template $smarty
20 *
21 * @return string href attribute contents
22 * @throws SmartyException
23 */
24
25function smarty_function_bootstrap_modal($params, $smarty)
26{
27	$smarty->loadPlugin('smarty_function_service');
28	if (! empty($params['size'])) {
29		$size = '" data-size="' . $params['size'];
30		unset($params['size']);
31	} else {
32		$size = '';
33	}
34	$params['modal'] = 1;
35	$href = smarty_function_service($params, $smarty);
36	return "$href\" data-toggle=\"modal\" data-backdrop=\"static\" data-target=\".modal.fade:not(.show)$size";
37}
38