Ejemplo n.º 1
0
 /**
  * Helper function that prints an array as js object. can call itself in case of nested arrays
  *
  * @return void
  */
 static function print_javascript($objects = array(), $print = true, $passed = "")
 {
     $output = "";
     if ($print) {
         $output .= "\n<script type='text/javascript' class='av-php-sent-to-frontend'>/* <![CDATA[ */ \n";
     }
     foreach ($objects as $key => $object) {
         if (is_array($object)) {
             if (empty($passed)) {
                 $output .= "var {$key} = {};\n";
                 $pass = $key;
             } else {
                 $output .= "{$passed}['{$key}'] = {};\n";
                 $pass = "******";
             }
             $output .= AviaHelper::print_javascript($object, false, $pass);
         } else {
             if (!is_numeric($object) && !is_bool($object)) {
                 $object = json_encode($object);
             }
             if (empty($object)) {
                 $object = "false";
             }
             if (empty($passed)) {
                 $output .= "var {$key} = {$object};\n";
             } else {
                 $output .= "{$passed}['{$key}'] = {$object};\n";
             }
         }
     }
     if ($print) {
         $output .= "\n /* ]]> */</script>\n\n";
         echo $output;
     }
     return $output;
 }
Ejemplo n.º 2
0
 function send_var_to_frontend()
 {
     //filter to add new map marker programmatically before they are passed to the frontend
     self::$js_vars = apply_filters('avf_gmap_vars', self::$js_vars);
     AviaHelper::print_javascript(self::$js_vars);
 }