diff --git a/appbrowse.php b/appbrowse.php index f246b00..0f5df9a 100644 --- a/appbrowse.php +++ b/appbrowse.php @@ -45,36 +45,57 @@ if($subs) echo html_frame_end(); echo html_frame_start("","98%","",0); - echo "\n\n"; - - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; + + $oTable = new Table(); + $oTable->SetWidth("100%"); + $oTable->SetBorder(0); + $oTable->SetCellPadding(3); + $oTable->SetCellSpacing(1); + + $oTableRow = new TableRow(); + $oTableRow->SetClass("color4"); + $oTableRow->AddTextCell("Sub Category"); + $oTableRow->AddTextCell("Description"); + $oTableRow->AddTextCell("No. Apps"); + $oTable->SetHeader($oTableRow); while(list($i,$iSubcatId) = each($subs)) { $oSubCat= new Category($iSubcatId); //set row color - $bgcolor = ($i % 2) ? "color0" : "color1"; - + $sColor = ($i % 2) ? "color0" : "color1"; + + $oTableRowHighlight = GetStandardRowHighlight($i); + + $sUrl = "appbrowse.php?iCatId=$iSubcatId"; + + $oTableRowClick = new TableRowClick($sUrl); + $oTableRowClick->SetHighlight($oTableRowHighlight); + //get number of apps in this sub-category - $appcount = $oSubCat->getApplicationCount(); + $iAppcount = $oSubCat->getApplicationCount(); //format desc - $desc = substr(stripslashes($oSubCat->sDescription),0,70); + $sDesc = substr(stripslashes($oSubCat->sDescription),0,70); //display row - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; + $oTableRow = new TableRow(); + $oTableRow->SetClass($sColor); + $oTableRow->SetRowClick($oTableRowClick); + + $oTableCell = new TableCell($oSubCat->sName); + $oTableCell->SetCellLink($sUrl); + $oTableRow->AddCell($oTableCell); + $oTableRow->AddTextCell("$sDesc  "); + $oTableRow->AddTextCell("$iAppcount  "); + + $oTable->AddRow($oTableRow); } - echo "
Sub CategoryDescriptionNo. Apps
".$oSubCat->sName."$desc  $appcount  
\n\n"; + // output the table + echo $oTable->GetString(); + echo html_frame_end("$c categories"); } @@ -89,33 +110,52 @@ if($apps) echo html_frame_end(); echo html_frame_start("","98%","",0); - echo "\n\n"; - - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; + + $oTable = new Table(); + $oTable->SetWidth("100%"); + $oTable->SetBorder(0); + $oTable->SetCellPadding(3); + $oTable->SetCellSpacing(1); + + $oTableRow = new TableRow(); + $oTableRow->SetClass("color4"); + $oTableRow->AddTextCell("Application name"); + $oTableRow->AddTextCell("Description"); + $oTableRow->AddTextCell("No. Versions"); + + $oTable->SetHeader($oTableRow); while(list($i, $iAppId) = each($apps)) { $oApp = new Application($iAppId); //set row color - $bgcolor = ($i % 2) ? "color0" : "color1"; + $sColor = ($i % 2) ? "color0" : "color1"; + + $oTableRowHighlight = GetStandardRowHighlight($i); + + $sUrl = $oApp->objectMakeUrl(); + + $oTableRowClick = new TableRowClick($sUrl); + $oTableRowClick->SetHighlight($oTableRowHighlight); //format desc - $desc = util_trim_description($oApp->sDescription); + $sDesc = util_trim_description($oApp->sDescription); //display row - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; + $oTableRow = new TableRow(); + $oTableRow->SetRowClick($oTableRowClick); + $oTableRow->SetClass($sColor); + $oTableRow->AddTextCell($oApp->objectMakeLink()); + $oTableRow->AddTextCell("$sDesc  "); + $oTableRow->AddTextCell(sizeof($oApp->aVersionsIds)); + + $oTable->AddRow($oTableRow); } - echo "
Application NameDescriptionNo. Versions
".$oApp->objectMakeLink()."$desc  ".sizeof($oApp->aVersionsIds)."
\n\n"; + // output table + echo $oTable->GetString(); + echo html_frame_end("$c applications in this category"); } diff --git a/browse_by_rating.php b/browse_by_rating.php index 4af78c2..24ae6cc 100644 --- a/browse_by_rating.php +++ b/browse_by_rating.php @@ -22,38 +22,75 @@ if (empty($aClean['sRating'])) echo "Rating: $sPathtrail"; echo html_frame_end(); echo html_frame_start("", '98%', '', 2); - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - html_tr_highlight_clickable("browse_by_rating.php?sRating=".PLATINUM_RATING, "platinum", "platinum", "platinum"); - echo " "; - echo " \n"; - echo " \n"; - echo " \n"; - html_tr_highlight_clickable("browse_by_rating.php?sRating=".GOLD_RATING, "gold", "gold", "gold"); - echo " "; - echo " \n"; - echo " \n"; - echo " \n"; - html_tr_highlight_clickable("browse_by_rating.php?sRating=".SILVER_RATING, "silver", "silver", "silver"); - echo " "; - echo " \n"; - echo " \n"; - echo " \n"; - html_tr_highlight_clickable("browse_by_rating.php?sRating=".BRONZE_RATING, "bronze", "bronze", "bronze"); - echo " "; - echo " \n"; - echo " \n"; - echo " \n"; - html_tr_highlight_clickable("browse_by_rating.php?sRating=".GARBAGE_RATING, "garbage", "garbage", "garbage"); - echo " "; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
RatingDescriptionNo. Apps
PlatinumApplications that install and run out of the box".Application::countWithRating(PLATINUM_RATING)."
GoldApplications that work flawlessly with some DLL overrides or other settings, crack etc.".Application::countWithRating(GOLD_RATING)."
SilverApplications that work excellently for 'normal use'".Application::countWithRating(SILVER_RATING)."
BronzeApplications that work but have some issues, even for 'normal use'".Application::countWithRating(BRONZE_RATING)."
GarbageApplications that don't work as intended, there should be at least one bug report if an app gets this rating".Application::countWithRating(GARBAGE_RATING)."
\n"; + + // create the table + $oTable = new Table(); + $oTable->SetCellSpacing(1); + $oTable->SetCellPadding(3); + $oTable->SetBorder(0); + $oTable->SetWidth("100%"); + + // create the header row + $aHeaderCells = array(); + $oTableCell = new TableCell("Rating"); + $oTableCell->SetBold(true); + $aHeaderCells[] = $oTableCell; + + $oTableCell = new TableCell("Description"); + $oTableCell->SetBold(true); + $aHeaderCells[] = $oTableCell; + + $oTableCell = new TableCell("No. Apps"); + $oTableCell->SetBold(true); + $aHeaderCells[] = $oTableCell; + + $oTableRowHeader = new TableRow(); + $oTableRowHeader->AddCells($aHeaderCells); + $oTableRowHeader->SetClass("color4"); + + $oTable->SetHeader($oTableRowHeader); + + // setup arrays for processing in the below loop + $aColorName = array("Platinum", "Gold", "Silver", "Bronze", "Garbage"); + $aRating = array(PLATINUM_RATING, GOLD_RATING, SILVER_RATING, + BRONZE_RATING, GARBAGE_RATING); + $aRatingText = array("Applications that install and run out of the box", + "Applications that work flawlessly with some DLL overrides or other settings, crack etc.", + "Applications that work excellently for 'normal use'", + "Applications that work but have some issues, even for 'normal use'", + "Applications that don't work as intended, there should be at least one bug report if an app gets this rating"); + + $iIndex = 0; + foreach($aColorName as $sColor) + { + $oTableRow = new TableRow(); + $oTableRow->SetClass($aRating[$iIndex]); + + $sUrl = "browse_by_rating.php?sRating=".$aRating[$iIndex]; + + $oTableCell = new TableCell($aColorName[$iIndex]); + $oTableCell->SetCellLink($sUrl); + $oTableRow->AddCell($oTableCell); + $oTableRow->AddTextCell($aRatingText[$iIndex]); + $oTableRow->AddTextCell(Application::countWithRating($aRating[$iIndex])); + + // click entry for the row + $oInactiveColor = new color(); + $oInactiveColor->SetColorByName($aColorName[$iIndex]); + $oHighlightColor = GetHighlightColorFromInactiveColor($oInactiveColor); + $oTableRowHighlight = new TableRowHighlight($oHighlightColor, $oInactiveColor); + $oTableRowClick = new TableRowClick($sUrl); + $oTableRowClick->SetHighlight($oTableRowHighlight); + + // set the clickable row + $oTableRow->SetRowClick($oTableRowClick); + + $oTable->AddRow($oTableRow); + + $iIndex++; + } + + echo $oTable->GetString(); echo html_frame_end(); } else @@ -142,33 +179,60 @@ if (empty($aClean['sRating'])) echo ""; echo html_frame_start("","98%","",0); - echo "\n\n"; + + $oTable = new Table(); + $oTable->SetWidth("100%"); + $oTable->SetBorder(0); + $oTable->SetCellPadding(3); + $oTable->SetCellSpacing(1); + + $oTableRow = new TableRow(); + $oTableRow->SetClass("color4"); + + $oTableCell = new TableCell("Application Name"); + $oTableCell->SetBold(true); + $oTableRow->AddCell($oTableCell); + + $oTableCell = new TableCell("Description"); + $oTableCell->SetBold(true); + $oTableRow->AddCell($oTableCell); - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; + $oTableCell = new TableCell("No. Versions"); + $oTableCell->SetBold(true); + $oTableRow->AddCell($oTableCell); + + $oTable->AddRow($oTableRow); - while(list($i, $iAppId) = each($apps)) + while(list($iIndex, $iAppId) = each($apps)) { $oApp = new Application($iAppId); - //set row color - $bgcolor = ($i % 2) ? "color0" : "color1"; - + $oTableRowHighlight = GetStandardRowHighlight($iIndex); + + $sUrl = $oApp->objectMakeUrl(); + + $sColor = ($iIndex % 2) ? "color0" : "color1"; + + $oTableRowClick = new TableRowClick($sUrl); + $oTableRowClick->SetHighlight($oTableRowHighlight); + //format desc - $desc = util_trim_description($oApp->sDescription); + $sDesc = util_trim_description($oApp->sDescription); //display row - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; + $oTableRow = new TableRow(); + $oTableRow->SetRowClick($oTableRowClick); + $oTableRow->SetClass($sColor); + + $oTableRow->AddTextCell($oApp->objectMakeLink()); + $oTableRow->AddTextCell("$sDesc  "); + $oTableRow->AddTextCell(sizeof($oApp->aVersionsIds)); + + $oTable->AddRow($oTableRow); } - echo "
Application NameDescriptionNo. Versions
".$oApp->objectMakeLink()."$desc  ".sizeof($oApp->aVersionsIds)."
\n\n"; + // output the table + echo $oTable->GetString(); echo html_frame_end(); echo "
"; diff --git a/browse_downloadable.php b/browse_downloadable.php index 2ce6aec..71c2fcc 100644 --- a/browse_downloadable.php +++ b/browse_downloadable.php @@ -108,29 +108,53 @@ if(!$sLicense) if($hResult && mysql_num_rows($hResult)) { echo html_frame_start("", "90%"); - echo html_table_begin("width=\"100%\" align=\"center\""); - echo html_tr(array( - "Name", - "Description"), - "color4"); + + $oTable = new Table(); + $oTable->SetWidth("100%"); + $oTable->SetAlign("center"); - for($i = 1; $oRow = mysql_fetch_object($hResult); $i++) + $oTableRow = new TableRow(); + $oTableCell = new TableCell("Name"); + $oTableCell->SetBold(true); + $oTableRow->AddCell($oTableCell); + $oTableCell = new TableCell("Description"); + $oTableCell->SetBold(true); + $oTableRow->AddCell($oTableCell); + + $oTableRow->SetClass("color4"); + $oTable->AddRow($oTableRow); + + for($iIndex = 1; $oRow = mysql_fetch_object($hResult); $iIndex++) { $oVersion = new version($oRow->versionId); - echo html_tr_highlight_clickable( - $oVersion->objectMakeUrl(), - ($i % 2) ? "color1" : "color0", - ($i % 2) ? "color1" : "color0", - ($i % 2) ? "color1" : "color0"); - echo "".version::fullNameLink($oVersion->iVersionId)."\n"; - echo "$oRow->description\n"; - echo "\n"; + + $oTableRow = new TableRow(); + if($iIndex % 2) + $sColor = "color1"; + else + $sColor = "color0"; + + $oTableRow->SetClass($sColor); + + $oTableRowHighlight = GetStandardRowHighlight($iIndex); + + $oTableRowClick = new TableRowClick($oVersion->objectMakeUrl()); + $oTableRowClick->SetHighlight($oTableRowHighlight); + + $oTableRow->SetRowClick($oTableRowClick); + + $oTableRow->AddCell(new TableCell(version::fullNameLink($oVersion->iVersionId))); + $oTableRow->AddCell(new TableCell($oRow->description)); + $oTable->AddRow($oTableRow); } - echo html_table_end(); + echo $oTable->GetString(); + echo html_frame_end(" "); } echo "\n"; +apidb_footer(); + ?> diff --git a/contact.php b/contact.php index 25b700d..3271bb7 100644 --- a/contact.php +++ b/contact.php @@ -46,25 +46,40 @@ if(!$aClean['sSubmit']) } echo "

E-mail $oRecipient->sRealname.

"; - echo html_table_begin("width\"100%\" border=\"0\" cellpadding=\"2\"". - "cellspacing=\"2\""); - echo html_tr(array( - array("Subject", ""), - ""), - "color4"); - echo html_tr(array( - array("Message", "valign=\"top\""), - ""), - "color4"); - echo html_tr(array( - "", - "") - ); + + $oTable = new Table(); + $oTable->SetWidth("100%"); + $oTable->SetBorder(0); + $oTable->SetCellPadding(2); + $oTable->SetCellSpacing(2); + + $oTableRow = new TableRow(); + $oTableRow->SetClass("color4"); + $oTableRow->AddTextCell("Subject"); + $oTableCell = new TableCell(""); + $oTableRow->AddCell($oTableCell); + $oTable->AddRow($oTableRow); + + $oTableRow = new TableRow(); + $oTableRow->SetClass("color4"); + $oTableCell = new TableCell("Message"); + $oTableCell->SetValign("top"); + $oTableRow->AddCell($oTableCell); + $oTableCell = new TableCell(""); + $oTableRow->AddCell($oTableCell); + $oTable->AddRow($oTableRow); + + $oTableRow = new TableRow(); + $oTableRow->AddTextCell(""); + $oTableRow->AddTextCell(""); + $oTable->AddRow($oTableRow); + + // output the table + echo $oTable->GetString(); echo "iUserId\" />"; - echo html_table_end(); echo "\n"; echo html_frame_end(" "); diff --git a/include/application.php b/include/application.php index ca2c5ae..aaf9ceb 100644 --- a/include/application.php +++ b/include/application.php @@ -524,7 +524,7 @@ class Application { // app Category $w = new TableVE("view"); echo 'Category',"\n"; - $w->make_option_list("iAppCatId", $this->iCatId,"appCategory","catId","catName"); + echo $w->make_option_list("iAppCatId", $this->iCatId,"appCategory","catId","catName"); echo '',"\n"; // vendor name @@ -534,9 +534,9 @@ class Application { // alt vendor $x = new TableVE("view"); echo ' ',"\n"; - $x->make_option_list("iAppVendorId", - $this->iVendorId,"vendor","vendorId","vendorName", - array("vendor.queued", "false")); + echo $x->make_option_list("iAppVendorId", + $this->iVendorId,"vendor","vendorId","vendorName", + array("vendor.queued", "false")); echo '',"\n"; // url @@ -772,29 +772,35 @@ class Application { if(!$hResult || !mysql_num_rows($hResult)) return false; - $sResult = html_table_begin("width=\"100%\" align=\"center\""); - $sResult .= html_tr(array( - "Application", - "Description", - "Vendor", - "Submission Date"), - "color4"); + $oTable = new Table(); + $oTable->SetWidth("100%"); + $oTable->SetAlign("center"); + + $oTableRow = new TableRow(); + $oTableRow->AddTextCell("Application"); + $oTableRow->AddTextCell("Description"); + $oTableRow->AddTextCell("Vendor"); + $oTableRow->AddTextCell("Submission Date"); + $oTableRow->SetClass("color4"); + $oTable->SetHeader($oTableRow); for($i = 1; $oRow = mysql_fetch_object($hResult); $i++) { + $oVendor = new vendor($oRow->vendorId); $oApp = new application($oRow->appId); - $sResult .= html_tr(array( - $oApp->objectMakeLink(), - $oRow->description, - $oVendor->objectMakeLink(), - print_date(mysqltimestamp_to_unixtimestamp($oRow->submitTime))), - ($i % 2) ? "color0" : "color1"); + + $oTableRow = new TableRow(); + $oTableRow->AddTextCell($oApp->objectMakeLink()); + $oTableRow->AddTextCell($oRow->description); + $oTableRow->AddTextCell($oVendor->objectMakeLink()); + $oTableRow->AddTextCell(print_date(mysqltimestamp_to_unixtimestamp($oRow->submitTime))); + $oTableRow->SetClass(($i % 2) ? "color0" : "color1"); + + $oTable->AddRow($oTableRow); } - $sResult .= html_table_end(); - - return $sResult; + return $oTable->GetString(); } function objectMakeUrl() @@ -858,14 +864,14 @@ class Application { else $sVendor = $oVendor->objectMakeLink(); - $aCells = array( - print_date(mysqltimestamp_to_unixtimestamp($this->sSubmitTime)), - $oUser->objectMakeLink(), - $sVendor, - $this->sName); + $oTableRow = new TableRow(); + $oTableRow->AddTextCell(print_date(mysqltimestamp_to_unixtimestamp($this->sSubmitTime))); + $oTableRow->AddTextCell($oUser->objectMakeLink()); + $oTableRow->AddTextCell($sVendor); + $oTableRow->AddTextCell($this->sName); - $oTableRow = new TableRow($aCells); - return $oTableRow; + $oOMTableRow = new OMTableRow($oTableRow); + return $oOMTableRow; } function canEdit() @@ -942,6 +948,7 @@ class Application { echo " messages in its forums or become a maintainer to help others trying to run the application.

"; } } + function objectGetEntriesCount($bQueued, $bRejected) { $sQueued = objectManager::getQueueString($bQueued, $bRejected); diff --git a/include/browse_newest_apps.php b/include/browse_newest_apps.php index 60fe59a..4e38c77 100644 --- a/include/browse_newest_apps.php +++ b/include/browse_newest_apps.php @@ -68,15 +68,21 @@ class browse_newest_apps function objectGetTableRow() { $oApp = new application($this->iAppId); - $aCells = array( - array(print_short_date(mysqltimestamp_to_unixtimestamp($oApp->sSubmitTime)), - "width=\"20%\""), - $oApp->objectMakeLink(), - util_trim_description($oApp->sDescription)); + $oTableRow = new TableRow(); - $oTableRow = new TableRow($aCells); - return $oTableRow; + $oTableCell = new TableCell(print_short_date(mysqltimestamp_to_unixtimestamp($oApp->sSubmitTime))); + $oTableCell->SetWidth("20%"); + $oTableRow->AddCell($oTableCell); + $oTableRow->AddTextCell($oApp->objectMakeLink()); + $oTableRow->AddTextCell(util_trim_description($oApp->sDescription)); + + // make the row clickable + $oTableRowClick = new TableRowClick($oApp->objectMakeUrl()); + $oTableRow->SetRowClick($oTableRowClick); + + $oOMTableRow = new OMTableRow($oTableRow); + return $oOMTableRow; } function objectGetItemsPerPage($bQueued = false) diff --git a/include/distribution.php b/include/distribution.php index 78aff70..fce949a 100644 --- a/include/distribution.php +++ b/include/distribution.php @@ -455,17 +455,24 @@ class distribution { function objectGetTableRow() { - $aCells = array( - $this->objectMakeLink(), - "sUrl\">$this->sUrl", - array(sizeof($this->aTestingIds), "align=\"right\"")); + $oTableRow = new TableRow(); + + $oTableRow->AddTextCell($this->objectMakeLink()); + + $oTableCell = new TableCell("$this->sUrl"); + $oTableCell->SetCellLink($this->sUrl); + $oTableRow->AddCell($oTableCell); + + $oTableCell = new TableCell(sizeof($this->aTestingIds)); + $oTableCell->SetAlign("right"); + $oTableRow->AddCell($oTableCell); // enable the 'delete' action if this distribution has no testing results $bDeleteLink = sizeof($this->aTestingIds) ? FALSE : TRUE; - $oTableRow = new TableRow($aCells); - $oTableRow->SetRowHasDeleteLink($bDeleteLink); - return $oTableRow; + $oOMTableRow = new OMTableRow($oTableRow); + $oOMTableRow->SetRowHasDeleteLink($bDeleteLink); + return $oOMTableRow; } // Whether the user has permission to edit distributions diff --git a/include/form_edit.php b/include/form_edit.php index d7b0cfa..74d4b44 100644 --- a/include/form_edit.php +++ b/include/form_edit.php @@ -4,27 +4,39 @@ require_once(BASE."include/util.php"); /*********************/ /* Edit Account Form */ /*********************/ + +// returns an array of TableRow instances +function GetEditAccountFormRows($sUserEmail) +{ + $aTableRows = array(); + + $oTableRow = new TableRow(); + $oTableRow->AddTextCell("  Email Address"); + $oTableRow->AddTextCell(''); + $aTableRows[] = $oTableRow; + + $oTableRow = new TableRow(); + $oTableRow->AddTextCell("  Password"); + $oTableRow->AddTextCell(''); + $aTableRows[] = $oTableRow; + + $oTableRow = new TableRow(); + $oTableRow->AddTextCell("  Password (again)"); + $oTableRow->AddTextCell(''); + $aTableRows[] = $oTableRow; + + $oTableRow = new TableRow(); + $oTableRow->AddTextCell("  Real Name"); + $oTableRow->AddTextCell(''); + $aTableRows[] = $oTableRow; + + $oTableRow = new TableRow(); + $oTableRow->AddTextCell(" "); + $oTableRow->AddTextCell(" "); + $aTableRows[] = $oTableRow; + + return $aTableRows; +} + ?> - - - -   Email Address - - - -   Password - - - -   Password (again) - - - -   Real Name - - - -   - - - diff --git a/include/html.php b/include/html.php index 78f29a2..e8cdfdb 100644 --- a/include/html.php +++ b/include/html.php @@ -69,16 +69,6 @@ function html_tr($arr, $class = "", $extra = "") return do_html_tr("td", $arr, $class, $extra); } -function html_tr_highlight_clickable($sUrl, $sClass, $sHighlightColor, $sInactiveColor, - $sTextDecorationHighlight = "none", - $sTextDecorationInactive = "none") -{ - echo ''; -} - // HTML TABLE function html_table_begin($extra = "") { diff --git a/include/incl.php b/include/incl.php index fbf49fa..8469faa 100644 --- a/include/incl.php +++ b/include/incl.php @@ -13,6 +13,7 @@ require(BASE."include/menu.php"); require(BASE."include/html.php"); require(BASE."include/error_log.php"); require(BASE."include/query.php"); +require(BASE."include/table.php"); require_once(BASE."include/objectManager.php"); /* if magic quotes are enabled make sure the user disables them */ diff --git a/include/maintainer.php b/include/maintainer.php index 23badcf..d142061 100644 --- a/include/maintainer.php +++ b/include/maintainer.php @@ -630,15 +630,16 @@ class maintainer $oApp = new Application($this->iAppId); $oVersion = new Version($this->iVersionId); - $aCells = array( - print_date(mysqldatetime_to_unixtimestamp($this->aSubmitTime)), - $oApp->objectMakeLink(), - ($this->bSuperMaintainer) ? "N/A" : $oVersion->objectMakeLink(), - ($this->bSuperMaintainer) ? "Yes" : "No", - $oUser->objectMakeLink()); + $oTableRow = new TableRow(); - $oTableRow = new TableRow($aCells); - return $oTableRow; + $oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($this->aSubmitTime))); + $oTableRow->AddTextCell($oApp->objectMakeLink()); + $oTableRow->AddTextCell(($this->bSuperMaintainer) ? "N/A" : $oVersion->objectMakeLink()); + $oTableRow->AddTextCell(($this->bSuperMaintainer) ? "Yes" : "No"); + $oTableRow->AddTextCell($oUser->objectMakeLink()); + + $oOMTableRow = new OMTableRow($oTableRow); + return $oOMTableRow; } function ObjectDisplayQueueProcessingHelp() diff --git a/include/menu.php b/include/menu.php index 02001df..66d8403 100644 --- a/include/menu.php +++ b/include/menu.php @@ -39,19 +39,32 @@ class htmlmenu { /* add a table row */ function add($sName, $shUrl = null, $sAlign = "left") { + $oTableRow = new TableRow(); + if($shUrl) { - // we have a valid url, make the entire table row clickable and provide - // some highlighting for visual feedback - html_tr_highlight_clickable($shUrl, "sideMenu", "#e0e6ff", "#ffffff"); - echo " ". - "$sName"; - echo "\n"; + $oTableCell = new TableCell(" ". + "$sName"); + + $oHighlightColor = new Color(0xe0, 0xe6, 0xff); + $oInactiveColor = new Color(0xff, 0xff, 0xff); + $oTableRowHighlight = new TableRowHighlight($oHighlightColor, $oInactiveColor); + + $oTableRowClick = new TableRowClick($shUrl); + $oTableRowClick->SetHighlight($oTableRowHighlight); + + $oTableRow->SetRowClick($oTableRowClick); } else { - echo "  $sName\n"; + $oTableCell = new TableCell(" $sName"); } + $oTableCell->SetAlign($sAlign); + $oTableCell->SetWidth("100%"); + + $oTableRow->SetClass("sidemenu"); + $oTableRow->AddCell($oTableCell); + + echo $oTableRow->GetString(); } function addmisc($sStuff, $sAlign = "left") diff --git a/include/objectManager.php b/include/objectManager.php index a121be2..3516e24 100644 --- a/include/objectManager.php +++ b/include/objectManager.php @@ -23,7 +23,7 @@ class ObjectManager $this->sTitle = $sTitle; $this->iId = $iId; $this->oMultiPage = new MultiPage(FALSE); - $this->oTableRow = new TableRow(null); + $this->oTableRow = new OMTableRow(null); // initialize the common responses array $this->aCommonResponses = array(); @@ -104,10 +104,14 @@ class ObjectManager /* if we are requesting a list of its queued objects or */ /* all of its objects */ if($this->oMultiPage->bEnabled) + { $hResult = $oObject->objectGetEntries($this->bIsQueue, $this->bIsRejected, - $this->oMultiPage->iItemsPerPage, $this->oMultiPage->iLowerLimit); - else + $this->oMultiPage->iItemsPerPage, + $this->oMultiPage->iLowerLimit); + } else + { $hResult = $oObject->objectGetEntries($this->bIsQueue, $this->bIsRejected); + } /* did we get any entries? */ if(!$hResult || mysql_num_rows($hResult) == 0) @@ -144,8 +148,21 @@ class ObjectManager $this->oTableRow = $oObject->objectGetTableRow(); - if(!$this->oTableRow->sStyle) - $this->oTableRow->sStyle = ($iCount % 2) ? "color0" : "color1"; + $sColor = ($iCount % 2) ? "color0" : "color1"; + + //TODO: we shouldn't access this method directly, should make an accessor for it + if(!$this->oTableRow->oTableRow->sClass) + { + $this->oTableRow->oTableRow->sClass = $sColor; + } + + // if this row is clickable, make it highlight appropirately + $oTableRowClick = $this->oTableRow->oTableRow->oTableRowClick; + if($oTableRowClick) + { + $oTableRowHighlight = GetStandardRowHighlight($iCount); + $oTableRowClick->SetHighlight($oTableRowHighlight); + } $sEditLinkLabel = $this->bIsQueue ? "process" : "edit"; @@ -155,15 +172,16 @@ class ObjectManager $shDeleteLink = ""; if($this->oTableRow->bHasDeleteLink) { - $shDeleteLink = ' [ objectGetid()). - '">delete ]'; + $shDeleteLink = ' [ objectGetid()). + '">delete ]'; } - $this->oTableRow->aCells[] = '[ objectGetId()).'">'.$sEditLinkLabel.' ]'.$shDeleteLink; + $oTableCell = new TableCell('[ objectGetId()).'">'.$sEditLinkLabel.' ]'.$shDeleteLink); + $this->oTableRow->AddCell($oTableCell); } - echo html_tr($this->oTableRow->aCells, $this->oTableRow->sStyle); + echo $this->oTableRow->GetString(); } echo ""; @@ -770,41 +788,4 @@ class MultiPage } } -class TableRow -{ - var $aCells; // array that contains the columns for a table row - var $sStyle; // CSS style to be used - var $bHasDeleteLink; - var $aRowClickable; //FIXME: we should describe the entries required here by creating a class for a clickable row entry or something - var $bCanEdit; - - function TableRow($aCells) - { - if(!$aCells) - return; - - $this->aCells = $aCells; - - // initialize the rest of the variables - $this->sStyle = null; - $this->bHasDeleteLink = false; - $this->aRowClickable = null; - } - - function SetStyle($sStyle) - { - $this->sStyle = $sStyle; - } - - function SetRowHasDeleteLink($bHasDeleteLink) - { - $this->bHasDeleteLink = $bHasDeleteLink; - } - - function SetRowClickable($aRowClickableInfo) - { - $this->aRowClickable = $aRowClickableInfo; - } -} - ?> diff --git a/include/table.php b/include/table.php new file mode 100644 index 0000000..34dbb5d --- /dev/null +++ b/include/table.php @@ -0,0 +1,456 @@ +oHighlightColor = $oHighlightColor; + $this->oInactiveColor = $oInactiveColor; + + $this->sTextDecorationHighlight = $sTextDecorationHighlight; + $this->sTextDecorationInactive = $sTextDecorationInactive; + } +} + +class TableRowClick +{ + var $oTableRowHighlight; + var $bHasHighlight; + var $shUrl; + + function TableRowClick($shUrl) + { + $this->shUrl = $shUrl; + $this->bHasHighlight = false; + $this->oTableRowHighlight = null; + } + + //TODO: php5, type hint to TableRowHighlight class + function SetHighlight($oTableRowHighlight) + { + $this->oTableRowHighlight = $oTableRowHighlight; + } + + function GetString() + { + $sStr = ""; + + // if we have highlighting output the attributes necessary to enable the javascript tht we use + // to perform the highlighting actions + if($this->oTableRowHighlight) + { + $sStr.= 'onmouseover="ChangeTr(this, true,'. + '\''.$this->oTableRowHighlight->oHighlightColor->GetHexString().'\','. + '\''.$this->oTableRowHighlight->oInactiveColor->GetHexString().'\','. + '\''.$this->oTableRowHighlight->sTextDecorationHighlight.'\','. + '\''.$this->oTableRowHighlight->sTextDecorationInactive.'\');"'; + $sStr.= ' onmouseout="ChangeTr(this, false,'. + '\''.$this->oTableRowHighlight->oHighlightColor->GetHexString().'\','. + '\''.$this->oTableRowHighlight->oInactiveColor->GetHexString().'\','. + '\''.$this->oTableRowHighlight->sTextDecorationHighlight.'\','. + '\''.$this->oTableRowHighlight->sTextDecorationInactive.'\');"'; + } + + $sStr.= ' onclick="DoNav(\''.$this->shUrl.'\');"'; + + return $sStr; + } +} + +class TableCell +{ + //TODO: make these private when we move to php5 + var $sCell; + var $sStyle; + var $sClass; + var $sAlign; // align="$sAlign" will be output if this is not null + var $sValign; // valign="$sValign" will be output if this is not null + var $sWidth; // width="$sWidth" + var $sUrl; // wraps the cell contents in an anchor tag if $sUrl is not null + var $bBold; // if true will output the cell contents as bold + + // NOTE: We specifically have limited the parameters to the constructor + // to only the contents of the cell. Additional parameters, while + // appearing convienent, make the parameters confusing + // Use accessors to set additional parameters. + function TableCell($sCellContents) + { + $this->sCellContents = $sCellContents; + $this->sStyle = null; + $this->sClass = null; + $this->sAlign = null; + $this->sValign = null; + $this->sWidth = null; + $this->bBold = false; + } + + function SetCellContents($sCellContents) + { + $this->sCellContents = $sCellContents; + } + + function SetStyle($sStyle) + { + $this->sStyle = $sStyle; + } + + function SetClass($sClass) + { + $this->sClass = $sClass; + } + + function SetAlign($sAlign) + { + $this->sAlign = $sAlign; + } + + function SetValign($sValign) + { + $this->sValign = $sValign; + } + + function SetWidth($sWidth) + { + $this->sWidth = $sWidth; + } + + function SetCellLink($sUrl) + { + $this->sUrl = $sUrl; + } + + //php5 make sure this type is boolean + function SetBold($bBold) + { + $this->bBold = $bBold; + } + + function GetString() + { + $sStr = "sClass) + $sStr.=" class=\"".$this->sClass."\";"; + + if($this->sStyle) + $sStr.=" style=\"".$this->sStyle."\";"; + + if($this->sAlign) + $sStr.=" align=\"".$this->sAlign."\";"; + + if($this->sValign) + $sStr.=" valign=\"".$this->sValign."\";"; + + if($this->sWidth) + $sStr.=" width=\"".$this->sWidth."\";"; + + $sStr.=">"; + + // if we have a url, output the start of the anchor tag + if($this->sUrl) + $sStr.=''; + + if($this->bBold) + $sStr.=''; + + // output the contents of the cell + $sStr.=$this->sCellContents; + + if($this->bBold) + $sStr.=''; + + // if we have a url, close the anchor tag + if($this->sUrl) + $sStr.=''; + + $sStr.=""; + + 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 = "sClass) + $sStr.= ' class="'.$this->sClass.'"'; + + if($this->sWidth) + $sStr.= ' width="'.$this->sWidth.'"'; + + if($this->iBorder) + $sStr.= ' border="'.$this->iBorder.'"'; + + if($this->sAlign) + $sStr.= ' align="'.$this->sAlign.'"'; + + if($this->iCellSpacing) + $sStr.= ' cellspacing="'.$this->iCellSpacing.'"'; + + if($this->iCellPadding) + $sStr.= ' cellpadding="'.$this->iCellPadding.'"'; + + $sStr.= ">"; // close the open table element + + if($this->oTableRowHeader) + { + $sStr.=""; + $sStr.= $this->oTableRowHeader->GetString(); + $sStr.=""; + } + + foreach($this->aTableRows as $oTableRow) + { + $sStr.= $oTableRow->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"; + $sStr.= "\n"; while(list($iId, $sName) = mysql_fetch_row($hResult)) { if ($sName == "NONAME") continue; if($iId == $sCvalue) - echo "