Torsten: Objekt einer Klasse prüfen

Beitrag lesen

Hallo noch mal,

ich poste mal am besten den relevanten Code, Code sagt meistens mehr als 1000 Worte ;-)

die Klasse ContentBox:

  
<?php  
  class Content_Box  
  {  
    // Instanzvariablen  
    var $current_page; // Aktuelle Seite  
    var $template_dir; // Verzeichnis der Seite  
    var $forum;        // Pfad des Forums (forum/index.php)  
  
    // Konstruktor  
    function Content_box($cp,$td,$fm)  
    {  
      $this->current_page = $cp;  
      $this->template_dir = $td;  
      $this->forum = $fm;  
    }  
  
    function set_heading()  
    {  
      $heading = basename($this->current_page,".php"); //-> page (ohne .php)  
      if($heading == "index") $heading = "forum";  
      return "<div class=\"bg_heading\"><div class=\"$heading\"></div></div>\n";  
    }  
  
    function content_text()  
    {  
      switch($this->current_page)  
      {  
        case "start.php":  
          /* hier stehen text inhalte, die als  
             array zurück gegeben werden */  
          return $arr;  
        break;  
  
        case "news.php";  
        ...  
        break;  
        ...  
      }  
    }  
  
    function set_content($content_text)  
    {  
      if($this->current_page == $this->forum) {  
        return "<iframe src=\"$this->forum\" id=\"myIframe\" name=\"myIframe\" onLoad=\"dynfrm()\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" style=\"width:710px;margin-bottom:15px\" allowtransparency=\"true\"></iframe>";  
      }  
      else {  
        echo "<div id=\"conback\">";  
          include($this->template_dir .= $this->current_page); //-> include(templates/page.php);  
        echo "</div>";  
      }  
    }  
  }  
?>  

Die Instanziierung:

  
$conbox_obj = new Content_box(CURRENT_PAGE,TEMPLATE_DIR,FORUM_PATH);  

Das Layout:

  
    <div id="nav">  
      <div class="menu"><?php menu(); ?></div>  
    </div> <!-- /nav -->  
    <div id="content">  
      <?=$conbox_obj->set_heading()?>  
      <?=$conbox_obj->set_content($conbox_obj->content_text())?>  
    </div> <!-- /content -->  

und hier(evtl. nicht so relevant) die dynamische Anpassung des Inhaltes der iFrame:

  
function dynfrm() {  
  nav_div = document.getElementById("nav");  
  content_div = document.getElementById("content");  
  
  ifrm = document.getElementById('myIframe');  
  cont_ifrm = myIframe.document.getElementById('forumdiv');  
  
  //Höche des Inhaltes/Iframe wird der Höche/Iframe angepasst  
  ifrm.style.height = (cont_ifrm.offsetHeight + 45) + 'px';  
  content_div.style.height = (ifrm.offsetHeight + 88) + "px";  
  
  //Anpassung des Layouts  
  if(ifrm.offsetHeight > nav_div.offsetHeight)  
    nav_div.style.height = (ifrm.offsetHeight + 100) + "px";  
  else  
    nav_div.style.height = (content_div.offsetHeight + 10) + "px";  
}  

vielleicht erkennt ja jemand spontan wo ran es evtl. liegen könnte.
Über Tipps wie man es evtl. besser machen könnte, würde ich mich natürlich auch sehr freuen.

PS: Wie man sieht, ich bin kein Profi! Ich mach das nur nebenher, als eine Art Hobby!

Gruß
Torsten