Created
July 27, 2019 10:31
-
-
Save AppWerft/f214d2a3eaf70b039b1d7ec047f3a84c to your computer and use it in GitHub Desktop.
Importer
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 | |
$ts = ''; | |
$R = 'EXT:hosvisualization/Resources/Public'; | |
$EP = "/home/mirko/.web/raw"; | |
$NS = "hosvirt_"; | |
$doc = new DOMDocument(); | |
$doc->loadHTMLFile($EP . "/index.html"); | |
$xpath = new DOMXPath($doc); | |
$count = 10; | |
foreach ($xpath->evaluate("//link[contains(@href, 'css')]") as $node) { | |
$href = $node->getAttribute("href"); | |
$ts .= "//ext. CSS\n"; | |
file_put_contents("Resources/Public/$NS$count.css",getFile($href,$EP)); | |
$ts .= "page.includeCSS.$count = $R/$NS$count.css\n"; | |
$count+=5; | |
} | |
foreach ($xpath->evaluate("//script") as $node) { | |
$src = $node->getAttribute("src"); | |
if ($src == "") { | |
$ts .= "//Inline JS code:\n"; | |
$ts .= "page.jsFooterInline {\n"; | |
$ts .= " $NS$count = TEXT\n"; | |
$ts .= " $NS$count.value(\n"; | |
$ts .= " /* inlinecode from $NS */\n $node->textContent\n"; | |
$ts .= " )\n"; | |
$ts .= "}\n"; | |
file_put_contents("Resources/Public/$NS$count.js",$node->textContent); | |
$ts .= "page.includeJS.$NS$count = $R/$count.js\n"; | |
} else { | |
$src = $node->getAttribute('src'); | |
$ts .= "//ext JS code:\n"; | |
$basename = basename($src); | |
file_put_contents("Resources/Public/$basename",getFile($src,$EP)); | |
$ts .= "page.includeJSFooter.$NS$count = $R/$basename\n"; | |
} | |
$count+=5; | |
} | |
file_put_contents("./Configuration/TypoScript/setup.txt",$ts); | |
function getFile($foo,$EP) { | |
$bar = str_replace('./','/', $EP .$foo); | |
return file_get_contents($bar); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment