function query($query) { displayDebug("function query", 4); displayDebug("query: " . $query, 4); displayDebugParam($r, 4); $r = new resultset_abstract($query, $this->db); return $r; }
function getAnnotations(&$fn_image) { // The $fn_image must be passed by reference because this functions sets parameters. $DHTML_MAXWIDTH = $fn_image->param['width']; $DHTML_MAXHEIGHT = $fn_image->param['height']; //$this->image = $fn_image->param['image']; $this->image = $fn_image->param['image_path']; displayDebug('FNRetrieveJPEGHeader called & image is ' . $this->image, 4); //$imageinfo = $this->getImageInfo($imagefile); //$size = getimagesize($imageinfo['image_src']); $size = getimagesize($this->image); displayDebugParam($size, 4); $ratioWidth = $DHTML_MAXWIDTH / $size[0]; $ratioHeight = $DHTML_MAXHEIGHT / $size[1]; if ($ratioHeight > $ratioWidth) { $ratio = $ratioWidth; } else { $ratio = $ratioHeight; } if ($ratio > 1) { $ratio = 1; } $fn_image->setFnImageParam('scalefactor', $ratio); $this->annotationXMLBlock = $this->getAnnotationsXMLBlockFromJPEGHeader(); $fn_image->setFnImageParam("annotationXMLBlock", $this->annotationXMLBlock); //return $this->annotationXMLBlock; //$xml = $this->readFotonotesXML($imagefile); // from older code $xml = $this->annotationXMLBlock; preg_match_all("#<entry>(.*)</entry>#Umsi", $xml, $entries); foreach ($entries[1] as $entry) { preg_match("#<fn:boundingBox>(.*)</fn:boundingBox>#Umsi", $entry, $coordstring); $coords = explode(",", $coordstring[1]); list($annotation['upperleftx'], $annotation['upperlefty'], $annotation['lowerrightx'], $annotation['lowerrighty']) = $coords; //$annotation['width'] = ($coords[2] - $coords[0])*$ratio; $annotation['width'] = ($coords[2] - $coords[0]) * $ratio; $annotation['height'] = ($coords[3] - $coords[1]) * $ratio; $annotation['upperlefty'] *= $ratio; $annotation['upperleftx'] *= $ratio; $annotation['lowerrightx'] *= $ratio; $annotation['lowerrighty'] *= $ratio; preg_match("#<title>(.*)</title>#Umsi", $entry, $title); $annotation['title'] = $title[1]; preg_match("#<content.*>(.*)</content>#Umsi", $entry, $content); $annotation['content'] = $content[1]; preg_match("#<name>(.*)</name>#Umsi", $entry, $author); $annotation['author'] = $author[1]; preg_match("#<created>(.*)</created>#Umsi", $entry, $created); $annotation['created'] = $created[1]; preg_match("#<issued>(.*)</issued>#Umsi", $entry, $issued); $annotation['issued'] = $issued[1]; preg_match("#<modified>(.*)</modified>#Umsi", $entry, $modified); $annotation['modified'] = $modified[1]; preg_match("#<id>(.*)</id>#Umsi", $entry, $id); //$annotation['id'] = basename($id[1]); Do not get basename, use full url $annotation['id'] = $id[1]; $annotations[] = $annotation; } return $annotations; }
foreach ($_POST as $key => $value) { $fni->setFnImageParam($key, urldecode($value)); } break; case "GET": foreach ($_GET as $key => $value) { echo "\nkey: {$key}"; $fni->setFnImageParam($key, urldecode($value)); } break; } $fni->setFnImageParam("timestamp", gmdate("Y-m-d\\TH:i:s\\Z", time())); // DETERMINE path to the image $fni->setFnImageParam("url_parts", parse_url($fni->param['image'])); displayDebug("url_parts", 4); displayDebugParam($fni->param['url_parts']); $fni->setFnImageParam("image_path", $_SERVER['DOCUMENT_ROOT'] . $fni->param['url_parts']['path']); displayDebug("image_path: " . $fni->param['image_path'], 4); displayDebug("action: " . $fni->param['action'], 2); // CLEANUP incoming XML from client, if exists if ($fni->fnImageParamExists("xml")) { $fni->param["xml"] = preg_replace("#<\\?xml.*>#Umsi", "", $fni->param["xml"]); $fni->param["xml"] = preg_replace("#<feed.*>#Umsi", "", $fni->param["xml"]); $fni->param["xml"] = preg_replace("#</feed>#Umsi", "", $fni->param["xml"]); $fni->param["xml"] = stripslashes($fni->param["xml"]); // Determine username by userid preg_match("#<userid>(.*)</userid>#", $fni->param["xml"], $matches); $userid = $matches[1]; $username = $FN_USER->getDisplayNameByUserID($userid); $fni->setFnImageParam("username", $username); $userpropername = $FN_USER->getProperNameByUserID($userid);
function generateFnImageAnnotationXmlV03() { // make sure <entry>...<entry> is clearly generated global $FN_FEED_PATH, $FN_FEED_STYLESHEET_PATH, $FN_FOTONOTES_DATA_PATH_PREFIX, $FILETYPES; global $ANNOTATIONS_ORIGINALS_FOLDER, $ANNOTATIONS_THUMBNAILS_FOLDER; $xml = null; // get unique uuid for feed $feed_uuid = getNewUUID(); $this->param["feed_uuid"] = $feed_uuid; // get feed file destination based on today's date $createdtime = time(); $year = gmdate("Y", $createdtime); $month = gmdate("m", $createdtime); $day = gmdate("d", $createdtime); $created = gmdate("Y-m-d\\TH:i:s\\Z", $createdtime); $storagepath = $FN_FEED_PATH . $year . "/" . $month . "/" . $day; $feed_file_path = $storagepath . "/" . $feed_uuid . ".xml"; $this->param["feed_file_path"] = $feed_file_path; displayDebug("feed_file_path: {$feed_file_path}", 3); displayDebug("param[feed_file_path]: " . $this->param["feed_file_path"], 3); //make sure path exists createPath($storagepath); // parse incoming xml displayDebug("this->param[src_xml]", 2); displayDebugParam($this->param["src_xml"], 2); $entry_array = $this->parseEntryXML($this->param["src_xml"]); // ASSIGN *entry_array* values to *annotations* params foreach ($entry_array as $key => $value) { $this->setFnImageAnnotationParam($key, $value); } // fix uuid // first transform existing <id> in xml to <fn:id> //$xml = preg_replace("#<id>(.*)</id>#","<fn2:id>$1</fn2:id>",$xml); $this->param["src_xml"] = preg_replace("#<id>(.*)</id>#", "<fn:id>\$1</fn:id>", $this->param["src_xml"]); $entry_uuid = "<id>{$entry_array['id']}</id>\n"; $parent_entry_id = $entry_array['parent_id']; $parent_entry_uuid = "<parent_uuid>" . $entry_array['parent_id'] . "</parent_uuid>"; $parent_entry_array = null; //getEntriesXML2Array($parent_entry_id); //echo "\ngeom: ".$parent_entry_array['geometry']. "\n"; $entry_geometry = "<geometry>" . $parent_entry_array['geometry'] . "</geometry>"; // SET parent_image_link in fn_anntoation $this->param["parent_link_jpg"] = $parent_entry_array["link_jpg"]; // PREPARE *make image* parameters displayDebug("<p>parent_entry_array: {$parent_entry_array}", 2); displayDebugParam($parent_entry_array, 2); $annotation_storagepath = $ANNOTATIONS_ORIGINALS_FOLDER . "/" . $year . "/" . $month . "/" . $day; displayDebug("annotation_storagepath: {$annotation_storagepath}", 1); // CHECK AND CREATE *file path* createPath($annotation_storagepath); // PREPARE xml links for section of photo $entry_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes.php#", "", $_SERVER['REQUEST_URI']) . $annotation_storagepath . '/' . $entry_array[id] . '.jpg'; $entry_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes2.php#", "", $_SERVER['REQUEST_URI']) . $annotation_storagepath . '/' . $entry_array[id] . '.jpg'; displayDebug("\$entry_link_jpg: {$entry_link_jpg}", 3); // this won't always be jpg $entry_mimetype = "image/jpg"; $entry_annotation_link = "<link href=\"{$entry_link_jpg}\" rel=\"annotated_region\" type=\"{$entry_mimetype}\" />"; $entry_jpg_link = "<link href=\"{$entry_link_jpg}\" rel=\"jpg\" type=\"{$entry_mimetype}\" />"; // WRITE annotated section of photo to file system displayDebug("\n fn_makeImage ({$parent_entry_array['link_jpg']}, " . str_replace(",", " ", $entry_array[boundingbox]) . ", 1,\n\t\t\tnull, null, {$annotation_storagepath}.'/'.{$entry_array['id']}.'.jpg')"); fn_makeImage($parent_entry_array['link_jpg'], str_replace(",", " ", $entry_array[boundingbox]), 1, null, null, $annotation_storagepath . '/' . $entry_array[id] . '.jpg', 1); // PREPARE *make image* parameters for *thumbnail* of annotated region $annotation_thumbnail_storagepath = $ANNOTATIONS_THUMBNAILS_FOLDER . "/" . $year . "/" . $month . "/" . $day; displayDebug("annotation_storagepath: {$annotation_thumbnail_storagepath}", 3); // calculate thumbscale factor - This needs to be better, to actually calculate scale! $thumbscale = 1; // CHECK AND CREATE *file path* for *thumbnail* of annotated region createPath($annotation_thumbnail_storagepath); // PREPARE xml links for *thumbnail* of annotated region $entry_thumbnail_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes.php#", "", $_SERVER['REQUEST_URI']) . $annotation_thumbnail_storagepath . '/' . $entry_array[id] . '.jpg'; $entry_thumbnail_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes2.php#", "", $_SERVER['REQUEST_URI']) . $annotation_thumbnail_storagepath . '/' . $entry_array[id] . '.jpg'; // this won't always be jpg $entry_mimetype = "image/jpg"; $entry_mimetype_thn = "image/thn-jpg"; $entry_thumbnail_link = "<link href=\"{$entry_link_jpg}\" rel=\"annotated region image\" type=\"{$entry_mimetype}\" />"; $entry_annotation_thumbnail_link = "<link href=\"{$entry_thumbnail_link_jpg}\" rel=\"thn\" type=\"{$entry_mimetype_thn}\" />"; // this won't always be jpg $parent_entry_mimetype = "image/jpg"; $parent_entry_url = ""; $parent_entry_link = "<link href=\"\" rel=\"annotated image\" type=\"{$parent_entry_mimetype}\" />"; // WRITE *thumbnail of annotated section of photo to file system fn_makeImage($parent_entry_array['link_jpg'], str_replace(",", " ", $entry_array[boundingbox]), $thumbscale, null, null, $annotation_thumbnail_storagepath . '/' . $entry_array[id] . '.jpg'); // Almost done - just need to create annotation entry xml, store it properly, and put feed on file system. // BUILD *annotation entry xml* // this needs fixing - what should $xml be that is getting replaced? $xml_entryinfo = preg_replace("#<entry>#", "<entry title=\"FotoNotes Annotation\" type=\"fn\" " . " xmlns:fn=\"http://fotonotes.net/protocol/fotonotes_0.2\">" . $entry_uuid . $entry_geometry . $entry_jpg_link . $entry_annotation_link . $entry_annotation_thumbnail_link . $parent_entry_uuid, $this->param["src_xml"]); $xml_entryinfo = preg_replace("#<([a-zA-Z])#", "\n<\$1", $xml_entryinfo); $xml_entryinfo = preg_replace("#</fn:selection>#", "\n</fn:selection>", $xml_entryinfo); $xml_entryinfo = preg_replace("#</author>#", "\n</author>", $xml_entryinfo); $xml_entryinfo = preg_replace("#</entry>#", "\n</entry>", $xml_entryinfo); displayDebug("xml_entryinfo: ", 2); displayDebugParam($xml_entryinfo, 2); $this->param["xml_entryinfo"] = $xml_entryinfo; displayDebug("generateFnImageAnnotationXml xml_entryinfo:", 2); displayDebugParam($this->param["xml_entryinfo"]); return $this->param["xml_entryinfo"]; }
function deleteAnnotationByID(&$fn_image, &$fn_annotation) { displayDebug("deleting annotation in JPEGHeader row", 2); global $FN_DB, $FN_USER, $PERMISSIONS; $timestamp = time(); // RETRIEVE existing annotations from image; getAnnotations also sets fni's param['annotationXMLBlock'] $this->oldxml = $fn_image->getAnnotations(); displayDebug("***************** fn_annotation object ***************************", 4); displayDebugParam($fn_annotation, 4); displayDebug("***************** fn_image object ***************************", 4); displayDebugParam($fn_image, 4); // REMOVE entry with indicated ID from existing annotation xml block displayDebug("replace: " . "#<entry><id>" . $fn_annotation->param['id'] . "</id></entry>#Umsi", 4); displayDebug("searching annotationxmlblock: " . $fn_image->param['annotationXMLBlock'], 4); $results = preg_match("#<entry><id>" . $fn_annotation->param['id'] . "</id>.*</entry>#Umsi", $fn_image->param['annotationXMLBlock']); displayDebug("match: {$results}", 4); $fn_image->param['annotationXMLBlock'] = preg_replace("#<entry><id>" . $fn_annotation->param['id'] . "</id>.*</entry>#Umsi", "", $fn_image->param['annotationXMLBlock']); // <entry><id>http://gelaptop.local/fnsclient/3@flamingo.jpg</id> // $xml = preg_replace("#<entry><id>$id</id>.*</entry>#Umsi", "", $oldxml); $results = $this->writeJPEGHeaders($fn_image, $fn_annotation); return $results; }
function getAnnotationsHTMLFromAnnotations($annotationsArray) { global $DHTML_MAXWIDTH, $DHTML_MAXHEIGHT; // Should not caluculate max width and height - displayDebugParam($annotations, 3); $content = null; $content .= "\n<!--module_fotonotesmod-->\n"; // canvas offsets $this->setFnImageParam('canvasOffSetTop', 20); $this->setFnImageParam('canvasOffSetBottom', 0); $this->setFnImageParam('canvasOffSetLeft', 0); $this->setFnImageParam('canvasOffSetRight', 0); $this->setFnImageParam('canvasHeight', $this->param['height'] + $this->param['canvasOffSetTop'] + $this->param['canvasOffSetBottom']); $this->setFnImageParam('canvasWidth', $this->param['width'] + $this->param['canvasOffSetLeft'] + $this->param['canvasOffSetRight']); $content .= "<div id=\"fn-canvas-id-" . $this->param['image'] . "\" class=\"fn-canvas fn-container-active\" style=\"width: " . $this->param['canvasWidth'] . "px; height: " . $this->param['canvasHeight'] . "px;\">\n"; //$content .= "<div class=\"errorMessage\">{%ERRORS%}</div>"; $content .= "<div id=\"unique-id-" . $this->param['image'] . "\" class=\"fn-container fn-container-active\" style=\"width: " . $this->param['width'] . "px; height: " . $this->param['height'] . "px; top:" . $this->param['canvasOffSetTop'] . "px; left:" . $this->param['canvasOffSetLeft'] . "px;\">\n"; $content .= "<img src=\"" . $this->param['image'] . "\" width=\"" . $this->param['width'] . "\" height=\"" . $this->param['height'] . "\" alt=\"" . $this->param['alt'] . "\" style=\"" . $this->param['style'] . "\" />\n"; $content .= "<span class=\"fn-scalefactor\" title=\"" . $this->param['scalefactor'] . "\"></span>"; for ($i = 0; $i < count($annotationsArray); $i++) { $annotations = null; $annotations = $annotationsArray[$i]; $content .= "\n\n<!-- ******* ANNOTATION {$i} : {$annotations['content']} ********* -->\n"; $content .= <<<EOF <div class="fn-area" style="left: {$annotations['upperleftx']}px; top: {$annotations['upperlefty']}px; width: {$annotations['width']}px; height: {$annotations['height']}px; border-color: {$annotations['bordercolor']};"> \t\t\t<div class="fn-note"> \t\t\t\t<span class="fn-note-created">{$annotations['createddtg']}</span> \t\t\t\t<span class="fn-note-title">{$annotations['title']}</span> \t\t\t\t<span class="fn-note-content">{$annotations['content']}</span> \t\t\t\t<span class="fn-note-author">{$annotations['author']}</span> \t\t\t\t<span class="fn-note-userid" style="display:none;">{$annotations['userid']}</span> \t\t\t\t<span class="fn-note-id" title="{$annotations['id']}"></span> \t\t\t</div> \t\t\t<div class="fn-area-innerborder-left"></div> \t\t\t<div class="fn-area-innerborder-right"></div> \t\t\t<div class="fn-area-innerborder-top"></div> \t\t\t<div class="fn-area-innerborder-bottom"></div> \t\t\t \t\t</div> \t\t<!-- end fn-area --> \t\t EOF; } /* Bordercolor UI elements have been removed fn div elements. See fnclient-0.4.0.bordercolor for elements.*/ $content .= <<<EOF \t \t<div class="fn-controlbar fn-controlbar-active"> \t\t\t<!--span class="fn-controlbar-logo"></span--> \t\t\t<span class="fn-controlbar-credits"></span> \t\t\t<span class="fn-controlbar-del-inactive"></span> \t\t\t<span class="fn-controlbar-edit-inactive"></span> \t\t\t<span class="fn-controlbar-add-inactive"></span> \t\t\t<span class="fn-controlbar-toggle-inactive"></span> \t\t</div> \t \t<form class="fn-editbar fn-editbar-inactive" name="fn_editbar" id="fn_editbar"> \t \t\t\t\t \t\t<div class="fn-editbar-fields"> \t\t\t<p>TITLE:</p> \t\t\t<input type="input" class="fn-editbar-title" name="title" value="default" /> \t \t\t\t<input type="hidden" class="fn-editbar-author" name="author" value="{$annotations['author']}" /> \t\t\t <input type="hidden" class="fn-editbar-userid" name="userid" value="{$annotations['userid']}" /> \t\t\t <input type="hidden" class="fn-editbar-entry_id" name="entry_ID" value="{$annotations['id']}" /> \t\t\t <input type="hidden" class="fn-editbar-border-color" name="border_color" value="#FE0000" /> \t\t\t \t \t\t</div> \t \t \t\t<div class="fn-editbar-fields"> \t \t\t\t<p>CONTENT:</p> \t\t\t\t<textarea class="fn-editbar-content" name="content"></textarea> \t \t\t</div> \t \t\t<div class="fn-editbar-fields"> \t \t\t\t<span class="fn-editbar-ok"></span> \t\t\t\t<span class="fn-editbar-cancel"></span> \t\t\t</div> \t \t</form> \t \t \t</div> EOF; $content .= "\n</div><!--close fn-canvas-->\n"; $content .= "\n<!--module_fotonotesmod-->\n"; return $content; }