Created
May 7, 2014 16:05
-
-
Save helhum/01e9fe673fc49eef0246 to your computer and use it in GitHub Desktop.
Hosting your own Fluid XSD schemas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-l | |
RewriteRule .* /index.php [L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[host /htdocs/]$ ls | |
index.php ns | |
[host /htdocs/]$ ls ns/ | |
News.xsd TYPO3.CMS.Fluid.xsd TYPO3.Fluid.xsd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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