huchister has asked for the wisdom of the Perl Monks concerning the following question:
I am relatively new to perl, so Please help! perl monk!
I am working on this 'Approve user uploaded pictures' before let it go live, However I also like to move them into each specific gallery while I approve it at the same time
I have to use SELECT HTML array and send selected value(gallery id) as Perl parameter. Now the problem is I am not only sending one picture. I am sending multiple picture into multiple gallery. (can be selected), but I am stuck on PERL function where I have to set each selected value into different item
sub accpending { my $self = shift; #reads the checked list from pending function. my @pids = param('list'); my @selectedparam = param('gallery'); my $i = 0; foreach my $pid (@pids) { my ( $pxml, $pob ) = @$self{'pxml','pob'}; my $item = $pob->find_node( $pxml->{'xml'}, 'item', id => $pid ); # points to gallery my $chosengallery = @selectedparam[$i]; # print "item: $item\n"; #if item cannot be found in pending list, prints this. # if( !$item ) { # WCM::Basic::doheader($self); # print "Item to approve is already gone"; # return; # } # recevie the selected gallery for addtogallery # from approve() function $item->{'_change'} = 1; # change gallery according from seelcted param. $item->{'gallery'} = {value => $chosengallery}; my $node = $self->addtogallery($item, 0); $self->genthumbs ($node); #we want to save it at iob real list to make sure we have the item + in the gallery. $self->{'iob'}->save(); #make sure to delete node from pob, since file has been moved to a +pproval list already. we dont want this picture to keep in our system +. #save the newly updated pending list. #comment out if you want to temporary disable moving from pendingl +ist. #$pob->del_node( $pxml->{'xml'}, 'item', id => $pid ); $pob->save(); $i++; } }
Here is the HTML section.
#new galleryops for choosing gallery my $dgallery = xval $item->{'gallery'}; my $galleryops = $self->gengalleryops( $dgallery ); my $className = ( $i % 2 ) ? 'row t_list' : 'row t_list_alt'; $i++; # List pending images along with checked list $ret .= " <tr class='$className'> <td onmouseout='showPicture(\"$file\",0, \"$path\")' + onmouseover='showPicture(\"$file\",1, \"$path\")'>$file</td> <td onmouseout='showPicture(\"$file\",0, \"$path\")' + onmouseover='showPicture(\"$file\",1, \"$path\")'>$shorttitle</td> <td id='$file'></td> <td>$date</td> <td onmouseout='showPicture(\"$file\",0, \"$path\")' + onmouseover='showPicture(\"$file\",1, \"$path\")'>$desc</td> <td> <select id='curgal' onchange='showgalfields()' name='g +allery[]'> <option value='-1'>Select One</option>$galleryops </select> </td> <td onmouseout='showPicture(\"$file\",0, \"$path\")' + onmouseover='showPicture(\"$file\",1, \"$path\")'> </td> <td><input type='checkbox' name='list' value='$id' s +tyle='float: right;'></td> </tr>"; }
Notice only checked list value need to get approval. But at the same time, it needs to move into USER SELECTED GALLERY
I also need to set if statement if user didn't SELECT gallery, dont approve it
So, Basically I am stuck where I have to make while statement to run array simutaneously, and I need to make if statement to make sure ONLY THE CHECKED VALUE gets approval.
.... HELPPPPP!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I need a help! regarding with SELECT html with Perl
by GrandFather (Saint) on Sep 20, 2012 at 21:47 UTC | |
by huchister (Acolyte) on Sep 28, 2012 at 13:14 UTC |