当前位置: 首页>>代码示例>>PHP>>正文


PHP EasyBlogHelper::getFirstImage方法代码示例

本文整理汇总了PHP中EasyBlogHelper::getFirstImage方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyBlogHelper::getFirstImage方法的具体用法?PHP EasyBlogHelper::getFirstImage怎么用?PHP EasyBlogHelper::getFirstImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EasyBlogHelper的用法示例。


在下文中一共展示了EasyBlogHelper::getFirstImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: googleone

    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;
    }
开发者ID:alexinteam,项目名称:joomla3,代码行数:64,代码来源:socialbutton.php

示例2: getHTML

    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;
    }
开发者ID:Tommar,项目名称:vino2,代码行数:62,代码来源:pinterest.php


注:本文中的EasyBlogHelper::getFirstImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。