diff options
author | tailor <dag@janrain.com> | 2008-05-23 22:14:44 +0000 |
---|---|---|
committer | tailor <dag@janrain.com> | 2008-05-23 22:14:44 +0000 |
commit | cf2b16b8dc2a030751a2bc0e6c39152ef89dd66a (patch) | |
tree | 7e118fd6c6cdc757f157deaf1fb6bf80f2e127b8 /Auth | |
parent | 0a58ec4c1d3cc96b249147e4e2554a83ff80f725 (diff) | |
download | php-openid-cf2b16b8dc2a030751a2bc0e6c39152ef89dd66a.zip php-openid-cf2b16b8dc2a030751a2bc0e6c39152ef89dd66a.tar.gz php-openid-cf2b16b8dc2a030751a2bc0e6c39152ef89dd66a.tar.bz2 |
[project @ Add toHTML methods. Server.toFormMarkup passes through form attributes]
Diffstat (limited to 'Auth')
-rw-r--r-- | Auth/OpenID.php | 9 | ||||
-rw-r--r-- | Auth/OpenID/Consumer.php | 18 | ||||
-rw-r--r-- | Auth/OpenID/Server.php | 19 |
3 files changed, 44 insertions, 2 deletions
diff --git a/Auth/OpenID.php b/Auth/OpenID.php index 41e850b..0c071b9 100644 --- a/Auth/OpenID.php +++ b/Auth/OpenID.php @@ -557,5 +557,14 @@ class Auth_OpenID { $message = call_user_func_array('sprintf', $args); error_log($message); } + + function autoSubmitHTML($form) + { + return("<html>". + "<body onload='document.forms[0].submit();'>". + $form . + "</body>". + "</html>"); + } } ?> diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php index d5fd53f..3619e5a 100644 --- a/Auth/OpenID/Consumer.php +++ b/Auth/OpenID/Consumer.php @@ -1935,6 +1935,24 @@ class Auth_OpenID_AuthRequest { $form_tag_attrs); } + /** + * Get a complete html document that will autosubmit the request + * to the IDP. + * + * Wraps formMarkup. See the documentation for that function. + */ + function htmlMarkup($realm, $return_to=null, $immediate=false, + $form_tag_attrs=null) + { + $form = $this->formMarkup($realm, $return_to, $immediate, + $form_tag_attrs); + + if (Auth_OpenID::isFailure($form)) { + return $form; + } + return Auth_OpenID::autoSubmitHTML($form); + } + function shouldSendRedirect() { return $this->endpoint->compatibilityMode(); diff --git a/Auth/OpenID/Server.php b/Auth/OpenID/Server.php index 0d91769..70283a3 100644 --- a/Auth/OpenID/Server.php +++ b/Auth/OpenID/Server.php @@ -205,10 +205,16 @@ class Auth_OpenID_ServerError { 'error' => $this->toString())); } - function toFormMarkup() + function toFormMarkup($form_tag_attrs=null) { $msg = $this->toMessage(); - return $msg->toFormMarkup($this->getReturnTo()); + return $msg->toFormMarkup($this->getReturnTo(), $form_tag_attrs); + } + + function toHTML($form_tag_attrs=null) + { + return Auth_OpenID::autoSubmitHTML( + $this->toFormMarkup($form_tag_attrs)); } function toMessage() @@ -1193,6 +1199,15 @@ class Auth_OpenID_ServerResponse { } /* + * Returns an HTML document containing the form markup for this + * response that autosubmits with javascript. + */ + function toHTML() + { + return Auth_OpenID::autoSubmitHTML($this->toFormMarkup()); + } + + /* * Returns True if this response's encoding is ENCODE_HTML_FORM. * Convenience method for server authors. * |