Commit f76adaf3db236d5dd55c3b94c6fdd818d267a1bc

Authored by Kevin G Fourie
1 parent 16fda31c

Merged MultiSelect "overridden" fieldset files.

plugins/multiselect/InetdocumentFieldsv2.php
1 1 <?php
  2 +
2 3 /**
3 4 * $Id$
4 5 *
... ... @@ -6,31 +7,31 @@
6 7 * Document Management Made Simple
7 8 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 9 * Portions copyright The Jam Warehouse Software (Pty) Limited
9   - *
  10 + *
10 11 * This program is free software; you can redistribute it and/or modify it under
11 12 * the terms of the GNU General Public License version 3 as published by the
12 13 * Free Software Foundation.
13   - *
  14 + *
14 15 * This program is distributed in the hope that it will be useful, but WITHOUT
15 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 18 * details.
18   - *
  19 + *
19 20 * You should have received a copy of the GNU General Public License
20 21 * 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,
  22 + *
  23 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
23 24 * California 94120-7775, or email info@knowledgetree.com.
24   - *
  25 + *
25 26 * The interactive user interfaces in modified source and object code versions
26 27 * of this program must display Appropriate Legal Notices, as required under
27 28 * Section 5 of the GNU General Public License version 3.
28   - *
  29 + *
29 30 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 31 * 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
  32 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
32 33 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
33   - * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * must display the words "Powered by KnowledgeTree" and retain the original
34 35 * copyright notice.
35 36 * Contributor( s): ______________________________________
36 37 *
... ... @@ -45,7 +46,7 @@ class InetDocumentFieldDispatcher extends KTAdminDispatcher {
45 46 var $bAutomaticTransaction = true;
46 47 var $bHaveConditional = null;
47 48 var $sHelpPage = 'ktcore/admin/document fieldsets.html';
48   -
  49 +
49 50 /**
50 51 *
51 52 * @return.
... ... @@ -83,7 +84,7 @@ class InetDocumentFieldDispatcher extends KTAdminDispatcher {
83 84 ));
84 85 return $oTemplate;
85 86 }
86   -
  87 +
87 88 /**
88 89 * form for creating new fieldset.
89 90 * @Param.
... ... @@ -131,7 +132,7 @@ class InetDocumentFieldDispatcher extends KTAdminDispatcher {
131 132 $widgets[] = array('ktcore.widgets.selection', array(
132 133 'label' => _kt("Fieldset Type"),
133 134 'use_simple' => false,
134   - 'description' => _kt("It is possibler to create different types of fieldsets. The most common kind is a \"normal\" fieldset, which can be configured to have different kinds of fields. The administrator may have installed additional plugins which provide different types of fieldsets."),
  135 + 'description' => _kt("It is possible to create different types of fieldsets. The most common kind is a \"normal\" fieldset, which can be configured to have different kinds of fields. The administrator may have installed additional plugins which provide different types of fieldsets."),
135 136 'important_description' => _kt('Note that it is not possible to convert between different types of fieldsets, so please choose carefully.'),
136 137 'name' => 'fieldset_type',
137 138 'required' => true,
... ... @@ -311,7 +312,6 @@ class InetDocumentFieldDispatcher extends KTAdminDispatcher {
311 312 * iNET Process
312 313 */
313 314 function do_edit() {
314   -
315 315 // here we engage in some major evil.
316 316 // we check for the subevent var
317 317 // and subdispatch if appropriate.
... ... @@ -334,8 +334,8 @@ class InetDocumentFieldDispatcher extends KTAdminDispatcher {
334 334 {
335 335  
336 336 require_once(KT_DIR.'/plugins/ktcore/admin/fieldsets/basic.inc.php');
337   - $oSubDispatcher = new BasicFieldsetManagementDispatcher;
338   - }
  337 + $oSubDispatcher = new BasicFieldsetManagementDispatcher;
  338 + }
339 339 // multiselect change end
340 340  
341 341  
... ... @@ -477,9 +477,12 @@ class InetDocumentFieldDispatcher extends KTAdminDispatcher {
477 477 $data = $res['results'];
478 478 $errors = $res['errors'];
479 479 $extra_errors = array();
  480 +
  481 + // check that the fieldset name either hasn't changed, or doesn't exist.
480 482 if ($data['name'] != $this->oFieldset->getName()) {
481 483 $oOldFieldset = KTFieldset::getByName($data['name']);
482   - if (!PEAR::isError($oOldFieldset)) {
  484 + // If the fieldset exists throw an error. Mysql doesn't distinguish between and e so check the names are different in php.
  485 + if (!PEAR::isError($oOldFieldset) && $oOldFieldset->getName() == $data['name']) {
483 486 $extra_errors['name'][] = _kt("A fieldset with that name already exists.");
484 487 }
485 488 }
... ... @@ -517,4 +520,4 @@ class InetDocumentFieldDispatcher extends KTAdminDispatcher {
517 520 }
518 521 }
519 522  
520   -?>
521 523 \ No newline at end of file
  524 +?>
... ...
plugins/multiselect/inetbasic.inc.php
1 1 <?php
  2 +
2 3 /**
3 4 * $Id$
4 5 *
... ... @@ -6,31 +7,31 @@
6 7 * Document Management Made Simple
7 8 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 9 * Portions copyright The Jam Warehouse Software (Pty) Limited
9   - *
  10 + *
10 11 * This program is free software; you can redistribute it and/or modify it under
11 12 * the terms of the GNU General Public License version 3 as published by the
12 13 * Free Software Foundation.
13   - *
  14 + *
14 15 * This program is distributed in the hope that it will be useful, but WITHOUT
15 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 18 * details.
18   - *
  19 + *
19 20 * You should have received a copy of the GNU General Public License
20 21 * 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,
  22 + *
  23 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
23 24 * California 94120-7775, or email info@knowledgetree.com.
24   - *
  25 + *
25 26 * The interactive user interfaces in modified source and object code versions
26 27 * of this program must display Appropriate Legal Notices, as required under
27 28 * Section 5 of the GNU General Public License version 3.
28   - *
  29 + *
29 30 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 31 * 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
  32 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
32 33 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
33   - * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * must display the words "Powered by KnowledgeTree" and retain the original
34 35 * copyright notice.
35 36 * Contributor( s): ______________________________________
36 37 *
... ... @@ -46,7 +47,7 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
46 47 var $bAutomaticTransaction = true;
47 48 var $bHaveConditional = null;
48 49 var $sHelpPage = 'ktcore/admin/document fieldsets.html';
49   -
  50 +
50 51 /**
51 52 * @param.
52 53 * @return.
... ... @@ -93,7 +94,7 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
93 94 function do_main () {
94 95 return _kt("Something very unexpected happened.");
95 96 }
96   -
  97 +
97 98 /**
98 99 * returns array of field type.
99 100 *
... ... @@ -107,6 +108,8 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
107 108 'normal' => _kt("Normal (String)"),
108 109 'lookup' => _kt("Lookup"),
109 110 'tree' => _kt("Tree"),
  111 + 'largetextbox' => _kt("Large Text"),
  112 + 'date' => _kt("Date"),
110 113 'Multiselect' => _kt("Multiselect"),
111 114 );
112 115 return $types;
... ... @@ -127,7 +130,7 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
127 130 );
128 131 return $types;
129 132 }
130   -
  133 +
131 134 /**
132 135 * returns lookup type
133 136 * @return string
... ... @@ -231,7 +234,7 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
231 234  
232 235 return $oForm->render();
233 236 }
234   -
  237 +
235 238 /**
236 239 * Creats a new field->multiselect
237 240 * @return
... ... @@ -258,16 +261,26 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
258 261  
259 262 $lookup = false;
260 263 $tree = false;
  264 +
  265 + //$largeField = false;
  266 +
  267 + $DataType = 'STRING';
261 268 // multiselect change start
262 269 $inetlookup = false;
263 270 $inetlookupvalue = '';
264 271 // multiselect change end
265   -
  272 +
266 273 if ($data['field_type'] == 'lookup') {
267 274 $lookup = true;
268 275 } else if ($data['field_type'] == 'tree') {
269 276 $lookup = true;
270 277 $tree = true;
  278 + } else if ($data['field_type'] == 'largetextbox') {
  279 + //$largeField = true;
  280 + $DataType = 'LARGE TEXT';
  281 + } else if ($data['field_type'] == 'date') {
  282 + //$largeField = true;
  283 + $DataType = 'DATE';
271 284 }
272 285 // multiselect change start
273 286 else if($data['field_type'] == 'Multiselect')
... ... @@ -276,11 +289,11 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
276 289 $inetlookupvalue = $this->getDefaultLookupType();
277 290 }
278 291 // multiselect change end
279   -
  292 +
280 293 $oField = DocumentField::createFromArray(array(
281 294 'Name' => $data['name'],
282 295 'Description' => $data['description'],
283   - 'DataType' => 'STRING',
  296 + 'DataType' => $DataType,
284 297 'IsGeneric' => false,
285 298 'HasLookup' => $lookup,
286 299 'HasLookupTree' => $tree,
... ... @@ -434,6 +447,32 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
434 447 ));
435 448 return $oTemplate->render();
436 449 }
  450 +
  451 + function do_updatelargetextoptions() {
  452 +
  453 + $this->oField = DocumentField::get(KTUtil::arrayGet($_REQUEST, 'fFieldId'));
  454 +
  455 + $oValues = KTUtil::arrayGet($_REQUEST, 'largefield');
  456 +
  457 + if($oValues['size'] != "")
  458 + $this->oField->setMaxLength($oValues['size']);
  459 +
  460 + $this->oField->setIsHTML($oValues['html']);
  461 + //$this->oField->setIsHTML(true);
  462 +
  463 + //$oValue = $this->oField->_fieldValues();
  464 + //$this->successRedirectTo('managefield',_kt("Field updated. -> ") . $this->oField->getMaxLength() . " -> " . $oValue['max_length']);
  465 +
  466 + //$this->successRedirectTo('managefield',_kt("Field updated. -> ") . $oValues['html']);
  467 +
  468 + $res = $this->oField->update();
  469 + if (PEAR::isError($res)) {
  470 + return $oForm->handleError(sprintf(_kt("Failed to update field: %s"), $res->getMessage()));
  471 + }
  472 +
  473 + $this->successRedirectTo('managefield',_kt("Field updated."));
  474 + }
  475 +
437 476 /**
438 477 * Updates a field
439 478 * @return.
... ... @@ -451,7 +490,8 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
451 490 // check that the field name either hasn't changed, or doesn't exist.
452 491 if ($data['name'] != $this->oField->getName()) {
453 492 $oOldField = DocumentField::getByFieldsetAndName($this->oFieldset, $data['name']);
454   - if (!PEAR::isError($oOldField)) {
  493 + // If the field exists throw an error. Mysql doesn't distinguish between é and e so check the names are different in php.
  494 + if (!PEAR::isError($oOldField) && $oOldField->getName() == $data['name']) {
455 495 $extra_errors['name'] = _kt("That name is already in use in this fieldset. Please specify a unique name.");
456 496 }
457 497 }
... ... @@ -516,7 +556,7 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
516 556  
517 557 return $oForm;
518 558 }
519   -
  559 +
520 560 /**
521 561 * Add lookup values
522 562 * @return
... ... @@ -729,7 +769,7 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
729 769  
730 770 /**
731 771 * Save the edited lookup values
732   - *
  772 + *
733 773 * @param.
734 774 * @return.
735 775 *
... ... @@ -748,7 +788,7 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
748 788 if (PEAR::isError($oMetaData)) {
749 789 $this->addErrorMessage(_kt('Invalid lookup selected').': '.$sValue);
750 790 continue;
751   -
  791 + //$this->errorRedirectTo('managelookups', _kt('Invalid lookup selected'));
752 792 }
753 793 if(empty($sValue)){
754 794 $this->addErrorMessage(_kt('Lookup cannot be empty').': '.$oMetaData->getName());
... ... @@ -857,7 +897,7 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
857 897  
858 898 // under here we do the subaction rendering.
859 899 // we do this so we don't have to do _very_ strange things with multiple actions.
860   -
  900 + //$default->log->debug("Subaction: " . $subaction);
861 901 $fieldTree =& new MDTree();
862 902 $fieldTree->buildForField($oField->getId());
863 903  
... ... @@ -962,7 +1002,7 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
962 1002 $constructedTree->deleteNode($current_node);
963 1003 return true;
964 1004 }
965   -
  1005 +
966 1006 /**
967 1007 *
968 1008 * @param $constructedTree object
... ... @@ -1002,7 +1042,7 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
1002 1042 * This whole thing needs to replaced, as soon as I work out how
1003 1043 * to non-sucking Smarty recursion.
1004 1044 */
1005   -
  1045 +
1006 1046 /**
1007 1047 * render to subnode of tree
1008 1048 *
... ... @@ -1066,13 +1106,13 @@ class InetBasicFieldsetManagementDispatcher extends KTAdminDispatcher {
1066 1106 $treeStr .= ' (<a href="' . KTUtil::addQueryStringSelf($this->meldPersistQuery('current_node=0', 'managetree')) . '">' . _kt('attach keywords') . '</a>)';
1067 1107 $treeStr .= '<ul>';
1068 1108  
1069   -
  1109 + //$default->log->debug("EVILRENDER: " . print_r($treeToRender, true));
1070 1110 foreach ($treeToRender->getRoot() as $node_id => $subtree_nodes)
1071 1111 {
1072   -
  1112 + //$default->log->debug("EVILRENDER: ".$node_id." => ".$subtree_nodes." (".($node_id === "leaves").")");
1073 1113 // leaves are handled differently.
1074 1114 if ($node_id !== "leaves") {
1075   -
  1115 + // $default->log->debug("EVILRENDER: " . print_r($subtree_nodes, true));
1076 1116 $treeStr .= '<li class="treenode active"><a class="pathnode" onclick="toggleElementClass(\'active\', this.parentNode);toggleElementClass(\'inactive\', this.parentNode);">' . $treeToRender->mapnodes[$subtree_nodes]->getName() . '</a>';
1077 1117 $treeStr .= $this->_evilActionHelper($iFieldsetId, $iFieldId, false, $subtree_nodes);
1078 1118 $treeStr .= $this->_evilTreeRecursion($subtree_nodes, $treeToRender);
... ...