<?php
/**
 * Smarty plugin
 * ----------------------------------------------------------------
 * Type:     modifier
 * Name:     dropcap
 * Purpose:  Wraps string in p tags
 * 			 wraps first letter in span class = $dropclass
 *           wraps remainder in span with no class
 * Author:   Ken Griffith, kengriffith@gmail.com /
 *        http://dev.cmsmadesimple.org/users/kendo451/
 * ----------------------------------------------------------------
 **/
function smarty_cms_modifier_dropcaps($string,$dropclass='firstLetter')
{
  /** Clean HTML tags from string first **/
  $string=strip_tags($string);
  
  $str_array = str_split( $string ); 
  
  $newstring = '<p>';
  
  foreach ( $str_array as $index => $char)
  
	{
		if ( $index == 0 ){
			
			$newstring .= '<span class="' . $dropclass . '"><span>' . $char . '</span></span><span>';
			}
		elseif ( $index == ( strlen( $string) - 1) ){
			$newstring .= $char . '</span></p>';
			}
		else $newstring .= $char;

	}
  return $newstring;    
}//end of function
?>
