Commit 6545785db2aa3209ba2fe969273908b4e7a2f01a

Authored by nbm
1 parent 6175d106

Remove unused PatternDatabaseTable


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3011 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/visualpatterns/PatternDatabaseTable.inc deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Builds a query using the table name and the array of specified columns  
6 - * and displays the results in an HTML table. The ID column of the table is  
7 - * included by default (basically renders a database table in html)  
8 - *  
9 - * The first column in the table can be rendered as a link  
10 - * to the document/folder using the $iLinkType variable to specify the link type,  
11 - * the $sLinkPageURL to specify the page URL to link to and $sLinkImageURL to specify  
12 - * the image to display in the case of either a $iLinkType of 2 (image only) or 3 (image + text)  
13 - *  
14 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
15 - *  
16 - * This program is free software; you can redistribute it and/or modify  
17 - * it under the terms of the GNU General Public License as published by  
18 - * the Free Software Foundation; either version 2 of the License, or  
19 - * (at your option) any later version.  
20 - *  
21 - * This program is distributed in the hope that it will be useful,  
22 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
23 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
24 - * GNU General Public License for more details.  
25 - *  
26 - * You should have received a copy of the GNU General Public License  
27 - * along with this program; if not, write to the Free Software  
28 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
29 - *  
30 - * @version $Revision$  
31 - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa  
32 - * @package lib.visualpatterns  
33 - * @todo $iLinkImageURL is hard coded - change  
34 - * @todo $sLinkPageURL is hard coded - change  
35 - */  
36 -class PatternDatabaseTable {  
37 -  
38 - /* Name of table to query */  
39 - var $sTableName;  
40 - /* Columns in table to query (ID is included by default) */  
41 - var $aColumns;  
42 - /* Column types. Possibles are 1 = text, 2 = boolean*/  
43 - var $aColumnTypes;  
44 - /* Where clause */  
45 - var $sWhereClause;  
46 - /* Order by clause */  
47 - var $sOrderByClause;  
48 - /* Link type. Possibles are: 0 = none; 1 = text; 2 = image, 3 = text/image */  
49 - var $iLinkType;  
50 - /* Image to display if $iLinkType = 1 */  
51 - var $sLinkImageURL;  
52 - /* URL of page to redirect to */  
53 - var $sLinkPageURL = "Navigate.inc";  
54 - /* Number of result to display in the table. The default value is 15 */  
55 - var $iResultsToDisplay;  
56 - /* Result number to start on (internal variable - not set by developer) */  
57 - var $iStartIndex;  
58 -  
59 - function PatternTableSqlQuery($sTmpTableName, $aTmpColumns, $aTmpColumnTypes, $sTmpWhereClause = null, $iTmpLinkType = 0, $sTmpLinkImageURL = null, $iTmpResultsToDisplay = 15) {  
60 - $this->sTableName = & $sTmpTableName;  
61 - $this->aColumns = & $aTmpColumns;  
62 - $this->aColumnTypes = $aTmpColumnTypes;  
63 - $this->sWhereClause = & $sTmpWhereClause;  
64 - $this->iLinkType = & $iTmpLinkType;  
65 - $this->iResultsToDisplay = $iTmpResultsToDisplay;  
66 - $this->sLinkImageURL = "C:\temp\test\up.jpg";  
67 - }  
68 -  
69 - /** Set the variable $this->sTableName */  
70 - function setTableName($sNewVal) {  
71 - $this->sTableName = & $sNew7Val;  
72 - }  
73 -  
74 - /** Set the variable $this->aColumns */  
75 - function setColumns($aNewVal) {  
76 - $this->aColumns = & $aNewVal;  
77 - }  
78 -  
79 - /** Set the variable $this->aColumnTypes */  
80 - function setColumnTypes($aNewVal) {  
81 - $this->aColumnTypes = $aTmpColumnTypes;  
82 - }  
83 -  
84 - /** Set the variable $this->sWhereClause */  
85 - function setWhereClause($sNewVal) {  
86 - $this->sWhereClause = & $sNewVal;  
87 - }  
88 -  
89 - /** Set the variable $this->iLinkType */  
90 - function setLinkType($iNewVal) {  
91 - $this->iLinkType = & $iNewVal;  
92 - }  
93 -  
94 - /** Set the variable $this->sLinkImageURL */  
95 - function setLinkImageURL($sNewVal) {  
96 - $this->sLinkImageURL = & $sNewVal;  
97 - }  
98 -  
99 - /** Set the variable $this->iStartIndex */  
100 - function setStartIndex($iNewVal) {  
101 - $this->iStartIndex = & $iNewVal;  
102 - }  
103 -  
104 - /** Set the variable $this->iResultsToDisplay */  
105 - function setResultsToDisplay($iNewVal) {  
106 - $this->iResultsToDisplay = & $iNewVal;  
107 - }  
108 -  
109 -  
110 - /**  
111 - * Build the HTML string used to render the object  
112 - *  
113 - * @return String of HTML used to render object  
114 - *  
115 - * @todo possibly add in image size restraints for link types 2 and 3  
116 - */  
117 - function & render() {  
118 - global $default;  
119 -  
120 - $sToRender = "<table width=\"100%\" height=\"100%\">\n";  
121 - $sToRender .= "<tr>\n";  
122 - //$i starts at 1 because the $aColumns[0] is the ID column, which  
123 - //is used in links, but never actually displayed  
124 - for ($i = 0; $i < count($this->aColumns); $i++) {  
125 - $sToRender .= "<th align=\"left\">".$this->aColumns[$i]."</th>\n";  
126 - }  
127 - $sToRender .= "</tr>\n";  
128 -  
129 - $sql = & $default->db;  
130 - $sql->createSQLQueryWithOffset($this->sTableName, $this->aColumns, $this->iStartIndex, $this->iResultsToDisplay);  
131 -  
132 -  
133 - $iDisplayed = 0;  
134 - //limit the result set displayed  
135 - while(($aRow = $sql->next_record()) && ($iDisplayed < $this->iResultsToDisplay)) {  
136 - $sToRender .= "<tr>";  
137 -  
138 - //get the value for each column in the row  
139 - //and put it in a table column.  
140 - //$i starts at 1 because $aRow[0] is the ID column for the specified table, which  
141 - //is used in links, but never actually displayed  
142 - //$i < count(this->aColumns) + 1 because $this->aColumns should not contain the ID column  
143 - for ($i = 1; $i < count($this->aColumns) + 1; $i++) {  
144 - //if the first column is a link column  
145 - if (($this->iLinkType == 1 || $this->iLinkType == 2 || $this->iLinkType == 3) && ($i == 1)) {  
146 - switch ($this->iLinkType) {  
147 - case 1:  
148 - //display text only  
149 - $sToRender .= "<td><a href=\"" . $this->iLinkPageURL . "?fID=" . $aRow[0] . "&fTableName=" . $this->sTableName . "\">" . $aRow[$i] . "</td>\n";  
150 -  
151 - $sToRender .= "</a></td>\n";  
152 - break;  
153 - case 2:  
154 - //display an image only  
155 - $sToRender .= "<td><a href=\"" . $this->iLinkPageURL . "?fID=" . $aRow[0] . "&fTableName=" . $this->sTableName . "\"><img src=\"" . $this->sLinkImageURL . "\"/></a></td>\n";  
156 - break;  
157 - case 3:  
158 - //display both an image and text  
159 - $sToRender .= "<td><a href=\"" . $this->iLinkPageURL . "?fID=" . $aRow[0] . "&fTableName=" . $this->sTableName . "\"><img src=\"" . $this->sLinkImageURL . "\"/>" . $aRow[0] . "</a></td>\n";  
160 - break;  
161 - default:  
162 - break;  
163 - }  
164 - } else {  
165 - $sToRender .= "<td>".$aRow[$i]."</td>\n";  
166 - }  
167 - }  
168 - $sToRender .= "</tr>\n";  
169 - $iDisplayed++;  
170 - }  
171 -  
172 - //if we displayed less results than the number to display  
173 - //simply pad the table  
174 - while ($iDisplayed < $this->iResultsToDisplay) {  
175 - $sToRender .= "<tr><td>&nbsp</td></tr>\n";  
176 - $iDisplayed++;  
177 - }  
178 -  
179 - $sToRender .= "<tr>\n";  
180 -  
181 - /* Display only the next button */  
182 - if (($this->iStartIndex + $this->iResultsToDisplay) < $sql->getLastQueryResultCount() && $this->iStartIndex == 0) {  
183 - $sToRender .= "<td>";  
184 - $sToRender .= ("<a href=\"test.php?fStartIndex=" . ($this->iStartIndex + $this->iResultsToDisplay) . "\">Next</a>");  
185 - $sToRender .= "</td>\n";  
186 - }  
187 - /* Display both the next and the previous buttons */  
188 - else if (($this->iStartIndex + $this->iResultsToDisplay) < $sql->getLastQueryResultCount() && $this->iStartIndex > 0) {  
189 - $sToRender .= "<td>";  
190 - $sToRender .= ("<a href=\"test.php?fStartIndex=" . ($this->iStartIndex + $this->iResultsToDisplay) . "\">Next</a>");  
191 - $sToRender .= "</td>";  
192 - $sToRender .= "<td>";  
193 - $sToRender .= ("<a href=\"test.php?fStartIndex=" . ($this->iStartIndex - $this->iResultsToDisplay) . "\">Previous</a>");  
194 - $sToRender .= "</td>\n";  
195 -  
196 - }  
197 - /* Display only the previous button */  
198 - else if ($this->iStartIndex > 0) {  
199 - $sToRender .= "<td>\n";  
200 - $sToRender .= ("&nbsp");  
201 - $sToRender .= "</td>";  
202 - $sToRender .= "<td>\n";  
203 - $sToRender .= ("<a href=\"test.php?fStartIndex=" . ($this->iStartIndex - $this->iResultsToDisplay) . "\">Previous</a>");  
204 - $sToRender .= "</td>";  
205 - }  
206 -  
207 -  
208 - //$sToRender .= "</td>\n";  
209 - $sToRender .= "</tr>\n";  
210 - $sToRender .= "</table>\n";  
211 - return $sToRender;  
212 - }  
213 -  
214 -}  
215 -  
216 -?>