Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2020-10-07 22:11:31 +0300
committerPhie <phie@phie.ovh>2020-10-07 22:11:31 +0300
commit711d515e680101f0c94d782a2e17da75a661e04d (patch)
tree3c8ec6e9baf4336176b175d39402369626d3bf33
parent0121231ec5e4f557a122d4449cef77dad526286b (diff)
exporter.php
-rw-r--r--templates/exporter.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/templates/exporter.php b/templates/exporter.php
new file mode 100644
index 0000000..2c14314
--- /dev/null
+++ b/templates/exporter.php
@@ -0,0 +1,44 @@
+<?php
+global $currentpath;
+global $root;
+global $appVersion;
+$appVersion = $_['app_version'];
+$currentpath = __DIR__."/CarnetElectron/";
+$root = \OCP\Util::linkToAbsolute("carnet","templates");
+$root = parse_url($root, PHP_URL_PATH);
+
+$file = file_get_contents($currentpath."exporter/exporter.html");
+$file = preg_replace_callback('/<link(.*?)href=\"(.*?\.css(?:\?.*?)?)"/s',function ($matches) {
+ global $currentpath;
+ global $appVersion;
+ global $root;
+ return "<link".$matches[1]."href=\"".$matches[2]."?v=".$appVersion."\"";
+}, $file);
+$file = str_replace("href=\"","href=\"".$root."/CarnetElectron/exporter/",$file);
+
+$file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) {
+ global $currentpath;
+ global $fullscreen;
+ global $appVersion;
+ global $root;
+
+ return "<script".$matches[1]."src=\"".$root."/CarnetElectron/exporter/".$matches[2]."?v=".$appVersion."\"";
+}, $file);
+// token is needed to pass the csfr check
+$file .= "<span style=\"display:none;\" id=\"token\">".$_['requesttoken']."</span>";
+
+
+$file .= "<script src=\"".$root."/CarnetElectron/compatibility/nextcloud/fullscreen.js?v=".$appVersion."\"></script>";
+
+$file = str_replace("<!ROOTPATH>", $root."/CarnetElectron/", $file);
+$root = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']));
+$urlGenerator = \OC::$server->getURLGenerator();
+$file = str_replace("<!ROOTURL>", $root."/CarnetElectron/", $file);
+if (method_exists(\OC::$server, "getContentSecurityPolicyNonceManager")){
+ $nonce = \OC::$server->getContentSecurityPolicyNonceManager()->getNonce();
+ $file = str_replace("src=\"","defer nonce='".$nonce."' src=\"",$file);
+}
+$file = str_replace("<!APIURL>", parse_url($urlGenerator->linkToRouteAbsolute("carnet.page.index"), PHP_URL_PATH), $file);
+echo $file;
+
+?> \ No newline at end of file