Commit c217daac55cd74c8003ea384b00078b2f7bff6fb
1 parent
9f717f27
No longer used.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4538 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
8 changed files
with
0 additions
and
1379 deletions
lib/visualpatterns/PatternBrowsableSearchResults.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Renders paginated query results in a table. | |
| 6 | - * | |
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 8 | - * | |
| 9 | - * This program is free software; you can redistribute it and/or modify | |
| 10 | - * it under the terms of the GNU General Public License as published by | |
| 11 | - * the Free Software Foundation; either version 2 of the License, or | |
| 12 | - * (at your option) any later version. | |
| 13 | - * | |
| 14 | - * This program is distributed in the hope that it will be useful, | |
| 15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | - * GNU General Public License for more details. | |
| 18 | - * | |
| 19 | - * You should have received a copy of the GNU General Public License | |
| 20 | - * along with this program; if not, write to the Free Software | |
| 21 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | - * | |
| 23 | - * @version $Revision$ | |
| 24 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 25 | - * @package lib.visualpatterns | |
| 26 | - */ | |
| 27 | - | |
| 28 | -require_once(KT_LIB_DIR . '/visualpatterns/PatternTableSqlQuery.inc'); | |
| 29 | - | |
| 30 | -class PatternBrowseableSearchResults { | |
| 31 | - | |
| 32 | - /** query to be executed */ | |
| 33 | - var $sQuery; | |
| 34 | - /** columns in query to be displayed */ | |
| 35 | - var $aColumns; | |
| 36 | - /** column types */ | |
| 37 | - var $aColumnTypes; | |
| 38 | - /** column headings to display */ | |
| 39 | - var $aColumnHeadings; | |
| 40 | - /** link href for column type 3 */ | |
| 41 | - var $aLinkURLs; | |
| 42 | - /** database column values to append to link url if a column type of 3 is specified */ | |
| 43 | - var $aDBQueryStringColumns; | |
| 44 | - /** variables names to give $aDBQueryStringColumns on the query string */ | |
| 45 | - var $aQueryStringVariableNames; | |
| 46 | - /** number of results to display per page */ | |
| 47 | - var $iResultsToDisplay; | |
| 48 | - /* Result number to start on */ | |
| 49 | - var $iStartIndex; | |
| 50 | - /** Column to order by */ | |
| 51 | - var $sOrderByColumn; | |
| 52 | - /** direction of ordering, ascending or descending */ | |
| 53 | - var $sOrderDirection = "ASC"; | |
| 54 | - /** New QueryString when submitting to self */ | |
| 55 | - var $sQueryString; | |
| 56 | - /** Search criteria **/ | |
| 57 | - var $sSearchText; | |
| 58 | - /** Advanced Search Criteria to remember **/ | |
| 59 | - var $aRememberValues; | |
| 60 | - | |
| 61 | - function PatternBrowseableSearchResults($sTmpQuery, $iTmpResultsToDisplay, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaders, $aTmpLinkURLs = null, $aTmpDBQueryStringColumns = null, $aTmpQueryStringVariableNames = null) { | |
| 62 | - $this->sQuery = $sTmpQuery; | |
| 63 | - $this->iResultsToDisplay = $iTmpResultsToDisplay; | |
| 64 | - $this->aColumns = $aTmpColumns; | |
| 65 | - $this->aColumnHeadings = $aTmpColumnHeaders; | |
| 66 | - $this->aColumnTypes = $aTmpColumnTypes; | |
| 67 | - $this->aLinkURLs = $aTmpLinkURLs; | |
| 68 | - $this->aDBQueryStringColumns = $aTmpDBQueryStringColumns; | |
| 69 | - $this->aQueryStringVariableNames = $aTmpQueryStringVariableNames; | |
| 70 | - $this->sQueryString = ""; | |
| 71 | - $this->aRememberValues = array(); | |
| 72 | - } | |
| 73 | - | |
| 74 | - function setQueryString($sNewQueryString) { | |
| 75 | - $this->sQueryString = $sNewQueryString; | |
| 76 | - } | |
| 77 | - | |
| 78 | - function getQueryString() { | |
| 79 | - return $this->sOrderByColumn; | |
| 80 | - } | |
| 81 | - | |
| 82 | - function setStartIndex($iNewValue) { | |
| 83 | - $this->iStartIndex = $iNewValue; | |
| 84 | - } | |
| 85 | - | |
| 86 | - function setOrderByColumn($sNewValue) { | |
| 87 | - $this->sOrderByColumn = $sNewValue; | |
| 88 | - } | |
| 89 | - | |
| 90 | - function setOrderDirection($sNewValue) { | |
| 91 | - $this->sOrderDirection = $sNewValue; | |
| 92 | - } | |
| 93 | - function setSearchText($sNewValue) { | |
| 94 | - $this->sSearchText = $sNewValue; | |
| 95 | - } | |
| 96 | - | |
| 97 | - function setRememberValues($aRemember) { | |
| 98 | - $this->aRememberValues = $aRemember; | |
| 99 | - } | |
| 100 | - | |
| 101 | - /** | |
| 102 | - * Build the HTML string used to render the object | |
| 103 | - * | |
| 104 | - * @return String of HTML used to render object | |
| 105 | - * | |
| 106 | - * @todo possibly add in image size restraints for link types 2 and 3 | |
| 107 | - */ | |
| 108 | - function & render() { | |
| 109 | - global $default; | |
| 110 | - | |
| 111 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 112 | - $sTHBGColour = $default->siteMap->getSectionColour($sSectionName, "th"); | |
| 113 | - | |
| 114 | - // run the query first and get the number of rows | |
| 115 | - $iTotalResults = $this->getResultCount(); | |
| 116 | - | |
| 117 | - // now add the limit and offset stuff for cutting down result set | |
| 118 | - // decrement startIndex because LIMIT starts at zero and startIndex starts at 1 (for display purposes) | |
| 119 | - if (is_array($this->sQuery)) { | |
| 120 | - $sQuery = $this->sQuery[0]; | |
| 121 | - $aParams = $this->sQuery[1]; | |
| 122 | - } else { | |
| 123 | - $sQuery = $this->sQuery; | |
| 124 | - $aParams = array(); | |
| 125 | - } | |
| 126 | - $sQuery = $sQuery . " LIMIT ?, ?"; | |
| 127 | - $aParams[] = $this->iStartIndex - 1; | |
| 128 | - $aParams[] = $this->iResultsToDisplay; | |
| 129 | - | |
| 130 | - $oResult = DBUtil::runQuery(array($sQuery, $aParams)); | |
| 131 | - if (PEAR::isError($oResult)) { | |
| 132 | - $GLOBALS['default']->log->error('PatternBrowsableSearchResults: query returned error: ' . $oResult->getMessage()); | |
| 133 | - return $oResult; | |
| 134 | - } | |
| 135 | - $oResultSet = new SqlResultSetAdapter($oResult); | |
| 136 | - | |
| 137 | - if ($oResultSet->isEmpty()) { | |
| 138 | - //no results | |
| 139 | - $sToRender .= "<table width=\"100%\" height=\"80%\">\n"; | |
| 140 | - $sToRender .= "<tr>\n"; | |
| 141 | - $sToRender .= "<td><p class=\"errorText\">" . _("No results matched your criteria") . "</p></td>\n"; | |
| 142 | - $sToRender .= "</tr>\n"; | |
| 143 | - $sToRender .= "</table>\n"; | |
| 144 | - } else { | |
| 145 | - | |
| 146 | - $sToRender .= "<table width=\"100%\" height=\"80%\">\n"; | |
| 147 | - | |
| 148 | - // display the number of results | |
| 149 | - $iEndIndex = $this->iStartIndex+$this->iResultsToDisplay-1 < $iTotalResults ? $this->iStartIndex+$this->iResultsToDisplay-1 : $iTotalResults; | |
| 150 | - | |
| 151 | - if ($this->sSearchText) { | |
| 152 | - $sToRender .= "<tr><td colspan=\"3\">" . sprintf(_("Searched the KnowledgeTree for '%s'."), $this->sSearchText) . "</td></tr>"; | |
| 153 | - } | |
| 154 | - | |
| 155 | - $sToRender .= "<tr><td colspan=\"3\" align=\"right\">" . sprintf(_("Displaying results %s - %s of %s"), $this->iStartIndex, $iEndIndex, $iTotalResults) . "</td></tr>\n"; | |
| 156 | - | |
| 157 | - $sToRender .= "<tr>\n"; | |
| 158 | - for ($i = 0; $i < count($this->aColumnHeadings); $i++) { | |
| 159 | - if (! (strcmp($this->sOrderByColumn, $this->aColumns[$i]) === false) && (strcmp($this->sOrderByColumn, $this->aColumns[$i]) == 0)) { | |
| 160 | - if (!(strcmp($this->sOrderDirection,"ASC") === false) && (strcmp($this->sOrderDirection,"ASC") == 0)) { | |
| 161 | - $sToRender .= "<th align=\"left\" bgcolor=\"" . $sTHBGColour . "\">" . $this->aColumnHeadings[$i]. "</th>\n"; | |
| 162 | - } else { | |
| 163 | - $sToRender .= "<th align=\"left\" bgcolor=\"" . $sTHBGColour . "\">" . $this->aColumnHeadings[$i]. "</th>\n"; | |
| 164 | - } | |
| 165 | - } else { | |
| 166 | - $sToRender .= "<th align=\"left\" bgcolor=\"" . $sTHBGColour . "\">" . $this->aColumnHeadings[$i]. "</th>\n"; | |
| 167 | - } | |
| 168 | - } | |
| 169 | - $sToRender .= "</tr>\n"; | |
| 170 | - $iColour = 0; | |
| 171 | - $iDisplayed = 0; | |
| 172 | - | |
| 173 | - //limit the result set displayed | |
| 174 | - while($oRow = $oResultSet->next()) { | |
| 175 | - $sToRender .= "<tr bgcolor=\"" . getColour($iColour) . "\">"; | |
| 176 | - $iColour++; $iDisplayed++; | |
| 177 | - | |
| 178 | - for ($i = 0; $i < count($this->aColumns); $i++) { | |
| 179 | - switch ($this->aColumnTypes[$i]) { | |
| 180 | - case 1: | |
| 181 | - //display text | |
| 182 | - $sToRender .= "<td>" . $oRow->get($this->aColumns[$i]) . "</td>\n"; | |
| 183 | - break; | |
| 184 | - case 2: | |
| 185 | - //display a checkbox | |
| 186 | - $sToRender .= "<td>" . ($oRow->get($this->aColumns[$i]) ? "Yes" : "No") . "</td>\n"; | |
| 187 | - break; | |
| 188 | - case 3: | |
| 189 | - //display a url | |
| 190 | - $sToRender .= "<td><a href=\"" ; | |
| 191 | - $sURLplusQuery = $this->aLinkURLs[$i]; | |
| 192 | - for ($j = 0; $j < count($this->aDBQueryStringColumns); $j++) { | |
| 193 | - if (strpos($sURLplusQuery, "?") === false) { | |
| 194 | - $sURLplusQuery .= "?" . $this->aQueryStringVariableNames[$j] . "=" . $oRow->get($this->aDBQueryStringColumns[$j]); | |
| 195 | - } else { | |
| 196 | - $sURLplusQuery .= "&" . $this->aQueryStringVariableNames[$j] . "=" . $oRow->get($this->aDBQueryStringColumns[$j]); | |
| 197 | - } | |
| 198 | - } | |
| 199 | - $sToRender .= $sURLplusQuery; | |
| 200 | - $sToRender .= "\">" . $oRow->get($this->aColumns[$i]) . "</a></td>\n"; | |
| 201 | - | |
| 202 | - break; | |
| 203 | - case 4: | |
| 204 | - //diplay an image URL | |
| 205 | - $sToRender .= "<td><a href=\"" . $this->aLinkURLs[$i]; | |
| 206 | - for ($j = 0; $j < count($this->aDBQueryStringColumns); $j++) { | |
| 207 | - if (strpos($sToRender, "?") === false) { | |
| 208 | - $sToRender .= "?" . $this->aQueryStringVariableNames[$j] . "=" . $oRow->get($this->aDBQueryStringColumns[$j]); | |
| 209 | - } else { | |
| 210 | - $sToRender .= "&" . $this->aQueryStringVariableNames[$j] . "=" . $oRow->get($this->aDBQueryStringColumns[$j]); | |
| 211 | - } | |
| 212 | - } | |
| 213 | - $sToRender .= "\"><img src=\"" . $oRow->get($this->aColumns[$i]) . "\" border=\"0\" /></a></td>\n"; | |
| 214 | - break; | |
| 215 | - default: | |
| 216 | - break; | |
| 217 | - } | |
| 218 | - } | |
| 219 | - $sToRender .= "</tr>\n"; | |
| 220 | - } | |
| 221 | - | |
| 222 | - //if we displayed less results than the number to display | |
| 223 | - //simply pad the table | |
| 224 | - while ($iDisplayed < $this->iResultsToDisplay) { | |
| 225 | - $sToRender .= "<tr><td> </td></tr>\n"; | |
| 226 | - $iDisplayed++; | |
| 227 | - } | |
| 228 | - $sToRender .= "</table>"; | |
| 229 | - | |
| 230 | - $sToRender .= "<table>"; | |
| 231 | - $sToRender .= "<tr>\n"; | |
| 232 | - foreach ($this->aRememberValues as $k => $v) { | |
| 233 | - $v = htmlentities(urlencode($v)); | |
| 234 | - $sToRender .= "<input type=\"hidden\" name=\"$k\" value=\"$v\" />\n"; | |
| 235 | - } | |
| 236 | - // Display only the next button | |
| 237 | - if (($this->iStartIndex + $this->iResultsToDisplay - 1) < $iTotalResults && $this->iStartIndex == 1) { | |
| 238 | - $sToRender .= "<td> </td>"; | |
| 239 | - $sToRender .= "<td align=\"left\">"; | |
| 240 | - $sToRender .= "<input type=\"image\" src=\"" . KTHtml::getNextButton() . "\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex + $this->iResultsToDisplay) . $this->sQueryString . "')\" />"; | |
| 241 | - $sToRender .= "</td>\n"; | |
| 242 | - } | |
| 243 | - // Display both the next and the previous buttons | |
| 244 | - else if (($this->iStartIndex + $this->iResultsToDisplay - 1) < $iTotalResults && $this->iStartIndex > 1) { | |
| 245 | - $sToRender .= "<td>"; | |
| 246 | - $sToRender .= "<input type=\"image\" src=\"" . KTHtml::getPreviousButton() . "\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex - $this->iResultsToDisplay) . $this->sQueryString . "')\" />"; | |
| 247 | - $sToRender .= "</td>"; | |
| 248 | - $sToRender .= "<td>"; | |
| 249 | - $sToRender .= "<input type=\"image\" src=\"" . KTHtml::getNextButton() . "\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex + $this->iResultsToDisplay) . $this->sQueryString . "')\" />"; | |
| 250 | - $sToRender .= "</td>\n"; | |
| 251 | - | |
| 252 | - } | |
| 253 | - // Display only the previous button | |
| 254 | - else if ($this->iStartIndex > 1) { | |
| 255 | - $sToRender .= "<td align=\"left\">\n"; | |
| 256 | - $sToRender .= "<input type=\"image\" src=\"" . KTHtml::getPreviousButton() . "\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex - $this->iResultsToDisplay) . $this->sQueryString . "')\" />"; | |
| 257 | - $sToRender .= "</td>"; | |
| 258 | - } | |
| 259 | - | |
| 260 | - $sToRender .= "</tr>\n"; | |
| 261 | - $sToRender .= "</table>\n"; | |
| 262 | - } | |
| 263 | - return $sToRender; | |
| 264 | - } | |
| 265 | - | |
| 266 | - function getResultCount() { | |
| 267 | - global $default; | |
| 268 | - $sql = & $default->db; | |
| 269 | - if ($sql->query($this->sQuery)) { | |
| 270 | - return $sql->num_rows(); | |
| 271 | - } else { | |
| 272 | - return 0; | |
| 273 | - } | |
| 274 | - } | |
| 275 | -} | |
| 276 | -?> |
lib/visualpatterns/PatternCustom.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Used to specify html code that is not catered for by any of the other patterns. | |
| 6 | - * | |
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 8 | - * | |
| 9 | - * This program is free software; you can redistribute it and/or modify | |
| 10 | - * it under the terms of the GNU General Public License as published by | |
| 11 | - * the Free Software Foundation; either version 2 of the License, or | |
| 12 | - * (at your option) any later version. | |
| 13 | - * | |
| 14 | - * This program is distributed in the hope that it will be useful, | |
| 15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | - * GNU General Public License for more details. | |
| 18 | - * | |
| 19 | - * You should have received a copy of the GNU General Public License | |
| 20 | - * along with this program; if not, write to the Free Software | |
| 21 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | - * | |
| 23 | - * @version $Revision$ | |
| 24 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 25 | - * @package lib.visualpatterns | |
| 26 | - */ | |
| 27 | -class PatternCustom { | |
| 28 | - | |
| 29 | - /** Custom HTML string */ | |
| 30 | - var $sHtml; | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * Set the HTML string | |
| 34 | - * | |
| 35 | - * @param string new HTML string | |
| 36 | - */ | |
| 37 | - function setHtml($sNewValue) { | |
| 38 | - $this->sHtml = $sNewValue; | |
| 39 | - } | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * Appends to the html string | |
| 43 | - * | |
| 44 | - * @param string the html to append | |
| 45 | - */ | |
| 46 | - function addHtml($sMoreHtml) { | |
| 47 | - $this->sHtml = $this->sHtml . $sMoreHtml; | |
| 48 | - } | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * Render the object | |
| 52 | - * | |
| 53 | - * @return string html string | |
| 54 | - */ | |
| 55 | - function & render() { | |
| 56 | - return $this->sHtml; | |
| 57 | - } | |
| 58 | -} | |
| 59 | -?> |
lib/visualpatterns/PatternEditableTableSqlQuery.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Will take a query that generates a table like | |
| 6 | - * result and create and editable HTML table from it that can | |
| 7 | - * be used as part of a form. | |
| 8 | - * | |
| 9 | - * 1 columns is REQUIRED in the Sql query: | |
| 10 | - * o column giving primary key of entry in table (primary key column name specified in $aPrimaryKey) | |
| 11 | - * | |
| 12 | - * 3 hidden fields are generated for each editable entry: | |
| 13 | - * o <uniquename>_id: holds the primary key of the entry in the table (-1 = no entry in table i.e. create not update) | |
| 14 | - * o <uniquename>_tn: holds the tablename for which the primary key is valid | |
| 15 | - * o <uniquename>_type: holds the type of entry (text/boolean/list) - for parsing purposes | |
| 16 | - * | |
| 17 | - * The actual value is held in a form field name <uniquename> | |
| 18 | - * | |
| 19 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 20 | - * | |
| 21 | - * This program is free software; you can redistribute it and/or modify | |
| 22 | - * it under the terms of the GNU General Public License as published by | |
| 23 | - * the Free Software Foundation; either version 2 of the License, or | |
| 24 | - * (at your option) any later version. | |
| 25 | - * | |
| 26 | - * This program is distributed in the hope that it will be useful, | |
| 27 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 28 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 29 | - * GNU General Public License for more details. | |
| 30 | - * | |
| 31 | - * You should have received a copy of the GNU General Public License | |
| 32 | - * along with this program; if not, write to the Free Software | |
| 33 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 34 | - * | |
| 35 | - * @version $Revision$ | |
| 36 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 37 | - * @package lib.visualpatterns | |
| 38 | - * @todo - add client side validation stuff | |
| 39 | - * @todo - add column type 3 -> select field stuff | |
| 40 | - */ | |
| 41 | -class PatternEditableTableSqlQuery { | |
| 42 | - | |
| 43 | - /** query to execute*/ | |
| 44 | - var $sQuery; | |
| 45 | - /** table to perform insert/update on */ | |
| 46 | - var $sTableName; | |
| 47 | - /** columns names in $sQuery to display */ | |
| 48 | - var $aDisplayColumnNames; | |
| 49 | - /** column names in $sQuery that will be stored/updated */ | |
| 50 | - var $aStoreColumnNames; | |
| 51 | - /** Array of boolean values dictating column editability */ | |
| 52 | - var $aColumnsEditable; | |
| 53 | - /** columns visible or not (store columns) */ | |
| 54 | - var $aColumnsVisible; | |
| 55 | - /** column types: 1 = text, 2 = boolean, 3 = drop down list, 4 = meta data lookup */ | |
| 56 | - var $aColumnDisplayTypes; | |
| 57 | - /** 0 = id, 1 = text, 2 = boolean*/ | |
| 58 | - var $aColumnDatabaseTypes; | |
| 59 | - /** Unique name */ | |
| 60 | - var $sUniqueName; | |
| 61 | - /** message that will be displayed if the table is empty*/ | |
| 62 | - var $sEmptyTableMessage; | |
| 63 | - /** whether or not to include javascript validation rendering automatically */ | |
| 64 | - var $bRenderJavascriptValidation = true; | |
| 65 | - /** temporary array holding the required fields */ | |
| 66 | - var $aRequiredVariables; | |
| 67 | - | |
| 68 | - var $aRequiredColumnNames; | |
| 69 | - var $aRequiredFieldNames; | |
| 70 | - var $aMetaDataFields; | |
| 71 | - | |
| 72 | - var $sPreCode; | |
| 73 | - | |
| 74 | - function PatternEditableTableSqlQuery($sTmpQuery, $sTmpTableName, $aTmpStoreColumnNames, $aTmpDisplayColumnNames, $aTmpColumnsEditable, $aTmpColumnsVisible, $aTmpColumnDisplayTypes, $aTmpColumnDatabaseTypes) { | |
| 75 | - $this->sQuery = $sTmpQuery; | |
| 76 | - $this->sTableName = $sTmpTableName; | |
| 77 | - $this->aStoreColumnNames = $aTmpStoreColumnNames; | |
| 78 | - $this->aDisplayColumnNames = $aTmpDisplayColumnNames; | |
| 79 | - $this->aColumnsEditable = $aTmpColumnsEditable; | |
| 80 | - $this->sUniqueName = $sTmpUniqueName; | |
| 81 | - $this->aColumnsVisible = $aTmpColumnsVisible; | |
| 82 | - $this->aColumnDisplayTypes = $aTmpColumnDisplayTypes; | |
| 83 | - $this->aColumnDatabaseTypes = $aTmpColumnDatabaseTypes; | |
| 84 | - } | |
| 85 | - | |
| 86 | - function setUniqueName($sNewValue) { $this->sUniqueName = $sNewValue; } | |
| 87 | - function setMetaDataFields($aNewValue) { $this->aMetaDataFields = $aNewValue; } | |
| 88 | - function setDisplayColumnHeadings($bNewValue) { $this->bDisplayColumnHeadings = $bNewValue; } | |
| 89 | - function setTableCaption($sNewValue) { $this->sTableCaption = $sNewValue; } | |
| 90 | - function setColumnHeaderNames($aNewValue) { $this->aColumnHeaderNames = $aNewValue; } | |
| 91 | - function setRequiredColumnNames($aNewValue) { $this->aRequiredColumnNames = $aNewValue; } | |
| 92 | - function setEmptyTableMessage($sNewValue) { $this->sEmptyTableMessage = $sNewValue; } | |
| 93 | - function setRenderJavascriptValidation($bNewValue) { $this->bRenderJavascriptValidation = $bNewValue; } | |
| 94 | - function setPreCode($sNewValue) { $this->sPreCode = $sNewValue; } | |
| 95 | - function setPostCode($sNewValue) { $this->sPostCode = $sNewValue; } | |
| 96 | - | |
| 97 | - function & render() { | |
| 98 | - global $default; | |
| 99 | - | |
| 100 | - $sToRender = "<table cellpadding=\"5\" border=\"0\">\n"; | |
| 101 | - if (isset($this->sTableCaption)) { | |
| 102 | - $sToRender .= "<caption align=\"top\" colspan=\"" . count($this->aColumnsSql) . "\" align=\"left\"><b>$this->sTableCaption</b></caption>\n"; | |
| 103 | - } | |
| 104 | - if ($this->bDisplayColumnHeadings) { | |
| 105 | - for ($i = 0; $i < count($this->aColumnHeaderNames); $i++) { | |
| 106 | - $sToRender .= "<th align=left>" . $this->aColumnHeaderNames[$i] . "</th>\n"; | |
| 107 | - } | |
| 108 | - } | |
| 109 | - | |
| 110 | - $this->sUniqueName .= KTUtil::randomString(); | |
| 111 | - | |
| 112 | - $sql = $default->db; | |
| 113 | - $sql->query($this->sQuery); | |
| 114 | - if ($sql->num_rows() == 0) { | |
| 115 | - $sToRender .= "<tr>\n"; | |
| 116 | - if (isset($this->sEmptyTableMessage)) { | |
| 117 | - $sToRender .= "<td colspan=" . count($this->aStoreColumnNames) . ">$this->sEmptyTableMessage</td>\n"; | |
| 118 | - } else { | |
| 119 | - $sToRender .= "<td colspan=" . count($this->aStoreColumnNames) . ">" . | |
| 120 | - sprintf(_("No %s data"), (isset($this->sTableCaption) ? $this->sTableCaption : "")) . | |
| 121 | - "</td>\n"; | |
| 122 | - } | |
| 123 | - $sToRender .= "</tr>\n"; | |
| 124 | - } else { | |
| 125 | - $this->aRequiredVariables = array(); | |
| 126 | - $iRowCount = 0; | |
| 127 | - while ($sql->next_record()) { | |
| 128 | - $sToRender .= "<tr>\n"; | |
| 129 | - $_SESSION["pelfq_" . $this->sUniqueName . $iRowCount . "_id"] = $sql->f("id"); | |
| 130 | - $_SESSION["pelfq_" . $this->sUniqueName . $iRowCount . "_code_pre"] = $this->sPreCode; | |
| 131 | - $_SESSION["pelfq_" . $this->sUniqueName . $iRowCount . "_code_post"] = $this->sPostCode; | |
| 132 | - $_SESSION["pelfq_" . $this->sUniqueName . $iRowCount . "_tn"] = $this->sTableName; | |
| 133 | - $_SESSION["pelfq_" . $this->sUniqueName . $iRowCount . "_columns"] = $this->aStoreColumnNames; | |
| 134 | - $sToRender .= "<input type=\"hidden\" name=\"unique_start_" . $this->sUniqueName . $iRowCount . "\" value=\"\" />\n"; | |
| 135 | - // $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . "\" value=\"" . $sql->f("id") . "\" />\n"; | |
| 136 | - // $sToRender .= "<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . "_tn\" value=\"" . $this->sTableName . "\" />\n"; | |
| 137 | - | |
| 138 | - // check for is_mandatory field validation | |
| 139 | - if ($sql->f("is_mandatory") == "1") { | |
| 140 | - $this->aRequiredVariables[]["formName"] = $this->sUniqueName . "_" . $iRowCount . (count($this->aStoreColumnNames)-1) . "_value"; | |
| 141 | - } | |
| 142 | - for ($i = 0; $i < count($this->aStoreColumnNames); $i++) { | |
| 143 | - if (isset($this->aRequiredColumnNames)) { | |
| 144 | - for ($k = 0; $k < count($this->aRequiredColumnNames); $k++) { | |
| 145 | - if (strcmp($this->aStoreColumnNames[$i], $this->aRequiredColumnNames[$k]) == 0) { | |
| 146 | - $this->aRequiredVariables[count($this->aRequiredVariables)]["formName"] = $this->sUniqueName . "_" . $iRowCount . $i . "_value"; | |
| 147 | - } | |
| 148 | - } | |
| 149 | - } | |
| 150 | - | |
| 151 | - //generate the right kind of editable field | |
| 152 | - $sToRender .= "\t<td>\n"; | |
| 153 | - switch ($this->aColumnDisplayTypes[$i]) { | |
| 154 | - case 1: | |
| 155 | - //output the table column name | |
| 156 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_tc\" value=\"" . $this->aStoreColumnNames[$i] . "\" />\n"; | |
| 157 | - //output the column type | |
| 158 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_type\" value=\"" . $this->aColumnDatabaseTypes[$i] . "\" />\n"; | |
| 159 | - //output the value | |
| 160 | - if ($this->aColumnsVisible[$i]) { | |
| 161 | - if ($this->aColumnsEditable[$i]) { | |
| 162 | - $sToRender .= "\t<input type=\"text\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />\n"; | |
| 163 | - } else { | |
| 164 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />" . $sql->f($this->aDisplayColumnNames[$i])."\n"; | |
| 165 | - } | |
| 166 | - } else { | |
| 167 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />\n"; | |
| 168 | - } | |
| 169 | - break; | |
| 170 | - case 2: | |
| 171 | - //output the table column name | |
| 172 | - $sToRender .= "\t<input type=\"hidden\" name=\"tc_" . $this->sUniqueName . "_" . $iRowCount . $i . "_tc\" value=\"" . $this->aStoreColumnNames[$i] . "\" />\n"; | |
| 173 | - //output the column type | |
| 174 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_type\" value=\"" . $this->aColumnDatabaseTypes[$i] . "\" />\n"; | |
| 175 | - //output the value | |
| 176 | - if ($this->aColumnsVisible[$i]) { | |
| 177 | - if ($this->aColumnsEditable[$i]) { | |
| 178 | - $sToRender .= "\t<input type=\"checkbox\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . ($sql->f($this->aStoreColumnNames[$i] ? "1\" checked" : "0\"")) . " />\n"; | |
| 179 | - } else { | |
| 180 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />".$sql->f($this->aDisplayColumnNames[$i])."\n"; | |
| 181 | - } | |
| 182 | - } else { | |
| 183 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />\n"; | |
| 184 | - } | |
| 185 | - break; | |
| 186 | - case 3: | |
| 187 | - $sToRender .= "<b>" . _("The column type for drop downs is not implemented yet") . "</b>\n"; | |
| 188 | - break; | |
| 189 | - case 4: | |
| 190 | - //meta data | |
| 191 | - //could either be a drop down or a text field, depending | |
| 192 | - | |
| 193 | - //output the table column name | |
| 194 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_tc\" value=\"" . $this->aStoreColumnNames[$i] . "\" />\n"; | |
| 195 | - //output the column type | |
| 196 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_type\" value=\"" . $this->aColumnDatabaseTypes[$i] . "\" />\n"; | |
| 197 | - if ($this->aColumnsVisible[$i]) { | |
| 198 | - if ($this->aColumnsEditable[$i]) { | |
| 199 | - $oPattern = & new PatternMetaData($sql->f($this->aMetaDataFields[$i]), $this->sUniqueName . "_" . $iRowCount . $i . "_value", $sql->f($this->aStoreColumnNames[$i])); | |
| 200 | - $sToRender .= $oPattern->render(); | |
| 201 | - } else { | |
| 202 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />".$sql->f($this->aDisplayColumnNames[$i])."\n"; | |
| 203 | - } | |
| 204 | - } else { | |
| 205 | - $sToRender .= "\t<input type=\"hidden\" name=\"" . $this->sUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />\n"; | |
| 206 | - } | |
| 207 | - break; | |
| 208 | - | |
| 209 | - break; | |
| 210 | - default: | |
| 211 | - $sToRender .= "<b>" . | |
| 212 | - sprintf(_("You are attempting to render an unknown column type %s in PatternEditableTableSqlQuery"), | |
| 213 | - ($this->aColumnTypes[$i])) . | |
| 214 | - "</b>\n"; | |
| 215 | - break; | |
| 216 | - } | |
| 217 | - | |
| 218 | - $sToRender .= "\t</td>\n"; | |
| 219 | - } | |
| 220 | - $sToRender .= "<input type=\"hidden\" name=\"unique_end_" . $this->sUniqueName . $iRowCount . "\" value=\"\" />\n"; | |
| 221 | - $sToRender .= "</tr>\n"; | |
| 222 | - $iRowCount++; | |
| 223 | - } | |
| 224 | - } | |
| 225 | - $sToRender .= "</table>"; | |
| 226 | - if (isset($this->aRequiredVariables)) { | |
| 227 | - if ($this->bRenderJavascriptValidation) { | |
| 228 | - $sToRender .= $this->generateRequiredFieldValidation($this->aRequiredVariables); | |
| 229 | - } | |
| 230 | - } | |
| 231 | - return $sToRender; | |
| 232 | - } | |
| 233 | - | |
| 234 | - function generateRequiredFieldValidation($aValidationColumnNames) { | |
| 235 | - $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | |
| 236 | - $sToRender .= "function validateForm(theForm) {\n"; | |
| 237 | - for ($i = 0; $i < count($aValidationColumnNames); $i++) { | |
| 238 | - $sToRender .= "\tif (!(validRequired(document.MainForm." . $aValidationColumnNames[$i]["formName"] . ", 'selected'))) {\n"; | |
| 239 | - $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 240 | - } | |
| 241 | - $sToRender .= "return true;\n}\n"; | |
| 242 | - $sToRender .= "//-->\n</script>\n\n"; | |
| 243 | - return $sToRender; | |
| 244 | - } | |
| 245 | - | |
| 246 | - function getValidationJavascript() { | |
| 247 | - for ($i = 0; $i < count($this->aRequiredVariables); $i++) { | |
| 248 | - $sToRender .= "\tif (!(validRequired(document.MainForm." . $this->aRequiredVariables[$i]["formName"] . ", 'selected'))) {\n"; | |
| 249 | - $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 250 | - } | |
| 251 | - return $sToRender; | |
| 252 | - } | |
| 253 | -} | |
| 254 | -?> |
lib/visualpatterns/PatternListBox.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Creates a drop down list box using a table name and | |
| 6 | - * two column names (one column is the display value, the other | |
| 7 | - * is the option value). The option value column should always | |
| 8 | - * be an ID that is a primary key in a table | |
| 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 | - * @package lib.visualpatterns | |
| 29 | - * @todo - if the list is set to submit on change, it submits the form. Investigate ways | |
| 30 | - * to get a list action to occur, instead of the default form action | |
| 31 | - */ | |
| 32 | -class PatternListBox { | |
| 33 | - | |
| 34 | - /** Database table to get information from */ | |
| 35 | - var $sTableName; | |
| 36 | - /** Column in table to display */ | |
| 37 | - var $sDisplayColumn; | |
| 38 | - /** Column in table to use as option value */ | |
| 39 | - var $sValueColumn; | |
| 40 | - /** Select name */ | |
| 41 | - var $sSelectName; | |
| 42 | - /** Where clause */ | |
| 43 | - var $sWhereClause; | |
| 44 | - /**from clause, use to add extra inner joins. The default selected table gets | |
| 45 | - a name of ST and the two selected columns are 'value' and 'display' */ | |
| 46 | - var $sFromClause; | |
| 47 | - /** Order columns ascending*/ | |
| 48 | - var $bOrderAsc; | |
| 49 | - /** set this to true to cause the list box to post back on a change */ | |
| 50 | - var $bPostBackOnChange = false; | |
| 51 | - /** action to perform on a postback */ | |
| 52 | - var $sOnChangeAction = "document.MainForm.submit();"; | |
| 53 | - /** currently selected value */ | |
| 54 | - var $selectedValue; | |
| 55 | - /** error message for an empty list box */ | |
| 56 | - var $sEmptyErrorMessage = "No values"; | |
| 57 | - /** whether to include 'None' as an option*/ | |
| 58 | - var $bIncludeDefaultValue = true; | |
| 59 | - /** additional list box items */ | |
| 60 | - var $aAdditionalEntries; | |
| 61 | - /** override display name */ | |
| 62 | - var $sCompositeDisplayColumnName; | |
| 63 | - /** override query */ | |
| 64 | - var $sQuery; | |
| 65 | - | |
| 66 | - /** | |
| 67 | - * Constructor | |
| 68 | - * | |
| 69 | - * @param Table in database that information will come from | |
| 70 | - * @param Column in table that will be display in list box | |
| 71 | - * @param Column in table that will be assigned to the 'option' attribute | |
| 72 | - * @param 'name' attribute of 'select' tab | |
| 73 | - * @param Where clause | |
| 74 | - */ | |
| 75 | - function PatternListBox($sNewTableName, $sNewDisplayColumn, $sNewValueColumn, $sNewSelectName, $sNewWhereClause = null, $bNewOrderAsc = true) { | |
| 76 | - $this->sTableName = $sNewTableName; | |
| 77 | - $this->sDisplayColumn = $sNewDisplayColumn; | |
| 78 | - $this->sValueColumn = $sNewValueColumn; | |
| 79 | - $this->sSelectName = $sNewSelectName; | |
| 80 | - $this->sWhereClause = $sNewWhereClause; | |
| 81 | - $this->bOrderAsc = $bNewOrderAsc; | |
| 82 | - } | |
| 83 | - | |
| 84 | - function setQuery($sQuery) { | |
| 85 | - $this->sQuery = $sQuery; | |
| 86 | - } | |
| 87 | - function setSelectName($sNewSelectName) { | |
| 88 | - $this->sSelectName = $sNewSelectName; | |
| 89 | - } | |
| 90 | - | |
| 91 | - function setPostBackOnChange($bNewValue) { | |
| 92 | - $this->bPostBackOnChange = $bNewValue; | |
| 93 | - } | |
| 94 | - | |
| 95 | - function setOnChangeAction($sNewValue) { | |
| 96 | - $this->sOnChangeAction = $sNewValue; | |
| 97 | - } | |
| 98 | - | |
| 99 | - function setSelectedValue($NewValue) { | |
| 100 | - $this->selectedValue = $NewValue; | |
| 101 | - } | |
| 102 | - | |
| 103 | - function setWhereClause($sNewValue) { | |
| 104 | - $this->sWhereClause = $sNewValue; | |
| 105 | - } | |
| 106 | - | |
| 107 | - function setFromClause($sNewValue) { | |
| 108 | - $this->sFromClause = $sNewValue; | |
| 109 | - } | |
| 110 | - | |
| 111 | - function setEmptyErrorMessage($sNewValue) { | |
| 112 | - $this->sEmptyErrorMessage = $sNewValue; | |
| 113 | - } | |
| 114 | - | |
| 115 | - function setIncludeDefaultValue($bNewValue) { | |
| 116 | - $this->bIncludeDefaultValue = $bNewValue; | |
| 117 | - } | |
| 118 | - | |
| 119 | - function setAdditionalEntries($aNewValue) { | |
| 120 | - $this->aAdditionalEntries = $aNewValue; | |
| 121 | - } | |
| 122 | - | |
| 123 | - function setCompositeDisplayName($sNewValue) { | |
| 124 | - $this->sCompositeDisplayColumnName = $sNewValue; | |
| 125 | - } | |
| 126 | - | |
| 127 | - /** | |
| 128 | - * Create the HTML string that will be used to render the list box | |
| 129 | - * | |
| 130 | - * @return String html used to render the list box | |
| 131 | - * | |
| 132 | - */ | |
| 133 | - function & render() { | |
| 134 | - global $default; | |
| 135 | - | |
| 136 | - $sql = $default->db; | |
| 137 | - if (isset($this->sQuery)) { | |
| 138 | - $sQuery = $this->sQuery; | |
| 139 | - } else { | |
| 140 | - $sQuery = "SELECT ";/*wc*/ | |
| 141 | - if (isset($this->sCompositeDisplayColumnName)) { | |
| 142 | - $sQuery .= "$this->sCompositeDisplayColumnName"; | |
| 143 | - } else { | |
| 144 | - $sQuery .= "DISTINCT ST." . $this->sDisplayColumn; | |
| 145 | - } | |
| 146 | - $sQuery .= " AS display, ST." . $this->sValueColumn . " AS value FROM $this->sTableName AS ST "; | |
| 147 | - if (isset($this->sFromClause)) { | |
| 148 | - $sQuery .= $this->sFromClause . " "; | |
| 149 | - } | |
| 150 | - if (isset($this->sWhereClause)) { | |
| 151 | - $sQuery .= "WHERE " . $this->sWhereClause . " "; | |
| 152 | - } | |
| 153 | - $sQuery .= "ORDER BY ST.$this->sDisplayColumn " . ($this->bOrderAsc ? "ASC" : "DESC"); | |
| 154 | - } | |
| 155 | - $sql->query($sQuery); | |
| 156 | - if ($sql->num_rows() > 0 || $this->bIncludeDefaultValue && (strlen($this->sEmptyErrorMessage) == 0)) { | |
| 157 | - if (isset($this->sOnChangeAction)) { | |
| 158 | - $sToRender = "<SELECT NAME=\"$this->sSelectName\" ". ($this->bPostBackOnChange ? "onChange=\"$this->sOnChangeAction\" " : " ") . ">\n"; | |
| 159 | - } else { | |
| 160 | - $sToRender = "<SELECT NAME=\"$this->sSelectName\" ". ($this->bPostBackOnChange ? "onChange=\"document.MainForm.submit();\" " : " ") . ">\n"; | |
| 161 | - } | |
| 162 | - if ($this->bIncludeDefaultValue) { | |
| 163 | - $sToRender .= "<OPTION value=\"\">None</OPTION>\n"; | |
| 164 | - } | |
| 165 | - while ($sql->next_record()) { | |
| 166 | - if ($this->selectedValue == $sql->f("value")) { | |
| 167 | - $sToRender .= "<OPTION value=\"" . $sql->f("value") . "\" SELECTED>" . $sql->f("display") . "</OPTION>\n"; | |
| 168 | - } else { | |
| 169 | - $sToRender .= "<OPTION value=\"" . $sql->f("value") . "\">" . $sql->f("display") . "</OPTION>\n"; | |
| 170 | - } | |
| 171 | - } | |
| 172 | - if (isset($this->aAdditionalEntries)) { | |
| 173 | - for ($i=0; $i<count($this->aAdditionalEntries); $i++) { | |
| 174 | - $sToRender .= "<OPTION value=\"" . $this->aAdditionalEntries[$i]["value"] . "\">" . $this->aAdditionalEntries[$i]["display"] . "</OPTION>\n"; | |
| 175 | - } | |
| 176 | - } | |
| 177 | - $sToRender .= "</SELECT>\n"; | |
| 178 | - } else { | |
| 179 | - $sToRender .= "<label class=\"errorText\">$this->sEmptyErrorMessage</label>\n"; | |
| 180 | - } | |
| 181 | - return $sToRender; | |
| 182 | - } | |
| 183 | - | |
| 184 | - function getEntries() { | |
| 185 | - global $default; | |
| 186 | - | |
| 187 | - $sql = $default->db; | |
| 188 | - $sQuery = "SELECT DISTINCT ST." . $this->sDisplayColumn . " AS display, ST." . $this->sValueColumn . " AS value FROM $this->sTableName AS ST ";/*wc*/ | |
| 189 | - if (isset($this->sFromClause)) { | |
| 190 | - $sQuery .= $this->sFromClause . " "; | |
| 191 | - } | |
| 192 | - if (isset($this->sWhereClause)) { | |
| 193 | - $sQuery .= "WHERE " . $this->sWhereClause . " "; | |
| 194 | - | |
| 195 | - } | |
| 196 | - | |
| 197 | - $sQuery .= "ORDER BY ST.$this->sDisplayColumn " . ($this->bOrderAsc ? "ASC" : "DESC"); | |
| 198 | - | |
| 199 | - $sql->query($sQuery); | |
| 200 | - $aValues = array(); | |
| 201 | - while ($sql->next_record()) { | |
| 202 | - $aValues[] = array("value" => $sql->f("value"), | |
| 203 | - "display" => $sql->f("display")); | |
| 204 | - } | |
| 205 | - return $aValues; | |
| 206 | - } | |
| 207 | -} | |
| 208 | -?> |
lib/visualpatterns/PatternListFromQuery.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Takes a SQL query, an array of column names and and an array of column types | |
| 6 | - * and displays the data in a two column list format. | |
| 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 | - * @todo implement HyperLinkURL option | |
| 28 | - */ | |
| 29 | - | |
| 30 | -require_once(KT_LIB_DIR . '/templating/templating.inc.php'); | |
| 31 | - | |
| 32 | -class PatternListFromQuery { | |
| 33 | - | |
| 34 | - /** SQL query to execute */ | |
| 35 | - var $sQuery; | |
| 36 | - /** array of columns to display */ | |
| 37 | - var $aColumns; | |
| 38 | - /** array of column types (1 = text, 2 = boolean, 3 = hyperlink) */ | |
| 39 | - var $aColumnTypes; | |
| 40 | - /** names of columns to display */ | |
| 41 | - var $aColumnNames; | |
| 42 | - /** array of hyperlink URLS */ | |
| 43 | - var $aHyperLinkURL; | |
| 44 | - /** array of text to be used on querystring with a hyperlink */ | |
| 45 | - var $aQueryStringText; | |
| 46 | - /** number of rows for text area if text area option is being used */ | |
| 47 | - var $iTextAreaRows = 6; | |
| 48 | - /** number of colums for text area if text area option is being used */ | |
| 49 | - var $iTextAreaColums = 20; | |
| 50 | - /** heading for table */ | |
| 51 | - var $sTableHeading; | |
| 52 | - /** set the table width */ | |
| 53 | - var $iTableWidth = null; | |
| 54 | - /** Picture paths */ | |
| 55 | - var $sChkPicPath = "widgets/checked.gif"; | |
| 56 | - var $sUnChkPicPath = "widgets/unchecked.gif"; | |
| 57 | - /** message that will be displayed if the table is empty*/ | |
| 58 | - var $sEmptyTableMessage; | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * Default constructor | |
| 62 | - * | |
| 63 | - * @param String Query to execute | |
| 64 | - * @param | |
| 65 | - */ | |
| 66 | - function PatternListFromQuery($sNewQuery, $aNewColumns, $aNewColumnNames, $aNewColumnTypes, $aNewHyperLinkURL = null, $aNewQueryStringText = null) { | |
| 67 | - $this->sQuery = $sNewQuery; | |
| 68 | - $this->aColumns = $aNewColumns; | |
| 69 | - $this->aColumnNames = $aNewColumnNames; | |
| 70 | - $this->aColumnTypes = $aNewColumnTypes; | |
| 71 | - $this->aHyperLinkURL = $aNewHyperLinkURL; | |
| 72 | - $this->aQueryStringText = $aNewQueryStringText; | |
| 73 | - } | |
| 74 | - | |
| 75 | - function setTableWidth($iNewValue) { | |
| 76 | - $this->iTableWidth = $iNewValue; | |
| 77 | - } | |
| 78 | - | |
| 79 | - function setTextAreaRows($iNewValue) { | |
| 80 | - $this->iTextAreaRows = $iNewValue; | |
| 81 | - } | |
| 82 | - | |
| 83 | - function setTextAreaColumns($iNewValue) { | |
| 84 | - $this->iTextAreaColumns = $iNewValue; | |
| 85 | - } | |
| 86 | - | |
| 87 | - function setTableHeading($sNewValue) { | |
| 88 | - $this->sTableHeading = $sNewValue; | |
| 89 | - } | |
| 90 | - | |
| 91 | - function setRenderIndividualTableForEachResult($bNewValue) { | |
| 92 | - $this->bIndividualTableForEachResult = $bNewValue; | |
| 93 | - } | |
| 94 | - | |
| 95 | - function setEmptyTableMessage($sNewValue) { | |
| 96 | - $this->sEmptyTableMessage = $sNewValue; | |
| 97 | - } | |
| 98 | - | |
| 99 | - function & render() { | |
| 100 | - global $default; | |
| 101 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 102 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | |
| 103 | - | |
| 104 | - $aRows = DBUtil::getResultArray($this->sQuery); | |
| 105 | - $sToRender = ""; | |
| 106 | - $sToRender .= "<table border=\"0\" cellpadding=\"5\" " . (isset($this->iTableWidth) ? " width=\"$this->iTableWidth\"" : "") . " >\n"; | |
| 107 | - | |
| 108 | - if (isset($this->sTableHeading)) { | |
| 109 | - $sToRender .= "<caption align=\"top\" colspan=\"" . count($this->aColumns) . "\"><b>$this->sTableHeading</b></caption>\n"; | |
| 110 | - } | |
| 111 | - | |
| 112 | - if (count($aRows) == 0) { | |
| 113 | - $sToRender .= "<tr>\n"; | |
| 114 | - if (isset($this->sEmptyTableMessage)) { | |
| 115 | - $sToRender .= "<td colspan=" . count($this->aColumns) . ">$this->sEmptyTableMessage</td>\n"; | |
| 116 | - } else { | |
| 117 | - $sToRender .= "<td colspan=" . count($this->aColumns) . ">" . | |
| 118 | - sprintf(_("No %s data"), (isset($this->sTableHeading) ? "$this->sTableHeading" : "")) . | |
| 119 | - "</td>\n"; | |
| 120 | - } | |
| 121 | - $sToRender .= "</tr>\n"; | |
| 122 | - $sToRender .= "</table>\n"; | |
| 123 | - return $sToRender; | |
| 124 | - } | |
| 125 | - | |
| 126 | - $map = array(); | |
| 127 | - foreach ($this->aColumns as $sColumn) { | |
| 128 | - $map[$sColumn] = array(); | |
| 129 | - } | |
| 130 | - | |
| 131 | - $iColour = 0; | |
| 132 | - foreach ($aRows as $aRow) { | |
| 133 | - $i = 0; | |
| 134 | - foreach ($this->aColumns as $sColumn) { | |
| 135 | - switch ($this->aColumnTypes[$i]) { | |
| 136 | - //plain text field | |
| 137 | - case 1: | |
| 138 | - $value = $aRow[$this->aColumns[$i]]; | |
| 139 | - break; | |
| 140 | - case 2: | |
| 141 | - $value = $aRow[$this->aColumns[$i]]; | |
| 142 | - if (!empty($value)) { | |
| 143 | - if ($value) { | |
| 144 | - $value = "<img src=\"$default->graphicsUrl/" . $this->sChkPicPath . "\">"; | |
| 145 | - } else { | |
| 146 | - $value = "<img src=\"$default->graphicsUrl/" . $this->sUnChkPicPath . "\">"; | |
| 147 | - } | |
| 148 | - $value .= " "; | |
| 149 | - } | |
| 150 | - break; | |
| 151 | - case 3: | |
| 152 | - $value = $aRow[$this->aColumns[$i]]; | |
| 153 | - $value = sprintf('<a href="%s?%s">%s</a>', | |
| 154 | - $this->aHyperLinkURL[$i], | |
| 155 | - $this->replaceValues($this->aQueryStringText[$i], ""), | |
| 156 | - $value); | |
| 157 | - break; | |
| 158 | - default: | |
| 159 | - break; | |
| 160 | - } | |
| 161 | - | |
| 162 | - $map[$sColumn][] = $value; | |
| 163 | - $i++; | |
| 164 | - } | |
| 165 | - } | |
| 166 | - $oTemplating =& KTTemplating::getSingleton(); | |
| 167 | - $oTemplate = $oTemplating->loadTemplate('ktcore/document_data'); | |
| 168 | - $aColumnNames = array(); | |
| 169 | - $iLen = count($this->aColumnNames); | |
| 170 | - for ($c = 0; $c < $iLen; $c++) { | |
| 171 | - $aColumnNames[$this->aColumns[$c]] = $this->aColumnNames[$c]; | |
| 172 | - } | |
| 173 | - $sToRender = $oTemplate->render(array( | |
| 174 | - 'map' => $map, | |
| 175 | - 'cnames' => $aColumnNames, | |
| 176 | - )); | |
| 177 | - return $sToRender; | |
| 178 | - } | |
| 179 | - | |
| 180 | - function replaceValues($sQueryStringText, $sql) { | |
| 181 | - return $sQueryStringText; | |
| 182 | - } | |
| 183 | -} | |
| 184 | -?> |
lib/visualpatterns/PatternMetaData.inc deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -require_once("PatternListBox.inc"); | |
| 4 | -require_once(KT_LIB_DIR . "/documentmanagement/MDTree.inc"); | |
| 5 | - | |
| 6 | -/** | |
| 7 | - * $Id$ | |
| 8 | - * | |
| 9 | - * Renders document field appropriately (as a listbox if required). | |
| 10 | - * | |
| 11 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 12 | - * | |
| 13 | - * This program is free software; you can redistribute it and/or modify | |
| 14 | - * it under the terms of the GNU General Public License as published by | |
| 15 | - * the Free Software Foundation; either version 2 of the License, or | |
| 16 | - * (at your option) any later version. | |
| 17 | - * | |
| 18 | - * This program is distributed in the hope that it will be useful, | |
| 19 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 21 | - * GNU General Public License for more details. | |
| 22 | - * | |
| 23 | - * You should have received a copy of the GNU General Public License | |
| 24 | - * along with this program; if not, write to the Free Software | |
| 25 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 26 | - * | |
| 27 | - * @version $Revision$ | |
| 28 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 29 | - * @package lib.visualpatterns | |
| 30 | - */ | |
| 31 | -class PatternMetaData { | |
| 32 | - | |
| 33 | - var $sMetaDataField; | |
| 34 | - var $sFormName; | |
| 35 | - var $sValue; | |
| 36 | - /** 1 = drop down, 2 = text field */ | |
| 37 | - var $iType; | |
| 38 | - | |
| 39 | - | |
| 40 | - function PatternMetaData($sNewMetaDataField, $sNewFormName, $sNewValue = null) { | |
| 41 | - $this->sMetaDataField = $sNewMetaDataField; | |
| 42 | - $this->sFormName = $sNewFormName; | |
| 43 | - $this->sValue = $sNewValue; | |
| 44 | - } | |
| 45 | - | |
| 46 | - | |
| 47 | - function render() { | |
| 48 | - global $default; | |
| 49 | - $sQuery = "SELECT has_lookup, data_type, has_lookuptree, id FROM $default->document_fields_table WHERE name LIKE '" . DBUtil::escapeSimple($this->sMetaDataField) . "'";/*ok*/ | |
| 50 | - | |
| 51 | - $sql = $default->db; | |
| 52 | - $sql->query($sQuery); | |
| 53 | - if ($sql->next_record()) { | |
| 54 | - if ($sql->f("has_lookup") and (!$sql->f("has_lookuptree"))) { | |
| 55 | - //is a lookup, so display a drop down list | |
| 56 | - $sWhereClause = "DF.name LIKE '" . $this->sMetaDataField . "'"; | |
| 57 | - $sFromClause = "INNER JOIN $default->document_fields_table AS DF ON ST.document_field_id = DF.id"; | |
| 58 | - $oPatternListBox = & new PatternListBox("$default->metadata_table", "name", "name", $this->sFormName); | |
| 59 | - if ($this->sValue != null) { | |
| 60 | - $oPatternListBox->setSelectedValue($this->sValue); | |
| 61 | - } | |
| 62 | - $oPatternListBox->setFromClause($sFromClause); | |
| 63 | - $oPatternListBox->setWhereClause($sWhereClause); | |
| 64 | - return $oPatternListBox->render(); | |
| 65 | - } else if ($sql->f("has_lookup") and ($sql->f("has_lookuptree"))) { | |
| 66 | - $fieldTree = new MDTree(); | |
| 67 | - $fieldTree->buildForField($sql->f("id")); | |
| 68 | - $fieldTree->setActiveItem($this->sValue); | |
| 69 | - return $fieldTree->_evilTreeRenderer($fieldTree, $this->sFormName); | |
| 70 | - } else { | |
| 71 | - $textboxlength = null; | |
| 72 | - switch($sql->f("data_type")) { | |
| 73 | - case "TEXT": | |
| 74 | - $sToRender = '<textarea name="%s" rows="5" cols="44">%s</textarea>'; | |
| 75 | - break; | |
| 76 | - case "INT": | |
| 77 | - case "FLOAT": | |
| 78 | - $sToRender = '<input type="text" size="30" name="%s" value="%s" />'; | |
| 79 | - break; | |
| 80 | - case "STRING": | |
| 81 | - default: | |
| 82 | - $sToRender = '<input type="text" size="60" name="%s" value="%s" />'; | |
| 83 | - } | |
| 84 | - return sprintf($sToRender, $this->sFormName, $this->sValue); | |
| 85 | - } | |
| 86 | - } else { | |
| 87 | - return "Error in PatternMetaData"; | |
| 88 | - } | |
| 89 | - } | |
| 90 | - | |
| 91 | -} | |
| 92 | - | |
| 93 | -?> |
lib/visualpatterns/PatternTableGeneric.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * $BasedOnId: PatternTableSqlQuery.inc,v 1.39 2003/09/09 09:20:36 michael Exp $ | |
| 5 | - * | |
| 6 | - * Renders an iterable result set in a table. | |
| 7 | - * | |
| 8 | - * The first column in the table can be rendered as a link | |
| 9 | - * to the document/folder using the $iLinkType variable to specify the link type, | |
| 10 | - * the $sLinkPageURL to specify the page URL to link to and $sLinkImageURL to specify | |
| 11 | - * the image to display in the case of either a $iLinkType of 2 (image only) or 3 (image + text) | |
| 12 | - * | |
| 13 | - * If you wish to include images, there are two ways to do this | |
| 14 | - * o set the image url - this means that all rows will use the same image | |
| 15 | - * o set $bUseImageURLFromQuery to true - this will look for a column entitled image_url in | |
| 16 | - * the sql result set, allowing you to specify different images for each entry | |
| 17 | - * | |
| 18 | - * Copyright (c) 2004 Jam Warehouse http://www.jamwarehouse.com | |
| 19 | - * | |
| 20 | - * This program is free software; you can redistribute it and/or modify | |
| 21 | - * it under the terms of the GNU General Public License as published by | |
| 22 | - * the Free Software Foundation; either version 2 of the License, or | |
| 23 | - * (at your option) any later version. | |
| 24 | - * | |
| 25 | - * This program is distributed in the hope that it will be useful, | |
| 26 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 27 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 28 | - * GNU General Public License for more details. | |
| 29 | - * | |
| 30 | - * You should have received a copy of the GNU General Public License | |
| 31 | - * along with this program; if not, write to the Free Software | |
| 32 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 33 | - * | |
| 34 | - * @version $Revision$ | |
| 35 | - * @author Neil Blakey-Milner, Jam Warehouse (Pty) Ltd, South Africa | |
| 36 | - * @package lib.visualpatterns | |
| 37 | - * @todo $iLinkImageURL is hard coded - change | |
| 38 | - * @todo $sLinkPageURL is hard coded - change | |
| 39 | - */ | |
| 40 | -class PatternTableGeneric { | |
| 41 | - /** query to execute*/ | |
| 42 | - var $oResultSet; | |
| 43 | - /* Columns in table to query (ID is included by default) */ | |
| 44 | - var $aColumns; | |
| 45 | - /* Column types. Possibles are 1 = text, 2 = boolean, 3 = hyperlink url */ | |
| 46 | - var $aColumnTypes; | |
| 47 | - /** header names to display */ | |
| 48 | - var $aColumnHeaderNames; | |
| 49 | - /** table width, either in pixels or as a percentage e.g. 600 or 100%*/ | |
| 50 | - var $sWidth; | |
| 51 | - /** link url used if a column type of 3 is specified */ | |
| 52 | - var $aLinkURLs; | |
| 53 | - /** database column values to append to link url if a column type of 3 is specified */ | |
| 54 | - var $aDBQueryStringColumns; | |
| 55 | - /** variables names to give $aDBQueryStringColumns on the query string */ | |
| 56 | - var $aQueryStringVariableNames; | |
| 57 | - /** display the column headings or not */ | |
| 58 | - var $bDisplayColumnHeadings; | |
| 59 | - /** table heading */ | |
| 60 | - var $sTableHeading; | |
| 61 | - /** specify an image at the start of each row in the table */ | |
| 62 | - var $sImageURL; | |
| 63 | - /** specify whether to use $sImageURL or to get the image url from the sql result set */ | |
| 64 | - var $bUseImageURLFromQuery = false; | |
| 65 | - /** message that will be displayed if the table is empty*/ | |
| 66 | - var $sEmptyTableMessage; | |
| 67 | - /** Picture paths */ | |
| 68 | - var $sChkPicPath = "widgets/checked.gif"; | |
| 69 | - var $sUnChkPicPath = "widgets/unchecked.gif"; | |
| 70 | - /** whether to force entries to wrap */ | |
| 71 | - var $bWordWrap = false; | |
| 72 | - /** whether the table cannot be edited */ | |
| 73 | - var $bDisabled = false; | |
| 74 | - | |
| 75 | - function PatternTableGeneric($oResultSet, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaderNames, $sTmpWidth, $aTmpLinkURLs = null, $aTmpDBQueryStringColumns = null, $aNewQueryStringVariableNames = null) { | |
| 76 | - $this->oResultSet =& $oResultSet; | |
| 77 | - $this->aColumns = & $aTmpColumns; | |
| 78 | - $this->aColumnTypes = $aTmpColumnTypes; | |
| 79 | - $this->aColumnHeaderNames = $aTmpColumnHeaderNames; | |
| 80 | - $this->sWidth = $sTmpWidth; | |
| 81 | - $this->bDisplayColumnHeadings = $bTmpDisplayColumnHeadings; | |
| 82 | - $this->aLinkURLs = $aTmpLinkURLs; | |
| 83 | - $this->aDBQueryStringColumns = $aTmpDBQueryStringColumns; | |
| 84 | - $this->aQueryStringVariableNames = $aNewQueryStringVariableNames; | |
| 85 | - } | |
| 86 | - | |
| 87 | - function setEmptyTableMessage($sNewValue) { $this->sEmptyTableMessage = $sNewValue; } | |
| 88 | - function setTableHeading($sNewValue) { $this->sTableHeading = $sNewValue; } | |
| 89 | - function setImageURL($sNewValue) { $this->sImageURL = $sNewValue; } | |
| 90 | - function setUseImageURLFromQuery($bNewValue) { $this->bUseImageURLFromQuery = $bNewValue; } | |
| 91 | - function setDisplayColumnHeadings($bNewValue) { $this->bDisplayColumnHeadings = $bNewValue; } | |
| 92 | - function setIncludeBorder($bNewValue) { $this->bIncludeBorder = $bNewValue; } | |
| 93 | - function setChkPicPath($sNewChkPicPath) { $this->sChkPicPath = $sNewChkPicPath; } | |
| 94 | - function getChkPicPath() { return $this->sChkPicPath ; } | |
| 95 | - function setWordWrap($bNewValue) { $this->bWordWrap = $bNewValue; } | |
| 96 | - function setDisabled($bNewValue) { $this->bDisabled = $bNewValue; } | |
| 97 | - | |
| 98 | - /** | |
| 99 | - * Build the HTML string used to render the object | |
| 100 | - * | |
| 101 | - * @return String of HTML used to render object | |
| 102 | - * | |
| 103 | - * @todo possibly add in image size restraints for link types 2 and 3 | |
| 104 | - */ | |
| 105 | - function & render() { | |
| 106 | - global $default; | |
| 107 | - | |
| 108 | - $sToRender = "<table cellpadding=\"5\" border=\"" . ($this->bIncludeBorder ? "1" : "0") . "\" width=\"" . $this->sWidth . "\">\n"; | |
| 109 | - if (isset($this->sTableHeading)) { | |
| 110 | - $sToRender .= "<caption align=\"top\" colspan=\"" . count($this->aColumns) . "\" align=\"left\"><b>$this->sTableHeading</b></caption>\n"; | |
| 111 | - } | |
| 112 | - if ($this->bDisplayColumnHeadings) { | |
| 113 | - for ($i = 0; $i < count($this->aColumnHeaderNames); $i++) { | |
| 114 | - $sToRender .= "<th align=left>" . $this->aColumnHeaderNames[$i] . "</th>\n"; | |
| 115 | - } | |
| 116 | - } | |
| 117 | - # $sql->query($this->sQuery); | |
| 118 | - $oResultSet =& $this->oResultSet; | |
| 119 | - if ($oResultSet->isEmpty()) { | |
| 120 | - $sToRender .= "<tr>\n"; | |
| 121 | - if (isset($this->sEmptyTableMessage)) { | |
| 122 | - $sToRender .= "<td colspan=" . count($this->aColumns) . ">$this->sEmptyTableMessage</td>\n"; | |
| 123 | - } else { | |
| 124 | - $sToRender .= "<td colspan=" . count($this->aColumns) . ">" . | |
| 125 | - sprintf(_("No %s data admin"), (isset($this->sTableHeading) ? $this->sTableHeading : "")) . | |
| 126 | - "</td>\n"; | |
| 127 | - } | |
| 128 | - $sToRender .= "</tr>\n"; | |
| 129 | - } else { | |
| 130 | - $iColour = 0; | |
| 131 | - while ($oResult = $oResultSet->next()) { | |
| 132 | - $sToRender .= "<tr bgcolor=\"" . getColour($iColour) . "\">\n"; | |
| 133 | - $iColour++; | |
| 134 | - for ($i = 0; $i < count($this->aColumns); $i++) { | |
| 135 | - switch ($this->aColumnTypes[$i]) { | |
| 136 | - case 1: | |
| 137 | - //text | |
| 138 | - $sToRender .= "<td>"; | |
| 139 | - if (isset($this->sImageURL)) { | |
| 140 | - $sToRender .= $this->generateImageURL($this->sImageURL); | |
| 141 | - } else if ($this->bUseImageURLFromQuery) { | |
| 142 | - $sToRender .= $this->generateImageURL($oResult->get("image_url")); | |
| 143 | - } | |
| 144 | - if ($oResult->get($this->aColumns[$i]) != null) { | |
| 145 | - if ($this->bWordWrap) { | |
| 146 | - $sToRender .= wordwrap($oResult->get($this->aColumns[$i]), 25, " ", 1) . "</td>"; | |
| 147 | - } else { | |
| 148 | - $sToRender .= $oResult->get($this->aColumns[$i]) . "</td>"; | |
| 149 | - } | |
| 150 | - } else { | |
| 151 | - $sToRender .= " </td>"; | |
| 152 | - } | |
| 153 | - break; | |
| 154 | - case 2: | |
| 155 | - //boolean | |
| 156 | - $sToRender .= "<td>"; | |
| 157 | - if ($oResult->get($this->aColumns[$i]) != null) { | |
| 158 | - $value = $oResult->get($this->aColumns[$i]); | |
| 159 | - if ($value) { | |
| 160 | - $sToRender .= "<img src=\"$default->graphicsUrl/" . $this->sChkPicPath . "\">"; | |
| 161 | - } else { | |
| 162 | - $sToRender .= "<img src=\"$default->graphicsUrl/" . $this->sUnChkPicPath . "\">"; | |
| 163 | - } | |
| 164 | - $sToRender .= " </td>"; | |
| 165 | - } else { | |
| 166 | - $sToRender .= " </td>"; | |
| 167 | - } | |
| 168 | - | |
| 169 | - break; | |
| 170 | - case 3: | |
| 171 | - if ($this->bDisabled === true) { | |
| 172 | - $sToRender .= '<td><span style="background-color: #CCCCCC; color: #222222;">'; | |
| 173 | - $sToRender .= $oResult->get($this->aColumns[$i]); | |
| 174 | - $sToRender .= '</span></td>'; | |
| 175 | - $sToRender .= "\n"; | |
| 176 | - break; | |
| 177 | - } | |
| 178 | - //hyperlink | |
| 179 | - $sToRender .= "<td><a href=\""; | |
| 180 | - $sLink = $this->aLinkURLs[$i]; | |
| 181 | - for ($j = 0; $j < count($this->aDBQueryStringColumns); $j++) { | |
| 182 | - if (strpos($sLink, "?") === false) { | |
| 183 | - $sLink .= "?" . $this->aQueryStringVariableNames[$j] . "=" . $oResult->get($this->aDBQueryStringColumns[$j]); | |
| 184 | - } else { | |
| 185 | - $sLink .= "&" . $this->aQueryStringVariableNames[$j] . "=" . $oResult->get($this->aDBQueryStringColumns[$j]); | |
| 186 | - } | |
| 187 | - } | |
| 188 | - $sToRender .= $sLink . "\">"; | |
| 189 | - | |
| 190 | - if (isset($this->sImageURL)) { | |
| 191 | - $sToRender .= $this->generateImageURL($this->sImageURL); | |
| 192 | - } else if ($this->bUseImageURLFromQuery) { | |
| 193 | - $sToRender .= $this->generateImageURL($oResult->get("image_url")); | |
| 194 | - } | |
| 195 | - $sToRender .= $oResult->get($this->aColumns[$i]) . "</a></td>\n"; | |
| 196 | - break; | |
| 197 | - default: | |
| 198 | - break; | |
| 199 | - } | |
| 200 | - } | |
| 201 | - $sToRender .= "</tr>\n"; | |
| 202 | - } | |
| 203 | - } | |
| 204 | - $sToRender .= "</table>"; | |
| 205 | - return $sToRender; | |
| 206 | - } | |
| 207 | - | |
| 208 | - function generateImageURL($sURL) { | |
| 209 | - return "<img src=\"" . $sURL . "\" border=\"0\"/>"; | |
| 210 | - } | |
| 211 | -} | |
| 212 | -?> |
lib/visualpatterns/PatternTableSqlQuery.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Renders query results in a table. | |
| 6 | - * | |
| 7 | - * The first column in the table can be rendered as a link | |
| 8 | - * to the document/folder using the $iLinkType variable to specify the link type, | |
| 9 | - * the $sLinkPageURL to specify the page URL to link to and $sLinkImageURL to specify | |
| 10 | - * the image to display in the case of either a $iLinkType of 2 (image only) or 3 (image + text) | |
| 11 | - * | |
| 12 | - * If you wish to include images, there are two ways to do this | |
| 13 | - * o set the image url - this means that all rows will use the same image | |
| 14 | - * o set $bUseImageURLFromQuery to true - this will look for a column entitled image_url in | |
| 15 | - * the sql result set, allowing you to specify different images for each entry | |
| 16 | - * | |
| 17 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 18 | - * | |
| 19 | - * This program is free software; you can redistribute it and/or modify | |
| 20 | - * it under the terms of the GNU General Public License as published by | |
| 21 | - * the Free Software Foundation; either version 2 of the License, or | |
| 22 | - * (at your option) any later version. | |
| 23 | - * | |
| 24 | - * This program is distributed in the hope that it will be useful, | |
| 25 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 26 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 27 | - * GNU General Public License for more details. | |
| 28 | - * | |
| 29 | - * You should have received a copy of the GNU General Public License | |
| 30 | - * along with this program; if not, write to the Free Software | |
| 31 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 32 | - * | |
| 33 | - * @version $Revision$ | |
| 34 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 35 | - * @package lib.visualpatterns | |
| 36 | - * @todo $iLinkImageURL is hard coded - change | |
| 37 | - * @todo $sLinkPageURL is hard coded - change | |
| 38 | - */ | |
| 39 | - | |
| 40 | -require_once('PatternTableGeneric.inc'); | |
| 41 | - | |
| 42 | -class SqlResultSetAdapter { | |
| 43 | - // Has there been an error setting up the result set? | |
| 44 | - var $broken = false; | |
| 45 | - | |
| 46 | - function SqlResultSetAdapter ($oResultSet) { | |
| 47 | - global $default; | |
| 48 | - $this->oResultSet = $oResultSet; | |
| 49 | - if (PEAR::isError($oResultSet)) { | |
| 50 | - $this->broken = true; | |
| 51 | - } | |
| 52 | - } | |
| 53 | - | |
| 54 | - function isEmpty () { | |
| 55 | - global $default; | |
| 56 | - if ($this->broken) { | |
| 57 | - return $this->oResultSet; | |
| 58 | - } | |
| 59 | - return ($this->oResultSet->numRows() == 0); | |
| 60 | - } | |
| 61 | - | |
| 62 | - function next () { | |
| 63 | - global $default; | |
| 64 | - if ($this->broken) { | |
| 65 | - return $this->oResultSet; | |
| 66 | - } | |
| 67 | - $aNextResult = $this->oResultSet->fetchRow(DB_FETCHMODE_ASSOC); | |
| 68 | - if ($aNextResult === null) { | |
| 69 | - return null; | |
| 70 | - } | |
| 71 | - return new SqlResultAdapter ($aNextResult); | |
| 72 | - } | |
| 73 | -} | |
| 74 | - | |
| 75 | -class SqlResultAdapter { | |
| 76 | - function SqlResultAdapter ($oResult) { | |
| 77 | - $this->oResult = $oResult; | |
| 78 | - } | |
| 79 | - function get ($sField) { | |
| 80 | - global $default; | |
| 81 | - return $this->oResult[$sField]; | |
| 82 | - } | |
| 83 | -} | |
| 84 | - | |
| 85 | -class PatternTableSqlQuery extends PatternTableGeneric { | |
| 86 | - function PatternTableSqlQuery($sTmpQuery, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaderNames, $sTmpWidth, $aTmpLinkURLs = null, $aTmpDBQueryStringColumns = null, $aNewQueryStringVariableNames = null) { | |
| 87 | - $oResult = DBUtil::runQuery($sTmpQuery); | |
| 88 | - $oResultSet =& new SqlResultSetAdapter ($oResult); | |
| 89 | - $this->PatternTableGeneric($oResultSet, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaderNames, $sTmpWidth, $aTmpLinkURLs, $aTmpDBQueryStringColumns, $aNewQueryStringVariableNames); | |
| 90 | - } | |
| 91 | -} | |
| 92 | - | |
| 93 | -?> |