From 563fc050fa6d2ac450df1106ae803aa77cdfd93f Mon Sep 17 00:00:00 2001 From: kevin_fourie Date: Sun, 3 Aug 2008 20:56:08 +0000 Subject: [PATCH] Merged in from STABLE trunk... --- browse.php | 14 ++++++++++++-- lib/actions/folderaction.inc.php | 28 +++++++++++++++++++--------- lib/widgets/portlet.inc.php | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------ resources/css/kt-framing.css | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- resources/graphics/btn_left.gif | Bin 0 -> 171 bytes resources/graphics/btn_left_ro.gif | Bin 0 -> 166 bytes resources/graphics/btn_middle.gif | Bin 0 -> 79 bytes resources/graphics/btn_middle_ro.gif | Bin 0 -> 79 bytes resources/graphics/btn_right.gif | Bin 0 -> 173 bytes resources/graphics/btn_right_ro.gif | Bin 0 -> 173 bytes resources/graphics/download_arrow.gif | Bin 0 -> 662 bytes resources/graphics/upload_arrow.gif | Bin 0 -> 662 bytes templates/kt3/portlets/actions_portlet.smarty | 3 +++ view.php | 16 ++++++++++++++-- 14 files changed, 203 insertions(+), 26 deletions(-) create mode 100644 resources/graphics/btn_left.gif create mode 100644 resources/graphics/btn_left_ro.gif create mode 100644 resources/graphics/btn_middle.gif create mode 100644 resources/graphics/btn_middle_ro.gif create mode 100644 resources/graphics/btn_right.gif create mode 100644 resources/graphics/btn_right_ro.gif create mode 100644 resources/graphics/download_arrow.gif create mode 100644 resources/graphics/upload_arrow.gif diff --git a/browse.php b/browse.php index 4179468..8df7aa0 100644 --- a/browse.php +++ b/browse.php @@ -164,7 +164,7 @@ class BrowseDispatcher extends KTStandardDispatcher { 'ignorepermissions' => KTBrowseUtil::inAdminMode($this->oUser, $oFolder), ); $this->oQuery = new BrowseQuery($oFolder->getId(), $this->oUser, $aOptions); - + $this->resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fFolderId=%d', $oFolder->getId())); // and the portlets @@ -176,6 +176,16 @@ 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); @@ -255,7 +265,7 @@ class BrowseDispatcher extends KTStandardDispatcher { $aOptions['result_url'] = $this->resultURL; $aOptions['is_browse'] = true; - + $collection->setOptions($aOptions); $collection->setQueryObject($this->oQuery); diff --git a/lib/actions/folderaction.inc.php b/lib/actions/folderaction.inc.php index d6a1887..8d8b0bb 100644 --- a/lib/actions/folderaction.inc.php +++ b/lib/actions/folderaction.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): ______________________________________ * @@ -157,6 +157,16 @@ 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 b711c18..b7a1e52 100644 --- a/lib/widgets/portlet.inc.php +++ b/lib/widgets/portlet.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): ______________________________________ * @@ -116,6 +116,7 @@ class KTActionPortlet extends KTPortlet { var $actions = array(); var $bActive = true; + var $btn = ''; // current action is the one we are currently on. function setActions($actions, $currentaction) { @@ -131,8 +132,64 @@ class KTActionPortlet extends KTPortlet { } } ksort($this->actions); + } + + /** + * Display a button for a given action + * + * @param array $action + * @param string $btn + * @return boolean + */ + function setButton($action, $btn) { + // Ensure action is set + if(!isset($action[0])){ + return false; + } - //echo '
'; print_r($this->actions);
+        $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;
+        }
+
+        // Create button html
+        $button = "";
+
+        $this->btn = $button;
+        return true;
     }
 
     function render() {
@@ -140,11 +197,17 @@ class KTActionPortlet extends KTPortlet {
             return null;
         }
         $oTemplating =& KTTemplating::getSingleton();
-        $oTemplate = $oTemplating->loadTemplate("kt3/portlets/actions_portlet");
+        $oTemplate = $oTemplating->loadTemplate('kt3/portlets/actions_portlet');
         $aTemplateData = array(
-            "context" => $this,
+            'context' => $this,
         );
 
+        // 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/resources/css/kt-framing.css b/resources/css/kt-framing.css
index 1d727be..74d1632 100644
--- a/resources/css/kt-framing.css
+++ b/resources/css/kt-framing.css
@@ -1172,6 +1172,85 @@ The text will be hidden for screen view.  The generic fahrner-ish approach comes
 
 
 
+/* upload / download buttons */
+
+.portlet_button {
+    padding: 2px;
+    padding-bottom: 0;
+    height: 40px;
+}
+
+.portlet_button a .btn_text {
+    color: #F8A00C;
+    padding-top: 15px;
+    text-align: center;
+    font-weight: bold;
+    float: left;
+}
+
+
+.portlet_button a:hover .btn_text {
+    color: #F8B01C;
+}
+
+
+#portletbar .portlet .portlet_button a:hover {
+    color: #FFAA00;
+    border: 0px;
+    text-decoration: none;
+}
+
+.portlet_button a .arrow_download {
+    background: transparent url(../../resources/graphics/download_arrow.gif) top right no-repeat;
+    width: 27px;
+    height: 47px;
+    float: right;
+}
+
+.portlet_button a .arrow_upload {
+    background: transparent url(../../resources/graphics/upload_arrow.gif) top right no-repeat;
+    width: 27px;
+    height: 47px;
+    float: right;
+}
+
+.portlet_button a .big_btn_left {
+    background: transparent url(../../resources/graphics/btn_left.gif) top left no-repeat;
+    width: 10px;
+    height: 47px;
+    float: left;
+}
+
+.portlet_button a .big_btn_middle {
+    background: transparent url(../../resources/graphics/btn_middle.gif) repeat-x;
+    height: 47px;
+    float: left;
+    text-align: center;
+    vertical-align: middle;
+    align: center;
+    width: 89%;
+}
+
+.portlet_button a .big_btn_right {
+    background: transparent url(../../resources/graphics/btn_right.gif) top right no-repeat;
+    float: left;
+    width: 10px;
+    height: 47px;
+}
+
+.portlet_button a:hover .big_btn_left {
+    background: transparent url(../../resources/graphics/btn_left_ro.gif) top left no-repeat;
+}
+
+.portlet_button a:hover .big_btn_middle {
+    background: transparent url(../../resources/graphics/btn_middle_ro.gif) repeat-x;
+}
+
+.portlet_button a:hover .big_btn_right {
+    background: transparent url(../../resources/graphics/btn_right_ro.gif) top right no-repeat;
+}
+
+
 /* =========== standard listings. */
 
 
@@ -2160,7 +2239,7 @@ body #content #add_dashlet
     vertical-align: top;
 }
 
-/* Search widget - override ExtJS CSS */
+/* ================= Search widget - override ExtJS CSS ================= */
 
 .x-toolbar{
     border: none;
diff --git a/resources/graphics/btn_left.gif b/resources/graphics/btn_left.gif
new file mode 100644
index 0000000..6241bb1
Binary files /dev/null and b/resources/graphics/btn_left.gif differ
diff --git a/resources/graphics/btn_left_ro.gif b/resources/graphics/btn_left_ro.gif
new file mode 100644
index 0000000..b9a88ed
Binary files /dev/null and b/resources/graphics/btn_left_ro.gif differ
diff --git a/resources/graphics/btn_middle.gif b/resources/graphics/btn_middle.gif
new file mode 100644
index 0000000..59f6fe5
Binary files /dev/null and b/resources/graphics/btn_middle.gif differ
diff --git a/resources/graphics/btn_middle_ro.gif b/resources/graphics/btn_middle_ro.gif
new file mode 100644
index 0000000..31cc6bb
Binary files /dev/null and b/resources/graphics/btn_middle_ro.gif differ
diff --git a/resources/graphics/btn_right.gif b/resources/graphics/btn_right.gif
new file mode 100644
index 0000000..9ab1f8b
Binary files /dev/null and b/resources/graphics/btn_right.gif differ
diff --git a/resources/graphics/btn_right_ro.gif b/resources/graphics/btn_right_ro.gif
new file mode 100644
index 0000000..b5dc908
Binary files /dev/null and b/resources/graphics/btn_right_ro.gif differ
diff --git a/resources/graphics/download_arrow.gif b/resources/graphics/download_arrow.gif
new file mode 100644
index 0000000..c5e1e6b
Binary files /dev/null and b/resources/graphics/download_arrow.gif differ
diff --git a/resources/graphics/upload_arrow.gif b/resources/graphics/upload_arrow.gif
new file mode 100644
index 0000000..0a668c4
Binary files /dev/null and b/resources/graphics/upload_arrow.gif differ
diff --git a/templates/kt3/portlets/actions_portlet.smarty b/templates/kt3/portlets/actions_portlet.smarty
index e271fc4..fe95616 100644
--- a/templates/kt3/portlets/actions_portlet.smarty
+++ b/templates/kt3/portlets/actions_portlet.smarty
@@ -1,3 +1,6 @@
+{if $showBtn}
+
{$btn}
+{/if}
    {foreach item=action from=$context->actions } {if $action != null} diff --git a/view.php b/view.php index 42d4de3..10d7c13 100644 --- a/view.php +++ b/view.php @@ -96,6 +96,18 @@ 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); } @@ -152,7 +164,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { ); $this->oDocument =& $oDocument; - + //Figure out if we came here by navigating trough a shortcut. //If we came here from a shortcut, the breadcrumbspath should be relative //to the shortcut folder. @@ -165,7 +177,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { }else{ $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument, $aOptions, $iSymLinkFolderId)); } - + $this->oPage->setBreadcrumbDetails(_kt('document details')); $this->addPortlets('Document Details'); -- libgit2 0.21.4