Commit 87f45b982355c15015ddde02f22b3f8e9bafae93

Authored by rob
1 parent 203f76f5

Initial revision. Allows linking of two existing documents


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1905 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentLinkBL.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 +* Business Logic to link a two documents together in a parent child
  5 +* relationship
  6 +*
  7 +* Expected form variable:
  8 +* o $fDocumentID - primary key of document user is currently viewing
  9 +*
  10 +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
  11 +* @date 22 May 2003
  12 +* @package presentation.lookAndFeel.knowledgeTree.documentmanagement
  13 +*/
  14 +
  15 +require_once("../../../../config/dmsDefaults.php");
  16 +
  17 +if (checkSession()) {
  18 + require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
  19 + require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentLink.inc");
  20 + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
  21 + require_once("$default->fileSystemRoot/lib/security/permission.inc");
  22 + require_once("addDocumentLinkUI.inc");
  23 +
  24 + if (Permission::userHasDocumentWritePermission($fDocumentID)) {
  25 + //user has permission to link this document to another
  26 + if (isset($fForStore)) {
  27 + //create a new document link
  28 + $oDocumentLink = & new DocumentLink($fDocumentID, $fTargetDocumentID);
  29 + if ($oDocumentLink->create()) {
  30 + redirect($default->rootUrl . "/control.php?action=viewDocument&fDocumentID=$fDocumentID");
  31 + } else {
  32 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  33 + //an error occured while trying to create the document link
  34 + $oPatternCustom = & new PatternCustom();
  35 + $oPatternCustom->setHtml(getPage($fDocumentID));
  36 +
  37 + $main->setCentralPayload($oPatternCustom);
  38 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentID=$fDocumentID&fForStore=1");
  39 + $main->setHasRequiredFields(true);
  40 + $main->setErrorMessage("An error occured whilst attempting to link the two documents");
  41 + $main->render();
  42 +
  43 + }
  44 + } else {
  45 + //display the add page
  46 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  47 +
  48 + $oPatternCustom = & new PatternCustom();
  49 + $oPatternCustom->setHtml(getPage($fDocumentID));
  50 + $main->setCentralPayload($oPatternCustom);
  51 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentID=$fDocumentID&fForStore=1");
  52 + $main->setHasRequiredFields(true);
  53 + $main->render();
  54 + }
  55 +
  56 + }
  57 +
  58 +
  59 +}
  60 +
  61 +?>
0 \ No newline at end of file 62 \ No newline at end of file
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentLinkUI.inc 0 → 100644
  1 +<?php
  2 +/**
  3 +* Presentation logic used to link one document to another
  4 +*
  5 +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
  6 +* @date 22 May 2003
  7 +* @package presentation.lookAndFeel.knowledgeTree.documentmanagement
  8 +*/
  9 +
  10 +
  11 +function renderHeading($sHeading) {
  12 + global $default;
  13 + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
  14 + $sColor = $default->siteMap->getSectionColour($sSectionName, "th");
  15 + $sToRender = "<table border=\"0\" width=\"100%\">\n";
  16 + $sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\">$sHeading</th></tr>\n";
  17 + $sToRender .= "<tr/>\n";
  18 + $sToRender .= "<tr/>\n";
  19 + $sToRender .= "</table>\n";
  20 + return $sToRender;
  21 +}
  22 +
  23 +function getPage($iDocumentID) {
  24 + global $default;
  25 +
  26 + $sToRender = renderHeading("Document Linking");
  27 + $sToRender .= "<table>";
  28 + $sToRender .= "<tr>";
  29 + //had a slight problem with netscape 4.7x - it doesn't support disabled. So I had to use
  30 + //javascript to set the onFocus attribute to blur
  31 + $bAddNetscapeScript = false;
  32 + if (! (($default->phpSniff->property("browser") == "moz") && ($default->phpSniff->property("version") <= "4.79")) ) {
  33 + //for any other browser but netscape 4.7 do this
  34 + $sToRender .= "<td>Document to link</td><td><input type=\"text\" DISABLED name=\"fTargetDocument\" value=\"\" /><input type=\"button\" value=\"Browse\" onClick=\"newWindow('http://ktdev/control.php?action=templateBrowse','window2')\"></td>\n";
  35 + }else {
  36 + //for netscape 4.7 do this
  37 + $sToRender .= "<td>Document to link</td><td><input type=\"text\" value=\"\" name=\"fTargetDocument\" onblur=\"disable(document.MainForm.fTargetDocument);\" /><input type=\"button\" value=\"Browse\" onClick=\"disable(document.MainForm.fTargetDocument);newWindow('http://ktdev/control.php?action=templateBrowse','window2')\"></td>\n";
  38 + $bAddNetscapeScript = true;
  39 + }
  40 + $sToRender .= "</tr>\n";
  41 + $sToRender .= "<tr>\n";
  42 + $sToRender .= "<td><table><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/update.gif\" border=\"0\"/></td><td><a href=\"" . $default->rootUrl . "/control.php?action=viewDocument&fDocumentID=$iDocumentID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/></a></td></tr></table>\n";
  43 + //$sToRender .= "<td><table><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/update.gif\" border=\"0\"/></td><td><a href=\"" . $_SERVER["PHP_SELF"] . "?fDocumentID=$iDocumentID&fForStore=1\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/></a></td></tr></table>\n";
  44 + $sToRender .= "</tr>\n";
  45 + $sToRender .= "</table>\n";
  46 + $sToRender .= "<input type=\"hidden\" name=\"fTargetDocumentID\" value=\"-1\" />\n";
  47 +
  48 + return $sToRender . "\n\n" . getValidationJavaScript() . "\n\n" . getBrowseJavaScript() . ($bAddNetscapeScript ? getNetscapeDisableScript() : "");
  49 +}
  50 +
  51 +function getValidationJavaScript() {
  52 + $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n";
  53 + $sToRender .= "function validateForm(theForm) {\n";
  54 + $sToRender .= "\tif (!(validRequired(theForm.fTargetDocument,'Document'))) {\n";
  55 + $sToRender .= "\t\treturn false;\n\t}\n";
  56 + $sToRender .= "return true;\n}\n";
  57 + $sToRender .= "//-->\n</script>\n\n";
  58 + return $sToRender;
  59 +}
  60 +
  61 +function getBrowseJavaScript() {
  62 + $sToRender = "<script language=\"JavaScript\"><!--\n ";
  63 + $sToRender .= "function newWindow(file,window) {\n ";
  64 + $sToRender .= "\tmsgWindow=open(file,window,'resizable=yes,scrollbars=yes, width=400,height=600');\n ";
  65 + $sToRender .= "\tif (msgWindow.opener == null) msgWindow.opener = self; \n ";
  66 + $sToRender .= "}\n";
  67 + $sToRender .= "//--></script>\n";
  68 + return $sToRender;
  69 +}
  70 +
  71 +function getNetscapeDisableScript() {
  72 + $sToRender = "<script language=\"JavaScript\"><!--\n ";
  73 + $sToRender .= "function disable(elem) {\n";
  74 + $sToRender .= "\telem.onfocus=elem.blur;\n";
  75 + $sToRender .= "}\n";
  76 + $sToRender .= "//--></script>\n\n";
  77 + return $sToRender;
  78 +
  79 +}
  80 +
  81 +
  82 +?>
0 \ No newline at end of file 83 \ No newline at end of file