本文整理汇总了PHP中TYPO3\CMS\Core\Utility\HttpUtility::buildUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpUtility::buildUrl方法的具体用法?PHP HttpUtility::buildUrl怎么用?PHP HttpUtility::buildUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\HttpUtility
的用法示例。
在下文中一共展示了HttpUtility::buildUrl方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Call the inliner CSS processor
*
* @param string $content
*
* @return string
*/
public function process($content)
{
GeneralUtility::requireOnce(ExtensionManagementUtility::extPath('ink', 'Resources/Private/Php/vendor/autoload.php'));
$pattern = '%<(link|style)(?=[^<>]*?(?:type="(text/css)"|>))(?=[^<>]*?(?:media="([^<>"]*)"|>))(?=[^<>]*?(?:href="(.*?)"|>))(?=[^<>]*(?:rel="([^<>"]*)"|>))(?:.*?</\\1>|[^<>]*>)%si';
$matches = array();
$css = '';
preg_match_all($pattern, $content, $matches);
if (isset($matches[0])) {
foreach ($matches[0] as $key => $match) {
if ($matches[1][$key] === 'style') {
$css .= strip_tags($match);
} elseif (strpos($match, 'type="text/css"') !== FALSE) {
$file = preg_replace('/^(.+)\\.(\\d+)\\.css$/', '$1.css', $matches[4][$key]);
$parts = parse_url($file);
if (isset($parts['query'])) {
unset($parts['query']);
}
if (!isset($parts['host'])) {
$parts['path'] = ltrim($parts['path'], '/');
}
if ($parts['host'] === GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')) {
unset($parts['scheme']);
unset($parts['host']);
$parts['path'] = ltrim($parts['path'], '/');
}
$file = HttpUtility::buildUrl($parts);
$css .= GeneralUtility::getUrl($file);
} else {
continue;
}
$content = str_replace($match, '', $content);
}
}
$format = new CssToInlineStyles($content, $css);
return $format->convert();
}
示例2: isUrlBuiltCorrectly
/**
* @param array $urlParts
* @param string $expected
* @dataProvider isUrlBuiltCorrectlyDataProvider
* @test
*/
public function isUrlBuiltCorrectly(array $urlParts, $expected)
{
$url = \TYPO3\CMS\Core\Utility\HttpUtility::buildUrl($urlParts);
$this->assertEquals($expected, $url);
}
示例3: getUser
public function getUser()
{
$user = false;
if ($this->isServiceResponsible()) {
$loginPid = $this->extConf['basic.']['login_pid'];
$urlParts = ['scheme' => GeneralUtility::getIndpEnv('TYPO3_SSL') ? 'https' : 'http', 'host' => GeneralUtility::getIndpEnv('HTTP_HOST')];
$additionalUrlParts = ['query' => 'id=' . $loginPid . '&no_cache=1&logintype=login&tx_pxhybridauth_login[provider]=' . $this->provider . '&pid=' . $this->userRecordStoragePage . '&tx_pxhybridauth_login[redirect_url]=' . $this->redirectUrl . '&tx_pxhybridauth_login[redirect_pid]=' . $this->redirectPid];
ArrayUtility::mergeRecursiveWithOverrule($urlParts, $additionalUrlParts);
$returnUrl = HttpUtility::buildUrl($urlParts);
$this->signalSlotDispatcher->dispatch(__CLASS__, 'returnUrl', [&$returnUrl, $this]);
$additionalUrlParts = ['query' => 'id=' . $loginPid . '&no_cache=1&tx_pxhybridauth_login[login_error]=1&tx_pxhybridauth_login[provider]=' . $this->provider];
ArrayUtility::mergeRecursiveWithOverrule($urlParts, $additionalUrlParts);
$returnUrlNoUser = HttpUtility::buildUrl($urlParts);
$this->signalSlotDispatcher->dispatch(__CLASS__, 'returnUrlNoUser', [&$returnUrlNoUser, $this]);
$socialUser = $this->singleSignOnUtility->authenticate($this->provider, $returnUrl);
$user = $this->fetchUserRecordByIdentifier($socialUser->identifier);
if (isset($user['username'])) {
$this->login['uname'] = $user['username'];
}
$this->signalSlotDispatcher->dispatch(__CLASS__, 'getUser', [&$user, $socialUser, $this]);
// redirect to px_hybrid_auth login box, when no user found
if (!$user) {
HttpUtility::redirect($returnUrlNoUser);
}
}
return $user;
}
示例4: getServiceUri
/**
* Get the Service URI
*
* @return string
*/
protected function getServiceUri()
{
$uri = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
$parts = (array) parse_url($uri);
$parts['query'] = 'eID=SoapServer&server=' . $this->serverKey;
return HttpUtility::buildUrl($parts);
}
示例5: correctUrl
/**
* Correct url based on RealURL configuration
* if defaultToHTMLsuffixOnPrev is not set, force the trailing / in url
*
* @param string $url
* @return string
*/
protected function correctUrl($url)
{
$urlParameters = parse_url($url);
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) {
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']) && (int) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['fileName']['defaultToHTMLsuffixOnPrev'] === 0) {
if (substr($url, -1) !== '/') {
if (isset($urlParameters['path'])) {
$pathInfo = pathinfo($urlParameters['path']);
if (empty($pathInfo['extension'])) {
$urlParameters['path'] = rtrim($urlParameters['path'], '/') . '/';
$url = \TYPO3\CMS\Core\Utility\HttpUtility::buildUrl($urlParameters);
}
}
}
}
}
// Only look if query is configured and link is relative to the root
if (isset($urlParameters['query']) && !isset($urlParameters['host'])) {
$idOnlyRegEx = '/^id=[1-9][0-9]{0,15}$/i';
if (preg_match($idOnlyRegEx, $urlParameters['query'])) {
$pageId = (int) str_replace('id=', '', $urlParameters['query']);
if ($pageId > 0) {
$url = $pageId;
}
} elseif (class_exists('TYPO3\\CMS\\Core\\Utility\\MathUtility') && method_exists('TYPO3\\CMS\\Core\\Utility\\MathUtility', 'canBeInterpretedAsInteger')) {
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($urlParameters['query'])) {
$url = $urlParameters['query'];
}
}
}
return $url;
}
示例6: generateUrlHash
/**
* Generate the Url Hash
*
* @param string $url
* @return string
*/
public function generateUrlHash($url)
{
$urlParts = parse_url($url);
if (!empty($urlParts['path'])) {
// Remove trailing slash from url generation
$urlParts['path'] = rtrim($urlParts['path'], '/');
}
if (!empty($urlParts['query'])) {
$excludedQueryParameters = $this->getCHashExcludedParameters();
if (!empty($excludedQueryParameters)) {
parse_str($urlParts['query'], $queryParameters);
if (!empty($queryParameters)) {
foreach ($queryParameters as $key => $value) {
if (in_array($key, $excludedQueryParameters)) {
unset($queryParameters[$key]);
$this->keptQueryParameters[$key] = $value;
}
}
$urlParts['query'] = !empty($queryParameters) ? http_build_query($queryParameters) : null;
}
}
}
$url = HttpUtility::buildUrl($urlParts);
// Make sure the hash is case-insensitive
$url = strtolower($url);
return sha1($url);
}
示例7: redirectToAction
protected function redirectToAction($action = 'main')
{
$urlParts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
parse_str($urlParts['query'], $queryParts);
$queryParts['action'] = $action;
$urlParts['query'] = http_build_query($queryParts);
$redirectUrl = \TYPO3\CMS\Core\Utility\HttpUtility::buildUrl($urlParts);
header('Location: ' . $redirectUrl);
exit;
}