-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSocialShariffWidget.php
98 lines (82 loc) · 2.23 KB
/
SocialShariffWidget.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* SocialShariffWidget class file.
*
* @author schlypel <[email protected]>
* @link https://github.com/schlypel/Yii-SocialShariff
* @license MIT
*/
/**
* SocialShariffWidget is a wrapper for Shariff, the privacy aware social media button solution from heise.de.
* see: https://github.com/heiseonline/shariff
*
* The following example shows how to use SocialShariffWidget:
*
*
<pre>
$this->widget('ext.socialShariff.CoinSliderWidget', array(
'theme' => 'white',
'orientation' => 'vertical'
));
</pre>
*
*
*/
class SocialShariffWidget extends CWidget {
/**
* @var string name of theme (white, gray, none)
*/
public $theme = 'white';
/**
* @var string orientation of buttons
*/
public $orientation = 'vertical';
/**
* @var bool if info button shall be shown
*/
public $showInfo = true;
/**
* @var bool fontawesome allready loaded
*/
public $loadFA = false;
/**
* @var bool jQuery allready loaded
*/
public $loadJQ = false;
/**
* @var string holds the path to wiget assets
*/
private $_assets;
public function init() {
if ($this->_assets === null) {
$assetsPath = Yii::getPathOfAlias('ext.socialShariff.assets');
$this->_assets = Yii::app()->getAssetManager()->publish($assetsPath);
}
Yii::app()->clientScript->registerScriptFile($this->_assets . '/' . $this->getScriptName(), CClientScript::POS_END);
Yii::app()->clientScript->registerCssFile($this->_assets . '/' . $this->getStylesheetName());
if (!$this->showInfo) {
Yii::app()->clientScript->registerCss('hide-shariff-info', '.shariff ul li.shariff-button.info {display: none;}');
}
}
public function run() {
$this->render('socialShariff', array(
'theme' => $this->theme,
'orientation' => $this->orientation
));
}
/**
*
* @return string
*/
private function getStylesheetName() {
return $this->loadFA ? 'shariff.complete.css' : 'shariff.min.css';
}
/**
*
* @return string
*/
private function getScriptName() {
return $this->loadJQ ? 'shariff.complete.js' : 'shariff.min.js';
}
}
?>