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.
$existingFaces = ORM :: factory ( " items_face " )
-> where ( " item_id " , " = " , $item -> id )
-> find_all ();
$existingNotes = ORM :: factory ( " items_note " )
-> where ( " item_id " , " = " , $item -> id )
-> find_all ();
$tags_arraystring = " " ;
$jscode = " " ;
$legend_faces = " " ;
$legend_notes = " " ;
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.
if (( count ( $existingFaces ) > 0 ) || ( count ( $existingNotes ) > 0 )) {
$jscode = " notes: [ " ;
foreach ( $existingFaces as $oneFace ) {
$oneTag = ORM :: factory ( " tag " , $oneFace -> tag_id );
if ( module :: get_var ( " photoannotation " , " showfaces " , false )) {
$legend_faces .= " <a href= \" " . $oneTag -> url () . " \" > " . html :: clean ( $oneTag -> name ) . " </a>, " ;
}
$jscode .= " { \" top \" : " . $oneFace -> y1 . " , \n " ;
$jscode .= " \" left \" : " . $oneFace -> x1 . " , \n " ;
$jscode .= " \" width \" : " . ( $oneFace -> x2 - $oneFace -> x1 ) . " , \n " ;
$jscode .= " \" height \" : " . ( $oneFace -> y2 - $oneFace -> y1 ) . " , \n " ;
2010-08-28 16:07:08 +00:00
$jscode .= " \" text \" : \" " . html :: clean ( $oneTag -> name ) . " \" , \n " ;
$jscode .= " \" description \" : \" " . html :: clean ( $oneFace -> description ) . " \" , \n " ;
2010-08-28 08:49:50 +00:00
$jscode .= " \" noteid \" : " . $oneFace -> id . " , \n " ;
$jscode .= " \" notetype \" : \" face \" , \n " ;
$jscode .= " \" editable \" : true, \n " ;
$jscode .= " \" url \" : \" " . $oneTag -> url () . " \" }, \n " ;
}
if ( $legend_faces != " " ) {
$legend_faces = trim ( $legend_faces , " , " );
$legend_faces = t ( " Faces on this photo: " ) . $legend_faces ;
}
foreach ( $existingNotes as $oneNote ) {
if ( module :: get_var ( " photoannotation " , " shownotes " , false )) {
$legend_notes .= html :: clean ( $oneNote -> title ) . " , " ;
}
$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 .= " ], " ;
if ( $legend_notes != " " ) {
$legend_notes = trim ( $legend_notes , " , " );
$legend_notes = t ( " Notes on this photo: " ) . $legend_notes ;
}
}
$legend_display = $legend_faces ;
if ( $legend_display == " " ) {
$legend_display = $legend_notes ;
} else {
if ( $legend_notes != " " ) {
$legend_display = $legend_display . " <br /> " . $legend_notes ;
}
}
$item_tags = ORM :: factory ( " tag " )
-> join ( " items_tags " , " tags.id " , " items_tags.tag_id " )
-> where ( " items_tags.item_id " , " = " , $item -> id )
-> find_all ();
$tags_arraystring = " tags: [ " ;
foreach ( $item_tags as $current_tag ) {
$tags_arraystring .= " { 'name':' " . html :: clean ( $current_tag -> name ) . " ','id':' " . $current_tag -> id . " '}, " ;
}
$tags_arraystring = trim ( $tags_arraystring , " , " );
$tags_arraystring .= " ], " ;
$labels_arraystring = " labels: [ ' " . t ( " Tag: " ) . " ',' " . t ( " Note Title: " ) . " ',' " . t ( " Description (optional): " ) . " ',' " . t ( " Are you sure you want to delete this annotation? " ) . " ' ], " ;
?>
< script language = " 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-28 08:49:50 +00:00
< ? = $tags_arraystring ?>
< ? = $labels_arraystring ?>
< ? = $jscode ?>
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 >
< ? if ( $legend_display != " " ) : ?>
< ? = " <div style= \" text-align: center \" > " . $legend_display . " </div> " ?>
2010-08-28 16:07:08 +00:00
< ? endif ?>