/** * Converts a variable value to its javascript equivalent. * String variables are escaped (see {@link escapeString()}). * * @param string $param coment * @access public * @return mixed return */ function convertValue($val) { switch (gettype($val)) { case 'boolean': return $val ? 'true' : 'false'; case 'integer': case 'double': return $val; case 'string': return "'" . HTML_Javascript_Convert::escapeString($val) . "'"; case 'array': return HTML_Javascript_Convert::convertArray($val, $varname, $global); break; default: return HTML_Javascript_Convert::raiseError(HTML_JAVASCRIPT_ERROR_INVVAR); break; } }
/** * Converts a variable value to its javascript equivalent. * String variables are escaped (see {@link escapeString()}). * * @param string $param coment * @access public * @return mixed return */ static function convertValue($val) { switch (gettype($val)) { case 'boolean': return $val ? 'true' : 'false'; case 'integer': case 'double': return $val; case 'string': return "'" . HTML_Javascript_Convert::escapeString($val) . "'"; case 'array': return HTML_Javascript_Convert::convertArray($val, $varname, $global); case 'NULL': return 'null'; default: return HTML_Javascript_Convert::raiseError(HTML_JAVASCRIPT_ERROR_CONVERT_INVVAR, __FUNCTION__ . ':' . gettype($val)); } }
/** * Creates a new popup window containing a string. Inside the popup windows * you can access the opener window with the opener var. * * @param string $assign the JS variable to assign the window to * @param string $str the string that will appear in the new window * (HTML tags would be parsed by the browser, of course) * @param string $title the title of the window * @param int $width the width of the window * @param int $height the height of the window * @param mixed $attr see popup() * @param int $top distance from the top (in pixels * @param int $left distance from the left (in pixels) * @see popup() * @return the processed string */ function popupWrite($assign, $str, $title, $width, $height, $attr, $top = 300, $left = 300) { static $cnt_popup; $str = HTML_Javascript_Convert::escapeString($str); $assign = strlen($assign) == 0 ? 'pearpopup' . $cnt_popup++ : $assign; if ($attr) { $attr = array('yes', 'yes', 'yes', 'yes', 'yes', 'yes', $top, $left); } else { $attr = array('no', 'no', 'no', 'no', 'no', 'no', $top, $height); } $windows = $assign . "= window.open(\"\"," . " \"{$title}\"," . " \"width={$width}, height={$height}," . " resizable={$attr['0']}, scrollbars={$attr['1']}," . " menubar={$attr['2']}, toolbar={$attr['3']}," . " status={$attr['4']}, location={$attr['5']}," . " top={$attr['6']}, left={$attr['7']}\")" . HTML_JAVASCRIPT_NL; $windows .= "\n if ({$assign}){\n {$assign}.focus();\n {$assign}.document.open();\n {$assign}.document.write('{$str}');\n {$assign}.document.close();\n if ({$assign}.opener == null) {$assign}.opener = self;\n }\n "; $ret = HTML_Javascript::_out($windows); return $ret; }