<?xml version="1.0"?>
     <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
     <channel>
      <link>http://www.bitacora.davidesperalta.com/</link>
      <title>David Esperalta - Entrada "Filosophy of SMC extensions" de la bitácora</title>
      <generator>Gesbit</generator>
      <description>Bitácora personal, software, opinión</description>
      <atom:link href="http://www.bitacora.davidesperalta.com/rss/" rel="self"
       type="application/rss+xml" />
    
      <item>
       <link>http://www.bitacora.davidesperalta.com/filosophy-of-smc-extensions/</link>
       <guid>http://www.bitacora.davidesperalta.com/filosophy-of-smc-extensions/</guid>
       <pubDate>Sun, 07 Oct 2007 10:48:55 +0200</pubDate>
       <title><![CDATA[ Filosophy of SMC extensions ]]></title>
       <description><![CDATA[ SMC no order notes and paranoias
 Chapter I.  Filosophy of SMC extensions
 <p style="font-style: italic;">(Disclaimer: I not speak english, and writting... very bad, as you can see if continue reading: please, sorry my faults and be benevolent &gt;^|)</p>
 <p>Filosophy of SMC extensions. A extension is here the appropiate response for an user input argument. For every argument, a exception is prepared.</p>
 <p>Ok, but, what is an user input argument exaclty? SMC can looking for variables and arguments that contain the user input data.</p>
 <p>The class Input managed the variables and arguments, you can see, but, dont worry, I try explain here this "cocepts".</p>
 <p>Suppose that SMC is installed on the URL: <em>http://www.asmc.com/</em></p>
 <p>Ok. This URL not contain any one variable or any var argument, as you see.</p>
 <p>Now, suppose this other URL: <em>http://www.asmc.com/?search=query</em></p>
 <p>You have reason. Its correct. This URL have one variable "search", and one value "query".</p>
 <p>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:</p><div class="gbhighlighcode"><div class="sourcecode"><pre class="php"> <span style="color: #0000ff;">$querySearh</span> = <span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">GetVar</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'search'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>
 <p>Ok, ok... this is the variables... what happened with the arguments? And what happened with the EXTENSIONS too!?</p>
 <p><strong>Just now!</strong></p>
 <p>See this now URL: <p>http://www.asmc.com/search/query/</em></p>
 <p>Ok. Two argument is passed with the URL. And you can use again the Input class to retrieve this:</p><div class="gbhighlighcode"><div class="sourcecode"><pre class="php"> <span style="color: #0000ff;">$firstArgument</span> = <span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">GetArg</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
 <span style="color: #0000ff;">$secondArgument</span> = <span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">GetArg</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>
 <p>Or in other words:</p><div class="gbhighlighcode"><div class="sourcecode"><pre class="php"> <span style="color: #0000ff;">$extensionName</span> = <span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">GetArg</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
 <span style="color: #0000ff;">$firstArgument</span> = <span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">GetArg</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>
 <p>Cappici mio caro amico? But... extensions, arguments... arguments, extensions, how do work this?</p>
 <p>Real example (argument, not URL): <em>http://www.asmc.com/smc-login/</em></p>
 <p>When you use this URL on a SMC instalation you can view the login form, and this is the followed step:</p>
 <ol>
  <li>
   <p>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.</p><div class="gbhighlighcode"><div class="sourcecode"><pre class="text">   Samples: smc-login.php, smc-logout.php, smc-recover.php, etc.</pre></div></div>
  </li>
  <li>
   <p>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...</p><div class="gbhighlighcode"><div class="sourcecode"><pre class="php">   <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$extensions</span>-&gt;<span style="color: #006600;">Exists</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/trim"><span style="color: #000066;">trim</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">GetArg</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #0000ff;">$extensions</span>-&gt;<span style="color: #006600;">RequireExt</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/trim"><span style="color: #000066;">trim</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">GetArg</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>
  <p>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.</p>
 <li>
  <p>At this point, we can say, theh extension file take the control of the program and is looking for the better users response.</p>
  <p>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.</p>
  <p>Considerer too that a extension have a name,... just the file name of the extension, without the ".php" extension........</p><div class="gbhighlighcode"><div class="sourcecode"><pre class="text">   Files: smc-login.php, smc-logout.php, smc-recover.php, etc.
   Extension name: smc-login, smc-logout, smc-recover, etc.</pre></div></div>
  <p>
  Any comments are welcome. <strong>Thanks!!</strong>
  </p>]]></description>
      </item>
      
     </channel>
    </rss>