| Current Path : /var/www/plugins/content/yendifvideoshare/ |
| Current File : /var/www/plugins/content/yendifvideoshare/yendifvideoshare.php |
<?php
/**
* @version 1.2.9
* @package Com_YendifVideoShare
* @author PluginsWare Interactive Pvt. Ltd <admin@yendifplayer.com>
* @copyright Copyright (c) 2012 - 2021 PluginsWare Interactive Pvt. Ltd. All Rights Reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Prevent direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
if ( ! defined( 'DS' ) ) {
define( 'DS', DIRECTORY_SEPARATOR );
}
require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_yendifvideoshare' . DS . 'libraries' . DS . 'player.php';
class plgContentYendifVideoShare extends JPlugin {
protected $autoloadLanguage = true;
public function onContentPrepare( $context, &$article, &$params, $page = 0 ) {
// Don't run this plugin when the content is being indexed
if ( $context === 'com_finder.indexer' ) {
return;
}
// Simple performance check to determine whether bot should process further
if ( strpos( $article->text, 'yendifplayer' ) === false ) {
return;
}
// Expression to search for
$regex = '/{yendifplayer\s*.*?}/i';
// Find all instances of plugin and put in $matches
preg_match_all( $regex, $article->text, $matches );
$this->process( $article, $matches[0], $regex );
}
private function process( $article, $matches, $regex ) {
foreach ( $matches as $match ) {
$query = str_replace( '{yendifplayer', '', $match );
$query = str_replace( '}', '', $query );
$query = str_replace( '"', '', $query );
$query = str_replace( "'", '', $query );
$query = strip_tags( $query );
$query = trim( $query );
$query = explode( ' ', $query );
$query = implode( '&', $query );
$player = $this->load( $query );
$article->text = str_replace( $match, $player, $article->text );
}
// Removes the left tags
$article->text = preg_replace( $regex, '', $article->text );
}
private function load( $query ) {
parse_str( $query, $params );
if ( isset( $params['catid'] ) && ! empty( $params['catid'] ) ) {
jimport( 'joomla.application.module.helper' );
$document = JFactory::getDocument();
$renderer = $document->loadRenderer( 'module' );
return $renderer->render( JModuleHelper::getModule( 'mod_yendifvideoshare_playlist' ), $params );
}
return YendifVideoSharePlayer::load( $params );
}
}