1 | <?php |
---|
2 | if ( !defined('PHPWG_ROOT_PATH') ) |
---|
3 | define('PHPWG_ROOT_PATH','../../'); |
---|
4 | |
---|
5 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
6 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
7 | include_once( dirname(__FILE__) .'/include/functions_map.php'); |
---|
8 | |
---|
9 | check_status(ACCESS_GUEST); |
---|
10 | if (!isset($rvm_dir)) |
---|
11 | access_denied( 'Plugin not installed' ); |
---|
12 | |
---|
13 | rvm_load_language(); |
---|
14 | |
---|
15 | $section = ''; |
---|
16 | if ( $conf['question_mark_in_urls']==false and |
---|
17 | isset($_SERVER["PATH_INFO"]) and !empty($_SERVER["PATH_INFO"]) ) |
---|
18 | { |
---|
19 | $section = $_SERVER["PATH_INFO"]; |
---|
20 | $section = str_replace('//', '/', $section); |
---|
21 | if ( !isset($page['root_path']) ) |
---|
22 | { |
---|
23 | $path_count = count( explode('/', $section) ); |
---|
24 | $page['root_path'] = PHPWG_ROOT_PATH.str_repeat('../', $path_count-1); |
---|
25 | } |
---|
26 | } |
---|
27 | else |
---|
28 | { |
---|
29 | foreach ($_GET as $key=>$value) |
---|
30 | { |
---|
31 | if (!strlen($value)) $section=$key; |
---|
32 | break; |
---|
33 | } |
---|
34 | } |
---|
35 | |
---|
36 | // deleting first "/" if displayed |
---|
37 | $tokens = explode( |
---|
38 | '/', |
---|
39 | preg_replace('#^/#', '', $section) |
---|
40 | ); |
---|
41 | $next_token = 0; |
---|
42 | $result = rvm_parse_blowup_url($tokens, $next_token); |
---|
43 | $page = array_merge( $page, $result ); |
---|
44 | |
---|
45 | $order_by=null; |
---|
46 | if ( isset($page['ll']) ) |
---|
47 | $where_sql = rvm_ll_to_sql($page['ll'], $order_by); |
---|
48 | else |
---|
49 | $where_sql = rvm_bounds_to_sql( $page['box'] ); |
---|
50 | |
---|
51 | $img_fields = ' i.id,i.tn_ext,i.name,i.path,i.lat,i.lon'; |
---|
52 | |
---|
53 | $was_flat = @$page['flat']; |
---|
54 | $page['flat']=true; |
---|
55 | rvm_build_section_items($img_fields, $where_sql, RVM_BUILD_HASH, $order_by); |
---|
56 | if (!$was_flat) unset($page['flat']); |
---|
57 | |
---|
58 | $template->set_filename( 'map', dirname(__FILE__).'/template/mapl.tpl'); |
---|
59 | |
---|
60 | if (!empty($page['items'])) |
---|
61 | { |
---|
62 | /* GENERATE THE CATEGORY LIST *************************************************/ |
---|
63 | $where_sql = 'i.id IN ('.implode(',', array_keys($page['items']) ).')'; |
---|
64 | $where_sql .= get_sql_condition_FandF( |
---|
65 | array( 'forbidden_categories' => 'category_id' ), |
---|
66 | ' AND' |
---|
67 | ); |
---|
68 | $query = ' |
---|
69 | SELECT DISTINCT c.id, c.name, c.permalink, COUNT(DISTINCT i.id) counter |
---|
70 | FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id=image_id |
---|
71 | INNER JOIN '.CATEGORIES_TABLE.' c ON c.id=category_id |
---|
72 | WHERE '.$where_sql.' |
---|
73 | GROUP BY category_id |
---|
74 | ORDER BY counter DESC |
---|
75 | LIMIT 0,5 |
---|
76 | ;'; |
---|
77 | $result = pwg_query($query); |
---|
78 | $categories=array(); |
---|
79 | while ($row=mysql_fetch_assoc($result)) |
---|
80 | array_push($categories, $row); |
---|
81 | $categories = add_level_to_tags($categories); |
---|
82 | |
---|
83 | foreach( $categories as $category) |
---|
84 | { |
---|
85 | $template->append( |
---|
86 | 'related_categories', array( |
---|
87 | 'U_MAP' => rvm_make_map_index_url( array( 'category' => $category ) ), |
---|
88 | 'URL' => make_index_url( array( 'category' => $category ) ), |
---|
89 | 'NAME' => trigger_event('render_element_description', $category['name']), |
---|
90 | 'TITLE' => l10n_dec( '%d photo', '%d photos', $category['counter'] ), |
---|
91 | 'CLASS' => 'tagLevel'.$category['level'] |
---|
92 | ) |
---|
93 | ); |
---|
94 | } |
---|
95 | |
---|
96 | /* GENERATE THE TAG LIST ******************************************************/ |
---|
97 | $tags = get_common_tags( array_keys($page['items']), $conf['content_tag_cloud_items_number'], null); |
---|
98 | $tags = add_level_to_tags($tags); |
---|
99 | function counter_compare($a, $b) |
---|
100 | { |
---|
101 | $d = $a['counter'] - $b['counter']; |
---|
102 | if ($d==0) |
---|
103 | return strcmp($a['name'], $b['name']); |
---|
104 | return -$d; |
---|
105 | } |
---|
106 | usort($tags, 'counter_compare'); |
---|
107 | foreach ($tags as $tag) |
---|
108 | { |
---|
109 | $template->append( |
---|
110 | 'related_tags', |
---|
111 | array_merge( $tag, |
---|
112 | array( |
---|
113 | 'U_MAP' => rvm_make_map_index_url( array( 'tags' => array($tag) ) ), |
---|
114 | 'URL' => make_index_url( array( 'tags' => array($tag) ) ), |
---|
115 | 'TITLE' => l10n_dec( '%d photo', '%d photos', $tag['counter'] ), |
---|
116 | ) |
---|
117 | ) |
---|
118 | ); |
---|
119 | } |
---|
120 | } // end !empty items |
---|
121 | |
---|
122 | |
---|
123 | $title = '<a target="_top" title="'.sprintf( l10n('go to %s'),$page['title']).'" href="'.duplicate_index_url( array('start'=>0) ).'">'.$page['title'].'</a>'; |
---|
124 | if ( count($page['items']) > 0) |
---|
125 | $title.=' ['.count($page['items']).']'; |
---|
126 | |
---|
127 | $template->assign( |
---|
128 | array( |
---|
129 | 'PLUGIN_ROOT_URL' => get_absolute_root_url().'plugins/'.$rvm_dir, |
---|
130 | 'TITLE' => $title, |
---|
131 | 'U_HOME' => make_index_url(), |
---|
132 | 'U_KML' => rvm_duplicate_kml_index_url( array('flat'=>1), array('start') ), |
---|
133 | 'KML_LINK_TITLE' => sprintf( l10n('opens %s in Google Earth'), strip_tags($page['title']) ), |
---|
134 | ) |
---|
135 | ); |
---|
136 | |
---|
137 | $url = rvm_duplicate_blowup_url(array('start'=>0)); |
---|
138 | $navbar = create_navigation_bar($url, count( $page['items'] ), $page['start'], 48); |
---|
139 | $template->assign('navbar', $navbar); |
---|
140 | |
---|
141 | $page['items'] = array_slice( |
---|
142 | $page['items'], |
---|
143 | $page['start'], |
---|
144 | 48 |
---|
145 | ); |
---|
146 | |
---|
147 | foreach ($page['items'] as $img) |
---|
148 | { |
---|
149 | $img['file'] = basename( $img['path'] ); |
---|
150 | $thumbnail_url = get_thumbnail_url($img); |
---|
151 | $page_url = duplicate_picture_url( |
---|
152 | array( |
---|
153 | 'image_id' => $img['id'], |
---|
154 | 'image_file' => $img['file'], |
---|
155 | 'flat' => 1, |
---|
156 | ), |
---|
157 | array('start') |
---|
158 | ); |
---|
159 | if (!empty( $img['name'] ) ) |
---|
160 | $title = $img['name']; |
---|
161 | else |
---|
162 | $title = str_replace('_', ' ', get_filename_wo_extension($img['file'])); |
---|
163 | |
---|
164 | $template->append( |
---|
165 | 'thumbnails', |
---|
166 | array( |
---|
167 | 'TN_SRC' => $thumbnail_url, |
---|
168 | 'URL' => $page_url, |
---|
169 | 'TN_ALT' => $img['file'], |
---|
170 | 'TN_TITLE' => $title, |
---|
171 | ) |
---|
172 | ); |
---|
173 | } |
---|
174 | |
---|
175 | $title = $page['title']; |
---|
176 | $page['body_id'] = 'theMapListPage'; |
---|
177 | |
---|
178 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
179 | $template->parse('map'); |
---|
180 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
181 | |
---|
182 | ?> |
---|