Exemplo n.º 1
0
 /**
  * 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;
 }