cvs: pear /HTML_Javascript/Javascript Convert.php

From: Date: Wed, 07 Apr 2004 10:48:49 +0000
Subject: cvs: pear /HTML_Javascript/Javascript Convert.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-17979@lists.php.net to get a copy of this message
alan_k Wed Apr 7 06:48:49 2004 EDT Modified files: /pear/HTML_Javascript/Javascript Convert.php Log: add null support http://cvs.php.net/diff.php/pear/HTML_Javascript/Javascript/Convert.php?r1=1.11&r2=1.12&ty=u Index: pear/HTML_Javascript/Javascript/Convert.php diff -u pear/HTML_Javascript/Javascript/Convert.php:1.11 pear/HTML_Javascript/Javascript/Convert.php:1.12 --- pear/HTML_Javascript/Javascript/Convert.php:1.11 Wed Apr 7 06:25:33 2004 +++ pear/HTML_Javascript/Javascript/Convert.php Wed Apr 7 06:48:48 2004 @@ -16,7 +16,7 @@ // | Authors: Tal Peer <tal@php.net> | // | Pierre-Alain Joye <paj@pearfr.org> | // +----------------------------------------------------------------------+ -// $Id: Convert.php,v 1.11 2004/04/07 10:25:33 alan_k Exp $ +// $Id: Convert.php,v 1.12 2004/04/07 10:48:48 alan_k Exp $ /** * A class for converting PHP variables into JavaScript variables * @@ -147,6 +147,11 @@ $var, $varname, $global ); break; + case 'NULL': + return HTML_Javascript_Convert::convertArray( + $varname, $global + ); + break; default: return HTML_Javascript_Convert::raiseError( HTML_JAVASCRIPT_ERROR_INVVAR @@ -214,14 +219,14 @@ /** * Converts a PHP boolean variable into a JS boolean variable. - * Note this function does not check the type of $book, only if + * Note this function does not check the type of $bool, only if * the expression $bool is true or false. * * @access public * @param boolean $bool the boolean variable * @param string $varname the variable name to declare * @param boolean $global set to true to make the JS variable global - * @return mixed a PEAR_Error on error or a string with the declaration + * @return string the value as javascript */ function convertBoolean($bool, $varname, $global = false) { @@ -235,6 +240,27 @@ } // }}} convertBoolean + // {{{ convertNull + + /** + * Converts a PHP null variable into a JS null value. + * + * @access public + * @param string $varname the variable name to declare + * @param boolean $global set to true to make the JS variable global + * @return string the value as javascript + */ + function convertNull($varname, $global = false) + { + $var = ''; + if($global) { + $var = 'var '; + } + return $varname.' = null;'.HTML_JAVASCRIPT_NL; + } + + // }}} convertNull + // {{{ convertArray /** @@ -357,6 +383,8 @@ $val, $varname, $global ); break; + case 'NULL': + return 'null'; default: return HTML_Javascript_Convert::raiseError( HTML_JAVASCRIPT_ERROR_INVVAR

« previous php.pear.cvs (#17979) next »