当前位置: 首页>>代码示例>>PHP>>正文


PHP Lang::getDefaultLanguage方法代码示例

本文整理汇总了PHP中Thelia\Model\Lang::getDefaultLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP Lang::getDefaultLanguage方法的具体用法?PHP Lang::getDefaultLanguage怎么用?PHP Lang::getDefaultLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thelia\Model\Lang的用法示例。


在下文中一共展示了Lang::getDefaultLanguage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testQuery

 public function testQuery()
 {
     new Translator(new Container());
     $export = new ProductSEOExport(new Container());
     $data = $export->buildData(Lang::getDefaultLanguage());
     $keys = ["ref", "visible", "product_title", "url", "page_title", "meta_description", "meta_keywords"];
     sort($keys);
     $rawData = $data->getData();
     $max = count($rawData);
     /**
      * If there's more that 50 entries,
      * just pick 50, it would be faster and as tested as if we test 1000 entries.
      */
     if ($max > 50) {
         $max = 50;
     }
     for ($i = 0; $i < $max; ++$i) {
         $row = $rawData[$i];
         $rowKeys = array_keys($row);
         $this->assertTrue(sort($rowKeys));
         $this->assertEquals($keys, $rowKeys);
         $product = ProductQuery::create()->findOneByRef($row["ref"]);
         $this->assertNotNull($product);
         $this->assertEquals($product->getVisible(), $row["visible"]);
         $this->assertEquals($product->getTitle(), $row["product_title"]);
         $this->assertEquals($product->getMetaTitle(), $row["page_title"]);
         $this->assertEquals($product->getMetaDescription(), $row["meta_description"]);
         $this->assertEquals($product->getMetaKeywords(), $row["meta_keywords"]);
         $this->assertEquals($product->getRewrittenUrl("en_US"), $row["url"]);
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:31,代码来源:ProductSEOExportTest.php

示例2: testRenderLoop

 public function testRenderLoop()
 {
     $customerId = CustomerQuery::create()->findOne()->getId();
     $this->handler->expects($this->any())->method("buildDataSet")->willReturn($this->handler->renderLoop("address", ["customer" => $customerId]));
     $lang = Lang::getDefaultLanguage();
     $loop = $this->handler->buildDataSet($lang);
     $this->assertInstanceOf("Thelia\\Core\\Template\\Loop\\Address", $loop);
     $data = $this->handler->buildData($lang);
     $addresses = AddressQuery::create()->filterByCustomerId($customerId)->find()->toArray("Id");
     foreach ($data->getData() as $row) {
         $this->assertArrayHasKey("id", $row);
         $this->assertArrayHasKey($row["id"], $addresses);
         $this->assertEquals(count($addresses), $row["loop_total"]);
         $address = $addresses[$row["id"]];
         $this->assertEquals($row["address1"], $address["Address1"]);
         $this->assertEquals($row["address2"], $address["Address2"]);
         $this->assertEquals($row["address3"], $address["Address3"]);
         $this->assertEquals($row["cellphone"], $address["Cellphone"]);
         $this->assertEquals($row["city"], $address["City"]);
         $this->assertEquals($row["company"], $address["Company"]);
         $this->assertEquals($row["country"], $address["CountryId"]);
         $this->assertEquals($row["create_date"], $address["CreatedAt"]);
         $this->assertEquals($row["update_date"], $address["UpdatedAt"]);
         $this->assertEquals($row["firstname"], $address["Firstname"]);
         $this->assertEquals($row["lastname"], $address["Lastname"]);
         $this->assertEquals($row["id"], $address["Id"]);
         $this->assertEquals($row["label"], $address["Label"]);
         $this->assertEquals($row["phone"], $address["Phone"]);
         $this->assertEquals($row["title"], $address["TitleId"]);
         $this->assertEquals($row["zipcode"], $address["Zipcode"]);
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:32,代码来源:ExportHandlerTest.php

示例3: testImportWorks

 public function testImportWorks()
 {
     // Export data
     $data = $this->exportHandler->buildData(Lang::getDefaultLanguage());
     $compareData = array();
     $currentData = $data->getData();
     // Replace the prices
     foreach ($currentData as $key => &$entry) {
         // let  6/10 prices be changed.
         if (rand(1, 100) >= 60) {
             $compareData[$key] = $rand = rand(1, 1000);
             $entry["price"] = $rand;
         } else {
             $compareData[$key] = $entry["price"];
         }
     }
     // Import new prices
     $this->importHandler->retrieveFromFormatterData($data->setData($currentData));
     // Export once again
     $newData = $this->exportHandler->buildData(Lang::getDefaultLanguage());
     $newDataEntries = $newData->getData();
     // Check them
     foreach ($compareData as $key => $price) {
         $this->assertEquals($price, $newDataEntries[$key]["price"]);
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:26,代码来源:ExportPriceThenImportItTest.php

示例4: generateAction

 /**
  * render the RSS feed
  *
  * @param $context string   The context of the feed : catalog, content. default: catalog
  * @param $lang string      The lang of the feed : fr_FR, en_US, ... default: default language of the site
  * @param $id string        The id of the parent element. The id of the main parent category for catalog context.
  *                          The id of the content folder for content context
  * @return Response
  * @throws \RuntimeException
  */
 public function generateAction($context, $lang, $id)
 {
     /** @var Request $request */
     $request = $this->getRequest();
     // context
     if ("" === $context) {
         $context = "catalog";
     } else {
         if (!in_array($context, array("catalog", "content", "brand"))) {
             $this->pageNotFound();
         }
     }
     // the locale : fr_FR, en_US,
     if ("" !== $lang) {
         if (!$this->checkLang($lang)) {
             $this->pageNotFound();
         }
     } else {
         try {
             $lang = Lang::getDefaultLanguage();
             $lang = $lang->getLocale();
         } catch (\RuntimeException $ex) {
             // @todo generate error page
             throw new \RuntimeException("No default language is defined. Please define one.");
         }
     }
     if (null === ($lang = LangQuery::create()->findOneByLocale($lang))) {
         $this->pageNotFound();
     }
     $lang = $lang->getId();
     // check if element exists and is visible
     if ("" !== $id) {
         if (false === $this->checkId($context, $id)) {
             $this->pageNotFound();
         }
     }
     $flush = $request->query->get("flush", "");
     // check if feed already in cache
     $cacheContent = false;
     $cacheDir = $this->getCacheDir();
     $cacheKey = self::FEED_CACHE_KEY . $lang . $context . $id;
     $cacheExpire = intval(ConfigQuery::read("feed_ttl", '7200')) ?: 7200;
     $cacheDriver = new FilesystemCache($cacheDir);
     if (!($this->checkAdmin() && "" !== $flush)) {
         $cacheContent = $cacheDriver->fetch($cacheKey);
     } else {
         $cacheDriver->delete($cacheKey);
     }
     // if not in cache
     if (false === $cacheContent) {
         // render the view
         $cacheContent = $this->renderRaw("feed", array("_context_" => $context, "_lang_" => $lang, "_id_" => $id));
         // save cache
         $cacheDriver->save($cacheKey, $cacheContent, $cacheExpire);
     }
     $response = new Response();
     $response->setContent($cacheContent);
     $response->headers->set('Content-Type', 'application/rss+xml');
     return $response;
 }
开发者ID:margery,项目名称:thelia,代码行数:70,代码来源:FeedController.php

示例5: update_status

 /**
  * Checks if we are the payment module for the order, and if the order is paid,
  * then send a confirmation email to the customer.
  *
  * @params OrderEvent $order
  */
 public function update_status(OrderEvent $event)
 {
     $payzen = new Payzen();
     if ($event->getOrder()->isPaid() && $payzen->isPaymentModuleFor($event->getOrder())) {
         $contact_email = ConfigQuery::read('store_email', false);
         $lang = Lang::getDefaultLanguage();
         $locale = $lang->getLocale();
         Tlog::getInstance()->debug("Sending confirmation email from store contact e-mail {$contact_email}");
         if ($contact_email) {
             $message = MessageQuery::create()->filterByName(Payzen::CONFIRMATION_MESSAGE_NAME)->findOne();
             if (false === $message) {
                 throw new \Exception(sprintf("Failed to load message '%s'.", Payzen::CONFIRMATION_MESSAGE_NAME));
             }
             $order = $event->getOrder();
             $customer = $order->getCustomer();
             $this->parser->assign('order_id', $order->getId());
             $this->parser->assign('order_ref', $order->getRef());
             $this->parser->assign('locale', $locale);
             $message->setLocale($order->getLang()->getLocale());
             $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
             // Build subject and body
             $message->buildMessage($this->parser, $instance);
             $this->getMailer()->send($instance);
             Tlog::getInstance()->debug("Confirmation email sent to customer " . $customer->getEmail());
         }
     } else {
         Tlog::getInstance()->debug("No confirmation email sent (order not paid, or not the proper payment module).");
     }
 }
开发者ID:nabil509,项目名称:Payzen,代码行数:35,代码来源:SendConfirmationEmail.php

示例6: __construct

 public function __construct(Request $request)
 {
     if ($request->getSession() != null) {
         $this->locale = $request->getLocale();
     } else {
         $this->locale = Lang::getDefaultLanguage()->getLocale();
     }
 }
开发者ID:zorn-v,项目名称:thelia,代码行数:8,代码来源:TinyMCELanguage.php

示例7: buildForm

 protected function buildForm($change_mode = false)
 {
     $name_constraints = array(new Constraints\NotBlank());
     if (!$change_mode) {
         $name_constraints[] = new Constraints\Callback(array("methods" => array(array($this, "checkDuplicateName"))));
     }
     $this->formBuilder->add("name", "text", array("constraints" => $name_constraints, "label" => Translator::getInstance()->trans('Name'), "label_attr" => array("for" => "name", 'help' => Translator::getInstance()->trans("This is an identifier that will be used in the code to get this message")), 'attr' => ['placeholder' => Translator::getInstance()->trans("Mail template name")]))->add("title", "text", array("constraints" => array(new Constraints\NotBlank()), "label" => Translator::getInstance()->trans('Purpose'), "label_attr" => array("for" => "purpose", 'help' => Translator::getInstance()->trans("Enter here the mail template purpose in the default language (%title%)", ['%title%' => Lang::getDefaultLanguage()->getTitle()])), 'attr' => ['placeholder' => Translator::getInstance()->trans("Mail template purpose")]))->add("locale", "hidden", array("constraints" => array(new Constraints\NotBlank())))->add("secured", "hidden", array());
 }
开发者ID:badelas,项目名称:thelia,代码行数:8,代码来源:MessageCreationForm.php

示例8: applyUserLocale

 protected function applyUserLocale(Admin $user)
 {
     // Set the current language according to Admin locale preference
     $locale = $user->getLocale();
     if (null === ($lang = LangQuery::create()->findOneByLocale($locale))) {
         $lang = Lang::getDefaultLanguage();
     }
     $this->getSession()->setLang($lang);
 }
开发者ID:alex63530,项目名称:thelia,代码行数:9,代码来源:SessionController.php

示例9: addI18nCondition

 public static function addI18nCondition(ModelCriteria $query, $i18nTableName, $tableIdColumn, $i18nIdColumn, $localeColumn, $locale)
 {
     if (null === static::$defaultLocale) {
         static::$defaultLocale = Lang::getDefaultLanguage()->getLocale();
     }
     $locale = static::realEscape($locale);
     $defaultLocale = static::realEscape(static::$defaultLocale);
     $query->_and()->where("CASE WHEN " . $tableIdColumn . " IN" . "(SELECT DISTINCT " . $i18nIdColumn . " " . "FROM `" . $i18nTableName . "` " . "WHERE locale={$locale}) " . "THEN " . $localeColumn . " = {$locale} " . "ELSE " . $localeColumn . " = {$defaultLocale} " . "END");
 }
开发者ID:margery,项目名称:thelia,代码行数:9,代码来源:I18n.php

示例10: getProduct

 public function getProduct(ConnectionInterface $con = null, $locale = null)
 {
     $product = parent::getProduct($con);
     $translation = $product->getTranslation($locale);
     if ($translation->isNew()) {
         if (ConfigQuery::getDefaultLangWhenNoTranslationAvailable()) {
             $locale = Lang::getDefaultLanguage()->getLocale();
         }
     }
     $product->setLocale($locale);
     return $product;
 }
开发者ID:alex63530,项目名称:thelia,代码行数:12,代码来源:CartItem.php

示例11: testPrices

 public function testPrices()
 {
     $container = new Container();
     new Translator($container);
     $handler = new ProductTaxedPricesExport($container);
     $lang = Lang::getDefaultLanguage();
     $data = $handler->buildData($lang)->getData();
     foreach ($data as $line) {
         $product = ProductSaleElementsQuery::create()->findOneByRef($line["ref"]);
         $currency = CurrencyQuery::create()->findOneByCode($line["currency"]);
         $this->assertNotNull($product);
         $prices = $product->getPricesByCurrency($currency);
         $this->assertEquals($prices->getPrice(), $line["price"]);
         $this->assertEquals($prices->getPromoPrice(), $line["promo_price"]);
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:16,代码来源:ProductTaxedPricesExportTest.php

示例12: getTaxonomy

 public function getTaxonomy($langId = null)
 {
     $lang = LangQuery::create()->findOneById($langId);
     if ($lang === null) {
         $lang = Lang::getDefaultLanguage();
     }
     $file = file_get_contents("http://www.google.com/basepages/producttype/taxonomy." . str_replace("_", "-", $lang->getLocale()) . ".txt");
     $rows = explode("\n", $file);
     $cats = [];
     foreach ($rows as $row) {
         $splittedCat = explode('>', $row);
         $name = end($splittedCat);
         $cats[$name] = htmlspecialchars($row);
     }
     return new JsonResponse(['cats' => $cats]);
 }
开发者ID:Mertiozys,项目名称:GoogleShopping,代码行数:16,代码来源:CategoryController.php

示例13: buildModelCriteria

 public function buildModelCriteria()
 {
     $query = GoogleshoppingProductSynchronisationQuery::create()->filterByProductId($this->getProductId());
     if ($this->getCountry()) {
         $targetCountry = $this->getCountry();
     } else {
         $targetCountry = Country::getDefaultCountry()->getIsoalpha2();
     }
     if ($this->getLocale()) {
         $lang = LangQuery::create()->findOneByLocale($this->getLocale())->getCode();
     } else {
         $lang = Lang::getDefaultLanguage()->getCode();
     }
     $query->filterByTargetCountry($targetCountry)->filterByLang($lang);
     return $query;
 }
开发者ID:Mertiozys,项目名称:GoogleShopping,代码行数:16,代码来源:ProductSync.php

示例14: testPrices

 public function testPrices()
 {
     new Translator(new Container());
     $export = new ProductTaxedPricesExport(new Container());
     $data = $export->buildData(Lang::getDefaultLanguage());
     $keys = ["attributes", "currency", "ean", "id", "price", "product_id", "promo", "promo_price", "tax_id", "tax_title", "title"];
     $rawData = $data->getData();
     $max = count($rawData);
     /**
      * If there are more than 50 entries, a test on 50 entries will be as efficient
      * and quicker than a test on all the entries
      */
     if ($max > 50) {
         $max = 50;
     }
     for ($i = 0; $i < $max; ++$i) {
         $row = $rawData[$i];
         $rowKeys = array_keys($row);
         $this->assertTrue(sort($rowKeys));
         $this->assertEquals($keys, $rowKeys);
         $pse = ProductSaleElementsQuery::create()->findPk($row["id"]);
         $this->assertNotNull($pse);
         $this->assertEquals($pse->getEanCode(), $row["ean"]);
         $this->assertEquals($pse->getPromo(), $row["promo"]);
         $currency = CurrencyQuery::create()->findOneByCode($row["currency"]);
         $this->assertNotNull($currency);
         $price = $pse->getPricesByCurrency($currency);
         $this->assertEquals(round($price->getPrice(), 3), round($row["price"], 3));
         $this->assertEquals(round($price->getPromoPrice(), 3), round($row["promo_price"], 3));
         $this->assertEquals($pse->getProduct()->getTitle(), $row["title"]);
         $attributeCombinations = $pse->getAttributeCombinations();
         $attributes = [];
         foreach ($attributeCombinations as $attributeCombination) {
             if (!in_array($attributeCombination->getAttributeAv()->getTitle(), $attributes)) {
                 $attributes[] = $attributeCombination->getAttributeAv()->getTitle();
             }
         }
         $rowAttributes = !empty($row["attributes"]) ? explode(",", $row["attributes"]) : [];
         sort($rowAttributes);
         sort($attributes);
         $this->assertEquals($attributes, $rowAttributes);
         $taxId = $pse->getProduct()->getTaxRule()->getId();
         $this->assertEquals($taxId, $row["tax_id"]);
         $taxTitle = $pse->getProduct()->getTaxRule()->getTitle();
         $this->assertEquals($taxTitle, $row["tax_title"]);
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:47,代码来源:ProductTaxedPricesExportTest.php

示例15: getFrontEndI18n

 /**
  * @param ModelCriteria $search
  * @param               $requestedLocale
  * @param array $columns
  * @param null $foreignTable
  * @param string $foreignKey
  * @param bool $forceReturn
  * @param string $forceReturn
  */
 public static function getFrontEndI18n(ModelCriteria &$search, $requestedLocale, $columns, $foreignTable, $foreignKey, $forceReturn = false, $localeAlias = null)
 {
     if (!empty($columns)) {
         if ($foreignTable === null) {
             $foreignTable = $search->getTableMap()->getName();
             $aliasPrefix = '';
         } else {
             $aliasPrefix = $foreignTable . '_';
         }
         if ($localeAlias === null) {
             $localeAlias = $search->getTableMap()->getName();
         }
         $defaultLangWithoutTranslation = ConfigQuery::getDefaultLangWhenNoTranslationAvailable();
         $requestedLocaleI18nAlias = $aliasPrefix . 'requested_locale_i18n';
         $defaultLocaleI18nAlias = $aliasPrefix . 'default_locale_i18n';
         if ($defaultLangWithoutTranslation == Lang::STRICTLY_USE_REQUESTED_LANGUAGE) {
             $requestedLocaleJoin = new Join();
             $requestedLocaleJoin->addExplicitCondition($localeAlias, $foreignKey, null, $foreignTable . '_i18n', 'ID', $requestedLocaleI18nAlias);
             $requestedLocaleJoin->setJoinType($forceReturn === false ? Criteria::INNER_JOIN : Criteria::LEFT_JOIN);
             $defaultLocaleJoin = new Join();
             $defaultLocaleJoin->addExplicitCondition($localeAlias, $foreignKey, null, $foreignTable . '_i18n', 'ID', $defaultLocaleI18nAlias);
             $search->addJoinObject($requestedLocaleJoin, $requestedLocaleI18nAlias)->addJoinCondition($requestedLocaleI18nAlias, '`' . $requestedLocaleI18nAlias . '`.LOCALE = ?', $requestedLocale, null, \PDO::PARAM_STR);
             $search->addJoinObject($defaultLocaleJoin, $defaultLocaleI18nAlias)->addJoinCondition($defaultLocaleI18nAlias, '`' . $defaultLocaleI18nAlias . '`.LOCALE <> ?', $requestedLocale, null, \PDO::PARAM_STR);
             $search->withColumn('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED');
             foreach ($columns as $column) {
                 $search->withColumn('`' . $requestedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column);
             }
         } else {
             $defaultLocale = Lang::getDefaultLanguage()->getLocale();
             $defaultLocaleJoin = new Join();
             $defaultLocaleJoin->addExplicitCondition($localeAlias, $foreignKey, null, $foreignTable . '_i18n', 'ID', $defaultLocaleI18nAlias);
             $defaultLocaleJoin->setJoinType(Criteria::LEFT_JOIN);
             $search->addJoinObject($defaultLocaleJoin, $defaultLocaleI18nAlias)->addJoinCondition($defaultLocaleI18nAlias, '`' . $defaultLocaleI18nAlias . '`.LOCALE = ?', $defaultLocale, null, \PDO::PARAM_STR);
             $requestedLocaleJoin = new Join();
             $requestedLocaleJoin->addExplicitCondition($localeAlias, $foreignKey, null, $foreignTable . '_i18n', 'ID', $requestedLocaleI18nAlias);
             $requestedLocaleJoin->setJoinType(Criteria::LEFT_JOIN);
             $search->addJoinObject($requestedLocaleJoin, $requestedLocaleI18nAlias)->addJoinCondition($requestedLocaleI18nAlias, '`' . $requestedLocaleI18nAlias . '`.LOCALE = ?', $requestedLocale, null, \PDO::PARAM_STR);
             $search->withColumn('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED');
             if ($forceReturn === false) {
                 $search->where('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.ID)')->_or()->where('NOT ISNULL(`' . $defaultLocaleI18nAlias . '`.ID)');
             }
             foreach ($columns as $column) {
                 $search->withColumn('CASE WHEN NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.ID) THEN `' . $requestedLocaleI18nAlias . '`.`' . $column . '` ELSE `' . $defaultLocaleI18nAlias . '`.`' . $column . '` END', $aliasPrefix . 'i18n_' . $column);
             }
         }
     }
 }
开发者ID:zorn-v,项目名称:thelia,代码行数:56,代码来源:ModelCriteriaTools.php


注:本文中的Thelia\Model\Lang::getDefaultLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。