Commit 7b5bb21833b121502f8856737421e3522b376c0d
1 parent
acf24f4f
Fix for KTS-89: multi-way comparison support between documents.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4683 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
92 additions
and
7 deletions
templates/kt3/document/metadata_history.smarty
| ... | ... | @@ -10,7 +10,8 @@ |
| 10 | 10 | <th class="username">{i18n}User{/i18n}</th> |
| 11 | 11 | <th class="date">{i18n}Metadata Version{/i18n}</th> |
| 12 | 12 | <th class="date">{i18n}Content Version{/i18n}</th> |
| 13 | - <th class="compare">{i18n}Compare{/i18n}</th> | |
| 13 | + <th class="compare">{i18n}Compare with Current{/i18n}</th> | |
| 14 | + <th class="compare">{i18n}Compare with Other Version{/i18n}</th> | |
| 14 | 15 | |
| 15 | 16 | </tr> |
| 16 | 17 | </thead> |
| ... | ... | @@ -26,9 +27,10 @@ |
| 26 | 27 | {if ($document->getMetadataVersion() == $oVersion->getMetadataVersion())} |
| 27 | 28 | <strong>{i18n}current version{/i18n}</strong> |
| 28 | 29 | {else} |
| 29 | - <a href="{$smarty.server.PHP_SELF}?action=viewComparison&fDocumentId={$document->getId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}">{i18n}compare with current{/i18n}</a></td> | |
| 30 | + <a href="{$smarty.server.PHP_SELF}?action=viewComparison&fDocumentId={$document->getId()}&fBaseVersion={$oVersion->getMetadataVersionId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}">{i18n}compare with current{/i18n}</a></td> | |
| 30 | 31 | {/if} |
| 31 | - </td> | |
| 32 | + </td> | |
| 33 | + <td><a href="{$smarty.server.PHP_SELF}?action=startComparison&fDocumentId={$document->getId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}">{i18n}compare with other version{/i18n}</a></td> | |
| 32 | 34 | </tr> |
| 33 | 35 | {/foreach} |
| 34 | 36 | </tbody> | ... | ... |
templates/ktcore/document/comparison_version_select.smarty
0 → 100644
| 1 | +<h2>{i18n}Select Document Version to compare against{/i18n}</h2> | |
| 2 | + | |
| 3 | +<p class="descriptiveText">{i18n}This page lists versions of document metadata and allows you to compare a metadata version with the current metadata content.{/i18n}</p> | |
| 4 | + | |
| 5 | + <table class="document_history" summary="{i18n}Document History for KnowledgeTree New UI Presentation{/i18n}" cellspacing="0"> | |
| 6 | + | |
| 7 | + <thead> | |
| 8 | + <tr> | |
| 9 | + <th class="username">{i18n}User{/i18n}</th> | |
| 10 | + <th class="date">{i18n}Metadata Version{/i18n}</th> | |
| 11 | + <th class="compare">{i18n}Compare{/i18n}</th> | |
| 12 | + </tr> | |
| 13 | + </thead> | |
| 14 | + <tbody> | |
| 15 | + {foreach item=oVersion from=$versions} | |
| 16 | + <tr class="{cycle options=even,odd}"> | |
| 17 | + <td class="username">{$context->getUserForId($oVersion->getVersionCreatorId())}</td> | |
| 18 | + <td class="date">{$oVersion->getMetadataVersion()}</td> | |
| 19 | + <td class="compare"> | |
| 20 | + {if ($document->getCurrentMetadataVersionId() == $oVersion->getCurrentMetadataVersionId())} | |
| 21 | + <strong>{i18n}comparing against this version{/i18n}</strong> | |
| 22 | + {else} | |
| 23 | + <a href="{$smarty.server.PHP_SELF}?action=viewComparison&fDocumentId={$document->getId()}&fBaseVersion={$document->getCurrentMetadataVersionId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}">{i18n}compare{/i18n}</a> | |
| 24 | + {/if} | |
| 25 | + </td> | |
| 26 | + </tr> | |
| 27 | + {/foreach} | |
| 28 | + </tbody> | |
| 29 | + | |
| 30 | + </table> | ... | ... |
view.php
| ... | ... | @@ -255,7 +255,8 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 255 | 255 | // this gets in: |
| 256 | 256 | // fDocumentId (document to compare against) |
| 257 | 257 | // fComparisonVersion (the metadata_version of the appropriate document) |
| 258 | - function do_viewComparison() { | |
| 258 | + function do_viewComparison() { | |
| 259 | + | |
| 259 | 260 | $document_data = array(); |
| 260 | 261 | $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); |
| 261 | 262 | if ($document_id === null) { |
| ... | ... | @@ -264,10 +265,13 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 264 | 265 | } |
| 265 | 266 | $document_data["document_id"] = $document_id; |
| 266 | 267 | |
| 268 | + | |
| 269 | + $base_version = KTUtil::arrayGet($_REQUEST, 'fBaseVersion'); | |
| 270 | + | |
| 267 | 271 | // try get the document. |
| 268 | - $oDocument =& Document::get($document_id); | |
| 272 | + $oDocument =& Document::get($document_id, $base_version); | |
| 269 | 273 | if (PEAR::isError($oDocument)) { |
| 270 | - $this->oPage->addError('The document you attempted to retrieve is invalid. Please <a href="' . KTBrowseUtil::getBrowseBaseUrl() . '">browse</a> for one.'); | |
| 274 | + $this->oPage->addError('The base document you attempted to retrieve is invalid. Please <a href="' . KTBrowseUtil::getBrowseBaseUrl() . '">browse</a> for one.'); | |
| 271 | 275 | return $this->do_error(); |
| 272 | 276 | } |
| 273 | 277 | if (!Permission::userHasDocumentReadPermission($oDocument)) { |
| ... | ... | @@ -360,7 +364,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 360 | 364 | } |
| 361 | 365 | |
| 362 | 366 | // FIXME handle ad-hoc fieldsets. |
| 363 | - | |
| 367 | + $this->addPortlets(); | |
| 364 | 368 | $oTemplating = new KTTemplating; |
| 365 | 369 | $oTemplate = $oTemplating->loadTemplate("kt3/compare_document"); |
| 366 | 370 | $aTemplateData = array( |
| ... | ... | @@ -382,6 +386,55 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 382 | 386 | // FIXME show something useful / generic. |
| 383 | 387 | } |
| 384 | 388 | |
| 389 | + function do_startComparison() { | |
| 390 | + $document_data = array(); | |
| 391 | + $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); | |
| 392 | + if ($document_id === null) { | |
| 393 | + $this->oPage->addError('No document was requested. Please <a href="' . KTBrowseUtil::getBrowseBaseUrl() . '">browse</a> for one.'); | |
| 394 | + return $this->do_error(); | |
| 395 | + } | |
| 396 | + $document_data["document_id"] = $document_id; | |
| 397 | + | |
| 398 | + $comparison_version = KTUtil::arrayGet($_REQUEST, 'fComparisonVersion'); | |
| 399 | + if ($comparison_version=== null) { | |
| 400 | + $this->oPage->addError('No comparison version was requested. Please <a href="?action=history&fDocumentId='.$document_id.'">select a version</a>.'); | |
| 401 | + return $this->do_error(); | |
| 402 | + } | |
| 403 | + | |
| 404 | + // try get the document. | |
| 405 | + $oDocument =& Document::get($document_id, $comparison_version); | |
| 406 | + if (PEAR::isError($oDocument)) { | |
| 407 | + $this->oPage->addError('The document you attempted to retrieve is invalid. Please <a href="' . KTBrowseUtil::getBrowseBaseUrl() . '">browse</a> for one.'); | |
| 408 | + return $this->do_error(); | |
| 409 | + } | |
| 410 | + if (!Permission::userHasDocumentReadPermission($oDocument)) { | |
| 411 | + // FIXME inconsistent. | |
| 412 | + $this->oPage->addError(_('You are not allowed to view this document')); | |
| 413 | + return $this->do_error(); | |
| 414 | + } | |
| 415 | + $this->oDocument =& $oDocument; | |
| 416 | + $aOptions = array("final" => false); | |
| 417 | + $this->aBreadcrumbs = array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument, $aOptions)); | |
| 418 | + $this->oPage->setBreadcrumbDetails(_("Select Document Version to compare against")); | |
| 419 | + | |
| 420 | + $aMetadataVersions = KTDocumentMetadataVersion::getByDocument($oDocument); | |
| 421 | + $aVersions = array(); | |
| 422 | + foreach ($aMetadataVersions as $oVersion) { | |
| 423 | + $aVersions[] = Document::get($oDocument->getId(), $oVersion->getId()); | |
| 424 | + } | |
| 425 | + | |
| 426 | + $oTemplating = new KTTemplating; | |
| 427 | + $oTemplate = $oTemplating->loadTemplate("ktcore/document/comparison_version_select"); | |
| 428 | + $aTemplateData = array( | |
| 429 | + "context" => $this, | |
| 430 | + "document_id" => $document_id, | |
| 431 | + "document" => $oDocument, | |
| 432 | + "versions" => $aVersions, | |
| 433 | + 'downloadaction' => $oAction, | |
| 434 | + ); | |
| 435 | + return $oTemplate->render($aTemplateData); | |
| 436 | + } | |
| 437 | + | |
| 385 | 438 | function getUserForId($iUserId) { |
| 386 | 439 | $u = User::get($iUserId); |
| 387 | 440 | return $u->getName(); | ... | ... |