Commit 9ed98afd3725f20305962b4f776c5b9c89ccdf4a

Authored by nbm
1 parent a3813eea

Remove old PatternCreate and create.php.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4364 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/visualpatterns/PatternCreate.inc deleted
1   -<?php
2   -/**
3   - * $Id$
4   - *
5   - * This pattern facilities the creation of new entries in the database using
6   - * the objects associated with those entries.
7   - *
8   - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com
9   - *
10   - * This program is free software; you can redistribute it and/or modify
11   - * it under the terms of the GNU General Public License as published by
12   - * the Free Software Foundation; either version 2 of the License, or
13   - * (at your option) any later version.
14   - *
15   - * This program is distributed in the hope that it will be useful,
16   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18   - * GNU General Public License for more details.
19   - *
20   - * You should have received a copy of the GNU General Public License
21   - * along with this program; if not, write to the Free Software
22   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23   - *
24   - * @version $Revision$
25   - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
26   - * @package lib.visualpatterns
27   - */
28   -class PatternCreate {
29   -
30   - var $sObject;
31   - var $sObjectPath;
32   - var $aDisplayRowNames;
33   - var $aParameterNumbers;
34   - var $aDisplayColumnTypes;
35   - var $aRequired;
36   - var $aDropDownListTableNames;
37   - var $aDropDownListValueColumns;
38   - var $aDropDownListDisplayColumns;
39   - var $sUniqueName;
40   - var $aDefaultValues;
41   -
42   - /**
43   - * Default constructor
44   - *
45   - * @param String Name of object
46   - * @param Array Name of each item that will be displayed
47   - * @param Array Paramater number for each column e.g. is it constructor parameter 1 or 2 etc.
48   - NB PARAMETER NUMBERS START AT ZERO
49   - * @param Array Types of columns to be displayed (1 = text, 2 = boolean, 3 = drop down list)
50   - * @param Array Names of lookup tables for display column type 3
51   - * @param Array Names of column in lookup table to use as value in select (if not is specified, id is assumed)
52   - * @param Array Names of column in lookup table to display (if not is specified, name is assumed)
53   - */
54   - function PatternCreate($sNewObject, $sNewObjectPath, $aNewDisplayRowNames, $aNewParameterNumbers, $aNewDisplayColumnTypes, $aNewRequired, $aNewDropDownListTableNames = null, $aNewDropDownListValueColumns = null, $aNewDropDownListDisplayColumns = null) {
55   - $this->sObject = $sNewObject;
56   - $this->sObjectPath = $sNewObjectPath;
57   - $this->sNewQuery = $sNewQuery;
58   - $this->aDisplayRowNames = $aNewDisplayRowNames;
59   - $this->aParameterNumbers = $aNewParameterNumbers;
60   - $this->aDisplayColumnTypes = $aNewDisplayColumnTypes;
61   - $this->aRequired = $aNewRequired;
62   - $this->aDropDownListTableNames = $aNewDropDownListTableNames;
63   - $this->aDropDownListValueColumns = $aNewDropDownListValueColumns;
64   - $this->aDropDownListDisplayColumns = $aNewDropDownListDisplayColumns;
65   -
66   - }
67   -
68   - function setUniqueName($sNewValue) {
69   - $this->sUniqueName = $sNewValue;
70   - }
71   -
72   - function setDefaultValues($aNewValue) {
73   - $this->aDefaultValues = $aNewValue;
74   - }
75   -
76   - function render() {
77   - global $default;
78   - $this->sUniqueName .= KTUtil::randomString();
79   - $_SESSION["pelfq_" . $this->sUniqueName . "_object"] = $this->sObject;
80   - $_SESSION["pelfq_" . $this->sUniqueName . "_fn"] = $this->sObjectPath;
81   - $_SESSION["pageAccess"][$default->rootUrl . '/presentation/lookAndFeel/knowledgeTree/create.php'] = true;
82   -
83   - $sToRender = "<table border=\"0\">\n";
84   - //unique_start marks the start of information to be parsed from the HTML page by create.php
85   - $sToRender .= "<input type=\"hidden\" name=\"unique_start_" . $this->sUniqueName . "\" />\n";
86   - //write the name of the object to be created
87   - // $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_object\" value=\"" . $this->sObject . "\" />\n";
88   - //name of folder in lib directory in which object .inc file is located
89   - // $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_fn\" value=\"" . $this->sObjectPath . "\" />\n";
90   - for ($i = 0; $i < count($this->aDisplayRowNames); $i++) {
91   - $sToRender .= "<tr>\n";
92   - //write the parameter number of this value in the object's constructor
93   - $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $i . "_parnum\" value=\"" . $this->aParameterNumbers[$i] . "\" />\n";
94   - switch ($this->aDisplayColumnTypes[$i]) {
95   - case 1:
96   - //write the type (in this case text)
97   - $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $i . "_type\" value=\"1\" />\n";
98   - //write the value
99   - $sToRender .= "<td>" . $this->aDisplayRowNames[$i] . "</td><td><input size = \"30\" type=\"text\" name=\"" . $this->sUniqueName . "_" . $i . "_value\" value=\"" . (isset($this->aDefaultValues[$i]) ? $this->aDefaultValues[$i] : "") . "\" /></td>\n";
100   - break;
101   - case 2:
102   - //write the type (in this case checkbox)
103   - $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $i . "_type\" value=\"2\" />\n";
104   - //write the value
105   - $sToRender .= "<td>" . $this->aDisplayRowNames[$i] . "</td><td><input type=\"checkbox\" name=\"" . $this->sUniqueName . "_" . $i . "_value\" value=\"1\" /></td>\n";
106   - break;
107   - case 3:
108   - //write the type (in this case dropdown)
109   - $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $i . "_type\" value=\"3\" />\n";
110   - $sDisplayColumn;
111   - $sValueColumn;
112   - //write the value
113   - if (isset($this->aDropDownListValueColumns[$i])) {
114   - $sValueColumn = $this->aDropDownListValueColumns[$i];
115   - } else {
116   - $sValueColumn = "id";
117   - }
118   -
119   - if (isset($this->aDropDownListDisplayColumns[$i])) {
120   - $sDisplayColumn = $this->aDropDownListDisplayColumns[$i];
121   - } else {
122   - $sDisplayColumn = "name";
123   - }
124   - $oPatternListBox = & new PatternListBox($this->aDropDownListTableNames[$i], $sDisplayColumn, $sValueColumn, $this->sUniqueName . "_" . $i . "_value");
125   - $sToRender .= "\t<td>" . $this->aDisplayRowNames[$i] . "</td><td>" . $oPatternListBox->render() . "</td>\t\n";
126   - break;
127   - default;
128   - break;
129   - }
130   -
131   - $sToRender .= "</tr>\n";
132   - }
133   - //unique_end marks the end of information to be parsed from the HTML page by create.php
134   - $sToRender .= "<input type=\"hidden\" name=\"unique_end_" . $this->sUniqueName . "\" />\n";
135   - $sToRender .= "</table>\n";
136   -
137   - $sToRender .= $this->generateRequiredFieldValidation();
138   -
139   - return $sToRender;
140   - }
141   -
142   - function generateRequiredFieldValidation() {
143   - $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n";
144   - $sToRender .= "function validateForm(theForm) {\n";
145   - for ($i = 0; $i < count($this->aDisplayRowNames); $i++) {
146   - if ($this->aRequired[$i]) {
147   - $sToRender .= "\tif (!(validRequired(document.MainForm." . $this->sUniqueName . "_" . $i . "_value, '" . $this->aDisplayRowNames[$i] . "'))) {\n";
148   - $sToRender .= "\t\treturn false;\n\t}\n";
149   - }
150   - }
151   - $sToRender .= "return true;\n}\n";
152   - $sToRender .= "//-->\n</script>\n\n";
153   -
154   - return $sToRender;
155   - }
156   -}
157   -?>
presentation/lookAndFeel/knowledgeTree/create.php deleted
1   -<?php
2   -/**
3   - * $Id$
4   - *
5   - * Page used by PatternCreate. Creates the actual object and stores it
6   - *
7   - * Expected form variables:
8   - * o $fRedirectURL - URL to redirect to after object creation (must be URL encoded)
9   - *
10   - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com
11   - *
12   - * This program is free software; you can redistribute it and/or modify
13   - * it under the terms of the GNU General Public License as published by
14   - * the Free Software Foundation; either version 2 of the License, or
15   - * (at your option) any later version.
16   - *
17   - * This program is distributed in the hope that it will be useful,
18   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
19   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20   - * GNU General Public License for more details.
21   - *
22   - * You should have received a copy of the GNU General Public License
23   - * along with this program; if not, write to the Free Software
24   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25   - *
26   - * @version $Revision$
27   - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
28   - */
29   -
30   -require_once("../../../config/dmsDefaults.php");
31   -require_once("$default->fileSystemRoot/presentation/Html.inc");
32   -
33   -if (!checkSession()) {
34   - exit(0);
35   -}
36   -
37   -$aKeys = array_keys($_POST);
38   -$aParameterValues = array();
39   -// $sObjectName;
40   -// $sObjectFolderName;
41   -//parse the information in the html page
42   -for ($i = 0; $i < count($aKeys); $i++) {
43   - $sRowStart = $aKeys[$i];
44   - $pos = strncasecmp("unique_start", $sRowStart, 12);
45   - if ($pos == 0) {
46   - $i++;
47   - //get the object to create
48   - //$sObjectName = $_POST[$aKeys[$i]];
49   - //$i++;
50   - //get the object folder name
51   - //$sObjectFolderName = $_POST[$aKeys[$i]];
52   - //$i++;
53   - $sRandomString = substr($sRowStart, 13);
54   - $sObjectName = $_SESSION["pelfq_" . $sRandomString . "_object"];
55   - $sObjectFolderName = $_SESSION["pelfq_" . $sRandomString . "_fn"];
56   -
57   - while ((strncasecmp("unique_end", $sRowStart, 10) != 0) && ($i < count($aKeys))) {
58   - //get the paramater number
59   - $iParameterNumber = $_POST[$aKeys[$i]];
60   - $i++;
61   - $iType = $_POST[$aKeys[$i]];
62   - $value;
63   - switch ($iType) {
64   - case 1:
65   - $i++;
66   - $value = $_POST[$aKeys[$i]];
67   - break;
68   - case 2:
69   - //check boxes don't post back any values if they are unchecked
70   - //so we have to do a special check
71   - if ((strpos($aKeys[$i + 1], "parnum") != 0) || (substr($aKeys[$i + 1],0,10) == "unique_end")) {
72   - //if the next key is one of type parnum or is the end of the section, then the checkbox
73   - //didn't post anything back and is obviously unchecked
74   - $value = 0;
75   - } else {
76   - //the checkbox did post back a value and was therefore checked
77   - //the checkbox posts back a value of "on" so don't actually use the postback
78   - //value, rather just set value to true
79   - $i++;
80   - $value = 1;
81   - }
82   - break;
83   - case 3:
84   - $i++;
85   - $value = $_POST[$aKeys[$i]];
86   - break;
87   - }
88   - $aParameterValues[$iParameterNumber] = $value;
89   - $i++;
90   - $sRowStart = $aKeys[$i];
91   - }
92   - }
93   -}
94   -
95   -
96   -//include the correct file for the object
97   -include_once("$default->fileSystemRoot/lib/$sObjectFolderName");
98   -
99   -$oObject = call_user_func(strtolower($sObjectName) . "createFromArray",$aParameterValues);
100   -if ($oObject->create()) {
101   - $bSuccess = true;
102   -} else {
103   - $bSuccess = false;
104   -}
105   -
106   -//redirect the user
107   -if (array_key_exists('fRedirectURL', $_REQUEST)) {
108   - redirect(strip_tags(urldecode($_REQUEST['fRedirectURL'])) . $oObject->iId . "&fSuccess=" . $bSuccess);
109   -} else {
110   - redirect("$default->rootUrl/control.php");
111   -}
112   -
113   -?>