示例#1
1
function createEmailFromTemplate($templateName, $user, $data = null)
{
    global $APP_DIR;
    $email_config = getConfig("_email");
    if (!$email_config || !$templateName || !$user) {
        return null;
    }
    $templateDir = $email_config["templates"];
    $template = readTextFile("{$APP_DIR}/{$templateDir}/{$templateName}.html");
    if (!$template) {
        return null;
    }
    $name = is_string($user) ? substringBefore($user, "@") : $user["first_name"] . " " . $user["last_name"];
    $to_email = is_string($user) ? $user : $user["email"];
    if (isset($email_config["to"])) {
        $to_email = $email_config["to"];
    }
    $logo = combine($email_config["baseUrl"], getConfig("app.logo"));
    $cfg = array("site" => getConfig("defaultTitle"), "baseUrl" => $email_config["baseUrl"], "logo" => $logo, "name" => $name, "to" => $to_email);
    $template = replaceVariables($template, $cfg);
    $template = replaceVariables($template, $user);
    $template = replaceVariables($template, $data);
    $subject = substringBefore($template, "\n");
    $body = substringAfter($template, "\n");
    //replace classes with inlineStyles
    $styles = readConfigFile("{$APP_DIR}/{$templateDir}/inline.css");
    if ($styles) {
        $body = "<div class=\"fp-email\">{$body}</div>";
        $body = inlineStyles($body, $styles);
    }
    debug("createEmail subject", $subject);
    debug("createEmail body", $body);
    return createEmail($to_email, $subject, $body, true);
}
 public function process($currentXml)
 {
     if (!file_exists($this->generatePath('docvert--all-docbook.xml'))) {
         $editableDocbook = xsltTransform($currentXml, $this->docvertTransformDirectory . 'docbook-to-docbook-with-placeholders.xsl');
         $this->saveFile('docvert--all-docbook.xml', $editableDocbook);
     }
     $chosenTheme = getGlobalConfigItem('theme');
     if ($chosenTheme == null) {
         $chosenTheme = 'docvert';
     }
     $editorTemplatePath = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $chosenTheme . DIRECTORY_SEPARATOR . 'fckeditor-template.html';
     $editorTemplate = file_get_contents($editorTemplatePath);
     $editorTemplate = preg_replace_callback('/\\&(.*?)\\;/s', 'replaceLanguagePlaceholder', $editorTemplate);
     include_once dirname(__FILE__) . '/DocBookToXHTML.php';
     $toHtmlObject = new DocBookToXHTML($this->elementAttributes, $this->pipelineDirectory, $this->contentDirectory, $this->docvertTransformDirectory, $this->loopDepth, $this->depthArray, $this->previewDirectory, $this->pipelineSettings);
     $html = $toHtmlObject->process($currentXml);
     $documentTitlePattern = "/<title[^>]*?>(.*?)<\\/title>/sm";
     preg_match($documentTitlePattern, $html, $matches);
     $documentTitle = trim($matches[1]);
     $documentTitle = preg_replace("/<.*?>/", '', $documentTitle);
     //die($documentTitle.'<hr />'.$html);
     $html = substringAfter($html, '<body');
     $html = substringAfter($html, '>');
     $html = substringBefore($html, '</body');
     $paragraphTitlePattern = "/<p.*?documentTitle[^>]*?>(.*?)<\\/p>/sm";
     $html = preg_replace($paragraphTitlePattern, '', $html);
     $imagePathPrefix = '../../../../writable/' . basename($this->previewDirectory) . '/' . basename($this->contentDirectory) . '/';
     $html = str_replace('src="', 'src="' . $imagePathPrefix, $html);
     //displayXmlString($html);
     $html = str_replace('&', '&amp;', $html);
     $html = str_replace('<', '&lt;', $html);
     $html = str_replace('>', '&gt;', $html);
     $html = str_replace('"', '&quot;', $html);
     $html = trim($html);
     $autoPipeline = $this->pipelineSettings['autopipeline'];
     $autoPipeline = str_replace('.xml', '', $autoPipeline);
     $autoPipeline = str_replace('.default', '', $autoPipeline);
     $editorTemplate = str_replace('{{value}}', $html, $editorTemplate);
     $editorTemplate = str_replace('{{config}}', '', $editorTemplate);
     $editorTemplate = str_replace('{{documentTitle}}', $documentTitle, $editorTemplate);
     $editorTemplate = str_replace('{{documentPath}}', basename($this->previewDirectory) . '/' . basename($this->contentDirectory), $editorTemplate);
     $editorTemplate = str_replace('{{pathToRemove}}', $imagePathPrefix, $editorTemplate);
     $editorTemplate = str_replace('{{pipeline}}', $this->pipelineSettings['pipeline'], $editorTemplate);
     $editorTemplate = str_replace('{{autopipeline}}', $autoPipeline, $editorTemplate);
     $this->saveFile('docvert--all-html.html', $editorTemplate);
     return $currentXml;
 }
示例#3
0
文件: lib.php 项目: Nolfneo/docvert
function zipFiles($path, $zipFilePath)
{
    require_once DOCVERT_DIR . 'core/lib/pclzip-2-6/pclzip.lib.php';
    $archive = new PclZip($zipFilePath);
    $baseDirectoryToRemoveForZipping = $path . DIRECTORY_SEPARATOR;
    if (strpos($path, ":")) {
        // PCLZip will remove path for zipping but it doesn't want the drive letter prefix (eg remove the "c:" part)
        $baseDirectoryToRemoveForZipping = substringAfter($baseDirectoryToRemoveForZipping, ':');
    }
    $returnCode = $archive->create($path, PCLZIP_OPT_REMOVE_PATH, $baseDirectoryToRemoveForZipping);
    if ($returnCode == 0) {
        webServiceError('&error-problem-zipping-files; ' . revealXml($archive->errorInfo(true)));
    }
    return $zipFilePath;
}
示例#4
0
function hasDemographicFilters($filters)
{
    foreach ($filters as $key => $answerId) {
        $questionId = substringAfter($key, "Q_");
        if ($questionId !== "") {
            return true;
        }
    }
    return false;
}
示例#5
0
            $extraParameters .= "&error-commandline-output-directory-does-not-exist;";
        }
        //print $outputZip."\n";
    } elseif (stringStartsWith($argument, '--pipeline=')) {
        //die(substringAfter($argument, '--pipeline='));
        $pipelineName = rawurldecode(substringAfter($argument, '--pipeline='));
        if (!file_exists(DOCVERT_DIR . 'pipeline' . DIRECTORY_SEPARATOR . $pipelineName)) {
            $extraParameters .= '&error-commandline-no-pipeline;';
            $errorPlaceholders['pipeline'] = $pipelineName;
        } else {
            $pipeline = 'regularpipeline:' . $pipelineName;
        }
    } elseif (stringStartsWith($argument, '--autopipeline=')) {
        $autoPipeline = rawurldecode(substringAfter($argument, '--autopipeline='));
    } elseif (stringStartsWith($argument, '--converter=')) {
        $converter = substringAfter($argument, '--converter=');
    } else {
        $extraParameters .= 'Unknown argument: ' . $argument;
        if (!stringStartsWith($argument, '--')) {
            $extraParameters .= '&error-commandline-forget-double-dash;';
        }
        $extraParameters .= "\n\n";
    }
}
if (!$files || !$converter || !$pipeline || !$outputZip || $extraParameters) {
    $commandLineHelp = "\n" . $extraParameters;
    $commandLineHelp .= '&error-command-line-help;';
    $errorPlaceholders['commandLineFiles'] = '';
    $errorPlaceholders['commandLineConverter'] = '';
    $errorPlaceholders['commandLinePipeline'] = '';
    $errorPlaceholders['commandLineOutputZip'] = '';