2009-08-14 03:53:00 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
|
|
|
<?
|
2009-08-28 01:29:08 +00:00
|
|
|
// Check and see if the current photo has any faces or notes associated with it.
|
2009-08-14 03:53:00 +00:00
|
|
|
$existingFaces = ORM::factory("items_face")
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("item_id", "=", $item->id)
|
2009-08-14 03:53:00 +00:00
|
|
|
->find_all();
|
2009-08-28 01:29:08 +00:00
|
|
|
$existingNotes = ORM::factory("items_note")
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("item_id", "=", $item->id)
|
2009-08-28 01:29:08 +00:00
|
|
|
->find_all();
|
2009-12-23 05:31:03 +00:00
|
|
|
|
2009-08-14 03:53:00 +00:00
|
|
|
// If it does, then insert some javascript and display an image map
|
|
|
|
// to show where the faces are at.
|
2009-08-28 01:29:08 +00:00
|
|
|
if ((count($existingFaces) > 0) || (count($existingNotes) > 0)) {
|
2009-08-14 03:53:00 +00:00
|
|
|
?>
|
2009-08-24 21:15:56 +00:00
|
|
|
<style>
|
|
|
|
.transparent30
|
|
|
|
{
|
2009-12-23 05:31:03 +00:00
|
|
|
filter:alpha(opacity=30);
|
|
|
|
-moz-opacity: 0.3;
|
|
|
|
opacity: 0.3;
|
2009-08-24 21:15:56 +00:00
|
|
|
}
|
|
|
|
.transparent80
|
|
|
|
{
|
2009-12-23 05:31:03 +00:00
|
|
|
filter:alpha(opacity=80);
|
|
|
|
-moz-opacity: 0.8;
|
|
|
|
opacity: 0.8;
|
2009-08-24 21:15:56 +00:00
|
|
|
}
|
|
|
|
</style>
|
2009-08-14 03:53:00 +00:00
|
|
|
|
|
|
|
<script type="text/JavaScript">
|
|
|
|
function setfacemap() {
|
|
|
|
// Insert the usemap element into the resize photo's image tag.
|
2009-10-04 20:40:59 +00:00
|
|
|
var photoimg = document.getElementById('g-photo-id-<?=$item->id ?>');
|
2009-08-14 03:53:00 +00:00
|
|
|
photoimg.useMap = '#faces';
|
|
|
|
}
|
|
|
|
|
2009-08-28 01:29:08 +00:00
|
|
|
function highlightbox(x1, y1, x2, y2, str_title, str_description, str_url) {
|
2009-08-24 21:15:56 +00:00
|
|
|
var divtext = document.getElementById('divtagtext');
|
2009-10-04 20:40:59 +00:00
|
|
|
var photodiv = document.getElementById('g-photo');
|
|
|
|
var photoimg = document.getElementById('<?="g-photo-id-{$item->id}"?>');
|
2009-08-24 21:15:56 +00:00
|
|
|
var divface = document.getElementById('divsquare');
|
2009-12-23 05:31:03 +00:00
|
|
|
|
2009-08-24 21:15:56 +00:00
|
|
|
divface.style.display = 'block';
|
|
|
|
divface.style.left = (photoimg.offsetLeft + x1) + 'px';
|
2010-01-11 07:26:03 +00:00
|
|
|
divface.style.top = (photodiv.offsetTop + 24 + y1) + 'px';
|
2009-08-24 21:15:56 +00:00
|
|
|
divface.style.width=(x2-x1) + 'px';
|
|
|
|
divface.style.height=(y2-y1) + 'px';
|
2009-08-28 01:29:08 +00:00
|
|
|
if (str_url == '') {
|
|
|
|
divface.onclick = function() {return; }
|
|
|
|
} else {
|
|
|
|
divface.onclick = function() {self.location.href = str_url;}
|
|
|
|
}
|
2009-12-23 05:31:03 +00:00
|
|
|
|
2009-08-24 21:15:56 +00:00
|
|
|
divtext.style.display = 'block';
|
|
|
|
divtext.style.left = divface.style.left;
|
2009-12-23 05:31:03 +00:00
|
|
|
|
2009-08-28 01:29:08 +00:00
|
|
|
if (str_description == '') {
|
|
|
|
divtext.innerText = str_title;
|
|
|
|
divtext.textContent = str_title;
|
|
|
|
} else {
|
|
|
|
divtext.innerHTML = str_title + '<br/>' + str_description;
|
|
|
|
}
|
2009-12-23 05:31:03 +00:00
|
|
|
|
2009-08-24 21:15:56 +00:00
|
|
|
divtext.style.top = (parseInt(divface.style.top.split('p')[0]) + parseInt(divface.style.height.split('p')[0]) + 2) + 'px';
|
|
|
|
}
|
2009-08-14 03:53:00 +00:00
|
|
|
|
2009-08-24 21:15:56 +00:00
|
|
|
function hidebox() {
|
|
|
|
// Hide the divs when the mouse moves off of the face.
|
|
|
|
document.getElementById('divsquare').style.display = 'none';
|
|
|
|
document.getElementById('divtagtext').style.display = 'none';
|
|
|
|
}
|
2009-12-23 05:31:03 +00:00
|
|
|
|
2009-08-14 03:53:00 +00:00
|
|
|
// Call setfacemap when the page loads.
|
|
|
|
window.onload = setfacemap();
|
|
|
|
</script>
|
|
|
|
|
2009-12-23 05:31:03 +00:00
|
|
|
<div id="divtagtext" class="transparent80" style="position:absolute;display:none;border:2px #000000 outset;background-color:#ffffff;font-weight:bold;"></div>
|
2009-08-24 21:15:56 +00:00
|
|
|
<div id="divsquare" class="transparent30" onMouseOut="hidebox()" style="position:absolute;display:none;border:2px solid #000000;background-color:#ffffff;" onclick="self.location.href = '';"></div>
|
|
|
|
|
2009-08-14 03:53:00 +00:00
|
|
|
<map name="faces">
|
|
|
|
<?
|
|
|
|
// For each face, add a rectangle area to the page.
|
|
|
|
foreach ($existingFaces as $oneFace) {
|
|
|
|
$oneTag = ORM::factory("tag", $oneFace->tag_id)
|
|
|
|
?>
|
2010-01-10 07:35:10 +00:00
|
|
|
<area shape="rect" coords="<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>" href="<?=$oneTag->url() ?>" title="<?=html::clean($oneTag->name); ?>" alt="<?=$oneTag->name; ?>" onMouseOver="highlightbox(<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>,'<?=html::clean($oneTag->name); ?>', '<?=html::clean($oneFace->description); ?>', '<?=$oneTag->url() ?>')" />
|
2009-08-14 03:53:00 +00:00
|
|
|
<? } ?>
|
2009-08-28 01:29:08 +00:00
|
|
|
|
|
|
|
<?
|
|
|
|
// For each note, add a rectangle area to the page.
|
|
|
|
foreach ($existingNotes as $oneNote) {
|
|
|
|
?>
|
2009-08-31 18:08:43 +00:00
|
|
|
<area shape="rect" coords="<?=$oneNote->x1 ?>,<?=$oneNote->y1 ?>,<?=$oneNote->x2 ?>,<?=$oneNote->y2 ?>" title="<?=html::clean($oneNote->title); ?>" alt="<?=$oneNote->title; ?>" onMouseOver="highlightbox(<?=$oneNote->x1 ?>,<?=$oneNote->y1 ?>,<?=$oneNote->x2 ?>,<?=$oneNote->y2 ?>,'<?=html::clean($oneNote->title); ?>', '<?=html::clean($oneNote->description); ?>', '')" />
|
2009-08-28 01:29:08 +00:00
|
|
|
<? } ?>
|
|
|
|
|
2009-08-14 03:53:00 +00:00
|
|
|
</map>
|
|
|
|
<?
|
|
|
|
}
|
|
|
|
?>
|