addStyle("albumMaker.css");
$page->addStyle("albumViewer.css"); // for the display of album thumbnails before setting captions
$page->addScript("albumMaker.js");
$page->requireLogin();
$page->addModule(new UserLinksModule(), 0);
$page->addModule(albumMaker_main(), 1);
$page->addModule(albumMaker_tips(), 2);
$page->addModule(new AdModule(), 2);
$page->display();
////
// Displays a rundown of the steps in the process and what stage you are at
// currently.
////
function albumMaker_steps($currStep){
print "
\n";
} // end albumMaker_steps()
////
// Displays the main block of the album maker (differs by the phase in the
// creation of the album).
////
function albumMaker_main(){
$title = "Album Maker"; // STRINGTABLES
ob_start();
$albumId = getVal($_GET, 'editAlbum');
if($albumId != ""){
albumMaker_editAlbum($albumId);
} else {
$MIN_STEP = 1;
$MAX_STEP = 3;
$step = getVal($_GET, 'step', $MIN_STEP);
if(($step < $MIN_STEP) || ($step > $MAX_STEP)){
$step = $MIN_STEP; // on unknowns, always default to first step.
}
albumMaker_steps($step);
$albumAdded = albumMaker_process(); // returns the id of the album added or an empty-string
switch($step){
case 3:
$title .= " - Step 3";
albumMaker_addMeta();
break;
case 2:
$title .= " - Step 2";
albumMaker_addPhotos($albumAdded);
break;
case 1:
default:
$title .= " - Step 1";
albumMaker_createAlbum();
break;
}
}
$content = ob_get_clean();
$retVal = new TextModule($content, 'text', $title);
return $retVal;
} // end albumMaker_main()
////
//
////
function albumMaker_tips(){
$title = "Album Maker Tips"; // STRINGTABLES
ob_start();
$username = getUser()->getUsername();
print "This page will let you quickly pump a ton of pictures into the system, then get them tagged and out to the world.";
print "
\n";
print "View your uploads.\n";
$content = ob_get_clean();
$retVal = new TextModule($content, 'text', $title);
return $retVal;
} // end albumMaker_tips()
////
// Displays the content of the module to edit an album given the albumId
// to edit. This function is responsible to make sure that the user is allowed
// to edit the album.
////
function albumMaker_editAlbum($albumId){
$user = getUser();
$userId = $user->getId();
$PHP_SELF = $_SERVER['PHP_SELF'];
$allowed = (0 0)){
$cnt = 0;
$albumName = mysql_result($result, $cnt, "name");
$albumDesc = mysql_result($result, $cnt, "description");
print "
\n";
print " \n";
}
}
} else {
// STRINGTABLES
dispError("Your album could not be found.
Back to the Album Maker you go!");
}
} // end albumMaker_editAlbum()
////
// Displays the content of the module for creating an album.
////
function albumMaker_createAlbum(){
// STRINGTABLES FOR WHOLE FUNCTION
print "
\n";
print "This step is optional. If you would prefer, you can add ";
print "pictures to one of your previous albums or use the default album.";
print " \n";
print "
\n";
}
} else {
logQueryError("Error fetching albums for a given user", $queryString);
}
if($numFound == 0){
// STRINGTABLES
print "
You do not have any albums to edit yet. ";
print "Any photos you have will be in a default album.\n";
print "
\n";
}
print "
\n";
} // end albumMaker_createAlbum()
////
// Displays the form to create or edit an album.
////
function albumMaker_form($albumName='', $albumDesc='', $albumId=''){
$PHP_SELF = $_SERVER['PHP_SELF'];
if($albumId != ""){
print "\n";
if($albumId != ""){
print " \n";
print "...or you discard your changes and go back\n";
}
} // end albumMaker_form()
////
// Content of forms to add photos to the album.
////
function albumMaker_addPhotos($albumId){
// The passed in value overrides, if no value was passed, check the GET parameter.
$albumId = ($albumId==""?getVal($_GET, 'addTo'):$albumId);
$db = dil_connect();
$user = getUser();
$userId = $user->getId();
$PHP_SELF = $_SERVER['PHP_SELF'];
print "
\n";
// Box to agree to terms (will toggle visibility of the entire form).
print "
Loading...
\n";
print "\n";
print "
\n";
// Select-box to choose which album to add these photos to.
print "
\n";
include_once "albumTools.php";
albumSelectAlbum($userId, $albumId, true); // true makes sure it does the javascript updating of iFrames on changes
print "
\n";
// Upload-boxes for each image.
$NUM_UPLOAD_FIELDS = 7; // NOTE: IF THIS IS CHANGED, ALSO CHANGE NEXT_UPLOAD_ID IN js/albumMaker.js
for($cnt=0; $cnt<$NUM_UPLOAD_FIELDS; $cnt++){
albumMaker_uploadField($cnt, $albumId);
}
print "
\n";
$PHP_SELF = $_SERVER['PHP_SELF'];
print "Continue to captions when you are done uploading.\n";
print "
\n"; // end of 'allForms' div (for the JS reveal after terms agreement).
print "
\n";
} // end albumMaker_addPhotos()
////
// Outputs an upload-field.
////
function albumMaker_uploadField($id, $albumId=''){
$failureCode = "IFRAME support required. Please use a modern browser, or complain to the management.";
print "";
} // end albumMaker_uploadField()
////
// Displays the form to add meta information (captions, time the photo was taken, etc.)
// to images.
////
function albumMaker_addMeta(){
$uploads = getVal($_SESSION, 'albumMaker_uploads', array());
// STRINGTABLES FOR WHOLE FUNCTION
if(count($uploads) == 0){
print "
You have not uploaded any new photos.
\n";
} else {
include_once 'albumTools.php';
$user = getUser();
$userId = $user->getId();
$username = $user->getUsername();
// Date-taken is now automatically retrieved from images. If it is a real photo from a digital camera it will almost always have this set, so creating a GUI for this would only get in the way.
//print "Add the date the pictures were taken (optional) \n";
//print "Since many albums contain pictures from the same date, you can use this date-chooser to set the date to all of the photos you just uploaded at once. ";
//print "If the photos are from different days, or you do not wish to add the date they were taken, you can skip this step.\n";
//print "
\n";
//print "Add captions \n";
print "You can add or edit the captions to any picture in your albums at any time by clicking the 'edit' button on the picture's page.\n";
print " \n";
if(count($uploads) > 0){
$picData = array();
foreach($uploads as $picId){
$picData[] = array(
//INDEX_OWNER_ID => $userId,
//INDEX_OWNER_NAME => $username,
INDEX_PIC_ID => $picId
//INDEX_TT_DESC =>
//INDEX_TT_TITLE =>
);
}
$numCols = 3;
albumTable($picData, $numCols, $userId, $username);
print "
\n";
print "Done? ...view your albums.\n";
} else {
print "You haven't uploaded any pictures yet this session. To edit pictures you previously uploaded, ";
print "please find them in your albums.\n";
}
}
} // end albumMaker_addMeta()
////
// Processes posts by any of the forms (except the ajax).
////
function albumMaker_process(){
$retVal = "";
$formName = getPost('formName');
if($formName == "createAlbum"){
include_once 'sanitizer.php';
$albumName = sanitize(getPost('albumName'));
$albumDescription = sanitize(getPost('albumDesc'), ALLOW_HTML);
if("$albumName$albumDescription" != ""){
$albumName = ($albumName==""?"Photos - ".date("F Y"):$albumName); // empty-string wouldn't be a very good name.
$userId = getUser()->getId();
$queryString = "INSERT INTO albums (user_id, name, description, createdOn) VALUES ";
$queryString.= "($userId, '$albumName', '$albumDescription', NOW())";
if(sendQuery($queryString)){
// STRINGTABLES
$albumName = str_replace("\'", "'", $albumName);
dispSuccess("$albumName created.");
$retVal = mysql_insert_id();
} else {
logEvent("There was an error creating a new album with query $queryString Userstring: ".getUserString(), 3);
// STRINGTABLES
$msg = "There was an error creating your new album. We have logged this problem, please try again. ";
$msg.= "If the problems persist, please skip this step - you can still add photos to albums after they have been created.";
dispError($msg);
}
}
} else if($formName == "editAlbum"){
include_once 'sanitizer.php';
$userId = getUser()->getId();
$albumId = getPost('albumId');
$albumName = sanitize(getPost('albumName'));
$albumDesc = sanitize(getPost('albumDesc'), ALLOW_HTML);
$allowed = (0 Back to the Album Maker you go!");
}
}
return $retVal;
} // end albumMaker_process()
?>