예제 #1
0
<html>
<body>
<?php 
//ini_set('include_path','.:/data/peartest/share/pear');
//ini_set('include_path','.:/data/pear/cvsroot/pear:/data/pear/cvsroot/php4/pear');
require_once 'HTML/Javascript.php';
require_once 'HTML/Javascript/Convert.php';
// ,array(741,742,743)
$test = array("foo1" => "this \\ is a string test &\" and 'nothing' must failed", "foo2" => 2, "foo3" => 3, "foo4" => 4, "foo5" => 5, "foo6" => 6, "foo7" => array(71, 72, 73, "foo74" => array(741, 742, 743)));
$js = new HTML_Javascript();
echo $js->startScript();
echo HTML_Javascript_Convert::convertArray($test, 'arTest', true);
echo HTML_Javascript::alert('toto');
echo HTML_Javascript::prompt('toto', 'toto');
echo $js->confirm('sure', 'Are you sure?!');
echo $js->popup('win', './test.html', 'window', 200, 200, false);
echo $js->popupWrite('win2', 'Foo? Bar!', 'window2222222222222222222222', 200, 200, true);
echo $js->endScript();
?>
<script>


function interrogate(what) {
    var output = '';
    for (var i in what){
        output += i+ " ";
    }
    alert(output);
}

</script>
예제 #2
0
파일: Convert.php 프로젝트: roojs/pear
 /**
  * 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));
     }
 }
예제 #3
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;
 }
예제 #4
0
 /**
  * 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;
     }
 }
예제 #5
0
    echo htmlspecialchars($t->GetUserName());
}
?>
: Врач: Приём</title>
  </head>

  <body>
    <?php 
if ($t->popup_url) {
    ?>
        <?php 
    require_once 'HTML/Javascript/Convert.php';
    ?>
<script type='text/javascript'>
<?php 
    $__tmp = HTML_Javascript_Convert::convertVar($t->popup_url, 'popup_url', true);
    echo is_a($__tmp, "PEAR_Error") ? "<pre>" . print_r($__tmp, true) . "</pre>" : $__tmp;
    ?>
</script>
        <script language="javascript"><!--
            var s =  popup_url;
            var vWnd = window.open(popup_url, "print_popup", "location=0; menubar=0; resizable=1; scrollbars=0; status=0; toolbar=0;");
            vWnd.focus();
        --></script>
    <?php 
}
?>
    <table cellspacing="0" cellpadding="4">
      <tr>
        <td valign="top" class="maintable">
          <?php