Commit 563fc050fa6d2ac450df1106ae803aa77cdfd93f

Authored by kevin_fourie
1 parent 62d0b4c6

Merged in from STABLE trunk...

KTS-3372
"Add prominent Upload and Download buttons to the web interface"
Fixed. Added checkin / download document action buttons and upload document folder action.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.5.3-Release-Branch@8966 c91229c3-7414-0410-bfa2-8a42b809f60b
browse.php
... ... @@ -164,7 +164,7 @@ class BrowseDispatcher extends KTStandardDispatcher {
164 164 'ignorepermissions' => KTBrowseUtil::inAdminMode($this->oUser, $oFolder),
165 165 );
166 166 $this->oQuery = new BrowseQuery($oFolder->getId(), $this->oUser, $aOptions);
167   -
  167 +
168 168 $this->resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fFolderId=%d', $oFolder->getId()));
169 169  
170 170 // and the portlets
... ... @@ -176,6 +176,16 @@ class BrowseDispatcher extends KTStandardDispatcher {
176 176 $portlet = new KTActionPortlet(sprintf(_kt('Actions on this folder')));
177 177 $aActions = KTFolderActionUtil::getFolderActionsForFolder($oFolder, $this->oUser);
178 178 $portlet->setActions($aActions,null);
  179 + // Set upload button
  180 + $btnName = _kt('Add Document');
  181 + $btnAction = '';
  182 + foreach ($aActions as $item){
  183 + if($item->getDisplayName() == $btnName){
  184 + $btnAction = array($item);
  185 + break;
  186 + }
  187 + }
  188 + $portlet->setButton($btnAction, 'folder_upload');
179 189 $this->oPage->addPortlet($portlet);
180 190  
181 191  
... ... @@ -255,7 +265,7 @@ class BrowseDispatcher extends KTStandardDispatcher {
255 265 $aOptions['result_url'] = $this->resultURL;
256 266 $aOptions['is_browse'] = true;
257 267  
258   -
  268 +
259 269  
260 270 $collection->setOptions($aOptions);
261 271 $collection->setQueryObject($this->oQuery);
... ...
lib/actions/folderaction.inc.php
... ... @@ -6,31 +6,31 @@
6 6 * Document Management Made Simple
7 7 * Copyright (C) 2008 KnowledgeTree Inc.
8 8 * Portions copyright The Jam Warehouse Software (Pty) Limited
9   - *
  9 + *
10 10 * This program is free software; you can redistribute it and/or modify it under
11 11 * the terms of the GNU General Public License version 3 as published by the
12 12 * Free Software Foundation.
13   - *
  13 + *
14 14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 17 * details.
18   - *
  18 + *
19 19 * You should have received a copy of the GNU General Public License
20 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21   - *
22   - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
23 23 * California 94120-7775, or email info@knowledgetree.com.
24   - *
  24 + *
25 25 * The interactive user interfaces in modified source and object code versions
26 26 * of this program must display Appropriate Legal Notices, as required under
27 27 * Section 5 of the GNU General Public License version 3.
28   - *
  28 + *
29 29 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 30 * these Appropriate Legal Notices must retain the display of the "Powered by
31   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
32 32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
33   - * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
34 34 * copyright notice.
35 35 * Contributor( s): ______________________________________
36 36 *
... ... @@ -157,6 +157,16 @@ class KTFolderAction extends KTStandardDispatcher {
157 157 $portlet = new KTActionPortlet(sprintf(_kt('Actions on this folder')));
158 158 $aActions = KTFolderActionUtil::getFolderActionsForFolder($this->oFolder, $this->oUser);
159 159 $portlet->setActions($aActions,$this->sName);
  160 + // Set upload button
  161 + $btnName = _kt('Add Document');
  162 + $btnAction = '';
  163 + foreach ($aActions as $item){
  164 + if($item->getDisplayName() == $btnName){
  165 + $btnAction = array($item);
  166 + break;
  167 + }
  168 + }
  169 + $portlet->setButton($btnAction, 'folder_upload');
160 170 $this->oPage->addPortlet($portlet);
161 171  
162 172 if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.folder_details', $this->oFolder)) {
... ...
lib/widgets/portlet.inc.php
... ... @@ -6,31 +6,31 @@
6 6 * Document Management Made Simple
7 7 * Copyright (C) 2008 KnowledgeTree Inc.
8 8 * Portions copyright The Jam Warehouse Software (Pty) Limited
9   - *
  9 + *
10 10 * This program is free software; you can redistribute it and/or modify it under
11 11 * the terms of the GNU General Public License version 3 as published by the
12 12 * Free Software Foundation.
13   - *
  13 + *
14 14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 17 * details.
18   - *
  18 + *
19 19 * You should have received a copy of the GNU General Public License
20 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21   - *
22   - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
23 23 * California 94120-7775, or email info@knowledgetree.com.
24   - *
  24 + *
25 25 * The interactive user interfaces in modified source and object code versions
26 26 * of this program must display Appropriate Legal Notices, as required under
27 27 * Section 5 of the GNU General Public License version 3.
28   - *
  28 + *
29 29 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 30 * these Appropriate Legal Notices must retain the display of the "Powered by
31   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
32 32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
33   - * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
34 34 * copyright notice.
35 35 * Contributor( s): ______________________________________
36 36 *
... ... @@ -116,6 +116,7 @@ class KTActionPortlet extends KTPortlet {
116 116 var $actions = array();
117 117  
118 118 var $bActive = true;
  119 + var $btn = '';
119 120  
120 121 // current action is the one we are currently on.
121 122 function setActions($actions, $currentaction) {
... ... @@ -131,8 +132,64 @@ class KTActionPortlet extends KTPortlet {
131 132 }
132 133 }
133 134 ksort($this->actions);
  135 + }
  136 +
  137 + /**
  138 + * Display a button for a given action
  139 + *
  140 + * @param array $action
  141 + * @param string $btn
  142 + * @return boolean
  143 + */
  144 + function setButton($action, $btn) {
  145 + // Ensure action is set
  146 + if(!isset($action[0])){
  147 + return false;
  148 + }
134 149  
135   - //echo '<pre>'; print_r($this->actions);
  150 + $info = $action[0]->getInfo();
  151 +
  152 + // Ensure user has permission on / access to the action
  153 + if(empty($info)){
  154 + return false;
  155 + }
  156 +
  157 + $link = $info['url'];
  158 + $text = $info['name'];
  159 +
  160 + switch($btn){
  161 + case 'document_checkin':
  162 + $text = _kt('Checkin Document');
  163 + $class = 'arrow_upload';
  164 + break;
  165 + case 'folder_upload':
  166 + $text = _kt('Upload Document');
  167 + $class = 'arrow_upload';
  168 + break;
  169 + case 'document_download':
  170 + $text = _kt('Download Document');
  171 + $class = 'arrow_download';
  172 + break;
  173 + default:
  174 + return false;
  175 + }
  176 +
  177 + // Create button html
  178 + $button = "<div class='portlet_button'>
  179 + <a href='$link'>
  180 + <div class='big_btn_left'></div>
  181 + <div class='big_btn_middle'>
  182 + <div class='btn_text'>{$text}
  183 + </div>
  184 + <div class='{$class}'>
  185 + </div>
  186 + </div>
  187 + <div class='big_btn_right'></div>
  188 + </a>
  189 + </div>";
  190 +
  191 + $this->btn = $button;
  192 + return true;
136 193 }
137 194  
138 195 function render() {
... ... @@ -140,11 +197,17 @@ class KTActionPortlet extends KTPortlet {
140 197 return null;
141 198 }
142 199 $oTemplating =& KTTemplating::getSingleton();
143   - $oTemplate = $oTemplating->loadTemplate("kt3/portlets/actions_portlet");
  200 + $oTemplate = $oTemplating->loadTemplate('kt3/portlets/actions_portlet');
144 201 $aTemplateData = array(
145   - "context" => $this,
  202 + 'context' => $this,
146 203 );
147 204  
  205 + // Display a button above the action list
  206 + if(isset($this->btn) && !empty($this->btn)){
  207 + $aTemplateData['showBtn'] = true;
  208 + $aTemplateData['btn'] = $this->btn;
  209 + }
  210 +
148 211 return $oTemplate->render($aTemplateData);
149 212 }
150 213 }
... ...
resources/css/kt-framing.css
... ... @@ -1172,6 +1172,85 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes
1172 1172  
1173 1173  
1174 1174  
  1175 +/* upload / download buttons */
  1176 +
  1177 +.portlet_button {
  1178 + padding: 2px;
  1179 + padding-bottom: 0;
  1180 + height: 40px;
  1181 +}
  1182 +
  1183 +.portlet_button a .btn_text {
  1184 + color: #F8A00C;
  1185 + padding-top: 15px;
  1186 + text-align: center;
  1187 + font-weight: bold;
  1188 + float: left;
  1189 +}
  1190 +
  1191 +
  1192 +.portlet_button a:hover .btn_text {
  1193 + color: #F8B01C;
  1194 +}
  1195 +
  1196 +
  1197 +#portletbar .portlet .portlet_button a:hover {
  1198 + color: #FFAA00;
  1199 + border: 0px;
  1200 + text-decoration: none;
  1201 +}
  1202 +
  1203 +.portlet_button a .arrow_download {
  1204 + background: transparent url(../../resources/graphics/download_arrow.gif) top right no-repeat;
  1205 + width: 27px;
  1206 + height: 47px;
  1207 + float: right;
  1208 +}
  1209 +
  1210 +.portlet_button a .arrow_upload {
  1211 + background: transparent url(../../resources/graphics/upload_arrow.gif) top right no-repeat;
  1212 + width: 27px;
  1213 + height: 47px;
  1214 + float: right;
  1215 +}
  1216 +
  1217 +.portlet_button a .big_btn_left {
  1218 + background: transparent url(../../resources/graphics/btn_left.gif) top left no-repeat;
  1219 + width: 10px;
  1220 + height: 47px;
  1221 + float: left;
  1222 +}
  1223 +
  1224 +.portlet_button a .big_btn_middle {
  1225 + background: transparent url(../../resources/graphics/btn_middle.gif) repeat-x;
  1226 + height: 47px;
  1227 + float: left;
  1228 + text-align: center;
  1229 + vertical-align: middle;
  1230 + align: center;
  1231 + width: 89%;
  1232 +}
  1233 +
  1234 +.portlet_button a .big_btn_right {
  1235 + background: transparent url(../../resources/graphics/btn_right.gif) top right no-repeat;
  1236 + float: left;
  1237 + width: 10px;
  1238 + height: 47px;
  1239 +}
  1240 +
  1241 +.portlet_button a:hover .big_btn_left {
  1242 + background: transparent url(../../resources/graphics/btn_left_ro.gif) top left no-repeat;
  1243 +}
  1244 +
  1245 +.portlet_button a:hover .big_btn_middle {
  1246 + background: transparent url(../../resources/graphics/btn_middle_ro.gif) repeat-x;
  1247 +}
  1248 +
  1249 +.portlet_button a:hover .big_btn_right {
  1250 + background: transparent url(../../resources/graphics/btn_right_ro.gif) top right no-repeat;
  1251 +}
  1252 +
  1253 +
1175 1254 /* =========== standard listings. */
1176 1255  
1177 1256  
... ... @@ -2160,7 +2239,7 @@ body #content #add_dashlet
2160 2239 vertical-align: top;
2161 2240 }
2162 2241  
2163   -/* Search widget - override ExtJS CSS */
  2242 +/* ================= Search widget - override ExtJS CSS ================= */
2164 2243  
2165 2244 .x-toolbar{
2166 2245 border: none;
... ...
resources/graphics/btn_left.gif 0 → 100644

171 Bytes

resources/graphics/btn_left_ro.gif 0 → 100644

166 Bytes

resources/graphics/btn_middle.gif 0 → 100644

79 Bytes

resources/graphics/btn_middle_ro.gif 0 → 100644

79 Bytes

resources/graphics/btn_right.gif 0 → 100644

173 Bytes

resources/graphics/btn_right_ro.gif 0 → 100644

173 Bytes

resources/graphics/download_arrow.gif 0 → 100644

662 Bytes

resources/graphics/upload_arrow.gif 0 → 100644

662 Bytes

templates/kt3/portlets/actions_portlet.smarty
  1 +{if $showBtn}
  2 +<div style='width: 100%;'>{$btn}</div>
  3 +{/if}
1 4 <ul class="actionlist">
2 5 {foreach item=action from=$context->actions }
3 6 {if $action != null}
... ...
view.php
... ... @@ -96,6 +96,18 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
96 96 $this->actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser);
97 97 $oPortlet = new KTActionPortlet(sprintf(_kt('Document actions'), $this->oDocument->getName()));
98 98 $oPortlet->setActions($this->actions, $currentaction);
  99 +
  100 + // Set download / checkin button
  101 + if($this->oDocument->getIsCheckedOut() && $this->oDocument->getCheckedOutUserID() == $this->oUser->getId()){
  102 + $btn = 'document_checkin';
  103 + $aNames = array('ktcore.actions.document.checkin');
  104 + $btnAction = KTDocumentActionUtil::getDocumentActionsByNames($aNames, 'documentaction', $this->oDocument, $this->oUser);
  105 + }else {
  106 + $btn = 'document_download';
  107 + $aNames = array('ktcore.actions.document.view');
  108 + $btnAction = KTDocumentActionUtil::getDocumentActionsByNames($aNames, 'documentinfo', $this->oDocument, $this->oUser);
  109 + }
  110 + $oPortlet->setButton($btnAction, $btn);
99 111 $this->oPage->addPortlet($oPortlet);
100 112 }
101 113  
... ... @@ -152,7 +164,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
152 164 );
153 165  
154 166 $this->oDocument =& $oDocument;
155   -
  167 +
156 168 //Figure out if we came here by navigating trough a shortcut.
157 169 //If we came here from a shortcut, the breadcrumbspath should be relative
158 170 //to the shortcut folder.
... ... @@ -165,7 +177,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
165 177 }else{
166 178 $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument, $aOptions, $iSymLinkFolderId));
167 179 }
168   -
  180 +
169 181 $this->oPage->setBreadcrumbDetails(_kt('document details'));
170 182 $this->addPortlets('Document Details');
171 183  
... ...