cvs: smarty / NEWS /libs/plugins function.popup_init.php

[email protected] ("boots") Thu, 04 May 2006 19:10:13 -0000
Newsgroups php.smarty.cvs
Message-ID <cvsboots1146769813@cvsserver>
boots		Thu May  4 19:10:13 2006 UTC

  Modified files:              
    /smarty	NEWS 
    /smarty/libs/plugins	function.popup_init.php 
  Log:
  changed {popup_init} to only emit code once during a request
  
  Thanks to TGKnIght from forums
  
http://cvs.php.net/viewcvs.cgi/smarty/NEWS?r1=1.527&r2=1.528&diff_format=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.527 smarty/NEWS:1.528
--- smarty/NEWS:1.527	Sat Apr 22 08:16:57 2006
+++ smarty/NEWS	Thu May  4 19:10:13 2006
@@ -1,3 +1,4 @@
+- changed {popup_init} to only emit code once during a request (TGKnIght, boots)
 - fix handling of block-methods of registered objects (El Hombre Gris,
   messju)
 
http://cvs.php.net/viewcvs.cgi/smarty/libs/plugins/function.popup_init.php?r1=1.10&r2=1.11&diff_format=u
Index: smarty/libs/plugins/function.popup_init.php
diff -u smarty/libs/plugins/function.popup_init.php:1.10 smarty/libs/plugins/function.popup_init.php:1.11
--- smarty/libs/plugins/function.popup_init.php:1.10	Tue Oct 11 16:22:56 2005
+++ smarty/libs/plugins/function.popup_init.php	Thu May  4 19:10:13 2006
@@ -21,20 +21,24 @@
  */
 function smarty_function_popup_init($params, &$smarty)
 {
-    $zindex = 1000;
+    static $already_init;
     
-    if (!empty($params['zindex'])) {
-        $zindex = $params['zindex'];
-    }
-    
-    if (!empty($params['src'])) {
-        return '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>' . "\n"
-         . '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>' . "\n";
-    } else {
-        $smarty->trigger_error("popup_init: missing src parameter");
+    if (!$already_init) {
+        $zindex = 1000;
+        
+        if (!empty($params['zindex'])) {
+            $zindex = $params['zindex'];
+        }
+        
+        if (!empty($params['src'])) {
+            return '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>' . "\n"
+             . '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>' . "\n";
+        } else {
+            $smarty->trigger_error("popup_init: missing src parameter");
+        }
     }
 }
 
 /* vim: set expandtab: */
 
-?>
+?>
\ No newline at end of file