| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:28:27 2008 ] | [ PgMarket 2.2.3 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 // (C) 2000-2002 Marco Pratesi <marco@pgmarket.net> 3 // (C) 2000 Ying Zhang (ying@zippydesign.com) 4 5 include ("../config.inc.php"); 6 include ("../common.inc.php"); 7 8 $id = nvl($_GET["id"], 1); 9 if (!isset($_GET["page_number"])) { 10 $page_number = 1; 11 } else { 12 $page_number = max(1, abs(intval($_GET["page_number"]))); 13 } 14 15 $DOC_TITLE = "Shopping_Catalog"; 16 $PGM_SESSION["goback"]["request_uri"] = stripsid(me() . "?" . $_SERVER["QUERY_STRING"]); 17 include ($CFG["dirroot"] . "header.php"); 18 19 build_category_path($id, $category_path); 20 21 /* get the name and description of all the sub-categories under this one */ 22 $qid_c = new PGM_Sql(); 23 //get_subcategories($qid_c, $id); 24 $qid_c->pgm_lang_join_query( 25 $CFG["base_lang"], 26 array("categories c", "categories_i18n l"), 27 array(array("c.id", "l.category_id", 1, $PGM_SESSION["lang"])), 28 array(array("l.name AS lname")), 29 "c.id, c.name, c.special_level", 30 "", 31 "parent_id = '$id' AND id > 1", 32 "special_level, name", 33 array() 34 ); 35 /* get all the products under this category */ 36 $qid_p = new PGM_Sql(); 37 //get_products_under_category($qid_p, $id, $page_number, $num); 38 $qid_p->query(" 39 SELECT COUNT(p.id) AS cnt 40 FROM products p, products_categories pc 41 WHERE p.id = pc.product_id AND pc.category_id = '$id' 42 "); 43 $qid_p->next_record(); 44 include ($CFG["libdir"] . "pgm_pager.inc.php"); 45 if (!isset($_GET["page_number"])) { 46 $page_number = 1; 47 } else { 48 $page_number = max(1, abs(intval($_GET["page_number"]))); 49 } 50 $result = pgm_pager($ME, $qid_p->f("cnt"), $PGM_SESSION["products_per_catalog_page"], $page_number); 51 $limit = $result["last"] - $result["first"] + 1; 52 $qid_p->pgm_lang_join_query( 53 $CFG["base_lang"], 54 array("products p", "products_i18n l"), 55 array(array("p.id", "l.product_id", 1, $PGM_SESSION["lang"])), 56 array(array("l.name AS lname", "l.description AS ldescription")), 57 "p.id, p.code, p.name AS name, p.price, p.discount, p.discqty, p.weight, p.special_flag, p.special_level, p.description, p.thumbtype, p.thumbwidth, p.thumbheight, pc.category_id, b.name AS bname, i.iva", 58 "products_categories pc, brands b, iva i", 59 "p.id = pc.product_id AND p.brand_id = b.id AND p.iva_id = i.id AND pc.category_id = '$id'", 60 "special_level ASC", 61 array($result["first"], $limit) 62 ); 63 64 if ($CFG["color_used"]) { 65 $qid_col = new PGM_Sql(); 66 } 67 68 $t = new Template(); 69 $t->set_file("page", "templates/index.ihtml"); 70 include ($CFG["localelangdir"] . "global-common.inc.php"); 71 include ($CFG["localelangdir"] . "global-shopping.inc.php"); 72 include ($CFG["localelangdir"] . "global-admin.inc.php"); 73 $t->set_var(array( 74 "wwwroot" => $CFG["wwwroot"], 75 "productswww" => $CFG["productswww"], 76 "id" => $id, 77 "category_path" => $category_path, 78 "QSID" => (SID == "") ? "" : "?" . SID 79 )); 80 81 $t->set_block("page", "noframes", "noframes_blck"); 82 $t->set_var("noframes_blck", ""); 83 $t->set_block("page", "noframes2", "noframes2_blck"); 84 $t->set_var("noframes2_blck", ""); 85 if (!$PGM_SESSION["frames_used"] || has_priv("admin")) { 86 $t->parse("noframes_blck", "noframes", true); 87 $t->set_block("noframes2", "no_sub_categories", "no_sub_categories_blck"); 88 $t->set_var("no_sub_categories_blck", ""); 89 $t->set_block("noframes2", "category_row", "category_rows"); 90 $t->set_var("category_rows", ""); 91 $t->set_block("noframes2", "adminnoframes2", "adminnoframes2_blck"); 92 $t->set_var("adminnoframes2_blck", ""); 93 $t->set_block("noframes2", "noframesnolayersmenu", "noframesnolayersmenu_blck"); 94 $t->set_var("noframesnolayersmenu_blck", ""); 95 if ($qid_c->num_rows() == 0) { 96 $t->parse("no_sub_categories_blck", "no_sub_categories", true); 97 } else { 98 while ($qid_c->next_record()) { 99 $foobar = ($qid_c->f("lname") != "") ? $qid_c->f("lname") : $qid_c->f("name"); 100 if (has_priv("admin")) { 101 $t->set_var(array( 102 "c_special_level" => $qid_c->f("special_level") . " - ", 103 "category_id" => $qid_c->f("id"), 104 "cname" => ov($foobar) 105 )); 106 } else { 107 $t->set_var(array( 108 "c_special_level" => "", 109 "category_id" => $qid_c->f("id"), 110 "cname" => ov($foobar) 111 )); 112 } 113 $t->parse("category_rows", "category_row", true); 114 } 115 } 116 if (has_priv("admin")) { 117 $t->parse("adminnoframes2_blck", "adminnoframes2", true); 118 } 119 if ((!$PGM_SESSION["frames_used"]) && (!$PGM_SESSION["layersmenu_used"])) { 120 include ($CFG["libdir"] . $CFG["dbms"] . "_treemenu_queries.inc.php"); 121 include ($CFG["libdir"] . "phplayersmenu/layersmenu.inc.php"); 122 include ($CFG["libdir"] . "phplayersmenu/layersmenu-noscript.inc.php"); 123 build_catbrowser($categories, 0); 124 if ($categories != "") { 125 $tree_mid = new XLayersMenu(); 126 $tree_mid->set_separator("^"); 127 $tree_mid->set_dirroot($CFG["dirroot"]); 128 $tree_mid->set_libdir($CFG["libdir"] . "phplayersmenu/"); 129 $tree_mid->set_libwww($CFG["libwww"] . "phplayersmenu/"); 130 $tree_mid->set_imgdir($CFG["imagesdir"]); 131 $tree_mid->set_imgwww($CFG["imageswww"]); 132 $tree_mid->set_menu_structure_string($categories); 133 $tree_mid->parse_menu_structure("navigation"); 134 $tree_mid->new_tree_menu("navigation"); 135 $t->set_var("treemenu", $tree_mid->get_tree_menu("navigation")); 136 } else { 137 $t->set_var("treemenu", ""); 138 } 139 $t->parse("noframesnolayersmenu_blck", "noframesnolayersmenu", true); 140 } 141 $t->parse("noframes2_blck", "noframes2", true); 142 } 143 144 $t->set_block("page", "products", "products_blck"); 145 $t->set_var("products_blck", ""); 146 $t->set_block("page", "no_products", "no_products_blck"); 147 $t->set_var("no_products_blck", ""); 148 if ($qid_p->num_rows() == 0) { 149 $t->parse("no_products_blck", "no_products", true); 150 } else { 151 // Let us define blocks nested inside a product_row... 152 // We indent the code to highlight the blocks' hierarchical nesting... 153 $t->set_block("products", "pages_links_top", "pages_links_top_blck"); 154 $t->set_var("pages_links_top_blck", ""); 155 $t->set_block("products", "pages_links_bottom", "pages_links_bottom_blck"); 156 $t->set_var("pages_links_bottom_blck", ""); 157 if ($result["num_pages"] > 1) { 158 $t->set_var("pages_links", $result["html"]); 159 $t->parse("pages_links_top_blck", "pages_links_top", true); 160 $t->parse("pages_links_bottom_blck", "pages_links_bottom", true); 161 } 162 $t->set_block("products", "product_row", "product_rows"); 163 $t->set_block("product_row", "brand_used", "brand_used_blck"); 164 $t->set_block("product_row", "adminprod", "adminprod_blck"); 165 $t->set_block("adminprod", "special_flag", "special_flag_blck"); 166 $t->set_block("product_row", "prodthumb", "prodthumb_blck"); 167 $t->set_block("product_row", "nothumb", "nothumb_blck"); 168 $t->set_block("product_row", "user_discount_used", "user_discount_used_blck"); 169 $t->set_block("product_row", "iva_used", "iva_used_blck"); 170 $t->set_block("product_row", "discount_block", "discount_block_blck"); 171 $t->set_block("discount_block", "discqty_block", "discqty_block_blck"); 172 $t->set_block("product_row", "weight_used", "weight_used_blck"); 173 $t->set_block("product_row", "color_used", "color_used_blck"); 174 // ... end of the blocks :) 175 $t->set_var("product_rows", ""); // Now let us reset the product rows container... 176 while ($qid_p->next_record()) { 177 // Now let us reset the blocks contents... 178 // We indent the code to highlight the blocks' hierarchical nesting... 179 $t->set_var("brand_used_blck", ""); 180 $t->set_var("adminprod_blck", ""); 181 $t->set_var("special_flag_blck", ""); 182 $t->set_var("prodthumb_blck", ""); 183 $t->set_var("nothumb_blck", ""); 184 $t->set_var("user_discount_used_blck", ""); 185 $t->set_var("iva_used_blck", ""); 186 $t->set_var("discount_block_blck", ""); 187 $t->set_var("discqty_block_blck", ""); 188 $t->set_var("weight_used_blck", ""); 189 $t->set_var("color_used_blck", ""); 190 // ... now we have reset all nested blocks :) 191 $t->set_var(array( 192 "id" => $id, 193 "product_id" => $qid_p->f("id"), 194 "product_code" => $qid_p->f("code"), 195 "pname" => ($qid_p->f("lname") != "") ? ov($qid_p->f("lname")) : ov($qid_p->f("name")), 196 "fprice" => formatted_price($qid_p->f("price")), 197 "description" => ($qid_p->f("ldescription") != "") ? ovwbr($qid_p->f("ldescription")) : ovwbr($qid_p->f("description")), 198 "productitemcount" => $PGM_SESSION["CART"]->get_product_qty($qid_p->f("id")) 199 )); 200 if (has_priv("admin")) { 201 $t->set_var("p_special_level", $qid_p->f("special_level")); 202 if ($qid_p->f("special_flag")) { 203 $t->parse("special_flag_blck", "special_flag", true); 204 } 205 $t->parse("adminprod_blck", "adminprod", true); 206 } 207 if ($CFG["images_on_file_system"] && file_exists($CFG["productsdir"] . $qid_p->f("id") . ".thumb." . $qid_p->f("thumbtype"))) { 208 $t->set_var(array( 209 "thumbwidth" => $qid_p->f("thumbwidth"), 210 "thumbheight" => $qid_p->f("thumbheight") 211 )); 212 if (has_priv("admin")) { 213 $t->set_var("thumbsrc", $CFG["wwwroot"] . "admin/getimage.php?image=" . $qid_p->f("id") . ".thumb." . $qid_p->f("thumbtype") . "&type=" . $qid_p->f("thumbtype")); 214 } else { 215 $t->set_var("thumbsrc", $CFG["productswww"] . $qid_p->f("id") . ".thumb." . $qid_p->f("thumbtype")); 216 } 217 $t->parse("prodthumb_blck", "prodthumb", true); 218 } else if (!$CFG["images_on_file_system"] && $qid_p->f("thumbtype") != "") { 219 $t->set_var(array( 220 "thumbwidth" => $qid_p->f("thumbwidth"), 221 "thumbheight" => $qid_p->f("thumbheight") 222 )); 223 if (has_priv("admin")) { 224 $t->set_var("thumbsrc", $CFG["wwwroot"] . "admin/dbgetthumb.php?id=" . $qid_p->f("id")); 225 } else { 226 $t->set_var("thumbsrc", $CFG["wwwroot"] . "dbgetthumb.php?id=" . $qid_p->f("id")); 227 } 228 $t->parse("prodthumb_blck", "prodthumb", true); 229 } else { 230 $t->parse("nothumb_blck", "nothumb", true); 231 } 232 if ($CFG["brand_used"] && $qid_p->f("bname") != "") { 233 $t->set_var("bname", ov($qid_p->f("bname"))); 234 $t->parse("brand_used_blck", "brand_used", true); 235 } 236 if ($CFG["user_discount_used"] && is_logged_in() && $PGM_SESSION["user"]["user_discount"] > 0) { 237 $t->set_var(array( 238 "user_discount" => $PGM_SESSION["user"]["user_discount"], 239 "discounted_price" => formatted_price((1.0-$PGM_SESSION["user"]["user_discount"]/100.0)*$qid_p->f("price")) 240 )); 241 $t->parse("user_discount_used_blck", "user_discount_used", true); 242 } 243 if ($CFG["iva_used"]) { 244 $t->set_var("iva", $qid_p->f("iva")); 245 $t->parse("iva_used_blck", "iva_used", true); 246 } 247 if ($qid_p->f("discount") > 0) { 248 $t->set_var("discount", $qid_p->f("discount")); 249 if ($qid_p->f("discqty") > 1) { 250 $t->set_var("discqty", $qid_p->f("discqty")); 251 $t->parse("discqty_block_blck", "discqty_block", true); 252 } 253 $t->parse("discount_block_blck", "discount_block", true); 254 } 255 if ($CFG["weight_used"]) { 256 $t->set_var("fweight", formatted_weight($qid_p->f("weight"))); 257 $t->parse("weight_used_blck", "weight_used", true); 258 } 259 if ($CFG["color_used"]) { 260 $foobar = get_product_color_options($qid_p->f("id"), $color_options, 1); 261 if ($foobar > 0) { 262 $t->set_var("color_options", $color_options); 263 $t->parse("color_used_blck", "color_used", true); 264 } 265 } 266 $t->parse("product_rows", "product_row", true); 267 } 268 $t->parse("products_blck", "products", true); 269 } 270 271 $t->pparse("out", "page"); 272 273 include ($CFG["dirroot"] . "footer.php"); 274 275 pgm_session_close($PGM_SESSION, $session_name); 276 277 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |