<?php
/**
 * magictoolbox products_all_listing module
 */

    $orig = dirname(__FILE__) . '/tpl_modules_products_all_listing_original.php';
    if(!file_exists($orig)) {
        $orig = DIR_WS_TEMPLATES . 'template_default/templates/tpl_modules_products_all_listing.php';
    }
    
    function parse_content ($content) {
        $content = preg_replace_callback('/(<a[^>]href=\"([^"]*)\"><img[^>]src=\"([^"]*)\".*?title=\"([^"]*)\".*?width=\"([0-9]*)\".*?height=\"([0-9]*)\".*?><\/a[^>]*>)/is','parse_content_callback',$content);
        return $content;
    }
    
    function parse_content_callback ($matches) {

        require_once(DIR_FS_CATALOG . DIR_WS_MODULES . 'magictoolbox/magictoolbox_addons.php');
        $mod = & magictoolboxLoadModule('MagicThumb');
        if ($mod->params->checkValue('use-effect-on-products-all-page','No')) return $matches[0];
        


        $img = DIR_WS_CATALOG . $matches[3];
        $thumb = DIR_WS_CATALOG . magictoolboxGetThumb($matches[3], $matches[5], $mod->params->getValue('thumb-size-depends-on'), $mod->params->getValue('image-magick-path'));
        $id = preg_replace('/^.*?products_id=([0-9]*).*/is','$1',$matches[2]);
        $title = $description = $matches[4];
        if($mod->params->checkValue('link-to-product-page', 'Yes')) {
        $link = $matches[2];
        } else { 

        $link = '';
        }


        $result = $mod->template(compact("img","thumb","id","title","description","link"));
        


        return $result;
    }
    ob_start('parse_content');
    require_once($orig);
    ob_end_flush();
?>