Location: PHPKode > scripts > Phramework > phramework/PhrameworkDocumentation.html
<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Word 10 (filtered)">
<title>Phramework</title>

<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:Times;
	panose-1:2 2 6 3 5 4 5 2 3 4;}
@font-face
	{font-family:"Lucida Sans Unicode";
	panose-1:2 11 6 2 3 5 4 2 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
h1
	{margin-top:12.0pt;
	margin-right:0in;
	margin-bottom:3.0pt;
	margin-left:0in;
	text-indent:0in;
	page-break-after:avoid;
	font-size:14.0pt;
	font-family:Tahoma;}
h2
	{margin-top:12.0pt;
	margin-right:0in;
	margin-bottom:3.0pt;
	margin-left:0in;
	text-indent:0in;
	page-break-after:avoid;
	font-size:13.0pt;
	font-family:Tahoma;
	font-style:italic;}
h3
	{margin-top:12.0pt;
	margin-right:0in;
	margin-bottom:3.0pt;
	margin-left:0in;
	text-indent:0in;
	page-break-after:avoid;
	font-size:11.0pt;
	font-family:Tahoma;}
h4
	{margin-top:12.0pt;
	margin-right:0in;
	margin-bottom:3.0pt;
	margin-left:0in;
	text-indent:0in;
	page-break-after:avoid;
	font-size:11.0pt;
	font-family:Times;}
p.MsoToc1, li.MsoToc1, div.MsoToc1
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoToc2, li.MsoToc2, div.MsoToc2
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:10.0pt;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoToc3, li.MsoToc3, div.MsoToc3
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:20.0pt;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoToc4, li.MsoToc4, div.MsoToc4
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:42.45pt;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoToc5, li.MsoToc5, div.MsoToc5
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:56.6pt;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoToc6, li.MsoToc6, div.MsoToc6
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:70.75pt;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoToc7, li.MsoToc7, div.MsoToc7
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:84.9pt;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoToc8, li.MsoToc8, div.MsoToc8
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:99.05pt;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoToc9, li.MsoToc9, div.MsoToc9
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:113.2pt;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoCaption, li.MsoCaption, div.MsoCaption
	{margin-top:6.0pt;
	margin-right:0in;
	margin-bottom:6.0pt;
	margin-left:0in;
	font-size:10.0pt;
	font-family:Tahoma;
	font-style:italic;}
p.MsoList, li.MsoList, div.MsoList
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:6.0pt;
	margin-left:0in;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoTitle, li.MsoTitle, div.MsoTitle
	{margin-top:12.0pt;
	margin-right:0in;
	margin-bottom:3.0pt;
	margin-left:0in;
	text-align:center;
	font-size:16.0pt;
	font-family:Tahoma;
	font-weight:bold;}
p.MsoBodyText, li.MsoBodyText, div.MsoBodyText
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:6.0pt;
	margin-left:0in;
	font-size:10.0pt;
	font-family:Tahoma;}
p.MsoSubtitle, li.MsoSubtitle, div.MsoSubtitle
	{margin-top:12.0pt;
	margin-right:0in;
	margin-bottom:6.0pt;
	margin-left:0in;
	text-align:center;
	page-break-after:avoid;
	font-size:14.0pt;
	font-family:Arial;
	font-style:italic;}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:maroon;
	text-decoration:underline;}
span.Heading4Char
	{font-family:Times;
	font-weight:bold;}
p.Index, li.Index, div.Index
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.Heading, li.Heading, div.Heading
	{margin-top:12.0pt;
	margin-right:0in;
	margin-bottom:6.0pt;
	margin-left:0in;
	page-break-after:avoid;
	font-size:14.0pt;
	font-family:Arial;}
p.ContentsHeading, li.ContentsHeading, div.ContentsHeading
	{margin-top:12.0pt;
	margin-right:0in;
	margin-bottom:6.0pt;
	margin-left:0in;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:Arial;
	font-weight:bold;}
p.Contents10, li.Contents10, div.Contents10
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:127.35pt;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.TableContents, li.TableContents, div.TableContents
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:Tahoma;}
p.TableHeading, li.TableHeading, div.TableHeading
	{margin:0in;
	margin-bottom:.0001pt;
	text-align:center;
	font-size:10.0pt;
	font-family:Tahoma;
	font-weight:bold;
	font-style:italic;}
 /* Page Definitions */
 @page Section1
	{size:8.5in 11.0in;
	margin:.5in .5in .5in .5in;}
div.Section1
	{page:Section1;}
@page Section2
	{size:8.5in 11.0in;
	margin:.5in .5in .5in .5in;}
div.Section2
	{page:Section2;}
@page Section3
	{size:8.5in 11.0in;
	margin:.5in .5in .5in .5in;}
div.Section3
	{page:Section3;}
@page Section4
	{size:8.5in 11.0in;
	margin:.5in .5in .5in .5in;}
div.Section4
	{page:Section4;}
@page Section5
	{size:8.5in 11.0in;
	margin:.5in .5in .5in .5in;}
div.Section5
	{page:Section5;}
 /* List Definitions */
 ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
-->
</style>

</head>

<body bgcolor=white lang=EN-US link=blue vlink=maroon>

<div class=Section1>

<p class=MsoTitle>Phramework</p>

</div>

<b><span style='font-size:16.0pt;font-family:Tahoma'><br clear=all
style='page-break-before:auto'>
</span></b>

<div class=Section2>

<p class=ContentsHeading>Table of Contents</p>

</div>

<b><span style='font-size:16.0pt;font-family:Arial'><br clear=all
style='page-break-before:auto'>
</span></b>

<div class=Section3>

<p class=MsoToc1>License....................................................................................................................................................................... 1</p>

<p class=MsoToc1>Introduction................................................................................................................................................................ 2</p>

<p class=MsoToc1>Installation.................................................................................................................................................................. 2</p>

<p class=MsoToc2>index.php................................................................................................................................................................ 2</p>

<p class=MsoToc2>config.properties...................................................................................................................................................... 2</p>

<p class=MsoToc1>Concept...................................................................................................................................................................... 2</p>

<p class=MsoToc1>Main Methods.............................................................................................................................................................. 2</p>

<p class=MsoToc2>import($path).......................................................................................................................................................... 2</p>

<p class=MsoToc1>Classes....................................................................................................................................................................... 3</p>

<p class=MsoToc2>Action class............................................................................................................................................................. 3</p>

<p class=MsoToc3>execute() Method.................................................................................................................................................. 3</p>

<p class=MsoToc2>ActionResult class..................................................................................................................................................... 3</p>

<p class=MsoToc3>ActionResult($mapping, $data) Constructor............................................................................................................. 3</p>

<p class=MsoToc2>View class............................................................................................................................................................... 3</p>

<p class=MsoToc3>processView($data) Method................................................................................................................................... 3</p>

<p class=MsoToc2>ViewPlugin class....................................................................................................................................................... 3</p>

<p class=MsoToc3>init($params) Method............................................................................................................................................ 4</p>

<p class=MsoToc3>destroy() Method.................................................................................................................................................. 4</p>

<p class=MsoToc3>processView($viewValue, $data) Method................................................................................................................ 4</p>

<p class=MsoToc2>PropertiesParser class.............................................................................................................................................. 4</p>

<p class=MsoToc3>getProperty($key, $default=null, $split=false) Method.............................................................................................. 4</p>

<p class=MsoToc3>containsKey($key)................................................................................................................................................. 4</p>

<p class=MsoToc1>Configuration.............................................................................................................................................................. 4</p>

<p class=MsoToc2>config.properties (revisited)....................................................................................................................................... 4</p>

<p class=MsoToc3>Replacement Areas............................................................................................................................................... 4</p>

<p class=MsoToc3>Phramework Specific Properties............................................................................................................................. 4</p>

<p class=MsoToc4>phramework.config.files................................................................................................................................. 4</p>

<p class=MsoToc4>phramework.classpath................................................................................................................................... 5</p>

<p class=MsoToc4>phramework.import.extensions....................................................................................................................... 5</p>

<p class=MsoToc4>phramework.page.identifier............................................................................................................................ 5</p>

<p class=MsoToc3>Action Properties.................................................................................................................................................. 5</p>

<p class=MsoToc3>View Properties.................................................................................................................................................... 5</p>

<p class=MsoToc3>ViewPlugin Properties............................................................................................................................................ 5</p>

<p class=MsoToc4>.extensions property...................................................................................................................................... 5</p>

<p class=MsoToc4>.initparams property...................................................................................................................................... 6</p>

<p class=MsoToc3>User Defined Properties......................................................................................................................................... 6</p>

<p class=MsoToc1>Examples.................................................................................................................................................................... 6</p>

<p class=MsoToc2>Hello World Example (Part 1)..................................................................................................................................... 6</p>

<p class=MsoToc2>Hello World Example (Part 2)..................................................................................................................................... 8</p>

<p class=MsoToc3>Setup.................................................................................................................................................................. 9</p>

<p class=MsoToc3>Application........................................................................................................................................................... 9</p>

<p class=MsoToc1>Conclusion................................................................................................................................................................ 13</p>

<p class=MsoToc1>Appendix I: Tips And Tricks........................................................................................................................................ 13</p>

<p class=MsoToc2>Make Use Of Phramework's Classpath...................................................................................................................... 14</p>

</div>

<span style='font-size:10.0pt;font-family:Tahoma'><br clear=all
style='page-break-before:auto'>
</span>

<div class=Section4></div>

<b><span style='font-size:16.0pt;font-family:Arial'><br clear=all
style='page-break-before:auto'>
</span></b>

<div class=Section5>

<h1 style='margin-left:0in;text-indent:0in'>License</h1>

<p class=MsoNormal>Phramework Copyright (C) 2005 GodsArmor.com </p>

<p class=MsoNormal> </p>

<p class=MsoNormal>This library is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the License,
or (at your option) any</p>

<p class=MsoNormal>later version.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>This library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to theFree Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>

<h1 style='margin-left:0in;text-indent:0in'>Introduction</h1>

<p class=MsoNormal>Phramework is a PHP framework that follows the MVC framework
for web applications.  It very loosely follows the Struts framework in its
terminology and was developed so that there would only be two mandatory files
that would need to be included for the framework.  This makes the code slightly
less readable, but makes installation a breeze.</p>

<h1 style='margin-left:0in;text-indent:0in'>Installation</h1>

<p class=MsoNormal>There are two files that need to be included for Phramework
to be a complete installation.  The first is called index.php and the second is
config.properties</p>

<h2 style='margin-left:0in;text-indent:0in'>index.php</h2>

<p class=MsoNormal>This file contains the actual Phramework code, acts as the
controller for the web application and is the entry point for every request
that should be handled by Phramework.  This file contains a number of classes
and utility functions that can be used by other parts of the web application.</p>

<h2 style='margin-left:0in;text-indent:0in'>config.properties</h2>

<p class=MsoNormal>This file contains all the configuration information about
the web application including Phramework actions, views, plugins and other web
application specific configuration data.  This will be explained later.</p>

<h1 style='margin-left:0in;text-indent:0in'>Concept</h1>

<p class=MsoNormal>Phramework initially started out as a very simple method of
creating PHP namespaces.  I wanted an ‘import’ function that I could pass a
fully qualified class name and ‘require_once’ that class.  As I got more and
more into it, I found I needed more and more configuration information.  One
thing led to another and Phramework was born.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Phramework uses an MVC architecture where Phramework is the
controller, and you the developer build the model and view.  When Phramework
receives a request, it determines which Action class it should send the request
to based on information in the config.properties file.  The Action returns an
ActionResult object which contains data and a view mapping.  Phramework then
matches the view mapping to a value in the config.properties file and calls the
class that should render the view.  This class either extends the View object
or can be a ViewPlugin.  ViewPlugins have been written so that other view
methods can be used, such as static html, Smarty templates, XSLT, etc.</p>

<h1 style='margin-left:0in;text-indent:0in'>Main Methods</h1>

<h2 style='margin-left:0in;text-indent:0in'>import($path)</h2>

<p class=MsoNormal>This method is not part of any class and is available to any
class.  It is used to import classes into the web application.  It uses the
same constructs as importing a Java class.  You can import a class by calling
import with the path to the class as a string variable to the method.  For
example if you call import(‘com.myname.myclasses.AClass’) import will attempt
to look in the ‘com/myname/myclasses’ directory for a class called AClass.php
(extension configurable; see phramework.import.extensions in the configuration
section).  The import method heavily utilizes the ‘import_path’ ini variable
which means that you can put your classes in a secured area outside of your web
site and include that path in the ‘import_path’ ini variable.  Phramework will
append the subpath (i.e. ‘com/myname/myclasses’) to import_path items and
attempt to find the AClass.php file.  Once found, the import method will
‘require_once’ the class and return its name to the caller.  The main
constraints of this method is that the $path must exist in the ‘include_path’
and that the name of the class must be the same as the name of the file.  So,
AClass.php must contain a class called AClass.  Otherwise the require_once will
fail.  See the phramework.classpath configuration property for more information.</p>

<h1 style='margin-left:0in;text-indent:0in'>Classes</h1>

<p class=MsoNormal>The following are classes that are used by Phramework in a
request lifecycle.</p>

<h2 style='margin-left:0in;text-indent:0in'>Action class</h2>

<p class=MsoNormal>The action class handles processing the request from the
browser.  This is the first non-Phramework class that gets called.  It’s job is
to process the request and then send the result (in an ActionResult class) back
to Phramework.  Any action defined in the config.properties file must extend
the Action class.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Phramework will call the no argument constructor for the
subclass of the Action class and then call its execute() method.</p>

<h3 style='margin-left:0in;text-indent:0in'>execute() Method</h3>

<p class=MsoNormal>The execute method is called by Phramework.  It has no
parameters.  The Action class should access GET or POST variables via the
$_GET, $_POST or $_REQUEST global variables.  I prefer $_REQUEST since is
doesn’t require that the user know the method of the request.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Once the execute method has done its processing it should
return an object of type ActionResult.</p>

<h2 style='margin-left:0in;text-indent:0in'>ActionResult class</h2>

<p class=MsoNormal>The ActionResult class is nothing more than a placeholder
for data returned by a subclass of the Action class as well as a mapping for
the view.  There is no need to subclass this class.  Instead, the execute
method of the Action class should create a new instance of this class, passing
in the data to return to the user as well as a string value identifying a
mapping for the action in order for the view to be generated.</p>

<h3 style='margin-left:0in;text-indent:0in'>ActionResult($mapping, $data)
Constructor</h3>

<p class=MsoNormal>The constructor for the ActionResult class takes a $mapping
which is a string that maps to a specific view for this action as well as any
data that the view class needs to process it’s view.  The data is not of any
type.  It can be an array, a string of XML a set of objects, even null.  In
this way, the controller is not tied to any particular method of generating a
view.  The model knows what type of data its view needs in order to show a
proper page to the user.  In fact, multiple methods can be used in the same web
application.</p>

<h2 style='margin-left:0in;text-indent:0in'>View class</h2>

<p class=MsoNormal>There are two ways to generate a view.  The first way is via
a PHP class.  The class must extend the View class.  Its job would be to take
the data from the ActionResult class and echo output to the browser (most
likely HTML).  Phramework will create an instance of the View subclass via its
no argument constructor and call its processView($data) method.</p>

<h3 style='margin-left:0in;text-indent:0in'>processView($data) Method</h3>

<p class=MsoNormal>This is the method that will process the view that is sent
back to the browser.  At the point of this method call, no headers have been
sent to the browser, so if necessary it can be done here.  Phramework doesn’t
have any idea as to what this method will echo to the browser and frankly
doesn’t care.  It could be HTML, text, XML, pig latin, whatever.  The $data is
the same data that was passed to Phramework from the Action subclass via the
ActionResult class.</p>

<h2 style='margin-left:0in;text-indent:0in'>ViewPlugin class</h2>

<p class=MsoNormal>I later found out that using a class to output HTML to the
browser was not the smartest method of output because it coupled PHP with HTML
in a reverse method of how it is generally done.  I wanted to decouple the view
from the code further, so I created the ViewPlugin class.  View plugins are
subclasses of the ViewPlugin class and define a method of generating a view
depending on the value of the mapping result.  Phramework will look at the
extension of the view mapping value and then look for a plugin that would
handle the view for that extension.  For example, you could define a
SmartyPlugin in your configuration file and assign it to be used whenever the
view mapping has a .tpl extension.  Or you could define an XsltPlugin and
assign it to be used whenever the view mapping has a .xslt extension.  It’s up
to you.  I have defined reusable plugins for static HTML, Smarty and XSLT, but
other plugins could be defined.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Phramework will create a new instance of the plugin using
its no argument constructor, call its init($params) method to initialize the
plugin, call its processView($viewValue, $data) method to generate the view and
finally call its destroy method for any cleanup that the plugin should do.</p>

<h3 style='margin-left:0in;text-indent:0in'>init($params) Method</h3>

<p class=MsoNormal>This method is used to initialize the plugin.  You define
initialization parameters in the configuration file for the plugin and those
parameters are passed into this method.  More information can be found in the
configuration section.</p>

<h3 style='margin-left:0in;text-indent:0in'>destroy() Method</h3>

<p class=MsoNormal>This method is used to do any cleanup that the plugin should
do after it has generated the view.  This could include unsetting any
variables, etc.</p>

<h3 style='margin-left:0in;text-indent:0in'>processView($viewValue, $data)
Method</h3>

<p class=MsoNormal>This method does the work for creating the view.  The
$viewValue variable contains the value that was found for the view mapping. 
Again it is up to the view and the action as to what is contained in this
value, but for example, in a SmartyPlugin, this would most likely contain the
template to generate.  The $data variable contains the data that was passed
back to Phramework by the Action in the ActionResult object.</p>

<h2 style='margin-left:0in;text-indent:0in'>PropertiesParser class</h2>

<p class=MsoNormal>This class is used to parse the properties file.  Once the
file(s) have been parsed, an instance of this object is put into
$GLOBALS[&quot;properties&quot;] so any part of the web application can get to
it.  This allows you to put application configuration information in the
properties file for your convenience such as database connectivity information,
timestamp formatting, etc.</p>

<h3 style='margin-left:0in;text-indent:0in'>getProperty($key, $default=null,
$split=false) Method</h3>

<p class=MsoNormal>This method will return the value of a key in the properties
file passed in the $key variable.  If the $key property is not found, the
$default value will be returned.  Finally, the configuration file can contain
pipe separated (|) values.  If the $split variable contains true, the value of
the property will be split on the pipe separator (|) and will be returned as an
array of values.  The default is false which means the value found for the
property will be returned as a string value.</p>

<h3 style='margin-left:0in;text-indent:0in'>containsKey($key)</h3>

<p class=MsoNormal>This method returns true if there is a property in the
properties file with the value of $key or false if not.</p>

<h1 style='margin-left:0in;text-indent:0in'>Configuration</h1>

<h2 style='margin-left:0in;text-indent:0in'>config.properties (revisited)</h2>

<p class=MsoNormal>The config.properties file is where all the configuration
information goes for your entire web application.  In addition to Phramework
specific information it also allows global accessibility to your web classes
via $GLOBALS[&quot;properties&quot;].  This means you can put application
specific data in your config.properties file and grab it via the
PropertiesParser class.  You can also have multiple config.properties files in
different locations.  The only mandatory file is config.properties and it must
reside in the same directory as index.php.  Inside config.properties you can
define the location of other properties files and they will be read in and
appended to the list of properties.</p>

<h3 style='margin-left:0in;text-indent:0in'>Replacement Areas</h3>

<p class=MsoNormal>You can also define replacement areas where the results of
one property will replace a portion of the value of another property.  The
delimiters for a replacement area is ${ and }  Suppose I had a property called
‘my.first.property’ with a value of ‘abc’.  Then suppose I had another property
called ‘a.different.property’ with a value of ‘${my.first.property}def’.  When
accessing the ‘a.different.property’ key, the value returned would be the
result of replacing the ${…} with the value of that property.  Thus the
returned value for ‘a.different.property’ would be ‘abcdef’.  It is not
necessary for the replacement property to be defined before the property to be
replaced.</p>

<h3 style='margin-left:0in;text-indent:0in'>Phramework Specific Properties</h3>

<h4 style='margin-left:0in;text-indent:0in'>phramework.config.files</h4>

<p class=MsoNormal style='margin-left:0in;text-indent:0in'>Phramework allows
you to have multiple configuration files for an individual application.  The
benefits to this are twofold. First, it allows you to separate application
configuration from Phramework configuration.  This, for example, means you
could have database access information stored in its own configuration file
that could be used by multiple applications. Second, it allows for a more
secure application because you could store sensitive information outside of the
application's web path and tell Phramework where to access that information.</p>

<p class=MsoNormal style='margin-left:0in;text-indent:0in'>&nbsp;</p>

<p class=MsoNormal style='margin-left:0in;text-indent:0in'>Tip: For a very
secure application, only put this configuation parameter in the
config.properties file and have it point to multiple files outside of your web
path to gather the remaining information.  If a user decides to look at your
config.properties file, all he will be able to see is the path to the other
configuration files.</p>

<h4 style='margin-left:0in;text-indent:0in'>phramework.classpath</h4>

<p class=MsoNormal>Phramework heavily utilizes the ‘include_path’ which has
been re-coined classpath in this instance.  All classes, files, images, etc.
should be accessible via the ‘include_path’ PHP ini variable.  Phramework looks
for each class in a subdirectory of its set of ‘include_path’s.  So if you are
including a class ‘com.myclasses.someapp.AClass’, Phramework assumes that there
will be a file called AClass.php (extension configurable; see
phramework.import.extensions) in the com/myclasses/someapp subdirectory and the
‘com’ directory must be at the root of one of the ‘include_path’ entries.  It’s
almost exactly how Java handles including classes and namespaces.  This allows
you to put your application classes in a secured area outside of the web site
and still access the code.  It only requires that the root directory is on the
‘include_path’.</p>

<h4 style='margin-left:0in;text-indent:0in'>phramework.import.extensions</h4>

<p class=MsoNormal>This allows you to define what extensions are valid for
filenames when using the import($path) method.  It can be a pipe separated (|)
set of values.  For example, if you have this property set to
‘php|class.php|inc.php|class’ and try to import a class
‘com.myclasses.someapp.AClass’ the Phramework will look for files in the
‘com/myclasses/someapp’ directory called either AClass.php, AClass.class.php,
AClass.inc.php or AClass.class.  The first one it finds will be used as the
file to import.  For performance reasons, it would be best to limit the number
of extensions as much as possible.</p>

<h4 style='margin-left:0in;text-indent:0in'>phramework.page.identifier</h4>

<p class=MsoNormal>This configuration options defines the request variable that
should be queried to find out what Action class should be called.  If set to
‘action’ for example, Phramework will look in $_REQUEST[‘action’] for the
identifier of the Action subclass that should be used.</p>

<h3 style='margin-left:0in;text-indent:0in'>Action Properties</h3>

<p class=MsoNormal>All actions must have an action property associated with
them.  Based on the value of the phramework.page.identifier key the framework
will choose an action to perform.  For example if the action request variable
is 'editPage' the phramework will search for an action called ‘action.editPage’
and run the class on that action.  If no action request variable is passed in
to the page, Phramework will run the action.default action.  So, action.default
should always be defined to execute some action.  Actions must extend the
Action class defined by the phramework.  See the Action Class section earlier.</p>

<h3 style='margin-left:0in;text-indent:0in'>View Properties</h3>

<p class=MsoNormal>When an action has completed its processing, it needs to
forward information to a particular view by passing a &quot;mapping&quot; value
back to Phramework.  This value is a string that will be appended to the action
request variable and searched for as a key in this config file.  For example,
if the action is 'editPage' and the class for edit page returned 'success',
Phramework look for a view called view.editPage.success.  If it could not be
found, Phramework will then look for global.view.success.  An action specific
view will always take precedence over a global view.  Views must extend the
View class defined by Phramework.  See the View Class section earlier.</p>

<h3 style='margin-left:0in;text-indent:0in'>ViewPlugin Properties</h3>

<p class=MsoNormal>View plugins allow views to be generated by methods other
than php classes.  By default and if there are no plugins defined the view for
the action will imported into Phramework as a PHP class that extends the View
class defined by Phramework and its processView method will be executed.  If
view plugins are defined and the extension of the view mapping matches the
extension for the plugin, the plugin will be imported and loaded and its
processView method will be called.  View plugins must extend the ViewPlugin
class defined by Phramework.  Each plugin must also define the extensions that
it will handle.  That is how Phramework knows to pass the view to the plugin. 
You can also pass in initialization parameters to the plugin which will be
passed in to the plugin via the init($params) method of the ViewPlugin subclass. 
See the ViewPlugin Class section earlier.</p>

<h4 style='margin-left:0in;text-indent:0in'>.extensions property</h4>

<p class=MsoNormal>These are the extensions that this plugin will process.  It
can be a pipe separated list of extensions without the ‘.’.  If the plugin name
is ‘smarty’, the plugin property would be defined as viewplugin.smarty and its
extensions would be defined in the viewplugin.smarty.extensions property.</p>

<h4 style='margin-left:0in;text-indent:0in'>.initparams property</h4>

<p class=MsoNormal>These are the initialization parameters that should be
passed to the plugin when the init($params) method is called.  They will be
passed in as an array of key value pairs where the key is the item after
‘iniparams’ and the value is the value of the property.  For example if the
plugin name is ‘smarty’, the plugin property would be defined as
viewplugin.smarty and a sample initialization parameter would be defined as
viewplugin.smarty.initparams.template_dir.  In the associative array passed to
the init($params) method, the key would be ‘template_dir’ and the value would
be the value of the property found in ‘viewplugin.smarty.initparams.template_dir’. 
All initparams must contain a key.  So, ‘viewplugin.smarty.initparams’ is
invalid but ‘viewplugin.smarty.initparams.template_dir’ is valid.</p>

<h3 style='margin-left:0in;text-indent:0in'>User Defined Properties</h3>

<p class=MsoNormal>As long as they do not conflict with any of the above
properties, any other key/value pair is valid in the configuration file.  Your
application can access these variables via the getProperty method of the
$_GLOBALS[“properties”] global variable.  See the getProperty($key,
$default=null, $split=false) section described above.</p>

<h1 style='margin-left:0in;text-indent:0in'>Examples</h1>

<h2 style='margin-left:0in;text-indent:0in'>Hello World Example (Part 1)</h2>

<p class=MsoNormal>For me, the easiest way to learn something is to have an
example, so let’s jump in with the classic Hello World example.  This example
will display a page for the user to type in his name and then will display a
hello &lt;name&gt; message.  A working version of this example can be found at <a
href="http://www.godsarmor.com/phramework/example1">http://www.godsarmor.com/phramework/example1</a>. 
The code for this example can be found at <a
href="http://www.godsarmor.com/phramework/example1/example1.zip">http://www.godsarmor.com/phramework/example1/example1.zip</a>. 
To get it working on your server, simply unzip the file to a location on your
web server and change the value of the 'example.path' configuration property in
config.properties to the full path where you unzipped the files.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>We will make the following assumptions:</p>

<ol style='margin-top:0in' start=1 type=1>
 <li class=MsoNormal>The index.php and config.properties file reside in the
     same directory under /home/user/public_html/example1.</li>
 <li class=MsoNormal>You have the ability to modify the ‘include_path’ ini
     variable on the fly (most web hosts allow this).</li>
</ol>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>The first thing we need to do is define what identifier
should be used to determine the action to perform.  Let’s use ‘action’.  To do
this change (or add) the phramework.page.identifier configuration property in
config.properties and set it to the value ‘action’ (i.e.
phramework.page.identifier=action).</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>We next need to tell Phramework which extensions it should
look for when importing class files.  In our case we will name all files with a
.php extension just to make it simple.  To do this create a key in the
properties file called 'phramework.import.extensions' and set the value equal
to 'php'.  Do not include the '.'.  Just include the extension.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Next we need to define what class should be called when the
default action (or no action) is passed in.  Let’s create a class called
DefaultAction and put it in the following location relative to your public_html
directory; classes/com/example1/actions/DefaultAction.php.  We know this page
will just be a static html page, so we don’t need to do anything in the Action
class, we can just hand it off to the View class.  So the class is very
skeletal.  Here’s an example of what the DefaultAction could look like:</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-1.0pt;border-collapse:collapse'>
 <tr style='height:152.25pt'>
  <td width=737 valign=top style='width:552.8pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt;height:152.25pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>&lt;?php</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>class
  DefaultAction extends Action {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  DefaultAction() {}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  execute() {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $mapping =
  &quot;success&quot;;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $data =
  null;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        return new
  ActionResult($mapping, $data);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>?&gt;</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>What does that $mapping = “success” line mean?  Good
question.  Let’s put that on the back burner for later.  Save the file and we
are done with the action.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Now let’s create a view that will display the default page. 
Let’s put this in classes/com/example1/views/DefaultView.php.  This again will
just spit out some very generic code and can look something like this:</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-1.0pt;border-collapse:collapse'>
 <tr style='height:140.0pt'>
  <td width=737 valign=top style='width:552.8pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt;height:140.0pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>&lt;?php</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>class DefaultView
  extends View {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  DefaultView() {}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  processView($data) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            echo
  &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Hello World Example
  1&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&quot;;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            echo
  &quot;&lt;form action=\&quot;index.php\&quot;
  method=\&quot;POST\&quot;&gt;Type your name: &lt;input
  type=\&quot;text\&quot; name=\&quot;name\&quot;/&gt;&quot;;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            echo
  &quot;&lt;input type=\&quot;hidden\&quot; name=\&quot;action\&quot;
  value=\&quot;showHello\&quot;&lt;/form&gt;&quot;;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            echo
  &quot;&lt;/body&gt;&lt;/html&gt;&quot;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>?&gt;</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Take note of the hidden input variable.  This variable has a
name of “action” and a value of “showHello”.  These will be used later.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Now we need to set up the config.properties file so that the
classes we just created are in Phramework's classpath and so Phramework can
call the correct classes for the appropriate actions.  Since we put all of our classes
in /home/user/public_html/classes, we need to add that path to our
phramework.classpath property.  Then when Phramework attempts to import
'com.example1.views.DefaultView, it will find it correctly.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>In this case we are dealing with the default action (an
request with no action property is defined as the default action) so we need to
set up the default action to call the 'com.example1.actions.DefaultAction'
class.  Therefore, set the 'action.default' key to
'com.example1.actions.DefaultAction'.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>If we look back at the DefaultAction class shown earlier, we
see that the ActionResult passed back has a $mapping equal to 'success'.  What
this means is that Phramework should look for a 'success' view mapping for the
default action mapping.  So Phramwork will look for a view.default.success key
in the properties file and call the class that it corresponds to.  In order to
make this mapping, add a key of 'view.default.success' with a value of
'com.example1.views.DefaultView'.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>This is enough right now to run the application.  If you
open your browser and navigate to the index.php Phramework page, you should get
a page similar to the one below.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>

<table cellpadding=0 cellspacing=0 align=left>
 <tr>
  <td width=208 height=0></td>
 </tr>
 <tr>
  <td></td>
  <td><img width=303 height=59 src="http://www.godsarmor.com/phramework/image001.gif"></td>
 </tr>
</table>

<br clear=ALL>
</p>

<p class=MsoNormal>Looking at the source of the page we notice two things that
are important.  The first is the hidden form field called action with a value
of 'showHello' and the text input with a name of 'name'.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Next we need to write the classes to handle when the user
submits the form.  Let's create a class in the com/example1/actions subfolder. 
And let's call it SubmitFormAction.  Below is an example of what the class
would look like:</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-1.0pt;border-collapse:collapse'>
 <tr style='height:152.25pt'>
  <td width=737 valign=top style='width:552.8pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt;height:152.25pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>&lt;?php</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>class
  SubmitFormAction extends Action {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  SubmitFormAction() {}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  execute() {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $mapping =
  &quot;success&quot;;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $data =
  $_REQUEST['name'];</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        return new
  ActionResult($mapping, $data);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>?&gt;</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Notice that we are setting the $data variable to the value
that the user typed in and that we are setting the $mapping variable to
'success' (again).</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>We can also create a new class called SubmitFormView which
will display write out the web page to the browser.  So, we'll create another
class in the com/example1/views directory called SubmitFormView.php.  Below is
an example of the view class.</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-1.0pt;border-collapse:collapse'>
 <tr style='height:104.75pt'>
  <td width=737 valign=top style='width:552.8pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt;height:104.75pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>&lt;?php</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>class
  SubmitFormView extends View {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  SubmitFormView() {}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  processView($data) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            echo
  &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Hello World Example
  1&lt;/title&gt;&lt;/head&gt;&lt;body&gt;Hello
  $data!&lt;/body&gt;&lt;/html&gt;&quot;;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>?&gt;</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Notice that we are using the value that the action class set
the $data variable to to print out the typed in information.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>To set up the configuration, we need to add another action
and view.  From viewing the source of the initial page, we see that the action
is going to be called 'showHello'.  So we need to set up an action called
'action.showHello' and set its value equal to
'com.example1.actions.SubmitFormAction'.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>The SubmitFormAction maps to a view called 'success'. 
Therefore we need to set up a view with a key of 'view.showHello.success' and
set its value to 'com.example1.views.SubmitFormView'.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>After filling out the form and hitting the return key, you
should see a page similar to the following:</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>

<table cellpadding=0 cellspacing=0 align=left>
 <tr>
  <td width=284 height=0></td>
 </tr>
 <tr>
  <td></td>
  <td><img width=151 height=55 src="http://www.godsarmor.com/phramework/image002.gif"></td>
 </tr>
</table>

<br clear=ALL>
</p>

<p class=MsoNormal>This should give a good start in creating web applications
using Phramework.  Continue on to Example 2 to replace the view classes with
ViewPlugin classes.</p>

<h2 style='margin-left:0in;text-indent:0in'>Hello World Example (Part 2)</h2>

<p class=MsoNormal>In this example we will create the same example from Part 1
and replace the View classes with ViewPlugin classes.  A working version of
this example can be found at <a
href="http://www.godsarmor.com/phramework/example2">http://www.godsarmor.com/phramework/example2</a>. 
The code for this example can be found at <a
href="http://www.godsarmor.com/phramework/example2/example2.zip">http://www.godsarmor.com/phramework/example2/example2.zip</a>. 
To get it working on your server, simply unzip the file to a location on your
web server and change the value of the 'example.path' configuration property in
config.properties to the full path where you unzipped the files.  This example
uses view plugins to generate the view and specifically uses an HTML view
plugin and a Smarty view plugin.  The zip file not only contains the example,
but it also contains the <a href="http://smarty.php.net/">Smarty template
engine</a> for ease of setup.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Again, like in example 1, we will make the following
assumptions:</p>

<ol style='margin-top:0in' start=1 type=1>
 <li class=MsoNormal>The index.php and config.properties file reside in the
     same directory under /home/user/public_html/example2.</li>
 <li class=MsoNormal>You have the ability to modify the ‘include_path’ ini
     variable on the fly (most web hosts allow this).</li>
</ol>

<h3 style='margin-left:0in;text-indent:0in'>Setup</h3>

<p class=MsoNormal>Let's do some initial setup for Smarty to begin with. 
Download Smarty (<a href="http://smarty.php.net/">http://smarty.php.net</a>)
and unzip it to a temporary folder.  In a folder called 'lib/Smarty' in
'/home/user/public_html/example2' take the contents of the 'lib' directory from
your temporary folder and upload it.  Underneath the
'/home/user/public_html/example2/lib/Smarty' directory there should be two
other directories, 'internals' and 'plugins' as well as the actual Smarty
classes.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Next we need to set up the location of the compiled Smarty
templates and cache files.  In '/home/user/public_html/example2' create
subdirectories called 'smartyfiles/cache', 'smartyfiles/config' and
'smartyfiles/templates_c'.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Smarty should be set up properly at this point and we can
get on to the real application.</p>

<h3 style='margin-left:0in;text-indent:0in'>Application</h3>

<p class=MsoNormal>Let's start by creating the HTML page that should be shown
when the user opens his browser and navigates to the example2 directory.  This
is just a static HTML page and could look like the example below:</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:2.75pt;border-collapse:collapse'>
 <thead>
  <tr>
   <td width=720 valign=top style='width:540.25pt;border:solid black 1.0pt;
   background:#FFFF99;padding:2.75pt 2.75pt 2.75pt 2.75pt'>
   <p class=TableContents style='layout-grid-mode:char;background:#FFFF99'><span
   style='font-family:"Courier New"'>&lt;html&gt;</span></p>
   <p class=TableContents style='background:#FFFF99'><span style='font-family:
   "Courier New"'>      &lt;head&gt;&lt;title&gt;Hello World
   Example&lt;/title&gt;&lt;/head&gt;</span></p>
   <p class=TableContents style='background:#FFFF99'><span style='font-family:
   "Courier New"'>      &lt;body&gt;</span></p>
   <p class=TableContents style='background:#FFFF99'><span style='font-family:
   "Courier New"'>            &lt;form action=&quot;index.php&quot;
   method=&quot;POST&quot;&gt;Type your name: &lt;input type=&quot;text&quot;
   name=&quot;name&quot;/&gt;</span></p>
   <p class=TableContents style='background:#FFFF99'><span style='font-family:
   "Courier New"'>            &lt;input type=&quot;hidden&quot;
   name=&quot;action&quot; value=&quot;showHello&quot;&gt;&lt;/form&gt;</span></p>
   <p class=TableContents style='background:#FFFF99'><span style='font-family:
   "Courier New"'>      &lt;/body&gt;</span></p>
   <p class=TableContents style='background:#FFFF99'><span style='font-family:
   "Courier New"'>&lt;/html&gt;</span></p>
   </td>
  </tr>
 </thead>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Put this file in '/home/user/public_html/example2/pages/html'
and call it helloWorld.html.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Next we need to create a class that extends the Phramework
ViewPlugin class whose job it is to display html pages.  The class could look
like the example below.</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>class HtmlPlugin extends ViewPlugin {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    function HtmlPlugin(){}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    function
  processView($viewValue, $data) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            readfile($viewValue,
  true);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>}</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Notice that all this class does is take the value of
$viewValue and try to write the contents of the file out to the browser.  Put
this file in '/home/user/public_html/example2/classes/com/example2/plugins' and
call it 'HtmlPlugin.php'.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Next, we need to create an action that will handle the
default an incoming request from the browser.  Since we are just going to be
displaying a static HTML page, let’s create a static page action which does
nothing but forward the request to the view.  It could look like the class
below:</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>class StaticPageAction extends Action {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  StaticPageAction() {}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  execute() {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $mapping =
  &quot;success&quot;;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $data =
  null;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        return new
  ActionResult($mapping, $data);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>}</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Put this file in
'/home/user/public_html/example2/classes/com/example2/actions' and call it
'StaticPageAction.php'.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Finally, let’s configure Phramework to display the static
HTML page to the browser when the user navigates to the example2 subdirectory. 
In order to do this, we need to do a number of things.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Let’s set up some user defined configuration properties in
config.properties that correspond to the paths we’ve defined above as well as
some we will need for Smarty, it’s file locations and it’s template locations:</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>example.path=/home/user/public_html/example2</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>classes.path=${example.path}/classes</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>smarty.path=${example.path}/lib/Smarty</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>smarty.templates.path=${example.path}/pages/templates</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>smarty.files.path=${example.path}/smartyfiles</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>html.pages.path=${example.path}/pages/html</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>phramework.classpath=${classes.path}|${smarty.path}|${html.pages.path}|${smarty.templates.path}|${smarty.files.path}</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>In this configuration section we are setting up the
classpath so Phramework knows where to find all of the resources it needs. 
Notice how we used properties defined earlier ('example.path') to define other
properties ('smarty.path', 'html.pages.path', etc).</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Next, as in example 1, we need to define the extensions that
Phramework will import when 'require_once'ing a class.  In example 1, we only
defined 'php' as an extension, but Smarty uses 'class.php' as it’s extension,
so we have to allow that extension also.  Here we also define the request
identifier that will tell us which action to perform.  Add this to your
config.properties file:</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>phramework.import.extensions=php|class.php</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>phramework.page.identifier=action</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Before setting up the actions and views, let’s define the
Phramework view plugin that we created for showing static HTML pages in the
config.properties file.  This plugin requires no initialization parameters, so
the configuration is pretty simple.  We need to tell Phramework which class
should be called when a specific extension is found in the view for a
particular action.  Here we are telling Phramework that the
'com.example2.plugins.HtmlPlugin' class should be called when the extension of
the view is 'html'.</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>viewplugin.html=com.example2.plugins.HtmlPlugin</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.html.extensions=html</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>The format for a plugin is
'viewplugin.&lt;someidentifier&gt;'.  The &lt;someidentifier&gt; piece is not
important, but groups a view plugin with it’s extension and initialization
parameters.  Later, we will set up another view plugin for Smarty which is
slightly more complicated.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Finally, we need to set up the default action and view.  As
you remember from example 1, the 'action.default' is the action that will be
called when the request property defined by the 'phramework.page.identifier' is
not found in the request.  You will also remember that every action has a view
defined by 'view.&lt;action identifier&gt;.&lt;mapping&gt;' where &lt;action
identifier&gt; is the action id (in our case, 'default') and the
&lt;mapping&gt; is the view mapping that should be performed.  If you look at
the StaticPageAction class again, the mapping will be 'success'.  So based on
that information, our action and view mapping for the static page would look
like this:</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>action.default=com.example2.actions.StaticPageAction</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>view.default.success=helloWorld.html</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>At this point, you have a working application that will
display a page similar to the beginning page from example 1 above.  This page
will have a text box where you can enter your name.  Next we need to handle
displaying the name in the browser when the user submits the page.  In order to
make this example slightly more complicated for learning purposes, we will use
Smarty to generate the response back to the user.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Start by creating a Smarty template which will display the
name entered from the previous static HTML form.  I’ll assume you are familiar
with Smarty.  So here is the template.</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>&lt;html&gt;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      &lt;head&gt;&lt;title&gt;Hello
  World Example2 ({$appName})&lt;/title&gt;&lt;/head&gt;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      &lt;body&gt;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            Hello
  {$name}!</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      &lt;/body&gt;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&lt;/html&gt;</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Put this page in '/home/user/example2/pages/templates' and
call it helloWorldResponse.tpl.  Notice we gave it an extension of 'tpl'.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Next, create an action to handle the form being submitted. 
This will take the request property and put it into an array that Smarty can
handle.</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>class ShowHelloAction extends Action {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  ShowHelloAction() {}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      function
  execute() {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $config =
  $GLOBALS[&quot;properties&quot;];</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $mapping =
  &quot;success&quot;;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $data['name']
  = 'no name';</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        if
  (isset($_REQUEST['name'])) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            $data['name']
  = $_REQUEST['name'];</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        return new
  ActionResult($mapping, $data);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>      }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>}</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Put it in '/home/user/example2/classes/com/example2/actions'
and call it ShowHelloAction.php.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Now let’s create the Smarty view plugin.  This is very
similar to the HtmlPlugin class we created earlier, however Smarty does require
some initialization information.  This information is passed to the view plugin
via the 'init($params)' method of the class and is an array of key/value pairs.</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>import('Smarty');</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>class SmartyPlugin
  extends ViewPlugin {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    var $smarty;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    function
  SmartyPlugin() {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $this-&gt;smarty
  = new Smarty();</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    function
  init($params) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $this-&gt;smarty-&gt;template_dir
  = $params['template_dir'];</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $this-&gt;smarty-&gt;compile_dir
  = $params['compile_dir'];</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $this-&gt;smarty-&gt;config_dir
  = $params['config_dir'];</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $this-&gt;smarty-&gt;cache_dir
  = $params['cache_dir'];</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        if
  (array_key_exists('plugins_dir', $params)) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            if
  (strlen(trim($params['plugins_dir'])) &gt; 0) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>                //
  append this list of plugins directories to the current one</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>                //
  placing the ones in the configuration file first</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>                $arrPluginsDir
  = explode('|', $params['plugins_dir']);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>                $arrPluginsDir[]
  = $this-&gt;smarty-&gt;plugins_dir[0];</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>                $this-&gt;smarty-&gt;plugins_dir
  = $arrPluginsDir;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        if
  (array_key_exists('caching', $params)) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            $this-&gt;smarty-&gt;caching
  = $params['caching'];</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        } else {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            $this-&gt;smarty-&gt;caching
  = 0;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $this-&gt;setAssigns($params);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    function
  destroy() {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        unset($this-&gt;smarty);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    function
  processView($viewValue, $data) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $this-&gt;setAssigns($data);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        $this-&gt;smarty-&gt;display($viewValue);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    </span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    function
  setAssigns($params) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        if
  (is_array($params)) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            $arrKeys
  = array_keys($params);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            foreach($arrKeys
  as $key) {</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>                $this-&gt;smarty-&gt;assign($key,
  $params[$key]);</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>            }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>        }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>    }</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>}</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Put this file in
'/home/user/example2/classes/com/example2/plugins' and call it
SmartyPlugin.php.  Notice we are importing Smarty which is doable because the
Smarty library files have been defined on the Phramework classpath.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Finally we need to set up the configuration for when the
user submits the page.  When looking at the static HTML page, we can see that
there is a hidden property called 'action' with a value of 'showHello'.  This
corresponds to our action identifier, so our action and view will be
'showHello'.  You can also see from our ShowHelloAction class that the view
mapping returned to Phramework is 'success'.  And when we see the success view,
we want to pass the information to the Smarty template called
'helloWorldResponse.tpl'.  Based on that information, our config.properties
entries for the action and view would be the following:</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>action.showHello=com.example2.actions.ShowHelloAction</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>view.showHello.success=helloWorldResponse.tpl</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal> This can be placed in the config.properties file.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Now how does Phramework know to display the
'helloWorldResponse.tpl' file through Smarty.  Well, just like we did with the
HTML view plugin, we need to configure the Smarty view plugin and tell
Phramework that it should handle all views that end in the 'tpl' extension. 
Smarty also requires some initialization information regarding where it should
compile templates, where it’s cache is, etc.  We do that through the
'initparams' part of the view plugin configuration.  Anything after the
'initparams' piece will be a key to an array that is passed to the view
plugin.  The value of the key will be the value of the configuration
parameter.  Based on that, we can set up the Smarty view plugin like so:</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>viewplugin.smarty=com.example2.plugins.SmartyPlugin</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.extensions=tpl</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.template_dir=${example.path}/pages/templates/</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.compile_dir=${smarty.files.path}/templates_c/</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.config_dir=${smarty.files.path}/configs/</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.cache_dir=${smarty.files.path}/cache/</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.caching=0</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.plugins_dir=${smarty.plugins.path}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.appName=Phramework
  Example</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal> </p>

<p class=MsoNormal>Notice that it has a different identifier than the HTML
plugin had.  Also notice that we are telling Phramework that the class
'com.example2.plugins.SmartyPlugin' should handle any views where the view
value in the configuration property has an extension of 'tpl'.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Below is the full config.properties file with everything
configured.</p>

<p class=MsoNormal>&nbsp;</p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='margin-left:-.25pt;border-collapse:collapse'>
 <tr>
  <td width=735 valign=top style='width:551.3pt;border:solid black 1.0pt;
  background:#FFFF99;padding:0in 5.4pt 0in 5.4pt'>
  <p class=MsoNormal style='layout-grid-mode:char'><span style='font-family:
  "Courier New"'>example.path=/kunden/homepages/41/d89035854/htdocs/phramework/example2</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>classes.path=${example.path}/classes</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>smarty.path=${example.path}/lib/Smarty</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>smarty.templates.path=${example.path}/pages/templates</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>smarty.files.path=${example.path}/smartyfiles</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>html.pages.path=${example.path}/pages/html</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>phramework.classpath=${classes.path}|${smarty.path}|${html.pages.path}|${smarty.templates.path}|${smarty.files.path}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>phramework.import.extensions=php|class.php</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>phramework.page.identifier=action</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>action.default=com.example2.actions.StaticPageAction</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>action.showHello=com.example2.actions.ShowHelloAction</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>view.default.success=helloWorld.html</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>view.showHello.success=helloWorldResponse.tpl</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty=com.example2.plugins.SmartyPlugin</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.extensions=tpl</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.template_dir=${example.path}/pages/templates/</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.compile_dir=${smarty.files.path}/templates_c/</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.config_dir=${smarty.files.path}/configs/</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.cache_dir=${smarty.files.path}/cache/</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.caching=0</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.plugins_dir=${smarty.plugins.path}</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.smarty.initparams.appName=Phramework
  Example</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>&nbsp;</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.html=com.example2.plugins.HtmlPlugin</span></p>
  <p class=MsoNormal><span style='font-family:"Courier New"'>viewplugin.html.extensions=html</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>You should be able to run this application and it should
behave exactly the same as example 1 above.  This is slightly overkill for such
a simple application, but it gives you an idea of the versatility and power of
Phramework.</p>

<h1 style='margin-left:0in;text-indent:0in'>Conclusion</h1>

<p class=MsoNormal>This concludes the Phramework user guide.  Hopefully it has
give you a better idea of what Phramework can do for you.  In the future there
will be a full application that can be analyzed to understand some of the more
complex concepts better.</p>

<h1 style='margin-left:0in;text-indent:0in'>Appendix I: Tips And Tricks</h1>

<p class=MsoNormal>This sections contains tips and tricks that can be used to
either enhance security of your application or speed up development time.  It
will expand as more items are added (of course).</p>

<h2 style='margin-left:0in;text-indent:0in'>Make Use Of Phramework's Classpath</h2>

<p class=MsoNormal>As long as the files you are trying to access are in
Phramework's classpath, Phramework does not care where in your file system the
files physically reside.  This goes for any type of file, whether they are
classes, HTML files, Smarty templates, XSLT stylesheets, other configuration
files, whatever.  What this means to you is you can create a library of
reusable classes, common stylesheets or common HTML files for example and use
them across multiple applications.</p>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>As an example, let's take the case of database access. 
Phramework allows you to create multiple configuration files and link to them
through the 'phramework.config.files' configuration parameter in your main
config.properties file.  You could store a number of database parameters in a
separate file (called db.properties for example) outside of your web directory
so no one could gain access to it.  Then in your config.properties file, add
the full path and filename to the 'phramework.config.files' configuration
property.  Phramework will read the db.properties file and add it to its list
of properties.  Since these properties are accessible to any class via the
$GLOBALS['properties'] global variable, you could write a Phramework aware
database layer that uses the configuration properties to create a connection to
your database.  The exciting thing about that is that your database layer could
also be completely abstracted outside of the application so that any
application using Phramework could have a database connection without any
recoding.</p>

</div>

</body>

</html>
Return current item: Phramework