--- ../../moodle-194/lib/tablelib.php 2008-05-22 17:18:23.000000000 -0700 +++ lib/tablelib.php 2009-03-09 16:00:03.000000000 -0700 @@ -1,4 +1,4 @@ -column_properties + * + * If $merge = true, then $properties will be added to any existing properties, overwriting any properties with the same index. Otherwise + * $properties will overwrite any existing properties. + * + * @param string $column + * @param array $properties + * @param bool $merge + * @return void + */ + function column_properties($column, $properties, $merge=true) { + if(!is_array($properties)) { + return; + } + + if(!isset($this->column_properties[$column])) { + return; + } + + if($merge) { + $this->column_properties[$column] = array_merge($this->column_properties[$column], $properties); + } else { + $this->column_properties[$column] = $properties; + } + } + // End MOD + /** * Sets all columns of the given $property to the given $value in $this->column_style. * @param integer $property @@ -227,13 +258,19 @@ $this->columns = array(); $this->column_style = array(); $this->column_class = array(); + // MOD -- Adding column_properties + $this->column_properties = array(); + // End MOD $colnum = 0; foreach($columns as $column) { - $this->columns[$column] = $colnum++; - $this->column_style[$column] = array(); - $this->column_class[$column] = ''; - $this->column_suppress[$column] = false; + $this->columns[$column] = $colnum++; + $this->column_style[$column] = array(); + $this->column_class[$column] = ''; + // MOD -- Adding column_properties + $this->column_properties[$column] = array(); + // End MOD + $this->column_suppress[$column] = false; } } @@ -454,7 +491,16 @@ if(!empty($sortstring)) { $sortstring .= ', '; } - $sortstring .= $column.($order == SORT_ASC ? ' ASC' : ' DESC'); + // MOD -- Bring in correct order by for text fields + if($uniqueid === NULL && // "Non-static" function call + isset($this->column_properties[$column], $this->column_properties[$column]['type']) && // Has a type property set + $this->column_properties[$column]['type'] == 'text' // Type property is set to 'text' + ) { + $sortstring .= sql_order_by_text($column).($order == SORT_ASC ? ' ASC' : ' DESC'); + } else { + $sortstring .= $column.($order == SORT_ASC ? ' ASC' : ' DESC'); + } + // End MOD } return $sortstring; }