| | All rights reserved | +------------------------------------------------------------------------------+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "license.txt"| | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE | | AT THE FOLLOWING URL: http://www.magneticone.com/store/license.php | | | | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE | | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT MAGNETICONE | | (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING | | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). | | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT | | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, | | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY | | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS | | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS | | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND | | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS | | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE | | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE. | | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. | | | | The Developer of the Code is MagneticOne, | | Copyright (C) 2006 All Rights Reserved. | +-----------------------------------------------------------------------------*/ define('M1_RSS_GENERATOR_NAME', 'osCommerce RSS Generator'); define('M1_CONFIGURATION_VALUE_FIELD', 'configuration_value'); define('M1_CONFIGURATION_KEY_FIELD', 'configuration_key'); class oscm1_main { var $export_products = array(); // list of the products for export. array key is product id var $export_categories = array(); // list of the categories for export. array key is category id var $options = array(); // list of export options var $available_currencies_full = array(); // list of currencies in cart /** * Class constructor, reads configuration only * * @param none * @return boolean */ function oscm1_main() { $this->ReadConfig(); return true; } /** * Updates onfiguration value. Should be changed for different carts * * @param string field name to be updated * @param string fields value to be updated * @param string configuration key for WHERE * @return boolean */ function update($field, $value, $where) { return tep_db_perform(TABLE_CONFIGURATION, array($field=>$value), 'update', $where); } /** * Get onfiguration value. Should be changed for different carts * * @param string configuration key for WHERE * @return string */ function select_config_value ($where) { $query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key='$where'"); if (tep_db_num_rows($query) > 0) { $row = tep_db_fetch_array($query); $value = $row['configuration_value']; } else { $value = ''; } return $value; } /** * Selects products for export. Should be changed for different carts * * @param array categories to export products from * @param array languages to export products from * @return array */ function select_products($categories = '', $languages = ''){ $where = ' 1=1 '; if ($categories != '') { $where .= " AND c.categories_id IN ($categories)"; } if ($languages != '') { $where .= " AND pd.language_id IN ($languages)"; } if ($this->options['get_all_products'] != true) { $where .= " AND products_status=1"; } $sql = "SELECT p.*, c.*, pd.*, cd.*, m.*, s.specials_new_products_price, l.name as languages_name, l.code as languages_code from " . TABLE_PRODUCTS . " p INNER JOIN " . TABLE_PRODUCTS_TO_CATEGORIES. " pc ON p.products_id=pc.products_id INNER JOIN " . TABLE_CATEGORIES . " c ON c.categories_id=pc.categories_id INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id INNER JOIN " . TABLE_CATEGORIES_DESCRIPTION. " cd ON c.categories_id=cd.categories_id LEFT JOIN " . TABLE_MANUFACTURERS . " m ON p.manufacturers_id=m.manufacturers_id LEFT JOIN " . TABLE_SPECIALS . " s ON ( s.products_id = p.products_id AND ( ( (s.expires_date > CURRENT_DATE) OR (s.expires_date = 0) ) AND ( s.status = 1 ) ) ) INNER JOIN ".TABLE_LANGUAGES ." l on pd.language_id=l.languages_id and cd.language_id=l.languages_id WHERE $where -- GROUP BY p.products_id, pd.language_id"; $query = tep_db_query($sql); if (tep_db_num_rows($query) > 0) { while($curr_product = tep_db_fetch_array($query)) { $output[] = $curr_product; } } return $output; } /** * Selects availble currencies in cart. Should be changed for different carts * * @return array */ function get_currencies() { $cc_code = $this->get_default_currency(); $query = tep_db_query("SELECT * FROM " . TABLE_CURRENCIES); if (tep_db_num_rows($query) > 0) { while($curr_currency = tep_db_fetch_array($query)) { $this->available_currencies_full[$curr_currency['currencies_id']]['id'] = $curr_currency['currencies_id']; $this->available_currencies_full[$curr_currency['currencies_id']]['name'] = $curr_currency['title']; $this->available_currencies_full[$curr_currency['currencies_id']]['text'] = $curr_currency['title']; $this->available_currencies_full[$curr_currency['currencies_id']]['code'] = $curr_currency['code']; $this->available_currencies_full[$curr_currency['currencies_id']]['symbol_left'] = $curr_currency['symbol_left']; $this->available_currencies_full[$curr_currency['currencies_id']]['symbol_right'] = $curr_currency['symbol_right']; $this->available_currencies_full[$curr_currency['currencies_id']]['value'] = $curr_currency['value']; if (strtoupper($curr_currency['code']) == strtoupper($cc_code)) { $this->default_currency = $curr_currency['currencies_id']; } } } } /** * Selects categories for export. Should be changed for different carts * * @param array categories to export products from * @param array languages to export products from * @return array */ function select_categories($categories = '', $languages = '') { $where = ' 1=1 '; if ($categories != '') { $where .= " AND c.categories_id IN ($categories)"; } if ($languages != '') { $where .= " AND cd.language_id IN ($languages)"; } $query = tep_db_query(" SELECT * FROM categories c , categories_description cd WHERE c.categories_id = cd.categories_id AND $where" ); if (tep_db_num_rows($query) > 0) { while($curr_category = tep_db_fetch_array($query)) { $output[] = $curr_category; } return $output; } } function Export() { $this->FormatGeneralInformation(); $this->GetExportParams(); $this->get_export_products(); $this->get_export_categories(); $this->GenerateExport(); } function FormatGeneralInformation() { $this->export_general['store_name'] = utf8_encode(STORE_NAME); $this->export_general['rss_title'] = utf8_encode(STORE_NAME); $this->export_general['weblink'] = utf8_encode(HTTP_SERVER); $this->export_general['description'] = utf8_encode(TITLE); $this->export_general['email_address'] = utf8_encode(STORE_OWNER_EMAIL_ADDRESS); } function get_export_products() { $tmp = $this->select_products($this->options['export_categories'], $this->options['export_languages']); if (is_array($tmp)) { foreach ($tmp as $k => $v) { $this->export_products[$v['products_id']]['id'] = $v['products_id']; $this->export_products[$v['products_id']]['quantity'] = $v['products_quantity']; $this->export_products[$v['products_id']]['image'] = $v['products_image']; $this->export_products[$v['products_id']]['price'] = $v['products_price']; $this->export_products[$v['products_id']]['special_price'] = $v['specials_new_products_price']; $this->export_products[$v['products_id']]['date_added'] = $v['products_date_added']; $this->export_products[$v['products_id']]['last_modified'] = $v['products_last_modified']; $this->export_products[$v['products_id']]['date_available'] = $v['products_date_available']; $this->export_products[$v['products_id']]['name'] = $v['products_name']; $this->export_products[$v['products_id']]['description'] = $v['products_description']; $this->export_products[$v['products_id']]['url'] = $v['products_url']; $this->export_products[$v['products_id']]['category_id'] = $v['categories_id']; $this->export_products[$v['products_id']]['category_name'] = $v['categories_name']; $this->export_products[$v['products_id']]['manufacturer_name'] = $v['manufacturers_name']; $this->export_products[$v['products_id']]['language_name'] = $v['languages_name']; $this->export_products[$v['products_id']]['language_code'] = strtoupper($v['languages_code']); $this->export_products[$v['products_id']]['instock'] = $v['products_status']; $this->export_products[$v['products_id']]['model'] = $v['products_model']; $this->export_products[$v['products_id']]['weight'] = $v['weight']; $this->export_products[$v['products_id']]['sku'] = $v['products_id']; $this->export_products[$v['products_id']]['mysimon_id'] = $v['mysimon_id']; } } } function get_export_categories() { $tmp = $this->select_categories($this->options['export_categories'], $this->options['export_languages']); if (is_array($tmp)) { foreach ($tmp as $k => $v) { $this->export_categories[$v['categories_id']]['id'] = $v['categories_id']; $this->export_categories[$v['categories_id']]['parent_id'] = $v['parent_id']; $this->export_categories[$v['categories_id']]['image'] = $v['categories_image']; $this->export_categories[$v['categories_id']]['name'] = $v['categories_name']; $this->export_categories[$v['categories_id']]['date_added'] = $v['date_added']; $this->export_categories[$v['categories_id']]['last_modified'] = $v['last_modified']; } } } function GenerateExport() { foreach ($this->supported_formats as $k => $v) { if ($v['id'] == $this->options['export_format']) { $this->export_general['export_format_name'] = $v['text']; } } if ($this->export_general['export_format_name'] == '') { echo "unsupported format: check configuration"; exit(); } if (!method_exists($this,'GenerateFormat_' . $this->options['export_format'])) { echo "unsupported format: not implemented"; exit(); } else { call_user_method('GenerateFormat_' . $this->options['export_format'], $this); } } function format_image_url($img) { if ($img != '') { return HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $img; } else { return ''; } } function format_product_url($id, $lang_id, $safe = true) { $category_path = tep_get_path($this->export_products[$id]['category_id']); $link = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $id . '&language=' . strtolower($lang_id) . '&' . $category_path); if (defined('SID') && SID !== "") { $session_name = SID; } else { $session_name = tep_session_name(); } if ($safe) { return htmlspecialchars(substr($link, 0, strpos($link, $session_name)-1)); } else { return substr($link, 0, strpos($link, $session_name)-1); } } function get_default_currency() { return $this->select_config_value('DEFAULT_CURRENCY'); } function prepare_input($src) { return tep_db_prepare_input($src); } } //// // Output a form pull down menu function tep_draw_pull_down_menu_multiple($name, $values, $default = '', $parameters = '', $required = false, $size = 1, $multiple = false) { /* if ($multiple == false) { return tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false); } */ if ($multiple) { $parameters .= " size='$size' multiple='multiple' "; } $field = ''; if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field; } /** * Outputs variable or array * * @param string, integer, array, boolean, float $var */ function dump($var) { global $dumpCounterRND; echo "
".(int)$dumpCounterRND++.". ";

        if (is_array($var)) {
            print_r($var);
        } else {
            var_dump($var);
        }

        echo "

"; } $d = dir(DIR_FS_CATALOG.DIR_WS_CLASSES . 'oscm1/'); while (false !== ($entry = $d->read())) { if ($entry != '.' && $entry != '..') { require(DIR_FS_CATALOG.DIR_WS_CLASSES . 'oscm1/' . $entry); } } ?>