File: imagemap.php

package info (click to toggle)
gallery 1.5.4-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 26,712 kB
  • ctags: 6,567
  • sloc: php: 33,824; sh: 446; xml: 96; makefile: 88; perl: 61
file content (307 lines) | stat: -rw-r--r-- 9,976 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<?php
/*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2006 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
*
* $Id: imagemap.php 13338 2006-03-27 15:32:14Z jenst $
*/
?>
<?php
/**
 * @package Item
 */

require_once(dirname(__FILE__) . '/init.php');

list($full, $index, $imageareas, $formaction) = getRequestVar(array('full', 'index', 'imageareas', 'formaction'));

// Hack check and prevent errors
if (! $gallery->user->canChangeTextOfAlbum($gallery->album)) {
    header("Location: " . makeAlbumHeaderUrl());
    return;
}

if ($index > $gallery->album->numPhotos(1)) {
    $index = 1;
}
$id = $gallery->album->getPhotoId($index);

// Determine if user has the rights to view full-sized images
if (!empty($full) && !$gallery->user->canViewFullImages($gallery->album)) {
    header("Location: " . makeAlbumHeaderUrl($gallery->session->albumName, $id));
    return;
} elseif (!$gallery->album->isResized($index) && !$gallery->user->canViewFullImages($gallery->album)) {
    header("Location: " . makeAlbumHeaderUrl($gallery->session->albumName));
    return;
}

if (!isset($full) || (isset($full) && !$gallery->album->isResized($index))) {
    $full = NULL;
}

switch($formaction) {
    case 'delete':
        if(!empty($imageareas)) {
            foreach($imageareas as $nr) {
                $gallery->album->deleteImageArea($index, $nr);
            }
            $gallery->album->save();
        }
    break;
    case 'create':
        list($xvals, $yvals, $url, $text) = getRequestVar(array('xvals', 'yvals', 'areaurl', 'areatext'));
        if (isset($xvals) && isset($yvals)) {
            $xcoords = explode(',', $xvals);
            $ycoords = explode(',', $yvals);
    
            if (!empty($xcoords)) {
                $coords = $xcoords[0] .',' . $ycoords[0];
                for ($i = 1 ; $i < sizeof($xcoords); $i++) {
                    $coords .= ','. $xcoords[$i] .',' . $ycoords[$i];
                }
                $gallery->album->addImageArea($index, array(
                    'coords'   => $coords,
                    'x_coords' => $xvals,
                    'y_coords' => $yvals,
                    'url'      => $url,
                    'hover_text' => $text)
                );
                $gallery->album->save();
            }
        }
    break;
    case 'update':
        list($url, $text) = getRequestVar(array('areaurl', 'areatext'));
        foreach($imageareas as $area_index) {
            $gallery->album->updateImageArea($index, $area_index, array(
                'url'      => $url,
                'hover_text' => $text)
            );
        }
        $gallery->album->save();
    break;
    default:
    break;
}

$photo = $gallery->album->getPhoto($index);
$image = $photo->image;

$photoURL = $gallery->album->getAlbumDirURL("full") . "/" . $image->name . "." . $image->type;
list($imageWidth, $imageHeight) = $image->getRawDimensions();

if (!$GALLERY_EMBEDDED_INSIDE) {
	doctype(); ?>
<html> 
<head>
  <title><?php echo $gallery->app->galleryTitle; ?> :: ImageMaps :: </title>
  <?php
common_header();
?>
</head>
<body dir="<?php echo $gallery->direction ?>">
<?php
} // End if ! embedded

includeHtmlWrap("photo.header");

?>
  <script language="JavaScript" type="text/javascript" src="<?php echo $gallery->app->photoAlbumURL .'/js/wz_jsgraphics.js'; ?>"></script>
  <script language="JavaScript" type="text/javascript" src="<?php echo $gallery->app->photoAlbumURL .'/js/imagemap.js'; ?>"></script>
  <script type="text/javascript">
      init_mousemove();
 </script>
 
<?php

$rows = $gallery->album->fields["rows"];
$cols = $gallery->album->fields["cols"];
$perPage = $rows * $cols;
$page = (int)(ceil($index / ($rows * $cols)));

$iconElements = array();
if (!$GALLERY_EMBEDDED_INSIDE && !$gallery->session->offline) {
    if ($gallery->user->isLoggedIn()) {
        $iconText = getIconText('exit.gif', _("logout"));
        $iconElements[] = '<a href="'.
          doCommand("logout", array(), "view_album.php", array("page" => $page)) .
          '">'. $iconText .'</a>';
    } else {
        $iconText = getIconText('identity.gif', _("login"));
        $iconElements[] = popup_link($iconText, "login.php", false);
    }
}

$navigator["id"] = $id;
$navigator["allIds"] = $gallery->album->getIds($gallery->user->canWriteToAlbum($gallery->album));
$navigator["fullWidth"] = "100";
$navigator["widthUnits"] = "%";
$navigator["url"] = ".";

#-- breadcrumb text ---
$upArrowURL = gImage('nav_home.gif', _("navigate UP"));

foreach ($gallery->album->getParentAlbums(true) as $navAlbum) {
    $breadcrumb["text"][] = $navAlbum['prefixText'] .': '.
      galleryLink($navAlbum['url'], $navAlbum['title'] .'&nbsp;'. $upArrowURL, array('class' => 'bread'));
}

$breadcrumb["text"][] = galleryLink(
	makeAlbumUrl($gallery->session->albumName, $id),
	  _("Original photo") .'&nbsp;'. $upArrowURL,
	  array('class' => 'bread')
	);

$adminbox["commands"] = makeIconMenu($iconElements, 'right');

includeLayout('navtablebegin.inc');
includeLayout('adminbox.inc');
includeLayout('navtablemiddle.inc');

$breadcrumb["bordercolor"] = $gallery->album->fields["bordercolor"];
includeLayout('breadcrumb.inc');
includeLayout('navtableend.inc');

echo "</td></tr>\n";
echo "\n<!-- End Header Part -->";

echo "\n<!-- Real Content -->";
echo "\n<tr><td>\n\t";

list($width, $height) = $photo->getDimensions($full);

//print_r($photo);

echo showImageMap($index);

$allImageAreas = $gallery->album->getAllImageAreas($index);

if (!empty($allImageAreas)) {
    echo "\n". '<script type="text/javascript">';
    echo "\n\tvar map = new Array();";
    foreach($gallery->album->getAllImageAreas($index) as $nr => $area) {
        echo "\n\t map[$nr] = new Array();";
        echo "\n\t map[$nr]['x_coords'] = new Array(". $area['x_coords'] .');';
        echo "\n\t map[$nr]['y_coords'] = new Array(". $area['y_coords'] .');';
        echo "\n\t map[$nr]['url'] = '". $area['url'] ."';";
        echo "\n\t map[$nr]['hover_text'] = '". $area['hover_text'] ."';";
    }

    echo "\n</script>";

    $photoTag = $gallery->album->getPhotoTag($index, $full,"id=\"myPic\" usemap=\"myMap\"");
}
else {
    $photoTag = $gallery->album->getPhotoTag($index, $full,"id=\"myPic\"");
}
?>

<div class="popup" style="text-align: <?php echo langLeft(); ?>">
<?php
echo _("Here you can create, edit or delete imagemaps for the selected photo.");
echo "\n<br>";
echo _("Click the questionmark icon for helpful instructions.");
echo popup_link('<img src="'. getImagePath('icons/help.gif') .'">', 'help/imagemap.php');
?>
</div>

<?php 
echo makeFormIntro('imagemap.php',
    array('name' => 'areas'),
    array('index' => $index, 'formaction' => '')
    );
?>
<table width="100%" border="0">
<tr>
  <td width="300" style="vertical-align: top;">
    <?php $type = (isDebugging()) ? 'text':'hidden'; ?>
	<input type="<?php echo $type; ?>" name="ausg" id="current_position">
	<input type="<?php echo $type; ?>" name="xvals">
	<input type="<?php echo $type; ?>" name="yvals">
	<br>
	<input type="button" onClick="resetAndClear();" value="<?php echo _("Clear and reset canvas"); ?>">
	<hr>
	<?php echo gTranslate('core', "Optional link-url"); ?><br>
	<input type="text" size="50" name="areaurl" id="areaurl"><br>
	<?php echo gTranslate('core', "Description"); ?><br>
	<textarea name="areatext" id="areatext" cols="40" rows="5"></textarea>
	<input type="submit" value="<?php echo _("Save Imagemap") ?>" onclick="document.areas.formaction.value='create'">
    <hr>
<?php
//print_r($photo);
if (!empty($allImageAreas)) {
    $selectSize = (sizeof($allImageAreas) > 10) ? 10:sizeof($allImageAreas);

    echo _("Select entries to show image area in your photo.");
    echo "<br><select id=\"imageareas\" name=\"imageareas[]\" size=\"$selectSize\" multiple onChange=\"updatePictureAndArea()\">";
    foreach($gallery->album->getAllImageAreas($index) as $nr => $coords) {
        echo "\n<option value=\"$nr\">Map $nr</option>";
    }
    echo "\n</select>";

    echo "\n<hr>";
    echo "<input type=\"submit\" value=\"". _("Delete selected ImageMap(s)") ."\" onclick=\"document.areas.formaction.value='delete'\">";

    echo "\n<hr>";
    echo "<input type=\"submit\" value=\"". _("Update selected ImageMap(s)") ."\" onclick=\"document.areas.formaction.value='update'\">";

    echo '<div class="attention">'. gTranslate('core', "Be aware, that the text of ALL selected entries will be updated!") .'</div>';
}
else {
    echo _("No ImageMaps");
}
?>
  </td>
  <td>
    <div id="myCanvas" style="border: 1px dashed red; width:<?php echo $image->width; ?>px; height:<?php echo $image->height; ?>px">
      <?php echo $photoTag; ?>
    </div>
  </td>
</tr>
</table>
</form>

  </td>
</tr>
<!-- End Real Content -->
<!-- Start Footer Part -->
<tr>
  <td>
<?php 

includeLayout('navtablebegin.inc');
includeLayout('breadcrumb.inc');
includeLayout('navtableend.inc');
echo languageSelector();

includeHtmlWrap("photo.footer");

if (!empty($allImageAreas)) {
    echo '<script language="JavaScript" type="text/javascript" src="'. $gallery->app->photoAlbumURL .'/js/wz_tooltip.js"></script>';
}
?>    
    <script type="text/javascript">
    <!--
      initPaintArea ();
    //-->
    </script>
<?php
if (!$GALLERY_EMBEDDED_INSIDE) { ?>
</body>
</html>
<?php }
?>