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 127 2011-05-21 09:14:54Z meweasle $, $Revision: 70 $

Copyright:

  • Copyright (c) 2007-2009 Florian Sonnenburg

Variables

Constants

Methods



Class Details

[line 56]
Formagic main and interface class

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

You can use the following options when creating a formagic instance:

  • attributes
  • action
  • method
  • name
  • pluginBaseDir
  • renderer
  • trackSubmission
  • translator
  • defaultValues
  • multipageStorage




Tags:

author:  Florian Sonnenburg
version:  $Id: Formagic.php 127 2011-05-21 09:14:54Z meweasle $, $Revision: 70 $
copyright:  Copyright (c) 2007-2009 Florian Sonnenburg


[ Top ]


Class Variables

static $_baseDirs = array()

[line 126]

Array of directories classes are searched for



Tags:

access:  protected

Type:   array


[ Top ]

static $_translator =

[line 132]

Formagic_Translator object



Tags:

access:  protected



[ Top ]

$_attributes = array(
        'enctype' => 'multipart/form-data',
        'accept-charset' => 'utf-8'
    )

[line 74]

HTML attributes for the form tag



Tags:

access:  protected

Type:   Array


[ Top ]

$_formAction =

[line 114]

Action for form tag



Tags:

access:  private

Type:   string


[ Top ]

$_itemHolder =

[line 102]

Container item holding all items added to Formagic object



Tags:

access:  private



[ Top ]

$_method =  'post'

[line 62]

Form submission method (POST or GET)



Tags:

access:  protected

Type:   string


[ Top ]

$_name =  'formagic'

[line 108]

Form name



Tags:

access:  private

Type:   string


[ Top ]

$_renderer =

[line 90]

Type of renderer used to display form



Tags:

see:  Formagic::setRenderer()
access:  private

Type:   Formagic_Renderer


[ Top ]

$_submissionItem =

[line 120]

Track submission item



Tags:

access:  private



[ Top ]

$_submitValues = array()

[line 68]

Array of submitted values



Tags:

access:  protected

Type:   array


[ Top ]

$_supportedMethods = array('get', 'post')

[line 83]

Submit methods supported by Formagic



Tags:

access:  protected

Type:   array


[ Top ]

$_trackSubmission =  true

[line 96]

Enables or disables submission tracking



Tags:

access:  private

Type:   boolean


[ Top ]



Class Methods


static method addBaseDir [line 327]

static void addBaseDir( string $baseDir)

Adds a directory to base dir stack (globally for all Formagic instances).



Tags:

access:  public


Parameters:

string   $baseDir   BaseDir to be added

[ Top ]

static method createItem [line 527]

static Formagic_Item_Abstract 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:

return:  New item instance
access:  public


Parameters:

string   $type   Item type string
string   $name   Item name
array   $args   Item options array

[ Top ]

static method getBaseDirs [line 340]

static array getBaseDirs( )

Returns current plugin base directory stack.



Tags:

return:  Plugin base directory stack
access:  public


[ Top ]

static method getTranslator [line 492]

static Formagic_Translator getTranslator( )

Returns translator object.

If no translator is specified, an empty translator object is returned.




Tags:

return:  The translator object
access:  public


[ Top ]

static method loadClass [line 708]

static void loadClass( string $class)

Loads a class located in defined baseDir locations.

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 if item class could not be loaded
access:  public


Parameters:

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

[ Top ]

static method setTranslator [line 463]

static Formagic setTranslator( [ $translatorDefinition = null], array|object|Formagic_Translator $translator)

Sets translator object and method if present.

$translator has to be either an array with two members, the first one beeing the translator object and the second one the name of the translator method, or a translator object. In the latter case the translator method is assumed '$translatorObject->_($string)'.




Tags:

return:  Fluent interface
access:  public


Parameters:

array|object|Formagic_Translator   $translator   Array with translator object and method or any translator object or Formagic_Translator object
   $translatorDefinition  

[ Top ]

constructor __construct [line 150]

Formagic __construct( [ $options = null])

Constructor.



Tags:

throws:  Formagic_Exception
access:  public


Parameters:

array   $options   Array of options for the form.

[ Top ]

method getFormAction [line 566]

string getFormAction( )

Returns current form action



Tags:

return:  Form action string
access:  public


[ Top ]

method getInfo [line 505]

string getInfo( )

Returns form information string.



Tags:

return:  The form information string.
access:  public


[ Top ]

method getItemHolder [line 540]

Formagic_Item_Container getItemHolder( )

Returns root container.



Tags:

return:  Item holder item
access:  public


[ Top ]

method getMethod [line 424]

string getMethod( )

Returns the form method.



Tags:

return:  The form submit method.
access:  public


[ Top ]

method getRaw [line 645]

array getRaw( )

Returns undvalidated and unfiltered submit values.



Tags:

return:  Values array
access:  public


[ Top ]

method getRenderer [line 381]

Formagic_Renderer_Interface getRenderer( )

Returns the current renderer object.



Tags:

return:  The renderer object
access:  public


[ Top ]

method getTrackSubmission [line 446]

boolean getTrackSubmission( )

Returns submission tracking status.



Tags:

return:  Submission tracking status.
access:  public


[ Top ]

method getValues [line 635]

array getValues( )

Returns array with values from all added items.



Tags:

return:  Array of form item values
access:  public


[ Top ]

method isSubmitted [line 661]

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:

return:  Submission status
access:  public


[ Top ]

method render [line 603]

string render( )

Returns output generated by renderer

Loads renderer class and calls renderer::fetch()




Tags:

return:  Renderer result
access:  public


[ Top ]

method setFormAction [line 551]

Formagic setFormAction( string $value)

Sets the form action URL.



Tags:

return:  Fluent interface
access:  public


Parameters:

string   $value   Form action URL

[ Top ]

method setMethod [line 408]

Formagic setMethod( string $method)

Sets the form's submit method.



Tags:

return:  Fluent interface
access:  public


Parameters:

string   $method   The new form submit method

[ Top ]

method setRenderer [line 352]

Formagic setRenderer( string|Formagic_Renderer_Interface $renderer)

Defines renderer for current Formagic object



Tags:

return:  Fluent interface
access:  public


Parameters:

string|Formagic_Renderer_Interface   $renderer   Formagic_Renderer object or string with name of renderer class

[ Top ]

method setTrackSubmission [line 435]

Formagic setTrackSubmission( boolean $flag)

Enables or disables submission tracking.



Tags:

return:  Fluent interface
access:  public


Parameters:

boolean   $flag   Track submission status

[ Top ]

method setValues [line 624]

Formagic setValues( $values)

Sets default values.



Tags:

return:  Fluent interface
access:  public


Parameters:

array   $values   Form values

[ Top ]

method validate [line 584]

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:

return:  Validation result
todo:  Think of a better solution for setValues() in line 611
access:  public


[ Top ]

method _getTrackSubmissionItem [line 682]

Formagic_Item_Hidden _getTrackSubmissionItem( )

Returns the track submission item.



Tags:

return:  Track submission item
access:  private


[ Top ]

method _init [line 203]

void _init( )

Allows subclass initialization.



Tags:

access:  public


[ Top ]

method _setName [line 392]

Fluent _setName( string $name)

Sets form name and thus name of trackSubmission item.



Tags:

return:  interface
access:  private


Parameters:

string   $name  

[ Top ]

method _setOptions [line 269]

void _setOptions( $options, string $name, mixed $value)

Sets Formagic option $name to $value

Triggers warning if option $name is not supported.




Tags:

throws:  Formagic_Exception
access:  protected


Parameters:

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

[ Top ]

method __call [line 225]

mixed __call( string $method, array $args)

Proxies method calls to underlying container $this->_itemHolder.



Tags:

return:  The container method result.
access:  public


Parameters:

string   $method   Method name string.
array   $args   Array of method parameters.

[ Top ]

method __get [line 241]

Formagic_Item_Abstract __get( string $itemName)

Member overloading: Tries to return a form item with member's name.



Tags:

return:  Item object
throws:  Formagic_Exception
access:  public


Parameters:

string   $itemName   Name of requested member.

[ Top ]

method __set [line 254]

void __set( string $key, mixed $value)

Will throw an Formagic_Exception, because member overloading is not allowed.



Tags:

throws:  Formagic_Exception
access:  public


Parameters:

string   $key   Member name
mixed   $value   Member value

[ Top ]

method __toString [line 212]

string __toString( )

Returns result for string casting of Formagic object.



Tags:

return:  The rendering result.
access:  public


[ Top ]


Class Constants

API_VERSION =  '2.0'

[line 142]

Formagic API version


[ Top ]

VERSION =  '1.0'

[line 137]

Formagic version


[ Top ]



Documentation generated on Sun, 22 May 2011 22:40:11 +0200 by phpDocumentor 1.4.3