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
$oVersion = new version($oRow->versionId);
$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 $img;
echo "<div align=center>". substr($oRow->description,0,20). "\n";

View File

@@ -545,7 +545,7 @@ class Application {
}
// 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 " </table>\n"; /* close of name/vendor/bugs/url table */

View File

@@ -359,22 +359,16 @@ class Screenshot {
if($sEmail)
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.
* If the version is not set, get a random app image
*
* $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)
{
{
// we want a random screenshots for this app
if($iAppId && !$iVersionId)
{
@@ -432,10 +426,10 @@ function get_screenshot_img($iAppId = null, $iVersionId = null,
$sImg .= html_frame_end()."<br />";
return $sImg;
}
}
function get_screenshots($iAppId = null, $iVersionId = null, $bQueued = "false")
{
function get_screenshots($iAppId = null, $iVersionId = null, $bQueued = "false")
{
/*
* We want all screenshots for this app.
*/
@@ -465,36 +459,36 @@ function get_screenshots($iAppId = null, $iVersionId = null, $bQueued = "false")
}
return $hResult;
}
function get_thumbnail($id)
{
$oScreenshot = new Screenshot($id);
}
function get_thumbnail_img()
{
// generate random tag for popup window
$randName = User::generate_passwd(5);
$sRandName = User::generate_passwd(5);
// set img tag
$imgSRC = '<img src="'.apidb_fullurl("appimage.php").
'?bThumbnail=true&iId='.$id.'" alt="'.$oScreenshot->sDescription.
'" width="'.$oScreenshot->get_thumbnail_width().
'" height="'.$oScreenshot->get_thumbnail_height().'">';
$img = '<a href="'.apidb_fullurl("appimage.php").
'?iId='.$id.
$shImgSRC = '<img src="'.apidb_fullurl("appimage.php").
'?bThumbnail=true&iId='.$this->iScreenshotId.'" alt="'.$this->sDescription.
'" width="'.$this->get_thumbnail_width().
'" height="'.$this->get_thumbnail_height().'">';
$shImg = '<a href="'.apidb_fullurl("appimage.php").
'?iId='.$this->iScreenshotId.
'" onclick="javascript:openWin(\''.apidb_fullurl("appimage.php").
'?iId='.$id.'\',\''.$randName.'\','.
($oScreenshot->get_screenshot_width() + 20).','.
($oScreenshot->get_screenshot_height() + 6).
');return false;">'.$imgSRC.'</a>';
'?iId='.$this->iScreenshotId.'\',\''.$sRandName.'\','.
($this->get_screenshot_width() + 20).','.
($this->get_screenshot_height() + 6).
');return false;">'.$shImgSRC.'</a>';
// set image link based on user pref
if ($_SESSION['current']->isLoggedIn())
{
if ($_SESSION['current']->getpref("window:screenshot") == "no")
{
$img = '<a href="'.apidb_fullurl("appimage.php").
'?iImageId='.$id.'">'.$imgSRC.'</a>';
$shImg = '<a href="'.apidb_fullurl("appimage.php").
'?iImageId='.$this->iScreenshotId.'">'.$shImgSRC.'</a>';
}
}
return $img;
return $shImg;
}
}
?>

View File

@@ -291,7 +291,7 @@ function outputTopXRow($oRow)
{
$oVersion = new Version($oRow->versionId);
$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 '
<tr class="white">
<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";
// 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";
// display all maintainers of this application

View File

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

View File

@@ -69,7 +69,8 @@ while ($oRow = mysql_fetch_object($Ids))
// display thumbnail
$oVersion = new version($oRow->versionId);
$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 $img;
echo "<div align=center>". substr($oRow->description,0,20). "\n";