Author: chabotc
Date: Mon Feb 23 14:36:23 2009
New Revision: 747031
URL: http://svn.apache.org/viewvc?rev=747031&view=rev
Log:
Don't crash if no OAuth links are specified (doh) and properly parse it's end
points if it is specified
Modified:
incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php
Modified: incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php?rev=747031&r1=747030&r2=747031&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php Mon Feb 23
14:36:23 2009
@@ -1,5 +1,4 @@
<?php
-
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -52,8 +51,7 @@
$this->parseLinks($doc, $gadget);
$this->parseUserPrefs($doc, $gadget);
$this->parseViews($doc, $gadget);
- //TODO
- // PipelinedData
+ //TODO: parse pipelined data
return $gadget;
}
@@ -239,20 +237,22 @@
throw new GadgetSpecException("A gadget can only have one OAuth
element (though multiple service entries are allowed in that one OAuth
element)");
}
$oauth = array();
- $oauthNode = $oauthNodes->item(0);
- if (($serviceNodes = $oauthNode->getElementsByTagName('Service')) !=
null) {
- foreach ($serviceNodes as $service) {
- if (($entryNodes = $service->getElementsByTagName('*')) != null) {
- foreach ($entryNodes as $entry) {
- $type = strtolower($entry->tagName);
- $url = $entry->getAttribute('url');
- $method = $entry->getAttribute('method') != null ?
strtoupper($entry->getAttribute('method')) : 'GET';
- $oauth[$type] = array('url' => $url, 'method' => $method);
+ if ($oauthNodes->length > 0) {
+ $oauthNode = $oauthNodes->item(0);
+ if (($serviceNodes = $oauthNode->getElementsByTagName('Service')) !=
null) {
+ foreach ($serviceNodes as $service) {
+ if (($entryNodes = $service->getElementsByTagName('*')) != null) {
+ foreach ($entryNodes as $entry) {
+ $type = strtolower($entry->tagName);
+ $url = $entry->getAttribute('url');
+ $method = $entry->getAttribute('method') != null ?
strtoupper($entry->getAttribute('method')) : 'GET';
+ $oauth[$type] = array('url' => $url, 'method' => $method);
+ }
}
}
}
+ $gadget->oauth = $oauth;
}
- $gadget->oauth = $oauth;
}
}