diff --git a/lib/WebGUI/Operation/Trash.pm b/lib/WebGUI/Operation/Trash.pm index f53444bc3..b7fb656ae 100644 --- a/lib/WebGUI/Operation/Trash.pm +++ b/lib/WebGUI/Operation/Trash.pm @@ -256,9 +256,11 @@ sub www_emptyTrashConfirm { #------------------------------------------------------------------- sub www_manageTrash { return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::isInGroup(4)); - my ($sth, @data, @row, $i, $p, $allUsers); + + my ($sth, @data, @row, @sorted_row, $i, $p, $allUsers); my $output = helpIcon(66); + # Add appropriate html page header if ($session{setting}{sharedTrash} eq "1") { $allUsers = 1; $output .= '

'. WebGUI::International::get(962) .'

'; @@ -270,22 +272,18 @@ sub www_manageTrash { $allUsers = 0; $output .= '

'. WebGUI::International::get(962) .'

'; } - - - # - # Generate list of pages - # + # Generate list of pages in trash if ($allUsers) { $sth = WebGUI::SQL->read("select pageId,title,urlizedTitle,bufferUserId,bufferDate,bufferPrevId " - ."from page where parentId=3 order by bufferDate desc,bufferUserId"); + ."from page where parentId=3 order by bufferDate"); } else { $sth = WebGUI::SQL->read("select pageId,title,urlizedTitle,bufferUserId,bufferDate,bufferPrevId " ."from page where parentId=3 and bufferUserId=" - . $session{user}{userId} . " order by bufferDate desc"); + . $session{user}{userId} . " order by bufferDate"); } while (@data = $sth->array) { - my ($pageId,$title,$urlizedTitle,$bufferUserId,$bufferDate,$bufferPrevId,$url); + my ($pageId,$title,$urlizedTitle,$bufferUserId,$bufferDate,$bufferPrevId,$url,$htmlData); $pageId = $data[0]; $title = $data[1]; $urlizedTitle = $data[2]; @@ -306,41 +304,38 @@ sub www_manageTrash { $bufferPrevId = '' .$bufferPrevId .''; } } - $row[$i] = ''; - $row[$i] .= '' + + # create html row data + $htmlData = ''; + $htmlData .= '' .pageIcon() .deleteIcon('op=deleteTrashItem&pageId='.$pageId) .cutIcon('op=cutTrashItem&pageId='.$pageId); - $row[$i] .= ''; - $row[$i] .= ''.$title; - $row[$i] .= ''; - $row[$i] .= ''.WebGUI::International::get(2); - $row[$i] .= ''; - $row[$i] .= ''.$bufferDate; - $row[$i] .= ''; - $row[$i] .= ''.$bufferPrevId; - $row[$i] .= ''; + $htmlData .= ''; + $htmlData .= ''. $title .''; + $htmlData .= ''. WebGUI::International::get(2) .''; + $htmlData .= ''. $bufferDate .''; + $htmlData .= ''. $bufferPrevId .''; if ($allUsers) { - $row[$i] .= ''.$bufferUserId; - $row[$i] .= ''; + $htmlData .= ''. $bufferUserId .''; } - $row[$i] .= ''; - $i++; + $htmlData .= ''; + + # store row data in array of arrays with integer bufferDate for later sorting + push @row, [$data[4], $htmlData]; } - # - # Generate list of wobjects - # + # Generate list of wobjects in clipboard if ($allUsers) { $sth = WebGUI::SQL->read("select wobjectId,namespace,title,bufferUserId,bufferDate,bufferPrevId " - . "from wobject where pageId=3 order by bufferDate desc,bufferUserId"); + . "from wobject where pageId=3 order by bufferDate"); } else { $sth = WebGUI::SQL->read("select wobjectId,namespace,title,bufferUserId,bufferDate,bufferPrevId " . "from wobject where pageId=3 and bufferUserId=" - . $session{user}{userId} ." order by bufferDate desc"); + . $session{user}{userId} ." order by bufferDate"); } while (@data = $sth->array) { - my ($wobjectId,$namespace,$title,$bufferUserId,$bufferDate,$bufferPrevId,$url); + my ($wobjectId,$namespace,$title,$bufferUserId,$bufferDate,$bufferPrevId,$url,$htmlData); $wobjectId = $data[0]; $namespace = $data[1]; @@ -364,44 +359,50 @@ sub www_manageTrash { .$bufferUsername .''; } - $row[$i] = ''; - $row[$i] .= '' + # create html row data + $htmlData = ''; + $htmlData .= '' .wobjectIcon() .deleteIcon('op=deleteTrashItem&wid='.$wobjectId) .cutIcon('op=cutTrashItem&wid='.$wobjectId); - $row[$i] .= ''.$title; - $row[$i] .= ''; - $row[$i] .= ''.$namespace; - $row[$i] .= ''; - $row[$i] .= ''.$bufferDate; - $row[$i] .= ''; - $row[$i] .= ''.$bufferPrevId; - $row[$i] .= ''; + $htmlData .= ''; + $htmlData .= ''. $title .''; + $htmlData .= ''. $namespace .''; + $htmlData .= ''. $bufferDate .''; + $htmlData .= ''. $bufferPrevId .''; if ($allUsers) { - $row[$i] .= ''.$bufferUserId; - $row[$i] .= ''; + $htmlData .= ''. $bufferUserId .''; } - $row[$i] .= ''; - $i++; + $htmlData .= ''; + + # store row data in array of arrays with integer bufferDate for later sorting + push @row, [$data[4], $htmlData]; } $sth->finish; + + # Reverse sort row htmlData by bufferDate + @sorted_row = sort {$b->[0] <=> $a->[0]} @row; + @row = (); + for $i ( 0 .. $#sorted_row ) { + push @row, $sorted_row[$i][1]; + } + + # Create output with pagination + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + if ($allUsers) { + $output .= ''; + } + $output .= ''; if ($session{form}{systemTrash} eq "1") { $p = WebGUI::Paginator->new(WebGUI::URL::page('op=manageTrash&systemTrash=1'),\@row); } else { $p = WebGUI::Paginator->new(WebGUI::URL::page('op=manageTrash'),\@row); } - $output .= '
'. WebGUI::International::get(99) .''. WebGUI::International::get(783) .''. WebGUI::International::get(963) .''. WebGUI::International::get(953) .''. WebGUI::International::get(50) .'
'; - $output .= '' - .'' - .'' - .'' - .''; - if ($allUsers) { - $output .= '' - .''; - } else { - $output .= ''; - } $output .= $p->getPage($session{form}{pn}); $output .= '
'. WebGUI::International::get(99) .''. WebGUI::International::get(783) .''. WebGUI::International::get(963) .''. WebGUI::International::get(953) .''. WebGUI::International::get(50) .'
'; $output .= $p->getBarTraditional($session{form}{pn});