[Linpha-cvs] SF.net SVN: linpha: [4566] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-09-25 21:07:34
|
Revision: 4566 http://svn.sourceforge.net/linpha/?rev=4566&view=rev Author: fangehrn Date: 2006-09-25 14:07:11 -0700 (Mon, 25 Sep 2006) Log Message: ----------- * some minor updates * improved admin/import Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/import.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/thumbnails.js trunk/linpha2/lib/modules/module.filemanager.php trunk/linpha2/templates/default/css/view_thumb.css trunk/linpha2/templates/default/global.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/ChangeLog 2006-09-25 21:07:11 UTC (rev 4566) @@ -1,3 +1,7 @@ +2006-09-25 flo + * some minor updates + * improved admin/import + 2006-08-30 flo * improved admin config Modified: trunk/linpha2/admin/import.php =================================================================== --- trunk/linpha2/admin/import.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/admin/import.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -1,12 +1,42 @@ <?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * This file updates the database + * @package Import + */ + if(!defined('LINPHA_DIR')) { exit(1); } -$array_meta = Array('exif','iptc','xmp'); +/** + * try it, it works sometimes + */ +ini_set("max_execution_time", "6000"); +$array_meta = Array('exif','iptc','xmp'); if( isset($_POST['cmd']) && $_POST['cmd']=='import') { + echo '<h1>'.i18n("Running Import...").'</h1><br />'; + if(!isset($_REQUEST['album_select']) OR $_REQUEST['album_select'][0]=='all') { $all_albums = true; @@ -22,7 +52,7 @@ */ if($_REQUEST['index_import']=='index') { - echo i18n("Running Import...").'<br />'; + echo '<h2>'.i18n("Directory Import").'</h2><br />'; if($all_albums) { echo i18n("Parsing All Directories...").'<br />'; @@ -56,9 +86,9 @@ * we would have to take care to the script backwards, * that means first of the depest subfolder until we're on top */ - if($_REQUEST['index_thumbnails']!='no') + if($_REQUEST['index_thumbnails']!='no' OR isset($_REQUEST['index_thumbnails_delete'])) { - echo i18n("Creating Thumbnails...").'<br />'; + echo '<h2>'.i18n("Thumbnails").'</h2><br />'; $thumbnail = new LinImage(); @@ -67,120 +97,176 @@ $_GET['force'] = true; } + /** + * all albums selected + */ if($all_albums) { - echo i18n("Parsing All Directories...").'<br />'; - echo i18n("Create Thumbnail"); - - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); - while($data = $query->FetchRow(ADODB_FETCH_NUM)) + /** + * delete thumbnails + */ + if( isset($_REQUEST['index_thumbnails_delete']) ) { - if( ! $thumbnail->createThumbnail($data[0]) ) + echo i18n("Delete All Existing Thumbnails...").'<br />'; + $thumbcachepath = LinSql::getPath('cache').'/thumb'; + LinFilesys::rm_rf( $thumbcachepath ); // all subfolders will automatically be recreated on each image access + if(file_exists($thumbcachepath)) { - echo "Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg."<br />"; + echo i18n("Warning while deleting file/folder, check permissions!").'<br />'; } - if( ! $thumbnail->isCached ) + else { - echo " ".$data[0].","; + mkdir( $thumbcachepath ); } - flush(); } - + + /** + * set query string for create/recreate thumbnails + */ + if($_REQUEST['index_thumbnails']!='no') + { + echo '<h3>'.i18n("Parsing All Directories...").'</h3><br />'; + $createthumbquery = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); + } } - else + else // $all_albums == false -> not all directory selected { + /** + * go through each selected directory + */ foreach($_REQUEST['album_select'] AS $key=>$value) { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($value)."'"); - echo i18n("Parsing Directory:").' '.$data['name'].'<br />'; - echo i18n("Create Thumbnail"); + echo '<h3>'.i18n("Parsing Directory:").' '.$data['name'].'</h3><br />'; - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE " . + $sql = "SELECT id FROM ".PREFIX."photos WHERE " . "parent_id = '".LinSql::linAddslashes($value)."' AND " . - "img_type <> 0 AND img_type <> 9999999"); - while($data = $query->FetchRow(ADODB_FETCH_NUM)) + "img_type <> 0 AND img_type <> 9999999"; + + /** + * delete thumbnails + */ + if( isset($_REQUEST['index_thumbnails_delete']) ) { - if( ! $thumbnail->createThumbnail($data[0]) ) + echo i18n("Delete Thumbnails"); + $query = $GLOBALS['linpha']->db->Execute($sql); + while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - echo "Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg."<br />"; + if( LinImage::deleteCachedThumbnail($data[0]) ) + { + echo " ".$data[0].","; + } } - if( ! $thumbnail->isCached ) - { - echo " ".$data[0].","; - } - flush(); + echo '<br />'; } + + /** + * set query string for create/recreate thumbnails + */ + if($_REQUEST['index_thumbnails']!='no') + { + $createthumbquery = $GLOBALS['linpha']->db->Execute($sql); + } } } + /** + * now create thumbnails, $query has been set previously + */ + if($_REQUEST['index_thumbnails']!='no') + { + echo i18n("Create Thumbnail"); + while($data = $createthumbquery->FetchRow(ADODB_FETCH_NUM)) + { + if( ! $thumbnail->createThumbnail($data[0]) ) + { + echo i18n("Error While Creating Thumbnail!")."<br />Error: ".$thumbnail->error_msg."<br />"; + } + if( ! $thumbnail->isCached ) // thumbnail wasn't cached -> now created! + { + echo " ".$data[0].","; + } + flush(); + } + echo '<br />'; + } + echo '<br /><br />'; } /** * exif, iptc, xmp + * + * if "Delete First" and "All albums" was selected, the whole table will be deleted */ include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); $MetaData = new MetaData(); foreach($array_meta AS $meta_value) { - if( isset( $_REQUEST['index_'.$meta_value] ) ) + if( isset( $_REQUEST['index_'.$meta_value] ) && + ( $_REQUEST['index_'.$meta_value] == 'index' OR isset($_REQUEST['index_'.$meta_value.'_delete']) ) ) { - echo i18n("Indexing Files...").' ('.strtoupper($meta_value).')<br />'; + echo '<h2>'.i18n("File Indexing").' ('.strtoupper($meta_value).')</h2><br />'; /** * get imgids to indexing, if reindex is selected: delete these entries first */ if($all_albums) { - echo i18n("Parsing All Directories...").'<br />'; + echo i18n("All Directories selected").'<br />'; $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); while($data = $query->FetchRow()) { - if( $_REQUEST['index_'.$meta_value] != 'no') - { - $array_meta_ids[$data['id']] = $data['md5sum']; - } - - if( isset($_REQUEST['index_'.$meta_value.'_delete'])) - { - $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_".$meta_value." WHERE md5sum = '".$data['md5sum']."'"); - } + $array_meta_ids[$data['id']] = $data['md5sum']; } - } else { + echo i18n("Directory selected:").' '; foreach($_REQUEST['album_select'] AS $key=>$value) { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($value)."'"); - echo i18n("Parsing Directory:").' '.$data['name'].'<br />'; + echo $data['name'].', '; $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum FROM ".PREFIX."photos WHERE " . "parent_id = '".LinSql::linAddslashes($value)."' AND " . "img_type <> 0 AND img_type <> 9999999"); while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - if( $_REQUEST['index_'.$meta_value] != 'no') - { - $array_meta_ids[$data['id']] = $data['md5sum']; - } - - if( isset($_REQUEST['index_'.$meta_value.'_delete'])) - { - $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_".$meta_value." WHERE md5sum = '".$data['md5sum']."'"); - } + $array_meta_ids[$data['id']] = $data['md5sum']; } } + echo '<br />'; } - + /** - * parse all ids + * delete first (if selected) */ - if(isset($array_meta_ids)) + if( isset($_REQUEST['index_'.$meta_value.'_delete']) ) { + if( $all_albums ) + { + echo i18n("Delete all index data").'<br />'; + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_".$meta_value); + } + elseif( isset($array_meta_ids) ) + { + echo i18n("Delete index data of selected directories").'<br />'; + foreach($array_meta_ids AS $id=>$md5sum) + { + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_".$meta_value." WHERE md5sum = '".$md5sum."'"); + } + } + } + + /** + * index image, parse all saved ids + */ + if( isset($array_meta_ids) && $_REQUEST['index_'.$meta_value] == 'index' ) + { $MetaData->setFields($meta_value); echo i18n("Index Image"); @@ -223,7 +309,7 @@ } -echo '<h2>'.i18n("Import").'</h2>'; +echo '<h1>'.i18n("Import").'</h1>'; echo i18n("Select Folders For Import/Update:"); ?> <br /> @@ -241,6 +327,7 @@ <?php echo i18n("Thumbnails").':'; ?> <br /> +<input type="checkbox" id="index_thumbnails_deletefirst" name="index_thumbnails_delete" value="delete" /><label for="index_thumbnails_deletefirst"> <?php echo i18n("Delete First"); ?></label><br /> <input type="radio" id="index_thumbnails_no" name="index_thumbnails" value="no" /><label for="index_thumbnails_no"> <?php echo i18n("No Create"); ?></label><br /> <input type="radio" id="index_thumbnails_index" name="index_thumbnails" value="create" checked="checked" /><label for="index_thumbnails_index"> <?php echo i18n("Create"); ?></label><br /> <input type="radio" id="index_thumbnails_reindex" name="index_thumbnails" value="recreate" /><label for="index_thumbnails_reindex"> <?php echo i18n("Re-create"); ?></label><br /> @@ -320,6 +407,8 @@ /** * exif, iptc, xmp + * + * nr images to index: (nr_total - nr_indexed) */ $nr_total = $GLOBALS['linpha']->db->GetRow("SELECT sum(stats_numbers) FROM ".PREFIX."photos WHERE parent_id = '0' GROUP BY parent_id"); foreach($array_meta AS $value) Modified: trunk/linpha2/lib/classes/linpha.filesys.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -49,9 +49,15 @@ /** * delete recurisvely - same as "rm -rf" * @todo should we really have such a dangerous function in linpha? + * @param string $path folder to be deleted + * @param boolean $followLinks delete also contents inside links */ function rm_rf($path,$followLinks=false) { + if(empty($path)) { + return false; + } + if( is_file($path) ) { @unlink( $path ); @@ -163,6 +169,8 @@ /** * if $path is absolute, input is just returned, if $path is relative, * the relative path starting from the linpha root directory is returned +* +* always removed ending '/' to have unified paths in linpha * * @author flo * @param string $path a path Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -464,6 +464,10 @@ * returns the full path to the cached image * in thumb mode, $id is the photoid * in image mode, $id is the cached photoid + * + * @param string $what 'thumb' or 'img' + * @param int $id image id + * @return string full path to cached image */ function getCachePath($what,$id) { @@ -485,6 +489,7 @@ * deleteCached thumbnail by id * * @param int $id id of thumb in database + * @return boolean false if there was no image, true if there was an image to delete */ function deleteCachedThumbnail($id) { @@ -494,9 +499,15 @@ { if( ! @unlink( $output ) ) { - linSysLog('Warning: '.$output.' cannot be deleted, check permissions'); + linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); } + + return true; } + else + { + return false; + } } /** @@ -515,7 +526,7 @@ { if( ! @unlink( $output ) ) { - linSysLog('Warning: '.$output.' cannot be deleted, check permissions'); + linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); } } } Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -463,7 +463,9 @@ case 'recreate': if($GLOBALS['linpha']->sql->isAdmin()) { - LinImage::createThumbnail($this->id_current,$this->img_type,$force=true); + $thumbnail = new LinImage(); + $_GET['force'] = true; + $thumbnail->createThumbnail($this->id_current); } break; case 'rotate_left': Modified: trunk/linpha2/lib/classes/thumbnails.js =================================================================== --- trunk/linpha2/lib/classes/thumbnails.js 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/lib/classes/thumbnails.js 2006-09-25 21:07:11 UTC (rev 4566) @@ -57,7 +57,7 @@ /** * set correct main height only if photos_per_page == auto */ -// document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; + document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; /** * calculate nr of photos per page (from select form) Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -183,7 +183,7 @@ <?php break; case 'delete': - echo i18n("Delete All The Following Files/Folders including contensts:").'<br />'; + echo i18n("Delete all the following files/folders including contents:").'<br />'; foreach($_REQUEST['checkedfiles'] AS $value) { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos " . Modified: trunk/linpha2/templates/default/css/view_thumb.css =================================================================== --- trunk/linpha2/templates/default/css/view_thumb.css 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/templates/default/css/view_thumb.css 2006-09-25 21:07:11 UTC (rev 4566) @@ -1,6 +1,6 @@ -#main { +/*#main { height: 85%; -} +}*/ /** * need this to calculate heigh of main div Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/templates/default/global.html.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -121,17 +121,22 @@ <?php if( isset( $GLOBALS['linpha']->template->output['menu_More'] ) ) { $GLOBALS['linpha']->template->printMenu("More"); } ?> + + <!-- icons --> <div> - <!-- icons --> <?php if( isset( $GLOBALS['linpha']->template->output['menu_Icons'] ) ) { echo $GLOBALS['linpha']->template->output['menu_Icons']; } ?> <a href="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&slideshow=play"><img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png'; ?>" border="0" title="<?php echo i18n("Play Slideshow"); ?>" /></a> </div> + + <?php if($GLOBALS['linpha']->sql->isLoggedIn()) { ?> + <!-- my settings and admin links --> <ul> <li><a href="<?php echo LINPHA_DIR; ?>/?cat=settings"><?php echo i18n("My Settings"); ?></a></li> </ul> <?php $GLOBALS['linpha']->template->printMenu("Admin",LINPHA_DIR."/admin/"); ?> + <?php } ?> </div> <div style="clear: both;"></div> <!-- end menu --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |