";
+
+ return $sStr;
+ }
+}
+
+class TableRow
+{
+ //TODO: make these private when we get php5
+ var $aTableCells; // array that contains the cells for the table row
+ var $sStyle; // CSS style to be used
+ var $sClass; // CSS class to be used
+ var $sExtra; // extra things to put into the table row
+
+ var $oTableRowClick; // information about whether the table row is clickable etc
+
+ function TableRow()
+ {
+ $this->aTableCells = array();
+ $this->sStyle = null;
+ $this->sClass = null;
+ $this->oTableRowClick = null;
+ }
+
+ // TODO: php5 need to add type hinting here to make sure this is a TableCell instance
+ function AddCell($oTableCell)
+ {
+ $this->aTableCells[] = $oTableCell;
+ }
+
+ function AddCells($aTableCells)
+ {
+ foreach($aTableCells as $oTableCell)
+ {
+ $this->AddCell($oTableCell);
+ }
+ }
+
+ // TODO: php5 type hint as text
+ function AddTextCell($sCellText)
+ {
+ $this->AddCell(new TableCell($sCellText));
+ }
+
+ function SetStyle($sStyle)
+ {
+ $this->sStyle = $sStyle;
+ }
+
+ function SetClass($sClass)
+ {
+ $this->sClass = $sClass;
+ }
+
+ function SetRowClick($oTableRowClick)
+ {
+ $this->oTableRowClick = $oTableRowClick;
+ }
+
+ // get a string that contains the html representation
+ // of this table row
+ function GetString()
+ {
+ // generate the opening of the tr element
+ $sStr = "
sClass)
+ $sStr.= " class=\"$this->sClass\"";
+
+ if($this->sStyle)
+ $sStr.= " style=\"$this->sStyle\"";
+
+ if($this->sExtra)
+ $sStr.= " $this->sExtra";
+
+ if($this->oTableRowClick)
+ $sStr.= " ".$this->oTableRowClick->GetString();
+
+ $sStr.= ">"; // close the opening tr
+
+ // process the td elements
+ foreach($this->aTableCells as $oTableCell)
+ {
+ $sStr.=$oTableCell->GetString();
+ }
+
+ // close the table row
+ $sStr.= "
";
+
+ return $sStr;
+ }
+}
+
+// object manager table row, has additional parameters used by the object manager
+// when outputting a table row
+//TODO: php5 consider inheriting from HtmlTableRow since this class is really an
+// extension of that class
+class OMTableRow
+{
+ var $oTableRow;
+ var $bHasDeleteLink;
+ var $bCanEdit;
+
+ function OMTableRow($oTableRow)
+ {
+ $this->oTableRow = $oTableRow;
+ $this->bHasDeleteLink = false;
+ $this->bCanEdit = false;
+ }
+
+ // php5 hint that type is bool
+ function SetRowHasDeleteLink($bHasDeleteLink)
+ {
+ $this->bHasDeleteLink = $bHasDeleteLink;
+ }
+
+ // php5 hint type here
+ function SetRowClickable($oTableRowClick)
+ {
+ $this->oTableRowClick = $oTableRowClick;
+ }
+
+ function SetStyle($sStyle)
+ {
+ $this->oTableRow->SetStyle($sStyle);
+ }
+
+ // add a TableCell to an existing row
+ function AddCell($oTableCell)
+ {
+ $this->oTableRow->AddCell($oTableCell);
+ }
+
+ function GetString()
+ {
+ return $this->oTableRow->GetString();
+ }
+}
+
+class Table
+{
+ //TODO: make private when we have php5
+ var $oTableRowHeader;
+ var $aTableRows;
+ var $sClass;
+ var $sWidth;
+ var $iBorder;
+ var $sAlign; // align="$sAlign" - deprecated in html standards
+ var $iCellSpacing; // cellspacing="$iCellSpacing"
+ var $iCellPadding; // cellpadding="$iCellPadding"
+
+ function Table()
+ {
+ $this->oTableRowHeader = null;
+ $this->aTableRows = array();
+ $this->sClass = null;
+ $this->sWidth = null;
+ $this->iBorder = null;
+ $this->sAlign = null;
+ $this->iCellSpacing = null;
+ $this->iCellPadding = null;
+ }
+
+ function AddRow($oTableRow)
+ {
+ $this->aTableRows[] = $oTableRow;
+ }
+
+ // TODO: php5 force type to HtmlTableRow
+ function SetHeader($oTableRowHeader)
+ {
+ $this->oTableRowHeader = $oTableRowHeader;
+ }
+
+ function SetClass($sClass)
+ {
+ $this->sClass = $sClass;
+ }
+
+ function SetWidth($sWidth)
+ {
+ $this->sWidth = $sWidth;
+ }
+
+ function SetBorder($iBorder)
+ {
+ $this->iBorder = $iBorder;
+ }
+
+ function SetAlign($sAlign)
+ {
+ $this->sAlign = $sAlign;
+ }
+
+ function SetCellSpacing($iCellSpacing)
+ {
+ $this->iCellSpacing = $iCellSpacing;
+ }
+
+ function SetCellPadding($iCellPadding)
+ {
+ $this->iCellPadding = $iCellPadding;
+ }
+
+ function GetString()
+ {
+ $sStr = "
";
+
+ return $sStr;
+ }
+}
+
+// input is the row index, we alternate colors based on odd or even index rows
+// returns a TableRowHighlight instance
+function GetStandardRowHighlight($iRowIndex)
+{
+ //set row color
+ $sColor = ($iRowIndex % 2) ? "color0" : "color1";
+
+ $oInactiveColor = new color();
+ $oInactiveColor->SetColorByName($sColor);
+
+ $oHighlightColor = GetHighlightColorFromInactiveColor($oInactiveColor);
+
+ $oTableRowHighlight = new TableRowHighlight($oHighlightColor, $oInactiveColor);
+
+ return $oTableRowHighlight;
+}
+
+// TODO: php5 type hint this to color class
+// returns a color class instance
+function GetHighlightColorFromInactiveColor($oInactiveColor)
+{
+ $oHighlightColor = new color($oInactiveColor->iRed,
+ $oInactiveColor->iGreen,
+ $oInactiveColor->iBlue);
+ $oHighlightColor->Add(50);
+
+ return $oHighlightColor;
+}
+
+?>
diff --git a/include/tableve.php b/include/tableve.php
index ecd6353..3c46fb6 100644
--- a/include/tableve.php
+++ b/include/tableve.php
@@ -171,8 +171,11 @@ class TableVE {
echo html_frame_end();
}
+ // returns a string that contains the option list
function make_option_list($sVarname, $sCvalue, $sTable, $sIdField, $sNameField, $aWhere = null)
{
+ $sStr = "";
+
/* We do not allow direct insertion into of SQL code, so the WHERE clause is
is accepted in an array form, where the first element is the variable
and the second is the value it must be equal to */
@@ -182,20 +185,22 @@ class TableVE {
$hResult = query_parameters("SELECT ?, ? FROM ? $sWhere ORDER BY '?'",
$sIdField, $sNameField, $sTable, $sNameField);
if(!$hResult)
- return; // Oops
+ return $sStr; // Oops
- echo "\n";
+
+ return $sStr;
}
@@ -212,25 +217,25 @@ class TableVE {
if($field->name == "appId" && $field->table != "appFamily")
{
- $this->make_option_list($varname, $value, "appFamily", "appId", "appName");
+ echo $this->make_option_list($varname, $value, "appFamily", "appId", "appName");
return;
}
if($field->name == "vendorId" && $field->table != "vendor")
{
- $this->make_option_list($varname, $value, "vendor", "vendorId", "vendorName");
+ echo $this->make_option_list($varname, $value, "vendor", "vendorId", "vendorName");
return;
}
if($field->name == "catId" && $field->table != "appCategory")
{
- $this->make_option_list($varname, $value, "appCategory", "catId", "catName");
+ echo $this->make_option_list($varname, $value, "appCategory", "catId", "catName");
return;
}
if($field->name == "catParent")
{
- $this->make_option_list($varname, $value, "appCategory", "catId", "catName");
+ echo $this->make_option_list($varname, $value, "appCategory", "catId", "catName");
return;
}
diff --git a/include/testData.php b/include/testData.php
index 1d021b2..3b9b8bf 100644
--- a/include/testData.php
+++ b/include/testData.php
@@ -436,7 +436,7 @@ class testData{
}
// Show the Test results for a application version
- function ShowVersionsTestingTable($link, $iDisplayLimit)
+ function ShowVersionsTestingTable($sLink, $iDisplayLimit)
{
global $aClean;
@@ -467,18 +467,27 @@ class testData{
echo '
',"\n";
echo '
Test Results
',"\n";
echo '
',"\n";
- echo '
',"\n";
- echo '',"\n";
- echo '
',"\n";
- echo '
',"\n";
- echo '
Distribution
',"\n";
- echo '
Test date
',"\n";
- echo '
Wine version
',"\n";
- echo '
Installs?
',"\n";
- echo '
Runs?
',"\n";
- echo '
Rating
',"\n";
- echo '
Submitter
',"\n";
- echo '
',"\n";
+
+ // create the table
+ $oTable = new Table();
+ $oTable->SetClass("historyTable");
+ $oTable->SetBorder(1);
+ $oTable->SetWidth("100%");
+
+ // setup the table header
+ $oTableRowHeader = new TableRow();
+ $oTableRowHeader->SetClass("historyHeader");
+ $oTableRowHeader->AddTextCell("");
+ $oTableRowHeader->AddTextCell("Distribution");
+ $oTableRowHeader->AddTextCell("Test date");
+ $oTableRowHeader->AddTextCell("Wine version");
+ $oTableRowHeader->AddTextCell("Installs?");
+ $oTableRowHeader->AddTextCell("Runs?");
+ $oTableRowHeader->AddTextCell("Rating");
+ $oTableRowHeader->AddTextCell("Submitter");
+ $oTable->SetHeader($oTableRowHeader);
+
+ $iIndex = 0;
while($oRow = mysql_fetch_object($hResult))
{
$oTest = new testData($oRow->testingId);
@@ -488,46 +497,73 @@ class testData{
$oDistribution = new distribution($oTest->iDistributionId);
$bgcolor = $oTest->sTestedRating;
+ // initialize the array ech time we loop
+ $oTableRowClick = null;
+
+ $oTableRow = new TableRow();
+
/* if the test we are displaying is this test then */
/* mark it as the current test */
if ($oTest->iTestingId == $this->iTestingId)
{
- echo '
',"\n";
- echo '
Current
',"\n";
+ $sTRClass = $bgcolor;
+
+ $oTableCell = new TableCell("Current");
+ $oTableCell->SetAlign("center");
} else /* make all non-current rows clickable so clicking on them selects the test as current */
{
- html_tr_highlight_clickable($link.$oTest->iTestingId, $bgcolor, "", "color2", "underline");
- echo '
',"\n";
- else
- echo '">Show]',"\n";
+ $oInactiveColor = new color();
+ $oInactiveColor->SetColorByName($oTest->sTestedRating);
+
+ $oHighlightColor = GetHighlightColorFromInactiveColor($oInactiveColor);
+
+ $oTableRowHighlight = new TableRowHighlight($oHighlightColor, $oInactiveColor);
+
+ $sUrl = $sLink.$oTest->iTestingId;
+
+ $oTableRowClick = new TableRowClick($sUrl);
+ $oTableRowClick->SetHighlight($oTableRowHighlight);
+
+ // add the table element indicating that the user can show the row by clicking on it
+ $oTableCell = new TableCell("Show");
+ $oTableCell->SetCellLink($sUrl);
+ $oTableCell->SetAlign("center");
}
- echo '
',"\n";
+
+ // if this is a clickable row, set the appropriate property
+ if($oTableRowClick)
+ $oTableRow->SetRowClick($oTableRowClick);
+
+ // add the row to the table
+ $oTable->AddRow($oTableRow);
+
+ $iIndex++;
}
- echo '
',"\n";
+ echo $oTable->GetString();
echo ' ',"\n"; // put a space after the test results table and the button
@@ -973,20 +1009,21 @@ class testData{
$hMaintainers = maintainer::getMaintainersForAppIdVersionId(null, $this->iVersionId);
$bHasMaintainer = (mysql_num_rows($hMaintainers) == 0) ? false : true;
- $aCells = array(
- print_date(mysqltimestamp_to_unixtimestamp($this->sSubmitTime)),
- $oUser->objectMakeLink(),
- $oApp->objectMakeLink(),
- $oVersion->objectMakeLink(),
- $this->sTestedRelease,
- ($bHasMaintainer ? "YES" : "no"),
- $this->sTestedRating);
+ $oTableRow = new TableRow();
+ $oTableRow->AddCell(new TableCell(print_date(mysqltimestamp_to_unixtimestamp($this->sSubmitTime))));
+ $oTableRow->AddCell(new TableCell($oUser->objectMakeLink()));
+ $oTableRow->AddCell(new TableCell($oApp->objectMakeLink()));
+ $oTableRow->AddCell(new TableCell($oVersion->objectMakeLink()));
+ $oTableRow->AddCell(new TableCell($this->sTestedRelease));
+ $oTableRow->AddCell(new TableCell($bHasMaintainer ? "YES" : "no"));
+ $oTableRow->AddCell(new TableCell($this->sTestedRating));
- $oTableRow = new TableRow($aCells);
$oTableRow->SetStyle($this->sTestedRating);
- $oTableRow->SetRowHasDeleteLink(true);
- return $oTableRow;
+ $oOMTableRow = new OMTableRow($oTableRow);
+ $oOMTableRow->SetRowHasDeleteLink(true);
+
+ return $oOMTableRow;
}
function canEdit()
diff --git a/include/util.php b/include/util.php
index 001de61..9f3fc82 100644
--- a/include/util.php
+++ b/include/util.php
@@ -157,8 +157,11 @@ function get_xml_tag ($file, $mode = null)
// $sVarname - name of the selection array that this function will output
// this is the name to use to retrieve the selection on the form postback
// $sSelectedValue - the currently selected entry
+// returns a string that contains the version list output
function make_bugzilla_version_list($sVarname, $sSelectedValue)
{
+ $sStr = "";
+
$sTable = BUGZILLA_DB.".versions";
$sWhere = "WHERE product_id=".BUGZILLA_PRODUCT_ID;
$sQuery = "SELECT value FROM $sTable $sWhere";
@@ -198,18 +201,18 @@ function make_bugzilla_version_list($sVarname, $sSelectedValue)
// build the selection array
- echo "\n";
- echo "\n";
+ $sStr.= "\n";
+ $sStr.= "\n";
$bFoundSelectedValue = false;
foreach($aVersions as $sKey => $sValue)
{
if($sValue == $sSelectedValue)
{
- echo "\n";
+ $sStr.= "\n";
+
+ return $sStr;
}
function make_maintainer_rating_list($varname, $cvalue)
@@ -280,12 +285,36 @@ function outputTopXRow($oRow)
$oVersion = new Version($oRow->versionId);
$oApp = new Application($oVersion->iAppId);
$img = Screenshot::get_random_screenshot_img(null, $oRow->versionId, false); // image, disable extra formatting
- html_tr_highlight_clickable($oVersion->objectMakeUrl(), "white", "#f0f6ff", "white");
- echo '
-
'.version::fullNameLink($oVersion->iVersionId).'
-
'.util_trim_description($oApp->sDescription).'
-
'.$img.'
- ';
+
+ // create the table row
+ $oTableRow = new TableRow();
+ $oTableRow->SetClass("white");
+
+ // create the cells that represent the row
+ $oTableCell = new TableCell(version::fullNameLink($oVersion->iVersionId));
+ $oTableCell->SetClass("app_name");
+ $oTableRow->AddCell($oTableCell);
+ $oTableRow->AddTextCell(util_trim_description($oApp->sDescription));
+ $oTableCell = new TableCell($img);
+ $oTableCell->SetStyle("text-align:center;");
+ $oTableRow->AddCell($oTableCell);
+
+ // create a new TableRowHighlight instance
+ $oHighlightColor = new color(0xf0, 0xf6, 0xff);
+ $oInactiveColor = new color();
+ $oInactiveColor->SetColorByName("White");
+ $oTableRowHighlight = new TableRowHighlight($oHighlightColor, $oInactiveColor);
+
+ // create a new TableRowclick
+ $oTableRowClick = new TableRowClick($oVersion->objectMakeUrl());
+ $oTableRowClick->SetHighlight($oTableRowHighlight);
+
+ // set the click property of the html table row
+ $oTableRow->SetRowClick($oTableRowClick);
+
+ // output the entire table row
+ echo $oTableRow->GetString();
+ echo "\n";
}
/* Output the rows for the Top-X tables on the main page */
@@ -950,49 +979,64 @@ class color
$this->iBlue = $iBlue;
}
- function setColorByName($sColorName)
+ function SetColorByName($sColorName)
{
- switch($sColorName)
+ switch(strtolower($sColorName))
{
- case "Platinum":
+ case "platinum":
$this->iRed = 0xEC;
$this->iGreen = 0xEC;
$this->iBlue = 0xEC;
break;
- case "Gold":
+ case "gold":
$this->iRed = 0xFF;
$this->iGreen = 0xF6;
$this->iBlue = 0x00;
break;
- case "Silver":
+ case "silver":
$this->iRed = 0xC0;
$this->iGreen = 0xC0;
$this->iBlue = 0xC0;
break;
- case "Bronze":
+ case "bronze":
$this->iRed = 0xFC;
$this->iGreen = 0xBA;
$this->iBlue = 0x0A;
break;
- case "Garbage":
+ case "garbage":
$this->iRed = 0x99;
$this->iGreen = 0x96;
$this->iBlue = 0x66;
break;
+ case "white":
+ $this->iRed = 0xff;
+ $this->iGreen = 0xff;
+ $this->iBlue = 0xff;
+ break;
+ case "color0":
+ $this->iRed = 0xe0;
+ $this->iGreen = 0xe0;
+ $this->iBlue = 0xe0;
+ break;
+ case "color1":
+ $this->iRed = 0xc0;
+ $this->iGreen = 0xc0;
+ $this->iBlue = 0xc0;
+ break;
default:
break;
}
}
// convert the color value into a html rgb hex string
- function getHexString()
+ function GetHexString()
{
return sprintf("#%02X%02X%02X", $this->iRed, $this->iGreen, $this->iBlue);
}
// add $iAmount to each color value, maxing out at 0xFF, the largest
// color value allowed
- function add($iAmount)
+ function Add($iAmount)
{
if($this->iRed + $iAmount > 0xFF)
$this->iRed = 0xFF;
@@ -1009,6 +1053,6 @@ class color
else
$this->iBlue += $iAmount;
}
-};
+}
?>
diff --git a/include/vendor.php b/include/vendor.php
index 7e37fac..cb07ad6 100644
--- a/include/vendor.php
+++ b/include/vendor.php
@@ -171,22 +171,45 @@ class Vendor {
function outputEditor()
{
- echo "