src/View/Helper/AlaxosHtmlHelper.php
public function encodeEmail($email)
	{
		$this->includeAlaxosEncodeJS();

		$js_code = '<script type="text/javascript">';

		$email_id = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, 1) . intval(mt_rand()); //valid XHTML tag id can not start with a number
		$js_code .= 'alaxos_' . $email_id . '=';

		for($i = 0; $i < strlen($email); $i++)
		{
			$char = strtolower($email[$i]);

			switch($char)
			{
				case '.':
					$js_code .= 'l_dot.charAt(0)';
					break;
				case '_':
					$js_code .= 'l_under.charAt(0)';
					break;
				case '-':
					$js_code .= 'l_dash.charAt(0)';
					break;
				case '@':
					$js_code .= 'l_at.charAt(0)';
					break;
				default:
					$js_code .= 'l_' . $char . '.charAt(0)';
					break;
			}

			$js_code .= ($i < strlen($email) - 1) ? '+' : '';
		}

		if(!$this->getView()->getRequest()->is('ajax'))
		{
			$js_code .= ';' . $this->getConfig('jquery_variable') . '(document).ready(function(){	' . $this->getConfig('jquery_variable') . '("#' . $email_id . '").attr("href", "mailto:" + alaxos_' . $email_id . ');' . $this->getConfig('jquery_variable') . '("#' . $email_id . '").html(alaxos_' . $email_id . ');	});</script><a id="' . $email_id . '"><em>missing email</em></a>';
		}
		else
		{
			$js_code .= ';' . $this->getConfig('jquery_variable') . '("#' . $email_id . '").attr("href", "mailto:" + alaxos_' . $email_id . ');' . $this->getConfig('jquery_variable') . '("#' . $email_id . '").html(alaxos_' . $email_id . ');</script><a id="' . $email_id . '"><em>missing email</em></a>';
		}

		return $js_code;
	}
public function encodeEmail($email)
	{
		$this->includeAlaxosEncodeJS();

		$js_code = '<script type="text/javascript">';

		$email_id = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, 1) . intval(mt_rand()); //valid XHTML tag id can not start with a number
		$js_code .= 'alaxos_' . $email_id . '=';

		for($i = 0; $i < strlen($email); $i++)
		{
			$char = strtolower($email[$i]);

			switch($char)
			{
				case '.':
					$js_code .= 'l_dot.charAt(0)';
					break;
				case '_':
					$js_code .= 'l_under.charAt(0)';
					break;
				case '-':
					$js_code .= 'l_dash.charAt(0)';
					break;
				case '@':
					$js_code .= 'l_at.charAt(0)';
					break;
				default:
					$js_code .= 'l_' . $char . '.charAt(0)';
					break;
			}

			$js_code .= ($i < strlen($email) - 1) ? '+' : '';
		}

		if(!$this->getView()->getRequest()->is('ajax'))
		{
			$js_code .= ';' . $this->getConfig('jquery_variable') . '(document).ready(function(){	' . $this->getConfig('jquery_variable') . '("#' . $email_id . '").attr("href", "mailto:" + alaxos_' . $email_id . ');' . $this->getConfig('jquery_variable') . '("#' . $email_id . '").html(alaxos_' . $email_id . ');	});</script><a id="' . $email_id . '"><em>missing email</em></a>';
		}
		else
		{
			$js_code .= ';' . $this->getConfig('jquery_variable') . '("#' . $email_id . '").attr("href", "mailto:" + alaxos_' . $email_id . ');' . $this->getConfig('jquery_variable') . '("#' . $email_id . '").html(alaxos_' . $email_id . ');</script><a id="' . $email_id . '"><em>missing email</em></a>';
		}

		return $js_code;
	}
public function encodeEmail ( $ email ) { $ this -> includeAlaxosEncodeJS ( ) ; $ js_code = '<script type="text/javascript">' ; $ email_id = substr ( str_shuffle ( 'abcdefghijklmnopqrstuvwxyz' ) , 0 , 1 ) . intval ( mt_rand ( ) ) ; //valid XHTML tag id can not start with a number $ js_code .= 'alaxos_' . $ email_id . '=' ; for ( $ i = 0 ; $ i < strlen ( $ email ) ; $ i ++ ) { $ char = strtolower ( $ email [ $ i ] ) ; switch ( $ char ) { case '.' : $ js_code .= 'l_dot.charAt(0)' ; break ; case '_' : $ js_code .= 'l_under.charAt(0)' ; break ; case '-' : $ js_code .= 'l_dash.charAt(0)' ; break ; case '@' : $ js_code .= 'l_at.charAt(0)' ; break ; default : $ js_code .= 'l_' . $ char . '.charAt(0)' ; break ; } $ js_code .= ( $ i < strlen ( $ email ) - 1 ) ? '+' : '' ; } if ( ! $ this -> getView ( ) -> getRequest ( ) -> is ( 'ajax' ) ) { $ js_code .= ';' . $ this -> getConfig ( 'jquery_variable' ) . '(document).ready(function(){	' . $ this -> getConfig ( 'jquery_variable' ) . '("#' . $ email_id . '").attr("href", "mailto:" + alaxos_' . $ email_id . ');' . $ this -> getConfig ( 'jquery_variable' ) . '("#' . $ email_id . '").html(alaxos_' . $ email_id . ');	});</script><a id="' . $ email_id . '"><em>missing email</em></a>' ; } else { $ js_code .= ';' . $ this -> getConfig ( 'jquery_variable' ) . '("#' . $ email_id . '").attr("href", "mailto:" + alaxos_' . $ email_id . ');' . $ this -> getConfig ( 'jquery_variable' ) . '("#' . $ email_id . '").html(alaxos_' . $ email_id . ');</script><a id="' . $ email_id . '"><em>missing email</em></a>' ; } return $ js_code ; }
Return a string that is a JS encoded email address.

Printing this JS string instead of the plain email text should reduce the probability to get the email harvested by spamming robots.

Note:
The returned string is made of a <script> block and a <a> block.

@param $email
Return a string that is a JS encoded email address .