From: Dan F. <dfr...@cs...> - 2004-05-28 17:39:28
|
Reini Urban wrote: > Dan Frankowski schrieb: > >> Reini Urban wrote: >> >>> Dan Frankowski schrieb: >>> >>>> - Sorting on the PageList widget >>> >>> sortby=rating? ok. >> >> >> Not exactly. Two things here so far: >> >> 1. We need to sort on things not in the DB (e.g., predicted value). >> Thus, I am adding sorting of pages in memory based on >> column::_getValue() (incidentally for any column, which is nice). >> 2. We need multiple columns of the same type (e.g., 'ratingvalue' >> type for my buddies A, B, C, D, etc. on the same PageList). > > > Ok. Sorting as generic slow PageList method, to be able to sort on > every column. Even better. > >> I have been delaying my reply until I have posted some code for this >> on WikiLens, but it's going slower than I'd hoped, so I'm replying >> without code in order to give you a heads-up. 2 is more challenging-- >> it requires identifying column by something other than name or type. >> Right now, I am trying to convert the code so it can still use the >> name, but immediately translates it into column # (0, 1, 2, 3, etc.) >> for the purposes of button headings specifying sorting. I'll post >> this as soon as I can. > Okay, we have PageList column sorting on wikilens.org. I attach our new PageList.php. I do not attach a patch file because: a) so much of it looked changed (often in small ways) b) some of the "changes" are actually that we are on 1.3.9, not the latest CVS PageList.php, so we probably have some change merging to do. Anyway, below I describe a little more the changes in the attached PageList.php, and I hope they are generally useful. Dan Here are our changes. At the high level, we wanted a) To be able to sort on any column, even if not in the DB (e.g., predicted value). b) To be able to have multiple columns of the same type (e.g., rating value for Sam, Joe, Mary, etc.). This requires referring to the columns by an id other than column name. We chose number (col# 0, 1, 2, 3, ..). In detail, in order of how they show up when I use tkdiff (a graphical diff): - We don't yet have creator, owner, etc. (probably from 1.3.10?). - require_once()s, so our PageListTest.php unit tests work - add _PageList_Column_base::getHeading() because at one point I thought we might have to override on a subclass - ditched heading() because no one seemed to be using it anywhere - add parms to button_heading(): $pagelist to refer to it in the sortby() function, $colNum to generate HTML for headings. - add _PageList_Column_Base::_compare() for default sorting. - add more column types: numbacklinks is probably useful, the rest (coagreement, minmisery, averagerating) are WikiLens-specific, and we'll end up pulling them out later - We don't yet have author/creator changes (1.3.10 or CVS?) - add _PageList_Column_pagename::_compare - add _PageList_Page class for sorting - add PageList::_columnsMap to map column names to #s - PageList::_rows => PageList::_pages to signify we are storing _PageList_Page entries now - Set PageList::_options right away, so it is accessible to all functions - Change getTotal(), isEmpty(), addPage() to work with _pages. - Make a _renderPageRow() that turns a _pages entry into HTML, so we can delay its HTML rendering until after we sort it - don't have maxLen() .. don't know what that is - Get rid of sortable_columns() .. they're all sortable now - Add getOption() function to get options because it is convenient to not get PHP warnings about "array index doesn't exist" - Change _addColumn(): add commentary, have it call addColumnObject() - Add addColumnObject() to allow outside objects to add columns of the same type, by repeated calling of this function. - Add _pageCompare() and_sortPages() for sorting - We don't have any paging code yet .. this will unfortunately perhaps interfere with sorting in some ways. - _generateList() and _generateTable() use _renderPageRow() |