Commit 0573fffe8b96b78efe90380a88b0e45ad60178e7

Authored by bshuttle
1 parent 5de6b7c9

moved admin/documentlink to new environment


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4088 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/LinkType.inc
... ... @@ -83,6 +83,7 @@ class LinkType extends KTEntity {
83 83 $oLinkType->iId = $res['id'];
84 84 return $oLinkType;
85 85 }
  86 +
86 87 }
87 88  
88 89 function &linktypecreateFromArray($aParameters) {
... ...
plugins/ktcore/KTAdminPlugins.php
... ... @@ -30,6 +30,7 @@ $oAdminRegistry->registerLocation("admin",null,"principals", "Add/Remove Users",
30 30  
31 31 // documents
32 32 $oAdminRegistry->registerLocation("fieldmanagement",'KTDocumentFieldDispatcher','documents', 'Document Fieldsets','Control which kinds of documents have which sets of information associated with them.', KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/documentFields.php', null);
  33 +$oAdminRegistry->registerLocation("linkmanagement",'KTDocLinkAdminDispatcher','documents', 'Link Type Management','Specify the different "link types" - ways to relate different documents togeter.', KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/doclinkmanagement/documentLinks.php', null);
33 34  
34 35  
35 36 // storage
... ...
presentation/lookAndFeel/knowledgeTree/administration/doclinkmanagement/documentLinks.php 0 → 100644
  1 +<?php
  2 +
  3 +/*
  4 + * Document Link Type management
  5 + *
  6 + * Copyright (c) 2003 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; either version 2 of the License, or
  11 + * (at your option) any later version.
  12 + *
  13 + * This program is distributed in the hope that it will be useful,
  14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 + * GNU General Public License for more details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program; if not, write to the Free Software
  20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21 + *
  22 + * @version $Revision$
  23 + * @author Brad Shuttleworth <brad@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
  24 + * @package documentmanagement
  25 + */
  26 +
  27 +/* boilerplate */
  28 +//require_once('../../../../../config/dmsDefaults.php');
  29 +
  30 +require_once(KT_LIB_DIR . '/dispatcher.inc.php');
  31 +require_once(KT_LIB_DIR . '/templating/kt3template.inc.php');
  32 +
  33 +require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php');
  34 +
  35 +require_once(KT_LIB_DIR . '/documentmanagement/LinkType.inc'); // a horrible piece of work.
  36 +
  37 +class KTDocLinkAdminDispatcher extends KTAdminDispatcher {
  38 +
  39 + // Breadcrumbs base - added to in methods
  40 + var $aBreadcrumbs = array(
  41 + array('action' => 'administration', 'name' => 'Administration'),
  42 + );
  43 +
  44 + function check() {
  45 + return true;
  46 + }
  47 +
  48 + function do_main() {
  49 + $this->aBreadcrumbs[] = array('name' => 'Document Links');
  50 + $this->oPage->setBreadcrumbDetails("view");
  51 +
  52 + $aLinkTypes =& LinkType::getList('id > 0');
  53 +
  54 + $addLinkForm = array();
  55 + // KTBaseWidget($sLabel, $sDescription, $sName, $value, $oPage, $bRequired = false, $sId = null, $aErrors = null, $aOptions = null)
  56 + $addLinkForm[] = new KTStringWidget('Name','A short, human-readable name for the link type.', 'fName', null, $this->oPage, true);
  57 + $addLinkForm[] = new KTStringWidget('Description','A short brief description of the relationship implied by this link type.', 'fDescription', null, $this->oPage, true);
  58 +
  59 +
  60 + $oTemplating =& KTTemplating::getSingleton();
  61 + $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/linktypesadmin');
  62 + $oTemplate->setData(array(
  63 + "context" => $this,
  64 + "add_form" => $addLinkForm,
  65 + "links" => $aLinkTypes,
  66 + ));
  67 + return $oTemplate;
  68 + }
  69 +
  70 + function do_edit() {
  71 + $link_id = KTUtil::arrayGet($_REQUEST, 'fLinkTypeId', null, false);
  72 + if ($link_id === null) {
  73 + $this->errorRedirectToMain("Please specify a link type to edit.");
  74 + }
  75 +
  76 + $oLinkType =& LinkType::get($link_id);
  77 +
  78 + $this->aBreadcrumbs[] = array('name' => 'Document Links');
  79 + $this->oPage->setBreadcrumbDetails("view");
  80 +
  81 + $aLinkTypes =& LinkType::getList('id > 0');
  82 +
  83 + $editLinkForm = array();
  84 + // KTBaseWidget($sLabel, $sDescription, $sName, $value, $oPage, $bRequired = false, $sId = null, $aErrors = null, $aOptions = null)
  85 + $editLinkForm[] = new KTStringWidget('Name','A short, human-readable name for the link type.', 'fName', $oLinkType->getName(), $this->oPage, true);
  86 + $editLinkForm[] = new KTStringWidget('Description','A short brief description of the relationship implied by this link type.', 'fDescription', $oLinkType->getDescription(), $this->oPage, true);
  87 +
  88 +
  89 + $oTemplating =& KTTemplating::getSingleton();
  90 + $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/linktypesadmin');
  91 + $oTemplate->setData(array(
  92 + "context" => $this,
  93 + "edit_form" => $editLinkForm,
  94 + "old_link" => $oLinkType,
  95 + "links" => $aLinkTypes,
  96 + ));
  97 + return $oTemplate;
  98 + }
  99 +
  100 +
  101 + function do_update() {
  102 + $link_id = KTUtil::arrayGet($_REQUEST, 'fLinkTypeId', null, false);
  103 + if ($link_id === null) {
  104 + $this->errorRedirectToMain("Please specify a link type to update.");
  105 + }
  106 +
  107 + $name = KTUtil::arrayGet($_REQUEST, 'fName');
  108 + $description = KTUtil::arrayGet($_REQUEST, 'fDescription');
  109 +
  110 + if (empty($name) || empty($description)) { // for bonus points, make this go to edit, and edit catch it.
  111 + $this->errorRedirectToMain('Please enter information for all fields.');
  112 + }
  113 +
  114 + $oLinkType =& LinkType::get($link_id);
  115 +
  116 + $oLinkType->setName($name);
  117 + $oLinkType->setDescription($description);
  118 + $oLinkType->update();
  119 +
  120 + $this->successRedirectToMain("Link Type updated.");
  121 + }
  122 +
  123 + function do_add() {
  124 + $name = KTUtil::arrayGet($_REQUEST, 'fName');
  125 + $description = KTUtil::arrayGet($_REQUEST, 'fDescription');
  126 +
  127 + if (empty($name) || empty($description)) {
  128 + $this->errorRedirectToMain('Please enter information for all fields.');
  129 + }
  130 +
  131 + $oLinkType = new LinkType($name, $description);
  132 + $oLinkType->create();
  133 +
  134 + //$oLinkType =& LinkType::createFromArray(array("sName" => $name, "sDescription" => $description));
  135 +
  136 + $this->successRedirectToMain("Link Type created.");
  137 + }
  138 +
  139 + function do_delete() {
  140 + $types_to_delete = KTUtil::arrayGet($_REQUEST, 'fLinksToDelete'); // is an array.
  141 +
  142 + if (empty($types_to_delete)) {
  143 + $this->errorRedirectToMain('Please select one or more link types to delete.');
  144 + }
  145 +
  146 + $count = 0;
  147 + foreach ($types_to_delete as $link_id) {
  148 + $oLinkType = LinkType::get($link_id);
  149 + $oLinkType->delete(); // technically, this is a bad thing
  150 + $count += 1;
  151 + }
  152 +
  153 + //$oLinkType =& LinkType::createFromArray(array("sName" => $name, "sDescription" => $description));
  154 +
  155 + $this->successRedirectToMain($count . " Link types deleted.");
  156 + }
  157 +
  158 +
  159 +}
  160 +
  161 +// use the new admin framework.
  162 +//$d = new KTDocLinkAdminDispatcher();
  163 +//$d->dispatch();
  164 +
  165 +?>
0 166 \ No newline at end of file
... ...
templates/ktcore/document/admin/linktypesadmin.smarty 0 → 100644
  1 +<h2>Document Link Type Management</h2>
  2 +
  3 +<p class="descriptiveText">Within the <strong>KnowledgeTree</strong> it is possible for users
  4 +to create links between related documents. Each of these links has a certain type.
  5 +<strong>FIXME</strong> this help text is useless.</p>
  6 +
  7 +{if ($add_form)}
  8 +
  9 +<form action="{$smarty.server.PHP_SELF}" method="POST">
  10 +<fieldset>
  11 +<legend>Add a link type</legend>
  12 +<p class="descriptiveText">Specify the details for a new link type below.</p>
  13 +
  14 +{foreach item=oWidget from=$add_form}
  15 + {$oWidget->render()}
  16 +{/foreach}
  17 +
  18 +<div class="form_actions">
  19 + <input type="hidden" name="action" value="add" />
  20 + <input type="submit" value="Add Link Type" />
  21 +</div>
  22 +</fieldset>
  23 +</form>
  24 +
  25 +{/if}
  26 +
  27 +{if ($edit_form)}
  28 +
  29 +<form action="{$smarty.server.PHP_SELF}" method="POST">
  30 +<fieldset>
  31 +<legend>Edit a link type</legend>
  32 +<p class="descriptiveText">Specify the details for the link type below.</p>
  33 +<input type="hidden" name="fLinkTypeId" value="{$old_link->iId}" />
  34 +{foreach item=oWidget from=$edit_form}
  35 + {$oWidget->render()}
  36 +{/foreach}
  37 +
  38 +<div class="form_actions">
  39 + <input type="hidden" name="action" value="update" />
  40 + <input type="submit" value="Change Link Type" />
  41 +</div>
  42 +</fieldset>
  43 +</form>
  44 +
  45 +{/if}
  46 +
  47 +<!-- now the list of existing link types. -->
  48 +
  49 +<form action="{$smarty.server.PHP_SELF}" method="POST">
  50 +<fieldset>
  51 +<legend>Manage Existing Link Types</legend>
  52 +<p class="descriptiveText">From this panel you can edit or delete existing link types.
  53 +<strong>Note:</strong> deleting a link type will delete <strong>all</strong>
  54 +links of that type within the system.</p>
  55 +
  56 +<input type="hidden" name="action" value="delete" />
  57 +
  58 +{if (!empty($links))}
  59 +<table class="listing">
  60 +<thead>
  61 + <tr>
  62 + <th colspan="2">Name</th>
  63 + <th>Description</th>
  64 + <th>Edit</th>
  65 + </tr>
  66 +</thead>
  67 +
  68 +<tbody>
  69 + {foreach item=oLinkType from=$links}
  70 + <tr class="{cycle values=even,odd}">
  71 + <td>
  72 + <input type="checkbox" name="fLinksToDelete[]" value="{$oLinkType->iId}" />
  73 + </td>
  74 + <td>{$oLinkType->getName()}</td>
  75 + <td class="descriptiveText">{$oLinkType->getDescription()}</td>
  76 + <td><a href="{$smarty.server.PHP_SELF}?action=edit&fLinkTypeId={$oLinkType->iId}">edit link type</a></td>
  77 + </tr>
  78 + {/foreach}
  79 +</tbody>
  80 +</table>
  81 +
  82 +<div class="form_actions">
  83 + <input type="submit" value="Remove Link Type(s) " />
  84 +</div>
  85 +{else}
  86 +
  87 +<p><strong>No link administrator changeable link types available.</strong>
  88 +
  89 +{/if}
  90 +
  91 +</fieldset>
  92 +</form>
0 93 \ No newline at end of file
... ...