diff --git a/modules/photoannotation/controllers/photoannotation.php b/modules/photoannotation/controllers/photoannotation.php index e76e6884..be4b97ea 100644 --- a/modules/photoannotation/controllers/photoannotation.php +++ b/modules/photoannotation/controllers/photoannotation.php @@ -35,6 +35,23 @@ class photoannotation_Controller extends Controller { $str_face_description = $_POST["desc"]; $redir_uri = url::abs_site("{$item->type}s/{$item->id}"); + //Add tag to item, create tag if not exists + if ($tag_data != "") { + $tag = ORM::factory("tag")->where("name", "=", $tag_data)->find(); + if (!$tag->loaded()) { + $tag->name = $tag_data; + $tag->count = 0; + } + + $tag->add($item); + $tag->count++; + $tag->save(); + $tag_data = $tag->id; + } else { + $tag_data = -1; + } + + // Decide if we are saving a face or a note. if ($noteid == "new") { @@ -150,7 +167,6 @@ class photoannotation_Controller extends Controller { url::redirect($redir_uri); return; } - if ($notetype == "face") { db::build()->delete("items_faces")->where("id", "=", $noteid)->execute(); message::success(t("Annotation deleted.")); diff --git a/modules/photoannotation/css/photoannotation.css b/modules/photoannotation/css/photoannotation.css index e578e0d9..adc14bef 100644 --- a/modules/photoannotation/css/photoannotation.css +++ b/modules/photoannotation/css/photoannotation.css @@ -40,15 +40,19 @@ } .image-annotate-edit { display: none; + direction: ltr !important; } #image-annotate-edit-form { background: #FFFFFF none repeat scroll 0 0; border: 1px solid #000000; - height: 220px; + height: 230px; padding: 7px; position: absolute; width: 250px; } +.image-annotate-rtl form { + text-align: right !important; +} #image-annotate-edit-form form { clear: right; margin: 0 !important; @@ -68,6 +72,7 @@ font-family: Verdana, Sans-Serif; font-size: 12px; width: 248px; + resize: none; } #image-annotate-edit-form fieldset { background: transparent none repeat scroll 0 0; @@ -84,6 +89,10 @@ float: left; margin: 3px 6px 3px 0; } +.image-annotate-rtl a { + float: right !important; + margin: 3px 0 3px 6px !important; +} .image-annotate-edit-area { border: 1px solid black; cursor: move; diff --git a/modules/photoannotation/helpers/photoannotation.php b/modules/photoannotation/helpers/photoannotation.php new file mode 100644 index 00000000..24b26404 --- /dev/null +++ b/modules/photoannotation/helpers/photoannotation.php @@ -0,0 +1,91 @@ +item_id = $item->id; + $newnote->x1 = $x1; + $newnote->y1 = $y1; + $newnote->x2 = $x2; + $newnote->y2 = $y2; + $newnote->title = $tag_title; + $newnote->description = $description; + $newnote->save(); + } catch (Exception $e) { + Kohana_Log::add("error", "Error adding note annotation.\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + } + } elseif ( $bTag && !empty($tag_title) ) { + try { + //we are adding a tag + //first find the tag + $tag = ORM::factory("tag")->where("name", "=", $tag_title)->find(); + //tag was not found + if (!$tag->loaded()) { + $tag->name = $tag_title; + $tag->count = 0; + } + + $tag->add($item); + $tag->count++; + $tag->save(); + //check if the tag is attached to the item + // if the tag isn't attached, attach it + //check if the face is already tagged + $existingFace = ORM::factory("items_face") + ->where("tag_id", "=", $tag->id) + ->where("item_id", "=", $item->id) + ->find_all(); + + if (count($existingFace) == 0) { + // Save the new face to the database. + $newface = ORM::factory("items_face"); + $newface->tag_id = $tag->id; + $newface->item_id = $item->id; + $newface->x1 = $x1; + $newface->y1 = $y1; + $newface->x2 = $x2; + $newface->y2 = $y2; + $newface->description = $description; + $newface->save(); + } else { + // Update the coordinates of an existing face. + $updatedFace = ORM::factory("items_face", $existingFace[0]->id); + $updatedFace->x1 = $x1; + $updatedFace->y1 = $y1; + $updatedFace->x2 = $x2; + $updatedFace->y2 = $y2; + $updatedFace->description = $description; + $updatedFace->save(); + } + } catch (Exception $e) { + Kohana_Log::add("error", "Error adding note annotation.\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + } + } else { + throw new exception("@todo MISSING_TAG_OR_DESCRIPTION"); + } + } +} +?> + diff --git a/modules/photoannotation/helpers/photoannotation_installer.php b/modules/photoannotation/helpers/photoannotation_installer.php index 625c15f9..a00a74db 100644 --- a/modules/photoannotation/helpers/photoannotation_installer.php +++ b/modules/photoannotation/helpers/photoannotation_installer.php @@ -46,12 +46,13 @@ class photoannotation_installer { DEFAULT CHARSET=utf8;"); // Set the module's version number. - module::set_version("photoannotation", 1); + module::set_version("photoannotation", 2); } static function upgrade($version) { - $db = Database::instance(); - module::set_version("photoannotation", $version); + if ($version == 1) { + module::set_version("photoannotation", $version = 2); + } } static function deactivate() { diff --git a/modules/photoannotation/helpers/photoannotation_theme.php b/modules/photoannotation/helpers/photoannotation_theme.php index 375298cf..a2fbacd5 100644 --- a/modules/photoannotation/helpers/photoannotation_theme.php +++ b/modules/photoannotation/helpers/photoannotation_theme.php @@ -22,7 +22,6 @@ class photoannotation_theme_Core { if ($theme->page_subtype == "photo") { $theme->css("photoannotation.css"); $theme->script("jquery.annotate.js"); - //Return ""; } } diff --git a/modules/photoannotation/js/jquery.annotate.js b/modules/photoannotation/js/jquery.annotate.js index 7a7482b4..eb8d8fd3 100644 --- a/modules/photoannotation/js/jquery.annotate.js +++ b/modules/photoannotation/js/jquery.annotate.js @@ -24,6 +24,7 @@ this.labels = opts.labels; this.csrf = opts.csrf; this.cssaclass = opts.cssaclass; + this.rtlsupport = opts.rtlsupport; // Add the canvas this.canvas = $('