Commit 0c2397ec authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

hide dirs: .xxx and _xxx, 'showall' to reveal

parent 94c70f40
...@@ -6,12 +6,18 @@ var markers = []; ...@@ -6,12 +6,18 @@ var markers = [];
$(function(){ $(function(){
//init(); //init();
parseURL();
init_maps(); init_maps();
var url = 'list.php';
if (SETTINGS.showall){
url += "?showall";
}
$.ajax({ $.ajax({
url: "list.php", url: url,
success: function(response){ success: function(response){
List = response; List = response;
...@@ -24,6 +30,21 @@ $(function(){ ...@@ -24,6 +30,21 @@ $(function(){
}); });
var SETTINGS = {
'showall':false
};
// no comments
function parseURL(){
var parameters=location.href.replace(/\?/ig,"&").split("&");
for (var i=0;i<parameters.length;i++) parameters[i]=parameters[i].split("=");
for (var i=1;i<parameters.length;i++) {
switch (parameters[i][0]) {
case "showall": SETTINGS.showall = true; break;
}
}
}
function parse_list(res){ function parse_list(res){
var index = 0; var index = 0;
......
...@@ -5,53 +5,59 @@ $base = "models"; ...@@ -5,53 +5,59 @@ $base = "models";
$THUMBNAME = "thumb.jpeg"; $THUMBNAME = "thumb.jpeg";
$READMENAME = "README.txt"; $READMENAME = "README.txt";
$models = selective_scandir($base); $showall = false;
if (isset($_GET['showall'])){
$showall = true;
}
$models = selective_scandir($base,false);
$res = ""; $res = "";
foreach($models as $model){ foreach($models as $model){
$model_path = "$base/$model"; $model_path = "$base/$model";
$thumb = "$model_path/$THUMBNAME"; $thumb = "$model_path/$THUMBNAME";
$versions = selective_scandir($model_path); $versions = selective_scandir($model_path,$showall);
// create thumb // create thumb
create_thumbnail($model_path,$versions,$thumb); create_thumbnail($model_path,$versions,$thumb);
if (!is_file($thumb)){ if (!is_file($thumb)){
$thumb=""; $thumb="";
} }
$res .= "<model name='$model' thumb='$thumb'>\n"; $res .= "<model name='$model' thumb='$thumb'>\n";
// read kml // read kml
$res .= "\t<map>\n".parse_kml("$base/$model/$model.kml")."\t</map>\n"; $res .= "\t<map>\n".parse_kml("$base/$model/$model.kml")."\t</map>\n";
foreach($versions as $version){ foreach($versions as $version){
$res .= "\t<version name='$version'>\n"; $res .= "\t<version name='$version'>\n";
$comments = "-"; $comments = "-";
$readme = "$model_path/$version/$READMENAME"; $readme = "$model_path/$version/$READMENAME";
if (is_file($readme)){ if (is_file($readme)){
$comments = trim(file_get_contents($readme),"\t\n\r"); $comments = trim(file_get_contents($readme),"\t\n\r");
} }
$res .= "\t\t<comments>$comments</comments>\n"; $res .= "\t\t<comments>$comments</comments>\n";
$res .= "\t</version>\n"; $res .= "\t</version>\n";
} }
$res .= "</model>\n"; $res .= "</model>\n";
} }
return_xml($res); return_xml($res);
//functions //functions
function selective_scandir($path){ function selective_scandir($path,$showall){
$results = Array(); $results = Array();
...@@ -59,10 +65,17 @@ function selective_scandir($path){ ...@@ -59,10 +65,17 @@ function selective_scandir($path){
foreach($contents as $item){ foreach($contents as $item){
if ($item!='.'&&$item!='..'&&is_dir("$path/$item")){ if ($item!='.'&&$item!='..'&&is_dir("$path/$item")){
array_push($results,$item); if ($showall){
array_push($results,$item);
}else{
if (($item[0]!=".")&&($item[0]!="_")){
array_push($results,$item);
}
}
} }
} }
return $results; return $results;
} }
...@@ -81,40 +94,40 @@ function return_xml($str){ ...@@ -81,40 +94,40 @@ function return_xml($str){
function create_thumbnail($path,$vpaths,$thumbname){ function create_thumbnail($path,$vpaths,$thumbname){
if (!is_file($thumbname)){ if (!is_file($thumbname)){
if (count($vpaths)>=1){ if (count($vpaths)>=1){
$srcpath = "$path/{$vpaths[0]}"; $srcpath = "$path/{$vpaths[0]}";
$files = scandir($srcpath); $files = scandir($srcpath);
foreach($files as $file){ foreach($files as $file){
$test = preg_match('/(texture-bgnd-ext)/',$file); $test = preg_match('/(texture-bgnd-ext)/',$file);
if ($test){ if ($test){
$file = "$srcpath/$file"; $file = "$srcpath/$file";
if (extension_loaded('imagick')){ if (extension_loaded('imagick')){
$imagick = new Imagick($file); $imagick = new Imagick($file);
$imagick->trimImage(0); $imagick->trimImage(0);
$w = $imagick->getImageWidth(); $w = $imagick->getImageWidth();
$h = $imagick->getImageHeight(); $h = $imagick->getImageHeight();
$imagick->borderImage('black', 100, 100); $imagick->borderImage('black', 100, 100);
//$imagick->cropImage($w/2, $h/4, $w/4, $h/4); //$imagick->cropImage($w/2, $h/4, $w/4, $h/4);
$imagick->thumbnailImage(200, 100, true, true); $imagick->thumbnailImage(200, 100, true, true);
$imagick->writeImage($thumbname); $imagick->writeImage($thumbname);
} }
break; break;
} }
/* /*
$pinfo = pathinfo("$srcpath/$file"); $pinfo = pathinfo("$srcpath/$file");
if ($pinfo['extension']=="jpeg"){ if ($pinfo['extension']=="jpeg"){
...@@ -124,11 +137,11 @@ function create_thumbnail($path,$vpaths,$thumbname){ ...@@ -124,11 +137,11 @@ function create_thumbnail($path,$vpaths,$thumbname){
} }
*/ */
} }
} }
} }
return 0; return 0;
} }
...@@ -138,15 +151,15 @@ function parse_kml($file){ ...@@ -138,15 +151,15 @@ function parse_kml($file){
$res = ""; $res = "";
if (is_file($file)){ if (is_file($file)){
$xml = simplexml_load_file($file); $xml = simplexml_load_file($file);
$recs = $xml->Document->children(); $recs = $xml->Document->children();
foreach($recs as $rec){ foreach($recs as $rec){
$res .= "\t".$rec->Camera->asXML()."\n"; $res .= "\t".$rec->Camera->asXML()."\n";
} }
}else{ }else{
$res = <<<TEXT $res = <<<TEXT
<Camera> <Camera>
...@@ -161,7 +174,7 @@ TEXT; ...@@ -161,7 +174,7 @@ TEXT;
} }
return $res; return $res;
} }
?> ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment