Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Add another parameter "flatten" to get all changes or pre-flatten the…
Browse files Browse the repository at this point in the history
…m server-side
  • Loading branch information
cdujeu committed Jun 20, 2014
1 parent c244de4 commit 1637f10
Showing 1 changed file with 38 additions and 23 deletions.
61 changes: 38 additions & 23 deletions core/src/plugins/meta.syncable/class.ChangesTracker.php
Expand Up @@ -90,33 +90,48 @@ public function switchActions($actionName, $httpVars, $fileVars)
$row->node[$att] = $row->$att;
unset($row->$att);
}
if ($row->node_id == $previousNodeId) {
$previousRow->target = $row->target;
$previousRow->seq = $row->seq;
if ($order[$row->type] > $order[$previousRow->type]) {
$previousRow->type = $row->type;
}
} else {
if (isSet($previousRow) && ($previousRow->source != $previousRow->target || $previousRow->type == "content")) {
if($this->filterRow($previousRow, $filter)){
$previousRow = $row;
$previousNodeId = $row->node_id;
$lastSeq = $row->seq;
continue;
if(!isSet($httpVars["flatten"]) || $httpVars["flatten"] == "false"){

if(!$this->filterRow($row, $filter)){
if ($valuesSent) {
echo $separator;
}
if($valuesSent) echo $separator;
echo json_encode($previousRow);
echo json_encode($row);
$valuesSent = true;
}
$previousRow = $row;
$previousNodeId = $row->node_id;

}else{

if ($row->node_id == $previousNodeId) {
$previousRow->target = $row->target;
$previousRow->seq = $row->seq;
if ($order[$row->type] > $order[$previousRow->type]) {
$previousRow->type = $row->type;
}
} else {
if (isSet($previousRow) && ($previousRow->source != $previousRow->target || $previousRow->type == "content")) {
if($this->filterRow($previousRow, $filter)){
$previousRow = $row;
$previousNodeId = $row->node_id;
$lastSeq = $row->seq;
continue;
}
if($valuesSent) echo $separator;
echo json_encode($previousRow);
$valuesSent = true;
}
$previousRow = $row;
$previousNodeId = $row->node_id;
}
$lastSeq = $row->seq;
flush();
}
$lastSeq = $row->seq;
flush();
}
if (isSet($previousRow) && ($previousRow->source != $previousRow->target || $previousRow->type == "content") && !$this->filterRow($previousRow, $filter)) {
if($valuesSent) echo $separator;
echo json_encode($previousRow);
if (isSet($previousRow) && ($previousRow->source != $previousRow->target || $previousRow->type == "content") && !$this->filterRow($previousRow, $filter)) {
if($valuesSent) echo $separator;
echo json_encode($previousRow);
$valuesSent = true;
}

}
if (isSet($lastSeq)) {
if($stream){
Expand Down

0 comments on commit 1637f10

Please sign in to comment.