2009-06-30 10:46:00 +00:00
< ? php
/**
* Page Rendering Functions
2009-07-01 06:09:17 +00:00
*
* @ author The phpLDAPadmin development team
2009-06-30 10:46:41 +00:00
* @ package phpLDAPadmin
2009-06-30 10:46:00 +00:00
*/
2009-07-01 06:09:17 +00:00
/**
* This class controls the final output to the browser .
*
* @ package phpLDAPadmin
* @ subpackage Page
*/
2009-06-30 10:46:00 +00:00
class page {
# pre-HTML headers
2009-06-30 10:46:41 +00:00
protected $_pageheader ;
2009-06-30 10:46:00 +00:00
# Items to get into the <head>
2009-06-30 10:46:41 +00:00
protected $_head ;
2009-06-30 10:46:00 +00:00
# Settings for this application
2009-06-30 10:46:41 +00:00
protected $_app ;
2009-06-30 10:46:00 +00:00
# Default values array.
2009-06-30 10:46:41 +00:00
protected $_default ;
2009-06-30 10:46:00 +00:00
2009-07-01 06:09:17 +00:00
public function __construct ( $index = null ) {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
2009-07-25 08:01:05 +00:00
# If we done have a configuration, then our IMGDIR and CSS are not defined
if ( ! defined ( 'IMGDIR' ))
define ( 'IMGDIR' , 'images/default' );
if ( ! defined ( 'CSSDIR' ))
define ( 'CSSDIR' , 'css/default' );
2009-07-08 06:14:50 +00:00
$this -> index = $index ;
2009-06-30 10:46:00 +00:00
# To be defined in a configuration file.
2009-07-01 06:09:17 +00:00
$this -> _app [ 'title' ] = app_name ();
2009-07-08 06:14:50 +00:00
$this -> _app [ 'logo' ] = IMGDIR . '/logo-small.png' ;
if ( ! is_null ( $index ))
$this -> _app [ 'urlcss' ] = sprintf ( '%s/%s' , CSSDIR , $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'stylesheet' ));
else
$this -> _app [ 'urlcss' ] = sprintf ( '%s/%s' , CSSDIR , 'style.css' );
2009-06-30 10:46:00 +00:00
# Default Values for configurable items.
2009-07-08 06:14:50 +00:00
$this -> _default [ 'sysmsg' ][ 'error' ] = IMGDIR . '/error-big.png' ;
$this -> _default [ 'sysmsg' ][ 'warn' ] = IMGDIR . '/warn-big.png' ;
$this -> _default [ 'sysmsg' ][ 'info' ] = IMGDIR . '/info-big.png' ;
2009-06-30 10:46:00 +00:00
# Capture any output so far (in case we send some headers below) - there shouldnt be any output anyway.
$preOutput = '' ;
2009-06-30 10:46:41 +00:00
# Try and work around if php compression is on, or the user has set compression in the config.
# type = 1 for user gzip, 0 for php.ini gzip.
$obStatus = ob_get_status ();
2009-06-30 11:46:44 +00:00
if ( isset ( $obStatus [ 'type' ]) && $obStatus [ 'type' ] && $obStatus [ 'status' ]) {
2009-06-30 10:46:00 +00:00
$preOutput = ob_get_contents ();
ob_end_clean ();
}
2009-06-30 10:46:41 +00:00
header ( 'Content-type: text/html; charset="UTF-8"' );
2009-06-30 11:52:55 +00:00
if ( isCompress ()) {
2009-06-30 10:46:00 +00:00
header ( 'Content-Encoding: gzip' );
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED )
2009-08-19 03:39:37 +00:00
debug_log ( 'Sent COMPRESSED header to browser and discarded (%s)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $preOutput );
2009-06-30 10:46:00 +00:00
}
2009-06-30 11:46:44 +00:00
if ( isset ( $_SESSION [ APPCONFIG ])
2009-07-01 06:09:17 +00:00
&& $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'compress' )
2009-06-30 10:46:41 +00:00
&& ini_get ( 'zlib.output_compression' ))
2009-07-01 06:09:17 +00:00
$this -> setsysmsg ( array ( 'title' => _ ( 'Warning' ), 'body' => _ ( 'WARNING: You cannot have PHP compression and application compression enabled at the same time. Please unset zlib.output_compression or set $config->custom->appearance[\'compress\']=false' ), 'type' => 'warn' ));
2009-06-30 10:46:41 +00:00
2009-06-30 10:46:00 +00:00
# Turn back on output buffering.
ob_start ();
# Initial Values
2010-02-24 15:03:10 +00:00
#$this->_pageheader[] .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"';
#$this->_pageheader[] .= '"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">'."\n";
$this -> _pageheader [] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' ;
$this -> _pageheader [] .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="auto">' . " \n " ;
2009-06-30 10:46:00 +00:00
}
/* Add to the HTML Header */
public function head_add ( $html ) {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
$this -> _head [] .= $html ;
}
/* Print out the HTML header */
private function pageheader_print () {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
# HTML prepage requirements.
foreach ( $this -> _pageheader as $line )
echo $line . " \n " ;
# Page Title
echo '<head>' ;
2009-09-20 00:32:47 +00:00
printf ( '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' );
2009-06-30 10:46:00 +00:00
2009-06-30 11:46:44 +00:00
if ( isset ( $_SESSION [ APPCONFIG ]))
2009-06-30 10:46:00 +00:00
printf ( '<title>%s (%s) - %s</title>' ,
2009-07-01 06:09:17 +00:00
$this -> _app [ 'title' ], app_version (), $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'page_title' ));
2009-06-30 10:46:00 +00:00
else
2009-07-01 06:09:17 +00:00
printf ( '<title>%s - %s</title>' , $this -> _app [ 'title' ], app_version ());
2009-06-30 10:46:00 +00:00
2009-08-22 11:30:50 +00:00
echo '<link rel="shortcut icon" href="images/favicon.ico" type="image/vnd.microsoft.icon" />' ;
2009-06-30 10:46:00 +00:00
# Style sheet.
printf ( '<link type="text/css" rel="stylesheet" href="%s" />' , $this -> _app [ 'urlcss' ]);
2009-06-30 11:46:44 +00:00
if ( defined ( 'JSDIR' )) {
printf ( '<link type="text/css" rel="stylesheet" media="all" href="%sjscalendar/calendar-blue.css" title="blue" />' , JSDIR );
echo " \n " ;
2010-02-24 15:03:10 +00:00
printf ( '<script type="text/javascript" src="%sajax_functions.js"></script>' , JSDIR );
printf ( '<script type="text/javascript" src="%sjscalendar/calendar.js"></script>' , JSDIR );
2009-06-30 11:46:44 +00:00
echo " \n " ;
}
2009-06-30 10:46:00 +00:00
# HTML head requirements.
2009-09-06 14:13:58 +00:00
if ( is_array ( $this -> _head ) && count ( $this -> _head ))
2009-06-30 10:46:00 +00:00
foreach ( $this -> _head as $line )
echo $line . " \n " ;
echo '</head>' ;
echo " \n " ;
}
private function head_print () {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
2009-06-30 11:46:44 +00:00
if ( isset ( $_SESSION [ APPCONFIG ]))
2009-07-01 06:09:17 +00:00
$pagetitle = $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'page_title' ) ? ' - ' . $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'page_title' ) : '' ;
2009-06-30 10:46:00 +00:00
else
$pagetitle = '' ;
2009-07-01 06:09:17 +00:00
echo '<tr class="pagehead">' ;
2009-06-30 10:46:00 +00:00
2010-02-24 15:03:10 +00:00
echo '<td colspan="3"><div id="ajHEAD"><table width="100%" border="0"><tr>' ;
printf ( '<td style="text-align: left;"><a href="%s" onclick="target=\'_blank\';"><img src="%s" alt="Logo" class="logo" /></a></td>' , get_href ( 'sf' ), $this -> _app [ 'logo' ]);
2009-07-01 06:09:17 +00:00
echo '<td class="imagetop">' ;
$empty = true ;
if ( function_exists ( 'cmd_control_pane' ))
2009-07-25 15:17:47 +00:00
foreach ( cmd_control_pane ( 'top' ) as $cmddetails )
if (( isset ( $cmddetails [ 'enable' ]) && $cmddetails [ 'enable' ]) || ! isset ( $cmddetails [ 'enable' ])) {
if ( ! $empty )
echo ' ' ;
2009-07-01 06:09:17 +00:00
2009-07-25 15:17:47 +00:00
printf ( '<a %s>%s</a>' , $cmddetails [ 'link' ], $cmddetails [ 'image' ]);
2009-06-30 10:46:00 +00:00
2009-07-25 15:17:47 +00:00
$empty = false ;
}
2009-07-01 06:09:17 +00:00
if ( $empty )
echo ' ' ;
2009-07-25 15:17:47 +00:00
2009-07-01 06:09:17 +00:00
echo '</td>' ;
echo '</tr></table></div></td>' ;
2009-06-30 10:46:00 +00:00
echo '</tr>' ;
2009-07-01 06:09:17 +00:00
echo " \n " ;
2009-06-30 10:46:00 +00:00
}
private function control_print () {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
2010-02-24 15:03:10 +00:00
echo '<table class="control" width="100%" border="0">' ;
2009-07-01 06:09:17 +00:00
echo '<tr><td>' ;
2009-06-30 10:46:00 +00:00
$empty = true ;
2009-06-30 11:46:44 +00:00
if ( function_exists ( 'cmd_control_pane' ))
2009-07-25 15:17:47 +00:00
foreach ( cmd_control_pane ( 'main' ) as $cmddetails )
if (( isset ( $cmddetails [ 'enable' ]) && trim ( $cmddetails [ 'enable' ])) || ! isset ( $cmddetails [ 'enable' ])) {
if ( ! $empty )
2009-08-12 13:53:14 +00:00
echo ' | ' ;
2009-07-01 06:09:17 +00:00
2009-07-25 15:17:47 +00:00
printf ( '<a %s>%s</a>' , $cmddetails [ 'link' ],
2009-08-28 07:18:08 +00:00
( isset ( $_SESSION [ APPCONFIG ]) && $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'control_icons' )) ? $cmddetails [ 'image' ] : $cmddetails [ 'title' ]);
2009-06-30 10:46:00 +00:00
2009-07-25 15:17:47 +00:00
$empty = false ;
}
2009-06-30 10:46:00 +00:00
2009-07-01 06:09:17 +00:00
echo '</td>' ;
2009-06-30 11:46:44 +00:00
if ( $empty )
2009-07-01 06:09:17 +00:00
echo '<td> </td>' ;
2009-06-30 10:46:00 +00:00
echo '</tr>' ;
echo '</table>' ;
}
protected function tree () {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
2009-06-30 11:46:44 +00:00
if ( ! isset ( $_SESSION [ APPCONFIG ]))
2009-06-30 10:46:00 +00:00
return ;
2009-07-01 06:09:17 +00:00
if ( is_null ( $this -> index ))
$this -> index = min ( array_keys ( $_SESSION [ APPCONFIG ] -> getServerList ()));
2009-06-30 10:46:00 +00:00
2009-07-01 06:09:17 +00:00
if ( count ( $_SESSION [ APPCONFIG ] -> getServerList ()) > 1 ) {
2010-02-24 15:03:10 +00:00
echo '<form id="server_select" action="cmd.php" method="post">' ;
2009-06-30 10:46:00 +00:00
echo '<table class="server_select"><tr><td>' ;
2009-07-01 06:09:17 +00:00
printf ( '%s:<br />%s' , _ ( 'Server Select' ),
server_select_list ( $this -> index , false , 'index' , true , sprintf ( " onchange= \" tree_unhide('index',%s) \" " , $this -> index )));
2009-06-30 10:46:00 +00:00
echo '</td></tr></table>' ;
echo '</form>' ;
echo " \n \n " ;
}
2009-07-01 06:09:17 +00:00
foreach ( $_SESSION [ APPCONFIG ] -> getServerList () as $index => $server ) {
printf ( '<div id="ajSID_%s" style="display: %s">' , $server -> getIndex (),( $server -> getIndex () == $this -> index ) ? 'block' : 'none' );
$tree = Tree :: getInstance ( $server -> getIndex ());
2009-06-30 10:46:00 +00:00
$tree -> draw ();
echo '</div>' ;
2009-07-01 06:09:17 +00:00
echo " \n \n " ;
2009-06-30 10:46:00 +00:00
}
}
public function block_add ( $side , $object ) {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
if ( ! is_object ( $object ))
2009-06-30 11:46:44 +00:00
error ( sprintf ( 'block_add called with [%s], but it is not an object' , serialize ( $object )));
2009-06-30 10:46:00 +00:00
$this -> _block [ $side ][] = $object ;
}
private function block_print ( $side ) {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
if ( ! isset ( $this -> _block [ $side ]))
return ;
2010-02-24 15:03:10 +00:00
printf ( '<td class="%s" colspan="2">' , $side );
2009-06-30 10:46:00 +00:00
foreach ( $this -> _block [ $side ] as $object )
echo $object -> draw ( $side );
echo '</td>' ;
}
private function sysmsg () {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
if ( isset ( $this -> sysmsg )) {
foreach ( $this -> sysmsg as $index => $details ) {
switch ( $details [ 'type' ]) {
case 'error' :
$icon = $this -> _default [ 'sysmsg' ][ 'error' ];
break ;
case 'warn' :
$icon = $this -> _default [ 'sysmsg' ][ 'warn' ];
break ;
case 'info' :
default :
$icon = $this -> _default [ 'sysmsg' ][ 'info' ];
break ;
}
if ( isset ( $details [ 'title' ]))
2010-02-24 15:03:10 +00:00
printf ( '<tr><td class="icon" rowspan="2"><img src="%s" alt="%s" /></td><td class="head">%s</td></tr>' ,
2009-06-30 10:46:00 +00:00
$icon , $details [ 'type' ], $details [ 'title' ]);
if ( isset ( $details [ 'body' ]))
if ( is_array ( $details [ 'body' ])) {
echo '<tr><td class="body">' ;
foreach ( $details [ 'body' ] as $line )
printf ( '%s<br />' , $line );
echo '</td></tr>' ;
} else
printf ( '<tr><td class="body">%s</td></tr>' , $details [ 'body' ]);
}
}
}
2009-07-01 06:09:17 +00:00
private function body ( $raw = false ) {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
2009-06-30 11:46:44 +00:00
# Add the Session System Messages
if ( isset ( $_SESSION [ 'sysmsg' ]) && is_array ( $_SESSION [ 'sysmsg' ])) {
foreach ( $_SESSION [ 'sysmsg' ] as $msg )
$this -> setsysmsg ( $msg );
2009-06-30 10:46:00 +00:00
unset ( $_SESSION [ 'sysmsg' ]);
}
if ( isset ( $this -> sysmsg )) {
echo '<table class="sysmsg">' ;
$this -> sysmsg ();
echo '</table>' ;
echo " \n " ;
}
2009-07-01 06:09:17 +00:00
if ( isset ( $this -> _block [ 'body' ]))
2009-06-30 10:46:00 +00:00
foreach ( $this -> _block [ 'body' ] as $object )
2009-07-01 06:09:17 +00:00
echo $object -> draw ( 'body' , $raw );
}
private function footer_print () {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-07-01 06:09:17 +00:00
2010-02-24 15:03:10 +00:00
printf ( '<tr class="foot"><td><small>%s</small></td><td colspan="2"><div id="ajFOOT">%s</div>%s</td></tr>' ,
2009-07-01 06:09:17 +00:00
isCompress () ? '[C]' : ' ' ,
app_version (),
2010-02-24 15:03:10 +00:00
get_href ( 'logo' ) ? sprintf ( '<a href="%s"><img src="%s" alt="SourceForge.net Logo" style="border: 0px;" /></a>' , get_href ( 'sf' ), get_href ( 'logo' )) : ' ' );
2009-07-01 06:09:17 +00:00
}
/**
* Only show a particular page frame - used by an AJAX call
*/
public function show ( $frame , $compress = false , $raw = false ) {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-07-01 06:09:17 +00:00
# If the body is called via AJAX, and compression is enable, we need to compress the output
if ( $compress && ob_get_level () && isCompress ()) {
ob_end_clean ();
ob_start ();
}
switch ( $frame ) {
case 'BODY' :
$this -> body ( $raw );
break ;
case 'TREE' :
$this -> tree ();
break ;
default :
error ( sprintf ( 'show called with unknown frame [%s]' , $frame ), 'error' , 'index.php' );
2009-06-30 10:46:00 +00:00
}
2009-06-30 11:52:55 +00:00
if ( $compress && ob_get_level () && isCompress ()) {
2009-06-30 10:46:00 +00:00
$output = ob_get_contents ();
ob_end_clean ();
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED )
2009-08-19 03:39:37 +00:00
debug_log ( 'Sending COMPRESSED output to browser[(%s),%s]' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ ,
2009-06-30 10:46:00 +00:00
strlen ( $output ), $output );
print gzencode ( $output );
}
}
public function display ( $filter = array ()) {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
# Control what is displayed.
$display = array (
2009-07-01 06:09:17 +00:00
'HEAD' => true ,
'CONTROL' => true ,
'TREE' => true ,
'FOOT' => true
2009-06-30 10:46:00 +00:00
);
$display = array_merge ( $display , $filter );
# HTML Header
$this -> pageheader_print ();
# Start of body
# Page Header
echo '<body>' ;
echo " \n " ;
2010-02-24 15:03:10 +00:00
echo '<table class="page" border="0" width="100%">' ;
2009-06-30 10:46:00 +00:00
2009-07-01 06:09:17 +00:00
if ( $display [ 'HEAD' ])
$this -> head_print ();
2009-06-30 10:46:00 +00:00
# Control Line
2009-07-01 06:09:17 +00:00
if ( $display [ 'CONTROL' ]) {
2010-02-24 15:03:10 +00:00
echo '<tr class="control"><td colspan="3">' ;
2009-07-01 06:09:17 +00:00
echo '<div id="ajCONTROL">' ;
$this -> control_print ();
echo '</div></td></tr>' ;
echo " \n " ;
}
2009-06-30 10:46:00 +00:00
# Left Block
echo '<tr>' ;
2009-07-01 06:09:17 +00:00
if ( $display [ 'TREE' ]) {
2010-02-24 15:03:10 +00:00
echo '<td class="tree" colspan="2">' ;
printf ( '<acronym title="%s"><img src="%s/plus.png" alt="" style="float: right;" onclick="if (document.getElementById(\'ajTREE\').style.display == \'none\') { document.getElementById(\'ajTREE\').style.display = \'block\' } else { document.getElementById(\'ajTREE\').style.display = \'none\' };"/></acronym>' , _ ( 'Hide/Unhide the tree' ), IMGDIR );
2009-07-01 06:09:17 +00:00
echo '<div id="ajTREE">' ;
2009-06-30 10:46:00 +00:00
$this -> tree ();
2009-07-01 06:09:17 +00:00
echo '</div>' ;
echo '</td>' ;
2009-06-30 10:46:00 +00:00
}
2010-02-24 15:03:10 +00:00
echo '<td class="body" style="width: 80%;">' ;
2009-07-01 06:09:17 +00:00
echo '<div id="ajBODY">' ;
2009-06-30 10:46:00 +00:00
echo " \n " ;
$this -> body ();
echo '</div>' ;
echo '</td>' ;
echo '</tr>' ;
echo " \n " ;
# Page Footer
2009-07-01 06:09:17 +00:00
if ( $display [ 'FOOT' ])
$this -> footer_print ();
2009-06-30 10:46:00 +00:00
# Finish HTML
echo '</table>' ;
echo '</body>' ;
echo '</html>' ;
# compress output
2009-06-30 11:52:55 +00:00
if ( ob_get_level () && isCompress ()) {
2009-06-30 10:46:00 +00:00
$output = ob_get_contents ();
ob_end_clean ();
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED )
2009-08-19 03:39:37 +00:00
debug_log ( 'Sending COMPRESSED output to browser[(%s),%s]' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ ,
2009-06-30 10:46:00 +00:00
strlen ( $output ), $output );
print gzencode ( $output );
}
}
public function setsysmsg ( $data ) {
2009-08-28 07:18:08 +00:00
if ( defined ( 'DEBUG_ENABLED' ) && DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2009-08-19 03:39:37 +00:00
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
2009-06-30 10:46:00 +00:00
if ( ! is_array ( $data ))
return ;
if ( isset ( $this -> sysmsg ))
2009-06-30 11:46:44 +00:00
$msgnum = count ( $this -> sysmsg ) + 1 ;
2009-06-30 10:46:00 +00:00
else
2009-06-30 11:46:44 +00:00
$msgnum = 1 ;
2009-06-30 10:46:00 +00:00
2009-06-30 11:46:44 +00:00
foreach ( array ( 'title' , 'body' , 'type' ) as $index )
if ( isset ( $data [ $index ]))
$this -> sysmsg [ $msgnum ][ $index ] = $data [ $index ];
2009-06-30 10:46:00 +00:00
}
}
2009-07-01 06:09:17 +00:00
/**
* This class draws a block .
*
* @ package phpLDAPadmin
* @ subpackage Page
*/
2009-06-30 10:46:00 +00:00
class block {
private $title ;
private $body ;
private $foot ;
public function setTitle ( $html ) {
$this -> title = $html ;
}
public function setBody ( $html ) {
$this -> body = $html ;
}
public function setFooter ( $html ) {
$this -> foot = $html ;
}
2009-07-01 06:09:17 +00:00
public function draw ( $side , $raw = false ) {
2009-06-30 10:46:00 +00:00
$output = '' ;
2009-07-01 06:09:17 +00:00
if ( $raw )
$output .= $this -> body ;
2009-06-30 10:46:00 +00:00
2009-07-01 06:09:17 +00:00
else {
$output .= sprintf ( '<table class="%s">' , $side );
2009-06-30 10:46:00 +00:00
2009-07-01 06:09:17 +00:00
if ( isset ( $this -> title ))
$output .= sprintf ( '<tr><td class="head">%s</td></tr>' , $this -> title );
if ( isset ( $this -> body ))
$output .= sprintf ( '<tr><td>%s</td></tr>' , $this -> body );
if ( isset ( $this -> footer ))
$output .= sprintf ( '<tr><td class="foot">%s</td></tr>' , $this -> foot );
$output .= '</table>' ;
}
2009-06-30 10:46:00 +00:00
return $output ;
}
}
?>