diff --git a/browse.php b/browse.php
index 8df7aa0..c5d4e2e 100644
--- a/browse.php
+++ b/browse.php
@@ -176,16 +176,6 @@ class BrowseDispatcher extends KTStandardDispatcher {
$portlet = new KTActionPortlet(sprintf(_kt('Actions on this folder')));
$aActions = KTFolderActionUtil::getFolderActionsForFolder($oFolder, $this->oUser);
$portlet->setActions($aActions,null);
- // Set upload button
- $btnName = _kt('Add Document');
- $btnAction = '';
- foreach ($aActions as $item){
- if($item->getDisplayName() == $btnName){
- $btnAction = array($item);
- break;
- }
- }
- $portlet->setButton($btnAction, 'folder_upload');
$this->oPage->addPortlet($portlet);
diff --git a/lib/actions/documentaction.inc.php b/lib/actions/documentaction.inc.php
index 8e3323c..1aa24bf 100644
--- a/lib/actions/documentaction.inc.php
+++ b/lib/actions/documentaction.inc.php
@@ -6,31 +6,31 @@
* Document Management Made Simple
* Copyright (C) 2008 KnowledgeTree Inc.
* Portions copyright The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
- * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
+ * must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
* Contributor( s): ______________________________________
*
@@ -155,17 +155,21 @@ class KTDocumentAction extends KTStandardDispatcher {
}
function getName() {
- return sanitizeForSQLtoHTML($this->sName);
+ return $this->sName;
}
function getDisplayName() {
// Should be overridden by the i18nised display name
// This is here solely for backwards compatibility
- return sanitizeForSQLtoHTML($this->sDisplayName);
+ return $this->sDisplayName;
}
function getDescription() {
- return sanitizeForSQLtoHTML($this->sDescription);
+ return $this->sDescription;
+ }
+
+ function getButton(){
+ return false;
}
function customiseInfo($aInfo) {
@@ -192,8 +196,8 @@ class KTDocumentAction extends KTStandardDispatcher {
$actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser);
$oPortlet = new KTActionPortlet(sprintf(_kt('Document actions')));
$oPortlet->setActions($actions, $this->sName);
- $this->oPage->addPortlet($oPortlet);
+ $this->oPage->addPortlet($oPortlet);
$this->oPage->setSecondaryTitle($this->oDocument->getName());
return true;
diff --git a/lib/actions/folderaction.inc.php b/lib/actions/folderaction.inc.php
index 8d8b0bb..deac892 100644
--- a/lib/actions/folderaction.inc.php
+++ b/lib/actions/folderaction.inc.php
@@ -132,6 +132,10 @@ class KTFolderAction extends KTStandardDispatcher {
return sanitizeForSQLtoHTML($this->sDescription);
}
+ function getButton(){
+ return false;
+ }
+
function customiseInfo($aInfo) {
return $aInfo;
}
@@ -157,16 +161,6 @@ class KTFolderAction extends KTStandardDispatcher {
$portlet = new KTActionPortlet(sprintf(_kt('Actions on this folder')));
$aActions = KTFolderActionUtil::getFolderActionsForFolder($this->oFolder, $this->oUser);
$portlet->setActions($aActions,$this->sName);
- // Set upload button
- $btnName = _kt('Add Document');
- $btnAction = '';
- foreach ($aActions as $item){
- if($item->getDisplayName() == $btnName){
- $btnAction = array($item);
- break;
- }
- }
- $portlet->setButton($btnAction, 'folder_upload');
$this->oPage->addPortlet($portlet);
if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.folder_details', $this->oFolder)) {
diff --git a/lib/widgets/portlet.inc.php b/lib/widgets/portlet.inc.php
index b7a1e52..a8c7ff1 100644
--- a/lib/widgets/portlet.inc.php
+++ b/lib/widgets/portlet.inc.php
@@ -116,7 +116,7 @@ class KTActionPortlet extends KTPortlet {
var $actions = array();
var $bActive = true;
- var $btn = '';
+ var $btns = '';
// current action is the one we are currently on.
function setActions($actions, $currentaction) {
@@ -128,86 +128,77 @@ class KTActionPortlet extends KTPortlet {
unset($aInfo["url"]);
$aInfo['active'] = true;
}
- $this->actions[$aInfo['name']] = $aInfo;
+ $aBtn = $action->getButton();
+
+ if($aBtn){
+ $this->btns[$aInfo['name']] = array_merge($aInfo, $aBtn);
+ }else{
+ $this->actions[$aInfo['name']] = $aInfo;
+ }
}
}
ksort($this->actions);
+ ksort($this->btns);
}
/**
- * Display a button for a given action
+ * Render a button for a given action
*
- * @param array $action
- * @param string $btn
- * @return boolean
+ * @param string $text
+ * @param string $link
+ * @param string $class
+ * @return unknown
*/
- function setButton($action, $btn) {
- // Ensure action is set
- if(!isset($action[0])){
- return false;
- }
-
- $info = $action[0]->getInfo();
-
- // Ensure user has permission on / access to the action
- if(empty($info)){
- return false;
- }
-
- $link = $info['url'];
- $text = $info['name'];
-
- switch($btn){
- case 'document_checkin':
- $text = _kt('Checkin Document');
- $class = 'arrow_upload';
- break;
- case 'folder_upload':
- $text = _kt('Upload Document');
- $class = 'arrow_upload';
- break;
- case 'document_download':
- $text = _kt('Download Document');
- $class = 'arrow_download';
- break;
- default:
- return false;
- }
+ function renderBtn($text, $link, $class) {
// Create button html
$button = "
";
- $this->btn = $button;
- return true;
+ return $button;
+ }
+
+ /**
+ * Render the specified actions as buttons
+ */
+ function showButtons() {
+ if(empty($this->btns)){
+ return '';
+ }
+
+ $rendered = '';
+ foreach ($this->btns as $btn){
+ $text = !empty($btn['display_text']) ? $btn['display_text'] : $btn['name'];
+ $link = $btn['url'];
+ $class = $btn['arrow_class'];
+ $rendered .= $this->renderBtn($text, $link, $class);
+ }
+
+ return $rendered;
}
function render() {
if (empty($this->actions)) {
return null;
}
+
+ $btn = $this->showButtons();
+
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate('kt3/portlets/actions_portlet');
$aTemplateData = array(
'context' => $this,
+ 'btn' => $btn
);
- // Display a button above the action list
- if(isset($this->btn) && !empty($this->btn)){
- $aTemplateData['showBtn'] = true;
- $aTemplateData['btn'] = $this->btn;
- }
-
return $oTemplate->render($aTemplateData);
}
}
diff --git a/plugins/ktcore/KTDocumentActions.php b/plugins/ktcore/KTDocumentActions.php
index ad25ff6..773b632 100644
--- a/plugins/ktcore/KTDocumentActions.php
+++ b/plugins/ktcore/KTDocumentActions.php
@@ -6,31 +6,31 @@
* Document Management Made Simple
* Copyright (C) 2008 KnowledgeTree Inc.
* Portions copyright The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
- * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
+ * must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
* Contributor( s): ______________________________________
*
@@ -326,6 +326,13 @@ class KTDocumentViewAction extends KTDocumentAction {
return _kt('Download');
}
+ function getButton() {
+ $btn = array();
+ $btn['display_text'] = _kt('Download Document');
+ $btn['arrow_class'] = 'arrow_download';
+ return $btn;
+ }
+
function customiseInfo($aInfo) {
$aInfo['alert'] = _kt('This will download a copy of the document and is not the same as Checking Out a document. Changes to this downloaded file will not be managed in the DMS.');
return $aInfo;
@@ -531,6 +538,13 @@ class KTDocumentCheckInAction extends KTDocumentAction {
return _kt('Checkin');
}
+ function getButton() {
+ $btn = array();
+ $btn['display_text'] = _kt('Check Document In');
+ $btn['arrow_class'] = 'arrow_upload';
+ return $btn;
+ }
+
function getInfo() {
if (!$this->oDocument->getIsCheckedOut()) {
return null;
@@ -853,8 +867,8 @@ class KTDocumentDeleteAction extends KTDocumentAction {
$_SESSION['KTErrorMessage'][]= _kt('This document can\'t be deleted because it is checked out');
controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId());
exit(0);
- }
-
+ }
+
return true;
}
@@ -869,11 +883,11 @@ class KTDocumentDeleteAction extends KTDocumentAction {
'submit_label' => _kt('Delete Document'),
'context' => &$this,
));
-
+
return $oForm;
}
-
+
function form_main() {
$oForm = new KTForm;
$oForm->setOptions(array(
@@ -916,7 +930,7 @@ class KTDocumentDeleteAction extends KTDocumentAction {
));
return $oTemplate->render();
}
-
+
function do_confirm(){
$this->oPage->setBreadcrumbDetails(_kt('Confirm delete'));
$oTemplate =& $this->oValidator->validateTemplate('ktcore/action/delete_confirm');
@@ -1386,11 +1400,11 @@ class KTDocumentArchiveAction extends KTDocumentAction {
'submit_label' => _kt('Archive Document'),
'context' => &$this,
));
-
+
return $oForm;
}
-
+
function form_main() {
$oForm = new KTForm;
$oForm->setOptions(array(
@@ -1435,7 +1449,7 @@ class KTDocumentArchiveAction extends KTDocumentAction {
));
return $oTemplate->render();
}
-
+
function do_confirm(){
$this->oPage->setBreadcrumbDetails(_kt('Confirm archive'));
$oTemplate =& $this->oValidator->validateTemplate('ktcore/action/archive_confirm');
diff --git a/plugins/ktcore/folder/addDocument.php b/plugins/ktcore/folder/addDocument.php
index c4969c2..ed96f64 100644
--- a/plugins/ktcore/folder/addDocument.php
+++ b/plugins/ktcore/folder/addDocument.php
@@ -54,6 +54,13 @@ class KTFolderAddDocumentAction extends KTFolderAction {
return _kt('Add Document');
}
+ function getButton(){
+ $btn = array();
+ $btn['display_text'] = _kt('Upload Document');
+ $btn['arrow_class'] = 'arrow_upload';
+ return $btn;
+ }
+
function check() {
$res = parent::check();
if (empty($res)) {
diff --git a/templates/kt3/portlets/actions_portlet.smarty b/templates/kt3/portlets/actions_portlet.smarty
index fe95616..5e116b0 100644
--- a/templates/kt3/portlets/actions_portlet.smarty
+++ b/templates/kt3/portlets/actions_portlet.smarty
@@ -1,4 +1,4 @@
-{if $showBtn}
+{if $btn}
{$btn}
{/if}
diff --git a/view.php b/view.php
index 10d7c13..d2c55e3 100644
--- a/view.php
+++ b/view.php
@@ -96,18 +96,6 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
$this->actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser);
$oPortlet = new KTActionPortlet(sprintf(_kt('Document actions'), $this->oDocument->getName()));
$oPortlet->setActions($this->actions, $currentaction);
-
- // Set download / checkin button
- if($this->oDocument->getIsCheckedOut() && $this->oDocument->getCheckedOutUserID() == $this->oUser->getId()){
- $btn = 'document_checkin';
- $aNames = array('ktcore.actions.document.checkin');
- $btnAction = KTDocumentActionUtil::getDocumentActionsByNames($aNames, 'documentaction', $this->oDocument, $this->oUser);
- }else {
- $btn = 'document_download';
- $aNames = array('ktcore.actions.document.view');
- $btnAction = KTDocumentActionUtil::getDocumentActionsByNames($aNames, 'documentinfo', $this->oDocument, $this->oUser);
- }
- $oPortlet->setButton($btnAction, $btn);
$this->oPage->addPortlet($oPortlet);
}