* new screenshot and image classes

This commit is contained in:
Jonathan Ernst
2005-01-27 15:42:53 +00:00
committed by Jeremy Newman
parent fc4f7db66a
commit d5a50ecec4
9 changed files with 788 additions and 208 deletions

View File

@@ -5,6 +5,7 @@
include("path.php");
require(BASE."include/"."incl.php");
require(BASE."include/"."screenshot.php");
require(BASE."include/"."tableve.php");
require(BASE."include/"."category.php");
@@ -123,18 +124,19 @@ if (!$_REQUEST['queueId'])
//data
if($obj_row->type == "image")
{
$oScreenshot = new Screenshot($obj_row->queueId,true);
echo '<tr valign=top><td class=color0><b>Submited image</b></td>',"\n";
echo '<td>';
$imgSRC = '<img width="'.APPDB_THUMBNAIL_WIDTH.'" height="'.APPDB_THUMBNAIL_HEIGHT.'" src="screenshotQueue.php?queueId='.$obj_row->queueId.'" />';
$imgSRC = '<img width="'.$oScreenshot->oThumbnailImage->width.'" height="'.$oScreenshot->oThumbnailImage->height.'" src="../appimage.php?queued=true&id='.$obj_row->queueId.'" />';
// generate random tag for popup window
$randName = generate_passwd(5);
// set image link based on user pref
$img = '<a href="javascript:openWin(\'screenshotQueue.php?queueId='.$obj_row->queueId.'\',\''.$randName.'\','.APPDB_SCREENSHOT_MAXWIDTH.','.APPDB_SCREENSHOT_MAXHEIGHT.');">'.$imgSRC.'</a>';
$img = '<a href="javascript:openWin(\'../appimage.php?queued=true&id='.$obj_row->queueId.'\',\''.$randName.'\','.$oScreenshot->oScreenshotImage->width.','.($oScreenshot->oScreenshotImage->height+4).');">'.$imgSRC.'</a>';
if (loggedin())
{
if ($_SESSION['current']->getpref("window:screenshot") == "no")
{
$img = '<a href="screenshotQueue.php?queueId='.$obj_row->queueId.'">'.$imgSRC.'</a>';
$img = '<a href="../appimage.php?queued=true&id='.$obj_row->queueId.'">'.$imgSRC.'</a>';
}
}
echo $img;
@@ -171,13 +173,15 @@ if (!$_REQUEST['queueId'])
$sQuery = "INSERT INTO appData VALUES (null, ".$obj_row->appId.", ".$obj_row->versionId.", 'image', ".
"'".addslashes($_REQUEST['description'])."', '')";
query_appdb($sQuery);
$int_id = mysql_insert_id();
$iId = mysql_insert_id();
// we move the content in the live directory
rename("../data/queued/screenshots/".$obj_row->queueId, "../data/screenshots/".$int_id);
rename("../data/queued/screenshots/".$obj_row->queueId, "../data/screenshots/".$iId);
rename("../data/queued/screenshots/originals/".$obj_row->queueId, "../data/screenshots/originals/".$iId);
rename("../data/queued/screenshots/thumbnails/".$obj_row->queueId, "../data/screenshots/thumbnails/".$iId);
// we have to update the entry now that we know its name
$sQuery = "UPDATE appData SET url = '".$int_id."' WHERE id = '".$int_id."'";
$sQuery = "UPDATE appData SET url = '".$iId."' WHERE id = '".$iId."'";
}
elseif ($obj_row->type == "url") {
@@ -229,6 +233,8 @@ if (!$_REQUEST['queueId'])
//delete main item
$sQuery = "DELETE from appDataQueue where queueId = ".$obj_row->queueId.";";
unlink("../data/queued/screenshots/".$obj_row->queueId);
unlink("../data/queued/screenshots/originals/".$obj_row->queueId);
unlink("../data/queued/screenshots/thumbnails/".$obj_row->queueId);
$hResult = query_appdb($sQuery);
echo html_frame_start("Delete application data submission",400,"",0);

140
admin/adminScreenshots.php Normal file
View File

@@ -0,0 +1,140 @@
<?php
/************************************************************/
/* Page for managing all of the screenshots in the AppDB */
/* Without having go into each application version to do so */
/************************************************************/
include("path.php");
include(BASE."include/"."incl.php");
require(BASE."include/"."screenshot.php");
apidb_header("Screenshots");
// deny access if not admin
if(!havepriv("admin"))
{
errorpage("Insufficient privileges.");
exit;
}
// regenerate all screenshots
if($_REQUEST['regenerate'])
{
$sQuery = "SELECT id FROM appData";
$hResult = query_appdb($sQuery);
while($oRow = mysql_fetch_object($hResult))
{
echo "REGENERATING IMAGE ".$oRow->id."<br/>";
$screenshot = new Screenshot($oRow->id);
$screenshot->generate();
$screenshot->free();
}
}
echo "<a href=\"".$_SERVER['PHP_SELF']."?regenerate=true\">Regenerate all screenshots ! (use only if you know what you are doing)</a><br />";
function display_range($currentPage, $pageRange, $totalPages, $screenshotsPerPage)
{
/* display the links to each of these pages */
if($currentPage != 0)
{
$previousPage = $currentPage - 1;
echo "<a href='adminScreenshots.php?page=$previousPage&screenshotsPerPage=$screenshotsPerPage'>Previous</a> ";
} else
echo "Previous ";
/* display the next 10 and previous 10 pages */
$pageRange = 10;
if($currentPage > $pageRange)
$startPage = $currentPage - $pageRange;
else
$startPage = 0;
if($currentPage + $pageRange < $totalPages)
$endPage = $currentPage + $pageRange;
else
$endPage = $totalPages;
/* display the desired range */
for($x = $startPage; $x <= $endPage; $x++)
{
if($x != $currentPage)
echo "<a href='adminScreenshots.php?page=$x&screenshotsPerPage=$screenshotsPerPage'>$x</a> ";
else
echo "$x ";
}
if($currentPage < $totalPages)
{
$nextPage = $currentPage + 1;
echo "<a href='adminScreenshots.php?page=$nextPage&screenshotsPerPage=$screenshotsPerPage'>Next</a> ";
} else
echo "Next ";
}
$screenshotsPerPage = 10;
$currentPage = 0;
if($_REQUEST['page'])
$currentPage = $_REQUEST['page'];
if($_REQUEST['screenshotsPerPage'])
$screenshotsPerPage = $_REQUEST['screenshotsPerPage'];
$totalPages = floor(getNumberOfComments()/$screenshotsPerPage);
if($screenshotsPerPage > 100) $screenshotsPerPage = 100;
/* display page selection links */
echo "<center>";
echo "<b>Page $currentPage of $totalPages</b><br />";
display_range($currentPage, $pageRange, $totalPages, $screenshotsPerPage);
echo "<br />";
echo "<br />";
/* display the option to choose how many comments per-page to disable */
echo "<form method=\"get\" name=\"message\" action=\"".$_SERVER['PHP_SELF']."\">";
echo "<b>Number of comments per page:</b>";
echo "<select name='screenshotsPerPage'>";
$screenshotsPerPageArray = array(10, 20, 50, 100);
foreach($screenshotsPerPageArray as $i => $value)
{
if($screenshotsPerPageArray[$i] == $screenshotsPerPage)
echo "<option value='$screenshotsPerPageArray[$i]' SELECTED>$screenshotsPerPageArray[$i]";
else
echo "<option value='$screenshotsPerPageArray[$i]'>$screenshotsPerPageArray[$i]";
}
echo "</select>";
echo "<input type=hidden name=page value=$currentPage>";
echo "<input type=submit value='Refresh'>";
echo "</form>";
echo "</center>";
/* query for all of the commentId's, ordering by their time in reverse order */
$offset = $currentPage * $screenshotsPerPage;
$commentIds = query_appdb("SELECT id from appData ORDER BY ".
"id ASC LIMIT $offset, $screenshotsPerPage;");
while ($ob = mysql_fetch_object($commentIds))
{
$qstring = "SELECT id, appId, versionId, type, description ".
"FROM appData WHERE id = $ob->id;";
$result = query_appdb($qstring);
/* call view_app_comment to display the comment */
$comment_ob = mysql_fetch_object($result);
// TODO: display the thumbnail with link to screenshot
}
/* display page selection links */
echo "<center>";
display_range($currentPage, $pageRange, $totalPages, $screenshotsPerPage);
echo "</center>";
apidb_footer();
?>