// Copyright: Copyright (C) 2004-2007 Pristine Communications // Set the include path if (!defined("INCPATH_SET")) { require_once dirname(__FILE__) . "/incpath.inc.php"; } // Referenced subroutines require_once "monica/callform.inc.php"; require_once "monica/getlang.inc.php"; require_once "monica/gettext.inc.php"; require_once "monica/htmlchar.inc.php"; require_once "monica/lninfo.inc.php"; require_once "monica/page2rel.inc.php"; require_once "monica/pagefunc.inc.php"; require_once "monica/requri.inc.php"; require_once "monica/sql.inc.php"; // fetch_preview: Retrieve a previously suspended preview from, // from $_SESSION or database function fetch_preview() { // S/N not specified if (!array_key_exists("sn", $_GET)) { return array("msg"=>NC_("The following field was not received: \"%s\"."), "margs"=>array("sn"), "isform"=>false); } // Check the source to retrieve the preview form $source = "session"; if (array_key_exists("source", $_GET)) { switch ($_GET["source"]) { // Retrieve from the database case "db": $source = "db"; break; // Retrieve from the $_SESSION saveform case "session": $source = "session"; break; // Other preview sources default: return array("msg"=>NC_("Unknown preview source: \"%s\"."), "margs"=>array($_GET["source"]), "isform"=>false); break; } } // Retrieve the preview form switch ($source) { // Retrieve from the database case "db": // Fetch with fetch_curitem() fetch_curitem(); $GLOBALS["PREVIEW"] =& $GLOBALS["CURRENT"]; break; // Retrieve from the $_SESSION saveform case "session": $GLOBALS["PREVIEW"] =& retrieve_form($_GET["sn"]); if (count($GLOBALS["PREVIEW"]) == 0) { unset($GLOBALS["PREVIEW"]); return array("msg"=>NC_("Unknown preview form: %d."), "margs"=>array($_GET["sn"]), "isform"=>false); } break; } // Tag that this is a preview content $GLOBALS["PREVIEW"]["preview"] = true; // OK return null; } // html_preview: Display the preview function html_preview() { // Lock the required tables if (array_key_exists("REBUILD_TABLES", $GLOBALS)) { $sql_lock = array(); foreach ($GLOBALS["REBUILD_TABLES"] as $table) { $sql_lock[$table] = LOCK_SH; } } sql_lock($sql_lock); global $PREVIEW; $html = compose_page($PREVIEW); $path = $PREVIEW["path"]; // A multi-lingual website if (count($GLOBALS["ALL_LINGUAS"]) > 1 && !preg_match("/\.php\?/", $path)) { $path = "/" . getlang(LN_FILENAME) . $path; } $html = page2rel(page2abs($html, $path), REQUEST_PATH); echo $html; return; } // html_preview_mark: Print the HTML preview mark function html_preview_mark($args = null) { // Obtain page parameters $args = page_param($args); // This is only for the preview if (is_null($args["preview"])) { return; } // Decide the data source $source = "session"; if (array_key_exists("source", $_GET)) { switch ($_GET["source"]) { // Retrieve from the database case "db": $source = "db"; break; // Retrieve from the $_SESSION saveform case "session": $source = "session"; break; // Other preview sources default: trigger_error("Unknown preview source: \"" . $_GET["source"] . "\"", E_USER_ERROR); break; } } // Set the query arguments switch ($source) { // Retrieve from the database case "db": $url = REQUEST_PATH . "?form=cur&sn=" . $_GET["sn"]; break; // Retrieve from the $_SESSION saveform case "session": $url = REQUEST_PATH . "?formid=" . $_GET["sn"]; break; } $areatitle = C_("Preview Mark Area"); ?>