hmmm...

Description

Although this solution would work it is not very nice:
  1. It causes too much additional code that has to be updated.
  2. It's works indepent to the rendering of lists (ignores sorting, filtering, etc.)
  3. There is no preview - the result might look different
I would prefer this approach:
  1. On pages featuring one list only (e.g. projViewTasks, companyList, projectList etc.) add an "Export as CSV" link below the table. This link would use the same url as the page with the additional parameter "format=csv"
  2. In renderPage(), renderList(), renderBlock() etc. evaluate this format
  3. Overwrite ListBlock::render_list() to check the format parameter and probably ignore the html rendering of columns and render public fields of each object in the list.
This would have following benefits:
  1. You can use the html-interface to customize the exported list
  2. This approach is open for other formats like RSS. XML etc.
  3. It does not require additional code for each object type / list:
    • There only has to be a generic ListBlock::renderCSV() which is called by ListBlock::renderList().
    • For all lists that overwrite ListBlock::renderList() (there are some) this function has to be called if appropriate. Maybe we should turn Block::renderList() into a wrapper function and place its old content into a new function `Block::renderListHtml()ยด
Trac illustrates a similar behavior very well.