<?php
/*Copyright (C) 2014 Handoyo yonghan79@gmail.com*/

if (! defined ( 'DIR_CORE' )) {
header ( 'Location: static_pages/' );
}

class ExtensionSharethis extends Extension {
    public $data = array();
    public function onControllerPagesProductProduct_UpdateData()
    {
        $that = $this->baseObject;
        $that->view->assign('spans',$that->config->get('sharethis_spans'));
        $that->view->assign('bottomJSCode',$that->config->get('sharethis_bottomJSCode'));
        $that->view->assign('cssTag',html_entity_decode($that->config->get('sharethis_cssTag')));
        $that->loadLanguage('sharethis/sharethis');
        $that->view->assign('share_text',$that->language->get('sharethis_share_text'));
        $that->processTemplate('pages/product/product.tpl');
    }

    public function onControllerCommonHead_InitData()
    {
        $that = $this->baseObject;
        $resource = new AResource('image');
        $that->view->assign('headJSCode',$that->config->get('sharethis_headJSCode'));
        if (isset($that->request->get['product_id'])) {
            $product_id = $that->request->get['product_id'];
        } else {
            $product_id = 0;
        }
        $that->loadModel('catalog/category');
        $sizes = array(
            'thumb'=> array('width'=>$that->config->get('config_image_thumb_width'),
                'height' => $that->config->get('config_image_thumb_height')));
        $array[] = $resource->getResourceAllObjects('products', $product_id, $sizes,1, false);
        $that->view->assign('ogImg',$array[0]['thumb_url']);

    }
 }