示例#1
0
 public function isAllSettingsConfigured()
 {
     $tabs = array('param' => EbayValidatorTab::getParametersTabConfiguration($this->id), 'categories' => EbayValidatorTab::getCategoryTabConfiguration($this->id), 'items_specifics' => EbayValidatorTab::getitemSpecificsTabConfiguration($this->id), 'shipping' => EbayValidatorTab::getShippingTabConfiguration($this->id), 'template' => EbayValidatorTab::getTemplateTabConfiguration($this->id));
     $is_all_set = true;
     foreach ($tabs as $key => $tab) {
         if (isset($tab['indicator']) && $tab['indicator'] !== 'success') {
             $is_all_set = false;
             break;
         }
     }
     return $is_all_set;
 }
示例#2
0
 private function _displayForm()
 {
     $alerts = $this->_getAlerts();
     $stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 2)));
     $url_data = array('version' => $this->version, 'shop' => urlencode(Configuration::get('PS_SHOP_NAME')), 'registered' => in_array('registration', $alerts) ? 'no' : 'yes', 'url' => urlencode($_SERVER['HTTP_HOST']), 'iso_country' => Tools::strtolower($this->ebay_country->getIsoCode()), 'iso_lang' => Tools::strtolower($this->context->language->iso_code), 'id_lang' => (int) $this->context->language->id, 'email' => urlencode(Configuration::get('PS_SHOP_EMAIL')), 'security' => md5(Configuration::get('PS_SHOP_EMAIL') . _COOKIE_IV_));
     $url = 'http://api.prestashop.com/partner/modules/ebay.php?' . http_build_query($url_data);
     $prestashop_content = @Tools::file_get_contents($url, false, $stream_context);
     if (!Validate::isCleanHtml($prestashop_content)) {
         $prestashop_content = '';
     }
     $ebay_send_stats = Configuration::get('EBAY_SEND_STATS');
     // profiles data
     $id_shop = version_compare(_PS_VERSION_, '1.5', '>') ? Shop::getContextShopID() : Shop::getCurrentShop();
     $profiles = EbayProfile::getProfilesByIdShop($id_shop);
     $id_ebay_profiles = array();
     foreach ($profiles as &$profile) {
         $profile['site_name'] = EbayCountrySpec::getSiteNameBySiteId($profile['ebay_site_id']);
         $id_ebay_profiles[] = $profile['id_ebay_profile'];
     }
     $nb_products = EbayProduct::getNbProductsByIdEbayProfiles($id_ebay_profiles);
     foreach ($profiles as &$profile) {
         $profile['nb_products'] = isset($nb_products[$profile['id_ebay_profile']]) ? $nb_products[$profile['id_ebay_profile']] : 0;
     }
     $add_profile = Tools::getValue('action') == 'addProfile';
     $url_vars = array('id_tab' => '1', 'section' => 'parameters', 'action' => 'addProfile');
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $url_vars['controller'] = Tools::getValue('controller');
     } else {
         $url_vars['tab'] = Tools::getValue('tab');
     }
     $add_profile_url = $this->_getUrl($url_vars);
     // main tab
     $id_tab = Tools::getValue('id_tab', 1);
     if (in_array($id_tab, array(5, 14))) {
         $main_tab = 'sync';
     } elseif (in_array($id_tab, array(15, 16, 9, 6, 11, 12))) {
         $main_tab = 'visu';
     } elseif (in_array($id_tab, array(13))) {
         $main_tab = 'advanced-settings';
     } else {
         $main_tab = 'settings';
     }
     // check domain
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $shop = $this->ebay_profile instanceof EbayProfile ? new Shop($this->ebay_profile->id_shop) : new Shop();
         $wrong_domain = $_SERVER['HTTP_HOST'] != $shop->domain && $_SERVER['HTTP_HOST'] != $shop->domain_ssl && Tools::getValue('ajax') == false;
     } else {
         $wrong_domain = $_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN') && $_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN_SSL');
     }
     if ($wrong_domain) {
         $url_vars = array();
         if (version_compare(_PS_VERSION_, '1.5', '>')) {
             $url_vars['controller'] = 'AdminMeta';
         } else {
             $url_vars['tab'] = 'AdminMeta';
         }
         $warning_url = $this->_getUrl($url_vars);
     }
     $this->smarty->assign(array('img_stats' => $this->ebay_country->getImgStats(), 'alert' => $alerts, 'regenerate_token' => Configuration::get('EBAY_TOKEN_REGENERATE', null, 0, 0), 'prestashop_content' => $prestashop_content, 'path' => $this->_path, 'multishop' => version_compare(_PS_VERSION_, '1.5', '>') && Shop::isFeatureActive(), 'site_extension' => $this->ebay_country->getSiteExtension(), 'documentation_lang' => $this->ebay_country->getDocumentationLang(), 'is_version_one_dot_five' => version_compare(_PS_VERSION_, '1.5', '>'), 'is_version_one_dot_five_dot_one' => version_compare(_PS_VERSION_, '1.5.1', '>=') && version_compare(_PS_VERSION_, '1.5.2', '<'), 'css_file' => $this->_path . 'views/css/ebay_back.css', 'font_awesome_css_file' => $this->_path . 'views/css/font-awesome/css/font-awesome.min.css', 'tooltip' => $this->_path . 'views/js/jquery.tooltipster.min.js', 'tips202' => $this->_path . 'views/js/202tips.js', 'noConflicts' => $this->_path . 'views/js/jquery.noConflict.php?version=1.7.2', 'ebayjquery' => $this->_path . 'views/js/jquery-1.7.2.min.js', 'fancybox' => $this->_path . 'views/js/jquery.fancybox.min.js', 'fancyboxCss' => $this->_path . 'views/css/jquery.fancybox.css', 'parametersValidator' => $this->ebay_profile ? EbayValidatorTab::getParametersTabConfiguration($this->ebay_profile->id) : '', 'categoryValidator' => $this->ebay_profile ? EbayValidatorTab::getCategoryTabConfiguration($this->ebay_profile->id) : '', 'itemSpecificValidator' => $this->ebay_profile ? EbayValidatorTab::getitemSpecificsTabConfiguration($this->ebay_profile->id) : '', 'shippingValidator' => $this->ebay_profile ? EbayValidatorTab::getShippingTabConfiguration($this->ebay_profile->id) : '', 'synchronisationValidator' => $this->ebay_profile ? EbayValidatorTab::getSynchronisationTabConfiguration($this->ebay_profile->id) : '', 'templateValidator' => $this->ebay_profile ? EbayValidatorTab::getTemplateTabConfiguration($this->ebay_profile->id) : '', 'show_welcome_stats' => $ebay_send_stats === false, 'free_shop_for_90_days' => $this->shopIsAvailableFor90DaysOffer(), 'show_welcome' => $ebay_send_stats !== false && !count($id_ebay_profiles), 'show_seller_tips' => $ebay_send_stats !== false && $this->ebay_profile && $this->ebay_profile->getToken(), 'current_profile' => $this->ebay_profile, 'current_profile_site_extension' => $this->ebay_profile ? EbayCountrySpec::getSiteExtensionBySiteId($this->ebay_profile->ebay_site_id) : '', 'profiles' => $profiles, 'add_profile' => $add_profile, 'add_profile_url' => $add_profile_url, 'delete_profile_url' => _MODULE_DIR_ . 'ebay/ajax/deleteProfile.php?token=' . Configuration::get('EBAY_SECURITY_TOKEN') . '&time=' . pSQL(date('Ymdhis')), 'main_tab' => $main_tab, 'id_tab' => (int) Tools::getValue('id_tab'), 'pro_url' => $this->ebay_country->getProUrl(), 'signin_pro_url' => $this->ebay_country->getSignInProURL(), 'fee_url' => $this->ebay_country->getFeeUrl(), 'title_desc_url' => $this->ebay_country->getTitleDescUrl(), 'picture_url' => $this->ebay_country->getPictureUrl(), 'similar_items_url' => $this->ebay_country->getSimilarItemsUrl(), 'top_rated_url' => $this->ebay_country->getTopRatedUrl(), 'warning_url' => isset($warning_url) ? $warning_url : null, '_module_dir_' => _MODULE_DIR_, 'date' => pSQL(date('Ymdhis'))));
     // test if multishop Screen and all shops
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $is_all_shops = in_array(Shop::getContext(), array(Shop::CONTEXT_ALL, Shop::CONTEXT_GROUP));
     } else {
         $is_all_shops = false;
     }
     if ($ebay_send_stats === false) {
         $template = $this->_displayFormStats();
     } elseif (!($this->ebay_profile && $this->ebay_profile->getToken()) || $add_profile || Tools::isSubmit('ebayRegisterButton')) {
         $template = $this->_displayFormRegister();
     } else {
         $template = $this->_displayFormConfig();
     }
     return $this->display(__FILE__, 'views/templates/hook/form.tpl') . $template;
 }