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,142 +359,136 @@ 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,
$bFormatting = true)
{
// we want a random screenshots for this app
if($iAppId && !$iVersionId)
/**
* 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_random_screenshot_img($iAppId = null, $iVersionId = null,
$bFormatting = true)
{
$hResult = query_parameters("SELECT appData.id, appData.description, RAND() AS rand
// we want a random screenshots for this app
if($iAppId && !$iVersionId)
{
$hResult = query_parameters("SELECT appData.id, appData.description, RAND() AS rand
FROM appData, appVersion
WHERE appData.versionId = appVersion.versionId
AND appVersion.appId = '?'
AND type = 'image'
AND appData.queued = 'false'
ORDER BY rand", $iAppId);
} else if ($iVersionId) // we want a random screenshot for this version
{
$hResult = query_parameters("SELECT id, description, RAND() AS rand
} else if ($iVersionId) // we want a random screenshot for this version
{
$hResult = query_parameters("SELECT id, description, RAND() AS rand
FROM appData
WHERE versionId = '?'
AND type = 'image'
AND queued = 'false'
ORDER BY rand", $iVersionId);
}
if($bFormatting)
$sImgFile .= '<center>';
if(!$hResult || !mysql_num_rows($hResult))
{
$sImgFile = '<img src="images/no_screenshot.png" alt="No Screenshot" />';
} else
{
$oRow = mysql_fetch_object($hResult);
$sImgFile = '<img src="appimage.php?bThumbnail=true&amp;iId='.$oRow->id.'" alt="'.$oRow->description.'" />';
}
if($bFormatting)
$sImgFile .= '</center>';
if($bFormatting)
$sImg = html_frame_start("",'128','',2);
/* we have screenshots */
if(mysql_num_rows($hResult))
{
if($iVersionId)
$sImg .= "<a href='screenshots.php?iAppId=$iAppId&amp;iVersionId=$iVersionId'>$sImgFile<center>View/Submit&nbsp;Screenshot</center></a>";
else
$sImg .= "<a href='screenshots.php?iAppId=$iAppId&amp;iVersionId=$iVersionId'>$sImgFile<center>View&nbsp;Screenshot</center></a>";
} else if($iVersionId) /* we are asking for a specific app version but it has no screenshots */
{
$sImg .= "<a href='screenshots.php?iAppId=$iAppId&amp;iVersionId=$iVersionId'>$sImgFile<center>Submit&nbsp;Screenshot</center></a>";
} else /* we have no screenshots and we aren't a specific version, we don't allow adding screenshots for an app */
{
$sImg .= $sImgFile;
}
if($bFormatting)
$sImg .= html_frame_end()."<br />";
return $sImg;
}
if($bFormatting)
$sImgFile .= '<center>';
if(!$hResult || !mysql_num_rows($hResult))
function get_screenshots($iAppId = null, $iVersionId = null, $bQueued = "false")
{
$sImgFile = '<img src="images/no_screenshot.png" alt="No Screenshot" />';
} else
{
$oRow = mysql_fetch_object($hResult);
$sImgFile = '<img src="appimage.php?bThumbnail=true&amp;iId='.$oRow->id.'" alt="'.$oRow->description.'" />';
}
if($bFormatting)
$sImgFile .= '</center>';
if($bFormatting)
$sImg = html_frame_start("",'128','',2);
/* we have screenshots */
if(mysql_num_rows($hResult))
{
if($iVersionId)
$sImg .= "<a href='screenshots.php?iAppId=$iAppId&amp;iVersionId=$iVersionId'>$sImgFile<center>View/Submit&nbsp;Screenshot</center></a>";
else
$sImg .= "<a href='screenshots.php?iAppId=$iAppId&amp;iVersionId=$iVersionId'>$sImgFile<center>View&nbsp;Screenshot</center></a>";
} else if($iVersionId) /* we are asking for a specific app version but it has no screenshots */
{
$sImg .= "<a href='screenshots.php?iAppId=$iAppId&amp;iVersionId=$iVersionId'>$sImgFile<center>Submit&nbsp;Screenshot</center></a>";
} else /* we have no screenshots and we aren't a specific version, we don't allow adding screenshots for an app */
{
$sImg .= $sImgFile;
}
if($bFormatting)
$sImg .= html_frame_end()."<br />";
return $sImg;
}
function get_screenshots($iAppId = null, $iVersionId = null, $bQueued = "false")
{
/*
* We want all screenshots for this app.
*/
if($iAppId && !$iVersionId)
{
$hResult = query_parameters("SELECT appData.*, appVersion.appId as appId
/*
* We want all screenshots for this app.
*/
if($iAppId && !$iVersionId)
{
$hResult = query_parameters("SELECT appData.*, appVersion.appId as appId
FROM appData, appVersion
WHERE appVersion.versionId = appData.versionId
AND type = 'image'
AND appVersion.appId = '?'
AND appData.queued = '?'", $iAppId, $bQueued);
}
/*
* We want all screenshots for this version.
*/
else if ($iVersionId)
{
$hResult = query_parameters("SELECT appData.*, appVersion.appId as appId
}
/*
* We want all screenshots for this version.
*/
else if ($iVersionId)
{
$hResult = query_parameters("SELECT appData.*, appVersion.appId as appId
FROM appData, appVersion
WHERE appVersion.versionId = appData.versionId
AND type = 'image'
AND appData.versionId = '?'
AND appData.queued = '?'", $iVersionId, $bQueued);
} else
{
return false;
}
return $hResult;
}
function get_thumbnail($id)
{
$oScreenshot = new Screenshot($id);
// generate random tag for popup window
$randName = 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.
'" onclick="javascript:openWin(\''.apidb_fullurl("appimage.php").
'?iId='.$id.'\',\''.$randName.'\','.
($oScreenshot->get_screenshot_width() + 20).','.
($oScreenshot->get_screenshot_height() + 6).
');return false;">'.$imgSRC.'</a>';
// set image link based on user pref
if ($_SESSION['current']->isLoggedIn())
{
if ($_SESSION['current']->getpref("window:screenshot") == "no")
} else
{
$img = '<a href="'.apidb_fullurl("appimage.php").
'?iImageId='.$id.'">'.$imgSRC.'</a>';
return false;
}
return $hResult;
}
function get_thumbnail_img()
{
// generate random tag for popup window
$sRandName = User::generate_passwd(5);
// set img tag
$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='.$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")
{
$shImg = '<a href="'.apidb_fullurl("appimage.php").
'?iImageId='.$this->iScreenshotId.'">'.$shImgSRC.'</a>';
}
}
return $shImg;
}
return $img;
}
?>

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";