Location: PHPKode > projects > PHP on Trax > johnpipi-trax-f599562/trax/doc/__filesource/fsource_PHPonTrax__vendortraxtrax_generator.php.html
<html>
<head>
<title>File Source for trax_generator.php</title>
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
    <td class="header_top">PHPonTrax</td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td class="header_menu">
  		  [ <a href="../classtrees_PHPonTrax.html" class="menu">class tree: PHPonTrax</a> ]
		  [ <a href="../elementindex_PHPonTrax.html" class="menu">index: PHPonTrax</a> ]
		  [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="200" class="menu">
	<div id="todolist">
			<p><a href="../todolist.html">Todo List</a></p>
	</div>
      <b>Packages:</b><br />
              <a href="../li_PHPonTrax.html">PHPonTrax</a><br />
              <a href="../li_PHPonTraxTest.html">PHPonTraxTest</a><br />
            <br /><br />
                  
                </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<h1 align="center">Source for file trax_generator.php</h1>
<p>Documentation is available at <a href="../PHPonTrax/_vendor_trax_trax_generator_php.html">trax_generator.php</a></p>
<div class="php">
<div class="listing"><pre><ol><li><a name="a1"></a><span class="src-php">&lt;?php</span></li>
<li><a name="a2"></a><span class="src-doc">/**</span></li>
<li><a name="a3"></a><span class="src-doc"> *  File containing the TraxGenerator class</span></li>
<li><a name="a4"></a><span class="src-doc"> *</span></li>
<li><a name="a5"></a><span class="src-doc"> *  (PHP 5)</span></li>
<li><a name="a6"></a><span class="src-doc"> *</span></li>
<li><a name="a7"></a><span class="src-doc"> *  </span><span class="src-doc-coretag">@package</span><span class="src-doc"> PHPonTrax</span></li>
<li><a name="a8"></a><span class="src-doc"> *  </span><span class="src-doc-coretag">@version</span><span class="src-doc"> $Id$</span></li>
<li><a name="a9"></a><span class="src-doc"> *  </span><span class="src-doc-coretag">@copyright</span><span class="src-doc"> (c) 2005 John Peterson</span></li>
<li><a name="a10"></a><span class="src-doc"> *</span></li>
<li><a name="a11"></a><span class="src-doc"> *   Permission is hereby granted, free of charge, to any person obtaining</span></li>
<li><a name="a12"></a><span class="src-doc"> *   a copy of this software and associated documentation files (the</span></li>
<li><a name="a13"></a><span class="src-doc"> *   &quot;Software&quot;), to deal in the Software without restriction, including</span></li>
<li><a name="a14"></a><span class="src-doc"> *   without limitation the rights to use, copy, modify, merge, publish,</span></li>
<li><a name="a15"></a><span class="src-doc"> *   distribute, sublicense, and/or sell copies of the Software, and to</span></li>
<li><a name="a16"></a><span class="src-doc"> *   permit persons to whom the Software is furnished to do so, subject to</span></li>
<li><a name="a17"></a><span class="src-doc"> *   the following conditions:</span></li>
<li><a name="a18"></a><span class="src-doc"> *</span></li>
<li><a name="a19"></a><span class="src-doc"> *   The above copyright notice and this permission notice shall be</span></li>
<li><a name="a20"></a><span class="src-doc"> *   included in all copies or substantial portions of the Software.</span></li>
<li><a name="a21"></a><span class="src-doc"> *</span></li>
<li><a name="a22"></a><span class="src-doc"> *   THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,</span></li>
<li><a name="a23"></a><span class="src-doc"> *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span></li>
<li><a name="a24"></a><span class="src-doc"> *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span></li>
<li><a name="a25"></a><span class="src-doc"> *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE</span></li>
<li><a name="a26"></a><span class="src-doc"> *   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION</span></li>
<li><a name="a27"></a><span class="src-doc"> *   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION</span></li>
<li><a name="a28"></a><span class="src-doc"> *   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</span></li>
<li><a name="a29"></a><span class="src-doc"> *</span></li>
<li><a name="a30"></a><span class="src-doc"> *  </span><span class="src-doc-coretag">@package</span><span class="src-doc"> PHPonTrax</span></li>
<li><a name="a31"></a><span class="src-doc"> */</span></li>
<li><a name="a32"></a>&nbsp;</li>
<li><a name="a33"></a><span class="src-doc">/**</span></li>
<li><a name="a34"></a><span class="src-doc"> *  Generate application files in the Trax work area</span></li>
<li><a name="a35"></a><span class="src-doc"> *</span></li>
<li><a name="a36"></a><span class="src-doc"> *  Implements the commands of </span><span class="src-doc-inlinetag">{@link generate.php script/generate.php}</span></li>
<li><a name="a37"></a><span class="src-doc"> *  &lt;p&gt;Legal commands:&lt;/p&gt;</span></li>
<li><a name="a38"></a><span class="src-doc"> *  &lt;ul&gt;</span></li>
<li><a name="a39"></a><span class="src-doc"> *    &lt;li&gt;</span><span class="src-doc-inlinetag">{@link generate_controller() controller}</span><span class="src-doc">&lt;/li&gt;</span></li>
<li><a name="a40"></a><span class="src-doc"> *    &lt;li&gt;</span><span class="src-doc-inlinetag">{@link generate_model() model}</span><span class="src-doc">&lt;/li&gt;</span></li>
<li><a name="a41"></a><span class="src-doc"> *    &lt;li&gt;</span><span class="src-doc-inlinetag">{@link generate_scaffold() scaffold}</span><span class="src-doc">&lt;/li&gt;</span></li>
<li><a name="a42"></a><span class="src-doc"> *  &lt;/ul&gt;</span></li>
<li><a name="a43"></a><span class="src-doc"> */</span></li>
<li><a name="a44"></a><span class="src-key">class </span><a href="../PHPonTrax/TraxGenerator.html">TraxGenerator</a> <span class="src-sym">{</span></li>
<li><a name="a45"></a>&nbsp;</li>
<li><a name="a46"></a>    <span class="src-doc">/**</span></li>
<li><a name="a47"></a><span class="src-doc">     *  Filesystem path to the app/views directory in the Trax work area</span></li>
<li><a name="a48"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a49"></a><span class="src-doc">     */</span></li>
<li><a name="a50"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$view_path">$view_path</a><span class="src-sym">;</span></li>
<li><a name="a51"></a>&nbsp;</li>
<li><a name="a52"></a>    <span class="src-doc">/**</span></li>
<li><a name="a53"></a><span class="src-doc">     *  Filesystem path to the app/controllers directory in the Trax work area</span></li>
<li><a name="a54"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a55"></a><span class="src-doc">     */</span></li>
<li><a name="a56"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$controller_path">$controller_path</a><span class="src-sym">;</span></li>
<li><a name="a57"></a>&nbsp;</li>
<li><a name="a58"></a>    <span class="src-doc">/**</span></li>
<li><a name="a59"></a><span class="src-doc">     *  Filesystem path to the app/helpers directory in the Trax work area</span></li>
<li><a name="a60"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a61"></a><span class="src-doc">     */</span></li>
<li><a name="a62"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$helper_path">$helper_path</a><span class="src-sym">;</span></li>
<li><a name="a63"></a>&nbsp;</li>
<li><a name="a64"></a>    <span class="src-doc">/**</span></li>
<li><a name="a65"></a><span class="src-doc">     *  Filesystem path to the app/model directory in the Trax work area</span></li>
<li><a name="a66"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a67"></a><span class="src-doc">     */</span></li>
<li><a name="a68"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$model_path">$model_path</a><span class="src-sym">;</span></li>
<li><a name="a69"></a>&nbsp;</li>
<li><a name="a70"></a>    <span class="src-doc">/**</span></li>
<li><a name="a71"></a><span class="src-doc">     *  Generated subdirectories in the Trax work area</span></li>
<li><a name="a72"></a><span class="src-doc">     *</span></li>
<li><a name="a73"></a><span class="src-doc">     *  When a controller is generated with a name that includes '/',</span></li>
<li><a name="a74"></a><span class="src-doc">     *  $extra_path is set to the implied subdirectories.</span></li>
<li><a name="a75"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a76"></a><span class="src-doc">     */</span></li>
<li><a name="a77"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$extra_path">$extra_path</a><span class="src-sym">;</span></li>
<li><a name="a78"></a>&nbsp;</li>
<li><a name="a79"></a>    <span class="src-doc">/**</span></li>
<li><a name="a80"></a><span class="src-doc">     *  Platform-dependent command to make a directory</span></li>
<li><a name="a81"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a82"></a><span class="src-doc">     */</span></li>
<li><a name="a83"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$mkdir_cmd">$mkdir_cmd</a><span class="src-sym">;</span></li>
<li><a name="a84"></a>&nbsp;</li>
<li><a name="a85"></a>    <span class="src-doc">/**</span></li>
<li><a name="a86"></a><span class="src-doc">     *  Filesystem path to the templates/controller.php file</span></li>
<li><a name="a87"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a88"></a><span class="src-doc">     */</span></li>
<li><a name="a89"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$controller_template_file">$controller_template_file</a><span class="src-sym">;</span></li>
<li><a name="a90"></a>&nbsp;</li>
<li><a name="a91"></a>    <span class="src-doc">/**</span></li>
<li><a name="a92"></a><span class="src-doc">     *  Filesystem path to the templates/helper.php file</span></li>
<li><a name="a93"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a94"></a><span class="src-doc">     */</span></li>
<li><a name="a95"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$helper_template_file">$helper_template_file</a><span class="src-sym">;</span></li>
<li><a name="a96"></a>&nbsp;</li>
<li><a name="a97"></a>    <span class="src-doc">/**</span></li>
<li><a name="a98"></a><span class="src-doc">     *  Filesystem path to the templates/view.phtml file</span></li>
<li><a name="a99"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a100"></a><span class="src-doc">     */</span></li>
<li><a name="a101"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$view_template_file">$view_template_file</a><span class="src-sym">;</span></li>
<li><a name="a102"></a>&nbsp;</li>
<li><a name="a103"></a>    <span class="src-doc">/**</span></li>
<li><a name="a104"></a><span class="src-doc">     *  Filesystem path to the templates/model.php file</span></li>
<li><a name="a105"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a106"></a><span class="src-doc">     */</span></li>
<li><a name="a107"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$model_template_file">$model_template_file</a><span class="src-sym">;</span></li>
<li><a name="a108"></a>&nbsp;</li>
<li><a name="a109"></a>    <span class="src-doc">/**</span></li>
<li><a name="a110"></a><span class="src-doc">     *  Filesystem path to templates/scaffolds/generator_templates directory</span></li>
<li><a name="a111"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a112"></a><span class="src-doc">     */</span></li>
<li><a name="a113"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$scaffold_template_path">$scaffold_template_path</a><span class="src-sym">;</span></li>
<li><a name="a114"></a>&nbsp;</li>
<li><a name="a115"></a>    <span class="src-doc">/**</span></li>
<li><a name="a116"></a><span class="src-doc">     *  Filesystem path to the app/views/layouts/ directory in the</span></li>
<li><a name="a117"></a><span class="src-doc">     *  Trax work area</span></li>
<li><a name="a118"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a119"></a><span class="src-doc">     */</span></li>
<li><a name="a120"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$layouts_path">$layouts_path</a><span class="src-sym">;</span></li>
<li><a name="a121"></a>&nbsp;</li>
<li><a name="a122"></a>    <span class="src-doc">/**</span></li>
<li><a name="a123"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@todo</span><span class="src-doc"> Document this variable</span></li>
<li><a name="a124"></a><span class="src-doc">     *</span></li>
<li><a name="a125"></a><span class="src-doc">     *   Value is set by </span><span class="src-doc-inlinetag">{@link generate_controller()}</span><span class="src-doc"> and used by</span></li>
<li><a name="a126"></a><span class="src-doc">     *   </span><span class="src-doc-inlinetag">{@link generate_scaffold()}</span></li>
<li><a name="a127"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a128"></a><span class="src-doc">     */</span></li>
<li><a name="a129"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$layout_filename">$layout_filename</a><span class="src-sym">;</span></li>
<li><a name="a130"></a>&nbsp;</li>
<li><a name="a131"></a>    <span class="src-doc">/**</span></li>
<li><a name="a132"></a><span class="src-doc">     *  CamelCase name of the controller class</span></li>
<li><a name="a133"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a134"></a><span class="src-doc">     */</span></li>
<li><a name="a135"></a>    <span class="src-key">private </span><a href="../PHPonTrax/TraxGenerator.html#var$controller_class">$controller_class</a><span class="src-sym">;</span></li>
<li><a name="a136"></a>&nbsp;</li>
<li><a name="a137"></a>    <span class="src-doc">/**</span></li>
<li><a name="a138"></a><span class="src-doc">     *  Value of the view files extension (usually '.phtml')</span></li>
<li><a name="a139"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a140"></a><span class="src-doc">     */</span></li>
<li><a name="a141"></a>    <span class="src-key">public </span><a href="../PHPonTrax/TraxGenerator.html#var$view_file_extention">$view_file_extention</a> = <span class="src-id">TRAX_VIEWS_EXTENTION</span><span class="src-sym">;</span></li>
<li><a name="a142"></a>&nbsp;</li>
<li><a name="a143"></a>    <span class="src-doc">/**</span></li>
<li><a name="a144"></a><span class="src-doc">     *  Constructor for the TraxGenerator object</span></li>
<li><a name="a145"></a><span class="src-doc">     *</span></li>
<li><a name="a146"></a><span class="src-doc">     *  Compute and store filesystem paths to the various</span></li>
<li><a name="a147"></a><span class="src-doc">     *  subdirectories of the Trax work area and the template files</span></li>
<li><a name="a148"></a><span class="src-doc">     *  used to generate application files</span></li>
<li><a name="a149"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> $GLOBALS['TRAX_INCLUDES']</span></li>
<li><a name="a150"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string[] </span><span class="src-doc-var">$GLOBALS['TRAX_INCLUDES'] </span><span class="src-doc">Array of paths to</span></li>
<li><a name="a151"></a><span class="src-doc">     *                                              various Trax directories</span></li>
<li><a name="a152"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> controller_path</span></li>
<li><a name="a153"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> controller_template_file</span></li>
<li><a name="a154"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> helper_path</span></li>
<li><a name="a155"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> helper_template_file</span></li>
<li><a name="a156"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> layouts_path</span></li>
<li><a name="a157"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> model_path</span></li>
<li><a name="a158"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> model_template_file</span></li>
<li><a name="a159"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> scaffold_template_path</span></li>
<li><a name="a160"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> view_path</span></li>
<li><a name="a161"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> view_template_file</span></li>
<li><a name="a162"></a><span class="src-doc">     */</span></li>
<li><a name="a163"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#method__construct">__construct</a><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a164"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a> =</li>
<li><a name="a165"></a>               <span class="src-id"><a href="../PHPonTrax/_data_config_environment_php.html#defineTRAX_ROOT">TRAX_ROOT</a> </span>. <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'TRAX_INCLUDES'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'views'</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a166"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$controller_path">controller_path</a> =</li>
<li><a name="a167"></a>               <span class="src-id"><a href="../PHPonTrax/_data_config_environment_php.html#defineTRAX_ROOT">TRAX_ROOT</a> </span>. <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'TRAX_INCLUDES'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'controllers'</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a168"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$helper_path">helper_path</a> =</li>
<li><a name="a169"></a>               <span class="src-id"><a href="../PHPonTrax/_data_config_environment_php.html#defineTRAX_ROOT">TRAX_ROOT</a> </span>. <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'TRAX_INCLUDES'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'helpers'</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a170"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$model_path">model_path</a> =</li>
<li><a name="a171"></a>               <span class="src-id"><a href="../PHPonTrax/_data_config_environment_php.html#defineTRAX_ROOT">TRAX_ROOT</a> </span>. <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'TRAX_INCLUDES'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'models'</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a172"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$layouts_path">layouts_path</a> =</li>
<li><a name="a173"></a>               <span class="src-id"><a href="../PHPonTrax/_data_config_environment_php.html#defineTRAX_ROOT">TRAX_ROOT</a> </span>. <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'TRAX_INCLUDES'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'layouts'</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a174"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$controller_template_file">controller_template_file</a> =</li>
<li><a name="a175"></a>               <span class="src-id"><a href="../PHPonTrax/_data_config_environment_php.html#defineTRAX_LIB_ROOT">TRAX_LIB_ROOT</a> </span>. <span class="src-str">&quot;/templates/controller.php&quot;</span><span class="src-sym">;</span></li>
<li><a name="a176"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$helper_template_file">helper_template_file</a> =</li>
<li><a name="a177"></a>               <span class="src-id"><a href="../PHPonTrax/_data_config_environment_php.html#defineTRAX_LIB_ROOT">TRAX_LIB_ROOT</a> </span>. <span class="src-str">&quot;/templates/helper.php&quot;</span><span class="src-sym">;</span></li>
<li><a name="a178"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$view_template_file">view_template_file</a> =</li>
<li><a name="a179"></a>               <span class="src-id"><a href="../PHPonTrax/_data_config_environment_php.html#defineTRAX_LIB_ROOT">TRAX_LIB_ROOT</a> </span>. <span class="src-str">&quot;/templates/view.&quot;</span>.<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$view_file_extention">view_file_extention</a><span class="src-sym">;</span></li>
<li><a name="a180"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$model_template_file">model_template_file</a> =</li>
<li><a name="a181"></a>               <span class="src-id"><a href="../PHPonTrax/_data_config_environment_php.html#defineTRAX_LIB_ROOT">TRAX_LIB_ROOT</a> </span>. <span class="src-str">&quot;/templates/model.php&quot;</span><span class="src-sym">;</span></li>
<li><a name="a182"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$scaffold_template_path">scaffold_template_path</a> =</li>
<li><a name="a183"></a>               <span class="src-id"><a href="../PHPonTrax/_data_config_environment_php.html#defineTRAX_LIB_ROOT">TRAX_LIB_ROOT</a> </span>. <span class="src-str">&quot;/templates/scaffolds/generator_templates&quot;</span><span class="src-sym">;</span></li>
<li><a name="a184"></a>&nbsp;</li>
<li><a name="a185"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-id">PHP_OS</span><span class="src-sym">, </span><span class="src-num">0</span><span class="src-sym">, </span><span class="src-num">3</span><span class="src-sym">) </span>== <span class="src-str">'WIN'</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a186"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$mkdir_cmd">mkdir_cmd</a> = <span class="src-str">&quot;mkdir&quot;</span><span class="src-sym">;</span></li>
<li><a name="a187"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a188"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$mkdir_cmd">mkdir_cmd</a> = <span class="src-str">&quot;mkdir -p&quot;</span><span class="src-sym">;</span></li>
<li><a name="a189"></a>        <span class="src-sym">}</span></li>
<li><a name="a190"></a>    <span class="src-sym">}</span></li>
<li><a name="a191"></a>&nbsp;</li>
<li><a name="a192"></a>    <span class="src-doc">/**</span></li>
<li><a name="a193"></a><span class="src-doc">     *  Parse command line and carry out the command</span></li>
<li><a name="a194"></a><span class="src-doc">     *</span></li>
<li><a name="a195"></a><span class="src-doc">     *  Command line arguments, if any are in $_SERVER['argv']</span></li>
<li><a name="a196"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> controller_help()</span></li>
<li><a name="a197"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> generate_controller()</span></li>
<li><a name="a198"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> generate_model()</span></li>
<li><a name="a199"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> generate_scaffold()</span></li>
<li><a name="a200"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> generator_help()</span></li>
<li><a name="a201"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> model_help()</span></li>
<li><a name="a202"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> scaffold_help()</span></li>
<li><a name="a203"></a><span class="src-doc">     */</span></li>
<li><a name="a204"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodrun">run</a><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a205"></a>&nbsp;</li>
<li><a name="a206"></a>        <span class="src-comm">//  If command line arguments exist, parse them</span></li>
<li><a name="a207"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/array_key_exists">array_key_exists</a><span class="src-sym">(</span><span class="src-str">'argv'</span><span class="src-sym">, </span><span class="src-var">$_SERVER</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a208"></a>            <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/array_key_exists">array_key_exists</a><span class="src-sym">(</span><span class="src-num">1</span><span class="src-sym">, </span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'argv'</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a209"></a>                <span class="src-var">$command </span>= <a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a210"></a>            <span class="src-sym">}</span></li>
<li><a name="a211"></a>            <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/array_key_exists">array_key_exists</a><span class="src-sym">(</span><span class="src-num">2</span><span class="src-sym">, </span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'argv'</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a212"></a>                <span class="src-var">$command_name </span>= <span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">2</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a213"></a>            <span class="src-sym">}</span></li>
<li><a name="a214"></a>        <span class="src-sym">}</span></li>
<li><a name="a215"></a>&nbsp;</li>
<li><a name="a216"></a>        <span class="src-comm">//  Execute command or output a diagnostic</span></li>
<li><a name="a217"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$command</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a218"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodgenerator_help">generator_help</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a219"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a220"></a>            <span class="src-key">switch</span><span class="src-sym">(</span><span class="src-var">$command</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a221"></a>&nbsp;</li>
<li><a name="a222"></a>                <span class="src-comm">//  Process &quot;controller&quot; command</span></li>
<li><a name="a223"></a>                <span class="src-key">case </span><span class="src-str">&quot;controller&quot;</span>:</li>
<li><a name="a224"></a>                    <span class="src-key">if</span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$command_name</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a225"></a>                        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodcontroller_help">controller_help</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a226"></a>                    <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a227"></a>                        <span class="src-var">$views </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a228"></a>                        <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/array_key_exists">array_key_exists</a><span class="src-sym">(</span><span class="src-num">3</span><span class="src-sym">, </span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'argv'</span><span class="src-sym">]</span><span class="src-sym">)</span></li>
<li><a name="a229"></a>                           &amp;&amp; <span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">3</span><span class="src-sym">] </span>!= <span class="src-str">&quot;&quot;</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a230"></a>                            <span class="src-key">for</span><span class="src-sym">(</span><span class="src-var">$i</span>=<span class="src-num">3</span><span class="src-sym">;</span><span class="src-var">$i </span>&lt; <a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span><span class="src-var">$i</span>++<span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a231"></a>                               <span class="src-var">$views</span><span class="src-sym">[</span><span class="src-sym">] </span>= <a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-var">$i</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a232"></a>                            <span class="src-sym">}</span></li>
<li><a name="a233"></a>                        <span class="src-sym">}</span></li>
<li><a name="a234"></a>                        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodgenerate_controller">generate_controller</a><span class="src-sym">(</span><span class="src-var">$command_name</span><span class="src-sym">, </span><span class="src-var">$views</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a235"></a>                    <span class="src-sym">}</span></li>
<li><a name="a236"></a>                    <span class="src-key">break</span><span class="src-sym">;</span></li>
<li><a name="a237"></a>&nbsp;</li>
<li><a name="a238"></a>                <span class="src-comm">//  Process &quot;model&quot; command</span></li>
<li><a name="a239"></a>                <span class="src-comm">//  $command_name is the name of the model</span></li>
<li><a name="a240"></a>                <span class="src-key">case </span><span class="src-str">&quot;model&quot;</span>:</li>
<li><a name="a241"></a>                    <span class="src-key">if</span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$command_name</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a242"></a>                        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodmodel_help">model_help</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a243"></a>                    <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a244"></a>                        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodgenerate_model">generate_model</a><span class="src-sym">(</span><span class="src-var">$command_name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a245"></a>                    <span class="src-sym">}</span></li>
<li><a name="a246"></a>                    <span class="src-key">break</span><span class="src-sym">;</span></li>
<li><a name="a247"></a>&nbsp;</li>
<li><a name="a248"></a>                <span class="src-comm">//  Process &quot;scaffold&quot; command</span></li>
<li><a name="a249"></a>                <span class="src-comm">//  $command_name has the name of the model</span></li>
<li><a name="a250"></a>                <span class="src-comm">//  $_SERVER['argv'][3] has the name of the controller</span></li>
<li><a name="a251"></a>                <span class="src-key">case </span><span class="src-str">&quot;scaffold&quot;</span>:</li>
<li><a name="a252"></a>&nbsp;</li>
<li><a name="a253"></a>                    <span class="src-comm">//  Model name is required</span></li>
<li><a name="a254"></a>                    <span class="src-key">if</span><span class="src-sym">( </span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$command_name</span><span class="src-sym">) ) </span><span class="src-sym">{</span></li>
<li><a name="a255"></a>                        echo <span class="src-str">&quot;Error: name of model omitted\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a256"></a>                        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodscaffold_help">scaffold_help</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a257"></a>                        <span class="src-key">break</span><span class="src-sym">;</span></li>
<li><a name="a258"></a>                    <span class="src-sym">}</span></li>
<li><a name="a259"></a>&nbsp;</li>
<li><a name="a260"></a>                    <span class="src-comm">//  Controller name is optional</span></li>
<li><a name="a261"></a>                    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/array_key_exists">array_key_exists</a><span class="src-sym">(</span><span class="src-num">3</span><span class="src-sym">, </span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a262"></a>                        <span class="src-var">$controller_name </span>= <span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">3</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a263"></a>                    <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a264"></a>                        <span class="src-var">$controller_name </span>= <span class="src-id">null</span><span class="src-sym">;</span></li>
<li><a name="a265"></a>                    <span class="src-sym">}</span></li>
<li><a name="a266"></a>                        </li>
<li><a name="a267"></a>                    <span class="src-comm">//  Views are optional following controller name</span></li>
<li><a name="a268"></a>                    <span class="src-var">$views </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a269"></a>                    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/array_key_exists">array_key_exists</a><span class="src-sym">(</span><span class="src-num">4</span><span class="src-sym">, </span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span></li>
<li><a name="a270"></a>                        &amp;&amp; <span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">4</span><span class="src-sym">] </span>!= <span class="src-str">&quot;&quot;</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a271"></a>                        <span class="src-key">for</span><span class="src-sym">(</span><span class="src-var">$i</span>=<span class="src-num">4</span><span class="src-sym">;</span><span class="src-var">$i </span>&lt; <a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span><span class="src-var">$i</span>++<span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a272"></a>                            <span class="src-var">$views</span><span class="src-sym">[</span><span class="src-sym">] </span>= <a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;argv&quot;</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-var">$i</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a273"></a>                        <span class="src-sym">}</span></li>
<li><a name="a274"></a>                    <span class="src-sym">}</span></li>
<li><a name="a275"></a>                    <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodgenerate_scaffold">generate_scaffold</a><span class="src-sym">(</span><span class="src-var">$command_name</span><span class="src-sym">,</span></li>
<li><a name="a276"></a>                                             <span class="src-var">$controller_name</span><span class="src-sym">, </span><span class="src-var">$views</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a277"></a>                    <span class="src-key">break</span><span class="src-sym">;                    </span></li>
<li><a name="a278"></a>&nbsp;</li>
<li><a name="a279"></a>            <span class="src-key">default</span>:</li>
<li><a name="a280"></a>                <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodgenerator_help">generator_help</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a281"></a>            <span class="src-sym">}                            </span><span class="src-comm">// switch($command)</span></li>
<li><a name="a282"></a>        <span class="src-sym">}</span></li>
<li><a name="a283"></a>        <span class="src-key">return</span><span class="src-sym">;</span></li>
<li><a name="a284"></a>    <span class="src-sym">}</span></li>
<li><a name="a285"></a>&nbsp;</li>
<li><a name="a286"></a>    <span class="src-doc">/**</span></li>
<li><a name="a287"></a><span class="src-doc">     *  Implement &quot;generate controller&quot; command</span></li>
<li><a name="a288"></a><span class="src-doc">     *</span></li>
<li><a name="a289"></a><span class="src-doc">     *  &lt;p&gt;Example:&lt;br&gt;&lt;samp&gt;php script/generate.php controller&lt;/samp&gt;</span></li>
<li><a name="a290"></a><span class="src-doc">     *  &lt;i&gt;SomeName&lt;/i&gt;&lt;br&gt;</span></li>
<li><a name="a291"></a><span class="src-doc">     *  will generate:&lt;/p&gt;</span></li>
<li><a name="a292"></a><span class="src-doc">     *  &lt;ul&gt;</span></li>
<li><a name="a293"></a><span class="src-doc">     *    &lt;li&gt;a file</span></li>
<li><a name="a294"></a><span class="src-doc">     *  &lt;samp&gt;app/controllers/&lt;/samp&gt;&lt;i&gt;some_name&lt;/i&gt;&lt;samp&gt;_controller.php&lt;/samp&gt;&lt;br&gt;</span></li>
<li><a name="a295"></a><span class="src-doc">     *  containing the class definition&lt;br&gt;</span></li>
<li><a name="a296"></a><span class="src-doc">     *  &lt;samp&gt;class&lt;/samp&gt; &lt;i&gt;SomeName&lt;/i&gt;&lt;samp&gt;Controller extends</span></li>
<li><a name="a297"></a><span class="src-doc">     *  ApplicationController {}&lt;/samp&gt;&lt;/li&gt;</span></li>
<li><a name="a298"></a><span class="src-doc">     *     &lt;li&gt;a file</span></li>
<li><a name="a299"></a><span class="src-doc">     *  &lt;samp&gt;app/helpers/&lt;/samp&gt;&lt;i&gt;some_name&lt;/i&gt;&lt;samp&gt;_helper.php&lt;/samp&gt;&lt;/li&gt;</span></li>
<li><a name="a300"></a><span class="src-doc">     *     &lt;li&gt;a directory</span></li>
<li><a name="a301"></a><span class="src-doc">     *  &lt;samp&gt;app/views/&lt;/samp&gt;&lt;i&gt;some_name&lt;/i&gt;&lt;/li&gt;</span></li>
<li><a name="a302"></a><span class="src-doc">     *  &lt;/ul&gt;</span></li>
<li><a name="a303"></a><span class="src-doc">     *</span></li>
<li><a name="a304"></a><span class="src-doc">     *  &lt;p&gt;Optionally, one or more views can be appended to the command:&lt;br&gt;</span></li>
<li><a name="a305"></a><span class="src-doc">     *  &lt;samp&gt;php script/generate.php controller&lt;/samp&gt;</span></li>
<li><a name="a306"></a><span class="src-doc">     *  &lt;i&gt;SomeName view1 view2&lt;/i&gt;&lt;br&gt;</span></li>
<li><a name="a307"></a><span class="src-doc">     *  which will additionally generate files:&lt;br&gt;</span></li>
<li><a name="a308"></a><span class="src-doc">     *  &lt;samp&gt;app/views/&lt;/samp&gt;&lt;i&gt;some_name/view1&lt;/i&gt;&lt;samp&gt;.phtml&lt;/samp&gt;&lt;br&gt;</span></li>
<li><a name="a309"></a><span class="src-doc">     *  &lt;samp&gt;app/views/&lt;/samp&gt;&lt;i&gt;some_name/view2&lt;/i&gt;&lt;samp&gt;.phtml&lt;/samp&gt;&lt;/p&gt;</span></li>
<li><a name="a310"></a><span class="src-doc">     *</span></li>
<li><a name="a311"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">Name in CamelCase of the controller to generate.</span></li>
<li><a name="a312"></a><span class="src-doc">     *                       The value may include '/' which will cause</span></li>
<li><a name="a313"></a><span class="src-doc">     *                       creation of subdirectories indicated to</span></li>
<li><a name="a314"></a><span class="src-doc">     *                       hold the controller and view files.</span></li>
<li><a name="a315"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$views </span><span class="src-doc"> Optional list of views to generate</span></li>
<li><a name="a316"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">boolean </span><span class="src-doc-var">$scaffolding </span></li>
<li><a name="a317"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> Inflector::underscore()</span></li>
<li><a name="a318"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> $controller_class   Set during call</span></li>
<li><a name="a319"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> $controller_path    Must be set before call.</span></li>
<li><a name="a320"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> create_controller()</span></li>
<li><a name="a321"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> create_helper()</span></li>
<li><a name="a322"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> create_view()</span></li>
<li><a name="a323"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> $extra_path         Set during call</span></li>
<li><a name="a324"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> $helper_path        Must be set before call.</span></li>
<li><a name="a325"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> $layouts_path       Must be set before call.</span></li>
<li><a name="a326"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> $layout_filename    Set during call</span></li>
<li><a name="a327"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> $view_path          Must be set before call.</span></li>
<li><a name="a328"></a><span class="src-doc">     */</span></li>
<li><a name="a329"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodgenerate_controller">generate_controller</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">, </span><span class="src-var">$views</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">, </span><span class="src-var">$scaffolding </span>= <span class="src-id">false</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a330"></a>&nbsp;</li>
<li><a name="a331"></a>        <span class="src-comm"># Set the View and Controller extra path info</span></li>
<li><a name="a332"></a>        <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/stristr">stristr</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">, </span><span class="src-str">&quot;/&quot;</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a333"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$extra_path">extra_path</a> = <a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">,</span><span class="src-num">0</span><span class="src-sym">,</span><a href="http://www.php.net/strrpos">strrpos</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">, </span><span class="src-str">&quot;/&quot;</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a334"></a>            <span class="src-var">$name </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodunderscore">underscore</a><span class="src-sym">(</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">,</span><a href="http://www.php.net/strrpos">strrpos</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">, </span><span class="src-str">&quot;/&quot;</span><span class="src-sym">)</span>+<span class="src-num">1</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a335"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a> .= <span class="src-str">&quot;</span><span class="src-str">/<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$extra_path">extra_path</a>/<span class="src-var">$name</span></span><span class="src-str">&quot;</span><span class="src-sym">;           </span></li>
<li><a name="a336"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$layouts_path">layouts_path</a> .= <span class="src-str">&quot;</span><span class="src-str">/<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$extra_path">extra_path</a><span class="src-str">"</span></span><span class="src-sym">;</span></li>
<li><a name="a337"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$controller_path">controller_path</a> .= <span class="src-str">&quot;</span><span class="src-str">/<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$extra_path">extra_path</a><span class="src-str">"</span></span><span class="src-sym">;</span></li>
<li><a name="a338"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$helper_path">helper_path</a> .= <span class="src-str">&quot;</span><span class="src-str">/<span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$extra_path">extra_path</a><span class="src-str">"</span></span><span class="src-sym">;</span></li>
<li><a name="a339"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a340"></a>            <span class="src-var">$name </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodunderscore">underscore</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a341"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a> .= <span class="src-str">&quot;</span><span class="src-str">/<span class="src-var">$name</span></span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a342"></a>        <span class="src-sym">}</span></li>
<li><a name="a343"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$layout_filename">layout_filename</a> = <span class="src-var">$name</span><span class="src-sym">;</span></li>
<li><a name="a344"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$controller_class">controller_class</a> = <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodcamelize">camelize</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a345"></a>&nbsp;</li>
<li><a name="a346"></a>        <span class="src-comm"># Create the extra folders for View / Controller</span></li>
<li><a name="a347"></a>        <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a348"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">exists</span> <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a349"></a>        <span class="src-sym">} </span><span class="src-key">else</span><span class="src-sym">{</span></li>
<li><a name="a350"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodexec">exec</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str"><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$mkdir_cmd">mkdir_cmd</a> <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a><span class="src-str">"</span></span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a351"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">create</span> <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a352"></a>        <span class="src-sym">}</span></li>
<li><a name="a353"></a>&nbsp;</li>
<li><a name="a354"></a>        <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$controller_path">controller_path</a><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a355"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">exists</span> <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$controller_path">controller_path</a>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a356"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a357"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodexec">exec</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str"><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$mkdir_cmd">mkdir_cmd</a> <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$controller_path">controller_path</a><span class="src-str">"</span></span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a358"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">create</span> <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$controller_path">controller_path</a>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a359"></a>        <span class="src-sym">}</span></li>
<li><a name="a360"></a>&nbsp;</li>
<li><a name="a361"></a>        <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$helper_path">helper_path</a><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a362"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">exists</span> <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$helper_path">helper_path</a>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a363"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a364"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodexec">exec</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str"><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$mkdir_cmd">mkdir_cmd</a> <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$helper_path">helper_path</a><span class="src-str">"</span></span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a365"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">create</span> <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$helper_path">helper_path</a>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a366"></a>        <span class="src-sym">}</span></li>
<li><a name="a367"></a>&nbsp;</li>
<li><a name="a368"></a>        <span class="src-comm"># Create the actual controller/helper files</span></li>
<li><a name="a369"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$scaffolding</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a370"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodcreate_controller">create_controller</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">, </span><span class="src-var">$views</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a371"></a>        <span class="src-sym">} </span></li>
<li><a name="a372"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodcreate_helper">create_helper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a373"></a>&nbsp;</li>
<li><a name="a374"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$extra_path">extra_path</a><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a375"></a>            <span class="src-var">$name </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$extra_path">extra_path</a>.<span class="src-str">&quot;/&quot;</span>.<span class="src-var">$name</span><span class="src-sym">;</span></li>
<li><a name="a376"></a>        <span class="src-sym">}</span></li>
<li><a name="a377"></a>&nbsp;</li>
<li><a name="a378"></a>        <span class="src-comm"># Create view files if any</span></li>
<li><a name="a379"></a>        <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$views</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a380"></a>            <span class="src-key">foreach</span><span class="src-sym">(</span><span class="src-var">$views </span><span class="src-key">as </span><span class="src-var">$view</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a381"></a>                <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodcreate_view">create_view</a><span class="src-sym">(</span><span class="src-var">$view</span><span class="src-sym">,</span><span class="src-var">$name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a382"></a>            <span class="src-sym">}</span></li>
<li><a name="a383"></a>        <span class="src-sym">} </span><span class="src-key">elseif</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$views</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a384"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodcreate_view">create_view</a><span class="src-sym">(</span><span class="src-var">$views</span><span class="src-sym">,</span><span class="src-var">$name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a385"></a>        <span class="src-sym">}</span></li>
<li><a name="a386"></a>    <span class="src-sym">}</span></li>
<li><a name="a387"></a>&nbsp;</li>
<li><a name="a388"></a>    <span class="src-doc">/**</span></li>
<li><a name="a389"></a><span class="src-doc">     *  Implement the &quot;generate model&quot; command</span></li>
<li><a name="a390"></a><span class="src-doc">     *</span></li>
<li><a name="a391"></a><span class="src-doc">     *  &lt;p&gt;Example:&lt;br&gt;&lt;samp&gt;php script/generate.php model&lt;/samp&gt;</span></li>
<li><a name="a392"></a><span class="src-doc">     *  &lt;i&gt;SomeName&lt;/i&gt;&lt;br&gt;</span></li>
<li><a name="a393"></a><span class="src-doc">     *  will generate a file</span></li>
<li><a name="a394"></a><span class="src-doc">     *  &lt;samp&gt;app/models/&lt;/samp&gt;&lt;i&gt;some_name&lt;/i&gt;&lt;samp&gt;.php&lt;/samp&gt;&lt;br&gt;</span></li>
<li><a name="a395"></a><span class="src-doc">     *  containing the class definition&lt;br&gt;</span></li>
<li><a name="a396"></a><span class="src-doc">     *  &lt;samp&gt;class&lt;/samp&gt; &lt;i&gt;SomeName&lt;/i&gt; &lt;samp&gt;extends</span></li>
<li><a name="a397"></a><span class="src-doc">     *  ActiveRecord {}&lt;/samp&gt;</span></li>
<li><a name="a398"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">Name of the model.  May be in either</span></li>
<li><a name="a399"></a><span class="src-doc">     *                 under_score or CamelCase.  If no '_' exists in</span></li>
<li><a name="a400"></a><span class="src-doc">     *                 $name it is treated as CamelCase.</span></li>
<li><a name="a401"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> Inflector::underscore()</span></li>
<li><a name="a402"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> model_path           Must be set before call.</span></li>
<li><a name="a403"></a><span class="src-doc">     *                              Not changed during call.</span></li>
<li><a name="a404"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> model_template_file  Must be set before call.</span></li>
<li><a name="a405"></a><span class="src-doc">     *                              Not changed during call.</span></li>
<li><a name="a406"></a><span class="src-doc">     */</span></li>
<li><a name="a407"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodgenerate_model">generate_model</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a408"></a>&nbsp;</li>
<li><a name="a409"></a>        <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/stristr">stristr</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">, </span><span class="src-str">&quot;_&quot;</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a410"></a>            <span class="src-var">$model_file </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$model_path">model_path</a>.<span class="src-str">&quot;/&quot;</span>.<a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>.<span class="src-str">&quot;.php&quot;</span><span class="src-sym">;</span></li>
<li><a name="a411"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a412"></a>            <span class="src-var">$model_file </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$model_path">model_path</a>.<span class="src-str">&quot;/&quot;</span>.<span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodunderscore">underscore</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>.<span class="src-str">&quot;.php&quot;</span><span class="src-sym">;</span></li>
<li><a name="a413"></a>        <span class="src-sym">}</span></li>
<li><a name="a414"></a>&nbsp;</li>
<li><a name="a415"></a>        <span class="src-var">$model_class </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodcamelize">camelize</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a416"></a>&nbsp;</li>
<li><a name="a417"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$model_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a418"></a>            <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$model_template_file">model_template_file</a><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a419"></a>                <span class="src-var">$template </span>= <a href="http://www.php.net/file_get_contents">file_get_contents</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$model_template_file">model_template_file</a><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a420"></a>                <span class="src-var">$template </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">'[class_name]'</span><span class="src-sym">,</span><span class="src-var">$model_class</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a421"></a>                <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$model_file</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a422"></a>                    echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">error</span> <span class="src-id">creating</span> <span class="src-id">model</span> <span class="src-id">file</span>: <span class="src-var">$model_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a423"></a>                <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a424"></a>                    echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">create</span> <span class="src-var">$model_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a425"></a>                    <span class="src-key">return </span><span class="src-id">true</span><span class="src-sym">;</span></li>
<li><a name="a426"></a>                <span class="src-sym">}</span></li>
<li><a name="a427"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a428"></a>                echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">error</span> <span class="src-id">model</span> <span class="src-id">template</span> <span class="src-id">file</span> <span class="src-id">doesn</span>'<span class="src-id">t</span> <span class="src-id">exist</span>: <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$model_template_file">model_template_file</a>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a429"></a>            <span class="src-sym">}</span></li>
<li><a name="a430"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a431"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">exists</span> <span class="src-var">$model_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a432"></a>            <span class="src-key">return </span><span class="src-id">true</span><span class="src-sym">;</span></li>
<li><a name="a433"></a>        <span class="src-sym">}</span></li>
<li><a name="a434"></a>        <span class="src-key">return </span><span class="src-id">false</span><span class="src-sym">;</span></li>
<li><a name="a435"></a>    <span class="src-sym">}</span></li>
<li><a name="a436"></a>    </li>
<li><a name="a437"></a>    <span class="src-doc">/**</span></li>
<li><a name="a438"></a><span class="src-doc">     *  Implement the &quot;generate scaffold&quot; command</span></li>
<li><a name="a439"></a><span class="src-doc">     *</span></li>
<li><a name="a440"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$model_name </span></li>
<li><a name="a441"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$controller_name </span></li>
<li><a name="a442"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$views </span></li>
<li><a name="a443"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> generate_controller()</span></li>
<li><a name="a444"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> generate_model()</span></li>
<li><a name="a445"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> Inflector::classify()</span></li>
<li><a name="a446"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> Inflector::humanize()</span></li>
<li><a name="a447"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> Inflector::pluralize()</span></li>
<li><a name="a448"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> Inflector::singularize()</span></li>
<li><a name="a449"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> Inflector::underscore()</span></li>
<li><a name="a450"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> $layout_filename          Set as output from</span></li>
<li><a name="a451"></a><span class="src-doc">     *                                   generate_controller().</span></li>
<li><a name="a452"></a><span class="src-doc">     *                                   Not changed afterward.</span></li>
<li><a name="a453"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> fix_php_brackets()</span></li>
<li><a name="a454"></a><span class="src-doc">     */</span></li>
<li><a name="a455"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodgenerate_scaffold">generate_scaffold</a><span class="src-sym">(</span><span class="src-var">$model_name</span><span class="src-sym">, </span><span class="src-var">$controller_name</span><span class="src-sym">, </span><span class="src-var">$views</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a456"></a>        <span class="src-comm">//echo 'generate_scaffold(&quot;'.$model_name.'&quot;, &quot;'</span></li>
<li><a name="a457"></a>        <span class="src-comm">//          .$controller_name.'&quot;, &quot;'.$views.'&quot;)'.&quot;\n&quot;;</span></li>
<li><a name="a458"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$model_exists </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodgenerate_model">generate_model</a><span class="src-sym">(</span><span class="src-var">$model_name</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a459"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">Error</span> - <span class="src-id">Can</span>'<span class="src-id">t</span> <span class="src-id">create</span> <span class="src-id">Model</span>: <span class="src-var">$model_name</span>.\n</span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a460"></a>            <span class="src-key">return</span><span class="src-sym">;</span></li>
<li><a name="a461"></a>        <span class="src-sym">}</span></li>
<li><a name="a462"></a>&nbsp;</li>
<li><a name="a463"></a>        <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'current_controller_object'</span><span class="src-sym">] </span>=<span class="src-sym">&amp; </span><span class="src-var">$this</span><span class="src-sym">;</span></li>
<li><a name="a464"></a>        <span class="src-var">$model_class_name </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodclassify">classify</a><span class="src-sym">(</span><span class="src-var">$model_name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a465"></a>        <span class="src-var">$singular_model_name </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodsingularize">singularize</a><span class="src-sym">(</span><span class="src-var">$model_name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a466"></a>        <span class="src-var">$plural_model_name </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodpluralize">pluralize</a><span class="src-sym">(</span><span class="src-var">$model_name</span><span class="src-sym">)</span><span class="src-sym">;  </span></li>
<li><a name="a467"></a>        <span class="src-var">$human_model_name </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodhumanize">humanize</a><span class="src-sym">(</span><span class="src-var">$model_name</span><span class="src-sym">)</span><span class="src-sym">;      </span></li>
<li><a name="a468"></a>&nbsp;</li>
<li><a name="a469"></a>        try <span class="src-sym">{</span></li>
<li><a name="a470"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-sym">{</span><span class="src-var">$singular_model_name</span><span class="src-sym">} </span>= <span class="src-key">new </span><span class="src-var">$model_class_name</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a471"></a>        <span class="src-sym">} </span>catch <span class="src-sym">(</span><span class="src-id">ActiveRecordError </span><span class="src-var">$e</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a472"></a>            echo <span class="src-str">&quot;Can't create model.\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a473"></a>            echo <span class="src-var">$e</span><span class="src-sym">-&gt;</span><span class="src-id">getMessage</span><span class="src-sym">(</span><span class="src-sym">)</span>.<span class="src-str">&quot;\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a474"></a>            echo <span class="src-str">&quot;for database '&quot;</span></li>
<li><a name="a475"></a>                . <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'TRAX_DB_SETTINGS'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-id">TRAX_MODE</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'database'</span><span class="src-sym">]</span></li>
<li><a name="a476"></a>                . <span class="src-str">&quot;' on host '&quot;</span></li>
<li><a name="a477"></a>                . <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'TRAX_DB_SETTINGS'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-id">TRAX_MODE</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'hostspec'</span><span class="src-sym">]</span></li>
<li><a name="a478"></a>                . <span class="src-str">&quot;' as user '&quot;</span></li>
<li><a name="a479"></a>                . <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'TRAX_DB_SETTINGS'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-id">TRAX_MODE</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'username'</span><span class="src-sym">]</span></li>
<li><a name="a480"></a>                . <span class="src-str">&quot;'\nDid you configure file &quot;</span></li>
<li><a name="a481"></a>                . <span class="src-id">TRAX_ROOT </span>. <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'TRAX_INCLUDES'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'config'</span><span class="src-sym">]</span></li>
<li><a name="a482"></a>                . <span class="src-str">&quot;/database.ini correctly?\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a483"></a>            <span class="src-key">die</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a484"></a>        <span class="src-sym">}</span></li>
<li><a name="a485"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$controller_name</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a486"></a>            <span class="src-var">$controller_name </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodunderscore">underscore</a><span class="src-sym">(</span><span class="src-var">$model_name</span><span class="src-sym">)</span><span class="src-sym">;   </span></li>
<li><a name="a487"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a488"></a>            <span class="src-var">$controller_name </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodunderscore">underscore</a><span class="src-sym">(</span><span class="src-var">$controller_name</span><span class="src-sym">)</span><span class="src-sym">;    </span></li>
<li><a name="a489"></a>        <span class="src-sym">}</span></li>
<li><a name="a490"></a>        <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'current_controller_name'</span><span class="src-sym">] </span>= <span class="src-var">$controller_name</span><span class="src-sym">;</span></li>
<li><a name="a491"></a>        <span class="src-var">$controller_file </span>=</li>
<li><a name="a492"></a>            <span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$controller_path">controller_path</a></span>/<span class="src-str">&quot; </span>. <span class="src-var">$controller_name</span>.<span class="src-str">&quot;_controller.php&quot;</span><span class="src-sym">;</span></li>
<li><a name="a493"></a>        <span class="src-var">$GLOBALS</span><span class="src-sym">[</span><span class="src-str">'current_controller_path'</span><span class="src-sym">] </span>= <span class="src-var">$controller_file</span><span class="src-sym">;</span></li>
<li><a name="a494"></a>        <span class="src-var">$non_scaffolded_actions </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a495"></a>        <span class="src-var">$illegal_views </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">&quot;index&quot;</span><span class="src-sym">,</span><span class="src-str">&quot;add&quot;</span><span class="src-sym">,</span><span class="src-str">&quot;edit&quot;</span><span class="src-sym">,</span><span class="src-str">&quot;show&quot;</span><span class="src-sym">)</span><span class="src-sym">;      </span></li>
<li><a name="a496"></a>        <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$views</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a497"></a>            <span class="src-key">foreach</span><span class="src-sym">(</span><span class="src-var">$views </span><span class="src-key">as </span><span class="src-var">$view</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a498"></a>                <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/in_array">in_array</a><span class="src-sym">(</span><span class="src-var">$view</span><span class="src-sym">, </span><span class="src-var">$illegal_views</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a499"></a>                    <span class="src-var">$non_scaffolded_actions</span><span class="src-sym">[</span><span class="src-sym">] </span>= <span class="src-var">$view</span><span class="src-sym">;  </span></li>
<li><a name="a500"></a>                <span class="src-sym">}           </span></li>
<li><a name="a501"></a>            <span class="src-sym">}</span></li>
<li><a name="a502"></a>        <span class="src-sym">}         </span></li>
<li><a name="a503"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodgenerate_controller">generate_controller</a><span class="src-sym">(</span><span class="src-var">$controller_name</span><span class="src-sym">,</span></li>
<li><a name="a504"></a>                                   <span class="src-var">$non_scaffolded_actions</span><span class="src-sym">, </span><span class="src-id">true</span><span class="src-sym">)</span><span class="src-sym">; </span></li>
<li><a name="a505"></a>        <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/stristr">stristr</a><span class="src-sym">(</span><span class="src-var">$controller_name</span><span class="src-sym">, </span><span class="src-str">&quot;/&quot;</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a506"></a>            <span class="src-var">$controller_class_name </span>=</li>
<li><a name="a507"></a>                <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodclassify">classify</a><span class="src-sym">(</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$controller_name</span><span class="src-sym">,</span></li>
<li><a name="a508"></a>                                           <a href="http://www.php.net/strrpos">strrpos</a><span class="src-sym">(</span><span class="src-var">$controller_name</span><span class="src-sym">, </span><span class="src-str">&quot;/&quot;</span><span class="src-sym">)</span>+<span class="src-num">1</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a509"></a>            <span class="src-var">$human_controller_name </span>=</li>
<li><a name="a510"></a>                <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodhumanize">humanize</a><span class="src-sym">(</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$controller_name</span><span class="src-sym">,</span></li>
<li><a name="a511"></a>                                           <a href="http://www.php.net/strrpos">strrpos</a><span class="src-sym">(</span><span class="src-var">$controller_name</span><span class="src-sym">, </span><span class="src-str">&quot;/&quot;</span><span class="src-sym">)</span>+<span class="src-num">1</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a512"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a513"></a>            <span class="src-var">$controller_class_name </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodclassify">classify</a><span class="src-sym">(</span><span class="src-var">$controller_name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a514"></a>            <span class="src-var">$human_controller_name </span>= <span class="src-id"><a href="../PHPonTrax/Inflector.html">Inflector</a></span><span class="src-sym">::</span><a href="../PHPonTrax/Inflector.html#methodhumanize">humanize</a><span class="src-sym">(</span><span class="src-var">$controller_name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a515"></a>        <span class="src-sym">}             </span></li>
<li><a name="a516"></a>     </li>
<li><a name="a517"></a>        <span class="src-comm"># Generate the controller</span></li>
<li><a name="a518"></a>                <a href="http://www.php.net/ob_start">ob_start</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;    </span></li>
<li><a name="a519"></a>        <span class="src-inc">include</span><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">scaffold_template_path</span>/<span class="src-id">controller</span>.<span class="src-id">php</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a520"></a>        <span class="src-var">$controller_contents </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodfix_php_brackets">fix_php_brackets</a><span class="src-sym">(</span><a href="http://www.php.net/ob_get_contents">ob_get_contents</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a521"></a>        <a href="http://www.php.net/ob_end_clean">ob_end_clean</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a522"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$controller_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a523"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$controller_file</span><span class="src-sym">, </span><span class="src-var">$controller_contents</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a524"></a>                echo <span class="src-str">&quot;</span><span class="src-id">error creating controller class </span><a href="http://www.php.net/file">file</a>: <span class="src-var">$controller_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a525"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a526"></a>                echo <span class="src-str">&quot;</span><span class="src-id">create </span><span class="src-var">$controller_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a527"></a>            <span class="src-sym">}        </span></li>
<li><a name="a528"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a529"></a>            echo <span class="src-str">&quot;</span><span class="src-id">exists </span><span class="src-var">$controller_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;        </span></li>
<li><a name="a530"></a>        <span class="src-sym">} </span></li>
<li><a name="a531"></a>                </li>
<li><a name="a532"></a>        <span class="src-comm"># Generate the index.phtml view</span></li>
<li><a name="a533"></a>                <span class="src-var">$view_file </span>= <span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a></span>/<span class="src-id">index</span>.<span class="src-str">&quot;</span>.<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_file_extention">view_file_extention</a></span><span class="src-sym">;</span></li>
<li><a name="a534"></a>        <a href="http://www.php.net/ob_start">ob_start</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;    </span></li>
<li><a name="a535"></a>        <span class="src-inc">include</span><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">scaffold_template_path</span>/<span class="src-id">view_index</span>.<span class="src-id">phtml</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a536"></a>        <span class="src-var">$index_contents </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodfix_php_brackets">fix_php_brackets</a><span class="src-sym">(</span><a href="http://www.php.net/ob_get_contents">ob_get_contents</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a537"></a>        <a href="http://www.php.net/ob_end_clean">ob_end_clean</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a538"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a539"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">, </span><span class="src-var">$index_contents</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a540"></a>                echo <span class="src-str">&quot;</span><span class="src-id">error creating view </span><a href="http://www.php.net/file">file</a>: <span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a541"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a542"></a>                echo <span class="src-str">&quot;</span><span class="src-id">create </span><span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a543"></a>            <span class="src-sym">}</span></li>
<li><a name="a544"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a545"></a>            echo <span class="src-str">&quot;</span><span class="src-id">exists </span><span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;        </span></li>
<li><a name="a546"></a>        <span class="src-sym">} </span></li>
<li><a name="a547"></a>               </li>
<li><a name="a548"></a>        <span class="src-comm"># Generate the add.phtml view</span></li>
<li><a name="a549"></a>                <span class="src-var">$view_file </span>= <span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a></span>/<span class="src-id">add</span>.<span class="src-str">&quot;</span>.<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_file_extention">view_file_extention</a></span><span class="src-sym">;</span></li>
<li><a name="a550"></a>        <a href="http://www.php.net/ob_start">ob_start</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;    </span></li>
<li><a name="a551"></a>        <span class="src-inc">include</span><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">scaffold_template_path</span>/<span class="src-id">view_add</span>.<span class="src-id">phtml</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a552"></a>        <span class="src-var">$add_contents </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodfix_php_brackets">fix_php_brackets</a><span class="src-sym">(</span><a href="http://www.php.net/ob_get_contents">ob_get_contents</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a553"></a>        <a href="http://www.php.net/ob_end_clean">ob_end_clean</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;       </span></li>
<li><a name="a554"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a555"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">, </span><span class="src-var">$add_contents</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a556"></a>                echo <span class="src-str">&quot;</span><span class="src-id">error creating view </span><a href="http://www.php.net/file">file</a>: <span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a557"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a558"></a>                echo <span class="src-str">&quot;</span><span class="src-id">create </span><span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a559"></a>            <span class="src-sym">}</span></li>
<li><a name="a560"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a561"></a>            echo <span class="src-str">&quot;</span><span class="src-id">exists </span><span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;        </span></li>
<li><a name="a562"></a>        <span class="src-sym">} </span></li>
<li><a name="a563"></a>        </li>
<li><a name="a564"></a>        <span class="src-comm"># Generate the edit.phtml view</span></li>
<li><a name="a565"></a>                <span class="src-var">$view_file </span>= <span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a></span>/<span class="src-id">edit</span>.<span class="src-str">&quot;</span>.<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_file_extention">view_file_extention</a></span><span class="src-sym">;</span></li>
<li><a name="a566"></a>        <a href="http://www.php.net/ob_start">ob_start</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;    </span></li>
<li><a name="a567"></a>        <span class="src-inc">include</span><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">scaffold_template_path</span>/<span class="src-id">view_edit</span>.<span class="src-id">phtml</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a568"></a>        <span class="src-var">$edit_contents </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodfix_php_brackets">fix_php_brackets</a><span class="src-sym">(</span><a href="http://www.php.net/ob_get_contents">ob_get_contents</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a569"></a>        <a href="http://www.php.net/ob_end_clean">ob_end_clean</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">; </span></li>
<li><a name="a570"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a571"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">, </span><span class="src-var">$edit_contents</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a572"></a>                echo <span class="src-str">&quot;</span><span class="src-id">error creating view </span><a href="http://www.php.net/file">file</a>: <span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a573"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a574"></a>                echo <span class="src-str">&quot;</span><span class="src-id">create </span><span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a575"></a>            <span class="src-sym">}</span></li>
<li><a name="a576"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a577"></a>            echo <span class="src-str">&quot;</span><span class="src-id">exists </span><span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;        </span></li>
<li><a name="a578"></a>        <span class="src-sym">} </span></li>
<li><a name="a579"></a>        </li>
<li><a name="a580"></a>        <span class="src-comm"># Generate the show.phtml view</span></li>
<li><a name="a581"></a>                <span class="src-var">$view_file </span>= <span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a></span>/<span class="src-id">show</span>.<span class="src-str">&quot;</span>.<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_file_extention">view_file_extention</a></span><span class="src-sym">;</span></li>
<li><a name="a582"></a>        <a href="http://www.php.net/ob_start">ob_start</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;    </span></li>
<li><a name="a583"></a>        <span class="src-inc">include</span><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">scaffold_template_path</span>/<span class="src-id">view_show</span>.<span class="src-id">phtml</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a584"></a>        <span class="src-var">$show_contents </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodfix_php_brackets">fix_php_brackets</a><span class="src-sym">(</span><a href="http://www.php.net/ob_get_contents">ob_get_contents</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a585"></a>        <a href="http://www.php.net/ob_end_clean">ob_end_clean</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a586"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a587"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">, </span><span class="src-var">$show_contents</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a588"></a>                echo <span class="src-str">&quot;</span><span class="src-id">error creating view </span><a href="http://www.php.net/file">file</a>: <span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a589"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a590"></a>                echo <span class="src-str">&quot;</span><span class="src-id">create </span><span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a591"></a>            <span class="src-sym">}</span></li>
<li><a name="a592"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a593"></a>            echo <span class="src-str">&quot;</span><span class="src-id">exists </span><span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;        </span></li>
<li><a name="a594"></a>        <span class="src-sym">} </span></li>
<li><a name="a595"></a>               </li>
<li><a name="a596"></a>        <span class="src-comm"># Generate the partial containing the form elments from the database</span></li>
<li><a name="a597"></a>                <span class="src-var">$view_file </span>= <span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a></span>/<span class="src-id">_form</span>.<span class="src-str">&quot;</span>.<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_file_extention">view_file_extention</a></span><span class="src-sym">;</span></li>
<li><a name="a598"></a>        <a href="http://www.php.net/ob_start">ob_start</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;    </span></li>
<li><a name="a599"></a>        require <span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">scaffold_template_path</span>/<span class="src-id">form_scaffolding</span>.<span class="src-id">phtml</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a600"></a>        <span class="src-var">$_form_contents </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodfix_php_brackets">fix_php_brackets</a><span class="src-sym">(</span><a href="http://www.php.net/ob_get_contents">ob_get_contents</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a601"></a>        <a href="http://www.php.net/ob_end_clean">ob_end_clean</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;  </span></li>
<li><a name="a602"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a603"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">, </span><span class="src-var">$_form_contents</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a604"></a>                echo <span class="src-str">&quot;</span><span class="src-id">error creating view </span><a href="http://www.php.net/file">file</a>: <span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a605"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a606"></a>                echo <span class="src-str">&quot;</span><span class="src-id">create </span><span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a607"></a>            <span class="src-sym">}</span></li>
<li><a name="a608"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a609"></a>            echo <span class="src-str">&quot;</span><span class="src-id">exists </span><span class="src-var">$view_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;        </span></li>
<li><a name="a610"></a>        <span class="src-sym">} </span></li>
<li><a name="a611"></a>        </li>
<li><a name="a612"></a>        <span class="src-comm"># Generate the layout for the scaffolding</span></li>
<li><a name="a613"></a>                <span class="src-var">$layout_file </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$layouts_path">layouts_path</a></span>.<span class="src-str">&quot;/&quot;</span></li>
<li><a name="a614"></a>            . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$layout_filename">layout_filename</a></span>.<span class="src-str">&quot;.&quot;</span></li>
<li><a name="a615"></a>            . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_file_extention">view_file_extention</a></span><span class="src-sym">;</span></li>
<li><a name="a616"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$layouts_path">layouts_path</a></span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a617"></a>            <a href="http://www.php.net/mkdir">mkdir</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$layouts_path">layouts_path</a></span><span class="src-sym">)</span><span class="src-sym">;        </span></li>
<li><a name="a618"></a>        <span class="src-sym">}</span></li>
<li><a name="a619"></a>        <a href="http://www.php.net/ob_start">ob_start</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;    </span></li>
<li><a name="a620"></a>        <span class="src-inc">include</span><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">scaffold_template_path</span>/<span class="src-id">layout</span>.<span class="src-id">phtml</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a621"></a>        <span class="src-var">$layout_contents </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#methodfix_php_brackets">fix_php_brackets</a><span class="src-sym">(</span><a href="http://www.php.net/ob_get_contents">ob_get_contents</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a622"></a>        <a href="http://www.php.net/ob_end_clean">ob_end_clean</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;  </span></li>
<li><a name="a623"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$layout_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a624"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$layout_file</span><span class="src-sym">, </span><span class="src-var">$layout_contents</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a625"></a>                echo <span class="src-str">&quot;</span><span class="src-id">error creating layout </span><a href="http://www.php.net/file">file</a>: <span class="src-var">$layout_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a626"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a627"></a>                echo <span class="src-str">&quot;</span><span class="src-id">create </span><span class="src-var">$layout_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a628"></a>            <span class="src-sym">}</span></li>
<li><a name="a629"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a630"></a>            echo <span class="src-str">&quot;</span><span class="src-id">exists </span><span class="src-var">$layout_file</span>\n<span class="src-str">&quot;</span><span class="src-sym">;        </span></li>
<li><a name="a631"></a>        <span class="src-sym">}                   </span></li>
<li><a name="a632"></a>    <span class="src-sym">}    </span></li>
<li><a name="a633"></a>&nbsp;</li>
<li><a name="a634"></a>    <span class="src-doc">/**</span></li>
<li><a name="a635"></a><span class="src-doc">     *  Create a controller file with optional view methods</span></li>
<li><a name="a636"></a><span class="src-doc">     *</span></li>
<li><a name="a637"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$controller </span><span class="src-doc">Name of the controller</span></li>
<li><a name="a638"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string[] </span><span class="src-doc-var">$views </span><span class="src-doc">   Name(s) of view(s), if any</span></li>
<li><a name="a639"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> controller_class    Must be set before call.</span></li>
<li><a name="a640"></a><span class="src-doc">     *                             Not changed during call.</span></li>
<li><a name="a641"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> controller_path     Must be set before call.</span></li>
<li><a name="a642"></a><span class="src-doc">     *                             Not changed during call.</span></li>
<li><a name="a643"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> controller_template_file Must be set before call.</span></li>
<li><a name="a644"></a><span class="src-doc">     *                             Not changed during call.</span></li>
<li><a name="a645"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@todo</span><span class="src-doc"> Should return succeed/fail indication</span></li>
<li><a name="a646"></a><span class="src-doc">     */</span></li>
<li><a name="a647"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodcreate_controller">create_controller</a><span class="src-sym">(</span><span class="src-var">$controller</span><span class="src-sym">,</span><span class="src-var">$views</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a648"></a>&nbsp;</li>
<li><a name="a649"></a>        <span class="src-var">$controller_file </span>= <span class="src-str">&quot;</span><span class="src-str"><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$controller_path">controller_path</a>/</span><span class="src-str">&quot;</span></li>
<li><a name="a650"></a>            . <span class="src-var">$controller </span>. <span class="src-str">&quot;_controller.php&quot;</span><span class="src-sym">;</span></li>
<li><a name="a651"></a>&nbsp;</li>
<li><a name="a652"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$controller_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a653"></a>            <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$controller_template_file">controller_template_file</a></span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a654"></a>                <span class="src-var">$template </span>= <a href="http://www.php.net/file_get_contents">file_get_contents</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$controller_template_file">controller_template_file</a></span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a655"></a>                <span class="src-var">$template </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">'[class_name]'</span><span class="src-sym">,</span></li>
<li><a name="a656"></a>                                        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$controller_class">controller_class</a></span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a657"></a>                <span class="src-comm">//  Add view methods</span></li>
<li><a name="a658"></a>                <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$views</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a659"></a>&nbsp;</li>
<li><a name="a660"></a>                    <span class="src-comm">//  There are some views, add a method for each</span></li>
<li><a name="a661"></a>                    <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$views</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a662"></a>&nbsp;</li>
<li><a name="a663"></a>                        <span class="src-comm">//  Multiple views in an array</span></li>
<li><a name="a664"></a>                        <span class="src-key">foreach</span><span class="src-sym">(</span><span class="src-var">$views </span><span class="src-key">as </span><span class="src-var">$view</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a665"></a>                            <span class="src-var">$classMethods</span><span class="src-sym">[</span><span class="src-sym">] </span>= <span class="src-str">&quot;</span><span class="src-str">\t<span class="src-id">function</span> <span class="src-var">$view</span>() <span class="src-sym">{</span>\n\t<span class="src-sym">}</span></span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a666"></a>                        <span class="src-sym">}</span></li>
<li><a name="a667"></a>                        <span class="src-var">$classMethods </span>= <a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;\n\n&quot;</span><span class="src-sym">,</span><span class="src-var">$classMethods</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a668"></a>                    <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a669"></a>                        <span class="src-var">$classMethods </span>= <span class="src-str">&quot;</span><span class="src-str">\t<span class="src-id">function</span> <span class="src-var">$views</span>() <span class="src-sym">{</span>\n\t<span class="src-sym">}</span>\n\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a670"></a>                    <span class="src-sym">}</span></li>
<li><a name="a671"></a>                    <span class="src-var">$template </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">'[class_methods]'</span><span class="src-sym">,</span></li>
<li><a name="a672"></a>                                            <span class="src-var">$classMethods</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a673"></a>                <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a674"></a>&nbsp;</li>
<li><a name="a675"></a>                    <span class="src-comm">//  No view methods to add, so remove unneeded template</span></li>
<li><a name="a676"></a>                    <span class="src-var">$template </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">'[class_methods]'</span><span class="src-sym">, </span><span class="src-str">''</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a677"></a>                <span class="src-sym">}</span></li>
<li><a name="a678"></a>&nbsp;</li>
<li><a name="a679"></a>                <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$controller_file</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a680"></a>                    echo <span class="src-str">&quot;error creating controller class file: &quot;</span></li>
<li><a name="a681"></a>                        . <span class="src-var">$controller_file </span>. <span class="src-str">&quot;\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a682"></a>                <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a683"></a>                    echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">create</span> <span class="src-var">$controller_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a684"></a>                <span class="src-sym">}</span></li>
<li><a name="a685"></a>&nbsp;</li>
<li><a name="a686"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a687"></a>                echo <span class="src-str">&quot;error controller template file doesn't exist: &quot;</span></li>
<li><a name="a688"></a>                    . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$controller_template_file">controller_template_file</a> </span>. <span class="src-str">&quot;\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a689"></a>            <span class="src-sym">}</span></li>
<li><a name="a690"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a691"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">exists</span> <span class="src-var">$controller_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a692"></a>        <span class="src-sym">}</span></li>
<li><a name="a693"></a>    <span class="src-sym">}</span></li>
<li><a name="a694"></a>&nbsp;</li>
<li><a name="a695"></a>    <span class="src-doc">/**</span></li>
<li><a name="a696"></a><span class="src-doc">     *  Create a helper file for a controller</span></li>
<li><a name="a697"></a><span class="src-doc">     *</span></li>
<li><a name="a698"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$controller </span><span class="src-doc">Name of the controller</span></li>
<li><a name="a699"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> controller_class      Must be set before call.</span></li>
<li><a name="a700"></a><span class="src-doc">     *                               Not changed during call.</span></li>
<li><a name="a701"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> helper_path           Must be set before call.</span></li>
<li><a name="a702"></a><span class="src-doc">     *                               Not changed during call.</span></li>
<li><a name="a703"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> helper_template_file  Must be set before call.</span></li>
<li><a name="a704"></a><span class="src-doc">     *                               Not changed during call.</span></li>
<li><a name="a705"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@todo</span><span class="src-doc"> Should return succeed/fail indication</span></li>
<li><a name="a706"></a><span class="src-doc">     */</span></li>
<li><a name="a707"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodcreate_helper">create_helper</a><span class="src-sym">(</span><span class="src-var">$controller</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a708"></a>        <span class="src-var">$helper_file </span>= <span class="src-str">&quot;</span><span class="src-str"><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$helper_path">helper_path</a>/</span><span class="src-str">&quot;</span>.<span class="src-var">$controller</span>.<span class="src-str">&quot;_helper.php&quot;</span><span class="src-sym">;</span></li>
<li><a name="a709"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$helper_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a710"></a>            <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$helper_template_file">helper_template_file</a></span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a711"></a>                <span class="src-var">$template </span>= <a href="http://www.php.net/file_get_contents">file_get_contents</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$helper_template_file">helper_template_file</a></span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a712"></a>                <span class="src-var">$template </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">'[class_name]'</span><span class="src-sym">,</span></li>
<li><a name="a713"></a>                                        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$controller_class">controller_class</a></span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a714"></a>                <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$helper_file</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a715"></a>                    echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">error</span> <span class="src-id">creating</span> <span class="src-id">helper</span> <span class="src-id">file</span>: <span class="src-var">$helper_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a716"></a>                <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a717"></a>                    echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">create</span> <span class="src-var">$helper_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a718"></a>                <span class="src-sym">}</span></li>
<li><a name="a719"></a>&nbsp;</li>
<li><a name="a720"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a721"></a>                echo <span class="src-str">&quot;error helper template file doesn't exist: &quot;</span></li>
<li><a name="a722"></a>                    . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$helper_template_file">helper_template_file</a> </span>. <span class="src-str">&quot;\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a723"></a>            <span class="src-sym">}</span></li>
<li><a name="a724"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a725"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">exists</span> <span class="src-var">$helper_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a726"></a>        <span class="src-sym">}</span></li>
<li><a name="a727"></a>    <span class="src-sym">}</span></li>
<li><a name="a728"></a>&nbsp;</li>
<li><a name="a729"></a>    <span class="src-doc">/**</span></li>
<li><a name="a730"></a><span class="src-doc">     *  Create a view file if it doesn't exist</span></li>
<li><a name="a731"></a><span class="src-doc">     *</span></li>
<li><a name="a732"></a><span class="src-doc">     *  Create a view file in the Trax work area if the required file</span></li>
<li><a name="a733"></a><span class="src-doc">     *  does not yet exist.  Generate the view file contents by</span></li>
<li><a name="a734"></a><span class="src-doc">     *  customizing the view template file with information about the</span></li>
<li><a name="a735"></a><span class="src-doc">     *  controller and view names.</span></li>
<li><a name="a736"></a><span class="src-doc">     *</span></li>
<li><a name="a737"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$view </span><span class="src-doc">          Name of the view</span></li>
<li><a name="a738"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$controller </span><span class="src-doc">    Name of the controller</span></li>
<li><a name="a739"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> controller_class        Must be set before call.</span></li>
<li><a name="a740"></a><span class="src-doc">     *                                 Not changed during call.</span></li>
<li><a name="a741"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> view_file_extension     Must be set before call.</span></li>
<li><a name="a742"></a><span class="src-doc">     *                                 Not changed during call.</span></li>
<li><a name="a743"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> view_path               Must be set before call.</span></li>
<li><a name="a744"></a><span class="src-doc">     *                                 Not changed during call.</span></li>
<li><a name="a745"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> view_template_file      Must be set before call.</span></li>
<li><a name="a746"></a><span class="src-doc">     *                                 Not changed during call.</span></li>
<li><a name="a747"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@todo</span><span class="src-doc"> Should return succeed/fail indication</span></li>
<li><a name="a748"></a><span class="src-doc">     */</span></li>
<li><a name="a749"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodcreate_view">create_view</a><span class="src-sym">(</span><span class="src-var">$view</span><span class="src-sym">, </span><span class="src-var">$controller</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a750"></a>        <span class="src-var">$view_file </span>= <span class="src-str">&quot;</span><span class="src-str"><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../PHPonTrax/TraxGenerator.html#var$view_path">view_path</a>/</span><span class="src-str">&quot;</span>.<span class="src-var">$view</span>.<span class="src-str">&quot;.&quot;</span>.<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_file_extention">view_file_extention</a></span><span class="src-sym">;</span></li>
<li><a name="a751"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a752"></a>            <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_template_file">view_template_file</a></span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a753"></a>                <span class="src-var">$template </span>= <a href="http://www.php.net/file_get_contents">file_get_contents</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_template_file">view_template_file</a></span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a754"></a>                <span class="src-var">$template </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">'[class_name]'</span><span class="src-sym">,</span></li>
<li><a name="a755"></a>                                        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$controller_class">controller_class</a></span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a756"></a>                <span class="src-var">$template </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">'[controller]'</span><span class="src-sym">,</span><span class="src-var">$controller</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a757"></a>                <span class="src-var">$template </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">'[view]'</span><span class="src-sym">,</span><span class="src-var">$view</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a758"></a>                <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_put_contents">file_put_contents</a><span class="src-sym">(</span><span class="src-var">$view_file</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a759"></a>                    echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">error</span> <span class="src-id">creating</span> <span class="src-id">view</span> <span class="src-id">file</span>: <span class="src-var">$view_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a760"></a>                <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a761"></a>                    echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">create</span> <span class="src-var">$view_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a762"></a>                <span class="src-sym">}</span></li>
<li><a name="a763"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a764"></a>                echo <span class="src-str">&quot;error view template file doesn't exist: &quot;</span></li>
<li><a name="a765"></a>                    . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id"><a href="../PHPonTrax/TraxGenerator.html#var$view_template_file">view_template_file</a> </span>. <span class="src-str">&quot;\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a766"></a>            <span class="src-sym">}</span></li>
<li><a name="a767"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a768"></a>            echo <span class="src-str">&quot;</span><span class="src-str"><span class="src-id">exists</span> <span class="src-var">$view_file</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a769"></a>        <span class="src-sym">}</span></li>
<li><a name="a770"></a>    <span class="src-sym">}</span></li>
<li><a name="a771"></a>&nbsp;</li>
<li><a name="a772"></a>    <span class="src-doc">/**</span></li>
<li><a name="a773"></a><span class="src-doc">     *  Execute an operating system command</span></li>
<li><a name="a774"></a><span class="src-doc">     *</span></li>
<li><a name="a775"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$cmd </span><span class="src-doc"> Command to be executed</span></li>
<li><a name="a776"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@todo</span><span class="src-doc"> Replace with calls to filesystem methods</span></li>
<li><a name="a777"></a><span class="src-doc">     */</span></li>
<li><a name="a778"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodexec">exec</a><span class="src-sym">(</span><span class="src-var">$cmd</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a779"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-id">PHP_OS</span><span class="src-sym">, </span><span class="src-num">0</span><span class="src-sym">, </span><span class="src-num">3</span><span class="src-sym">) </span>== <span class="src-str">'WIN'</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a780"></a>            <a href="../PHPonTrax/TraxGenerator.html#methodexec">exec</a><span class="src-sym">(</span><a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;/&quot;</span><span class="src-sym">,</span><span class="src-str">&quot;\\&quot;</span><span class="src-sym">,</span><span class="src-var">$cmd</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a781"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a782"></a>            <a href="../PHPonTrax/TraxGenerator.html#methodexec">exec</a><span class="src-sym">(</span><span class="src-var">$cmd</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a783"></a>        <span class="src-sym">}</span></li>
<li><a name="a784"></a>    <span class="src-sym">}</span></li>
<li><a name="a785"></a>    </li>
<li><a name="a786"></a>    <span class="src-doc">/**</span></li>
<li><a name="a787"></a><span class="src-doc">     *  Replace &quot;&lt; ?php ... ? &gt;&quot; with &quot;&lt;?php ... ?&gt;&quot;</span></li>
<li><a name="a788"></a><span class="src-doc">     *</span></li>
<li><a name="a789"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$string </span><span class="src-doc"> String to be edited</span></li>
<li><a name="a790"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">Edited input string</span></li>
<li><a name="a791"></a><span class="src-doc">     */</span></li>
<li><a name="a792"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodfix_php_brackets">fix_php_brackets</a><span class="src-sym">(</span><span class="src-var">$string</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a793"></a>        <span class="src-key">return </span><a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;? &gt;&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;?&gt;&quot;</span><span class="src-sym">,</span></li>
<li><a name="a794"></a>                           <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;&lt; ?php&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;&lt;?php&quot;</span><span class="src-sym">, </span><span class="src-var">$string</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a795"></a>    <span class="src-sym">}</span></li>
<li><a name="a796"></a>&nbsp;</li>
<li><a name="a797"></a>    <span class="src-doc">/**</span></li>
<li><a name="a798"></a><span class="src-doc">     *  Output console help message for &quot;generate controller&quot;</span></li>
<li><a name="a799"></a><span class="src-doc">     */</span></li>
<li><a name="a800"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodcontroller_help">controller_help</a><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a801"></a>        echo <span class="src-str">&quot;Usage: php generate.php controller ControllerName [view1 view2 ...]\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a802"></a>        echo <span class="src-str">&quot;Description:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a803"></a>        echo <span class="src-str">&quot;\tThe controller generator creates functions for a new controller and\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a804"></a>        echo<span class="src-str">&quot;\tits views.\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a805"></a>        echo <span class="src-str">&quot;\tThe generator takes a controller name and a list of views as arguments.\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a806"></a>        echo <span class="src-str">&quot;\tThe controller name may be given in CamelCase or under_score and should\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a807"></a>        echo <span class="src-str">&quot;\tnot be suffixed with 'Controller'.  To create a controller within a\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a808"></a>        echo <span class="src-str">&quot;\tmodule, specify the controller name as 'folder/controller'.\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a809"></a>        echo <span class="src-str">&quot;\tThe generator creates a controller class in app/controllers with view\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a810"></a>        echo <span class="src-str">&quot;\ttemplates in app/views/controller_name.\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a811"></a>        echo <span class="src-str">&quot;Example:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a812"></a>        echo <span class="src-str">&quot;\tphp script/generate.php controller CreditCard open debit credit close\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a813"></a>        echo <span class="src-str">&quot;\tCredit card controller with URLs like /credit_card/debit.\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a814"></a>        echo <span class="src-str">&quot;\t\tController: app/controllers/credit_card_controller.php\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a815"></a>        echo <span class="src-str">&quot;\t\tViews:      app/views/credit_card/debit.phtml [...]\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a816"></a>        echo <span class="src-str">&quot;\t\tHelper:     app/helpers/credit_card_helper.php\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a817"></a>        echo <span class="src-str">&quot;Module/Folders Example:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a818"></a>        echo <span class="src-str">&quot;\tphp script/generate.php controller 'admin/credit_card' suspend late_fee\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a819"></a>        echo <span class="src-str">&quot;\tCredit card admin controller with URLs /admin/credit_card/suspend.\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a820"></a>        echo <span class="src-str">&quot;\t\tController: app/controllers/admin/credit_card_controller.php\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a821"></a>        echo <span class="src-str">&quot;\t\tViews:      app/views/admin/credit_card/suspend.phtml [...]\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a822"></a>        echo <span class="src-str">&quot;\t\tHelper:     app/helpers/credit_card_helper.php\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a823"></a>    <span class="src-sym">}</span></li>
<li><a name="a824"></a>&nbsp;</li>
<li><a name="a825"></a>    <span class="src-doc">/**</span></li>
<li><a name="a826"></a><span class="src-doc">     *  Output console help message for &quot;generate model&quot;</span></li>
<li><a name="a827"></a><span class="src-doc">     */</span></li>
<li><a name="a828"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodmodel_help">model_help</a><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a829"></a>        echo <span class="src-str">&quot;Usage: php generate.php model ModelName\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a830"></a>        echo <span class="src-str">&quot;Description:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a831"></a>        echo <span class="src-str">&quot;\tThe model generator creates functions for a new model.\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a832"></a>        echo <span class="src-str">&quot;\tThe generator takes a model name as its argument.  The model name\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a833"></a>        echo <span class="src-str">&quot;\tmay be given in CamelCase or under_score and should not be suffixed\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a834"></a>        echo <span class="src-str">&quot;\twith 'Model'. The generator creates a model class in app/models.\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a835"></a>        echo <span class="src-str">&quot;Example:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a836"></a>        echo <span class="src-str">&quot;\tphp script/generate.php model Account\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a837"></a>        echo <span class="src-str">&quot;\tThis will create an Account model:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a838"></a>        echo <span class="src-str">&quot;\t\tModel:      app/models/account.php\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a839"></a>    <span class="src-sym">}</span></li>
<li><a name="a840"></a>    </li>
<li><a name="a841"></a>    <span class="src-doc">/**</span></li>
<li><a name="a842"></a><span class="src-doc">     *  Output console help message for &quot;generate scaffold&quot;</span></li>
<li><a name="a843"></a><span class="src-doc">     */</span></li>
<li><a name="a844"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodscaffold_help">scaffold_help</a><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a845"></a>        echo <span class="src-str">&quot;Usage: php script/generate.php scaffold ModelName [ControllerName] [view1 view2 ...]\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a846"></a>        echo <span class="src-str">&quot;Description:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a847"></a>        echo <span class="src-str">&quot;\tThe scaffold generator creates a controller to interact with a model.\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a848"></a>        echo <span class="src-str">&quot;\tIf the model does not exist, it creates the model as well.  The\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a849"></a>        echo <span class="src-str">&quot;\tgenerated code is equivalent to the ( public \$scaffold = \&quot;model\&quot;; )\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a850"></a>        echo <span class="src-str">&quot;\tdeclaration, making it easy to migrate when you wish to customize\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a851"></a>        echo <span class="src-str">&quot;\tyour controller and views.\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a852"></a>        echo <span class="src-str">&quot;\tThe generator takes a model name, an optional controller name, and a\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a853"></a>        echo <span class="src-str">&quot;\tlist of views as arguments.  Scaffolded actions and views are created\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a854"></a>        echo <span class="src-str">&quot;\tautomatically.\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a855"></a>        echo <span class="src-str">&quot;\tThe auto scaffolded actions and views are:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a856"></a>        echo <span class="src-str">&quot;\t\tindex, show, add, edit, delete\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a857"></a>        echo <span class="src-str">&quot;\tIf a controller name is not given, the plural form of the model name\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a858"></a>        echo <span class="src-str">&quot;\twill be used.  The model and controller names may be given in CamelCase\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a859"></a>        echo <span class="src-str">&quot;\tor under_score and should not be suffixed with 'Model' or 'Controller'.\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a860"></a>        echo <span class="src-str">&quot;Example:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a861"></a>        echo <span class="src-str">&quot;\tphp script/generate.php scaffold Account Bank debit credit\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a862"></a>        echo <span class="src-str">&quot;\tThis will generate an Account model and BankController with a basic\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a863"></a>        echo <span class="src-str">&quot;\tuser interface.  Now create the accounts table in your database and\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a864"></a>        echo <span class="src-str">&quot;\t browse to http://localhost/bank/.  Voila, you're on Trax!\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a865"></a>        echo <span class="src-str">&quot;Module/Folders Example:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a866"></a>        echo <span class="src-str">&quot;\tphp script/generate.php scaffold CreditCard 'admin/credit_card' suspend late_fee\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a867"></a>        echo <span class="src-str">&quot;\tThis will generate a CreditCard model and CreditCardController\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a868"></a>        echo <span class="src-str">&quot;\tcontroller in the admin module.\n&quot;</span><span class="src-sym">;            </span></li>
<li><a name="a869"></a>    <span class="src-sym">}</span></li>
<li><a name="a870"></a>&nbsp;</li>
<li><a name="a871"></a>    <span class="src-doc">/**</span></li>
<li><a name="a872"></a><span class="src-doc">     *  Output console help message for unrecognized command</span></li>
<li><a name="a873"></a><span class="src-doc">     */</span></li>
<li><a name="a874"></a>    <span class="src-key">function </span><a href="../PHPonTrax/TraxGenerator.html#methodgenerator_help">generator_help</a><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a875"></a>        echo <span class="src-str">&quot;Usage:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a876"></a>        echo <span class="src-str">&quot;Generate Controller:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a877"></a>        echo <span class="src-str">&quot;php script/generate.php controller controller_name [view1 view2 ..]\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a878"></a>        echo <span class="src-str">&quot;for more controller info php script/generate.php controller\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a879"></a>        echo <span class="src-str">&quot;Generate Model:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a880"></a>        echo <span class="src-str">&quot;php script/generate.php model ModelName\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a881"></a>        echo <span class="src-str">&quot;for more model info php script/generate.php model\n\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a882"></a>        echo <span class="src-str">&quot;Generate Scaffold:\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a883"></a>        echo <span class="src-str">&quot;php script/generate.php scaffold ModelName [controller_name] [view1 view2 ...]\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a884"></a>        echo <span class="src-str">&quot;for more scaffold info php script/generate.php scaffold\n\n&quot;</span><span class="src-sym">;        </span></li>
<li><a name="a885"></a>    <span class="src-sym">}</span></li>
<li><a name="a886"></a><span class="src-sym">}</span></li>
<li><a name="a887"></a>&nbsp;</li>
<li><a name="a888"></a><span class="src-comm">// -- set Emacs parameters --</span></li>
<li><a name="a889"></a><span class="src-comm">// Local variables:</span></li>
<li><a name="a890"></a><span class="src-comm">// tab-width: 4</span></li>
<li><a name="a891"></a><span class="src-comm">// c-basic-offset: 4</span></li>
<li><a name="a892"></a><span class="src-comm">// c-hanging-comment-ender-p: nil</span></li>
<li><a name="a893"></a><span class="src-comm">// indent-tabs-mode: nil</span></li>
<li><a name="a894"></a><span class="src-comm">// End:</span></li>
<li><a name="a895"></a><span class="src-php">?&gt;</span></li>
</ol></pre></div>
</div>
        <div class="credit">
		    <hr />
		    Documentation generated on Thu, 04 May 2006 19:48:03 -0600 by <a href="http://www.phpdoc.org">phpDocumentor 1.3.0RC4</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>
Return current item: PHP on Trax