Пример #1
0
 function GenerateOdt($template)
 {
     require_once "generate_odt.php";
     $engine = new XmlTemplateEngine($this->con);
     return $engine->processOdtTemplate($template);
 }
Пример #2
0
        fwrite($zipFile, $template, strlen($template));
        fclose($zipFile);
        $zip = new ZipArchive();
        if ($zip->open('zipFile.odt') !== TRUE) {
            throw new Exception("Template isn't a .odt file");
        }
        $data = $zip->getFromName('content.xml');
        if ($data == '') {
            throw new Exception("Template doesn't contain content.xml");
        }
        $expanded = $this->expandTemplate($data);
        $zip->deleteName('content.xml');
        $zip->addFromString('content.xml', $expanded);
        $zip->close();
        $newData = file_get_contents("zipFile.odt");
        return $newData;
    }
}
// "main body" is just debugging
if ($DEBUGGING) {
    $db = mysqli_connect("localhost", 'ctcweb9_ctcadmin', 'murgatr0ad');
    $db || die('Could not connect to database');
    $db->select_db('ctcweb9_newsletter') || die('Could not open database');
    $filename = "newsletterTemplate.odt";
    $template = file_get_contents($filename);
    $engine = new XmlTemplateEngine($db);
    $result = $engine->processOdtTemplate($template);
    $outFile = fopen('result.odt', 'w');
    fwrite($outFile, $result);
    fclose($outFile);
}