Your IP : 216.73.216.240


Current Path : /home/juvelize/www/plugins/content/uyguntabs/
Upload File :
Current File : /home/juvelize/www/plugins/content/uyguntabs/uyguntabs.php

<?php
// Uyguntabs Copyright 2012
// Version 1.0
// GNU GPL based on Tabs and Sliders joomlaworks.net

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.plugin.plugin');
jimport('joomla.html.parameter');


class plgContentUyguntabs extends JPlugin {

  // Uygunmedya reference parameters
	var $plg_name								= "uyguntabs";
	var $plg_copyrights_start		= "\n\n<!-- Uygunmedya \"Tab\" Plugin starts here -->\n";
	var $plg_copyrights_end			= "\n<!-- Uygunmedya \"Tab\" Plugin ends here -->\n\n";

	function plgContentUyguntabs( &$subject, $params ){
		parent::__construct( $subject, $params );
	}

	// Joomla! 3.0
	function onContentPrepare($context, &$row, &$params, $page = 0){
		$this->renderTS($row, $params, $page = 0);
	}

	// The main function
	function renderTS(&$row, &$params, $page = 0){

		// API
    $mainframe= &JFactory::getApplication();
		$document = &JFactory::getDocument();

		// Assign paths
		$sitePath = JPATH_SITE;
		$siteUrl  = JURI::root(true);

		$pluginLivePath = JURI::root(true).'/plugins/content/'.$this->plg_name.'/'.$this->plg_name;

		// Simple performance checks to determine whether plugin should process further
		if(!preg_match("#{tab=.+?}|{slide=.+?}|{slider=.+?}#s", $row->text)) return;

    // Check if plugin is enabled
    if(JPluginHelper::isEnabled('content',$this->plg_name)==false) return;

		// Load the plugin language file the proper way
		JPlugin::loadLanguage('plg_content_'.$this->plg_name, JPATH_ADMINISTRATOR);

		// Includes
		require_once(dirname(__FILE__).'/uyguntabs'.'/includes'.'/helper.php');



		// ----------------------------------- Get plugin parameters -----------------------------------

		$plugin =& JPluginHelper::getPlugin('content',$this->plg_name);
		$pluginParams = new JForm( $plugin->params );

		// Parameters
		$template = json_decode('template','Default');
		$tabContentHeight = json_decode('tabContentHeight',0);



		// ----------------------------------- Render the output -----------------------------------

		// Variable cleanups for K2
		if(JRequest::getCmd('format')=='raw'){
			$this->plg_copyrights_start = '';
			$this->plg_copyrights_end = '';
		}

		// Get the current template layout folder
		$pluginTemplateFolder = UyguntabsHelper::getTemplatePath($this->plg_name,$template);

		// Append head includes only when the document is in HTML mode
		if(JRequest::getCmd('format')=='html' || JRequest::getCmd('format')==''){

		

			// JS
			
			JHtml::_('behavior.framework',true);

		$cookie123 = $this->params->get('cookie');
        if ($cookie123 == 1){
			$document->addScript($pluginLivePath.'/includes/js/behaviour.js');
        }else{
			$document->addScript($pluginLivePath.'/includes/js/behaviour.min.js');		
		}

			// CSS
			$document->addStyleSheet($pluginLivePath.'/tmpl/css/template.css');

			if($tabContentHeight){
				$document->addStyleDeclaration('.tabs_tabberlive .tabs_tabbertab {height:'.$tabContentHeight.'px!important;overflow:auto!important;}');
			}

		}

		// --- Tabs ---
		if(JRequest::getCmd('format')!='pdf' || !JRequest::getCmd('print')){
			$b=1;
			unset($tabs);
			if(preg_match_all("/{tab=.+?}{tab=.+?}|{tab=.+?}|{\/tabs}/", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
				foreach($matches[0] as $match) {
					if($b==1 && $match!="{/tabs}") {
						$tabs[] = 1;
						$b=2;
					} elseif($match=="{/tabs}"){
						$tabs[]=3;
						$b=1;
					} elseif(preg_match("/{tab=.+?}{tab=.+?}/", $match)){
						$tabs[]=2;
						$tabs[]=1;
						$b=2;
					} else {
						$tabs[]=2;
					}
				}
			}
			@reset($tabs);
			$tabscount = 0;
			if(preg_match_all("/{tab=.+?}|{\/tabs}/", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
				$tabid=1;
				foreach($matches[0] as $match) {
					if($tabs[$tabscount]==1) {
						$match = str_replace("{tab=", "", $match);
						$match = str_replace("}", "", $match);
						$row->text = str_replace("{tab=".$match."}", $this->plg_copyrights_start.'<div class="tabs_tabber" id="tabs_tab'.$tabid.'"><div class="tabs_tabbertab" title="'.$match.'"><h2><a href="#" name="advtab">'.$match.'</a></h2>', $row->text);
						$tabid++;
					} elseif($tabs[$tabscount]==2) {
						$match = str_replace("{tab=", "", $match);
						$match = str_replace("}", "", $match);
						$row->text = str_replace("{tab=".$match."}", '</div><div class="tabs_tabbertab" title="'.$match.'"><h2><a href="#" name="advtab">'.$match.'</a></h2>', $row->text);
					} elseif($tabs[$tabscount]==3) {
						$row->text = str_replace("{/tabs}", '</div></div><div class="tabs_clr"></div>'.$this->plg_copyrights_end, $row->text);
					}
					$tabscount++;
				}
			}
		} else {
			if(preg_match_all("/{tab=.+?}/", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
				foreach($matches[0] as $match) {
					$match = str_replace("{tab=", "", $match);
					$match = str_replace("}", "", $match);
					$row->text = str_replace("{tab=".$match."}", '<h3>'.$match.'</h3>', $row->text);
					$row->text = str_replace("{/tabs}", '', $row->text);
				}
			}
		}
	}	// End function

} // End class