Back to index

awl  0.53
Public Member Functions | Public Attributes
BrowserColumn Class Reference

List of all members.

Public Member Functions

 BrowserColumn ($field, $header="", $align="", $format="", $sql="", $class="", $datatype="", $hook=null)
 BrowserColumn constructor.
 GetTarget ()
 GetTarget.
 RenderHeader ($order_field, $order_direction, $browser_array_key=0, $forced_order=false)
 RenderHeader Renders the column header cell for this column.
 SetTranslatable ()
 RenderValue ($value, $extraclass="")

Public Attributes

 $Field
 $Header
 $Format
 $Sql
 $Align
 $Class
 $Type
 $Translatable
 $Hook
 $current_row

Detailed Description

Definition at line 32 of file classBrowser.php.


Member Function Documentation

BrowserColumn::BrowserColumn ( field,
header = "",
align = "",
format = "",
sql = "",
class = "",
datatype = "",
hook = null 
)

BrowserColumn constructor.

Only the first parameter is mandatory.

Parameters:
stringfield The name of the column in the SQL result.
stringheader The text to appear in the column header on output (
See also:
BrowserColumn::RenderHeader()). If this is not supplied then a default of the field name will be used.
Parameters:
stringalign left|center|right - text alignment. Defaults to 'left'.
stringformat A format (a-la-printf) to render data values within. (
See also:
BrowserColumn::RenderValue()). If this is not supplied then the default will ensure the column value is displayed as-is.
Parameters:
stringsql Some SQL which will return the desired value to be presented as column 'field' of the result. If this is blank then the column is assumed to be a real data column.
stringclass Additional classes to apply to the column header and column value cells.
stringdatatype This will allow 'date' or 'timestamp' to preformat the field correctly before using it in replacements or display. Other types may be added in future.
string$hookThe name of a global function which will preprocess the column value

The hook function should be defined as follows: function hookfunction( $column_value, $column_name, $database_row ) { ... return $value; }

Definition at line 69 of file classBrowser.php.

                                                                                                                    {
    $this->Field  = $field;
    $this->Sql    = $sql;
    $this->Header = $header;
    $this->Format = $format;
    $this->Class  = $class;
    $this->Align  = $align;
    $this->Type   = $datatype;
    $this->Translatable = false;
    $this->Hook   = $hook;
  }

GetTarget.

Retrieves a 'field' or '...SQL... AS field' definition for the target list of the SQL.

Definition at line 86 of file classBrowser.php.

                       {
    if ( $this->Sql == "" ) return $this->Field;
    return "$this->Sql AS $this->Field";
  }
BrowserColumn::RenderHeader ( order_field,
order_direction,
browser_array_key = 0,
forced_order = false 
)

RenderHeader Renders the column header cell for this column.

This will be rendered as a

... with class and alignment applied to it. Browser column headers are clickable, and the ordering will also display an 'up' or 'down' triangle with the column header that the SQL is sorted on at the moment.

Parameters:
stringorder_field The name of the field currently being sorted on.
stringorder_direction Whether the sort is Ascending or Descending.
intbrowser_array_key Used this to help handle separate ordering of multiple browsers on the same page.
stringforced_order If true, then we don't allow order to be changed.

Definition at line 104 of file classBrowser.php.

                                                                                                     {
    global $c;
    if ( $this->Align == "" ) $this->Align = "left";
    $html = '<th class="'.$this->Align.'" '. ($this->Class == "" ? "" : "class=\"$this->Class\"") . '>';

    $direction = 'A';
    $image = "";
    if ( !$forced_order && $order_field == $this->Field ) {
      if ( strtoupper( substr( $order_direction, 0, 1) ) == 'A' ) {
        $image = 'down';
        $direction = 'D';
      }
      else {
        $image = 'up';
      }
      $image = "<img class=\"order\" src=\"$c->images/$image.gif\" alt=\"$image\" />";
    }
    if ( !isset($browser_array_key) || $browser_array_key == '' ) $browser_array_key = 0;
    if ( !$forced_order ) $html .= '<a href="'.replace_uri_params( $_SERVER['REQUEST_URI'], array( "o[$browser_array_key]" => $this->Field, "d[$browser_array_key]" => $direction ) ).'" class="order">';
    $html .= ($this->Header == "" ? $this->Field : $this->Header);
    if ( !$forced_order ) $html .= "$image</a>";
    $html .= "</th>\n";
    return $html;
  }
BrowserColumn::RenderValue ( value,
extraclass = "" 
)

Definition at line 133 of file classBrowser.php.

                                                   {
    global $session;

    if ( $this->Type == 'date' || $this->Type == 'timestamp') {
      $value = $session->FormattedDate( $value, $this->Type );
    }

    if ( $this->Hook && function_exists($this->Hook) ) {
      dbg_error_log( "Browser", ":Browser: Hook for $this->Hook on column $this->Field");
      $value = call_user_func( $this->Hook, $value, $this->Field, $this->current_row );
    }

    if ( $this->Translatable ) {
      $value = translate($value);
    }

    $value = str_replace( "\n", "<br />", $value );
    if ( substr(strtolower($this->Format),0,3) == "<td" ) {
      $html = sprintf($this->Format,$value);
    }
    else {
      // These quite probably don't work.  The CSS standard for multiple classes is 'class="a b c"' but is lightly
      // implemented according to some web references.  Perhaps modern browsers are better?
      $class = $this->Align . ($this->Class == "" ? "" : " $this->Class") . ($extraclass == "" ? "" : " $extraclass");
      if ( $class != "" ) $class = ' class="'.$class.'"';
      $html = sprintf('<td%s>',$class);
      $html .= ($this->Format == "" ? $value : sprintf($this->Format,$value,$value));
      $html .= "</td>\n";
    }
    return $html;
  }

Definition at line 129 of file classBrowser.php.

                             {
    $this->Translatable = true;
  }

Member Data Documentation

Definition at line 38 of file classBrowser.php.

Definition at line 39 of file classBrowser.php.

Definition at line 43 of file classBrowser.php.

Definition at line 34 of file classBrowser.php.

Definition at line 36 of file classBrowser.php.

Definition at line 35 of file classBrowser.php.

Definition at line 42 of file classBrowser.php.

Definition at line 37 of file classBrowser.php.

Definition at line 41 of file classBrowser.php.

Definition at line 40 of file classBrowser.php.


The documentation for this class was generated from the following file: