Skip to content

Instantly share code, notes, and snippets.

@helhum
Created May 7, 2014 16:05
Show Gist options
  • Save helhum/01e9fe673fc49eef0246 to your computer and use it in GitHub Desktop.
Save helhum/01e9fe673fc49eef0246 to your computer and use it in GitHub Desktop.
Hosting your own Fluid XSD schemas
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* /index.php [L]
[host /htdocs/]$ ls
index.php ns
[host /htdocs/]$ ls ns/
News.xsd TYPO3.CMS.Fluid.xsd TYPO3.Fluid.xsd
<?php
$hostName = 'xsd.helmut-hummel.de';
$namespacePrefix = '/ns/';
$namespaceSuffix = '/ViewHelpers';
$requestUri = $_SERVER['REQUEST_URI'];
$packageKey = str_replace('/', '.', preg_replace(
'#^' . preg_quote($namespacePrefix, '#') . '#', '',
preg_replace(
'#' . preg_quote($namespaceSuffix, '#') . '$#', '',
$requestUri
)
));
$fileName = __DIR__ . '/ns/' . $packageKey . '.xsd';
if (file_exists($fileName)) {
header('Content-Type: application/xml');
echo str_replace('targetNamespace="http://typo3.org/ns/Your/Package/ViewHelpers"', 'targetNamespace="http://' . $hostName . '/ns/' . implode('/', explode('.', $packageKey)) . '/ViewHelpers"', file_get_contents($fileName));
exit;
} else {
header('HTTP/1.1 404 Not Found');
echo 'No XSD found for package ' . htmlspecialchars($packageKey);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment