Changeset 7139 for extensions/GMaps/gmaps_aip.class.inc.php
- Timestamp:
- Oct 9, 2010, 9:55:26 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GMaps/gmaps_aip.class.inc.php
r7132 r7139 27 27 { 28 28 parent::__construct($prefixeTable, $filelocation); 29 29 30 $this->loadConfig(); 30 31 $this->configForTemplate(); … … 36 37 37 38 $this->tabsheet = new tabsheet(); 38 39 39 40 40 if($this->amdState!='advanced') … … 231 231 $datas=Array( 232 232 'urlRequest' => $this->getAdminLink('ajax'), 233 'cats' => $this->makeCategor iesTree(),233 'cats' => $this->makeCategoryList(), 234 234 'maps' => $this->makeMapsList(), 235 235 'icons' => $this->makeIconsList(), 236 'markers' => $this->makeMarkersList(), 236 237 'kmlFiles' => $this->makeKmlFilesList() 237 238 ); … … 322 323 323 324 324 /** 325 * build the categories tree 326 * @return Array : an array, ready to use in the template 327 */ 328 private function makeCategoriesTree() 325 326 /** 327 * build an ordered category list 328 * returns an array, each item is an array like : 329 * 'id' => the category Id 330 * 'name' => the category name 331 * 'rank' => the category rank (global) 332 * 'level' => the category level 333 * 334 * @return Array : the list 335 */ 336 protected function makeCategoryList() 329 337 { 330 338 $returned=array( 331 339 array( 332 'id' => 0, 333 'name' => '-- '.l10n('gmaps_applyForAllTheGallery').' --' 340 'id' => 0, 341 'name' => l10n('gmaps_applyForAllTheGallery'), 342 'rank' => '0000', 343 'level' => 0, 344 'status' => 'public', 345 'childs' => false 334 346 ) 335 347 ); 336 348 337 $sql="SELECT id, name, global_rank 338 FROM ".CATEGORIES_TABLE." 339 ORDER BY global_rank"; 340 $result = pwg_query($sql); 349 $sql="SELECT DISTINCT pct.id, pct.name, pct.global_rank AS rank 350 FROM ".CATEGORIES_TABLE." pct 351 JOIN ( 352 SELECT DISTINCT pgat.cat_id AS catId FROM ".GROUP_ACCESS_TABLE." pgat 353 UNION DISTINCT 354 SELECT DISTINCT puat.cat_id AS catId FROM ".USER_ACCESS_TABLE." puat 355 ) pat 356 ON (pat.catId = pct.id AND pct.status = 'private') OR (pct.status = 'public') 357 ORDER BY global_rank;"; 358 $result=pwg_query($sql); 341 359 if($result) 342 360 { 343 while ($row =pwg_db_fetch_assoc($result))361 while($row=pwg_db_fetch_assoc($result)) 344 362 { 345 $returned[]=array( 346 'id' => $row['id'], 347 'name' => str_repeat(' ', substr_count($row['global_rank'], '.')).$row['name'] 348 ); 363 $row['level']=1+substr_count($row['rank'], '.'); 364 365 /* rank is in formated without leading zero, giving bad order 366 * 1 367 * 1.10 368 * 1.11 369 * 1.2 370 * 1.3 371 * .... 372 * 373 * this loop cp,vert all sub rank in four 0 format, allowing to order 374 * categories easily 375 * 0001 376 * 0001.0010 377 * 0001.0011 378 * 0001.0002 379 * 0001.0003 380 */ 381 $row['rank']=explode('.', $row['rank']); 382 foreach($row['rank'] as $key=>$rank) 383 { 384 $row['rank'][$key]=str_pad($rank, 4, '0', STR_PAD_LEFT); 385 } 386 $row['rank']=implode('.', $row['rank']); 387 388 $returned[]=$row; 349 389 } 350 390 } 351 391 392 usort($returned, array(&$this, 'compareCat')); 393 352 394 return($returned); 353 } //makeCategoriesTree 395 } 396 397 /** 398 * used for sort comparison 399 * defined as public, but don't use it directly 400 * 401 * this function compare two categorie with their rank value 402 */ 403 public function compareCat($catA, $catB) 404 { 405 if($catA['rank'] == $catB['rank']) 406 { 407 return(0); 408 } 409 return( ($catA['rank'] < $catB['rank'])?-1:1 ); 410 } 354 411 355 412 … … 400 457 { 401 458 $returned[]=array( 402 'type' => (strtolower(substr($file,0,1))=='i')?'img':'other',403 459 'file' => $file 404 460 ); … … 409 465 } //makeIconsList 410 466 467 468 /** 469 * build the markers list 470 * @return Array : an array, ready to use in the template 471 */ 472 private function makeMarkersList() 473 { 474 $returned=array(); 475 476 $directory=scandir(GMAPS_PATH.'img/'); 477 foreach($directory as $file) 478 { 479 $ext=(pathinfo($file, PATHINFO_EXTENSION)); 480 if(preg_match('/^mS(\d\d)_(\d\d)\.png$/i', $file)) 481 { 482 $returned[]=array( 483 'file' => $file 484 ); 485 } 486 } 487 488 return($returned); 489 } //makeIconsList 411 490 412 491 /**
Note: See TracChangeset
for help on using the changeset viewer.