function getCustomFilenames() { $defaultFilenameForIndex = "index.html"; $customFilenameIndex = getGlobalConfigItem('customFilenameIndex'); if ($customFilenameIndex === null) { $customFilenameIndex = $defaultFilenameForIndex; } $defaultFilenameForSection = "section#.html"; $customFilenameSection = getGlobalConfigItem('customFilenameSection'); if ($customFilenameSection === null) { $customFilenameSection = $defaultFilenameForSection; } return array($defaultFilenameForIndex, $customFilenameSection); }
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('&', '&', $html); $html = str_replace('<', '<', $html); $html = str_replace('>', '>', $html); $html = str_replace('"', '"', $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; }
function getSuperUserPreference() { $superUserPreference = 'sudo'; $customSuperUserPreference = getGlobalConfigItem('superUserPreference'); if ($customSuperUserPreference) { $superUserPreference = $customSuperUserPreference; } return $superUserPreference; }
function forcePipeline() { if (!$this->allowedAdminAccess) { return; } if (isset($_POST['forcePipeline'])) { setGlobalConfigItem('forcePipeline', $_POST['forcePipeline']); } $template = $this->getThemeFragment('admin-force-pipeline.htmlf'); $pipelinesDirectory = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'pipeline' . DIRECTORY_SEPARATOR; $pipelines = glob($pipelinesDirectory . '*'); $optionsHtmlString = ''; $forcedPipeline = getGlobalConfigItem('forcePipeline'); foreach ($pipelines as $pipeline) { $optionsHtmlString .= '<option value="' . basename($pipeline) . '" '; if (basename($pipeline) == $forcedPipeline) { $optionsHtmlString .= ' selected="selected" '; } $optionsHtmlString .= '>' . basename($pipeline) . '</option>'; } $template = str_replace('{{pipelines}}', $optionsHtmlString, $template); $forcePipeline = getGlobalConfigItem('forcePipeline'); if ($forcePipeline == null) { $template = str_replace('{{forcePipelineEnabled}}', '', $template); $template = str_replace('{{freelyChoosePipelinesEnabled}}', 'disabled="disabled" style="background:#99ff99;border:none"', $template); } else { $template = str_replace('{{forcePipelineEnabled}}', ' style="background:#99ff99;color:black"', $template); $template = str_replace('{{freelyChoosePipelinesEnabled}}', ' ', $template); } return $template; }
function getLanguageToUse() { $language = getGlobalConfigItem('language'); if ($language == '' || $language == getAutoDetectLanguage()) { $langCodes = array(); if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $httpLangCodes = substringBefore($_SERVER['HTTP_ACCEPT_LANGUAGE'], ';'); $httpLangCodes = explode(',', $httpLangCodes); foreach ($httpLangCodes as $httpLangCode) { if (strlen($httpLangCode) >= 2) { $langCodes[] = substr($httpLangCode, 0, 2); } } } elseif (isset($_ENV['LC_MESSAGES']) || isset($_ENV[' LC_ALL']) || isset($_ENV['LANG'])) { $langCode = ''; if (isset($_ENV['LC_MESSAGES']) && trim($_ENV['LC_MESSAGES'])) { $langCode = $_ENV['LC_MESSAGES']; } elseif (isset($_ENV['LC_ALL']) && trim($_ENV['LC_ALL'])) { $langCode = $_ENV['LC_ALL']; } elseif (isset($_ENV['LANG']) && trim($_ENV['LANG'])) { $langCode = $_ENV['LANG']; } if (strlen($langCode) >= 2) { $langCodes = array(substr($langCode, 0, 2)); } } foreach ($langCodes as $langCode) { switch ($langCode) { case 'en': return 'english'; case 'fr': return 'french'; } } return 'english'; } else { return $language; } }
static function getAdminPassword() { return getGlobalConfigItem('adminPassword'); }