Help OpenID module make its little form

This commit is contained in:
Evan Prodromou 2009-01-23 02:17:29 +01:00
parent 9a4333f5f3
commit f54f0a179a

View File

@ -184,15 +184,13 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
// Display an error if the form markup couldn't be generated; // Display an error if the form markup couldn't be generated;
// otherwise, render the HTML. // otherwise, render the HTML.
if (Auth_OpenID::isFailure($form_html)) { if (Auth_OpenID::isFailure($form_html)) {
$this->show_form(sprintf(_('Could not create OpenID form: %s'), $form_html->message)); common_server_error(sprintf(_('Could not create OpenID form: %s'), $form_html->message));
} else { } else {
common_show_header(_('OpenID Auto-Submit'), null, null, '_oid_print_instructions'); $action = new AutosubmitAction(); // see below
common_raw($form_html); $action->form_html = $form_html;
common_element('script', null, $action->form_id = $form_id;
'$(document).ready(function() { ' . $action->prepare(array('action' => 'autosubmit'));
' $("#'. $form_id .'").submit(); '. $action->handle(array('action' => 'autosubmit'));
'});');
common_show_footer();
} }
} }
} }
@ -251,3 +249,29 @@ function oid_update_user(&$user, &$sreg)
return true; return true;
} }
class AutosubmitAction extends Action
{
var $form_html = null;
var $form_id = null;
function handle($args)
{
parent::handle($args);
$this->showPage();
}
function title()
{
return _('OpenID Auto-Submit');
}
function showContent()
{
$this->raw($this->form_html);
$this->element('script', null,
'$(document).ready(function() { ' .
' $(\'#'. $this->form_id .'\').submit(); '.
'});');
}
}