So I've decided to redo much of the WysGUI brain with OOP. Not only did this increase load time & functionality significantly, it made me more clearly see & read the code. I think it looks more lean as well.
The content loading works great, and there aren't any problems.. that I've found yet. In fact, this system made it right away compatible for content in the Header, L/R Sidebars, Body, or Footer. In fact, you can even make a custom template with more/less parents [or sections] and get it to work (after I write the new and improved docs that go with it). Technically, it's possible to make sub-section parents, but I need to work some things out, experiment, and release docs.
Now, I also decided to redo the module include system. Thaat's where it got a bit ugly. All was good at first until I noticed something when I logged in. It went much faster, but something was missing. Oh yeah, the welcome message. It's stored in the `action.php` part of the module. Note that each module composes of 4 core include files. The message is stored in a regular variable called $goodMsg. It is then called to & displayed in the `form.php` part of the module. Before when I did it procedurally, everything worked as expected. The include was being executed on the page the user sees. So all of the variables & functions were all treated as if they were included precisely the part of the page they were told.
So that's when I noticed variables are lost if you include a page through a function() method, as opposed to just saying `include($moduleRow['settings']);` with a procedural method.
- Let me stop for a second and start again by saying this:
If you create a new page called `pageName.php`, It's organized like this:
So I imagine the problem is most likely in the Module Class.Code:pageName.php
- template.php
- - include brain.
- - call Module Class [MC]
- - include module settings/action
- - begin constructing <HTML>.
- - include <head> data & module head data
- - begin constructing <body>
- - call Content Class [CC]
- - - Note: [apply [MC] if content type is module, and puts `form.php` where it belongs.]
- - apply [CC] to header.
- - apply [CC] to l_sidebar.
- - apply [CC] to mainbody.
- - apply [CC] to R_sidebar.
- - apply [CC] to footer.
- - end.
I include this page into the template. [brain's action. {settings, head_data & form closely follow this method}]
The `load_from_module` class is preloaded inside the brain because it's going to be used on every page. Just like content. That's pretty much it...PHP Code:<?php
$action = new load_from_module();
$action->type = 'action';
$action->url = $thisURL;
$action->place();
$errMsg .= $action->error_message; //temp. work around
$goodMsg .= $action->good_message; //temp. work around
?>
So here's the code for the module class:
Notice the Work Arounds. Those are temporary until I sort this out. There must be a way for you to connect variables between different parts of modules. That's a tiny, yet key peace to my goal for a versatile engine. I want to use this one function, place() to place every single part to every single module, on every single page it's assigned to. That's why when I click "Log In" on the lean login page, I can hardly blink twice before the page notifies me I'm logged in. [only notifies me after the work-around :]PHP Code:<?php
class load_from_module extends MySQL_Connect
{
public $type,
$url,
$error_message, //Temp. Work Around
$good_message; //Temp. Work Around
private $include_path;
private function load()
{
$this->connect();
$query = mysql_query('SELECT `'.$this->type.'` FROM `modules`
WHERE `pageURL` = "'.$this->url.'"
OR `pageURL` = "*"');
$t = 0;
while($row = mysql_fetch_array($query))
{
if(file_exists($row[$this->type]))
{
$t++;
$this->include_path[$t] = $row[$this->type];
}
else
{
$this->error_message = '<p>Could not load Module `'.$this->type.'` for ''.$row[$this->type].''.</p>';
}
}
return $t>0 ? true : false;
}
public function place()
{
if($this->load())
{
for($i=0;$i<=count($this->include_path);$i++)
{
if( file_exists($this->include_path[$i]) ) include($this->include_path[$i]);
$this->error_message = $errMsg; //Work Around for Failing Error Messages.
$this->good_message = $goodMsg; //Work Around for Failing Good Messages.
}
return true;
}
}
}
?>
Moving onto a possible solution:
Here's one way it might work, that I don't really approve of, but it's not that bad..
I include this page into the template. [instead of the last one]
With this method, I'd have to make load() & $include_path public. Which isn't a problem except for the fact that $this->connect() is protected. Other than that, the whole thing is run by $type & $url.. which are public. I just don't know if it will connect globally or just within that little class.. Actually I think MySQL connections will be fine. If not, I'll make that work.PHP Code:<?php
$action = new load_from_module();
$action->type = 'action';
$action->url = $thisURL;
if($action->load())
for($i=0;$i<=count($action->include_path);$i++)
if( file_exists($action->include_path[$i]) )
include($action->include_path[$i]);
?>
I would also have to execute these lines of code 4 times. [action, settings, head_data, and form].
The only role the class plays is loading the data from MySQL into an array. From there, it's all procedural.
The only way to make a connection is to extend the connection class. However, you do not need to worry about MySQL connections when working within modules because it's included within a function within that class, so technically, it already is extending MySQL_Connect and makes a connection when load() is called. With that said, calling $action->load() should make a root connection.
My question: Is there a better method for using classes & functions for including pages, or do I have to make a Frankenstein OOP+Procedural mess on 4 pages like I provided above?:laugh: -> :ehh:
Oh yeah, and what's a Method do again? That must be what solves my problem :) *Re-Researches* :/:
Edit: Oh wait, is a method just a function/variable in a class?

