<?php
/**
 * @var $url
 * @var $this Controller
 */
// vk - 3082475
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile('http://userapi.com/js/api/openapi.js?52');

$cs->registerCssFile('http://stg.odnoklassniki.ru/share/odkl_share.css');
$cs->registerScriptFile('http://stg.odnoklassniki.ru/share/odkl_share.js');
$cs->registerScript('vk_app_id', 'if(!!window.VK) VK.init({apiId: 3082475, onlyWidgets: true});', CClientScript::POS_HEAD);
$cs->registerScript('odnokl_init', 'ODKL.init();', CClientScript::POS_LOAD);

$id = crc32($url)+rand(1,10000);

$vkOptions = array(
    'type' => 'button',
    'height' => 20,
    'pageTitle'=>strtr($this->getPageTitle(),array('"'=>'')),
    //'pageDescription'=>strtr($this->getPageTitle(),array('"'=>'')),
);
if( Yii::app()->getBaseUrl(true) . Yii::app()->request->getUrl() != $url)
    $vkOptions['pageUrl'] = $url;
$vkOptions = CJavaScript::encode($vkOptions);


$cs->registerScript("vk_like_{$id}", "if(!!window.VK) VK.Widgets.Like(\"vk_like_{$id}\", {$vkOptions});", CClientScript::POS_END);
$cs->registerScript('twitter_btns', <<<JS
!function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (!d.getElementById(id)) {
            js = d.createElement(s);
            js.id = id;
            js.src = "https://platform.twitter.com/widgets.js";
            fjs.parentNode.insertBefore(js, fjs);
        }
    }(document, "script", "twitter-wjs");
JS
    , CClientScript::POS_END);

?>




<div class="soc-share-btn">
    <div class="fb-like" data-href="<?php echo CHtml::encode($url)?>" data-send="false" data-layout="button_count"
         data-width="450" data-show-faces="true"></div>
</div>

<div class="soc-share-btn">
    <div id="vk_like_<?php echo $id;?>"></div>
</div>

<div class="soc-share-btn">
    <a href="https://twitter.com/share"
       class="twitter-share-button"
       data-lang="ru" data-url="<?php echo CHtml::encode($url)?>">
        Tweet</a>
</div>
<!--<div class="soc-share-btn">-->
<!--    <a target="_blank" class="mrc__plugin_uber_like_button" href="http://connect.mail.ru/share?url=--><?php //echo CHtml::encode($url)?><!--" data-mrc-config="{'cm' : '1', 'ck' : '3', 'sz' : '20', 'st' : '3'}">Нравится</a>-->
<!--    <script src="http://cdn.connect.mail.ru/js/loader.js" type="text/javascript" charset="UTF-8"></script>-->
<!--</div>-->

<div class="soc-share-btn">
    <div style="float: left;">
        <a class="odkl-klass-oc" href="<?php echo CHtml::encode($url)?>"
           onclick="_gaq.push(['_trackEvent', 'Social', 'Share', 'Од']); ODKL.Share(this);return false;"><span>0</span></a>
    </div>
</div>