Extension system a complex problem about expanding a complex script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • infinull

    #1

    Extension system a complex problem about expanding a complex script

    I am making a script that is a very complex Content Management system.
    it makes a UDM navigation bar and writes content and a title.
    i want it to write content other that just basic text, like a calendar
    or a guest-book, and to do it with an extension system, the page says
    what type of content it is and an extension file processes the info.
    the content file would hold, a title, the type of content it is using,
    and content, the content needs to be passed to the extension, the
    title, probably isn't necessary.

    format in html of a page:
    <h1>
    #global page title
    <ul class="udm">
    #navbar
    </ul>
    <div id="bdy">
    #content
    </div>

    All I want you to help with is the #content.
    all files in the www/ directory are added to the navbar, and their
    content is put into body, if they are the current page.

    currently this function is used to make the body of a file, The $file
    input is
    the file whose content is to be printed.

    $GLOBALS['pathtofolder'] = "www/";
    $GLOBALS['seperator'] = "\n";

    //the above values can be changed, but i find these make the most
    sense


    function makeBody($file) {
    if(is_readable( $GLOBALS['pathtofolder']."$this->dir/$file.htm"))
    {
    $rfile = $this->Translate(file _get_contents(" $this->dir/$file.htm"));
    $reqfile = explode($GLOBAL S['seperator'],$rfile);
    $r .= $GLOBALS['Doc']->writeTag("h2", $reqfile[0]);
    for($i=1;$i<cou nt($reqfile);$i ++) {
    $r.= "<p>$reqfil e[$i]</p>";
    }
    } else {
    $r.= "page:\"$GLOBAL S[requesturi]\" cannot be found(this is error 404
    secondary)";
    }
    return $r;
    }

    $GLOBASL['Doc'] = an instantiation of the HTMLDoc class, which is a
    class that writes HTML seen with its write tag method.
    HTMLDoc::wirteT ag($tag, $content, [$properties = array()]);

    <$tag $properties[key]="$propertie s[values]">$content</$tag>

    current code for extenstion system:

    $extArr = navigation::sca nDir("ext/");
    for($i=0; $i<count($extAr r); $i++) {
    if(substr($extA rr[$i],0,4)=="ext.") {
    include "ext/".$extArr[$i];
    }
    }

    i have this part figured out, which loads all files with in a
    directory by

    this code will be run before any makeBody() functions are called.
    The way i see it this could work, but it uses eval.

    first add this code under the above code.
    $extNames= array();
    for($i=0; $i<count($extAr r); $i++) {
    $extNames[$i]=substr($extArr[$i],4,-4); //remove "ext." and
    ".php" from the Array, as new array
    }
    then change the lines of makeBody to this
    function makeBody($file) {
    if(is_readable( $GLOBALS['pathtofolder']."$this->dir/$file.htm"))
    {
    $reqfile = explode($GLOBAL S['seperator'],file_get_conte nts("$this->dir/$file.htm"));
    $r .= $GLOBALS['Doc']->writeTag("h2", $reqfile[0]);
    ****$type = $reqfile[1];**
    for($i=2;$i<cou nt($reqfile);$i ++) {
    $r.= $reqfile[$i];
    }
    ****$r=eval("$t ype($r);")
    } else {
    $r.= "page:\"$GLOBAL S[requesturi]\" cannot be found(this is error 404
    secondary)";
    }
    return $r;
    }

    I would like a better way that doesn't use eval(), please :-)
    --Infinull, I hope that wasn't too wordy or awkward, I had a lot to
    say
Working...