function getContent() { $is_one_dot_five = version_compare(_PS_VERSION_, '1.5', '>'); // Load prestashop ebay's configuration $configs = Configuration::getMultiple(array('EBAY_CATEGORY_LOADED_' . $this->ebay_profile->ebay_site_id, 'EBAY_SECURITY_TOKEN')); // Check if the module is configured if (!$this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')) { return $this->display('error_paypal_email.tpl', array('error_form_category', 'true')); } // Load categories only if necessary if (EbayCategoryConfiguration::getTotalCategoryConfigurations($this->ebay_profile->id) && Tools::getValue('section') != 'category') { $template_vars = array('isOneDotFive' => $is_one_dot_five, 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'form_categories' => EbaySynchronizer::getNbSynchronizableEbayCategorie($this->ebay_profile->id)); return $this->display('pre_form_categories.tpl', $template_vars); } // Display eBay Categories $ebay_site_id = $this->ebay_profile->ebay_site_id; if (!isset($configs['EBAY_CATEGORY_LOADED_' . $ebay_site_id]) || !$configs['EBAY_CATEGORY_LOADED_' . $ebay_site_id] || !EbayCategory::areCategoryLoaded($ebay_site_id)) { $ebay_request = new EbayRequest(); EbayCategory::insertCategories($ebay_site_id, $ebay_request->getCategories(), $ebay_request->getCategoriesSkuCompliancy()); Configuration::updateValue('EBAY_CATEGORY_LOADED_' . $ebay_site_id, 1); } // Smarty $template_vars = array('alerts' => $this->_getAlertCategories(), 'tabHelp' => '&id_tab=7', 'id_lang' => $this->context->cookie->id_lang, 'id_ebay_profile' => $this->ebay_profile->id, '_path' => $this->path, 'configs' => $configs, '_module_dir_' => _MODULE_DIR_, 'isOneDotFive' => $is_one_dot_five, 'request_uri' => $_SERVER['REQUEST_URI'], 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'date' => pSQL(date('Ymdhis')), 'form_categories' => EbaySynchronizer::getNbSynchronizableEbayCategorie($this->ebay_profile->id), 'nb_categorie' => count(Category::getCategories($this->context->cookie->id_lang, true, false))); return $this->display('form_categories.tpl', $template_vars); }
/** * Main Form Method * */ public function getContent() { if ($this->ebay_profile && !Configuration::get('EBAY_CATEGORY_MULTI_SKU_UPDATE')) { $ebay = new EbayRequest(); EbayCategory::updateCategoryTable($ebay->getCategoriesSkuCompliancy()); } if (Tools::getValue('refresh_store_cat')) { $ebay = new EbayRequest(); EbayStoreCategory::updateStoreCategoryTable($ebay->getStoreCategories(), $this->ebay_profile); } if ($this->ebay_profile) { $this->ebay_profile->loadStoreCategories(); } // Checking Extension if (!extension_loaded('curl') || !ini_get('allow_url_fopen')) { if (!extension_loaded('curl') && !ini_get('allow_url_fopen')) { return $this->html . $this->displayError($this->l('You must enable cURL extension and allow_url_fopen option on your server if you want to use this module.')); } elseif (!extension_loaded('curl')) { return $this->html . $this->displayError($this->l('You must enable cURL extension on your server if you want to use this module.')); } elseif (!ini_get('allow_url_fopen')) { return $this->html . $this->displayError($this->l('You must enable allow_url_fopen option on your server if you want to use this module.')); } } // If isset Post Var, post process else display form if (!empty($_POST) && (Tools::isSubmit('submitSave') || Tools::isSubmit('btnSubmitSyncAndPublish') || Tools::isSubmit('btnSubmitSync'))) { $errors = $this->_postValidation(); if (!count($errors)) { $this->_postProcess(); } else { foreach ($errors as $error) { $this->html .= '<div class="alert error"><img src="../modules/ebay/views/img/forbbiden.gif" alt="nok" /> ' . $error . '</div>'; } } if (Configuration::get('EBAY_SEND_STATS')) { $ebay_stat = new EbayStat($this->stats_version, $this->ebay_profile); $ebay_stat->save(); } } $this->html .= $this->_displayForm(); // Set old Context Shop /* RAPH if (version_compare(_PS_VERSION_, '1.5', '>') && Shop::isFeatureActive()) $this->_setContextShop($old_context_shop); */ return $this->html; }
private function _displayFormCategory() { $is_one_dot_five = version_compare(_PS_VERSION_, '1.5', '>'); // Load prestashop ebay's configuration $configs = Configuration::getMultiple(array('EBAY_PAYPAL_EMAIL', 'EBAY_CATEGORY_LOADED', 'EBAY_SECURITY_TOKEN')); // Check if the module is configured if (!isset($configs['EBAY_PAYPAL_EMAIL']) || $configs['EBAY_PAYPAL_EMAIL'] === false) { return $this->display(dirname(__FILE__), '/views/templates/hook/error_paypal_email.tpl'); } // Load categories only if necessary if (EbayCategoryConfiguration::getTotalCategoryConfigurations() && Tools::getValue('section') != 'category') { $this->smarty->assign(array('isOneDotFive' => $is_one_dot_five, 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'))); return $this->display(dirname(__FILE__), '/views/templates/hook/pre_form_categories.tpl'); } // Display eBay Categories if (!isset($configs['EBAY_CATEGORY_LOADED']) || !$configs['EBAY_CATEGORY_LOADED']) { $ebay = new EbayRequest(); EbayCategory::insertCategories($ebay->getCategories(), $ebay->getCategoriesSkuCompliancy()); $this->setConfiguration('EBAY_CATEGORY_LOADED', 1); $this->setConfiguration('EBAY_CATEGORY_LOADED_DATE', date('Y-m-d H:i:s')); } // Smarty $template_vars = array('alerts' => $this->_getAlertCategories(), 'tabHelp' => '&id_tab=7', 'id_lang' => $this->context->cookie->id_lang, '_path' => $this->_path, 'configs' => $configs, '_module_dir_' => _MODULE_DIR_, 'isOneDotFive' => $is_one_dot_five, 'request_uri' => $_SERVER['REQUEST_URI'], 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'date' => pSQL(date('Ymdhis'))); $this->smarty->assign($template_vars); return $this->display(dirname(__FILE__), '/views/templates/hook/form_categories.tpl'); }