SNSView.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2020-02-20 10:41
  7. */
  8. namespace frontend\widgets;
  9. use Yii;
  10. use common\components\Feehi;
  11. use yii\helpers\Url;
  12. class SNSView extends \yii\base\Widget
  13. {
  14. public $template = '<div class="textwidget">
  15. <div class="social">
  16. <a href="{%WEIBO%}" rel="external nofollow" title="" target="_blank" data-original-title="新浪微博"><i class="sinaweibo fa fa-weibo"></i></a>
  17. <a href="{%FACEBOOK%}" rel="external nofollow" title="" target="_blank" data-original-title="Facebook"><i class="facebook fa fa-facebook"></i></a>
  18. <a class="weixin" data-original-title="" title=""><i class="weixins fa fa-weixin"></i>
  19. <div class="weixin-popover">
  20. <div class="popover bottom in">
  21. <div class="arrow"></div>
  22. <div class="popover-title">{%FOLLOW_WECHAT%}{%WECHAT%}</div>
  23. <div class="popover-content"><img src="{%WECHAT_IMG%}"></div>
  24. </div>
  25. </div>
  26. </a>
  27. <a href="mailto:{%EMAIL%}" rel="external nofollow" title="" target="_blank" data-original-title="Email"><i class="email fa fa-envelope-o"></i></a>
  28. <a href="http://wpa.qq.com/msgrd?v=3&amp;uin={%QQ%}&amp;site=qq&amp;menu=yes" rel="external nofollow" title="" target="_blank" data-original-title="联系QQ"><i class="qq fa fa-qq"></i></a>
  29. <a href="{%RSS%}" rel="external nofollow" target="_blank" title="" data-original-title="订阅本站"><i class="rss fa fa-rss"></i></a>
  30. </div>
  31. </div>';
  32. public function run()
  33. {
  34. /** @var Feehi $feehi */
  35. $feehi = Yii::$app->get("feehi");
  36. $wechatImg = Yii::$app->getRequest()->getBaseUrl() . "/static/images/weixin.jpg";
  37. $template = str_replace("{%WEIBO%}", $feehi->weibo, $this->template);
  38. $template = str_replace("{%FACEBOOK%}", $feehi->facebook, $template);
  39. $template = str_replace("{%WECHAT%}", $feehi->wechat, $template);
  40. $template = str_replace("{%WECHAT_IMG%}", $wechatImg, $template);
  41. $template = str_replace("{%EMAIL%}", $feehi->email, $template);
  42. $template = str_replace("{%FOLLOW_WECHAT%}", Yii::t("frontend", "Follow Wechat"), $template);
  43. $template = str_replace("{%QQ%}", $feehi->qq, $template);
  44. $template = str_replace("{%RSS%}", Url::to(['article/rss']), $template);
  45. return $template;
  46. }
  47. }