Merge remote-tracking branch 'origin/4.5' into 4.5-master-2015-02-24-17-24-05
[civicrm-core.git] / CRM / Core / Smarty / plugins / block.crmScope.php
index b37050b326d95867975dce14fff6eddc014c0e57..66bb8bcb4fdac8098422820dd4d87ae1d74c588a 100644 (file)
  * {/tsScope}
  * @endcode
  *
- * @param array $params must define 'name'
- * @param string $content Default content
- * @param object $smarty the Smarty object
+ * @param array $params
+ *   Must define 'name'.
+ * @param string $content
+ *   Default content.
+ * @param CRM_Core_Smarty $smarty
+ *   The Smarty object.
  *
  * @param $repeat
  *
  * @return string
  */
 function smarty_block_crmScope($params, $content, &$smarty, &$repeat) {
-  // A list of variables/values to save temporarily
-  static $backupFrames = array();
+  /** @var CRM_Core_Smarty $smarty */
 
   if ($repeat) {
     // open crmScope
-    $vars = $smarty->get_template_vars();
-    $backupFrame = array();
-    foreach ($params as $key => $value) {
-      $backupFrame[$key] = isset($vars[$key]) ? $vars[$key] : NULL;
-    }
-    $backupFrames[] = $backupFrame;
-    _smarty_block_crmScope_applyFrame($smarty, $params);
+    $smarty->pushScope($params);
   }
   else {
     // close crmScope
-    _smarty_block_crmScope_applyFrame($smarty, array_pop($backupFrames));
+    $smarty->popScope();
   }
 
   return $content;
 }
-
-/**
- * @param $smarty
- * @param $frame
- */
-function _smarty_block_crmScope_applyFrame(&$smarty, $frame) {
-  foreach ($frame as $key => $value) {
-    $smarty->assign($key, $value);
-  }
-}