author | Dan |
Sat, 16 Feb 2008 23:10:17 -0500 | |
changeset 20 | d8a281557365 |
parent 18 | c1c398349651 |
child 19 | 08bf8aa2f0ab |
permissions | -rw-r--r-- |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
1 |
<?php |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
2 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
3 |
/* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
4 |
* Snapr |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
5 |
* Version 0.1 beta 1 |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
6 |
* Copyright (C) 2007 Dan Fuhry |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
7 |
* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
10 |
* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
13 |
*/ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
14 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
15 |
## |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
16 |
## GALLERY NAMESPACE HANDLER |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
17 |
## |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
18 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
19 |
$plugins->attachHook('page_not_found', 'gallery_namespace_handler($this);'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
20 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
21 |
function gallery_namespace_handler(&$page) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
22 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
23 |
global $db, $session, $paths, $template, $plugins; // Common objects |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
24 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
25 |
if ( $page->namespace != 'Gallery' ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
26 |
return false; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
27 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
28 |
if ( $page->page_id == 'Root' ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
29 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
30 |
page_Special_Gallery(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
31 |
return true; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
32 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
33 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
34 |
if ( preg_match('/^[0-9]+$/', $page->page_id) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
35 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
36 |
$img_id = intval($page->page_id); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
37 |
if ( !$img_id ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
38 |
return false; |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
39 |
$q = $db->sql_query('SELECT img_id, img_title, img_desc, print_sizes, img_time_upload, img_time_mod, img_filename, folder_parent, img_tags FROM '.table_prefix.'gallery WHERE img_id=' . $img_id . ';'); |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
40 |
if ( !$q ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
41 |
$db->_die(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
42 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
43 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
44 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
45 |
// Ech... he sent us a string... parse it and see what we get |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
46 |
if ( strstr($page->page_id, '/') ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
47 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
48 |
$folders = explode('/', $page->page_id); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
49 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
50 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
51 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
52 |
$folders = array($page->page_id); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
53 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
54 |
foreach ( $folders as $i => $_crap ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
55 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
56 |
$folder =& $folders[$i]; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
57 |
$folder = dirtify_page_id($folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
58 |
$folder = str_replace('_', ' ', $folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
59 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
60 |
unset($folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
61 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
62 |
$folders = array_reverse($folders); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
63 |
// This is one of the best MySQL tricks on the market. We're going to reverse-travel a folder path using LEFT JOIN and the incredible power of metacoded SQL |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
64 |
$sql = 'SELECT g0.img_id, g0.img_title, g0.img_desc, g0.print_sizes, g0.img_time_upload, g0.img_time_mod, g0.img_filename, g0.folder_parent, g0.img_tags FROM '.table_prefix.'gallery AS g0'; |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
65 |
$where = "\n " . 'WHERE g0.img_title=\'' . $db->escape($folders[0]) . '\''; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
66 |
foreach ( $folders as $i => $folder ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
67 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
68 |
if ( $i == 0 ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
69 |
continue; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
70 |
$i_dec = $i - 1; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
71 |
$folder = $db->escape($folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
72 |
$sql .= "\n LEFT JOIN ".table_prefix."gallery AS g{$i}\n ON ( g{$i}.img_id=g{$i_dec}.folder_parent AND g{$i}.img_title='$folder' )"; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
73 |
$where .= "\n ".'AND g'.$i.'.img_id IS NOT NULL'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
74 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
75 |
$where .= "\n AND g{$i}.folder_parent IS NULL"; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
76 |
$sql .= $where . ';'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
77 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
78 |
if ( !$db->sql_query($sql) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
79 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
80 |
$db->_die('The image metadata could not be loaded.'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
81 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
82 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
83 |
// Now that the folder data is no longer needed, we can fool around with it a little |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
84 |
$folders = $page->page_id; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
85 |
if ( !strstr($folders, '/') ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
86 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
87 |
$hier = '/'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
88 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
89 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
90 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
91 |
$hier = preg_replace('/\/([^\/]+)$/', '/', $folders); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
92 |
$hier = sanitize_page_id($hier); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
93 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
94 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
95 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
96 |
if ( $db->numrows() < 1 ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
97 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
98 |
// Image not found - show custom error message |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
99 |
$template->header(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
100 |
echo '<h3>There is no image in the gallery with this ID.</h3>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
101 |
echo '<p>You have requested an image that couldn\'t be looked up. Please check the URL and try again, or visit the <a href="' . makeUrlNS('Special', 'Gallery') . '">Gallery index</a>.</p>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
102 |
$template->footer(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
103 |
return false; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
104 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
105 |
$row = $db->fetchrow(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
106 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
107 |
$db->free_result(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
108 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
109 |
$img_id = $row['img_id']; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
110 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
111 |
if ( !$row['folder_parent'] ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
112 |
$row['folder_parent'] = ' IS NULL'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
113 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
114 |
$row['folder_parent'] = '=' . $row['folder_parent']; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
115 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
116 |
// Fetch image parent properties |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
117 |
$q = $db->sql_query('SELECT img_id, img_title FROM '.table_prefix.'gallery WHERE folder_parent' . $row['folder_parent'] . ' AND is_folder!=1 ORDER BY img_title ASC;'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
118 |
if ( !$q ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
119 |
$db->_die(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
120 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
121 |
$folder_total = $db->numrows(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
122 |
$folder_this = 0; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
123 |
$prev = false; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
124 |
$next = false; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
125 |
$next_title = ''; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
126 |
$prev_title = ''; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
127 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
128 |
$i = 0; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
129 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
130 |
while ( $r = $db->fetchrow() ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
131 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
132 |
$i++; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
133 |
if ( $i == $folder_total && $r['img_id'] == $img_id ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
134 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
135 |
$folder_this = $i; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
136 |
$next = false; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
137 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
138 |
else if ( $i < $folder_total && $r['img_id'] == $img_id ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
139 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
140 |
$folder_this = $i; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
141 |
$next = true; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
142 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
143 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
144 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
145 |
if ( $next ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
146 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
147 |
$next = $r['img_id']; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
148 |
$next_title = $r['img_title']; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
149 |
break; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
150 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
151 |
$prev = $r['img_id']; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
152 |
$prev_title = $r['img_title']; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
153 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
154 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
155 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
156 |
if ( $next ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
157 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
158 |
$next_sanitized = sanitize_page_id($next_title); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
159 |
$next_url = ( isset($hier) ) ? makeUrlNS('Gallery', $hier . $next_sanitized ) : makeUrlNS('Gallery', $next); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
160 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
161 |
if ( $prev ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
162 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
163 |
$prev_sanitized = sanitize_page_id($prev_title); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
164 |
$prev_url = ( isset($hier) ) ? makeUrlNS('Gallery', $hier . $prev_sanitized ) : makeUrlNS('Gallery', $prev); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
165 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
166 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
167 |
$db->free_result(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
168 |
|
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
169 |
$perms = $session->fetch_page_acl(strval($img_id), 'Gallery'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
170 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
171 |
if ( isset($_POST['ajax']) && @$_POST['ajax'] === 'true' && isset($_POST['act']) ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
172 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
173 |
$mode =& $_POST['act']; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
174 |
$response = array(); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
175 |
switch($mode) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
176 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
177 |
case 'add_tag': |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
178 |
if ( !$perms->get_permissions('snapr_add_tag') ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
179 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
180 |
die(snapr_json_encode(array( |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
181 |
'mode' => 'error', |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
182 |
'error' => 'You don\'t have permission to add tags.' |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
183 |
))); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
184 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
185 |
if ( empty($row['img_tags']) ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
186 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
187 |
$row['img_tags'] = '[]'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
188 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
189 |
$row['img_tags'] = snapr_json_decode($row['img_tags']); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
190 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
191 |
$canvas_data = snapr_json_decode($_POST['canvas_params']); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
192 |
$tag_data = array( |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
193 |
'tag' => sanitize_html($_POST['tag']), |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
194 |
'canvas_data' => $canvas_data |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
195 |
); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
196 |
$row['img_tags'][] = $tag_data; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
197 |
$tag_data['note_id'] = count($row['img_tags']) - 1; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
198 |
$tag_data['mode'] = 'add'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
199 |
$tag_data['initial_hide'] = false; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
200 |
$tag_data['auth_delete'] = true; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
201 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
202 |
$row['img_tags'] = snapr_json_encode($row['img_tags']); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
203 |
$row['img_tags'] = $db->escape($row['img_tags']); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
204 |
$q = $db->sql_query('UPDATE ' . table_prefix . "gallery SET img_tags = '{$row['img_tags']}' WHERE img_id = $img_id;"); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
205 |
if ( !$q ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
206 |
$db->die_json(); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
207 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
208 |
$response[] = $tag_data; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
209 |
break; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
210 |
case 'del_tag': |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
211 |
if ( !$perms->get_permissions('snapr_add_tag') ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
212 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
213 |
die(snapr_json_encode(array( |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
214 |
'mode' => 'error', |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
215 |
'error' => 'You don\'t have permission to add tags.' |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
216 |
))); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
217 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
218 |
if ( empty($row['img_tags']) ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
219 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
220 |
$row['img_tags'] = '[]'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
221 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
222 |
$row['img_tags'] = snapr_json_decode($row['img_tags']); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
223 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
224 |
$tag_id = intval(@$_POST['tag_id']); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
225 |
if ( isset($row['img_tags'][$tag_id]) ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
226 |
unset($row['img_tags'][$tag_id]); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
227 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
228 |
$row['img_tags'] = snapr_json_encode($row['img_tags']); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
229 |
$row['img_tags'] = $db->escape($row['img_tags']); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
230 |
$q = $db->sql_query('UPDATE ' . table_prefix . "gallery SET img_tags = '{$row['img_tags']}' WHERE img_id = $img_id;"); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
231 |
if ( !$q ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
232 |
$db->die_json(); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
233 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
234 |
$response[] = array( |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
235 |
'mode' => 'remove', |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
236 |
'note_id' => $tag_id |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
237 |
); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
238 |
break; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
239 |
case 'get_tags': |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
240 |
$response = snapr_json_decode($row['img_tags']); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
241 |
foreach ( $response as $key => $_ ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
242 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
243 |
unset($_); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
244 |
$tag =& $response[$key]; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
245 |
$tag['note_id'] = $key; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
246 |
$tag['mode'] = 'add'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
247 |
$tag['initial_hide'] = true; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
248 |
$tag['auth_delete'] = $perms->get_permissions('snapr_add_tag'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
249 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
250 |
unset($tag); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
251 |
break; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
252 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
253 |
echo snapr_json_encode($response); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
254 |
return true; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
255 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
256 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
257 |
$have_notes = ( empty($row['img_tags']) ) ? false : ( count(snapr_json_decode($row['img_tags'])) > 0 ); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
258 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
259 |
$template->add_header('<script type="text/javascript" src="' . scriptPath . '/plugins/gallery/canvas.js"></script>'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
260 |
$template->add_header('<script type="text/javascript" src="' . scriptPath . '/plugins/gallery/tagging.js"></script>'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
261 |
|
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
262 |
$template->tpl_strings['PAGE_NAME'] = 'Gallery image: ' . htmlspecialchars($row['img_title']); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
263 |
$title_spacey = strtolower(htmlspecialchars($row['img_title'])); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
264 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
265 |
$template->header(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
266 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
267 |
$img_id = intval($img_id); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
268 |
$bc_folders = gallery_imgid_to_folder($img_id); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
269 |
$bc_folders = array_reverse($bc_folders); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
270 |
$bc_url = ''; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
271 |
$breadcrumbs = array(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
272 |
$breadcrumbs[] = '<a href="' . makeUrlNS('Special', 'Gallery') . '">Gallery index</a>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
273 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
274 |
foreach ( $bc_folders as $folder ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
275 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
276 |
$bc_url .= '/' . dirtify_page_id($folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
277 |
$breadcrumbs[] = '<a href="' . makeUrlNS('Special', 'Gallery' . $bc_url, false, true) . '">' . htmlspecialchars($folder) . '</a>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
278 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
279 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
280 |
$breadcrumbs[] = htmlspecialchars($row['img_title']); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
281 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
282 |
// From here, this breadcrumb stuff is a piece of... sourdough French bread :-) *smacks lips* |
11
3c4304fae21e
Updated browser and viewimage to use the breadcrumbs css class in enano-shared; this breaks 1.0 compatibility
Dan
parents:
9
diff
changeset
|
283 |
echo '<div class="breadcrumbs" style="padding: 4px; margin-bottom: 7px;">'; |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
284 |
// The actual breadcrumbs |
11
3c4304fae21e
Updated browser and viewimage to use the breadcrumbs css class in enano-shared; this breaks 1.0 compatibility
Dan
parents:
9
diff
changeset
|
285 |
echo '<small>' . implode(' » ', $breadcrumbs) . '</small>'; |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
286 |
echo '</div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
287 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
288 |
echo '<div style="text-align: center; margin: 10px auto; border: 1px solid #DDDDDD; padding: 7px 10px; display: table;">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
289 |
$img_url = makeUrlNS('Special', 'GalleryFetcher/preview/' . $img_id); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
290 |
$img_href = makeUrlNS('Special', 'GalleryFetcher/full/' . $img_id); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
291 |
|
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
292 |
echo '<div snapr:imgid="' . $img_id . '"><img alt="Image preview (640px max width)" src="' . $img_url . '" id="snapr_preview_img" style="border-width: 0; margin-bottom: 5px; display: block;" /></div>'; |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
293 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
294 |
echo '<table border="0" width="100%"><tr><td style="text-align: left; width: 24px;">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
295 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
296 |
// Prev button |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
297 |
if ( $prev ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
298 |
echo '<a href="' . $prev_url . '"><img style="border-width: 0px;" alt="< Previous" src="' . scriptPath . '/plugins/gallery/prev.gif" /></a>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
299 |
//echo '</td><td style="text-align: left;">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
300 |
// if ( $prev ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
301 |
// echo '<a href="' . $prev_url . '">previous image</a>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
302 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
303 |
echo '</td><td style="text-align: center; letter-spacing: 5px;">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
304 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
305 |
// Image title |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
306 |
echo $title_spacey; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
307 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
308 |
echo '</td><td style="text-align: right; width: 24px;">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
309 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
310 |
// Next button |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
311 |
if ( $next ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
312 |
// echo '<a href="' . $next_url . '">next image</a>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
313 |
//echo '</td><td style="text-align: right;">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
314 |
if ( $next ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
315 |
echo '<a href="' . $next_url . '"><img style="border-width: 0px;" alt="< Previous" src="' . scriptPath . '/plugins/gallery/next.gif" /></a>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
316 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
317 |
echo '</td></tr>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
318 |
echo '<tr><td colspan="3">' . "image $folder_this of $folder_total" . '</td></tr>'; |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
319 |
if ( $perms->get_permissions('gal_full_res') || $have_notes ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
320 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
321 |
echo '<tr><td colspan="3"><small>'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
322 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
323 |
if ( $perms->get_permissions('gal_full_res') ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
324 |
echo "<a href=\"$img_href\" onclick=\"window.open(this.href, '', 'toolbar=no,address=no,menus=no,status=no,scrollbars=yes'); return false;\">View in original resolution</a>"; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
325 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
326 |
if ( $perms->get_permissions('gal_full_res') && $have_notes ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
327 |
echo ' :: '; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
328 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
329 |
if ( $have_notes ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
330 |
echo 'Mouse over photo to view tags'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
331 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
332 |
echo '</small></td></tr>'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
333 |
} |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
334 |
echo '</table>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
335 |
echo '</div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
336 |
|
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
337 |
if ( $session->user_level >= USER_LEVEL_ADMIN || $perms->get_permissions('snapr_add_tag') ) |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
338 |
{ |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
339 |
echo '<div style="float: right;">'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
340 |
if ( $session->user_level >= USER_LEVEL_ADMIN ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
341 |
echo '[ <a href="' . makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $img_id, true) . '">edit image</a> ] '; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
342 |
if ( $perms->get_permissions('snapr_add_tag') ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
343 |
echo '[ <a href="#" onclick="snapr_add_tag(); return false;"><img alt=" " src="' . scriptPath . '/plugins/gallery/tag-image.gif" style="border-width: 0;" /> add a tag</a> ] '; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
11
diff
changeset
|
344 |
echo '</div>'; |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
345 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
346 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
347 |
if ( !empty($row['img_desc']) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
348 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
349 |
echo '<h2>Image description</h2>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
350 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
351 |
$desc = RenderMan::render($row['img_desc']); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
352 |
echo $desc; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
353 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
354 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
355 |
echo '<div class="tblholder" style="font-size: smaller; display: table;' . ( empty($row['img_desc']) ? '' : 'margin: 0 auto;' ) . '"> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
356 |
<table border="0" cellspacing="1" cellpadding="3">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
357 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
358 |
// By the time I got to this point, it was 1:32AM (I was on vacation) and my 5-hour playlist on my iPod had been around about 3 times today. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
359 |
// So I'm glad this is like the last thing on the list tonight. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
360 |
|
9
ebd7003e73c6
Snapr now works with Enano's HTML/gzip optimization switches (1.0 compatibility broken, need 1.0.1 now)
Dan
parents:
2
diff
changeset
|
361 |
$ext = get_file_extension($row['img_filename']); |
ebd7003e73c6
Snapr now works with Enano's HTML/gzip optimization switches (1.0 compatibility broken, need 1.0.1 now)
Dan
parents:
2
diff
changeset
|
362 |
$ext = strtoupper($ext); |
ebd7003e73c6
Snapr now works with Enano's HTML/gzip optimization switches (1.0 compatibility broken, need 1.0.1 now)
Dan
parents:
2
diff
changeset
|
363 |
|
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
364 |
echo '<tr><th colspan="2">Image details</th></tr>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
365 |
echo '<tr><td class="row2">Uploaded:</td><td class="row1">' . date('F d, Y h:i a', $row['img_time_upload']) . '</td></tr>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
366 |
echo '<tr><td class="row2">Last modified:</td><td class="row1">' . date('F d, Y h:i a', $row['img_time_mod']) . '</td></tr>'; |
9
ebd7003e73c6
Snapr now works with Enano's HTML/gzip optimization switches (1.0 compatibility broken, need 1.0.1 now)
Dan
parents:
2
diff
changeset
|
367 |
echo '<tr><td class="row2">Original format:</td><td class="row1">' . $ext . '</td></tr>'; |
ebd7003e73c6
Snapr now works with Enano's HTML/gzip optimization switches (1.0 compatibility broken, need 1.0.1 now)
Dan
parents:
2
diff
changeset
|
368 |
echo '<tr><td class="row3" colspan="2" style="text-align: center;"><a href="' . makeUrlNS('Special', 'GalleryFetcher/full/' . $img_id, 'download', 'true') . '">Download image</a></td></tr>'; |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
369 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
370 |
echo '</table></div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
371 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
372 |
$template->footer(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
373 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
374 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
375 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
376 |
?> |