From a5a25ff29c3b0a9c40a01fd6990e81dac6b7d62b Mon Sep 17 00:00:00 2001 From: Ed Van Duinen Date: Fri, 23 May 2003 14:42:42 +0000 Subject: [PATCH] www_manageClipboard sort order fix --- lib/WebGUI/Operation/Clipboard.pm | 113 +++++++++++++++--------------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/lib/WebGUI/Operation/Clipboard.pm b/lib/WebGUI/Operation/Clipboard.pm index 70b9d2af2..31e499cff 100644 --- a/lib/WebGUI/Operation/Clipboard.pm +++ b/lib/WebGUI/Operation/Clipboard.pm @@ -184,9 +184,11 @@ sub www_emptyClipboardConfirm { #------------------------------------------------------------------- sub www_manageClipboard { 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(65); + # Add appropriate html page header if ($session{setting}{sharedClipboard} eq "1") { $allUsers = 1; $output .= '

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

'; @@ -199,21 +201,17 @@ sub www_manageClipboard { $output .= '

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

'; } - - - # - # Generate list of pages - # + # Generate list of pages in clipboard if ($allUsers) { $sth = WebGUI::SQL->read("select pageId,title,urlizedTitle,bufferUserId,bufferDate,bufferPrevId " - ."from page where parentId=2 order by bufferDate desc,bufferUserId"); + ."from page where parentId=2 order by bufferDate"); } else { $sth = WebGUI::SQL->read("select pageId,title,urlizedTitle,bufferUserId,bufferDate,bufferPrevId " ."from page where parentId=2 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]; @@ -234,41 +232,38 @@ sub www_manageClipboard { $bufferPrevId = '' .$bufferPrevId .''; } } - $row[$i] = ''; - $row[$i] .= '' + + # create html row data + $htmlData = ''; + $htmlData .= '' .pageIcon() .deleteIcon('op=deleteClipboardItem&pageId='.$pageId) .pasteIcon('op=pastePage&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=2 order by bufferDate desc,bufferUserId"); + . "from wobject where pageId=2 order by bufferDate"); } else { $sth = WebGUI::SQL->read("select wobjectId,namespace,title,bufferUserId,bufferDate,bufferPrevId " . "from wobject where pageId=2 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]; @@ -292,44 +287,50 @@ sub www_manageClipboard { .$bufferUsername .''; } - $row[$i] = ''; - $row[$i] .= '' + # create html row data + $htmlData = ''; + $htmlData .= '' .wobjectIcon() .deleteIcon('op=deleteClipboardItem&wid='.$wobjectId) .pasteIcon('func=paste&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}{systemClipboard} eq "1") { $p = WebGUI::Paginator->new(WebGUI::URL::page('op=manageClipboard&systemClipboard=1'),\@row); } else { $p = WebGUI::Paginator->new(WebGUI::URL::page('op=manageClipboard'),\@row); } - $output .= '
'. WebGUI::International::get(99) .''. WebGUI::International::get(783) .''. WebGUI::International::get(952) .''. 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(952) .''. WebGUI::International::get(953) .''. WebGUI::International::get(50) .'
'; $output .= $p->getBarTraditional($session{form}{pn});