Commit bda2c2b3d038f83f277526394e53a9e9951d51f1
1 parent
8f9aa69d
Fieldset-aware and simplified field management page
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3682 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
190 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/documentFields.php
0 โ 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once('../../../../../config/dmsDefaults.php'); | |
| 4 | +require_once(KT_LIB_DIR . '/dispatcher.inc.php'); | |
| 5 | +require_once(KT_LIB_DIR . '/templating/templating.inc.php'); | |
| 6 | + | |
| 7 | +require_once(KT_LIB_DIR . '/documentmanagement/DocumentField.inc'); | |
| 8 | +require_once(KT_LIB_DIR . '/metadata/fieldset.inc.php'); | |
| 9 | +require_once(KT_LIB_DIR . '/metadata/metadatautil.inc.php'); | |
| 10 | + | |
| 11 | +$sectionName = "Administration"; | |
| 12 | +require_once(KT_DIR . "/presentation/webpageTemplate.inc"); | |
| 13 | + | |
| 14 | +class KTDocumentFieldDispatcher extends KTStandardDispatcher { | |
| 15 | + function do_main () { | |
| 16 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 17 | + $oTemplate = $oTemplating->loadTemplate('ktcore/fields/list'); | |
| 18 | + $oTemplate->setData(array( | |
| 19 | + 'fieldsets' => KTFieldset::getList(), | |
| 20 | + )); | |
| 21 | + return $oTemplate; | |
| 22 | + } | |
| 23 | + | |
| 24 | + function do_edit() { | |
| 25 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 26 | + $oTemplate = $oTemplating->loadTemplate('ktcore/fields/edit'); | |
| 27 | + $oFieldset =& KTFieldset::get($_REQUEST['fFieldsetId']); | |
| 28 | + $oTemplate->setData(array( | |
| 29 | + 'oFieldset' => $oFieldset, | |
| 30 | + )); | |
| 31 | + return $oTemplate; | |
| 32 | + } | |
| 33 | + | |
| 34 | + function do_editobject() { | |
| 35 | + $oFieldset =& KTFieldset::get($_REQUEST['fFieldsetId']); | |
| 36 | + $oFieldset->setName($_REQUEST['name']); | |
| 37 | + $oFieldset->setNamespace($_REQUEST['namespace']); | |
| 38 | + $res = $oFieldset->update(); | |
| 39 | + if (PEAR::isError($res) || ($res === false)) { | |
| 40 | + $this->errorRedirectTo('edit', 'Could not save fieldset changes', 'fFieldsetId=' . $oFieldset->getId()); | |
| 41 | + exit(0); | |
| 42 | + } | |
| 43 | + $this->errorRedirectTo('edit', 'Changes saved', 'fFieldsetId=' . $oFieldset->getId()); | |
| 44 | + exit(0); | |
| 45 | + } | |
| 46 | + | |
| 47 | + function do_newfield() { | |
| 48 | + $is_lookup = false; | |
| 49 | + $is_tree = false; | |
| 50 | + if ($_REQUEST['type'] === "lookup") { | |
| 51 | + $is_lookup = true; | |
| 52 | + } | |
| 53 | + if ($_REQUEST['type'] === "tree") { | |
| 54 | + $is_lookup = true; | |
| 55 | + $is_tree = true; | |
| 56 | + } | |
| 57 | + $oFieldset = KTFieldset::get($_REQUEST['fFieldsetId']); | |
| 58 | + $oField =& DocumentField::createFromArray(array( | |
| 59 | + 'name' => $_REQUEST['name'], | |
| 60 | + 'datatype' => 'STRING', | |
| 61 | + 'haslookup' => $is_lookup, | |
| 62 | + 'haslookuptree' => $is_tree, | |
| 63 | + 'parentfieldset' => $oFieldset->getId(), | |
| 64 | + )); | |
| 65 | + if (PEAR::isError($res) || ($res === false)) { | |
| 66 | + $this->errorRedirectTo('edit', 'Could not create field', 'fFieldsetId=' . $oFieldset->getId()); | |
| 67 | + exit(0); | |
| 68 | + } | |
| 69 | + $this->errorRedirectTo('edit', 'Field created', 'fFieldsetId=' . $oFieldset->getId()); | |
| 70 | + exit(0); | |
| 71 | + } | |
| 72 | + | |
| 73 | + function handleOutput($data) { | |
| 74 | + global $main; | |
| 75 | + $main->bFormDisabled = true; | |
| 76 | + $main->setCentralPayload($data); | |
| 77 | + $main->render(); | |
| 78 | + } | |
| 79 | +} | |
| 80 | + | |
| 81 | +$d =& new KTDocumentFieldDispatcher; | |
| 82 | +$d->dispatch(); | |
| 83 | + | |
| 84 | +?> | ... | ... |
templates/ktcore/fields/edit.smarty
0 โ 100644
| 1 | +<h1>Fieldset: {$oFieldset->getName()|escape}</h1> | |
| 2 | + | |
| 3 | +<h2>Fieldset properties</h2> | |
| 4 | +<form action="{$smarty.server.PHP_SELF}" method="POST"> | |
| 5 | +<input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}"> | |
| 6 | +<input type="hidden" name="action" value="editobject"> | |
| 7 | +<table class="prettysw" cellpadding="0" cellspacing="0"> | |
| 8 | + <tr> | |
| 9 | + <th>Name</th> | |
| 10 | + <td><input type="textbox" name="name" value="{$oFieldset->getName()|escape}"></td> | |
| 11 | + </tr> | |
| 12 | + <tr> | |
| 13 | + <th>Namespace</th> | |
| 14 | + <td><input type="textbox" name="namespace" value="{$oFieldset->getNamespace()|escape}"></td> | |
| 15 | + </tr> | |
| 16 | +</table> | |
| 17 | +<input type="submit" name="submit" value="Change"> | |
| 18 | +</form> | |
| 19 | + | |
| 20 | +<h2>Fieldset members</h2> | |
| 21 | + | |
| 22 | +{if $oFieldset->getFields() } | |
| 23 | +<h3>Existing members</h3> | |
| 24 | +<form action="{$smarty.server.PHP_SELF}" method="POST"> | |
| 25 | +<input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}"> | |
| 26 | +<ul> | |
| 27 | +{foreach from=$oFieldset->getFields() item=oField} | |
| 28 | + <li><label><input type="checkbox" | |
| 29 | +name="fieldsetids[]" | |
| 30 | +value="{$oField->getId()}">{$oField->getName()|escape}</label></li> | |
| 31 | +{/foreach} | |
| 32 | +</ul> | |
| 33 | +<input type="submit" name="submit" value="Remove fields"> | |
| 34 | +</form> | |
| 35 | +{/if} | |
| 36 | + | |
| 37 | +<h3>Add a new field</h3> | |
| 38 | + | |
| 39 | +<form action="{$smarty.server.PHP_SELF}" method="POST"> | |
| 40 | +<input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}"> | |
| 41 | +<input type="hidden" name="action" value="newfield"> | |
| 42 | +<table class="prettysw" cellpadding="0" cellspacing="0"> | |
| 43 | + <tr> | |
| 44 | + <th>Name</th> | |
| 45 | + <td><input type="textbox" name="name" /> | |
| 46 | + </tr> | |
| 47 | + <tr> | |
| 48 | + <th>Type</th> | |
| 49 | + <td> | |
| 50 | +<select name="type"> | |
| 51 | +<option value="normal">Normal</option> | |
| 52 | +<option value="lookup">Lookup</option> | |
| 53 | +<option value="tree">Tree</option> | |
| 54 | +</select> | |
| 55 | + </td> | |
| 56 | + </tr> | |
| 57 | +</table> | |
| 58 | +<input type="submit" name="submit" value="Add field"> | |
| 59 | +</form> | ... | ... |
templates/ktcore/fields/list.smarty
0 โ 100644
| 1 | +<h1>Document Fields</h1> | |
| 2 | + | |
| 3 | +{ if $fieldsets} | |
| 4 | +<h2>Existing generic document fields</h2> | |
| 5 | + | |
| 6 | +<table class="pretty" cellspacing="0" cellpadding="0"> | |
| 7 | + <thead> | |
| 8 | + <tr> | |
| 9 | + <th>Name</th> | |
| 10 | + <th>Generic</th> | |
| 11 | + <th>Fields</th> | |
| 12 | + </tr> | |
| 13 | + </thead> | |
| 14 | + <tbody> | |
| 15 | +{foreach from=$fieldsets item=oFieldset} | |
| 16 | + <tr> | |
| 17 | + <td> | |
| 18 | + <a href="?action=edit&fFieldsetId={$oFieldset->getId()}"> { $oFieldset->getName() } | |
| 19 | + </a> | |
| 20 | + </td> | |
| 21 | + <td> | |
| 22 | +{if $oFieldset->getIsGeneric()} | |
| 23 | + Yes | |
| 24 | +{else} | |
| 25 | + No | |
| 26 | +{/if} | |
| 27 | + </td> | |
| 28 | + <td> | |
| 29 | +<ul> | |
| 30 | +{foreach from=$oFieldset->getFields() item=oField} | |
| 31 | + <li>{$oField->getName()}</li> | |
| 32 | +{/foreach} | |
| 33 | +</ul> | |
| 34 | + </td> | |
| 35 | + </tr> | |
| 36 | + </tbody> | |
| 37 | +{/foreach} | |
| 38 | +</table> | |
| 39 | +{/if} | |
| 40 | + | |
| 41 | +<h2>Create a new document field set</h2> | |
| 42 | + | |
| 43 | +<form method="POST"> | |
| 44 | +<input type="hidden" name="action" value="new"> | |
| 45 | +<input type="textbox" name="name"> | |
| 46 | +<input type="submit" name="submit" value="Create"> | |
| 47 | +</form> | ... | ... |