Location: PHPKode > scripts > Prioritexter > TextBox.php
<?php
class TextBox {

  var $width, $title_style, $content_style, $box_style,
    $show_title, $show_content, 
    $content, $title, $padding, $show_bottom_padding, 
    $title_align, $content_align;

  function TextBox($title, $content, $width=DEFAULT_ITEM_WIDTH) {
    $this->title=$title;
    $this->content=$content;
    $this->width=$width;
    $this->show_title = (strlen($title)>0);
    $this->show_content = (strlen($content)>0);
    $this->padding = ITEM_INTERNAL_TABLE_PADDING;
    $this->show_bottom_padding = true;
    $this->title_style=TEXTBOX_TITLE_DEFAULT_STYLE;
    $this->content_style=TEXTBOX_CONTENT_DEFAULT_STYLE;
    $this->title_align=left;
    $this->content_align=left;
  }

  function box($box_style = ITEM_BOX_STYLE) {
    $this->box_style = $box_style;
  }

  function startBox($width) {
    // NOTE: ALL these echos, and all echos in project, will need
    // to be changed to string concats, so that toStr is universal.
    // don't get stuck echo'ing!
    echo "\n\n";
    echo Indenter::indent("<table cellspacing=0 cellpadding=1 ","++");
    //    if (isset($this->border_color)) 
    //  echo "bgcolor=\"$this->border_color\" "; 
    if (isset($this->box_style)) 
      echo "class=\"$this->box_style\" "; 
    echo "align=center width=\"". $this->width ."\">\n";
    echo Indenter::indent("<tr>\n","++");
    echo Indenter::indent("<td width='100%'>\n","++");
    
    echo Indenter::indent('<table cellspacing=1 cellpadding=',"++");
    echo $this->padding .' border="0" width="100%">';
  }

  function endBox() {
    echo Indenter::indent("</table>","--");

    echo Image::spacer($this->width-2*$this->padding-2);
    echo "</td>\n";
    echo Indenter::indent("","--");
    echo Indenter::indent("</tr>\n","--");
    echo Indenter::indent("</table>\n","--");
  }

  function displayTitle() {
    if ($this->show_title) {
      echo "\n";
      echo Indenter::indent("<tr><td class=$this->title_style","++");
      echo " align=$this->title_align>";
      echo $this->title;
      echo "</td>\n";
      echo Indenter::indent("</tr>\n","--");
    }
  }

  function displayContent() {
    if ($this->show_content) {
      echo "\n";
      echo Indenter::indent("<!-- content cell -->\n");
      echo Indenter::indent("<tr><td class=$this->content_style","++");
      echo " align=$this->content_align>";
      echo $this->content;
      if ($this->show_bottom_padding)
	echo Text::smallBreak(2);
      echo "</td>\n";
      echo Indenter::indent("</tr>\n","--");
    }
  }

  function display() {
    $this->startBox($this->width);
    $this->displayTitle(); 
    $this->displayContent();
    $this->endBox();
  }

}
?>
Return current item: Prioritexter