2010-08-28 08:49:50 +00:00
< ? php defined ( " SYSPATH " ) or die ( " No direct script access. " );
// Check and see if the current photo has any faces or notes associated with it.
2010-09-03 14:57:57 +00:00
$existingUsers = ORM :: factory ( " items_user " )
-> where ( " item_id " , " = " , $item -> id )
-> find_all ();
2010-08-28 08:49:50 +00:00
$existingFaces = ORM :: factory ( " items_face " )
-> where ( " item_id " , " = " , $item -> id )
-> find_all ();
$existingNotes = ORM :: factory ( " items_note " )
-> where ( " item_id " , " = " , $item -> id )
-> find_all ();
2010-09-03 14:57:57 +00:00
$fullname = module :: get_var ( " photoannotation " , " fullname " , false );
$showusers = module :: get_var ( " photoannotation " , " showusers " , false );
$showfaces = module :: get_var ( " photoannotation " , " showfaces " , false );
$shownotes = module :: get_var ( " photoannotation " , " shownotes " , false );
2010-08-31 15:12:25 +00:00
if ( locales :: is_rtl ()) {
$rtl_support = " image-annotate-rtl " ;
} else {
$rtl_support = " " ;
}
2010-08-28 08:49:50 +00:00
$tags_arraystring = " " ;
$jscode = " " ;
$legend_faces = " " ;
$legend_notes = " " ;
2010-09-19 17:32:18 +00:00
$legend_users = " " ;
2010-08-28 23:47:15 +00:00
if ( module :: get_var ( " gallery " , " active_site_theme " ) == " greydragon " ) {
$css_item_id = " #g-photo-id- " . $item -> id ;
$css_a_class = " .g-sb-preview " ;
} else {
$css_item_id = " #g-item-id- " . $item -> id ;
$css_a_class = " .g-fullsize-link " ;
}
2010-08-28 08:49:50 +00:00
// If it does, then insert some javascript and display an image map
// to show where the faces are at.
2010-09-03 14:57:57 +00:00
if (( count ( $existingFaces ) > 0 ) || ( count ( $existingNotes ) > 0 ) || ( count ( $existingUsers ) > 0 )) {
2010-08-28 08:49:50 +00:00
$jscode = " notes: [ " ;
2010-09-03 14:57:57 +00:00
foreach ( $existingUsers as $oneUser ) {
$oneTag = ORM :: factory ( " user " , $oneUser -> user_id );
2010-09-05 20:27:38 +00:00
if ( $oneTag -> loaded ()) {
2010-09-07 16:40:14 +00:00
if ( $fullname ) {
$user_text = $oneTag -> display_name ();
2010-09-05 20:27:38 +00:00
} else {
$user_text = $oneTag -> name ;
}
if ( $showusers ) {
2010-09-22 14:03:44 +00:00
$legend_users .= " <span id= \" photoannotation-legend-user- " . $oneUser -> id . " \" ><a href= \" " . user_profile :: url ( $oneUser -> user_id ) . " \" > " . html :: clean ( $user_text ) . " </a></span> " ;
2010-09-05 20:27:38 +00:00
}
$jscode .= " { \" top \" : " . $oneUser -> y1 . " , \n " ;
$jscode .= " \" left \" : " . $oneUser -> x1 . " , \n " ;
$jscode .= " \" width \" : " . ( $oneUser -> x2 - $oneUser -> x1 ) . " , \n " ;
$jscode .= " \" height \" : " . ( $oneUser -> y2 - $oneUser -> y1 ) . " , \n " ;
$jscode .= " \" text \" : \" " . html :: clean ( $user_text ) . " \" , \n " ;
2010-09-07 16:40:14 +00:00
$jscode .= " \" internaltext \" : \" " . $oneTag -> display_name () . " ( " . $oneTag -> name . " ) \" , \n " ;
2010-09-05 20:27:38 +00:00
$jscode .= " \" description \" : \" " . html :: clean ( $oneUser -> description ) . " \" , \n " ;
$jscode .= " \" noteid \" : " . $oneUser -> id . " , \n " ;
$jscode .= " \" notetype \" : \" user \" , \n " ;
$jscode .= " \" editable \" : true, \n " ;
$jscode .= " \" url \" : \" " . user_profile :: url ( $oneUser -> user_id ) . " \" }, \n " ;
2010-09-03 14:57:57 +00:00
}
}
2010-08-28 08:49:50 +00:00
foreach ( $existingFaces as $oneFace ) {
$oneTag = ORM :: factory ( " tag " , $oneFace -> tag_id );
2010-09-05 20:27:38 +00:00
if ( $oneTag -> loaded ()) {
if ( $showfaces ) {
2010-09-22 14:03:44 +00:00
$legend_faces .= " <span id= \" photoannotation-legend-face- " . $oneFace -> id . " \" ><a href= \" " . $oneTag -> url () . " \" > " . html :: clean ( $oneTag -> name ) . " </a></span> " ;
2010-09-05 20:27:38 +00:00
}
$jscode .= " { \" top \" : " . $oneFace -> y1 . " , \n " ;
$jscode .= " \" left \" : " . $oneFace -> x1 . " , \n " ;
$jscode .= " \" width \" : " . ( $oneFace -> x2 - $oneFace -> x1 ) . " , \n " ;
$jscode .= " \" height \" : " . ( $oneFace -> y2 - $oneFace -> y1 ) . " , \n " ;
$jscode .= " \" text \" : \" " . html :: clean ( $oneTag -> name ) . " \" , \n " ;
$jscode .= " \" description \" : \" " . html :: clean ( $oneFace -> description ) . " \" , \n " ;
$jscode .= " \" noteid \" : " . $oneFace -> id . " , \n " ;
$jscode .= " \" notetype \" : \" face \" , \n " ;
$jscode .= " \" editable \" : true, \n " ;
$jscode .= " \" url \" : \" " . $oneTag -> url () . " \" }, \n " ;
2010-08-28 08:49:50 +00:00
}
}
foreach ( $existingNotes as $oneNote ) {
2010-09-03 14:57:57 +00:00
if ( $shownotes ) {
2010-09-22 14:03:44 +00:00
$legend_notes .= " <span id= \" photoannotation-legend-note- " . $oneNote -> id . " \" > " . html :: clean ( $oneNote -> title ) . " </span> " ;
2010-08-28 08:49:50 +00:00
}
$jscode .= " { \" top \" : " . $oneNote -> y1 . " , \n " ;
$jscode .= " \" left \" : " . $oneNote -> x1 . " , \n " ;
$jscode .= " \" width \" : " . ( $oneNote -> x2 - $oneNote -> x1 ) . " , \n " ;
$jscode .= " \" height \" : " . ( $oneNote -> y2 - $oneNote -> y1 ) . " , \n " ;
2010-08-28 16:07:08 +00:00
$jscode .= " \" text \" : \" " . html :: clean ( $oneNote -> title ) . " \" , \n " ;
$jscode .= " \" description \" : \" " . html :: clean ( $oneNote -> description ) . " \" , \n " ;
2010-08-28 08:49:50 +00:00
$jscode .= " \" noteid \" : " . $oneNote -> id . " , \n " ;
$jscode .= " \" notetype \" : \" note \" , \n " ;
$jscode .= " \" editable \" : false, \n " ;
$jscode .= " \" url \" : \" \" }, \n " ;
}
$jscode = trim ( $jscode , " , \n " );
$jscode .= " ], " ;
}
2010-09-23 10:05:05 +00:00
$display = " none " ;
if ( $legend_users != " " ) {
$display = " block " ;
}
$legend_users = t ( " <span id= \" photoannotation-legend-user \" style= \" display: " . $display . " \" >People on this photo: " ) . $legend_users . " </span> " ;
$display = " none " ;
if ( $legend_faces != " " ) {
$display = " block " ;
}
$legend_faces = t ( " <span id= \" photoannotation-legend-face \" style= \" display: " . $display . " \" >Faces on this photo: " ) . $legend_faces . " </span> " ;
$display = " none " ;
if ( $legend_notes != " " ) {
$display = " block " ;
}
$legend_notes = t ( " <span id= \" photoannotation-legend-note \" style= \" display: " . $display . " \" >Notes on this photo: " ) . $legend_notes . " </span> " ;
2010-09-11 20:00:14 +00:00
$legend_display = $legend_users . $legend_faces . $legend_notes ;
2010-09-21 16:04:45 +00:00
$labels_arraystring = " labels: [ ' " . t ( " Tag: " ) . " ',' " . t ( " Note Title: " ) . " ',' " . t ( " Description (optional) " ) . " ',' " . t ( " Are you sure you want to delete this annotation? " ) . " ',' " . t ( " or " ) . " ',' " . t ( " Yes " ) . " ',' " . t ( " No " ) . " ',' " . t ( " Confirm deletion " ) . " ',' " . t ( " Save " ) . " ',' " . t ( " Cancel " ) . " ',' " . t ( " Person: " ) . " ',' " . t ( " No user selected " ) . " ',' " . t ( " Select one of the following " ) . " ',' " . t ( " An error ocurred while saving annotation " ) . " ',' " . t ( " OK " ) . " ',' " . t ( " An error ocurred while deleting annotation " ) . " ',' " . t ( " View fullsize " ) . " ' ], " ;
2010-08-28 08:49:50 +00:00
?>
2010-08-31 15:12:25 +00:00
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
2010-08-28 23:47:15 +00:00
$ ( " <?= $css_item_id ?> " ) . annotateImage ({
2010-08-28 08:49:50 +00:00
< ? if (( access :: can ( " view " , $item )) && ( access :: can ( " edit " , $item ))) : ?>
editable : true ,
< ? else : ?>
editable : false ,
< ? endif ?>
saveUrl : '<?= url::site("photoannotation/save/". $item->id) ?>' ,
2010-08-30 10:39:06 +00:00
deleteUrl : '<?= url::site("photoannotation/delete/". $item->id) ?>' ,
2010-08-31 15:12:25 +00:00
tags : '<?= url::site("tags/autocomplete") ?>' ,
2010-08-28 08:49:50 +00:00
< ? = $labels_arraystring ?>
< ? = $jscode ?>
2010-09-07 16:40:14 +00:00
users : '<?= url::site("photoannotation/autocomplete") ?>' ,
2010-08-31 15:12:25 +00:00
rtlsupport : '<?= $rtl_support ?>' ,
2010-08-28 08:49:50 +00:00
useAjax : false ,
2010-08-28 23:47:15 +00:00
cssaclass : '<?= $css_a_class ?>' ,
2010-08-28 08:49:50 +00:00
csrf : '<?= $csrf ?>'
});
});
</ script >
2010-09-22 14:03:44 +00:00
< ? = " <div id= \" photoannotation-legend \" class= \" g-breadcrumbs \" style= \" text-align: center \" > " . $legend_display . " </div> " ?>