Revision: 2201
Author: olavmrk
Date: Fri Mar  5 07:12:33 2010
Log: SAML2_Utils: Add the new addStrings()-function.
http://code.google.com/p/simplesamlphp/source/detail?r=2201

Modified:
 /trunk/lib/SAML2/Assertion.php
 /trunk/lib/SAML2/Utils.php

=======================================
--- /trunk/lib/SAML2/Assertion.php      Fri Mar  5 07:12:21 2010
+++ /trunk/lib/SAML2/Assertion.php      Fri Mar  5 07:12:33 2010
@@ -1070,12 +1070,7 @@
$ar = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:AudienceRestriction');
                        $conditions->appendChild($ar);

-                       foreach ($this->validAudiences as $audience) {
-                               $a = 
$document->createElementNS(SAML2_Const::NS_SAML, 'saml:Audience');
-                               $ar->appendChild($a);
-
-                               
$a->appendChild($document->createTextNode($audience));
-                       }
+ SAML2_Utils::addStrings($ar, SAML2_Const::NS_SAML, 'saml:Audience', FALSE, $this->validAudiences);
                }
        }

=======================================
--- /trunk/lib/SAML2/Utils.php  Fri Mar  5 07:12:21 2010
+++ /trunk/lib/SAML2/Utils.php  Fri Mar  5 07:12:33 2010
@@ -387,5 +387,32 @@

                return $n;
        }
+
+
+       /**
+        * Append string elements.
+        *
+ * @param DOMElement $parent The parent element we should append the new nodes to.
+        * @param string $namespace  The namespace of the created elements
+        * @param string $name  The name of the created elements
+ * @param bool $localized Whether the strings are localized, and should include the xml:lang attribute.
+        * @param array $values  The values we should create the elements from.
+        */
+ public static function addStrings(DOMElement $parent, $namespace, $name, $localized, array $values) {
+               assert('is_string($namespace)');
+               assert('is_string($name)');
+               assert('is_bool($localized)');
+
+               $doc = $parent->ownerDocument;
+
+               foreach ($values as $index => $value) {
+                       $n = $doc->createElementNS($namespace, $name);
+                       $n->appendChild($doc->createTextNode($value));
+                       if ($localized) {
+                               $n->setAttribute('xml:lang', $index);
+                       }
+                       $parent->appendChild($n);
+               }
+       }

 }

--
You received this message because you are subscribed to the Google Groups 
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/simplesamlphp-commits?hl=en.

Reply via email to