$labels = init_labels(array("num_changes" => null, "no_changes" => null, "version_short" => null, "diff_details_rev" => null, "type" => null, "status" => null, "name" => "title", "doc_id" => null, "revision_short" => null, "revision" => null)); $itemMgr = new requirement_spec_mgr($db); $differ = new diff(); $args = init_args(); $gui = initializeGui($db, $args, $labels, $itemMgr); // if already two revisions are selected, display diff // else display template with versions to select if ($args->doCompare) { // Side By Side $sbs = getItemsToCompare($args->left_item_id, $args->right_item_id, $gui->items); prepareUserFeedback($db, $gui, $args->req_spec_id, $labels, $sbs); $gui->attrDiff = getAttrDiff($sbs['left_item'], $sbs['right_item'], $labels); $cfields = getCFToCompare($sbs, $args->tproject_id, $itemMgr); $gui->cfieldsDiff = null; if (!is_null($cfields)) { $gui->cfieldsDiff = getCFDiff($cfields, $itemMgr); } $gui->diff = array("scope" => array()); foreach ($gui->diff as $key => $val) { if ($args->useDaisyDiff) { $diff = new HTMLDiffer(); list($differences, $diffcount) = $diff->htmlDiff($sbs['left_item'][$key], $sbs['right_item'][$key]); $gui->diff[$key]["diff"] = $differences; $gui->diff[$key]["count"] = $diffcount; } else { // insert line endings so diff is better readable and makes sense (not everything in one line) // then cast to array with \n as separating character, differ needs that $gui->diff[$key]["left"] = explode("\n", str_replace("</p>", "</p>\n", $sbs['left_item'][$key])); $gui->diff[$key]["right"] = explode("\n", str_replace("</p>", "</p>\n", $sbs['right_item'][$key])); $gui->diff[$key]["diff"] = $differ->inline($gui->diff[$key]["left"], $gui->leftID, $gui->diff[$key]["right"], $gui->rightID, $args->context); $gui->diff[$key]["count"] = count($differ->changes);
$reqMgr = new requirement_mgr($db); $differ = new diff(); $args = init_args(); checkRights($db, $_SESSION['currentUser'], $args); $gui = initializeGui($db, $args, $labels, $reqMgr); // if already two versions are selected, display diff // else display template with versions to select if ($args->compare_selected_versions) { // Side By Side $sbs = getItemsToCompare($args->left_item_id, $args->right_item_id, $gui->items); prepareUserFeedback($db, $gui, $args->req_id, $labels, $sbs); $gui->attrDiff = getAttrDiff($sbs['left_item'], $sbs['right_item'], $labels); $cfields = getCFToCompare($sbs, $args->tproject_id, $reqMgr); $gui->cfieldsDiff = null; if (!is_null($cfields)) { $gui->cfieldsDiff = getCFDiff($cfields, $reqMgr); } $gui->diff = array("scope" => array()); foreach ($gui->diff as $key => $val) { // 20110107 - new diff engine if ($args->use_daisydiff) { // using daisydiff as diffing engine $diff = new HTMLDiffer(); list($differences, $diffcount) = $diff->htmlDiff($sbs['left_item'][$key], $sbs['right_item'][$key]); $gui->diff[$key]["diff"] = $differences; $gui->diff[$key]["count"] = $diffcount; } else { // insert line endings so diff is better readable and makes sense (not everything in one line) // then cast to array with \n as separating character, differ needs that $gui->diff[$key]["left"] = explode("\n", str_replace("</p>", "</p>\n", $sbs['left_item'][$key])); $gui->diff[$key]["right"] = explode("\n", str_replace("</p>", "</p>\n", $sbs['right_item'][$key]));