Commit 8a0697291dddb2e0effd1f5bcf98b7f56dfdb907

Authored by bshuttle
1 parent 52d4da76

reordering widget work from BD.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5151 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/browse/BrowseColumns.inc.php
... ... @@ -319,6 +319,44 @@ class SelectionColumn extends BrowseColumn {
319 319 }
320 320  
321 321  
  322 +class SingleSelectionColumn extends SelectionColumn {
  323 + var $show_documents;
  324 + var $show_folders;
  325 +
  326 + function SelectionColumn ($sLabel, $sName, $bShowFolders = true, $bShowDocs = true) {
  327 + $this->show_documents = $bShowDocs;
  328 + $this->show_folders = $bShowFolders;
  329 + parent::BrowseColumn($sLabel, $sName);
  330 + }
  331 +
  332 + function renderHeader($sReturnURL) {
  333 + global $main;
  334 + }
  335 +
  336 + // only include the _f or _d IF WE HAVE THE OTHER TYPE.
  337 + function renderData($aDataRow) {
  338 + $localname = $this->name;
  339 +
  340 + if (($aDataRow["type"] === "folder") && ($this->show_folders)) {
  341 + if ($this->show_documents) {
  342 + $localname .= "_f";
  343 + }
  344 + $v = $aDataRow["folderid"];
  345 + } else if (($aDataRow["type"] === "document") && $this->show_documents) {
  346 + if ($this->show_folders) {
  347 + $localname .= "_d";
  348 + }
  349 + $v = $aDataRow["docid"];
  350 + } else {
  351 + return ' ';
  352 + }
  353 +
  354 + return '<input type="radio" name="' . $localname . '" value="' . $v . '"/>';
  355 + }
  356 +
  357 +}
  358 +
  359 +
322 360 class WorkflowColumn extends BrowseColumn {
323 361  
324 362 function renderHeader($sReturnURL) {
... ...
lib/widgets/reorderdisplay.inc.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * $Id$
  5 + *
  6 + * Copyright (c) 2006 Jam Warehouse http://www.jamwarehouse.com
  7 + *
  8 + * This program is free software; you can redistribute it and/or modify
  9 + * it under the terms of the GNU General Public License as published by
  10 + * the Free Software Foundation; using version 2 of the License.
  11 + *
  12 + * This program is distributed in the hope that it will be useful,
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15 + * GNU General Public License for more details.
  16 + *
  17 + * You should have received a copy of the GNU General Public License
  18 + * along with this program; if not, write to the Free Software
  19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20 + *
  21 + * -------------------------------------------------------------------------
  22 + *
  23 + * You can contact the copyright owner regarding licensing via the contact
  24 + * details that can be found on the KnowledgeTree web site:
  25 + *
  26 + * http://www.ktdms.com/
  27 + */
  28 +
  29 +
  30 +require_once(KT_LIB_DIR . "/templating/templating.inc.php");
  31 +
  32 +
  33 +class ReorderDisplay {
  34 +
  35 + // $aItems is an array of arrays, each subarray having 'id' and 'title' parameters
  36 + function ReorderDisplay($aItems) {
  37 + $this->aItems = $aItems;
  38 + }
  39 +
  40 + function render() {
  41 + global $main;
  42 + $main->requireJSResource("resources/js/reorder.js");
  43 +
  44 + $oTemplating =& KTTemplating::getSingleton();
  45 + $oTemplate = $oTemplating->loadTemplate("kt3/reorderdisplay");
  46 + $aTemplateData = array(
  47 + "context" => $this,
  48 + "items" => $this->aItems,
  49 + );
  50 +
  51 + return $oTemplate->render($aTemplateData);
  52 + }
  53 +}
  54 +
  55 +?>
... ...
resources/css/kt-framing.css
... ... @@ -762,6 +762,8 @@ The text will be hidden for screen view. The generic fahrner-ish approach comes
762 762 .ktActionLink.ktBack, .ktAction.ktBack { background-image: url(../../thirdparty/icon-theme/16x16/actions/back.png); }
763 763 .ktActionLink.ktAllowed, .ktAction.ktAllowed { background-image: url(../../resources/graphics/allowed.png); }
764 764 .ktActionLink.ktDenied, .ktAction.ktDenied { background-image: url(../../resources/graphics/denied.png); }
  765 +.ktActionLink.ktMoveUp, .ktAction.ktMoveUp { background-image: url(../../thirdparty/icon-theme/16x16/actions/move-up.png); }
  766 +.ktActionLink.ktMoveDown, .ktAction.ktMoveDown { background-image: url(../../thirdparty/icon-theme/16x16/actions/move-down.png); }
765 767  
766 768 /* this is sometimes used separately to get the auto-delete help. */
767 769 .ktDelete { }
... ...
resources/css/kt-ie-icons.css
... ... @@ -11,6 +11,8 @@
11 11 .ktActionLink.ktBack, .ktAction.ktBack { background-image: url(../../thirdparty/icon-theme/16x16/actions/back.gif); }
12 12 .ktActionLink.ktAllowed, .ktAction.ktAllowed { background-image: url(../../resources/graphics/allowed.gif); }
13 13 .ktActionLink.ktDenied, .ktAction.ktDenied { background-image: url(../../resources/graphics/denied.gif); }
  14 +.ktActionLink.ktMoveUp, .ktAction.ktMoveUp { background-image: url(../../thirdparty/icon-theme/16x16/actions/move-up.gif); }
  15 +.ktActionLink.ktMoveDown, .ktAction.ktMoveDown { background-image: url(../../thirdparty/icon-theme/16x16/actions/move-down.gif); }
14 16  
15 17 .contenttype.office { background-image: url(../../resources/mimetypes/office.gif); }
16 18 .contenttype.word { background-image: url(../../resources/mimetypes/word.gif); }
... ...
resources/js/reorder.js 0 → 100644
  1 +function getSibling(elm, which) {
  2 + var ret = elm[which + 'Sibling'];
  3 +
  4 + while(!isUndefinedOrNull(ret) && ret.nodeName == '#text') ret = ret[which + 'Sibling'];
  5 + if(isUndefinedOrNull(ret)) return false;
  6 + return ret;
  7 +}
  8 +
  9 +function swapItems(first, second) {
  10 + // ALWAYS in order
  11 + toggleElementClass('odd', first, second);
  12 + toggleElementClass('even', first, second);
  13 + first.parentNode.insertBefore(first, second);
  14 + var pos = first.reorderField.value;
  15 + first.reorderField.value = second.reorderField.value;
  16 + second.reorderField.value = pos;
  17 +
  18 +}
  19 +
  20 +function moveUp() {
  21 + var otherItem = getSibling(this, 'previous');
  22 + if(otherItem) {
  23 + swapItems(this, otherItem);
  24 + }
  25 + return false;
  26 +}
  27 +
  28 +
  29 +function moveDown() {
  30 + var otherItem = getSibling(this, 'next');
  31 + if(otherItem) {
  32 + swapItems(otherItem, this);
  33 + }
  34 + return false;
  35 +}
  36 +
  37 +
  38 +function hookReorderDisplay() {
  39 + var container = $('reorder-container');
  40 + if(isUndefinedOrNull(container)) return;
  41 + forEach(getElementsByTagAndClassName('*', 'reorder-item', container), function(item) {
  42 + var up = getElementsByTagAndClassName('*', 'reorder-up', item)[0],
  43 + down = getElementsByTagAndClassName('*', 'reorder-down', item)[0];
  44 +
  45 + up.onclick = bind(moveUp, item);
  46 + down.onclick = bind(moveDown, item);
  47 + item.reorderField = getElementsByTagAndClassName('input', 'reorder-field', item)[0];
  48 + });
  49 +}
  50 +
  51 +
  52 +
  53 +addLoadEvent(hookReorderDisplay);
0 54 \ No newline at end of file
... ...
templates/kt3/reorderdisplay.smarty 0 → 100644
  1 +
  2 +
  3 +
  4 +<table class="kt_collection">
  5 + <thead>
  6 + <tr>
  7 + <th>Item</th>
  8 + <th>Up</th>
  9 + <th>Down</th>
  10 + </tr>
  11 + </thead>
  12 +
  13 + <tbody id="reorder-container">
  14 +{foreach from=$items key=iPosition item=aItem}
  15 + <tr class="reorder-item {cycle values=odd,even}">
  16 + <td>
  17 + <input type="hidden" class="reorder-field" name="position[]" value="{$iPosition}" />
  18 + <input type="hidden" name="id[]" value="{$aItem.id}" />
  19 + {$aItem.title}
  20 + </td>
  21 + <td><a href="#" class="reorder-up ktAction ktMoveUp">&nbsp;</a></td>
  22 + <td><a href="#" class="reorder-down ktAction ktMoveDown">&nbsp;</a></td>
  23 + </tr>
  24 +{/foreach}
  25 + </tbody>
  26 +</table>
... ...
thirdparty/icon-theme/16x16/actions/move-down.gif 0 → 100644

334 Bytes

thirdparty/icon-theme/16x16/actions/move-down.png 0 → 100644

440 Bytes

thirdparty/icon-theme/16x16/actions/move-up.gif 0 → 100644

333 Bytes

thirdparty/icon-theme/16x16/actions/move-up.png 0 → 100644

441 Bytes