diff --git a/lib/visualpatterns/PatternBrowsableSearchResults.inc b/lib/visualpatterns/PatternBrowsableSearchResults.inc deleted file mode 100644 index 07208b1..0000000 --- a/lib/visualpatterns/PatternBrowsableSearchResults.inc +++ /dev/null @@ -1,276 +0,0 @@ -sQuery = $sTmpQuery; - $this->iResultsToDisplay = $iTmpResultsToDisplay; - $this->aColumns = $aTmpColumns; - $this->aColumnHeadings = $aTmpColumnHeaders; - $this->aColumnTypes = $aTmpColumnTypes; - $this->aLinkURLs = $aTmpLinkURLs; - $this->aDBQueryStringColumns = $aTmpDBQueryStringColumns; - $this->aQueryStringVariableNames = $aTmpQueryStringVariableNames; - $this->sQueryString = ""; - $this->aRememberValues = array(); - } - - function setQueryString($sNewQueryString) { - $this->sQueryString = $sNewQueryString; - } - - function getQueryString() { - return $this->sOrderByColumn; - } - - function setStartIndex($iNewValue) { - $this->iStartIndex = $iNewValue; - } - - function setOrderByColumn($sNewValue) { - $this->sOrderByColumn = $sNewValue; - } - - function setOrderDirection($sNewValue) { - $this->sOrderDirection = $sNewValue; - } - function setSearchText($sNewValue) { - $this->sSearchText = $sNewValue; - } - - function setRememberValues($aRemember) { - $this->aRememberValues = $aRemember; - } - - /** - * Build the HTML string used to render the object - * - * @return String of HTML used to render object - * - * @todo possibly add in image size restraints for link types 2 and 3 - */ - function & render() { - global $default; - - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTHBGColour = $default->siteMap->getSectionColour($sSectionName, "th"); - - // run the query first and get the number of rows - $iTotalResults = $this->getResultCount(); - - // now add the limit and offset stuff for cutting down result set - // decrement startIndex because LIMIT starts at zero and startIndex starts at 1 (for display purposes) - if (is_array($this->sQuery)) { - $sQuery = $this->sQuery[0]; - $aParams = $this->sQuery[1]; - } else { - $sQuery = $this->sQuery; - $aParams = array(); - } - $sQuery = $sQuery . " LIMIT ?, ?"; - $aParams[] = $this->iStartIndex - 1; - $aParams[] = $this->iResultsToDisplay; - - $oResult = DBUtil::runQuery(array($sQuery, $aParams)); - if (PEAR::isError($oResult)) { - $GLOBALS['default']->log->error('PatternBrowsableSearchResults: query returned error: ' . $oResult->getMessage()); - return $oResult; - } - $oResultSet = new SqlResultSetAdapter($oResult); - - if ($oResultSet->isEmpty()) { - //no results - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "

" . _("No results matched your criteria") . "

\n"; - } else { - - $sToRender .= "\n"; - - // display the number of results - $iEndIndex = $this->iStartIndex+$this->iResultsToDisplay-1 < $iTotalResults ? $this->iStartIndex+$this->iResultsToDisplay-1 : $iTotalResults; - - if ($this->sSearchText) { - $sToRender .= ""; - } - - $sToRender .= "\n"; - - $sToRender .= "\n"; - for ($i = 0; $i < count($this->aColumnHeadings); $i++) { - if (! (strcmp($this->sOrderByColumn, $this->aColumns[$i]) === false) && (strcmp($this->sOrderByColumn, $this->aColumns[$i]) == 0)) { - if (!(strcmp($this->sOrderDirection,"ASC") === false) && (strcmp($this->sOrderDirection,"ASC") == 0)) { - $sToRender .= "\n"; - } else { - $sToRender .= "\n"; - } - } else { - $sToRender .= "\n"; - } - } - $sToRender .= "\n"; - $iColour = 0; - $iDisplayed = 0; - - //limit the result set displayed - while($oRow = $oResultSet->next()) { - $sToRender .= ""; - $iColour++; $iDisplayed++; - - for ($i = 0; $i < count($this->aColumns); $i++) { - switch ($this->aColumnTypes[$i]) { - case 1: - //display text - $sToRender .= "\n"; - break; - case 2: - //display a checkbox - $sToRender .= "\n"; - break; - case 3: - //display a url - $sToRender .= "\n"; - - break; - case 4: - //diplay an image URL - $sToRender .= "\n"; - break; - default: - break; - } - } - $sToRender .= "\n"; - } - - //if we displayed less results than the number to display - //simply pad the table - while ($iDisplayed < $this->iResultsToDisplay) { - $sToRender .= "\n"; - $iDisplayed++; - } - $sToRender .= "
" . sprintf(_("Searched the KnowledgeTree for '%s'."), $this->sSearchText) . "
" . sprintf(_("Displaying results %s - %s of %s"), $this->iStartIndex, $iEndIndex, $iTotalResults) . "
" . $this->aColumnHeadings[$i]. "" . $this->aColumnHeadings[$i]. "" . $this->aColumnHeadings[$i]. "
" . $oRow->get($this->aColumns[$i]) . "" . ($oRow->get($this->aColumns[$i]) ? "Yes" : "No") . "aLinkURLs[$i]; - for ($j = 0; $j < count($this->aDBQueryStringColumns); $j++) { - if (strpos($sURLplusQuery, "?") === false) { - $sURLplusQuery .= "?" . $this->aQueryStringVariableNames[$j] . "=" . $oRow->get($this->aDBQueryStringColumns[$j]); - } else { - $sURLplusQuery .= "&" . $this->aQueryStringVariableNames[$j] . "=" . $oRow->get($this->aDBQueryStringColumns[$j]); - } - } - $sToRender .= $sURLplusQuery; - $sToRender .= "\">" . $oRow->get($this->aColumns[$i]) . "aLinkURLs[$i]; - for ($j = 0; $j < count($this->aDBQueryStringColumns); $j++) { - if (strpos($sToRender, "?") === false) { - $sToRender .= "?" . $this->aQueryStringVariableNames[$j] . "=" . $oRow->get($this->aDBQueryStringColumns[$j]); - } else { - $sToRender .= "&" . $this->aQueryStringVariableNames[$j] . "=" . $oRow->get($this->aDBQueryStringColumns[$j]); - } - } - $sToRender .= "\">get($this->aColumns[$i]) . "\" border=\"0\" />
 
"; - - $sToRender .= ""; - $sToRender .= "\n"; - foreach ($this->aRememberValues as $k => $v) { - $v = htmlentities(urlencode($v)); - $sToRender .= "\n"; - } - // Display only the next button - if (($this->iStartIndex + $this->iResultsToDisplay - 1) < $iTotalResults && $this->iStartIndex == 1) { - $sToRender .= ""; - $sToRender .= "\n"; - } - // Display both the next and the previous buttons - else if (($this->iStartIndex + $this->iResultsToDisplay - 1) < $iTotalResults && $this->iStartIndex > 1) { - $sToRender .= ""; - $sToRender .= "\n"; - - } - // Display only the previous button - else if ($this->iStartIndex > 1) { - $sToRender .= ""; - } - - $sToRender .= "\n"; - $sToRender .= "
             "; - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= "\n"; - $sToRender .= ""; - $sToRender .= "
\n"; - } - return $sToRender; - } - - function getResultCount() { - global $default; - $sql = & $default->db; - if ($sql->query($this->sQuery)) { - return $sql->num_rows(); - } else { - return 0; - } - } -} -?> diff --git a/lib/visualpatterns/PatternCustom.inc b/lib/visualpatterns/PatternCustom.inc deleted file mode 100644 index 3633389..0000000 --- a/lib/visualpatterns/PatternCustom.inc +++ /dev/null @@ -1,59 +0,0 @@ -sHtml = $sNewValue; - } - - /** - * Appends to the html string - * - * @param string the html to append - */ - function addHtml($sMoreHtml) { - $this->sHtml = $this->sHtml . $sMoreHtml; - } - - /** - * Render the object - * - * @return string html string - */ - function & render() { - return $this->sHtml; - } -} -?> diff --git a/lib/visualpatterns/PatternEditableTableSqlQuery.inc b/lib/visualpatterns/PatternEditableTableSqlQuery.inc deleted file mode 100644 index 81d7ff6..0000000 --- a/lib/visualpatterns/PatternEditableTableSqlQuery.inc +++ /dev/null @@ -1,254 +0,0 @@ -_id: holds the primary key of the entry in the table (-1 = no entry in table i.e. create not update) - * o _tn: holds the tablename for which the primary key is valid - * o _type: holds the type of entry (text/boolean/list) - for parsing purposes - * - * The actual value is held in a form field name - * - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @version $Revision$ - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa - * @package lib.visualpatterns - * @todo - add client side validation stuff - * @todo - add column type 3 -> select field stuff - */ -class PatternEditableTableSqlQuery { - - /** query to execute*/ - var $sQuery; - /** table to perform insert/update on */ - var $sTableName; - /** columns names in $sQuery to display */ - var $aDisplayColumnNames; - /** column names in $sQuery that will be stored/updated */ - var $aStoreColumnNames; - /** Array of boolean values dictating column editability */ - var $aColumnsEditable; - /** columns visible or not (store columns) */ - var $aColumnsVisible; - /** column types: 1 = text, 2 = boolean, 3 = drop down list, 4 = meta data lookup */ - var $aColumnDisplayTypes; - /** 0 = id, 1 = text, 2 = boolean*/ - var $aColumnDatabaseTypes; - /** Unique name */ - var $sUniqueName; - /** message that will be displayed if the table is empty*/ - var $sEmptyTableMessage; - /** whether or not to include javascript validation rendering automatically */ - var $bRenderJavascriptValidation = true; - /** temporary array holding the required fields */ - var $aRequiredVariables; - - var $aRequiredColumnNames; - var $aRequiredFieldNames; - var $aMetaDataFields; - - var $sPreCode; - - function PatternEditableTableSqlQuery($sTmpQuery, $sTmpTableName, $aTmpStoreColumnNames, $aTmpDisplayColumnNames, $aTmpColumnsEditable, $aTmpColumnsVisible, $aTmpColumnDisplayTypes, $aTmpColumnDatabaseTypes) { - $this->sQuery = $sTmpQuery; - $this->sTableName = $sTmpTableName; - $this->aStoreColumnNames = $aTmpStoreColumnNames; - $this->aDisplayColumnNames = $aTmpDisplayColumnNames; - $this->aColumnsEditable = $aTmpColumnsEditable; - $this->sUniqueName = $sTmpUniqueName; - $this->aColumnsVisible = $aTmpColumnsVisible; - $this->aColumnDisplayTypes = $aTmpColumnDisplayTypes; - $this->aColumnDatabaseTypes = $aTmpColumnDatabaseTypes; - } - - function setUniqueName($sNewValue) { $this->sUniqueName = $sNewValue; } - function setMetaDataFields($aNewValue) { $this->aMetaDataFields = $aNewValue; } - function setDisplayColumnHeadings($bNewValue) { $this->bDisplayColumnHeadings = $bNewValue; } - function setTableCaption($sNewValue) { $this->sTableCaption = $sNewValue; } - function setColumnHeaderNames($aNewValue) { $this->aColumnHeaderNames = $aNewValue; } - function setRequiredColumnNames($aNewValue) { $this->aRequiredColumnNames = $aNewValue; } - function setEmptyTableMessage($sNewValue) { $this->sEmptyTableMessage = $sNewValue; } - function setRenderJavascriptValidation($bNewValue) { $this->bRenderJavascriptValidation = $bNewValue; } - function setPreCode($sNewValue) { $this->sPreCode = $sNewValue; } - function setPostCode($sNewValue) { $this->sPostCode = $sNewValue; } - - function & render() { - global $default; - - $sToRender = "\n"; - if (isset($this->sTableCaption)) { - $sToRender .= "\n"; - } - if ($this->bDisplayColumnHeadings) { - for ($i = 0; $i < count($this->aColumnHeaderNames); $i++) { - $sToRender .= "\n"; - } - } - - $this->sUniqueName .= KTUtil::randomString(); - - $sql = $default->db; - $sql->query($this->sQuery); - if ($sql->num_rows() == 0) { - $sToRender .= "\n"; - if (isset($this->sEmptyTableMessage)) { - $sToRender .= "\n"; - } else { - $sToRender .= "\n"; - } - $sToRender .= "\n"; - } else { - $this->aRequiredVariables = array(); - $iRowCount = 0; - while ($sql->next_record()) { - $sToRender .= "\n"; - $_SESSION["pelfq_" . $this->sUniqueName . $iRowCount . "_id"] = $sql->f("id"); - $_SESSION["pelfq_" . $this->sUniqueName . $iRowCount . "_code_pre"] = $this->sPreCode; - $_SESSION["pelfq_" . $this->sUniqueName . $iRowCount . "_code_post"] = $this->sPostCode; - $_SESSION["pelfq_" . $this->sUniqueName . $iRowCount . "_tn"] = $this->sTableName; - $_SESSION["pelfq_" . $this->sUniqueName . $iRowCount . "_columns"] = $this->aStoreColumnNames; - $sToRender .= "sUniqueName . $iRowCount . "\" value=\"\" />\n"; - // $sToRender .= "sUniqueName . "_" . $iRowCount . "\" value=\"" . $sql->f("id") . "\" />\n"; - // $sToRender .= "sUniqueName . "_" . $iRowCount . "_tn\" value=\"" . $this->sTableName . "\" />\n"; - - // check for is_mandatory field validation - if ($sql->f("is_mandatory") == "1") { - $this->aRequiredVariables[]["formName"] = $this->sUniqueName . "_" . $iRowCount . (count($this->aStoreColumnNames)-1) . "_value"; - } - for ($i = 0; $i < count($this->aStoreColumnNames); $i++) { - if (isset($this->aRequiredColumnNames)) { - for ($k = 0; $k < count($this->aRequiredColumnNames); $k++) { - if (strcmp($this->aStoreColumnNames[$i], $this->aRequiredColumnNames[$k]) == 0) { - $this->aRequiredVariables[count($this->aRequiredVariables)]["formName"] = $this->sUniqueName . "_" . $iRowCount . $i . "_value"; - } - } - } - - //generate the right kind of editable field - $sToRender .= "\t\n"; - } - $sToRender .= "sUniqueName . $iRowCount . "\" value=\"\" />\n"; - $sToRender .= "\n"; - $iRowCount++; - } - } - $sToRender .= "
aColumnsSql) . "\" align=\"left\">$this->sTableCaption
" . $this->aColumnHeaderNames[$i] . "
$this->sEmptyTableMessage" . - sprintf(_("No %s data"), (isset($this->sTableCaption) ? $this->sTableCaption : "")) . - "
\n"; - switch ($this->aColumnDisplayTypes[$i]) { - case 1: - //output the table column name - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_tc\" value=\"" . $this->aStoreColumnNames[$i] . "\" />\n"; - //output the column type - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_type\" value=\"" . $this->aColumnDatabaseTypes[$i] . "\" />\n"; - //output the value - if ($this->aColumnsVisible[$i]) { - if ($this->aColumnsEditable[$i]) { - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />\n"; - } else { - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />" . $sql->f($this->aDisplayColumnNames[$i])."\n"; - } - } else { - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />\n"; - } - break; - case 2: - //output the table column name - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_tc\" value=\"" . $this->aStoreColumnNames[$i] . "\" />\n"; - //output the column type - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_type\" value=\"" . $this->aColumnDatabaseTypes[$i] . "\" />\n"; - //output the value - if ($this->aColumnsVisible[$i]) { - if ($this->aColumnsEditable[$i]) { - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . ($sql->f($this->aStoreColumnNames[$i] ? "1\" checked" : "0\"")) . " />\n"; - } else { - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />".$sql->f($this->aDisplayColumnNames[$i])."\n"; - } - } else { - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />\n"; - } - break; - case 3: - $sToRender .= "" . _("The column type for drop downs is not implemented yet") . "\n"; - break; - case 4: - //meta data - //could either be a drop down or a text field, depending - - //output the table column name - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_tc\" value=\"" . $this->aStoreColumnNames[$i] . "\" />\n"; - //output the column type - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_type\" value=\"" . $this->aColumnDatabaseTypes[$i] . "\" />\n"; - if ($this->aColumnsVisible[$i]) { - if ($this->aColumnsEditable[$i]) { - $oPattern = & new PatternMetaData($sql->f($this->aMetaDataFields[$i]), $this->sUniqueName . "_" . $iRowCount . $i . "_value", $sql->f($this->aStoreColumnNames[$i])); - $sToRender .= $oPattern->render(); - } else { - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />".$sql->f($this->aDisplayColumnNames[$i])."\n"; - } - } else { - $sToRender .= "\tsUniqueName . "_" . $iRowCount . $i . "_value\" value=\"" . $sql->f($this->aStoreColumnNames[$i]) . "\" />\n"; - } - break; - - break; - default: - $sToRender .= "" . - sprintf(_("You are attempting to render an unknown column type %s in PatternEditableTableSqlQuery"), - ($this->aColumnTypes[$i])) . - "\n"; - break; - } - - $sToRender .= "\t
"; - if (isset($this->aRequiredVariables)) { - if ($this->bRenderJavascriptValidation) { - $sToRender .= $this->generateRequiredFieldValidation($this->aRequiredVariables); - } - } - return $sToRender; - } - - function generateRequiredFieldValidation($aValidationColumnNames) { - $sToRender .= "\n\n\n\n"; - return $sToRender; - } - - function getValidationJavascript() { - for ($i = 0; $i < count($this->aRequiredVariables); $i++) { - $sToRender .= "\tif (!(validRequired(document.MainForm." . $this->aRequiredVariables[$i]["formName"] . ", 'selected'))) {\n"; - $sToRender .= "\t\treturn false;\n\t}\n"; - } - return $sToRender; - } -} -?> diff --git a/lib/visualpatterns/PatternListBox.inc b/lib/visualpatterns/PatternListBox.inc deleted file mode 100644 index c715d24..0000000 --- a/lib/visualpatterns/PatternListBox.inc +++ /dev/null @@ -1,208 +0,0 @@ -sTableName = $sNewTableName; - $this->sDisplayColumn = $sNewDisplayColumn; - $this->sValueColumn = $sNewValueColumn; - $this->sSelectName = $sNewSelectName; - $this->sWhereClause = $sNewWhereClause; - $this->bOrderAsc = $bNewOrderAsc; - } - - function setQuery($sQuery) { - $this->sQuery = $sQuery; - } - function setSelectName($sNewSelectName) { - $this->sSelectName = $sNewSelectName; - } - - function setPostBackOnChange($bNewValue) { - $this->bPostBackOnChange = $bNewValue; - } - - function setOnChangeAction($sNewValue) { - $this->sOnChangeAction = $sNewValue; - } - - function setSelectedValue($NewValue) { - $this->selectedValue = $NewValue; - } - - function setWhereClause($sNewValue) { - $this->sWhereClause = $sNewValue; - } - - function setFromClause($sNewValue) { - $this->sFromClause = $sNewValue; - } - - function setEmptyErrorMessage($sNewValue) { - $this->sEmptyErrorMessage = $sNewValue; - } - - function setIncludeDefaultValue($bNewValue) { - $this->bIncludeDefaultValue = $bNewValue; - } - - function setAdditionalEntries($aNewValue) { - $this->aAdditionalEntries = $aNewValue; - } - - function setCompositeDisplayName($sNewValue) { - $this->sCompositeDisplayColumnName = $sNewValue; - } - - /** - * Create the HTML string that will be used to render the list box - * - * @return String html used to render the list box - * - */ - function & render() { - global $default; - - $sql = $default->db; - if (isset($this->sQuery)) { - $sQuery = $this->sQuery; - } else { - $sQuery = "SELECT ";/*wc*/ - if (isset($this->sCompositeDisplayColumnName)) { - $sQuery .= "$this->sCompositeDisplayColumnName"; - } else { - $sQuery .= "DISTINCT ST." . $this->sDisplayColumn; - } - $sQuery .= " AS display, ST." . $this->sValueColumn . " AS value FROM $this->sTableName AS ST "; - if (isset($this->sFromClause)) { - $sQuery .= $this->sFromClause . " "; - } - if (isset($this->sWhereClause)) { - $sQuery .= "WHERE " . $this->sWhereClause . " "; - } - $sQuery .= "ORDER BY ST.$this->sDisplayColumn " . ($this->bOrderAsc ? "ASC" : "DESC"); - } - $sql->query($sQuery); - if ($sql->num_rows() > 0 || $this->bIncludeDefaultValue && (strlen($this->sEmptyErrorMessage) == 0)) { - if (isset($this->sOnChangeAction)) { - $sToRender = "sSelectName\" ". ($this->bPostBackOnChange ? "onChange=\"document.MainForm.submit();\" " : " ") . ">\n"; - } - if ($this->bIncludeDefaultValue) { - $sToRender .= "\n"; - } - while ($sql->next_record()) { - if ($this->selectedValue == $sql->f("value")) { - $sToRender .= "\n"; - } else { - $sToRender .= "\n"; - } - } - if (isset($this->aAdditionalEntries)) { - for ($i=0; $iaAdditionalEntries); $i++) { - $sToRender .= "\n"; - } - } - $sToRender .= "\n"; - } else { - $sToRender .= "\n"; - } - return $sToRender; - } - - function getEntries() { - global $default; - - $sql = $default->db; - $sQuery = "SELECT DISTINCT ST." . $this->sDisplayColumn . " AS display, ST." . $this->sValueColumn . " AS value FROM $this->sTableName AS ST ";/*wc*/ - if (isset($this->sFromClause)) { - $sQuery .= $this->sFromClause . " "; - } - if (isset($this->sWhereClause)) { - $sQuery .= "WHERE " . $this->sWhereClause . " "; - - } - - $sQuery .= "ORDER BY ST.$this->sDisplayColumn " . ($this->bOrderAsc ? "ASC" : "DESC"); - - $sql->query($sQuery); - $aValues = array(); - while ($sql->next_record()) { - $aValues[] = array("value" => $sql->f("value"), - "display" => $sql->f("display")); - } - return $aValues; - } -} -?> diff --git a/lib/visualpatterns/PatternListFromQuery.inc b/lib/visualpatterns/PatternListFromQuery.inc deleted file mode 100644 index 5dadb1f..0000000 --- a/lib/visualpatterns/PatternListFromQuery.inc +++ /dev/null @@ -1,184 +0,0 @@ -sQuery = $sNewQuery; - $this->aColumns = $aNewColumns; - $this->aColumnNames = $aNewColumnNames; - $this->aColumnTypes = $aNewColumnTypes; - $this->aHyperLinkURL = $aNewHyperLinkURL; - $this->aQueryStringText = $aNewQueryStringText; - } - - function setTableWidth($iNewValue) { - $this->iTableWidth = $iNewValue; - } - - function setTextAreaRows($iNewValue) { - $this->iTextAreaRows = $iNewValue; - } - - function setTextAreaColumns($iNewValue) { - $this->iTextAreaColumns = $iNewValue; - } - - function setTableHeading($sNewValue) { - $this->sTableHeading = $sNewValue; - } - - function setRenderIndividualTableForEachResult($bNewValue) { - $this->bIndividualTableForEachResult = $bNewValue; - } - - function setEmptyTableMessage($sNewValue) { - $this->sEmptyTableMessage = $sNewValue; - } - - function & render() { - global $default; - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); - - $aRows = DBUtil::getResultArray($this->sQuery); - $sToRender = ""; - $sToRender .= "iTableWidth) ? " width=\"$this->iTableWidth\"" : "") . " >\n"; - - if (isset($this->sTableHeading)) { - $sToRender .= "\n"; - } - - if (count($aRows) == 0) { - $sToRender .= "\n"; - if (isset($this->sEmptyTableMessage)) { - $sToRender .= "\n"; - } else { - $sToRender .= "\n"; - } - $sToRender .= "\n"; - $sToRender .= "
aColumns) . "\">$this->sTableHeading
$this->sEmptyTableMessage" . - sprintf(_("No %s data"), (isset($this->sTableHeading) ? "$this->sTableHeading" : "")) . - "
\n"; - return $sToRender; - } - - $map = array(); - foreach ($this->aColumns as $sColumn) { - $map[$sColumn] = array(); - } - - $iColour = 0; - foreach ($aRows as $aRow) { - $i = 0; - foreach ($this->aColumns as $sColumn) { - switch ($this->aColumnTypes[$i]) { - //plain text field - case 1: - $value = $aRow[$this->aColumns[$i]]; - break; - case 2: - $value = $aRow[$this->aColumns[$i]]; - if (!empty($value)) { - if ($value) { - $value = "graphicsUrl/" . $this->sChkPicPath . "\">"; - } else { - $value = "graphicsUrl/" . $this->sUnChkPicPath . "\">"; - } - $value .= " "; - } - break; - case 3: - $value = $aRow[$this->aColumns[$i]]; - $value = sprintf('%s', - $this->aHyperLinkURL[$i], - $this->replaceValues($this->aQueryStringText[$i], ""), - $value); - break; - default: - break; - } - - $map[$sColumn][] = $value; - $i++; - } - } - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate('ktcore/document_data'); - $aColumnNames = array(); - $iLen = count($this->aColumnNames); - for ($c = 0; $c < $iLen; $c++) { - $aColumnNames[$this->aColumns[$c]] = $this->aColumnNames[$c]; - } - $sToRender = $oTemplate->render(array( - 'map' => $map, - 'cnames' => $aColumnNames, - )); - return $sToRender; - } - - function replaceValues($sQueryStringText, $sql) { - return $sQueryStringText; - } -} -?> diff --git a/lib/visualpatterns/PatternMetaData.inc b/lib/visualpatterns/PatternMetaData.inc deleted file mode 100644 index f9c0ba3..0000000 --- a/lib/visualpatterns/PatternMetaData.inc +++ /dev/null @@ -1,93 +0,0 @@ -sMetaDataField = $sNewMetaDataField; - $this->sFormName = $sNewFormName; - $this->sValue = $sNewValue; - } - - - function render() { - global $default; - $sQuery = "SELECT has_lookup, data_type, has_lookuptree, id FROM $default->document_fields_table WHERE name LIKE '" . DBUtil::escapeSimple($this->sMetaDataField) . "'";/*ok*/ - - $sql = $default->db; - $sql->query($sQuery); - if ($sql->next_record()) { - if ($sql->f("has_lookup") and (!$sql->f("has_lookuptree"))) { - //is a lookup, so display a drop down list - $sWhereClause = "DF.name LIKE '" . $this->sMetaDataField . "'"; - $sFromClause = "INNER JOIN $default->document_fields_table AS DF ON ST.document_field_id = DF.id"; - $oPatternListBox = & new PatternListBox("$default->metadata_table", "name", "name", $this->sFormName); - if ($this->sValue != null) { - $oPatternListBox->setSelectedValue($this->sValue); - } - $oPatternListBox->setFromClause($sFromClause); - $oPatternListBox->setWhereClause($sWhereClause); - return $oPatternListBox->render(); - } else if ($sql->f("has_lookup") and ($sql->f("has_lookuptree"))) { - $fieldTree = new MDTree(); - $fieldTree->buildForField($sql->f("id")); - $fieldTree->setActiveItem($this->sValue); - return $fieldTree->_evilTreeRenderer($fieldTree, $this->sFormName); - } else { - $textboxlength = null; - switch($sql->f("data_type")) { - case "TEXT": - $sToRender = ''; - break; - case "INT": - case "FLOAT": - $sToRender = ''; - break; - case "STRING": - default: - $sToRender = ''; - } - return sprintf($sToRender, $this->sFormName, $this->sValue); - } - } else { - return "Error in PatternMetaData"; - } - } - -} - -?> diff --git a/lib/visualpatterns/PatternTableGeneric.inc b/lib/visualpatterns/PatternTableGeneric.inc deleted file mode 100644 index 9217f1f..0000000 --- a/lib/visualpatterns/PatternTableGeneric.inc +++ /dev/null @@ -1,212 +0,0 @@ -oResultSet =& $oResultSet; - $this->aColumns = & $aTmpColumns; - $this->aColumnTypes = $aTmpColumnTypes; - $this->aColumnHeaderNames = $aTmpColumnHeaderNames; - $this->sWidth = $sTmpWidth; - $this->bDisplayColumnHeadings = $bTmpDisplayColumnHeadings; - $this->aLinkURLs = $aTmpLinkURLs; - $this->aDBQueryStringColumns = $aTmpDBQueryStringColumns; - $this->aQueryStringVariableNames = $aNewQueryStringVariableNames; - } - - function setEmptyTableMessage($sNewValue) { $this->sEmptyTableMessage = $sNewValue; } - function setTableHeading($sNewValue) { $this->sTableHeading = $sNewValue; } - function setImageURL($sNewValue) { $this->sImageURL = $sNewValue; } - function setUseImageURLFromQuery($bNewValue) { $this->bUseImageURLFromQuery = $bNewValue; } - function setDisplayColumnHeadings($bNewValue) { $this->bDisplayColumnHeadings = $bNewValue; } - function setIncludeBorder($bNewValue) { $this->bIncludeBorder = $bNewValue; } - function setChkPicPath($sNewChkPicPath) { $this->sChkPicPath = $sNewChkPicPath; } - function getChkPicPath() { return $this->sChkPicPath ; } - function setWordWrap($bNewValue) { $this->bWordWrap = $bNewValue; } - function setDisabled($bNewValue) { $this->bDisabled = $bNewValue; } - - /** - * Build the HTML string used to render the object - * - * @return String of HTML used to render object - * - * @todo possibly add in image size restraints for link types 2 and 3 - */ - function & render() { - global $default; - - $sToRender = "bIncludeBorder ? "1" : "0") . "\" width=\"" . $this->sWidth . "\">\n"; - if (isset($this->sTableHeading)) { - $sToRender .= "\n"; - } - if ($this->bDisplayColumnHeadings) { - for ($i = 0; $i < count($this->aColumnHeaderNames); $i++) { - $sToRender .= "\n"; - } - } - # $sql->query($this->sQuery); - $oResultSet =& $this->oResultSet; - if ($oResultSet->isEmpty()) { - $sToRender .= "\n"; - if (isset($this->sEmptyTableMessage)) { - $sToRender .= "\n"; - } else { - $sToRender .= "\n"; - } - $sToRender .= "\n"; - } else { - $iColour = 0; - while ($oResult = $oResultSet->next()) { - $sToRender .= "\n"; - $iColour++; - for ($i = 0; $i < count($this->aColumns); $i++) { - switch ($this->aColumnTypes[$i]) { - case 1: - //text - $sToRender .= ""; - } else { - $sToRender .= $oResult->get($this->aColumns[$i]) . ""; - } - } else { - $sToRender .= " "; - } - break; - case 2: - //boolean - $sToRender .= ""; - } else { - $sToRender .= " "; - } - - break; - case 3: - if ($this->bDisabled === true) { - $sToRender .= ''; - $sToRender .= "\n"; - break; - } - //hyperlink - $sToRender .= "\n"; - break; - default: - break; - } - } - $sToRender .= "\n"; - } - } - $sToRender .= "
aColumns) . "\" align=\"left\">$this->sTableHeading
" . $this->aColumnHeaderNames[$i] . "
$this->sEmptyTableMessage" . - sprintf(_("No %s data admin"), (isset($this->sTableHeading) ? $this->sTableHeading : "")) . - "
"; - if (isset($this->sImageURL)) { - $sToRender .= $this->generateImageURL($this->sImageURL); - } else if ($this->bUseImageURLFromQuery) { - $sToRender .= $this->generateImageURL($oResult->get("image_url")); - } - if ($oResult->get($this->aColumns[$i]) != null) { - if ($this->bWordWrap) { - $sToRender .= wordwrap($oResult->get($this->aColumns[$i]), 25, " ", 1) . ""; - if ($oResult->get($this->aColumns[$i]) != null) { - $value = $oResult->get($this->aColumns[$i]); - if ($value) { - $sToRender .= "graphicsUrl/" . $this->sChkPicPath . "\">"; - } else { - $sToRender .= "graphicsUrl/" . $this->sUnChkPicPath . "\">"; - } - $sToRender .= " '; - $sToRender .= $oResult->get($this->aColumns[$i]); - $sToRender .= 'aLinkURLs[$i]; - for ($j = 0; $j < count($this->aDBQueryStringColumns); $j++) { - if (strpos($sLink, "?") === false) { - $sLink .= "?" . $this->aQueryStringVariableNames[$j] . "=" . $oResult->get($this->aDBQueryStringColumns[$j]); - } else { - $sLink .= "&" . $this->aQueryStringVariableNames[$j] . "=" . $oResult->get($this->aDBQueryStringColumns[$j]); - } - } - $sToRender .= $sLink . "\">"; - - if (isset($this->sImageURL)) { - $sToRender .= $this->generateImageURL($this->sImageURL); - } else if ($this->bUseImageURLFromQuery) { - $sToRender .= $this->generateImageURL($oResult->get("image_url")); - } - $sToRender .= $oResult->get($this->aColumns[$i]) . "
"; - return $sToRender; - } - - function generateImageURL($sURL) { - return ""; - } -} -?> diff --git a/lib/visualpatterns/PatternTableSqlQuery.inc b/lib/visualpatterns/PatternTableSqlQuery.inc deleted file mode 100644 index a26bacc..0000000 --- a/lib/visualpatterns/PatternTableSqlQuery.inc +++ /dev/null @@ -1,93 +0,0 @@ -oResultSet = $oResultSet; - if (PEAR::isError($oResultSet)) { - $this->broken = true; - } - } - - function isEmpty () { - global $default; - if ($this->broken) { - return $this->oResultSet; - } - return ($this->oResultSet->numRows() == 0); - } - - function next () { - global $default; - if ($this->broken) { - return $this->oResultSet; - } - $aNextResult = $this->oResultSet->fetchRow(DB_FETCHMODE_ASSOC); - if ($aNextResult === null) { - return null; - } - return new SqlResultAdapter ($aNextResult); - } -} - -class SqlResultAdapter { - function SqlResultAdapter ($oResult) { - $this->oResult = $oResult; - } - function get ($sField) { - global $default; - return $this->oResult[$sField]; - } -} - -class PatternTableSqlQuery extends PatternTableGeneric { - function PatternTableSqlQuery($sTmpQuery, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaderNames, $sTmpWidth, $aTmpLinkURLs = null, $aTmpDBQueryStringColumns = null, $aNewQueryStringVariableNames = null) { - $oResult = DBUtil::runQuery($sTmpQuery); - $oResultSet =& new SqlResultSetAdapter ($oResult); - $this->PatternTableGeneric($oResultSet, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaderNames, $sTmpWidth, $aTmpLinkURLs, $aTmpDBQueryStringColumns, $aNewQueryStringVariableNames); - } -} - -?>