home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / class / smarty / plugins / function.popup.php < prev    next >
Encoding:
PHP Script  |  2007-09-09  |  3.2 KB  |  120 lines

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8.  
  9. /**
  10.  * Smarty {popup} function plugin
  11.  *
  12.  * Type:     function<br>
  13.  * Name:     popup<br>
  14.  * Purpose:  make text pop up in windows via overlib
  15.  * @link http://smarty.php.net/manual/en/language.function.popup.php {popup}
  16.  *          (Smarty online manual)
  17.  * @author   Monte Ohrt <monte at ohrt dot com>
  18.  * @param array
  19.  * @param Smarty
  20.  * @return string
  21.  */
  22. function smarty_function_popup($params, &$smarty)
  23. {
  24.     $append = '';
  25.     foreach ($params as $_key=>$_value) {
  26.         switch ($_key) {
  27.             case 'text':
  28.             case 'trigger':
  29.             case 'function':
  30.             case 'inarray':
  31.                 $$_key = (string)$_value;
  32.                 if ($_key == 'function' || $_key == 'inarray')
  33.                     $append .= ',' . strtoupper($_key) . ",'$_value'";
  34.                 break;
  35.  
  36.             case 'caption':
  37.             case 'closetext':
  38.             case 'status':
  39.                 $append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'";
  40.                 break;
  41.  
  42.             case 'fgcolor':
  43.             case 'bgcolor':
  44.             case 'textcolor':
  45.             case 'capcolor':
  46.             case 'closecolor':
  47.             case 'textfont':
  48.             case 'captionfont':
  49.             case 'closefont':
  50.             case 'fgbackground':
  51.             case 'bgbackground':
  52.             case 'caparray':
  53.             case 'capicon':
  54.             case 'background':
  55.             case 'frame':
  56.                 $append .= ',' . strtoupper($_key) . ",'$_value'";
  57.                 break;
  58.  
  59.             case 'textsize':
  60.             case 'captionsize':
  61.             case 'closesize':
  62.             case 'width':
  63.             case 'height':
  64.             case 'border':
  65.             case 'offsetx':
  66.             case 'offsety':
  67.             case 'snapx':
  68.             case 'snapy':
  69.             case 'fixx':
  70.             case 'fixy':
  71.             case 'padx':
  72.             case 'pady':
  73.             case 'timeout':
  74.             case 'delay':
  75.                 $append .= ',' . strtoupper($_key) . ",$_value";
  76.                 break;
  77.  
  78.             case 'sticky':
  79.             case 'left':
  80.             case 'right':
  81.             case 'center':
  82.             case 'above':
  83.             case 'below':
  84.             case 'noclose':
  85.             case 'autostatus':
  86.             case 'autostatuscap':
  87.             case 'fullhtml':
  88.             case 'hauto':
  89.             case 'vauto':
  90.             case 'mouseoff':
  91.             case 'followmouse':
  92.             case 'closeclick':
  93.                 if ($_value) $append .= ',' . strtoupper($_key);
  94.                 break;
  95.  
  96.             default:
  97.                 $smarty->trigger_error("[popup] unknown parameter $_key", E_USER_WARNING);
  98.         }
  99.     }
  100.  
  101.     if (empty($text) && !isset($inarray) && empty($function)) {
  102.         $smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required");
  103.         return false;
  104.     }
  105.  
  106.     if (empty($trigger)) { $trigger = "onmouseover"; }
  107.  
  108.     $retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\'';
  109.     $retval .= $append . ');"';
  110.     if ($trigger == 'onmouseover')
  111.        $retval .= ' onmouseout="nd();"';
  112.  
  113.  
  114.     return $retval;
  115. }
  116.  
  117. /* vim: set expandtab: */
  118.  
  119. ?>
  120.