Clean up application and version classes. Move class related functions into the class as static member functions

This commit is contained in:
Chris Morgan
2006-06-29 16:07:19 +00:00
committed by WineHQ
parent 245a6b993e
commit 034ea689bc
17 changed files with 138 additions and 138 deletions

View File

@@ -73,8 +73,8 @@ if (!$aClean['id'])
echo $oUser->sRealname;
echo $oUser->sEmail ? "</a>":"";
echo "</td>\n";
echo "<td>".lookup_app_name($ob->appId)."</td>\n";
echo "<td>".lookup_version_name($ob->versionId)."</td>\n";
echo "<td>".Application::lookup_name($ob->appId)."</td>\n";
echo "<td>".Version::lookup_name($ob->versionId)."</td>\n";
echo "<td>".$ob->type."</td>\n";
echo "<td align=\"center\">[<a href='adminAppDataQueue.php?id=$ob->id'>process</a>]</td>\n";
echo "</tr>\n\n";
@@ -105,11 +105,11 @@ if (!$aClean['id'])
// app name
echo '<tr valign=top><td class=color0><b>App Name</b></td>',"\n";
echo "<td>".lookup_app_name($obj_row->appId)."</td></tr>\n";
echo "<td>".Application::lookup_name($obj_row->appId)."</td></tr>\n";
// version
echo '<tr valign=top><td class=color0><b>App Version</b></td>',"\n";
echo "<td>".lookup_version_name($obj_row->versionId)."</td></tr>\n";
echo "<td>".Version::lookup_name($obj_row->versionId)."</td></tr>\n";
//dataDescription
echo '<tr valign=top><td class=color0><b>Description</b></td>',"\n";
@@ -185,7 +185,7 @@ if (!$aClean['id'])
if ($oUser->sEmail)
{
$sSubject = "Application Data Request Report";
$sMsg = "Your submission of an application data for ".lookup_app_name($obj_row->appId).lookup_version_name($obj_row->versionId)." has been accepted. ";
$sMsg = "Your submission of an application data for ".Application::lookup_name($obj_row->appId).Version::lookup_name($obj_row->versionId)." has been accepted. ";
$sMsg .= $aClean['replyText'];
$sMsg .= "We appreciate your help in making the Application Database better for all users.\r\n";
@@ -207,7 +207,7 @@ if (!$aClean['id'])
if ($oUser->sEmail)
{
$sSubject = "Application Data Request Report";
$sMsg = "Your submission of an application data for ".lookup_app_name($obj_row->appId).lookup_version_name($obj_row->versionId)." was rejected. ";
$sMsg = "Your submission of an application data for ".Application::lookup_name($obj_row->appId).Version::lookup_name($obj_row->versionId)." was rejected. ";
$sMsg .= $aClean['replyText'];
mail_appdb($oUser->sEmail, $sSubject ,$sMsg);
}

View File

@@ -115,7 +115,7 @@ function display_move_test_to_versions_table($aVersionsIds,$icurrentVersionId)
echo "<tr class=$bgcolor>\n";
echo " <td>".html_ahref($oVersion->sName,"adminAppQueue.php?sub=movetest&apptype=version&versionId=".$icurrentVersionId."&versionIdMergeTo=".$oVersion->iVersionId)."</td>\n";
echo " <td>".trim_description($oVersion->sDescription)."</td>\n";
echo " <td>".util_trim_description($oVersion->sDescription)."</td>\n";
echo " <td align=center>".$oVersion->sTestedRating."</td>\n";
echo " <td align=center>".$oVersion->sTestedRelease."</td>\n";
echo " <td align=center>".sizeof($oVersion->aCommentsIds)."</td>\n";
@@ -302,7 +302,7 @@ if ($aClean['sub'])
{
echo html_frame_start("Potential duplicate versions in the database","90%","",0);
$oAppForVersion = new Application($oVersion->iAppId);
display_approved_versions($oAppForVersion->aVersionsIds);
Version::display_approved($oAppForVersion->aVersionsIds);
echo html_frame_end("&nbsp;");
echo html_frame_start("Move test to version","90%","",0);
@@ -456,7 +456,7 @@ else /* if ($aClean['sub']) is not defined, display the main app queue page */
echo "</td></tr></table></div>\n\n";
//show applist
showAppList($hResult);
Application::showList($hResult);
}
@@ -482,7 +482,7 @@ else /* if ($aClean['sub']) is not defined, display the main app queue page */
echo "</td></tr></table></div>\n\n";
//show version list
showVersionList($hResult);
Version::showList($hResult);
}
}

View File

@@ -115,12 +115,12 @@ if ($aClean['sub'])
echo " <td><a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a></td>\n";
if($ob->superMaintainer)
{
echo " <td><a href='".BASE."appview.php?appId=$ob->appId'>".lookup_app_name($ob->appId)."</a></td>\n";
echo " <td><a href='".BASE."appview.php?appId=$ob->appId'>".Application::lookup_name($ob->appId)."</a></td>\n";
echo " <td>*</td>\n";
} else
{
echo " <td><a href='".BASE."appview.php?appId=$ob->appId'>".lookup_app_name($ob->appId)."</a></td>\n";
echo " <td><a href='".BASE."appview.php?versionId=$ob->versionId'>".lookup_version_name($ob->versionId)."</a>&nbsp;</td>\n";
echo " <td><a href='".BASE."appview.php?appId=$ob->appId'>".Application::lookup_name($ob->appId)."</a></td>\n";
echo " <td><a href='".BASE."appview.php?versionId=$ob->versionId'>".Version::lookup_name($ob->versionId)."</a>&nbsp;</td>\n";
}
echo " <td align=\"center\">[<a href='adminMaintainers.php?sub=delete&maintainerId=$ob->maintainerId'>delete</a>]</td>\n";
echo "</tr>\n\n";

View File

@@ -115,7 +115,7 @@ if($apps)
$bgcolor = ($i % 2) ? "color0" : "color1";
//format desc
$desc = trim_description($oApp->sDescription);
$desc = util_trim_description($oApp->sDescription);
//display row
echo "<tr class=$bgcolor>\n";

View File

@@ -317,7 +317,7 @@ if ($aClean['sub'])
{
$oAppForVersion = new Application($oVersion->iAppId);
echo html_frame_start("Potential duplicate versions in the database for application: ".$oAppForVersion->sName,"90%","",0);
display_approved_versions($oAppForVersion->aVersionsIds);
Version::display_approved($oAppForVersion->aVersionsIds);
echo html_frame_end("&nbsp;");
//help
@@ -421,7 +421,7 @@ else // if ($aClean['sub']) is not defined, display the main app queue page
echo "</td></tr></table></div>\n\n";
//show applist
showAppList($hResult);
Application::showList($hResult);
}
// get queued versions (only versions where application are not queued already)

View File

@@ -72,7 +72,7 @@ function display_bundle($iAppId)
//display row
echo "<tr class=\"$bgcolor\">\n";
echo " <td><a href=\"appview.php?appId=$ob->appId\">".stripslashes($ob->appName)."</a></td>\n";
echo " <td>".trim_description($oApp->sDescription)."</td>\n";
echo " <td>".util_trim_description($oApp->sDescription)."</td>\n";
echo "</tr>\n\n";
$c++;

View File

@@ -657,65 +657,25 @@ class Application {
echo html_frame_end("For more details and user comments, view the versions of this application.");
// display versions
display_approved_versions($this->aVersionsIds);
Version::display_approved($this->aVersionsIds);
// display bundle
display_bundle($this->iAppId);
}
}
function lookup_name($appId)
{
if(!$appId) return null;
$result = query_parameters("SELECT appName FROM appFamily WHERE appId = '?'",
$appId);
if(!$result || mysql_num_rows($result) != 1)
return null;
$ob = mysql_fetch_object($result);
return $ob->appName;
}
/*
* Application functions that are not part of the class
*/
function lookup_version_name($versionId)
{
if(!$versionId) return null;
$result = query_parameters("SELECT versionName FROM appVersion WHERE versionId = '?'",
$versionId);
if(!$result || mysql_num_rows($result) != 1)
return null;
$ob = mysql_fetch_object($result);
return $ob->versionName;
}
function lookup_app_name($appId)
{
if(!$appId) return null;
$result = query_parameters("SELECT appName FROM appFamily WHERE appId = '?'",
$appId);
if(!$result || mysql_num_rows($result) != 1)
return null;
$ob = mysql_fetch_object($result);
return $ob->appName;
}
/**
* Remove html formatting from description and extract the first part of the description only.
* This is to be used for search results, application summary tables, etc.
*/
function trim_description($sDescription)
{
// 1) let's take the first line of the description:
$aDesc = explode("\n",trim($sDescription),2);
// 2) maybe it's an html description and lines are separated with <br> or </p><p>
$aDesc = explode("<br>",$aDesc[0],2);
$aDesc = explode("<br />",$aDesc[0],2);
$aDesc = explode("</p><p>",$aDesc[0],2);
$aDesc = explode("</p><p /><p>",$aDesc[0],2);
return trim(strip_tags($aDesc[0]));
}
function GetDefaultApplicationDescription()
{
return "<p>Enter a description of the application here</p>";
}
function showAppList($hResult)
{
function showList($hResult)
{
//show applist
echo html_frame_start("","90%","",0);
echo "<table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\">
@@ -756,5 +716,7 @@ function showAppList($hResult)
}
echo "</table>\n\n";
echo html_frame_end("&nbsp;");
}
}
?>

View File

@@ -198,14 +198,15 @@ class Bug {
if($this->iSubmitterId)
{
$oSubmitter = new User($this->iSubmitterId);
$sAppName = Application::lookup_name($this->iAppId)." ".Version::lookup_name($this->iVersionId);
if(!$bRejected)
{
$sSubject = "Submitted Bug Link accepted";
$sMsg = "The Bug Link you submitted for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." has been accepted.";
$sMsg = "The Bug Link you submitted for ".$sAppName." has been accepted.";
} else
{
$sSubject = "Submitted Bug Link rejected";
$sMsg = "The Bug Link you submitted for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." has been rejected.";
$sMsg = "The Bug Link you submitted for ".$sAppName." has been rejected.";
}
$sMsg .= $aClean['replyText']."\n";
$sMsg .= "We appreciate your help in making the Application Database better for all users.";
@@ -217,11 +218,12 @@ class Bug {
function SendNotificationMail($bDeleted=false)
{
$sAppName = Application::lookup_name($this->iAppId)." ".Version::lookup_name($this->iVersionId);
if(!$bDeleted)
{
if(!$this->bQueued)
{
$sSubject = "Link between Bug ".$this->iBug_id." and ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." added by ".$_SESSION['current']->sRealname;
$sSubject = "Link between Bug ".$this->iBug_id." and ".$sAppName." added by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
if($this->iSubmitterId)
{
@@ -232,7 +234,7 @@ class Bug {
addmsg("The Bug Link was successfully added into the database.", "green");
} else // Bug Link queued.
{
$sSubject = "Link between Bug ".$this->iBug_id." and ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." submitted by ".$_SESSION['current']->sRealname;
$sSubject = "Link between Bug ".$this->iBug_id." and ".$sAppName." submitted by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
$sMsg .= "This Bug Link has been queued.";
$sMsg .= "\n";
@@ -240,7 +242,7 @@ class Bug {
}
} else // Bug Link deleted.
{
$sSubject = "Link between Bug ".$this->iBug_id." and ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." deleted by ".$_SESSION['current']->sRealname;
$sSubject = "Link between Bug ".$this->iBug_id." and ".$sAppName." deleted by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
addmsg("Bug Link deleted.", "green");
}

View File

@@ -84,7 +84,7 @@ class Comment {
$sEmail.="$value ";
}
$sSubject = "Comment for '".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)."' added by ".$_SESSION['current']->sRealname;
$sSubject = "Comment for '".Application::lookup_name($this->iAppId)." ".Version::lookup_name($this->iVersionId)."' added by ".$_SESSION['current']->sRealname;
$sMsg = "To reply to this email please use the link provided below.\n";
$sMsg .= "DO NOT reply via your email client as it will not reach the person who wrote the comment\n";
$sMsg .= APPDB_ROOT."appview.php?versionId=".$this->iVersionId."&mode=nested#Comment-".$this->iCommentId."\n";
@@ -165,7 +165,7 @@ class Comment {
$sEmail .= $this->oOwner->sEmail;
if($sEmail)
{
$sSubject = "Comment for '".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)."' deleted by ".$_SESSION['current']->sRealname;
$sSubject = "Comment for '".Application::lookup_name($this->iAppId)." ".Version::lookup_name($this->iVersionId)."' deleted by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
$sMsg .= "\n";
$sMsg .= "This comment was made on ".substr($this->sDateCreated,0,10)." by ".$this->oOwner->sRealname."\n";

View File

@@ -93,19 +93,25 @@ class Monitor {
function SendNotificationMail($sAction="add",$sMsg=null)
{
/* set $aAppName appropriately */
if(isset($this->iVersionId))
$sAppName = Application::lookup_name($oVersion->iAppId)." ".Version::lookup_name($this->iVersionId);
else
$sAppName = Application::lookup_name($oVersion->iAppId);
switch($sAction)
{
case "add":
if (isset($this->iVersionId))
{
$oVersion = new Version($this->iVersionId);
$sSubject = "Monitor for ".lookup_app_name($oVersion->iAppId)." ".lookup_version_name($this->iVersionId);
$sSubject = "Monitor for ".$sAppName;
$sSubject .= " added: ".$_SESSION['current']->sRealname;
$sMsg .= APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
addmsg("You will now recieve an email whenever changes are made to this Application version.", "green");
} else
{
$sSubject = "Monitor for ".lookup_app_name($this->iAppId)." added: ".$_SESSION['current']->sRealname;
$sSubject = "Monitor for ".$sAppName." added: ".$_SESSION['current']->sRealname;
$sMsg .= APPDB_ROOT."appview.php?appId=".$this->iAppid."\n";
addmsg("You will now recieve an email whenever changes are made to this Application.", "green");
}
@@ -114,13 +120,13 @@ class Monitor {
if (isset($this->iVersionId))
{
$oVersion = new Version($this->iVersionId);
$sSubject = "Monitor for ".lookup_app_name($oVersion->iAppId)." ".lookup_version_name($this->iVersionId);
$sSubject = "Monitor for ".$sAppName;
$sSubject .= " removed: ".$_SESSION['current']->sRealname;
$sMsg .= APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
addmsg("You will no longer recieve an email whenever changes are made to this Application version.", "green");
} else
{
$sSubject = "Monitor for ".lookup_app_name($this->iAppId)." removed: ".$_SESSION['current']->sRealname;
$sSubject = "Monitor for ".$sAppName." removed: ".$_SESSION['current']->sRealname;
$sMsg .= APPDB_ROOT."appview.php?appId=".$this->iAppid."\n";
addmsg("You will no longer recieve an email whenever changes are made to this Application.", "green");
}

View File

@@ -125,19 +125,20 @@ class Note {
function SendNotificationMail($sAction="add",$sMsg=null)
{
$sAppName = Application::lookup_name($this->iAppId)." ".Version::lookup_name($this->iVersionId);
switch($sAction)
{
case "add":
$sSubject = "Note ".$this->sTitle." for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." added by ".$_SESSION['current']->sRealname;
$sSubject = "Note ".$this->sTitle." for ".$sAppName." added by ".$_SESSION['current']->sRealname;
$sMsg .= APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
addmsg("The note was successfully added into the database.", "green");
break;
case "edit":
$sSubject = "Note ".$this->sTitle." for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." has been modified by ".$_SESSION['current']->sRealname;
$sSubject = "Note ".$this->sTitle." for ".$sAppName." has been modified by ".$_SESSION['current']->sRealname;
addmsg("Note modified.", "green");
break;
case "delete":
$sSubject = "Note ".$this->sTitle." for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." has been deleted by ".$_SESSION['current']->sRealname;
$sSubject = "Note ".$this->sTitle." for ".$sAppName." has been deleted by ".$_SESSION['current']->sRealname;
$sMsg .= "This note was made on ".substr($this->sDateCreated,0,10)." by ".$this->oOwner->sRealname."\n";
$sMsg .= "\n";
$sMsg .= "Subject: ".$this->sTitle."\n";

View File

@@ -240,15 +240,16 @@ class Screenshot {
if($this->iSubmitterId)
{
$sAppName = Application::lookup_name($this->iAppId)." ".Version::lookup_name($this->iVersionId);
$oSubmitter = new User($this->iSubmitterId);
if(!$bRejected)
{
$sSubject = "Submitted screenshot accepted";
$sMsg = "The screenshot you submitted for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." has been accepted.";
$sMsg = "The screenshot you submitted for ".$sAppName." has been accepted.";
} else
{
$sSubject = "Submitted screenshot rejected";
$sMsg = "The screenshot you submitted for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." has been rejected.";
$sMsg = "The screenshot you submitted for ".$sAppName." has been rejected.";
}
$sMsg .= $aClean['replyText']."\n";
$sMsg .= "We appreciate your help in making the Application Database better for all users.";
@@ -260,11 +261,12 @@ class Screenshot {
function mailMaintainers($bDeleted=false)
{
$sAppName = Application::lookup_name($this->iAppId)." ".Version::lookup_name($this->iVersionId);
if(!$bDeleted)
{
if(!$this->bQueued)
{
$sSubject = "Screenshot for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." added by ".$_SESSION['current']->sRealname;
$sSubject = "Screenshot for ".$sAppName." added by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
if($this->iSubmitterId)
{
@@ -275,7 +277,7 @@ class Screenshot {
addmsg("The screenshot was successfully added into the database.", "green");
} else // Screenshot queued.
{
$sSubject = "Screenshot for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." submitted by ".$_SESSION['current']->sRealname;
$sSubject = "Screenshot for ".$sAppName." submitted by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
$sMsg .= "This screenshot has been queued.";
$sMsg .= "\n";
@@ -283,7 +285,7 @@ class Screenshot {
}
} else // Screenshot deleted.
{
$sSubject = "Screenshot for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." deleted by ".$_SESSION['current']->sRealname;
$sSubject = "Screenshot for ".$sAppName." deleted by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
addmsg("Screenshot deleted.", "green");
}

View File

@@ -27,9 +27,9 @@ function global_sidebar_login() {
while(list($index, list($appId, $versionId, $superMaintainer)) = each($apps_user_maintains))
{
if($superMaintainer)
$g->addmisc("<a href='".BASE."appview.php?appId=$appId'>".lookup_app_name($appId)."*</a>", "center");
$g->addmisc("<a href='".BASE."appview.php?appId=$appId'>".Application::lookup_name($appId)."*</a>", "center");
else
$g->addmisc("<a href='".BASE."appview.php?versionId=$versionId'>".lookup_app_name($appId)." ".lookup_version_name($versionId)."</a>", "center");
$g->addmisc("<a href='".BASE."appview.php?versionId=$versionId'>".Application::lookup_name($appId)." ".Version::lookup_name($versionId)."</a>", "center");
}
}
$appsRejected = $_SESSION['current']->getAllRejectedApps();

View File

@@ -185,15 +185,16 @@ class Url {
$aClean['replyText'] = makeSafe($_REQUEST['replyText']);
if($this->iSubmitterId)
{
$sAppName = Application::lookup_name($this->appId)." ".Version::lookup_name($this->versionId);
$oSubmitter = new User($this->iSubmitterId);
if(!$bRejected)
{
$sSubject = "Submitted url accepted";
$sMsg = "The url you submitted for ".lookup_app_name($this->appId)." ".lookup_version_name($this->versionId)." has been accepted.";
$sMsg = "The url you submitted for ".$sAppName." has been accepted.";
} else
{
$sSubject = "Submitted url rejected";
$sMsg = "The url you submitted for ".lookup_app_name($this->appId)." ".lookup_version_name($this->versionId)." has been rejected.";
$sMsg = "The url you submitted for ".$sAppName." has been rejected.";
}
$sMsg .= $aClean['replyText']."\n";
$sMsg .= "We appreciate your help in making the Application Database better for all users.";
@@ -205,11 +206,12 @@ class Url {
function SendNotificationMail($bDeleted=false)
{
$sAppName = Application::lookup_name($this->appId)." ".Version::lookup_name($this->versionId);
if(!$bDeleted)
{
if(!$this->bQueued)
{
$sSubject = "Url for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." added by ".$_SESSION['current']->sRealname;
$sSubject = "Url for ".$sAppName." added by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
if($this->iSubmitterId)
{
@@ -220,7 +222,7 @@ class Url {
addmsg("The url was successfully added into the database.", "green");
} else // Url queued.
{
$sSubject = "Url for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." submitted by ".$_SESSION['current']->sRealname;
$sSubject = "Url for ".$sAppName." submitted by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
$sMsg .= "This url has been queued.";
$sMsg .= "\n";
@@ -228,7 +230,7 @@ class Url {
}
} else // Url deleted.
{
$sSubject = "Url for ".lookup_app_name($this->iAppId)." ".lookup_version_name($this->iVersionId)." deleted by ".$_SESSION['current']->sRealname;
$sSubject = "Url for ".$sAppName." deleted by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?versionId=".$this->iVersionId."\n";
addmsg("Url deleted.", "green");
}

View File

@@ -271,7 +271,7 @@ function outputTopXRow($oRow)
echo '
<tr class="white">
<td class="app_name"><a href="appview.php?versionId='.$oRow->versionId.'">'.$oApp->sName.' '.$oVersion->sName.'</a></td>
<td>'.trim_description($oApp->sDescription).'</td>
<td>'.util_trim_description($oApp->sDescription).'</td>
<td><center>'.$img.'</center></td>
</tr>';
}
@@ -542,7 +542,7 @@ function outputSearchTableForhResult($search_words, $hResult)
//display row
echo "<tr class=$bgcolor>\n";
echo " <td>".html_ahref($oRow->appName,BASE."appview.php?appId=$oRow->appId")."</td>\n";
echo " <td>".trim_description($oRow->description)."</td>\n";
echo " <td>".util_trim_description($oRow->description)."</td>\n";
echo " <td>$y->versions &nbsp;</td>\n";
echo "</tr>\n\n";
@@ -981,4 +981,20 @@ function HtmlAreaLoaderScript($aTextareas)
$outputIndex++; /* increment the output index */
}
/**
* Remove html formatting from description and extract the first part of the description only.
* This is to be used for search results, application summary tables, etc.
*/
function util_trim_description($sDescription)
{
// 1) let's take the first line of the description:
$aDesc = explode("\n",trim($sDescription),2);
// 2) maybe it's an html description and lines are separated with <br> or </p><p>
$aDesc = explode("<br>",$aDesc[0],2);
$aDesc = explode("<br />",$aDesc[0],2);
$aDesc = explode("</p><p>",$aDesc[0],2);
$aDesc = explode("</p><p /><p>",$aDesc[0],2);
return trim(strip_tags($aDesc[0]));
}
?>

View File

@@ -838,10 +838,20 @@ class Version {
// Comments Section
view_app_comments($this->iVersionId);
}
}
function showVersionList($hResult)
{
function lookup_name($versionId)
{
if(!$versionId) return null;
$result = query_parameters("SELECT versionName FROM appVersion WHERE versionId = '?'",
$versionId);
if(!$result || mysql_num_rows($result) != 1)
return null;
$ob = mysql_fetch_object($result);
return $ob->versionName;
}
function showList($hResult)
{
//show applist
echo html_frame_start("","90%","",0);
echo "<table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\">
@@ -879,49 +889,48 @@ function showVersionList($hResult)
}
echo "</table>\n\n";
echo html_frame_end("&nbsp;");
}
}
// display the versions
// Used in appview.php appsubmit.php and adminAppQueue.php
function display_approved_versions($aVersionsIds)
{
if ($aVersionsIds)
// display the versions
function display_approved($aVersionsIds)
{
echo html_frame_start("","98%","",0);
echo "<table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n\n";
echo "<tr class=color4>\n";
echo " <td width=\"80\">Version</td>\n";
echo " <td>Description</td>\n";
echo " <td width=\"80\">Rating</td>\n";
echo " <td width=\"80\">Wine version</td>\n";
echo " <td width=\"40\">Comments</td>\n";
echo "</tr>\n\n";
$c = 0;
foreach($aVersionsIds as $iVersionId)
if ($aVersionsIds)
{
$oVersion = new Version($iVersionId);
if ($oVersion->sQueued == 'false')
echo html_frame_start("","98%","",0);
echo "<table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n\n";
echo "<tr class=color4>\n";
echo " <td width=\"80\">Version</td>\n";
echo " <td>Description</td>\n";
echo " <td width=\"80\">Rating</td>\n";
echo " <td width=\"80\">Wine version</td>\n";
echo " <td width=\"40\">Comments</td>\n";
echo "</tr>\n\n";
$c = 0;
foreach($aVersionsIds as $iVersionId)
{
// set row color
$bgcolor = ($c % 2 == 0) ? "color0" : "color1";
$oVersion = new Version($iVersionId);
if ($oVersion->sQueued == 'false')
{
// set row color
$bgcolor = ($c % 2 == 0) ? "color0" : "color1";
//display row
echo "<tr class=$bgcolor>\n";
echo " <td><a href=\"".BASE."appview.php?versionId=".$iVersionId."\">".$oVersion->sName."</a></td>\n";
echo " <td>".trim_description($oVersion->sDescription)."</td>\n";
echo " <td align=center>".$oVersion->sTestedRating."</td>\n";
echo " <td align=center>".$oVersion->sTestedRelease."</td>\n";
echo " <td align=center>".sizeof($oVersion->aCommentsIds)."</td>\n";
echo "</tr>\n\n";
//display row
echo "<tr class=$bgcolor>\n";
echo " <td><a href=\"".BASE."appview.php?versionId=".$iVersionId."\">".$oVersion->sName."</a></td>\n";
echo " <td>".util_trim_description($oVersion->sDescription)."</td>\n";
echo " <td align=center>".$oVersion->sTestedRating."</td>\n";
echo " <td align=center>".$oVersion->sTestedRelease."</td>\n";
echo " <td align=center>".sizeof($oVersion->aCommentsIds)."</td>\n";
echo "</tr>\n\n";
$c++;
$c++;
}
}
echo "</table>\n";
echo html_frame_end("Click the Version Name to view the details of that Version");
}
echo "</table>\n";
echo html_frame_end("Click the Version Name to view the details of that Version");
}
}

View File

@@ -126,8 +126,8 @@ function vote_menu()
{
if(isset($votes[$i]))
{
$appName = lookup_app_name($votes[$i]->appId);
$str = "<a href='appview.php?appId=".$votes[$i]->appId."'> $appName</a>";
$sAppName = Application::lookup_name($votes[$i]->appId);
$str = "<a href='appview.php?appId=".$votes[$i]->appId."'> $sAppName</a>";
$m->add("<input type=radio name=slot value='$i'> ".$str);
}
else