Пример #1
0
 protected static function addCldrDatasToCurrency($currencies, $isObject = false)
 {
     $cldr = new Repository(Context::getContext()->language);
     if (is_array($currencies)) {
         foreach ($currencies as $k => $c) {
             if ($isObject) {
                 $currencies[$k] = Currency::getCurrencyInstance($c['id_currency']);
             } else {
                 $currency = $cldr->getCurrency($c['iso_code']);
                 $currencies[$k]['name'] = ucfirst($currency['name']);
                 $currencies[$k]['iso_code_num'] = $currency['iso_code'];
                 $currencies[$k]['sign'] = $currency['symbol'];
                 $currencies[$k]['format'] = '';
             }
         }
     } else {
         if ($isObject) {
             $currencies = Currency::getCurrencyInstance($currencies['id_currency']);
         } else {
             $currency = $cldr->getCurrency($currencies['iso_code']);
             $currencies['name'] = ucfirst($currency['name']);
             $currencies['iso_code_num'] = $currency['iso_code'];
             $currencies['sign'] = $currency['symbol'];
             $currencies['format'] = '';
         }
     }
     return $currencies;
 }
Пример #2
0
 /**
  * Assign smarty variables for the header
  */
 public function initHeader()
 {
     header('Cache-Control: no-store, no-cache');
     // Multishop
     $is_multishop = Shop::isFeatureActive();
     // Quick access
     if ((int) $this->context->employee->id) {
         $quick_access = QuickAccess::getQuickAccesses($this->context->language->id);
         foreach ($quick_access as $index => $quick) {
             if ($quick['link'] == '../' && Shop::getContext() == Shop::CONTEXT_SHOP) {
                 $url = $this->context->shop->getBaseURL();
                 if (!$url) {
                     unset($quick_access[$index]);
                     continue;
                 }
                 $quick_access[$index]['link'] = $url;
             } else {
                 preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $admin_tab);
                 if (isset($admin_tab[1])) {
                     if (strpos($admin_tab[1], '&')) {
                         $admin_tab[1] = substr($admin_tab[1], 0, strpos($admin_tab[1], '&'));
                     }
                     $token = Tools::getAdminToken($admin_tab[1] . (int) Tab::getIdFromClassName($admin_tab[1]) . (int) $this->context->employee->id);
                     $quick_access[$index]['target'] = $admin_tab[1];
                     $quick_access[$index]['link'] .= '&token=' . $token;
                 }
             }
         }
     }
     $tabs = $this->getTabs();
     $currentTabLevel = 0;
     foreach ($tabs as &$tab) {
         $currentTabLevel = isset($tab['current_level']) ? $tab['current_level'] : $currentTabLevel;
     }
     if (Validate::isLoadedObject($this->context->employee)) {
         $accesses = Profile::getProfileAccesses($this->context->employee->id_profile, 'class_name');
         $helperShop = new HelperShop();
         /* Hooks are voluntary out the initialize array (need those variables already assigned) */
         $bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color;
         $this->context->smarty->assign(array('help_box' => Configuration::get('PS_HELPBOX'), 'round_mode' => Configuration::get('PS_PRICE_ROUND_MODE'), 'brightness' => Tools::getBrightness($bo_color) < 128 ? 'white' : '#383838', 'bo_width' => (int) $this->context->employee->bo_width, 'bo_color' => isset($this->context->employee->bo_color) ? Tools::htmlentitiesUTF8($this->context->employee->bo_color) : null, 'show_new_orders' => Configuration::get('PS_SHOW_NEW_ORDERS') && isset($accesses['AdminOrders']) && $accesses['AdminOrders']['view'], 'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS') && isset($accesses['AdminCustomers']) && $accesses['AdminCustomers']['view'], 'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES') && isset($accesses['AdminCustomerThreads']) && $accesses['AdminCustomerThreads']['view'], 'employee' => $this->context->employee, 'search_type' => Tools::getValue('bo_search_type'), 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))), 'quick_access' => $quick_access, 'multi_shop' => Shop::isFeatureActive(), 'shop_list' => $helperShop->getRenderedShopList(), 'current_shop_name' => $helperShop->getCurrentShopName(), 'shop' => $this->context->shop, 'shop_group' => new ShopGroup((int) Shop::getContextShopGroupID()), 'is_multishop' => $is_multishop, 'multishop_context' => $this->multishop_context, 'default_tab_link' => $this->context->link->getAdminLink(Tab::getClassNameById((int) Context::getContext()->employee->default_tab)), 'login_link' => $this->context->link->getAdminLink('AdminLogin'), 'collapse_menu' => isset($this->context->cookie->collapse_menu) ? (int) $this->context->cookie->collapse_menu : 0));
     } else {
         $this->context->smarty->assign('default_tab_link', $this->context->link->getAdminLink('AdminDashboard'));
     }
     // Shop::initialize() in config.php may empty $this->context->shop->virtual_uri so using a new shop instance for getBaseUrl()
     $this->context->shop = new Shop((int) $this->context->shop->id);
     $cldrRepository = new Cldr\Repository($this->context->language->language_code);
     $this->context->smarty->assign(array('img_dir' => _PS_IMG_, 'iso' => $this->context->language->iso_code, 'class_name' => $this->className, 'iso_user' => $this->context->language->iso_code, 'country_iso_code' => $this->context->country->iso_code, 'version' => _PS_VERSION_, 'lang_iso' => $this->context->language->iso_code, 'full_language_code' => $this->context->language->language_code, 'full_cldr_language_code' => $cldrRepository->getCulture(), 'link' => $this->context->link, 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'base_url' => $this->context->shop->getBaseURL(), 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'current_tab_level' => $currentTabLevel, 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_ . '/../install'), 'pic_dir' => _THEME_PROD_PIC_DIR_, 'controller_name' => htmlentities(Tools::getValue('controller')), 'currentIndex' => self::$currentIndex, 'bootstrap' => $this->bootstrap, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT'), 'display_addons_connection' => Tab::checkTabRights(Tab::getIdFromClassName('AdminModulesController'))));
 }