Source of file SocialSharePageExtension.php
Size: 1,219 Bytes - Last Modified: 2021-12-24T06:43:35+00:00
/var/www/docs.ssmods.com/process/src/code/extension/SocialSharePageExtension.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | <?php /** * SocialSharePageExtension * * @package silverstripe-social-sharer * @license MIT License https://github.com/cyber-duck/silverstripe-social-sharerblob/master/LICENSE * @author <andrewm@cyber-duck.co.uk> **/ class SocialSharePageExtension extends DataExtension { /** * Render the social widget * * @since version 1.0.0 * * @return string **/ public function SocialShareWidget() { Requirements::css(SOCIAL_SHARER.'/css/social-sharer.css'); Requirements::javascript(SOCIAL_SHARER.'/javascript/social-sharer.js'); return $this->owner ->customise([ 'SocialNetworks' => SocialShareNetwork::get() ]) ->renderWith('SocialShareWidget'); } /** * Replace the path string variables with the page link and title * * @since version 1.0.0 * * @param string $path * * @return string **/ public function SocialSharerUrl($path) { $find = ['{$AbsoluteLink}', '{$Title}']; $replace = [urlencode($this->owner->AbsoluteLink()), urlencode($this->owner->Title)]; return str_replace($find, $replace, $path); } } |