http://www.bitacora.davidesperalta.com/ David Esperalta - Entrada "Filosophy of SMC extensions" de la bitácora Gesbit Bitácora personal, software, opinión http://www.bitacora.davidesperalta.com/filosophy-of-smc-extensions/ http://www.bitacora.davidesperalta.com/filosophy-of-smc-extensions/ Sun, 07 Oct 2007 10:48:55 +0200 <![CDATA[ Filosophy of SMC extensions ]]> (Disclaimer: I not speak english, and writting... very bad, as you can see if continue reading: please, sorry my faults and be benevolent >^|)

Filosophy of SMC extensions. A extension is here the appropiate response for an user input argument. For every argument, a exception is prepared.

Ok, but, what is an user input argument exaclty? SMC can looking for variables and arguments that contain the user input data.

The class Input managed the variables and arguments, you can see, but, dont worry, I try explain here this "cocepts".

Suppose that SMC is installed on the URL: http://www.asmc.com/

Ok. This URL not contain any one variable or any var argument, as you see.

Now, suppose this other URL: http://www.asmc.com/?search=query

You have reason. Its correct. This URL have one variable "search", and one value "query".

To get and set this types of variables SMC use the Input class, that have methods to work with this. For example, to obtain the mentioned variable:

 $querySearh = $input->GetVar('search');

Ok, ok... this is the variables... what happened with the arguments? And what happened with the EXTENSIONS too!?

Just now!

See this now URL:

http://www.asmc.com/search/query/

Ok. Two argument is passed with the URL. And you can use again the Input class to retrieve this:

 $firstArgument = $input->GetArg(0);
 $secondArgument = $input->GetArg(1);

Or in other words:

 $extensionName = $input->GetArg(0);
 $firstArgument = $input->GetArg(1);

Cappici mio caro amico? But... extensions, arguments... arguments, extensions, how do work this?

Real example (argument, not URL): http://www.asmc.com/smc-login/

When you use this URL on a SMC instalation you can view the login form, and this is the followed step:

  1. Extensions class is instantiated and have all the availables extensions. Extensions class (you can see) find for extensions on the /smc-includes/extensions/ directory. Every file here become a available extension.

       Samples: smc-login.php, smc-logout.php, smc-recover.php, etc.
  2. The FrontEnd class loocking this if have a argument that is a valid extension. You can view this code on the "Respond" method of the FrondEnd class... and remember that this is the main, sacred and unique method...

       if($extensions->Exists(trim($input->GetArg()))){
        $extensions->RequireExt(trim($input->GetArg()));

    As you can view first we probed if the firts URL argument is a valid extension, and, if it is, require the extension file and exit the FrontEnd::Respond() method.

  3. At this point, we can say, theh extension file take the control of the program and is looking for the better users response.

    In sume. A extensions is a response to an argument. Not any argument... the first argument (zero). Of course is posible to use all the arguments, but, the first is the extension, amico.

    Considerer too that a extension have a name,... just the file name of the extension, without the ".php" extension........

       Files: smc-login.php, smc-logout.php, smc-recover.php, etc.
       Extension name: smc-login, smc-logout, smc-recover, etc.

    Any comments are welcome. Thanks!!

    ]]>