source: extensions/rv_gmaps/trunk/admin/admin_edit.php @ 9069

Last change on this file since 9069 was 9069, checked in by rvelices, 13 years ago

fix admin modification of coordinates (element_set become batch_manager)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1<?php 
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4$admin_url = PHPWG_ROOT_PATH.'admin.php';
5
6if ( !isset($_GET['cat']) )
7  $_GET['cat'] = 'caddie';
8$_GET['mode'] = 'map';
9include (PHPWG_ROOT_PATH.'admin/batch_manager.php');
10
11$template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d photo', '%d photos', count($page['cat_elements_id'])));
12
13if ( isset($_POST['submit']) )
14{
15  $collection = array();
16
17  switch ($_POST['target'])
18  {
19    case 'all' :
20      $collection = $page['cat_elements_id'];
21      break;
22    case 'selection' :
23      if (!isset($_POST['selection']) or count($_POST['selection']) == 0)
24        array_push($page['errors'], l10n('Select at least one photo'));
25      else
26        $collection = $_POST['selection'];
27      break;
28  }
29  if ( count($collection)>0 )
30  {
31    $lat = trim($_POST['lat']);
32    $lon = trim($_POST['lon']);
33
34    if ( strlen($lat)>0 and strlen($lon)>0 )
35    {
36      if ( (double)$lat<=90 and (double)$lat>=-90
37          and (double)$lon<=180 and (double)$lat>=-180 )
38        $update_query = 'lat='.$lat.', lon='.$lon;
39      else
40        $page['errors'][] = 'Invalid lat or lon value';
41    }
42    elseif ( strlen($lat)==0 and strlen($lon)==0 )
43      $update_query = 'lat=NULL, lon=NULL';
44    else
45      $page['errors'][] = 'Both lat/lon must be empty or not empty';
46
47    if (isset($update_query))
48    {
49      $update_query = '
50UPDATE '.IMAGES_TABLE.' SET '.$update_query.'
51  WHERE id IN ('.implode(',',$collection).')';
52      pwg_query($update_query);
53      rvm_invalidate_cache();
54    }
55  }
56}
57
58$specials_selected = null;
59foreach( array('caddie'=>'Caddie', 'recent'=>'Recent photos') as $k => $v)
60{
61        $link = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$k;
62        $template->append(
63                'specials',
64                array(
65                        $link => l10n($v),
66                        ),
67                true
68                );
69        if ($k == $_GET['cat']) $specials_selected = $link;
70}
71$template->assign('specials_selected', $specials_selected);
72
73$query = '
74SELECT id,name,uppercats,global_rank
75  FROM '.CATEGORIES_TABLE.'
76;';
77$result = pwg_query($query);
78$categories = array();
79$selecteds = array();
80if (!empty($result))
81{
82        while ($row = mysql_fetch_assoc($result))
83        {
84                $url = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$row['id'];
85                if ( $row['id']==$_GET['cat'] ) $selecteds[] = $url;
86                $row['id']=$url;
87                array_push($categories, $row);
88        }
89}
90usort($categories, 'global_rank_compare');
91display_select_categories($categories, $selecteds, 'categories', false);
92
93if (!empty($_GET['display']))
94{
95  if ('all' == $_GET['display'])
96    $page['nb_images'] = count($page['cat_elements_id']);
97  else
98    $page['nb_images'] = intval($_GET['display']);
99}
100else
101  $page['nb_images'] = 20;
102
103if ( !empty($page['cat_elements_id']) )
104{
105  $nav_bar = create_navigation_bar(
106    $admin_url.get_query_string_diff(array('start')),
107    count($page['cat_elements_id']),
108    $page['start'],
109    $page['nb_images']
110    );
111  $template->assign('navbar', $nav_bar);
112}
113
114$images=array();
115if ( !empty($page['cat_elements_id']) )
116{
117  $query='
118SELECT id,tn_ext,name,path,file,lat,lon FROM '.IMAGES_TABLE.'
119  WHERE id IN ('.implode(',',$page['cat_elements_id']).')
120  '.$conf['order_by'].'
121  LIMIT '.$page['start'].', '.$page['nb_images'].'
122;';
123  $result = pwg_query($query);
124  while ( $row=mysql_fetch_assoc($result) )
125    $images[] = $row;
126}
127
128foreach ($images as $image)
129{
130        $tpl_var = array_merge( $image,
131      array(
132        'U_TN' => get_thumbnail_url($image),
133        'TITLE' => get_thumbnail_title($image)
134      )
135    );
136  if ( isset($image['lat']) )
137    $tpl_var['U_MAP'] = rvm_make_map_picture_url( array('image_id'=>$image['id'], 'image_file'=>$image['file']) );
138        $template->append('thumbnails', $tpl_var);
139}
140
141$template->assign(
142    array(
143      'U_DISPLAY'=> $admin_url.get_query_string_diff(array('display'))
144    ) 
145  );
146
147?>
Note: See TracBrowser for help on using the repository browser.