示例#1
0
  function show_mss($classes, $keys, $bounds, $options=array()) { 
    global $class_info;
    global $map_key_cascadenik_aliases;
    global $map_key_cascadenik_hide;

//    print_r($class_info);
    if($options[geom])
      $default_geom=$options[geom];
    else
      $default_geom=array();

    $style=array();

    foreach($classes as $class_index=>$class) {
      $dep_list=array(array());
      //foreach($keys as $k=>$vs) {
      $keys_keys=array_keys($keys);
      for($i=sizeof($keys_keys)-1; $i>=0; $i--) {
	$k=$keys_keys[$i];
	$vs=$keys[$k];
        if($vs=="*") {
          $new_dep_list=array();
	  if($class_info[$class]["keys"][$k]) {
	    foreach($class_info[$class]["keys"][$k] as $v) {
	      if(!sizeof($dep_list)) {
		$new_dep_list[]=array("$k$v");
	      }
	      else {
		foreach($dep_list as $d) {
		  $new_dep_list[]=array_merge(array("$k$v"), $d);
		}
	      }
	    }
	    $dep_list=$new_dep_list;
	  }
        }
        elseif(is_string($vs)) {
          $new_dep_list=array();
          if(!sizeof($dep_list)) {
            $dep_list[]=array("$k$vs");
          }
          else {
            foreach($dep_list as $d) {
              $new_dep_list[]=array_merge($d, array("$k$vs"));
            }
            $dep_list=$new_dep_list;
          }
        }
        else {
          $new_dep_list=array();
          foreach($vs as $v) {
            if(!sizeof($dep_list)) {
              $new_dep_list[]=array("$k$v");
            }
            else {
              foreach($dep_list as $d) {
                $new_dep_list[]=array_merge(array("$k$v"), $d);
              }
            }
          }
          $dep_list=$new_dep_list;
        }

//        foreach($dep_list) {
//        sort($dep_list);
//        $dep_list=implode("|", $dep_list);
//
//        $style[$dep_list][$class]=$class_info[$class]["styles"][$dep_list];
      }
    }

    foreach($classes as $class_index=>$class) {
      //print_r($dep_list);
      foreach($dep_list as $d) {
//	$ds=array();
//	foreach($keys as $k=>$dummy) {
//	  if($d[$k])
//	    $ds[]=$d[$k];
//	}
//	$d=$ds;
        //rsort($d);
        $d_key=implode("|", $d);
        for($i=0; $i<pow(2, sizeof($d)); $i++) {
          $d1=array();
          for($j=0; $j<sizeof($d); $j++) {
            if(pow(2, $j)&$i) {
              $d1[]=$d[$j];
            }
          }

          $d1_key=implode("|", $d1);
	  if($class_info[$class]["styles"][$d1_key])
	  foreach($class_info[$class]["styles"][$d1_key] as $column=>$this_style) {
//            print "$class_index $d1_key\n";
	  if(!$style[$d_key][$class_index][$column])
	    $style[$d_key][$class_index][$column]=array("column"=>$column);
	    if($this_style) {
	      //print "$class_index $d1_key\n";
	      $style[$d_key][$class_index][$column]=
		array_merge($style[$d_key][$class_index][$column], $this_style);
	      //print_r($this_style);
	      //print_r($style[$d_key][$class_index]);
	    }
	  }
        }
      }
    }

    $new_style=array();
    foreach($style as $depend=>$s1) {
      foreach($s1 as $s) {
	foreach($s as $style) {
	  $new_style[$depend][]=$style;
	}
      }
    }
    $style=$new_style;

    foreach($style as $depend=>$s) {
      $p=array();
      $geom=$default_geom;

      foreach($s as $index=>$s1) {
        if($s1["line-width"])
          $geom["line"]=1;
        if($s1["line-pattern-file"]) {
	  if(preg_match("/^url\('(.*)'\)$/", $s1['line-pattern-file'], $m))
	    $s[$index]['line-pattern-file']="{$options['img_base_path']}/$m[1]";
          $geom["line"]=1;
	}
        if($s1["polygon-pattern-file"]) {
	  if(preg_match("/^url\('(.*)'\)$/", $s1['polygon-pattern-file'], $m))
	    $s[$index]['polygon-pattern-file']="{$options['img_base_path']}/$m[1]";
          $geom["poly"]=1;
	}
        if($s1["point-file"]) {
	  if(preg_match("/^url\('(.*)'\)$/", $s1['point-file'], $m))
	    $s[$index]['point-file']="{$options['img_base_path']}/$m[1]";
          $geom["point"]=1;
	}
        if($s1["polygon-fill"])
          $geom["poly"]=1;
        if($s1["point-file"])
          $geom["point"]=1;
        if($s1["text-size"])
          $geom["point"]=1;
      }

      if($map_key_cascadenik_hide[$depend])
        continue;

      if(sizeof($geom)) {
        $ret.="<tr><td>\n";
        build_request($s, "param", &$p);
        $param=implode("&", $p);

	if($geom["poly"])
	  $ret.="<div><embed width='30' height='12' type='image/svg+xml' src='plugins/map_key/symbol_polygon.php?$param' /></div>";
	elseif($geom["line"])
	  $ret.="<div><embed width='30' height='12' type='image/svg+xml' src='plugins/map_key/symbol_line.php?$param' /></div>";
	elseif($geom["point"])
	  $ret.="<div><embed width='30' height='30' type='image/svg+xml' src='plugins/map_key/symbol_point.php?$param' /></div>";
        $ret.="</td><td>\n";

        // Compile name
        if(!isset($options['name_prefix']))
          $options['name_prefix']="tag:";
        if(!($name=$map_key_cascadenik_aliases[$depend]))
          $name=$depend;
        if(isset($options['tags_format'])) {
          $options['tags_format']['prefix']=$options['name_prefix'];
          $name=explode("|", $name);
          $name=tags_format($name, $options['tags_format']);
        }
        else if((!isset($options['name_explode'])||($options['name_explode']))) {
          $name=explode("|", $name);
          for($i=0; $i<sizeof($name); $i++)
            $name[$i]=lang("{$options['name_prefix']}{$name[$i]}");
          $name=implode(", ", $name);
        }
        else {
          $name=lang("{$options['name_prefix']}{$name}");
        }
        $ret.=$name;

        $ret.="</td></tr>\n";
      }
    }

    return $ret;
  }
示例#2
0
    $searchIndex = $idx;
    //$displaySI = $searchIndex;
    if (!in_array($searchIndex, $categories)) {
        $keyword .= ' ' . $searchIndex;
        $searchIndex = 'All';
        // reassign All
    }
    $keyword = str_replace(" ", "+", $keyword);
    $keyword = urlencode($keyword);
    $operation = 'ItemSearch';
    //$searchIndex = 'All';
    $service = 'AWSECommerceService';
    $version = '2011-08-01';
    $responseGroup = 'ItemAttributes,Images';
    $browseNode = $nodeID;
    $string_to_sign = build_request($keyword, $searchIndex, $operation, $service, $version, $responseGroup, 0, $browseNode);
    $signature = get_signature($string_to_sign);
    $request = $cg['amazonUrl'] . '?' . $string_to_sign;
    $request .= "&Signature=" . $signature;
    $maxPage = $searchIndex == 'All' ? 5 : 10;
    //$response = file_get_contents($request);
    $response = curl_string($request);
} else {
    $response = false;
}
if ($response) {
    $xml = array();
    $res = simplexml_load_string($response);
    //echo '<meta charset="utf-8">';
    //echo $string_to_sign . '<br/>';
    //echo '<pre>';