Just like with the FilterHeader, the ColumnHeader should delegate all processing to different classes for each Column type.
For example, there will be a urlColumn class and a linkColumn class.
The Column classes will all extend ColumnBase, which will have the following structure:
<?php
public class ColumnBase {
public static function filterValue($key, $value, $options=array()) {
return $value;
}
}
The difficult part is figuring out which Column class to use . In order to be backwards compatible with a legacy system, it must support several different formats including:
- rpadN - N is the number of spaces that will be appended to the value. Should map to the rpadColumn class with $options['spaces'] = N
- link(display) - Use the value as the href of a link and use display as the display text. Should map to the linkColumn class with $options['display'] = display
- link - Same as link(display), but with "link" as the display value.
- link_blank(display) - Same as link(display) except target="_blank" is added.
- link_blank - Same as link except target="_blank" is added
The preferred shorthand syntax will be as follows:
//with options
link(display=My Display,blank)
//no options
link
This way, we can easily get the Column class to use and easily construct the $options array. If an option is specified by name only (e.g. "blank" above), $options[name] will be set to true and $options[] will be set to name. For this example, $options = array(0=>"blank", "blank"=>true)
I have to figure out a way to convert the legacy formats to the new format.
link and link_blank are easy, since I can just create a link_blankColumn class that extends the linkColumn class.
The rpadN and lpadN ones are tricky and may just need to be hardcoded to be replaced with rpad(spaces=N) and lpad(spaces=N).