[Linpha-cvs] SF.net SVN: linpha: [4406] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-03-08 21:48:29
|
Revision: 4406 Author: fangehrn Date: 2006-03-08 13:48:13 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4406&view=rev Log Message: ----------- * adding image and album comments Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/include/common.php trunk/linpha2/templates/main_html/global.html.php trunk/linpha2/templates/main_html/view_img.html.php Added Paths: ----------- trunk/linpha2/templates/main_html/view_comment.html.php trunk/linpha2/templates/main_html/view_meta.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-03-08 16:32:29 UTC (rev 4405) +++ trunk/linpha2/ChangeLog 2006-03-08 21:48:13 UTC (rev 4406) @@ -1,5 +1,6 @@ 2006-03-08 flo * finished first stage of image fields + * adding image and album comments 2006-03-07 flo * adding forced thumbnail recreation Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-03-08 16:32:29 UTC (rev 4405) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-03-08 21:48:13 UTC (rev 4406) @@ -3,6 +3,22 @@ class linImage { +/** + * delete thumbnail + */ +function deleteThumbnail($id) +{ + $output = linSql::getCachePath('thumb',$id); + + if(file_exists($output)) + { + unlink($output); + } +} + +/** + * create thumbnail + */ function createThumbnail($id,$img_type,$force) { /** Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-03-08 16:32:29 UTC (rev 4405) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-03-08 21:48:13 UTC (rev 4406) @@ -28,8 +28,7 @@ public $photos; public $photos_filtered; public $use_javascript; -public $id_current; -public $id_parent; +public $id_current, $id_parent, $img_type, $filename, $md5sum; private $album_dir; private $nr_pages, $current_page; // only used if javascript disabled @@ -66,8 +65,11 @@ /** * switch between alb_view and img_view */ - $current_data = $GLOBALS['linpha']->db->GetRow("SELECT id, name, img_type, parent_id FROM ".PREFIX."photos " . + $current_data = $GLOBALS['linpha']->db->GetRow("SELECT id, name, img_type, parent_id, md5sum FROM ".PREFIX."photos " . "WHERE id = '".linSql::linAddslashes($_GET['id'])."'"); + $this->img_type = $current_data['img_type']; + $this->filename = $current_data['name']; + $this->md5sum = $current_data['md5sum']; /** * check for valid id @@ -76,7 +78,7 @@ { $this->id_current = $current_data['id']; - if($current_data['img_type'] == 0) + if( $this->img_type == 0) { $this->id_parent = $current_data['id']; @@ -90,6 +92,12 @@ case 'basket': $this->view = 'basket_view'; break; + case 'meta': + $this->view = 'meta_view'; + break; + case 'comment': + $this->view = 'comment_view'; + break; default: $this->view = 'thumb_view'; } @@ -101,7 +109,24 @@ } else { - $this->view = 'img_view'; + if(isset($_SESSION['view'])) + { + switch($_SESSION['view']) + { + case 'meta': + $this->view = 'meta_view'; + break; + case 'comment': + $this->view = 'comment_view'; + break; + default: + $this->view = 'img_view'; + } + } + else + { + $this->view = 'img_view'; + } $this->id_parent = $current_data['parent_id']; } } @@ -145,6 +170,13 @@ break; case 'basket_view': $this->viewBasket_view(); + break; + case 'meta_view': + $this->viewMeta_view(); + break; + case 'comment_view': + $this->viewComment_view(); + break; } include_once(LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'_html/global.html.php'); @@ -225,6 +257,10 @@ ), 'edit' => Array( 'set_permissions' => $edit_permission_link + ), + 'metainfo' => Array( + 'edit album comment' => $this->link_url.'&id='.$this->id_current.'&view=comment', + 'edit album information' => $this->link_url.'&id='.$this->id_current.'&view=meta' ) ); break; @@ -244,6 +280,9 @@ 'rot_left' => '#', 'rot_right' => '#', 'set_permissions' => $edit_permission_link + ), + 'metainfo' => Array( + 'edit image information' => $this->link_url.'&id='.$this->id_current.'&view=meta' ) ); break; @@ -607,5 +646,21 @@ $this->setSubFolders(); $this->viewThumb_View_nojs(); } + +/** + * comment_view + */ + function viewComment_view() + { + $GLOBALS['linpha']->template->setModuleName('view_comment'); + } + +/** + * meta_view + */ + function viewMeta_view() + { + $GLOBALS['linpha']->template->setModuleName('view_meta'); + } } // end class linImgview ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-03-08 16:32:29 UTC (rev 4405) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-03-08 21:48:13 UTC (rev 4406) @@ -224,7 +224,16 @@ "parent_id , name, img_type , md5sum , time_add , time_mod , stats_numbers ) " . "VALUES ( '".$parent_id."' , '".$GLOBALS['linpha']->sql->linAddslashes($filename)."', " . "'".$org_type."' , '".$md5sum."', '".time()."', '".time()."', '1' )"); - + + /** + * delete thumbnail if one exists with the same id + */ + $inserted_id = $GLOBALS['linpha']->db->Insert_ID(); + linImage::deleteThumbnail($inserted_id); + + /** + * update number of photos + */ linImport::updateNumberPhotos( $parent_id ); } else @@ -240,9 +249,15 @@ $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."photos ( parent_id , img_type , name , time_add , time_mod )" . " VALUES ( '".$parent_id."' , '0' , '". linSql::linAddSlashes($filename)."' , '".time()."' , '".time()."' )"); + /** + * delete thumbnail if one exists with the same id + */ + $inserted_id = $GLOBALS['linpha']->db->Insert_ID(); + linImage::deleteThumbnail($inserted_id); + if($recursive) { - $inserted_id = $GLOBALS['linpha']->db->Insert_ID(); + linImport::addNew( $inserted_id , $dirname.$filename.'/' , $recursive); } } Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-03-08 16:32:29 UTC (rev 4405) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-03-08 21:48:13 UTC (rev 4406) @@ -21,7 +21,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','..'); } +if(!defined('LINPHA_DIR')) { exit(1); } class MetaData { Modified: trunk/linpha2/lib/include/common.php =================================================================== --- trunk/linpha2/lib/include/common.php 2006-03-08 16:32:29 UTC (rev 4405) +++ trunk/linpha2/lib/include/common.php 2006-03-08 21:48:13 UTC (rev 4406) @@ -1,4 +1,6 @@ <?php +if(!defined('LINPHA_DIR')) { exit(1); } + /** * This file removes the magic quotes * always include this file with *include_once* to prevent multiple remove of magic quotes! Modified: trunk/linpha2/templates/main_html/global.html.php =================================================================== --- trunk/linpha2/templates/main_html/global.html.php 2006-03-08 16:32:29 UTC (rev 4405) +++ trunk/linpha2/templates/main_html/global.html.php 2006-03-08 21:48:13 UTC (rev 4406) @@ -1,7 +1,7 @@ <html> <head> <link rel='stylesheet' href='<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'_css/global.css'; ?>' type='text/css'> -<?php if( isset($output['sys_log'])) { ?> +<?php if( isset($GLOBALS['output']['sys_log'])) { ?> <style> .sys_log { position: absolute; @@ -34,12 +34,12 @@ </head> <body> -<?php if( isset($output['sys_log']) ) { ?> +<?php if( isset($GLOBALS['output']['sys_log']) ) { ?> <div id="sys_log" class="sys_log"> <div class="sys_log_close"><a href="javascript:toggleWindow()">X</a></div> <div id="sys_log_text" class="sys_log_text"> Linpha Syslog:<br /> - <?php echo $output['sys_log']; ?> + <?php echo $GLOBALS['output']['sys_log']; ?> </div> </div> <script language="JavaScript" type="text/javascript"> Added: trunk/linpha2/templates/main_html/view_comment.html.php =================================================================== --- trunk/linpha2/templates/main_html/view_comment.html.php (rev 0) +++ trunk/linpha2/templates/main_html/view_comment.html.php 2006-03-08 21:48:13 UTC (rev 4406) @@ -0,0 +1,47 @@ +<?php + +if( isset( $_POST['cmd'] ) ) +{ + /** + * check if comment exists + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."meta_comments " . + "WHERE md5sum = '".$GLOBALS['linpha']->imgview->id_current."'"); + + if($query->RecordCount()==0) // insert + { + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (time, md5sum, author, comment)" . + "VALUES ('".time()."','".$GLOBALS['linpha']->imgview->id_current."','".linSql::linAddslashes($_POST['author'])."'," . + "'".linSql::linAddslashes($_POST['comment'])."')"); + } + else // update + { + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."meta_comments SET ". + "time = '".time()."', ". + "author = '".linSql::linAddslashes($_POST['author'])."', " . + "comment = '".linSql::linAddslashes($_POST['comment'])."' " . + "WHERE md5sum = '".$GLOBALS['linpha']->imgview->id_current."'"); + } +} + + +?> + +<div id='maindiv' class='main'> +<form action="<?php echo $GLOBALS['linpha']->imgview->link_url.'&id='.$GLOBALS['linpha']->imgview->id_current; ?>" method="POST"> +<?php +$data = $GLOBALS['linpha']->db->GetRow("SELECT id, time, author, comment FROM ".PREFIX."meta_comments"); +?> +<a href="<?php echo $GLOBALS['linpha']->imgview->link_url.'&id='.$GLOBALS['linpha']->imgview->id_current.'&view=thumb'; ?>">back</a> +<br /><br /> + +Author: +<input type="text" name="author" value="<?php echo $data['author']; ?>" size="40" maxlength="40" /> +<br /> +<textarea name="comment" rows="10" cols="50"><?php echo $data['comment']; ?></textarea> +<br /> +<input type="hidden" name="cmd" value="add_comment" /> +<input type="submit" name="submit" value="submit" /> + +</form> +</div> \ No newline at end of file Modified: trunk/linpha2/templates/main_html/view_img.html.php =================================================================== --- trunk/linpha2/templates/main_html/view_img.html.php 2006-03-08 16:32:29 UTC (rev 4405) +++ trunk/linpha2/templates/main_html/view_img.html.php 2006-03-08 21:48:13 UTC (rev 4406) @@ -20,4 +20,75 @@ <div id='maindiv' class='main'> <?php echo $GLOBALS['linpha']->imgview->output['image']; ?> -</div> \ No newline at end of file +<br /><br /> + +<?php +if( isset( $_POST['cmd'] ) ) +{ + if( !empty($_POST['comment_textarea'])) + { + $comment = $_POST['comment_textarea']; + } + else + { + $comment = $_POST['comment_text']; + } + + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (time, md5sum, author, comment)" . + "VALUES ('".time()."','".$GLOBALS['linpha']->imgview->md5sum."','".linSql::linAddslashes($_POST['author'])."'," . + "'".linSql::linAddslashes($comment)."')"); +} +?> +<style> +.add_comment { + color: #036; + width: 600px; +} +.add_comment input, .add_comment textarea { + background-color: #d5eeff; +} + +.comments { + border: 1px solid #09f; + width: 200px; + margin: 5px; + margin-left: 150px; +} +</style> +<div class="add_comment"> +<form action="<?php echo $GLOBALS['linpha']->imgview->link_url.'&id='.$GLOBALS['linpha']->imgview->id_current; ?>" method="POST"> +Name: +<input type="text" name="author" value="" size="10" maxlength="40" /> +Comment: +<input type="text" id="comment_text" name="comment_text" value="" size="40" maxlength="40" /> +<a href="javascript:open_textarea()">(+)</a> +<textarea style="display: none;" id="comment_textarea" name="comment_textarea" rows="10" cols="50"></textarea> +<input type="hidden" name="cmd" value="add_comment" /> +<input type="submit" name="submit" value="submit" /> +</form> +</div> +<br /><br /> + +<?php +$query = $GLOBALS['linpha']->db->Execute("SELECT id, time, author, comment FROM ".PREFIX."meta_comments " . + "WHERE md5sum = '".$GLOBALS['linpha']->imgview->md5sum."'"); +while($data = $query->FetchRow()) +{ + echo '<div class="comments">'; + echo $data['time'].' '.$data['author'].'<br />'; + echo $data['comment'].'<br /><br />'; + echo '</div>'; +} +?> + +</div> + +<script language="Javascript"> +function open_textarea() +{ + document.getElementById('comment_textarea').style.display = 'block'; + document.getElementById('comment_text').style.display = 'none'; + + document.getElementById('comment_textarea').value = document.getElementById('comment_text').value; +} +</script> \ No newline at end of file Added: trunk/linpha2/templates/main_html/view_meta.html.php =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |