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")
|
|
|
|
->where("item_id", $item->id)
|
|
|
|
->find_all();
|
2009-08-28 01:29:08 +00:00
|
|
|
$existingNotes = ORM::factory("items_note")
|
|
|
|
->where("item_id", $item->id)
|
|
|
|
->find_all();
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
filter:alpha(opacity=30);
|
|
|
|
-moz-opacity: 0.3;
|
|
|
|
opacity: 0.3;
|
|
|
|
}
|
|
|
|
.transparent80
|
|
|
|
{
|
|
|
|
filter:alpha(opacity=80);
|
|
|
|
-moz-opacity: 0.8;
|
|
|
|
opacity: 0.8;
|
|
|
|
}
|
|
|
|
</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.
|
|
|
|
var photoimg = document.getElementById('gPhotoId-<?=$item->id ?>');
|
|
|
|
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');
|
|
|
|
var photodiv = document.getElementById('gPhoto');
|
|
|
|
var photoimg = document.getElementById('<?="gPhotoId-{$item->id}"?>');
|
|
|
|
var divface = document.getElementById('divsquare');
|
|
|
|
|
|
|
|
divface.style.display = 'block';
|
|
|
|
divface.style.left = (photoimg.offsetLeft + x1) + 'px';
|
|
|
|
divface.style.top = (photodiv.offsetTop + y1) + 'px';
|
|
|
|
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-08-24 21:15:56 +00:00
|
|
|
|
|
|
|
divtext.style.display = 'block';
|
|
|
|
divtext.style.left = divface.style.left;
|
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-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-08-14 03:53:00 +00:00
|
|
|
// Call setfacemap when the page loads.
|
|
|
|
window.onload = setfacemap();
|
|
|
|
</script>
|
|
|
|
|
2009-08-24 21:15:56 +00:00
|
|
|
<div id="divtagtext" class="transparent80" style="position:absolute;display:none;border:2px #000000 outset;background-color:#ffffff;font-weight:bold;"></div>
|
|
|
|
<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)
|
|
|
|
?>
|
2009-08-28 01:29:08 +00:00
|
|
|
<area shape="rect" coords="<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>" href="<?=url::site("tags/$oneFace->tag_id") ?>" title="<?=p::clean($oneTag->name); ?>" alt="<?=p::clean($oneTag->name); ?>" onMouseOver="highlightbox(<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>,'<?=p::clean($oneTag->name); ?>', '<?=p::clean($oneFace->description); ?>', '<?=url::site("tags/$oneFace->tag_id") ?>')" />
|
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) {
|
|
|
|
?>
|
|
|
|
<area shape="rect" coords="<?=$oneNote->x1 ?>,<?=$oneNote->y1 ?>,<?=$oneNote->x2 ?>,<?=$oneNote->y2 ?>" title="<?=p::clean($oneNote->title); ?>" alt="<?=p::clean($oneNote->title); ?>" onMouseOver="highlightbox(<?=$oneNote->x1 ?>,<?=$oneNote->y1 ?>,<?=$oneNote->x2 ?>,<?=$oneNote->y2 ?>,'<?=p::clean($oneNote->title); ?>', '<?=p::clean($oneNote->description); ?>', '')" />
|
|
|
|
<? } ?>
|
|
|
|
|
2009-08-14 03:53:00 +00:00
|
|
|
</map>
|
|
|
|
<?
|
|
|
|
}
|
|
|
|
?>
|