Your IP : 216.73.216.55


Current Path : /home/g/i/t/giteleslfp/www/administrator/components/com_templateck/views/template/
Upload File :
Current File : /home/g/i/t/giteleslfp/www/administrator/components/com_templateck/views/template/view.html.php

<?php

/**
 * @name		Template Creator CK
 * @copyright	Copyright (C) since 2011. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 * @author		Cedric Keiflin - http://www.template-creator.com - http://www.joomlack.fr
 */
// No direct access
use Joomla\CMS\Table\Table;
defined('TCK_LOADED') or die;
jimport('joomla.application.component.view');

/**
 * View to edit
 */
class TemplateckViewTemplate extends JViewLegacy {

	protected $state;
	protected $item;
	protected $form;
//	protected $params;

	/**
	 * Display the view
	 */
	public function display($tpl = null) {

		$app = JFactory::getApplication();
		$user = JFactory::getUser();

		$this->state = $this->get('State');
		$this->item = $this->get('Data');
//		$this->form = $this->get('Form');

		$this->isTemplateInstalled = $this->_checkIfTemplateInstalled($this->item->name);
		$this->imagespath = TEMPLATECREATORCK_MEDIA_URI . '/images/menustyles/';
		$this->interface = new CKInterface();
		$this->input = new TCK_Input();
		// $this->params = $app->getParams('com_templateck');

		// Check for errors.
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}

		if ($this->_layout == 'edit' || !$this->item->id) {
			$authorised = $user->authorise('core.edit.own', 'com_templateck');

			if ($authorised !== true) {
				// Redirect to the edit screen.
				$app->redirect(JURI::root() . 'index.php?option=com_templateck&view=login&template=templatecreatorck&tmpl=login&id=' . $this->item->id);
				return false;
			}
		}

		parent::display($tpl);
		exit();
	}

	/**
	 * private function to load the fonts in the page
	 */
	function _callfonts() {
		$fontstyles = '';
		$fontsheets = '';
		$db = JFactory::getDBO();
		$query = "SELECT *
		FROM #__templateck_fonts
		  ";
		$db->setQuery($query);
		$rows = $db->loadObjectList();
		if (!$rows)
			return false;
		foreach ($rows as $row) {
			if (stristr($row->styles, '@import')) 
			{
				$fontsheets .= str_replace(");", "' rel='stylesheet' type='text/css'>", str_replace("@import url(", "<link href='", $row->styles));
			} else {
				$fontstyles .= str_replace("url('", "url('" . JURI::base(true) . "/components/com_templateck/fonts/" . $row->name . "/", $row->styles);
			}
		}
		if ($fontstyles)
			echo "<style type=\"text/css\">" . $fontstyles . "</style>";
		if ($fontsheets)
			echo $fontsheets;
	}

	/**
	 * private function to check if the current template is installed
	 */
	function _checkIfTemplateInstalled($name) {
		$db = JFactory::getDBO();
		$query = "SELECT * FROM #__extensions 
			WHERE type = 'template'
			AND element = '" . $name . "'
			AND enabled = '1'
		";
		$db->setQuery($query);
		$result = $db->loadResult();

		if (! $result) {
			return false;
		} else {
			return true;
		}

		return false;
		
	}
}