예제 #1
0
    public function googleone()
    {
        $config = EasyBlogHelper::getConfig();
        $document = JFactory::getDocument();
        $frontpage = $this->isFrontend;
        $pos = $this->position;
        $googleone = !$frontpage && $config->get('main_googleone') || $frontpage && $config->get('main_googleone_frontpage', $config->get('social_show_frontpage')) && $config->get('main_googleone');
        $socialFrontEnd = $config->get('main_googleone_frontpage', 0);
        $html = '';
        if ($googleone) {
            $size = $config->get('main_googleone_layout');
            $dataURL = $this->_getDataURL();
            $dataTitle = $this->_getDataTitle();
            $buttonSize = 'social-button-';
            switch ($size) {
                case 'tall':
                    $buttonSize .= 'large';
                    break;
                case 'medium':
                default:
                    $buttonSize .= 'small';
                    break;
            }
            // Add snippet info into headers
            $document = JFactory::getDocument();
            $meta = EasyBlogHelper::getTable('Meta', 'Table');
            $meta->loadByType(META_TYPE_POST, $this->blog->id);
            $document->addCustomTag('<meta itemprop="name" content="' . $this->blog->title . '" />');
            if (!empty($meta->description)) {
                $meta->description = EasyBlogStringHelper::escape($meta->description);
                // Remove JFBConnect codes.
                $pattern = '/\\{JFBCLike(.*)\\}/i';
                $meta->description = preg_replace($pattern, '', $meta->description);
                $document->addCustomTag('<meta itemprop="description" content="' . $meta->description . '" />');
            } else {
                $maxContentLen = 350;
                $text = strip_tags($this->blog->intro . $this->blog->content);
                $text = JString::strlen($text) > $maxContentLen ? JString::substr($text, 0, $maxContentLen) . '...' : $text;
                // Remove JFBConnect codes.
                $pattern = '/\\{JFBCLike(.*)\\}/i';
                $text = preg_replace($pattern, '', $text);
                $text = EasyBlogStringHelper::escape($text);
                $document->addCustomTag('<meta itemprop="description" content="' . $text . '" />');
            }
            $image = EasyBlogHelper::getFirstImage($this->blog->intro . $this->blog->content);
            if ($image !== false) {
                $document->addCustomTag('<meta itemprop="image" content="' . $image . '" />');
            }
            $placeholder = 'sb-' . rand();
            $html .= '<div class="social-button ' . $buttonSize . ' google-plusone"><span id="' . $placeholder . '"></span></div>';
            // TODO: Verify $socialFrontEnd, what is it used for.
            // if( ! $socialFrontEnd )
            // $googleHTML	.= '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>';
            // $googleHTML	.= '<g:plusone size="' . $size . '" href="' . $dataURL . '"></g:plusone>';
            if ($this->isBottom) {
                $html = '<div class="socialbutton-vertical align' . $pos . '">' . $html . '</div>';
            }
            $html .= EasyBlogHelper::addScriptDeclarationBookmarklet('$("#' . $placeholder . '").bookmarklet("googlePlusOne", {
				href: "' . $dataURL . '",
				size: "' . $size . '"
			});');
        }
        return $html;
    }
예제 #2
0
파일: pinterest.php 프로젝트: Tommar/vino2
    public function getHTML($frontpage, $position, $blog, $teamIdLink)
    {
        $config = EasyBlogHelper::getConfig();
        $enabled = !$frontpage && $config->get('main_pinit_button') || $frontpage && $config->get('main_pinit_button_frontpage', $config->get('social_show_frontpage')) && $config->get('main_pinit_button');
        if (!$enabled) {
            return false;
        }
        $style = $config->get('main_pinit_button_style');
        $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
        // @task: Test for blog image first.
        $image = '';
        if ($blog->getImage()) {
            $image = $blog->getImage()->getSource('frontpage');
        }
        if (empty($image)) {
            // Fetch the first image of the blog post
            $image = EasyBlogHelper::getFirstImage($blog->intro . $blog->content);
            // @rule: Test if there's any ->images
            if (isset($blog->images) && $blog->images) {
                $image = $blog->images[0];
            }
        }
        // @rule: If post doesn't contain any images, do not show button.
        if (!$image) {
            return false;
        }
        $buttonSize = 'social-button-';
        switch ($style) {
            case 'vertical':
                $buttonSize .= 'large';
                break;
            case 'horizontal':
                $buttonSize .= 'small';
                break;
            default:
                $buttonSize .= 'plain';
                break;
        }
        // @TODO: Configurable maximum length
        $contentLength = 350;
        $text = $blog->intro . $blog->content;
        $text = nl2br($text);
        $text = strip_tags($text);
        $text = trim(preg_replace('/\\s+/', ' ', $text));
        $text = JString::strlen($text) > $contentLength ? JString::substr($text, 0, $contentLength) . '...' : $text;
        $theme = new CodeThemes();
        $title = $blog->title;
        // Urlencode all the necessary properties.
        $url = urlencode($url);
        $text = urlencode($text);
        $image = urlencode($image);
        $placeholder = 'sb-' . rand();
        $output = '<div class="social-button ' . $buttonSize . ' pinterest"><span id="' . $placeholder . '"></span></div>';
        $output .= EasyBlogHelper::addScriptDeclarationBookmarklet('$("#' . $placeholder . '").bookmarklet("pinterest", {
					url: "' . $url . '",
					style: "' . $style . '",
					media: "' . $image . '",
					title: "' . $title . '",
					description: "' . $text . '"
				});');
        return $output;
    }