Merge remote-tracking branch 'upstream/4.4' into 4.4-4.5-2014-09-29-14-51-22
[civicrm-core.git] / CRM / Core / Smarty / plugins / block.crmScope.php
1 <?php
2
3 /**
4 * Smarty block function to temporarily define variables.
5 *
6 * Example:
7 *
8 * @code
9 * {tsScope x=1}
10 * Expect {$x}==1
11 * {tsScope x=2}
12 * Expect {$x}==2
13 * {/tsScope}
14 * Expect {$x}==1
15 * {/tsScope}
16 * @endcode
17 *
18 * @param array $params must define 'name'
19 * @param string $content Default content
20 * @param object $smarty the Smarty object
21 *
22 * @param $repeat
23 *
24 * @return string
25 */
26 function smarty_block_crmScope($params, $content, &$smarty, &$repeat) {
27 /** @var CRM_Core_Smarty $smarty */
28
29 if ($repeat) {
30 // open crmScope
31 $smarty->pushScope($params);
32 }
33 else {
34 // close crmScope
35 $smarty->popScope();
36 }
37
38 return $content;
39 }