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:
@@ -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";
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
@@ -359,142 +359,136 @@ class Screenshot {
|
|||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
/*
|
* Get a random image for a particular version of an app.
|
||||||
* Screenshot functions that are not part of the class
|
* If the version is not set, get a random app image
|
||||||
*/
|
*
|
||||||
|
* $bFormatting == false turns off all extranious formatting applied to the returned image html
|
||||||
/**
|
*/
|
||||||
* Get a random image for a particular version of an app.
|
function get_random_screenshot_img($iAppId = null, $iVersionId = null,
|
||||||
* If the version is not set, get a random app image
|
$bFormatting = true)
|
||||||
*
|
|
||||||
* $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)
|
|
||||||
{
|
{
|
||||||
$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
|
FROM appData, appVersion
|
||||||
WHERE appData.versionId = appVersion.versionId
|
WHERE appData.versionId = appVersion.versionId
|
||||||
AND appVersion.appId = '?'
|
AND appVersion.appId = '?'
|
||||||
AND type = 'image'
|
AND type = 'image'
|
||||||
AND appData.queued = 'false'
|
AND appData.queued = 'false'
|
||||||
ORDER BY rand", $iAppId);
|
ORDER BY rand", $iAppId);
|
||||||
} else if ($iVersionId) // we want a random screenshot for this version
|
} else if ($iVersionId) // we want a random screenshot for this version
|
||||||
{
|
{
|
||||||
$hResult = query_parameters("SELECT id, description, RAND() AS rand
|
$hResult = query_parameters("SELECT id, description, RAND() AS rand
|
||||||
FROM appData
|
FROM appData
|
||||||
WHERE versionId = '?'
|
WHERE versionId = '?'
|
||||||
AND type = 'image'
|
AND type = 'image'
|
||||||
AND queued = 'false'
|
AND queued = 'false'
|
||||||
ORDER BY rand", $iVersionId);
|
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&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&iVersionId=$iVersionId'>$sImgFile<center>View/Submit Screenshot</center></a>";
|
||||||
|
else
|
||||||
|
$sImg .= "<a href='screenshots.php?iAppId=$iAppId&iVersionId=$iVersionId'>$sImgFile<center>View 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&iVersionId=$iVersionId'>$sImgFile<center>Submit 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)
|
function get_screenshots($iAppId = null, $iVersionId = null, $bQueued = "false")
|
||||||
$sImgFile .= '<center>';
|
|
||||||
|
|
||||||
if(!$hResult || !mysql_num_rows($hResult))
|
|
||||||
{
|
{
|
||||||
$sImgFile = '<img src="images/no_screenshot.png" alt="No Screenshot" />';
|
/*
|
||||||
} else
|
* We want all screenshots for this app.
|
||||||
{
|
*/
|
||||||
$oRow = mysql_fetch_object($hResult);
|
if($iAppId && !$iVersionId)
|
||||||
$sImgFile = '<img src="appimage.php?bThumbnail=true&iId='.$oRow->id.'" alt="'.$oRow->description.'" />';
|
{
|
||||||
}
|
$hResult = query_parameters("SELECT appData.*, appVersion.appId as appId
|
||||||
|
|
||||||
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&iVersionId=$iVersionId'>$sImgFile<center>View/Submit Screenshot</center></a>";
|
|
||||||
else
|
|
||||||
$sImg .= "<a href='screenshots.php?iAppId=$iAppId&iVersionId=$iVersionId'>$sImgFile<center>View 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&iVersionId=$iVersionId'>$sImgFile<center>Submit 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
|
|
||||||
FROM appData, appVersion
|
FROM appData, appVersion
|
||||||
WHERE appVersion.versionId = appData.versionId
|
WHERE appVersion.versionId = appData.versionId
|
||||||
AND type = 'image'
|
AND type = 'image'
|
||||||
AND appVersion.appId = '?'
|
AND appVersion.appId = '?'
|
||||||
AND appData.queued = '?'", $iAppId, $bQueued);
|
AND appData.queued = '?'", $iAppId, $bQueued);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* We want all screenshots for this version.
|
* We want all screenshots for this version.
|
||||||
*/
|
*/
|
||||||
else if ($iVersionId)
|
else if ($iVersionId)
|
||||||
{
|
{
|
||||||
$hResult = query_parameters("SELECT appData.*, appVersion.appId as appId
|
$hResult = query_parameters("SELECT appData.*, appVersion.appId as appId
|
||||||
FROM appData, appVersion
|
FROM appData, appVersion
|
||||||
WHERE appVersion.versionId = appData.versionId
|
WHERE appVersion.versionId = appData.versionId
|
||||||
AND type = 'image'
|
AND type = 'image'
|
||||||
AND appData.versionId = '?'
|
AND appData.versionId = '?'
|
||||||
AND appData.queued = '?'", $iVersionId, $bQueued);
|
AND appData.queued = '?'", $iVersionId, $bQueued);
|
||||||
} else
|
} 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")
|
|
||||||
{
|
{
|
||||||
$img = '<a href="'.apidb_fullurl("appimage.php").
|
return false;
|
||||||
'?iImageId='.$id.'">'.$imgSRC.'</a>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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";
|
||||||
|
|||||||
Reference in New Issue
Block a user