hostbox/nette-component-social-plugins

Nette 框架的社交插件组件

v1.5.2 2014-08-29 17:07 UTC

This package is not auto-updated.

Last update: 2024-09-24 01:37:00 UTC


README

支持 Facebook、Twitter、Google+、LinkedIn 和 Pinterest

Facebook

  • 动态流
  • 评论
  • 嵌入式帖子
  • 脸谱
  • 关注按钮
  • 点赞框
  • 点赞按钮
  • 发送按钮
  • 分享按钮

Twitter

  • 关注按钮
  • 哈希标签按钮
  • 提及按钮
  • 分享按钮
  • 嵌入式时间轴
  • 嵌入式收藏夹
  • 嵌入式搜索

Google+

  • +1 按钮
  • 分享按钮
  • 个人资料徽章
  • 页面徽章
  • 社区徽章

LinkedIn

  • 公司内幕
  • 公司简介
  • 成员简介
  • 分享按钮
  • 推荐按钮

Pinterest

  • Pin It 按钮
  • 关注按钮
  • Pin 小部件
  • 个人资料小部件
  • 版块小部件

包安装

安装 Social Plugins 的最佳方式是使用 Composer

$ composer require hostbox/nette-component-social-plugins

Packagist - 版本

Nette 论坛(cs)- 插件部分

Nette 扩展

或者在项目中手动编辑 composer.json

"require": {
    "hostbox/nette-component-social-plugins": "v1.5.0"
}

组件安装

config.neon

services:
    # Configs
    - HostBox\Components\Facebook\SocialPlugins\Config('facebookAppId')
    - HostBox\Components\Twitter\SocialPlugins\Config
    - HostBox\Components\Google\SocialPlugins\Config
    # Factories
    - HostBox\Components\Facebook\SocialPlugins\FacebookFactory
    - HostBox\Components\Twitter\SocialPlugins\TwitterFactory
    - HostBox\Components\Google\SocialPlugins\GoogleFactory
    - HostBox\Components\Pinterest\SocialPlugins\PinterestFactory

表示器

use HostBox\Components\Facebook\SocialPlugins\LikeBox;
use HostBox\Components\Google\SocialPlugins\GoogleFactory;
use HostBox\Components\Google\SocialPlugins\PlusOneButton;
use HostBox\Components\Pinterest\SocialPlugins\PinItButton;
use HostBox\Components\Pinterest\SocialPlugins\PinterestFactory;
use HostBox\Components\Twitter\SocialPlugins\FollowButton;
use HostBox\Components\Twitter\SocialPlugins\TwitterFactory;

class HomepagePresenter extends BasePresenter {

    /** @var FacebookFactory */
    protected $facebookFactory;

    /** @var TwitterFactory */
    protected $twitterFactory;

    /** @var GoogleFactory */
    protected $googleFactory;

    /** @var PinterestFactory */
    protected $pinterestFactory;

    /**
     * @var LinkedInFactory
     * @inject
     */
    public $linkedInFactory;

    public function __construct(FacebookFactory $facebookFactory, TwitterFactory $twitterFactory, GoogleFactory $googleFactory, PinterestFactory $pinterestFactory) {
        $this->facebookFactory = $facebookFactory;
        $this->twitterFactory = $twitterFactory;
        $this->googleFactory = $googleFactory;
        $this->pinterestFactory = $pinterestFactory;
    }

    // component create by Factory
    public function createComponentFacebookLikeButton() {
        return $this->facebookFactory->createLikeButton();
    }

    // default settings by factory function parameter
    public function createComponentFacebookLikeBox() {
        return $this->facebookFactory->createLikeBox(array(
            'colorScheme' => LikeBox::COLOR_SCHEME_DARK,
            'showFaces' => TRUE
        ));
    }

    // by component function parameter
    public function createComponentTwitterShareButton() {
        $component = $this->twitterFactory->createFollowButton();
        $component->assign(array(
            'size' => FollowButton::SIZE_LARGE,
            'showCount' => TRUE
        ));

        return $component;
    }

    // by component variable
    public function createComponentGooglePlusOneButton() {
        $component = $this->googleFactory->createPlusOneButton();
        $component->size = PlusOneButton::SIZE_SMALL;

        return $component;
    }

    public function createComponentLinkedInShareButton() {
        return $this->linkedInFactory->createShareButton();
    }

    public function createComponentPinterestFollowButton() {
        return $this->pinterestFactory->createFollowButton(array(
            'userName' => 'pinterest',
            'text' => 'Pinterest'
        ));
    }
}

模板

{control facebookLikeButton}

// temporary(only for this render) settings editing in Template
{control facebookLikeButton, layout => 'box_count', showFaces => true}

{control facebookLikeBox}
{control twitterShareButton}
{control googlePlusOneButton}
{control linkedInShareButton}
{control pinterestFollowButton}

{control facebookLikeButton:jsScript}
{control twitterShareButton:jsScript}
{control googlePlusOneButton:jsScript}
{control linkedInShareButton:jsScript}
{control pinterestFollowButton:jsScript}