Sindbad~EG File Manager

Current Path : /var/www/ispania.gr/templates/rslibro/classes/
Upload File :
Current File : /var/www/ispania.gr/templates/rslibro/classes/template.php

<?php
/**
 * @package RSLibro!
 * @copyright (C) 2016 www.rsjoomla.com
 * @license GPL, http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die;

require_once dirname(__FILE__).'/widget.php';

class RSTemplate
{
	public $widgets = array();
	
	protected $document;
	protected $root;
	protected $option;
	protected $params;
	protected $absolute_root;
	public $customCSSPath;

	public function __construct($document, $params=null) {
		$this->root				= JUri::root(true);
		$this->option			= JFactory::getApplication()->input->getCmd('option');
		
		// set document
		$this->document = &$document;
		
		// set params
		$this->params = is_null($params) ? $this->document->params : $params;
		
		$this->widgets['logo'] 		= new RSTemplateWidget('logo', 	 $this->params);
		$this->widgets['social'] 	= new RSTemplateWidget('social', $this->params);
	}
	
	// gets the current component
	public function getOption() {
		return $this->option;
	}
	
	public function getItemId() {
		$app 	= JFactory::getApplication();
		$menu 	= $app->getMenu();
		$active = $menu->getActive();
		if ($active) { 
			return $active->id;
		}
		else {
			return $app->input->getInt('Itemid', 0);
		}
	}
	
	public function isHome() {
		$active = $this->getItemId();
		$app = JFactory::getApplication();
		$menu = $app->getMenu();
		$lang = '*';

		if ($app->getLanguageFilter()) {
			$lang = JFactory::getLanguage()->getTag();
		}

		$home = $menu->getDefault($lang);

		return ($active && $home && $active == $home->id);
	}
	
	public function isHomeHidden() {
		$isHome = $this->isHome();
		return ($this->params->get('hideHome') && $isHome);
	}
	
	// add Google Analytics code
	public function addGoogleAnalytics() {
		if ($this->params->get('googleAnalyticsCode')) {
			return $this->params->get('googleAnalyticsCode');
		}
	}

	// add Google Tag Manger code
	public function addGoogleTagManager() {
		if ($this->params->get('googleTagManagerCode')) {
			return $this->params->get('googleTagManagerCode');
		}
	}
	
	// set the menu effect
	public function setMenuEffect() {
		if ($this->params->get('deviceCompatibility')) {
			$this->addJS('jquery/jquery.mobile.custom.js');
			if ($this->params->get('useMenuEffects')) {
				$this->addJS('device-dropdown-animation.js');
			} else {
				$this->addJS('device-dropdown.js');
			}
		}
		if ($this->params->get('useMenuEffects')) {
			$this->addCSS('menu-animation.css');
			$this->addJS('menu-animation.js');
		} else {
			$this->addJS('menu-delay.js');
		}
		
		if ($this->params->get('menuPosition') == 'menu-left') {
			$this->document->addStyleDeclaration("@media (min-width: 979px) { .rstpl-main-menu-position .navbar-inner, .rstpl-main-menu-full-width-position .navbar-inner { text-align: left; } }");
		} else if ($this->params->get('menuPosition') == 'menu-center') {
			$this->document->addStyleDeclaration("@media (min-width: 979px) { .rstpl-main-menu-position .navbar-inner, .rstpl-main-menu-full-width-position .navbar-inner { text-align: center; } }");
		} else {
			$this->document->addStyleDeclaration("@media (min-width: 979px) { .rstpl-main-menu-position .navbar-inner, .rstpl-main-menu-full-width-position .navbar-inner { text-align: right; } }");
		}
		
		if ($this->params->get('stickyMenu')) {
			$this->addJS('sticky-menu.js');
		}
	}

	// set preloader
	public function setPreloader() {
		$preloaderLoad		= $this->params->get('preloaderLoad');
		$preloaderEffect	= $this->params->get('preloaderEffect');
		$preloaderType		= $this->params->get('preloaderType');

		if (($preloaderLoad == 'homepage' && $this->isHome()) || ($preloaderLoad == 'all_pages')) {

			$preloaderTypeHtml = '';
			if ($preloaderType == 'filling_text') {
				$preloaderTypeHtml = '<div class="filling-text-loader" data-text="'.JText::_('TPL_RSLIBRO_PRELOADER_TYPE_FILLING_TEXT_DATA').'">'.JText::_('TPL_RSLIBRO_PRELOADER_TYPE_FILLING_TEXT_DATA').'</div>';
			} else if ($preloaderType == 'floating_bullets') {
				$preloaderTypeHtml = '<div class="floating-bullets-loader"><span></span><span></span><span></span><span></span><span></span></div>';
			} else if ($preloaderType == 'circle_notch') {
				$preloaderTypeHtml = '<div class="circle-notch-loader"></div>';
			} else if ($preloaderType == 'fading_bars') {
				$preloaderTypeHtml = '<div class="fading-bars-loader"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div>';
			} else if ($preloaderType == 'spinning_circle') {
				$preloaderTypeHtml = '<div class="spinning-circle-loader"></div>';
			} else if ($preloaderType == 'bouncing_circle') {
				$preloaderTypeHtml = '<div class="bouncing-circle-loader"><span></span><span></span></div>';
			} else if ($preloaderType == 'fading_bullets') {
				$preloaderTypeHtml = '<div class="fading-bullets-loader"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div>';
			} else if ($preloaderType == 'stretching_bars') {
				$preloaderTypeHtml = '<div class="stretching-bars-loader"><span></span><span></span><span></span><span></span><span></span></div>';
			} else if ($preloaderType == 'waving_bullets') {
				$preloaderTypeHtml = '<div class="waving-bullets-loader"><span></span><span></span><span></span></div>';
			}
			
			echo '<div id="loader" class="pageload-overlay">
					'.$preloaderTypeHtml.'
				</div>';

			echo '<script type="text/javascript">RSTemplate.showPreloader(\'' . $preloaderEffect . '\');</script>';
		}
	}
	
	// set content fade effect
	public function setFadeContentEffect() {
		if ($this->params->get('fadeContent')) {
			$this->addJS('scrollReveal.min.js');
		}
	}

	// set content ripple effect
	public function setRippleEffect() {
		$this->addJS('jquery/jquery.ripple.js');
	}
	
	// set input animate border effect
	public function setAnimateBorderEffect() {
		$this->addJS('jquery/jquery.animate.border.js');
	}
	
	// set the default Google Classes and the Extra Ones the user sets
	public function addGoogleFont() {
		if (is_null($this->params->get('loadGoogleFonts')) || $this->params->get('loadGoogleFonts')) {
			$uri = JUri::getInstance();
			$prefix_protocol = 'http';
			if ($uri->isSSL()) {
				$prefix_protocol .= 's';
			}
			$sufix = ':300,400,700,400italic,700italic';
			if ($this->params->get('googleFontSubset') && $this->params->get('googleFontSubset') != '') {
				$sufix = '&amp;subset='.$this->params->get('googleFontSubset');
			}
			// Google font for Titles
			if ($this->params->get('googleTitleFont') != 'BebasNeue') {
				$this->document->addCustomTag('<link href="'.$prefix_protocol.'://fonts.googleapis.com/css?family='.urlencode($this->params->get('googleTitleFont')).$sufix.'" rel="stylesheet" type="text/css" />');
			}

			// Google font for Content
			$this->document->addCustomTag('<link href="'.$prefix_protocol.'://fonts.googleapis.com/css?family='.urlencode($this->params->get('googleContentFont')).$sufix.'" rel="stylesheet" type="text/css" />');

			// Title selectors with Google Font 
			$extraTitleSelectors = '';
			if (trim($this->params->get('addGoogleTitleClasses')) != '') {
				$extraTitleSelectors = trim($this->params->get('addGoogleTitleClasses'), ',');
			}
			$allTitleSelectors  = $this->params->get('googleTitleClasses');
			if ($extraTitleSelectors) {
				$allTitleSelectors .= ', '.$extraTitleSelectors;
			}
			if ($this->params->get('googleTitleFont')) {
				$this->document->addStyleDeclaration($allTitleSelectors." { font-family: '".$this->escape($this->params->get('googleTitleFont'))."', sans-serif; }");
			}

			// Content selectors with Google Font 
			$extraContentSelectors = '';
			if (trim($this->params->get('addGoogleContentClasses')) != '') {
				$extraContentSelectors = trim($this->params->get('addGoogleContentClasses'), ',');
			}
			$allContentSelectors  = $this->params->get('googleContentClasses');
			if ($extraContentSelectors) {
				$allContentSelectors .= ', '.$extraContentSelectors;
			}
			if ($this->params->get('googleContentFont')) {
				$this->document->addStyleDeclaration($allContentSelectors." { font-family: '".$this->escape($this->params->get('googleContentFont'))."', sans-serif; }");
			}
		}
	}
	
	// escaping function 
	public function escape($string) {
		return htmlentities($string, ENT_COMPAT, 'utf-8');
	}
	
	// add used javascript files
	public function addJS($url, $useRoot = true, $return = false) {
		$prefix = '';
		
		if ($useRoot) {
			$prefix = $this->root.'/templates/'.$this->document->template.'/js/';
		}

		if ($return) {
			return $prefix.$url;
		} else {
			$this->document->addScript($prefix.$url);
		}
	}

	public function addTemplateJs() {
		$this->addJS('template.js');
		
		// load waypoints
		$this->addJS('jquery/jquery.waypoints.min.js');
		
		// load progress bars
		$this->addJs('velocity.min.js');
		
		$this->addJs('jquery/jquery.roundabout.js');
	}

	public function addjQuery() {
		$value = $this->params->get('loadJQuery', 1);
		if (!in_array($value, array('no', 0, '0'), true)) {
			JHtml::_('jquery.framework');
		}
	}

	// add normal stylesheet for the template
	public function addCSS($url, $useRoot = true, $return = true) {
		static $added = array();
		
		$url = $useRoot ? $this->root.'/templates/'.$this->document->template.'/css/'.$url : $url;
		
		if (!in_array($url, $added)) {
			$added[] = $url;
			
			if ($return) {
				$this->document->addStyleSheet($url);
			} else {
				echo "\t".'<link rel="stylesheet" href="'.$url.'" type="text/css" />'."\r\n";
			}
 		}
	}
	
	// adds a custom stylesheet for the current component (com_content.css for example)
	public function addComponentCSS() {
		$cssName = $this->option.'.css';
		$cssPath = RSTEMPLATE_PATH.'/css/components/'.$cssName;
		
		if (file_exists($cssPath)) {
			$this->addCSS('components/'.$cssName, true, false);
		}
		
		if (JFactory::getLanguage()->get('rtl')) {
			$cssName = $this->option.'-rtl.css';
			$cssPath = RSTEMPLATE_PATH.'/css/components/'.$cssName;
			
			if (file_exists($cssPath)) {
				$this->addCSS('components/'.$cssName, true, false);
			}
		}
	}
	// adds a custom stylesheet for the modules if exist (mod_login.css for example)
	public function addModulesCSS() {
		$xml 		= simplexml_load_file(JPATH_SITE."/templates/".$this->document->template."/templateDetails.xml");
		$positions 	= $xml->positions->position;
		
		if (count($positions)) {
			foreach ($positions as $position) {
				$modules = JModuleHelper::getModules($position);
				foreach ($modules as $module) {
					$cssName = $module->module.'.css';
					$cssPath = RSTEMPLATE_PATH.'/css/modules/'.$cssName;
					
					if (file_exists($cssPath)) {
						$this->addCSS('modules/'.$cssName, true, false);
					}
					
					if (JFactory::getLanguage()->get('rtl')) {
						$cssName = $module->module.'-rtl.css';
						$cssPath = RSTEMPLATE_PATH.'/css/modules/'.$cssName;
						
						if (file_exists($cssPath)) {
							$this->addCSS('modules/'.$cssName, true, false);
						}
					}
				}
			}
		}
	}
	
	// adds template-rtl.css file if the selected languages requires rtl text direction
	public function addRTL() {
		if (JFactory::getLanguage()->get('rtl')) {
			$this->addCSS('template-rtl.css', true, false);
			$this->addCSS('theme/' . $this->params->get('templateTheme') . '-rtl.css', true, false);
		}
	}
	
	// adds a custom.css file if exists
	public function addCustomCSS() {
		$cssName					= 'custom.css';
		$this->customCSSPath 		= RSTEMPLATE_PATH.'/css/'.$cssName;
		if (file_exists($this->customCSSPath)) {
			$this->addCSS($cssName, true, false);
		}
	}

	// adds a custom.js file if exists
	public function addCustomJS() {
		$jsName				= 'custom.js';
		if (file_exists(RSTEMPLATE_PATH.'/js/'.$jsName)) {
			$this->addJS($jsName);
		}
	}
	
	public function addBootstrap() {
		// Add JavaScript Frameworks
		JHtml::_('bootstrap.framework');
		
		// Load optional rtl Bootstrap css and Bootstrap bugfixes
		JHtmlBootstrap::loadCss($includeMaincss = true, $this->document->direction);
	}
	
	public function getCSSPath($category, $file) {
		switch ($category) {
			case 'bootstrap':
				return '/media/jui/css/'.$file;
			break;
		}
	}
	
	public function getJSPath($category, $file) {
		switch ($category) {
			case 'bootstrap':
			case 'jquery':
				return '/media/jui/js/'.$file;
			break;
			
			case 'html5':
				return '/media/jui/js/'.$file;
			break;
		}
	}

	public function getPositions() {
		if ($this->params->get('definedPositions')) {
			$positions = explode(',', $this->params->get('definedPositions'));
			return $positions;
		}
	}
	
	/**
	 * Add the favicon tag
	 * @method addFavicon
	 */
	public function addFavicon() {
		$favicon			= $this->params->get('favicon', '');

		if (!$favicon) {
			$dirs = array(
				JPATH_THEMES . '/' . $this->document->template,
				JPATH_BASE
			);

			foreach ($dirs as $key => $dir) {
				if (file_exists($dir . '/favicon.ico')) {
					$favicon = ($dir == JPATH_BASE) ? 'favicon.ico' : 'templates/' . $this->document->template . '/favicon.ico';
					break;
				}
			}
		}

		echo '<link href="' . $this->document->baseurl . '/' . $this->escape($favicon).'" rel="shortcut icon" type="image/vnd.microsoft.icon" />';
	}
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists