Procedural File: mooan_x_pointer_lib.php
Source Location: /mooan_x_pointer_lib.php
Page Details:
Functions for setting up highlighting of elements in the document based on the XPointers in the comment data.
Tags:
mooan_create_span_node
object The mooan_create_span_node(
object $document, boolean $tomarkread, object $comment, &$counter, int $counter)
[line 617]
Creates a new span node and sets it's id attribute and class attributes.
Tags:
- return - newly created span node or null on failure
Parameters
-
object
$document
-
DOMDocument object containing the page we are adding highlighting to.
-
boolean
$tomarkread
-
If true, the comment being positioned should be marked having been read already
-
object
$comment
-
MooanMessageData of the comment we are highlighting now
-
int
$counter
-
Running counter to make sure all the id attributes are unique. Is incremented by this function when used.
-
&$counter
-
[ Top ]
mooan_do_rangeto
void mooan_do_rangeto(
object $document, boolean $tomarkread, object $comment, array $params, &$counter, int $counter)
[line 148]
Handles a range-to type XPointer. Wraps all of the text within the given range with span nodes, respecting element boundaries and cutting text elements to smaller ones at the range edges if necessary.
The algorithm and structure of this function is based on the equivalent in Anno-project.
Parameters
-
object
$document
-
DOMDocument containing the page being manipulated
-
boolean
$tomarkread
-
If true, the comment being positioned should be marked having been read already
-
object
$comment
-
MooanMessageData containing the comment being highlighted
-
array
$params
-
The result of $comment->position being parsed with mooan_parse_rangeto().
-
int
$counter
-
The running counter for keeping generated IDs unique
-
&$counter
-
[ Top ]
mooan_do_stringrange
void mooan_do_stringrange(
object $document, boolean $tomarkread, object $comment, array $params, &$counter, int $counter)
[line 397]
Handles a string-range type XPointer. Wraps all of the text within the given range with span nodes, respecting element boundaries and cutting text elements to smaller ones at the range edges if necessary.
The algorithm and structure of this function is based on the equivalent in Anno-project.
Parameters
-
object
$document
-
DOMDocument containing the page being manipulated
-
boolean
$tomarkread
-
If true, the comment being positioned should be marked having been read already
-
object
$comment
-
MooanMessageData containing the comment being highlighted
-
array
$params
-
The result of $comment->position being parsed with mooan_parse_stringrange().
-
int
$counter
-
The running counter for keeping generated IDs unique
-
&$counter
-
[ Top ]
mooan_get_common_parent
The mooan_get_common_parent(
object $node1, object $node2)
[line 291]
Calculates the deepest node that is a parent of both $node1 and $node2.
Tags:
- return - parent node found
Parameters
-
object
$node1
-
DOMNode for which to seek closest commont parent with $node2
-
object
$node2
-
DOMNode for which to seek closest commont parent with $node1
[ Top ]
mooan_get_last_modified
int mooan_get_last_modified(
object $message)
[line 654]
Gets the UNIX timestamp of when a modification was last made to the comment & response subtree starting with the given comment.
Tags:
- return - The UNIX timestamp of the date when a something was either modified or added to the subtree.
Parameters
-
object
$message
-
MooanMessageData of the root comment of the subtree to examine
[ Top ]
mooan_parse_rangeto
array mooan_parse_rangeto(
mixed $string)
[line 339]
Parses the sub-parameters from a range-to type XPointer.
Tags:
- return - On failure false, on success an associative array of xpath => the xpath parameter to string-range (1st param) string => the string parameter to string-range (2nd param) offset => the offset parameter to string-range (3rd param) length => the length parameter to string-range (4th param)
Parameters
[ Top ]
mooan_parse_stringrange
array mooan_parse_stringrange(
mixed $string)
[line 520]
A function to wrap the massive regexp used to get the string-range paramaters out of a string-range part of an XPointer.
Tags:
- return - On failure false, on success an associative array of xpath => the xpath parameter to string-range (1st param) string => the string parameter to string-range (2nd param) offset => the offset parameter to string-range (3rd param) length => the length parameter to string-range (4th param)
Parameters
[ Top ]
mooan_parse_xpath
mixed mooan_parse_xpath(
object $document, string $xpath)
[line 685]
Determines the element pointed at by the given "XPath".
Only handles such XPaths as could be generated by the interface side of our code.
Tags:
- return - The DOMElement found once $xpath has been fully evaluated, or false if something failed.
Parameters
-
object
$document
-
The DOMDocument object containing the page we are working on
-
string
$xpath
-
The XPath to evaluate
[ Top ]
mooan_place
void mooan_place(
object $document, array $commentarray, array $readbyuser)
[line 43]
Sets span elements to highlight all comments in $commentarray whose location can be found.
Parameters
-
object
$document
-
DOMDocument object into which the captured page has been loaded.
-
array
$commentarray
-
Array of MooanMessageData containing all the comments made to the page loaded into $document.
-
array
$readbyuser
-
Array of commentID => date, where the keys list the comments that have been read by current user
[ Top ]
mooan_wrap_children_new_span
void mooan_wrap_children_new_span(
object $target, boolean $tomarkread, object $comment, &$counter, int $counter)
[line 576]
Loops over all the text elements in the subtree starting from the target and moves them to be children of span nodes.
Parameters
-
object
$target
-
DOMNode whose children to move
-
boolean
$tomarkread
-
If true, the comment being positioned should be marked having been read already
-
object
$comment
-
MooanMessageData of the comment we are highlighting
-
int
$counter
-
Running counter to keep generated span IDs unique
-
&$counter
-
[ Top ]