0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-20 03:36:20 +02:00

- add missing Smarty plugin

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@887 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
Sebastian 2010-11-23 19:11:37 +00:00
parent cc3972a3c5
commit 1ad8eafdff

View File

@ -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;
}
}
?>