Commit 0b97eb1b691b4e58f15989c3853088361e4d869d
1 parent
a567016d
Viewlet framework. Of course, there are no viewlets, but
they will come. Fixes KTS-669 git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5906 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
68 additions
and
41 deletions
lib/actions/documentviewlet.inc.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * $Id: documentaction.inc.php 5848 2006-08-16 15:58:51Z bshuttle $ | ||
| 5 | + * | ||
| 6 | + * The contents of this file are subject to the KnowledgeTree Public | ||
| 7 | + * License Version 1.1 ("License"); You may not use this file except in | ||
| 8 | + * compliance with the License. You may obtain a copy of the License at | ||
| 9 | + * http://www.ktdms.com/KPL | ||
| 10 | + * | ||
| 11 | + * Software distributed under the License is distributed on an "AS IS" | ||
| 12 | + * basis, | ||
| 13 | + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
| 14 | + * for the specific language governing rights and limitations under the | ||
| 15 | + * License. | ||
| 16 | + * | ||
| 17 | + * The Original Code is: KnowledgeTree Open Source | ||
| 18 | + * | ||
| 19 | + * The Initial Developer of the Original Code is The Jam Warehouse Software | ||
| 20 | + * (Pty) Ltd, trading as KnowledgeTree. | ||
| 21 | + * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | ||
| 22 | + * (C) 2006 The Jam Warehouse Software (Pty) Ltd; | ||
| 23 | + * All Rights Reserved. | ||
| 24 | + * | ||
| 25 | + */ | ||
| 26 | + | ||
| 27 | +require_once(KT_LIB_DIR . "/actions/documentaction.inc.php"); | ||
| 28 | + | ||
| 29 | +class KTDocumentViewlet extends KTDocumentAction { | ||
| 30 | + var $sName; | ||
| 31 | + var $sDescription; | ||
| 32 | + | ||
| 33 | + var $_sShowPermission = "ktcore.permissions.read"; | ||
| 34 | + | ||
| 35 | + // the only major distinction of the viewlet vs. the action is the | ||
| 36 | + // display_viewlet() method. | ||
| 37 | + | ||
| 38 | + function display_viewlet() { | ||
| 39 | + return ""; | ||
| 40 | + } | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +?> |
templates/ktcore/document/view.smarty
| @@ -40,20 +40,14 @@ these tasks, use the Request Assistance action.{/i18n} | @@ -40,20 +40,14 @@ these tasks, use the Request Assistance action.{/i18n} | ||
| 40 | {$oFieldset->render($document_data)} | 40 | {$oFieldset->render($document_data)} |
| 41 | {/foreach} | 41 | {/foreach} |
| 42 | 42 | ||
| 43 | +{if !empty($viewlets)} | ||
| 44 | + | ||
| 43 | <!-- Document "Views" --> | 45 | <!-- Document "Views" --> |
| 44 | <div id="document-views"> | 46 | <div id="document-views"> |
| 45 | 47 | ||
| 46 | -<div class="ktError"><p>Someone please suggest some "viewlets" we can ship by default ... | ||
| 47 | -this is a tad bare.</p></div> | ||
| 48 | - | ||
| 49 | -{* | ||
| 50 | -<div class="downloadbox"> | ||
| 51 | - <ul> | ||
| 52 | - {foreach from=$viewlet_info item=aInfo} | ||
| 53 | - <li class="{$aInfo.icon_class}"><a href="{$aInfo.url}">{$aInfo.name}</a></li> | ||
| 54 | - {/foreach} | ||
| 55 | - </ul> | ||
| 56 | -</div> | ||
| 57 | -*} | 48 | +{foreach from=$viewlets item=oViewlet} |
| 49 | + {$oViewlet->display_viewlet()} | ||
| 50 | +{/foreach} | ||
| 58 | 51 | ||
| 59 | </div> | 52 | </div> |
| 53 | +{/if} |
view.php
| @@ -200,36 +200,26 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { | @@ -200,36 +200,26 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { | ||
| 200 | } | 200 | } |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | - $this->oPage->setContentClass('view'); | ||
| 204 | - /* | ||
| 205 | - // we want to enable the viewlets. | ||
| 206 | - | ||
| 207 | - $aMajorInfo = KTDocumentActionUtil::getDocumentActionsByNames(array('ktcore.actions.document.view',), 'documentinfo', $this->oDocument, $this->oUser); | ||
| 208 | - $aMajorActions = KTDocumentActionUtil::getDocumentActionsByNames(array( | ||
| 209 | - 'ktcore.actions.document.checkout', | ||
| 210 | - 'ktcore.actions.document.cancelcheckout', | ||
| 211 | - 'ktcore.actions.document.checkin', | ||
| 212 | - 'ktcore.actions.document.edit' | ||
| 213 | - ), 'documentaction', $this->oDocument, $this->oUser); | ||
| 214 | - | ||
| 215 | - $aMajorViewletActions = kt_array_merge($aMajorInfo, $aMajorActions); | ||
| 216 | - $aViewletInfo = array(); | ||
| 217 | - | ||
| 218 | - //var_dump($aMajorActions[0]); | ||
| 219 | - | ||
| 220 | - foreach ($aMajorViewletActions as $action) { | ||
| 221 | - | ||
| 222 | - $aInfo = $action->getInfo(); | ||
| 223 | - | 203 | + // viewlets. |
| 204 | + $aViewlets = array(); | ||
| 205 | + $aViewletActions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser, 'documentviewlet'); | ||
| 206 | + foreach ($aViewletActions as $oAction) { | ||
| 207 | + $aInfo = $oAction->getInfo(); | ||
| 208 | + | ||
| 224 | if ($aInfo !== null) { | 209 | if ($aInfo !== null) { |
| 225 | - if ($aInfo["ns"] == $this->sName) { | ||
| 226 | - unset($aInfo["url"]); | ||
| 227 | - $aInfo['active'] = true; | ||
| 228 | - } | ||
| 229 | - $aViewletInfo[] = $aInfo; | 210 | + $aViewlets[] = $oAction; // use the action, since we display_viewlet() later. |
| 230 | } | 211 | } |
| 231 | - } | ||
| 232 | - */ | 212 | + } |
| 213 | + | ||
| 214 | + | ||
| 215 | + $content_class = 'view'; | ||
| 216 | + if (!empty($aViewlets)) { | ||
| 217 | + $content_class = 'view withviewlets'; | ||
| 218 | + } | ||
| 219 | + $this->oPage->setContentClass($content_class); | ||
| 220 | + | ||
| 221 | + | ||
| 222 | + | ||
| 233 | $oTemplating =& KTTemplating::getSingleton(); | 223 | $oTemplating =& KTTemplating::getSingleton(); |
| 234 | $oTemplate = $oTemplating->loadTemplate("ktcore/document/view"); | 224 | $oTemplate = $oTemplating->loadTemplate("ktcore/document/view"); |
| 235 | $aTemplateData = array( | 225 | $aTemplateData = array( |
| @@ -241,7 +231,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { | @@ -241,7 +231,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { | ||
| 241 | "document" => $oDocument, | 231 | "document" => $oDocument, |
| 242 | "document_data" => $document_data, | 232 | "document_data" => $document_data, |
| 243 | "fieldsets" => $fieldsets, | 233 | "fieldsets" => $fieldsets, |
| 244 | - 'viewlet_info' => $aViewletInfo, | 234 | + 'viewlets' => $aViewlets, |
| 245 | ); | 235 | ); |
| 246 | //return '<pre>' . print_r($aTemplateData, true) . '</pre>'; | 236 | //return '<pre>' . print_r($aTemplateData, true) . '</pre>'; |
| 247 | return $oTemplate->render($aTemplateData); | 237 | return $oTemplate->render($aTemplateData); |