Screenshot class cleanups. Move screenshot related functions into the class. Rename get_screenshot_img() to

get_random_screenshot_img() so the name of the function matches its purpose
This commit is contained in:
Chris Morgan
2006-07-11 03:37:07 +00:00
committed by WineHQ
parent d831939a07
commit 160f739da8
7 changed files with 112 additions and 115 deletions

View File

@@ -118,7 +118,8 @@ while ($oRow = mysql_fetch_object($Ids))
// display thumbnail // display thumbnail
$oVersion = new version($oRow->versionId); $oVersion = new version($oRow->versionId);
$oApp = new Application($oVersion->iAppId); $oApp = new Application($oVersion->iAppId);
$img = get_thumbnail($oRow->id); $oScreenshot = new Screenshot($oRow->id);
$img = $oScreenshot->get_thumbnail_img();
echo "<td align=center>\n"; echo "<td align=center>\n";
echo $img; echo $img;
echo "<div align=center>". substr($oRow->description,0,20). "\n"; echo "<div align=center>". substr($oRow->description,0,20). "\n";

View File

@@ -545,7 +545,7 @@ class Application {
} }
// image // image
$img = get_screenshot_img($this->iAppId); $img = Screenshot::get_random_screenshot_img($this->iAppId);
echo "<tr><td align=\"center\" colspan=\"2\">$img</td></tr>\n"; echo "<tr><td align=\"center\" colspan=\"2\">$img</td></tr>\n";
echo " </table>\n"; /* close of name/vendor/bugs/url table */ echo " </table>\n"; /* close of name/vendor/bugs/url table */

View File

@@ -359,12 +359,6 @@ class Screenshot {
if($sEmail) if($sEmail)
mail_appdb($sEmail, $sSubject ,$sMsg); mail_appdb($sEmail, $sSubject ,$sMsg);
} }
}
/*
* Screenshot functions that are not part of the class
*/
/** /**
* Get a random image for a particular version of an app. * Get a random image for a particular version of an app.
@@ -372,7 +366,7 @@ class Screenshot {
* *
* $bFormatting == false turns off all extranious formatting applied to the returned image html * $bFormatting == false turns off all extranious formatting applied to the returned image html
*/ */
function get_screenshot_img($iAppId = null, $iVersionId = null, function get_random_screenshot_img($iAppId = null, $iVersionId = null,
$bFormatting = true) $bFormatting = true)
{ {
// we want a random screenshots for this app // we want a random screenshots for this app
@@ -467,34 +461,34 @@ function get_screenshots($iAppId = null, $iVersionId = null, $bQueued = "false")
return $hResult; return $hResult;
} }
function get_thumbnail($id) function get_thumbnail_img()
{ {
$oScreenshot = new Screenshot($id);
// generate random tag for popup window // generate random tag for popup window
$randName = User::generate_passwd(5); $sRandName = User::generate_passwd(5);
// set img tag // set img tag
$imgSRC = '<img src="'.apidb_fullurl("appimage.php"). $shImgSRC = '<img src="'.apidb_fullurl("appimage.php").
'?bThumbnail=true&iId='.$id.'" alt="'.$oScreenshot->sDescription. '?bThumbnail=true&iId='.$this->iScreenshotId.'" alt="'.$this->sDescription.
'" width="'.$oScreenshot->get_thumbnail_width(). '" width="'.$this->get_thumbnail_width().
'" height="'.$oScreenshot->get_thumbnail_height().'">'; '" height="'.$this->get_thumbnail_height().'">';
$img = '<a href="'.apidb_fullurl("appimage.php"). $shImg = '<a href="'.apidb_fullurl("appimage.php").
'?iId='.$id. '?iId='.$this->iScreenshotId.
'" onclick="javascript:openWin(\''.apidb_fullurl("appimage.php"). '" onclick="javascript:openWin(\''.apidb_fullurl("appimage.php").
'?iId='.$id.'\',\''.$randName.'\','. '?iId='.$this->iScreenshotId.'\',\''.$sRandName.'\','.
($oScreenshot->get_screenshot_width() + 20).','. ($this->get_screenshot_width() + 20).','.
($oScreenshot->get_screenshot_height() + 6). ($this->get_screenshot_height() + 6).
');return false;">'.$imgSRC.'</a>'; ');return false;">'.$shImgSRC.'</a>';
// set image link based on user pref // set image link based on user pref
if ($_SESSION['current']->isLoggedIn()) if ($_SESSION['current']->isLoggedIn())
{ {
if ($_SESSION['current']->getpref("window:screenshot") == "no") if ($_SESSION['current']->getpref("window:screenshot") == "no")
{ {
$img = '<a href="'.apidb_fullurl("appimage.php"). $shImg = '<a href="'.apidb_fullurl("appimage.php").
'?iImageId='.$id.'">'.$imgSRC.'</a>'; '?iImageId='.$this->iScreenshotId.'">'.$shImgSRC.'</a>';
} }
} }
return $img; return $shImg;
} }
}
?> ?>

View File

@@ -291,7 +291,7 @@ function outputTopXRow($oRow)
{ {
$oVersion = new Version($oRow->versionId); $oVersion = new Version($oRow->versionId);
$oApp = new Application($oVersion->iAppId); $oApp = new Application($oVersion->iAppId);
$img = get_screenshot_img(null, $oRow->versionId, false); // image, disable extra formatting $img = Screenshot::get_random_screenshot_img(null, $oRow->versionId, false); // image, disable extra formatting
echo ' echo '
<tr class="white"> <tr class="white">
<td class="app_name"><a href="appview.php?iVersionId='.$oRow->versionId.'">'.$oApp->sName.' '.$oVersion->sName.'</a></td> <td class="app_name"><a href="appview.php?iVersionId='.$oRow->versionId.'">'.$oApp->sName.' '.$oVersion->sName.'</a></td>

View File

@@ -657,7 +657,7 @@ class Version {
echo "<tr class=\"color0\" valign=\"top\"><td><b>Maintainers Version</b></td><td>".$this->sTestedRelease."</td></tr>\n"; echo "<tr class=\"color0\" valign=\"top\"><td><b>Maintainers Version</b></td><td>".$this->sTestedRelease."</td></tr>\n";
// image // image
$img = get_screenshot_img($oApp->iAppId, $this->iVersionId); $img = Screenshot::get_random_screenshot_img($oApp->iAppId, $this->iVersionId);
echo "<tr><td align=\"center\" colspan=\"2\">$img</td></tr>\n"; echo "<tr><td align=\"center\" colspan=\"2\">$img</td></tr>\n";
// display all maintainers of this application // display all maintainers of this application

View File

@@ -52,7 +52,7 @@ if($aClean['sCmd'])
// we didn't issued any command // we didn't issued any command
$hResult = get_screenshots($aClean['iAppId'], $aClean['iVersionId']); $hResult = Screenshot::get_screenshots($aClean['iAppId'], $aClean['iVersionId']);
apidb_header("Screenshots"); apidb_header("Screenshots");
$oApp = new Application($aClean['iAppId']); $oApp = new Application($aClean['iAppId']);
$oVersion = new Version($aClean['iVersionId']); $oVersion = new Version($aClean['iVersionId']);
@@ -78,7 +78,8 @@ if($hResult && mysql_num_rows($hResult))
echo html_frame_start("Version ".Version::lookup_name($currentVersionId)); echo html_frame_start("Version ".Version::lookup_name($currentVersionId));
echo "<div align=center><table><tr>\n"; echo "<div align=center><table><tr>\n";
} }
$img = get_thumbnail($oRow->id); $oScreenshot = new Screenshot($oRow->id);
$img = $oScreenshot->get_thumbnail_img();
// display image // display image
echo "<td>\n"; echo "<td>\n";
echo $img; echo $img;

View File

@@ -69,7 +69,8 @@ while ($oRow = mysql_fetch_object($Ids))
// display thumbnail // display thumbnail
$oVersion = new version($oRow->versionId); $oVersion = new version($oRow->versionId);
$oApp = new Application($oVersion->iAppId); $oApp = new Application($oVersion->iAppId);
$img = get_thumbnail($oRow->id); $oScreenshot = new Screenshot($oRow->id);
$img = $oScreenshot->get_thumbnail_img();
echo "<td align=center>\n"; echo "<td align=center>\n";
echo $img; echo $img;
echo "<div align=center>". substr($oRow->description,0,20). "\n"; echo "<div align=center>". substr($oRow->description,0,20). "\n";