Automatically exported from code.google.com/p/planningalerts
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

120 řádky
3.2 KiB

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