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

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

=======================================
--- /trunk/lib/SAML2/Utils.php  Fri Mar  5 07:11:27 2010
+++ /trunk/lib/SAML2/Utils.php  Fri Mar  5 07:11:43 2010
@@ -324,6 +324,28 @@
                return $decryptedElement;
        }

-}
-
-?>
+
+       /**
+        * Extract localized strings from a set of nodes.
+        *
+ * @param DOMElement $parent The element we should rund the XPath query on. + * @param string $query The XPath query we should use to retrieve the nodes.
+        * @return array  Localized strings.
+        */
+ public static function extractLocalizedStrings(DOMElement $parent, $query) {
+               assert('is_string($query)');
+
+               $ret = array();
+               foreach (self::xpQuery($parent, $query) as $node) {
+                       if ($node->hasAttribute('xml:lang')) {
+                               $language = $node->getAttribute('xml:lang');
+                       } else {
+                               $language = 'en';
+                       }
+                       $ret[$language] = trim($node->textContent);
+               }
+
+               return $ret;
+       }
+
+}

--
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