Esempio n. 1
0
 function recordToAnnotation($r)
 {
     $annotation = new Annotation();
     $annotation->setAnnotationId($r->id);
     $annotation->setUserId($r->userid);
     if ($r->access) {
         $annotation->setAccess($r->access);
     }
     if ($r->url) {
         $annotation->setUrl($r->url);
     }
     if ($r->note) {
         $annotation->setNote($r->note);
     }
     if ($r->quote) {
         $annotation->setQuote($r->quote);
     }
     if ($r->quote_title) {
         $annotation->setQuoteTitle($r->quote_title);
     }
     if ($r->quote_author) {
         $annotation->setQuoteAuthor($r->quote_author);
     }
     if ($r->link) {
         $annotation->setLink($r->link);
     }
     if ($r->link_title) {
         $annotation->setLinkTitle($r->link_title);
     }
     $annotation->setCreated($r->created);
     if ($r->start_block !== null) {
         $range = new SequenceRange();
         $range->setStart(new SequencePoint($r->start_block, $r->start_word, $r->start_char));
         $range->setEnd(new SequencePoint($r->end_block, $r->end_word, $r->end_char));
         $annotation->setSequenceRange($range);
     } else {
         if (!empty($r->range)) {
             $range = new SequenceRange();
             $range->fromString($r->range);
             $annotation->setSequenceRange($range);
         }
     }
     if ($r->start_xpath !== null) {
         $range = new XPathRange();
         $range->setStart(new XPathPoint($r->start_xpath, $r->start_word, $r->start_char));
         $range->setEnd(new XpathPoint($r->end_xpath, $r->end_word, $r->end_char));
         $annotation->setXPathRange($range);
     }
     return $annotation;
 }