Browse Source

Fixes #1713.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
011c6c14ae
  1. 6
      extensions/yii/authclient/views/redirect.php
  2. 36
      extensions/yii/authclient/widgets/Choice.php

6
extensions/yii/authclient/views/redirect.php

@ -7,10 +7,10 @@ use yii\helpers\Json;
/* @var $enforceRedirect boolean */
$redirectJavaScript = <<<EOL
function popupWindowRedirect(url, enforceRedirect = true) {
function popupWindowRedirect(url, enforceRedirect) {
if (window.opener) {
window.close();
if (enforceRedirect) {
if (enforceRedirect === undefined || enforceRedirect) {
window.opener.location = url;
}
} else {
@ -35,4 +35,4 @@ $redirectJavaScript .= 'popupWindowRedirect(' . Json::encode($url) . ', ' . Json
document.getElementById('link').style.display = 'none';
</script>
</body>
</html>
</html>

36
extensions/yii/authclient/widgets/Choice.php

@ -18,8 +18,9 @@ use yii\authclient\ClientInterface;
* to get auth clients information.
*
* Example:
* ~~~
* <?= yii\authclient\Choice::widget([
*
* ~~~php
* <?= yii\authclient\widgets\Choice::widget([
* 'baseAuthUrl' => ['site/auth']
* ]); ?>
* ~~~
@ -28,8 +29,8 @@ use yii\authclient\ClientInterface;
* along with using method {@link clientLink()} or {@link createClientUrl()}.
* For example:
*
* ~~~
* <?php $authChoice = yii\authclient\Choice::beginWidget([
* ~~~php
* <?php $authChoice = yii\authclient\widgets\Choice::beginWidget([
* 'baseAuthUrl' => ['site/auth']
* ]); ?>
* <ul>
@ -37,7 +38,7 @@ use yii\authclient\ClientInterface;
* <li><?= $authChoice->clientLink($client); ?></li>
* <?php endforeach; ?>
* </ul>
* <?php yii\authclient\Choice::endWidget(); ?>
* <?php yii\authclient\widgets\Choice::endWidget(); ?>
* ~~~
*
* @see \yii\authclient\AuthAction
@ -51,27 +52,19 @@ use yii\authclient\ClientInterface;
class Choice extends Widget
{
/**
* @var ClientInterface[] auth providers list.
*/
private $_clients;
/**
* @var string name of the auth client collection application component.
* This component will be used to fetch services value if it is not set.
*/
public $clientCollection = 'authClientCollection';
/**
* @var array configuration for the external clients base authentication URL.
*/
private $_baseAuthUrl;
/**
* @var string name of the GET param , which should be used to passed auth client id to URL
* defined by {@link baseAuthUrl}.
* defined by [[baseAuthUrl]].
*/
public $clientIdGetParamName = 'authclient';
/**
* @var array the HTML attributes that should be rendered in the div HTML tag representing the container element.
*/
public $mainContainerHtmlOptions = [
public $options = [
'class' => 'auth-clients'
];
/**
@ -85,6 +78,15 @@ class Choice extends Widget
public $autoRender = true;
/**
* @var array configuration for the external clients base authentication URL.
*/
private $_baseAuthUrl;
/**
* @var ClientInterface[] auth providers list.
*/
private $_clients;
/**
* @param ClientInterface[] $clients auth providers
*/
public function setClients(array $clients)
@ -212,8 +214,8 @@ class Choice extends Widget
ChoiceAsset::register($view);
$view->registerJs("\$('#" . $this->getId() . "').authchoice();");
}
$this->mainContainerHtmlOptions['id'] = $this->getId();
echo Html::beginTag('div', $this->mainContainerHtmlOptions);
$this->options['id'] = $this->getId();
echo Html::beginTag('div', $this->options);
}
/**

Loading…
Cancel
Save