- <?
- /**
- * @package table
- * @filesource
- * @see HTMP_TABLE_COMPONENT_PATH.'/TableHeader.php'
- * @copyright (c) http://Finn-Rasmussen.com
- * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
- * @author http://Finn-Rasmussen.com
- * @version 1.9
- * @since 21-oct-2005
- */
-
- /**
- * The required files
- */
- require_once(HTML_PATH.'/Html.php');
- require_once(HTML_TABLE_COMPONENT_PATH.'/Table.php');
- require_once(HTML_BASE_UTIL_PATH.'/Images.php');
- if (defined('HTML_LOG_UTIL_PATH')) {
- require_once(HTML_LOG_UTIL_PATH.'/Log.php');
- }
-
- /**
- * Generates a table header
- * <code>
- * +-------------------------
- * | > | Text header |
- * +-------------------------
- * | :
- * Usage:
- * $header = new TableHeader($text,$width,$class,$border,$cellPadding,$cellSpacing);
- * print $header->getHtml();
- * Or
- * TableHeader::display($text,$width,$class,$border,$cellPadding,$cellSpacing);
- * </code>
- * @package table
- */
-
- class TableHeader extends Html {
- /**
- * @var String $text The text heading
- */
- var $text = '';
-
- // Table
-
- var $width = '';
- var $border = '';
- var $class = '';
- var $cellPadding = '';
- var $cellSpacing = '';
- var $summary = '';
- var $caption = '';
-
- var $css = ''; // The css color and layout
-
-
-
- var $image = NULL; // The Image object
-
-
-
- /**
- * Constructor
- * @param String $text The text header for the table
- * @param String $width The Width for the table
- * @param String $class The Class
- * @param String $border The Border
- * @param String $cellpadding The CellSpacing
- * @param String $cellspacing The CellPadding
- */
- function TableHeader($text='',$width='',$class='',$border='',$cellPadding='',$cellSpacing='') {
- $this->Html();
- if (defined('HTML_LOG_UTIL_PATH') && LOG_LEVEL & LOG_LEVEL_DEBUG) {
- $this->text = $text!=''?$text:$this->getClassName().'(), you forgot to add text';
- } else {
- $this->text = trim($text!=''?$text:'');
- }
-
- // Global table characteristics
- $this->width = $width!=''?$width:TABLE_WIDTH;
- $this->border = $border!=''?$border:TABLE_BORDER;
- $this->class = $class!=''?$class:TABLE_CLASS;
- $this->cellPadding = $cellPadding!=''?$cellPadding:'1';
- $this->cellSpacing = $cellSpacing!=''?$cellSpacing:'0';
-
- // Global header color
- if (defined('CSS_COLOR_HEADER')) {
- $this->css = CSS_COLOR_HEADER;
- }
- $this->image = NULL; // TODO
- }
-
- /**
- * Builds the html for a table header, and return it
- * @return String The table header as html
- */
- function getHtml() {
- $html = $this->html;
- if (HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) {
- $class = "$this->class";
- if ($this->text!='') {
- $table = new Table($this->text, $this->width,$this->class,$this->border,$this->cellPadding,$this->cellSpacing,$this->summary,$this->caption);
- $html .= $table->getStart();
- $html .= ' <tr>'."\r\n";
- $html .= ' <td valign="middle"';
- if (defined('CSS_ARROW_HEADLINE')) {
- $html .= ' class="'.CSS_ARROW_HEADLINE.'"';
- }
- $html .= ">\n";
- if ($this->image!=NULL) {
- $html .= $this->image->getHtml();
- } else {
- $image = new Images('arrow-headline','','','');
- $html .= $image->getHtml();
- }
- $html .= "</td>\r\n";
- $text = htmlspecialchars(ucfirst(str_replace('_',' ',$this->text)));
- $html .= ' <th align="left"';
- if ($this->css!='') {
- $html .= ' class="'.$this->css.'"';
- }
- $html .= '> '.$text.'</th>'."\r\n"; // Translate html special chars
- /*******
- if (DEBUG_LEVEL & DEBUG_LEVEL_SHOW_PHP) {
- $html .= '<th class="'.$this->css.'">';
- $href = Server::getPhpSelf().'?'.REQUEST_SHOW_SOURCE_CODE.'=1&'.REQUEST_SHOW_SOURCE_PATH.'=.&'.REQUEST_SHOW_SOURCE_FILE.'='.md5(CONTENT_FILE_NAME);
- $language = Request::get(REQUEST_LANGUAGE);
- if ($language!='') {
- $href .= '&'.REQUEST_LANGUAGE.'='.$language;
- }
- $link = new Link('',$href,$this->css);
- $link->add(new Images(IMAGE_SEARCHX,'','','',$this->css));
- $html .= $link->getHtml();
- $html .= "</th>\r\n";
- }
- if (DEBUG_LEVEL & DEBUG_LEVEL_SHOW_EDIT) {
- $html .= '<th class="'.$this->css.'">';
- $link = new Link('','TODO',$this->css);
- $link->add(new Images(IMAGE_UPDATE,'','','',$this->css));
- $html .= $link->getHtml();
- $html .= "</th>\r\n";
- }
- *******/
- $html .= ' </tr>'."\r\n";
- $html .= $table->getEnd();
- } else {
- $html .= '<!-- No text in TableHeader -->'."\n";
- }
- }
- return $html;
- }
-
- /**
- * Display html
- * <code>
- * Usage:
- * TableHeader::display($text,$width,$class,$border,$cellPadding,$cellSpacing);
- * </code>
- * @static
- * @param String $text The text header for the table
- * @param String $width The Width for the table
- * @param String $class The Class
- * @param String $border The Border
- * @param String $cellpadding The CellSpacing
- * @param String $cellspacing The CellPadding
- */
- function display($text='',$width='',$class='',$border='',$cellPadding='',$cellSpacing='') {
- $html = new TableHeader($text,$width,$class,$border,$cellPadding,$cellSpacing);
- $html->addHtml();
- }
- }
- ?>