From 7b5bb21833b121502f8856737421e3522b376c0d Mon Sep 17 00:00:00 2001 From: bshuttle Date: Wed, 25 Jan 2006 12:22:38 +0000 Subject: [PATCH] Fix for KTS-89: multi-way comparison support between documents. --- templates/kt3/document/metadata_history.smarty | 8 +++++--- templates/ktcore/document/comparison_version_select.smarty | 30 ++++++++++++++++++++++++++++++ view.php | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 templates/ktcore/document/comparison_version_select.smarty diff --git a/templates/kt3/document/metadata_history.smarty b/templates/kt3/document/metadata_history.smarty index 31704e2..85764b4 100644 --- a/templates/kt3/document/metadata_history.smarty +++ b/templates/kt3/document/metadata_history.smarty @@ -10,7 +10,8 @@ {i18n}User{/i18n} {i18n}Metadata Version{/i18n} {i18n}Content Version{/i18n} - {i18n}Compare{/i18n} + {i18n}Compare with Current{/i18n} + {i18n}Compare with Other Version{/i18n} @@ -26,9 +27,10 @@ {if ($document->getMetadataVersion() == $oVersion->getMetadataVersion())} {i18n}current version{/i18n} {else} - {i18n}compare with current{/i18n} + {i18n}compare with current{/i18n} {/if} - + + {i18n}compare with other version{/i18n} {/foreach} diff --git a/templates/ktcore/document/comparison_version_select.smarty b/templates/ktcore/document/comparison_version_select.smarty new file mode 100644 index 0000000..3dc1cd3 --- /dev/null +++ b/templates/ktcore/document/comparison_version_select.smarty @@ -0,0 +1,30 @@ +

{i18n}Select Document Version to compare against{/i18n}

+ +

{i18n}This page lists versions of document metadata and allows you to compare a metadata version with the current metadata content.{/i18n}

+ + + + + + + + + + + + {foreach item=oVersion from=$versions} + + + + + + {/foreach} + + +
{i18n}User{/i18n}{i18n}Metadata Version{/i18n}{i18n}Compare{/i18n}
{$context->getUserForId($oVersion->getVersionCreatorId())}{$oVersion->getMetadataVersion()} + {if ($document->getCurrentMetadataVersionId() == $oVersion->getCurrentMetadataVersionId())} + {i18n}comparing against this version{/i18n} + {else} + {i18n}compare{/i18n} + {/if} +
diff --git a/view.php b/view.php index a3f9365..6ce6f37 100755 --- a/view.php +++ b/view.php @@ -255,7 +255,8 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { // this gets in: // fDocumentId (document to compare against) // fComparisonVersion (the metadata_version of the appropriate document) - function do_viewComparison() { + function do_viewComparison() { + $document_data = array(); $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); if ($document_id === null) { @@ -264,10 +265,13 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { } $document_data["document_id"] = $document_id; + + $base_version = KTUtil::arrayGet($_REQUEST, 'fBaseVersion'); + // try get the document. - $oDocument =& Document::get($document_id); + $oDocument =& Document::get($document_id, $base_version); if (PEAR::isError($oDocument)) { - $this->oPage->addError('The document you attempted to retrieve is invalid. Please browse for one.'); + $this->oPage->addError('The base document you attempted to retrieve is invalid. Please browse for one.'); return $this->do_error(); } if (!Permission::userHasDocumentReadPermission($oDocument)) { @@ -360,7 +364,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { } // FIXME handle ad-hoc fieldsets. - + $this->addPortlets(); $oTemplating = new KTTemplating; $oTemplate = $oTemplating->loadTemplate("kt3/compare_document"); $aTemplateData = array( @@ -382,6 +386,55 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { // FIXME show something useful / generic. } + function do_startComparison() { + $document_data = array(); + $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); + if ($document_id === null) { + $this->oPage->addError('No document was requested. Please browse for one.'); + return $this->do_error(); + } + $document_data["document_id"] = $document_id; + + $comparison_version = KTUtil::arrayGet($_REQUEST, 'fComparisonVersion'); + if ($comparison_version=== null) { + $this->oPage->addError('No comparison version was requested. Please select a version.'); + return $this->do_error(); + } + + // try get the document. + $oDocument =& Document::get($document_id, $comparison_version); + if (PEAR::isError($oDocument)) { + $this->oPage->addError('The document you attempted to retrieve is invalid. Please browse for one.'); + return $this->do_error(); + } + if (!Permission::userHasDocumentReadPermission($oDocument)) { + // FIXME inconsistent. + $this->oPage->addError(_('You are not allowed to view this document')); + return $this->do_error(); + } + $this->oDocument =& $oDocument; + $aOptions = array("final" => false); + $this->aBreadcrumbs = array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument, $aOptions)); + $this->oPage->setBreadcrumbDetails(_("Select Document Version to compare against")); + + $aMetadataVersions = KTDocumentMetadataVersion::getByDocument($oDocument); + $aVersions = array(); + foreach ($aMetadataVersions as $oVersion) { + $aVersions[] = Document::get($oDocument->getId(), $oVersion->getId()); + } + + $oTemplating = new KTTemplating; + $oTemplate = $oTemplating->loadTemplate("ktcore/document/comparison_version_select"); + $aTemplateData = array( + "context" => $this, + "document_id" => $document_id, + "document" => $oDocument, + "versions" => $aVersions, + 'downloadaction' => $oAction, + ); + return $oTemplate->render($aTemplateData); + } + function getUserForId($iUserId) { $u = User::get($iUserId); return $u->getName(); -- libgit2 0.21.4