formit.class.php
FormIt
Copyright 2009-2011 by Shaun McCormick shaun@modx.com
FormIt is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
FormIt 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with
FormIt; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
Suite 330, Boston, MA 02111-1307 USA
- package
- formit
Base class for FormIt. Used for initializing the form processing engine, handling templating and running snippets.
- package
- formit
Properties



boolean
$_initialized= 'false'
True if the class has been initialized or not.
Default valuefalseDetails
- Type
- boolean



int
$debugTimer= '0'
In debug mode, will monitor execution time.
Default value0Details
- Type
- int
- access
- public



boolean
$inTestMode= 'false'
Used when running unit tests to prevent emails/headers from being sent
Default valuefalseDetails
- Type
- boolean
Methods



__construct(
\modX $modx, array $config
=
array
)
:
FormIt constructor
Parameters
| Name |
Type |
Description |
| $modx |
\modX |
&$modx A reference to the modX instance.
|
| $config |
array |
An array of configuration options. Optional. |



_getTplChunk(
string $name
)
:
\modChunk/booleanReturns a modChunk object from a template file.
Parameters
| Name |
Type |
Description |
| $name |
string |
The name of the Chunk. Will parse to name.chunk.tpl |
Returns
| Type |
Description |
| \modChunk/boolean |
|
Details
- access
- private



endDebugTimer(
)
:
intEnds the debug timer and returns the total number of seconds script took
to run.
Returns
Details
- access
- protected



getChunk(
string $name, array $properties
=
array
)
:
stringGets a Chunk and caches it; also falls back to file-based templates
for easier debugging.
Will always use the file-based chunk if $debug is set to true.
Parameters
| Name |
Type |
Description |
| $name |
string |
The name of the Chunk |
| $properties |
array |
The properties for the Chunk |
Returns
Details
- access
- public



initialize(
string $context
=
web
)
:
mixedInitialize the component into a context and provide context-specific
handling actions.
Parameters
| Name |
Type |
Description |
| $context |
string |
The context to initialize FormIt into |
Returns
Details
- access
- public



loadHooks(
\$type $type
=
post, \$config $config
=
array
)
:
\fiHooksLoads the Hooks class.
Parameters
| Name |
Type |
Description |
| $type |
\$type |
string The type of hook to load. |
| $config |
\$config |
array An array of configuration parameters for the hooks class |
Returns
Details
- access
- public



loadModule(
string $className, string $serviceName, array $config
=
array
)
:
\fiModule
Parameters
| Name |
Type |
Description |
| $className |
string |
|
| $serviceName |
string |
|
| $config |
array |
|
Returns



output(
string $output
)
:
stringOutput the final output and wrap in the wrapper chunk. Optional, but
recommended for debugging as it outputs the execution time to the output.
Also, it is good to output your snippet code with wrappers for easier
CSS isolation and styling.
Parameters
| Name |
Type |
Description |
| $output |
string |
The output to process |
Returns
Details
- access
- public



startDebugTimer(
)
:
intStarts the debug timer.
Returns
Details
- access
- protected