PageRenderTime 43ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/modules/pages/print_page/main_template_vars.php

https://github.com/happyxlq/lt_svn
PHP | 191 lines | 122 code | 44 blank | 25 comment | 15 complexity | 9ae46c805c2c3f164196aac7379644dd MD5 | raw file
Possible License(s): AGPL-1.0, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * product_info main_template_vars.php
  4. *
  5. * @package productTypes
  6. * @copyright Copyright 2003-2007 Zen Cart Development Team
  7. * @copyright Portions Copyright 2003 osCommerce
  8. * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  9. * @version $Id: main_template_vars.php 6275 2007-05-02 11:46:37Z drbyte $
  10. */
  11. /*
  12. * Extracts and constructs the data to be used in the product-type template tpl_TYPEHANDLER_info_display.php
  13. */
  14. // This should be first line of the script:
  15. $zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_START_PRODUCT_INFO');
  16. $module_show_categories = PRODUCT_INFO_CATEGORIES;
  17. $sql = "select count(*) as total
  18. from " . TABLE_PRODUCTS . " p, " .
  19. TABLE_PRODUCTS_DESCRIPTION . " pd
  20. where p.products_status = '1'
  21. and p.products_id = '" . (int)$_GET['products_id'] . "'
  22. and pd.products_id = p.products_id
  23. and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
  24. $res = $db->Execute($sql);
  25. if ( $res->fields['total'] < 1 ) {
  26. $tpl_page_body = '/tpl_product_info_noproduct.php';
  27. } else {
  28. $tpl_page_body = '/tpl_print_page_display.php';
  29. $sql = "update " . TABLE_PRODUCTS_DESCRIPTION . "
  30. set products_viewed = products_viewed+1
  31. where products_id = '" . (int)$_GET['products_id'] . "'
  32. and language_id = '" . (int)$_SESSION['languages_id'] . "'";
  33. $res = $db->Execute($sql);
  34. $sql = "select p.products_id, pd.products_name,
  35. pd.products_description, p.products_model,
  36. p.products_quantity, p.products_image,
  37. pd.products_url, p.products_price,
  38. p.products_tax_class_id, p.products_date_added,
  39. p.products_date_available, p.manufacturers_id, p.products_quantity,
  40. p.products_weight, p.products_priced_by_attribute, p.product_is_free,
  41. p.products_qty_box_status,p.products_quantity_order_min,
  42. p.products_quantity_order_max,
  43. p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter
  44. from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
  45. where p.products_status = '1'
  46. and p.products_id = '" . (int)$_GET['products_id'] . "'
  47. and pd.products_id = p.products_id
  48. and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
  49. $product_info = $db->Execute($sql);
  50. $products_price_sorter = $product_info->fields['products_price_sorter'];
  51. $products_price = $currencies->display_price($product_info->fields['products_price'],
  52. zen_get_tax_rate($product_info->fields['products_tax_class_id']));
  53. $manufacturers_name= zen_get_products_manufacturers_name((int)$_GET['products_id']);
  54. if ($new_price = zen_get_products_special_price($product_info->fields['products_id'])) {
  55. $specials_price = $currencies->display_price($new_price,
  56. zen_get_tax_rate($product_info->fields['products_tax_class_id']));
  57. }
  58. // set flag for attributes module usage:
  59. $flag_show_weight_attrib_for_this_prod_type = SHOW_PRODUCT_INFO_WEIGHT_ATTRIBUTES;
  60. // get attributes
  61. require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_ATTRIBUTES));
  62. // if review must be approved or disabled do not show review
  63. $review_status = " and r.status = '1'";
  64. $reviews_query = "select r.reviews_id,r.customers_name,r.reviews_rating,r.date_added,r.reviews_is_featured,rd.reviews_title,rd.reviews_text from " . TABLE_REVIEWS . " r, "
  65. . TABLE_REVIEWS_DESCRIPTION . " rd
  66. where r.products_id = '" . (int)$_GET['products_id'] . "'
  67. and r.reviews_id = rd.reviews_id
  68. and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "'" .
  69. $review_status;
  70. $reviews = $db->Execute($reviews_query);
  71. }
  72. require(DIR_WS_MODULES . zen_get_module_directory('product_prev_next.php'));
  73. $products_id = $product_info->fields['products_id'];
  74. $products_name = $product_info->fields['products_name'];
  75. $products_model = $product_info->fields['products_model'];
  76. $products_description = $product_info->fields['products_description'];
  77. $products_quantity_order_min = $product_info->fields['products_quantity_order_min'];
  78. if ($product_info->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
  79. $products_image = PRODUCTS_IMAGE_NO_IMAGE;
  80. } else {
  81. $products_image = $product_info->fields['products_image'];
  82. }
  83. $products_url = $product_info->fields['products_url'];
  84. $products_date_available = $product_info->fields['products_date_available'];
  85. $products_date_added = $product_info->fields['products_date_added'];
  86. $products_manufacturer = $manufacturers_name;
  87. $products_weight = $product_info->fields['products_weight'];
  88. $products_quantity = $product_info->fields['products_quantity'];
  89. $products_qty_box_status = $product_info->fields['products_qty_box_status'];
  90. $products_quantity_order_max = $product_info->fields['products_quantity_order_max'];
  91. $products_base_price = $currencies->display_price(zen_get_products_base_price((int)$_GET['products_id']),
  92. zen_get_tax_rate($product_info->fields['products_tax_class_id']));
  93. $product_is_free = $product_info->fields['product_is_free'];
  94. $products_tax_class_id = $product_info->fields['products_tax_class_id'];
  95. $module_show_categories = PRODUCT_INFO_CATEGORIES;
  96. $module_next_previous = PRODUCT_INFO_PREVIOUS_NEXT;
  97. $products_id_current = (int)$_GET['products_id'];
  98. $products_discount_type = $product_info->fields['products_discount_type'];
  99. $products_discount_type_from = $product_info->fields['products_discount_type_from'];
  100. /**
  101. * Load product-type-specific main_template_vars
  102. */
  103. $prod_type_specific_vars_info = DIR_WS_MODULES . 'pages/' . $current_page_base . '/main_template_vars_product_type.php';
  104. if (file_exists($prod_type_specific_vars_info)) {
  105. include_once($prod_type_specific_vars_info);
  106. }
  107. $zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_PRODUCT_TYPE_VARS_PRODUCT_INFO');
  108. /**
  109. * Load all *.PHP files from the /includes/templates/MYTEMPLATE/PAGENAME/extra_main_template_vars
  110. */
  111. $extras_dir = $template->get_template_dir('.php', DIR_WS_TEMPLATE, $current_page_base . 'extra_main_template_vars', $current_page_base . '/' . 'extra_main_template_vars');
  112. if ($dir = @dir($extras_dir)) {
  113. while ($file = $dir->read()) {
  114. if (!is_dir($extras_dir . '/' . $file)) {
  115. if (preg_match('/\.php$/', $file) > 0) {
  116. $directory_array[] = '/' . $file;
  117. }
  118. }
  119. }
  120. $dir->close();
  121. }
  122. if (sizeof($directory_array)) sort($directory_array);
  123. for ($i = 0, $n = sizeof($directory_array); $i < $n; $i++) {
  124. if (file_exists($extras_dir . $directory_array[$i])) include($extras_dir . $directory_array[$i]);
  125. }
  126. // build show flags from product type layout settings
  127. $flag_show_product_info_starting_at = zen_get_show_product_switch($_GET['products_id'], 'starting_at');
  128. $flag_show_product_info_model = zen_get_show_product_switch($_GET['products_id'], 'model');
  129. $flag_show_product_info_weight = zen_get_show_product_switch($_GET['products_id'], 'weight');
  130. $flag_show_product_info_quantity = zen_get_show_product_switch($_GET['products_id'], 'quantity');
  131. $flag_show_product_info_manufacturer = zen_get_show_product_switch($_GET['products_id'], 'manufacturer');
  132. $flag_show_product_info_in_cart_qty = zen_get_show_product_switch($_GET['products_id'], 'in_cart_qty');
  133. $flag_show_product_info_tell_a_friend = zen_get_show_product_switch($_GET['products_id'], 'tell_a_friend');
  134. $flag_show_product_info_reviews = zen_get_show_product_switch($_GET['products_id'], 'reviews');
  135. $flag_show_product_info_reviews_count = zen_get_show_product_switch($_GET['products_id'], 'reviews_count');
  136. $flag_show_product_info_date_available = zen_get_show_product_switch($_GET['products_id'], 'date_available');
  137. $flag_show_product_info_date_added = zen_get_show_product_switch($_GET['products_id'], 'date_added');
  138. $flag_show_product_info_url = zen_get_show_product_switch($_GET['products_id'], 'url');
  139. $flag_show_product_info_additional_images = zen_get_show_product_switch($_GET['products_id'], 'additional_images');
  140. $flag_show_product_info_free_shipping = zen_get_show_product_switch($_GET['products_id'], 'always_free_shipping_image_switch');
  141. require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCTS_QUANTITY_DISCOUNTS));
  142. $zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_EXTRA_PRODUCT_INFO');
  143. require($template->get_template_dir($tpl_page_body,DIR_WS_TEMPLATE, $current_page_base,'templates'). $tpl_page_body);
  144. //require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_ALSO_PURCHASED_PRODUCTS));
  145. // This should be last line of the script:
  146. $zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_END_PRODUCT_INFO');
  147. ?>