phpDocumentor table
[ class tree: table ] [ index: table ] [ all elements ]

Source for file TableHeader.php

Documentation is available at TableHeader.php

  1. <?
  2. /**
  3. * @package table
  4. * @filesource
  5. * @see HTMP_TABLE_COMPONENT_PATH.'/TableHeader.php'
  6. * @copyright (c) http://Finn-Rasmussen.com
  7. * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
  8. * @author http://Finn-Rasmussen.com
  9. * @version 1.9
  10. * @since 21-oct-2005
  11. */
  12.  
  13. /**
  14. * The required files
  15. */
  16. require_once(HTML_PATH.'/Html.php');
  17. require_once(HTML_TABLE_COMPONENT_PATH.'/Table.php');
  18. require_once(HTML_BASE_UTIL_PATH.'/Images.php');
  19. if (defined('HTML_LOG_UTIL_PATH')) {
  20. require_once(HTML_LOG_UTIL_PATH.'/Log.php');
  21. }
  22.  
  23. /**
  24. * Generates a table header
  25. * <code>
  26. * +-------------------------
  27. * | > | Text header |
  28. * +-------------------------
  29. * | :
  30. * Usage:
  31. * $header = new TableHeader($text,$width,$class,$border,$cellPadding,$cellSpacing);
  32. * print $header->getHtml();
  33. * Or
  34. * TableHeader::display($text,$width,$class,$border,$cellPadding,$cellSpacing);
  35. * </code>
  36. * @package table
  37. */
  38.  
  39. class TableHeader extends Html {
  40. /**
  41. * @var String $text The text heading
  42. */
  43. var $text = '';
  44.  
  45. // Table
  46. var $width = '';
  47. var $border = '';
  48. var $class = '';
  49. var $cellPadding = '';
  50. var $cellSpacing = '';
  51. var $summary = '';
  52. var $caption = '';
  53.  
  54. var $css = ''; // The css color and layout
  55.  
  56.  
  57. var $image = NULL; // The Image object
  58.  
  59.  
  60. /**
  61. * Constructor
  62. * @param String $text The text header for the table
  63. * @param String $width The Width for the table
  64. * @param String $class The Class
  65. * @param String $border The Border
  66. * @param String $cellpadding The CellSpacing
  67. * @param String $cellspacing The CellPadding
  68. */
  69. function TableHeader($text='',$width='',$class='',$border='',$cellPadding='',$cellSpacing='') {
  70. $this->Html();
  71. if (defined('HTML_LOG_UTIL_PATH') && LOG_LEVEL & LOG_LEVEL_DEBUG) {
  72. $this->text = $text!=''?$text:$this->getClassName().'(), you forgot to add text';
  73. } else {
  74. $this->text = trim($text!=''?$text:'');
  75. }
  76.  
  77. // Global table characteristics
  78. $this->width = $width!=''?$width:TABLE_WIDTH;
  79. $this->border = $border!=''?$border:TABLE_BORDER;
  80. $this->class = $class!=''?$class:TABLE_CLASS;
  81. $this->cellPadding = $cellPadding!=''?$cellPadding:'1';
  82. $this->cellSpacing = $cellSpacing!=''?$cellSpacing:'0';
  83.  
  84. // Global header color
  85. if (defined('CSS_COLOR_HEADER')) {
  86. $this->css = CSS_COLOR_HEADER;
  87. }
  88. $this->image = NULL; // TODO
  89. }
  90.  
  91. /**
  92. * Builds the html for a table header, and return it
  93. * @return String The table header as html
  94. */
  95. function getHtml() {
  96. $html = $this->html;
  97. if (HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) {
  98. $class = "$this->class";
  99. if ($this->text!='') {
  100. $table = new Table($this->text, $this->width,$this->class,$this->border,$this->cellPadding,$this->cellSpacing,$this->summary,$this->caption);
  101. $html .= $table->getStart();
  102. $html .= ' <tr>'."\r\n";
  103. $html .= ' <td valign="middle"';
  104. if (defined('CSS_ARROW_HEADLINE')) {
  105. $html .= ' class="'.CSS_ARROW_HEADLINE.'"';
  106. }
  107. $html .= ">\n";
  108. if ($this->image!=NULL) {
  109. $html .= $this->image->getHtml();
  110. } else {
  111. $image = new Images('arrow-headline','','','');
  112. $html .= $image->getHtml();
  113. }
  114. $html .= "</td>\r\n";
  115. $text = htmlspecialchars(ucfirst(str_replace('_',' ',$this->text)));
  116. $html .= ' <th align="left"';
  117. if ($this->css!='') {
  118. $html .= ' class="'.$this->css.'"';
  119. }
  120. $html .= '>&nbsp;'.$text.'</th>'."\r\n"; // Translate html special chars
  121. /*******
  122. if (DEBUG_LEVEL & DEBUG_LEVEL_SHOW_PHP) {
  123. $html .= '<th class="'.$this->css.'">';
  124. $href = Server::getPhpSelf().'?'.REQUEST_SHOW_SOURCE_CODE.'=1&amp;'.REQUEST_SHOW_SOURCE_PATH.'=.&amp;'.REQUEST_SHOW_SOURCE_FILE.'='.md5(CONTENT_FILE_NAME);
  125. $language = Request::get(REQUEST_LANGUAGE);
  126. if ($language!='') {
  127. $href .= '&amp;'.REQUEST_LANGUAGE.'='.$language;
  128. }
  129. $link = new Link('',$href,$this->css);
  130. $link->add(new Images(IMAGE_SEARCHX,'','','',$this->css));
  131. $html .= $link->getHtml();
  132. $html .= "</th>\r\n";
  133. }
  134. if (DEBUG_LEVEL & DEBUG_LEVEL_SHOW_EDIT) {
  135. $html .= '<th class="'.$this->css.'">';
  136. $link = new Link('','TODO',$this->css);
  137. $link->add(new Images(IMAGE_UPDATE,'','','',$this->css));
  138. $html .= $link->getHtml();
  139. $html .= "</th>\r\n";
  140. }
  141. *******/
  142. $html .= ' </tr>'."\r\n";
  143. $html .= $table->getEnd();
  144. } else {
  145. $html .= '<!-- No text in TableHeader -->'."\n";
  146. }
  147. }
  148. return $html;
  149. }
  150.  
  151. /**
  152. * Display html
  153. * <code>
  154. * Usage:
  155. * TableHeader::display($text,$width,$class,$border,$cellPadding,$cellSpacing);
  156. * </code>
  157. * @static
  158. * @param String $text The text header for the table
  159. * @param String $width The Width for the table
  160. * @param String $class The Class
  161. * @param String $border The Border
  162. * @param String $cellpadding The CellSpacing
  163. * @param String $cellspacing The CellPadding
  164. */
  165. function display($text='',$width='',$class='',$border='',$cellPadding='',$cellSpacing='') {
  166. $html = new TableHeader($text,$width,$class,$border,$cellPadding,$cellSpacing);
  167. $html->addHtml();
  168. }
  169. }
  170. ?>

Documentation generated on Thu, 22 Dec 2005 17:19:47 +0100 by phpDocumentor 1.3.0RC3