Exemplo n.º 1
0
 function ka_php2js($a)
 {
     if (is_null($a)) {
         return 'null';
     }
     if ($a === false) {
         return 'false';
     }
     if ($a === true) {
         return 'true';
     }
     if (is_scalar($a)) {
         $a = addslashes($a);
         //   $a = str_replace("'", '\\\'', $a);
         $a = str_replace("\n", '\\n', $a);
         $a = str_replace("\r", '\\r', $a);
         return "'{$a}'";
     }
     $isList = true;
     for ($i = 0, reset($a); $i < count($a); $i++, next($a)) {
         if (key($a) !== $i) {
             $isList = false;
             break;
         }
     }
     $result = array();
     if ($isList) {
         foreach ($a as $v) {
             $result[] = KA::_php2js($v);
         }
         return '[ ' . join(',', $result) . ' ]';
     } else {
         foreach ($a as $k => $v) {
             $result[] = KA::_php2js($k) . ': ' . KA::_php2js($v);
         }
         return '{ ' . join(',', $result) . ' }';
     }
 }
Exemplo n.º 2
0
 function get_head()
 {
     $title = $this->map['title'] != '' ? $this->config['site']['name'] . $this->map['title'] : $this->config['site']['name'];
     // create head and ajax parts ---
     require_once "lib/ajax.lib.php";
     $ajax = new KA();
     $ajax->js_error = "alert(type);";
     $ajax->timeout = 30;
     //   export to ajax names of back-end functions
     if ($this->back_names != '') {
         foreach ($this->back_names as $val) {
             $ajax->export($val);
         }
     }
     $ajax->header = "Content-type: text/html; charset=UTF-8";
     $ajax->init();
     $ajax_js = $ajax->get_javascript();
     $jscode = $this->config['site']['js_include'] . $ajax_js . $this->map['js_functions'];
     $jsonload = $this->map['js_onload'] ? "onload='" . $this->map['js_onload'] . "'" : "";
     $this->map['head'] = "<!DOCTYPE html><html>\n<head>\n<title>" . $title . "</title>\n<link href='./css/" . $this->map['style'] . "' rel='stylesheet' type='text/css'>\n<meta http-equiv='content-type' content='text/html; charset=UTF-8'>\n<script src='js/jquery-2.1.1.min.js' type='text/javascript'></script>\n" . $this->map['js_include'] . "\n</head>\n<body " . $jsonload . ">\n<script language='JavaScript' >" . $jscode . "\n</script>";
 }