Skip to content

Commit

Permalink
Upgrade to release v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Oct 8, 2014
1 parent 18b74d7 commit c142831
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
6 changes: 5 additions & 1 deletion CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
version 1.0.0
=============
- PSR4 alias change
- (enh #8): Allow language configuration for Facebook, Twitter, and Google plugins.

version 1.0.0
=============

*Date:* 01-Dec-2013

- Initial release
- PSR4 alias change
6 changes: 3 additions & 3 deletions FacebookPlugin.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2013
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
* @package yii2-social
* @version 1.0.0
* @version 1.1.0
*/

namespace kartik\social;
Expand Down Expand Up @@ -109,7 +109,7 @@ protected function registerAssets()
return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId={$this->appId}";
js.src = "//connect.facebook.net/{$this->language}/all.js#xfbml=1&appId={$this->appId}";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
SCRIPT;
Expand Down
22 changes: 10 additions & 12 deletions GooglePlugin.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2013
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
* @package yii2-social
* @version 1.0.0
* @version 1.1.0
*/

namespace kartik\social;

use Yii;
use yii\base\InvalidConfigException;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\web\View;

/**
* Widget to render various Google plugins
Expand Down Expand Up @@ -144,16 +146,12 @@ protected function setPluginOptions($convertLowerCase = true)
protected function registerAssets()
{
$view = $this->getView();
$js = <<< SCRIPT
(function() {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/plusone.js?onload=onLoadCallback';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
SCRIPT;
$view->registerJs($js);
$view->registerJsFile('https://apis.google.com/js/platform.js', [
'position'=>View::POS_HEAD,
'async'=>true,
'defer'=>true
]);
$view->registerJs("\nwindow.___gcfg={lang:'{$this->language}'};\n", View::POS_HEAD);
}

}
5 changes: 3 additions & 2 deletions TwitterPlugin.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2013
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
* @package yii2-social
* @version 1.0.0
* @version 1.1.0
*/

namespace kartik\social;
Expand Down Expand Up @@ -76,6 +76,7 @@ public function init()
parent::init();
$this->tag = ($this->type === self::TWEET) ? 'blockquote' : 'a';
$this->setConfig('twitter');
$this->settings['lang'] = $this->language;
if ($this->type === self::HASHTAG && empty($this->hashTag) && empty($this->options['data-href'])) {
throw new InvalidConfigException("The Twitter 'hashTag' must be set for displaying the 'hashtag' button.");
}
Expand Down
18 changes: 16 additions & 2 deletions Widget.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2013
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
* @package yii2-social
* @version 1.0.0
* @version 1.1.0
*/

namespace kartik\social;
Expand All @@ -20,6 +20,17 @@
*/
class Widget extends \yii\base\Widget
{
private static $defaultLanguage = [
'facebook' => 'en_US',
'twitter' => 'en',
'google' => 'en-US'
];

/**
* @var string the language used in displaying content.
* If not provided, defaults to `en_US`.
*/
public $language;

/**
* @var string the tag for enclosing the plugin. Defaults to 'div'.
Expand Down Expand Up @@ -134,6 +145,9 @@ public function setConfig($widget)
}
}
}
if (empty($this->language) && isset(self::$defaultLanguage[$widget])) {
$this->language = self::$defaultLanguage[$widget];
}
}

/**
Expand Down

0 comments on commit c142831

Please sign in to comment.