Source for file Toolbox.php
Documentation is available at Toolbox.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | Copyright (c) 2002-2003 Brent Cook |
// +----------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | This library 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 |
// | Lesser General Public License for more details. |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA|
// +----------------------------------------------------------------------+
// $Id: Toolbox.php,v 1.6 2003/01/27 04:33:37 busterb Exp $
* Insert widgets into a quickform object suitable for updating a row in a DBA
* @author Brent Cook <busterb@mail.utexas.edu>
foreach ($schema as $name=> $meta) {
if (isset ($auxMeta['default'])) {
$defaults[$name] = $auxMeta['default'];
if (isset ($auxMeta[$name])) {
$desc = isset ($auxMeta[$name]['desc']) ?
$auxMeta[$name]['desc'] : $name;
switch($meta[DBA_TYPE ]) {
if (isset ($auxMeta[$name]['min']) &&
isset ($auxMeta[$name]['max'])) {
$form->addElement ('select', $name, $desc,
range($auxMeta[$name]['min'],
$auxMeta[$name]['max']));
$form->addElement ('text', $name, $desc,
array ('size'=>4 , 'maxlength'=>4 ));
if ($meta[DBA_SIZE ] <= 60 ) {
$form->addElement ('text', $name, $desc,
array ('size'=> $meta[DBA_SIZE ]));
$form->addElement ('textarea', $name, $desc,
array ('rows'=>4 , 'wrap'=> 'soft', 'cols'=>45 ));
$form->addElement ('select', $name, $desc,
array ('yes'=> 'Yes', 'no'=> 'No'));
$form->addElement ('textarea', $name, $desc,
array ('rows'=>4 , 'wrap'=> 'soft', 'cols'=>45 ));
* Postprocess $_POST variables that were left by a form using addQuickformDBA
* @return array DBA row suitable for inserting into a DBA table
foreach ($schema as $name=> $meta) {
if (isset ($auxMeta[$name]) && isset ($_POST[$name])) {
if (($meta[DBA_TYPE ] == DBA_INTEGER ) &&
isset ($auxMeta['min'])) {
$data[$name] = $_POST[$name] - $auxMeta['min'];
$data[$name] = $_POST[$name];
* Generates a text table from a results set, a-la MySQL
* @param array $fields list of fields to display
* @param string $style style to display table in; 'oracle', 'mysql'
* @return string text-formatted results set
$corner = ($style == 'oracle') ? ' ' : '+';
$wall = ($style == 'oracle') ? ' ' : '|';
// get the maximum length of each field
foreach ($fields as $key=> $field) {
$longest[$key] = strlen($field) + 1;
foreach ($rows as $row) {
$rowLen = strlen($row[$field]) + 1;
if ($rowLen > $longest[$key]) {
$longest[$key] = $rowLen;
// generate separator line
foreach ($longest as $length) {
$separator .= " $corner\n";
$buffer = ($style == 'oracle') ? '' : $separator;
foreach ($fields as $key=> $field) {
$buffer .= " $wall ". str_pad($field, $longest[$key]);
$buffer .= " $wall\n$separator";
foreach ($rows as $row) {
foreach ($fields as $key=> $field) {
$buffer .= " $wall ". str_pad($row[$field],
$buffer .= ($style == 'oracle') ? '' : $separator;
* Generates an HTML table from a results set
* This function uses custom CSS classes to define the table style.
* A recommended CSS is as follows:
* border-collapse: collapse;
* background-color: #CCCCFF;
* background-color: #FFFFFF;
* background-color: #F4F4F4;
* @param array $fields list of fields to display
* @return string HTML-formatted results set
$buffer = "<table class=\"dbatable\">\n";
foreach ($fields as $field) {
$buffer .= " <th class=\"dbatablefield\"> "
." $field </th>\n";
foreach ($rows as $row) {
foreach ($fields as $field) {
$buffer .= " <td class=\"dbatablerow$rowStyle\"> "
. $row[$field]. " </td>\n";
$rowStyle = 1 - $rowStyle;
Documentation generated on Mon, 11 Mar 2019 14:59:55 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|