Page 2 of 2

Re: hi yogi

Posted: Thu Jan 08, 2004 5:11 pm
by lazy_yogi
ghost007 wrote:The idea was to include backend php in my private classes and only use frontend in the pages that will output info to the user.

e.g. index php will include frontend.php and use createobject when it needs for example the user.class.php also.

in the user.class.php I will include only the backend.php and include other classes that I need separately e.g. include mysql.class.php also because I connect to DB.

I thought this would make the code more portable as this was my only objective by using this structure.
Yea was thinking about that yesterday

I use baseObject instead of backend, and basePage instead of front end
But it's basically what you'er talking about

Then each page has a default db connection, header, footer, session, userSession, and maybe some other stuff.

Then each page is laid out as below. So the page itself becomes an object.
This is moving towards the M$ .net framework incase you haven't seen it before.

Code: Select all

<?
        # ---------- start code behind ---------- #

include_once 'basePage.php';

class Page(basePage)
&#123;
    function __construct()
    &#123;
        // construct the page ... using other functions and objects etc ..
    &#125;

    // other functions ....
&#125;
$page = new Page(); // instantuate the page above.

        # ----------- end code behind ----------- #
?>
<html><body>

... rest of page layout here, such as:
<a href="<? echo $page->somelink ?>">home</a>

<table>

</body></html>

Posted: Fri Jan 09, 2004 7:19 pm
by ghost007
This is moving towards the M$ .net framework incase you haven't seen it before.
I have never tried it but what I heard about it it's nice. For the moment I'm busy enough with php :-)

my error handeling code for forms:

Code: Select all

<?php
		function set_error ($nr){
			$count = count ($this->err);
			if ($count == 0)$this->err[] = "99";
			$this->err[] = $nr;
		}
		
		function parse_error ($field){
			include ("error_msg.php");
			$count = count ($this->err);
			
			for ($x=0; $x<$count; $x++)
			{
				$this->prnt_errors[] [$field] = $incl_errors [$this->err[$x]]."<br>";
			}
			return $this->prnt_errors;
		}


?>
Basicaly I store all vars in array "err" and when I processed all fields I count the errors in the array. If more than 1 => I call parse_error that uses an external file with all my errors.

The backend script (basepage) has the err var (var err = array();) in it so I can access it from anywhere in my script as class.errorcheck.php extends this class.

cheers
Siech

PHP-code investigation

Posted: Mon Jan 19, 2004 5:35 am
by IlyaNemihin
Hi, all!

I like object-oriented programming.
I think that investigation of existing oo-code brings many help in understunding of object-oriented approach,
f.e. take a look to my system ElementalSiteMaker (http://esitemaker.sf.net), it's easy CMS, but have many classes inside :) I've tried to divide whole system to small subsystems, f.e. Session subsystem, Auth subsystem, Persistence system (no mysql) etc. Also there is some kind of MVC approach - there is Model (business classes), Viewer, Controller. But additional there is Manager class. May be I'll draw uml diagrams of this system, later.

Regards,
Ilya