forked from SleepWalker/hoauth
/
HOAuthWidget.php
45 lines (39 loc) · 1.37 KB
/
HOAuthWidget.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* HOAuthWidget provides widgets with button for login with social networs
*
* @uses CWidget
* @version 1.2.1
* @copyright Copyright © 2013 Sviatoslav Danylenko
* @author Sviatoslav Danylenko <dev@udf.su>
* @license PGPLv3 ({@link http://www.gnu.org/licenses/gpl-3.0.html})
* @link https://github.com/SleepWalker/hoauth
*/
/**
* NOTE: If you want to change the order of button it is better to change this order in HybridAuth config.php file
*/
class HOAuthWidget extends CWidget
{
/**
* @var string $route id of module and controller (eg. module/controller) for wich to generate oauth urls
*/
public $route = false;
public function run()
{
if(!$this->route)
$this->route = $this->controller->module ? $this->controller->module->id . '/' . $this->controller->id : $this->controller->id;
require(dirname(__FILE__).'/models/UserOAuth.php');
$config = UserOAuth::getConfig();
$this->registerFiles();
foreach($config['providers'] as $provider => $settings)
if($settings['enabled'])
$this->render('link', array(
'provider' => $provider,
));
}
protected function registerFiles()
{
$assetsUrl = Yii::app()->getAssetManager()->publish(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets',false,-1,YII_DEBUG);
Yii::app()->getClientScript()->registerCssFile($assetsUrl.'/css/zocial.css');
}
}