734 function Render( $title_tag =
null, $subtitle_tag =
null ) {
735 global $c, $BrowserCurrentRow;
737 if ( !isset($this->Query) ) $this->DoQuery();
739 dbg_error_log(
"Browser",
":Render: browser $this->Title");
740 $html = $this->DivOpen;
741 if ( $this->Title !=
"" ) {
742 if ( !isset($title_tag) ) $title_tag =
'h1';
743 $html .=
"<$title_tag>$this->Title</$title_tag>\n";
745 if ( $this->SubTitle !=
"" ) {
746 if ( !isset($subtitle_tag) ) $subtitle_tag =
'h2';
747 $html .=
"<$subtitle_tag>$this->SubTitle</$subtitle_tag>\n";
750 $html .=
"<table id=\"browse_table\">\n";
751 $html .=
"<thead><tr class=\"header\">\n";
752 foreach( $this->Columns AS $k => $column ) {
753 $html .= $column->RenderHeader( $this->OrderField, $this->OrderDirection, $this->OrderBrowserKey, $this->ForcedOrder );
755 $html .=
"</tr></thead>\n<tbody>";
757 $rowanswers = array();
758 while( $BrowserCurrentRow = $this->Query->Fetch() ) {
762 foreach( $this->BeginRowArgs AS $k => $fld ) {
763 if ( isset($BrowserCurrentRow->{$fld}) ) {
764 $rowanswers[$k] = $BrowserCurrentRow->{$fld};
769 $rowanswers[$k] = ($this->Query->rownum() % 2);
772 $rowanswers[$k] = $fld;
777 $row_html = vsprintf( preg_replace(
"/#@even@#/", ($this->Query->rownum() % 2), $this->BeginRow), $rowanswers);
779 if ( isset($this->match_column) && isset($this->match_value) && $BrowserCurrentRow->{$this->match_column} == $this->match_value ) {
780 $row_html .= call_user_func( $this->match_function, $BrowserCurrentRow );
784 foreach( $this->Columns AS $k => $column ) {
785 $row_html .= $column->RenderValue( (isset($BrowserCurrentRow->{$column->Field})?$BrowserCurrentRow->{$column->Field}:
'') );
786 if ( isset($this->Totals[$column->Field]) ) {
787 if ( isset($this->TotalFuncs[$column->Field]) && function_exists($this->TotalFuncs[$column->Field]) ) {
789 $this->Totals[$column->Field] += $this->TotalFuncs[$column->Field]( $BrowserCurrentRow, $BrowserCurrentRow->{$column->Field} );
793 $this->Totals[$column->Field] += doubleval( preg_replace(
'/[^0-9.-]/',
'', $BrowserCurrentRow->{$column->Field} ));
800 $row_html .= preg_replace(
"/#@even@#/", ($this->Query->rownum() % 2), $this->CloseRow);
801 $this->current_row = $BrowserCurrentRow;
802 $html .= preg_replace_callback(
"/##([^#]+)##/", array( &$this,
"ValueReplacement"), $row_html );
805 if ( count($this->Totals) > 0 ) {
806 $BrowserCurrentRow = (object)
"";
807 $row_html =
"<tr class=\"totals\">\n";
808 foreach( $this->Columns AS $k => $column ) {
809 if ( isset($this->Totals[$column->Field]) ) {
810 $row_html .= $column->RenderValue( $this->Totals[$column->Field],
"totals" );
813 $row_html .= $column->RenderValue(
"" );
816 $row_html .=
"</tr>\n";
817 $this->current_row = $BrowserCurrentRow;
818 $html .= preg_replace_callback(
"/##([^#]+)##/", array( &$this,
"ValueReplacement"), $row_html );
822 if ( is_array($this->ExtraRows) && count($this->ExtraRows) > 0 ) {
823 if ( !isset($this->BeginExtraRow) )
824 $this->BeginExtraRow = $this->BeginRow;
825 if ( !isset($this->CloseExtraRow) )
826 $this->CloseExtraRow = $this->CloseRow;
827 if ( !isset($this->BeginExtraRowArgs) )
828 $this->BeginExtraRowArgs = $this->BeginRowArgs;
830 foreach( $this->ExtraRows AS $k => $v ) {
831 $BrowserCurrentRow = (object) $v;
833 foreach( $this->BeginExtraRowArgs AS $k => $fld ) {
834 if ( isset( $BrowserCurrentRow->{$fld} ) ) {
835 $rowanswers[$k] = $BrowserCurrentRow->{$fld};
840 $rowanswers[$k] = ($this->Query->rownum() % 2);
843 $rowanswers[$k] = $fld;
849 $row_html = vsprintf( preg_replace(
"/#@even@#/", ($this->Query->rownum() % 2), $this->BeginExtraRow), $rowanswers);
851 if ( isset($this->match_column) && isset($this->match_value) && $BrowserCurrentRow->{$this->match_column} == $this->match_value ) {
852 $row_html .= call_user_func( $this->match_function, $BrowserCurrentRow );
856 foreach( $this->Columns AS $k => $column ) {
857 $row_html .= $column->RenderValue( (isset($BrowserCurrentRow->{$column->Field}) ? $BrowserCurrentRow->{$column->Field} :
'') );
862 $row_html .= preg_replace(
"/#@even@#/", ($this->Query->rownum() % 2), $this->CloseExtraRow);
863 $this->current_row = $BrowserCurrentRow;
864 $html .= preg_replace_callback(
"/##([^#]+)##/", array( &$this,
"ValueReplacement"), $row_html );
868 $html .=
"</tbody>\n</table>\n";
869 $html .= $this->DivClose;