". substr($oRow->description,0,20). "\n";
diff --git a/include/application.php b/include/application.php
index 99c8468..f38ac1d 100644
--- a/include/application.php
+++ b/include/application.php
@@ -545,7 +545,7 @@ class Application {
}
// image
- $img = get_screenshot_img($this->iAppId);
+ $img = Screenshot::get_random_screenshot_img($this->iAppId);
echo "
| $img |
\n";
echo " \n"; /* close of name/vendor/bugs/url table */
diff --git a/include/screenshot.php b/include/screenshot.php
index 47404f5..d570267 100644
--- a/include/screenshot.php
+++ b/include/screenshot.php
@@ -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 .= '
';
+
+ if(!$hResult || !mysql_num_rows($hResult))
+ {
+ $sImgFile = '
';
+ } else
+ {
+ $oRow = mysql_fetch_object($hResult);
+ $sImgFile = '
';
+ }
+
+ if($bFormatting)
+ $sImgFile .= '';
+
+ if($bFormatting)
+ $sImg = html_frame_start("",'128','',2);
+
+ /* we have screenshots */
+ if(mysql_num_rows($hResult))
+ {
+ if($iVersionId)
+ $sImg .= "
$sImgFileView/Submit Screenshot";
+ else
+ $sImg .= "
$sImgFileView Screenshot";
+ } else if($iVersionId) /* we are asking for a specific app version but it has no screenshots */
+ {
+ $sImg .= "
$sImgFileSubmit Screenshot";
+ } 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()."
";
+
+ return $sImg;
}
- if($bFormatting)
- $sImgFile .= '
';
-
- if(!$hResult || !mysql_num_rows($hResult))
+ function get_screenshots($iAppId = null, $iVersionId = null, $bQueued = "false")
{
- $sImgFile = '
';
- } else
- {
- $oRow = mysql_fetch_object($hResult);
- $sImgFile = '
';
- }
-
- if($bFormatting)
- $sImgFile .= '';
-
- if($bFormatting)
- $sImg = html_frame_start("",'128','',2);
-
- /* we have screenshots */
- if(mysql_num_rows($hResult))
- {
- if($iVersionId)
- $sImg .= "
$sImgFileView/Submit Screenshot";
- else
- $sImg .= "
$sImgFileView Screenshot";
- } else if($iVersionId) /* we are asking for a specific app version but it has no screenshots */
- {
- $sImg .= "
$sImgFileSubmit Screenshot";
- } 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()."
";
-
- 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 = '
get_screenshot_width() + 20).','.
- ($oScreenshot->get_screenshot_height() + 6).
- ');return false;">'.$imgSRC.'';
-
- // set image link based on user pref
- if ($_SESSION['current']->isLoggedIn())
- {
- if ($_SESSION['current']->getpref("window:screenshot") == "no")
+ } else
{
- $img = '
'.$imgSRC.'';
+ return false;
}
+
+ return $hResult;
+ }
+
+ function get_thumbnail_img()
+ {
+ // generate random tag for popup window
+ $sRandName = User::generate_passwd(5);
+ // set img tag
+ $shImgSRC = '

iScreenshotId.'" alt="'.$this->sDescription.
+ '" width="'.$this->get_thumbnail_width().
+ '" height="'.$this->get_thumbnail_height().'">';
+ $shImg = '
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.'';
+
+ // set image link based on user pref
+ if ($_SESSION['current']->isLoggedIn())
+ {
+ if ($_SESSION['current']->getpref("window:screenshot") == "no")
+ {
+ $shImg = '
iScreenshotId.'">'.$shImgSRC.'';
+ }
+ }
+ return $shImg;
}
- return $img;
}
+
?>
diff --git a/include/util.php b/include/util.php
index 37dd9f7..46a5c0c 100644
--- a/include/util.php
+++ b/include/util.php
@@ -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 '
| '.$oApp->sName.' '.$oVersion->sName.' |
diff --git a/include/version.php b/include/version.php
index f45be9b..2063f8a 100644
--- a/include/version.php
+++ b/include/version.php
@@ -657,7 +657,7 @@ class Version {
echo "
| Maintainers Version | ".$this->sTestedRelease." |
\n";
// image
- $img = get_screenshot_img($oApp->iAppId, $this->iVersionId);
+ $img = Screenshot::get_random_screenshot_img($oApp->iAppId, $this->iVersionId);
echo "
| $img |
\n";
// display all maintainers of this application
diff --git a/screenshots.php b/screenshots.php
index 03a0354..f7c9ab9 100644
--- a/screenshots.php
+++ b/screenshots.php
@@ -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 "
\n";
}
- $img = get_thumbnail($oRow->id);
+ $oScreenshot = new Screenshot($oRow->id);
+ $img = $oScreenshot->get_thumbnail_img();
// display image
echo "| \n";
echo $img;
diff --git a/viewScreenshots.php b/viewScreenshots.php
index 8e33431..61acb6b 100644
--- a/viewScreenshots.php
+++ b/viewScreenshots.php
@@ -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 " | \n";
echo $img;
echo " ". substr($oRow->description,0,20). "\n";
|