Formagic
[ class tree: Formagic ] [ index: Formagic ] [ all elements ]

Class: Formagic

Source Location: /Formagic.php

Class Overview


Formagic main and interface class


Author(s):

  • Florian Sonnenburg

Version:

  • $Id: Formagic.php 19 2007-08-22 22:02:47Z meweasle $

Copyright:

  • Copyright (c) 2007 Florian Sonnenburg

Variables

Constants

Methods



Class Details

[line 38]
Formagic main and interface class

Highly extensible formgenerator with various rendering options, form validation and multipage support.




Tags:

author:  Florian Sonnenburg
version:  $Id: Formagic.php 19 2007-08-22 22:02:47Z meweasle $
copyright:  Copyright (c) 2007 Florian Sonnenburg


[ Top ]


Class Variables

$constantValues = array()

[line 57]

Item values that are not effected by POST/GET



Tags:

access:  public

Type:   array


[ Top ]

$defaultValues =

[line 69]

Array of predefined values for this Formagic object



Tags:

access:  public

Type:   array


[ Top ]

$method =  'post'

[line 51]

Form submission method (POST or GET)



Tags:

access:  public

Type:   string


[ Top ]

$name =  'undefined'

[line 45]

Form name, used for eg. form action tag in HTML renderer



Tags:

access:  public

Type:   string


[ Top ]

$submitValues =

[line 63]

Points to either $_POST or $_GET



Tags:

access:  public

Type:   array


[ Top ]



Class Methods


constructor __construct [line 151]

void __construct( [ $name = 'formagic'], [array $options = null])

Consructor



Tags:

throws:  Formagic_Exception
access:  public


Parameters:

array   $options  
   $name  

[ Top ]

destructor __destruct [line 315]

void __destruct( )

Destructor

Restores formerly manipulated include path.




Tags:

access:  public


[ Top ]

method addItem [line 365]

object FormagicItem addItem( mixed $type, string $name, [array $args = null])

Adds Formagic item object to array of first level form items

Creates new item object and adds this or adds passed FormagicItem object




Tags:

return:  object
access:  public


Parameters:

mixed   $type   String with item type or FormagicItem object
string   $name   String with item name. NULL if $type is FormagicItem object
array   $args   Array with additional item information. NULL if $type is FormagicItem object

[ Top ]

method block [line 589]

boolean block( )

Freezes form



Tags:

access:  public


[ Top ]

method countItems [line 348]

integer countItems( )

Returns number of items added to Formagic object

Counts total number of items recursively




Tags:

access:  public


[ Top ]

method createItem [line 381]

Formagic_Item &createItem( string $type, string $name, [array $args = null])

Creates and returns FormagicItem object

Tries to load correct object class and creates new object. Returns object if successfull, false if not.




Tags:

access:  public


Parameters:

string   $type  
string   $name  
array   $args  

[ Top ]

method execute [line 490]

void execute( )

Runs execute callback



Tags:

throws:  Formagic_Exception
access:  public


[ Top ]

method fetch [line 475]

string fetch( )

Returns output generated by renderer

Loads renderer class and calls renderer::fetch()




Tags:

return:  Renderer result
access:  public


[ Top ]

method getFormAction [line 408]

string getFormAction( )

Returns current form action



Tags:

access:  public


[ Top ]

method getItemHolder [line 398]

array &getItemHolder( )

Returns pointer to Formagic items array



Tags:

access:  public


[ Top ]

method getMessages [line 629]

array getMessages( [string $level = null])

Returns Formagic messages of level $level or empty array if no messages of that level.



Tags:

throws:  Formagic_Exception
access:  public


Parameters:

string   $level  

[ Top ]

method getValue [line 512]

mixed &getValue( string $name)

Returns item value from Formagic value pool



Tags:

access:  public


Parameters:

string   $name  

[ Top ]

method getValues [line 531]

array getValues( )

Returns array with values from all added items



Tags:

access:  public


[ Top ]

method isSubmitted [line 570]

boolean isSubmitted( )

Checks if HTML form is submitted

Check result is true for following rules:

  • if submission tracking is enabled in Formagic options and the
submission variable is present
  • if submission tracking is disabled, but either GET or POST values
(dependent on chosen submission method) are present




Tags:

access:  public


[ Top ]

method loadClass [line 651]

boolean loadClass( string $class)

Includes Formagic extension class

Skipped if class is already loaded. loadClass() tries to load from any extension directories defined. Returns true if successful, false if not.




Tags:

throws:  Formagic_Exception
access:  public


Parameters:

string   $class   Class name. File name is $class.php

[ Top ]

method setDefaultValues [line 289]

array setDefaultValues( array $values)

Formagic::setDefaultValues()



Tags:

access:  public


Parameters:

array   $values  

[ Top ]

method setExecuteCallback [line 303]

void setExecuteCallback( mixed $callback)

Set callback property

$callback has to be a valid PHP callback variable.




Tags:

access:  public


Parameters:

mixed   $callback  

[ Top ]

method setMessage [line 615]

string setMessage( string $message, string $level)

Adds $message to Formagic message stack

Predefined $levels:

  • ERROR
  • NOTICE
  • DEBUG
Other levels can be used if neccessary. Corresponding level has to be used in Formagic::getMessages()




Tags:

see:  Formagic::getMessages()
access:  public


Parameters:

string   $message  
string   $level  

[ Top ]

method setOption [line 210]

boolean setOption( $options, [mixed $value = null], string $name)

Sets Formagic option $name to $value

Triggers warning if option $name is not supported.




Tags:

throws:  Formagic_Exception
access:  public


Parameters:

string   $name   Formagic option name or array with name => value
mixed   $value   value of option $name
   $options  

[ Top ]

method setRenderer [line 265]

boolean setRenderer( string $renderer)

Defines renderer for current Formagic object



Tags:

access:  public


Parameters:

string   $renderer   FormagicRenderer object or string with name of renderer class

[ Top ]

method validate [line 425]

boolean validate( )

Checks if form is submitted and all rules apply

Iterates through all items added to the form. If any rule is violated, iteration is stopped. Returns true if no rules are violated. The result of validate() is cached.




Tags:

access:  public


[ Top ]

method _execEvent [line 671]

boolean _execEvent( string $event)

Formagic event dispatcher



Tags:

access:  protected


Parameters:

string   $event   Event to be triggered

[ Top ]

method __toString [line 325]

string __toString( )

Returns result for string casting of Formagic object



Tags:

access:  public


[ Top ]


Class Constants

API_VERSION =  '1.2'

[line 137]


[ Top ]

DEBUG =  3

[line 142]


[ Top ]

ERROR =  1

[line 140]


[ Top ]

NOTICE =  2

[line 141]


[ Top ]

PAGE_REQUEST_KEY =  '__fm_sw'

[line 139]


[ Top ]

PAGE_TRACKING_KEY =  '__fm_rp'

[line 138]


[ Top ]

VERSION =  '0.2.3b'

[line 136]


[ Top ]



Documentation generated on Thu, 23 Aug 2007 00:29:38 +0200 by phpDocumentor 1.4.0