<?php
/**
 * Smarty plugin
 * ----------------------------------------------------------------
 * Type:     modifier
 * Name:     normalize
 * Purpose:  converts string to legal html id attribute
 * 
 * Author:   Ken Griffith, kengriffith@gmail.com /
 *        http://dev.cmsmadesimple.org/users/kendo451/
 * ----------------------------------------------------------------
 **/
function smarty_cms_modifier_normalize($string)
{
  
  	$gCms = cmsms();
	$smarty =& $gCms->getSmarty();

	$string = strip_tags($string);

	$old_pattern = array("/[^a-zA-Z0-9]/", "/_+/", "/_$/");
	$new_pattern = array("_", "_", "");

	$newstring = strtolower(preg_replace($old_pattern, $new_pattern , $string));

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