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

Source for file function.pnbutton.php

Documentation is available at function.pnbutton.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2004, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: function.pnbutton.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Template_Plugins
  10.  * @subpackage Functions
  11.  */
  12.  
  13. /**
  14.  * Smarty function to display an image form submission button
  15.  *
  16.  * BEWARE: Internt Explorer 6.x does NOT work especially well with <button> tags!
  17.  *
  18.  * available parameters:
  19.  *  - assign      if set, the button will be assigned to this variable
  20.  *  - type        if set, the type of button that will be generated (default: submit)
  21.  *  - mode        if set, the type of HTML element to be used (default: <button>). Values = [button|input]
  22.  *  - name        if set, the name of button that will be generated (default: value of 'type' parameter)
  23.  *  - value       if set, the value of button that will be generated
  24.  *  - id          if set, the ID of button
  25.  *  - class       if set, the class of button
  26.  *  - src         image source name
  27.  *  - set         image set name
  28.  *  - alt         if set, the constant that will be used for the alt attribute
  29.  *  - title       if set, the constant that will be used for the title attribute
  30.  *  - constants   if false then both alt and title will be assumed to be the final strings not constants
  31.  *  - gt          if true assume that gettext translation should be looked up for alt and title
  32.  *
  33.  * @author   Mark West
  34.  * @since    17th Nov. 2005
  35.  * @param    array    $params     All attributes passed to this function from the template
  36.  * @param    object   $smarty     Reference to the Smarty object
  37.  * @return   string   the version string
  38.  */
  39. function smarty_function_pnbutton($params&$smarty)
  40. {
  41.     extract($params);
  42.     unset($params);
  43.  
  44.     // we're going to make use of pnimg for path searching
  45.     require_once $smarty->_get_plugin_filepath('function''pnimg');
  46.  
  47.     // set some defaults
  48.     if (!isset($constants|| !is_bool($constants)) {
  49.         $constants true;
  50.     }
  51.     if (isset($gt&& is_bool($gt&& $gt{
  52.         $gt true;
  53.         $constants false;
  54.     else {
  55.         $gt false;
  56.         $constants true;
  57.     }
  58.  
  59.     if (!isset($alt)) {        
  60.         $gt $alt _("Submit"$alt _SUBMIT;
  61.     elseif ($gt{
  62.         $alt _($alt);
  63.     elseif ($constants{
  64.         $alt constant($alt);
  65.     }
  66.     if (!isset($title)) {
  67.         $gt $title _("Submit"$title _SUBMIT;
  68.     elseif ($gt{
  69.         $title _($title);
  70.     elseif ($constants{
  71.         $title constant($title);
  72.     }
  73.  
  74.  
  75.     if (!isset($type)) {
  76.         $type 'submit';
  77.     }
  78.     if (!isset($mode)) {
  79.         $mode 'button';
  80.     }
  81.     if (isset($name)) {
  82.         $name ' name="'.DataUtil::formatForDisplay($name).'"';
  83.     else {
  84.         $name ' name="'.DataUtil::formatForDisplay($type).'"';
  85.     }
  86.     if (isset($value)) {
  87.         $value ' value="'.DataUtil::formatForDisplay($value).'"';
  88.     else {
  89.         $value '';
  90.     }
  91.     if (isset($id)) {
  92.         $id ' id="'.DataUtil::formatForDisplay($id).'"';
  93.     else {
  94.         $id '';
  95.     }
  96.     if (isset($class)) {
  97.         $class ' class="'.DataUtil::formatForDisplay($class).'"';
  98.     else {
  99.         $class '';
  100.     }
  101.  
  102.     // call the pnimg plugin and work out the src from the assigned template vars
  103.     smarty_function_pnimg(array('assign' => 'buttonsrc''src' => $src'set' => $set'modname' => 'core')$smarty);
  104.     $imgvars $smarty->get_template_vars('buttonsrc');
  105.     $imgsrc $imgvars['src'];
  106.  
  107.     // form the button html
  108.     if ($mode == 'button'{
  109.         $return '<button'.$id.$class.' type="'.DataUtil::formatForDisplay($type).'"'.$name.$value.' title="'.DataUtil::formatForDisplay($title).'"><img src="'.DataUtil::formatForDisplay($imgsrc).'" alt="'.DataUtil::formatForDisplay($alt).'" /></button>';
  110.     else {
  111.         $return '<input'.$id.$class.' type="image"'.$name.$value.' title="'.DataUtil::formatForDisplay($title).'" src="'.DataUtil::formatForDisplay($imgsrc).'" alt="'.DataUtil::formatForDisplay($alt).'" />';
  112.     }
  113.  
  114.     if (isset($assign)) {
  115.         $smarty->assign($assign$return);
  116.     else {
  117.         return $return;
  118.     }
  119. }

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