Your IP : 216.73.216.240
<?php
/*
* @package Tech Fry Library
* @license https://www.gnu.org/licenses/gpl-3.0.en.html
*/
namespace TechFry\Library\View\Others;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;
class Social
{
public static function get_output($channels, $config = array())
{
// config - show_names, main_class, a_class
if (empty($channels))
{
return;
}
$config = (array) $config;
$doc = Factory::getDocument();
$uri = Uri::getInstance();
$current_url = $uri->toString();
$page_title = $doc->getTitle();
$output = '';
$output .= '<div class="' . $config['main_class'] . '">';
// https://www.facebook.com/sharer/sharer.php?u=
if (\in_array('facebook', $channels))
{
$output .= '<a class="' . $config['a_class'] . '" style="" onClick="window.open(\'https://www.facebook.com/sharer/sharer.php?u=' . $current_url . '\',\'Facebook\',\'width=600,height=300,left=\'+(screen.availWidth/2-300)+\',top=\'+(screen.availHeight/2-150)+\'\'); return false;" href="http://www.facebook.com/sharer.php?u=' . $current_url . '">';
$output .= '<i class="' . $config['fb_icon'] . '" aria-hidden="true"></i>';
if ($config['show_names'])
{
$output .= ' <span>' . $config['fb_text'] . '</span>';
}
$output .= '</a>';
}
// https://twitter.com/intent/tweet?text=
if (\in_array('twitter', $channels))
{
$output .= '<a class="' . $config['a_class'] . '" onClick="window.open(\'https://twitter.com/intent/tweet?text=' . urlencode($current_url) . '&text=' . str_replace(" ", "%20", $page_title) . '\',\'Twitter share\',\'width=600,height=300,left=\'+(screen.availWidth/2-300)+\',top=\'+(screen.availHeight/2-150)+\'\'); return false;" href="http://twitter.com/share?url=' . $current_url . '&text=' . str_replace(" ", "%20", $page_title) . '">';
$output .= '<i class="' . $config['t_icon'] . '" aria-hidden="true"></i>';
if ($config['show_names'])
{
$output .= ' <span>' . $config['t_text'] . '</span>';
}
$output .= '</a>';
}
// https://www.linkedin.com/shareArticle?mini=true&url=
if (\in_array('linkedin', $channels))
{
$output .= '<a class="' . $config['a_class'] . '" onClick="window.open(\'https://www.linkedin.com/shareArticle?mini=true&url=' . $current_url . '\',\'Linkedin\',\'width=585,height=666,left=\'+(screen.availWidth/2-292)+\',top=\'+(screen.availHeight/2-333)+\'\'); return false;" href="http://www.linkedin.com/shareArticle?mini=true&url=' . $current_url . '" >';
$output .= '<i class="' . $config['li_icon'] . '" aria-hidden="true"></i>';
if ($config['show_names'])
{
$output .= ' <span>' . $config['li_text'] . '</span>';
}
$output .= '</a>';
}
// https://pinterest.com/pin/create/button/?url=
if (in_array('pinterest', $channels))
{
$output .= '<a class="' . $config['a_class'] . '" onClick="window.open(\'https://pinterest.com/pin/create/button/?url=' . $current_url . '&description=' . $page_title . '\',\'Pinterest\',\'width=585,height=666,left=\'+(screen.availWidth/2-292)+\',top=\'+(screen.availHeight/2-333)+\'\'); return false;" href="http://pinterest.com/pin/create/button/?url=' . $current_url . '&description=' . $page_title . '" >';
$output .= '<i class="' . $config['p_icon'] . '" aria-hidden="true"></i>';
if ($config['show_names'])
{
$output .= ' <span>' . $config['p_text'] . '</span>';
}
$output .= '</a>';
}
// https://api.whatsapp.com/send?text=
if (in_array('whatsapp', $channels))
{
$output .= '<a class="' . $config['a_class'] . '" href="whatsapp://send?text=' . $current_url . '" >';
$output .= '<i class="' . $config['wa_icon'] . '" aria-hidden="true"></i>';
if ($config['show_names'])
{
$output .= ' <span>' . $config['wa_text'] . '</span>';
}
$output .= '</a>';
}
$output .= '</div>';
return $output;
}
}