= 1)
{
$sql_and = ' AND page = ?';
$sql_params[] = 'i'; $sql_params[] = $page;
}
$notes=ps_query("SELECT ref, top_pos, left_pos, width, height, preview_width, preview_height, note_id, user, `page`, node FROM annotate_notes WHERE ref= ?" . $sql_and, $sql_params);
$notecount = count($notes);
ps_query("UPDATE resource SET annotation_count= ? WHERE ref= ?", ['i', $notecount, 'i', $ref]);
// check if display size is different from original preview size, and if so, modify coordinates
for($i=0;$i<$notecount;$i++)
{
$annotate_node =[];
get_node($notes[$i]["node"],$annotate_node);
$notes[$i]["note"] = $annotate_node["name"];
}
$json="[";
$notes_array=array();
for ($x=0;$x\n', $notes[$x]['note']);
$notes[$x]['note'] = str_replace(chr(13), '
\n', $notes[$x]['note']);
$notes[$x]['note'] = str_replace(chr(10), '
\n', $notes[$x]['note']);
if (!$annotate_show_author) # Don't display author unless set in config
{
$notes[$x]['note'] = substr(strstr($notes[$x]['note'],": "),2);
}
if ($x>0){$json.=",";}
$json.="{";
$json.='"top":'.round($notes[$x]['top_pos']).', ';
$json.='"left":'.round($notes[$x]['left_pos']).', ';
$json.='"width":'.round($notes[$x]['width']).', ';
$json.='"height":'.round($notes[$x]['height']).', ';
$json.='"text":"'.config_encode($notes[$x]['note']).'", ';
$json.='"id":"'.$notes[$x]['note_id'].'", ';
if (isset($userref) && (($notes[$x]['user']==$userref) || in_array($usergroup,$annotate_admin_edit_access)))
{
$json.='"editable":true';
}
else
{
$json.='"editable":false';
}
$json.="}";
}
$json.="]";
echo $json;