- add missing Smarty plugin

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@887 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Sebastian 14 years ago
parent cc3972a3c5
commit 1ad8eafdff

@ -0,0 +1,55 @@
<?php
/**
* Smarty shared plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Function: smarty_needle
* Purpose: Used to find a string in a string
* Options: enter "case" to make case senstative
* Example: needle( 'Gabe-was-here', 'here' ) returns true
* Example2: needle( 'Gabe was here', 'gabe' ) returns true
* Example: needle ('Gabe was there', 'sde') returns false
* Smarty Sample: {$haystack|needle:"string"}
* Smarty Sample: {$haystack|needle:"string":"case"}
* @author Gabe LeBlanc "raven"
* @param string
* @return boolean
*/
function smarty_modifier_needle($haystack, $needle, $cases = "nocase") {
if(!empty($haystack) ) {
if($cases == "nocase") {
if(stristr($haystack, $needle)) {
return true;
}else{
return false;
}
}elseif($cases == "case") {
if(strstr($haystack, $needle)) {
return true;
}else{
return false;
}
}
}else{
return false;
}
}
?>
Loading…
Cancel
Save