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

Class: pnFormRender

Source Location: /includes/pnForm.php

Class Overview

Smarty
   |
   --pnRender
      |
      --pnFormRender

User interaction handler for pnForm system


Variables

Methods


Inherited Variables

Inherited Methods

Class: pnRender

pnRender::pnRender()
The class constructor.
pnRender::add_core_data()
add core data to the template
pnRender::clear_all_cache()
clear the entire contents of cache (all templates)
pnRender::clear_cache()
clears the cache for a specific template
pnRender::display()
executes & displays the template results
pnRender::fetch()
executes & returns the template results
pnRender::getInstance()
setup the current instance of the pnRender class and return it back to the module
pnRender::get_template_path()
Checks which path to use for required template
pnRender::is_cached()
finds out if a template is already cached
pnRender::template_exists()
Checks whether requested template exists.

Class: Smarty

Smarty::Smarty()
The class constructor.
Smarty::append()
appends values to template variables
Smarty::append_by_ref()
appends values to template variables by reference
Smarty::assign()
assigns values to template variables
Smarty::assign_by_ref()
assigns values to template variables by reference
Smarty::clear_all_assign()
clear all the assigned template variables.
Smarty::clear_all_cache()
clear the entire contents of cache (all templates)
Smarty::clear_assign()
clear the given assigned template variable.
Smarty::clear_cache()
clear cached content for the given template and cache id
Smarty::clear_compiled_tpl()
clears compiled version of specified template resource, or all compiled template files if one is not specified.
Smarty::clear_config()
clear configuration values
Smarty::config_load()
load configuration values
Smarty::display()
executes & displays the template results
Smarty::fetch()
executes & returns or displays the template results
Smarty::get_config_vars()
Returns an array containing config variables
Smarty::get_registered_object()
return a reference to a registered object
Smarty::get_template_vars()
Returns an array containing template variables
Smarty::is_cached()
test to see if valid cache exists for this template
Smarty::load_filter()
load a filter of specified type and name
Smarty::register_block()
Registers block function to be used in templates
Smarty::register_compiler_function()
Registers compiler function
Smarty::register_function()
Registers custom function to be used in templates
Smarty::register_modifier()
Registers modifier to be used in templates
Smarty::register_object()
Registers object to be used in templates
Smarty::register_outputfilter()
Registers an output filter function to apply to a template output
Smarty::register_postfilter()
Registers a postfilter function to apply to a compiled template after compilation
Smarty::register_prefilter()
Registers a prefilter function to apply to a template before compiling
Smarty::register_resource()
Registers a resource to fetch a template
Smarty::template_exists()
Checks whether requested template exists.
Smarty::trigger_error()
trigger Smarty error
Smarty::unregister_block()
Unregisters block function
Smarty::unregister_compiler_function()
Unregisters compiler function
Smarty::unregister_function()
Unregisters custom function
Smarty::unregister_modifier()
Unregisters modifier
Smarty::unregister_object()
Unregisters object
Smarty::unregister_outputfilter()
Unregisters an outputfilter function
Smarty::unregister_postfilter()
Unregisters a postfilter function
Smarty::unregister_prefilter()
Unregisters a prefilter function
Smarty::unregister_resource()
Unregisters a resource
Smarty::_compile_resource()
compile the template
Smarty::_compile_source()
compile the given source
Smarty::_dequote()
Remove starting and ending quotes from the string
Smarty::_eval()
wrapper for eval() retaining $this
Smarty::_fetch_resource_info()
fetch the template info. Gets timestamp, and source if get_source is true
Smarty::_get_auto_filename()
get a concrete filename for automagically created content
Smarty::_get_auto_id()
returns an auto_id for auto-file-functions
Smarty::_get_compile_path()
Get the compile path for this resource
Smarty::_get_filter_name()
Extracts the filter name from the given callback
Smarty::_get_plugin_filepath()
get filepath of requested plugin
Smarty::_include()
wrapper for include() retaining $this
Smarty::_is_compiled()
test if resource needs compiling
Smarty::_parse_resource_name()
parse out the type and name from the resource
Smarty::_process_compiled_include_callback()
callback function for preg_replace, to call a non-cacheable block
Smarty::_read_file()
read in a file
Smarty::_run_mod_handler()
Handle modifiers
Smarty::_smarty_cache_attrs()
get or set an array of cached attributes for function that is
Smarty::_smarty_include()
called for included templates
Smarty::_trigger_fatal_error()
trigger Smarty plugin error
Smarty::_unlink()
unlink a file, possibly using expiration time

Class Details

[line 35]
User interaction handler for pnForm system

This class is the main entry point for using the pnForm system. It is expected to be used in Zikula's user files, such as "pnuser.php", like this:

  1.  function modname_user_new($args)
  2.  {
  3.    // Create instance of pnFormRender class
  4.    $render FormUtil::newpnForm('howtopnforms');
  5.  
  6.    // Execute form using supplied template and event handler
  7.    return $render->pnFormExecute('modname_user_new.html'new modname_user_newHandler());
  8.  }
See tutorials elsewhere for general introduction to pnForm.




[ Top ]


Class Variables

$pnFormBlockStack =

[line 59]

Stack with all instantiated blocks (push when starting block, pop when ending block)


Type:   mixed


[ Top ]

$pnFormErrorMsgSet =

[line 95]

Error message has been set


Type:   mixed


[ Top ]

$pnFormEventHandler =

[line 89]

Reference to the main user code event handler


Type:   mixed


[ Top ]

$pnFormIdCount =

[line 83]

Current ID count - used to assign automatic ID's to all items


Type:   mixed


[ Top ]

$pnFormIncludes =

[line 47]

List of included files required to recreate plugins (Smarty function.xxx.php files)


Type:   mixed


[ Top ]

$pnFormPlugins =

[line 53]

List of instantiated plugins


Type:   mixed


[ Top ]

$pnFormRedirected =

[line 101]

Set to true if pnFormRedirect was called. Means no HTML output should be returned.


Type:   mixed


[ Top ]

$pnFormState =

[line 41]

Variable saving all required state information


Type:   mixed


[ Top ]

$pnFormValidationChecked =

[line 71]

Flag indicating if validation has been done or not


Type:   mixed


[ Top ]

$pnFormValidators =

[line 65]

List of validators on page


Type:   mixed


[ Top ]

$_pnFormIsValid =

[line 77]

Indicates whether page is valid or not


Type:   mixed


[ Top ]



Class Methods


constructor pnFormRender [line 110]

pnFormRender pnFormRender( $module)

Constructor

Use FormUtil::newpnForm() instead of instantiating pnFormRender directly.




Parameters:

   $module  

[ Top ]

method dumpPlugins [line 998]

void dumpPlugins( $msg, &$plugins)



Parameters:

   $msg  
   &$plugins  

[ Top ]

method dumpPlugins_rec [line 1007]

void dumpPlugins_rec( &$plugins)



Parameters:

   &$plugins  

[ Top ]

method pnFormAddValidator [line 424]

void pnFormAddValidator( &$validator)



Parameters:

   &$validator  

[ Top ]

method pnFormClearValidation [line 460]

void pnFormClearValidation( )



[ Top ]

method pnFormDecodeEventHandler [line 802]

void pnFormDecodeEventHandler( )



[ Top ]

method pnFormDecodeIncludes [line 641]

void pnFormDecodeIncludes( )



[ Top ]

method pnFormDecodePlugins [line 839]

void pnFormDecodePlugins( )



[ Top ]

method pnFormDecodePluginState [line 756]

void &pnFormDecodePluginState( )



[ Top ]

method pnFormDecodePluginState_rec [line 764]

void &pnFormDecodePluginState_rec( &$state)



Parameters:

   &$state  

[ Top ]

method pnFormDecodePlugins_rec [line 847]

void pnFormDecodePlugins_rec( &$plugins)



Parameters:

   &$plugins  

[ Top ]

method pnFormDecodePostBackEvent [line 857]

void pnFormDecodePostBackEvent( )



[ Top ]

method pnFormDecodePostBackEvent_rec [line 875]

void pnFormDecodePostBackEvent_rec( &$plugins)



Parameters:

   &$plugins  

[ Top ]

method pnFormDecodeState [line 740]

void pnFormDecodeState( )



[ Top ]

method pnFormDie [line 405]

void pnFormDie( $msg)



Parameters:

   $msg  

[ Top ]

method pnFormExecute [line 139]

mixed pnFormExecute( bool $template, &$eventHandler, pnFormHandler $eventHandler)

Main event loop handler

This is the function to call instead of the normal $render->fetch(...)




Tags:

return:  False on errors, true on redirects, and otherwise it returns the HTML output for the page.


Parameters:

bool   $template   Name of template file
pnFormHandler   $eventHandler   Instance of object that inherits from pnFormHandler
   &$eventHandler  

[ Top ]

method pnFormGetAuthKeyHTML [line 661]

void pnFormGetAuthKeyHTML( )



[ Top ]

method pnFormGetErrorMsg [line 512]

void pnFormGetErrorMsg( )



[ Top ]

method pnFormGetIncludesHTML [line 633]

void pnFormGetIncludesHTML( )



[ Top ]

method pnFormGetIncludesText [line 623]

void pnFormGetIncludesText( )



[ Top ]

method pnFormGetPluginById [line 364]

void &pnFormGetPluginById( $id)



Parameters:

   $id  

[ Top ]

method pnFormGetPluginById_rec [line 380]

void &pnFormGetPluginById_rec( &$plugin, $id)



Parameters:

   &$plugin  
   $id  

[ Top ]

method pnFormGetPluginId [line 353]

void pnFormGetPluginId( &$params)

pnFormGetPluginId



Parameters:

   &$params  

[ Top ]

method pnFormGetPluginState [line 693]

void pnFormGetPluginState( )



[ Top ]

method pnFormGetPluginState_rec [line 701]

void pnFormGetPluginState_rec( &$plugins)



Parameters:

   &$plugins  

[ Top ]

method pnFormGetPostBackEventReference [line 590]

void pnFormGetPostBackEventReference( plugin &$plugin, commandName $commandName)

Get postback reference

Call this method to get a piece of code that will generate a postback event. The returned JavaScript code can be called at any time to generate the postback. The plugin that receives the postback must implement a function "raisePostBackEvent(&$render, $eventArgument)" that will handle the event.

Example (taken from the pnFormContextMenuItem plugin):

  1.  function render(&$render)
  2.  {
  3.    $click $render->pnFormGetPostBackEventReference($this$this->commandName);
  4.    $url 'javascript:' $click;
  5.    $title $render->pnFormTranslateForDisplay($this->title);
  6.    $html "<li><a href=\"$url\">$title</a></li>";
  7.  
  8.    return $html;
  9.  }
  10.  
  11.  function raisePostBackEvent(&$render$eventArgument)
  12.  {
  13.    $args array('commandName' => $eventArgument'commandArgument' => null);
  14.    $render->pnFormRaiseEvent($this->onCommand == null 'handleCommand' $this->onCommand$args);
  15.  }




Parameters:

plugin   &$plugin   object Reference to the plugin that should receive the postback event
commandName   $commandName   string Command name to pass to the event handler

[ Top ]

method pnFormGetState [line 484]

void &pnFormGetState( $region, $varName)



Parameters:

   $region  
   $varName  

[ Top ]

method pnFormGetStateHTML [line 732]

void pnFormGetStateHTML( )



[ Top ]

method pnFormGetStateText [line 678]

void pnFormGetStateText( )



[ Top ]

method pnFormGetValidators [line 439]

void &pnFormGetValidators( )



[ Top ]

method pnFormGetValues [line 938]

void pnFormGetValues( )

Read all values from form

Use this function to read the values send by the browser on postback. The return value is an associative array of input names mapping to the posted values. For instance the data:

  1.  array('title'    => 'The posted title',
  2.        'text'     => 'The posted text',
  3.        'servings' => 4)

Most input plugins supports grouping of posted data. These inputs allows you to write something similar to what you do on the pnformtextinput plugin:

  1.    <!--[pnformtextinput id="title" group="A"]--><br/>
  2.    <!--[pnformtextinput id="text" textMode=multiline group="A"]-->
  3.    <!--[pnformintinput id="servings"]--><br/>

Grouped data is combined into associative arrays with all the values in the group. The above example would give the data set:

  1.  array('A' => array('title'    => 'The posted title',
  2.                     'text'     => 'The posted text'),
  3.        'servings' => 4)




[ Top ]

method pnFormGetValues_rec [line 948]

void pnFormGetValues_rec( &$plugins, &$result)



Parameters:

   &$plugins  
   &$result  

[ Top ]

method pnFormHasError [line 525]

void pnFormHasError( )



[ Top ]

method pnFormInitializeIncludes [line 618]

void pnFormInitializeIncludes( )



[ Top ]

method pnFormInitializePlugins [line 820]

void pnFormInitializePlugins( )



[ Top ]

method pnFormInitializePlugins_rec [line 828]

void pnFormInitializePlugins_rec( &$plugins)



Parameters:

   &$plugins  

[ Top ]

method pnFormInitializeState [line 672]

void pnFormInitializeState( )



[ Top ]

method pnFormIsPostBack [line 399]

void pnFormIsPostBack( )



[ Top ]

method pnFormIsValid [line 430]

void pnFormIsValid( )



[ Top ]

method pnFormPostRender [line 885]

void pnFormPostRender( )



[ Top ]

method pnFormPostRender_rec [line 893]

void pnFormPostRender_rec( &$plugins)



Parameters:

   &$plugins  

[ Top ]

method pnFormRaiseEvent [line 599]

void pnFormRaiseEvent( $eventHandlerName, $args)



Parameters:

   $eventHandlerName  
   $args  

[ Top ]

method pnFormRedirect [line 552]

void pnFormRedirect( $url)



Parameters:

   $url  

[ Top ]

method pnFormRegisterBlock [line 310]

void pnFormRegisterBlock( string $pluginName, array &$params, string &$content)

Regiser a block plugin

Use this like pnFormRegisterPlugin but for Smarty blocks instead of Smarty plugins.

  1.  // In file "block.myblock.php"
  2.  
  3.  // pnForm plugin class (also used for blocks)
  4.  class MyBlock extends pnFormPlugin
  5.  ... }
  6.  
  7.  // Smarty block function
  8.  function smarty_block_myblock($params$content&$render)
  9.  {
  10.    return return $render->pnFormRegisterBlock('MyBlock'$params$content);
  11.  }




Parameters:

string   $pluginName   Full class name of the plugin to register.
array   &$params   Parameters passed from the Smarty block function
string   &$content   Content passed from the Smarty block function

[ Top ]

method pnFormRegisterBlockBegin [line 323]

void pnFormRegisterBlockBegin( $pluginName, &$params)

pnFormRegisterBlockBegin



Parameters:

   $pluginName  
   &$params  

[ Top ]

method pnFormRegisterBlockEnd [line 335]

void pnFormRegisterBlockEnd( $pluginName, &$params, $content)

pnFormRegisterBlockEnd



Parameters:

   $pluginName  
   &$params  
   $content  

[ Top ]

method pnFormRegisterError [line 543]

void pnFormRegisterError( $dummy)

Register that we have used LogUtil::registerError() to set an error.

Example:

  1.  function initialize(&$render)
  2.  {
  3.    if (... not has access ...)
  4.      return $render->pnFormRegisterError(LogUtil::registerPermissionError());
  5.  }




Parameters:

   $dummy  

[ Top ]

method pnFormRegisterPlugin [line 215]

string pnFormRegisterPlugin( string $pluginName, array &$params, [bool $isBlock = false])

Register a plugin

This method registers a plugin used in a template. Plugins must beregistered to be used in pnForm (unlike Smarty plugins). The register call must be done inside the Smarty plugin function in a Smarty plugin file. Use like this:

  1.  // In file "function.myplugin.php"
  2.  
  3.  // pnForm plugin class
  4.  class MyPlugin extends pnFormPlugin
  5.  ... }
  6.  
  7.  // Smarty plugin function
  8.  function smarty_function_myplugin($params&$render)
  9.  {
  10.    return $render->pnFormRegisterPlugin('MyPlugin'$params);
  11.  }
Registering a plugin ensures it is included in the plugin hierarchy of the current page, so that it's various event handlers can be called by the framework.

Do dot use this function for registering Smarty blocks (the $isBlock parameter is for internal use). Use pnFormRegisterBlock instead.

See also all the function.pnformXXX.php plugins for examples.




Tags:

return:  Returns what the render() method of the plugin returns


Parameters:

string   $pluginName   Full class name of the plugin to register.
array   &$params   Parameters passed from the Smarty plugin function
bool   $isBlock   Indicates whether the plugin is a Smarty block or a Smarty function (internal)

[ Top ]

method pnFormSetErrorMsg [line 504]

void pnFormSetErrorMsg( $msg)

Register an error

Example:

  1.  function handleCommand(...)
  2.  {
  3.    if (... it did not work ...)
  4.      return $render->pnFormRegisterError('Operation X failed due to Y');
  5.  }




Parameters:

   $msg  

[ Top ]

method pnFormSetState [line 474]

void pnFormSetState( $region, $varName, &$varValue)



Parameters:

   $region  
   $varName  
   &$varValue  

[ Top ]

method pnFormSetValues [line 965]

void pnFormSetValues( &$values, [ $group = null])



Parameters:

   &$values  
   $group  

[ Top ]

method pnFormSetValues2 [line 972]

void pnFormSetValues2( &$values, [ $group = null], &$plugins)



Parameters:

   &$values  
   $group  
   &$plugins  

[ Top ]

method pnFormSetValues_rec [line 983]

void pnFormSetValues_rec( &$values, $group, &$plugins)



Parameters:

   &$values  
   $group  
   &$plugins  

[ Top ]

method pnFormTranslateForDisplay [line 412]

void pnFormTranslateForDisplay( $txt, [ $doEncode = true])



Parameters:

   $txt  
   $doEncode  

[ Top ]

method pnFormValidate [line 445]

void pnFormValidate( )



[ Top ]


Documentation generated on Fri, 18 Jul 2008 21:52:55 +0200 by phpDocumentor 1.4.1