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

writer.php « templates - github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ee6606d1183b52fc95637ec258d5f5cce1a40e90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
global $currentpath;
global $root;
$currentpath = __DIR__."/CarnetElectron/";
$root = \OCP\Util::linkToAbsolute("carnet","templates");
if(strpos($root,"http://") === 0 && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'){
    //should be https...
    $root = "https".substr($root,strlen("http"));
}
$file = file_get_contents($currentpath."reader/reader.html");

$file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) {
    global $currentpath;
    global $root;
    $src = str_replace("<!ROOTPATH>", $root."/CarnetElectron/", $matches[2]);
    $relativePath = str_replace("<!ROOTPATH>", "", $matches[2]);
    return "<script".$matches[1]."src=\"".$src."?mtime=".filemtime($currentpath.$relativePath)."\"";
}, $file);
$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);
$file = str_replace("<!APIURL>", $urlGenerator->linkToRouteAbsolute("carnet.page.index"), $file);
echo $file;

?>