![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Soon/Social/Block/Catalog/Product/ |
<?php /** * This file is part of Soon_Social for Magento. * * @license All rights reserved * @author Antoine Kociuba <[email protected]> <@antoinekociuba> * @category Soon * @package Soon_Social * @copyright Copyright (c) 2015 Agence Soon (http://www.agence-soon.fr) */ namespace Soon\Social\Block\Catalog\Product; use Magento\Framework\View\Element\Template; use Magento\Framework\View\Element\Template\Context; use Soon\Social\Helper\Catalog\Product as ProductHelper; use Soon\Social\Helper\Data as SocialHelper; /** * Catalog_Product_Links Block * @package Soon_Social */ class Links extends Template { /** * Template filename for this block * * @const TEMPLATE string */ const TEMPLATE = 'Soon_Social::catalog/product/links.phtml'; // Agence Soon Tag NEW_CONST // Agence Soon Tag NEW_VAR /** * @var \Soon\Social\Helper\Catalog\Product */ protected $_productHelper; /** * @var \Soon\Social\Helper\Data */ protected $_socialHelper; /** * Links constructor. * @param Context $context * @param ProductHelper $productHelper * @param SocialHelper $socialHelper * @param array $data */ public function __construct( Context $context, ProductHelper $productHelper, SocialHelper $socialHelper, array $data = [] ) { parent::__construct($context, $data); $this->_productHelper = $productHelper; $this->_socialHelper = $socialHelper; } /** * Get Facebook share Url * * @return null|string */ public function getFacebookShareUrl() { if (!$this->_socialHelper->getPlatformProductPageActivation('facebook')) { return null; } return $this->escapeUrl("https://www.facebook.com/sharer/sharer.php?u={$this->_getProductAttribute('url')}"); } /** * Get Twitter share Url * * @return null|string */ public function getTwitterShareUrl() { if (!$this->_socialHelper->getPlatformProductPageActivation('twitter')) { return null; } $url = "http://twitter.com/intent/tweet" . "?text={$this->_getTitle()}" . "&url={$this->_getProductAttribute('url')}"; if ($twitterUsername = urlencode($this->_socialHelper->getStoreConfig('twitter/username'))) { $url .= "&via={$twitterUsername}"; } return $this->escapeUrl($url); } /** * Get Pinterest Url * * @return string */ public function getPinterestUrl() { if (!$this->_socialHelper->getPlatformProductPageActivation('pinterest')) { return null; } $url = "https://www.pinterest.com/pin/create/button/" . "?url={$this->_getProductAttribute('url')}"; if ($description = $this->_getProductAttribute('description')) { $url .= "&description={$description}"; } if ($image = $this->_getProductAttribute('image')) { $url .= "&media={$image}"; } return $this->escapeUrl($url); } /** * Get LinkedIn share Url * * @return string */ public function getLinkedInShareUrl() { if (!$this->_socialHelper->getPlatformProductPageActivation('linkedin')) { return null; } $url = "https://www.linkedin.com/shareArticle" . "?mini=true" . "&url={$this->_getProductAttribute('url')}"; if ($title = $this->_getTitle()) { $url .= "&title={$title}"; } if ($description = $this->_getProductAttribute('description')) { $url .= "&summary={$description}"; } return $this->escapeUrl($url); } /** * @return \Magento\Catalog\Model\Product|mixed * @throws \Exception */ public function getProduct() { return $this->_productHelper->getProduct(); } /** * Get current title * * @return null|string */ protected function _getTitle() { if ($head = $this->getLayout()->getBlock('head')) { return rawurlencode($this->escapeQuote($head->getTitle())); } return null; } /** * Get product attribute * * @param $attributeName * * @return string */ protected function _getProductAttribute($attributeName) { return $this->_productHelper->getProductAttribute($attributeName, true); } /** * Prepare HTML * * @return string */ protected function _toHtml() { if (!$this->getProduct()) { return null; } return parent::_toHtml(); } // Agence Soon Tag NEW_METHOD }