Yoshihisa Fukuhara
higef****@users*****
2006年 6月 4日 (日) 10:48:07 JST
Index: affelio/apps/album/Album/AddAlbum.pm
diff -u /dev/null affelio/apps/album/Album/AddAlbum.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/AddAlbum.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,82 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::AddAlbum;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::AddAlbum::ISA = "Exporter";
+ @ Album::AddAlbum::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ debug_print("Album::AdminAlbum::handler: start.");
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/owner/add_album.tmpl";
+
+ show($album, $cgi, $out_ref);
+ debug_print("Album::AdminAlbum::handler: end.");
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+ debug_print("Album::AdminAlbum::show start.");
+
+ my $wi = new Affelio::misc::WebInput();
+ my $title = $album->escape($cgi->param("title"));
+ my $contents = $album->escape($cgi->param("contents"));
+ my $user = $album->{afap}->get_visitor_info("nickname");
+ my $afid = $album->{afap}->get_visitor_info("afid");
+
+ if($cgi->param("submit") ne "") {
+ $output_ref->{"SUBMIT"} = "1";
+ $album->addAlbum($title, $contents, $user, $afid);
+ my $ret = $album->getNewestAlbumId;
+ $output_ref->{"ID"} = $ret->{id};
+ }
+# Confirm information
+ elsif($cgi->param("confirm") ne "") {
+ $output_ref->{"CONFIRM"} = "1";
+ }
+# Edit infomation
+ else {
+ $output_ref->{"EDIT"} = "1";
+ }
+
+ $output_ref->{"TITLE"} = $title;
+ $output_ref->{"CONTENTS"} = $contents;
+ debug_print("Album::AddAlbum::show end.");
+ }
+
+}
Index: affelio/apps/album/Album/Admin.pm
diff -u /dev/null affelio/apps/album/Album/Admin.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/Admin.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,103 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+package Album;
+{
+ use strict;
+ use Album::AdminTop;
+ use Album::DeleteImage;
+ use Album::ManageAlbumContent;
+ ######################################################################
+ #run_admin
+ ######################################################################
+ sub run_admin{
+ my $self = shift;
+ my $afap = $self->{afap};
+ my $cgi = $self->{cgi};
+ my $wi = $self->{wi};
+
+ my %handlers = (
+ "add_album", "AddAlbum",
+ "delete_album","DeleteAlbum",
+ "edit_album_caption", "EditAlbumCaption",
+ "manage_album_content", "ManageAlbumContent",
+ "delete_comment", "DeleteComment",
+ "delete_image", "DeleteImage",
+ "admin_top", "AdminTop",
+ );
+
+ ###########################
+ #Check access
+ ###########################
+ unless ($afap->check_access("DF_access")) {
+ $self->accessErrorExit('Access Denied. You don\'t have permission to this application.');
+ }
+ unless ($afap->get_visitor_info("type") eq "self"){
+ $self->accessErrorExit('Access Denied. You don\'t have permission to this application.');
+ }
+ ###########################
+ #Going to the owner mode
+ ###########################
+ $afap->{af}->set_owner_mode();
+
+ ##############################################################
+ #prep vars
+ ##############################################################
+ my %output_data = ("tmpl_path", Cwd::getcwd()."/templates/");
+
+ ##############################################################
+ #Model invocation
+ ##############################################################
+ my $mode = $wi->PTN_mode($cgi->param("mode"));
+ if ($mode eq "") {$mode="admin_top";}
+ debug_print("Album::Admin::run: mode=$mode");
+
+ my $classname = "Album::" . $handlers{$mode};
+ debug_print("Album::Admin::run: handler= $classname");
+ eval "use $classname";
+ if($@){
+ throw Affelio::exception::SystemException("Could not load handler [$mode]");
+ }
+ debug_print("Album::Admin::run: handler function loaded.");
+
+ my $ret="";
+ try{
+ debug_print("Album::Admin::run: handler function..... ");
+ handler($cgi, $self, \%output_data);
+ debug_print("Album::Admin::run: handler function done.");
+ }catch Error with{
+ my $e = shift;
+ $output_data{"err_msg"} .= $e->stacktrace;
+ };
+ debug_print("Album::Admin::run: $output_data{tmpl_file}");
+ ##############################################################
+ #Output View
+ ##############################################################
+ my $tmpl = new HTML::Template(filename => $output_data{tmpl_file},
+ die_on_bad_params => 0);
+ $tmpl->param(%output_data);
+
+ print "Content-type: text/html; charset=UTF-8\n";
+ print "Pragma: no-cache", "\n\n";
+ print $afap->get_HTML_header("Affelio Photo Album: Owner mode");
+ print $self->translate_templateL10N($tmpl->output);
+ print $afap->get_HTML_footer;
+}
+
+
+}
+1;
Index: affelio/apps/album/Album/AdminTop.pm
diff -u /dev/null affelio/apps/album/Album/AdminTop.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/AdminTop.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,93 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::AdminTop;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::AdminTop::ISA = "Exporter";
+ @ Album::AdminTop::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ debug_print("Album::AdminTop::handler: start.");
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/owner/owner.tmpl";
+
+ show($album, $cgi, $out_ref);
+ debug_print("Album::AdminTop::handler: end.");
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+ debug_print("Album::AdminTop::show start.");
+
+ my $wi = new Affelio::misc::WebInput();
+ my $year = $wi->PTN_num($cgi->param("year"));
+ my $month = $wi->PTN_num($cgi->param("month"));
+ my $day = $wi->PTN_num($cgi->param("day"));
+
+ my @entries_param;
+ my @entries;
+ my @images;
+ @entries = $album->getAllEntries;;
+
+ my $i = 0;
+ foreach(@entries) {
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{update_time});
+ $mon+=1;
+ $year+=1900;
+ @images = $album->getAllImage($_->{id});
+
+ push @entries_param,
+ {
+ MONTH => $mon,
+ DAY => $mday,
+ #TIME => sprintf("%02d:%02d", $hour, $min),
+ TITLE => $_->{title},
+ CONTENTS=> $_->{contents},
+ ID => $_->{id},
+ IMAGE => $images[0]->{image},
+ EDITABLE=> 1
+ };
+ }
+
+ $output_ref->{"ENTRIES"} = \@entries_param;
+ $output_ref->{"EDITABLE"} = "1";
+ $output_ref->{"access_control_URL"} = $album->{afap}->get_URL("access_control");
+ $output_ref->{"install_title"} = $album->{afap}->get_app_info("install_title");
+ debug_print("Album::AdminTop::show end.");
+ }
+
+}
Index: affelio/apps/album/Album/Default.pm
diff -u /dev/null affelio/apps/album/Album/Default.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/Default.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,214 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::Default;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+use File::Basename;
+use Exporter;
+ @ Album::Default::ISA = "Exporter";
+ @ Album::Default::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/album.tmpl";
+
+ show($album, $cgi, $out_ref);
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+
+ my $wi = new Affelio::misc::WebInput();
+ my $id = $wi->PTN_num($cgi->param("id"));
+ my $entry = $album->getEntry($id);
+ my $edit = 0;
+ my $save_file=0;
+
+ if($album->{afap}->check_access("add_image")) {
+ $edit = 1;
+ }
+
+ my $col_num=4;
+
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($entry->{timestamp});
+ my ($up_sec, $up_min, $up_hour, $up_mday, $up_mon, $up_year) = localtime($entry->{update_time});
+ $mon+=1;
+ $year+=1900;
+ $up_mon+=1;
+ $up_year+=1900;
+
+# Album info
+ $output_ref->{YEAR} = $year;
+ $output_ref->{MONTH} = $mon;
+ $output_ref->{DAY} = $mday;
+ $output_ref->{UP_YEAR} = $up_year;
+ $output_ref->{UP_MONTH} = $up_mon;
+ $output_ref->{UP_DAY} = $up_mday;
+ $output_ref->{TITLE} = $entry->{title};
+ $output_ref->{CONTENTS} = $entry->{contents};
+ $output_ref->{ID} = $id;
+ $output_ref->{EDITABLE} = $edit;
+
+# upload image
+ if ($cgi->param("image_upload") ne ""){
+ my $filehandle=$cgi->param("uploadingfile"); #Get file handle
+ if ($filehandle){
+ fileparse_set_fstype("MSDOS"); #For IE user
+ my $basename = basename($filehandle,"");
+ if ($basename =~ /^[a-zA-Z0-9\.\-\_]{1,32}$/ ){ #Check Filename
+ my $fname=$album->{afap}->get_userdata_dir().'/'.$id.'/'.$basename;
+ my $thumb_fname=$album->{afap}->get_userdata_dir().'/'.$id.'/thumbnail/'.$basename;
+ my $chkFile = $album->checkImagefile($id,$basename);
+
+ if ($chkFile->{image} eq $basename){
+ unless ($cgi->param("rewrite")){
+ $output_ref->{EXIST_SAMEFILE} = "1";
+ $output_ref->{UPLOAD_IMAGE} = $basename;
+ }else{#override(not yet)
+ $save_file=2;
+ }
+ }else{
+ $save_file=1;
+ }
+
+ if ($save_file){
+ debug_print("hoge4 $filehandle");
+
+ # Save file
+ open (OUT,">$fname") or die "Can't make serverside file!\n";
+ while (my $bytesread = read($filehandle,my $buffer,1024)){
+ print OUT $buffer;
+ }
+ close(OUT);
+ debug_print("hoge5");
+
+ (eval 'use Image::Magick; 1;' ) ? ( $output_ref->{IMAGEMAGICK} = 0 ) : ( $output_ref->{IMAGEMAGICK}=1 );
+ my $image = Image::Magick->new;
+ $image->Read( $fname );
+ $image->Resize( geometry=>"100x100" );
+ $image->Set( quality=>75 );
+ $image->Write( $thumb_fname );
+
+ my $title = $album->escape($cgi->param("title"));
+ my $comment = $album->escape($cgi->param("comment"));
+ my $user = $album->{afap}->get_visitor_info("nickname");
+ my $afid = $album->{afap}->get_visitor_info("afid");
+
+ if(!$user){
+ $user = '';
+ $afid = '';
+ }
+ if ($save_file=1){
+ debug_print("hoge6");
+
+ $album->addImage($id, $title, $user, $afid, $comment, $basename);
+ }elsif($save_file=2){
+ debug_print("hoge7");
+
+ $album->updateImage($id, $title, $comment, $basename);
+ }
+ $album->updateTimestamp($id);
+ $output_ref->{DONE_UPLOAD} = "1";
+ $output_ref->{UPLOAD_IMAGE} = $basename;
+ }
+ }else{
+ $output_ref->{ERR_FILENAME} = "1";
+ }
+ }
+ else{
+ $output_ref->{NO_FILENAME} = "1";
+ }
+ }
+
+#Show thumbnail
+ my @image_files;
+ my @image_row;
+ my @image_filelist=$album->getAllImage($id);
+ if ($#image_filelist>=0){
+ $output_ref->{HAS_IMAGE} = "1";
+ for (my $i=0; $i<($#image_filelist+1)%$col_num; $i++){
+ push @image_filelist,
+ {
+ image => "",
+ pkey => "",
+ }
+ }
+
+ for (my $i=0; $i<($#image_filelist+1)/$col_num; $i++){
+ my $i_num=$i*$col_num;
+ for (my $j=0; $j<$col_num; $j++){
+ push @image_files,
+ {
+ IMAGE => $image_filelist[$i_num+$j]->{image},
+ ID2 => $id,
+ PKEY => $image_filelist[$i_num+$j]->{pkey},
+ };
+ }
+ push @image_row,
+ {IMG => [@image_files[$i_num..($i_num+($col_num-1))]]};
+
+ }
+ $output_ref->{THUMBNAIL} = \@image_row;
+ }
+
+# Show Comment
+ if($album->getCommentsNo($id) > 0) {
+ $output_ref->{HAS_COMMENTS} = "1";
+ my $user_uri;
+ my @comments_param;
+ my @comments = $album->getComments($id);
+ foreach(@comments) {
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{timestamp});
+ $mon += 1;
+ if ($_->{user} eq ''){
+ $user_uri="Guest";
+ }else{
+ $user_uri='<A HREF="'.$album->{afap}->get_site_info("web_root").'/outgoing.cgi?dest_url='.$_->{afid}.'">'.$_->{user}."</A>";
+ }
+ push @comments_param,
+ {
+ UNAME => $user_uri,
+ COMMENT_TIME => "$mon/$mday/$hour:$min",
+ COMMENT => $_->{comment}
+ };
+ }
+ $output_ref->{COMMENTS} = \@comments_param;
+ }
+
+ if($album->{afap}->check_access("write_comment")){
+ $output_ref->{comment_write} = "true";
+ }
+ }
+}
Index: affelio/apps/album/Album/DeleteAlbum.pm
diff -u /dev/null affelio/apps/album/Album/DeleteAlbum.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/DeleteAlbum.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,71 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::DeleteAlbum;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::DeleteAlbum::ISA = "Exporter";
+ @ Album::DeleteAlbum::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/owner/delete_album.tmpl";
+
+ show($album, $cgi, $out_ref);
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+
+ my $wi = new Affelio::misc::WebInput();
+
+ my $id = $wi->PTN_num($cgi->param("id"));
+ $output_ref->{"ID"} = $id;
+
+# done delete
+ if($cgi->param("delete") ne "") {
+ $album->removeAlbum($id);
+ $output_ref->{"DONE"} = "1";
+ $output_ref->{"DONE_LABEL"} = '<AF_M text="The album was deleted">';
+ }
+# confirm
+ elsif($cgi->param("delete_confirm") ne "") {
+ $output_ref->{"DELETE_CONFIRM"} = "1";
+ }
+
+ }
+
+}
Index: affelio/apps/album/Album/DeleteComment.pm
diff -u /dev/null affelio/apps/album/Album/DeleteComment.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/DeleteComment.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,67 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::DeleteComment;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::DeleteComment::ISA = "Exporter";
+ @ Album::DeleteComment::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/owner/delete_comment.tmpl";
+
+ show($album, $cgi, $out_ref);
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+
+ my $wi = new Affelio::misc::WebInput();
+
+ my $id = $wi->PTN_num($cgi->param("id"));
+
+ my @pkey = $cgi->param("delete_comment");
+#Done
+ if($cgi->param("delete") ne "") {
+ $album->removeComment($id, @ pkey);
+ $output_ref->{"ID"} = $id;
+ $output_ref->{"DONE"} = "1";
+ }
+
+ }
+
+}
Index: affelio/apps/album/Album/DeleteImage.pm
diff -u /dev/null affelio/apps/album/Album/DeleteImage.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/DeleteImage.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,64 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::DeleteImage;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::DeleteImage::ISA = "Exporter";
+ @ Album::DeleteImage::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/owner/delete_image.tmpl";
+
+ show($album, $cgi, $out_ref);
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+ my $wi = new Affelio::misc::WebInput();
+ my $id = $wi->PTN_num($cgi->param("id"));
+
+ my @pkey = $cgi->param("delete_image");
+# Done
+ if($cgi->param("delete") ne "") {
+ $album->removeImage($id, @ pkey);
+ $output_ref->{"ID"} = $id;
+ $output_ref->{"DONE"} = "1";
+ }
+ }
+
+}
Index: affelio/apps/album/Album/EditAlbumCaption.pm
diff -u /dev/null affelio/apps/album/Album/EditAlbumCaption.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/EditAlbumCaption.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,75 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::EditAlbumCaption;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::EditAlbumCaption::ISA = "Exporter";
+ @ Album::EditAlbumCaption::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/owner/edit_album_caption.tmpl";
+
+ show($album, $cgi, $out_ref);
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+ my $wi = new Affelio::misc::WebInput();
+
+ my $id = $wi->PTN_num($cgi->param("id"));
+ $output_ref->{"ID"} = $id;
+
+# done edit
+ if($cgi->param("edit") ne "") {
+ $album->updateEntry($id, $album->escape($cgi->param("title")), $album->escape($cgi->param("contents")));
+ $output_ref->{"DONE"} = "1";
+ $output_ref->{"DONE_LABEL"} = '<AF_M text="Information was updated.">';
+ }
+
+# comment edit
+ elsif ($cgi->param("comment_edit") ne ""){
+ $output_ref->{"EDIT"} = "1";
+ my $entry = $album->getEntry($id);
+ $entry->{contents} =~ s/<br \/>/\n/g;
+ $output_ref->{"TITLE"} = $entry->{title},
+ $output_ref->{"CONTENTS"} = $entry->{contents},
+ }
+
+ }
+
+}
Index: affelio/apps/album/Album/EditCaption.pm
diff -u /dev/null affelio/apps/album/Album/EditCaption.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/EditCaption.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,87 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::EditCaption;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::EditCaption::ISA = "Exporter";
+ @ Album::EditCaption::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/edit_caption.tmpl";
+
+ show($album, $cgi, $out_ref);
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+
+ my $wi = new Affelio::misc::WebInput();
+ my $id = $wi->PTN_num($cgi->param("id"));
+ my $afid = $album->{afap}->get_visitor_info("afid");
+ my $pkey = $wi->PTN_num($cgi->param("pkey"));
+ my $image_data = $album->getImage($id,$pkey);
+
+# owner can edit it
+ if($album->{afap}->check_access("add_image")){
+ unless($image_data->{afid} eq $afid || $album->{afap}->get_visitor_info("type") eq "self") {
+ $album->errorExit('<AF_M text="Access denied">');
+ }
+ }
+
+ $output_ref->{ID} = $id;
+ $output_ref->{PKEY} = $pkey;
+
+# done edit
+ if($cgi->param("edit") ne "") {
+ $album->updateImage($id, $album->escape($cgi->param("title")),
+ $album->escape($cgi->param("comment")),
+ $image_data->{image});
+ $output_ref->{DONE} = "1";
+ }
+
+# edit comment
+ elsif ($cgi->param("comment_edit") ne ""){
+ $output_ref->{EDIT} = "1";
+ my $entry = $album->getImage($id,$pkey);
+ $entry->{comment} =~ s/<br \/>/\n/g;
+ $output_ref->{TITLE} = $entry->{title};
+ $output_ref->{COMMENT} = $entry->{comment};
+ $output_ref->{PKEY} = $entry->{pkey};
+ }
+ }
+}
Index: affelio/apps/album/Album/ImageView.pm
diff -u /dev/null affelio/apps/album/Album/ImageView.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/ImageView.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,113 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::ImageView;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::ImageView::ISA = "Exporter";
+ @ Album::ImageView::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/image_view.tmpl";
+
+ show($album, $cgi, $out_ref);
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+
+ my $wi = new Affelio::misc::WebInput();
+ my $id = $wi->PTN_num($cgi->param("id"));
+ my $afid = $album->{afap}->get_visitor_info("afid");
+ my $pkey=$wi->PTN_num($cgi->param("pkey"));
+ my $entry = $album->getEntry($id);
+ my $image_data = $album->getImage($id,$pkey);
+
+#Content Owner can edit it
+ if($album->{afap}->check_access("add_image")){
+ if($image_data->{afid} eq $afid || $album->{afap}->get_visitor_info("type") eq "self") {
+ $output_ref->{"EDIT_COMMENT"} = "1";
+ }
+ }
+
+# Album info
+ $output_ref->{"TITLE"} = $entry->{title};
+ $output_ref->{"ID"} = $id;
+ $output_ref->{"PKEY"} = $pkey;
+
+ my $user_uri='';
+ if ($image_data->{user} eq ''){
+ $user_uri="ÄÄľÅÅ";
+ }else{
+ $user_uri='<A HREF="'.$album->{afap}->get_site_info("web_root").'/outgoing.cgi?dest_url='.$image_data->{afid}.'">'.$image_data->{user}."</A>";
+ }
+
+ $output_ref->{"IMAGE_OWNER"} = $user_uri;
+ if ($image_data->{title}){
+ $output_ref->{"HAS_TITLE"} = "1";
+ $output_ref->{"IMAGE_TITLE"} = $image_data->{title};
+ }
+ if ($image_data->{comment}){
+ $output_ref->{"HAS_COMMENT"} = "1";
+ $output_ref->{"IMAGE_COMMENT"} = $image_data->{comment};
+ }
+ if ($image_data->{image}){
+ $output_ref->{"HAS_IMAGE"} = "1";
+ $output_ref->{"IMAGE"} = $image_data->{image};
+ }
+
+#show image
+ my @image_files;
+ my @image_row;
+ my @image_filelist=$album->getAllImage($id);
+ my $i=0;
+ my $max=$#image_filelist;
+ foreach(@image_filelist){
+ if ($_->{pkey} eq $pkey){
+ if ($i>0){
+ $output_ref->{"HAS_PREV"} = "1";
+ $output_ref->{"PREV_IMAGE"} = $image_filelist[$i-1]->{pkey};
+ }
+ if ($i<$max){
+ $output_ref->{"HAS_NEXT"} = "1";
+ $output_ref->{"NEXT_IMAGE"} = $image_filelist[$i+1]->{pkey};
+ }
+ }
+ $i++;
+ }
+ }
+}
Index: affelio/apps/album/Album/ManageAlbumContent.pm
diff -u /dev/null affelio/apps/album/Album/ManageAlbumContent.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/ManageAlbumContent.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,111 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::ManageAlbumContent;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::ManageAlbumContent::ISA = "Exporter";
+ @ Album::ManageAlbumContent::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/owner/manage_album.tmpl";
+
+ show($album, $cgi, $out_ref);
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+ my $wi = new Affelio::misc::WebInput();
+
+ my $id = $wi->PTN_num($cgi->param("id"));
+ $output_ref->{"ID"} = $id;
+
+# image edit
+# if ($afap->{cgi}->param("image_arrange")){
+# $tmpl->param(ARRANGE => "1");
+
+# show thumbnails
+ my $col_num=4;
+ my @image_files;
+ my @image_row;
+ my @image_filelist=$album->getAllImage($id);
+ if ($#image_filelist>=0){
+ $output_ref->{"HAS_IMAGE"} = "1";
+ for (my $i=0; $i<($#image_filelist+1)%$col_num; $i++){
+ push @image_filelist,
+ {
+ image => "",
+ pkey => "",
+ }
+ }
+
+ for (my $i=0; $i<($#image_filelist+1)/$col_num; $i++){
+ my $i_num=$i*$col_num;
+ for (my $j=0; $j<$col_num; $j++){
+ push @image_files,
+ {
+ IMAGE => $image_filelist[$i_num+$j]->{image},
+ ID2 => $id,
+ PKEY=> $image_filelist[$i_num+$j]->{pkey}
+ };
+ }
+ push @image_row,
+ {IMG => [@image_files[$i_num..($i_num+($col_num-1))]]};
+ }
+ $output_ref->{"THUMBNAIL"} = \@image_row;
+ }
+
+# comment
+ if($album->getCommentsNo($id) > 0) {
+ $output_ref->{"HAS_COMMENTS"} = "1";
+ my @comments_param;
+ my @comments = $album->getComments($id);
+ foreach(@comments) {
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{timestamp});
+ $mon += 1;
+ push @comments_param,
+ {
+ UNAME => $_->{user},
+ COMMENT_TIME => "$mon/$mday/$hour:$min",
+ COMMENT => $_->{comment},
+ PKEY=> $_->{pkey}
+ };
+ }
+ $output_ref->{"COMMENTS"} = \@comments_param;
+ }
+ }
+}
Index: affelio/apps/album/Album/ShowImage.pm
diff -u /dev/null affelio/apps/album/Album/ShowImage.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/ShowImage.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,66 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::ShowImage;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::ShowImage::ISA = "Exporter";
+ @ Album::ShowImage::EXPORT = qw (handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+
+ my $wi = new Affelio::misc::WebInput();
+
+ my $image = $wi->PTN_basefilename($cgi->param('image'));
+ my $id = $wi->PTN_num($cgi->param('id'));
+ my $type = $wi->PTN_mode($cgi->param('type'));
+ my $filepath;
+ if ($type eq "thumbnail") {
+ $filepath = $album->{afap}->get_userdata_dir()."/".$id."/thumbnail/".$image;
+ }elsif($type eq "large"){
+ $filepath = $album->{afap}->get_userdata_dir()."/".$id."/".$image;
+ }else{
+ $filepath = "./resource/emp.jpg";
+ }
+ if ($image eq ""){
+ $filepath = "./resource/emp.jpg";
+ }
+ my $imgtype = 'jpeg';
+
+# open image file
+ open(IMG, "$filepath") or die;
+
+# show image
+ binmode IMG;
+ binmode STDOUT;
+ print "Content-type: image/$imgtype\n\n";
+ print while (<IMG>);
+
+# close image
+ close(IMG);
+}
+
+}
Index: affelio/apps/album/Album/Top.pm
diff -u /dev/null affelio/apps/album/Album/Top.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/Top.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,94 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::Top;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::Top::ISA = "Exporter";
+ @ Album::Top::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ debug_print("Album::Top::handler: start.");
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/index.tmpl";
+
+ show($album, $cgi, $out_ref);
+ debug_print("Album::Top::handler: end.");
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+ debug_print("Album::Top::show start.");
+
+ my $wi = new Affelio::misc::WebInput();
+
+ my $edit = 0;
+ if ($album->{afap}->get_visitor_info("type") eq "self"){
+ $edit = 1;
+ }
+
+ my @entries_param;
+ my @entries;
+ my @images;
+ @entries = $album->getAllEntries;
+
+ foreach(@entries) {
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{update_time});
+ $mon+=1;
+ $year+=1900;
+ @images = $album->getAllImage($_->{id});
+
+ push @entries_param,
+ {
+ MONTH => $mon,
+ DAY => $mday,
+ #TIME => sprintf("%02d:%02d", $hour, $min),
+ TITLE => $_->{title},
+ CONTENTS=> $_->{contents},
+ COMMENT_NO => $album->getCommentsNo($_->{id}),
+ ID => $_->{id},
+ IMAGE => $images[0]->{image},
+ };
+ }
+ $output_ref->{"ENTRIES"} = \@entries_param;
+
+ $output_ref->{"ENTRIES"} = \@entries_param;
+ $output_ref->{"EDITABLE"} = $edit;
+ $output_ref->{"install_title"} = $album->{afap}->get_app_info("install_title");
+ debug_print("Album::Top::show end.");
+ }
+
+}
Index: affelio/apps/album/Album/WriteComment.pm
diff -u /dev/null affelio/apps/album/Album/WriteComment.pm:1.1
--- /dev/null Sun Jun 4 10:48:07 2006
+++ affelio/apps/album/Album/WriteComment.pm Sun Jun 4 10:48:07 2006
@@ -0,0 +1,90 @@
+# Copyright (C) 2006 Affelio Inc.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+package Album::WriteComment;
+{
+use strict;
+use Affelio::misc::Debug qw( debug_print);
+
+use Exporter;
+ @ Album::WriteComment::ISA = "Exporter";
+ @ Album::WriteComment::EXPORT = qw (show handler);
+
+
+ #######################################################################
+ #handler
+ #######################################################################
+ sub handler{
+ my $cgi = shift;
+ my $album = shift;
+ my $out_ref = shift;
+
+ ###############################
+ #normal show
+ ###############################
+ $out_ref->{tmpl_file}
+ = $album->{afap}->{app__fs_root}."/templates/write_comment.tmpl";
+
+ show($album, $cgi, $out_ref);
+ }
+
+ #######################################################################
+ #show
+ #######################################################################
+ sub show{
+ my $album= shift;
+ my $cgi=shift;
+ my $output_ref = shift;
+
+ unless ($album->{afap}->check_access("write_comment")){
+ $album->errorExit('<AF_M text="Access denied">');
+ }
+
+ my $wi = new Affelio::misc::WebInput();
+ my $comment = $album->escape($cgi->param('comment'));
+ my $id = $wi->PTN_num($cgi->param('id')) or exit;
+ my $user = $album->{afap}->get_visitor_info("nickname");
+ my $afid = $album->{afap}->get_visitor_info("afid");
+ my $user_uri="";
+
+ if(!$user){
+ $user = "";
+ $user_uri = 'Guest';
+ $afid="";
+ }
+ else{
+ $user_uri='<A HREF="'.$album->{afap}->get_site_info("web_root").'/outgoing.cgi?dest_url='.$afid.'">'.$user."</A>";
+ }
+
+# confirm comment
+ if($cgi->param('comment_confirm') ne "") {
+ $output_ref->{CONFIRM} = "1";
+ $output_ref->{COMMENT} = $comment;
+ $output_ref->{ID} = $id;
+ $output_ref->{USER_NAME} = $user_uri;
+ }
+
+# submit comment
+ elsif($cgi->param('comment_commit') ne "") {
+ $album->addComment($id, $user, $afid, $comment);
+ $album->updateTimestamp($id);
+ $output_ref->{COMMIT} = "1";
+ $output_ref->{ID} = $id;
+ }
+ }
+}
+