summaryrefslogtreecommitdiff
path: root/smartyplugins/function.minifind.php
blob: d98c2dea9dd90d5b35f2bbf9290d016ecff668e3 (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
<?php
namespace Bitweaver\Plugins;

use Bitweaver\KernelTools;

/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Smarty {minifind} function plugin
 *
 * Type:     function
 * Name:     minifind
 * Input:    all parameters (except legend) that are passed in will be added as <input type="hidden" name=$name value=$value>. The 'legend' parameter will be used as the form legend, a string is expected.
 * Output:   a small form that allows you to search your table using $_REQUEST['find'] as search value
 */
function smarty_function_minifind($params, &$gSmartyTemplate) {
	global $gBitSmarty;

	if(isset($params['legend'])) {
		$legend = $params['legend'];
		unset($params['legend']);
	} else {
		$legend = 'find in entries';
	}

	if( !empty( $params['find_name'] ) ) {
		$gBitSmarty->assign( 'find_name', KernelTools::tra( $params['name'] ) );
	}

	if( !empty( $params['prompt'] ) ) {
		$gBitSmarty->assign( 'prompt', KernelTools::tra( $params['prompt'] ).'...' );
	}

	$gBitSmarty->assign( 'legend',$legend );
	$gBitSmarty->assign( 'hidden',$params );
	return $gBitSmarty->fetch( 'bitpackage:kernel/minifind.tpl' );
}