From 034ea689bc90d00acfd6789712c294240145c00e Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Thu, 29 Jun 2006 16:07:19 +0000 Subject: [PATCH] Clean up application and version classes. Move class related functions into the class as static member functions --- admin/adminAppDataQueue.php | 12 +++--- admin/adminAppQueue.php | 8 ++-- admin/adminMaintainers.php | 6 +-- appbrowse.php | 2 +- appsubmit.php | 4 +- appview.php | 2 +- include/application.php | 68 +++++++---------------------- include/bugs.php | 12 +++--- include/comment.php | 4 +- include/monitor.php | 14 ++++-- include/note.php | 7 +-- include/screenshot.php | 12 +++--- include/sidebar_login.php | 4 +- include/url.php | 12 +++--- include/util.php | 20 ++++++++- include/version.php | 85 ++++++++++++++++++++----------------- include/vote.php | 4 +- 17 files changed, 138 insertions(+), 138 deletions(-) diff --git a/admin/adminAppDataQueue.php b/admin/adminAppDataQueue.php index 06b4802..396708c 100644 --- a/admin/adminAppDataQueue.php +++ b/admin/adminAppDataQueue.php @@ -73,8 +73,8 @@ if (!$aClean['id']) echo $oUser->sRealname; echo $oUser->sEmail ? "":""; echo "\n"; - echo "".lookup_app_name($ob->appId)."\n"; - echo "".lookup_version_name($ob->versionId)."\n"; + echo "".Application::lookup_name($ob->appId)."\n"; + echo "".Version::lookup_name($ob->versionId)."\n"; echo "".$ob->type."\n"; echo "[process]\n"; echo "\n\n"; @@ -105,11 +105,11 @@ if (!$aClean['id']) // app name echo 'App Name',"\n"; - echo "".lookup_app_name($obj_row->appId)."\n"; + echo "".Application::lookup_name($obj_row->appId)."\n"; // version echo 'App Version',"\n"; - echo "".lookup_version_name($obj_row->versionId)."\n"; + echo "".Version::lookup_name($obj_row->versionId)."\n"; //dataDescription echo 'Description',"\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); } diff --git a/admin/adminAppQueue.php b/admin/adminAppQueue.php index b929afe..34a57aa 100644 --- a/admin/adminAppQueue.php +++ b/admin/adminAppQueue.php @@ -115,7 +115,7 @@ function display_move_test_to_versions_table($aVersionsIds,$icurrentVersionId) echo "\n"; echo " ".html_ahref($oVersion->sName,"adminAppQueue.php?sub=movetest&apptype=version&versionId=".$icurrentVersionId."&versionIdMergeTo=".$oVersion->iVersionId)."\n"; - echo " ".trim_description($oVersion->sDescription)."\n"; + echo " ".util_trim_description($oVersion->sDescription)."\n"; echo " ".$oVersion->sTestedRating."\n"; echo " ".$oVersion->sTestedRelease."\n"; echo " ".sizeof($oVersion->aCommentsIds)."\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(" "); 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 "\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 "\n\n"; //show version list - showVersionList($hResult); + Version::showList($hResult); } } diff --git a/admin/adminMaintainers.php b/admin/adminMaintainers.php index cfe5108..813a3c2 100644 --- a/admin/adminMaintainers.php +++ b/admin/adminMaintainers.php @@ -115,12 +115,12 @@ if ($aClean['sub']) echo " sEmail."\">".$oUser->sRealname."\n"; if($ob->superMaintainer) { - echo " ".lookup_app_name($ob->appId)."\n"; + echo " ".Application::lookup_name($ob->appId)."\n"; echo " *\n"; } else { - echo " ".lookup_app_name($ob->appId)."\n"; - echo " ".lookup_version_name($ob->versionId)." \n"; + echo " ".Application::lookup_name($ob->appId)."\n"; + echo " ".Version::lookup_name($ob->versionId)." \n"; } echo " [delete]\n"; echo "\n\n"; diff --git a/appbrowse.php b/appbrowse.php index 23e8eef..fc2a3f2 100644 --- a/appbrowse.php +++ b/appbrowse.php @@ -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 "\n"; diff --git a/appsubmit.php b/appsubmit.php index f2c23b9..bd7daa0 100644 --- a/appsubmit.php +++ b/appsubmit.php @@ -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(" "); //help @@ -421,7 +421,7 @@ else // if ($aClean['sub']) is not defined, display the main app queue page echo "\n\n"; //show applist - showAppList($hResult); + Application::showList($hResult); } // get queued versions (only versions where application are not queued already) diff --git a/appview.php b/appview.php index 479a3e8..8712d9c 100644 --- a/appview.php +++ b/appview.php @@ -72,7 +72,7 @@ function display_bundle($iAppId) //display row echo "\n"; echo " appId\">".stripslashes($ob->appName)."\n"; - echo " ".trim_description($oApp->sDescription)."\n"; + echo " ".util_trim_description($oApp->sDescription)."\n"; echo "\n\n"; $c++; diff --git a/include/application.php b/include/application.php index 7193dd3..02ee4c8 100644 --- a/include/application.php +++ b/include/application.php @@ -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
or

- $aDesc = explode("
",$aDesc[0],2); - $aDesc = explode("
",$aDesc[0],2); - $aDesc = explode("

",$aDesc[0],2); - $aDesc = explode("

",$aDesc[0],2); - return trim(strip_tags($aDesc[0])); -} - -function GetDefaultApplicationDescription() -{ - return "

Enter a description of the application here

"; -} - -function showAppList($hResult) -{ + function showList($hResult) + { //show applist echo html_frame_start("","90%","",0); echo " @@ -756,5 +716,7 @@ function showAppList($hResult) } echo "
\n\n"; echo html_frame_end(" "); + } } + ?> diff --git a/include/bugs.php b/include/bugs.php index 0b82036..de2a665 100644 --- a/include/bugs.php +++ b/include/bugs.php @@ -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"); } diff --git a/include/comment.php b/include/comment.php index 373910a..181309f 100644 --- a/include/comment.php +++ b/include/comment.php @@ -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"; diff --git a/include/monitor.php b/include/monitor.php index 23f6880..594a59a 100644 --- a/include/monitor.php +++ b/include/monitor.php @@ -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"); } diff --git a/include/note.php b/include/note.php index 4511dff..e780946 100644 --- a/include/note.php +++ b/include/note.php @@ -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"; diff --git a/include/screenshot.php b/include/screenshot.php index b12c05b..c088e8a 100644 --- a/include/screenshot.php +++ b/include/screenshot.php @@ -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"); } diff --git a/include/sidebar_login.php b/include/sidebar_login.php index f56ff8d..d62dbb0 100644 --- a/include/sidebar_login.php +++ b/include/sidebar_login.php @@ -27,9 +27,9 @@ function global_sidebar_login() { while(list($index, list($appId, $versionId, $superMaintainer)) = each($apps_user_maintains)) { if($superMaintainer) - $g->addmisc("".lookup_app_name($appId)."*", "center"); + $g->addmisc("".Application::lookup_name($appId)."*", "center"); else - $g->addmisc("".lookup_app_name($appId)." ".lookup_version_name($versionId)."", "center"); + $g->addmisc("".Application::lookup_name($appId)." ".Version::lookup_name($versionId)."", "center"); } } $appsRejected = $_SESSION['current']->getAllRejectedApps(); diff --git a/include/url.php b/include/url.php index 9e3ab18..378a379 100644 --- a/include/url.php +++ b/include/url.php @@ -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"); } diff --git a/include/util.php b/include/util.php index e9c6881..1fb3142 100644 --- a/include/util.php +++ b/include/util.php @@ -271,7 +271,7 @@ function outputTopXRow($oRow) echo ' '.$oApp->sName.' '.$oVersion->sName.' - '.trim_description($oApp->sDescription).' + '.util_trim_description($oApp->sDescription).'
'.$img.'
'; } @@ -542,7 +542,7 @@ function outputSearchTableForhResult($search_words, $hResult) //display row echo "\n"; echo " ".html_ahref($oRow->appName,BASE."appview.php?appId=$oRow->appId")."\n"; - echo " ".trim_description($oRow->description)."\n"; + echo " ".util_trim_description($oRow->description)."\n"; echo " $y->versions  \n"; echo "\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
or

+ $aDesc = explode("
",$aDesc[0],2); + $aDesc = explode("
",$aDesc[0],2); + $aDesc = explode("

",$aDesc[0],2); + $aDesc = explode("

",$aDesc[0],2); + return trim(strip_tags($aDesc[0])); +} + ?> diff --git a/include/version.php b/include/version.php index 229be4e..3dfe4fd 100644 --- a/include/version.php +++ b/include/version.php @@ -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 " @@ -879,49 +889,48 @@ function showVersionList($hResult) } echo "
\n\n"; echo html_frame_end(" "); + } -} - -// 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 "\n\n"; - - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\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 "
VersionDescriptionRatingWine versionComments
\n\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\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 "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; + //display row + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; - $c++; + $c++; + } } + echo "
VersionDescriptionRatingWine versionComments
".$oVersion->sName."".trim_description($oVersion->sDescription)."".$oVersion->sTestedRating."".$oVersion->sTestedRelease."".sizeof($oVersion->aCommentsIds)."
".$oVersion->sName."".util_trim_description($oVersion->sDescription)."".$oVersion->sTestedRating."".$oVersion->sTestedRelease."".sizeof($oVersion->aCommentsIds)."
\n"; + echo html_frame_end("Click the Version Name to view the details of that Version"); } - echo "\n"; - echo html_frame_end("Click the Version Name to view the details of that Version"); } } diff --git a/include/vote.php b/include/vote.php index 03b8460..a4a0504 100644 --- a/include/vote.php +++ b/include/vote.php @@ -126,8 +126,8 @@ function vote_menu() { if(isset($votes[$i])) { - $appName = lookup_app_name($votes[$i]->appId); - $str = " $appName"; + $sAppName = Application::lookup_name($votes[$i]->appId); + $str = " $sAppName"; $m->add(" ".$str); } else