From: <je...@us...> - 2006-10-30 02:18:26
|
Revision: 15001 http://svn.sourceforge.net/gallery/?rev=15001&view=rev Author: jenst Date: 2006-10-29 18:18:18 -0800 (Sun, 29 Oct 2006) Log Message: ----------- 2006-10-30 Jens Tkotz <je...@pe...> 1.6-alpha2-svn-b24 * Change: Added field $initialized to albumDB() - Better error handling. * Change: Added $allowedInvalidAlbums to albumDB() - You can now easier define whats allowed. e.g. "lost+found" * Fix: removed -v from jhead call, as the structure is different. * New: function generateCaption() * Change: Little code cleanup in popups/save_photos.php * Change: Added additional param to getItemCaptureDate(). Modified Paths: -------------- trunk/gallery/ChangeLog trunk/gallery/Version.php trunk/gallery/albums.php trunk/gallery/classes/AlbumDB.php trunk/gallery/util.php Modified: trunk/gallery/ChangeLog =================================================================== --- trunk/gallery/ChangeLog 2006-10-30 02:02:35 UTC (rev 15000) +++ trunk/gallery/ChangeLog 2006-10-30 02:18:18 UTC (rev 15001) @@ -1,3 +1,19 @@ +2006-10-30 Jens Tkotz <je...@pe...> 1.6-alpha2-svn-b24 + + * Change: Added field $initialized to albumDB() + - Better error handling. + + * Change: Added $allowedInvalidAlbums to albumDB() + - You can now easier define whats allowed. e.g. "lost+found" + + * Fix: removed -v from jhead call, as the structure is different. + + * New: function generateCaption() + + * Change: Little code cleanup in popups/save_photos.php + + * Change: Added additional param to getItemCaptureDate(). + 2006-10-30 Jens Tkotz <je...@pe...> 1.6-alpha2-svn-b23 * CHANGE: description is now a fixed item field, not a custom @@ -94,8 +110,6 @@ Thanks to Peter Schumacher for finding and reporting those bugs. - * Fix: Remove -v from jhead, as the output has different structure. - * Fix: Autorotate rotated in the wrong direction. * Fix: still some _(), converted to gTranslate() Modified: trunk/gallery/Version.php =================================================================== --- trunk/gallery/Version.php 2006-10-30 02:02:35 UTC (rev 15000) +++ trunk/gallery/Version.php 2006-10-30 02:18:18 UTC (rev 15001) @@ -22,7 +22,7 @@ ?> <?php -$gallery->version = '1.6-alpha2-svn-b23'; +$gallery->version = '1.6-alpha2-svn-b24'; $gallery->config_version = 99; $gallery->album_version = 39; $gallery->user_version = 6; Modified: trunk/gallery/albums.php =================================================================== --- trunk/gallery/albums.php 2006-10-30 02:02:35 UTC (rev 15000) +++ trunk/gallery/albums.php 2006-10-30 02:18:18 UTC (rev 15001) @@ -42,7 +42,7 @@ } fclose($fp); printf("<!-- From %s, created at %s -->", - $cache_file_basename, strftime("%D %T", $cache_stat[9])); + $cache_file_basename, strftime("%D %T", $cache_stat[9])); return; } } @@ -56,6 +56,10 @@ /* Read the album list */ $albumDB = new AlbumDB(FALSE); +if(! $albumDB->isInitialized()) { + exit; +} + $galleryTitle = clearGalleryTitle(); $gallery->session->albumName = ''; @@ -119,9 +123,11 @@ } else if ($numAccess != $numAlbums) { $adminText .= sprintf(gTranslate('core', "%s (%s), %s"), $toplevel_str, $total_str, $image_str); -} else if ($maxPages > 1) { +} +else if ($maxPages > 1) { $adminText .= sprintf(gTranslate('core', "%s, %s on %s"), $toplevel_str, $image_str, $page_str); -} else { +} +else { $adminText .= sprintf(gTranslate('core', "%s, %s"), $toplevel_str, $image_str); } @@ -257,14 +263,16 @@ if(sizeof($albumDB->outOfDateAlbums)) { $message = gTranslate('core', - "Gallery has detected that one of your albums is out of date.", - "Gallery has detected that %d of your albums are out of date.", + "Gallery has detected that one of your albums is out of date.", + "Gallery has detected that %d of your albums are out of date.", sizeof($albumDB->outOfDateAlbums), '', true ); $message .= "\n<br>"; $message .= sprintf(gTranslate('core', "Please %s."), - popup_link(gTranslate('core', "perform an upgrade"), "upgrade_album.php",0,0,500,500,"g-error", '', '', false)); + popup_link( + gTranslate('core', "perform an upgrade"), + "upgrade_album.php", 0, 0, 500, 500, 'g-error', '', '', false)); $notice_messages[] = array( 'type' => 'warning', @@ -276,7 +284,9 @@ if (getRequestVar('gRedir') == 1 && ! $gallery->session->gRedirDone) { $message = sprintf(gTranslate('core', "The album or photo that you were attempting to view either does not exist, or requires user privileges that you do not possess. %s"), ($gallery->user->isLoggedIn() && !$GALLERY_EMBEDDED_INSIDE ? '' : sprintf(gTranslate('core', "Login at the %s and try again."), - popup_link(gTranslate('core', "Login page"), "login.php", false, true, 500, 500, 'g-emphasis','','', false)))); + popup_link( + gTranslate('core', "Login page"), + 'login.php', false, true, 500, 500, 'g-emphasis','','', false)))); $notice_messages[] = array( 'type' => 'error', Modified: trunk/gallery/classes/AlbumDB.php =================================================================== --- trunk/gallery/classes/AlbumDB.php 2006-10-30 02:02:35 UTC (rev 15000) +++ trunk/gallery/classes/AlbumDB.php 2006-10-30 02:18:18 UTC (rev 15001) @@ -24,15 +24,30 @@ class AlbumDB { var $albumList; var $albumOrder; + var $initialized; - function AlbumDB($loadphotos=TRUE) { + function AlbumDB($loadphotos = true) { global $gallery; + $changed = 0; + $this->initialized = false; $dir = $gallery->app->albumDir; + + $allowedInvalidAlbums = array('CVS', 'SVN', '_vti_cnf', 'lost+found'); + if(!fs_is_dir($dir)) { + echo infoBox(array(array( + 'type' => 'error', + 'text' => sprintf("Albumdir (%s) not found! Please check the path to the albums folder in your config.php.", + $dir) + ))); + + return false; + } + $tmp = getFile("$dir/albumdb.dat"); - if (strcmp($tmp, "")) { + if (strcmp($tmp, '')) { $this->albumOrder = unserialize($tmp); // albumdb.dat is corrupt, rebuild it @@ -40,48 +55,62 @@ $this->albumOrder = array(); } $changed = 1; - } else { + } + else { $this->albumOrder = array(); } $this->albumList = array(); $this->brokenAlbums = array(); $this->outOfDateAlbums = array(); + + /* Loop through all albums already found in the albumdb.dat */ $i = 0; while ($i < sizeof($this->albumOrder)) { $name = $this->albumOrder[$i]; if (ereg("^\.", $name)) { // how did this get here?? - array_splice($this->albumOrder, $i, 1); - $changed = 1; - } else if (fs_is_dir("$dir/$name")) { + array_splice($this->albumOrder, $i, 1); + $changed = 1; + } + else if (fs_is_dir("$dir/$name")) { $album = new Album; - if ($album->load($name,$loadphotos)) { + if ($album->load($name, $loadphotos)) { array_push($this->albumList, $album); if ($album->versionOutOfDate()) { array_push($this->outOfDateAlbums, $name); } - } else if ($name != 'CVS') { + } + else if (!in_array($name, $allowedInvalidAlbums)) { array_push($this->brokenAlbums, $name); } $i++; - } else { + } + else { /* Couldn't find the album -- delete it from order */ array_splice($this->albumOrder, $i, 1); $changed = 1; } } + /* Now scan the albums folder */ if ($fd = fs_opendir($dir)) { while ($file = readdir($fd)) { if (!ereg("^\.", $file) && - fs_is_dir("$dir/$file") && - strcmp($file, "_vti_cnf") && - !in_array($file, $this->albumOrder)) { + fs_is_dir("$dir/$file") && + !in_array($file, $allowedInvalidAlbums) && + !in_array($file, $this->albumOrder)) { $album = new Album; - $album->load($file,$loadphotos); - array_push($this->albumList, $album); - array_push($this->albumOrder, $file); + if ($album->load($file, $loadphotos)) { + array_push($this->albumList, $album); + if ($album->versionOutOfDate()) { + array_push($this->outOfDateAlbums, $file); + } + } + else { + array_push($this->brokenAlbums, $file); + } $changed = 1; + } } closedir($fd); @@ -90,29 +119,41 @@ if ($changed) { $this->save(); } + + $this->initialized = true; } + /** + * Returns wether the AlbumDB was succesfully initialized or not + * + * @return boolean true if succesfully initialized. + * @author Jens Tkotz <je...@pe...> + */ + function isInitialized() { + return $this->initialized === true; + } + function sortByField($fieldname = '', $order = 'desc') { - $tmpOrder = array(); + $tmpOrder = array(); - if(!empty($fieldname)) { - if($fieldname == 'name') { - if($order == 'asc') { - sort($this->albumOrder); - } - else { - rsort($this->albumOrder); - } - } - else { - array_sort_by_fields($this->albumList, $fieldname , $order, true, false, true); - foreach ($this->albumList as $album) { - $tmpOrder[] = $album->fields["name"]; - } - $this->albumOrder = $tmpOrder; - } - $this->save(); - } + if(!empty($fieldname)) { + if($fieldname == 'name') { + if($order == 'asc') { + sort($this->albumOrder); + } + else { + rsort($this->albumOrder); + } + } + else { + array_sort_by_fields($this->albumList, $fieldname , $order, true, false, true); + foreach ($this->albumList as $album) { + $tmpOrder[] = $album->fields["name"]; + } + $this->albumOrder = $tmpOrder; + } + $this->save(); + } } function renameAlbum($oldName, $newName) { Modified: trunk/gallery/util.php =================================================================== --- trunk/gallery/util.php 2006-10-30 02:02:35 UTC (rev 15000) +++ trunk/gallery/util.php 2006-10-30 02:18:18 UTC (rev 15001) @@ -163,7 +163,8 @@ print "\n<br>". gTranslate('core', "Results:") ."<pre>"; if ($results) { print join("\n", $results); - } else { + } + else { print "<b>" .gTranslate('core', "none") ."</b>"; } print "</pre>"; @@ -194,7 +195,8 @@ if ($status == $gallery->app->expectedExecStatus) { return true; - } else { + } + else { if ($results) { echo '<hr><p>'. gallery_error("") . join("<br>", $results) .'</p>'; } @@ -543,9 +545,11 @@ if(isset($gallery->app->exiftags)) { return 'exiftags'; - } elseif (isset($gallery->app->use_exif)) { + } + elseif (isset($gallery->app->use_exif)) { return 'jhead'; - } else { + } + else { return false; } } @@ -591,7 +595,7 @@ break; } $path = $gallery->app->use_exif; - list($return, $status) = @exec_internal(fs_import_filename($path, 1) .' -v ' . + list($return, $status) = @exec_internal(fs_import_filename($path, 1) .' ' . // -v removed as the structure is different. fs_import_filename($file, 1)); $unwantedFields = array('File name'); @@ -630,47 +634,50 @@ * If exif is not supported, or no date was gotten, then the file creation date is returned. * Note: i used switch/case because this is easier to extend later. */ -function getItemCaptureDate($file) { - $success = false; - $exifSupported = getExifDisplayTool(); +function getItemCaptureDate($file, $exifData = array()) { + $success = false; + $exifSupported = getExifDisplayTool(); - if ($exifSupported) { - $return = getExif($file); - $exifData = $return[1]; - switch($exifSupported) { - case 'exiftags': - if (isset($exifData['Image Created'])) { - $tempDate = split(" ", $exifData['Image Created'], 2); - } - break; - case 'jhead': - if (isset($exifData['Date/Time'])) { - $tempDate = split(" ", $exifData['Date/Time'], 2); - } - break; - } - if (isset($tempDate)) { - $tempDay = strtr($tempDate[0], ':', '-'); - $tempTime = $tempDate[1]; + if ($exifSupported) { + if(empty($exifData)) { + list($status, $exifData) = getExif($file); + } - $itemCaptureTimeStamp = strtotime("$tempDay $tempTime"); + switch($exifSupported) { + case 'exiftags': + if (isset($exifData['Image Created'])) { + $tempDate = split(" ", $exifData['Image Created'], 2); + } + break; + case 'jhead': + if (isset($exifData['Date/Time'])) { + $tempDate = split(" ", $exifData['Date/Time'], 2); + } + break; + } - if ($itemCaptureTimeStamp != 0) { - $success = true; - } - } - } + if (isset($tempDate)) { + $tempDay = strtr($tempDate[0], ':', '-'); + $tempTime = $tempDate[1]; - // we were not able to get the capture date from exif... use file creation time - if (!$success) { - $itemCaptureTimeStamp = filemtime($file); - } + $itemCaptureTimeStamp = strtotime("$tempDay $tempTime"); - if (!isDebugging()) { - sprintf (gTranslate('core', "Item Capture Date : %s"), strftime('%Y', $itemCaptureTimeStamp)); - } + if ($itemCaptureTimeStamp != 0) { + $success = true; + } + } + } - return $itemCaptureTimeStamp; + // we were not able to get the capture date from exif... use file creation time + if (!$success) { + $itemCaptureTimeStamp = filemtime($file); + } + + if (!isDebugging()) { + sprintf (gTranslate('core', "Item Capture Date : %s"), strftime('%Y', $itemCaptureTimeStamp)); + } + + return $itemCaptureTimeStamp; } function doCommand($command, $args = array(), $returnTarget = '', $returnArgs = array()) { @@ -1079,7 +1086,10 @@ fs_unlink($gallery->app->tmpDir . "/$pic"); } } - } else { + } + else { + echo debugMessage(gTranslate('core', "Start Processing single file"), __FILE__, __LINE__); + echo debugMessage(gTranslate('core', "Filename processing."), __FILE__, __LINE__,3); /* Its a single file * remove %20 and the like from name */ @@ -1111,6 +1121,7 @@ set_time_limit($gallery->app->timeLimit); if (acceptableFormat($ext)) { + echo debugMessage(gTranslate('core', "extension is accepted."), __FILE__, __LINE__, 3); /* * Move the uploaded image to our temporary directory * using move_uploaded_file so that we work around @@ -1129,44 +1140,20 @@ /* What should the caption be, if no caption was given by user ? * See captionOptions.inc.php for options */ - - if (isset($gallery->app->dateTimeString)) { - $dateTimeFormat = $gallery->app->dateTimeString; - } else { - $dateTimeFormat = "%D %T"; - } - if (empty($caption)) { - switch ($setCaption) { - case 0: - $caption = ''; - break; - - case 1: - default: - /* Use filename */ - $caption = strtr($originalFilename, '_', ' '); - break; - - case 2: - /* Use file cration date */ - $caption = strftime($dateTimeFormat, filectime($file)); - break; - - case 3: - /* Use capture date */ - $caption = strftime($dateTimeFormat, getItemCaptureDate($file)); - break; - } + generateCaption($setCaption, $originalFilename, $file); } - echo "\n<p><b>******". sprintf(gTranslate('core', "Adding %s"), $name) ."*****</b></p>"; + echo infobox(array(array( + 'type' => 'informationm', + 'text' => '<b>'. sprintf(gTranslate('core', "Adding %s"), $name) .'</b>' + ))); /* After all the preprocessing, NOW ADD THE element * function addPhoto($file, $tag, $originalFilename, $caption, $pathToThumb="", $extraFields=array(), $owner="", $votes=NULL, * $wmName="", $wmAlign=0, $wmAlignX=0, $wmAlignY=0, $wmSelect=0) */ - $err = $gallery->album->addPhoto( + list($status, $statusMsg) = $gallery->album->addPhoto( $file, $ext, $mangledFilename, @@ -1178,13 +1165,15 @@ $wmName, $wmAlign, $wmAlignX, $wmAlignY, $wmSelect ); - if ($err) { - processingMsg(gallery_error($err)); + echo $statusMsg; + + if (!$status) { processingMsg("<b>". sprintf(gTranslate('core', "Need help? Look in the %s%s FAQ%s"), '<a href="http://gallery.sourceforge.net/faq.php" target=_new>', Gallery(), '</a>') . "</b>"); } - } else { + } + else { processingMsg(sprintf(gTranslate('core', "Skipping %s (can't handle %s format)"), $name, $ext)); } } @@ -1988,7 +1977,6 @@ * @return string $ret * @author Jens Tkotz <je...@pe...> */ - function clearGalleryTitle($topic = '') { global $gallery; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |