Commit b4b411bbcf13fca3e67e66ca5e1bc08b46902539
1 parent
e5717287
make links into a viewlet-capable system.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5944 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
96 additions
and
11 deletions
plugins/ktcore/KTCorePlugin.php
| ... | ... | @@ -217,10 +217,6 @@ class KTCorePlugin extends KTPlugin { |
| 217 | 217 | _kt('Document Fieldsets'), |
| 218 | 218 | _kt('Manage the different types of information that can be associated with classes of documents.'), |
| 219 | 219 | 'admin/documentFieldsv2.php', null); |
| 220 | - $this->registerAdminPage("linkmanagement", 'KTDocLinkAdminDispatcher', 'documents', | |
| 221 | - _kt('Link Type Management'), | |
| 222 | - _kt('Manage the different ways documents can be associated with one another.'), | |
| 223 | - 'admin/documentLinks.php', null); | |
| 224 | 220 | $this->registerAdminPage("workflows", 'KTWorkflowDispatcher', 'documents', |
| 225 | 221 | _kt('Workflows'), _kt('Configure the process documents go through.'), |
| 226 | 222 | 'admin/workflows.php', null); | ... | ... |
plugins/ktstandard/KTDocumentLinks.php
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | * All Rights Reserved. |
| 24 | 24 | * |
| 25 | 25 | */ |
| 26 | - | |
| 26 | +require_once(KT_LIB_DIR . "/actions/documentviewlet.inc.php"); | |
| 27 | 27 | require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php'); |
| 28 | 28 | require_once(KT_LIB_DIR . '/documentmanagement/DocumentLink.inc'); |
| 29 | 29 | require_once(KT_LIB_DIR . '/documentmanagement/LinkType.inc'); |
| ... | ... | @@ -47,6 +47,7 @@ class KTDocumentLinks extends KTPlugin { |
| 47 | 47 | |
| 48 | 48 | function setup() { |
| 49 | 49 | $this->registerAction('documentaction', 'KTDocumentLinkAction', 'ktcore.actions.document.link'); |
| 50 | + $this->registerAction('documentviewlet', 'KTDocumentLinkViewlet', 'ktcore.viewlets.document.link'); | |
| 50 | 51 | $this->registerColumn(_kt('Link Title'), 'ktdocumentlinks.columns.title', 'KTDocumentLinkTitle', |
| 51 | 52 | dirname(__FILE__) . '/KTDocumentLinksColumns.php'); |
| 52 | 53 | $this->registerAdminPage("linkmanagement", 'KTDocLinkAdminDispatcher', 'documents', |
| ... | ... | @@ -56,6 +57,74 @@ class KTDocumentLinks extends KTPlugin { |
| 56 | 57 | } |
| 57 | 58 | } |
| 58 | 59 | |
| 60 | + | |
| 61 | + | |
| 62 | +class KTDocumentLinkViewlet extends KTDocumentViewlet { | |
| 63 | + var $sName = 'ktcore.viewlets.document.link'; | |
| 64 | + | |
| 65 | + function display_viewlet() { | |
| 66 | + $oKTTemplating =& KTTemplating::getSingleton(); | |
| 67 | + $oTemplate =& $oKTTemplating->loadTemplate("ktstandard/links/links_viewlet"); | |
| 68 | + if (is_null($oTemplate)) { return ""; } | |
| 69 | + | |
| 70 | + $temp_links_from = DocumentLink::getLinksFromDocument($this->oDocument->getId()); | |
| 71 | + $temp_links_to = DocumentLink::getLinksToDocument($this->oDocument->getId()); | |
| 72 | + | |
| 73 | + $links_to = array(); | |
| 74 | + $links_from = array(); | |
| 75 | + | |
| 76 | + foreach ($temp_links_from as $link) { | |
| 77 | + $oDoc = $link->getChildDocument(); | |
| 78 | + if (PEAR::isError($oDoc)) { | |
| 79 | + continue; | |
| 80 | + } | |
| 81 | + | |
| 82 | + if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.read', $oDoc)) { | |
| 83 | + $type = $link->getLinkType(); | |
| 84 | + $aInfo = array( | |
| 85 | + 'url' => KTBrowseUtil::getUrlForDocument($oDoc), | |
| 86 | + 'name' => $oDoc->getName(), | |
| 87 | + 'type' => $type->getName(), | |
| 88 | + 'description' => $type->getDescription(), | |
| 89 | + ); | |
| 90 | + | |
| 91 | + $links_from[] = $aInfo; | |
| 92 | + } | |
| 93 | + } | |
| 94 | + | |
| 95 | + foreach ($temp_links_to as $link) { | |
| 96 | + $oDoc = $link->getParentDocument(); | |
| 97 | + if (PEAR::isError($oDoc)) { | |
| 98 | + continue; | |
| 99 | + } | |
| 100 | + | |
| 101 | + if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.read', $oDoc)) { | |
| 102 | + $type = $link->getLinkType(); | |
| 103 | + $aInfo = array( | |
| 104 | + 'url' => KTBrowseUtil::getUrlForDocument($oDoc), | |
| 105 | + 'name' => $oDoc->getName(), | |
| 106 | + 'type' => $type->getName(), | |
| 107 | + 'description' => $type->getDescription(), | |
| 108 | + ); | |
| 109 | + | |
| 110 | + $links_to[] = $aInfo; | |
| 111 | + } | |
| 112 | + } | |
| 113 | + | |
| 114 | + if (empty($links_from) && empty($links_to)) { | |
| 115 | + return ""; | |
| 116 | + } | |
| 117 | + | |
| 118 | + $oTemplate->setData(array( | |
| 119 | + 'context' => $this, | |
| 120 | + 'links_from' => $links_from, | |
| 121 | + 'links_to' => $links_to, | |
| 122 | + )); | |
| 123 | + return $oTemplate->render(); | |
| 124 | + } | |
| 125 | + | |
| 126 | +} | |
| 127 | + | |
| 59 | 128 | class KTDocumentLinkAction extends KTDocumentAction { |
| 60 | 129 | var $sName = 'ktcore.actions.document.link'; |
| 61 | 130 | ... | ... |
templates/ktcore/document/view.smarty
| ... | ... | @@ -45,9 +45,7 @@ these tasks, use the Request Assistance action.{/i18n} |
| 45 | 45 | <!-- Document "Views" --> |
| 46 | 46 | <div id="document-views"> |
| 47 | 47 | |
| 48 | -{foreach from=$viewlets item=oViewlet} | |
| 49 | - {$oViewlet->display_viewlet()} | |
| 50 | -{/foreach} | |
| 48 | +{$sviewlet_data} | |
| 51 | 49 | |
| 52 | 50 | </div> |
| 53 | 51 | {/if} | ... | ... |
templates/ktstandard/links/links_viewlet.smarty
0 → 100644
| 1 | +<div class="viewlet"> | |
| 2 | + {if $links_from} | |
| 3 | + <h3>Links from this document</h3> | |
| 4 | + <ul> | |
| 5 | + {foreach from=$links_from item=info} | |
| 6 | + <li class="descriptiveText">{i18n}from{/i18n} <a href="{$info.url}" title="{$info.description}">{$info.name}</a> ({$info.type})</li> | |
| 7 | + {/foreach} | |
| 8 | + </ul> | |
| 9 | + {/if} | |
| 10 | + | |
| 11 | + {if $links_to} | |
| 12 | + <h3>Links to this document</h3> | |
| 13 | + <ul> | |
| 14 | + {foreach from=$links_to item=info} | |
| 15 | + <li class="descriptiveText">{i18n}to{/i18n} <a href="{$info.url}" title="{$info.description}">{$info.name}</a> ({$info.type})</li> | |
| 16 | + {/foreach} | |
| 17 | + </ul> | |
| 18 | + {/if} | |
| 19 | + | |
| 20 | +</div> | ... | ... |
view.php
| ... | ... | @@ -207,13 +207,15 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 207 | 207 | $aInfo = $oAction->getInfo(); |
| 208 | 208 | |
| 209 | 209 | if ($aInfo !== null) { |
| 210 | - $aViewlets[] = $oAction; // use the action, since we display_viewlet() later. | |
| 210 | + $aViewlets[] = $oAction->display_viewlet(); // use the action, since we display_viewlet() later. | |
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | + $viewlet_data = implode(" ", $aViewlets); | |
| 215 | + $viewlet_data = trim($viewlet_data); | |
| 214 | 216 | |
| 215 | 217 | $content_class = 'view'; |
| 216 | - if (!empty($aViewlets)) { | |
| 218 | + if (!empty($viewlet_data)) { | |
| 217 | 219 | $content_class = 'view withviewlets'; |
| 218 | 220 | } |
| 219 | 221 | $this->oPage->setContentClass($content_class); |
| ... | ... | @@ -231,7 +233,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 231 | 233 | "document" => $oDocument, |
| 232 | 234 | "document_data" => $document_data, |
| 233 | 235 | "fieldsets" => $fieldsets, |
| 234 | - 'viewlets' => $aViewlets, | |
| 236 | + 'viewlet_data' => $viewlet_data, | |
| 235 | 237 | ); |
| 236 | 238 | //return '<pre>' . print_r($aTemplateData, true) . '</pre>'; |
| 237 | 239 | return $oTemplate->render($aTemplateData); | ... | ... |