Exemple #1
0
function fn_magiczoom_prepare_custom_options($block)
{
    static $addonOptions;
    static $enabledOptions;
    $headersBind = '';
    $generalParamsChangeBind = '';
    $includeOptionsJs = '';
    $initOptionsValidation = '';
    $magicscrollIcon = '';
    $blocks = array('product', 'category', 'search', 'newest', 'recent_products', 'most_popular', 'bestsellers', 'rating', 'on_sale', 'manually');
    if (!isset($addonOptions)) {
        $section = Settings::instance()->getSectionByName($_REQUEST['addon'], Settings::ADDON_SECTION);
        $addonOptions = db_get_hash_single_array('SELECT name, value FROM ?:settings_objects WHERE section_id = \'?p\' AND type != \'H\'', array('name', 'value'), $section['section_id']);
        $enabledOptions = db_get_hash_single_array('SELECT block, value FROM ?:addon_magiczoom_options WHERE name = \'enabled_options\'', array('block', 'value'));
    }
    switch ($block) {
        case 'general':
            if (isset($addonOptions['cache-path-to-cache'])) {
                $pathToCache = $addonOptions['cache-path-to-cache'];
            } else {
                $pathToCache = '/images/magictoolbox_cache';
            }
            $tool = fn_magiczoom_load();
            require_once dirname(__FILE__) . '/classes/magictoolbox.imagehelper.class.php';
            $imagehelper = new MagicToolboxImageHelperClass(Registry::get('config.dir.root'), $pathToCache, $tool->params);
            $usedSubCache = $imagehelper->getOptionsHash();
            $cacheInfo = fn_magiczoom_getCacheInfo(Registry::get('config.dir.root') . $pathToCache, $usedSubCache);
            $cacheInfo['formatedTotalSize'] = fn_magiczoom_format_size($cacheInfo['totalSize']);
            $cacheInfo['formatedUnusedSize'] = fn_magiczoom_format_size($cacheInfo['unusedSize']);
            $indexScript = Registry::get('config.admin_index');
            $return = <<<RETURN
<div class="control-group setting-wide magiczoom">
    <label for="addon_option_magiczoom_cache-path-to-cache" class="control-label" >Path to cache folder&nbsp;<a class="cm-tooltip" title="Relative for site base path."><i class="icon-question-sign"></i></a>:</label>
    <div class="controls">
        <input id="addon_option_magiczoom_cache-path-to-cache" type="text" name="addon_data[options][cache-path-to-cache]" value="{$pathToCache}" style="width:352px;" disabled="disabled" />
        <div class="right update-for-all"></div>
    </div>
</div>
<div class="control-group setting-wide magiczoom">
    <label for="addon_option_magiczoom_cache-total-items" class="control-label" >Total items:</label>
    <div class="controls">
        <input id="addon_option_magiczoom_cache-total-items" type="text" name="addon_data[options][cache-total-items]" value="{$cacheInfo['totalCount']} ({$cacheInfo['formatedTotalSize']})" size="30" disabled="disabled" />
        <div class="right update-for-all"></div>
    </div>
</div>
<div class="control-group setting-wide magiczoom">
    <label for="addon_option_magiczoom_cache-unused-items" class="control-label" >Unused items:</label>
    <div class="controls">
        <input id="addon_option_magiczoom_cache-unused-items" type="text" name="addon_data[options][cache-unused-items]" value="{$cacheInfo['unusedCount']} ({$cacheInfo['formatedUnusedSize']})" size="30" disabled="disabled" />
        <div class="right update-for-all"></div>
    </div>
</div>
<div class="control-group setting-wide magiczoom">
    <label for="addon_option_magiczoom_cache-what-clear" class="control-label " >Empty cache:</label>
    <div class="controls">
        <select id="addon_option_magiczoom_cache-what-clear" onchange="\$('#magiczoom_clear_cache_field').attr('href', '{$indexScript}?dispatch=magiczoom_cache.'+this.value).attr('rev', this.value);">
            <option value="clear_unused_items" selected="selected">Delete unused items</option>
            <option value="clear_all_items">Delete all items</option>
        </select>
        &nbsp;<a data-ca-event="ce.magiczoom_clear_cache_field" name="magiczoom_clear_cache_field" id="magiczoom_clear_cache_field" href="{$indexScript}?dispatch=magiczoom_cache.clear_unused_items" class="cm-ajax cm-confirm" rev="clear_unused_items" >Clear</a>
        <div class="right update-for-all"></div>
    </div>
</div>
RETURN;
            return $return;
            break;
        case 'manually':
            //only after last block
            $blocks = '"' . implode('", "', $blocks) . '"';
            //NOTE: does not work in hidden tabs
            //$headersBind = '$("#tabs_content_magiczoom h4.subheader").slice(1).click();';
            $headersBind = '
$("#tabs_content_magiczoom h4.subheader").slice(1).each(function() {
    var subheader = $(this);
    var target = subheader.attr(\'data-target\');
    subheader.addClass(\'collapsed\');
    $(target).removeClass(\'in\');
});
';
            $generalParamsChangeBind = '
$("#content_magiczoom_magiczoom_general").find("input[type=\'text\']").bind("change", function(){
var block_array = [' . $blocks . '];
var optionId = this.id.replace("addon_option_magiczoom_general-","");
var optioVal = $(this).val();
for(block in block_array) {
    $("#content_magiczoom_magiczoom_" + block_array[block]).
    find("#addon_option_magiczoom_" + block_array[block] + "-" + optionId + ":disabled").val(optioVal);
}
}).
end().find("select").bind("change", function(){
var block_array = [' . $blocks . '];
var optionId = this.id.replace("addon_option_magiczoom_general-","");
var optioVal = $(this).val().replace("general-" + optionId + "-", "");
for(block in block_array) {
    $("#content_magiczoom_magiczoom_" + block_array[block]).
    find("#addon_option_magiczoom_" + block_array[block] + "-" + optionId + ":disabled").val(block_array[block] + "-" + optionId + "-" + optioVal);
}
}).
end().find("input[type=\'radio\']").bind("change", function(){
var block_array = [' . $blocks . '];
var optionId = this.parentNode.parentNode.id.replace("addon_option_magiczoom_general-","");
var optioVal = $(this).val().replace("general-" + optionId + "-", "");
for(block in block_array) {
    $("#content_magiczoom_magiczoom_" + block_array[block]).
    find("#addon_option_magiczoom_" + block_array[block] + "-" + optionId + " input:disabled").val([block_array[block] + "-" + optionId + "-" + optioVal]);
}
});';
            $tool = fn_magiczoom_load();
            $includeOptionsJs = '<script type="text/javascript" src="' . Registry::get('config.http_location') . '/js/addons/magiczoom/options.js"></script>';
            $templateOptionId = Settings::instance()->getId('product-template', 'magiczoom');
            $magicscrollOptionId = Settings::instance()->getId('product-magicscroll', 'magiczoom');
            $initOptionsValidation = 'initOptionsValidation(\'addon_data[options][' . $templateOptionId . ']\', \'addon_data[options][' . $magicscrollOptionId . ']\', \'product-template-\', \'product-magicscroll-\');';
            $magicscrollIcon = '
var magicscrollIcon = document.createElement("img");
magicscrollIcon.id = "magicscroll_icon";
magicscrollIcon.src = "' . Registry::get('config.http_location') . "/design/backend/media/images/addons/magiczoom/magicscroll.png" . '";
magicscrollIcon.style.marginRight = "5px";
document.getElementById("addon_option_magiczoom_product-magicscroll").insertBefore(magicscrollIcon, document.getElementById("addon_option_magiczoom_product-magicscroll").firstChild);
';
    }
    $tool = fn_magiczoom_load();
    //$skip = array('zoomOn');
    $skip = array();
    $skip[] = 'quick-view-thumb-max-width';
    $skip[] = 'quick-view-thumb-max-height';
    foreach ($tool->params->getParams() as $param) {
        if (in_array($param['group'], array('General', 'Scroll', 'Scroll Arrows', 'Scroll Slider', 'Scroll effect', 'Multiple images'))) {
            $skip[] = $param['id'];
        }
    }
    $skip = implode('|', $skip);
    return $includeOptionsJs . '
        <input type="hidden" name="addon_data[options][' . $block . '-enabled-options]" id="addon_option_magiczoom_' . $block . '-enabled-options" value="' . $enabledOptions[$block] . '" />
        <script type="text/javascript">
            //<![CDATA[
                function fn_magiczoom_prepare_' . $block . '_block_options() {
                    fn_magiczoom_prepare_custom_options("' . $block . '", \'' . $skip . '\');
                    ' . $headersBind . $generalParamsChangeBind . $initOptionsValidation . $magicscrollIcon . '
                }
            //]]>
        </script>
    ';
}
Exemple #2
0
function magiczoomplus_getThumb($src, $size = null, $pid = null)
{
    if ($size === null) {
        $size = 'thumb';
    }
    require_once MTOOLBOX_ADMIN_FOLDER_magiczoomplus . 'magictoolbox.imagehelper.class.php';
    if (defined('HTTP_IMAGE')) {
        $url = str_replace('image/', '', HTTP_IMAGE);
    } else {
        $url = HTTP_SERVER;
    }
    $shop_dir = str_replace('system/', '', DIR_SYSTEM);
    $image_dir = str_replace($shop_dir, '', DIR_IMAGE);
    $imagehelper = new MagicToolboxImageHelperClass($shop_dir, '/' . $image_dir . 'magictoolbox_cache', $GLOBALS["magictoolbox"]["magiczoomplus"]->params, null, $url);
    return $imagehelper->create('/' . $src, $size, $pid);
}
Exemple #3
0
function getThumb($src, $size = null, $pid = null)
{
    if ($size === null) {
        $size = 'thumb';
    }
    require_once dirname(__FILE__) . '/magictoolbox.imagehelper.class.php';
    $url = str_replace('image/', '', HTTP_IMAGE);
    $shop_dir = str_replace('system/', '', DIR_SYSTEM);
    $image_dir = str_replace($shop_dir, '', DIR_IMAGE);
    $imagehelper = new MagicToolboxImageHelperClass($shop_dir, '/' . $image_dir . 'magictoolbox_cache', $GLOBALS["magictoolbox"]["magiczoom"]->params, null, $url);
    return $imagehelper->create('/' . $src, $size, $pid);
}
Exemple #4
0
 public function index()
 {
     $tool = $GLOBALS["magictoolbox"]["magiczoomplus"];
     $shop_dir = str_replace('system/', '', DIR_SYSTEM);
     $image_dir = str_replace($shop_dir, '', DIR_IMAGE);
     $pathToCache = '/' . $image_dir . 'magictoolbox_cache';
     $this->language->load('module/magiczoomplus');
     // load lang. file
     if (method_exists($this->document, 'setTitle')) {
         $this->document->setTitle($this->language->get('title'));
     } else {
         $this->document->title = $this->language->get('title');
         //load title
     }
     $this->load->model('setting/setting');
     //just include file admin/model/setting/setting.php and create object ModelSettingSetting
     $token = isset($this->session->data['token']) ? '&token=' . $this->session->data['token'] : '';
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         if (isset($this->request->post['clear_cache']) && $this->request->post['clear_cache'] == '1') {
             //clear cache
             $this->params = $this->model_setting_setting->getSetting('magiczoomplus');
             //load settings from DB
             foreach ($tool->params->getArray() as $param => $values) {
                 if (isset($this->params[$values['id']])) {
                     $tool->params->set($values['id'], $this->params[$values['id']]);
                 }
             }
             require_once DIR_APPLICATION . 'controller/module/magiczoomplus-opencart-module/magictoolbox.imagehelper.class.php';
             $imagehelper = new MagicToolboxImageHelperClass($shop_dir, $pathToCache, $tool->params);
             $usedSubCache = $imagehelper->getOptionsHash();
             if (is_dir($shop_dir . $pathToCache)) {
                 $this->clearCache($shop_dir . $pathToCache, $this->request->post['what-clear'] == 'all_items' ? null : $usedSubCache);
             }
         } else {
             //save params
             unset($this->request->post['clear_cache']);
             unset($this->request->post['what-clear']);
             if (VERSION < 2) {
                 $this->model_setting_setting->editSetting('magiczoomplus', $this->request->post);
                 $this->session->data['success'] = $this->language->get('text_success');
                 $this->redirect(HTTPS_SERVER . 'index.php?route=extension/module' . $token);
             } else {
                 $finalSettings = array('magiczoomplus_settings' => $this->request->post);
                 //serialize to avoid module name check for each option
                 $this->model_setting_setting->editSetting('magiczoomplus', $finalSettings);
                 $this->params = $this->model_setting_setting->getSetting('magiczoomplus');
                 //load settings from DB
                 $this->session->data['success'] = $this->language->get('text_success');
                 $this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
             }
         }
     }
     $extension_data['heading_title'] = $this->language->get('heading_title');
     $extension_data['text_enabled'] = $this->language->get('text_enabled');
     $extension_data['text_disabled'] = $this->language->get('text_disabled');
     $extension_data['entry_status'] = $this->language->get('entry_status');
     $extension_data['button_save'] = $this->language->get('button_save');
     $extension_data['button_cancel'] = $this->language->get('button_cancel');
     $extension_data['button_clear'] = $this->language->get('button_clear');
     $this->params = $this->model_setting_setting->getSetting('magiczoomplus');
     //load settings from DB
     if (VERSION >= 2) {
         if (isset($this->params['magiczoomplus_settings'])) {
             $this->params = $this->params['magiczoomplus_settings'];
         } else {
             $this->params = array();
         }
     }
     foreach ($tool->params->getArray() as $param => $values) {
         if (isset($this->params[$values['id']])) {
             $tool->params->set($values['id'], $this->params[$values['id']]);
         }
     }
     require_once DIR_APPLICATION . 'controller/module/magiczoomplus-opencart-module/magictoolbox.imagehelper.class.php';
     $imagehelper = new MagicToolboxImageHelperClass($shop_dir, $pathToCache, $tool->params);
     $usedSubCache = $imagehelper->getOptionsHash();
     $cacheInfo = $this->MagicZoomPlusgetCacheInfo($shop_dir . $pathToCache, $usedSubCache);
     $extension_data['path_to_cache'] = $pathToCache;
     $extension_data['total_items'] = $cacheInfo['totalCount'] . ' (' . $this->MagicZoomPlusformat_size($cacheInfo['totalSize']) . ')';
     $extension_data['unused_items'] = $cacheInfo['unusedCount'] . ' (' . $this->MagicZoomPlusformat_size($cacheInfo['unusedSize']) . ')';
     $extension_data['parameters'] = $tool->params->getArray();
     // LOAD PARAMS
     if (isset($this->error['warning'])) {
         $extension_data['error_warning'] = $this->error['warning'];
     } else {
         $extension_data['error_warning'] = '';
     }
     if (isset($this->error['code'])) {
         $extension_data['error_code'] = $this->error['code'];
     } else {
         $extension_data['error_code'] = '';
     }
     $extension_data['breadcrumbs'] = array();
     $extension_data['breadcrumbs'][] = array('href' => HTTPS_SERVER . 'index.php?route=common/home' . $token, 'text' => $this->language->get('text_home'), 'separator' => FALSE);
     $extension_data['breadcrumbs'][] = array('href' => HTTPS_SERVER . 'index.php?route=extension/module' . $token, 'text' => $this->language->get('text_module'), 'separator' => ' :: ');
     $extension_data['breadcrumbs'][] = array('href' => HTTPS_SERVER . 'index.php?route=module/magiczoomplus' . $token, 'text' => $this->language->get('heading_title'), 'separator' => ' :: ');
     $extension_data['action'] = HTTPS_SERVER . 'index.php?route=module/magiczoomplus' . $token;
     $extension_data['cancel'] = HTTPS_SERVER . 'index.php?route=extension/module' . $token;
     if (isset($this->request->post['magiczoomplus_status'])) {
         $extension_data['magiczoomplus_status'] = $this->request->post['magiczoomplus_status'];
     } else {
         if (isset($this->request->post['magiczoomplus_settings']['magiczoomplus_status'])) {
             $extension_data['magiczoomplus_status'] = $this->request->post['magiczoomplus_settings']['magiczoomplus_status'];
         } else {
             if (isset($this->params['magiczoomplus_status'])) {
                 $this->config->set('magiczoomplus_status', $this->params['magiczoomplus_status']);
             }
             $extension_data['magiczoomplus_status'] = $this->config->get('magiczoomplus_status');
         }
     }
     if (VERSION < 2) {
         foreach ($extension_data as $key => $value) {
             $this->data[$key] = $value;
         }
         $this->template = 'module/magiczoomplus_oc15.tpl';
         $this->children = array('common/header', 'common/footer');
         $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
     } else {
         foreach ($extension_data as $key => $value) {
             $data[$key] = $value;
         }
         $data['header'] = $this->load->controller('common/header');
         $data['column_left'] = $this->load->controller('common/column_left');
         $data['footer'] = $this->load->controller('common/footer');
         $this->response->setOutput($this->load->view('module/magiczoomplus_oc2.tpl', $data));
     }
 }
Exemple #5
0
 public function index()
 {
     $tool = $GLOBALS["magictoolbox"]["magiczoom"];
     $shop_dir = str_replace('system/', '', DIR_SYSTEM);
     $image_dir = str_replace($shop_dir, '', DIR_IMAGE);
     $pathToCache = '/' . $image_dir . 'magictoolbox_cache';
     /*STANDARD CODE*/
     $this->load->language('module/magiczoom');
     // load lang. file
     /*$this->document->title = $this->language->get('heading_title'); //load title*/
     $this->load->model('setting/setting');
     //just include file admin/model/setting/setting.php and create object ModelSettingSetting
     $token = isset($this->session->data['token']) ? '&token=' . $this->session->data['token'] : '';
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         if (isset($this->request->post['clear_cache']) && $this->request->post['clear_cache'] == '1') {
             //clear cache
             $this->params = $this->model_setting_setting->getSetting('magiczoom');
             //load settings from DB
             foreach ($tool->params->getArray() as $param => $values) {
                 if (isset($this->params[$values['id']])) {
                     $tool->params->set($values['id'], $this->params[$values['id']]);
                 }
             }
             require_once dirname(__FILE__) . '/magictoolbox/magictoolbox.imagehelper.class.php';
             $imagehelper = new MagicToolboxImageHelperClass($shop_dir, $pathToCache, $tool->params);
             $usedSubCache = $imagehelper->getOptionsHash();
             if (is_dir($shop_dir . $pathToCache)) {
                 $this->clearCache($shop_dir . $pathToCache, $this->request->post['what-clear'] == 'all_items' ? null : $usedSubCache);
             }
         } else {
             //save params
             unset($this->request->post['clear_cache']);
             unset($this->request->post['what-clear']);
             $this->model_setting_setting->editSetting('magiczoom', $this->request->post);
         }
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect(HTTPS_SERVER . 'index.php?route=extension/module' . $token);
     }
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_enabled'] = $this->language->get('text_enabled');
     $this->data['text_disabled'] = $this->language->get('text_disabled');
     $this->data['entry_status'] = $this->language->get('entry_status');
     $this->data['button_save'] = $this->language->get('button_save');
     $this->data['button_cancel'] = $this->language->get('button_cancel');
     $this->data['button_clear'] = $this->language->get('button_clear');
     $this->params = $this->model_setting_setting->getSetting('magiczoom');
     //load settings from DB
     foreach ($tool->params->getArray() as $param => $values) {
         if (isset($this->params[$values['id']])) {
             $tool->params->set($values['id'], $this->params[$values['id']]);
         }
     }
     require_once dirname(__FILE__) . '/magictoolbox/magictoolbox.imagehelper.class.php';
     $imagehelper = new MagicToolboxImageHelperClass($shop_dir, $pathToCache, $tool->params);
     $usedSubCache = $imagehelper->getOptionsHash();
     $cacheInfo = $this->getCacheInfo($shop_dir . $pathToCache, $usedSubCache);
     $this->data['path_to_cache'] = $pathToCache;
     $this->data['total_items'] = $cacheInfo['totalCount'] . ' (' . $this->format_size($cacheInfo['totalSize']) . ')';
     $this->data['unused_items'] = $cacheInfo['unusedCount'] . ' (' . $this->format_size($cacheInfo['unusedSize']) . ')';
     $this->data['parameters'] = $tool->params->getArray();
     // LOAD PARAMS
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->error['code'])) {
         $this->data['error_code'] = $this->error['code'];
     } else {
         $this->data['error_code'] = '';
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('href' => HTTPS_SERVER . 'index.php?route=common/home' . $token, 'text' => $this->language->get('text_home'), 'separator' => FALSE);
     $this->data['breadcrumbs'][] = array('href' => HTTPS_SERVER . 'index.php?route=extension/module' . $token, 'text' => $this->language->get('text_module'), 'separator' => ' :: ');
     $this->data['breadcrumbs'][] = array('href' => HTTPS_SERVER . 'index.php?route=module/magiczoom' . $token, 'text' => $this->language->get('heading_title'), 'separator' => ' :: ');
     $this->data['action'] = HTTPS_SERVER . 'index.php?route=module/magiczoom' . $token;
     $this->data['cancel'] = HTTPS_SERVER . 'index.php?route=extension/module' . $token;
     if (isset($this->request->post['magiczoom_status'])) {
         $this->data['magiczoom_status'] = $this->request->post['magiczoom_status'];
     } else {
         $this->data['magiczoom_status'] = $this->config->get('magiczoom_status');
     }
     $this->template = 'module/magiczoom.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
 }
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    return array(CONTROLLER_STATUS_OK);
}
if ($mode == 'clear_all_items' || $mode == 'clear_unused_items') {
    $section = Settings::instance()->getSectionByName('magiczoom', Settings::ADDON_SECTION);
    $addon_options = db_get_hash_single_array('SELECT name, value FROM ?:settings_objects WHERE section_id = \'?p\' AND type != \'H\'', array('name', 'value'), $section['section_id']);
    if (isset($addon_options['cache-path-to-cache'])) {
        $pathToCache = $addon_options['cache-path-to-cache'];
    } else {
        $pathToCache = '/images/magictoolbox_cache';
    }
    $tool = fn_magiczoom_load();
    require_once dirname(__FILE__) . '/../../classes/magictoolbox.imagehelper.class.php';
    $imagehelper = new MagicToolboxImageHelperClass(Registry::get('config.dir.root'), $pathToCache, $tool->params);
    $usedSubCache = $imagehelper->getOptionsHash();
    if (is_dir(Registry::get('config.dir.root') . $pathToCache)) {
        fn_magiczoom_clearCache(Registry::get('config.dir.root') . $pathToCache, $mode == 'clear_all_items' ? null : $usedSubCache);
    }
    fn_set_notification('N', __('notice'), "Image cache was cleared.");
    $cacheInfo = fn_magiczoom_getCacheInfo(Registry::get('config.dir.root') . $pathToCache, $usedSubCache);
    echo $cacheInfo['totalCount'] . ' (' . fn_magiczoom_format_size($cacheInfo['totalSize']) . ')';
    exit;
}
return array(CONTROLLER_STATUS_OK);
function fn_magiczoom_clearCache($path, $usedSubCache = null)
{
    $files = glob($path . DIRECTORY_SEPARATOR . '*');
    if ($files !== FALSE && !empty($files)) {
        foreach ($files as $file) {