Stores global URL alias data for $path to the backup table.

@param string $resource
@param string $path
@param string $languageCode
@param bool $alwaysAvailable
@param bool $forwarding
509614
protected function storeGlobalAliasPath(
        $resource,
        $path,
        $languageCode,
        $alwaysAvailable,
        $forwarding
    ) {
        $queryBuilder = $this->connection->createQueryBuilder();

        $queryBuilder->insert(static::GLOBAL_ALIAS_BACKUP_TABLE);
        $queryBuilder->values(
            [
                'id' => '?',
                'resource' => '?',
                'path' => '?',
                'language_code' => '?',
                'always_available' => '?',
                'forwarding' => '?',
            ]
        );
        $queryBuilder->setParameter(0, 0);
        $queryBuilder->setParameter(1, 'module:' . $resource);
        $queryBuilder->setParameter(2, $path);
        $queryBuilder->setParameter(3, $languageCode);
        $queryBuilder->setParameter(4, (int)$alwaysAvailable);
        $queryBuilder->setParameter(5, (int)$forwarding);

        $queryBuilder->execute();
    }
712518
private function setLanguageFromBrowser(): void
    {
        $userLang = App::$Properties->get('singleLanguage');
        $browserAccept = $this->getLanguages();
        if (Any::isArray($browserAccept) && count($browserAccept) > 0) {
            foreach ($browserAccept as $bLang) {
                if (Arr::in($bLang, App::$Properties->get('languages'))) {
                    $userLang = $bLang;
                    break; // stop calculating, language is founded in priority
                }
            }
        }

        // parse query string
        $queryString = null;
        if (count($this->query->all()) > 0) {
            $queryString = '?' . http_build_query($this->query->all());
        }

        // build response with redirect to language-based path
        $redirectUrl = $this->getSchemeAndHttpHost() . $this->basePath . '/' . $userLang . $this->getPathInfo() . $queryString;
        $response = new RedirectResponse($redirectUrl);
        $response->send();
        exit();
    }
979517
private function writeStream($path, $resource)
    {
        if (!ftp_fput($this->getConnection(), $path, $resource, $this->transfer_mode)) {
            return false;
        }

        $type = 'file';

        return compact('type', 'path');
    }
1353349
function lexicon($path,$ttl=0) {
		$languages=$this->languages?:explode(',',$this->fallback);
		$cache=Cache::instance();
		if ($cache->exists(
			$hash=$this->hash(implode(',',$languages).$path).'.dic',$lex))
			return $lex;
		$lex=[];
		foreach ($languages as $lang)
			foreach ($this->split($path) as $dir)
				if ((is_file($file=($base=$dir.$lang).'.php') ||
					is_file($file=$base.'.php')) &&
					is_array($dict=require($file)))
					$lex+=$dict;
				elseif (is_file($file=$base.'.json') &&
					is_array($dict=json_decode(file_get_contents($file), true)))
					$lex+=$dict;
				elseif (is_file($file=$base.'.ini')) {
					preg_match_all(
						'/(?<=^|\n)(?:'.
							'\[(?<prefix>.+?)\]|'.
							'(?<lval>[^\h\r\n;].*?)\h*=\h*'.
							'(?<rval>(?:\\\\\h*\r?\n|.+?)*)'.
						')(?=\r?\n|$)/',
						$this->read($file),$matches,PREG_SET_ORDER);
					if ($matches) {
						$prefix='';
						foreach ($matches as $match)
							if ($match['prefix'])
								$prefix=$match['prefix'].'.';
							elseif (!array_key_exists(
								$key=$prefix.$match['lval'],$lex))
								$lex[$key]=trim(preg_replace(
									'/\\\\\h*\r?\n/',"\n",$match['rval']));
					}
				}
		if ($ttl)
			$cache->set($hash,$lex,$ttl);
		return $lex;
	}
498272
public static function addPath($path)
    {
        if ( ! isset(self::$_i18nPaths[$path]))
        {
            self::$_i18nPaths[$path] = $path;
        }
    }
359198
protected function loadPath($path, $locale, $group)
    {
        $result = parent::loadPath($path, $locale, $group);

        if (empty($result) && str_contains($locale, '-')) {
            return parent::loadPath($path, strstr($locale, '-', true), $group);
        }

        return $result;
    }
1338858
public void initializeRelativePath(ServletRequest request, String relativeTo) 
    {
        if ( relativeTo == null )
        {
            relativeTo = _relativeTo;
        }

        if ( relativeTo == null ) return;

        assert ! relativeTo.endsWith("/") : relativeTo;
        String path = getPath();
         
        // If this is a local (relative) path, prefix it with the given 'relativeTo' path, and save a flag.
        // We save this flag in a local variable because the Forward object may be saved/restored for use again.
        if (! getContextRelative() && ! FileUtils.isAbsoluteURI(path)) {
            assert path.startsWith("/") : path;
            setPath(relativeTo + path);
            setContextRelative(true);
            _outsidePageFlowDirectory = true;
        }
        
        // Store a flag in the request that will prevent another page flow from being initialized implicitly because
        // we're hitting a path within it.  We want to stay in the context of the current page flow.
        if (_outsidePageFlowDirectory) {
            PageFlowRequestWrapper.get(request).setStayInCurrentModule(true);
        }
    }
40134
public function redirect($from_path, $to_path, $code = 302)
    {
        $this->all($from_path, function () use ($to_path, $code) {
            http_response_code($code);
            header("Location: {$to_path}");
        });
    }
783308
protected function buildUrlAliasDomainObject(SPIURLAlias $spiUrlAlias, string $path)
    {
        return new URLAlias(
            array(
                'id' => $spiUrlAlias->id,
                'type' => $spiUrlAlias->type,
                'destination' => $spiUrlAlias->destination,
                'languageCodes' => $spiUrlAlias->languageCodes,
                'alwaysAvailable' => $spiUrlAlias->alwaysAvailable,
                'path' => '/' . $path,
                'isHistory' => $spiUrlAlias->isHistory,
                'isCustom' => $spiUrlAlias->isCustom,
                'forward' => $spiUrlAlias->forward,
            )
        );
    }
345599
protected function findTranslationsFiles($path, array $locales, array $domains, $autocompletePath = true)
    {
        $finder = null;

        if (preg_match('#^win#i', PHP_OS)) {
            $path = preg_replace('#'. preg_quote(DIRECTORY_SEPARATOR, '#') .'#', '/', $path);
        }

        if (true === $autocompletePath) {
            $dir = (0 === strpos($path, $this->getApplication()->getKernel()->getRootDir() . '/Resources')) ? $path : $path . '/Resources/translations';
        } else {
            $dir = $path;
        }

        $this->output->writeln('<info>*** Using dir ' . $dir . ' to lookup translation files. ***</info>');

        if (is_dir($dir)) {
            $finder = new Finder();
            $finder->files()
                ->name($this->getFileNamePattern($locales, $domains))
                ->in($dir);
        }

        return (null !== $finder && $finder->count() > 0) ? $finder : null;
    }
711461
public static function to($path, $code = 302, $trigger = true)
    {
        $debuglvl = self::$debuglvl;
        self::$debuglvl = 2;

        if (headers_sent()) {
            throw new Exception('Headers already sent', $debuglvl);
        } elseif ($code < 300 || $code > 399) {
            throw new Exception('Invalid redirect HTTP status', $debuglvl);
        } elseif (empty($path)) {
            throw new Exception('Path is not defined', $debuglvl);
        } elseif (strpos($path, '/') === 0) {
            $path = Uri::root($path);
        }

        Response::status($code, $trigger);
        Response::putHeader('Location', $path);
    }
1061660
public function addTextDomain($domain, $path): void
    {
        // check path
        if (!is_dir($path)) {
            throw new ConfigurationException("Translator configuration path `$path` not found");
        }

        bindtextdomain($domain, $path);

        // @todo: hardcoded codeset
        bind_textdomain_codeset($domain, 'UTF-8');
    }
1097541
public function phpSourceFile($path, $source, $namespace = '')
    {
        if ($namespace) {
            $namespace = "namespace {$namespace};".PHP_EOL.PHP_EOL;
        }

        $this->file($path)->text('<?php'.PHP_EOL.PHP_EOL.$namespace.$source.PHP_EOL);
    }
1348535
protected String checkValidAliasPath(String path, Locale locale) {

        if (org.opencms.db.CmsAlias.ALIAS_PATTERN.matcher(path).matches()) {
            return null;
        } else {
            return Messages.get().getBundle(locale).key(Messages.ERR_ALIAS_INVALID_PATH_0);
        }
    }
537285
protected function findOrCreateRoute($path, $locale, CustomUrlBehavior $document, $route)
    {
        try {
            /** @var RouteDocument $routeDocument */
            $routeDocument = $this->documentManager->find($path, $locale);
        } catch (DocumentNotFoundException $ex) {
            return $this->documentManager->create('custom_url_route');
        }

        if (!$routeDocument instanceof RouteDocument
            || $routeDocument->getTargetDocument()->getUuid() !== $document->getUuid()
        ) {
            throw new ResourceLocatorAlreadyExistsException($route, $document->getTitle());
        }

        return $routeDocument;
    }
1128311
private function saveCacheFile($path, $data)
	{
		if (!is_writable($this->dir)) {
		    throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.', $this->dir));
		}

		$tempfile = tempnam($this->dir, uniqid('', true));

		if (false === $tempfile) {
		    throw new \RuntimeException(sprintf('Unable to create tempfile in directory: %s', $this->dir));
		}

		$written = file_put_contents($tempfile, '<?php return unserialize('.var_export(serialize($data), true).');');

		if (false === $written) {
		    throw new \RuntimeException(sprintf('Unable to write cached file to: %s', $tempfile));
		}

		@chmod($tempfile, 0666 & (~$this->umask));

		if (false === rename($tempfile, $path)) {
		    @unlink($tempfile);
		    throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
		}
	}
1342955
function nativeCopy($path, $newPath)
    {
        if (!$this->createDir(Util::dirname($newPath), new Config())) {
            return false;
        }

        $location    = $this->applyPathPrefix($this->encodePath($path));
        $newLocation = $this->applyPathPrefix($this->encodePath($newPath));

        try {
            $destination = $this->client->getAbsoluteUrl($newLocation);
            $response    = $this->client->request('COPY', '/' . ltrim($location, '/'), null, [
                'Destination' => $destination,
            ]);

            if ($response['statusCode'] >= 200 && $response['statusCode'] < 300) {
                return true;
            }
        } catch (NotFound $e) {
            // Would have returned false here, but would be redundant
        }

        return false;
    }