[evolvis-commits] r17757: add html_aonce for easy open-tag-for-autoclose-but-only-once

mirabilos at evolvis.org mirabilos at evolvis.org
Fri Dec 2 18:07:00 CET 2011


Author: mirabilos
Date: 2011-12-02 18:07:00 +0100 (Fri, 02 Dec 2011)
New Revision: 17757

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/www/include/html.php
Log:
add html_aonce for easy open-tag-for-autoclose-but-only-once


Modified: trunk/gforge_base/evolvisforge-5.1/src/www/include/html.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/include/html.php	2011-12-02 17:06:56 UTC (rev 17756)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/include/html.php	2011-12-02 17:07:00 UTC (rev 17757)
@@ -994,16 +994,45 @@
 }
 
 /**
+ * html_aonce() - Return once proper element XHTML start tag, with autoclose
+ *
+ * @param	ref	&$sptr
+			initialise this to false; will be modified
+ * @param	string	$name
+ *			element name
+ * @param	array	$attrs
+ *		(optional) associative array of element attributes
+ *			values: arrays are space-imploded;
+ *			    false values and empty arrays ignored
+ * @return	string
+ *		XHTML string suitable for echo'ing
+ */
+function html_aonce(&$sptr, $name, $attrs=array()) {
+	if ($sptr !== false) {
+		/* already run */
+		return "";
+	}
+	$sptr = html_ap();
+	return html_ao($name, $attrs);
+}
+
+/**
  * html_ac() - Return proper element XHTML end tags, autoclosing
  *
  * @param	integer	$spos
  *			stack position to return to
+ *			(nothing is done if === false)
  * @return	string
  *		XHTML string suitable for echo'ing
  */
 function html_ac($spos) {
 	global $html_autoclose_pos, $html_autoclose_stack;
 
+	if ($spos === false) {
+		/* support for html_aonce() */
+		return "";
+	}
+
 	if ($html_autoclose_pos < $spos) {
 		$e = "html_autoclose stack underflow; closing down to " .
 		    $spos . " but we're down to " . $html_autoclose_pos .



More information about the evolvis-commits mailing list