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


PHP ConfigQuery::isMultiDomainActivated方法代码示例

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


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

示例1: renderDefault

 public function renderDefault(array $param = array(), $status = 200)
 {
     $data = array();
     foreach (LangQuery::create()->find() as $lang) {
         $data[LangUrlForm::LANG_PREFIX . $lang->getId()] = $lang->getUrl();
     }
     $langUrlForm = $this->createForm(AdminForm::LANG_URL, 'form', $data);
     $this->getParserContext()->addForm($langUrlForm);
     return $this->render('languages', array_merge($param, array('lang_without_translation' => ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), 'one_domain_per_lang' => ConfigQuery::isMultiDomainActivated())), $status);
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:10,代码来源:LangController.php

示例2: registerPreviousUrl

 /**
  * Save the previous URL in session which is based on the referer header or the request, or
  * the _previous_url request attribute, if defined.
  *
  * If the value of _previous_url is "dont-save", the current referrer is not saved.
  *
  * @param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event
  */
 public function registerPreviousUrl(PostResponseEvent $event)
 {
     $request = $event->getRequest();
     if (!$request->isXmlHttpRequest() && $event->getResponse()->isSuccessful()) {
         $referrer = $request->attributes->get('_previous_url', null);
         if (null !== $referrer) {
             // A previous URL (or the keyword 'dont-save') has been specified.
             if ('dont-save' == $referrer) {
                 // We should not save the current URL as the previous URL
                 $referrer = null;
             }
         } else {
             // The current URL will become the previous URL
             $referrer = $request->getUri();
         }
         // Set previous URL, if defined
         if (null !== $referrer) {
             $session = $request->getSession();
             if (ConfigQuery::isMultiDomainActivated()) {
                 $components = parse_url($referrer);
                 $lang = LangQuery::create()->filterByUrl(sprintf("%s://%s", $components["scheme"], $components["host"]), ModelCriteria::LIKE)->findOne();
                 if (null !== $lang) {
                     $session->setReturnToUrl($referrer);
                 }
             } else {
                 if (false !== strpos($referrer, $request->getSchemeAndHttpHost())) {
                     $session->setReturnToUrl($referrer);
                 }
             }
         }
     }
 }
开发者ID:NandoKstroNet,项目名称:thelia,代码行数:40,代码来源:RequestListener.php

示例3: manageLocale

 protected function manageLocale(RewritingResolver $rewrittenUrlData, TheliaRequest $request)
 {
     $lang = LangQuery::create()->findOneByLocale($rewrittenUrlData->locale);
     $langSession = $request->getSession()->getLang();
     if ($lang != $langSession) {
         if (ConfigQuery::isMultiDomainActivated()) {
             $this->redirect(sprintf("%s/%s", $lang->getUrl(), $rewrittenUrlData->rewrittenUrl));
         } else {
             $request->getSession()->setLang($lang);
         }
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:12,代码来源:RewritingRouter.php

示例4: getUrlLanguage

 /**
  * A simple helper to get the URL based on the language.
  *
  * @param  string      $locale the locale, or null to get the current one
  * @return null|string the URL for the current language, or null if the "One domain for each lang" feature is disabled.
  */
 protected function getUrlLanguage($locale = null)
 {
     // Check if the functionality is activated
     if (!ConfigQuery::isMultiDomainActivated()) {
         return null;
     }
     // If we don't have a locale value, use the locale value in the session
     if (!$locale) {
         $locale = $this->getCurrentEditionLocale();
     }
     return LangQuery::create()->findOneByLocale($locale)->getUrl();
 }
开发者ID:margery,项目名称:thelia,代码行数:18,代码来源:BaseAdminController.php

示例5: detectLang

 /**
  * @param  Request                 $request
  * @return null|\Thelia\Model\Lang
  */
 protected function detectLang(Request $request)
 {
     $lang = null;
     //first priority => lang parameter present in request (get or post)
     if ($request->query->has("lang")) {
         $lang = LangQuery::create()->findOneByCode($request->query->get("lang"));
         if (is_null($lang)) {
             return Lang::getDefaultLanguage();
         }
         //if each lang has its own domain, we redirect the user to the good one.
         if (ConfigQuery::isMultiDomainActivated()) {
             //if lang domain is different from actuel domain, redirect to the good one
             if (rtrim($lang->getUrl(), "/") != $request->getSchemeAndHttpHost()) {
                 // TODO : search if http status 302 is the good one.
                 $redirect = new RedirectResponse($lang->getUrl(), 302);
                 return $redirect;
             } else {
                 //the user is actually on the good domain, nothing to change
                 return null;
             }
         } else {
             //one domain for all languages, the lang is set into session
             return $lang;
         }
     }
     //check if lang is not defined. If not we have to search the good one.
     if (null === $request->getSession()->getLang(false)) {
         if (ConfigQuery::isMultiDomainActivated()) {
             //find lang with domain
             return LangQuery::create()->filterByUrl($request->getSchemeAndHttpHost(), ModelCriteria::LIKE)->findOne();
         }
         //find default lang
         return Lang::getDefaultLanguage();
     }
 }
开发者ID:NandoKstroNet,项目名称:thelia,代码行数:39,代码来源:ParamInitMiddleware.php

示例6: detectLang

 /**
  * @param  TheliaRequest $request
  * @return null|\Thelia\Model\Lang
  */
 protected function detectLang(TheliaRequest $request)
 {
     // first priority => lang parameter present in request (get or post)
     if ($request->query->has("lang")) {
         // The lang parameter may contains a lang code (fr, en, ru) for Thelia < 2.2,
         // or a locale (fr_FR, en_US, etc.) for Thelia > 2.2.beta1
         $requestedLangCodeOrLocale = $request->query->get("lang");
         if (strlen($requestedLangCodeOrLocale) > 2) {
             $lang = LangQuery::create()->findOneByLocale($requestedLangCodeOrLocale);
         } else {
             $lang = LangQuery::create()->findOneByCode($requestedLangCodeOrLocale);
         }
         if (is_null($lang)) {
             return Lang::getDefaultLanguage();
         }
         // if each lang has its own domain, we redirect the user to the proper one.
         if (ConfigQuery::isMultiDomainActivated()) {
             $domainUrl = $lang->getUrl();
             if (!empty($domainUrl)) {
                 // if lang domain is different from current domain, redirect to the proper one
                 if (rtrim($domainUrl, "/") != $request->getSchemeAndHttpHost()) {
                     // TODO : search if http status 302 is the good one.
                     return new RedirectResponse($domainUrl, 302);
                 } else {
                     //the user is currently on the proper domain, nothing to change
                     return null;
                 }
             }
             Tlog::getInstance()->warning("The domain URL for language " . $lang->getTitle() . " (id " . $lang->getId() . ") is not defined.");
             return Lang::getDefaultLanguage();
         } else {
             // one domain for all languages, the lang has to be set into session
             return $lang;
         }
     }
     // Next, check if lang is defined in the current session. If not we have to set one.
     if (null === $request->getSession()->getLang(false)) {
         if (ConfigQuery::isMultiDomainActivated()) {
             // find lang with domain
             return LangQuery::create()->filterByUrl($request->getSchemeAndHttpHost(), ModelCriteria::LIKE)->findOne();
         }
         // At this point, set the lang to the default one.
         return Lang::getDefaultLanguage();
     }
     return null;
 }
开发者ID:hadesain,项目名称:thelia,代码行数:50,代码来源:ParamInitMiddleware.php


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