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

Source for file function.pnformerrormessage.php

Documentation is available at function.pnformerrormessage.php

  1. <?php
  2. /**
  3.  * Error message plugin
  4.  *
  5.  * @copyright (c) 2006, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: function.pnformerrormessage.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @author Jorn Wildt
  10.  * @package Zikula_Template_Plugins
  11.  * @subpackage Functions
  12.  */
  13.  
  14. /**
  15.  * Error message placeholder
  16.  *
  17.  * Use this plugin to display error messages. It should be added in your template in the exact location where
  18.  * you want the error message to be displayed. Then, on postback, you can do as shown here to set the
  19.  * error message:
  20.  * <code>
  21.  *  function handleCommand(&$render, &$args)
  22.  *  {
  23.  *    if ($args['commandName'] == 'update')
  24.  *    {
  25.  *      if (!$render->pnFormIsValid())
  26.  *        return false;
  27.  *
  28.  *      $data = $render->pnFormGetValues();
  29.  *      if (... something is wrong ...)
  30.  *      {
  31.  *        $errorPlugin = $render->pnFormGetPluginById('MyPluginId');
  32.  *        $errorPlugin->message = 'Something happend';
  33.  *        return false;
  34.  *      }
  35.  *
  36.  *      ... handle data ...
  37.  *    }
  38.  *
  39.  *    return true;
  40.  *  }
  41.  * </code>
  42.  * Beware that {@link pnFormRender::pnFormGetPluginById()} only works on postback.
  43.  *
  44.  * @package pnForm
  45.  * @subpackage Plugins
  46. */
  47. {
  48.     /**
  49.      * Displayed error message
  50.      * @var string 
  51.      */
  52.     var $message;
  53.  
  54.     /**
  55.      * CSS class for styling
  56.      * @var string 
  57.      */
  58.     var $cssClass;
  59.  
  60.  
  61.     function getFilename()
  62.     {
  63.         return __FILE__// FIXME: should be found in smarty's data???
  64.     }
  65.  
  66.  
  67.     function render(&$render)
  68.     {
  69.         if ($this->message != '')
  70.         {
  71.             $cssClass ($this->cssClass == null 'pn-errormsg' $this->cssClass);
  72.             $html "<div class=\"$cssClass\">$this->message . "</div>\n";
  73.  
  74.             return $html;
  75.         }
  76.  
  77.         return '';
  78.     }
  79. }
  80.  
  81.  
  82. function smarty_function_pnformerrormessage($params&$render)
  83. {
  84.     return $render->pnFormRegisterPlugin('pnFormErrorMessage'$params);
  85. }

Documentation generated on Fri, 18 Jul 2008 21:45:51 +0200 by phpDocumentor 1.4.1