Post by ArcherData » Sat May 30, 2015 5:03 am

After upload ... attempted to run install and got this error:
Fatal error: Call to a member function escape() on a non-object in /home/username/public_html/ocart2/system/library/vie_front.php on line 27
Here is line 26-27:

Code: Select all

// Load skin options
$theme_id = $this->db->escape($this->getTheme());
Otherwise, site appears OK.

Don Bledsoe


User avatar
New member

Posts

Joined
Mon Dec 24, 2012 4:30 am
Location - Cherryvale, KS

Post by chulcha » Sat May 30, 2015 6:53 am

Show all code from /home/username/public_html/ocart2/system/library/vie_front.php

Active Member

Posts

Joined
Fri Jul 18, 2014 4:39 pm

Post by ArcherData » Sat May 30, 2015 7:00 am

I do not know if this is part of the distribution or not. It's possible that's part of a Viethemes extension I installed, but one would think that there would be a header comment stating that.

Code: Select all

<?php
class Vie_Front {
	const TABLE_THEME 		= 'vie_lte_theme';
	const TABLE_SKIN 		= 'vie_lte_skin';
	const TABLE_SKIN_OPTION = 'vie_lte_skin_option';

	protected static $instance;

	protected $registry;

	protected $resources = array();

	public $positions = array();

	public $skin_options = array();

	public $vie;

	protected function __construct($registry) {
		$this->registry = $registry;

		$this->load->library('vie');

		$this->vie = Vie::getInstance();

		// Load skin options
		$theme_id = $this->db->escape($this->getTheme());
		$skin_id = $this->db->escape($this->getSkin());

		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . self::TABLE_SKIN_OPTION . " WHERE theme_id = '$theme_id' AND skin_id = '$skin_id'");

		$this->skin_options = array();
		foreach ($query->rows as $row) {
			$this->skin_options[$row['option']] = unserialize($row['value']);
		}

		// Load theme language
		$this->language->load('vie/theme_' . $theme_id);
	}

	public function __get($key) {
		return $this->registry->get($key);
	}

	public function __set($key, $value) {
		$this->registry->set($key, $value);
	}

	public static function getInstance() {
		if (empty(self::$instance)) {
			global $registry;
			self::$instance = new Vie_Front($registry);
		}

		return self::$instance;
	}

	public function init() {
		$this->setPreview();
		$this->initPositions();
	}

	public function getModules($position) {
		return isset($this->positions[$position]) ? $this->positions[$position] : array();
	}

	protected function initPositions() {
		$positions = $this->vie->getPositions();

		$this->load->model('design/layout');
		$this->load->model('extension/module');

		if (isset($this->request->get['route'])) {
			$route = (string)$this->request->get['route'];
		} else {
			$route = 'common/home';
		}

		$layout_id = 0;

		if ($route == 'product/category' && isset($this->request->get['path'])) {
			$this->load->model('catalog/category');
			
			$path = explode('_', (string)$this->request->get['path']);

			$layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));
		}

		if ($route == 'product/product' && isset($this->request->get['product_id'])) {
			$this->load->model('catalog/product');
			
			$layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
		}

		if ($route == 'information/information' && isset($this->request->get['information_id'])) {
			$this->load->model('catalog/information');
			
			$layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
		}

		if (!$layout_id) {
			$layout_id = $this->model_design_layout->getLayout($route);
		}

		if (!$layout_id) {
			$layout_id = $this->config->get('config_layout_id');
		}

		foreach ($positions as $position => $name) {
			$loaded_modules = array();		
			
			$modules = $this->model_design_layout->getLayoutModules($layout_id, $position);

			foreach ($modules as $module) {
				$part = explode('.', $module['code']);
				
				if (isset($part[0]) && $this->config->get($part[0] . '_status')) {
					$loaded_modules[] = $this->load->controller('module/' . $part[0]);
				}
				
				if (isset($part[1])) {
					$setting_info = $this->model_extension_module->getModule($part[1]);
					
					if ($setting_info && $setting_info['status']) {
						$loaded_modules[] = $this->load->controller('module/' . $part[0], $setting_info);
					}
				}
			}

			$this->positions[$position] = $loaded_modules;
		}
	}

	public function getTheme() {
		return 'vie';
	}

	public function getSkins() {

	}

	public function getRootSkin() {
		if (!empty($this->request->post['skin_id'])) {
			return $this->request->post['skin_id'];
		}
	}

	public function getSkin() {
		return $this->config->get('vie_theme_editor_skin_id');
	}

	public function getSkinOption($option, $from_cache = true) {
		$value = null;

		if ($this->isPreview()) {
			if (isset($this->session->data['vie_skin_options'][$option])) {
				$value = $this->session->data['vie_skin_options'][$option];
			}
		} else {
			if (isset($this->skin_options[$option])) {
				$value = $this->skin_options[$option];
			}
		}

		if (is_string($value)) {
			$value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
		}

		return $value;
	}

	public function getThemeVersion() {

	}

	public function getFrameworkVersion() {

	}

	public function setPreview() {
		if (!empty($this->request->get['vie_preview']) || !empty($this->session->data['vie_preview'])) {
			$this->session->data['vie_preview'] = true;
		} else {
			$this->session->data['vie_preview'] = false;
		}

		if (!empty($this->request->post['vie_preview_data'])) {
			$data = json_decode(htmlspecialchars_decode($this->request->post['vie_preview_data']), true);

			$this->session->data['vie_skin_id'] = $data['skin_id'];
			$this->session->data['vie_skin_options'] = $data['skin_options'];
		}
	}

	public function isPreview() {
		return !empty($this->request->get['vie_preview']) || !empty($this->session->data['vie_preview']);
	}

	public function clearPreview() {
		// TODO: Clear preview
	}

	public function addResources($position, $resources, $meta) {
		if (empty($this->resources[$position])) {
			$this->resources[$position] = array(
				'meta' => $meta,
				'resources' => array()
			);
		}

		if (!is_array($resources)) {
			$resources = array($resources);
		}

		$this->resources[$position]['resources'] = array_merge($this->resources[$position]['resources'], $resources);
	}

	public function renderResources($position) {
		$html = '';

		if (!empty($this->resources[$position])) {
			$resource_data = $this->resources[$position];

			if ($resource_data['meta'] == 'script') {
				foreach ($resource_data['resources'] as $resource) {
					$html .= '<script src="'. $resource .'"></script>';
				}
			} else if ($resource_data['meta'] == 'style') {
				foreach ($resource_data['resources'] as $resource) {
					$html .= '<link rel="stylesheet" href="'. $resource .'" />';
				}
			}
		}

		if ($position == 'header_styles') {
			$html = $this->processFonts($html);
		}

		if ($position == 'body_end_scripts' && $this->isPreview()) {
			// Load skins
			$skins_path = DIR_SYSTEM . 'vie/skins/';
			$skin_files = glob($skins_path . '*.ejs');

			foreach ($skin_files as $skin_file) {
				$content = file_get_contents($skin_file);
				$skin = basename($skin_file, '.ejs');

				$html .= '<script type="text/ejs" id="skin-'. $skin .'">' . $content . '</script>';
			}

			// Insert Preview Scripts
			$html .= '<script src="catalog/view/javascript/vie/theme_editor/ejs.js"></script>';
			$html .= '<script src="catalog/view/javascript/vie/theme_editor/processor.js"></script>';
		}

		echo $html;
	}

	protected function processFonts($html) {
		$google_fonts = array();

		if (!empty($this->skin_options)) {
			foreach ($this->skin_options as $option => $value) {
				if (preg_match('/font$/', $option) && !empty($value)) {
					$processed_font = $this->processFontFamily($value);

					if ($processed_font) {
						$google_fonts[] = $processed_font;
					}
				}
			}
		}

		if (!empty($google_fonts)) {
			$html = sprintf('<link href="%s" type="text/css" rel="stylesheet" />', '//fonts.googleapis.com/css?family=' . implode('|', $google_fonts) . '&subset=all') . $html;
		}

		return $html;
	}

	protected function processFontFamily($font) {
		$fonts = $this->getGoogleFonts();

		$variants = array();
		$is_exist = false;
		foreach ($fonts['items'] as $font_item) {
			if ($font_item['family'] == $font) {
				$is_exist = true;

				if (!empty($font_item['variants'])) {
					$variants = $font_item['variants'];
				}
			}
		}

		if (!$is_exist) {
			return null;
		}

		$font_family = preg_replace('/(\w)\s+(\w)/', '$1+$2', $font);

		if (!empty($variants)) {
			$font_family .= ':' . implode(',', $variants);
		}

		return $font_family;
	}

	protected function getGoogleFonts() {
		static $fonts;

		if (!$fonts) {
			$font_contents = file_get_contents(DIR_SYSTEM . 'vie/fonts.json');

			$fonts = json_decode($font_contents, true);
		}

		return $fonts;
	}

	public function getBodyClass() {

	}

	public function getQuickviewUrl($product_id) {
		return 'index.php?route=vie/quick_view&vie_pid=' . (int)$product_id;
	}

	public function getSaleBadge($product_id) {
		$type = $this->getSkinOption('sale_badge_type');

		$product = $this->model_catalog_product->getProduct($product_id);

		if ((float)$product['special']) {
			$special = $this->tax->calculate($product['special'], $product['tax_class_id'], $this->config->get('config_tax'));
		} else {
			$special = false;
		}

		if (!$special) {
			return null;
		}

		if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
			$price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'));
		} else {
			$price = false;
		}

		if (!$price) {
			return null;
		}

		$value = '';

		if ($type == 'percent') {
			$value = round($special / $price * 100) . '%';
		} else {
			$value = $this->language->get('text_vie_sale');
		}

		return $value;
	}

	public function translate($text) {
		return $this->vie->translate($text);
	}
}

Don Bledsoe


User avatar
New member

Posts

Joined
Mon Dec 24, 2012 4:30 am
Location - Cherryvale, KS

Post by chulcha » Sat May 30, 2015 3:54 pm

Oh, yes. This not not part of distibution

Code: Select all

protected function __construct($registry) {
      $this->registry = $registry;

      $this->load->library('vie');

      $this->vie = Vie::getInstance();

		$this->db = $registry->get('db');
....
$this->db = $registry->get('db'); - add string of code
OR
$this->db = $this->registry->get('db');

Active Member

Posts

Joined
Fri Jul 18, 2014 4:39 pm

Post by ArcherData » Sat May 30, 2015 10:20 pm

RESOLVED

This turned out to be a needed update for OC 2.0.3.1 by Viethemes for their Live Editor extension (which I REALLY love).

Upgrade completed successfuily.

Don Bledsoe


User avatar
New member

Posts

Joined
Mon Dec 24, 2012 4:30 am
Location - Cherryvale, KS

Post by viethemes » Tue Nov 08, 2016 9:37 am

Glad to hear that the problem is solved!
If you have any question please don't hesitate to contact us via email viethemes@gmail.com.

http://www.viethemes.com - OpenCart turtorials, news, tips and stricks, extension

Our extensions:
Visual Theme Editor - Powerful tool for customizing style of any theme visually
Live Theme Editor - Customize layout, colors, backgrounds, fonts of the default theme
Theme Animation - Animation Editor for any theme

Extra Positions PRO, Custom JavaScript, Custom CSS and others


User avatar
Active Member

Posts

Joined
Thu Jan 08, 2015 12:17 pm

Who is online

Users browsing this forum: No registered users and 7 guests