[Linpha-cvs] SF.net SVN: linpha: [4538] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-04-15 17:58:53
|
Revision: 4538 Author: fangehrn Date: 2006-04-15 10:58:34 -0700 (Sat, 15 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4538&view=rev Log Message: ----------- * basket - download currently broken, working on todos... Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/archiver.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/include/basket_build_print.php trunk/linpha2/lib/include/basket_build_zip.php trunk/linpha2/lib/modules/module.basket.php trunk/linpha2/templates/default/global.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/ChangeLog 2006-04-15 17:58:34 UTC (rev 4538) @@ -4,6 +4,10 @@ download needs still some improvements (chdir() to album dir to no get relative or absolute paths) + * added icon support + + * basket - download currently broken, working on todos... + 2006-04-14 flo * startet implementing basket checkout features (download, print, mail) * added settings all feature in admin section Modified: trunk/linpha2/lib/classes/archiver.class.php =================================================================== --- trunk/linpha2/lib/classes/archiver.class.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/classes/archiver.class.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -81,22 +81,9 @@ * Method to create filelist/path for files to download * @return string fullpath,path,src_path */ -function getImageList($img_ids) +function setImageList($files) { - $this->files = ''; - - foreach($img_ids AS $image_id) - { - $full_filename = LinSql::getFullImagePath( $image_id ); - - $this->files .= linEscapeString($full_filename)." "; - - /** - * store md5sum for later use (statistics) - * @todo - */ - //$this->md5sums[] = $data['md5sum']; - } + $this->files = $files; } @@ -118,14 +105,8 @@ $command = str_replace('{files}',$this->files,$command); // $this->files is already escaped $command = str_replace('{archive_name}',linEscapeString($this->tmpname),$command); - - //error_log($command); - - if(!chdir(LINPHA_DIR)) { - echo 'cannot chdir(LINPHA_DIR)!<br />'; - return false; - } + /** * delete tempfile first because winrar cannot write into this empty file (created with touch())! * -> it could be possible that linpha_tempnam() generates now a duplicate tmpname if another user @@ -133,8 +114,24 @@ * very unlikely because the session_id is included in tmpname and there is not much time between unlink() and exec() */ unlink($this->tmpname); + + + /** + * change dir to the albums dir to get nicer filenames in the archiv + */ + $olddir = getcwd(); + if(!chdir( $GLOBALS['linpha']->sql->getPath('album') )) { + echo 'cannot chdir(LINPHA_DIR)!<br />'; + return false; + } + exec($command,$array_output=Array(),$return_value=0); + + /** + * chdir back + */ + chdir($olddir); if(!file_exists($this->tmpname)) { echo 'Created archive doesnt exists<br />'; Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -384,6 +384,35 @@ break; } } + + /** + * Icons + */ + $GLOBALS['linpha']->template->output['menu_Icons'] = ''; + if($this->mode == 'thumb') + { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=download">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/download.png" border="0" title="'.i18n("Download Images").'" />' + .'</a>'."\n"; + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=print">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/print.png" border="0" title="'.i18n("Print Images").'" />' + .'</a>'."\n"; + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=mail">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Images").'" />' + .'</a>'."\n"; + } + elseif($this->mode == 'image') + { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.LINPHA_DIR.'/download_file.php?id='.$this->id_current.'">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/download.png" border="0" title="'.i18n("Download Image").'" />' + .'</a>'."\n"; + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_this_with_checkout&checkout_as=print">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/print.png" border="0" title="'.i18n("Print Image").'" />' + .'</a>'."\n"; + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_this_with_checkout&checkout_as=mail">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Image").'" />' + .'</a>'."\n"; + } } @@ -407,7 +436,12 @@ { } break; - case 'basket_add_all': // coming from imgview, mode=viewThumb + case 'basket_add_all': + case 'basket_add_all_with_checkout': + /** + * coming from imgview, mode=viewThumb + * the permission check with photoIsAllowed() is done while checking out + */ foreach($this->photos_filtered AS $value) { if($value['img_type']!=0) @@ -415,9 +449,25 @@ $_SESSION['basket_ids'][] = $value['id']; } } + + if($_GET['admin_cmd'] == 'basket_add_all_with_checkout') + { + header("Location: ".LINPHA_DIR."/?cat=basket&checkout_as=".$_GET['checkout_as']); + exit(); + } break; - case 'basket_add_this': // coming from imgview, mode=viewImg + case 'basket_add_this': + case 'basket_add_this_with_checkout': + /** + * coming from imgview, mode=viewImg + */ $_SESSION['basket_ids'][] = $this->id_current; + + if($_GET['admin_cmd'] == 'basket_add_this_with_checkout') + { + header("Location: ".LINPHA_DIR."/?cat=basket&checkout_as=".$_GET['checkout_as']); + exit(); + } break; } } Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -542,7 +542,7 @@ function getFullFilenameFromId( $photos_id ) { $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, parent_id FROM ".PREFIX."photos " . - "WHERE id = '".$GLOBALS['linpha']->sql->linAddslashes($photos_id)."'"); + "WHERE id = '".LinSql::linAddslashes($photos_id)."'"); $data = $query->FetchRow(); $array_names[ $photos_id ] = $data['name']; Modified: trunk/linpha2/lib/include/basket_build_print.php =================================================================== --- trunk/linpha2/lib/include/basket_build_print.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/include/basket_build_print.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -104,8 +104,10 @@ /** * read array with images to print */ +reset($_SESSION['basket_ids']); while(list($key, $image_id) = each($_SESSION['basket_ids'])) { + $full_filename = LinSql::getFullImagePath( $image_id ); /** Modified: trunk/linpha2/lib/include/basket_build_zip.php =================================================================== --- trunk/linpha2/lib/include/basket_build_zip.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/include/basket_build_zip.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -25,12 +25,23 @@ if(!defined('LINPHA_DIR')) { exit(1); } +/** + * set file list for direct use in exec() command + */ + $files = ''; + foreach($_SESSION['basket_ids'] AS $image_id) + { + $array_names = LinSql::getFullFilenameFromId( $image_id ); + + $filename = implode('/',$array_names); + + $files .= linEscapeString($filename)." "; + } + include_once(LINPHA_DIR.'/lib/classes/archiver.class.php'); - $archive = new Archive($_POST['ziptype'], $GLOBALS['linpha']->sql->config->value['sys_basket_download_limit']); +$archive->setImageList($files); -$archive->getImageList($_SESSION['basket_ids']); - if($archive->makeArchive()) { $archive->startDownload(); @@ -44,7 +55,14 @@ foreach($archive->md5sums AS $value) { linStats('download',$value,$time); - }*/ + } + /** + * store md5sum for later use (statistics) + * @todo + + //$this->md5sums[] = $data['md5sum']; + * + **/ } ?> Modified: trunk/linpha2/lib/modules/module.basket.php =================================================================== --- trunk/linpha2/lib/modules/module.basket.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/modules/module.basket.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -27,7 +27,6 @@ /** * parse POST data and GET commands */ - /** * download error handling */ @@ -47,72 +46,96 @@ switch($_REQUEST['cmd']) { case 'checkout': - if(! $GLOBALS['linpha']->sql->checkPermission($_REQUEST['checkout_as'])) + /** + * do the final checkout + */ + + try { - linSysLog(i18n("No Access")); - } - else - { /** + * check basket permission + */ + if(! $GLOBALS['linpha']->sql->checkPermission($_REQUEST['checkout_as'])) + { + throw new Exception(i18n("No Access")); + } + + /** * no images selected */ if( count($_SESSION['basket_ids']) == 0 ) { - echo linSysLog(i18n("No Images Selected!")); + throw new Exception(i18n("No Images Selected!")); } - else + + /** + * check permission of each image id + */ + foreach($_SESSION['basket_ids'] AS $value) { - - switch($_REQUEST['checkout_as']) + if(! $GLOBALS['linpha']->sql->photoIsAllowed($value)) { - case 'download': - include_once(LINPHA_DIR.'/lib/include/basket_build_zip.php'); - exit(); - break; - case 'print': - include_once(LINPHA_DIR.'/lib/include/basket_build_print.php'); - exit(); - break; - case 'mail': - include_once(LINPHA_DIR.'/lib/include/basket_build_mail.php'); - break; + throw new Exception(i18n("No Access")); } } + + /** + * do the final checkout + * exit script in download (the file download is startet in this file) and print (opens in a new page) + */ + switch($_REQUEST['checkout_as']) + { + case 'download': + include_once(LINPHA_DIR.'/lib/include/basket_build_zip.php'); + exit(); + break; + case 'print': + include_once(LINPHA_DIR.'/lib/include/basket_build_print.php'); + exit(); + break; + case 'mail': + include_once(LINPHA_DIR.'/lib/include/basket_build_mail.php'); + break; + } } + catch(Exception $error) + { + linSysLog(i18n("Error").": ".$error -> getMessage()); + } + break; - /** - * add ids to session if allowed - * coming from imgview, mode=viewBasket - */ case 'add_selected': + /** + * add ids to session + * coming from imgview, mode=viewBasket + * the permission check with photoIsAllowed() is done while checking out + */ if( isset( $_POST['img_id'] ) ) { foreach($_POST['img_id'] AS $value) { - if($GLOBALS['linpha']->sql->photoIsAllowed($value)) - { - $_SESSION['basket_ids'][] = $value; - } + $_SESSION['basket_ids'][] = $value; } } Header("Location: ".convert_amp($_SESSION['basket_ref_url'])); exit(); - - /** - * remove all - */ + case 'remove_all': + /** + * remove all + */ $_SESSION['basket_ids'] = Array(); break; - /** - * remove selected - */ case 'remove_selected': + /** + * remove selected + */ + if( isset( $_POST['img_id'] ) ) { foreach($_POST['img_id'] AS $value) Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/templates/default/global.html.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -122,8 +122,10 @@ $GLOBALS['linpha']->template->printMenu("More"); } ?> <div> - <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/download.png'; ?>" title="<?php echo i18n("Download Images"); ?>" /> - <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/print.png'; ?>" title="<?php echo i18n("Print Images"); ?>" /> + <!-- 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> <ul> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |