Пример #1
0
 protected function initializeCulture()
 {
     $culture = null;
     $language = $this->getCurrentLang();
     if ($language !== null) {
         $culture = Context\Culture::wakeUp($language["CULTURE_ID"]);
         $lang = $language["LID"];
     } else {
         $lang = "en";
     }
     if ($culture === null) {
         $culture = new Context\Culture();
     }
     $context = $this->getContext();
     $context->setCulture($culture);
     $context->setLanguage($lang);
     $this->setLanguage($lang);
 }
Пример #2
0
 protected function initializeSite()
 {
     $request = $this->getRequest();
     $currentDirectory = $request->getRequestedPageDirectory();
     $currentDomain = $request->getHttpHost(false);
     $site = SiteTable::getByDomainAndPath($currentDomain, $currentDirectory);
     if ($site === false) {
         $siteList = SiteTable::getList(array('filter' => array('ACTIVE' => 'Y'), 'order' => array('DEF' => 'DESC', 'SORT' => 'ASC'), 'select' => array('*', 'ID' => 'LID')));
         $site = $siteList->fetch();
     }
     if ($site === false) {
         throw new SystemException("Site not found");
     }
     $culture = Context\Culture::wakeUp($site["CULTURE_ID"]);
     if ($culture === null) {
         $culture = new Context\Culture();
     }
     $this->site = new Context\Site($site);
     $this->site->setCulture($culture);
     $this->setContextCulture($culture, $this->site->getLanguage());
 }
Пример #3
0
 protected function initializeSite()
 {
     $context = $this->application->getContext();
     $request = $context->getRequest();
     $currentDirectory = $request->getRequestedPageDirectory();
     $currentHost = "";
     $currentHostScheme = "";
     if ($request instanceof IHttpRequest) {
         /** @var $request \Bitrix\Main\HttpRequest */
         $currentHost = $request->getHttpHost();
         $currentHostScheme = $request->isHttps() ? "https://" : "http://";
     }
     $url = new Web\Uri($currentHostScheme . $currentHost, Web\UriType::ABSOLUTE);
     $currentDomain = $url->parse(Web\UriPart::HOST);
     $currentDomain = trim($currentDomain, "\t\r\n .");
     $connection = Application::getDbConnection();
     $helper = $connection->getSqlHelper();
     $sql = "\n\t\t\tSELECT L.*, L.LID as ID, L.LID as SITE_ID\n\t\t\tFROM b_lang L\n\t\t\t\tLEFT JOIN b_lang_domain LD ON L.LID=LD.LID AND '" . $helper->forSql($currentDomain, 255) . "' LIKE CONCAT('%', LD.DOMAIN)\n\t\t\tWHERE ('" . $helper->forSql($currentDirectory) . "' LIKE CONCAT(L.DIR, '%') OR LD.LID IS NOT NULL)\n\t\t\t\tAND L.ACTIVE='Y'\n\t\t\tORDER BY\n\t\t\t\tIF((L.DOMAIN_LIMITED='Y' AND LD.LID IS NOT NULL) OR L.DOMAIN_LIMITED<>'Y',\n\t\t\t\t\tIF('" . $helper->forSql($currentDomain) . "' LIKE CONCAT(L.DIR, '%'), 3, 1),\n\t\t\t\t\tIF('" . $helper->forSql($currentDirectory) . "' LIKE CONCAT(L.DIR, '%'), 2, 0)\n\t\t\t\t) DESC,\n\t\t\t\tLENGTH(L.DIR) DESC,\n\t\t\t\tL.DOMAIN_LIMITED DESC,\n\t\t\t\tSORT,\n\t\t\t\tLENGTH(LD.DOMAIN) DESC\n\t\t";
     //get site by path and domain
     $siteList = $connection->query($sql);
     $site = $siteList->fetch();
     //get site by default sorting
     if ($site === false) {
         $sql = "\n\t\t\t\tSELECT L.*, L.LID as ID, L.LID as SITE_ID\n\t\t\t\tFROM b_lang L\n\t\t\t\tWHERE L.ACTIVE='Y'\n\t\t\t\tORDER BY L.DEF DESC, L.SORT\n\t\t\t";
         $siteList = $connection->query($sql);
         $site = $siteList->fetch();
     }
     if ($site !== false) {
         $culture = Context\Culture::wakeUp($site["CULTURE_ID"]);
         if ($culture === null) {
             $culture = new Context\Culture();
         }
         $this->site = new Context\Site($site);
         $this->site->setCulture($culture);
     } else {
         throw new SystemException("Site not found.");
     }
 }
Пример #4
0
	/**
	 * Returns long (including time) date culture format.
	 *
	 * @param Context\Culture $culture Culture.
	 *
	 * @return string
	 */
	protected static function getCultureFormat(Context\Culture $culture)
	{
		return $culture->getDateTimeFormat();
	}