Your IP : 216.73.216.158


Current Path : /home/megadansyp/www/plugins/fwgallery/social/
Upload File :
Current File : /home/megadansyp/www/plugins/fwgallery/social/social.php

<?php
/**
 * FW Gallery 2.3.0
 * @copyright (C) 2020 Fastw3b
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link http://www.fastw3b.net/ Official website
 **/

defined( '_JEXEC' ) or die( 'Restricted access' );

class plgFwGallerySocial extends JPlugin {
	function __construct(&$subject, $config = array()) {
		JFactory::getLanguage()->load('plg_fwgallery_social', JPATH_ADMINISTRATOR);
		parent::__construct($subject, $config);
	}
	function onshowConfigFileListingDesignExtraFields($ext, $row) {
		if ($ext != 'com_fwgallery') return;

		echo fwgHelper::loadTemplate('admin.social.show_config_file_listing_design_extra_fields', array(
			'view' => $this,
			'row' => $row
		), dirname(__FILE__).'/layouts/');
	}
	function onshowConfigFileDesignExtraFields($ext, $row) {
		if ($ext != 'com_fwgallery') return;

		echo fwgHelper::loadTemplate('admin.social.show_config_file_design_extra_fields', array(
			'view' => $this,
			'row' => $row,
			'name' => 'config'
		), dirname(__FILE__).'/layouts/');
	}
	function onshowConfigSlideshowDesignExtraFields($ext, $row, $name) {
		if ($ext != 'com_fwgallery') return;

		echo fwgHelper::loadTemplate('admin.social.show_slideshow_file_listing_design_extra_fields', array(
			'view' => $this,
			'row' => $row,
			'name' => $name
		), dirname(__FILE__).'/layouts/');
	}
	function oncollectSlideshowParamsAliases($ext, &$aliases) {
		if ($ext != 'com_fwgallery') return;

		$aliases['show_files_social'] = array('slideshow_show_files_social'=>'1'); 
	}
	function onshowCategoryEditFileListingDesignExtraFields($ext, $row) {
		if ($ext != 'com_fwgallery') return;

		echo fwgHelper::loadTemplate('admin.social.show_category_edit_file_listing_design_extra_fields', array(
			'view' => $this,
			'row' => $row
		), dirname(__FILE__).'/layouts/');
	}
	function onshowCategoryEditFileDesignExtraFields($ext, $row) {
		if ($ext != 'com_fwgallery') return;

		echo fwgHelper::loadTemplate('admin.social.show_category_edit_file_design_extra_fields', array(
			'view' => $this,
			'row' => $row
		), dirname(__FILE__).'/layouts/');
	}
	/* showConfigExtraCards */
	function onshowConfigExtraCards($ext, $row) {
		if ($ext != 'com_fwgallery') return;
		return fwgHelper::loadTemplate('admin.social.show_config_extra_cards', array(
			'view' => $this,
			'row' => $row
		), dirname(__FILE__).'/layouts/');
	}
	function onshowFilesListingExtraFields($ext, $displayData) {
		if ($ext != 'com_fwgallery' or fwgHelper::pluginDisabledViaMenu('social')) return;
		$params = $displayData['view']->params;

		if ($params->get('show_files_social', 1)) {
			echo fwgHelper::loadTemplate('site.social.awesome', array_merge($displayData, array(
				'social_class' => 'fwmg-file-share'
			)), dirname(__FILE__).'/layouts/');
		}
	}
	function onshowFileExtraFields($ext, $displayData) {
		if ($ext != 'com_fwgallery' or fwgHelper::pluginDisabledViaMenu('social')) return;
		$params = $displayData['view']->params;

		if ($params->get('show_file_social', 1)) {
			echo fwgHelper::loadTemplate('site.social.awesome', array_merge($displayData, array(
				'social_class' => 'fwmg-file-share'
			)), dirname(__FILE__).'/layouts/');
		}
	}
	function onbeforeFileDisplay($ext, $row, &$params) {
		if ($ext != 'com_fwgallery' or empty($row->id) or fwgHelper::pluginDisabledViaMenu('social')) return;
        $doc = JFactory::getDocument();
		if (method_exists($doc, 'addCustomTag')) {
			$uri = JURI::getInstance();
			$doc->addCustomTag('<meta name="twitter:card" content="summary_large_image">');
			$doc->addCustomTag('<meta name="twitter:image" content="'.fwgHelper::route('index.php?option=com_fwgallery&view=item&layout=img&format=raw&w=600&h=400&id='.$row->id.':'.$row->alias, true, -1).'">');
			$doc->addCustomTag('<meta property="og:url" content="'.$uri->toString().'">');
			$doc->addCustomTag('<meta property="og:image" content="'.fwgHelper::route('index.php?option=com_fwgallery&view=item&layout=img&format=raw&w=600&h=400&id='.$row->id.':'.$row->alias, true, -1).'">');
			if ($row->name) {
				$doc->addCustomTag('<meta name="twitter:title" content="'.$this->escape($row->name).'">');
				$doc->addCustomTag('<meta property="og:title" content="'.$this->escape($row->name).'">');
			}
			if ($row->descr) {
				$descr = $row->descr;
				JFactory::getApplication()->triggerEvent('ongetAdditionalInfoShareDescription', array('com_fwgallery', $row, &$descr));
				$doc->addCustomTag('<meta name="twitter:description" content="'.str_replace(array('"', "\r", "\n"), array('&quot;', ' ',  ' '), strip_tags($descr)).'">');
				$doc->addCustomTag('<meta property="og:description" content="'.str_replace(array('"', "\r", "\n"), array('&quot;', ' ',  ' '), strip_tags($descr)).'">');
			}
		}
	}
	function escape($text) {
		return htmlspecialchars($text);
	}
}