Changeset 7132
- Timestamp:
- Oct 9, 2010, 12:28:05 AM (14 years ago)
- Location:
- extensions/GMaps
- Files:
-
- 5 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GMaps/admin/gmaps_admin.tpl
r7054 r7132 1 1 <h2 style="float:right;top:-24px;position:relative;height:auto;font-size:12px;font-weight:normal;">{$plugin.GMAPS_VERSION}</h2> 2 2 3 {if isset($errcode) and $errcode!=''} 4 <div class='errors' id='iErrorMsg'> 5 <p>{'gmaps_action_was_stopped'|@translate}</p> 6 <p style='font-style:italic;margin:0 30px;'>{$errcode}</p> 7 </div> 8 {/if} 9 3 10 {$GMAPS_BODY_PAGE} -
extensions/GMaps/admin/gmaps_category_maps.tpl
r7125 r7132 49 49 50 50 $('#iBDAssocMapId').bind('change', changeMapDisplayType); 51 $('[name=fBDAssocKmlFile]').bind('change', changeKmlFileSource); 51 52 52 53 loadList(); 53 54 } 55 56 /** 57 * called when the source of kml file changed 58 */ 59 var changeKmlFileSource = function () 60 { 61 switch($('[name=fBDAssocKmlFile]:checked').val()) 62 { 63 case 'N': 64 $('#iBDAssocKmlFileId').css('display', 'none'); 65 $('#iBDAssocKmlFileUrl').css('display', 'none'); 66 $('#iBDKmlWarning').css('display', 'none'); 67 break; 68 case 'S': 69 $('#iBDAssocKmlFileId').css('display', 'block'); 70 $('#iBDAssocKmlFileUrl').css('display', 'none'); 71 $('#iBDKmlWarning').css('display', 'block'); 72 break; 73 case 'U': 74 $('#iBDAssocKmlFileId').css('display', 'none'); 75 $('#iBDAssocKmlFileUrl').css('display', 'block'); 76 $('#iBDKmlWarning').css('display', 'block'); 77 break; 78 } 54 79 } 55 80 … … 196 221 $('#iBDAssocMapId').val($('#iBDAssocMapId option:first').val()); 197 222 $('#iBDAssocApplySubCat').val('y'); 223 $('#iBDAssocKmlNone').attr('checked', true); 224 $('#iBDAssocKmlFileId').val($('#iBDAssocKmlFileId option:first').val()); 198 225 $('#iBDAssocKmlFileUrl').val(''); 199 $('#iBDAssocIcon').val($('#iBDAssocIcon option: visible:first').val());226 $('#iBDAssocIcon').val($('#iBDAssocIcon option:first').val()); 200 227 $('#iBDAssocTitle').val(''); 201 228 } … … 207 234 $('#iBDAssocMapId').val(tmp.mapId); 208 235 $('#iBDAssocApplySubCat').val(tmp.applySubCat); 236 if(tmp.kmlFileId>0) 237 { 238 $('#iBDAssocKmlSelect').attr('checked', true); 239 } 240 else if(tmp.kmlFileUrl!='') 241 { 242 $('#iBDAssocKmlUrl').attr('checked', true); 243 } 244 else 245 { 246 $('#iBDAssocKmlNone').attr('checked', true); 247 } 248 $('#iBDAssocKmlFileId').val(tmp.kmlFileId); 209 249 $('#iBDAssocKmlFileUrl').val(tmp.kmlFileUrl); 210 250 $('#iBDAssocIcon').val(tmp.icon); … … 213 253 214 254 changeMapDisplayType(); 255 changeKmlFileSource(); 215 256 } 216 257 … … 269 310 mapId:$('#iBDAssocMapId').val(), 270 311 applySubCat:$('#iBDAssocApplySubCat').val(), 271 kmlFileUrl:$('#iBDAssocKmlFileUrl').val(), 312 kmlFileId:($('#iBDAssocKmlSelect').attr('checked'))?$('#iBDAssocKmlFileId').val():0, 313 kmlFileUrl:($('#iBDAssocKmlSelect').attr('checked'))?'':$('#iBDAssocKmlFileUrl').val(), 272 314 icon:$('#iBDAssocIcon').val(), 273 315 title:$('#iBDAssocTitle').val(), … … 339 381 <th>{'gmaps_category'|@translate}</th> 340 382 <th style="width:90px;">{'gmaps_apply_subcat'|@translate}</th> 341 <th style="width: 90px;">{'gmaps_mapType'|@translate}</th>342 <th style="width:35 6px;">{'gmaps_map'|@translate}</th>343 <th style="width: 90px;">{'gmaps_map_kmlfile'|@translate}</th>383 <th style="width:150px;">{'gmaps_mapType'|@translate}</th> 384 <th style="width:350px;">{'gmaps_map'|@translate}</th> 385 <th style="width:220px;">{'gmaps_map_associate_kmlfile'|@translate}</th> 344 386 <th width="40px"> </th> 345 387 </tr> … … 432 474 <td>{'gmaps_map_associate_kmlfile'|@translate}</td> 433 475 <td> 434 <input type="text" id="iBDAssocKmlFileUrl" maxlength='255' size='55' value=""> 476 <label><input type="radio" id='iBDAssocKmlNone' name="fBDAssocKmlFile" value="N"> {'gmaps_kml_file_none'|@translate}</label><br> 477 <label><input type="radio" id='iBDAssocKmlSelect' name="fBDAssocKmlFile" value="S"> {'gmaps_kml_file_selected'|@translate}</label><br> 478 <select style="margin-left:20px;margin-bottom:10px;" id="iBDAssocKmlFileId"> 479 {foreach from=$datas.kmlFiles item=file} 480 <option value='{$file.id}'>{$file.name}</option> 481 {/foreach} 482 </select> 483 484 <label><input type="radio" id='iBDAssocKmlUrl' name="fBDAssocKmlFile" value="U"> {'gmaps_kml_file_url'|@translate}</label><br> 485 <input style="margin-left:20px;" type="text" id="iBDAssocKmlFileUrl" maxlength='255' size='55' value=""><br> 486 <p id='iBDKmlWarning' class='helps' style="width:520px;padding-right:20px;">{'gmaps_kml_file_access'|@translate}</p> 487 435 488 </td> 436 489 </tr> -
extensions/GMaps/admin/gmaps_category_maps_iListMaps.tpl
r7125 r7132 4 4 <td>{$data.catName}</td> 5 5 <td style="width:90px;">{$data.applySubCat}</td> 6 <th style="width:150px;">{$data.displayType}</th> 7 <td style="width:300px;">{$data.mapName}</td> 8 <td style="width:90px;">{$data.mapKmlFile}</td> 6 <td style="width:150px;">{$data.displayType}</td> 7 <td style="width:350px;">{$data.mapName}</td> 8 <td style="width:220px;"> 9 {if $data.mapKmlFile==''} 10 {'gmaps_n'|@translate} 11 {else} 12 {'gmaps_y'|@translate} <span style='font-style:italic;'>({$data.mapKmlFile})</span> 13 {/if} 14 </td> 9 15 10 16 <td width="40px"> -
extensions/GMaps/gmaps.css
r7128 r7132 1 1 #iHeaderListMaps { width:100%; border:1px solid; border-collapse: collapse; margin-top:3px; } 2 #iListMaps, #iListAssoc { width:100%; border:1px solid; height:280px; border-top:0px; overflow:auto; position:relative; left:-1px;} 3 #iListMapsNb, #iListAssocNb { width:99%; text-align:right; margin-bottom:8px; padding:2px; font-size:80%; } 4 #iListMaps table, table.listMaps, #iListAssoc table { width:100%; text-align:left; border-collapse: collapse; } 5 #iListMaps.roma table tr:hover, #iListAssoc.roma table tr:hover { cursor:pointer; background:#303030; } 6 #iListMaps.clear table tr:hover, #iListAssoc.clear table tr:hover { cursor:pointer; color: #D54E21; background:#dbe8f3; } 2 #iListMaps, #iListAssoc, #iListKml { width:100%; border:1px solid; height:280px; border-top:0px; overflow:auto; position:relative; left:-1px;} 3 #iListMapsNb, #iListAssocNb, #iListKmlNb { width:99%; text-align:right; margin-bottom:8px; padding:2px; font-size:80%; } 4 5 #iListMaps table, table.listMaps, 6 #iListAssoc table, 7 #iListKml table { width:100%; text-align:left; border-collapse: collapse; } 8 9 #iListMaps.roma table tr:hover, 10 #iListAssoc.roma table tr:hover, 11 #iListKml.roma table tr:hover { cursor:pointer; background:#303030; } 12 13 #iListMaps.clear table tr:hover, 14 #iListAssoc.clear table tr:hover, 15 #iListKml.clear table tr:hover { cursor:pointer; color: #D54E21; background:#dbe8f3; } 16 7 17 div.addMap { text-align:left; } 8 18 -
extensions/GMaps/gmaps2.css
r7128 r7132 140 140 position:absolute; 141 141 z-index:1500; 142 background:# 000000;142 background:#ffffff; 143 143 opacity:0.55; 144 144 filter:alpha(opacity:55); -
extensions/GMaps/gmaps_aip.class.inc.php
r7128 r7132 50 50 l10n('gmaps_associate_category_maps'), 51 51 $this->getAdminLink()."&fGMaps_tabsheet=category_maps"); 52 /*53 52 $this->tabsheet->add('kml_files', 54 53 l10n('gmaps_kml_files_management'), 55 $this->getAdminLink()."&fGMaps_tabsheet=kml_files"); */54 $this->getAdminLink()."&fGMaps_tabsheet=kml_files"); 56 55 $this->tabsheet->add('search', 57 56 l10n('gmaps_search'), … … 128 127 129 128 $template->assign('plugin', $template_plugin); 129 130 if($_REQUEST['errcode']!='') 131 { 132 $template->assign('errcode', l10n('gmaps_error_code_'.$_REQUEST['errcode'])); 133 } 134 130 135 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 131 136 … … 144 149 { 145 150 //initialise $REQUEST values if not defined 151 152 if(!isset($_REQUEST['errcode'])) $_REQUEST['errcode']=''; 146 153 147 154 if(!isset($_REQUEST['fGMaps_tabsheet'])) … … 227 234 'maps' => $this->makeMapsList(), 228 235 'icons' => $this->makeIconsList(), 236 'kmlFiles' => $this->makeKmlFilesList() 229 237 ); 230 238 $template->assign('datas', $datas); … … 242 250 global $template; 243 251 244 /*$template->set_filename('body_page', 245 dirname($this->getFileLocation()).'/admin/plugin_admin_maps.tpl'); 246 247 248 $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page');*/ 252 $template->set_filename('body_page', 253 dirname($this->getFileLocation()).'/admin/gmaps_kmlfiles.tpl'); 254 255 $datas=Array( 256 'urlRequest' => $this->getAdminLink('ajax'), 257 ); 258 $template->assign('datas', $datas); 259 260 $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page'); 249 261 } 250 262 … … 370 382 371 383 return($returned); 372 } //make CategoriesTree384 } //makeMapsList 373 385 374 386 … … 395 407 396 408 return($returned); 409 } //makeIconsList 410 411 412 /** 413 * build the kml files list 414 * @return Array : an array, ready to use in the template 415 */ 416 private function makeKmlFilesList() 417 { 418 $returned=array(); 419 420 $sql="SELECT id, name 421 FROM ".$this->tables['kmlfiles']." 422 ORDER BY name, id"; 423 $result = pwg_query($sql); 424 if($result) 425 { 426 while($row = pwg_db_fetch_assoc($result)) 427 { 428 $returned[]=$row; 429 } 430 } 431 432 return($returned); 397 433 } //makeCategoriesTree 398 434 399 400 435 } //class 401 436 -
extensions/GMaps/gmaps_ajax.php
r7128 r7132 60 60 61 61 if(!isset($_REQUEST['ajaxfct'])) $_REQUEST['ajaxfct']=''; 62 if(!isset($_REQUEST['errcode'])) $_REQUEST['errcode']=''; 62 63 63 64 // check if asked function is valid … … 70 71 $_REQUEST['ajaxfct']=='admin.assoc.getAssoc' or 71 72 $_REQUEST['ajaxfct']=='admin.assoc.deleteAssoc' or 73 $_REQUEST['ajaxfct']=='admin.kmlFiles.getList' or 74 $_REQUEST['ajaxfct']=='admin.kmlFiles.setFile' or 75 $_REQUEST['ajaxfct']=='admin.kmlFiles.getFile' or 76 $_REQUEST['ajaxfct']=='admin.kmlFiles.deleteFile' or 72 77 73 78 $_REQUEST['ajaxfct']=='public.maps.init' or … … 87 92 88 93 /* 89 * check admin.maps.getMap & admin.assoc.getAssoc values 94 * check values for 95 * admin.maps.getMap 96 * admin.assoc.getAssoc 97 * admin.kmlFiles.getFile 90 98 */ 91 99 if($_REQUEST['ajaxfct']=="admin.maps.getMap" or 92 $_REQUEST['ajaxfct']=="admin.assoc.getAssoc") 100 $_REQUEST['ajaxfct']=="admin.assoc.getAssoc" or 101 $_REQUEST['ajaxfct']=="admin.kmlFiles.getFile") 93 102 { 94 103 if(!isset($_REQUEST['id']) or … … 98 107 99 108 /* 100 * check admin.maps.deleteMap values 109 * check values for 110 * admin.maps.deleteMap 111 * admin.assoc.deleteAssoc 112 * admin.kmlFiles.deleteFile 101 113 */ 102 114 if($_REQUEST['ajaxfct']=="admin.maps.deleteMap" or 103 $_REQUEST['ajaxfct']=="admin.maps.deleteAssoc") 115 $_REQUEST['ajaxfct']=="admin.assoc.deleteAssoc" or 116 $_REQUEST['ajaxfct']=="admin.kmlFiles.deleteFile") 104 117 { 105 118 if(!isset($_REQUEST['id']) or … … 190 203 isset($_REQUEST['datas']['mapId']) && 191 204 isset($_REQUEST['datas']['applySubCat']) && 205 isset($_REQUEST['datas']['kmlFileId']) && 192 206 isset($_REQUEST['datas']['kmlFileUrl']) && 193 207 isset($_REQUEST['datas']['icon']) && … … 208 222 } 209 223 } 224 225 226 /* 227 * check admin.kmlFiles.setFile values 228 */ 229 if($_REQUEST['ajaxfct']=="admin.kmlFiles.setFile") 230 { 231 if(!isset($_REQUEST['id']) ) 232 { 233 $_REQUEST['ajaxfct']=''; 234 } 235 else 236 { 237 if($_REQUEST['id']=='') 238 { 239 if(!(isset($_FILES['file']['name']) and 240 isset($_FILES['file']['tmp_name']))) $_REQUEST['ajaxfct']=''; 241 } 242 } 243 } 244 210 245 211 246 … … 293 328 $result=$this->ajax_gmaps_admin_assocDeleteAssoc($_REQUEST['id']); 294 329 break; 330 case 'admin.kmlFiles.getList': 331 $result=$this->ajax_gmaps_admin_kmlFilesGetList(); 332 break; 333 case 'admin.kmlFiles.getFile': 334 $result=$this->ajax_gmaps_admin_kmlFilesGetFile($_REQUEST['id']); 335 break; 336 case 'admin.kmlFiles.setFile': 337 $result=$this->ajax_gmaps_admin_kmlFilesSetFile($_REQUEST['id'], $_REQUEST['name']); 338 break; 339 case 'admin.kmlFiles.deleteFile': 340 $result=$this->ajax_gmaps_admin_kmlFilesDeleteFile($_REQUEST['id']); 341 break; 342 295 343 296 344 case 'public.maps.init': … … 496 544 $sql="SELECT pgcm.id, pgcm.categoryId, pct.name AS catName, 497 545 pgmm.name AS mapName, pgmm.displayType, 498 pgcm.kmlFile Url, pgcm.imgSort, pgcm.applySubCat, pgcm.icon,499 pgcm.title 500 FROM ( ".$this->tables['category_maps']." pgcm546 pgcm.kmlFileId, pgcm.kmlFileUrl, pgcm.imgSort, pgcm.applySubCat, pgcm.icon, 547 pgcm.title, pgkf.name AS kmlName 548 FROM ((".$this->tables['category_maps']." pgcm 501 549 LEFT JOIN ".CATEGORIES_TABLE." pct ON pct.id=pgcm.categoryId) 502 LEFT JOIN ".$this->tables['maps']." pgmm ON pgcm.mapId = pgmm.id 550 LEFT JOIN ".$this->tables['maps']." pgmm ON pgcm.mapId = pgmm.id) 551 LEFT JOIN ".$this->tables['kmlfiles']." pgkf ON pgkf.id = pgcm.kmlFileId 503 552 ORDER BY pct.name, pgmm.displayType, pgcm.imgSort"; 504 553 $result=pwg_query($sql); … … 513 562 $keys['prev']=$keys['curr']; 514 563 564 if($row['kmlFileId']>0) 565 { 566 $mapKmlFile=$row['kmlName']; 567 } 568 elseif($row['kmlFileUrl']!='') 569 { 570 $mapKmlFile='URL'; 571 } 572 else 573 { 574 $mapKmlFile=''; 575 } 576 577 515 578 $tmp=array( 516 579 'id' => $row['id'], … … 518 581 'applySubCat' => l10n('gmaps_'.$row['applySubCat']), 519 582 'mapName' => $row['mapName'], 520 'mapKmlFile' => l10n('gmaps_'.(($row['kmlFileUrl']=='')?'n':'y')),583 'mapKmlFile' => $mapKmlFile, 521 584 'icon' => $row['icon'], 522 585 'displayType' => l10n('gmaps_displayTypeShort'.$row['displayType']), … … 598 661 ($db['maxImgSort']+1)."', '". 599 662 $properties['applySubCat']."', '". 663 $properties['kmlFileId']."', '". 600 664 $properties['kmlFileUrl']."', '". 601 665 $properties['icon']."', '". … … 611 675 $properties['mapId']."', applySubCat='". 612 676 $properties['applySubCat']."', kmlFileUrl='". 613 $properties['kmlFileUrl']."', icon='". 677 $properties['kmlFileUrl']."', kmlFileId='". 678 $properties['kmlFileId']."', icon='". 614 679 $properties['icon']."', title='". 615 680 mysql_escape_string($properties['title'])."' … … 637 702 'mapId' => '', 638 703 'applySubCat'=> 'y', 704 'kmlFileId' => 0, 639 705 'kmlFileUrl' => '', 640 706 'icon' => '', … … 642 708 ); 643 709 644 $sql="SELECT id, categoryId, mapId, applySubCat, kmlFile Url,710 $sql="SELECT id, categoryId, mapId, applySubCat, kmlFileId, kmlFileUrl, 645 711 icon, title 646 712 FROM ".$this->tables['category_maps']." … … 676 742 return('ko!unknown error'); 677 743 } //ajax_gmaps_admin_assocDeleteAssoc 744 745 746 747 /** 748 * return a HTML list of referenced kml files 749 * 750 * @return String 751 */ 752 private function ajax_gmaps_admin_kmlFilesGetList() 753 { 754 global $template; 755 756 $template->set_filename('list_page', 757 dirname($this->getFileLocation()).'/admin/gmaps_kmlfiles_iListFiles.tpl'); 758 759 $datas=Array(); 760 761 $sql="SELECT pgkf.id, pgkf.file, pgkf.name, pgkf.fileDate, pgkf.fileSize, COUNT(pgcm.id) AS nbAssoc 762 FROM ".$this->tables['kmlfiles']." pgkf 763 LEFT JOIN ".$this->tables['category_maps']." pgcm ON pgcm.kmlFileId = pgkf.id 764 GROUP BY pgkf.id 765 ORDER BY pgkf.name"; 766 767 $result=pwg_query($sql); 768 if($result) 769 { 770 while($row=pwg_db_fetch_assoc($result)) 771 { 772 $row['fileSize']=$this->formatOctet($row['fileSize']); 773 $datas[]=$row; 774 } 775 } 776 777 $template->assign('datas', $datas); 778 return($template->parse('list_page', true)); 779 } //ajax_gmaps_admin_kmlFilesGetList 780 781 782 783 784 /** 785 * set properties for a given file id ; if no file id is given create a new 786 * file 787 * 788 * @param String $id : the file Id 789 * @param String $name : the name 790 * @param String $file : the file name 791 * @return String : the num id, or an error message 792 */ 793 private function ajax_gmaps_admin_kmlFilesSetFile($id, $name) 794 { 795 global $template; 796 797 if(isset($_FILES['file']['name'])) 798 { 799 $file=$_FILES['file']['name']; 800 } 801 else 802 { 803 $file=''; 804 } 805 806 if($file=='' and $id!='') 807 { 808 // update name for an existing file 809 $sql="UPDATE ".$this->tables['kmlfiles']." 810 SET name='".mysql_escape_string($name)."' 811 WHERE id='$id';"; 812 $result=pwg_query($sql); 813 } 814 elseif($file!='') 815 { 816 // check if this file is not already used by an another file id 817 $sql="SELECT file 818 FROM ".$this->tables['kmlfiles']." 819 WHERE file='".mysql_escape_string($_FILES['file']['name'])."'"; 820 if($id!='') $sql.=" AND id!='$id'"; 821 $result=pwg_query($sql); 822 if($result) 823 { 824 $ok=''; 825 while($row=pwg_db_fetch_assoc($result)) 826 { 827 $ok=$row['file']; 828 } 829 if($ok!='') 830 { 831 //file already used by another file id 832 header("Location: ".$_SERVER['HTTP_REFERER']."&errcode=aksf10"); 833 exit(); 834 } 835 } 836 else 837 { 838 //unknown error 839 header("Location: ".$_SERVER['HTTP_REFERER']."&errcode=aksf01"); 840 exit(); 841 } 842 843 $file=dirname(__FILE__).'/kml/'.$file; 844 845 if(file_exists($file)) unlink($file); 846 if($id!='') 847 { 848 $currentInfo=$this->ajax_gmaps_admin_kmlFilesGetFile($id, false); 849 if(file_exists(dirname(__FILE__).'/kml/'.$currentInfo['file'])) unlink(dirname(__FILE__).'/kml/'.$currentInfo['file']); 850 } 851 852 853 if(!move_uploaded_file($_FILES['file']['tmp_name'], $file)) 854 { 855 /* 856 * something was wrong, previous file was deleted, so delete the file 857 * from the database 858 */ 859 if($id!='') $this->ajax_gmaps_admin_kmlFilesDeleteFile($id); 860 // error when trying to copy the uploaded file 861 header("Location: ".$_SERVER['HTTP_REFERER']."&errcode=aksf02"); 862 exit(); 863 } 864 865 if($id!='') 866 { 867 // update file & name for an existing file 868 $sql="UPDATE ".$this->tables['kmlfiles']." 869 SET name='".mysql_escape_string($name)."', 870 file='".mysql_escape_string($_FILES['file']['name'])."', 871 fileSize=".filesize($file).", 872 fileDate='".date('Y-m-d H:i:s', filemtime($file))."' 873 WHERE id='$id';"; 874 $result=pwg_query($sql); 875 } 876 else 877 { 878 $sql="INSERT INTO ".$this->tables['kmlfiles']." 879 VALUES ('', '".mysql_escape_string($_FILES['file']['name'])."', 880 '".mysql_escape_string($name)."', 881 '".date('Y-m-d H:i:s', filemtime($file))."', 882 '".filesize($file)."')"; 883 $result=pwg_query($sql); 884 $id=pwg_db_insert_id(); 885 } 886 887 header("Location: ".$_SERVER['HTTP_REFERER']); 888 exit(); 889 } 890 891 892 893 return($id); 894 } //ajax_gmaps_admin_kmlFilesSetFile 895 896 897 898 /** 899 * get properties for a given file id 900 * 901 * @param String id : the file Id 902 * @param Bool $json : if true, return a json string, otherwise an array 903 * @return String : data formatted in a JSON string 904 */ 905 private function ajax_gmaps_admin_kmlFilesGetFile($id, $json=true) 906 { 907 $returned=array( 908 'id' => '', 909 'file' => '', 910 'name' => '', 911 'fileDate'=> '', 912 'fileSize' => 0, 913 'fileSizeUnits' => 0, 914 ); 915 916 $sql="SELECT id, file, name, fileDate, fileSize 917 FROM ".$this->tables['kmlfiles']." 918 WHERE id='$id';"; 919 $result=pwg_query($sql); 920 if($result) 921 { 922 while($row=pwg_db_fetch_assoc($result)) 923 { 924 $row['fileSizeUnits']=$this->formatOctet($row['fileSize']); 925 $returned=$row; 926 } 927 } 928 929 if($json) 930 { 931 return(json_encode($returned)); 932 } 933 else 934 { 935 return($returned); 936 } 937 } //ajax_gmaps_admin_kmlFilesGetFile 938 939 940 941 942 /** 943 * delete a file 944 * 945 * @param String id : if of the file to delete 946 * @return String : ok or ko 947 */ 948 private function ajax_gmaps_admin_kmlFilesDeleteFile($id) 949 { 950 $file=''; 951 952 /* 953 * before deleting record in the table, get the associated file name stored 954 * on the server 955 */ 956 $sql="SELECT file 957 FROM ".$this->tables['kmlfiles']." 958 WHERE id='$id';"; 959 $result=pwg_query($sql); 960 if($result) 961 { 962 while($row=pwg_db_fetch_assoc($result)) 963 { 964 $file=$row['file']; 965 } 966 } 967 968 // reset kmlFileId for assocation 969 $sql="UPDATE ".$this->tables['category_maps']." 970 SET kmlFileId='0' 971 WHERE kmlFileId='$id'"; 972 pwg_query($sql); 973 974 // delete the file 975 $sql="DELETE FROM ".$this->tables['kmlfiles']." 976 WHERE id='$id';"; 977 $result=pwg_query($sql); 978 if($result) 979 { 980 if($file!='' and file_exists(dirname(__FILE__).'/kml/'.$file)) 981 { 982 unlink(dirname(__FILE__).'/kml/'.$file); 983 } 984 return('ok'); 985 } 986 return('ko!unknown error'); 987 } //ajax_gmaps_admin_kmlFilesDeleteFile 988 989 678 990 679 991 … … 982 1294 } 983 1295 984 985 986 1296 $returned['markers'][]=$coords; 987 1297 $returned['datas']['nbPhotos']+=$coords['nbImages']; … … 993 1303 $returned['datas']['nbPhotos']=sprintf(l10n('gmaps_nb_pictures'), $returned['datas']['nbPhotos']); 994 1304 } 1305 elseif($returned['datas']['nbPhotos']==1) 1306 { 1307 $returned['datas']['nbPhotos']=l10n('gmaps_1_picture'); 1308 } 995 1309 else 996 1310 { 997 $returned['datas']['nbPhotos']=l10n('gmaps_ 1_picture');1311 $returned['datas']['nbPhotos']=l10n('gmaps_0_picture'); 998 1312 } 999 1313 … … 1002 1316 1003 1317 1318 1319 1320 /** 1321 * formats a file size into a human readable size 1322 * 1323 * @param String $format : "A" : auto 1324 * "Ai" : auto (io) 1325 * "O" : o 1326 * "K" : Ko 1327 * "M" : Mo 1328 * "G" : Go 1329 * "Ki" : Kio 1330 * "Mi" : Mio 1331 * "Gi" : Gio 1332 * @param String $thsep : thousand separator 1333 * @param Integer $prec : number of decimals 1334 * @param Bool $visible : display or not the unit 1335 * @return String : a formatted file size 1336 */ 1337 private function formatOctet($octets, $format="Ai", $thsep="", $prec=2, $visible=true) 1338 { 1339 if($format=="Ai") 1340 { 1341 if($octets<1024) 1342 { $format="O"; } 1343 elseif($octets<1024000) 1344 { $format="Ki"; } 1345 elseif($octets<1024000000) 1346 { $format="Mi"; } 1347 else 1348 { $format="Gi"; } 1349 } 1350 elseif($format=="A") 1351 { 1352 if($octets<1000) 1353 { $format="O"; } 1354 elseif($octets<1000000) 1355 { $format="Ki"; } 1356 elseif($octets<1000000000) 1357 { $format="Mi"; } 1358 else 1359 { $format="Gi"; } 1360 } 1361 1362 switch($format) 1363 { 1364 case "O": 1365 $unit="o"; $div=1; 1366 break; 1367 case "K": 1368 $unit="Ko"; $div=1000; 1369 break; 1370 case "M": 1371 $unit="Mo"; $div=1000000; 1372 break; 1373 case "G": 1374 $unit="Go"; $div=1000000000; 1375 break; 1376 case "Ki": 1377 $unit="Kio"; $div=1024; 1378 break; 1379 case "Mi": 1380 $unit="Mio"; $div=1024000; 1381 break; 1382 case "Gi": 1383 $unit="Gio"; $div=1024000000; 1384 break; 1385 } 1386 1387 $returned=number_format($octets/$div, $prec, '.', $thsep); 1388 if($visible) $returned.=' '.$unit; 1389 return($returned); 1390 } //function formatOctet 1391 1392 1393 1004 1394 } //class 1005 1395 -
extensions/GMaps/gmaps_install.class.inc.php
r7128 r7132 69 69 `imgSort` smallint(5) unsigned NOT NULL default '0', 70 70 `applySubCat` char(1) NOT NULL default 'y', 71 `kmlFileId` int(10) unsigned NOT NULL default '0', 71 72 `kmlFileUrl` varchar(255) NOT NULL, 72 73 `icon` varchar(255) NOT NULL, … … 87 88 `imageCatsPLink` varchar(255) NOT NULL, 88 89 PRIMARY KEY USING BTREE (`userId`,`requestId`,`imageId`) 90 )", 91 "CREATE TABLE `".$this->tables['kmlfiles']."` ( 92 `id` int(10) unsigned NOT NULL auto_increment, 93 `file` varchar(255) NOT NULL, 94 `name` varchar(255) NOT NULL, 95 `fileDate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, 96 `fileSize` mediumint(8) unsigned NOT NULL, 97 PRIMARY KEY (`id`) 89 98 )" 90 99 ); -
extensions/GMaps/gmaps_root.class.inc.php
r7128 r7132 76 76 $this->section_name=$this->getPluginNameFiles(); 77 77 78 $this->setTablesList(array('maps', 'category_maps', 'cache' ));78 $this->setTablesList(array('maps', 'category_maps', 'cache', 'kmlfiles')); 79 79 $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css"); 80 80 } … … 203 203 */ 204 204 $sql="SELECT DISTINCT pgcm.id, pgcm.categoryId, 205 pgcm.imgSort, pgcm.applySubCat, pgcm.kmlFileUrl, 205 pgcm.imgSort, pgcm.applySubCat, pgcm.kmlFileUrl, pgcm.kmlFileId, pgkf.file AS kmlFileUrlId, 206 206 pgcm.icon, pgcm.title, 207 207 pgmm.displayType, pgmm.sizeMode, … … 210 210 pgmm.navigationControl, pgmm.style, 211 211 IF(pgcm.categoryId=0, 0, pct.global_rank) AS priorityRank 212 FROM (".$this->tables['category_maps']." pgcm 213 LEFT JOIN ".$this->tables['maps']." pgmm ON pgcm.mapId = pgmm.id) 214 LEFT JOIN ".CATEGORIES_TABLE." pct ON (FIND_IN_SET(pgcm.categoryId, pct.uppercats)!=0 OR pgcm.categoryId=0) 212 FROM ((".$this->tables['category_maps']." pgcm 213 LEFT JOIN ".$this->tables['maps']." pgmm ON pgcm.mapId = pgmm.id) 214 LEFT JOIN ".CATEGORIES_TABLE." pct ON (FIND_IN_SET(pgcm.categoryId, pct.uppercats)!=0 OR pgcm.categoryId=0)) 215 LEFT JOIN ".$this->tables['kmlfiles']." pgkf ON pgkf.id = pgcm.kmlFileId 215 216 WHERE $where "; 216 217 if($category!=0) … … 237 238 while($row=pwg_db_fetch_assoc($result)) 238 239 { 240 // if an kml file id is given, apply the url of the file (needs to give the complete URI for google) 241 if($row['kmlFileId']>0 and $row['kmlFileUrlId']!='') $row['kmlFileUrl']=dirname($_SERVER['SCRIPT_URI']).'/plugins/GMaps/kml/'.$row['kmlFileUrlId']; 242 239 243 if($row['displayType']!='MP') 240 244 { -
extensions/GMaps/language/fr_FR/plugin.lang.php
r7128 r7132 14 14 $lang['gmaps_associate_category_maps'] = 'Association des cartes'; 15 15 $lang['gmaps_search'] = 'Rechercher'; 16 $lang['gmaps_kml_files_management'] = 'Gestion des fichiers KML ';16 $lang['gmaps_kml_files_management'] = 'Gestion des fichiers KML/KMZ'; 17 17 $lang['gmaps_help'] = 'Aide'; 18 18 … … 30 30 $lang['gmaps_pleaseConfirmMetadataDelete_1']="La carte ainsi que toutes les associations qui en dépendent seront supprimées."; 31 31 $lang['gmaps_pleaseConfirmMetadataDelete_2']="Merci de confirmer la suppression."; 32 $lang['gmaps_pleaseConfirmAssoc']="Merci de confirmer la suppression."; 32 $lang['gmaps_pleaseConfirmKml_1']="Le fichier KML/KMZ sera supprimé et toutes les références à celui seront réinitialisées."; 33 $lang['gmaps_pleaseConfirmKml_2']="Merci de confirmer la suppression."; 34 $lang['gmaps_pleaseConfirmKml']="Merci de confirmer la suppression."; 33 35 $lang['gmaps_deleteMap']="Suppression de la carte"; 34 36 $lang['gmaps_add_a_new_map']="Ajouter une carte"; 37 $lang['gmaps_deleteKml']="Suppression du fichier KML/KMZ"; 38 $lang['gmaps_add_a_new_kmlFile']="Ajouter un fichier KML/KMZ"; 35 39 36 40 $lang['gmaps_name']="Nom"; … … 95 99 $lang['gmaps_nb_pictures']="%s photos"; 96 100 $lang['gmaps_1_picture']="1 photo"; 101 $lang['gmaps_0_picture']="Il n'y a aucune photo sur cette zone géographique"; 97 102 $lang['gmaps_apply_subcat']="Appliquer aux sous-catégories"; 98 103 $lang['gmaps_map_id']="Carte"; 99 $lang['gmaps_map_kmlfile']="Présence fichier KML ";104 $lang['gmaps_map_kmlfile']="Présence fichier KML/KMZ"; 100 105 $lang['gmaps_map_icon']="Icone"; 101 $lang['gmaps_map_kmlfile']="Associer un fichier KML"; 102 $lang['gmaps_map_associate_kmlfile']="Associer un fichier KML (saisir l'URL)"; 106 $lang['gmaps_map_associate_kmlfile']="Associer un fichier KML/KMZ"; 103 107 104 108 $lang['gmaps_map_integration']="Intégration dans la galerie"; … … 134 138 135 139 140 $lang['gmaps_kml_file_management']="Gestion d\\'un fichier KML/KMZ"; 141 $lang['gmaps_kml_files_management']="Gestion des fichiers KML/KMZ"; 142 $lang['gmaps_file']="Fichier"; 143 $lang['gmaps_date']="Date"; 144 $lang['gmaps_file_size']="Taille du fichier"; 145 $lang['gmaps_nb_assoc']="Affectations"; 146 $lang['gmaps_file_required']="La sélection d\\'un fichier est requise !"; 147 $lang['gmaps_file_is_not_kml_kmz']="L\\'extension du fichier est invalide ! Seuls les fichiers KML et KMZ sont acceptés."; 148 149 $lang['gmaps_error_code_aksf01']="Une erreur d'origine inconnue est survenue... :-/"; 150 $lang['gmaps_error_code_aksf02']="Une erreur est survenu lors de l'enregistrement du fichier"; 151 $lang['gmaps_error_code_aksf10']="Un fichier portant le même nom est déjà utilisé"; 152 $lang['gmaps_action_was_stopped']="L'action a été interrompue pour le motif suivant :"; 153 154 $lang['gmaps_kml_file_selected']="Sélection parmi les fichiers gérés"; 155 $lang['gmaps_kml_file_url']="Saisie d'une URL"; 156 $lang['gmaps_kml_file_none']="Aucun"; 157 158 $lang['gmaps_kml_file_access']="Les fichiers KML/KMZ doivent, pour pouvoir être affichés sur une carte, être accessibles par les serveurs de Google"; 159 160 136 161 ?>
Note: See TracChangeset
for help on using the changeset viewer.