public function installOrderState() { if (Configuration::get('PS_OS_MYMOD_PAYMENT') < 1) { $order_state = new OrderState(); $order_state->send_email = true; $order_state->module_name = $this->name; $order_state->invoice = false; $order_state->color = '#98c3ff'; $order_state->logable = true; $order_state->shipped = false; $order_state->unremovable = false; $order_state->delivery = false; $order_state->hidden = false; $order_state->paid = false; $order_state->deleted = false; $order_state->name = array((int) Configuration::get('PS_LANG_DEFAULT') => pSQL($this->l('MyMod Payment - Awaiting confirmation'))); $order_state->template = array(); foreach (LanguageCore::getLanguages() as $l) { $order_state->template[$l['id_lang']] = 'mymodpayment'; } // We copy the mails templates in mail directory foreach (LanguageCore::getLanguages() as $l) { $module_path = dirname(__FILE__) . '/views/templates/mails/' . $l['iso_code'] . '/'; $application_path = dirname(__FILE__) . '/../../mails/' . $l['iso_code'] . '/'; if (!copy($module_path . 'mymodpayment.txt', $application_path . 'mymodpayment.txt') || !copy($module_path . 'mymodpayment.html', $application_path . 'mymodpayment.html')) { return false; } } if ($order_state->add()) { // We save the order State ID in Configuration database Configuration::updateValue('PS_OS_MYMOD_PAYMENT', $order_state->id); // We copy the module logo in order state logo directory copy(dirname(__FILE__) . '/logo.gif', dirname(__FILE__) . '/../../img/os/' . $order_state->id . '.gif'); copy(dirname(__FILE__) . '/logo.gif', dirname(__FILE__) . '/../../img/tmp/order_state_mini_' . $order_state->id . '.gif'); } else { return false; } } return true; }
public static function checkAndAddLanguage($iso_code, $lang_pack = false, $only_add = false, $params_lang = null) { $ret = parent::checkAndAddLanguage($iso_code, $lang_pack = false, $only_add = false, $params_lang = null); if (!Module::isInstalled('agilemultipleseller')) { return $ret; } ObjectModel::cleear_unnecessary_lang_data(); return $ret; }
public function install() { $id_lang_en = LanguageCore::getIdByIso('en'); $id_lang_fr = LanguageCore::getIdByIso('fr'); $this->installModuleTab('AdminMultifeature', array($id_lang_fr => 'Caractéristiques multiples', $id_lang_en => 'Multi features'), 9); $query = 'ALTER TABLE ' . _DB_PREFIX_ . 'feature_product DROP PRIMARY KEY , ADD PRIMARY KEY ( `id_feature` , `id_product` , `id_feature_value` )'; if (!Db::getInstance()->Execute($query)) { return false; } if (parent::install() == false) { return false; } return true; }
public static function countActiveLanguages() { if (!self::$countActiveLanguages) { self::$countActiveLanguages = Db::getInstance()->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'lang` WHERE `active` = 1'); } return self::$countActiveLanguages; }
public static function isInstalled($iso_code) { if (self::$_cache_language_installation === null) { self::$_cache_language_installation = array(); $result = Db::getInstance()->executeS('SELECT `id_lang`, `iso_code` FROM `' . _DB_PREFIX_ . 'lang`'); foreach ($result as $row) { self::$_cache_language_installation[$row['iso_code']] = $row['id_lang']; } } return isset(self::$_cache_language_installation[$iso_code]) ? self::$_cache_language_installation[$iso_code] : false; }
/** * Returns language code for customer language * @return string */ public function getDotLang() { $lang = strtolower(LanguageCore::getIsoById($this->context->cookie->id_lang)); if (in_array($lang, $this->config->getDotpayAvailableLanguage())) { return $lang; } else { return "en"; } }
public static function countActiveLanguages() { if (!self::$countActiveLanguages) { self::$countActiveLanguages = Db::getInstance()->getValue(' SELECT COUNT(DISTINCT l.id_lang) FROM `' . _DB_PREFIX_ . 'lang` l ' . Shop::addSqlAssociation('lang', 'l') . ' WHERE l.`active` = 1 '); } return self::$countActiveLanguages; }
/** * Get all languages * * @return array */ private function getLang() { return LanguageCore::getLanguages(); }
public function countProductWords($products) { if (!$products) { return array(); } $counts = array(); if (is_array($products)) { foreach ($products as $id_product) { $counts = $this->array_merge_sum($this->countProductWords($id_product), $counts); } return $counts; } else { $id_product = $products; } $product = new Product($id_product, true); foreach ($product->name as $id_lang => $name) { $counts['name'][LanguageCore::getIsoById($id_lang)] = str_word_count($name); } foreach ($product->description as $id_lang => $description) { $counts['description'][LanguageCore::getIsoById($id_lang)] = str_word_count($description); } foreach ($product->description_short as $id_lang => $description_short) { $counts['description_short'][LanguageCore::getIsoById($id_lang)] = str_word_count($description_short); } foreach ($product->meta_title as $id_lang => $meta_title) { $counts['meta_title'][LanguageCore::getIsoById($id_lang)] = str_word_count($meta_title); } foreach ($product->meta_description as $id_lang => $meta_description) { $counts['meta_description'][LanguageCore::getIsoById($id_lang)] = str_word_count($meta_description); } foreach ($product->meta_keywords as $id_lang => $meta_keywords) { $counts['meta_keywords'][LanguageCore::getIsoById($id_lang)] = str_word_count($meta_keywords); } foreach ($product->link_rewrite as $id_lang => $link_rewrite) { $counts['link_rewrite'][LanguageCore::getIsoById($id_lang)] = str_word_count($link_rewrite); } if ($product->tags) { foreach ($product->tags as $id_lang => $tags) { $tags_count = 0; foreach ($tags as $tag) { $tags_count += str_word_count($tag); } $counts['tags'][LanguageCore::getIsoById($id_lang)] = $tags_count; } } return $counts; }
private function installBackOffice() { $id_lang_en = LanguageCore::getIdByIso('en'); $id_lang_fr = LanguageCore::getIdByIso('fr'); $this->installModuleTab('AdminManageexportorder', array($id_lang_fr => 'Export des commandes', $id_lang_en => 'Order export'), 10); return true; }
public function getLanguages() { if (preg_match("/^1.3.*/", _PS_VERSION_)) { return Language::getLanguages(); } else { return LanguageCore::getLanguages(); } }
/** * Returns Nosto accounts based on active shops. * * The result is formatted as follows: * * array( * array(object(NostoAccount), int(id_shop), int(id_lang)) * ) * * @return NostoAccount[] the account data. */ protected function getAccountData() { $data = array(); /** @var NostoTaggingHelperAccount $account_helper */ $account_helper = Nosto::helper('nosto_tagging/account'); foreach ($this->getContextShops() as $shop) { $id_shop = (int) $shop['id_shop']; $id_shop_group = (int) $shop['id_shop_group']; foreach (LanguageCore::getLanguages(true, $id_shop) as $language) { $id_lang = (int) $language['id_lang']; $account = $account_helper->find($id_lang, $id_shop_group, $id_shop); if ($account === null || !$account->isConnectedToNosto()) { continue; } $data[] = array($account, $id_shop, $id_lang); } } return $data; }
/** * Returns language ISO code set for the current employee * @return array Languages */ public function getEmployeeLanguageIso() { return \LanguageCore::getIsoById($this->getContext()->employee->id_lang); }
/** * Process customization collection * * @param object $product * @param array $data * * @return bool */ public function processProductCustomization($product, $data) { //remove customization field langs foreach ($product->getCustomizationFieldIds() as $customizationFiled) { \Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'customization_field_lang WHERE `id_customization_field` = ' . (int) $customizationFiled['id_customization_field']); } //remove customization for the product \Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'customization_field WHERE `id_product` = ' . (int) $product->id); //create new customizations $countFieldText = 0; $countFieldFile = 0; $productCustomizableValue = 0; $hasRequiredField = false; $shopList = \ShopCore::getContextListShopID(); if ($data) { foreach ($data as $customization) { if ($customization['require']) { $hasRequiredField = true; } //create label \Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'customization_field` (`id_product`, `type`, `required`) VALUES (' . (int) $product->id . ', ' . (int) $customization['type'] . ', ' . ($customization['require'] ? 1 : 0) . ')'); $id_customization_field = (int) \Db::getInstance()->Insert_ID(); // Create multilingual label name $langValues = ''; foreach (\LanguageCore::getLanguages() as $language) { $name = $customization['label'][$language['id_lang']]; foreach ($shopList as $id_shop) { $langValues .= '(' . (int) $id_customization_field . ', ' . (int) $language['id_lang'] . ', ' . $id_shop . ',\'' . $name . '\'), '; } } \Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'customization_field_lang` (`id_customization_field`, `id_lang`, `id_shop`, `name`) VALUES ' . rtrim($langValues, ', ')); if ($customization['type'] == 0) { $countFieldFile++; } else { $countFieldText++; } } $productCustomizableValue = $hasRequiredField ? 2 : 1; } //update product count fields labels \Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'product` SET `customizable` = ' . $productCustomizableValue . ', `uploadable_files` = ' . (int) $countFieldFile . ', `text_fields` = ' . (int) $countFieldText . ' WHERE `id_product` = ' . (int) $product->id); //update product_shop count fields labels \ObjectModelCore::updateMultishopTable('product', array('customizable' => $productCustomizableValue, 'uploadable_files' => (int) $countFieldFile, 'text_fields' => (int) $countFieldText), 'a.id_product = ' . (int) $product->id); \ConfigurationCore::updateGlobalValue('PS_CUSTOMIZATION_FEATURE_ACTIVE', '1'); }
/** * Returns language iso from context. */ private function getLanguageIso() { $langId = Context::getContext()->employee instanceof \Employee ? Context::getContext()->employee->id_lang : Context::getContext()->language->iso_code; return \LanguageCore::getIsoById($langId); }