Index: drupal.fndb.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/imagenotes/drupal.fndb.inc,v retrieving revision 1.1 diff -u -r1.1 drupal.fndb.inc --- drupal.fndb.inc 10 Nov 2006 19:18:32 -0000 1.1 +++ drupal.fndb.inc 29 Mar 2008 00:05:48 -0000 @@ -20,14 +20,57 @@ function saveNewAnnotation($fn_image, $fn_annotation) { global $user; - $result = db_query("INSERT INTO {imagenotes} (nid, uid, annotation_id, title, content, xml) VALUES (%d, %d, '%s', '%s', '%s', '%s')", - $fn_image->param['nid'], $user->uid, $fn_annotation->param['id'], $fn_annotation->param['title'], $fn_annotation->param['content'], $fn_annotation->param['src_xml']); + + $width = $fn_image->param['source_x']; + $height = $fn_image->param['source_y']; + + //watchdog('debug', print_r($fn_image,1)); + //watchdog('debug', print_r($fn_annotation,1)); + //return; + + //$file = str_replace($fn_annotation->param['annotationID'] .'@', '', $fn_annotation->param['id']); + //$info = image_get_info(file_directory_path() . '/images/' . $file); + + //watchdog('debug', print_r($info,1)); + //return; + + + + $result = db_query("INSERT INTO {imagenotes} (nid, uid, annotation_id, title, content, xml, width, height) VALUES (%d, %d, '%s', '%s', '%s', '%s', %d, %d)", + $fn_image->param['nid'], $user->uid, $fn_annotation->param['id'], $fn_annotation->param['title'], $fn_annotation->param['content'], $fn_annotation->param['src_xml'], $width, $height); return true; } function updateExistingAnnotationByID($fn_image, $fn_annotation) { - $result = db_query("UPDATE {imagenotes} SET title='%s', content='%s', xml='%s' WHERE annotation_id='%s'", - $fn_annotation->param['title'], $fn_annotation->param['content'], $fn_annotation->param['src_xml'], $fn_annotation->param['id']); + + $width = $fn_image->param['source_x']; + $height = $fn_image->param['source_y']; + + $entry = $fn_annotation->param['src_xml']; + + preg_match("#(.*)#Umsi", $entry, $data); + $title = $data[1]; + preg_match("#(.*)#Umsi", $entry, $data); + $content = $data[1]; + + //watchdog('debug', print_r($fn_image,1)); + //watchdog('debug', print_r($fn_annotation,1)); + //return; + + $id = $fn_annotation->param['id']; + //$temp = explode('/', $fn_annotation->param['id']); + //$id = array_pop($temp); + + + $nid = db_result(db_query("SELECT nid FROM {imagenotes} WHERE annotation_id='%s'", $id)); + + $node = node_load(array('nid' => $nid)); + $node->changed = time(); + + node_save($node); + + $result = db_query("UPDATE {imagenotes} SET title='%s', content='%s', xml='%s', width=%d, height=%d WHERE annotation_id='%s'", + $title, $content, $entry, $width, $height, $id); return true; } @@ -54,25 +97,26 @@ } function getAnnotations(&$fn_image) { - global $DHTML_MAXWIDTH, $DHTML_MAXHEIGHT; + //global $DHTML_MAXWIDTH, $DHTML_MAXHEIGHT; - $node = node_load($fn_image->param['nid']); - $this->image = file_create_path($node->images['preview']); + //$node = node_load($fn_image->param['nid']); + //$this->image = file_create_path($node->images['preview']); - $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); - $fn_image->setFnImageParam('scalefactor', $ratio); - - $annoatations = array(); + $annotations = array(); $xml = ''; $result = db_query("SELECT * FROM {imagenotes} WHERE nid=%d", arg(1)); while ($row = db_fetch_object($result)) { + + $ratioWidth = arg(2) / $row->width; + $ratioHeight = arg(3) / $row->height; + + if($ratioHeight>$ratioWidth){$ratio=$ratioWidth;}else{$ratio=$ratioHeight;} + //if($ratio>1){$ratio=1;} + + watchdog('debug', $row->width . ' / ' . $info['width']); + $entry = $row->xml; preg_match("#(.*)#Umsi", $entry, $coordstring); $coords = explode(",", $coordstring[1]); @@ -80,7 +124,7 @@ $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; @@ -103,10 +147,12 @@ preg_match("#(.*)#Umsi", $entry, $id); //$annotation['id'] = basename($id[1]); Do not get basename, use full url $annotation['id'] = $id[1]; + preg_match("#(.*)#Umsi", $entry, $userid); $annotation['userid'] = $userid[1]; $annotations[] = $annotation; } + return $annotations; } Index: imagenotes.install =================================================================== RCS file: /cvs/drupal/contributions/modules/imagenotes/imagenotes.install,v retrieving revision 1.1 diff -u -r1.1 imagenotes.install --- imagenotes.install 10 Nov 2006 19:18:32 -0000 1.1 +++ imagenotes.install 29 Mar 2008 04:14:40 -0000 @@ -8,13 +8,19 @@ switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': - db_query("CREATE TABLE IF NOT EXISTS {imagenotes} ( - nid INTEGER UNSIGNED NOT NULL, - uid INTEGER UNSIGNED NOT NULL, - annotation_id VARCHAR(255), - title VARCHAR(255), - content TEXT, - xml TEXT - ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); + + db_query("CREATE TABLE `imagenotes` ( + `nid` int(10) unsigned NOT NULL, + `uid` int(10) unsigned NOT NULL, + `annotation_id` varchar(255) NOT NULL default '', + `title` varchar(255) default NULL, + `content` text, + `xml` text, + `width` smallint(5) unsigned NOT NULL default '0', + `height` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`annotation_id`), + KEY `nid` (`nid`) + )"); + } } \ No newline at end of file Index: imagenotes.module =================================================================== RCS file: /cvs/drupal/contributions/modules/imagenotes/imagenotes.module,v retrieving revision 1.2 diff -u -r1.2 imagenotes.module --- imagenotes.module 10 Nov 2006 19:18:32 -0000 1.2 +++ imagenotes.module 28 Mar 2008 20:22:24 -0000 @@ -1,18 +1,7 @@ type == 'image' && $page) { - drupal_add_js(drupal_get_path('module', 'imagenotes') . '/fnclient/fnclientlib/js/fnclient.js'); - drupal_set_html_head(theme('stylesheet_import', base_path() . drupal_get_path('module', 'imagenotes') .'/fnclient/fnclientlib/styles/fnclient.css')); - $js.= '\n"; - drupal_set_html_head($js); - } + + switch ($op) + { + case 'update index': + + $result = db_query("SELECT title, content FROM {imagenotes} WHERE nid=%d", $node->nid); + while ($db = db_fetch_object($result)) + { + $text .= $db->title . ' ' . $db->content . ' '; + } + + return $text; + + case 'view': + + if ($node->type == 'image' && $page) { + drupal_add_css(drupal_get_path('module', 'imagenotes') . '/fnclient/fnclientlib/styles/fnclient.css'); + drupal_add_js(drupal_get_path('module', 'imagenotes') . '/fnclient/fnclientlib/js/fnclient.js'); + + + $size = $_GET['size']; + if (!$size) + { + $size = IMAGE_PREVIEW; + } + + $info = image_get_info($node->images[$size]); + + $js .= "\n"; + + drupal_set_html_head($js, 'inline'); + } + + break; + } + } -function imagenotes_callback($nid) { + +function imagenotes_callback($nid,$source_x,$source_y) { global $user, $PERMISSIONS, $FNSAVESTRATEGY, $FNRETRIEVESTRATEGY, $FNANNOTATIONFEEDSAVESTRATEGY, $FN_FEED_PATH, $DHTML_MAXWIDTH, $DHTML_MAXHEIGHT, $FN_FEED_PATH; $path = drupal_get_path('module', 'imagenotes') . '/fnclient/'; @@ -47,16 +76,19 @@ $PERMISSIONS = array('ADD' => 'allow', 'MODIFY' => 'allow', 'DELETE' => 'allow'); + +/* $PERMISSIONS = array('ADD' => 'deny', 'MODIFY' => 'deny', 'DELETE' => 'deny'); +*/ $dir = file_create_path('imagenotes'); file_check_directory($dir, FILE_CREATE_DIRECTORY); $FN_FEED_PATH = $dir .'/'; - $DHTML_MAXWIDTH = 675; - $DHTML_MAXHEIGHT = 675; + $DHTML_MAXWIDTH = 675; + $DHTML_MAXHEIGHT = 675; $FNSAVESTRATEGY["FNSaveDatabaseRows"] = true; $FNSAVESTRATEGY["FNSaveDatabaseXMLBlock"] = false; @@ -98,6 +130,9 @@ // Set the nid as a param $fni->setFnImageParam('nid', $nid); + $fni->setFnImageParam('source_x', $source_x); + $fni->setFnImageParam('source_y', $source_y); + // CLEANUP incoming XML from client, if exists if ($fni->fnImageParamExists("xml")) { $fni->param["xml"] = preg_replace("#<\?xml.*>#Umsi", "", $fni->param["xml"]); @@ -111,7 +146,13 @@ // DO the requested action if ($fni->fnImageParamExists("action")) { - if ($fni->param['action'] == 'display' || user_access('create imagenotes')) { + + $node = node_load(array('nid' => $nid)); + + if ($fni->param['action'] == 'display' || user_access('administer imagenotes') || ($user->uid == $node->uid && user_access('create imagenotes'))) { + + //watchdog('debug', print_r($fni,1)); + $fni->doFnAction(); } else { --- LICENSE.txt +++ LICENSE.txt @@ -0,0 +1,0 @@ --- imagenotes.info +++ imagenotes.info @@ -0,0 +1,0 @@