コード例 #1
0
ファイル: podbor_function.php プロジェクト: gblok/rsc
function getProductByBrand($brandID)
{
    $sql = '
        select
        categoryID,
        name,
        productID,
        default_picture,
        sort_order,
        enabled,
        product_code,
        uri,
        uri_opt_val
        ' . convert_prices() . '
        FROM ' . PRODUCTS_TABLE . '
        WHERE categoryID = ' . (int) $brandID . '
        ORDER BY name';
    $q = db_query($sql);
    $result = array();
    while ($row = db_fetch_assoc($q)) {
        _setPictures($row);
        $row['url'] = fu_make_url($row);
        $result[] = $row;
    }
    return $result;
}
コード例 #2
0
ファイル: class.grd.php プロジェクト: gblok/rsc
 private function set_lnk($type, $data)
 {
     switch ($type) {
         case 'product_edit':
             $href = '/admin.php?&eaction=prod&productID=' . $data['productID'];
             break;
         case 'product_page':
             $href = '/' . fu_make_url($data);
             break;
     }
     return $href;
 }
コード例 #3
0
ファイル: sitemap.php プロジェクト: gblok/rsc
 function smGetCatItm($tree)
 {
     if (!empty($tree)) {
         foreach ($tree as $k => $v) {
             $sef = fu_make_url($v);
             $cat = array('name' => $v['name'], 'lvl' => $v['level'], 'url' => $sef);
             if (!empty($v['children'])) {
                 $cat['sub'] = smGetCatItm($v['children']);
             }
             $itm[] = $cat;
         }
     }
     return $itm;
 }
コード例 #4
0
ファイル: filter_function.php プロジェクト: gblok/rsc
function f_data_prod($data)
{
    $productID = $data['productID'];
    $src = $data['picture'] ? 'data/small/' . $data['picture'] : 'data/empty.png';
    $data['src'] = '/img/w130-h130/' . $src;
    $data['href'] = CONF_MOD_REWRITE ? fu_make_url($data) : ($data['href'] = '/index.php?productID=' . $productID);
    $data['name_clean'] = str_replace(array('Оригинальный', 'Совместимый'), '', $data['name']);
    $data['opt_margin'] = $data['opt_margin'] ? '<span class="hint">безналичный расчет ' . $data['margin_price_wu'] . '</span>' : '<span class="hint _empty">безналичный расчет без %</span>';
    if ($data['list_price'] == 0) {
        unset($data['list_price']);
    }
    if (CONF_SHOW_ADD2CART) {
        if ($data['ss']['cart']) {
            $data['cart']['set'] = 'type="hidden"';
            $data['cart']['hint'] = 'товар в корзине';
            $data['cart']['class'] = 'to_cart lnk is_active';
        } else {
            $data['cart']['hint'] = 'купить';
            $data['cart']['set'] = 'type="text" size="2" maxlength="2"';
            $data['cart']['class'] = 'to_cart lnk';
        }
    }
    if (!empty($data['product_extra'])) {
        $extras = array();
        foreach ($data['product_extra'] as $extra) {
            if (in_array($extra['optionID'], array(14, 15, 6, 18))) {
                $extra['value'] = $extra['option_type'] == 1 ? $extra['variant_name'] : $extra['option_value'];
                if ($extra['name'] == 'Цвет') {
                    $color = explode('~', $extra['variant_name']);
                    $color_name = trim($color[0]);
                    $color_class = trim(strtolower($color[1]));
                    $extra['value'] = ' <div class="color_wrap"><i class="ico _color _' . $color_class . '" title="цвет ' . $color_name . '}">&nbsp;</i>&nbsp;&nbsp;' . $color_name . '</div>';
                }
                $extras[] = $extra;
            }
        }
        if (!empty($extras)) {
            $data['product_extra'] = $extras;
        } else {
            unset($data['product_extra']);
        }
    }
    return $data;
}
コード例 #5
0
ファイル: breadcumb.php プロジェクト: gblok/rsc
function dizBreadcrumbPath($array, $parentId, $reset = true)
{
    static $breadcrumb;
    if ($reset == true) {
        $breadcrumb = array();
    }
    foreach ($array as $category) {
        if ($parentId == $category['categoryID']) {
            if (CONF_MOD_REWRITE) {
                $url = fu_make_url($category);
                //                  $url = 'category_' . $category['categoryID'] . '.html';
            } else {
                $url = 'index.php?categoryID=' . $category['categoryID'];
            }
            $breadcrumb[] = array('name' => $category['name'], 'categoryID' => $category['categoryID'], 'url' => $url);
            if ($category['parent'] > 0) {
                dizBreadcrumbPath($array, $category['parent'], false);
            }
        }
    }
    return array_reverse($breadcrumb);
}
コード例 #6
0
ファイル: modules_sitemap.php プロジェクト: gblok/rsc
function getsm_catalog($parent, $level)
{
    $f = "";
    $sql = '
        SELECT
        categoryID,
        uri
        FROM ' . CATEGORIES_TABLE . '
        WHERE parent=' . (int) $parent . '
        ORDER BY sort_order, name';
    $q = db_query($sql) or die(db_error());
    while ($row = db_fetch_assoc($q)) {
        if (CONF_MOD_REWRITE) {
            //            $sef = 'category_' . $row['categoryID'] . '.html';
            $sef = fu_make_url($row);
            $url = 'http://' . $_SERVER["SERVER_NAME"] . '/' . $sef;
        } else {
            $url = "http://" . $_SERVER["SERVER_NAME"] . "/index.php?categoryID=" . $row['categoryID'];
        }
        $f .= getsm_element($url, $_REQUEST['catalog_priority'], $_REQUEST['catalog_freq']);
        //add products
        $sql = '
        SELECT
        productID,
        categoryID,
        uri,
        uri_opt_val
        FROM ' . PRODUCTS_TABLE . '
        WHERE categoryID=' . $row['categoryID'] . ' AND enabled=1
        ORDER BY sort_order';
        $q1 = db_query($sql) or die(db_error());
        while ($row1 = db_fetch_assoc($q1)) {
            if (CONF_MOD_REWRITE) {
                //                $sef = 'product_' . $row1['productID'] . '.html';
                $sef = fu_make_url($row1);
                //                fbug($sef);
                $url = "http://" . $_SERVER["SERVER_NAME"] . "/" . $sef;
            } else {
                $url = "http://" . $_SERVER["SERVER_NAME"] . "/index.php?productID=" . $row1['productID'];
            }
            $f .= getsm_element($url, $_REQUEST['catalog_priority'], $_REQUEST['catalog_freq']);
        }
        //process all subcategories
        $f .= getsm_catalog($row['categoryID'], $level + 1);
    }
    return $f;
}
コード例 #7
0
ファイル: modules_yandex.php プロジェクト: gblok/rsc
 function _exportProducts($f, $rate, $export_product_name, $categories_select)
 {
     if (!count($categories_select)) {
         return 0;
     }
     include_once "core/classes/class.html2text.php";
     include_once "core/classes/class.htmlparser.php";
     fputs($f, "  <offers>\n");
     //товары с нулевым остатком на складе
     if (isset($_POST["yandex_dont_export_negative_stock"])) {
         $clause = " and in_stock>0";
     } else {
         $clause = "";
     }
     //какое описание экспортировать
     if ($_POST["yandex_export_description"] == 1) {
         $dsc = "description";
         $dsc_q = ", " . $dsc;
     } else {
         if ($_POST["yandex_export_description"] == 2) {
             $dsc = "brief_description";
             $dsc_q = ", " . $dsc;
         } else {
             $dsc = "";
             $dsc_q = "";
         }
     }
     $clause .= " and categoryID IN (" . implode(", ", xEscSQL($categories_select)) . ")";
     $sql = '
     SELECT
     productID,
     name,
     Price,
     categoryID,
     default_picture' . $dsc_q . ',
     in_stock,
     uri,
     uri_opt_val
     ' . convert_prices() . '
     FROM ' . PRODUCTS_TABLE . '
     WHERE enabled=1' . $clause;
     $q = db_query($sql);
     $store_url = correct_URL(CONF_FULL_SHOP_URL);
     while ($product = db_fetch_row($q)) {
         $price_row = priceRow($product);
         $url = $store_url . fu_make_url($product);
         fputs($f, " <offer available=\"" . ($product['in_stock'] || !CONF_CHECKSTOCK ? 'true' : 'false') . "\" id=\"" . $product["productID"] . "\">\n");
         fputs($f, "   <url>" . $url . "</url>\n");
         //fputs($f, "   <price>" . roundf($product["Price"] * $rate) . "</price>\n");
         fputs($f, "   <price>" . $price_row['Price_base'] . "</price>\n");
         fputs($f, "   <currencyId>RUR</currencyId>\n");
         fputs($f, "   <categoryId>" . $product["categoryID"] . "</categoryId>\n");
         if ($product["default_picture"] != NULL) {
             $pic_clause = " and photoID=" . (int) $product["default_picture"];
         } else {
             $pic_clause = "";
         }
         $q1 = db_query("select filename, thumbnail from " . PRODUCT_PICTURES . " where productID=" . (int) $product["productID"] . $pic_clause);
         $pic_row = db_fetch_row($q1);
         if ($pic_row) {
             if (strlen($pic_row["filename"]) && file_exists("data/small/" . $pic_row["filename"])) {
                 fputs($f, "   <picture>" . $store_url . "data/small/" . str_replace(' ', '%20', _deleteHTML_Elements($pic_row["filename"])) . "</picture>\n");
             } else {
                 if (strlen($pic_row["thumbnail"]) && file_exists("data/medium/" . $pic_row["thumbnail"])) {
                     fputs($f, "   <picture>" . $store_url . "data/medium/" . str_replace(' ', '%20', _deleteHTML_Elements($pic_row["thumbnail"])) . "</picture>\n");
                 }
             }
         }
         switch ($export_product_name) {
             default:
             case 'only_name':
                 $_NameAddi = '';
                 break;
             case 'path_and_name':
                 $_NameAddi = '';
                 $_t = catCalculatePathToCategory($product['categoryID']);
                 foreach ($_t as $__t) {
                     if ($__t['categoryID'] != 1) {
                         $_NameAddi .= $__t['name'] . ':';
                     }
                 }
                 break;
         }
         $product["name"] = _deleteHTML_Elements($_NameAddi . $product["name"]);
         fputs($f, "   <name>" . $product["name"] . "</name>\n");
         if (strlen($dsc) > 0) {
             $product_dsc = new Html2Text($product[$dsc], 10000);
             $product_dsc = $product_dsc->convert();
             fputs($f, "   <description>" . _deleteHTML_Elements($product_dsc) . "</description>\n");
         } else {
             fputs($f, "   <description></description>\n");
         }
         fputs($f, " </offer>\n");
     }
     fputs($f, "  </offers>\n");
 }
コード例 #8
0
ファイル: product_detailed.php プロジェクト: gblok/rsc
 }
 //get selected category info
 $q = db_query("select categoryID, name, description, picture, allow_products_comparison FROM " . CATEGORIES_TABLE . " WHERE categoryID=" . (int) $categoryID);
 $row = db_fetch_row($q);
 if ($row) {
     if (!file_exists("data/category/" . $row[3])) {
         $row[3] = "";
     }
     $smarty->assign("selected_category", $row);
     $a["allow_products_comparison"] = $row[4];
 } else {
     $smarty->assign("selected_category", NULL);
     $a["allow_products_comparison"] = NULL;
 }
 if (CONF_MOD_REWRITE) {
     $a['url'] = fu_make_url($a);
 } else {
     $a['url'] = '/index.php?productID=' . $productID;
 }
 //calculate a path to the category
 //            $smarty->assign("product_category_path", catCalculatePathToCategory((int) $categoryID));
 //reviews number
 //            $q = db_query("select count(*) FROM " . DISCUSSIONS_TABLE . " WHERE productID=" . $productID);
 //            $k = db_fetch_row($q);
 //            $k = $k[0];
 //
 //
 //extra parameters
 $extra = psGetExtra($productID);
 $extracount = count($extra);
 if ($extra) {
コード例 #9
0
ファイル: pricelist.php プロジェクト: gblok/rsc
function pricessCategories($parent, $level)
{
    //same as processCategories(), except it creates a pricelist of the shop
    $out = array();
    $cnt = 0;
    $sql = '
        SELECT
        categoryID,
        name,
        uri
        FROM ' . CATEGORIES_TABLE . '
        WHERE parent= ' . (int) $parent . '
        ORDER BY sort_order, name';
    $q1 = db_query($sql);
    while ($row = db_fetch_row($q1)) {
        $r = hexdec(substr('999999', 0, 2));
        $g = hexdec(substr('999999', 2, 2));
        $b = hexdec(substr('999999', 4, 2));
        $m = (double) max($r, max($g, $b));
        $r = round((190 + 20 * min($level, 3)) * $r / $m);
        $g = round((190 + 20 * min($level, 3)) * $g / $m);
        $b = round((190 + 20 * min($level, 3)) * $b / $m);
        $c = dechex($r) . dechex($g) . dechex($b);
        //final color
        //add category to the output
        $out[$cnt][0] = $row[0];
        $out[$cnt][1] = $row[1];
        $out[$cnt][2] = $level;
        $out[$cnt][3] = 1;
        $out[$cnt][4] = 0;
        //0 is for category, 1 - product
        $out[$cnt]['url'] = fu_make_url($row);
        $cnt++;
        if (!isset($_GET["sort"])) {
            $order_clause = "order by " . CONF_DEFAULT_SORT_ORDER . "";
        } else {
            //verify $_GET["sort"]
            if (!(!strcmp($_GET["sort"], "name") || !strcmp($_GET["sort"], "Price") || !strcmp($_GET["sort"], "customers_rating"))) {
                $_GET["sort"] = "name";
            }
            $order_clause = " order by " . xEscSQL($_GET["sort"]);
            if (isset($_GET["direction"])) {
                if (!strcmp($_GET["direction"], "DESC")) {
                    $order_clause .= " DESC ";
                } else {
                    $order_clause .= " ASC ";
                }
            }
        }
        //add products
        //        Price,
        //        in_stock,
        $sql = '

            SELECT
            productID,
            name,
            product_code,
            uri,
            uri_opt_val,
            categoryID
             ' . convert_prices() . '
            FROM ' . PRODUCTS_TABLE . '
            WHERE categoryID=' . $row[0] . ' AND Price > 0 AND enabled=1 ' . $order_clause;
        $q = db_query($sql);
        while ($row1 = db_fetch_row($q)) {
            if ($row1['Price'] < 0) {
                $cennik = "n/a";
                $row1['Price'] = "n/a";
            } else {
                $cennik = show_price($row1['Price']);
                $row1['Price'] = show_price($row1['Price'], 0, false);
            }
            $out[$cnt][0] = $row1['productID'];
            $out[$cnt][1] = $row1['name'];
            $out[$cnt][2] = $level;
            $out[$cnt][3] = "FFFFFF";
            $out[$cnt][4] = 1;
            //0 is for category, 1 - product
            $out[$cnt][5] = $cennik;
            $out[$cnt][6] = $row1['in_stock'];
            $out[$cnt][7] = $row1['product_code'];
            $out[$cnt][8] = $row1['Price'];
            $out[$cnt]['url'] = fu_make_url($row1);
            $cnt++;
        }
        //process all subcategories
        $sub_out = pricessCategories($row[0], $level + 1);
        //add $sub_out to the end of $out
        $c_sub_out = count($sub_out);
        for ($j = 0; $j < $c_sub_out; $j++) {
            $out[] = $sub_out[$j];
            $cnt++;
        }
    }
    return $out;
}
コード例 #10
0
function psGetRelatedProducts($products, $extra = null)
{
    if (is_array($products)) {
        $sql = '
        SELECT
        s.productID,
        s.categoryID,
        s.name,
        s.uri,
        s.uri_opt_val,
        p.filename AS src
        ' . convert_prices() . '
        FROM ' . PRODUCTS_TABLE . ' AS s
        LEFT JOIN ' . PRODUCT_PICTURES . ' AS p ON (s.default_picture=p.photoID AND s.productID=p.productID)
        WHERE s.productID IN (' . implode(',', $products) . ') AND s.enabled=1
        ORDER by s.name';
        $q = db_query($sql);
        $result = array();
        while ($row = db_fetch_assoc($q)) {
            if (!empty($extra)) {
                $row["color"] = psGetColor($row["productID"], $extra);
                $row["resource"] = psGetVal('resource', $extra, $row["productID"]);
            }
            $row['name'] = trim(str_replace(array('Оригинальный', 'Совместимый'), '', $row['name']));
            $row['url'] = fu_make_url($row);
            $row['ss'] = dizSpecialSet($row['productID']);
            $price_row = priceRow($row);
            $result[] = array_merge($row, $price_row);
        }
    }
    return $result;
}
コード例 #11
0
ファイル: diz_function.php プロジェクト: gblok/rsc
function dizAjxSearch($search)
{
    global $extra_set;
    $typeID = $extra_set['typeID'];
    $likeSearch = $search;
    $search = dizSearchPre($search);
    if (!empty($search)) {
        //        $sql = '
        //        SELECT
        //        p.productID,
        //        p.name,
        //        i.filename
        //        FROM  ' . PRODUCTS_TABLE . ' AS p
        //        JOIN ' . PRODUCTS_OPTIONS_SET_TABLE . ' AS s ON (s.optionID =' . $typeID . ' AND p.productID = s.productID )
        //        LEFT JOIN ' . PRODUCT_PICTURES . ' AS i ON (p.default_picture = i.photoID AND p.productID = i.productID)
        //        WHERE MATCH (p.meta_keywords, p.name, p.title) AGAINST ("' . implode(' ', $search) . '" IN BOOLEAN MODE)
        //        AND p.enabled=1';
        $sql = '
SELECT
categoryID,
productID,
name,
uri,
uri_opt_val
' . convert_prices() . '
FROM  ' . PRODUCTS_TABLE . '
WHERE (MATCH (meta_keywords, name, title) AGAINST ("' . implode(' ', $search) . '" IN BOOLEAN MODE) OR (LOWER(name) LIKE "%' . $likeSearch . '%"))
AND enabled=1';
        $q = db_query($sql);
        while ($row = db_fetch_assoc($q)) {
            $row['url'] = fu_make_url($row);
            $row['Price'] = priceСost($row['productID'], $row['Price']);
            unset($row['uri']);
            unset($row['uri_opt_val']);
            $result[] = $row;
        }
        $total = array('name' => 'Найдено товаров :', 'count' => count($result));
        if (count($result) > 10) {
            $result = array_slice($result, 0, 10);
        }
        if (!empty($total['count'])) {
            $result[] = $total;
        }
        return iconv_deep('utf-8', 'utf-8', $result);
    }
}